@homebound/beam 2.262.0 → 2.264.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.
@@ -7,5 +7,5 @@ interface MenuItemProps {
7
7
  onClose: VoidFunction;
8
8
  contrast: boolean;
9
9
  }
10
- export declare function MenuItemImpl(props: MenuItemProps): import("@emotion/react/jsx-runtime").JSX.Element;
10
+ export declare function MenuItemImpl(props: MenuItemProps): import("@emotion/react/jsx-runtime").JSX.Element | null;
11
11
  export {};
@@ -15,6 +15,9 @@ const defaultTestId_1 = require("../../utils/defaultTestId");
15
15
  function MenuItemImpl(props) {
16
16
  const { item, state, onClose, contrast } = props;
17
17
  const menuItem = item.value;
18
+ if (!menuItem) {
19
+ return null;
20
+ }
18
21
  const { disabled, onClick, label, destructive } = menuItem;
19
22
  const isDisabled = Boolean(disabled);
20
23
  const isSelected = state.selectionManager.selectedKeys.has(label);
@@ -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.$, "aria-label": label, children: [(0, jsx_runtime_1.jsx)(react_aria_1.VisuallyHidden, { children: (0, jsx_runtime_1.jsx)("input", { ref: ref, ...(0, react_aria_1.mergeProps)(inputProps, focusProps), ...tid }) }), (0, jsx_runtime_1.jsx)("span", { ...hoverProps, css: {
26
+ .if(isDisabled).cursorNotAllowed.$, "aria-label": label, children: [(0, jsx_runtime_1.jsx)(react_aria_1.VisuallyHidden, { children: (0, jsx_runtime_1.jsx)("input", { ref: ref, ...(0, react_aria_1.mergeProps)(inputProps, focusProps), ...tid, "data-indeterminate": isIndeterminate }) }), (0, jsx_runtime_1.jsx)("span", { ...hoverProps, css: {
27
27
  ...baseStyles,
28
28
  ...(((isSelected && !isDisabled) || isIndeterminate) && filledBoxStyles),
29
29
  ...(((isSelected && !isDisabled) || isIndeterminate) && isHovered && filledBoxHoverStyles),
@@ -24,9 +24,9 @@ function DateFieldBase(props) {
24
24
  const inputWrapRef = (0, react_1.useRef)(null);
25
25
  const buttonRef = (0, react_1.useRef)(null);
26
26
  const overlayRef = (0, react_1.useRef)(null);
27
- // Local focus state to conditionally call onBlur when the date picker closes.
27
+ // Local focus ref to conditionally call onBlur when the date picker closes. Using a ref instead of a state to have a reliable value between renders
28
28
  // E.g. If the picker closes due to focus going back to the input field then don't call onBlur. Also used to avoid updating WIP values
29
- const [isFocused, setIsFocused] = (0, react_1.useState)(false);
29
+ const isFocused = (0, react_1.useRef)(false);
30
30
  const dateFormat = (0, utils_1.getDateFormat)(format);
31
31
  // The `wipValue` allows the "range" mode to set the value to `undefined`, even if the `onChange` response cannot be undefined.
32
32
  // This makes working within the DateRangePicker much more user friendly.
@@ -45,8 +45,9 @@ function DateFieldBase(props) {
45
45
  };
46
46
  const state = (0, react_stately_1.useOverlayTriggerState)({
47
47
  onOpenChange: (isOpen) => {
48
- // Handles calling `onBlur` for the case where the user interacts with the overlay, removing focus from the input field, and eventually closes the overlay (whether clicking away, or selecting a date)
49
- if (!isOpen && !isFocused) {
48
+ // Handles avoiding calling `onBlur` for the case where the user closes the overlay by changing the DateField input value (TextFieldBase.onChange calls state.close()).
49
+ // Calls `onBlur` for the case where the user interacts with the overlay (!isFocused) and eventually closes the overlay (whether clicking away, or selecting a date) as focus is not returned to the field.
50
+ if (!isOpen && !isFocused.current) {
50
51
  (0, utils_2.maybeCall)(onBlur);
51
52
  }
52
53
  },
@@ -57,8 +58,8 @@ function DateFieldBase(props) {
57
58
  onFocus: () => {
58
59
  var _a;
59
60
  // Open overlay on focus of the input.
61
+ isFocused.current = true;
60
62
  state.open();
61
- setIsFocused(true);
62
63
  (0, utils_2.maybeCall)(onFocus);
63
64
  if (wipValue && dateFormat !== utils_1.dateFormats.short) {
64
65
  // When focused, change to use the "short" date format, as it is simpler to update by hand and parse.
@@ -69,7 +70,7 @@ function DateFieldBase(props) {
69
70
  },
70
71
  onBlur: (e) => {
71
72
  var _a, _b;
72
- setIsFocused(false);
73
+ isFocused.current = false;
73
74
  // If we are interacting any other part of `inputWrap` ref (such as the calendar button) return early as clicking anywhere within there will push focus to the input field.
74
75
  // Or if interacting with the DatePicker then also return early. The overlay will handle calling `onBlur` once it closes.
75
76
  if ((inputWrapRef.current && inputWrapRef.current.contains(e.relatedTarget)) ||
@@ -89,7 +90,10 @@ function DateFieldBase(props) {
89
90
  setInputValue((_b = (isRangeMode ? (0, utils_1.formatDateRange)(props.value, dateFormat) : (0, utils_1.formatDate)(props.value, dateFormat))) !== null && _b !== void 0 ? _b : "");
90
91
  }
91
92
  state.close();
92
- (0, utils_2.maybeCall)(onBlur);
93
+ // Only call `onBlur` if the overlay is closed. In other cases, the overlay's `onOpenChange` will handling calling `onBlur` when closing and the focus is not still on the input.
94
+ if (!state.isOpen) {
95
+ (0, utils_2.maybeCall)(onBlur);
96
+ }
93
97
  },
94
98
  onKeyDown: (e) => {
95
99
  var _a;
@@ -121,7 +125,7 @@ function DateFieldBase(props) {
121
125
  (0, react_1.useEffect)(() => {
122
126
  var _a;
123
127
  // Avoid updating any WIP values.
124
- if (!isFocused && !state.isOpen) {
128
+ if (!isFocused.current && !state.isOpen) {
125
129
  setWipValue(value);
126
130
  setInputValue((_a = (isRangeMode ? (0, utils_1.formatDateRange)(props.value, dateFormat) : (0, utils_1.formatDate)(props.value, dateFormat))) !== null && _a !== void 0 ? _a : "");
127
131
  }
@@ -36,7 +36,9 @@ function SelectField(props) {
36
36
  },
37
37
  // Read Only does not apply to `select` fields, instead we'll add in disabled for tests to verify.
38
38
  disabled: !!(disabled || readOnly), "data-error": !!errorMsg, "data-errormsg": errorMsg, "data-readonly": readOnly, children: [(0, jsx_runtime_1.jsx)("option", { disabled: true, value: "" }), options.map((option, i) => {
39
- return ((0, jsx_runtime_1.jsx)("option", { value: `${getOptionValue(option)}`, disabled: disabledOptions.includes(getOptionValue(option)), children: getOptionLabel(option) }, i));
39
+ return ((0, jsx_runtime_1.jsx)("option", { value: `${getOptionValue(option)}`, disabled: disabledOptions.some((dOption) => typeof dOption === "object"
40
+ ? dOption.value === getOptionValue(option)
41
+ : dOption === getOptionValue(option)), children: getOptionLabel(option) }, i));
40
42
  })] }), helperText && (0, jsx_runtime_1.jsx)("div", { ...tid.helperText, children: helperText })] }));
41
43
  }
42
44
  exports.SelectField = SelectField;
@@ -37,6 +37,9 @@ function toGroupState(values, onChange) {
37
37
  toggleValue: (value) => (values.includes(value) ? addValue(value) : removeValue(value)),
38
38
  isDisabled: false,
39
39
  isReadOnly: false,
40
+ // We do not use the validation state, as our Switch groups do not support error states. However, this field is required by the `CheckboxGroupState` so we need to include it.
41
+ // If we ever update our SwitchGroup component to support error states, we'll need to update this.
42
+ validationState: "valid",
40
43
  };
41
44
  }
42
45
  exports.toGroupState = toGroupState;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.262.0",
3
+ "version": "2.264.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -43,12 +43,12 @@
43
43
  "fast-deep-equal": "^3.1.3",
44
44
  "framer-motion": "^9.0.4",
45
45
  "memoize-one": "^5.2.1",
46
- "react-aria": "^3.18.0",
46
+ "react-aria": "^3.24.0",
47
47
  "react-day-picker": "8.0.7",
48
48
  "react-popper": "^2.3.0",
49
49
  "react-router": "^5.3.4",
50
50
  "react-router-dom": "^5.3.4",
51
- "react-stately": "^3.16.0",
51
+ "react-stately": "^3.22.0",
52
52
  "react-virtuoso": "2.10.2",
53
53
  "tributejs": "^5.1.3",
54
54
  "trix": "^1.3.1",