@jobber/components 4.87.2-JOB-91526-.0 → 4.87.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.
@@ -1 +1,7 @@
1
- export declare function useMediaQuery(CSSMediaQuery: string): boolean;
1
+ type MediaQuery = `(${string}:${string})`;
2
+ export declare const mediaQueryStore: {
3
+ subscribe(onChange: () => void, query: MediaQuery): () => void;
4
+ getSnapshot(query: MediaQuery): () => boolean;
5
+ };
6
+ export declare function useMediaQuery(query: MediaQuery): boolean;
7
+ export {};
@@ -101,7 +101,19 @@ function useDataListContext() {
101
101
  return React.useContext(DataListContext);
102
102
  }
103
103
 
104
- function useMediaQuery(CSSMediaQuery) {
104
+ const mediaQueryStore = {
105
+ subscribe(onChange, query) {
106
+ const matchMedia = window.matchMedia(query);
107
+ matchMedia.addEventListener("change", onChange);
108
+ return () => {
109
+ matchMedia.removeEventListener("change", onChange);
110
+ };
111
+ },
112
+ getSnapshot(query) {
113
+ return () => window.matchMedia(query).matches;
114
+ },
115
+ };
116
+ function useMediaQuery(query) {
105
117
  /**
106
118
  * matchMedia have had full support for browsers since 2012 but jest, being a
107
119
  * lite version of a DOM, doesn't support it.
@@ -113,18 +125,12 @@ function useMediaQuery(CSSMediaQuery) {
113
125
  * screen sizes, they can use the `mockViewportWidth` function from
114
126
  * `@jobber/components/useBreakpoints`.
115
127
  */
116
- if (window.matchMedia === undefined)
128
+ if (typeof window === "undefined" ||
129
+ typeof window.matchMedia === "undefined") {
117
130
  return true;
118
- const [matches, setMatches] = React.useState(window.matchMedia(CSSMediaQuery).matches);
119
- React.useEffect(() => {
120
- const media = window.matchMedia(CSSMediaQuery);
121
- if (media.matches !== matches) {
122
- setMatches(media.matches);
123
- }
124
- const listener = () => setMatches(media.matches);
125
- media.addEventListener("change", listener);
126
- return () => media.removeEventListener("change", listener);
127
- }, [CSSMediaQuery]);
131
+ }
132
+ const subscribeMediaQuery = React.useCallback((onChange) => mediaQueryStore.subscribe(onChange, query), [query]);
133
+ const matches = React.useSyncExternalStore(subscribeMediaQuery, mediaQueryStore.getSnapshot(query), () => true);
128
134
  return matches;
129
135
  }
130
136
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var DatePicker = require('../DatePicker-870c12ab.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-c0f9feb3.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-c0f9feb3.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,10 +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
- * The date format to use
20
- */
21
- readonly dateFormat?: string;
22
18
  }
23
19
  export declare function InputDate(inputProps: InputDateProps): JSX.Element;
24
20
  export {};
@@ -5,8 +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-870c12ab.js');
9
- var AtlantisContext = require('../AtlantisContext-c0f9feb3.js');
8
+ var DatePicker = require('../DatePicker-dd9173c7.js');
10
9
  require('../tslib.es6-754e2961.js');
11
10
  require('react-hook-form');
12
11
  require('../style-inject.es-9d2f5f4e.js');
@@ -31,33 +30,28 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
31
30
 
32
31
  function InputDate(inputProps) {
33
32
  const formFieldActionsRef = React.useRef(null);
34
- const atlantisContext = Object.assign({}, AtlantisContext.atlantisContextDefaultValues);
35
- if (inputProps.dateFormat) {
36
- atlantisContext.dateFormat = inputProps.dateFormat;
37
- }
38
- return (React__default["default"].createElement(AtlantisContext.AtlantisContext.Provider, { value: atlantisContext },
39
- React__default["default"].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 => {
40
- var _a;
41
- const { onChange, onClick, value } = activatorProps;
42
- const newActivatorProps = omit__default["default"](activatorProps, ["activator"]);
43
- const suffix = Object.assign({ icon: "calendar" }, (onClick && {
44
- onClick: onClick,
45
- ariaLabel: "Show calendar",
46
- }));
47
- // Set form field to formatted date string immediately, to avoid validations
48
- // triggering incorrectly when it blurs (to handle the datepicker UI click)
49
- value && ((_a = formFieldActionsRef.current) === null || _a === void 0 ? void 0 : _a.setValue(value));
50
- return (
51
- // 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
52
- React__default["default"].createElement("div", { onClick: onClick },
53
- React__default["default"].createElement(FormField.FormField, Object.assign({}, newActivatorProps, inputProps, { value: value, onChange: (_, event) => onChange && onChange(event), onBlur: () => {
54
- inputProps.onBlur && inputProps.onBlur();
55
- activatorProps.onBlur && activatorProps.onBlur();
56
- }, onFocus: () => {
57
- inputProps.onFocus && inputProps.onFocus();
58
- activatorProps.onFocus && activatorProps.onFocus();
59
- }, actionsRef: formFieldActionsRef, suffix: suffix }))));
60
- } })));
33
+ return (React__default["default"].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 => {
34
+ var _a;
35
+ const { onChange, onClick, value } = activatorProps;
36
+ const newActivatorProps = omit__default["default"](activatorProps, ["activator"]);
37
+ const suffix = Object.assign({ icon: "calendar" }, (onClick && {
38
+ onClick: onClick,
39
+ ariaLabel: "Show calendar",
40
+ }));
41
+ // Set form field to formatted date string immediately, to avoid validations
42
+ // triggering incorrectly when it blurs (to handle the datepicker UI click)
43
+ value && ((_a = formFieldActionsRef.current) === null || _a === void 0 ? void 0 : _a.setValue(value));
44
+ return (
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
46
+ React__default["default"].createElement("div", { onClick: onClick },
47
+ React__default["default"].createElement(FormField.FormField, Object.assign({}, newActivatorProps, inputProps, { value: value, onChange: (_, event) => onChange && onChange(event), onBlur: () => {
48
+ inputProps.onBlur && inputProps.onBlur();
49
+ activatorProps.onBlur && activatorProps.onBlur();
50
+ }, onFocus: () => {
51
+ inputProps.onFocus && inputProps.onFocus();
52
+ activatorProps.onFocus && activatorProps.onFocus();
53
+ }, actionsRef: formFieldActionsRef, suffix: suffix }))));
54
+ } }));
61
55
  }
62
56
 
63
57
  exports.InputDate = InputDate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "4.87.2-JOB-91526-.0+86784e15",
3
+ "version": "4.87.2",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -20,8 +20,8 @@
20
20
  ],
21
21
  "dependencies": {
22
22
  "@jobber/design": "^0.56.0",
23
- "@jobber/formatters": "^0.2.2",
24
- "@jobber/hooks": "^2.9.1",
23
+ "@jobber/formatters": "*",
24
+ "@jobber/hooks": "^2.9.2",
25
25
  "@popperjs/core": "^2.0.6",
26
26
  "@std-proposal/temporal": "0.0.1",
27
27
  "@tanstack/react-table": "8.5.13",
@@ -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": "86784e15a3e684b1f0b165428f4c822b343bbab3"
83
+ "gitHead": "2cc393810288051850e827744f6d533469c5a0d6"
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,56 +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
- * Determines how the component behaves when the app is online or offline.
17
- * This is set to `true` by default. If your usage doesn't require a different
18
- * experience, you can leave this as-is.
19
- */
20
- readonly isOnline: boolean;
21
- /**
22
- * Log errors to rollbar
23
- */
24
- readonly onLogError: (message: string) => void;
25
- /**
26
- * Grabs the decimal separator and group separator based on locale
27
- */
28
- readonly floatSeparators: Record<"decimal" | "group", string>;
29
- /**
30
- * The currency symbol Atlantis components will use
31
- */
32
- readonly currencySymbol: string;
33
- /**
34
- * The `headerHeight` property represents the height of the app header in Atlantis.
35
- * It plays a crucial role in determining the positioning of various elements within the app.
36
- * By accurately defining this value, Atlantis can effectively calculate the layout and alignment of its components.
37
- */
38
- readonly headerHeight: number;
39
- /**
40
- * Change the locale of the components. This updates the strings that comes
41
- * with the components, updates the date and time formats, and/or the
42
- * native 3rd-party packages.
43
- *
44
- * @default "en"
45
- */
46
- readonly locale: string;
47
- /**
48
- * The `setHeaderHeight` method allows you to set the height of the app header in Atlantis.
49
- * Adjusting this height is essential for ensuring the correct positioning and alignment of various elements within the app.
50
- * By setting this value accurately, Atlantis can dynamically adjust the layout of its components based on the specified header height.
51
- */
52
- readonly setHeaderHeight: (height: number) => void;
53
- }
54
- export declare const atlantisContextDefaultValues: AtlantisContextProps;
55
- export declare const AtlantisContext: import("react").Context<AtlantisContextProps>;
56
- 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-c0f9feb3.js');
6
- require('react');
7
-
8
-
9
-
10
- exports.AtlantisContext = AtlantisContext.AtlantisContext;
11
- exports.atlantisContextDefaultValues = AtlantisContext.atlantisContextDefaultValues;
12
- exports.useAtlantisContext = AtlantisContext.useAtlantisContext;
@@ -1,30 +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
- isOnline: true,
12
- onLogError: _ => {
13
- return;
14
- },
15
- floatSeparators: { group: ",", decimal: "." },
16
- currencySymbol: "$",
17
- headerHeight: 0,
18
- locale: "en",
19
- setHeaderHeight: _ => {
20
- return;
21
- },
22
- };
23
- const AtlantisContext = React.createContext(atlantisContextDefaultValues);
24
- function useAtlantisContext() {
25
- return React.useContext(AtlantisContext);
26
- }
27
-
28
- exports.AtlantisContext = AtlantisContext;
29
- exports.atlantisContextDefaultValues = atlantisContextDefaultValues;
30
- exports.useAtlantisContext = useAtlantisContext;