@spaced-out/ui-design-system 0.4.5 → 0.4.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/CHANGELOG.md +2 -0
- package/lib/components/Table/Cell.js +0 -2
- package/lib/components/Table/Cell.js.flow +0 -2
- package/lib/components/index.js +0 -11
- package/lib/components/index.js.flow +0 -1
- package/package.json +2 -3
- package/lib/components/DatePicker/DatePicker.js +0 -194
- package/lib/components/DatePicker/DatePicker.js.flow +0 -229
- package/lib/components/DatePicker/DatePicker.module.css +0 -11
- package/lib/components/DatePicker/custom-datepicker-style.css +0 -43
- package/lib/components/DatePicker/index.js +0 -16
- package/lib/components/DatePicker/index.js.flow +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.4.6](https://github.com/spaced-out/ui-design-system/compare/v0.4.5...v0.4.6) (2025-07-24)
|
|
6
|
+
|
|
5
7
|
### [0.4.5](https://github.com/spaced-out/ui-design-system/compare/v0.4.4...v0.4.5) (2025-07-24)
|
|
6
8
|
|
|
7
9
|
|
|
@@ -15,9 +15,7 @@ var _TableModule = _interopRequireDefault(require("./Table.module.css"));
|
|
|
15
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
16
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
17
17
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } // $FlowIssue[nonstrict-import] date-fns
|
|
18
|
-
// $FlowFixMe[untyped-import]
|
|
19
18
|
// $FlowIssue[nonstrict-import] date-fns
|
|
20
|
-
// $FlowFixMe[untyped-import]
|
|
21
19
|
const Cells = _ref => {
|
|
22
20
|
let {
|
|
23
21
|
children,
|
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
// $FlowIssue[nonstrict-import] date-fns
|
|
5
|
-
// $FlowFixMe[untyped-import]
|
|
6
5
|
import formatDistance from 'date-fns/formatDistance';
|
|
7
6
|
// $FlowIssue[nonstrict-import] date-fns
|
|
8
|
-
// $FlowFixMe[untyped-import]
|
|
9
7
|
import parseISO from 'date-fns/parseISO';
|
|
10
8
|
|
|
11
9
|
import {classify} from '../../utils/classify';
|
package/lib/components/index.js
CHANGED
|
@@ -212,17 +212,6 @@ Object.keys(_ConditionalWrapper).forEach(function (key) {
|
|
|
212
212
|
}
|
|
213
213
|
});
|
|
214
214
|
});
|
|
215
|
-
var _DatePicker = require("./DatePicker");
|
|
216
|
-
Object.keys(_DatePicker).forEach(function (key) {
|
|
217
|
-
if (key === "default" || key === "__esModule") return;
|
|
218
|
-
if (key in exports && exports[key] === _DatePicker[key]) return;
|
|
219
|
-
Object.defineProperty(exports, key, {
|
|
220
|
-
enumerable: true,
|
|
221
|
-
get: function () {
|
|
222
|
-
return _DatePicker[key];
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
215
|
var _DateRangePicker = require("./DateRangePicker");
|
|
227
216
|
Object.keys(_DateRangePicker).forEach(function (key) {
|
|
228
217
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -19,7 +19,6 @@ export * from './CircularLoader';
|
|
|
19
19
|
export * from './CollapsibleCard';
|
|
20
20
|
export * from './Combobox';
|
|
21
21
|
export * from './ConditionalWrapper';
|
|
22
|
-
export * from './DatePicker';
|
|
23
22
|
export * from './DateRangePicker';
|
|
24
23
|
export * from './Dialog';
|
|
25
24
|
export * from './Disclaimer';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spaced-out/ui-design-system",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"description": "Sense UI components library",
|
|
6
6
|
"author": {
|
|
@@ -45,13 +45,12 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@floating-ui/react": "^0.24.0",
|
|
48
|
-
"date-fns": "^
|
|
48
|
+
"date-fns": "^2.29.3",
|
|
49
49
|
"highcharts": "^11.4.1",
|
|
50
50
|
"highcharts-react-official": "^3.2.1",
|
|
51
51
|
"lodash": "^4.17.21",
|
|
52
52
|
"moment": "^2.29.4",
|
|
53
53
|
"moment-timezone": "^0.5.45",
|
|
54
|
-
"react-datepicker": "^8.4.0",
|
|
55
54
|
"react-dropzone": "^14.2.3",
|
|
56
55
|
"react-window": "^1.8.10"
|
|
57
56
|
},
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.DatePicker = void 0;
|
|
7
|
-
var React = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _reactDatepicker = _interopRequireWildcard(require("react-datepicker"));
|
|
9
|
-
var locales = _interopRequireWildcard(require("date-fns/locale"));
|
|
10
|
-
var _moment = _interopRequireDefault(require("moment"));
|
|
11
|
-
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
12
|
-
var _clickAway = require("../../utils/click-away");
|
|
13
|
-
var _Input = require("../Input");
|
|
14
|
-
require("react-datepicker/dist/react-datepicker.css");
|
|
15
|
-
require("./custom-datepicker-style.css");
|
|
16
|
-
var _DatePickerModule = _interopRequireDefault(require("./DatePicker.module.css"));
|
|
17
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
19
|
-
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } // $FlowFixMe[untyped-import]
|
|
20
|
-
// $FlowFixMe[untyped-import]
|
|
21
|
-
// $FlowFixMe[untyped-import]
|
|
22
|
-
const DatePicker = _ref => {
|
|
23
|
-
let {
|
|
24
|
-
locale = 'en',
|
|
25
|
-
value,
|
|
26
|
-
onChange,
|
|
27
|
-
classNames,
|
|
28
|
-
allowCalendarToggleOnIconClick = false,
|
|
29
|
-
datePickerProps,
|
|
30
|
-
inputProps,
|
|
31
|
-
pickerType,
|
|
32
|
-
clickAwayRef
|
|
33
|
-
} = _ref;
|
|
34
|
-
const {
|
|
35
|
-
placeholder,
|
|
36
|
-
type,
|
|
37
|
-
...restInputProps
|
|
38
|
-
} = inputProps || {};
|
|
39
|
-
|
|
40
|
-
// --- Picker Type Config ---
|
|
41
|
-
const getReactDatePickerPropsForPickerType = () => {
|
|
42
|
-
switch (pickerType) {
|
|
43
|
-
case 'date':
|
|
44
|
-
return {
|
|
45
|
-
dateFormat: 'dd/MM/yyyy',
|
|
46
|
-
popperPlacement: 'bottom',
|
|
47
|
-
...datePickerProps
|
|
48
|
-
};
|
|
49
|
-
case 'time':
|
|
50
|
-
return {
|
|
51
|
-
dateFormat: 'HH:mm',
|
|
52
|
-
popperPlacement: 'bottom',
|
|
53
|
-
showTimeSelect: true,
|
|
54
|
-
showTimeCaption: false,
|
|
55
|
-
showTimeSelectOnly: true,
|
|
56
|
-
timeIntervals: 15,
|
|
57
|
-
...datePickerProps
|
|
58
|
-
};
|
|
59
|
-
case 'date-time':
|
|
60
|
-
return {
|
|
61
|
-
dateFormat: 'dd/MM/yyyy HH:mm',
|
|
62
|
-
popperPlacement: 'bottom',
|
|
63
|
-
showTimeSelect: true,
|
|
64
|
-
timeCaption: '',
|
|
65
|
-
timeIntervals: 1,
|
|
66
|
-
...datePickerProps
|
|
67
|
-
};
|
|
68
|
-
case 'week':
|
|
69
|
-
return {
|
|
70
|
-
dateFormat: 'w, YYYY',
|
|
71
|
-
popperPlacement: 'bottom',
|
|
72
|
-
selectWeek: true,
|
|
73
|
-
showWeekNumbers: true,
|
|
74
|
-
showWeekPicker: true,
|
|
75
|
-
...datePickerProps
|
|
76
|
-
};
|
|
77
|
-
case 'month':
|
|
78
|
-
return {
|
|
79
|
-
dateFormat: 'MMMM yyyy',
|
|
80
|
-
popperPlacement: 'bottom',
|
|
81
|
-
showMonthYearPicker: true,
|
|
82
|
-
showMonthYearPickerOnly: true,
|
|
83
|
-
...datePickerProps
|
|
84
|
-
};
|
|
85
|
-
default:
|
|
86
|
-
return {};
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
// To convert date to YYYY-MM-DD format
|
|
91
|
-
const formatDateToYMD = dateStr => (0, _moment.default)(dateStr).format('YYYY-MM-DD');
|
|
92
|
-
|
|
93
|
-
// To convert time to HH:mm format
|
|
94
|
-
const formatTimeToHM = dateStr => (0, _moment.default)(dateStr).format('HH:mm');
|
|
95
|
-
|
|
96
|
-
// To combine date and time in IST format
|
|
97
|
-
const combineDateTimeInISO = (datePart, timePart) => {
|
|
98
|
-
if (!datePart || !timePart) {
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
// Date part is in DD/MM/YYYY format, convert it to YYYY-MM-DD format
|
|
102
|
-
const datePartInYYYYMMDD = datePart.split('/').reverse().join('-');
|
|
103
|
-
const isoString = `${datePartInYYYYMMDD}T${timePart}:00+05:30`;
|
|
104
|
-
return new Date(isoString);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
// To format the value based on the pickerType
|
|
108
|
-
const formatPickerValue = value => {
|
|
109
|
-
if (value === '') {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
if (pickerType === 'date') {
|
|
113
|
-
return combineDateTimeInISO(value, '00:00');
|
|
114
|
-
}
|
|
115
|
-
if (pickerType === 'time') {
|
|
116
|
-
return combineDateTimeInISO(formatDateToYMD(new Date()), value || '00:00');
|
|
117
|
-
}
|
|
118
|
-
if (pickerType === 'date-time') {
|
|
119
|
-
return combineDateTimeInISO(value.split(' ')[0], value.split(' ')[1]);
|
|
120
|
-
}
|
|
121
|
-
return '';
|
|
122
|
-
};
|
|
123
|
-
const [localValue, setLocalValue] = React.useState(formatPickerValue(value));
|
|
124
|
-
React.useEffect(() => {
|
|
125
|
-
if (localValue === '') {
|
|
126
|
-
setLocalValue(null);
|
|
127
|
-
}
|
|
128
|
-
}, [localValue]);
|
|
129
|
-
|
|
130
|
-
// Register locale for date-fns
|
|
131
|
-
(0, _reactDatepicker.registerLocale)(locale, locales[locale]);
|
|
132
|
-
|
|
133
|
-
// To handle the value change
|
|
134
|
-
const handleValueChange = value => {
|
|
135
|
-
setLocalValue(value);
|
|
136
|
-
if (pickerType === 'date') {
|
|
137
|
-
onChange(formatDateToYMD(value));
|
|
138
|
-
} else if (pickerType === 'time') {
|
|
139
|
-
onChange(formatTimeToHM(value));
|
|
140
|
-
} else if (pickerType === 'date-time') {
|
|
141
|
-
onChange(`${formatDateToYMD(value)}T${formatTimeToHM(value)}`);
|
|
142
|
-
} else {
|
|
143
|
-
onChange(value);
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
return /*#__PURE__*/React.createElement(_clickAway.ClickAway, {
|
|
147
|
-
clickAwayRef: clickAwayRef
|
|
148
|
-
}, _ref2 => {
|
|
149
|
-
let {
|
|
150
|
-
isOpen,
|
|
151
|
-
onOpen,
|
|
152
|
-
boundaryRef,
|
|
153
|
-
triggerRef
|
|
154
|
-
} = _ref2;
|
|
155
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
156
|
-
ref: boundaryRef,
|
|
157
|
-
className: (0, _classify.default)(_DatePickerModule.default.wrapper, classNames?.wrapper)
|
|
158
|
-
}, /*#__PURE__*/React.createElement(_reactDatepicker.default, _extends({}, getReactDatePickerPropsForPickerType(), {
|
|
159
|
-
popperPlacement: datePickerProps?.popperPlacement || 'bottom',
|
|
160
|
-
selected: localValue,
|
|
161
|
-
open: isOpen,
|
|
162
|
-
onChange: handleValueChange,
|
|
163
|
-
onClickOutside: e => {
|
|
164
|
-
e.stopPropagation();
|
|
165
|
-
onOpen();
|
|
166
|
-
},
|
|
167
|
-
locale: locale,
|
|
168
|
-
placeholderText: placeholder,
|
|
169
|
-
wrapperClassName: (0, _classify.default)(_DatePickerModule.default.datePickerWrapper, datePickerProps?.wrapperClassName),
|
|
170
|
-
disabled: inputProps?.disabled,
|
|
171
|
-
popperClassName: datePickerProps?.popperClassName,
|
|
172
|
-
className: (0, _classify.default)(_DatePickerModule.default.datePicker, datePickerProps?.className),
|
|
173
|
-
customInput: /*#__PURE__*/React.createElement(_Input.Input, _extends({}, restInputProps, {
|
|
174
|
-
value: value,
|
|
175
|
-
onContainerClick: e => {
|
|
176
|
-
e.stopPropagation();
|
|
177
|
-
onOpen();
|
|
178
|
-
},
|
|
179
|
-
onIconRightClick: () => {
|
|
180
|
-
if (allowCalendarToggleOnIconClick) {
|
|
181
|
-
onOpen();
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
onIconLeftClick: () => {
|
|
185
|
-
if (allowCalendarToggleOnIconClick) {
|
|
186
|
-
onOpen();
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
ref: triggerRef
|
|
190
|
-
}))
|
|
191
|
-
})));
|
|
192
|
-
});
|
|
193
|
-
};
|
|
194
|
-
exports.DatePicker = DatePicker;
|
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
// @flow strict
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
// $FlowFixMe[untyped-import]
|
|
5
|
-
import ReactDatePicker, {registerLocale} from 'react-datepicker';
|
|
6
|
-
// $FlowFixMe[untyped-import]
|
|
7
|
-
import * as locales from 'date-fns/locale';
|
|
8
|
-
// $FlowFixMe[untyped-import]
|
|
9
|
-
import moment from 'moment';
|
|
10
|
-
|
|
11
|
-
import classify from '../../utils/classify';
|
|
12
|
-
import {type ClickAwayRefType, ClickAway} from '../../utils/click-away';
|
|
13
|
-
import {type InputProps, Input} from '../Input';
|
|
14
|
-
|
|
15
|
-
import 'react-datepicker/dist/react-datepicker.css';
|
|
16
|
-
import './custom-datepicker-style.css';
|
|
17
|
-
import css from './DatePicker.module.css';
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
type ClassNames = $ReadOnly<{wrapper?: string}>;
|
|
21
|
-
|
|
22
|
-
export type DatePickerProps = {
|
|
23
|
-
locale?: string,
|
|
24
|
-
value: string,
|
|
25
|
-
classNames?: ClassNames,
|
|
26
|
-
onChange: (value: string) => mixed,
|
|
27
|
-
allowCalendarToggleOnIconClick?: boolean,
|
|
28
|
-
clickAwayRef?: ClickAwayRefType,
|
|
29
|
-
datePickerProps?: {
|
|
30
|
-
dateFormat?: string,
|
|
31
|
-
popperPlacement?: string,
|
|
32
|
-
showTimeSelect?: boolean,
|
|
33
|
-
showTimeCaption?: boolean,
|
|
34
|
-
showTimeSelectOnly?: boolean,
|
|
35
|
-
timeIntervals?: number,
|
|
36
|
-
timeCaption?: string,
|
|
37
|
-
selectWeek?: boolean,
|
|
38
|
-
showWeekNumbers?: boolean,
|
|
39
|
-
showWeekPicker?: boolean,
|
|
40
|
-
weekStartsOn?: number,
|
|
41
|
-
showMonthYearPicker?: boolean,
|
|
42
|
-
showMonthYearPickerOnly?: boolean,
|
|
43
|
-
wrapperClassName?: string,
|
|
44
|
-
popperClassName?: string,
|
|
45
|
-
className?: string,
|
|
46
|
-
...
|
|
47
|
-
},
|
|
48
|
-
inputProps?: InputProps,
|
|
49
|
-
pickerType: 'date' | 'time' | 'date-time' | 'week' | 'month',
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export const DatePicker = ({
|
|
53
|
-
locale = 'en',
|
|
54
|
-
value,
|
|
55
|
-
onChange,
|
|
56
|
-
classNames,
|
|
57
|
-
allowCalendarToggleOnIconClick = false,
|
|
58
|
-
datePickerProps,
|
|
59
|
-
inputProps,
|
|
60
|
-
pickerType,
|
|
61
|
-
clickAwayRef,
|
|
62
|
-
}: DatePickerProps): React.Node => {
|
|
63
|
-
const {placeholder, type, ...restInputProps} = inputProps || {};
|
|
64
|
-
|
|
65
|
-
// --- Picker Type Config ---
|
|
66
|
-
const getReactDatePickerPropsForPickerType = () => {
|
|
67
|
-
switch (pickerType) {
|
|
68
|
-
case 'date':
|
|
69
|
-
return {
|
|
70
|
-
dateFormat: 'dd/MM/yyyy',
|
|
71
|
-
popperPlacement: 'bottom',
|
|
72
|
-
...datePickerProps,
|
|
73
|
-
};
|
|
74
|
-
case 'time':
|
|
75
|
-
return {
|
|
76
|
-
dateFormat: 'HH:mm',
|
|
77
|
-
popperPlacement: 'bottom',
|
|
78
|
-
showTimeSelect: true,
|
|
79
|
-
showTimeCaption: false,
|
|
80
|
-
showTimeSelectOnly: true,
|
|
81
|
-
timeIntervals: 15,
|
|
82
|
-
...datePickerProps,
|
|
83
|
-
};
|
|
84
|
-
case 'date-time':
|
|
85
|
-
return {
|
|
86
|
-
dateFormat: 'dd/MM/yyyy HH:mm',
|
|
87
|
-
popperPlacement: 'bottom',
|
|
88
|
-
showTimeSelect: true,
|
|
89
|
-
timeCaption: '',
|
|
90
|
-
timeIntervals: 1,
|
|
91
|
-
...datePickerProps,
|
|
92
|
-
};
|
|
93
|
-
case 'week':
|
|
94
|
-
return {
|
|
95
|
-
dateFormat: 'w, YYYY',
|
|
96
|
-
popperPlacement: 'bottom',
|
|
97
|
-
selectWeek: true,
|
|
98
|
-
showWeekNumbers: true,
|
|
99
|
-
showWeekPicker: true,
|
|
100
|
-
...datePickerProps,
|
|
101
|
-
};
|
|
102
|
-
case 'month':
|
|
103
|
-
return {
|
|
104
|
-
dateFormat: 'MMMM yyyy',
|
|
105
|
-
popperPlacement: 'bottom',
|
|
106
|
-
showMonthYearPicker: true,
|
|
107
|
-
showMonthYearPickerOnly: true,
|
|
108
|
-
...datePickerProps,
|
|
109
|
-
};
|
|
110
|
-
default:
|
|
111
|
-
return {};
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
// To convert date to YYYY-MM-DD format
|
|
116
|
-
const formatDateToYMD = (dateStr) => moment(dateStr).format('YYYY-MM-DD');
|
|
117
|
-
|
|
118
|
-
// To convert time to HH:mm format
|
|
119
|
-
const formatTimeToHM = (dateStr) => moment(dateStr).format('HH:mm');
|
|
120
|
-
|
|
121
|
-
// To combine date and time in IST format
|
|
122
|
-
const combineDateTimeInISO = (datePart, timePart) => {
|
|
123
|
-
if (!datePart || !timePart) {
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
126
|
-
// Date part is in DD/MM/YYYY format, convert it to YYYY-MM-DD format
|
|
127
|
-
const datePartInYYYYMMDD = datePart.split('/').reverse().join('-');
|
|
128
|
-
const isoString = `${datePartInYYYYMMDD}T${timePart}:00+05:30`;
|
|
129
|
-
return new Date(isoString);
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
// To format the value based on the pickerType
|
|
133
|
-
const formatPickerValue = (value) => {
|
|
134
|
-
if (value === '') {
|
|
135
|
-
return null;
|
|
136
|
-
}
|
|
137
|
-
if (pickerType === 'date') {
|
|
138
|
-
return combineDateTimeInISO(value, '00:00');
|
|
139
|
-
}
|
|
140
|
-
if (pickerType === 'time') {
|
|
141
|
-
return combineDateTimeInISO(
|
|
142
|
-
formatDateToYMD(new Date()),
|
|
143
|
-
value || '00:00',
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
if (pickerType === 'date-time') {
|
|
147
|
-
return combineDateTimeInISO(value.split(' ')[0], value.split(' ')[1]);
|
|
148
|
-
}
|
|
149
|
-
return '';
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
const [localValue, setLocalValue] = React.useState(formatPickerValue(value));
|
|
153
|
-
|
|
154
|
-
React.useEffect(() => {
|
|
155
|
-
if (localValue === '') {
|
|
156
|
-
setLocalValue(null);
|
|
157
|
-
}
|
|
158
|
-
}, [localValue]);
|
|
159
|
-
|
|
160
|
-
// Register locale for date-fns
|
|
161
|
-
registerLocale(locale, locales[locale]);
|
|
162
|
-
|
|
163
|
-
// To handle the value change
|
|
164
|
-
const handleValueChange = (value) => {
|
|
165
|
-
setLocalValue(value);
|
|
166
|
-
if (pickerType === 'date') {
|
|
167
|
-
onChange(formatDateToYMD(value));
|
|
168
|
-
} else if (pickerType === 'time') {
|
|
169
|
-
onChange(formatTimeToHM(value));
|
|
170
|
-
} else if (pickerType === 'date-time') {
|
|
171
|
-
onChange(`${formatDateToYMD(value)}T${formatTimeToHM(value)}`);
|
|
172
|
-
} else {
|
|
173
|
-
onChange(value);
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
return (
|
|
178
|
-
<ClickAway clickAwayRef={clickAwayRef}>
|
|
179
|
-
{({isOpen, onOpen, boundaryRef, triggerRef}) => (
|
|
180
|
-
<div
|
|
181
|
-
ref={boundaryRef}
|
|
182
|
-
className={classify(css.wrapper, classNames?.wrapper)}
|
|
183
|
-
>
|
|
184
|
-
<ReactDatePicker
|
|
185
|
-
{...getReactDatePickerPropsForPickerType()}
|
|
186
|
-
popperPlacement={datePickerProps?.popperPlacement || 'bottom'}
|
|
187
|
-
selected={localValue}
|
|
188
|
-
open={isOpen}
|
|
189
|
-
onChange={handleValueChange}
|
|
190
|
-
onClickOutside={(e) => {
|
|
191
|
-
e.stopPropagation();
|
|
192
|
-
onOpen();
|
|
193
|
-
}}
|
|
194
|
-
locale={locale}
|
|
195
|
-
placeholderText={placeholder}
|
|
196
|
-
wrapperClassName={classify(
|
|
197
|
-
css.datePickerWrapper,
|
|
198
|
-
datePickerProps?.wrapperClassName,
|
|
199
|
-
)}
|
|
200
|
-
disabled={inputProps?.disabled}
|
|
201
|
-
popperClassName={datePickerProps?.popperClassName}
|
|
202
|
-
className={classify(css.datePicker, datePickerProps?.className)}
|
|
203
|
-
customInput={
|
|
204
|
-
<Input
|
|
205
|
-
{...restInputProps}
|
|
206
|
-
value={value}
|
|
207
|
-
onContainerClick={(e) => {
|
|
208
|
-
e.stopPropagation();
|
|
209
|
-
onOpen();
|
|
210
|
-
}}
|
|
211
|
-
onIconRightClick={() => {
|
|
212
|
-
if (allowCalendarToggleOnIconClick) {
|
|
213
|
-
onOpen();
|
|
214
|
-
}
|
|
215
|
-
}}
|
|
216
|
-
onIconLeftClick={() => {
|
|
217
|
-
if (allowCalendarToggleOnIconClick) {
|
|
218
|
-
onOpen();
|
|
219
|
-
}
|
|
220
|
-
}}
|
|
221
|
-
ref={triggerRef}
|
|
222
|
-
/>
|
|
223
|
-
}
|
|
224
|
-
/>
|
|
225
|
-
</div>
|
|
226
|
-
)}
|
|
227
|
-
</ClickAway>
|
|
228
|
-
);
|
|
229
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
:root {
|
|
2
|
-
--colorFillSecondary: #efebfa;
|
|
3
|
-
--colorBorderSecondary: #d1d1d1;
|
|
4
|
-
--colorFillPrimary: #5c34cd;
|
|
5
|
-
--colorTextPrimary: #17172a;
|
|
6
|
-
--borderWidthPrimary: 1px;
|
|
7
|
-
--size8: 8px;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.react-datepicker {
|
|
11
|
-
font-family: 'CENTRA NO 2' !important;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.react-datepicker__header {
|
|
15
|
-
background-color: var(--colorFillSecondary) !important;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.react-datepicker__day--selected {
|
|
19
|
-
background-color: var(--colorFillSecondary) !important;
|
|
20
|
-
color: var(--colorTextPrimary);
|
|
21
|
-
border: var(--borderWidthPrimary) solid var(--colorBorderSecondary);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.react-datepicker__month-text {
|
|
25
|
-
padding: var(--size8);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.react-datepicker__month-text--selected {
|
|
29
|
-
background-color: var(--colorFillSecondary) !important;
|
|
30
|
-
color: var(--colorTextPrimary) !important;
|
|
31
|
-
border: var(--borderWidthPrimary) solid var(--colorBorderSecondary);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.react-datepicker__time-list-item--selected {
|
|
35
|
-
background-color: var(--colorFillSecondary) !important;
|
|
36
|
-
color: var(--colorTextPrimary) !important;
|
|
37
|
-
border: var(--borderWidthPrimary) solid var(--colorBorderSecondary);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.react-datepicker__week-number--selected {
|
|
41
|
-
background-color: var(--colorFillPrimary) !important;
|
|
42
|
-
border: var(--borderWidthPrimary) solid var(--colorBorderSecondary);
|
|
43
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _DatePicker = require("./DatePicker");
|
|
7
|
-
Object.keys(_DatePicker).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _DatePicker[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _DatePicker[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|