@homebound/beam 2.338.0 → 2.340.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.
@@ -5,5 +5,6 @@ export interface DatePickerProps {
5
5
  onSelect: (value: Date) => void;
6
6
  disabledDays?: Matcher | Matcher[];
7
7
  dottedDays?: Matcher[];
8
+ useYearPicker?: boolean;
8
9
  }
9
10
  export declare function DatePicker(props: DatePickerProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -10,9 +10,9 @@ const Css_1 = require("../../../Css");
10
10
  const utils_1 = require("../../../utils");
11
11
  require("./DatePicker.css");
12
12
  function DatePicker(props) {
13
- const { value, onSelect, disabledDays, dottedDays } = props;
13
+ const { value, onSelect, disabledDays, dottedDays, useYearPicker } = props;
14
14
  const tid = (0, utils_1.useTestIds)(props, "datePicker");
15
- return ((0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.dib.bgWhite.xs.$, ...tid, children: (0, jsx_runtime_1.jsx)(react_day_picker_1.DayPicker, { components: { Caption: Header_1.Header, Head: WeekHeader_1.WeekHeader, Day: Day_1.Day },
15
+ return ((0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.dib.bgWhite.xs.$, ...tid, children: (0, jsx_runtime_1.jsx)(react_day_picker_1.DayPicker, { components: { Caption: useYearPicker ? Header_1.YearSkipHeader : Header_1.Header, Head: WeekHeader_1.WeekHeader, Day: Day_1.Day },
16
16
  // DatePicker only allows for a single date to be `selected` (per our props) though DayPicker expects an array of dates
17
17
  selected: value ? [value] : [], defaultMonth: value !== null && value !== void 0 ? value : new Date(), onDayClick: (day, modifiers) => {
18
18
  if (modifiers.disabled)
@@ -33,6 +33,8 @@ export interface DateFieldBaseProps extends Pick<TextFieldBaseProps<Properties>,
33
33
  mode: DateFieldMode;
34
34
  /** Range filters should only allow a full DateRange or nothing */
35
35
  isRangeFilterField?: boolean;
36
+ /** Render header that skips years in addition to months */
37
+ useYearPicker?: boolean;
36
38
  }
37
39
  export interface DateSingleFieldBaseProps extends DateFieldBaseProps {
38
40
  mode: "single";
@@ -18,7 +18,7 @@ function DateFieldBase(props) {
18
18
  var _a;
19
19
  const { label, disabled, required, value, onFocus, onBlur,
20
20
  // Pull `onChange` out of the props, but we're not directly using it. Do not want to keep it in `...others`
21
- onChange: _onChange, errorMsg, helperText, readOnly, format = "short", iconLeft = false, hideCalendarIcon = false, disabledDays, onEnter, defaultOpen, mode, isRangeFilterField = false, ...others } = props;
21
+ onChange: _onChange, errorMsg, helperText, readOnly, format = "short", iconLeft = false, hideCalendarIcon = false, disabledDays, onEnter, defaultOpen, mode, isRangeFilterField = false, useYearPicker = false, ...others } = props;
22
22
  const isRangeMode = mode === "range";
23
23
  const inputRef = (0, react_1.useRef)(null);
24
24
  const inputWrapRef = (0, react_1.useRef)(null);
@@ -169,12 +169,12 @@ function DateFieldBase(props) {
169
169
  // Note: Do not close date range picker on select to allow the user to select multiple dates at a time
170
170
  setInputValue((_a = (0, utils_1.formatDateRange)(dr, utils_1.dateFormats.short)) !== null && _a !== void 0 ? _a : "");
171
171
  onChange(dr);
172
- }, useYearPicker: isRangeFilterField, ...tid.datePicker })) : ((0, jsx_runtime_1.jsx)(internal_1.DatePicker, { value: wipValue, disabledDays: disabledDays, onSelect: (d) => {
172
+ }, useYearPicker: isRangeFilterField || useYearPicker, ...tid.datePicker })) : ((0, jsx_runtime_1.jsx)(internal_1.DatePicker, { value: wipValue, disabledDays: disabledDays, onSelect: (d) => {
173
173
  var _a;
174
174
  state.close();
175
175
  setInputValue((_a = (0, utils_1.formatDate)(d, utils_1.dateFormats.short)) !== null && _a !== void 0 ? _a : "");
176
176
  onChange(d);
177
- }, ...tid.datePicker })) }) }) }))] }));
177
+ }, useYearPicker: useYearPicker, ...tid.datePicker })) }) }) }))] }));
178
178
  }
179
179
  exports.DateFieldBase = DateFieldBase;
180
180
  function isParsedDateValid(d) {
@@ -52,6 +52,7 @@ export interface ComboBoxBaseProps<O, V extends Value> extends BeamFocusableProp
52
52
  unsetLabel?: string;
53
53
  hideErrorMessage?: boolean;
54
54
  multiline?: boolean;
55
+ onSearch?: (search: string) => void;
55
56
  }
56
57
  /**
57
58
  * Provides a non-native select/dropdown widget that allows the user to type to filter the options.
@@ -13,6 +13,7 @@ const ComboBoxInput_1 = require("./ComboBoxInput");
13
13
  const ListBox_1 = require("./ListBox");
14
14
  const Value_1 = require("../Value");
15
15
  const utils_1 = require("../utils");
16
+ const use_debounce_1 = require("use-debounce");
16
17
  /**
17
18
  * Provides a non-native select/dropdown widget that allows the user to type to filter the options.
18
19
  *
@@ -25,7 +26,7 @@ const utils_1 = require("../utils");
25
26
  function ComboBoxBase(props) {
26
27
  var _a, _b, _c, _d, _e;
27
28
  const { fieldProps } = (0, PresentationContext_1.usePresentationContext)();
28
- const { disabled, readOnly, onSelect, options: propOptions, multiselect = false, values: propValues, nothingSelectedText = "", contrast, disabledOptions, borderless, unsetLabel, getOptionLabel: propOptionLabel, getOptionValue: propOptionValue, getOptionMenuLabel: propOptionMenuLabel, fullWidth = (_a = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.fullWidth) !== null && _a !== void 0 ? _a : false, ...otherProps } = props;
29
+ const { disabled, readOnly, onSelect, options: propOptions, multiselect = false, values: propValues, nothingSelectedText = "", contrast, disabledOptions, borderless, unsetLabel, getOptionLabel: propOptionLabel, getOptionValue: propOptionValue, getOptionMenuLabel: propOptionMenuLabel, fullWidth = (_a = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.fullWidth) !== null && _a !== void 0 ? _a : false, onSearch, ...otherProps } = props;
29
30
  const labelStyle = (_c = (_b = otherProps.labelStyle) !== null && _b !== void 0 ? _b : fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.labelStyle) !== null && _c !== void 0 ? _c : "above";
30
31
  // Memoize the callback functions and handle the `unset` option if provided.
31
32
  const getOptionLabel = (0, react_1.useCallback)((o) => (unsetLabel && o === exports.unsetOption ? unsetLabel : propOptionLabel(o)),
@@ -166,8 +167,11 @@ function ComboBoxBase(props) {
166
167
  selectedKeys,
167
168
  onSelectionChange,
168
169
  });
170
+ const [debouncedSearch] = (0, use_debounce_1.useDebounce)(searchValue, 300);
169
171
  // Reset inputValue when closed or selected changes
170
172
  (0, react_1.useEffect)(() => {
173
+ if (debouncedSearch)
174
+ return;
171
175
  if (state.isOpen && multiselect) {
172
176
  // While the multiselect is open, let the user keep typing
173
177
  setFieldState((prevState) => ({
@@ -183,7 +187,11 @@ function ComboBoxBase(props) {
183
187
  inputValue: getInputValue(selectedOptions, getOptionLabel, multiselect, nothingSelectedText, isReadOnly),
184
188
  }));
185
189
  }
186
- }, [state.isOpen, selectedOptions, getOptionLabel, multiselect, nothingSelectedText, isReadOnly]);
190
+ }, [state.isOpen, selectedOptions, getOptionLabel, multiselect, nothingSelectedText, isReadOnly, debouncedSearch]);
191
+ // Call on search callback when the user types in the input field
192
+ (0, react_1.useEffect)(() => {
193
+ onSearch === null || onSearch === void 0 ? void 0 : onSearch(debouncedSearch !== null && debouncedSearch !== void 0 ? debouncedSearch : "");
194
+ }, [onSearch, debouncedSearch]);
187
195
  // For the most part, the returned props contain `aria-*` and `id` attributes for accessibility purposes.
188
196
  const { buttonProps: triggerProps, inputProps, listBoxProps, labelProps, } = (0, react_aria_1.useComboBox)({
189
197
  ...comboBoxProps,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.338.0",
3
+ "version": "2.340.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",