@jobber/components 4.87.5 → 4.87.7-JOB-91526-.6
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.
- package/AtlantisContext.d.ts +1 -0
- package/AtlantisContext.js +17 -0
- package/dist/AtlantisContext/AtlantisContext.d.ts +40 -0
- package/dist/AtlantisContext/index.d.ts +1 -0
- package/dist/AtlantisContext/index.js +12 -0
- package/dist/AtlantisContext-306beade.js +23 -0
- package/dist/DataList/hooks/useMediaQuery.d.ts +7 -1
- package/dist/DataList/index.js +18 -12
- package/dist/DatePicker/index.js +2 -1
- package/dist/{DatePicker-dd9173c7.js → DatePicker-b584d1e9.js} +11 -1
- package/dist/InputDate/InputDate.d.ts +9 -0
- package/dist/InputDate/index.js +17 -6
- package/package.json +6 -4
|
@@ -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,40 @@
|
|
|
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;
|
|
@@ -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-306beade.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,23 @@
|
|
|
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;
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
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 {};
|
package/dist/DataList/index.js
CHANGED
|
@@ -101,7 +101,19 @@ function useDataListContext() {
|
|
|
101
101
|
return React.useContext(DataListContext);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
|
|
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
|
|
128
|
+
if (typeof window === "undefined" ||
|
|
129
|
+
typeof window.matchMedia === "undefined") {
|
|
117
130
|
return true;
|
|
118
|
-
|
|
119
|
-
React.
|
|
120
|
-
|
|
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
|
|
package/dist/DatePicker/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var DatePicker = require('../DatePicker-
|
|
5
|
+
var DatePicker = require('../DatePicker-b584d1e9.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-306beade.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-306beade.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: [
|
|
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,15 @@ 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;
|
|
18
27
|
}
|
|
19
28
|
export declare function InputDate(inputProps: InputDateProps): JSX.Element;
|
|
20
29
|
export {};
|
package/dist/InputDate/index.js
CHANGED
|
@@ -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-
|
|
8
|
+
var DatePicker = require('../DatePicker-b584d1e9.js');
|
|
9
9
|
require('../tslib.es6-754e2961.js');
|
|
10
10
|
require('react-hook-form');
|
|
11
11
|
require('../style-inject.es-9d2f5f4e.js');
|
|
@@ -22,6 +22,7 @@ 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');
|
|
25
26
|
|
|
26
27
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
27
28
|
|
|
@@ -34,22 +35,32 @@ function InputDate(inputProps) {
|
|
|
34
35
|
var _a;
|
|
35
36
|
const { onChange, onClick, value } = activatorProps;
|
|
36
37
|
const newActivatorProps = omit__default["default"](activatorProps, ["activator"]);
|
|
37
|
-
const suffix =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const suffix = inputProps.showIcon !== false
|
|
39
|
+
? {
|
|
40
|
+
icon: "calendar",
|
|
41
|
+
ariaLabel: "Show calendar",
|
|
42
|
+
onClick: onClick && onClick,
|
|
43
|
+
}
|
|
44
|
+
: {};
|
|
41
45
|
// Set form field to formatted date string immediately, to avoid validations
|
|
42
46
|
// triggering incorrectly when it blurs (to handle the datepicker UI click)
|
|
43
47
|
value && ((_a = formFieldActionsRef.current) === null || _a === void 0 ? void 0 : _a.setValue(value));
|
|
48
|
+
const _value = value ? value : inputProps.emptyValuePlaceholder;
|
|
44
49
|
return (
|
|
45
50
|
// 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
51
|
React__default["default"].createElement("div", { onClick: onClick },
|
|
47
|
-
React__default["default"].createElement(FormField.FormField, Object.assign({}, newActivatorProps, inputProps, { value:
|
|
52
|
+
React__default["default"].createElement(FormField.FormField, Object.assign({}, newActivatorProps, inputProps, { value: _value, onChange: (_, event) => onChange && onChange(event), onBlur: () => {
|
|
48
53
|
inputProps.onBlur && inputProps.onBlur();
|
|
49
54
|
activatorProps.onBlur && activatorProps.onBlur();
|
|
50
55
|
}, onFocus: () => {
|
|
51
56
|
inputProps.onFocus && inputProps.onFocus();
|
|
52
57
|
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
|
+
}
|
|
53
64
|
}, actionsRef: formFieldActionsRef, suffix: suffix }))));
|
|
54
65
|
} }));
|
|
55
66
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "4.87.
|
|
3
|
+
"version": "4.87.7-JOB-91526-.6+0ee1c55b",
|
|
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": "
|
|
24
|
-
"@jobber/hooks": "^2.9.
|
|
23
|
+
"@jobber/formatters": "^0.2.2",
|
|
24
|
+
"@jobber/hooks": "^2.9.4",
|
|
25
25
|
"@popperjs/core": "^2.0.6",
|
|
26
26
|
"@std-proposal/temporal": "0.0.1",
|
|
27
27
|
"@tanstack/react-table": "8.5.13",
|
|
@@ -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": "
|
|
85
|
+
"gitHead": "0ee1c55b49cd9a0b0ce2dfd2d286aec45321ee46"
|
|
84
86
|
}
|