@semapps/date-components 0.6.0-alpha.2 → 0.6.0-alpha.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/README.md +2 -2
- package/dist/index.cjs.js +3 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +1 -1
- package/dist/index.es.js.map +1 -1
- package/package.json +4 -7
package/README.md
CHANGED
|
@@ -6,11 +6,11 @@ See the [dedicated page on the SemApps website](https://semapps.org/docs/fronten
|
|
|
6
6
|
|
|
7
7
|
## Development
|
|
8
8
|
|
|
9
|
-
### `
|
|
9
|
+
### `yarn run build`
|
|
10
10
|
|
|
11
11
|
Build the library in CommonJS and ES mode.
|
|
12
12
|
This command should always be run before publishing.
|
|
13
13
|
|
|
14
|
-
### `
|
|
14
|
+
### `yarn run watch`
|
|
15
15
|
|
|
16
16
|
Develop mode. Any change you make to a file in the `/src` directory will be immediately compiled.
|
package/dist/index.cjs.js
CHANGED
|
@@ -13,9 +13,11 @@ var $3RhHq$muistylesmakeStyles = require("@mui/styles/makeStyles");
|
|
|
13
13
|
var $3RhHq$reactrouterdom = require("react-router-dom");
|
|
14
14
|
var $3RhHq$fullcalendarlist = require("@fullcalendar/list");
|
|
15
15
|
|
|
16
|
+
|
|
16
17
|
function $parcel$export(e, n, v, s) {
|
|
17
18
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
18
19
|
}
|
|
20
|
+
|
|
19
21
|
function $parcel$interopDefault(a) {
|
|
20
22
|
return a && a.__esModule ? a.default : a;
|
|
21
23
|
}
|
|
@@ -61,7 +63,7 @@ const $c332daa71b957685$var$Picker = ({ PickerComponent: PickerComponent, label:
|
|
|
61
63
|
}),
|
|
62
64
|
isRequired && /*#__PURE__*/ (0, $3RhHq$reactjsxruntime.jsx)("span", {
|
|
63
65
|
"aria-hidden": "true",
|
|
64
|
-
children: "
|
|
66
|
+
children: "\u2009*"
|
|
65
67
|
})
|
|
66
68
|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AA,iDAAS;SAAE;QAAE,QAAQ,MAAM;QAAQ,aAAY;QAAa,GAAG,iBAAiB;;AACjH;AAEA,+BAAS,eAAe;IACtB,UAAU;AACZ;IAEA,2CAAe;;;;AJpBf,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 */\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"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA2C,GAC3C,+CAA+C;;;;ACD/C,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,EAA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AI,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 */\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
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;AAAA,2CAA2C,GAC3C,+CAA+C;;;;ACD/C,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,eAAO,EAAE;gBACX;gBACA;kBACA;eACA;gBACA;kBACA;sBACA;IACF;IAEA,MAAM,eAAe,CAAA,GAAA,kBAAU,EAC7B,CAAC;QACC,IAAI,iBAAiB,MACnB,MAAM,SAAS,iBAAiB,QAAQ,MAAM,gBAAgB,MAAM;aAEpE,MAAM,SAAS;IAEnB,GACA;QAAC;QAAO;KAAa;IAGvB,MAAM,iBAAiB,CAAA,GAAA,wBAAgB;IACvC,MAAM,gCACJ,iBAAC;;YACE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B,UAAU;AACZ;IAEA,2CAAe;;;;;;;;;AEtCf,MAAM,wCAAkB,CAAA,GAAA,0BAAS,EAAE,CAAA,QAAU,CAAA;QAC3C,WAAW;YACT,cAAc;gBACZ,iBAAiB,CAAC,EAAE,MAAM,QAAQ,QAAQ,KAAK,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,gBAAC,CAAA,GAAA,wBAAW;QAAE,SAAS;YAAC,CAAA,GAAA,uBAAS;SAAE;QAAE,QAAQ,MAAM;QAAQ,aAAY;QAAa,GAAG,iBAAiB;;AACjH;AAEA,+BAAS,eAAe;IACtB,UAAU;AACZ;IAEA,2CAAe;;;;AJpBf,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 */\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;;;;ACD/C,2CAA2C,GAC3C,8CAA8C;;;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,CAAA,GAAA,uBAAS;SAAE;QAAE,QAAQ,MAAM,MAAM;QAAE,aAAY;QAAa,GAAG,iBAAiB;;AACjH;AAEA,+BAAS,YAAY,GAAG;IACtB,UAAU;AACZ;IAEA,2CAAe;;;;AJpBf,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 */\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": "0.6.0-alpha.
|
|
3
|
+
"version": "0.6.0-alpha.3",
|
|
4
4
|
"description": "React-Admin components for date display and input",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Virtual Assembly",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"dist"
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
|
-
"build": "
|
|
16
|
-
"watch": "
|
|
15
|
+
"build": "parcel build && yalc publish --push --changed",
|
|
16
|
+
"watch": "nodemon --watch src --exec 'yarn build'",
|
|
17
17
|
"typecheck": "tsc --noEmit"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
@@ -37,12 +37,9 @@
|
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@mui/material": "^5.13.1",
|
|
39
39
|
"@mui/styles": "^5.13.1",
|
|
40
|
-
"@parcel/packager-ts": "^2.9.3",
|
|
41
|
-
"@parcel/transformer-typescript-types": "^2.9.3",
|
|
42
|
-
"parcel": "^2.9.3",
|
|
43
40
|
"react": "^18.2.0",
|
|
44
41
|
"react-admin": "^4.11.0",
|
|
45
42
|
"react-router-dom": "^6.1.0"
|
|
46
43
|
},
|
|
47
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "f7e2d37d80a63acb75a2fdc306d6b512b7f901d2"
|
|
48
45
|
}
|