ish-ui 1.0.36 → 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;
@@ -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
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ish-ui",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
4
4
  "description": "UI elements for onCourse and other ish apps",
5
5
  "main": "main.ts",
6
6
  "devDependencies": {