@jobber/components 6.68.1 → 6.68.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.
@@ -21,12 +21,12 @@ export interface ComboboxProps {
21
21
  /**
22
22
  * Callback function invoked upon the selection of an option. Provides the selected option(s) as an argument.
23
23
  */
24
- readonly onSelect: (selection: ComboboxSelection[]) => void;
24
+ readonly onSelect: (selection: ComboboxOption[]) => void;
25
25
  /**
26
26
  * Callback function invoked upon the selection of all options. Provides the selected option(s) as an argument.
27
27
  * This is only available when `multiSelect` is `true`.
28
28
  */
29
- readonly onSelectAll?: (selection: ComboboxSelection[]) => void;
29
+ readonly onSelectAll?: (selection: ComboboxOption[]) => void;
30
30
  /**
31
31
  * Callback function invoked upon the clearing of all options.
32
32
  * This is only available when `multiSelect` is `true`.
@@ -118,7 +118,6 @@ export interface ComboboxOptionProps {
118
118
  readonly onClick?: (option: ComboboxOption) => void;
119
119
  }
120
120
  export type ComboboxOption = ComboboxOptionProps;
121
- export type ComboboxSelection = Pick<ComboboxOptionProps, "id" | "label">;
122
121
  export interface ComboboxContentProps {
123
122
  /**
124
123
  * The selected options of the Combobox.
@@ -1,3 +1,3 @@
1
1
  export * from "./Combobox";
2
2
  export { ComboboxContextProvider } from "./ComboboxProvider";
3
- export { ComboboxOption, ComboboxCustomActivatorProps, ComboboxSelection, } from "./Combobox.types";
3
+ export { ComboboxOption, ComboboxCustomActivatorProps } from "./Combobox.types";
@@ -138,6 +138,14 @@ function ComboboxContent(props) {
138
138
  const optionsExist = props.options.length > 0;
139
139
  const { onClear, onSelectAll, optionsListRef } = useComboboxContent(props.open, props.selected);
140
140
  const { popperRef, popperStyles, floatingProps, nodeId, parentNodeId } = useComboboxAccessibility(props.handleSelection, props.options, optionsListRef, props.open, props.wrapperRef);
141
+ // options that are passed back to consumers via onSelectAll callback
142
+ // should only contain id and label
143
+ const optionsData = React.useMemo(() => {
144
+ return props.options.map(option => ({
145
+ id: option.id,
146
+ label: option.label,
147
+ }));
148
+ }, [props.options]);
141
149
  const content = (React.createElement("div", Object.assign({ ref: popperRef, id: constants.COMBOBOX_MENU_ID, "data-testid": constants.COMBOBOX_MENU_ID, "data-elevation": "elevated", tabIndex: 0, className: classnames(styles.content, {
142
150
  [styles.hidden]: !props.open,
143
151
  }), style: popperStyles }, floatingProps),
@@ -147,7 +155,7 @@ function ComboboxContent(props) {
147
155
  onClear === null || onClear === void 0 ? void 0 : onClear();
148
156
  }, onSelectAll: () => {
149
157
  props.selectedStateSetter(props.options);
150
- onSelectAll === null || onSelectAll === void 0 ? void 0 : onSelectAll(props.options);
158
+ onSelectAll === null || onSelectAll === void 0 ? void 0 : onSelectAll(optionsData);
151
159
  } })),
152
160
  React.createElement(ComboboxContentList.ComboboxContentList, { multiselect: props.multiselect, options: props.options, selected: props.selected, optionsListRef: optionsListRef, searchValue: props.searchValue, subjectNoun: props.subjectNoun, loading: props.loading, onLoadMore: props.onLoadMore }),
153
161
  props.actionElements && (React.createElement("div", { className: styles.actions, role: "group" }, props.actionElements.map((child, index, childrenArray) => (React.createElement("div", { key: index, className: classnames({
@@ -1,4 +1,4 @@
1
- import React__default, { useContext, useRef, useEffect } from 'react';
1
+ import React__default, { useContext, useRef, useEffect, useMemo } from 'react';
2
2
  import classnames from 'classnames';
3
3
  import { u as useFloatingParentNodeId, a as useFloatingNodeId, b as useFloating, c as autoPlacement, o as offset, s as shift, d as autoUpdate, e as useDismiss, f as useInteractions, F as FloatingTree, g as FloatingNode, h as FloatingPortal } from './floating-ui.react-es.js';
4
4
  import ReactDOM__default from 'react-dom';
@@ -136,6 +136,14 @@ function ComboboxContent(props) {
136
136
  const optionsExist = props.options.length > 0;
137
137
  const { onClear, onSelectAll, optionsListRef } = useComboboxContent(props.open, props.selected);
138
138
  const { popperRef, popperStyles, floatingProps, nodeId, parentNodeId } = useComboboxAccessibility(props.handleSelection, props.options, optionsListRef, props.open, props.wrapperRef);
139
+ // options that are passed back to consumers via onSelectAll callback
140
+ // should only contain id and label
141
+ const optionsData = useMemo(() => {
142
+ return props.options.map(option => ({
143
+ id: option.id,
144
+ label: option.label,
145
+ }));
146
+ }, [props.options]);
139
147
  const content = (React__default.createElement("div", Object.assign({ ref: popperRef, id: COMBOBOX_MENU_ID, "data-testid": COMBOBOX_MENU_ID, "data-elevation": "elevated", tabIndex: 0, className: classnames(styles.content, {
140
148
  [styles.hidden]: !props.open,
141
149
  }), style: popperStyles }, floatingProps),
@@ -145,7 +153,7 @@ function ComboboxContent(props) {
145
153
  onClear === null || onClear === void 0 ? void 0 : onClear();
146
154
  }, onSelectAll: () => {
147
155
  props.selectedStateSetter(props.options);
148
- onSelectAll === null || onSelectAll === void 0 ? void 0 : onSelectAll(props.options);
156
+ onSelectAll === null || onSelectAll === void 0 ? void 0 : onSelectAll(optionsData);
149
157
  } })),
150
158
  React__default.createElement(ComboboxContentList, { multiselect: props.multiselect, options: props.options, selected: props.selected, optionsListRef: optionsListRef, searchValue: props.searchValue, subjectNoun: props.subjectNoun, loading: props.loading, onLoadMore: props.onLoadMore }),
151
159
  props.actionElements && (React__default.createElement("div", { className: styles.actions, role: "group" }, props.actionElements.map((child, index, childrenArray) => (React__default.createElement("div", { key: index, className: classnames({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "6.68.1",
3
+ "version": "6.68.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -542,5 +542,5 @@
542
542
  "> 1%",
543
543
  "IE 10"
544
544
  ],
545
- "gitHead": "984dcaa45ef84984b1989dbd973dd95a7b729f94"
545
+ "gitHead": "2ac0d333a2eef4ee38b49817ff7930a998094645"
546
546
  }