@semapps/date-components 1.0.4 → 1.1.0-patch.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.
- package/dist/index.cjs.js +20 -20
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +20 -20
- package/dist/index.es.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -41,7 +41,7 @@ $parcel$export(module.exports, "useFullCalendarProps", () => $c8dbd8ec3b8f34cc$e
|
|
|
41
41
|
|
|
42
42
|
|
|
43
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 =
|
|
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
45
|
const { field: field, isRequired: isRequired, fieldState: { error: error, isTouched: isTouched, invalid: invalid }, formState: { isSubmitted: isSubmitted } } = (0, $3RhHq$reactadmin.useInput)({
|
|
46
46
|
format: format,
|
|
47
47
|
onBlur: onBlur,
|
|
@@ -52,7 +52,7 @@ const $c332daa71b957685$var$Picker = ({ PickerComponent: PickerComponent, label:
|
|
|
52
52
|
defaultValue: defaultValue
|
|
53
53
|
});
|
|
54
54
|
const handleChange = (0, $3RhHq$react.useCallback)((value)=>{
|
|
55
|
-
if (value instanceof Date) field.onChange(stringFormat ===
|
|
55
|
+
if (value instanceof Date) field.onChange(stringFormat === 'ISO' ? value.toISOString() : value.toString());
|
|
56
56
|
else field.onChange(null);
|
|
57
57
|
}, [
|
|
58
58
|
field,
|
|
@@ -80,7 +80,7 @@ const $c332daa71b957685$var$Picker = ({ PickerComponent: PickerComponent, label:
|
|
|
80
80
|
slotProps: {
|
|
81
81
|
textField: {
|
|
82
82
|
error: (isTouched || isSubmitted) && invalid,
|
|
83
|
-
size:
|
|
83
|
+
size: 'small',
|
|
84
84
|
fullWidth: fullWidth,
|
|
85
85
|
helperText: /*#__PURE__*/ (0, $3RhHq$reactjsxruntime.jsx)((0, $3RhHq$reactadmin.InputHelperText), {
|
|
86
86
|
touched: isTouched || isSubmitted,
|
|
@@ -130,9 +130,9 @@ const $c8dbd8ec3b8f34cc$var$useFullCalendarProps = ({ label: label, startDate: s
|
|
|
130
130
|
]);
|
|
131
131
|
const events = (0, $3RhHq$react.useMemo)(()=>!isLoading && data.filter((record)=>record).map((record)=>({
|
|
132
132
|
id: record.id,
|
|
133
|
-
title: typeof label ===
|
|
134
|
-
start: typeof startDate ===
|
|
135
|
-
end: typeof endDate ===
|
|
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
136
|
url: createPath({
|
|
137
137
|
resource: resource,
|
|
138
138
|
id: record.id,
|
|
@@ -145,7 +145,7 @@ const $c8dbd8ec3b8f34cc$var$useFullCalendarProps = ({ label: label, startDate: s
|
|
|
145
145
|
createPath
|
|
146
146
|
]);
|
|
147
147
|
return {
|
|
148
|
-
initialDate: query.has(
|
|
148
|
+
initialDate: query.has('month') ? new Date(query.get('year'), query.get('month') - 1) : new Date(),
|
|
149
149
|
events: events,
|
|
150
150
|
datesSet: datesSet,
|
|
151
151
|
eventClick: eventClick
|
|
@@ -155,18 +155,18 @@ var $c8dbd8ec3b8f34cc$export$2e2bcd8739ae039 = $c8dbd8ec3b8f34cc$var$useFullCale
|
|
|
155
155
|
|
|
156
156
|
|
|
157
157
|
const $563c84827e91e322$var$useGlobalStyles = (0, ($parcel$interopDefault($3RhHq$muistylesmakeStyles)))((theme)=>({
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
'@global': {
|
|
159
|
+
'.fc-button': {
|
|
160
160
|
backgroundColor: `${theme.palette.primary.main} !important`,
|
|
161
|
-
border:
|
|
162
|
-
opacity:
|
|
161
|
+
border: 'none !important',
|
|
162
|
+
opacity: '1 !important'
|
|
163
163
|
},
|
|
164
|
-
|
|
164
|
+
'.fc-day-today': {
|
|
165
165
|
backgroundColor: `${theme.palette.secondary.light} !important`
|
|
166
166
|
},
|
|
167
167
|
// Overwrite violet color of links
|
|
168
|
-
|
|
169
|
-
color:
|
|
168
|
+
'a.fc-daygrid-dot-event': {
|
|
169
|
+
color: 'black !important'
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
}));
|
|
@@ -185,7 +185,7 @@ const $563c84827e91e322$var$CalendarList = (props)=>{
|
|
|
185
185
|
});
|
|
186
186
|
};
|
|
187
187
|
$563c84827e91e322$var$CalendarList.defaultProps = {
|
|
188
|
-
linkType:
|
|
188
|
+
linkType: 'edit'
|
|
189
189
|
};
|
|
190
190
|
var $563c84827e91e322$export$2e2bcd8739ae039 = $563c84827e91e322$var$CalendarList;
|
|
191
191
|
|
|
@@ -197,11 +197,11 @@ var $563c84827e91e322$export$2e2bcd8739ae039 = $563c84827e91e322$var$CalendarLis
|
|
|
197
197
|
|
|
198
198
|
|
|
199
199
|
const $5379d12b87e743a4$var$useGlobalStyles = (0, ($parcel$interopDefault($3RhHq$muistylesmakeStyles)))((theme)=>({
|
|
200
|
-
|
|
201
|
-
|
|
200
|
+
'@global': {
|
|
201
|
+
'.fc-button': {
|
|
202
202
|
backgroundColor: `${theme.palette.primary.main} !important`,
|
|
203
|
-
border:
|
|
204
|
-
opacity:
|
|
203
|
+
border: 'none !important',
|
|
204
|
+
opacity: '1 !important'
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
}));
|
|
@@ -218,7 +218,7 @@ const $5379d12b87e743a4$var$DaysList = (props)=>{
|
|
|
218
218
|
});
|
|
219
219
|
};
|
|
220
220
|
$5379d12b87e743a4$var$DaysList.defaultProps = {
|
|
221
|
-
linkType:
|
|
221
|
+
linkType: 'edit'
|
|
222
222
|
};
|
|
223
223
|
var $5379d12b87e743a4$export$2e2bcd8739ae039 = $5379d12b87e743a4$var$DaysList;
|
|
224
224
|
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA2C,GAC3C,+CAA+C,GAE/C,sFAAsF;AACtF,kEAAkE;;;;;;ACJlE,2CAA2C,GAC3C,8CAA8C;;;;;AAgB9C,MAAM,+BAAS,CAAe,mBAC5B,eAAe,SACf,KAAK,UACL,MAAM,cACN,UAAU,aACV,SAAS,UACT,MAAM,YACN,QAAQ,UACR,MAAM,SACN,KAAK,YACL,QAAQ,gBACR,YAAY,UACZ,MAAM,gBACN,YAAY,gBACZ,eAAe,OACf,GAAG,MACgB;IACnB,MAAM,SACJ,KAAK,cACL,UAAU,EACV,YAAY,SAAE,KAAK,aAAE,SAAS,WAAE,OAAO,EAAE,EACzC,WAAW,eAAE,WAAW,EAAE,EAC3B,GAAG,CAAA,GAAA,0BAAO,EAAE;gBACX;gBACA;kBACA;eACA;gBACA;kBACA;sBACA;IACF;IAEA,MAAM,eAAe,CAAA,GAAA,wBAAU,EAC7B,CAAC;QACC,IAAI,iBAAiB,MACnB,MAAM,QAAQ,CAAC,iBAAiB,QAAQ,MAAM,WAAW,KAAK,MAAM,QAAQ;aAE5E,MAAM,QAAQ,CAAC;IAEnB,GACA;QAAC;QAAO;KAAa;IAGvB,MAAM,iBAAiB,CAAA,GAAA,mCAAgB;IACvC,MAAM,gCACJ,iCAAC;;YACE,eAAe;uBACd;wBACA;YACF;YACC,4BAAc,gCAAC;gBAAK,eAAY;0BAAO;;;;IAI5C,qBACE,gCAAC,CAAA,GAAA,+DAAmB;QAClB,aAAa,CAAA,GAAA,mDAAa;QAC1B,eA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GAAG;IAC1B,UAAU;AACZ;IAEA,2CAAe;;;;;;;;;AEtCf,MAAM,wCAAkB,CAAA,GAAA,oDAAS,EAAE,CAAA,QAAU,CAAA;QAC3C,WAAW;YACT,cAAc;gBACZ,iBAAiB,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC;gBAC3D,QAAQ;gBACR,SAAS;YACX;QACF;IACF,CAAA;AAEA,MAAM,iCAAW,CAAA;IACf,MAAM,oBAAoB,CAAA,GAAA,wCAAmB,EAAE;IAC/C;IAEA,qBAAO,gCAAC,CAAA,GAAA,kDAAW;QAAE,SAAS;YAAC,CAAA,GAAA,iDAAS;SAAE;QAAE,QAAQ,MAAM,MAAM;QAAE,aAAY;QAAa,GAAG,iBAAiB;;AACjH;AAEA,+BAAS,YAAY,GAAG;IACtB,UAAU;AACZ;IAEA,2CAAe;;;;AJff,MAAM,4CAAY,CAAS,sBACzB,gCAAC,CAAA,GAAA,wCAAK;QAAE,iBAAiB,CAAA,GAAA,2CAAS;QAAI,GAAG,KAAK;;AAEhD,MAAM,4CAAY,CAAS,sBACzB,gCAAC,CAAA,GAAA,wCAAK;QAAE,iBAAiB,CAAA,GAAA,2CAAS;QAAI,GAAG,KAAK;;AAEhD,MAAM,2CAAgB,CAAS,sBAC7B,gCAAC,CAAA,GAAA,wCAAK;QAAE,iBAAiB,CAAA,GAAA,mDAAa;QAAI,GAAG,KAAK","sources":["packages/date-components/src/index.tsx","packages/date-components/src/Picker.tsx","packages/date-components/src/CalendarList.js","packages/date-components/src/useFullCalendarProps.js","packages/date-components/src/DaysList.js"],"sourcesContent":["/* eslint-disable react/react-in-jsx-scope */\n/* eslint-disable react/jsx-props-no-spreading */\n\n// Solves bug with Vite in dev mode. Can be removed when we upgrade to FullCalendar v6\n// See https://github.com/fullcalendar/fullcalendar-vue/issues/152\nimport '@fullcalendar/core/vdom';\n\nimport { DatePicker, DatePickerProps } from '@mui/x-date-pickers/DatePicker';\nimport { TimePicker, TimePickerProps } from '@mui/x-date-pickers/TimePicker';\nimport { DateTimePicker, DateTimePickerProps } from '@mui/x-date-pickers/DateTimePicker';\nimport Picker, { Props as PickerProps } from './Picker';\n\nconst DateInput = <TDate,>(props: Omit<PickerProps<DatePickerProps<TDate>>, 'PickerComponent'>) => (\n <Picker PickerComponent={DatePicker} {...props} />\n);\nconst TimeInput = <TDate,>(props: Omit<PickerProps<TimePickerProps<TDate>>, 'PickerComponent'>) => (\n <Picker PickerComponent={TimePicker} {...props} />\n);\nconst DateTimeInput = <TDate,>(props: Omit<PickerProps<DateTimePickerProps<TDate>>, 'PickerComponent'>) => (\n <Picker PickerComponent={DateTimePicker} {...props} />\n);\n\nexport { DateInput, TimeInput, DateTimeInput };\n\nexport { default as CalendarList } from './CalendarList';\nexport { default as DaysList } from './DaysList';\nexport { default as useFullCalendarProps } from './useFullCalendarProps';\n","/* eslint-disable react/react-in-jsx-scope */\n/* eslint-disable react/require-default-props */\nimport { useCallback, ComponentType } from 'react';\nimport { useInput, InputHelperText, TextInputProps, useTranslateLabel } from 'react-admin';\nimport { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';\nimport { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';\nimport { getPickersLocalization } from '@mui/x-date-pickers/locales/utils/getPickersLocalization';\nimport { Locale } from 'date-fns';\n\nexport type Props<PickerProps> = TextInputProps &\n Omit<PickerProps, 'format'> & {\n PickerComponent: ComponentType;\n locale?: Locale;\n translations?: ReturnType<typeof getPickersLocalization>;\n stringFormat?: string;\n };\n\nconst Picker = <PickerProps,>({\n PickerComponent,\n label,\n source,\n helperText,\n fullWidth,\n onBlur,\n onChange,\n format,\n parse,\n validate,\n defaultValue,\n locale,\n translations,\n stringFormat = 'ISO',\n ...rest\n}: Props<PickerProps>) => {\n const {\n field,\n isRequired,\n fieldState: { error, isTouched, invalid },\n formState: { isSubmitted }\n } = useInput({\n format,\n onBlur,\n onChange,\n parse,\n source,\n validate,\n defaultValue\n });\n\n const handleChange = useCallback(\n (value: Date) => {\n if (value instanceof Date) {\n field.onChange(stringFormat === 'ISO' ? value.toISOString() : value.toString());\n } else {\n field.onChange(null);\n }\n },\n [field, stringFormat]\n );\n\n const translateLabel = useTranslateLabel();\n const translatedLabel = (\n <span>\n {translateLabel({\n label,\n source\n })}\n {isRequired && <span aria-hidden=\"true\"> *</span>}\n </span>\n );\n\n return (\n <LocalizationProvider\n dateAdapter={AdapterDateFns}\n adapterLocale={locale}\n localeText={translations?.components.MuiLocalizationProvider.defaultProps.localeText}\n >\n <PickerComponent\n label={translatedLabel}\n slotProps={{\n textField: {\n error: (isTouched || isSubmitted) && invalid,\n size: 'small',\n fullWidth,\n helperText: (\n <InputHelperText touched={isTouched || isSubmitted} error={error?.message} helperText={helperText} />\n )\n }\n }}\n value={field.value ? new Date(field.value) : null}\n onChange={handleChange}\n /* eslint-disable-next-line react/jsx-props-no-spreading */\n {...rest}\n />\n </LocalizationProvider>\n );\n};\n\nexport default Picker;\n","import React from 'react';\nimport FullCalendar from '@fullcalendar/react';\nimport dayGridPlugin from '@fullcalendar/daygrid';\nimport { useTheme } from '@mui/material';\nimport makeStyles from '@mui/styles/makeStyles';\nimport useFullCalendarProps from './useFullCalendarProps';\n\nconst useGlobalStyles = makeStyles(theme => ({\n '@global': {\n '.fc-button': {\n backgroundColor: `${theme.palette.primary.main} !important`,\n border: 'none !important',\n opacity: '1 !important'\n },\n '.fc-day-today': {\n backgroundColor: `${theme.palette.secondary.light} !important`\n },\n // Overwrite violet color of links\n 'a.fc-daygrid-dot-event': {\n color: 'black !important'\n }\n }\n}));\n\nconst CalendarList = props => {\n const theme = useTheme();\n const fullCalendarProps = useFullCalendarProps(props);\n useGlobalStyles();\n\n return (\n <FullCalendar\n plugins={[dayGridPlugin]}\n locale={props.locale}\n initialView=\"dayGridMonth\"\n eventBackgroundColor={theme.palette.primary.main}\n {...fullCalendarProps}\n />\n );\n};\n\nCalendarList.defaultProps = {\n linkType: 'edit'\n};\n\nexport default CalendarList;\n","import React, { useMemo, useCallback } from 'react';\nimport { useSearchParams, useNavigate } from 'react-router-dom';\nimport { useListContext, useCreatePath } from 'react-admin';\n\nconst useFullCalendarProps = ({ label, startDate, endDate, linkType }) => {\n const { data, isLoading, resource } = useListContext();\n const [searchParams, setSearchParams] = useSearchParams();\n const navigate = useNavigate();\n const createPath = useCreatePath();\n\n const query = new URLSearchParams(location.search);\n\n // Bypass the link in order to use React-Router\n const eventClick = useCallback(({ event, jsEvent }) => {\n jsEvent.preventDefault();\n navigate(event.url);\n }, []);\n\n // Change the query string when month change\n const datesSet = useCallback(\n ({ view }) => {\n setSearchParams(params => ({\n ...params,\n month: view.currentStart.getMonth() + 1,\n year: view.currentStart.getFullYear()\n }));\n },\n [setSearchParams]\n );\n\n const events = useMemo(\n () =>\n !isLoading &&\n data\n .filter(record => record)\n .map(record => ({\n id: record.id,\n title: typeof label === 'string' ? record[label] : label(record),\n start: typeof startDate === 'string' ? record[startDate] : startDate(record),\n end: typeof endDate === 'string' ? record[endDate] : endDate(record),\n url: createPath({ resource, id: record.id, type: linkType })\n })),\n [isLoading, data, resource, createPath]\n );\n\n return {\n initialDate: query.has('month') ? new Date(query.get('year'), query.get('month') - 1) : new Date(),\n events,\n datesSet,\n eventClick\n };\n};\n\nexport default useFullCalendarProps;\n","import React from 'react';\nimport FullCalendar from '@fullcalendar/react';\nimport listPlugin from '@fullcalendar/list';\nimport makeStyles from '@mui/styles/makeStyles';\nimport useFullCalendarProps from './useFullCalendarProps';\n\nconst useGlobalStyles = makeStyles(theme => ({\n '@global': {\n '.fc-button': {\n backgroundColor: `${theme.palette.primary.main} !important`,\n border: 'none !important',\n opacity: '1 !important'\n }\n }\n}));\n\nconst DaysList = props => {\n const fullCalendarProps = useFullCalendarProps(props);\n useGlobalStyles();\n\n return <FullCalendar plugins={[listPlugin]} locale={props.locale} initialView=\"listMonth\" {...fullCalendarProps} />;\n};\n\nDaysList.defaultProps = {\n linkType: 'edit'\n};\n\nexport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C;gBAC3D,QAAQ;gBACR,SAAS;YACX;QACF;IACF,CAAA;AAEA,MAAM,iCAAW,CAAA;IACf,MAAM,oBAAoB,CAAA,GAAA,wCAAmB,EAAE;IAC/C;IAEA,qBAAO,gCAAC,CAAA,GAAA,kDAAW;QAAE,SAAS;YAAC,CAAA,GAAA,iDAAS;SAAE;QAAE,QAAQ,MAAM,MAAM;QAAE,aAAY;QAAa,GAAG,iBAAiB;;AACjH;AAEA,+BAAS,YAAY,GAAG;IACtB,UAAU;AACZ;IAEA,2CAAe;;;;AJff,MAAM,4CAAY,CAAS,sBACzB,gCAAC,CAAA,GAAA,wCAAK;QAAE,iBAAiB,CAAA,GAAA,2CAAS;QAAI,GAAG,KAAK;;AAEhD,MAAM,4CAAY,CAAS,sBACzB,gCAAC,CAAA,GAAA,wCAAK;QAAE,iBAAiB,CAAA,GAAA,2CAAS;QAAI,GAAG,KAAK;;AAEhD,MAAM,2CAAgB,CAAS,sBAC7B,gCAAC,CAAA,GAAA,wCAAK;QAAE,iBAAiB,CAAA,GAAA,mDAAa;QAAI,GAAG,KAAK","sources":["packages/date-components/src/index.tsx","packages/date-components/src/Picker.tsx","packages/date-components/src/CalendarList.js","packages/date-components/src/useFullCalendarProps.js","packages/date-components/src/DaysList.js"],"sourcesContent":["/* eslint-disable react/react-in-jsx-scope */\n/* eslint-disable react/jsx-props-no-spreading */\n\n// Solves bug with Vite in dev mode. Can be removed when we upgrade to FullCalendar v6\n// See https://github.com/fullcalendar/fullcalendar-vue/issues/152\nimport '@fullcalendar/core/vdom';\n\nimport { DatePicker, DatePickerProps } from '@mui/x-date-pickers/DatePicker';\nimport { TimePicker, TimePickerProps } from '@mui/x-date-pickers/TimePicker';\nimport { DateTimePicker, DateTimePickerProps } from '@mui/x-date-pickers/DateTimePicker';\nimport Picker, { Props as PickerProps } from './Picker';\n\nconst DateInput = <TDate,>(props: Omit<PickerProps<DatePickerProps<TDate>>, 'PickerComponent'>) => (\n <Picker PickerComponent={DatePicker} {...props} />\n);\nconst TimeInput = <TDate,>(props: Omit<PickerProps<TimePickerProps<TDate>>, 'PickerComponent'>) => (\n <Picker PickerComponent={TimePicker} {...props} />\n);\nconst DateTimeInput = <TDate,>(props: Omit<PickerProps<DateTimePickerProps<TDate>>, 'PickerComponent'>) => (\n <Picker PickerComponent={DateTimePicker} {...props} />\n);\n\nexport { DateInput, TimeInput, DateTimeInput };\n\nexport { default as CalendarList } from './CalendarList';\nexport { default as DaysList } from './DaysList';\nexport { default as useFullCalendarProps } from './useFullCalendarProps';\n","/* eslint-disable react/react-in-jsx-scope */\n/* eslint-disable react/require-default-props */\nimport { useCallback, ComponentType } from 'react';\nimport { useInput, InputHelperText, TextInputProps, useTranslateLabel } from 'react-admin';\nimport { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';\nimport { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';\nimport { getPickersLocalization } from '@mui/x-date-pickers/locales/utils/getPickersLocalization';\nimport { Locale } from 'date-fns';\n\nexport type Props<PickerProps> = TextInputProps &\n Omit<PickerProps, 'format'> & {\n PickerComponent: ComponentType;\n locale?: Locale;\n translations?: ReturnType<typeof getPickersLocalization>;\n stringFormat?: string;\n };\n\nconst Picker = <PickerProps,>({\n PickerComponent,\n label,\n source,\n helperText,\n fullWidth,\n onBlur,\n onChange,\n format,\n parse,\n validate,\n defaultValue,\n locale,\n translations,\n stringFormat = 'ISO',\n ...rest\n}: Props<PickerProps>) => {\n const {\n field,\n isRequired,\n fieldState: { error, isTouched, invalid },\n formState: { isSubmitted }\n } = useInput({\n format,\n onBlur,\n onChange,\n parse,\n source,\n validate,\n defaultValue\n });\n\n const handleChange = useCallback(\n (value: Date) => {\n if (value instanceof Date) {\n field.onChange(stringFormat === 'ISO' ? value.toISOString() : value.toString());\n } else {\n field.onChange(null);\n }\n },\n [field, stringFormat]\n );\n\n const translateLabel = useTranslateLabel();\n const translatedLabel = (\n <span>\n {translateLabel({\n label,\n source\n })}\n {isRequired && <span aria-hidden=\"true\"> *</span>}\n </span>\n );\n\n return (\n <LocalizationProvider\n dateAdapter={AdapterDateFns}\n adapterLocale={locale}\n localeText={translations?.components.MuiLocalizationProvider.defaultProps.localeText}\n >\n <PickerComponent\n label={translatedLabel}\n slotProps={{\n textField: {\n error: (isTouched || isSubmitted) && invalid,\n size: 'small',\n fullWidth,\n helperText: (\n <InputHelperText touched={isTouched || isSubmitted} error={error?.message} helperText={helperText} />\n )\n }\n }}\n value={field.value ? new Date(field.value) : null}\n onChange={handleChange}\n /* eslint-disable-next-line react/jsx-props-no-spreading */\n {...rest}\n />\n </LocalizationProvider>\n );\n};\n\nexport default Picker;\n","import React from 'react';\nimport FullCalendar from '@fullcalendar/react';\nimport dayGridPlugin from '@fullcalendar/daygrid';\nimport { useTheme } from '@mui/material';\nimport makeStyles from '@mui/styles/makeStyles';\nimport useFullCalendarProps from './useFullCalendarProps';\n\nconst useGlobalStyles = makeStyles(theme => ({\n '@global': {\n '.fc-button': {\n backgroundColor: `${theme.palette.primary.main} !important`,\n border: 'none !important',\n opacity: '1 !important'\n },\n '.fc-day-today': {\n backgroundColor: `${theme.palette.secondary.light} !important`\n },\n // Overwrite violet color of links\n 'a.fc-daygrid-dot-event': {\n color: 'black !important'\n }\n }\n}));\n\nconst CalendarList = props => {\n const theme = useTheme();\n const fullCalendarProps = useFullCalendarProps(props);\n useGlobalStyles();\n\n return (\n <FullCalendar\n plugins={[dayGridPlugin]}\n locale={props.locale}\n initialView=\"dayGridMonth\"\n eventBackgroundColor={theme.palette.primary.main}\n {...fullCalendarProps}\n />\n );\n};\n\nCalendarList.defaultProps = {\n linkType: 'edit'\n};\n\nexport default CalendarList;\n","import React, { useMemo, useCallback } from 'react';\nimport { useSearchParams, useNavigate } from 'react-router-dom';\nimport { useListContext, useCreatePath } from 'react-admin';\n\nconst useFullCalendarProps = ({ label, startDate, endDate, linkType }) => {\n const { data, isLoading, resource } = useListContext();\n const [searchParams, setSearchParams] = useSearchParams();\n const navigate = useNavigate();\n const createPath = useCreatePath();\n\n const query = new URLSearchParams(location.search);\n\n // Bypass the link in order to use React-Router\n const eventClick = useCallback(({ event, jsEvent }) => {\n jsEvent.preventDefault();\n navigate(event.url);\n }, []);\n\n // Change the query string when month change\n const datesSet = useCallback(\n ({ view }) => {\n setSearchParams(params => ({\n ...params,\n month: view.currentStart.getMonth() + 1,\n year: view.currentStart.getFullYear()\n }));\n },\n [setSearchParams]\n );\n\n const events = useMemo(\n () =>\n !isLoading &&\n data\n .filter(record => record)\n .map(record => ({\n id: record.id,\n title: typeof label === 'string' ? record[label] : label(record),\n start: typeof startDate === 'string' ? record[startDate] : startDate(record),\n end: typeof endDate === 'string' ? record[endDate] : endDate(record),\n url: createPath({ resource, id: record.id, type: linkType })\n })),\n [isLoading, data, resource, createPath]\n );\n\n return {\n initialDate: query.has('month') ? new Date(query.get('year'), query.get('month') - 1) : new Date(),\n events,\n datesSet,\n eventClick\n };\n};\n\nexport default useFullCalendarProps;\n","import React from 'react';\nimport FullCalendar from '@fullcalendar/react';\nimport listPlugin from '@fullcalendar/list';\nimport makeStyles from '@mui/styles/makeStyles';\nimport useFullCalendarProps from './useFullCalendarProps';\n\nconst useGlobalStyles = makeStyles(theme => ({\n '@global': {\n '.fc-button': {\n backgroundColor: `${theme.palette.primary.main} !important`,\n border: 'none !important',\n opacity: '1 !important'\n }\n }\n}));\n\nconst DaysList = props => {\n const fullCalendarProps = useFullCalendarProps(props);\n useGlobalStyles();\n\n return <FullCalendar plugins={[listPlugin]} locale={props.locale} initialView=\"listMonth\" {...fullCalendarProps} />;\n};\n\nDaysList.defaultProps = {\n linkType: 'edit'\n};\n\nexport default DaysList;\n"],"names":[],"version":3,"file":"index.cjs.js.map"}
|
package/dist/index.es.js
CHANGED
|
@@ -26,7 +26,7 @@ import $5Ihaz$fullcalendarlist from "@fullcalendar/list";
|
|
|
26
26
|
|
|
27
27
|
|
|
28
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 =
|
|
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
30
|
const { field: field, isRequired: isRequired, fieldState: { error: error, isTouched: isTouched, invalid: invalid }, formState: { isSubmitted: isSubmitted } } = (0, $5Ihaz$useInput)({
|
|
31
31
|
format: format,
|
|
32
32
|
onBlur: onBlur,
|
|
@@ -37,7 +37,7 @@ const $610808f89222f9cc$var$Picker = ({ PickerComponent: PickerComponent, label:
|
|
|
37
37
|
defaultValue: defaultValue
|
|
38
38
|
});
|
|
39
39
|
const handleChange = (0, $5Ihaz$useCallback)((value)=>{
|
|
40
|
-
if (value instanceof Date) field.onChange(stringFormat ===
|
|
40
|
+
if (value instanceof Date) field.onChange(stringFormat === 'ISO' ? value.toISOString() : value.toString());
|
|
41
41
|
else field.onChange(null);
|
|
42
42
|
}, [
|
|
43
43
|
field,
|
|
@@ -65,7 +65,7 @@ const $610808f89222f9cc$var$Picker = ({ PickerComponent: PickerComponent, label:
|
|
|
65
65
|
slotProps: {
|
|
66
66
|
textField: {
|
|
67
67
|
error: (isTouched || isSubmitted) && invalid,
|
|
68
|
-
size:
|
|
68
|
+
size: 'small',
|
|
69
69
|
fullWidth: fullWidth,
|
|
70
70
|
helperText: /*#__PURE__*/ (0, $5Ihaz$jsx)((0, $5Ihaz$InputHelperText), {
|
|
71
71
|
touched: isTouched || isSubmitted,
|
|
@@ -115,9 +115,9 @@ const $37245c02f9b1b006$var$useFullCalendarProps = ({ label: label, startDate: s
|
|
|
115
115
|
]);
|
|
116
116
|
const events = (0, $5Ihaz$useMemo)(()=>!isLoading && data.filter((record)=>record).map((record)=>({
|
|
117
117
|
id: record.id,
|
|
118
|
-
title: typeof label ===
|
|
119
|
-
start: typeof startDate ===
|
|
120
|
-
end: typeof endDate ===
|
|
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
121
|
url: createPath({
|
|
122
122
|
resource: resource,
|
|
123
123
|
id: record.id,
|
|
@@ -130,7 +130,7 @@ const $37245c02f9b1b006$var$useFullCalendarProps = ({ label: label, startDate: s
|
|
|
130
130
|
createPath
|
|
131
131
|
]);
|
|
132
132
|
return {
|
|
133
|
-
initialDate: query.has(
|
|
133
|
+
initialDate: query.has('month') ? new Date(query.get('year'), query.get('month') - 1) : new Date(),
|
|
134
134
|
events: events,
|
|
135
135
|
datesSet: datesSet,
|
|
136
136
|
eventClick: eventClick
|
|
@@ -140,18 +140,18 @@ var $37245c02f9b1b006$export$2e2bcd8739ae039 = $37245c02f9b1b006$var$useFullCale
|
|
|
140
140
|
|
|
141
141
|
|
|
142
142
|
const $abbcc02f55461290$var$useGlobalStyles = (0, $5Ihaz$muistylesmakeStyles)((theme)=>({
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
'@global': {
|
|
144
|
+
'.fc-button': {
|
|
145
145
|
backgroundColor: `${theme.palette.primary.main} !important`,
|
|
146
|
-
border:
|
|
147
|
-
opacity:
|
|
146
|
+
border: 'none !important',
|
|
147
|
+
opacity: '1 !important'
|
|
148
148
|
},
|
|
149
|
-
|
|
149
|
+
'.fc-day-today': {
|
|
150
150
|
backgroundColor: `${theme.palette.secondary.light} !important`
|
|
151
151
|
},
|
|
152
152
|
// Overwrite violet color of links
|
|
153
|
-
|
|
154
|
-
color:
|
|
153
|
+
'a.fc-daygrid-dot-event': {
|
|
154
|
+
color: 'black !important'
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
}));
|
|
@@ -170,7 +170,7 @@ const $abbcc02f55461290$var$CalendarList = (props)=>{
|
|
|
170
170
|
});
|
|
171
171
|
};
|
|
172
172
|
$abbcc02f55461290$var$CalendarList.defaultProps = {
|
|
173
|
-
linkType:
|
|
173
|
+
linkType: 'edit'
|
|
174
174
|
};
|
|
175
175
|
var $abbcc02f55461290$export$2e2bcd8739ae039 = $abbcc02f55461290$var$CalendarList;
|
|
176
176
|
|
|
@@ -182,11 +182,11 @@ var $abbcc02f55461290$export$2e2bcd8739ae039 = $abbcc02f55461290$var$CalendarLis
|
|
|
182
182
|
|
|
183
183
|
|
|
184
184
|
const $69d9f850452774a2$var$useGlobalStyles = (0, $5Ihaz$muistylesmakeStyles)((theme)=>({
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
'@global': {
|
|
186
|
+
'.fc-button': {
|
|
187
187
|
backgroundColor: `${theme.palette.primary.main} !important`,
|
|
188
|
-
border:
|
|
189
|
-
opacity:
|
|
188
|
+
border: 'none !important',
|
|
189
|
+
opacity: '1 !important'
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
}));
|
|
@@ -203,7 +203,7 @@ const $69d9f850452774a2$var$DaysList = (props)=>{
|
|
|
203
203
|
});
|
|
204
204
|
};
|
|
205
205
|
$69d9f850452774a2$var$DaysList.defaultProps = {
|
|
206
|
-
linkType:
|
|
206
|
+
linkType: 'edit'
|
|
207
207
|
};
|
|
208
208
|
var $69d9f850452774a2$export$2e2bcd8739ae039 = $69d9f850452774a2$var$DaysList;
|
|
209
209
|
|
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA2C,GAC3C,+CAA+C,GAE/C,sFAAsF;AACtF,kEAAkE;;;;;;ACJlE,2CAA2C,GAC3C,8CAA8C;;;;;AAgB9C,MAAM,+BAAS,CAAe,mBAC5B,eAAe,SACf,KAAK,UACL,MAAM,cACN,UAAU,aACV,SAAS,UACT,MAAM,YACN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S,YAAY,GAAG;IACtB,UAAU;AACZ;IAEA,2CAAe;;;;AJff,MAAM,4CAAY,CAAS,sBACzB,gBAAC,CAAA,GAAA,wCAAK;QAAE,iBAAiB,CAAA,GAAA,iBAAS;QAAI,GAAG,KAAK;;AAEhD,MAAM,4CAAY,CAAS,sBACzB,gBAAC,CAAA,GAAA,wCAAK;QAAE,iBAAiB,CAAA,GAAA,iBAAS;QAAI,GAAG,KAAK;;AAEhD,MAAM,2CAAgB,CAAS,sBAC7B,gBAAC,CAAA,GAAA,wCAAK;QAAE,iBAAiB,CAAA,GAAA,qBAAa;QAAI,GAAG,KAAK","sources":["packages/date-components/src/index.tsx","packages/date-components/src/Picker.tsx","packages/date-components/src/CalendarList.js","packages/date-components/src/useFullCalendarProps.js","packages/date-components/src/DaysList.js"],"sourcesContent":["/* eslint-disable react/react-in-jsx-scope */\n/* eslint-disable react/jsx-props-no-spreading */\n\n// Solves bug with Vite in dev mode. Can be removed when we upgrade to FullCalendar v6\n// See https://github.com/fullcalendar/fullcalendar-vue/issues/152\nimport '@fullcalendar/core/vdom';\n\nimport { DatePicker, DatePickerProps } from '@mui/x-date-pickers/DatePicker';\nimport { TimePicker, TimePickerProps } from '@mui/x-date-pickers/TimePicker';\nimport { DateTimePicker, DateTimePickerProps } from '@mui/x-date-pickers/DateTimePicker';\nimport Picker, { Props as PickerProps } from './Picker';\n\nconst DateInput = <TDate,>(props: Omit<PickerProps<DatePickerProps<TDate>>, 'PickerComponent'>) => (\n <Picker PickerComponent={DatePicker} {...props} />\n);\nconst TimeInput = <TDate,>(props: Omit<PickerProps<TimePickerProps<TDate>>, 'PickerComponent'>) => (\n <Picker PickerComponent={TimePicker} {...props} />\n);\nconst DateTimeInput = <TDate,>(props: Omit<PickerProps<DateTimePickerProps<TDate>>, 'PickerComponent'>) => (\n <Picker PickerComponent={DateTimePicker} {...props} />\n);\n\nexport { DateInput, TimeInput, DateTimeInput };\n\nexport { default as CalendarList } from './CalendarList';\nexport { default as DaysList } from './DaysList';\nexport { default as useFullCalendarProps } from './useFullCalendarProps';\n","/* eslint-disable react/react-in-jsx-scope */\n/* eslint-disable react/require-default-props */\nimport { useCallback, ComponentType } from 'react';\nimport { useInput, InputHelperText, TextInputProps, useTranslateLabel } from 'react-admin';\nimport { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';\nimport { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';\nimport { getPickersLocalization } from '@mui/x-date-pickers/locales/utils/getPickersLocalization';\nimport { Locale } from 'date-fns';\n\nexport type Props<PickerProps> = TextInputProps &\n Omit<PickerProps, 'format'> & {\n PickerComponent: ComponentType;\n locale?: Locale;\n translations?: ReturnType<typeof getPickersLocalization>;\n stringFormat?: string;\n };\n\nconst Picker = <PickerProps,>({\n PickerComponent,\n label,\n source,\n helperText,\n fullWidth,\n onBlur,\n onChange,\n format,\n parse,\n validate,\n defaultValue,\n locale,\n translations,\n stringFormat = 'ISO',\n ...rest\n}: Props<PickerProps>) => {\n const {\n field,\n isRequired,\n fieldState: { error, isTouched, invalid },\n formState: { isSubmitted }\n } = useInput({\n format,\n onBlur,\n onChange,\n parse,\n source,\n validate,\n defaultValue\n });\n\n const handleChange = useCallback(\n (value: Date) => {\n if (value instanceof Date) {\n field.onChange(stringFormat === 'ISO' ? value.toISOString() : value.toString());\n } else {\n field.onChange(null);\n }\n },\n [field, stringFormat]\n );\n\n const translateLabel = useTranslateLabel();\n const translatedLabel = (\n <span>\n {translateLabel({\n label,\n source\n })}\n {isRequired && <span aria-hidden=\"true\"> *</span>}\n </span>\n );\n\n return (\n <LocalizationProvider\n dateAdapter={AdapterDateFns}\n adapterLocale={locale}\n localeText={translations?.components.MuiLocalizationProvider.defaultProps.localeText}\n >\n <PickerComponent\n label={translatedLabel}\n slotProps={{\n textField: {\n error: (isTouched || isSubmitted) && invalid,\n size: 'small',\n fullWidth,\n helperText: (\n <InputHelperText touched={isTouched || isSubmitted} error={error?.message} helperText={helperText} />\n )\n }\n }}\n value={field.value ? new Date(field.value) : null}\n onChange={handleChange}\n /* eslint-disable-next-line react/jsx-props-no-spreading */\n {...rest}\n />\n </LocalizationProvider>\n );\n};\n\nexport default Picker;\n","import React from 'react';\nimport FullCalendar from '@fullcalendar/react';\nimport dayGridPlugin from '@fullcalendar/daygrid';\nimport { useTheme } from '@mui/material';\nimport makeStyles from '@mui/styles/makeStyles';\nimport useFullCalendarProps from './useFullCalendarProps';\n\nconst useGlobalStyles = makeStyles(theme => ({\n '@global': {\n '.fc-button': {\n backgroundColor: `${theme.palette.primary.main} !important`,\n border: 'none !important',\n opacity: '1 !important'\n },\n '.fc-day-today': {\n backgroundColor: `${theme.palette.secondary.light} !important`\n },\n // Overwrite violet color of links\n 'a.fc-daygrid-dot-event': {\n color: 'black !important'\n }\n }\n}));\n\nconst CalendarList = props => {\n const theme = useTheme();\n const fullCalendarProps = useFullCalendarProps(props);\n useGlobalStyles();\n\n return (\n <FullCalendar\n plugins={[dayGridPlugin]}\n locale={props.locale}\n initialView=\"dayGridMonth\"\n eventBackgroundColor={theme.palette.primary.main}\n {...fullCalendarProps}\n />\n );\n};\n\nCalendarList.defaultProps = {\n linkType: 'edit'\n};\n\nexport default CalendarList;\n","import React, { useMemo, useCallback } from 'react';\nimport { useSearchParams, useNavigate } from 'react-router-dom';\nimport { useListContext, useCreatePath } from 'react-admin';\n\nconst useFullCalendarProps = ({ label, startDate, endDate, linkType }) => {\n const { data, isLoading, resource } = useListContext();\n const [searchParams, setSearchParams] = useSearchParams();\n const navigate = useNavigate();\n const createPath = useCreatePath();\n\n const query = new URLSearchParams(location.search);\n\n // Bypass the link in order to use React-Router\n const eventClick = useCallback(({ event, jsEvent }) => {\n jsEvent.preventDefault();\n navigate(event.url);\n }, []);\n\n // Change the query string when month change\n const datesSet = useCallback(\n ({ view }) => {\n setSearchParams(params => ({\n ...params,\n month: view.currentStart.getMonth() + 1,\n year: view.currentStart.getFullYear()\n }));\n },\n [setSearchParams]\n );\n\n const events = useMemo(\n () =>\n !isLoading &&\n data\n .filter(record => record)\n .map(record => ({\n id: record.id,\n title: typeof label === 'string' ? record[label] : label(record),\n start: typeof startDate === 'string' ? record[startDate] : startDate(record),\n end: typeof endDate === 'string' ? record[endDate] : endDate(record),\n url: createPath({ resource, id: record.id, type: linkType })\n })),\n [isLoading, data, resource, createPath]\n );\n\n return {\n initialDate: query.has('month') ? new Date(query.get('year'), query.get('month') - 1) : new Date(),\n events,\n datesSet,\n eventClick\n };\n};\n\nexport default useFullCalendarProps;\n","import React from 'react';\nimport FullCalendar from '@fullcalendar/react';\nimport listPlugin from '@fullcalendar/list';\nimport makeStyles from '@mui/styles/makeStyles';\nimport useFullCalendarProps from './useFullCalendarProps';\n\nconst useGlobalStyles = makeStyles(theme => ({\n '@global': {\n '.fc-button': {\n backgroundColor: `${theme.palette.primary.main} !important`,\n border: 'none !important',\n opacity: '1 !important'\n }\n }\n}));\n\nconst DaysList = props => {\n const fullCalendarProps = useFullCalendarProps(props);\n useGlobalStyles();\n\n return <FullCalendar plugins={[listPlugin]} locale={props.locale} initialView=\"listMonth\" {...fullCalendarProps} />;\n};\n\nDaysList.defaultProps = {\n linkType: 'edit'\n};\n\nexport default DaysList;\n"],"names":[],"version":3,"file":"index.es.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA2C,GAC3C,+CAA+C,GAE/C,sFAAsF;AACtF,kEAAkE;;;;;;ACJlE,2CAA2C,GAC3C,8CAA8C;;;;;AAgB9C,MAAM,+BAAS,CAAe,mBAC5B,eAAe,SACf,KAAK,UACL,MAAM,cACN,UAAU,aACV,SAAS,UACT,MAAM,YACN,QAAQ,UACR,MAAM,SACN,KAAK,YACL,QAAQ,gBACR,YAAY,UACZ,MAAM,gBACN,YAAY,gBACZ,eAAe,OACf,GAAG,MACgB;IACnB,MAAM,SACJ,KAAK,cACL,UAAU,EACV,YAAY,SAAE,KAAK,aAAE,SAAS,WAAE,OAAO,EAAE,EACzC,WAAW,eAAE,WAAW,EA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GAAA,iBAAS;QAAI,GAAG,KAAK;;AAEhD,MAAM,2CAAgB,CAAS,sBAC7B,gBAAC,CAAA,GAAA,wCAAK;QAAE,iBAAiB,CAAA,GAAA,qBAAa;QAAI,GAAG,KAAK","sources":["packages/date-components/src/index.tsx","packages/date-components/src/Picker.tsx","packages/date-components/src/CalendarList.js","packages/date-components/src/useFullCalendarProps.js","packages/date-components/src/DaysList.js"],"sourcesContent":["/* eslint-disable react/react-in-jsx-scope */\n/* eslint-disable react/jsx-props-no-spreading */\n\n// Solves bug with Vite in dev mode. Can be removed when we upgrade to FullCalendar v6\n// See https://github.com/fullcalendar/fullcalendar-vue/issues/152\nimport '@fullcalendar/core/vdom';\n\nimport { DatePicker, DatePickerProps } from '@mui/x-date-pickers/DatePicker';\nimport { TimePicker, TimePickerProps } from '@mui/x-date-pickers/TimePicker';\nimport { DateTimePicker, DateTimePickerProps } from '@mui/x-date-pickers/DateTimePicker';\nimport Picker, { Props as PickerProps } from './Picker';\n\nconst DateInput = <TDate,>(props: Omit<PickerProps<DatePickerProps<TDate>>, 'PickerComponent'>) => (\n <Picker PickerComponent={DatePicker} {...props} />\n);\nconst TimeInput = <TDate,>(props: Omit<PickerProps<TimePickerProps<TDate>>, 'PickerComponent'>) => (\n <Picker PickerComponent={TimePicker} {...props} />\n);\nconst DateTimeInput = <TDate,>(props: Omit<PickerProps<DateTimePickerProps<TDate>>, 'PickerComponent'>) => (\n <Picker PickerComponent={DateTimePicker} {...props} />\n);\n\nexport { DateInput, TimeInput, DateTimeInput };\n\nexport { default as CalendarList } from './CalendarList';\nexport { default as DaysList } from './DaysList';\nexport { default as useFullCalendarProps } from './useFullCalendarProps';\n","/* eslint-disable react/react-in-jsx-scope */\n/* eslint-disable react/require-default-props */\nimport { useCallback, ComponentType } from 'react';\nimport { useInput, InputHelperText, TextInputProps, useTranslateLabel } from 'react-admin';\nimport { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';\nimport { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';\nimport { getPickersLocalization } from '@mui/x-date-pickers/locales/utils/getPickersLocalization';\nimport { Locale } from 'date-fns';\n\nexport type Props<PickerProps> = TextInputProps &\n Omit<PickerProps, 'format'> & {\n PickerComponent: ComponentType;\n locale?: Locale;\n translations?: ReturnType<typeof getPickersLocalization>;\n stringFormat?: string;\n };\n\nconst Picker = <PickerProps,>({\n PickerComponent,\n label,\n source,\n helperText,\n fullWidth,\n onBlur,\n onChange,\n format,\n parse,\n validate,\n defaultValue,\n locale,\n translations,\n stringFormat = 'ISO',\n ...rest\n}: Props<PickerProps>) => {\n const {\n field,\n isRequired,\n fieldState: { error, isTouched, invalid },\n formState: { isSubmitted }\n } = useInput({\n format,\n onBlur,\n onChange,\n parse,\n source,\n validate,\n defaultValue\n });\n\n const handleChange = useCallback(\n (value: Date) => {\n if (value instanceof Date) {\n field.onChange(stringFormat === 'ISO' ? value.toISOString() : value.toString());\n } else {\n field.onChange(null);\n }\n },\n [field, stringFormat]\n );\n\n const translateLabel = useTranslateLabel();\n const translatedLabel = (\n <span>\n {translateLabel({\n label,\n source\n })}\n {isRequired && <span aria-hidden=\"true\"> *</span>}\n </span>\n );\n\n return (\n <LocalizationProvider\n dateAdapter={AdapterDateFns}\n adapterLocale={locale}\n localeText={translations?.components.MuiLocalizationProvider.defaultProps.localeText}\n >\n <PickerComponent\n label={translatedLabel}\n slotProps={{\n textField: {\n error: (isTouched || isSubmitted) && invalid,\n size: 'small',\n fullWidth,\n helperText: (\n <InputHelperText touched={isTouched || isSubmitted} error={error?.message} helperText={helperText} />\n )\n }\n }}\n value={field.value ? new Date(field.value) : null}\n onChange={handleChange}\n /* eslint-disable-next-line react/jsx-props-no-spreading */\n {...rest}\n />\n </LocalizationProvider>\n );\n};\n\nexport default Picker;\n","import React from 'react';\nimport FullCalendar from '@fullcalendar/react';\nimport dayGridPlugin from '@fullcalendar/daygrid';\nimport { useTheme } from '@mui/material';\nimport makeStyles from '@mui/styles/makeStyles';\nimport useFullCalendarProps from './useFullCalendarProps';\n\nconst useGlobalStyles = makeStyles(theme => ({\n '@global': {\n '.fc-button': {\n backgroundColor: `${theme.palette.primary.main} !important`,\n border: 'none !important',\n opacity: '1 !important'\n },\n '.fc-day-today': {\n backgroundColor: `${theme.palette.secondary.light} !important`\n },\n // Overwrite violet color of links\n 'a.fc-daygrid-dot-event': {\n color: 'black !important'\n }\n }\n}));\n\nconst CalendarList = props => {\n const theme = useTheme();\n const fullCalendarProps = useFullCalendarProps(props);\n useGlobalStyles();\n\n return (\n <FullCalendar\n plugins={[dayGridPlugin]}\n locale={props.locale}\n initialView=\"dayGridMonth\"\n eventBackgroundColor={theme.palette.primary.main}\n {...fullCalendarProps}\n />\n );\n};\n\nCalendarList.defaultProps = {\n linkType: 'edit'\n};\n\nexport default CalendarList;\n","import React, { useMemo, useCallback } from 'react';\nimport { useSearchParams, useNavigate } from 'react-router-dom';\nimport { useListContext, useCreatePath } from 'react-admin';\n\nconst useFullCalendarProps = ({ label, startDate, endDate, linkType }) => {\n const { data, isLoading, resource } = useListContext();\n const [searchParams, setSearchParams] = useSearchParams();\n const navigate = useNavigate();\n const createPath = useCreatePath();\n\n const query = new URLSearchParams(location.search);\n\n // Bypass the link in order to use React-Router\n const eventClick = useCallback(({ event, jsEvent }) => {\n jsEvent.preventDefault();\n navigate(event.url);\n }, []);\n\n // Change the query string when month change\n const datesSet = useCallback(\n ({ view }) => {\n setSearchParams(params => ({\n ...params,\n month: view.currentStart.getMonth() + 1,\n year: view.currentStart.getFullYear()\n }));\n },\n [setSearchParams]\n );\n\n const events = useMemo(\n () =>\n !isLoading &&\n data\n .filter(record => record)\n .map(record => ({\n id: record.id,\n title: typeof label === 'string' ? record[label] : label(record),\n start: typeof startDate === 'string' ? record[startDate] : startDate(record),\n end: typeof endDate === 'string' ? record[endDate] : endDate(record),\n url: createPath({ resource, id: record.id, type: linkType })\n })),\n [isLoading, data, resource, createPath]\n );\n\n return {\n initialDate: query.has('month') ? new Date(query.get('year'), query.get('month') - 1) : new Date(),\n events,\n datesSet,\n eventClick\n };\n};\n\nexport default useFullCalendarProps;\n","import React from 'react';\nimport FullCalendar from '@fullcalendar/react';\nimport listPlugin from '@fullcalendar/list';\nimport makeStyles from '@mui/styles/makeStyles';\nimport useFullCalendarProps from './useFullCalendarProps';\n\nconst useGlobalStyles = makeStyles(theme => ({\n '@global': {\n '.fc-button': {\n backgroundColor: `${theme.palette.primary.main} !important`,\n border: 'none !important',\n opacity: '1 !important'\n }\n }\n}));\n\nconst DaysList = props => {\n const fullCalendarProps = useFullCalendarProps(props);\n useGlobalStyles();\n\n return <FullCalendar plugins={[listPlugin]} locale={props.locale} initialView=\"listMonth\" {...fullCalendarProps} />;\n};\n\nDaysList.defaultProps = {\n linkType: 'edit'\n};\n\nexport default DaysList;\n"],"names":[],"version":3,"file":"index.es.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semapps/date-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.1.0-patch.1",
|
|
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": "b7a37bb6925e385b89b3df5a9b9d43a8c8cb1052"
|
|
45
45
|
}
|