@jobber/components 6.55.0 → 6.56.1

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.
@@ -245,6 +245,11 @@ interface BaseDataListItemActionsProps<T extends DataListObject> {
245
245
  * Callback when an item is clicked.
246
246
  */
247
247
  readonly onClick?: (item: T, event?: React.MouseEvent<HTMLElement>) => void;
248
+ /**
249
+ * Disable the custom context menu. This allows the browser's native context menu to be shown.
250
+ * @default false
251
+ */
252
+ readonly disableContextMenu?: boolean;
248
253
  }
249
254
  export interface DataListBulkActionsProps {
250
255
  /**
@@ -3,4 +3,5 @@ import { DataListActionProps, DataListObject } from "../DataList.types";
3
3
  export declare function useGetItemActions<T extends DataListObject>(item: T): {
4
4
  actions: ReactElement<DataListActionProps<T>>[];
5
5
  hasActions: boolean;
6
+ disableContextMenu: boolean;
6
7
  };
@@ -59,9 +59,11 @@ function DataListItemInternal({ children, item, }) {
59
59
  }
60
60
 
61
61
  function useGetItemActions(item) {
62
+ var _a;
62
63
  const { itemActionComponent } = DataListContext.useDataListContext();
63
64
  const itemActions = (itemActionComponent === null || itemActionComponent === void 0 ? void 0 : itemActionComponent.props.children) || [];
64
65
  const actionsArray = React.Children.toArray(itemActions);
66
+ const disableContextMenu = (_a = itemActionComponent === null || itemActionComponent === void 0 ? void 0 : itemActionComponent.props.disableContextMenu) !== null && _a !== void 0 ? _a : false;
65
67
  const actions = React.useMemo(() => {
66
68
  return actionsArray.filter(action => {
67
69
  if (React.isValidElement(action) && action.props.visible) {
@@ -73,6 +75,7 @@ function useGetItemActions(item) {
73
75
  return {
74
76
  actions: actions,
75
77
  hasActions: Boolean(actions.length),
78
+ disableContextMenu,
76
79
  };
77
80
  }
78
81
 
@@ -81,12 +84,12 @@ function DataListItem({ item, layout, }) {
81
84
  const [showMenu, setShowMenu] = React.useState(false);
82
85
  const [contextPosition, setContextPosition] = React.useState();
83
86
  const generatedItem = React.useMemo(() => DataList_utils.generateListItemElement(item), [item]);
84
- const { actions, hasActions } = useGetItemActions(item);
87
+ const { actions, hasActions, disableContextMenu } = useGetItemActions(item);
85
88
  const isContextMenuVisible = Boolean(contextPosition);
86
89
  const shouldShowContextMenu = showMenu && isContextMenuVisible && hasActions;
87
90
  const shouldShowHoverMenu = showMenu && hasActions && !hasInLayoutActions && !shouldShowContextMenu;
88
91
  return (React.createElement(DataListLayoutContext$1.DataListLayoutActionsContext.Provider, { value: { activeItem: item } },
89
- React.createElement("div", { onMouseEnter: handleShowMenu, onMouseLeave: handleHideMenu, onFocus: handleShowMenu, onBlur: handleHideMenu, onContextMenu: handleContextMenu, className: classnames(DataList_module.styles.listItem, {
92
+ React.createElement("div", { onMouseEnter: handleShowMenu, onMouseLeave: handleHideMenu, onFocus: handleShowMenu, onBlur: handleHideMenu, onContextMenu: disableContextMenu ? undefined : handleContextMenu, className: classnames(DataList_module.styles.listItem, {
90
93
  [DataList_module.styles.active]: showMenu && isContextMenuVisible,
91
94
  }), key: item.id },
92
95
  React.createElement(DataListItemInternal, { item: item },
@@ -57,9 +57,11 @@ function DataListItemInternal({ children, item, }) {
57
57
  }
58
58
 
59
59
  function useGetItemActions(item) {
60
+ var _a;
60
61
  const { itemActionComponent } = useDataListContext();
61
62
  const itemActions = (itemActionComponent === null || itemActionComponent === void 0 ? void 0 : itemActionComponent.props.children) || [];
62
63
  const actionsArray = Children.toArray(itemActions);
64
+ const disableContextMenu = (_a = itemActionComponent === null || itemActionComponent === void 0 ? void 0 : itemActionComponent.props.disableContextMenu) !== null && _a !== void 0 ? _a : false;
63
65
  const actions = useMemo(() => {
64
66
  return actionsArray.filter(action => {
65
67
  if (isValidElement(action) && action.props.visible) {
@@ -71,6 +73,7 @@ function useGetItemActions(item) {
71
73
  return {
72
74
  actions: actions,
73
75
  hasActions: Boolean(actions.length),
76
+ disableContextMenu,
74
77
  };
75
78
  }
76
79
 
@@ -79,12 +82,12 @@ function DataListItem({ item, layout, }) {
79
82
  const [showMenu, setShowMenu] = useState(false);
80
83
  const [contextPosition, setContextPosition] = useState();
81
84
  const generatedItem = useMemo(() => generateListItemElement(item), [item]);
82
- const { actions, hasActions } = useGetItemActions(item);
85
+ const { actions, hasActions, disableContextMenu } = useGetItemActions(item);
83
86
  const isContextMenuVisible = Boolean(contextPosition);
84
87
  const shouldShowContextMenu = showMenu && isContextMenuVisible && hasActions;
85
88
  const shouldShowHoverMenu = showMenu && hasActions && !hasInLayoutActions && !shouldShowContextMenu;
86
89
  return (React__default.createElement(DataListLayoutActionsContext.Provider, { value: { activeItem: item } },
87
- React__default.createElement("div", { onMouseEnter: handleShowMenu, onMouseLeave: handleHideMenu, onFocus: handleShowMenu, onBlur: handleHideMenu, onContextMenu: handleContextMenu, className: classnames(styles.listItem, {
90
+ React__default.createElement("div", { onMouseEnter: handleShowMenu, onMouseLeave: handleHideMenu, onFocus: handleShowMenu, onBlur: handleHideMenu, onContextMenu: disableContextMenu ? undefined : handleContextMenu, className: classnames(styles.listItem, {
88
91
  [styles.active]: showMenu && isContextMenuVisible,
89
92
  }), key: item.id },
90
93
  React__default.createElement(DataListItemInternal, { item: item },
@@ -1,5 +1,5 @@
1
- import React, { ChangeEvent, ReactElement } from "react";
2
- import { ReactDatePickerProps } from "react-datepicker";
1
+ import React, { ChangeEvent, ReactElement, RefObject } from "react";
2
+ import ReactDatePicker, { ReactDatePickerProps } from "react-datepicker";
3
3
  export interface DatePickerActivatorProps extends Pick<ReactDatePickerProps, "value" | "id" | "ariaDescribedBy" | "ariaInvalid" | "ariaLabelledBy" | "ariaRequired"> {
4
4
  readonly activator?: ReactElement | ((props: DatePickerActivatorProps) => ReactElement);
5
5
  readonly fullWidth?: boolean;
@@ -8,5 +8,6 @@ export interface DatePickerActivatorProps extends Pick<ReactDatePickerProps, "va
8
8
  onClick?(): void;
9
9
  onFocus?(): void;
10
10
  onKeyDown?(): void;
11
+ readonly pickerRef: RefObject<ReactDatePicker>;
11
12
  }
12
13
  export declare const DatePickerActivator: React.ForwardRefExoticComponent<DatePickerActivatorProps & React.RefAttributes<HTMLElement>>;
@@ -7317,7 +7317,7 @@ function DatePicker({ onChange, onMonthChange, activator, inline, selected, read
7317
7317
  React.useEffect(focusOnSelectedDate, [open]);
7318
7318
  }
7319
7319
  return (React.createElement("div", { className: wrapperClassName, ref: ref, "data-elevation": "elevated" },
7320
- React.createElement(Ht, { ref: pickerRef, calendarClassName: datePickerClassNames, showPopperArrow: false, selected: selected, inline: inline, disabled: disabled, readOnly: readonly, onChange: handleChange, maxDate: maxDate, preventOpenOnFocus: true, minDate: minDate, useWeekdaysShort: true, customInput: React.createElement(DatePickerActivator, { activator: activator, fullWidth: fullWidth }), renderCustomHeader: props => React.createElement(DatePickerCustomHeader, Object.assign({}, props)), onCalendarOpen: handleCalendarOpen, onCalendarClose: handleCalendarClose, dateFormat: [
7320
+ React.createElement(Ht, { ref: pickerRef, calendarClassName: datePickerClassNames, showPopperArrow: false, selected: selected, inline: inline, disabled: disabled, readOnly: readonly, onChange: handleChange, maxDate: maxDate, preventOpenOnFocus: true, minDate: minDate, useWeekdaysShort: true, customInput: React.createElement(DatePickerActivator, { pickerRef: pickerRef, activator: activator, fullWidth: fullWidth }), renderCustomHeader: props => React.createElement(DatePickerCustomHeader, Object.assign({}, props)), onCalendarOpen: handleCalendarOpen, onCalendarClose: handleCalendarClose, dateFormat: [
7321
7321
  dateFormat,
7322
7322
  "P",
7323
7323
  "PP",
@@ -7368,5 +7368,4 @@ function useEscapeKeyToCloseDatePicker(open, ref) {
7368
7368
  }
7369
7369
 
7370
7370
  exports.DatePicker = DatePicker;
7371
- exports.format = format;
7372
7371
  exports.isValid = isValid;
@@ -7315,7 +7315,7 @@ function DatePicker({ onChange, onMonthChange, activator, inline, selected, read
7315
7315
  useEffect(focusOnSelectedDate, [open]);
7316
7316
  }
7317
7317
  return (React__default.createElement("div", { className: wrapperClassName, ref: ref, "data-elevation": "elevated" },
7318
- React__default.createElement(Ht, { ref: pickerRef, calendarClassName: datePickerClassNames, showPopperArrow: false, selected: selected, inline: inline, disabled: disabled, readOnly: readonly, onChange: handleChange, maxDate: maxDate, preventOpenOnFocus: true, minDate: minDate, useWeekdaysShort: true, customInput: React__default.createElement(DatePickerActivator, { activator: activator, fullWidth: fullWidth }), renderCustomHeader: props => React__default.createElement(DatePickerCustomHeader, Object.assign({}, props)), onCalendarOpen: handleCalendarOpen, onCalendarClose: handleCalendarClose, dateFormat: [
7318
+ React__default.createElement(Ht, { ref: pickerRef, calendarClassName: datePickerClassNames, showPopperArrow: false, selected: selected, inline: inline, disabled: disabled, readOnly: readonly, onChange: handleChange, maxDate: maxDate, preventOpenOnFocus: true, minDate: minDate, useWeekdaysShort: true, customInput: React__default.createElement(DatePickerActivator, { pickerRef: pickerRef, activator: activator, fullWidth: fullWidth }), renderCustomHeader: props => React__default.createElement(DatePickerCustomHeader, Object.assign({}, props)), onCalendarOpen: handleCalendarOpen, onCalendarClose: handleCalendarClose, dateFormat: [
7319
7319
  dateFormat,
7320
7320
  "P",
7321
7321
  "PP",
@@ -7365,4 +7365,4 @@ function useEscapeKeyToCloseDatePicker(open, ref) {
7365
7365
  };
7366
7366
  }
7367
7367
 
7368
- export { DatePicker as D, format as f, isValid as i };
7368
+ export { DatePicker as D, isValid as i };
@@ -10,7 +10,6 @@ require('react-hook-form');
10
10
  require('framer-motion');
11
11
  require('@jobber/design');
12
12
  require('../Button-cjs.js');
13
- var AtlantisContext = require('../AtlantisContext-cjs.js');
14
13
  var InputText_index = require('../InputText/index.cjs');
15
14
  require('../_commonjsHelpers-cjs.js');
16
15
  require('../_baseGet-cjs.js');
@@ -28,6 +27,7 @@ require('react-dom');
28
27
  require('react-popper');
29
28
  require('../useRefocusOnActivator-cjs.js');
30
29
  require('../Typography-cjs.js');
30
+ require('../AtlantisContext-cjs.js');
31
31
  require('../Icon-cjs.js');
32
32
  require('../Text-cjs.js');
33
33
  require('../useFormFieldFocus-cjs.js');
@@ -38,9 +38,8 @@ require('../useSafeLayoutEffect-cjs.js');
38
38
 
39
39
  function InputDate$1(inputProps) {
40
40
  const formFieldActionsRef = React.useRef(null);
41
- const { dateFormat } = AtlantisContext.useAtlantisContext();
42
41
  return (React.createElement(DatePicker.DatePicker, { selected: inputProps.value, onChange: inputProps.onChange, disabled: inputProps.disabled, readonly: inputProps.readonly, fullWidth: !inputProps.inline, minDate: inputProps.minDate, maxDate: inputProps.maxDate, smartAutofocus: false, activator: activatorProps => {
43
- const { onChange, onClick, value } = activatorProps;
42
+ const { onChange, onClick, value, pickerRef } = activatorProps;
44
43
  const newActivatorProps = omit.omit(activatorProps, ["activator"]);
45
44
  const [isFocused, setIsFocused] = React.useState(false);
46
45
  const suffix = inputProps.showIcon !== false
@@ -63,6 +62,7 @@ function InputDate$1(inputProps) {
63
62
  React.createElement(FormField.FormField, Object.assign({}, newActivatorProps, inputProps, { value: showEmptyValueLabel ? inputProps.emptyValueLabel || "" : value, placeholder: inputProps.placeholder, onChange: (_, event) => {
64
63
  onChange && onChange(event);
65
64
  }, onBlur: () => {
65
+ var _a;
66
66
  inputProps.onBlur && inputProps.onBlur();
67
67
  activatorProps.onBlur && activatorProps.onBlur();
68
68
  setIsFocused(false);
@@ -83,12 +83,8 @@ function InputDate$1(inputProps) {
83
83
  */
84
84
  if (inputProps.restoreLastValueOnBlur) {
85
85
  if ((!value || !DatePicker.isValid(value)) && inputProps.value) {
86
- onChange === null || onChange === void 0 ? void 0 : onChange({
87
- // @ts-expect-error -- This is a hack to sync the value back to ReactDatePicker
88
- target: {
89
- value: DatePicker.format(inputProps.value, dateFormat),
90
- },
91
- });
86
+ // @ts-expect-error -- ReactDatePicker types don't include setSelected
87
+ (_a = pickerRef.current) === null || _a === void 0 ? void 0 : _a.setSelected(inputProps.value);
92
88
  }
93
89
  }
94
90
  }, onFocus: () => {
@@ -1,6 +1,6 @@
1
1
  import React__default, { useRef, useState, useEffect, forwardRef } from 'react';
2
2
  import { o as omit } from '../omit-es.js';
3
- import { D as DatePicker, i as isValid, f as format } from '../DatePicker-es.js';
3
+ import { D as DatePicker, i as isValid } from '../DatePicker-es.js';
4
4
  import { k as FormField } from '../FormField-es.js';
5
5
  import 'classnames';
6
6
  import '../tslib.es6-es.js';
@@ -8,7 +8,6 @@ import 'react-hook-form';
8
8
  import 'framer-motion';
9
9
  import '@jobber/design';
10
10
  import '../Button-es.js';
11
- import { u as useAtlantisContext } from '../AtlantisContext-es.js';
12
11
  import { InputText } from '../InputText/index.mjs';
13
12
  import '../_commonjsHelpers-es.js';
14
13
  import '../_baseGet-es.js';
@@ -26,6 +25,7 @@ import 'react-dom';
26
25
  import 'react-popper';
27
26
  import '../useRefocusOnActivator-es.js';
28
27
  import '../Typography-es.js';
28
+ import '../AtlantisContext-es.js';
29
29
  import '../Icon-es.js';
30
30
  import '../Text-es.js';
31
31
  import '../useFormFieldFocus-es.js';
@@ -36,9 +36,8 @@ import '../useSafeLayoutEffect-es.js';
36
36
 
37
37
  function InputDate$1(inputProps) {
38
38
  const formFieldActionsRef = useRef(null);
39
- const { dateFormat } = useAtlantisContext();
40
39
  return (React__default.createElement(DatePicker, { selected: inputProps.value, onChange: inputProps.onChange, disabled: inputProps.disabled, readonly: inputProps.readonly, fullWidth: !inputProps.inline, minDate: inputProps.minDate, maxDate: inputProps.maxDate, smartAutofocus: false, activator: activatorProps => {
41
- const { onChange, onClick, value } = activatorProps;
40
+ const { onChange, onClick, value, pickerRef } = activatorProps;
42
41
  const newActivatorProps = omit(activatorProps, ["activator"]);
43
42
  const [isFocused, setIsFocused] = useState(false);
44
43
  const suffix = inputProps.showIcon !== false
@@ -61,6 +60,7 @@ function InputDate$1(inputProps) {
61
60
  React__default.createElement(FormField, Object.assign({}, newActivatorProps, inputProps, { value: showEmptyValueLabel ? inputProps.emptyValueLabel || "" : value, placeholder: inputProps.placeholder, onChange: (_, event) => {
62
61
  onChange && onChange(event);
63
62
  }, onBlur: () => {
63
+ var _a;
64
64
  inputProps.onBlur && inputProps.onBlur();
65
65
  activatorProps.onBlur && activatorProps.onBlur();
66
66
  setIsFocused(false);
@@ -81,12 +81,8 @@ function InputDate$1(inputProps) {
81
81
  */
82
82
  if (inputProps.restoreLastValueOnBlur) {
83
83
  if ((!value || !isValid(value)) && inputProps.value) {
84
- onChange === null || onChange === void 0 ? void 0 : onChange({
85
- // @ts-expect-error -- This is a hack to sync the value back to ReactDatePicker
86
- target: {
87
- value: format(inputProps.value, dateFormat),
88
- },
89
- });
84
+ // @ts-expect-error -- ReactDatePicker types don't include setSelected
85
+ (_a = pickerRef.current) === null || _a === void 0 ? void 0 : _a.setSelected(inputProps.value);
90
86
  }
91
87
  }
92
88
  }, onFocus: () => {