@iabbb/bds-react 0.38.6 → 0.39.0-alpha
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/Button.d.ts +7 -0
- package/Button/index.cjs +115 -0
- package/Button/index.cjs.map +1 -0
- package/{src/Button/index.js → Button/index.d.ts} +2 -1
- package/Button/index.mjs +94 -0
- package/Button/index.mjs.map +1 -0
- package/Button/package.json +7 -0
- package/CallToAction/CallToAction.d.ts +6 -0
- package/CallToAction/index.cjs +83 -0
- package/CallToAction/index.cjs.map +1 -0
- package/{src/CallToAction/index.js → CallToAction/index.d.ts} +2 -1
- package/CallToAction/index.mjs +62 -0
- package/CallToAction/index.mjs.map +1 -0
- package/CallToAction/package.json +7 -0
- package/ErrorSummary/ErrorSummary.d.ts +14 -0
- package/ErrorSummary/index.cjs +194 -0
- package/ErrorSummary/index.cjs.map +1 -0
- package/{src/ErrorSummary/index.js → ErrorSummary/index.d.ts} +2 -2
- package/ErrorSummary/index.mjs +170 -0
- package/ErrorSummary/index.mjs.map +1 -0
- package/ErrorSummary/package.json +7 -0
- package/ErrorSummary/utils.d.ts +2 -0
- package/FieldTextInput/FieldTextInput.d.ts +10 -0
- package/FieldTextInput/index.cjs +109 -0
- package/FieldTextInput/index.cjs.map +1 -0
- package/{src/FieldTextInput/index.js → FieldTextInput/index.d.ts} +1 -1
- package/FieldTextInput/index.mjs +88 -0
- package/FieldTextInput/index.mjs.map +1 -0
- package/FieldTextInput/package.json +7 -0
- package/Pagination/Pagination.d.ts +8 -0
- package/Pagination/index.cjs +180 -0
- package/Pagination/index.cjs.map +1 -0
- package/{src/Pagination/index.js → Pagination/index.d.ts} +1 -1
- package/Pagination/index.mjs +159 -0
- package/Pagination/index.mjs.map +1 -0
- package/Pagination/package.json +7 -0
- package/README.md +17 -25
- package/Typography/Typography.d.ts +7 -0
- package/Typography/index.cjs +99 -0
- package/Typography/index.cjs.map +1 -0
- package/{src/Typography/index.js → Typography/index.d.ts} +1 -1
- package/Typography/index.mjs +78 -0
- package/Typography/index.mjs.map +1 -0
- package/Typography/package.json +7 -0
- package/index.cjs +447 -0
- package/index.cjs.map +1 -0
- package/index.d.ts +6 -0
- package/index.mjs +421 -0
- package/index.mjs.map +1 -0
- package/package.json +35 -21
- package/src/Button/Button.js +0 -54
- package/src/CallToAction/CallToAction.js +0 -16
- package/src/ErrorSummary/ErrorSummary.js +0 -102
- package/src/ErrorSummary/utils.js +0 -42
- package/src/FieldTextInput/FieldTextInput.js +0 -46
- package/src/Pagination/Pagination.js +0 -101
- package/src/Typography/Typography.js +0 -26
- package/src/index.js +0 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/ErrorSummary/utils.ts","../../src/ErrorSummary/ErrorSummary.tsx"],"sourcesContent":["export function getFragmentFromUrl(url: string) {\r\n return url.includes('#') ? url.split('#').pop() : undefined;\r\n}\r\n\r\nexport function getAssociatedLegendOrLabel(input: HTMLElement) {\r\n const fieldset = input.closest('fieldset');\r\n\r\n if (fieldset) {\r\n const legends = fieldset.getElementsByTagName('legend');\r\n\r\n if (legends.length) {\r\n const candidateLegend = legends[0];\r\n\r\n // If the input type is radio or checkbox, always use the legend if there\r\n // is one.\r\n if (input instanceof HTMLInputElement && (input.type === 'checkbox' || input.type === 'radio')) {\r\n return candidateLegend;\r\n }\r\n\r\n // For other input types, only scroll to the fieldset’s legend (instead of\r\n // the label associated with the input) if the input would end up in the\r\n // top half of the screen.\r\n //\r\n // This should avoid situations where the input either ends up off the\r\n // screen, or obscured by a software keyboard.\r\n const legendTop = candidateLegend.getBoundingClientRect().top;\r\n const inputRect = input.getBoundingClientRect();\r\n\r\n // If the browser doesn't support Element.getBoundingClientRect().height\r\n // or window.innerHeight (like IE8), bail and just link to the label.\r\n if (inputRect.height && window.innerHeight) {\r\n const inputBottom = inputRect.top + inputRect.height;\r\n\r\n if (inputBottom - legendTop < window.innerHeight / 2) {\r\n return candidateLegend;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return document.querySelector(`label[for='${input.getAttribute('id')}']`) ?? input.closest('label');\r\n}\r\n","import * as React from 'react';\r\n\r\nimport { getAssociatedLegendOrLabel, getFragmentFromUrl } from './utils';\r\n\r\ndeclare global {\r\n namespace JSX {\r\n interface IntrinsicElements {\r\n 'bds-error-summary': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;\r\n }\r\n }\r\n}\r\n\r\nexport const FormErrorKey = '_form';\r\n\r\nconst FINAL_FORM_ERROR = 'FINAL_FORM/form-error';\r\n\r\nexport type ErrorSummaryProps = {\r\n errors: Record<string, Array<string> | string> | null;\r\n mapNameToId?: (name: string) => string;\r\n};\r\n\r\nexport default function BdsErrorSummary({\r\n className,\r\n errors,\r\n mapNameToId = (name) => name,\r\n ...props\r\n}: ErrorSummaryProps & React.ComponentPropsWithoutRef<'div'>) {\r\n const headingId = React.useId();\r\n const groupRef = React.useRef<HTMLElement>(null);\r\n\r\n React.useEffect(() => {\r\n if (!errors || Object.keys(errors).length === 0) return;\r\n if (!groupRef.current) return;\r\n\r\n groupRef.current.focus();\r\n }, [errors]);\r\n\r\n if (!errors || Object.keys(errors).length === 0) return null;\r\n\r\n const handleLinkClick = (e) => {\r\n const inputId = getFragmentFromUrl(e.currentTarget.href);\r\n\r\n if (!inputId) {\r\n return;\r\n }\r\n\r\n const input = document.getElementById(inputId);\r\n\r\n if (!input) {\r\n return;\r\n }\r\n\r\n const legendOrLabel = getAssociatedLegendOrLabel(input);\r\n\r\n if (!legendOrLabel) {\r\n return;\r\n }\r\n\r\n e.preventDefault();\r\n\r\n legendOrLabel.scrollIntoView();\r\n input.focus({ preventScroll: true });\r\n };\r\n\r\n return (\r\n <bds-error-summary\r\n className={['stack', className].filter((x) => x).join(' ')}\r\n role=\"group\"\r\n aria-labelledby={headingId}\r\n ref={groupRef}\r\n tabIndex={-1}\r\n {...props}\r\n >\r\n <h2 className=\"bds-h5\" id={headingId}>\r\n <svg\r\n xmlns=\"http://www.w3.org/2000/svg\"\r\n viewBox=\"0 0 512 512\"\r\n aria-hidden=\"true\"\r\n height=\"1em\"\r\n width=\"1em\"\r\n fill=\"currentColor\"\r\n >\r\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\" />\r\n </svg>\r\n Issue\r\n </h2>\r\n <ul>\r\n {Object.keys(errors).map((errorKey) => {\r\n const message = errors[errorKey];\r\n const isFormError = [FINAL_FORM_ERROR, FormErrorKey].includes(errorKey);\r\n\r\n if (isFormError) {\r\n return <li key={errorKey} dangerouslySetInnerHTML={{ __html: message }} />;\r\n }\r\n\r\n const isArrayField = Array.isArray(message);\r\n\r\n const messages = isArrayField ? message : [message];\r\n\r\n return (\r\n <React.Fragment key={errorKey}>\r\n {messages.map((fieldMessage, index) => {\r\n const inputId = `${mapNameToId(errorKey)}${isArrayField ? `[${index}]` : ''}`;\r\n\r\n return (\r\n <li key={inputId}>\r\n <a href={`#${inputId}`} onClick={handleLinkClick}>\r\n {fieldMessage}\r\n {messages.length > 1 ? ` (${index + 1} of ${messages.length})` : undefined}\r\n </a>\r\n </li>\r\n );\r\n })}\r\n </React.Fragment>\r\n );\r\n })}\r\n </ul>\r\n </bds-error-summary>\r\n );\r\n}\r\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","className","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","filter","x","join","role","ref","tabIndex","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,MAAM,EAAE;AAClB,MAAA,IAAMC,eAAe,GAAGH,OAAO,CAAC,CAAC,CAAC,CAAA;;AAElC;AACA;AACA,MAAA,IAAIJ,KAAK,YAAYQ,gBAAgB,KAAKR,KAAK,CAACS,IAAI,KAAK,UAAU,IAAIT,KAAK,CAACS,IAAI,KAAK,OAAO,CAAC,EAAE;AAC9F,QAAA,OAAOF,eAAe,CAAA;AACxB,OAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;MACA,IAAMG,SAAS,GAAGH,eAAe,CAACI,qBAAqB,EAAE,CA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1,2 +1,2 @@
|
|
|
1
|
-
export { default } from './ErrorSummary';
|
|
2
|
-
export * from './ErrorSummary';
|
|
1
|
+
export { default } from './ErrorSummary';
|
|
2
|
+
export * from './ErrorSummary';
|
|
@@ -0,0 +1,170 @@
|
|
|
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
|
+
function getFragmentFromUrl(url) {
|
|
46
|
+
return url.includes('#') ? url.split('#').pop() : undefined;
|
|
47
|
+
}
|
|
48
|
+
function getAssociatedLegendOrLabel(input) {
|
|
49
|
+
var _document$querySelect;
|
|
50
|
+
var fieldset = input.closest('fieldset');
|
|
51
|
+
if (fieldset) {
|
|
52
|
+
var legends = fieldset.getElementsByTagName('legend');
|
|
53
|
+
if (legends.length) {
|
|
54
|
+
var candidateLegend = legends[0];
|
|
55
|
+
|
|
56
|
+
// If the input type is radio or checkbox, always use the legend if there
|
|
57
|
+
// is one.
|
|
58
|
+
if (input instanceof HTMLInputElement && (input.type === 'checkbox' || input.type === 'radio')) {
|
|
59
|
+
return candidateLegend;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// For other input types, only scroll to the fieldset’s legend (instead of
|
|
63
|
+
// the label associated with the input) if the input would end up in the
|
|
64
|
+
// top half of the screen.
|
|
65
|
+
//
|
|
66
|
+
// This should avoid situations where the input either ends up off the
|
|
67
|
+
// screen, or obscured by a software keyboard.
|
|
68
|
+
var legendTop = candidateLegend.getBoundingClientRect().top;
|
|
69
|
+
var inputRect = input.getBoundingClientRect();
|
|
70
|
+
|
|
71
|
+
// If the browser doesn't support Element.getBoundingClientRect().height
|
|
72
|
+
// or window.innerHeight (like IE8), bail and just link to the label.
|
|
73
|
+
if (inputRect.height && window.innerHeight) {
|
|
74
|
+
var inputBottom = inputRect.top + inputRect.height;
|
|
75
|
+
if (inputBottom - legendTop < window.innerHeight / 2) {
|
|
76
|
+
return candidateLegend;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return (_document$querySelect = document.querySelector("label[for='".concat(input.getAttribute('id'), "']"))) !== null && _document$querySelect !== void 0 ? _document$querySelect : input.closest('label');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
var _excluded = ["className", "errors", "mapNameToId"];
|
|
85
|
+
var FormErrorKey = '_form';
|
|
86
|
+
var FINAL_FORM_ERROR = 'FINAL_FORM/form-error';
|
|
87
|
+
function BdsErrorSummary(_ref) {
|
|
88
|
+
var className = _ref.className,
|
|
89
|
+
errors = _ref.errors,
|
|
90
|
+
_ref$mapNameToId = _ref.mapNameToId,
|
|
91
|
+
mapNameToId = _ref$mapNameToId === void 0 ? function (name) {
|
|
92
|
+
return name;
|
|
93
|
+
} : _ref$mapNameToId,
|
|
94
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
95
|
+
var headingId = React.useId();
|
|
96
|
+
var groupRef = React.useRef(null);
|
|
97
|
+
React.useEffect(function () {
|
|
98
|
+
if (!errors || Object.keys(errors).length === 0) return;
|
|
99
|
+
if (!groupRef.current) return;
|
|
100
|
+
groupRef.current.focus();
|
|
101
|
+
}, [errors]);
|
|
102
|
+
if (!errors || Object.keys(errors).length === 0) return null;
|
|
103
|
+
var handleLinkClick = function handleLinkClick(e) {
|
|
104
|
+
var inputId = getFragmentFromUrl(e.currentTarget.href);
|
|
105
|
+
if (!inputId) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
var input = document.getElementById(inputId);
|
|
109
|
+
if (!input) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
var legendOrLabel = getAssociatedLegendOrLabel(input);
|
|
113
|
+
if (!legendOrLabel) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
e.preventDefault();
|
|
117
|
+
legendOrLabel.scrollIntoView();
|
|
118
|
+
input.focus({
|
|
119
|
+
preventScroll: true
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
return /*#__PURE__*/React.createElement("bds-error-summary", _extends({
|
|
123
|
+
className: ['stack', className].filter(function (x) {
|
|
124
|
+
return x;
|
|
125
|
+
}).join(' '),
|
|
126
|
+
role: "group",
|
|
127
|
+
"aria-labelledby": headingId,
|
|
128
|
+
ref: groupRef,
|
|
129
|
+
tabIndex: -1
|
|
130
|
+
}, props), /*#__PURE__*/React.createElement("h2", {
|
|
131
|
+
className: "bds-h5",
|
|
132
|
+
id: headingId
|
|
133
|
+
}, /*#__PURE__*/React.createElement("svg", {
|
|
134
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
135
|
+
viewBox: "0 0 512 512",
|
|
136
|
+
"aria-hidden": "true",
|
|
137
|
+
height: "1em",
|
|
138
|
+
width: "1em",
|
|
139
|
+
fill: "currentColor"
|
|
140
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
141
|
+
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"
|
|
142
|
+
})), "Issue"), /*#__PURE__*/React.createElement("ul", null, Object.keys(errors).map(function (errorKey) {
|
|
143
|
+
var message = errors[errorKey];
|
|
144
|
+
var isFormError = [FINAL_FORM_ERROR, FormErrorKey].includes(errorKey);
|
|
145
|
+
if (isFormError) {
|
|
146
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
147
|
+
key: errorKey,
|
|
148
|
+
dangerouslySetInnerHTML: {
|
|
149
|
+
__html: message
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
var isArrayField = Array.isArray(message);
|
|
154
|
+
var messages = isArrayField ? message : [message];
|
|
155
|
+
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
156
|
+
key: errorKey
|
|
157
|
+
}, messages.map(function (fieldMessage, index) {
|
|
158
|
+
var inputId = "".concat(mapNameToId(errorKey)).concat(isArrayField ? "[".concat(index, "]") : '');
|
|
159
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
160
|
+
key: inputId
|
|
161
|
+
}, /*#__PURE__*/React.createElement("a", {
|
|
162
|
+
href: "#".concat(inputId),
|
|
163
|
+
onClick: handleLinkClick
|
|
164
|
+
}, fieldMessage, messages.length > 1 ? " (".concat(index + 1, " of ").concat(messages.length, ")") : undefined));
|
|
165
|
+
}));
|
|
166
|
+
})));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export { FormErrorKey, BdsErrorSummary as default };
|
|
170
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/ErrorSummary/utils.ts","../../src/ErrorSummary/ErrorSummary.tsx"],"sourcesContent":["export function getFragmentFromUrl(url: string) {\r\n return url.includes('#') ? url.split('#').pop() : undefined;\r\n}\r\n\r\nexport function getAssociatedLegendOrLabel(input: HTMLElement) {\r\n const fieldset = input.closest('fieldset');\r\n\r\n if (fieldset) {\r\n const legends = fieldset.getElementsByTagName('legend');\r\n\r\n if (legends.length) {\r\n const candidateLegend = legends[0];\r\n\r\n // If the input type is radio or checkbox, always use the legend if there\r\n // is one.\r\n if (input instanceof HTMLInputElement && (input.type === 'checkbox' || input.type === 'radio')) {\r\n return candidateLegend;\r\n }\r\n\r\n // For other input types, only scroll to the fieldset’s legend (instead of\r\n // the label associated with the input) if the input would end up in the\r\n // top half of the screen.\r\n //\r\n // This should avoid situations where the input either ends up off the\r\n // screen, or obscured by a software keyboard.\r\n const legendTop = candidateLegend.getBoundingClientRect().top;\r\n const inputRect = input.getBoundingClientRect();\r\n\r\n // If the browser doesn't support Element.getBoundingClientRect().height\r\n // or window.innerHeight (like IE8), bail and just link to the label.\r\n if (inputRect.height && window.innerHeight) {\r\n const inputBottom = inputRect.top + inputRect.height;\r\n\r\n if (inputBottom - legendTop < window.innerHeight / 2) {\r\n return candidateLegend;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return document.querySelector(`label[for='${input.getAttribute('id')}']`) ?? input.closest('label');\r\n}\r\n","import * as React from 'react';\r\n\r\nimport { getAssociatedLegendOrLabel, getFragmentFromUrl } from './utils';\r\n\r\ndeclare global {\r\n namespace JSX {\r\n interface IntrinsicElements {\r\n 'bds-error-summary': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;\r\n }\r\n }\r\n}\r\n\r\nexport const FormErrorKey = '_form';\r\n\r\nconst FINAL_FORM_ERROR = 'FINAL_FORM/form-error';\r\n\r\nexport type ErrorSummaryProps = {\r\n errors: Record<string, Array<string> | string> | null;\r\n mapNameToId?: (name: string) => string;\r\n};\r\n\r\nexport default function BdsErrorSummary({\r\n className,\r\n errors,\r\n mapNameToId = (name) => name,\r\n ...props\r\n}: ErrorSummaryProps & React.ComponentPropsWithoutRef<'div'>) {\r\n const headingId = React.useId();\r\n const groupRef = React.useRef<HTMLElement>(null);\r\n\r\n React.useEffect(() => {\r\n if (!errors || Object.keys(errors).length === 0) return;\r\n if (!groupRef.current) return;\r\n\r\n groupRef.current.focus();\r\n }, [errors]);\r\n\r\n if (!errors || Object.keys(errors).length === 0) return null;\r\n\r\n const handleLinkClick = (e) => {\r\n const inputId = getFragmentFromUrl(e.currentTarget.href);\r\n\r\n if (!inputId) {\r\n return;\r\n }\r\n\r\n const input = document.getElementById(inputId);\r\n\r\n if (!input) {\r\n return;\r\n }\r\n\r\n const legendOrLabel = getAssociatedLegendOrLabel(input);\r\n\r\n if (!legendOrLabel) {\r\n return;\r\n }\r\n\r\n e.preventDefault();\r\n\r\n legendOrLabel.scrollIntoView();\r\n input.focus({ preventScroll: true });\r\n };\r\n\r\n return (\r\n <bds-error-summary\r\n className={['stack', className].filter((x) => x).join(' ')}\r\n role=\"group\"\r\n aria-labelledby={headingId}\r\n ref={groupRef}\r\n tabIndex={-1}\r\n {...props}\r\n >\r\n <h2 className=\"bds-h5\" id={headingId}>\r\n <svg\r\n xmlns=\"http://www.w3.org/2000/svg\"\r\n viewBox=\"0 0 512 512\"\r\n aria-hidden=\"true\"\r\n height=\"1em\"\r\n width=\"1em\"\r\n fill=\"currentColor\"\r\n >\r\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\" />\r\n </svg>\r\n Issue\r\n </h2>\r\n <ul>\r\n {Object.keys(errors).map((errorKey) => {\r\n const message = errors[errorKey];\r\n const isFormError = [FINAL_FORM_ERROR, FormErrorKey].includes(errorKey);\r\n\r\n if (isFormError) {\r\n return <li key={errorKey} dangerouslySetInnerHTML={{ __html: message }} />;\r\n }\r\n\r\n const isArrayField = Array.isArray(message);\r\n\r\n const messages = isArrayField ? message : [message];\r\n\r\n return (\r\n <React.Fragment key={errorKey}>\r\n {messages.map((fieldMessage, index) => {\r\n const inputId = `${mapNameToId(errorKey)}${isArrayField ? `[${index}]` : ''}`;\r\n\r\n return (\r\n <li key={inputId}>\r\n <a href={`#${inputId}`} onClick={handleLinkClick}>\r\n {fieldMessage}\r\n {messages.length > 1 ? ` (${index + 1} of ${messages.length})` : undefined}\r\n </a>\r\n </li>\r\n );\r\n })}\r\n </React.Fragment>\r\n );\r\n })}\r\n </ul>\r\n </bds-error-summary>\r\n );\r\n}\r\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","className","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","filter","x","join","role","ref","tabIndex","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,MAAM,EAAE;AAClB,MAAA,IAAMC,eAAe,GAAGH,OAAO,CAAC,CAAC,CAAC,CAAA;;AAElC;AACA;AACA,MAAA,IAAIJ,KAAK,YAAYQ,gBAAgB,KAAKR,KAAK,CAACS,IAAI,KAAK,UAAU,IAAIT,KAAK,CAACS,IAAI,KAAK,OAAO,CAAC,EAAE;AAC9F,QAAA,OAAOF,eAAe,CAAA;AACxB,OAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;MACA,IAAMG,SAAS,GAAGH,eAAe,CAACI,qBAAqB,EAAE,CAACC,GAAG,CAAA;AAC7D,MAAA,IAAMC,SAAS,GAAGb,KAAK,CAACW,q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
3
|
+
as?: C;
|
|
4
|
+
error?: string;
|
|
5
|
+
hint?: string;
|
|
6
|
+
id?: string;
|
|
7
|
+
isOptional?: boolean;
|
|
8
|
+
label: string;
|
|
9
|
+
};
|
|
10
|
+
export default function FieldTextInput<C extends React.ElementType>({ as, error, hint, id, isOptional, label, ...props }: FieldTextInputProps<C> & React.ComponentPropsWithoutRef<C>): React.JSX.Element;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
function _interopNamespaceDefault(e) {
|
|
6
|
+
var n = Object.create(null);
|
|
7
|
+
if (e) {
|
|
8
|
+
Object.keys(e).forEach(function (k) {
|
|
9
|
+
if (k !== 'default') {
|
|
10
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return e[k]; }
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
n.default = e;
|
|
19
|
+
return Object.freeze(n);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
23
|
+
|
|
24
|
+
function _extends() {
|
|
25
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
26
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
27
|
+
var source = arguments[i];
|
|
28
|
+
for (var key in source) {
|
|
29
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
30
|
+
target[key] = source[key];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return target;
|
|
35
|
+
};
|
|
36
|
+
return _extends.apply(this, arguments);
|
|
37
|
+
}
|
|
38
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
39
|
+
if (source == null) return {};
|
|
40
|
+
var target = {};
|
|
41
|
+
var sourceKeys = Object.keys(source);
|
|
42
|
+
var key, i;
|
|
43
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
44
|
+
key = sourceKeys[i];
|
|
45
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
46
|
+
target[key] = source[key];
|
|
47
|
+
}
|
|
48
|
+
return target;
|
|
49
|
+
}
|
|
50
|
+
function _objectWithoutProperties(source, excluded) {
|
|
51
|
+
if (source == null) return {};
|
|
52
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
53
|
+
var key, i;
|
|
54
|
+
if (Object.getOwnPropertySymbols) {
|
|
55
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
56
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
57
|
+
key = sourceSymbolKeys[i];
|
|
58
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
59
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
60
|
+
target[key] = source[key];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return target;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
var _excluded = ["as", "error", "hint", "id", "isOptional", "label"];
|
|
67
|
+
function FieldTextInput(_ref) {
|
|
68
|
+
var _id;
|
|
69
|
+
var as = _ref.as,
|
|
70
|
+
error = _ref.error,
|
|
71
|
+
hint = _ref.hint,
|
|
72
|
+
id = _ref.id,
|
|
73
|
+
_ref$isOptional = _ref.isOptional,
|
|
74
|
+
isOptional = _ref$isOptional === void 0 ? false : _ref$isOptional,
|
|
75
|
+
label = _ref.label,
|
|
76
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
77
|
+
id = (_id = id) !== null && _id !== void 0 ? _id : props.name;
|
|
78
|
+
var errorId = React__namespace.useId();
|
|
79
|
+
var hintId = React__namespace.useId();
|
|
80
|
+
var InputComponent = as !== null && as !== void 0 ? as : 'input';
|
|
81
|
+
return /*#__PURE__*/React__namespace.createElement("div", {
|
|
82
|
+
className: "bds-text-input stack"
|
|
83
|
+
}, /*#__PURE__*/React__namespace.createElement("label", {
|
|
84
|
+
htmlFor: id
|
|
85
|
+
}, label, isOptional && ' (optional)'), hint && /*#__PURE__*/React__namespace.createElement("span", {
|
|
86
|
+
className: "bds-hint",
|
|
87
|
+
id: hintId
|
|
88
|
+
}, hint), error && /*#__PURE__*/React__namespace.createElement("span", {
|
|
89
|
+
className: "bds-error",
|
|
90
|
+
id: errorId
|
|
91
|
+
}, /*#__PURE__*/React__namespace.createElement("svg", {
|
|
92
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
93
|
+
viewBox: "0 0 512 512",
|
|
94
|
+
"aria-hidden": "true",
|
|
95
|
+
height: "1em",
|
|
96
|
+
width: "1em",
|
|
97
|
+
fill: "currentColor"
|
|
98
|
+
}, /*#__PURE__*/React__namespace.createElement("path", {
|
|
99
|
+
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"
|
|
100
|
+
})), error), /*#__PURE__*/React__namespace.createElement(InputComponent, _extends({
|
|
101
|
+
"aria-invalid": error ? true : undefined,
|
|
102
|
+
"aria-describedby": error && hint ? "".concat(hintId, " ").concat(errorId) : error ? errorId : hint ? hintId : undefined,
|
|
103
|
+
"aria-required": isOptional ? undefined : true,
|
|
104
|
+
id: id
|
|
105
|
+
}, props)));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
module.exports = FieldTextInput;
|
|
109
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/FieldTextInput/FieldTextInput.tsx"],"sourcesContent":["import * as React from 'react';\r\n\r\nexport type FieldTextInputProps<C> = {\r\n as?: C;\r\n error?: string;\r\n hint?: string;\r\n id?: string;\r\n isOptional?: boolean;\r\n label: string;\r\n};\r\n\r\nexport default function FieldTextInput<C extends React.ElementType>({\r\n as,\r\n error,\r\n hint,\r\n id,\r\n isOptional = false,\r\n label,\r\n ...props\r\n}: FieldTextInputProps<C> & React.ComponentPropsWithoutRef<C>) {\r\n id = id ?? props.name;\r\n\r\n const errorId = React.useId();\r\n const hintId = React.useId();\r\n\r\n const InputComponent = as ?? 'input';\r\n\r\n return (\r\n <div className=\"bds-text-input stack\">\r\n <label htmlFor={id}>\r\n {label}\r\n {isOptional && ' (optional)'}\r\n </label>\r\n {hint && (\r\n <span className=\"bds-hint\" id={hintId}>\r\n {hint}\r\n </span>\r\n )}\r\n {error && (\r\n <span className=\"bds-error\" id={errorId}>\r\n <svg\r\n xmlns=\"http://www.w3.org/2000/svg\"\r\n viewBox=\"0 0 512 512\"\r\n aria-hidden=\"true\"\r\n height=\"1em\"\r\n width=\"1em\"\r\n fill=\"currentColor\"\r\n >\r\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\" />\r\n </svg>\r\n {error}\r\n </span>\r\n )}\r\n <InputComponent\r\n aria-invalid={error ? true : undefined}\r\n aria-describedby={error && hint ? `${hintId} ${errorId}` : error ? errorId : hint ? hintId : undefined}\r\n aria-required={isOptional ? undefined : true}\r\n id={id}\r\n {...props}\r\n />\r\n </div>\r\n );\r\n}\r\n"],"names":["FieldTextInput","_ref","_id","as","error","hint","id","_ref$isOptional","isOptional","label","props","_objectWithoutProperties","_excluded","name","errorId","React","useId","hintId","InputComponent","createElement","className","htmlFor","xmlns","viewBox","height","width","fill","d","_extends","undefined","concat"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWe,SAASA,cAAcA,CAAAC,IAAA,EAQyB;AAAA,EAAA,IAAAC,GAAA,CAAA;AAAA,EAAA,IAP7DC,EAAE,GAAAF,IAAA,CAAFE,EAAE;IACFC,KAAK,GAAAH,IAAA,CAALG,KAAK;IACLC,IAAI,GAAAJ,IAAA,CAAJI,IAAI;IACJC,EAAE,GAAAL,IAAA,CAAFK,EAAE;IAAAC,eAAA,GAAAN,IAAA,CACFO,UAAU;AAAVA,IAAAA,UAAU,GAAAD,eAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,eAAA;IAClBE,KAAK,GAAAR,IAAA,CAALQ,KAAK;AACFC,IAAAA,KAAK,GAAAC,wBAAA,CAAAV,IAAA,EAAAW,SAAA,CAAA,CAAA;EAERN,EAAE,GAAA,CAAAJ,GAAA,GAAGI,EAAE,MAAA,IAAA,IAAAJ,GAAA,KAAA,KAAA,CAAA,GAAAA,GAAA,GAAIQ,KAAK,CAACG,IAAI,CAAA;AAErB,EAAA,IAAMC,OAAO,GAAGC,gBAAK,CAACC,KAAK,EAAE,CAAA;AAC7B,EAAA,IAAMC,MAAM,GAAGF,gBAAK,CAACC,KAAK,EAAE,CAAA;EAE5B,IAAME,cAAc,GAAGf,EAAE,KAAA,IAAA,IAAFA,EAAE,KAAFA,KAAAA,CAAAA,GAAAA,EAAE,GAAI,OAAO,CAAA;EAEpC,oBACEY,gBAAA,CAAAI,aAAA,CAAA,KAAA,EAAA;AAAKC,IAAAA,SAAS,EAAC,sBAAA;GACbL,eAAAA,gBAAA,CAAAI,aAAA,CAAA,OAAA,EAAA;AAAOE,IAAAA,OAAO,EA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'./FieldTextInput';
|
|
@@ -0,0 +1,88 @@
|
|
|
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 = ["as", "error", "hint", "id", "isOptional", "label"];
|
|
46
|
+
function FieldTextInput(_ref) {
|
|
47
|
+
var _id;
|
|
48
|
+
var as = _ref.as,
|
|
49
|
+
error = _ref.error,
|
|
50
|
+
hint = _ref.hint,
|
|
51
|
+
id = _ref.id,
|
|
52
|
+
_ref$isOptional = _ref.isOptional,
|
|
53
|
+
isOptional = _ref$isOptional === void 0 ? false : _ref$isOptional,
|
|
54
|
+
label = _ref.label,
|
|
55
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
56
|
+
id = (_id = id) !== null && _id !== void 0 ? _id : props.name;
|
|
57
|
+
var errorId = React.useId();
|
|
58
|
+
var hintId = React.useId();
|
|
59
|
+
var InputComponent = as !== null && as !== void 0 ? as : 'input';
|
|
60
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
61
|
+
className: "bds-text-input stack"
|
|
62
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
63
|
+
htmlFor: id
|
|
64
|
+
}, label, isOptional && ' (optional)'), hint && /*#__PURE__*/React.createElement("span", {
|
|
65
|
+
className: "bds-hint",
|
|
66
|
+
id: hintId
|
|
67
|
+
}, hint), error && /*#__PURE__*/React.createElement("span", {
|
|
68
|
+
className: "bds-error",
|
|
69
|
+
id: errorId
|
|
70
|
+
}, /*#__PURE__*/React.createElement("svg", {
|
|
71
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
72
|
+
viewBox: "0 0 512 512",
|
|
73
|
+
"aria-hidden": "true",
|
|
74
|
+
height: "1em",
|
|
75
|
+
width: "1em",
|
|
76
|
+
fill: "currentColor"
|
|
77
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
78
|
+
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"
|
|
79
|
+
})), error), /*#__PURE__*/React.createElement(InputComponent, _extends({
|
|
80
|
+
"aria-invalid": error ? true : undefined,
|
|
81
|
+
"aria-describedby": error && hint ? "".concat(hintId, " ").concat(errorId) : error ? errorId : hint ? hintId : undefined,
|
|
82
|
+
"aria-required": isOptional ? undefined : true,
|
|
83
|
+
id: id
|
|
84
|
+
}, props)));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { FieldTextInput as default };
|
|
88
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/FieldTextInput/FieldTextInput.tsx"],"sourcesContent":["import * as React from 'react';\r\n\r\nexport type FieldTextInputProps<C> = {\r\n as?: C;\r\n error?: string;\r\n hint?: string;\r\n id?: string;\r\n isOptional?: boolean;\r\n label: string;\r\n};\r\n\r\nexport default function FieldTextInput<C extends React.ElementType>({\r\n as,\r\n error,\r\n hint,\r\n id,\r\n isOptional = false,\r\n label,\r\n ...props\r\n}: FieldTextInputProps<C> & React.ComponentPropsWithoutRef<C>) {\r\n id = id ?? props.name;\r\n\r\n const errorId = React.useId();\r\n const hintId = React.useId();\r\n\r\n const InputComponent = as ?? 'input';\r\n\r\n return (\r\n <div className=\"bds-text-input stack\">\r\n <label htmlFor={id}>\r\n {label}\r\n {isOptional && ' (optional)'}\r\n </label>\r\n {hint && (\r\n <span className=\"bds-hint\" id={hintId}>\r\n {hint}\r\n </span>\r\n )}\r\n {error && (\r\n <span className=\"bds-error\" id={errorId}>\r\n <svg\r\n xmlns=\"http://www.w3.org/2000/svg\"\r\n viewBox=\"0 0 512 512\"\r\n aria-hidden=\"true\"\r\n height=\"1em\"\r\n width=\"1em\"\r\n fill=\"currentColor\"\r\n >\r\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\" />\r\n </svg>\r\n {error}\r\n </span>\r\n )}\r\n <InputComponent\r\n aria-invalid={error ? true : undefined}\r\n aria-describedby={error && hint ? `${hintId} ${errorId}` : error ? errorId : hint ? hintId : undefined}\r\n aria-required={isOptional ? undefined : true}\r\n id={id}\r\n {...props}\r\n />\r\n </div>\r\n );\r\n}\r\n"],"names":["FieldTextInput","_ref","_id","as","error","hint","id","_ref$isOptional","isOptional","label","props","_objectWithoutProperties","_excluded","name","errorId","React","useId","hintId","InputComponent","createElement","className","htmlFor","xmlns","viewBox","height","width","fill","d","_extends","undefined","concat"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWe,SAASA,cAAcA,CAAAC,IAAA,EAQyB;AAAA,EAAA,IAAAC,GAAA,CAAA;AAAA,EAAA,IAP7DC,EAAE,GAAAF,IAAA,CAAFE,EAAE;IACFC,KAAK,GAAAH,IAAA,CAALG,KAAK;IACLC,IAAI,GAAAJ,IAAA,CAAJI,IAAI;IACJC,EAAE,GAAAL,IAAA,CAAFK,EAAE;IAAAC,eAAA,GAAAN,IAAA,CACFO,UAAU;AAAVA,IAAAA,UAAU,GAAAD,eAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,eAAA;IAClBE,KAAK,GAAAR,IAAA,CAALQ,KAAK;AACFC,IAAAA,KAAK,GAAAC,wBAAA,CAAAV,IAAA,EAAAW,SAAA,CAAA,CAAA;EAERN,EAAE,GAAA,CAAAJ,GAAA,GAAGI,EAAE,MAAA,IAAA,IAAAJ,GAAA,KAAA,KAAA,CAAA,GAAAA,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AAG,IAAI,GAAGyB,SAAU;IACvC,kBAAkBzB,EAAAA,KAAK,IAAIC,IAAI,GAAA,EAAA,CAAAyB,MAAA,CAAMb,MAAM,OAAAa,MAAA,CAAIhB,OAAO,CAAKV,GAAAA,KAAK,GAAGU,OAAO,GAAGT,IAAI,GAAGY,MAAM,GAAGY,SAAU;AACvG,IAAA,eAAA,EAAerB,UAAU,GAAGqB,SAAS,GAAG,IAAK;AAC7CvB,IAAAA,EAAE,EAAEA,EAAAA;GACAI,EAAAA,KAAK,CACV,CACE,CAAC,CAAA;AAEV;;;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare type PaginationProps = {
|
|
3
|
+
buildPageUrl: (page: number) => string;
|
|
4
|
+
currentPage: number;
|
|
5
|
+
onPageClick?: (page: number) => void;
|
|
6
|
+
totalPages: number;
|
|
7
|
+
};
|
|
8
|
+
export default function Pagination({ buildPageUrl, className, currentPage, onPageClick, totalPages, ...props }: PaginationProps & React.ComponentPropsWithoutRef<'nav'>): React.JSX.Element;
|