@jobber/components 6.109.2 → 6.109.4

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.
@@ -241,6 +241,24 @@ function createInteractionPointerDownHandler(isHandlingMenuInteractionRef) {
241
241
  function useAutocomplete(props) {
242
242
  const { menu, emptyActions, getOptionLabel: getOptionLabelProp, isOptionEqualToValue, inputValue, onInputChange, value, onChange, multiple, openOnFocus = true, readOnly = false, debounce: debounceMs = 300, } = props;
243
243
  const isHandlingMenuInteractionRef = React.useRef(false);
244
+ const isValidSingleSelection = (v) => {
245
+ if (v && typeof v === "object" && "label" in v && v.label) {
246
+ return true;
247
+ }
248
+ return false;
249
+ };
250
+ const getSingleSelection = (v) => {
251
+ if (isValidSingleSelection(v)) {
252
+ return v;
253
+ }
254
+ return undefined;
255
+ };
256
+ const getFirstItemFromMultiSelection = (v) => {
257
+ if (v && Array.isArray(v)) {
258
+ return v[0];
259
+ }
260
+ return undefined;
261
+ };
244
262
  // TODO: Clean up the types in these refs by enhancing the type system in useCallbackRef
245
263
  const getOptionLabelPropRef = jobberHooks.useCallbackRef((opt) => getOptionLabelProp === null || getOptionLabelProp === void 0 ? void 0 : getOptionLabelProp(opt));
246
264
  const getOptionLabel = React.useCallback((opt) => {
@@ -258,8 +276,7 @@ function useAutocomplete(props) {
258
276
  const current = (_a = value) !== null && _a !== void 0 ? _a : [];
259
277
  return current.some(v => equals(v, opt));
260
278
  }
261
- const current = value;
262
- return current != null ? equals(current, opt) : false;
279
+ return isValidSingleSelection(value) ? equals(value, opt) : false;
263
280
  }, [multiple, value, equals]);
264
281
  const flatInitial = React.useMemo(() => flattenMenu(menu), [menu]);
265
282
  const sections = flatInitial.sections;
@@ -344,7 +361,7 @@ function useAutocomplete(props) {
344
361
  const current = (_a = value) !== null && _a !== void 0 ? _a : [];
345
362
  return Array.isArray(current) && current.length > 0;
346
363
  }
347
- return value != null;
364
+ return isValidSingleSelection(value);
348
365
  }, [multiple, value]);
349
366
  const headerInteractivePersistents = persistentsHeaders.filter(p => Boolean(p.onClick));
350
367
  const footerInteractivePersistents = persistentsFooters.filter(p => Boolean(p.onClick));
@@ -355,8 +372,8 @@ function useAutocomplete(props) {
355
372
  // Compute the currently selected index in the global navigable list (header -> middle -> footer)
356
373
  const selectedIndex = React.useMemo(() => {
357
374
  const selectedValue = multiple
358
- ? value === null || value === void 0 ? void 0 : value[0]
359
- : value;
375
+ ? getFirstItemFromMultiSelection(value)
376
+ : getSingleSelection(value);
360
377
  if (!selectedValue)
361
378
  return null;
362
379
  const middleIndex = findNavigableIndexForValue(renderable, equals, selectedValue);
@@ -442,8 +459,8 @@ function useAutocomplete(props) {
442
459
  if (!hasSelection)
443
460
  return;
444
461
  const selectedValue = multiple
445
- ? value === null || value === void 0 ? void 0 : value[0]
446
- : value;
462
+ ? getFirstItemFromMultiSelection(value)
463
+ : getSingleSelection(value);
447
464
  if (!selectedValue)
448
465
  return;
449
466
  const idx = findNavigableIndexForValue(renderable, equals, selectedValue);
@@ -466,8 +483,8 @@ function useAutocomplete(props) {
466
483
  // - If there is a current selection, highlight that option
467
484
  // - Otherwise, leave the highlight unset (null)
468
485
  const selectedValue = multiple
469
- ? value === null || value === void 0 ? void 0 : value[0]
470
- : value;
486
+ ? getFirstItemFromMultiSelection(value)
487
+ : getSingleSelection(value);
471
488
  if (selectedValue) {
472
489
  const selectedNavigableIndex = findNavigableIndexForValue(renderable, equals, selectedValue);
473
490
  if (selectedNavigableIndex != null) {
@@ -521,8 +538,8 @@ function useAutocomplete(props) {
521
538
  if (props.allowFreeForm === true)
522
539
  return;
523
540
  const selectedValue = multiple
524
- ? value === null || value === void 0 ? void 0 : value[0]
525
- : value;
541
+ ? getFirstItemFromMultiSelection(value)
542
+ : getSingleSelection(value);
526
543
  if (!selectedValue)
527
544
  return;
528
545
  const selectedLabel = getOptionLabel(selectedValue);
@@ -239,6 +239,24 @@ function createInteractionPointerDownHandler(isHandlingMenuInteractionRef) {
239
239
  function useAutocomplete(props) {
240
240
  const { menu, emptyActions, getOptionLabel: getOptionLabelProp, isOptionEqualToValue, inputValue, onInputChange, value, onChange, multiple, openOnFocus = true, readOnly = false, debounce: debounceMs = 300, } = props;
241
241
  const isHandlingMenuInteractionRef = useRef(false);
242
+ const isValidSingleSelection = (v) => {
243
+ if (v && typeof v === "object" && "label" in v && v.label) {
244
+ return true;
245
+ }
246
+ return false;
247
+ };
248
+ const getSingleSelection = (v) => {
249
+ if (isValidSingleSelection(v)) {
250
+ return v;
251
+ }
252
+ return undefined;
253
+ };
254
+ const getFirstItemFromMultiSelection = (v) => {
255
+ if (v && Array.isArray(v)) {
256
+ return v[0];
257
+ }
258
+ return undefined;
259
+ };
242
260
  // TODO: Clean up the types in these refs by enhancing the type system in useCallbackRef
243
261
  const getOptionLabelPropRef = useCallbackRef((opt) => getOptionLabelProp === null || getOptionLabelProp === void 0 ? void 0 : getOptionLabelProp(opt));
244
262
  const getOptionLabel = useCallback((opt) => {
@@ -256,8 +274,7 @@ function useAutocomplete(props) {
256
274
  const current = (_a = value) !== null && _a !== void 0 ? _a : [];
257
275
  return current.some(v => equals(v, opt));
258
276
  }
259
- const current = value;
260
- return current != null ? equals(current, opt) : false;
277
+ return isValidSingleSelection(value) ? equals(value, opt) : false;
261
278
  }, [multiple, value, equals]);
262
279
  const flatInitial = useMemo(() => flattenMenu(menu), [menu]);
263
280
  const sections = flatInitial.sections;
@@ -342,7 +359,7 @@ function useAutocomplete(props) {
342
359
  const current = (_a = value) !== null && _a !== void 0 ? _a : [];
343
360
  return Array.isArray(current) && current.length > 0;
344
361
  }
345
- return value != null;
362
+ return isValidSingleSelection(value);
346
363
  }, [multiple, value]);
347
364
  const headerInteractivePersistents = persistentsHeaders.filter(p => Boolean(p.onClick));
348
365
  const footerInteractivePersistents = persistentsFooters.filter(p => Boolean(p.onClick));
@@ -353,8 +370,8 @@ function useAutocomplete(props) {
353
370
  // Compute the currently selected index in the global navigable list (header -> middle -> footer)
354
371
  const selectedIndex = useMemo(() => {
355
372
  const selectedValue = multiple
356
- ? value === null || value === void 0 ? void 0 : value[0]
357
- : value;
373
+ ? getFirstItemFromMultiSelection(value)
374
+ : getSingleSelection(value);
358
375
  if (!selectedValue)
359
376
  return null;
360
377
  const middleIndex = findNavigableIndexForValue(renderable, equals, selectedValue);
@@ -440,8 +457,8 @@ function useAutocomplete(props) {
440
457
  if (!hasSelection)
441
458
  return;
442
459
  const selectedValue = multiple
443
- ? value === null || value === void 0 ? void 0 : value[0]
444
- : value;
460
+ ? getFirstItemFromMultiSelection(value)
461
+ : getSingleSelection(value);
445
462
  if (!selectedValue)
446
463
  return;
447
464
  const idx = findNavigableIndexForValue(renderable, equals, selectedValue);
@@ -464,8 +481,8 @@ function useAutocomplete(props) {
464
481
  // - If there is a current selection, highlight that option
465
482
  // - Otherwise, leave the highlight unset (null)
466
483
  const selectedValue = multiple
467
- ? value === null || value === void 0 ? void 0 : value[0]
468
- : value;
484
+ ? getFirstItemFromMultiSelection(value)
485
+ : getSingleSelection(value);
469
486
  if (selectedValue) {
470
487
  const selectedNavigableIndex = findNavigableIndexForValue(renderable, equals, selectedValue);
471
488
  if (selectedNavigableIndex != null) {
@@ -519,8 +536,8 @@ function useAutocomplete(props) {
519
536
  if (props.allowFreeForm === true)
520
537
  return;
521
538
  const selectedValue = multiple
522
- ? value === null || value === void 0 ? void 0 : value[0]
523
- : value;
539
+ ? getFirstItemFromMultiSelection(value)
540
+ : getSingleSelection(value);
524
541
  if (!selectedValue)
525
542
  return;
526
543
  const selectedLabel = getOptionLabel(selectedValue);
@@ -1,9 +1,5 @@
1
1
  import React from "react";
2
2
  export interface DataTableFooterProps extends React.HTMLAttributes<HTMLTableSectionElement> {
3
3
  readonly children: React.ReactNode;
4
- /**
5
- * Number of columns to span across. This should match the number of columns in your table.
6
- */
7
- readonly colSpan: number;
8
4
  }
9
- export declare function DataTableFooter({ children, className, colSpan, ...props }: DataTableFooterProps): React.JSX.Element;
5
+ export declare function DataTableFooter({ children, className, ...props }: DataTableFooterProps): React.JSX.Element;
@@ -59,10 +59,8 @@ function DataTableContainer(props) {
59
59
  }
60
60
 
61
61
  function DataTableFooter(_a) {
62
- var { children, className, colSpan } = _a, props = tslib_es6.__rest(_a, ["children", "className", "colSpan"]);
63
- return (React.createElement("tfoot", Object.assign({}, props, { className: classnames(styles.footer, className) }),
64
- React.createElement("tr", null,
65
- React.createElement("td", { colSpan: colSpan }, children))));
62
+ var { children, className } = _a, props = tslib_es6.__rest(_a, ["children", "className"]);
63
+ return (React.createElement("tfoot", Object.assign({}, props, { className: classnames(styles.footer, className) }), children));
66
64
  }
67
65
 
68
66
  function DataTableHeader(props) {
@@ -57,10 +57,8 @@ function DataTableContainer(props) {
57
57
  }
58
58
 
59
59
  function DataTableFooter(_a) {
60
- var { children, className, colSpan } = _a, props = __rest(_a, ["children", "className", "colSpan"]);
61
- return (React__default.createElement("tfoot", Object.assign({}, props, { className: classnames(styles.footer, className) }),
62
- React__default.createElement("tr", null,
63
- React__default.createElement("td", { colSpan: colSpan }, children))));
60
+ var { children, className } = _a, props = __rest(_a, ["children", "className"]);
61
+ return (React__default.createElement("tfoot", Object.assign({}, props, { className: classnames(styles.footer, className) }), children));
64
62
  }
65
63
 
66
64
  function DataTableHeader(props) {
package/dist/styles.css CHANGED
@@ -6724,6 +6724,8 @@ a._7BLGtYNuJOU-.zgRx3ehZ2z8-:hover {
6724
6724
  .thJ-CSoe0ps- {
6725
6725
  padding: 8px 16px;
6726
6726
  padding: var(--space-small) var(--space-base);
6727
+ border-top: 1px solid hsl(200, 13%, 87%);
6728
+ border-top: var(--border-base) solid var(--color-border);
6727
6729
  }
6728
6730
 
6729
6731
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "6.109.2",
3
+ "version": "6.109.4",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -538,5 +538,5 @@
538
538
  "> 1%",
539
539
  "IE 10"
540
540
  ],
541
- "gitHead": "210d6b515ba31e1f62cfc7ef55633d733952cbd2"
541
+ "gitHead": "8774f1709929f5e6dec002492593914bd8cb035d"
542
542
  }