@jobber/components 4.87.7-JOB-91526-.6 → 4.87.7

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var DatePicker = require('../DatePicker-b584d1e9.js');
5
+ var DatePicker = require('../DatePicker-dd9173c7.js');
6
6
  require('react');
7
7
  require('classnames');
8
8
  require('react-datepicker');
@@ -14,7 +14,6 @@ require('react-router-dom');
14
14
  require('../Icon-405a216c.js');
15
15
  require('@jobber/design');
16
16
  require('lodash/omit');
17
- require('../AtlantisContext-306beade.js');
18
17
 
19
18
 
20
19
 
@@ -8,7 +8,6 @@ var styleInject_es = require('./style-inject.es-9d2f5f4e.js');
8
8
  var Typography = require('./Typography-e2a23b7e.js');
9
9
  var Button = require('./Button-6b922fc1.js');
10
10
  var omit = require('lodash/omit');
11
- var AtlantisContext = require('./AtlantisContext-306beade.js');
12
11
 
13
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
13
 
@@ -66,11 +65,9 @@ function useFocusOnSelectedDate() {
66
65
  return { ref, focusOnSelectedDate };
67
66
  }
68
67
 
69
- /*eslint max-statements: ["error", 13]*/
70
68
  function DatePicker({ onChange, onMonthChange, activator, inline, selected, readonly = false, disabled = false, fullWidth = false, smartAutofocus = true, maxDate, minDate, highlightDates, }) {
71
69
  const { ref, focusOnSelectedDate } = useFocusOnSelectedDate();
72
70
  const [open, setOpen] = React.useState(false);
73
- const { dateFormat } = AtlantisContext.useAtlantisContext();
74
71
  const wrapperClassName = classnames__default["default"](styles.datePickerWrapper, {
75
72
  // react-datepicker uses this class name to not close the date picker when
76
73
  // the activator is clicked
@@ -91,14 +88,7 @@ function DatePicker({ onChange, onMonthChange, activator, inline, selected, read
91
88
  React.useEffect(focusOnSelectedDate, [open]);
92
89
  }
93
90
  return (React__default["default"].createElement("div", { className: wrapperClassName, ref: ref },
94
- React__default["default"].createElement(ReactDatePicker__default["default"], { 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["default"].createElement(DatePickerActivator, { activator: activator, fullWidth: fullWidth }), renderCustomHeader: props => React__default["default"].createElement(DatePickerCustomHeader, Object.assign({}, props)), onCalendarOpen: handleCalendarOpen, onCalendarClose: handleCalendarClose, dateFormat: [
95
- dateFormat,
96
- "P",
97
- "PP",
98
- "PPP",
99
- "MMM dd yyyy",
100
- "MMMM dd yyyy",
101
- ], highlightDates: highlightDates, onMonthChange: onMonthChange })));
91
+ React__default["default"].createElement(ReactDatePicker__default["default"], { 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["default"].createElement(DatePickerActivator, { activator: activator, fullWidth: fullWidth }), renderCustomHeader: props => React__default["default"].createElement(DatePickerCustomHeader, Object.assign({}, props)), onCalendarOpen: handleCalendarOpen, onCalendarClose: handleCalendarClose, dateFormat: ["P", "PP", "PPP", "MMM dd yyyy", "MMMM dd yyyy"], highlightDates: highlightDates, onMonthChange: onMonthChange })));
102
92
  /**
103
93
  * The onChange callback on ReactDatePicker returns a Date and an Event, but
104
94
  * the onChange in our interface only provides the Date. Simplifying the code
@@ -15,15 +15,6 @@ interface InputDateProps extends Omit<CommonFormFieldProps, "clearable">, Pick<F
15
15
  * The minimum selectable date.
16
16
  */
17
17
  readonly minDate?: Date;
18
- /**
19
- * Whether to show the calendar icon
20
- * @default true
21
- */
22
- readonly showIcon?: boolean;
23
- /**
24
- * Text to display instead of a date value
25
- */
26
- readonly emptyValuePlaceholder?: string;
27
18
  }
28
19
  export declare function InputDate(inputProps: InputDateProps): JSX.Element;
29
20
  export {};
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var omit = require('lodash/omit');
6
6
  var React = require('react');
7
7
  var FormField = require('../FormField-3ec1c85d.js');
8
- var DatePicker = require('../DatePicker-b584d1e9.js');
8
+ var DatePicker = require('../DatePicker-dd9173c7.js');
9
9
  require('../tslib.es6-754e2961.js');
10
10
  require('react-hook-form');
11
11
  require('../style-inject.es-9d2f5f4e.js');
@@ -22,7 +22,6 @@ require('framer-motion');
22
22
  require('../Spinner-9d8fc7ff.js');
23
23
  require('react-datepicker');
24
24
  require('@jobber/hooks/useRefocusOnActivator');
25
- require('../AtlantisContext-306beade.js');
26
25
 
27
26
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
28
27
 
@@ -35,32 +34,22 @@ function InputDate(inputProps) {
35
34
  var _a;
36
35
  const { onChange, onClick, value } = activatorProps;
37
36
  const newActivatorProps = omit__default["default"](activatorProps, ["activator"]);
38
- const suffix = inputProps.showIcon !== false
39
- ? {
40
- icon: "calendar",
41
- ariaLabel: "Show calendar",
42
- onClick: onClick && onClick,
43
- }
44
- : {};
37
+ const suffix = Object.assign({ icon: "calendar" }, (onClick && {
38
+ onClick: onClick,
39
+ ariaLabel: "Show calendar",
40
+ }));
45
41
  // Set form field to formatted date string immediately, to avoid validations
46
42
  // triggering incorrectly when it blurs (to handle the datepicker UI click)
47
43
  value && ((_a = formFieldActionsRef.current) === null || _a === void 0 ? void 0 : _a.setValue(value));
48
- const _value = value ? value : inputProps.emptyValuePlaceholder;
49
44
  return (
50
45
  // We prevent the picker from opening on focus for keyboard navigation, so to maintain a good UX for mouse users we want to open the picker on click
51
46
  React__default["default"].createElement("div", { onClick: onClick },
52
- React__default["default"].createElement(FormField.FormField, Object.assign({}, newActivatorProps, inputProps, { value: _value, onChange: (_, event) => onChange && onChange(event), onBlur: () => {
47
+ React__default["default"].createElement(FormField.FormField, Object.assign({}, newActivatorProps, inputProps, { value: value, onChange: (_, event) => onChange && onChange(event), onBlur: () => {
53
48
  inputProps.onBlur && inputProps.onBlur();
54
49
  activatorProps.onBlur && activatorProps.onBlur();
55
50
  }, onFocus: () => {
56
51
  inputProps.onFocus && inputProps.onFocus();
57
52
  activatorProps.onFocus && activatorProps.onFocus();
58
- }, onKeyUp: event => {
59
- var _a;
60
- if (inputProps.showIcon === false &&
61
- event.key === "ArrowDown") {
62
- (_a = activatorProps.onClick) === null || _a === void 0 ? void 0 : _a.call(activatorProps);
63
- }
64
53
  }, actionsRef: formFieldActionsRef, suffix: suffix }))));
65
54
  } }));
66
55
  }
@@ -44,15 +44,18 @@ function htmlTimeToCivilTime(timeString) {
44
44
 
45
45
  const DEBOUNCE_TIME = 300;
46
46
  function useTimePredict({ value, handleChange }) {
47
- const IS_12_HOUR_FORMAT = React.useRef(Intl.DateTimeFormat(navigator.language, {
48
- hour: "numeric",
49
- }).resolvedOptions().hour12);
47
+ const [IS_12_HOUR_FORMAT, set12HourFormat] = React.useState(false);
50
48
  const [typedTime, setTypedTime] = React.useState("");
51
49
  const predictTime = React.useCallback(debounce__default["default"](() => {
52
50
  if (value)
53
51
  return;
54
- handleChange(predictHours(typedTime, IS_12_HOUR_FORMAT.current));
55
- }, DEBOUNCE_TIME), [typedTime, value, handleChange]);
52
+ handleChange(predictHours(typedTime, IS_12_HOUR_FORMAT));
53
+ }, DEBOUNCE_TIME), [typedTime, value, handleChange, IS_12_HOUR_FORMAT]);
54
+ React.useEffect(() => {
55
+ set12HourFormat(Boolean(Intl.DateTimeFormat(navigator.language, {
56
+ hour: "numeric",
57
+ }).resolvedOptions().hour12));
58
+ }, []);
56
59
  /**
57
60
  * Predict the hour when user types a number
58
61
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "4.87.7-JOB-91526-.6+0ee1c55b",
3
+ "version": "4.87.7",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -20,7 +20,7 @@
20
20
  ],
21
21
  "dependencies": {
22
22
  "@jobber/design": "^0.56.0",
23
- "@jobber/formatters": "^0.2.2",
23
+ "@jobber/formatters": "*",
24
24
  "@jobber/hooks": "^2.9.4",
25
25
  "@popperjs/core": "^2.0.6",
26
26
  "@std-proposal/temporal": "0.0.1",
@@ -33,8 +33,6 @@
33
33
  "axios": "^1.6.0",
34
34
  "classnames": "^2.3.2",
35
35
  "color": "^3.1.2",
36
- "date-fns": "^2.30.0",
37
- "date-fns-tz": "^2.0.1",
38
36
  "filesize": "^6.1.0",
39
37
  "framer-motion": "^11.0.3",
40
38
  "lodash": "^4.17.21",
@@ -82,5 +80,5 @@
82
80
  "> 1%",
83
81
  "IE 10"
84
82
  ],
85
- "gitHead": "0ee1c55b49cd9a0b0ce2dfd2d286aec45321ee46"
83
+ "gitHead": "37173081586f137dfe0af6544153d858024b7032"
86
84
  }
@@ -1 +0,0 @@
1
- export * from "./dist/AtlantisContext";
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true,
5
- });
6
-
7
- var AtlantisContext = require("./dist/AtlantisContext");
8
-
9
- Object.keys(AtlantisContext).forEach(function(key) {
10
- if (key === "default" || key === "__esModule") return;
11
- Object.defineProperty(exports, key, {
12
- enumerable: true,
13
- get: function get() {
14
- return AtlantisContext[key];
15
- },
16
- });
17
- });
@@ -1,40 +0,0 @@
1
- /// <reference types="react" />
2
- export interface AtlantisContextProps {
3
- /**
4
- * The date format Atlantis components would use
5
- */
6
- readonly dateFormat: string;
7
- /**
8
- * The time format Atlantis components would use
9
- */
10
- readonly timeFormat: string;
11
- /**
12
- * Time zone used in converting the date and time formats
13
- */
14
- readonly timeZone: string;
15
- /**
16
- * Grabs the decimal separator and group separator based on locale
17
- */
18
- readonly floatSeparators: Record<"decimal" | "group", string>;
19
- /**
20
- * The currency symbol Atlantis components will use
21
- */
22
- readonly currencySymbol: string;
23
- /**
24
- * The `headerHeight` property represents the height of the app header in Atlantis.
25
- * It plays a crucial role in determining the positioning of various elements within the app.
26
- * By accurately defining this value, Atlantis can effectively calculate the layout and alignment of its components.
27
- */
28
- readonly headerHeight: number;
29
- /**
30
- * Change the locale of the components. This updates the strings that comes
31
- * with the components, updates the date and time formats, and/or the
32
- * native 3rd-party packages.
33
- *
34
- * @default "en"
35
- */
36
- readonly locale: string;
37
- }
38
- export declare const atlantisContextDefaultValues: AtlantisContextProps;
39
- export declare const AtlantisContext: import("react").Context<AtlantisContextProps>;
40
- export declare function useAtlantisContext(): AtlantisContextProps;
@@ -1 +0,0 @@
1
- export * from "./AtlantisContext";
@@ -1,12 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var AtlantisContext = require('../AtlantisContext-306beade.js');
6
- require('react');
7
-
8
-
9
-
10
- exports.AtlantisContext = AtlantisContext.AtlantisContext;
11
- exports.atlantisContextDefaultValues = AtlantisContext.atlantisContextDefaultValues;
12
- exports.useAtlantisContext = AtlantisContext.useAtlantisContext;
@@ -1,23 +0,0 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
-
5
- /* eslint-disable @typescript-eslint/no-unused-vars */
6
- const atlantisContextDefaultValues = {
7
- dateFormat: "P",
8
- // The system time is "p"
9
- timeFormat: "p",
10
- timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
11
- floatSeparators: { group: ",", decimal: "." },
12
- currencySymbol: "$",
13
- headerHeight: 0,
14
- locale: "en",
15
- };
16
- const AtlantisContext = React.createContext(atlantisContextDefaultValues);
17
- function useAtlantisContext() {
18
- return React.useContext(AtlantisContext);
19
- }
20
-
21
- exports.AtlantisContext = AtlantisContext;
22
- exports.atlantisContextDefaultValues = atlantisContextDefaultValues;
23
- exports.useAtlantisContext = useAtlantisContext;