@homebound/beam 2.135.1 → 2.135.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.
@@ -2,7 +2,7 @@ import { FieldState } from "@homebound/form-state";
2
2
  import { Only } from "../Css";
3
3
  import { TextFieldProps } from "../inputs";
4
4
  import { TextFieldXss } from "../interfaces";
5
- export declare type BoundTextFieldProps<X> = Omit<TextFieldProps<X>, "value" | "onChange" | "onBlur" | "onFocus" | "label"> & {
5
+ export declare type BoundTextFieldProps<X> = Omit<TextFieldProps<X>, "value" | "onChange" | "label"> & {
6
6
  label?: string;
7
7
  field: FieldState<any, string | null | undefined>;
8
8
  onChange?: (value: string | undefined) => void;
@@ -8,9 +8,15 @@ const utils_1 = require("../utils");
8
8
  const defaultLabel_1 = require("../utils/defaultLabel");
9
9
  /** Wraps `TextField` and binds it to a form field. */
10
10
  function BoundTextField(props) {
11
- const { field, readOnly, onChange = (value) => field.set(value), label = (0, defaultLabel_1.defaultLabel)(field.key), onEnter, ...others } = props;
11
+ const { field, readOnly, onBlur, onFocus, onChange = (value) => field.set(value), label = (0, defaultLabel_1.defaultLabel)(field.key), onEnter, ...others } = props;
12
12
  const testId = (0, utils_1.useTestIds)(props, field.key);
13
- return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => ((0, jsx_runtime_1.jsx)(inputs_1.TextField, Object.assign({ label: label, value: field.value || undefined, onChange: onChange, readOnly: readOnly !== null && readOnly !== void 0 ? readOnly : field.readOnly, errorMsg: field.touched ? field.errors.join(" ") : undefined, required: field.required, onBlur: () => field.blur(), onFocus: () => field.focus(), onEnter: () => {
13
+ return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => ((0, jsx_runtime_1.jsx)(inputs_1.TextField, Object.assign({ label: label, value: field.value || undefined, onChange: onChange, readOnly: readOnly !== null && readOnly !== void 0 ? readOnly : field.readOnly, errorMsg: field.touched ? field.errors.join(" ") : undefined, required: field.required, onBlur: () => {
14
+ (0, utils_1.maybeCall)(onBlur);
15
+ field.blur();
16
+ }, onFocus: () => {
17
+ (0, utils_1.maybeCall)(onFocus);
18
+ field.focus();
19
+ }, onEnter: () => {
14
20
  (0, utils_1.maybeCall)(onEnter);
15
21
  field.maybeAutoSave();
16
22
  } }, testId, others), void 0)) }, void 0));
@@ -1,3 +1,3 @@
1
1
  import { PressEvent } from "@react-types/shared";
2
2
  import { HTMLAttributes, ReactNode } from "react";
3
- export declare function getButtonOrLink(content: ReactNode, onClick: ((e: PressEvent) => void) | string, attrs: HTMLAttributes<HTMLButtonElement | HTMLAnchorElement>, openInNew?: boolean, downloadLink?: boolean): JSX.Element;
3
+ export declare function getButtonOrLink(content: ReactNode, onClick: ((e: PressEvent) => void) | VoidFunction | string | undefined, attrs: HTMLAttributes<HTMLButtonElement | HTMLAnchorElement>, openInNew?: boolean, downloadLink?: boolean): JSX.Element;
@@ -4,7 +4,12 @@ exports.getButtonOrLink = void 0;
4
4
  const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
5
  const react_router_dom_1 = require("react-router-dom");
6
6
  const index_1 = require("./index");
7
- function getButtonOrLink(content, onClick, attrs, openInNew = false, downloadLink = false) {
8
- return typeof onClick === "string" ? ((0, index_1.isAbsoluteUrl)(onClick) || openInNew || downloadLink ? ((0, jsx_runtime_1.jsx)("a", Object.assign({}, attrs, { href: onClick }, (downloadLink ? { download: "" } : { target: "_blank", rel: "noreferrer noopener" }), { children: content }), void 0)) : ((0, jsx_runtime_1.jsx)(react_router_dom_1.Link, Object.assign({}, attrs, { to: onClick }, { children: content }), void 0))) : ((0, jsx_runtime_1.jsx)("button", Object.assign({}, attrs, { children: content }), void 0));
7
+ function getButtonOrLink(content,
8
+ // PressEvent set by React-Aria's `useButton`.
9
+ onClick, attrs, openInNew = false, downloadLink = false) {
10
+ return typeof onClick === "string" ? ((0, index_1.isAbsoluteUrl)(onClick) || openInNew || downloadLink ? ((0, jsx_runtime_1.jsx)("a", Object.assign({}, attrs, { href: onClick }, (downloadLink ? { download: "" } : { target: "_blank", rel: "noreferrer noopener" }), { children: content }), void 0)) : ((0, jsx_runtime_1.jsx)(react_router_dom_1.Link, Object.assign({}, attrs, { to: onClick }, { children: content }), void 0))) : (
11
+ // Cast `onClick` as VoidFunction this is the type if will be if not overwritten by `attrs` (which happens via Button.tsx)
12
+ // Type `(e: PressEvent) => {}` is only used but Button.tsx, which passes the `onClick` prop as part of the `attrs`.
13
+ (0, jsx_runtime_1.jsx)("button", Object.assign({ onClick: onClick }, attrs, { children: content }), void 0));
9
14
  }
10
15
  exports.getButtonOrLink = getButtonOrLink;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.135.1",
3
+ "version": "2.135.2",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",