@semapps/date-components 1.1.1 → 1.1.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.
- package/dist/index.cjs.js +214 -211
- package/dist/index.es.js +219 -205
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -1,241 +1,244 @@
|
|
|
1
|
-
var $3RhHq$reactjsxruntime = require(
|
|
2
|
-
require(
|
|
3
|
-
var $3RhHq$muixdatepickersDatePicker = require(
|
|
4
|
-
var $3RhHq$muixdatepickersTimePicker = require(
|
|
5
|
-
var $3RhHq$muixdatepickersDateTimePicker = require(
|
|
6
|
-
var $3RhHq$react = require(
|
|
7
|
-
var $3RhHq$reactadmin = require(
|
|
8
|
-
var $3RhHq$muixdatepickersLocalizationProvider = require(
|
|
9
|
-
var $3RhHq$muixdatepickersAdapterDateFns = require(
|
|
10
|
-
var $3RhHq$fullcalendarreact = require(
|
|
11
|
-
var $3RhHq$fullcalendardaygrid = require(
|
|
12
|
-
var $3RhHq$muimaterial = require(
|
|
13
|
-
var $3RhHq$muistylesmakeStyles = require(
|
|
14
|
-
var $3RhHq$reactrouterdom = require(
|
|
15
|
-
var $3RhHq$fullcalendarlist = require(
|
|
16
|
-
|
|
1
|
+
var $3RhHq$reactjsxruntime = require('react/jsx-runtime');
|
|
2
|
+
require('@fullcalendar/core/vdom');
|
|
3
|
+
var $3RhHq$muixdatepickersDatePicker = require('@mui/x-date-pickers/DatePicker');
|
|
4
|
+
var $3RhHq$muixdatepickersTimePicker = require('@mui/x-date-pickers/TimePicker');
|
|
5
|
+
var $3RhHq$muixdatepickersDateTimePicker = require('@mui/x-date-pickers/DateTimePicker');
|
|
6
|
+
var $3RhHq$react = require('react');
|
|
7
|
+
var $3RhHq$reactadmin = require('react-admin');
|
|
8
|
+
var $3RhHq$muixdatepickersLocalizationProvider = require('@mui/x-date-pickers/LocalizationProvider');
|
|
9
|
+
var $3RhHq$muixdatepickersAdapterDateFns = require('@mui/x-date-pickers/AdapterDateFns');
|
|
10
|
+
var $3RhHq$fullcalendarreact = require('@fullcalendar/react');
|
|
11
|
+
var $3RhHq$fullcalendardaygrid = require('@fullcalendar/daygrid');
|
|
12
|
+
var $3RhHq$muimaterial = require('@mui/material');
|
|
13
|
+
var $3RhHq$muistylesmakeStyles = require('@mui/styles/makeStyles');
|
|
14
|
+
var $3RhHq$reactrouterdom = require('react-router-dom');
|
|
15
|
+
var $3RhHq$fullcalendarlist = require('@fullcalendar/list');
|
|
17
16
|
|
|
18
17
|
function $parcel$export(e, n, v, s) {
|
|
19
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
18
|
+
Object.defineProperty(e, n, { get: v, set: s, enumerable: true, configurable: true });
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
function $parcel$interopDefault(a) {
|
|
23
22
|
return a && a.__esModule ? a.default : a;
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
$parcel$export(module.exports,
|
|
27
|
-
$parcel$export(module.exports,
|
|
28
|
-
$parcel$export(module.exports,
|
|
29
|
-
$parcel$export(module.exports,
|
|
30
|
-
$parcel$export(module.exports,
|
|
31
|
-
$parcel$export(module.exports,
|
|
25
|
+
$parcel$export(module.exports, 'DateInput', () => $0ec82123656742c1$export$7edc06cf1783b30f);
|
|
26
|
+
$parcel$export(module.exports, 'TimeInput', () => $0ec82123656742c1$export$a1af6f79df847fac);
|
|
27
|
+
$parcel$export(module.exports, 'DateTimeInput', () => $0ec82123656742c1$export$183478aa40b5df1);
|
|
28
|
+
$parcel$export(module.exports, 'CalendarList', () => $563c84827e91e322$export$2e2bcd8739ae039);
|
|
29
|
+
$parcel$export(module.exports, 'DaysList', () => $5379d12b87e743a4$export$2e2bcd8739ae039);
|
|
30
|
+
$parcel$export(module.exports, 'useFullCalendarProps', () => $c8dbd8ec3b8f34cc$export$2e2bcd8739ae039);
|
|
32
31
|
/* eslint-disable react/react-in-jsx-scope */ /* eslint-disable react/jsx-props-no-spreading */ // Solves bug with Vite in dev mode. Can be removed when we upgrade to FullCalendar v6
|
|
33
32
|
// See https://github.com/fullcalendar/fullcalendar-vue/issues/152
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
touched: isTouched || isSubmitted,
|
|
87
|
-
error: error?.message,
|
|
88
|
-
helperText: helperText
|
|
89
|
-
})
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
value: field.value ? new Date(field.value) : null,
|
|
93
|
-
onChange: handleChange,
|
|
94
|
-
...rest
|
|
34
|
+
/* eslint-disable react/react-in-jsx-scope */ /* eslint-disable react/require-default-props */
|
|
35
|
+
|
|
36
|
+
const $c332daa71b957685$var$Picker = ({
|
|
37
|
+
PickerComponent: PickerComponent,
|
|
38
|
+
label: label,
|
|
39
|
+
source: source,
|
|
40
|
+
helperText: helperText,
|
|
41
|
+
fullWidth: fullWidth,
|
|
42
|
+
onBlur: onBlur,
|
|
43
|
+
onChange: onChange,
|
|
44
|
+
format: format,
|
|
45
|
+
parse: parse,
|
|
46
|
+
validate: validate,
|
|
47
|
+
defaultValue: defaultValue,
|
|
48
|
+
locale: locale,
|
|
49
|
+
translations: translations,
|
|
50
|
+
stringFormat: stringFormat = 'ISO',
|
|
51
|
+
...rest
|
|
52
|
+
}) => {
|
|
53
|
+
const {
|
|
54
|
+
field: field,
|
|
55
|
+
isRequired: isRequired,
|
|
56
|
+
fieldState: { error: error, isTouched: isTouched, invalid: invalid },
|
|
57
|
+
formState: { isSubmitted: isSubmitted }
|
|
58
|
+
} = (0, $3RhHq$reactadmin.useInput)({
|
|
59
|
+
format: format,
|
|
60
|
+
onBlur: onBlur,
|
|
61
|
+
onChange: onChange,
|
|
62
|
+
parse: parse,
|
|
63
|
+
source: source,
|
|
64
|
+
validate: validate,
|
|
65
|
+
defaultValue: defaultValue
|
|
66
|
+
});
|
|
67
|
+
const handleChange = (0, $3RhHq$react.useCallback)(
|
|
68
|
+
value => {
|
|
69
|
+
if (value instanceof Date) field.onChange(stringFormat === 'ISO' ? value.toISOString() : value.toString());
|
|
70
|
+
else field.onChange(null);
|
|
71
|
+
},
|
|
72
|
+
[field, stringFormat]
|
|
73
|
+
);
|
|
74
|
+
const translateLabel = (0, $3RhHq$reactadmin.useTranslateLabel)();
|
|
75
|
+
const translatedLabel = /*#__PURE__*/ (0, $3RhHq$reactjsxruntime.jsxs)('span', {
|
|
76
|
+
children: [
|
|
77
|
+
translateLabel({
|
|
78
|
+
label: label,
|
|
79
|
+
source: source
|
|
80
|
+
}),
|
|
81
|
+
isRequired &&
|
|
82
|
+
/*#__PURE__*/ (0, $3RhHq$reactjsxruntime.jsx)('span', {
|
|
83
|
+
'aria-hidden': 'true',
|
|
84
|
+
children: '\u2009*'
|
|
95
85
|
})
|
|
96
|
-
|
|
86
|
+
]
|
|
87
|
+
});
|
|
88
|
+
return /*#__PURE__*/ (0, $3RhHq$reactjsxruntime.jsx)(
|
|
89
|
+
(0, $3RhHq$muixdatepickersLocalizationProvider.LocalizationProvider),
|
|
90
|
+
{
|
|
91
|
+
dateAdapter: (0, $3RhHq$muixdatepickersAdapterDateFns.AdapterDateFns),
|
|
92
|
+
adapterLocale: locale,
|
|
93
|
+
localeText: translations?.components.MuiLocalizationProvider.defaultProps.localeText,
|
|
94
|
+
children: /*#__PURE__*/ (0, $3RhHq$reactjsxruntime.jsx)(PickerComponent, {
|
|
95
|
+
label: translatedLabel,
|
|
96
|
+
slotProps: {
|
|
97
|
+
textField: {
|
|
98
|
+
error: (isTouched || isSubmitted) && invalid,
|
|
99
|
+
size: 'small',
|
|
100
|
+
fullWidth: fullWidth,
|
|
101
|
+
helperText: /*#__PURE__*/ (0, $3RhHq$reactjsxruntime.jsx)((0, $3RhHq$reactadmin.InputHelperText), {
|
|
102
|
+
touched: isTouched || isSubmitted,
|
|
103
|
+
error: error?.message,
|
|
104
|
+
helperText: helperText
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
value: field.value ? new Date(field.value) : null,
|
|
109
|
+
onChange: handleChange,
|
|
110
|
+
...rest
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
);
|
|
97
114
|
};
|
|
98
115
|
var $c332daa71b957685$export$2e2bcd8739ae039 = $c332daa71b957685$var$Picker;
|
|
99
116
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
eventClick: eventClick
|
|
152
|
-
};
|
|
117
|
+
const $c8dbd8ec3b8f34cc$var$useFullCalendarProps = ({
|
|
118
|
+
label: label,
|
|
119
|
+
startDate: startDate,
|
|
120
|
+
endDate: endDate,
|
|
121
|
+
linkType: linkType
|
|
122
|
+
}) => {
|
|
123
|
+
const { data: data, isLoading: isLoading, resource: resource } = (0, $3RhHq$reactadmin.useListContext)();
|
|
124
|
+
const [searchParams, setSearchParams] = (0, $3RhHq$reactrouterdom.useSearchParams)();
|
|
125
|
+
const navigate = (0, $3RhHq$reactrouterdom.useNavigate)();
|
|
126
|
+
const createPath = (0, $3RhHq$reactadmin.useCreatePath)();
|
|
127
|
+
const query = new URLSearchParams(location.search);
|
|
128
|
+
// Bypass the link in order to use React-Router
|
|
129
|
+
const eventClick = (0, $3RhHq$react.useCallback)(({ event: event, jsEvent: jsEvent }) => {
|
|
130
|
+
jsEvent.preventDefault();
|
|
131
|
+
navigate(event.url);
|
|
132
|
+
}, []);
|
|
133
|
+
// Change the query string when month change
|
|
134
|
+
const datesSet = (0, $3RhHq$react.useCallback)(
|
|
135
|
+
({ view: view }) => {
|
|
136
|
+
setSearchParams(params => ({
|
|
137
|
+
...params,
|
|
138
|
+
month: view.currentStart.getMonth() + 1,
|
|
139
|
+
year: view.currentStart.getFullYear()
|
|
140
|
+
}));
|
|
141
|
+
},
|
|
142
|
+
[setSearchParams]
|
|
143
|
+
);
|
|
144
|
+
const events = (0, $3RhHq$react.useMemo)(
|
|
145
|
+
() =>
|
|
146
|
+
!isLoading &&
|
|
147
|
+
data
|
|
148
|
+
.filter(record => record)
|
|
149
|
+
.map(record => ({
|
|
150
|
+
id: record.id,
|
|
151
|
+
title: typeof label === 'string' ? record[label] : label(record),
|
|
152
|
+
start: typeof startDate === 'string' ? record[startDate] : startDate(record),
|
|
153
|
+
end: typeof endDate === 'string' ? record[endDate] : endDate(record),
|
|
154
|
+
url: createPath({
|
|
155
|
+
resource: resource,
|
|
156
|
+
id: record.id,
|
|
157
|
+
type: linkType
|
|
158
|
+
})
|
|
159
|
+
})),
|
|
160
|
+
[isLoading, data, resource, createPath]
|
|
161
|
+
);
|
|
162
|
+
return {
|
|
163
|
+
initialDate: query.has('month') ? new Date(query.get('year'), query.get('month') - 1) : new Date(),
|
|
164
|
+
events: events,
|
|
165
|
+
datesSet: datesSet,
|
|
166
|
+
eventClick: eventClick
|
|
167
|
+
};
|
|
153
168
|
};
|
|
154
169
|
var $c8dbd8ec3b8f34cc$export$2e2bcd8739ae039 = $c8dbd8ec3b8f34cc$var$useFullCalendarProps;
|
|
155
170
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
eventBackgroundColor: theme.palette.primary.main,
|
|
184
|
-
...fullCalendarProps
|
|
185
|
-
});
|
|
171
|
+
const $563c84827e91e322$var$useGlobalStyles = (0, $parcel$interopDefault($3RhHq$muistylesmakeStyles))(theme => ({
|
|
172
|
+
'@global': {
|
|
173
|
+
'.fc-button': {
|
|
174
|
+
backgroundColor: `${theme.palette.primary.main} !important`,
|
|
175
|
+
border: 'none !important',
|
|
176
|
+
opacity: '1 !important'
|
|
177
|
+
},
|
|
178
|
+
'.fc-day-today': {
|
|
179
|
+
backgroundColor: `${theme.palette.secondary.light} !important`
|
|
180
|
+
},
|
|
181
|
+
// Overwrite violet color of links
|
|
182
|
+
'a.fc-daygrid-dot-event': {
|
|
183
|
+
color: 'black !important'
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}));
|
|
187
|
+
const $563c84827e91e322$var$CalendarList = props => {
|
|
188
|
+
const theme = (0, $3RhHq$muimaterial.useTheme)();
|
|
189
|
+
const fullCalendarProps = (0, $c8dbd8ec3b8f34cc$export$2e2bcd8739ae039)(props);
|
|
190
|
+
$563c84827e91e322$var$useGlobalStyles();
|
|
191
|
+
return /*#__PURE__*/ (0, $3RhHq$reactjsxruntime.jsx)((0, $parcel$interopDefault($3RhHq$fullcalendarreact)), {
|
|
192
|
+
plugins: [(0, $parcel$interopDefault($3RhHq$fullcalendardaygrid))],
|
|
193
|
+
locale: props.locale,
|
|
194
|
+
initialView: 'dayGridMonth',
|
|
195
|
+
eventBackgroundColor: theme.palette.primary.main,
|
|
196
|
+
...fullCalendarProps
|
|
197
|
+
});
|
|
186
198
|
};
|
|
187
199
|
$563c84827e91e322$var$CalendarList.defaultProps = {
|
|
188
|
-
|
|
200
|
+
linkType: 'edit'
|
|
189
201
|
};
|
|
190
202
|
var $563c84827e91e322$export$2e2bcd8739ae039 = $563c84827e91e322$var$CalendarList;
|
|
191
203
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
$5379d12b87e743a4$var$useGlobalStyles();
|
|
211
|
-
return /*#__PURE__*/ (0, $3RhHq$reactjsxruntime.jsx)((0, ($parcel$interopDefault($3RhHq$fullcalendarreact))), {
|
|
212
|
-
plugins: [
|
|
213
|
-
(0, ($parcel$interopDefault($3RhHq$fullcalendarlist)))
|
|
214
|
-
],
|
|
215
|
-
locale: props.locale,
|
|
216
|
-
initialView: "listMonth",
|
|
217
|
-
...fullCalendarProps
|
|
218
|
-
});
|
|
204
|
+
const $5379d12b87e743a4$var$useGlobalStyles = (0, $parcel$interopDefault($3RhHq$muistylesmakeStyles))(theme => ({
|
|
205
|
+
'@global': {
|
|
206
|
+
'.fc-button': {
|
|
207
|
+
backgroundColor: `${theme.palette.primary.main} !important`,
|
|
208
|
+
border: 'none !important',
|
|
209
|
+
opacity: '1 !important'
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}));
|
|
213
|
+
const $5379d12b87e743a4$var$DaysList = props => {
|
|
214
|
+
const fullCalendarProps = (0, $c8dbd8ec3b8f34cc$export$2e2bcd8739ae039)(props);
|
|
215
|
+
$5379d12b87e743a4$var$useGlobalStyles();
|
|
216
|
+
return /*#__PURE__*/ (0, $3RhHq$reactjsxruntime.jsx)((0, $parcel$interopDefault($3RhHq$fullcalendarreact)), {
|
|
217
|
+
plugins: [(0, $parcel$interopDefault($3RhHq$fullcalendarlist))],
|
|
218
|
+
locale: props.locale,
|
|
219
|
+
initialView: 'listMonth',
|
|
220
|
+
...fullCalendarProps
|
|
221
|
+
});
|
|
219
222
|
};
|
|
220
223
|
$5379d12b87e743a4$var$DaysList.defaultProps = {
|
|
221
|
-
|
|
224
|
+
linkType: 'edit'
|
|
222
225
|
};
|
|
223
226
|
var $5379d12b87e743a4$export$2e2bcd8739ae039 = $5379d12b87e743a4$var$DaysList;
|
|
224
227
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
const $0ec82123656742c1$export$183478aa40b5df1 =
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
228
|
+
const $0ec82123656742c1$export$7edc06cf1783b30f = props =>
|
|
229
|
+
/*#__PURE__*/ (0, $3RhHq$reactjsxruntime.jsx)((0, $c332daa71b957685$export$2e2bcd8739ae039), {
|
|
230
|
+
PickerComponent: (0, $3RhHq$muixdatepickersDatePicker.DatePicker),
|
|
231
|
+
...props
|
|
232
|
+
});
|
|
233
|
+
const $0ec82123656742c1$export$a1af6f79df847fac = props =>
|
|
234
|
+
/*#__PURE__*/ (0, $3RhHq$reactjsxruntime.jsx)((0, $c332daa71b957685$export$2e2bcd8739ae039), {
|
|
235
|
+
PickerComponent: (0, $3RhHq$muixdatepickersTimePicker.TimePicker),
|
|
236
|
+
...props
|
|
237
|
+
});
|
|
238
|
+
const $0ec82123656742c1$export$183478aa40b5df1 = props =>
|
|
239
|
+
/*#__PURE__*/ (0, $3RhHq$reactjsxruntime.jsx)((0, $c332daa71b957685$export$2e2bcd8739ae039), {
|
|
240
|
+
PickerComponent: (0, $3RhHq$muixdatepickersDateTimePicker.DateTimePicker),
|
|
241
|
+
...props
|
|
242
|
+
});
|
|
240
243
|
|
|
241
244
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.es.js
CHANGED
|
@@ -1,227 +1,241 @@
|
|
|
1
|
-
import {jsx as $5Ihaz$jsx, jsxs as $5Ihaz$jsxs} from
|
|
2
|
-
import
|
|
3
|
-
import {DatePicker as $5Ihaz$DatePicker} from
|
|
4
|
-
import {TimePicker as $5Ihaz$TimePicker} from
|
|
5
|
-
import {DateTimePicker as $5Ihaz$DateTimePicker} from
|
|
6
|
-
import {useCallback as $5Ihaz$useCallback, useMemo as $5Ihaz$useMemo} from
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
import $5Ihaz$
|
|
1
|
+
import { jsx as $5Ihaz$jsx, jsxs as $5Ihaz$jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import '@fullcalendar/core/vdom';
|
|
3
|
+
import { DatePicker as $5Ihaz$DatePicker } from '@mui/x-date-pickers/DatePicker';
|
|
4
|
+
import { TimePicker as $5Ihaz$TimePicker } from '@mui/x-date-pickers/TimePicker';
|
|
5
|
+
import { DateTimePicker as $5Ihaz$DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';
|
|
6
|
+
import { useCallback as $5Ihaz$useCallback, useMemo as $5Ihaz$useMemo } from 'react';
|
|
7
|
+
import {
|
|
8
|
+
useInput as $5Ihaz$useInput,
|
|
9
|
+
useTranslateLabel as $5Ihaz$useTranslateLabel,
|
|
10
|
+
InputHelperText as $5Ihaz$InputHelperText,
|
|
11
|
+
useListContext as $5Ihaz$useListContext,
|
|
12
|
+
useCreatePath as $5Ihaz$useCreatePath
|
|
13
|
+
} from 'react-admin';
|
|
14
|
+
import { LocalizationProvider as $5Ihaz$LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
|
|
15
|
+
import { AdapterDateFns as $5Ihaz$AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
|
|
16
|
+
import $5Ihaz$fullcalendarreact from '@fullcalendar/react';
|
|
17
|
+
import $5Ihaz$fullcalendardaygrid from '@fullcalendar/daygrid';
|
|
18
|
+
import { useTheme as $5Ihaz$useTheme } from '@mui/material';
|
|
19
|
+
import $5Ihaz$muistylesmakeStyles from '@mui/styles/makeStyles';
|
|
20
|
+
import { useSearchParams as $5Ihaz$useSearchParams, useNavigate as $5Ihaz$useNavigate } from 'react-router-dom';
|
|
21
|
+
import $5Ihaz$fullcalendarlist from '@fullcalendar/list';
|
|
16
22
|
|
|
17
23
|
/* eslint-disable react/react-in-jsx-scope */ /* eslint-disable react/jsx-props-no-spreading */ // Solves bug with Vite in dev mode. Can be removed when we upgrade to FullCalendar v6
|
|
18
24
|
// See https://github.com/fullcalendar/fullcalendar-vue/issues/152
|
|
19
25
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
touched: isTouched || isSubmitted,
|
|
72
|
-
error: error?.message,
|
|
73
|
-
helperText: helperText
|
|
74
|
-
})
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
value: field.value ? new Date(field.value) : null,
|
|
78
|
-
onChange: handleChange,
|
|
79
|
-
...rest
|
|
26
|
+
/* eslint-disable react/react-in-jsx-scope */ /* eslint-disable react/require-default-props */
|
|
27
|
+
|
|
28
|
+
const $610808f89222f9cc$var$Picker = ({
|
|
29
|
+
PickerComponent: PickerComponent,
|
|
30
|
+
label: label,
|
|
31
|
+
source: source,
|
|
32
|
+
helperText: helperText,
|
|
33
|
+
fullWidth: fullWidth,
|
|
34
|
+
onBlur: onBlur,
|
|
35
|
+
onChange: onChange,
|
|
36
|
+
format: format,
|
|
37
|
+
parse: parse,
|
|
38
|
+
validate: validate,
|
|
39
|
+
defaultValue: defaultValue,
|
|
40
|
+
locale: locale,
|
|
41
|
+
translations: translations,
|
|
42
|
+
stringFormat: stringFormat = 'ISO',
|
|
43
|
+
...rest
|
|
44
|
+
}) => {
|
|
45
|
+
const {
|
|
46
|
+
field: field,
|
|
47
|
+
isRequired: isRequired,
|
|
48
|
+
fieldState: { error: error, isTouched: isTouched, invalid: invalid },
|
|
49
|
+
formState: { isSubmitted: isSubmitted }
|
|
50
|
+
} = (0, $5Ihaz$useInput)({
|
|
51
|
+
format: format,
|
|
52
|
+
onBlur: onBlur,
|
|
53
|
+
onChange: onChange,
|
|
54
|
+
parse: parse,
|
|
55
|
+
source: source,
|
|
56
|
+
validate: validate,
|
|
57
|
+
defaultValue: defaultValue
|
|
58
|
+
});
|
|
59
|
+
const handleChange = (0, $5Ihaz$useCallback)(
|
|
60
|
+
value => {
|
|
61
|
+
if (value instanceof Date) field.onChange(stringFormat === 'ISO' ? value.toISOString() : value.toString());
|
|
62
|
+
else field.onChange(null);
|
|
63
|
+
},
|
|
64
|
+
[field, stringFormat]
|
|
65
|
+
);
|
|
66
|
+
const translateLabel = (0, $5Ihaz$useTranslateLabel)();
|
|
67
|
+
const translatedLabel = /*#__PURE__*/ (0, $5Ihaz$jsxs)('span', {
|
|
68
|
+
children: [
|
|
69
|
+
translateLabel({
|
|
70
|
+
label: label,
|
|
71
|
+
source: source
|
|
72
|
+
}),
|
|
73
|
+
isRequired &&
|
|
74
|
+
/*#__PURE__*/ (0, $5Ihaz$jsx)('span', {
|
|
75
|
+
'aria-hidden': 'true',
|
|
76
|
+
children: '\u2009*'
|
|
80
77
|
})
|
|
81
|
-
|
|
78
|
+
]
|
|
79
|
+
});
|
|
80
|
+
return /*#__PURE__*/ (0, $5Ihaz$jsx)((0, $5Ihaz$LocalizationProvider), {
|
|
81
|
+
dateAdapter: (0, $5Ihaz$AdapterDateFns),
|
|
82
|
+
adapterLocale: locale,
|
|
83
|
+
localeText: translations?.components.MuiLocalizationProvider.defaultProps.localeText,
|
|
84
|
+
children: /*#__PURE__*/ (0, $5Ihaz$jsx)(PickerComponent, {
|
|
85
|
+
label: translatedLabel,
|
|
86
|
+
slotProps: {
|
|
87
|
+
textField: {
|
|
88
|
+
error: (isTouched || isSubmitted) && invalid,
|
|
89
|
+
size: 'small',
|
|
90
|
+
fullWidth: fullWidth,
|
|
91
|
+
helperText: /*#__PURE__*/ (0, $5Ihaz$jsx)((0, $5Ihaz$InputHelperText), {
|
|
92
|
+
touched: isTouched || isSubmitted,
|
|
93
|
+
error: error?.message,
|
|
94
|
+
helperText: helperText
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
value: field.value ? new Date(field.value) : null,
|
|
99
|
+
onChange: handleChange,
|
|
100
|
+
...rest
|
|
101
|
+
})
|
|
102
|
+
});
|
|
82
103
|
};
|
|
83
104
|
var $610808f89222f9cc$export$2e2bcd8739ae039 = $610808f89222f9cc$var$Picker;
|
|
84
105
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
eventClick: eventClick
|
|
137
|
-
};
|
|
106
|
+
const $37245c02f9b1b006$var$useFullCalendarProps = ({
|
|
107
|
+
label: label,
|
|
108
|
+
startDate: startDate,
|
|
109
|
+
endDate: endDate,
|
|
110
|
+
linkType: linkType
|
|
111
|
+
}) => {
|
|
112
|
+
const { data: data, isLoading: isLoading, resource: resource } = (0, $5Ihaz$useListContext)();
|
|
113
|
+
const [searchParams, setSearchParams] = (0, $5Ihaz$useSearchParams)();
|
|
114
|
+
const navigate = (0, $5Ihaz$useNavigate)();
|
|
115
|
+
const createPath = (0, $5Ihaz$useCreatePath)();
|
|
116
|
+
const query = new URLSearchParams(location.search);
|
|
117
|
+
// Bypass the link in order to use React-Router
|
|
118
|
+
const eventClick = (0, $5Ihaz$useCallback)(({ event: event, jsEvent: jsEvent }) => {
|
|
119
|
+
jsEvent.preventDefault();
|
|
120
|
+
navigate(event.url);
|
|
121
|
+
}, []);
|
|
122
|
+
// Change the query string when month change
|
|
123
|
+
const datesSet = (0, $5Ihaz$useCallback)(
|
|
124
|
+
({ view: view }) => {
|
|
125
|
+
setSearchParams(params => ({
|
|
126
|
+
...params,
|
|
127
|
+
month: view.currentStart.getMonth() + 1,
|
|
128
|
+
year: view.currentStart.getFullYear()
|
|
129
|
+
}));
|
|
130
|
+
},
|
|
131
|
+
[setSearchParams]
|
|
132
|
+
);
|
|
133
|
+
const events = (0, $5Ihaz$useMemo)(
|
|
134
|
+
() =>
|
|
135
|
+
!isLoading &&
|
|
136
|
+
data
|
|
137
|
+
.filter(record => record)
|
|
138
|
+
.map(record => ({
|
|
139
|
+
id: record.id,
|
|
140
|
+
title: typeof label === 'string' ? record[label] : label(record),
|
|
141
|
+
start: typeof startDate === 'string' ? record[startDate] : startDate(record),
|
|
142
|
+
end: typeof endDate === 'string' ? record[endDate] : endDate(record),
|
|
143
|
+
url: createPath({
|
|
144
|
+
resource: resource,
|
|
145
|
+
id: record.id,
|
|
146
|
+
type: linkType
|
|
147
|
+
})
|
|
148
|
+
})),
|
|
149
|
+
[isLoading, data, resource, createPath]
|
|
150
|
+
);
|
|
151
|
+
return {
|
|
152
|
+
initialDate: query.has('month') ? new Date(query.get('year'), query.get('month') - 1) : new Date(),
|
|
153
|
+
events: events,
|
|
154
|
+
datesSet: datesSet,
|
|
155
|
+
eventClick: eventClick
|
|
156
|
+
};
|
|
138
157
|
};
|
|
139
158
|
var $37245c02f9b1b006$export$2e2bcd8739ae039 = $37245c02f9b1b006$var$useFullCalendarProps;
|
|
140
159
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
eventBackgroundColor: theme.palette.primary.main,
|
|
169
|
-
...fullCalendarProps
|
|
170
|
-
});
|
|
160
|
+
const $abbcc02f55461290$var$useGlobalStyles = (0, $5Ihaz$muistylesmakeStyles)(theme => ({
|
|
161
|
+
'@global': {
|
|
162
|
+
'.fc-button': {
|
|
163
|
+
backgroundColor: `${theme.palette.primary.main} !important`,
|
|
164
|
+
border: 'none !important',
|
|
165
|
+
opacity: '1 !important'
|
|
166
|
+
},
|
|
167
|
+
'.fc-day-today': {
|
|
168
|
+
backgroundColor: `${theme.palette.secondary.light} !important`
|
|
169
|
+
},
|
|
170
|
+
// Overwrite violet color of links
|
|
171
|
+
'a.fc-daygrid-dot-event': {
|
|
172
|
+
color: 'black !important'
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}));
|
|
176
|
+
const $abbcc02f55461290$var$CalendarList = props => {
|
|
177
|
+
const theme = (0, $5Ihaz$useTheme)();
|
|
178
|
+
const fullCalendarProps = (0, $37245c02f9b1b006$export$2e2bcd8739ae039)(props);
|
|
179
|
+
$abbcc02f55461290$var$useGlobalStyles();
|
|
180
|
+
return /*#__PURE__*/ (0, $5Ihaz$jsx)((0, $5Ihaz$fullcalendarreact), {
|
|
181
|
+
plugins: [(0, $5Ihaz$fullcalendardaygrid)],
|
|
182
|
+
locale: props.locale,
|
|
183
|
+
initialView: 'dayGridMonth',
|
|
184
|
+
eventBackgroundColor: theme.palette.primary.main,
|
|
185
|
+
...fullCalendarProps
|
|
186
|
+
});
|
|
171
187
|
};
|
|
172
188
|
$abbcc02f55461290$var$CalendarList.defaultProps = {
|
|
173
|
-
|
|
189
|
+
linkType: 'edit'
|
|
174
190
|
};
|
|
175
191
|
var $abbcc02f55461290$export$2e2bcd8739ae039 = $abbcc02f55461290$var$CalendarList;
|
|
176
192
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
$69d9f850452774a2$var$useGlobalStyles();
|
|
196
|
-
return /*#__PURE__*/ (0, $5Ihaz$jsx)((0, $5Ihaz$fullcalendarreact), {
|
|
197
|
-
plugins: [
|
|
198
|
-
(0, $5Ihaz$fullcalendarlist)
|
|
199
|
-
],
|
|
200
|
-
locale: props.locale,
|
|
201
|
-
initialView: "listMonth",
|
|
202
|
-
...fullCalendarProps
|
|
203
|
-
});
|
|
193
|
+
const $69d9f850452774a2$var$useGlobalStyles = (0, $5Ihaz$muistylesmakeStyles)(theme => ({
|
|
194
|
+
'@global': {
|
|
195
|
+
'.fc-button': {
|
|
196
|
+
backgroundColor: `${theme.palette.primary.main} !important`,
|
|
197
|
+
border: 'none !important',
|
|
198
|
+
opacity: '1 !important'
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}));
|
|
202
|
+
const $69d9f850452774a2$var$DaysList = props => {
|
|
203
|
+
const fullCalendarProps = (0, $37245c02f9b1b006$export$2e2bcd8739ae039)(props);
|
|
204
|
+
$69d9f850452774a2$var$useGlobalStyles();
|
|
205
|
+
return /*#__PURE__*/ (0, $5Ihaz$jsx)((0, $5Ihaz$fullcalendarreact), {
|
|
206
|
+
plugins: [(0, $5Ihaz$fullcalendarlist)],
|
|
207
|
+
locale: props.locale,
|
|
208
|
+
initialView: 'listMonth',
|
|
209
|
+
...fullCalendarProps
|
|
210
|
+
});
|
|
204
211
|
};
|
|
205
212
|
$69d9f850452774a2$var$DaysList.defaultProps = {
|
|
206
|
-
|
|
213
|
+
linkType: 'edit'
|
|
207
214
|
};
|
|
208
215
|
var $69d9f850452774a2$export$2e2bcd8739ae039 = $69d9f850452774a2$var$DaysList;
|
|
209
216
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const $582746363a8b71b9$export$183478aa40b5df1 =
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
export {
|
|
217
|
+
const $582746363a8b71b9$export$7edc06cf1783b30f = props =>
|
|
218
|
+
/*#__PURE__*/ (0, $5Ihaz$jsx)((0, $610808f89222f9cc$export$2e2bcd8739ae039), {
|
|
219
|
+
PickerComponent: (0, $5Ihaz$DatePicker),
|
|
220
|
+
...props
|
|
221
|
+
});
|
|
222
|
+
const $582746363a8b71b9$export$a1af6f79df847fac = props =>
|
|
223
|
+
/*#__PURE__*/ (0, $5Ihaz$jsx)((0, $610808f89222f9cc$export$2e2bcd8739ae039), {
|
|
224
|
+
PickerComponent: (0, $5Ihaz$TimePicker),
|
|
225
|
+
...props
|
|
226
|
+
});
|
|
227
|
+
const $582746363a8b71b9$export$183478aa40b5df1 = props =>
|
|
228
|
+
/*#__PURE__*/ (0, $5Ihaz$jsx)((0, $610808f89222f9cc$export$2e2bcd8739ae039), {
|
|
229
|
+
PickerComponent: (0, $5Ihaz$DateTimePicker),
|
|
230
|
+
...props
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
export {
|
|
234
|
+
$582746363a8b71b9$export$7edc06cf1783b30f as DateInput,
|
|
235
|
+
$582746363a8b71b9$export$a1af6f79df847fac as TimeInput,
|
|
236
|
+
$582746363a8b71b9$export$183478aa40b5df1 as DateTimeInput,
|
|
237
|
+
$abbcc02f55461290$export$2e2bcd8739ae039 as CalendarList,
|
|
238
|
+
$69d9f850452774a2$export$2e2bcd8739ae039 as DaysList,
|
|
239
|
+
$37245c02f9b1b006$export$2e2bcd8739ae039 as useFullCalendarProps
|
|
240
|
+
};
|
|
227
241
|
//# sourceMappingURL=index.es.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semapps/date-components",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "React-Admin components for date display and input",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Virtual Assembly",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"react-admin": "^4.11.0",
|
|
42
42
|
"react-router-dom": "^6.1.0"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "8687009431024704e24db838a2c9ba69f578374c"
|
|
45
45
|
}
|