@bitrise/bitkit-v2 0.3.309 → 0.3.310
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.
|
@@ -7,6 +7,12 @@ export interface BitkitFieldProps extends Omit<Field.RootProps, 'disabled' | 'in
|
|
|
7
7
|
errorText?: ReactNode;
|
|
8
8
|
helperText?: ReactNode;
|
|
9
9
|
label?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Keep the label in the accessibility tree (associated with the control) but hide it visually.
|
|
12
|
+
* For fields whose purpose is already visually obvious — e.g. a search input with a magnifier icon.
|
|
13
|
+
* Badge, counter and tooltip are omitted in this mode, since they are purely visual.
|
|
14
|
+
*/
|
|
15
|
+
labelHidden?: boolean;
|
|
10
16
|
optional?: boolean;
|
|
11
17
|
state?: 'disabled' | 'error' | 'readOnly' | 'warning';
|
|
12
18
|
tooltip?: string;
|
|
@@ -2,10 +2,26 @@ import BitkitLabel from "../BitkitLabel/BitkitLabel.js";
|
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { Field } from "@chakra-ui/react/field";
|
|
5
|
+
import { VisuallyHidden } from "@chakra-ui/react/visually-hidden";
|
|
5
6
|
//#region lib/components/BitkitField/BitkitField.tsx
|
|
6
7
|
var BitkitField = forwardRef((props, ref) => {
|
|
7
|
-
const { badge, counterText, children, errorText, helperText, label, optional, state, tooltip, warningText, ...rest } = props;
|
|
8
|
+
const { badge, counterText, children, errorText, helperText, label, labelHidden, optional, state, tooltip, warningText, ...rest } = props;
|
|
8
9
|
const isInvalid = state === "error" || !!errorText;
|
|
10
|
+
let labelNode = null;
|
|
11
|
+
if (labelHidden) labelNode = label ? /* @__PURE__ */ jsx(VisuallyHidden, {
|
|
12
|
+
asChild: true,
|
|
13
|
+
children: /* @__PURE__ */ jsx(Field.Label, { children: label })
|
|
14
|
+
}) : null;
|
|
15
|
+
else if (label || badge || counterText) labelNode = /* @__PURE__ */ jsx(Field.Label, {
|
|
16
|
+
asChild: true,
|
|
17
|
+
children: /* @__PURE__ */ jsx(BitkitLabel, {
|
|
18
|
+
badge,
|
|
19
|
+
counterText,
|
|
20
|
+
optional,
|
|
21
|
+
tooltip,
|
|
22
|
+
children: label
|
|
23
|
+
})
|
|
24
|
+
});
|
|
9
25
|
return /* @__PURE__ */ jsxs(Field.Root, {
|
|
10
26
|
disabled: state === "disabled",
|
|
11
27
|
invalid: isInvalid,
|
|
@@ -14,16 +30,7 @@ var BitkitField = forwardRef((props, ref) => {
|
|
|
14
30
|
ref,
|
|
15
31
|
...rest,
|
|
16
32
|
children: [
|
|
17
|
-
|
|
18
|
-
asChild: true,
|
|
19
|
-
children: /* @__PURE__ */ jsx(BitkitLabel, {
|
|
20
|
-
badge,
|
|
21
|
-
counterText,
|
|
22
|
-
optional,
|
|
23
|
-
tooltip,
|
|
24
|
-
children: label
|
|
25
|
-
})
|
|
26
|
-
}) : null,
|
|
33
|
+
labelNode,
|
|
27
34
|
children,
|
|
28
35
|
!!helperText && !errorText && !warningText && /* @__PURE__ */ jsx(Field.HelperText, { children: helperText }),
|
|
29
36
|
!!warningText && !errorText && /* @__PURE__ */ jsx(Field.HelperText, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitkitField.js","names":[],"sources":["../../../lib/components/BitkitField/BitkitField.tsx"],"sourcesContent":["import { Field } from '@chakra-ui/react/field';\nimport { forwardRef, type ReactNode } from 'react';\n\nimport BitkitLabel from '../BitkitLabel/BitkitLabel';\n\nexport interface BitkitFieldProps extends Omit<Field.RootProps, 'disabled' | 'invalid' | 'readOnly'> {\n badge?: ReactNode;\n children: ReactNode;\n counterText?: string;\n errorText?: ReactNode;\n helperText?: ReactNode;\n label?: string;\n optional?: boolean;\n state?: 'disabled' | 'error' | 'readOnly' | 'warning';\n tooltip?: string;\n warningText?: ReactNode;\n}\n\nconst BitkitField = forwardRef<HTMLDivElement, BitkitFieldProps>((props, ref) => {\n const {
|
|
1
|
+
{"version":3,"file":"BitkitField.js","names":[],"sources":["../../../lib/components/BitkitField/BitkitField.tsx"],"sourcesContent":["import { Field } from '@chakra-ui/react/field';\nimport { VisuallyHidden } from '@chakra-ui/react/visually-hidden';\nimport { forwardRef, type ReactNode } from 'react';\n\nimport BitkitLabel from '../BitkitLabel/BitkitLabel';\n\nexport interface BitkitFieldProps extends Omit<Field.RootProps, 'disabled' | 'invalid' | 'readOnly'> {\n badge?: ReactNode;\n children: ReactNode;\n counterText?: string;\n errorText?: ReactNode;\n helperText?: ReactNode;\n label?: string;\n /**\n * Keep the label in the accessibility tree (associated with the control) but hide it visually.\n * For fields whose purpose is already visually obvious — e.g. a search input with a magnifier icon.\n * Badge, counter and tooltip are omitted in this mode, since they are purely visual.\n */\n labelHidden?: boolean;\n optional?: boolean;\n state?: 'disabled' | 'error' | 'readOnly' | 'warning';\n tooltip?: string;\n warningText?: ReactNode;\n}\n\nconst BitkitField = forwardRef<HTMLDivElement, BitkitFieldProps>((props, ref) => {\n const {\n badge,\n counterText,\n children,\n errorText,\n helperText,\n label,\n labelHidden,\n optional,\n state,\n tooltip,\n warningText,\n ...rest\n } = props;\n\n const isInvalid = state === 'error' || !!errorText;\n\n let labelNode: ReactNode = null;\n if (labelHidden) {\n // Field.Label still wires `htmlFor` to the control; VisuallyHidden only strips it from view.\n labelNode = label ? (\n <VisuallyHidden asChild>\n <Field.Label>{label}</Field.Label>\n </VisuallyHidden>\n ) : null;\n } else if (label || badge || counterText) {\n labelNode = (\n <Field.Label asChild>\n <BitkitLabel badge={badge} counterText={counterText} optional={optional} tooltip={tooltip}>\n {label}\n </BitkitLabel>\n </Field.Label>\n );\n }\n\n return (\n <Field.Root\n disabled={state === 'disabled'}\n invalid={isInvalid}\n readOnly={state === 'readOnly'}\n required={!optional}\n ref={ref}\n {...rest}\n >\n {labelNode}\n {children}\n {!!helperText && !errorText && !warningText && <Field.HelperText>{helperText}</Field.HelperText>}\n {!!warningText && !errorText && <Field.HelperText color=\"text/body\">{warningText}</Field.HelperText>}\n {!!errorText && <Field.ErrorText>{errorText}</Field.ErrorText>}\n </Field.Root>\n );\n});\n\nBitkitField.displayName = 'BitkitField';\n\nexport default BitkitField;\n"],"mappings":";;;;;;AAyBA,IAAM,cAAc,YAA8C,OAAO,QAAQ;CAC/E,MAAM,EACJ,OACA,aACA,UACA,WACA,YACA,OACA,aACA,UACA,OACA,SACA,aACA,GAAG,SACD;CAEJ,MAAM,YAAY,UAAU,WAAW,CAAC,CAAC;CAEzC,IAAI,YAAuB;CAC3B,IAAI,aAEF,YAAY,QACV,oBAAC,gBAAD;EAAgB,SAAA;YACd,oBAAC,MAAM,OAAP,EAAA,UAAc,MAAmB,CAAA;CACnB,CAAA,IACd;MACC,IAAI,SAAS,SAAS,aAC3B,YACE,oBAAC,MAAM,OAAP;EAAa,SAAA;YACX,oBAAC,aAAD;GAAoB;GAAoB;GAAuB;GAAmB;aAC/E;EACU,CAAA;CACF,CAAA;CAIjB,OACE,qBAAC,MAAM,MAAP;EACE,UAAU,UAAU;EACpB,SAAS;EACT,UAAU,UAAU;EACpB,UAAU,CAAC;EACN;EACL,GAAI;YANN;GAQG;GACA;GACA,CAAC,CAAC,cAAc,CAAC,aAAa,CAAC,eAAe,oBAAC,MAAM,YAAP,EAAA,UAAmB,WAA6B,CAAA;GAC9F,CAAC,CAAC,eAAe,CAAC,aAAa,oBAAC,MAAM,YAAP;IAAkB,OAAM;cAAa;GAA8B,CAAA;GAClG,CAAC,CAAC,aAAa,oBAAC,MAAM,WAAP,EAAA,UAAkB,UAA2B,CAAA;EACnD;;AAEhB,CAAC;AAED,YAAY,cAAc"}
|