@jobber/components 4.87.10 → 4.87.11-JOB-91526-.8
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 +34 -0
- package/dist/AtlantisContext/index.d.ts +1 -0
- package/dist/AtlantisContext/index.js +12 -0
- package/dist/AtlantisContext-64608897.js +22 -0
- package/dist/DatePicker/index.js +2 -1
- package/dist/{DatePicker-dd9173c7.js → DatePicker-305a5b82.js} +11 -1
- package/dist/InputDate/InputDate.d.ts +9 -0
- package/dist/InputDate/index.js +21 -6
- package/package.json +5 -3
|
@@ -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,34 @@
|
|
|
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
|
+
* Change the locale of the components. This updates the strings that comes
|
|
25
|
+
* with the components, updates the date and time formats, and/or the
|
|
26
|
+
* native 3rd-party packages.
|
|
27
|
+
*
|
|
28
|
+
* @default "en"
|
|
29
|
+
*/
|
|
30
|
+
readonly locale: string;
|
|
31
|
+
}
|
|
32
|
+
export declare const atlantisContextDefaultValues: AtlantisContextProps;
|
|
33
|
+
export declare const AtlantisContext: import("react").Context<AtlantisContextProps>;
|
|
34
|
+
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-64608897.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,22 @@
|
|
|
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
|
+
locale: "en",
|
|
14
|
+
};
|
|
15
|
+
const AtlantisContext = React.createContext(atlantisContextDefaultValues);
|
|
16
|
+
function useAtlantisContext() {
|
|
17
|
+
return React.useContext(AtlantisContext);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
exports.AtlantisContext = AtlantisContext;
|
|
21
|
+
exports.atlantisContextDefaultValues = atlantisContextDefaultValues;
|
|
22
|
+
exports.useAtlantisContext = useAtlantisContext;
|
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-305a5b82.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-64608897.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-64608897.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-f6fadff2.js');
|
|
8
|
-
var DatePicker = require('../DatePicker-
|
|
8
|
+
var DatePicker = require('../DatePicker-305a5b82.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-64608897.js');
|
|
25
26
|
|
|
26
27
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
27
28
|
|
|
@@ -34,22 +35,36 @@ 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
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const [showEmptyPlaceholder, setShowEmptyPlaceholder] = React.useState(!value);
|
|
39
|
+
const suffix = inputProps.showIcon !== false
|
|
40
|
+
? {
|
|
41
|
+
icon: "calendar",
|
|
42
|
+
ariaLabel: "Show calendar",
|
|
43
|
+
onClick: onClick && onClick,
|
|
44
|
+
}
|
|
45
|
+
: undefined;
|
|
41
46
|
// Set form field to formatted date string immediately, to avoid validations
|
|
42
47
|
// triggering incorrectly when it blurs (to handle the datepicker UI click)
|
|
43
48
|
value && ((_a = formFieldActionsRef.current) === null || _a === void 0 ? void 0 : _a.setValue(value));
|
|
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: value,
|
|
52
|
+
React__default["default"].createElement(FormField.FormField, Object.assign({}, newActivatorProps, inputProps, { value: showEmptyPlaceholder ? inputProps.emptyValuePlaceholder : value, placeholder: inputProps.placeholder, onChange: (_, event) => {
|
|
53
|
+
onChange && onChange(event);
|
|
54
|
+
setShowEmptyPlaceholder(false);
|
|
55
|
+
}, onBlur: () => {
|
|
48
56
|
inputProps.onBlur && inputProps.onBlur();
|
|
49
57
|
activatorProps.onBlur && activatorProps.onBlur();
|
|
58
|
+
setShowEmptyPlaceholder(!value);
|
|
50
59
|
}, onFocus: () => {
|
|
51
60
|
inputProps.onFocus && inputProps.onFocus();
|
|
52
61
|
activatorProps.onFocus && activatorProps.onFocus();
|
|
62
|
+
}, onKeyUp: event => {
|
|
63
|
+
var _a;
|
|
64
|
+
if (inputProps.showIcon === false &&
|
|
65
|
+
event.key === "ArrowDown") {
|
|
66
|
+
(_a = activatorProps.onClick) === null || _a === void 0 ? void 0 : _a.call(activatorProps);
|
|
67
|
+
}
|
|
53
68
|
}, actionsRef: formFieldActionsRef, suffix: suffix }))));
|
|
54
69
|
} }));
|
|
55
70
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "4.87.
|
|
3
|
+
"version": "4.87.11-JOB-91526-.8+54fc6d88",
|
|
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.4",
|
|
25
25
|
"@popperjs/core": "^2.0.6",
|
|
26
26
|
"@std-proposal/temporal": "0.0.1",
|
|
@@ -72,6 +72,8 @@
|
|
|
72
72
|
"typescript": "^4.9.5"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
|
+
"date-fns": "^2.0.0",
|
|
76
|
+
"date-fns-tz": "^2.0.0",
|
|
75
77
|
"react": "^18",
|
|
76
78
|
"react-dom": "^18"
|
|
77
79
|
},
|
|
@@ -80,5 +82,5 @@
|
|
|
80
82
|
"> 1%",
|
|
81
83
|
"IE 10"
|
|
82
84
|
],
|
|
83
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "54fc6d8847a17e457114e3388edebc8d11c7e847"
|
|
84
86
|
}
|