@semapps/date-components 1.1.1 → 1.1.3

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