@jobber/components 4.87.1 → 4.87.2-JOB-91526-.0

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.
@@ -0,0 +1 @@
1
+ export * from "./dist/AtlantisContext";
@@ -0,0 +1,17 @@
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
+ });
@@ -0,0 +1,56 @@
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;
@@ -0,0 +1 @@
1
+ export * from "./AtlantisContext";
@@ -0,0 +1,12 @@
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;
@@ -0,0 +1,30 @@
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;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var DatePicker = require('../DatePicker-dd9173c7.js');
5
+ var DatePicker = require('../DatePicker-870c12ab.js');
6
6
  require('react');
7
7
  require('classnames');
8
8
  require('react-datepicker');
@@ -14,6 +14,7 @@ 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');
17
18
 
18
19
 
19
20
 
@@ -8,6 +8,7 @@ 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');
11
12
 
12
13
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
14
 
@@ -65,9 +66,11 @@ function useFocusOnSelectedDate() {
65
66
  return { ref, focusOnSelectedDate };
66
67
  }
67
68
 
69
+ /*eslint max-statements: ["error", 13]*/
68
70
  function DatePicker({ onChange, onMonthChange, activator, inline, selected, readonly = false, disabled = false, fullWidth = false, smartAutofocus = true, maxDate, minDate, highlightDates, }) {
69
71
  const { ref, focusOnSelectedDate } = useFocusOnSelectedDate();
70
72
  const [open, setOpen] = React.useState(false);
73
+ const { dateFormat } = AtlantisContext.useAtlantisContext();
71
74
  const wrapperClassName = classnames__default["default"](styles.datePickerWrapper, {
72
75
  // react-datepicker uses this class name to not close the date picker when
73
76
  // the activator is clicked
@@ -88,7 +91,14 @@ function DatePicker({ onChange, onMonthChange, activator, inline, selected, read
88
91
  React.useEffect(focusOnSelectedDate, [open]);
89
92
  }
90
93
  return (React__default["default"].createElement("div", { className: wrapperClassName, ref: ref },
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 })));
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 })));
92
102
  /**
93
103
  * The onChange callback on ReactDatePicker returns a Date and an Event, but
94
104
  * the onChange in our interface only provides the Date. Simplifying the code
@@ -15,6 +15,10 @@ 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;
18
22
  }
19
23
  export declare function InputDate(inputProps: InputDateProps): JSX.Element;
20
24
  export {};
@@ -5,7 +5,8 @@ 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-dd9173c7.js');
8
+ var DatePicker = require('../DatePicker-870c12ab.js');
9
+ var AtlantisContext = require('../AtlantisContext-c0f9feb3.js');
9
10
  require('../tslib.es6-754e2961.js');
10
11
  require('react-hook-form');
11
12
  require('../style-inject.es-9d2f5f4e.js');
@@ -30,28 +31,33 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
30
31
 
31
32
  function InputDate(inputProps) {
32
33
  const formFieldActionsRef = React.useRef(null);
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
- } }));
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
+ } })));
55
61
  }
56
62
 
57
63
  exports.InputDate = InputDate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "4.87.1",
3
+ "version": "4.87.2-JOB-91526-.0+86784e15",
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": "*",
23
+ "@jobber/formatters": "^0.2.2",
24
24
  "@jobber/hooks": "^2.9.1",
25
25
  "@popperjs/core": "^2.0.6",
26
26
  "@std-proposal/temporal": "0.0.1",
@@ -33,6 +33,8 @@
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",
36
38
  "filesize": "^6.1.0",
37
39
  "framer-motion": "^11.0.3",
38
40
  "lodash": "^4.17.21",
@@ -80,5 +82,5 @@
80
82
  "> 1%",
81
83
  "IE 10"
82
84
  ],
83
- "gitHead": "76163e4b81edfc151e30c29407956a507b853706"
85
+ "gitHead": "86784e15a3e684b1f0b165428f4c822b343bbab3"
84
86
  }