mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-26 18:35:14 +00:00
1 line
14 KiB
Plaintext
1 line
14 KiB
Plaintext
{"version":3,"file":"index.js","sources":["../src/TextField.tsx","../src/Switch.tsx","../src/Checkbox.tsx","../src/CheckboxWithLabel.tsx","../src/Select.tsx","../src/SimpleFileUpload.tsx","../src/RadioGroup.tsx","../src/InputBase.tsx"],"sourcesContent":["import * as React from 'react';\nimport MuiTextField, {\n TextFieldProps as MuiTextFieldProps,\n} from '@material-ui/core/TextField';\nimport { FieldProps, getIn } from 'formik';\n\nexport interface TextFieldProps\n extends FieldProps,\n Omit<MuiTextFieldProps, 'name' | 'value' | 'error'> {}\n\nexport function fieldToTextField({\n disabled,\n field: { onBlur: fieldOnBlur, ...field },\n form: { isSubmitting, touched, errors },\n onBlur,\n helperText,\n ...props\n}: TextFieldProps): MuiTextFieldProps {\n const fieldError = getIn(errors, field.name);\n const showError = getIn(touched, field.name) && !!fieldError;\n\n return {\n variant: props.variant,\n error: showError,\n helperText: showError ? fieldError : helperText,\n disabled: disabled ?? isSubmitting,\n onBlur:\n onBlur ??\n function (e) {\n fieldOnBlur(e ?? field.name);\n },\n ...field,\n ...props,\n };\n}\n\nexport function TextField({ children, ...props }: TextFieldProps) {\n return <MuiTextField {...fieldToTextField(props)}>{children}</MuiTextField>;\n}\n\nTextField.displayName = 'FormikMaterialUITextField';\n","import * as React from 'react';\nimport MuiSwitch, {\n SwitchProps as MuiSwitchProps,\n} from '@material-ui/core/Switch';\nimport { FieldProps } from 'formik';\nimport invariant from 'tiny-warning';\n\nexport interface SwitchProps\n extends FieldProps,\n Omit<\n MuiSwitchProps,\n | 'checked'\n | 'name'\n | 'value'\n | 'defaultChecked'\n | 'form'\n // Excluded for conflict with Field type\n | 'type'\n > {\n type?: string;\n}\n\nexport function fieldToSwitch({\n disabled,\n field: { onBlur: fieldOnBlur, ...field },\n form: { isSubmitting },\n type,\n onBlur,\n ...props\n}: SwitchProps): MuiSwitchProps {\n if (process.env.NODE_ENV !== 'production') {\n invariant(\n type === 'checkbox',\n `property type=checkbox is missing from field ${field.name}, this can caused unexpected behaviour`\n );\n }\n\n return {\n disabled: disabled ?? isSubmitting,\n onBlur:\n onBlur ??\n function (e) {\n fieldOnBlur(e ?? field.name);\n },\n ...field,\n ...props,\n };\n}\n\nexport function Switch(props: SwitchProps) {\n return <MuiSwitch {...fieldToSwitch(props)} />;\n}\n\nSwitch.displayName = 'FormikMaterialUISwitch';\n","import * as React from 'react';\nimport MuiCheckbox, {\n CheckboxProps as MuiCheckboxProps,\n} from '@material-ui/core/Checkbox';\nimport { FieldProps } from 'formik';\nimport invariant from 'tiny-warning';\n\nexport interface CheckboxProps\n extends FieldProps,\n Omit<\n MuiCheckboxProps,\n | 'name'\n | 'value'\n | 'error'\n | 'form'\n | 'checked'\n | 'defaultChecked'\n // Excluded for conflict with Field type\n | 'type'\n > {\n type?: string;\n}\n\nexport function fieldToCheckbox({\n disabled,\n field: { onBlur: fieldOnBlur, ...field },\n form: { isSubmitting },\n type,\n onBlur,\n ...props\n}: CheckboxProps): MuiCheckboxProps {\n const indeterminate = !Array.isArray(field.value) && field.value == null;\n\n if (process.env.NODE_ENV !== 'production') {\n invariant(\n type === 'checkbox',\n `property type=checkbox is missing from field ${field.name}, this can caused unexpected behaviour`\n );\n }\n\n return {\n disabled: disabled ?? isSubmitting,\n indeterminate,\n onBlur:\n onBlur ??\n function (e) {\n fieldOnBlur(e ?? field.name);\n },\n ...field,\n ...props,\n };\n}\n\nexport function Checkbox(props: CheckboxProps) {\n return <MuiCheckbox {...fieldToCheckbox(props)} />;\n}\n\nCheckbox.displayName = 'FormikMaterialUICheckbox';\n","import * as React from 'react';\nimport MuiCheckbox from '@material-ui/core/Checkbox';\nimport FormControlLabel, {\n FormControlLabelProps as MuiFormControlLabelProps,\n} from '@material-ui/core/FormControlLabel';\nimport { FieldProps } from 'formik';\n\nimport { CheckboxProps, fieldToCheckbox } from './Checkbox';\n\n/**\n * Exclude props that are passed directly to the control\n * https://github.com/mui-org/material-ui/blob/v3.1.1/packages/material-ui/src/FormControlLabel/FormControlLabel.js#L71\n */\nexport interface CheckboxWithLabelProps extends FieldProps, CheckboxProps {\n Label: Omit<\n MuiFormControlLabelProps,\n 'checked' | 'name' | 'value' | 'control'\n >;\n}\n\nexport function CheckboxWithLabel<Val = unknown>({\n Label,\n ...props\n}: CheckboxWithLabelProps) {\n return (\n <FormControlLabel\n control={<MuiCheckbox {...fieldToCheckbox(props)} />}\n {...Label}\n />\n );\n}\n\nCheckboxWithLabel.displayName = 'FormikMaterialUICheckboxWithLabel';\n","import * as React from 'react';\nimport MuiSelect, {\n SelectProps as MuiSelectProps,\n} from '@material-ui/core/Select';\nimport { FieldProps } from 'formik';\n\nexport interface SelectProps\n extends FieldProps,\n Omit<MuiSelectProps, 'name' | 'value'> {}\n\nexport function fieldToSelect({\n disabled,\n field: { onBlur: fieldOnBlur, ...field },\n form: { isSubmitting },\n onBlur,\n ...props\n}: SelectProps): MuiSelectProps {\n return {\n disabled: disabled ?? isSubmitting,\n onBlur:\n onBlur ??\n function (e) {\n fieldOnBlur(e ?? field.name);\n },\n ...field,\n ...props,\n };\n}\n\nexport function Select(props: SelectProps) {\n return <MuiSelect {...fieldToSelect(props)} />;\n}\n\nSelect.displayName = 'FormikMaterialUISelect';\n","import * as React from 'react';\nimport { FieldProps, getIn } from 'formik';\nimport FormControl, { FormControlProps } from '@material-ui/core/FormControl';\nimport InputLabel, { InputLabelProps } from '@material-ui/core/InputLabel';\nimport Input, { InputProps } from '@material-ui/core/Input';\nimport FormHelperText from '@material-ui/core/FormHelperText';\n\nexport interface SimpleFileUploadProps extends FieldProps {\n label: string;\n disabled?: boolean;\n InputProps?: Omit<InputProps, 'name' | 'type' | 'label'>;\n InputLabelProps?: InputLabelProps;\n FormControlProps?: FormControlProps;\n}\n\nexport const SimpleFileUpload = ({\n field,\n form: { isSubmitting, touched, errors, setFieldValue },\n label,\n disabled = false,\n InputProps: inputProps,\n InputLabelProps: inputLabelProps,\n FormControlProps: formControlProps,\n}: SimpleFileUploadProps) => {\n const error = getIn(touched, field.name) && getIn(errors, field.name);\n\n return (\n <FormControl {...formControlProps}>\n {label && (\n <InputLabel shrink error={!!error} {...inputLabelProps}>\n {label}\n </InputLabel>\n )}\n <Input\n error={!!error}\n inputProps={{\n type: 'file',\n disabled: disabled || isSubmitting,\n name: field.name,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (event: React.ChangeEvent<any>) => {\n if (inputProps?.onChange) {\n inputProps.onChange(event);\n } else {\n const file = event.currentTarget.files[0];\n setFieldValue(field.name, file);\n }\n },\n }}\n {...inputProps}\n />\n {error && <FormHelperText error>{error}</FormHelperText>}\n </FormControl>\n );\n};\n","import * as React from 'react';\nimport MuiRadioGroup, {\n RadioGroupProps as MuiRadioGroupProps,\n} from '@material-ui/core/RadioGroup';\nimport { FieldProps } from 'formik';\n\nexport interface RadioGroupProps\n extends FieldProps,\n Omit<MuiRadioGroupProps, 'name' | 'value'> {}\n\nexport function fieldToRadioGroup({\n field: { onBlur: fieldOnBlur, ...field },\n form,\n onBlur,\n ...props\n}: RadioGroupProps): MuiRadioGroupProps {\n return {\n onBlur:\n onBlur ??\n function (e) {\n fieldOnBlur(e ?? field.name);\n },\n ...field,\n ...props,\n };\n}\n\nexport function RadioGroup(props: RadioGroupProps) {\n return <MuiRadioGroup {...fieldToRadioGroup(props)} />;\n}\n\nRadioGroup.displayName = 'FormikMaterialUIRadioGroup';\n","import * as React from 'react';\nimport MuiInputBase, {\n InputBaseProps as MuiInputBaseProps,\n} from '@material-ui/core/InputBase';\nimport { FieldProps } from 'formik';\n\nexport interface InputBaseProps\n extends FieldProps,\n Omit<MuiInputBaseProps, 'name' | 'value' | 'error'> {}\n\nexport function fieldToInputBase({\n disabled,\n field: { onBlur: fieldOnBlur, ...field },\n form: { isSubmitting },\n onBlur,\n ...props\n}: InputBaseProps): MuiInputBaseProps {\n return {\n disabled: disabled ?? isSubmitting,\n onBlur:\n onBlur ??\n function (e) {\n fieldOnBlur(e ?? field.name);\n },\n ...field,\n ...props,\n };\n}\n\nexport function InputBase(props: InputBaseProps) {\n return <MuiInputBase {...fieldToInputBase(props)} />;\n}\n\nInputBase.displayName = 'FormikMaterialUIInputBase';\n"],"names":["getIn","React.createElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAUgB,gBAAgB,CAAC,EAOhB;IANf,IAAA,QAAQ,cAAA,EACR,aAAwC,EAAvB,WAAW,YAAA,EAAK,KAAK,cAA/B,UAAiC,CAAF,EACtC,YAAuC,EAA/B,YAAY,kBAAA,EAAE,OAAO,aAAA,EAAE,MAAM,YAAA,EACrC,MAAM,YAAA,EACN,UAAU,gBAAA,EACP,KAAK,cANuB,qDAOhC,CADS;IAER,IAAM,UAAU,GAAGA,YAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7C,IAAM,SAAS,GAAGA,YAAK,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC;IAE7D,2BACE,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,KAAK,EAAE,SAAS,EAChB,UAAU,EAAE,SAAS,GAAG,UAAU,GAAG,UAAU,EAC/C,QAAQ,EAAE,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,YAAY,EAClC,MAAM,EACJ,MAAM,aAAN,MAAM,cAAN,MAAM,GACN,UAAU,CAAC;YACT,WAAW,CAAC,CAAC,aAAD,CAAC,cAAD,CAAC,GAAI,KAAK,CAAC,IAAI,CAAC,CAAC;SAC9B,IACA,KAAK,GACL,KAAK,EACR;CACH;AAED,SAAgB,SAAS,CAAC,EAAsC;IAApC,IAAA,QAAQ,cAAA,EAAK,KAAK,cAApB,YAAsB,CAAF;IAC5C,OAAOC,oBAAC,YAAY,eAAK,gBAAgB,CAAC,KAAK,CAAC,GAAG,QAAQ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