ish-ui 1.0.35 → 1.0.37

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.
@@ -1,3 +1,4 @@
1
1
  import React from 'react';
2
- declare const _default: React.FunctionComponent<any>;
3
- export default _default;
2
+ import { RadioButtonsProps } from '../model';
3
+ declare function FormRadioButtons({ items, disabled, input: { value, onChange, name }, meta: { invalid, error }, labelPath, valuePath, color, row, label, labelClass, labelAdornment, radioProps, radioGroupProps }: RadioButtonsProps): React.JSX.Element;
4
+ export default FormRadioButtons;
@@ -6,22 +6,24 @@
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
8
  import React from 'react';
9
- import { withStyles } from '@mui/styles';
10
- import { FormControl, FormControlLabel, Radio, RadioGroup } from '@mui/material';
9
+ import { FormControl, FormControlLabel, FormHelperText, InputLabel, Radio, RadioGroup, } from '@mui/material';
11
10
  import Typography from '@mui/material/Typography';
12
- const styles = theme => ({
13
- root: {
14
- display: 'flex'
15
- },
11
+ import { makeAppStyles } from '../styles';
12
+ const useStyles = makeAppStyles(theme => ({
16
13
  group: {
17
14
  margin: theme.spacing(1, 0)
18
15
  }
19
- });
20
- const FormRadioButtons = props => {
21
- const { classes, items, disabled, input: { value, onChange, name }, labelPath = 'label', valuePath = 'value', color = 'primary', row } = props;
22
- return (React.createElement("div", { className: classes.root },
23
- React.createElement(FormControl, { component: "fieldset" },
24
- React.createElement(RadioGroup, { className: classes.group, value: value, onChange: (e) => onChange(e.target.value), row: row }, items
25
- && items.map((i, n) => (React.createElement(FormControlLabel, { key: n, value: i[valuePath], control: React.createElement(Radio, { color: color, id: `input-${n}-${name}`, name: name }), label: (React.createElement(Typography, { component: "span", variant: "body2" }, i[labelPath])), disabled: disabled, htmlFor: `input-${n}-${name}` })))))));
26
- };
27
- export default withStyles(styles)(FormRadioButtons);
16
+ }));
17
+ function FormRadioButtons({ items, disabled, input: { value, onChange, name }, meta: { invalid, error }, labelPath = 'label', valuePath = 'value', color = 'primary', row, label, labelClass, labelAdornment, radioProps, radioGroupProps }) {
18
+ const classes = useStyles();
19
+ return (React.createElement(FormControl, { component: "fieldset", error: invalid },
20
+ label && (React.createElement(InputLabel, { shrink: true, htmlFor: `input-${name}`, className: labelClass },
21
+ label,
22
+ labelAdornment)),
23
+ React.createElement(RadioGroup, Object.assign({ className: classes.group, value: value, onChange: (e) => onChange(e.target.value), row: row }, radioGroupProps), items
24
+ && items.map((i, n) => (React.createElement(FormControlLabel, { key: n, value: i[valuePath], control: React.createElement(Radio, Object.assign({ color: color, id: `input-${n}-${name}`, name: name }, radioProps)), label: (React.createElement(Typography, { component: "span", variant: "body2" }, i[labelPath])), disabled: disabled, htmlFor: `input-${n}-${name}` })))),
25
+ React.createElement(FormHelperText, { classes: {
26
+ error: 'shakingError'
27
+ } }, error)));
28
+ }
29
+ export default FormRadioButtons;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- export declare const selectStyles: (theme: any) => import("@mui/styles").StyleRules<{}, "label" | "inline" | "multiple" | "error" | "root" | "expandIcon" | "menuItem" | "inputWrapper" | "readonly" | "editIcon" | "bottomMargin" | "bottomPadding" | "topMargin" | "editable" | "valid" | "autoWidthSelect" | "emptySelect" | "validUnderline" | "menuItemActive" | "menuList" | "hasPopup" | "hasClear">;
2
+ export declare const selectStyles: (theme: any) => import("@mui/styles").StyleRules<{}, "label" | "error" | "inline" | "multiple" | "root" | "expandIcon" | "menuItem" | "inputWrapper" | "readonly" | "editIcon" | "bottomMargin" | "bottomPadding" | "topMargin" | "editable" | "valid" | "autoWidthSelect" | "emptySelect" | "validUnderline" | "menuItemActive" | "menuList" | "hasPopup" | "hasClear">;
3
3
  export declare const ListRow: React.MemoExoticComponent<any>;
4
4
  export declare const ListboxComponent: React.ForwardRefExoticComponent<Omit<any, "ref"> & React.RefAttributes<any>>;
5
5
  export declare const NoWrapOption: (content: any, data: any, search: any, parentProps: any) => React.JSX.Element;
@@ -3,5 +3,5 @@
3
3
  * */
4
4
  import React from 'react';
5
5
  import { FieldInputProps, FormSwitchProps } from '../model';
6
- export declare const Switch: React.JSXElementConstructor<Omit<any, "classes"> & import("@mui/styles").StyledComponentProps<"default" | "icon" | "bar" | "inline" | "disabled" | "checked" | "root" | "focusVisible">>;
6
+ export declare const Switch: React.JSXElementConstructor<Omit<any, "classes"> & import("@mui/styles").StyledComponentProps<"icon" | "disabled" | "checked" | "default" | "bar" | "inline" | "root" | "focusVisible">>;
7
7
  export declare function FormSwitch<InputProps extends FieldInputProps>({ input, color, disabled, stringValue, label, className, inline, onChangeHandler, onClick }: FormSwitchProps<InputProps>): React.JSX.Element;
@@ -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,6 +5,8 @@ import { AnyArgFunction } from '../model/CommonFunctions';
5
5
  import { ShowConfirmCaller } from '../model/Confirm';
6
6
  import { PopperPlacementType } from '@mui/material';
7
7
  import { FormControlTypeMap } from '@mui/material/FormControl/FormControl';
8
+ import { RadioProps } from '@mui/material/Radio/Radio';
9
+ import { RadioGroupProps } from '@mui/material/RadioGroup/RadioGroup';
8
10
  export type EventHandler<Event> = (event: Event, name?: string) => void;
9
11
  export interface EventOrValueHandler<Event> extends EventHandler<Event> {
10
12
  (value: any): void;
@@ -244,6 +246,23 @@ export interface ColorPickerWrapperProps {
244
246
  placement?: PopperPlacementType;
245
247
  width?: number;
246
248
  }
249
+ export interface RadioButtonsProps<IP = FieldInputProps, MP = FieldMetaProps> {
250
+ items: Record<any, any>[];
251
+ input?: Partial<Omit<IP, 'onBlur'>> & {
252
+ onBlur?: AnyArgFunction;
253
+ };
254
+ meta?: Partial<MP>;
255
+ disabled?: boolean;
256
+ labelPath?: string;
257
+ valuePath?: string;
258
+ row?: boolean;
259
+ label?: any;
260
+ labelClass?: string;
261
+ labelAdornment?: any;
262
+ color?: RadioProps['color'];
263
+ radioProps?: RadioProps;
264
+ radioGroupProps?: RadioGroupProps;
265
+ }
247
266
  export type FormFieldProps = ({
248
267
  type: 'phone' | 'duration' | 'text' | 'multilineText' | 'password' | 'number' | 'file' | 'money';
249
268
  } & FormFieldBaseProps & EditInPlaceFieldProps<FieldInputProps, FieldMetaProps>) | ({
@@ -263,5 +282,7 @@ export type FormFieldProps = ({
263
282
  } & FormFieldBaseProps & TagsFieldProps<TagLike, FieldInputProps, FieldMetaProps>) | ({
264
283
  type: 'color';
265
284
  } & ColorPickerWrapperProps) | ({
285
+ type: 'radio';
286
+ } & RadioButtonsProps) | ({
266
287
  type: 'stub';
267
288
  });
@@ -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: {
@@ -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.35",
3
+ "version": "1.0.37",
4
4
  "description": "UI elements for onCourse and other ish apps",
5
5
  "main": "main.ts",
6
6
  "devDependencies": {