@semapps/date-components 1.1.7 → 1.2.1

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.
@@ -0,0 +1,275 @@
1
+ import { jsx as $5Ihaz$jsx, jsxs as $5Ihaz$jsxs } from 'react/jsx-runtime';
2
+ import '@fullcalendar/react/dist/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
+ // @ts-expect-error TS(2307): Cannot find module '@mui/styles/makeStyles' or its... Remove this comment to see the full error message
20
+ import { makeStyles } from 'tss-react/mui';
21
+ import { useSearchParams as $5Ihaz$useSearchParams, useNavigate as $5Ihaz$useNavigate } from 'react-router-dom';
22
+ import $5Ihaz$fullcalendarlist from '@fullcalendar/list';
23
+
24
+ /* 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
25
+ // See https://github.com/fullcalendar/fullcalendar-vue/issues/152
26
+
27
+ /* eslint-disable react/react-in-jsx-scope */ /* eslint-disable react/require-default-props */
28
+
29
+ // @ts-expect-error TS(7031): Binding element 'PickerComponent' implicitly has a... Remove this comment to see the full error message
30
+ const $610808f89222f9cc$var$Picker = ({
31
+ PickerComponent: PickerComponent,
32
+ label: label,
33
+ source: source,
34
+ helperText: helperText,
35
+ fullWidth: fullWidth,
36
+ onBlur: onBlur,
37
+ onChange: onChange,
38
+ format: format,
39
+ parse: parse,
40
+ validate: validate,
41
+ defaultValue: defaultValue,
42
+ locale: locale,
43
+ translations: translations,
44
+ stringFormat: stringFormat = 'ISO',
45
+ ...rest
46
+ }) => {
47
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
48
+ const {
49
+ field: field,
50
+ isRequired: isRequired,
51
+ fieldState: { error: error, isTouched: isTouched, invalid: invalid },
52
+ formState: { isSubmitted: isSubmitted }
53
+ } = (0, $5Ihaz$useInput)({
54
+ format: format,
55
+ onBlur: onBlur,
56
+ onChange: onChange,
57
+ parse: parse,
58
+ source: source,
59
+ validate: validate,
60
+ defaultValue: defaultValue
61
+ });
62
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
63
+ const handleChange = (0, $5Ihaz$useCallback)(
64
+ (value: any) => {
65
+ if (value instanceof Date) field.onChange(stringFormat === 'ISO' ? value.toISOString() : value.toString());
66
+ else field.onChange(null);
67
+ },
68
+ [field, stringFormat]
69
+ );
70
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
71
+ const translateLabel = (0, $5Ihaz$useTranslateLabel)();
72
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
73
+ const translatedLabel = /*#__PURE__*/ (0, $5Ihaz$jsxs)('span', {
74
+ children: [
75
+ translateLabel({
76
+ label: label,
77
+ source: source
78
+ }),
79
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
80
+ isRequired &&
81
+ /*#__PURE__*/ (0, $5Ihaz$jsx)('span', {
82
+ 'aria-hidden': 'true',
83
+ children: '\u2009*'
84
+ })
85
+ ]
86
+ });
87
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
88
+ return /*#__PURE__*/ (0, $5Ihaz$jsx)((0, $5Ihaz$LocalizationProvider), {
89
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
90
+ dateAdapter: (0, $5Ihaz$AdapterDateFns),
91
+ adapterLocale: locale,
92
+ localeText: translations?.components.MuiLocalizationProvider.defaultProps.localeText,
93
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
94
+ children: /*#__PURE__*/ (0, $5Ihaz$jsx)(PickerComponent, {
95
+ label: translatedLabel,
96
+ slotProps: {
97
+ textField: {
98
+ error: (isTouched || isSubmitted) && invalid,
99
+ size: 'small',
100
+ fullWidth: fullWidth,
101
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
102
+ helperText: /*#__PURE__*/ (0, $5Ihaz$jsx)((0, $5Ihaz$InputHelperText), {
103
+ touched: isTouched || isSubmitted,
104
+ error: error?.message,
105
+ helperText: helperText
106
+ })
107
+ }
108
+ },
109
+ value: field.value ? new Date(field.value) : null,
110
+ onChange: handleChange,
111
+ ...rest
112
+ })
113
+ });
114
+ };
115
+ var $610808f89222f9cc$export$2e2bcd8739ae039 = $610808f89222f9cc$var$Picker;
116
+
117
+ // @ts-expect-error TS(7031): Binding element 'label' implicitly has an 'any' ty... Remove this comment to see the full error message
118
+ const $37245c02f9b1b006$var$useFullCalendarProps = ({
119
+ label: label,
120
+ startDate: startDate,
121
+ endDate: endDate,
122
+ linkType: linkType = 'edit'
123
+ }) => {
124
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
125
+ const { data: data, isLoading: isLoading, resource: resource } = (0, $5Ihaz$useListContext)();
126
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
127
+ const [searchParams, setSearchParams] = (0, $5Ihaz$useSearchParams)();
128
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
129
+ const navigate = (0, $5Ihaz$useNavigate)();
130
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
131
+ const createPath = (0, $5Ihaz$useCreatePath)();
132
+ const query = new URLSearchParams(location.search);
133
+ // Bypass the link in order to use React-Router
134
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
135
+ const eventClick = (0, $5Ihaz$useCallback)(({ event: event, jsEvent: jsEvent }) => {
136
+ jsEvent.preventDefault();
137
+ navigate(event.url);
138
+ }, []);
139
+ // Change the query string when month change
140
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
141
+ const datesSet = (0, $5Ihaz$useCallback)(
142
+ ({ view: view }) => {
143
+ // @ts-expect-error TS(2345): Argument of type '(params: URLSearchParams) => { m... Remove this comment to see the full error message
144
+ setSearchParams(params => ({
145
+ ...params,
146
+ month: view.currentStart.getMonth() + 1,
147
+ year: view.currentStart.getFullYear()
148
+ }));
149
+ },
150
+ [setSearchParams]
151
+ );
152
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
153
+ const events = (0, $5Ihaz$useMemo)(
154
+ () =>
155
+ !isLoading &&
156
+ data
157
+ .filter(record => record)
158
+ .map(record => ({
159
+ id: record.id,
160
+ title: typeof label === 'string' ? record[label] : label(record),
161
+ start: typeof startDate === 'string' ? record[startDate] : startDate(record),
162
+ end: typeof endDate === 'string' ? record[endDate] : endDate(record),
163
+ url: createPath({
164
+ resource: resource,
165
+ id: record.id,
166
+ type: linkType
167
+ })
168
+ })),
169
+ [isLoading, data, resource, createPath]
170
+ );
171
+ return {
172
+ // @ts-expect-error TS(2345): Argument of type 'string | null' is not assignable... Remove this comment to see the full error message
173
+ initialDate: query.has('month') ? new Date(query.get('year'), query.get('month') - 1) : new Date(),
174
+ events: events,
175
+ datesSet: datesSet,
176
+ eventClick: eventClick
177
+ };
178
+ };
179
+ var $37245c02f9b1b006$export$2e2bcd8739ae039 = $37245c02f9b1b006$var$useFullCalendarProps;
180
+
181
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
182
+ const $abbcc02f55461290$var$useGlobalStyles = (0, $5Ihaz$muistylesmakeStyles)((theme: any) => ({
183
+ '@global': {
184
+ '.fc-button': {
185
+ backgroundColor: `${theme.palette.primary.main} !important`,
186
+ border: 'none !important',
187
+ opacity: '1 !important'
188
+ },
189
+ '.fc-day-today': {
190
+ backgroundColor: `${theme.palette.secondary.light} !important`
191
+ },
192
+ // Overwrite violet color of links
193
+ 'a.fc-daygrid-dot-event': {
194
+ color: 'black !important'
195
+ }
196
+ }
197
+ }));
198
+ const $abbcc02f55461290$var$CalendarList = (props: any) => {
199
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
200
+ const theme = (0, $5Ihaz$useTheme)();
201
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
202
+ const fullCalendarProps = (0, $37245c02f9b1b006$export$2e2bcd8739ae039)(props);
203
+ $abbcc02f55461290$var$useGlobalStyles();
204
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
205
+ return /*#__PURE__*/ (0, $5Ihaz$jsx)((0, $5Ihaz$fullcalendarreact), {
206
+ plugins: [
207
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
208
+ (0, $5Ihaz$fullcalendardaygrid)
209
+ ],
210
+ locale: props.locale,
211
+ initialView: 'dayGridMonth',
212
+ eventBackgroundColor: theme.palette.primary.main,
213
+ ...fullCalendarProps
214
+ });
215
+ };
216
+ var $abbcc02f55461290$export$2e2bcd8739ae039 = $abbcc02f55461290$var$CalendarList;
217
+
218
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
219
+ const $69d9f850452774a2$var$useGlobalStyles = (0, $5Ihaz$muistylesmakeStyles)((theme: any) => ({
220
+ '@global': {
221
+ '.fc-button': {
222
+ backgroundColor: `${theme.palette.primary.main} !important`,
223
+ border: 'none !important',
224
+ opacity: '1 !important'
225
+ }
226
+ }
227
+ }));
228
+ const $69d9f850452774a2$var$DaysList = (props: any) => {
229
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
230
+ const fullCalendarProps = (0, $37245c02f9b1b006$export$2e2bcd8739ae039)(props);
231
+ $69d9f850452774a2$var$useGlobalStyles();
232
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
233
+ return /*#__PURE__*/ (0, $5Ihaz$jsx)((0, $5Ihaz$fullcalendarreact), {
234
+ plugins: [
235
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
236
+ (0, $5Ihaz$fullcalendarlist)
237
+ ],
238
+ locale: props.locale,
239
+ initialView: 'listMonth',
240
+ ...fullCalendarProps
241
+ });
242
+ };
243
+ var $69d9f850452774a2$export$2e2bcd8739ae039 = $69d9f850452774a2$var$DaysList;
244
+
245
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
246
+ const $582746363a8b71b9$export$7edc06cf1783b30f = (props: any) =>
247
+ /*#__PURE__*/ (0, $5Ihaz$jsx)((0, $610808f89222f9cc$export$2e2bcd8739ae039), {
248
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
249
+ PickerComponent: (0, $5Ihaz$DatePicker),
250
+ ...props
251
+ });
252
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
253
+ const $582746363a8b71b9$export$a1af6f79df847fac = (props: any) =>
254
+ /*#__PURE__*/ (0, $5Ihaz$jsx)((0, $610808f89222f9cc$export$2e2bcd8739ae039), {
255
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
256
+ PickerComponent: (0, $5Ihaz$TimePicker),
257
+ ...props
258
+ });
259
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
260
+ const $582746363a8b71b9$export$183478aa40b5df1 = (props: any) =>
261
+ /*#__PURE__*/ (0, $5Ihaz$jsx)((0, $610808f89222f9cc$export$2e2bcd8739ae039), {
262
+ // @ts-expect-error TS(2695): Left side of comma operator is unused and has no s... Remove this comment to see the full error message
263
+ PickerComponent: (0, $5Ihaz$DateTimePicker),
264
+ ...props
265
+ });
266
+
267
+ export {
268
+ $582746363a8b71b9$export$7edc06cf1783b30f as DateInput,
269
+ $582746363a8b71b9$export$a1af6f79df847fac as TimeInput,
270
+ $582746363a8b71b9$export$183478aa40b5df1 as DateTimeInput,
271
+ $abbcc02f55461290$export$2e2bcd8739ae039 as CalendarList,
272
+ $69d9f850452774a2$export$2e2bcd8739ae039 as DaysList,
273
+ $37245c02f9b1b006$export$2e2bcd8739ae039 as useFullCalendarProps
274
+ };
275
+ //# 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.7",
3
+ "version": "1.2.1",
4
4
  "description": "React-Admin components for date display and input",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Virtual Assembly",
@@ -12,7 +12,7 @@
12
12
  "dist"
13
13
  ],
14
14
  "scripts": {
15
- "build": "parcel build && yalc publish --push --changed",
15
+ "build": "parcel build --no-cache && yalc publish --push --changed",
16
16
  "watch": "nodemon --ext ts,tsx,js--watch src --exec 'yarn build'",
17
17
  "typecheck": "tsc --noEmit"
18
18
  },
@@ -21,25 +21,24 @@
21
21
  "@fullcalendar/daygrid": "^5.7.2",
22
22
  "@fullcalendar/list": "^5.7.2",
23
23
  "@fullcalendar/react": "^5.7.0",
24
- "@mui/x-date-pickers": "^6.6.0",
25
- "date-fns": "~2.8.1"
24
+ "@mui/x-date-pickers": "^7.1.0",
25
+ "date-fns": "~2.8.1",
26
+ "tss-react": "^4.9.19"
26
27
  },
27
28
  "peerDependencies": {
28
- "@mui/material": "^5.13.1",
29
- "@mui/styles": "^5.13.1",
29
+ "@mui/material": "^7.1.0",
30
30
  "react": "^18.2.0",
31
- "react-admin": "^4.11.0",
32
- "react-router-dom": "^6.1.0"
31
+ "react-admin": "^5.10.1",
32
+ "react-router-dom": "^7.8.2"
33
33
  },
34
34
  "publishConfig": {
35
35
  "access": "public"
36
36
  },
37
37
  "devDependencies": {
38
- "@mui/material": "^5.13.1",
39
- "@mui/styles": "^5.13.1",
38
+ "@mui/material": "^7.1.0",
40
39
  "react": "^18.2.0",
41
- "react-admin": "^4.11.0",
42
- "react-router-dom": "^6.1.0"
40
+ "react-admin": "^5.10.1",
41
+ "react-router-dom": "^7.6.1"
43
42
  },
44
- "gitHead": "453e0ae67cb5c8d34f6cacfd59154a6ed056673b"
43
+ "gitHead": "d99536ece8974c9ca62448808e4905945ee08845"
45
44
  }