@iabbb/bds-react 0.47.1 → 0.47.3
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/ErrorMessage/index.cjs.map +1 -1
- package/ErrorMessage/index.mjs.map +1 -1
- package/ErrorSummary/index.cjs +47 -42
- package/ErrorSummary/index.cjs.map +1 -1
- package/ErrorSummary/index.mjs +47 -42
- package/ErrorSummary/index.mjs.map +1 -1
- package/FieldCheckbox/index.cjs.map +1 -1
- package/FieldCheckbox/index.mjs.map +1 -1
- package/FieldSelect/FieldSelect.d.ts +8 -2
- package/FieldSelect/index.cjs.map +1 -1
- package/FieldSelect/index.mjs.map +1 -1
- package/FieldTextInput/index.cjs.map +1 -1
- package/FieldTextInput/index.mjs.map +1 -1
- package/FieldTextarea/index.cjs.map +1 -1
- package/FieldTextarea/index.mjs.map +1 -1
- package/Fieldset/index.cjs.map +1 -1
- package/Fieldset/index.mjs.map +1 -1
- package/index.cjs +47 -42
- package/index.cjs.map +1 -1
- package/index.mjs +47 -42
- package/index.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/ErrorMessage/ErrorMessage.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/ErrorMessage/ErrorMessage.tsx"],"sourcesContent":["// biome-ignore lint/style/useImportType: following this rule does not work for some reason\nimport * 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGe,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;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/ErrorMessage/ErrorMessage.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/ErrorMessage/ErrorMessage.tsx"],"sourcesContent":["// biome-ignore lint/style/useImportType: following this rule does not work for some reason\nimport * 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGe,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;;;;"}
|
package/ErrorSummary/index.cjs
CHANGED
|
@@ -129,48 +129,53 @@ function BdsErrorSummary(_ref) {
|
|
|
129
129
|
preventScroll: true
|
|
130
130
|
});
|
|
131
131
|
};
|
|
132
|
-
return
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
var
|
|
166
|
-
return /*#__PURE__*/React__namespace.createElement(
|
|
167
|
-
key:
|
|
168
|
-
},
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
132
|
+
return (
|
|
133
|
+
/*#__PURE__*/
|
|
134
|
+
// biome-ignore lint/a11y/noInteractiveElementToNoninteractiveRole: group is not an interactive role
|
|
135
|
+
React__namespace.createElement("bds-error-summary", _extends({
|
|
136
|
+
role: "group",
|
|
137
|
+
"aria-labelledby": headingId,
|
|
138
|
+
ref: groupRef,
|
|
139
|
+
tabIndex: -1
|
|
140
|
+
}, props), /*#__PURE__*/React__namespace.createElement("h2", {
|
|
141
|
+
className: "bds-h5",
|
|
142
|
+
id: headingId
|
|
143
|
+
}, /*#__PURE__*/React__namespace.createElement("svg", {
|
|
144
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
145
|
+
viewBox: "0 0 512 512",
|
|
146
|
+
"aria-hidden": "true",
|
|
147
|
+
height: "1em",
|
|
148
|
+
width: "1em",
|
|
149
|
+
fill: "currentColor"
|
|
150
|
+
}, /*#__PURE__*/React__namespace.createElement("path", {
|
|
151
|
+
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"
|
|
152
|
+
})), "Issue"), /*#__PURE__*/React__namespace.createElement("ul", null, Object.keys(errors).map(function (errorKey) {
|
|
153
|
+
var message = errors[errorKey];
|
|
154
|
+
var isFormError = [FINAL_FORM_ERROR, FormErrorKey].includes(errorKey);
|
|
155
|
+
if (isFormError) {
|
|
156
|
+
// biome-ignore lint/security/noDangerouslySetInnerHtml: some generic form errors may include links
|
|
157
|
+
return /*#__PURE__*/React__namespace.createElement("li", {
|
|
158
|
+
key: errorKey,
|
|
159
|
+
dangerouslySetInnerHTML: {
|
|
160
|
+
__html: message
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
var isArrayField = Array.isArray(message);
|
|
165
|
+
var messages = isArrayField ? message : [message];
|
|
166
|
+
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, {
|
|
167
|
+
key: errorKey
|
|
168
|
+
}, messages.map(function (fieldMessage, index) {
|
|
169
|
+
var inputId = "".concat(mapNameToId(errorKey)).concat(isArrayField ? "[".concat(index, "]") : '');
|
|
170
|
+
return /*#__PURE__*/React__namespace.createElement("li", {
|
|
171
|
+
key: inputId
|
|
172
|
+
}, /*#__PURE__*/React__namespace.createElement("a", {
|
|
173
|
+
href: "#".concat(inputId),
|
|
174
|
+
onClick: handleLinkClick
|
|
175
|
+
}, fieldMessage, messages.length > 1 ? " (".concat(index + 1, " of ").concat(messages.length, ")") : undefined));
|
|
176
|
+
}));
|
|
177
|
+
})))
|
|
178
|
+
);
|
|
174
179
|
}
|
|
175
180
|
|
|
176
181
|
exports.FormErrorKey = FormErrorKey;
|
|
@@ -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\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,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,qBAAqB,EAAE,CAAA;;AAE/C;AACA;AACA,MAAA,IAAIE,SAAS,CAACC,MAAM,IAAIC,MAAM,CAACC,WAAW,EAAE;QAC1C,IAAMC,WAAW,GAAGJ,SAAS,CAACD,GAAG,GAAGC,SAAS,CAACC,M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AAY,EAAEC,KAAK,EAAK;AACrC,MAAA,IAAMjC,OAAO,GAAAzB,EAAAA,CAAAA,MAAA,CAAMQ,WAAW,CAACsC,QAAQ,CAAC,CAAA,CAAA9C,MAAA,CAAGoD,YAAY,GAAApD,GAAAA,CAAAA,MAAA,CAAO0D,KAAK,EAAA,GAAA,CAAA,GAAM,EAAE,CAAE,CAAA;MAE7E,oBACE5C,gBAAA,CAAAmB,aAAA,CAAA,IAAA,EAAA;AAAIgB,QAAAA,GAAG,EAAExB,OAAAA;OACPX,eAAAA,gBAAA,CAAAmB,aAAA,CAAA,GAAA,EAAA;AAAGN,QAAAA,IAAI,EAAA3B,GAAAA,CAAAA,MAAA,CAAMyB,OAAO,CAAG;AAACkC,QAAAA,OAAO,EAAEpC,eAAAA;OAC9BkC,EAAAA,YAAY,EACZF,QAAQ,CAACrE,MAAM,GAAG,CAAC,GAAAc,IAAAA,CAAAA,MAAA,CAAQ0D,KAAK,GAAG,CAAC,EAAA,MAAA,CAAA,CAAA1D,MAAA,CAAOuD,QAAQ,CAACrE,MAAM,EAAA,GAAA,CAAA,GAAMR,SAChE,CACD,CAAC,CAAA;AAET,KAAC,CACa,CAAC,CAAA;GAEpB,CACC,CACa,CAAC,CAAA;AAExB;;;;;"}
|
|
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\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 // biome-ignore lint/a11y/noInteractiveElementToNoninteractiveRole: group is not an interactive role\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 // biome-ignore lint/security/noDangerouslySetInnerHtml: some generic form errors may include links\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,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,C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|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
var
|
|
143
|
-
return /*#__PURE__*/React.createElement(
|
|
144
|
-
key:
|
|
145
|
-
},
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
109
|
+
return (
|
|
110
|
+
/*#__PURE__*/
|
|
111
|
+
// biome-ignore lint/a11y/noInteractiveElementToNoninteractiveRole: group is not an interactive role
|
|
112
|
+
React.createElement("bds-error-summary", _extends({
|
|
113
|
+
role: "group",
|
|
114
|
+
"aria-labelledby": headingId,
|
|
115
|
+
ref: groupRef,
|
|
116
|
+
tabIndex: -1
|
|
117
|
+
}, props), /*#__PURE__*/React.createElement("h2", {
|
|
118
|
+
className: "bds-h5",
|
|
119
|
+
id: headingId
|
|
120
|
+
}, /*#__PURE__*/React.createElement("svg", {
|
|
121
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
122
|
+
viewBox: "0 0 512 512",
|
|
123
|
+
"aria-hidden": "true",
|
|
124
|
+
height: "1em",
|
|
125
|
+
width: "1em",
|
|
126
|
+
fill: "currentColor"
|
|
127
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
128
|
+
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"
|
|
129
|
+
})), "Issue"), /*#__PURE__*/React.createElement("ul", null, Object.keys(errors).map(function (errorKey) {
|
|
130
|
+
var message = errors[errorKey];
|
|
131
|
+
var isFormError = [FINAL_FORM_ERROR, FormErrorKey].includes(errorKey);
|
|
132
|
+
if (isFormError) {
|
|
133
|
+
// biome-ignore lint/security/noDangerouslySetInnerHtml: some generic form errors may include links
|
|
134
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
135
|
+
key: errorKey,
|
|
136
|
+
dangerouslySetInnerHTML: {
|
|
137
|
+
__html: message
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
var isArrayField = Array.isArray(message);
|
|
142
|
+
var messages = isArrayField ? message : [message];
|
|
143
|
+
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
144
|
+
key: errorKey
|
|
145
|
+
}, messages.map(function (fieldMessage, index) {
|
|
146
|
+
var inputId = "".concat(mapNameToId(errorKey)).concat(isArrayField ? "[".concat(index, "]") : '');
|
|
147
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
148
|
+
key: inputId
|
|
149
|
+
}, /*#__PURE__*/React.createElement("a", {
|
|
150
|
+
href: "#".concat(inputId),
|
|
151
|
+
onClick: handleLinkClick
|
|
152
|
+
}, fieldMessage, messages.length > 1 ? " (".concat(index + 1, " of ").concat(messages.length, ")") : undefined));
|
|
153
|
+
}));
|
|
154
|
+
})))
|
|
155
|
+
);
|
|
151
156
|
}
|
|
152
157
|
|
|
153
158
|
export { FormErrorKey, BdsErrorSummary as default };
|
|
@@ -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\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,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,IAAI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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 // biome-ignore lint/a11y/noInteractiveElementToNoninteractiveRole: group is not an interactive role\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 // biome-ignore lint/security/noDangerouslySetInnerHtml: some generic form errors may include links\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,IA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QAAQ,CAACrE,MAAM,EAAA,GAAA,CAAA,GAAMR,SAChE,CACD,CAAC,CAAA;AAET,OAAC,CACa,CAAC,CAAA;AAErB,KAAC,CACC,CACa,CAAA;AAAC,IAAA;AAExB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/ErrorMessage/ErrorMessage.tsx","../../src/FieldCheckbox/FieldCheckbox.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/ErrorMessage/ErrorMessage.tsx","../../src/FieldCheckbox/FieldCheckbox.tsx"],"sourcesContent":["// biome-ignore lint/style/useImportType: following this rule does not work for some reason\nimport * 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","import * as React from 'react';\n\nimport ErrorMessage from '../ErrorMessage';\n\nexport type FieldCheckboxProps = {\n error?: string;\n label: React.ReactNode | string;\n} & React.ComponentPropsWithoutRef<'input'>;\n\nconst FieldCheckbox = React.forwardRef<HTMLInputElement, FieldCheckboxProps>(\n ({ error, id, label, ...props }, ref) => {\n const [isEnhanced, setIsEnhanced] = React.useState(false);\n\n const fallbackId = React.useId();\n const errorId = React.useId();\n\n const inputId = id ?? fallbackId;\n\n React.useEffect(() => {\n setIsEnhanced(true);\n }, []);\n\n return (\n <div className=\"bds-form-group\">\n {error && <ErrorMessage id={errorId}>{error}</ErrorMessage>}\n <div className=\"bds-checkbox\" data-enhanced={isEnhanced ? '' : undefined}>\n <input\n {...props}\n aria-describedby={error ? errorId : undefined}\n aria-invalid={error ? true : undefined}\n id={inputId}\n ref={ref}\n type=\"checkbox\"\n />\n {isEnhanced && (\n <svg width=\"32\" height=\"32\" viewBox=\"-4 -4 39 39\" aria-hidden=\"true\" focusable=\"false\">\n <rect\n className=\"background\"\n width=\"35\"\n height=\"35\"\n x=\"-2\"\n y=\"-2\"\n stroke=\"currentColor\"\n fill=\"none\"\n strokeWidth=\"1\"\n vectorEffect=\"non-scaling-stroke\"\n />\n <path\n className=\"checkmark\"\n d=\"M 4 14 L 12 23 L 28 5\"\n stroke=\"#ffff\"\n strokeDasharray=\"140\"\n strokeDashoffset=\"140\"\n />\n </svg>\n )}\n <label htmlFor={inputId}>{label}</label>\n </div>\n </div>\n );\n },\n);\n\nexport default FieldCheckbox;\n"],"names":["ErrorMessage","_ref","className","children","props","_objectWithoutProperties","_excluded","React","createElement","_extends","filter","x","join","xmlns","viewBox","height","width","fill","d","FieldCheckbox","forwardRef","ref","error","id","label","_React$useState","useState","_React$useState2","_slicedToArray","isEnhanced","setIsEnhanced","fallbackId","useId","errorId","inputId","useEffect","undefined","type","focusable","y","stroke","strokeWidth","vectorEffect","strokeDasharray","strokeDashoffset","htmlFor"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGe,SAASA,YAAYA,CAAAC,IAAA,EAA4E;AAAA,EAAA,IAAzEC,SAAS,GAAAD,IAAA,CAATC,SAAS;IAAEC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;AAAKC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AAa;AAAC,IAAA,aAAA,EAAY,MAAM;AAACwB,IAAAA,SAAS,EAAC,OAAA;GAC7E/B,eAAAA,gBAAA,CAAAC,aAAA,CAAA,MAAA,EAAA;AACEN,IAAAA,SAAS,EAAC,YAAY;AACtBc,IAAAA,KAAK,EAAC,IAAI;AACVD,IAAAA,MAAM,EAAC,IAAI;AACXJ,IAAAA,CAAC,EAAC,IAAI;AACN4B,IAAAA,CAAC,EAAC,IAAI;AACNC,IAAAA,MAAM,EAAC,cAAc;AACrBvB,IAAAA,IAAI,EAAC,MAAM;AACXwB,IAAAA,WAAW,EAAC,GAAG;AACfC,IAAAA,YAAY,EAAC,oBAAA;AAAoB,GAClC,CAAC,eACFnC,gBAAA,CAAAC,aAAA,CAAA,MAAA,EAAA;AACEN,IAAAA,SAAS,EAAC,WAAW;AACrBgB,IAAAA,CAAC,EAAC,uBAAuB;AACzBsB,IAAAA,MAAM,EAAC,OAAO;AACdG,IAAAA,eAAe,EAAC,KAAK;AACrBC,IAAAA,gBAAgB,EAAC,KAAA;AAAK,GACvB,CACE,CACN,eACDrC,gBAAA,CAAAC,aAAA,CAAA,OAAA,EAAA;AAAOqC,IAAAA,OAAO,EAAEX,OAAAA;GAAUV,EAAAA,KAAa,CACpC,CACF,CAAC,CAAA;AAEV,CACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/ErrorMessage/ErrorMessage.tsx","../../src/FieldCheckbox/FieldCheckbox.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/ErrorMessage/ErrorMessage.tsx","../../src/FieldCheckbox/FieldCheckbox.tsx"],"sourcesContent":["// biome-ignore lint/style/useImportType: following this rule does not work for some reason\nimport * 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","import * as React from 'react';\n\nimport ErrorMessage from '../ErrorMessage';\n\nexport type FieldCheckboxProps = {\n error?: string;\n label: React.ReactNode | string;\n} & React.ComponentPropsWithoutRef<'input'>;\n\nconst FieldCheckbox = React.forwardRef<HTMLInputElement, FieldCheckboxProps>(\n ({ error, id, label, ...props }, ref) => {\n const [isEnhanced, setIsEnhanced] = React.useState(false);\n\n const fallbackId = React.useId();\n const errorId = React.useId();\n\n const inputId = id ?? fallbackId;\n\n React.useEffect(() => {\n setIsEnhanced(true);\n }, []);\n\n return (\n <div className=\"bds-form-group\">\n {error && <ErrorMessage id={errorId}>{error}</ErrorMessage>}\n <div className=\"bds-checkbox\" data-enhanced={isEnhanced ? '' : undefined}>\n <input\n {...props}\n aria-describedby={error ? errorId : undefined}\n aria-invalid={error ? true : undefined}\n id={inputId}\n ref={ref}\n type=\"checkbox\"\n />\n {isEnhanced && (\n <svg width=\"32\" height=\"32\" viewBox=\"-4 -4 39 39\" aria-hidden=\"true\" focusable=\"false\">\n <rect\n className=\"background\"\n width=\"35\"\n height=\"35\"\n x=\"-2\"\n y=\"-2\"\n stroke=\"currentColor\"\n fill=\"none\"\n strokeWidth=\"1\"\n vectorEffect=\"non-scaling-stroke\"\n />\n <path\n className=\"checkmark\"\n d=\"M 4 14 L 12 23 L 28 5\"\n stroke=\"#ffff\"\n strokeDasharray=\"140\"\n strokeDashoffset=\"140\"\n />\n </svg>\n )}\n <label htmlFor={inputId}>{label}</label>\n </div>\n </div>\n );\n },\n);\n\nexport default FieldCheckbox;\n"],"names":["ErrorMessage","_ref","className","children","props","_objectWithoutProperties","_excluded","React","createElement","_extends","filter","x","join","xmlns","viewBox","height","width","fill","d","FieldCheckbox","forwardRef","ref","error","id","label","_React$useState","useState","_React$useState2","_slicedToArray","isEnhanced","setIsEnhanced","fallbackId","useId","errorId","inputId","useEffect","undefined","type","focusable","y","stroke","strokeWidth","vectorEffect","strokeDasharray","strokeDashoffset","htmlFor"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGe,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,WAAA,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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IAAAA,gBAAgB,EAAC,KAAA;AAAK,GACvB,CACE,CACN,eACDrC,KAAA,CAAAC,aAAA,CAAA,OAAA,EAAA;AAAOqC,IAAAA,OAAO,EAAEX,OAAAA;GAAUV,EAAAA,KAAa,CACpC,CACF,CAAC,CAAA;AAEV,CACF;;;;"}
|
|
@@ -5,6 +5,12 @@ export type FieldSelectProps = {
|
|
|
5
5
|
id?: string;
|
|
6
6
|
isOptional?: boolean;
|
|
7
7
|
label: React.ReactNode | string;
|
|
8
|
-
}
|
|
9
|
-
declare const FieldSelect: React.ForwardRefExoticComponent<
|
|
8
|
+
} & React.ComponentPropsWithoutRef<'select'>;
|
|
9
|
+
declare const FieldSelect: React.ForwardRefExoticComponent<{
|
|
10
|
+
error?: string | undefined;
|
|
11
|
+
hint?: React.ReactNode | string;
|
|
12
|
+
id?: string | undefined;
|
|
13
|
+
isOptional?: boolean | undefined;
|
|
14
|
+
label: React.ReactNode | string;
|
|
15
|
+
} & Omit<React.DetailedHTMLProps<React.SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>, "ref"> & React.RefAttributes<HTMLSelectElement>>;
|
|
10
16
|
export default FieldSelect;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/ErrorMessage/ErrorMessage.tsx","../../src/FieldSelect/FieldSelect.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/ErrorMessage/ErrorMessage.tsx","../../src/FieldSelect/FieldSelect.tsx"],"sourcesContent":["// biome-ignore lint/style/useImportType: following this rule does not work for some reason\nimport * 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","import * as React from 'react';\nimport ErrorMessage from '../ErrorMessage';\n\nexport type FieldSelectProps = {\n error?: string;\n hint?: React.ReactNode | string;\n id?: string;\n isOptional?: boolean;\n label: React.ReactNode | string;\n} & React.ComponentPropsWithoutRef<'select'>;\n\nconst FieldSelect = React.forwardRef<HTMLSelectElement, FieldSelectProps>(\n ({ error, hint, id, isOptional = false, label, ...props }, ref) => {\n id = id ?? props.name;\n\n const errorId = React.useId();\n const hintId = React.useId();\n\n return (\n <div className=\"bds-form-group\">\n <label htmlFor={id}>\n {label}\n {isOptional && ' (optional)'}\n </label>\n {hint && (\n <span className=\"bds-hint\" id={hintId}>\n {hint}\n </span>\n )}\n {error && <ErrorMessage id={errorId}>{error}</ErrorMessage>}\n <div className=\"bds-select\">\n <select\n aria-invalid={error ? true : undefined}\n aria-describedby={error && hint ? `${hintId} ${errorId}` : error ? errorId : hint ? hintId : undefined}\n id={id}\n ref={ref}\n {...props}\n />\n </div>\n </div>\n );\n },\n);\n\nexport default FieldSelect;\n"],"names":["ErrorMessage","_ref","className","children","props","_objectWithoutProperties","_excluded","React","createElement","_extends","filter","x","join","xmlns","viewBox","height","width","fill","d","FieldSelect","forwardRef","ref","_id","error","hint","id","_ref$isOptional","isOptional","label","name","errorId","useId","hintId","htmlFor","undefined","concat"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGe,SAASA,YAAYA,CAAAC,IAAA,EAA4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GE,SAAU;AACvGT,IAAAA,EAAE,EAAEA,EAAG;AACPJ,IAAAA,GAAG,EAAEA,GAAAA;AAAI,GAAA,EACLjB,KAAK,CACV,CACE,CACF,CAAC,CAAA;AAEV,CACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/ErrorMessage/ErrorMessage.tsx","../../src/FieldSelect/FieldSelect.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/ErrorMessage/ErrorMessage.tsx","../../src/FieldSelect/FieldSelect.tsx"],"sourcesContent":["// biome-ignore lint/style/useImportType: following this rule does not work for some reason\nimport * 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","import * as React from 'react';\nimport ErrorMessage from '../ErrorMessage';\n\nexport type FieldSelectProps = {\n error?: string;\n hint?: React.ReactNode | string;\n id?: string;\n isOptional?: boolean;\n label: React.ReactNode | string;\n} & React.ComponentPropsWithoutRef<'select'>;\n\nconst FieldSelect = React.forwardRef<HTMLSelectElement, FieldSelectProps>(\n ({ error, hint, id, isOptional = false, label, ...props }, ref) => {\n id = id ?? props.name;\n\n const errorId = React.useId();\n const hintId = React.useId();\n\n return (\n <div className=\"bds-form-group\">\n <label htmlFor={id}>\n {label}\n {isOptional && ' (optional)'}\n </label>\n {hint && (\n <span className=\"bds-hint\" id={hintId}>\n {hint}\n </span>\n )}\n {error && <ErrorMessage id={errorId}>{error}</ErrorMessage>}\n <div className=\"bds-select\">\n <select\n aria-invalid={error ? true : undefined}\n aria-describedby={error && hint ? `${hintId} ${errorId}` : error ? errorId : hint ? hintId : undefined}\n id={id}\n ref={ref}\n {...props}\n />\n </div>\n </div>\n );\n },\n);\n\nexport default FieldSelect;\n"],"names":["ErrorMessage","_ref","className","children","props","_objectWithoutProperties","_excluded","React","createElement","_extends","filter","x","join","xmlns","viewBox","height","width","fill","d","FieldSelect","forwardRef","ref","_id","error","hint","id","_ref$isOptional","isOptional","label","name","errorId","useId","hintId","htmlFor","undefined","concat"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGe,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,WAAA,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,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A,CAAA,MAAA,EAAA;AAAMN,IAAAA,SAAS,EAAC,UAAU;AAACuB,IAAAA,EAAE,EAAEO,MAAAA;GAC5BR,EAAAA,IACG,CACP,EACAD,KAAK,iBAAIhB,KAAA,CAAAC,aAAA,CAACR,YAAY,EAAA;AAACyB,IAAAA,EAAE,EAAEK,OAAAA;AAAQ,GAAA,EAAEP,KAAoB,CAAC,eAC3DhB,KAAA,CAAAC,aAAA,CAAA,KAAA,EAAA;AAAKN,IAAAA,SAAS,EAAC,YAAA;AAAY,GAAA,eACzBK,KAAA,CAAAC,aAAA,CAAA,QAAA,EAAAC,QAAA,CAAA;AACE,IAAA,cAAA,EAAcc,KAAK,GAAG,IAAI,GAAGW,SAAU;IACvC,kBAAkBX,EAAAA,KAAK,IAAIC,IAAI,GAAA,EAAA,CAAAW,MAAA,CAAMH,MAAM,OAAAG,MAAA,CAAIL,OAAO,CAAKP,GAAAA,KAAK,GAAGO,OAAO,GAAGN,IAAI,GAAGQ,MAAM,GAAGE,SAAU;AACvGT,IAAAA,EAAE,EAAEA,EAAG;AACPJ,IAAAA,GAAG,EAAEA,GAAAA;AAAI,GAAA,EACLjB,KAAK,CACV,CACE,CACF,CAAC,CAAA;AAEV,CACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/ErrorMessage/ErrorMessage.tsx","../../src/FieldTextInput/FieldTextInput.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/ErrorMessage/ErrorMessage.tsx","../../src/FieldTextInput/FieldTextInput.tsx"],"sourcesContent":["// biome-ignore lint/style/useImportType: following this rule does not work for some reason\nimport * 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","import * as React from 'react';\nimport ErrorMessage from '../ErrorMessage';\n\nexport type FieldTextInputProps<C> = {\n as?: C;\n error?: string;\n hint?: string;\n id?: string;\n isOptional?: boolean;\n label: string;\n};\n\nexport default function FieldTextInput<C extends React.ElementType>({\n as,\n className,\n error,\n hint,\n id,\n isOptional = false,\n label,\n ...props\n}: FieldTextInputProps<C> & React.ComponentPropsWithoutRef<C>) {\n id = id ?? props.name;\n\n const errorId = React.useId();\n const hintId = React.useId();\n\n const InputComponent = as ?? 'input';\n\n return (\n <div className=\"bds-form-group\">\n <label htmlFor={id}>\n {label}\n {isOptional && ' (optional)'}\n </label>\n {hint && (\n <span className=\"bds-hint\" id={hintId}>\n {hint}\n </span>\n )}\n {error && <ErrorMessage id={errorId}>{error}</ErrorMessage>}\n <InputComponent\n aria-invalid={error ? true : undefined}\n aria-describedby={error && hint ? `${hintId} ${errorId}` : error ? errorId : hint ? hintId : undefined}\n className={['bds-text-input', className].filter((x) => x).join(' ')}\n id={id}\n {...props}\n />\n </div>\n );\n}\n"],"names":["ErrorMessage","_ref","className","children","props","_objectWithoutProperties","_excluded","React","createElement","_extends","filter","x","join","xmlns","viewBox","height","width","fill","d","FieldTextInput","_id","as","error","hint","id","_ref$isOptional","isOptional","label","name","errorId","useId","hintId","InputComponent","htmlFor","undefined","concat"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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J,MAAM,OAAAI,MAAA,CAAIN,OAAO,CAAKP,GAAAA,KAAK,GAAGO,OAAO,GAAGN,IAAI,GAAGQ,MAAM,GAAGG,SAAU;IACvGhC,SAAS,EAAE,CAAC,gBAAgB,EAAEA,SAAS,CAAC,CAACQ,MAAM,CAAC,UAACC,CAAC,EAAA;AAAA,MAAA,OAAKA,CAAC,CAAA;AAAA,KAAA,CAAC,CAACC,IAAI,CAAC,GAAG,CAAE;AACpEY,IAAAA,EAAE,EAAEA,EAAAA;GACApB,EAAAA,KAAK,CACV,CACE,CAAC,CAAA;AAEV;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/ErrorMessage/ErrorMessage.tsx","../../src/FieldTextInput/FieldTextInput.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/ErrorMessage/ErrorMessage.tsx","../../src/FieldTextInput/FieldTextInput.tsx"],"sourcesContent":["// biome-ignore lint/style/useImportType: following this rule does not work for some reason\nimport * 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","import * as React from 'react';\nimport ErrorMessage from '../ErrorMessage';\n\nexport type FieldTextInputProps<C> = {\n as?: C;\n error?: string;\n hint?: string;\n id?: string;\n isOptional?: boolean;\n label: string;\n};\n\nexport default function FieldTextInput<C extends React.ElementType>({\n as,\n className,\n error,\n hint,\n id,\n isOptional = false,\n label,\n ...props\n}: FieldTextInputProps<C> & React.ComponentPropsWithoutRef<C>) {\n id = id ?? props.name;\n\n const errorId = React.useId();\n const hintId = React.useId();\n\n const InputComponent = as ?? 'input';\n\n return (\n <div className=\"bds-form-group\">\n <label htmlFor={id}>\n {label}\n {isOptional && ' (optional)'}\n </label>\n {hint && (\n <span className=\"bds-hint\" id={hintId}>\n {hint}\n </span>\n )}\n {error && <ErrorMessage id={errorId}>{error}</ErrorMessage>}\n <InputComponent\n aria-invalid={error ? true : undefined}\n aria-describedby={error && hint ? `${hintId} ${errorId}` : error ? errorId : hint ? hintId : undefined}\n className={['bds-text-input', className].filter((x) => x).join(' ')}\n id={id}\n {...props}\n />\n </div>\n );\n}\n"],"names":["ErrorMessage","_ref","className","children","props","_objectWithoutProperties","_excluded","React","createElement","_extends","filter","x","join","xmlns","viewBox","height","width","fill","d","FieldTextInput","_id","as","error","hint","id","_ref$isOptional","isOptional","label","name","errorId","useId","hintId","InputComponent","htmlFor","undefined","concat"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGe,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,WAAA,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;K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