ish-ui 1.0.30 → 1.0.32
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/formFields/EditInPlaceFileField.js +2 -1
- package/dist/formFields/EditInPlaceMoneyField.d.ts +1 -1
- package/dist/formFields/EditInPlaceMoneyField.js +3 -2
- package/dist/formFields/EditInPlacePhoneField.js +2 -1
- package/dist/timetable/miniCalendar/CalendarDay.d.ts +10 -2
- package/dist/timetable/miniCalendar/CalendarDay.js +27 -20
- package/dist/timetable/miniCalendar/CalendarHeader.d.ts +9 -3
- package/dist/timetable/miniCalendar/CalendarHeader.js +22 -18
- package/dist/timetable/miniCalendar/CalendarWeekPanel.d.ts +7 -6
- package/dist/timetable/miniCalendar/CalendarWeekPanel.js +14 -12
- package/dist/timetable/miniCalendar/WeekDay.d.ts +7 -7
- package/dist/timetable/miniCalendar/WeekDay.js +21 -16
- package/dist/utils/dates/timetable.d.ts +1 -1
- package/dist/utils/dates/timetable.js +6 -6
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/validation/datesValidation.d.ts +2 -0
- package/dist/utils/validation/datesValidation.js +23 -0
- package/dist/utils/validation/index.d.ts +1 -0
- package/dist/utils/validation/index.js +8 -0
- package/package.json +1 -1
|
@@ -25,6 +25,7 @@ import InputAdornment from '@mui/material/InputAdornment';
|
|
|
25
25
|
import EditInPlaceField from './EditInPlaceField';
|
|
26
26
|
import { stubFunction } from '../utils';
|
|
27
27
|
function EditInPlaceFileField(_a) {
|
|
28
|
+
var _b;
|
|
28
29
|
var { input } = _a, restProps = __rest(_a, ["input"]);
|
|
29
30
|
const inputRef = useRef();
|
|
30
31
|
const fileRef = useRef();
|
|
@@ -48,7 +49,7 @@ function EditInPlaceFileField(_a) {
|
|
|
48
49
|
onFocus: stubFunction,
|
|
49
50
|
onBlur: stubFunction
|
|
50
51
|
}, InputProps: {
|
|
51
|
-
startAdornment: React.createElement(InputAdornment, { position: "start" },
|
|
52
|
+
startAdornment: React.createElement(InputAdornment, { position: "start", className: (_b = restProps.fieldClasses) === null || _b === void 0 ? void 0 : _b.text },
|
|
52
53
|
React.createElement(AttachmentIcon, null)),
|
|
53
54
|
onFocus,
|
|
54
55
|
inputProps: {
|
|
@@ -5,5 +5,5 @@ interface Props<InputProps, MetaProps> extends EditInPlaceFieldProps<InputProps,
|
|
|
5
5
|
currencySymbol: string;
|
|
6
6
|
dispatch?: Dispatch;
|
|
7
7
|
}
|
|
8
|
-
declare function EditInPlaceMoneyField<IP, MP>({ InputProps, currencySymbol,
|
|
8
|
+
declare function EditInPlaceMoneyField<IP, MP>({ InputProps, currencySymbol, className, ...restProps }: Props<IP, MP>): React.JSX.Element;
|
|
9
9
|
export default EditInPlaceMoneyField;
|
|
@@ -31,7 +31,8 @@ const NumberFormatCustom = React.forwardRef((props, ref) => {
|
|
|
31
31
|
});
|
|
32
32
|
const preformatDisplayValue = value => value || value === 0 ? formatCurrency(value, '') : value;
|
|
33
33
|
function EditInPlaceMoneyField(_a) {
|
|
34
|
-
var
|
|
35
|
-
|
|
34
|
+
var _b;
|
|
35
|
+
var { InputProps, currencySymbol, className } = _a, restProps = __rest(_a, ["InputProps", "currencySymbol", "className"]);
|
|
36
|
+
return (React.createElement(EditInPlaceField, Object.assign({}, restProps, { preformatDisplayValue: preformatDisplayValue, InputProps: Object.assign(Object.assign({}, InputProps), { startAdornment: React.createElement(InputAdornment, { position: "start", className: (_b = restProps.fieldClasses) === null || _b === void 0 ? void 0 : _b.text }, currencySymbol), inputComponent: NumberFormatCustom }), className: clsx('money', className) })));
|
|
36
37
|
}
|
|
37
38
|
export default EditInPlaceMoneyField;
|
|
@@ -62,8 +62,9 @@ const NumberFormatCustom = React.forwardRef((props, ref) => {
|
|
|
62
62
|
return (React.createElement(NumberFormat, Object.assign({}, other, { getInputRef: getInputRef, onKeyPress: onKeyPress, prefix: prefix, onValueChange: onValueChange, format: format, type: "text" })));
|
|
63
63
|
});
|
|
64
64
|
function EditInPlacePhoneField(_a) {
|
|
65
|
+
var _b;
|
|
65
66
|
var { InputProps, className } = _a, restProps = __rest(_a, ["InputProps", "className"]);
|
|
66
|
-
return (React.createElement(EditInPlaceField, Object.assign({}, restProps, { InputProps: Object.assign(Object.assign({}, InputProps), { startAdornment: React.createElement(InputAdornment, { position: "start" },
|
|
67
|
+
return (React.createElement(EditInPlaceField, Object.assign({}, restProps, { InputProps: Object.assign(Object.assign({}, InputProps), { startAdornment: React.createElement(InputAdornment, { position: "start", className: (_b = restProps.fieldClasses) === null || _b === void 0 ? void 0 : _b.text },
|
|
67
68
|
React.createElement(PhoneIcon, null)), inputComponent: NumberFormatCustom }), className: className })));
|
|
68
69
|
}
|
|
69
70
|
export default EditInPlacePhoneField;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { DateArgFunction } from '../../model';
|
|
2
3
|
interface Props {
|
|
3
4
|
day: number;
|
|
4
5
|
isToday?: boolean;
|
|
@@ -8,8 +9,15 @@ interface Props {
|
|
|
8
9
|
selectedMonthSessionDays: number[];
|
|
9
10
|
disabled: boolean;
|
|
10
11
|
theme?: any;
|
|
11
|
-
targetDay?:
|
|
12
|
-
setTargetDay?:
|
|
12
|
+
targetDay?: Date;
|
|
13
|
+
setTargetDay?: DateArgFunction;
|
|
14
|
+
customClasses?: {
|
|
15
|
+
root?: string;
|
|
16
|
+
hasSession?: string;
|
|
17
|
+
today?: string;
|
|
18
|
+
selected?: string;
|
|
19
|
+
disabled?: string;
|
|
20
|
+
};
|
|
13
21
|
}
|
|
14
22
|
declare const CalendarDay: React.MemoExoticComponent<(props: Props) => React.JSX.Element>;
|
|
15
23
|
export default CalendarDay;
|
|
@@ -5,13 +5,12 @@
|
|
|
5
5
|
*
|
|
6
6
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
|
7
7
|
*/
|
|
8
|
-
import React, { useMemo } from 'react';
|
|
8
|
+
import React, { useMemo, memo } from 'react';
|
|
9
9
|
import { Button } from '@mui/material';
|
|
10
10
|
import { isSameDay } from 'date-fns';
|
|
11
11
|
import clsx from 'clsx';
|
|
12
12
|
import { alpha } from '@mui/material/styles';
|
|
13
13
|
import { makeAppStyles } from '../../styles';
|
|
14
|
-
import { useAppTheme } from '../../themes';
|
|
15
14
|
const useStyles = makeAppStyles(theme => ({
|
|
16
15
|
root: {
|
|
17
16
|
padding: 0,
|
|
@@ -39,26 +38,34 @@ const useStyles = makeAppStyles(theme => ({
|
|
|
39
38
|
border: `2px solid ${theme.palette.text.primary}`
|
|
40
39
|
}
|
|
41
40
|
},
|
|
42
|
-
same: {}
|
|
41
|
+
same: {},
|
|
42
|
+
hasSession: ({ dayIndexValue }) => {
|
|
43
|
+
const backgroundColor = alpha(theme.palette.primary.main, dayIndexValue);
|
|
44
|
+
return {
|
|
45
|
+
backgroundColor,
|
|
46
|
+
color: theme.palette.getContrastText(backgroundColor),
|
|
47
|
+
'&:hover': {
|
|
48
|
+
backgroundColor,
|
|
49
|
+
color: theme.palette.getContrastText(backgroundColor)
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
isToday: {
|
|
54
|
+
fontWeight: 900
|
|
55
|
+
}
|
|
43
56
|
}));
|
|
44
|
-
const CalendarDay =
|
|
45
|
-
const { day, status, date, disabled, targetDay, setTargetDay, selectedMonthSessionDays } = props;
|
|
46
|
-
const classes = useStyles();
|
|
47
|
-
const theme = useAppTheme();
|
|
57
|
+
const CalendarDay = memo((props) => {
|
|
58
|
+
const { customClasses = {}, day, status, date, disabled, targetDay, setTargetDay, selectedMonthSessionDays } = props;
|
|
48
59
|
const isSame = isSameDay(targetDay, date);
|
|
49
60
|
const isToday = isSameDay(new Date(), date);
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
return result;
|
|
61
|
-
}, [isToday, status, selectedMonthSessionDays, day, theme]);
|
|
62
|
-
return (React.createElement(Button, { className: clsx(classes.root, isSame && classes.same), onClick: () => setTargetDay(date), disabled: disabled, style: style }, day));
|
|
61
|
+
const dayIndexValue = selectedMonthSessionDays[day - 1];
|
|
62
|
+
const hasSession = useMemo(() => selectedMonthSessionDays.length && status === 'current' && dayIndexValue !== 0, [selectedMonthSessionDays, dayIndexValue, status]);
|
|
63
|
+
const classes = useStyles({ dayIndexValue, hasSession, isToday });
|
|
64
|
+
return (React.createElement(Button, { className: clsx(classes.root, customClasses.root, isSame && clsx(classes.same, customClasses.selected), {
|
|
65
|
+
[customClasses.hasSession || classes.hasSession]: hasSession,
|
|
66
|
+
[customClasses.today || classes.isToday]: isToday
|
|
67
|
+
}), onClick: () => setTargetDay(date), classes: {
|
|
68
|
+
disabled: customClasses.disabled
|
|
69
|
+
}, disabled: disabled }, day));
|
|
63
70
|
});
|
|
64
71
|
export default CalendarDay;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import React from
|
|
1
|
+
import React from 'react';
|
|
2
2
|
interface Props {
|
|
3
3
|
month: string;
|
|
4
4
|
year: number;
|
|
5
5
|
previousMonth: () => void;
|
|
6
6
|
nextMonth: () => void;
|
|
7
7
|
classes?: any;
|
|
8
|
+
customClasses?: {
|
|
9
|
+
root?: string;
|
|
10
|
+
leftButton?: string;
|
|
11
|
+
rightbutton?: string;
|
|
12
|
+
selectedMonth?: string;
|
|
13
|
+
};
|
|
8
14
|
}
|
|
9
|
-
declare const
|
|
10
|
-
export default
|
|
15
|
+
declare const CalendarHeader: ({ month, year, previousMonth, nextMonth, customClasses }: Props) => React.JSX.Element;
|
|
16
|
+
export default CalendarHeader;
|
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { IconButton, Typography } from
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IconButton, Typography } from '@mui/material';
|
|
3
|
+
import { KeyboardArrowLeft, KeyboardArrowRight } from '@mui/icons-material';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { makeAppStyles } from '../../styles';
|
|
6
|
+
const useStyles = makeAppStyles(theme => ({
|
|
6
7
|
root: {
|
|
7
|
-
display:
|
|
8
|
-
justifyContent:
|
|
9
|
-
alignItems:
|
|
8
|
+
display: 'flex',
|
|
9
|
+
justifyContent: 'space-between',
|
|
10
|
+
alignItems: 'center',
|
|
10
11
|
padding: theme.spacing(0, 1)
|
|
11
12
|
}
|
|
12
13
|
}));
|
|
13
|
-
const CalendarHeader = ({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
const CalendarHeader = ({ month, year, previousMonth, nextMonth, customClasses = {} }) => {
|
|
15
|
+
const classes = useStyles();
|
|
16
|
+
return React.createElement("div", { className: clsx(classes.root, customClasses.root) },
|
|
17
|
+
React.createElement(IconButton, { onClick: previousMonth, className: customClasses.leftButton },
|
|
18
|
+
React.createElement(KeyboardArrowLeft, null)),
|
|
19
|
+
React.createElement(Typography, { align: "center", className: customClasses.selectedMonth },
|
|
20
|
+
month,
|
|
21
|
+
" ",
|
|
22
|
+
year),
|
|
23
|
+
React.createElement(IconButton, { onClick: nextMonth, className: customClasses.rightbutton },
|
|
24
|
+
React.createElement(KeyboardArrowRight, null)));
|
|
25
|
+
};
|
|
26
|
+
export default CalendarHeader;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React from
|
|
1
|
+
import React from 'react';
|
|
2
2
|
interface Props {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
switchWeekDays?: (dayId: number) => void;
|
|
4
|
+
selectedWeekDays?: boolean[];
|
|
5
|
+
className?: string;
|
|
6
|
+
dayClass?: string;
|
|
6
7
|
}
|
|
7
|
-
declare const
|
|
8
|
-
export default
|
|
8
|
+
declare const CalendarWeekPanel: ({ className, dayClass, switchWeekDays, selectedWeekDays }: Props) => React.JSX.Element;
|
|
9
|
+
export default CalendarWeekPanel;
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import WeekDay from './WeekDay';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { makeAppStyles } from '../../styles';
|
|
5
|
+
const useStyles = makeAppStyles(theme => ({
|
|
5
6
|
root: {
|
|
6
|
-
display:
|
|
7
|
+
display: 'grid',
|
|
7
8
|
gridTemplateColumns: `repeat(7, ${theme.spacing(4)})`,
|
|
8
|
-
|
|
9
|
+
gap: 1,
|
|
9
10
|
padding: theme.spacing(0, 1),
|
|
10
11
|
marginBottom: theme.spacing(1),
|
|
11
|
-
justifyContent:
|
|
12
|
+
justifyContent: 'center'
|
|
12
13
|
}
|
|
13
|
-
});
|
|
14
|
-
const week = [
|
|
15
|
-
const CalendarWeekPanel = ({
|
|
16
|
-
|
|
14
|
+
}));
|
|
15
|
+
const week = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
|
|
16
|
+
const CalendarWeekPanel = ({ className, dayClass, switchWeekDays, selectedWeekDays = [] }) => {
|
|
17
|
+
const classes = useStyles();
|
|
18
|
+
return (React.createElement("div", { className: clsx(classes.root, className) }, week.map((el, id) => (React.createElement(WeekDay, { key: id, id: id, name: el, selected: selectedWeekDays[id], click: switchWeekDays, className: dayClass })))));
|
|
17
19
|
};
|
|
18
|
-
export default
|
|
20
|
+
export default CalendarWeekPanel;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React from
|
|
1
|
+
import React from 'react';
|
|
2
2
|
interface Props {
|
|
3
|
-
name: string;
|
|
4
|
-
selected: boolean;
|
|
5
|
-
click: (id: any) => void;
|
|
6
3
|
id: number;
|
|
7
|
-
|
|
4
|
+
name: string;
|
|
5
|
+
selected?: boolean;
|
|
6
|
+
click?: (id: any) => void;
|
|
7
|
+
className?: string;
|
|
8
8
|
}
|
|
9
|
-
declare const
|
|
10
|
-
export default
|
|
9
|
+
declare const WeekDay: ({ name, selected, click, id, className }: Props) => React.JSX.Element;
|
|
10
|
+
export default WeekDay;
|
|
@@ -1,25 +1,30 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Button, Typography } from
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
const
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button, Typography } from '@mui/material';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { makeAppStyles } from '../../styles';
|
|
5
|
+
const useStyles = makeAppStyles(theme => ({
|
|
6
6
|
weekButton: {
|
|
7
7
|
padding: theme.spacing(0.5),
|
|
8
|
-
minWidth:
|
|
9
|
-
textTransform:
|
|
8
|
+
minWidth: 'initial',
|
|
9
|
+
textTransform: 'capitalize'
|
|
10
10
|
},
|
|
11
11
|
selectedWeekDay: {
|
|
12
|
-
boxShadow:
|
|
13
|
-
|
|
14
|
-
boxShadow:
|
|
12
|
+
boxShadow: 'none',
|
|
13
|
+
'&:active': {
|
|
14
|
+
boxShadow: 'none'
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
weekDayText: {
|
|
18
18
|
color: theme.palette.common.white
|
|
19
19
|
}
|
|
20
|
-
});
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
}));
|
|
21
|
+
const DivRoot = props => React.createElement("div", { className: props.className });
|
|
22
|
+
const WeekDay = ({ name, selected, click, id, className }) => {
|
|
23
|
+
const classes = useStyles();
|
|
24
|
+
const Root = click ? Button : DivRoot;
|
|
25
|
+
return React.createElement(Root, { className: clsx(classes.weekButton, {
|
|
26
|
+
[classes.selectedWeekDay]: selected
|
|
27
|
+
}, className), onClick: () => click(id), variant: selected ? 'contained' : 'text', color: selected ? 'primary' : 'inherit', disableElevation: true },
|
|
28
|
+
React.createElement(Typography, { variant: "caption", align: "center", className: selected ? classes.weekDayText : '' }, name));
|
|
29
|
+
};
|
|
30
|
+
export default WeekDay;
|
|
@@ -13,12 +13,12 @@ const generateOneMonth = (today, status) => Array(getDaysInMonth(today))
|
|
|
13
13
|
date: new Date(today.getFullYear(), today.getMonth(), id + 1),
|
|
14
14
|
status
|
|
15
15
|
}));
|
|
16
|
-
export const getCalendarDays =
|
|
17
|
-
const currentMonth = generateOneMonth(
|
|
18
|
-
const previousMonth = generateOneMonth(new Date(
|
|
19
|
-
const nextMonth = generateOneMonth(new Date(
|
|
20
|
-
const firstDayIndex = getDay(new Date(
|
|
21
|
-
const lastDayIndex = getDay(lastDayOfMonth(
|
|
16
|
+
export const getCalendarDays = (date) => {
|
|
17
|
+
const currentMonth = generateOneMonth(date, 'current');
|
|
18
|
+
const previousMonth = generateOneMonth(new Date(date.getFullYear(), date.getMonth() - 1), 'previous');
|
|
19
|
+
const nextMonth = generateOneMonth(new Date(date.getFullYear(), date.getMonth() + 1), 'next');
|
|
20
|
+
const firstDayIndex = getDay(new Date(date.getFullYear(), date.getMonth(), 1));
|
|
21
|
+
const lastDayIndex = getDay(lastDayOfMonth(date));
|
|
22
22
|
const binaryCalendarState = (firstDayIndex, lastDayIndex) => parseInt(String(+!!firstDayIndex) + +(lastDayIndex < 6), 2);
|
|
23
23
|
switch (binaryCalendarState(firstDayIndex, lastDayIndex)) {
|
|
24
24
|
case 0:
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright ish group pty ltd 2023.
|
|
3
|
+
*
|
|
4
|
+
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
|
|
5
|
+
*
|
|
6
|
+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
|
7
|
+
*/
|
|
8
|
+
export const validateMinMaxDate = (value, minDate, maxDate, minErrMsg = 'Date is beyond minimum limit', maxErrMsg = 'Date is beyond maximum limit') => {
|
|
9
|
+
let result;
|
|
10
|
+
if (value) {
|
|
11
|
+
const valueTime = new Date(value).getTime();
|
|
12
|
+
if (minDate) {
|
|
13
|
+
const minDateTime = new Date(minDate).getTime();
|
|
14
|
+
result = valueTime >= minDateTime ? undefined : minErrMsg;
|
|
15
|
+
}
|
|
16
|
+
if (maxDate) {
|
|
17
|
+
const maxDateTime = new Date(maxDate).getTime();
|
|
18
|
+
result = valueTime <= maxDateTime ? undefined : maxErrMsg;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
export const validateDate = value => !Number.isNaN(new Date(value).getTime());
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './datesValidation';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright ish group pty ltd 2023.
|
|
3
|
+
*
|
|
4
|
+
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
|
|
5
|
+
*
|
|
6
|
+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
|
7
|
+
*/
|
|
8
|
+
export * from './datesValidation';
|