draft-components 4.9.1 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/css/draft-components.css
CHANGED
|
@@ -4243,6 +4243,18 @@
|
|
|
4243
4243
|
margin-bottom: 4px;
|
|
4244
4244
|
}
|
|
4245
4245
|
|
|
4246
|
+
.dc-form-field__label_sr-only {
|
|
4247
|
+
position: absolute;
|
|
4248
|
+
width: 1px;
|
|
4249
|
+
height: 1px;
|
|
4250
|
+
padding: 0;
|
|
4251
|
+
margin: -1px;
|
|
4252
|
+
overflow: hidden;
|
|
4253
|
+
white-space: nowrap;
|
|
4254
|
+
border: 0;
|
|
4255
|
+
clip: rect(0, 0, 0, 0);
|
|
4256
|
+
}
|
|
4257
|
+
|
|
4246
4258
|
.dc-form-field__input,
|
|
4247
4259
|
.dc-form-field__error,
|
|
4248
4260
|
.dc-form-field__hint {
|
|
@@ -10,6 +10,18 @@
|
|
|
10
10
|
margin-bottom: 4px;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
.dc-form-field__label_sr-only {
|
|
14
|
+
position: absolute;
|
|
15
|
+
width: 1px;
|
|
16
|
+
height: 1px;
|
|
17
|
+
padding: 0;
|
|
18
|
+
margin: -1px;
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
white-space: nowrap;
|
|
21
|
+
border: 0;
|
|
22
|
+
clip: rect(0, 0, 0, 0);
|
|
23
|
+
}
|
|
24
|
+
|
|
13
25
|
.dc-form-field__input,
|
|
14
26
|
.dc-form-field__error,
|
|
15
27
|
.dc-form-field__hint {
|
|
@@ -7,6 +7,7 @@ export type FormFieldRender = (props: {
|
|
|
7
7
|
}) => ReactNode;
|
|
8
8
|
type FormFieldHTMLProps = ComponentProps<'div'>;
|
|
9
9
|
type FormFieldBaseProps = {
|
|
10
|
+
srOnlyLabel?: boolean;
|
|
10
11
|
required?: boolean;
|
|
11
12
|
labelFor?: string;
|
|
12
13
|
label?: ReactNode;
|
|
@@ -15,5 +16,5 @@ type FormFieldBaseProps = {
|
|
|
15
16
|
children: ReactNode | FormFieldRender;
|
|
16
17
|
};
|
|
17
18
|
export type FormFieldProps = FormFieldBaseProps & Omit<FormFieldHTMLProps, keyof FormFieldBaseProps>;
|
|
18
|
-
export declare function FormField({ required, labelFor, label, error, hint, className, children, ...props }: FormFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare function FormField({ srOnlyLabel, required, labelFor, label, error, hint, className, children, ...props }: FormFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
19
20
|
export {};
|
|
@@ -3,7 +3,7 @@ import { useId } from 'react';
|
|
|
3
3
|
import { classNames } from '../../lib/react-helpers.js';
|
|
4
4
|
import { Label } from '../label/index.js';
|
|
5
5
|
import { Caption } from '../caption/index.js';
|
|
6
|
-
export function FormField({ required = false, labelFor = '', label, error, hint, className = '', children, ...props }) {
|
|
6
|
+
export function FormField({ srOnlyLabel = false, required = false, labelFor = '', label, error, hint, className = '', children, ...props }) {
|
|
7
7
|
const id = useId();
|
|
8
8
|
const invalid = Boolean(error);
|
|
9
9
|
const inputId = labelFor || `${id}-input`;
|
|
@@ -33,7 +33,7 @@ export function FormField({ required = false, labelFor = '', label, error, hint,
|
|
|
33
33
|
inputElement = children;
|
|
34
34
|
}
|
|
35
35
|
return (_jsxs("div", { ...props, className: classNames('dc-form-field', className), children: [label
|
|
36
|
-
? (_jsx(Label, { className:
|
|
36
|
+
? (_jsx(Label, { className: classNames('dc-form-field__label', srOnlyLabel && 'dc-form-field__label_sr-only'), required: required, htmlFor: inputId, children: label }))
|
|
37
37
|
: null, _jsx("div", { className: "dc-form-field__input", children: inputElement }), errorElement, hintElement] }));
|
|
38
38
|
}
|
|
39
39
|
function ExclamationTriangleIcon(props) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-field.js","sourceRoot":"","sources":["../../../src/components/form-field/form-field.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAuC,KAAK,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