@homebound/beam 2.96.1 → 2.96.2
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FieldState } from "@homebound/form-state";
|
|
2
2
|
import { CheckboxProps } from "../inputs";
|
|
3
|
-
export declare type BoundCheckboxFieldProps = Omit<CheckboxProps, "values" | "onChange" | "label"
|
|
3
|
+
export declare type BoundCheckboxFieldProps = Omit<CheckboxProps, "values" | "onChange" | "label"> & {
|
|
4
4
|
field: FieldState<any, boolean | null | undefined>;
|
|
5
5
|
/** Make optional so that callers can override if they want to. */
|
|
6
6
|
onChange?: (values: boolean) => void;
|
|
@@ -8,7 +8,7 @@ const utils_1 = require("../utils");
|
|
|
8
8
|
const defaultLabel_1 = require("../utils/defaultLabel");
|
|
9
9
|
/** Wraps `Checkbox` and binds it to a form field. */
|
|
10
10
|
function BoundCheckboxField(props) {
|
|
11
|
-
const { field, onChange = (value) => field.set(value), label = (0, defaultLabel_1.defaultLabel)(field.key), ...others } = props;
|
|
11
|
+
const { field, onChange = (value) => field.set(value), label = (0, defaultLabel_1.defaultLabel)(field.key), onFocus, onBlur, ...others } = props;
|
|
12
12
|
const testId = (0, utils_1.useTestIds)(props, field.key);
|
|
13
13
|
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => {
|
|
14
14
|
var _a;
|
|
@@ -16,7 +16,13 @@ function BoundCheckboxField(props) {
|
|
|
16
16
|
// We are triggering blur manually for checkbox fields due to its transactional nature
|
|
17
17
|
onChange(selected);
|
|
18
18
|
field.blur();
|
|
19
|
-
}, errorMsg: field.touched ? field.errors.join(" ") : undefined
|
|
19
|
+
}, errorMsg: field.touched ? field.errors.join(" ") : undefined, onFocus: () => {
|
|
20
|
+
field.focus();
|
|
21
|
+
(0, utils_1.maybeCall)(onFocus);
|
|
22
|
+
}, onBlur: () => {
|
|
23
|
+
field.blur();
|
|
24
|
+
(0, utils_1.maybeCall)(onBlur);
|
|
25
|
+
} }, testId, others), void 0));
|
|
20
26
|
} }, void 0));
|
|
21
27
|
}
|
|
22
28
|
exports.BoundCheckboxField = BoundCheckboxField;
|
|
@@ -14,5 +14,9 @@ export interface CheckboxProps {
|
|
|
14
14
|
selected?: boolean;
|
|
15
15
|
errorMsg?: string;
|
|
16
16
|
helperText?: string | ReactNode;
|
|
17
|
+
/** Callback fired when focus removes from the component */
|
|
18
|
+
onBlur?: () => void;
|
|
19
|
+
/** Callback fired when focus is set to the component */
|
|
20
|
+
onFocus?: () => void;
|
|
17
21
|
}
|
|
18
22
|
export declare function Checkbox(props: CheckboxProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -23,7 +23,7 @@ function CheckboxBase(props) {
|
|
|
23
23
|
.maxw((0, Css_1.px)(320))
|
|
24
24
|
.if(description !== undefined)
|
|
25
25
|
.maxw((0, Css_1.px)(344))
|
|
26
|
-
.if(isDisabled).cursorNotAllowed.$ }, { children: [(0, jsx_runtime_1.jsx)(react_aria_1.VisuallyHidden, { children: (0, jsx_runtime_1.jsx)("input", Object.assign({ ref: ref }, inputProps, focusProps, tid), void 0) }, void 0), (0, jsx_runtime_1.jsx)("span", Object.assign({}, hoverProps, { css: {
|
|
26
|
+
.if(isDisabled).cursorNotAllowed.$ }, { children: [(0, jsx_runtime_1.jsx)(react_aria_1.VisuallyHidden, { children: (0, jsx_runtime_1.jsx)("input", Object.assign({ ref: ref }, (0, react_aria_1.mergeProps)(inputProps, focusProps), tid), void 0) }, void 0), (0, jsx_runtime_1.jsx)("span", Object.assign({}, hoverProps, { css: {
|
|
27
27
|
...baseStyles,
|
|
28
28
|
...((isSelected || isIndeterminate) && filledBoxStyles),
|
|
29
29
|
...((isSelected || isIndeterminate) && isHovered && filledBoxHoverStyles),
|
|
@@ -24,7 +24,7 @@ function SelectField(props) {
|
|
|
24
24
|
},
|
|
25
25
|
// Read Only does not apply to `select` fields, instead we'll add in disabled for tests to verify.
|
|
26
26
|
disabled: !!(disabled || readOnly), "data-error": !!errorMsg, "data-errormsg": errorMsg, "data-readonly": readOnly }, { children: [(0, jsx_runtime_1.jsx)("option", { disabled: true, value: "" }, void 0), options.map((option, i) => {
|
|
27
|
-
return ((0, jsx_runtime_1.jsx)("option", Object.assign({ value: `${getOptionValue(option)}`, disabled: disabledOptions.includes(getOptionValue(option)
|
|
27
|
+
return ((0, jsx_runtime_1.jsx)("option", Object.assign({ value: `${getOptionValue(option)}`, disabled: disabledOptions.includes(getOptionValue(option)) }, { children: getOptionLabel(option) }), i));
|
|
28
28
|
})] }), void 0));
|
|
29
29
|
}
|
|
30
30
|
exports.SelectField = SelectField;
|