ish-ui 1.0.34 → 1.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ export interface CalendarDayModel {
2
+ day: number;
3
+ date: Date;
4
+ status: 'current' | 'previous' | 'next';
5
+ }
@@ -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 {};
@@ -5,3 +5,4 @@ export * from './NestedEntity';
5
5
  export * from './Theme';
6
6
  export * from './CommomObjects';
7
7
  export * from './CommonFunctions';
8
+ export * from './Calendar';
@@ -12,3 +12,4 @@ export * from './NestedEntity';
12
12
  export * from './Theme';
13
13
  export * from './CommomObjects';
14
14
  export * from './CommonFunctions';
15
+ export * from './Calendar';
@@ -1,14 +1,11 @@
1
1
  import React from 'react';
2
- import { DateArgFunction } from '../../model';
3
- interface Props {
4
- day: number;
2
+ import { DateArgFunction, CalendarDayModel } from '../../model';
3
+ interface Props extends CalendarDayModel {
4
+ dayIndexValue: number;
5
+ isSameAsTarget?: boolean;
6
+ hasSession?: boolean;
5
7
  isToday?: boolean;
6
- today?: any;
7
- date: Date;
8
- status: string;
9
- selectedMonthSessionDays: number[];
10
- disabled: boolean;
11
- theme?: any;
8
+ disabled?: boolean;
12
9
  targetDay?: Date;
13
10
  setTargetDay?: DateArgFunction;
14
11
  customClasses?: {
@@ -5,9 +5,8 @@
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, memo } from 'react';
8
+ import React, { memo } from 'react';
9
9
  import { Button } from '@mui/material';
10
- import { isSameDay } from 'date-fns';
11
10
  import clsx from 'clsx';
12
11
  import { alpha } from '@mui/material/styles';
13
12
  import { makeAppStyles } from '../../styles';
@@ -55,13 +54,9 @@ const useStyles = makeAppStyles(theme => ({
55
54
  }
56
55
  }));
57
56
  const CalendarDay = memo((props) => {
58
- const { customClasses = {}, day, status, date, disabled, targetDay, setTargetDay, selectedMonthSessionDays } = props;
59
- const isSame = isSameDay(targetDay, date);
60
- const isToday = isSameDay(new Date(), date);
61
- const dayIndexValue = selectedMonthSessionDays[day - 1];
62
- const hasSession = useMemo(() => selectedMonthSessionDays.length && status === 'current' && dayIndexValue !== 0, [selectedMonthSessionDays, dayIndexValue, status]);
57
+ const { customClasses = {}, day, date, setTargetDay, dayIndexValue, hasSession, isSameAsTarget, isToday, disabled } = props;
63
58
  const classes = useStyles({ dayIndexValue, hasSession, isToday });
64
- return (React.createElement(Button, { className: clsx(classes.root, customClasses.root, isSame && clsx(classes.same, customClasses.selected), {
59
+ return (React.createElement(Button, { className: clsx(classes.root, customClasses.root, isSameAsTarget && clsx(classes.same, customClasses.selected), {
65
60
  [customClasses.hasSession || classes.hasSession]: hasSession,
66
61
  [customClasses.today || classes.isToday]: isToday
67
62
  }), onClick: () => setTargetDay(date), classes: {
@@ -18,7 +18,7 @@ const useStyles = makeAppStyles(theme => ({
18
18
  color: theme.palette.common.white
19
19
  }
20
20
  }));
21
- const DivRoot = props => React.createElement("div", { className: props.className });
21
+ const DivRoot = props => React.createElement("div", { className: props.className }, props.children);
22
22
  const WeekDay = ({ name, selected, click, id, className }) => {
23
23
  const classes = useStyles();
24
24
  const Root = click ? Button : DivRoot;
@@ -1,5 +1,2 @@
1
- export declare const getCalendarDays: (date: Date) => {
2
- day: number;
3
- date: Date;
4
- status: any;
5
- }[];
1
+ import { CalendarDayModel } from '../../model';
2
+ export declare const getCalendarDays: (date: Date) => CalendarDayModel[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ish-ui",
3
- "version": "1.0.34",
3
+ "version": "1.0.36",
4
4
  "description": "UI elements for onCourse and other ish apps",
5
5
  "main": "main.ts",
6
6
  "devDependencies": {