{"version":3,"file":"AdaptModalButton-B9CXnIXK.js","sources":["../../../app/javascript/dashboards/components/common/AdaptRowItem.tsx","../../../app/javascript/shared/components/adapt-form/NumberInput.tsx","../../../app/javascript/shared/components/AdaptModalButton.tsx"],"sourcesContent":["import React, { ReactNode } from 'react';\nimport { Row, Stack } from '@angellist/adapt';\nimport { compact } from 'lodash';\n\nimport RowLoader from './RowLoader';\nimport { SimpleTableItem } from '../../../types';\n\nexport interface AdaptRowItemProps {\n key?: string | number;\n loading?: boolean;\n label?: string;\n hide?: boolean;\n suffix?: any;\n divider?: boolean;\n compact?: boolean;\n description?: ReactNode;\n tooltip?: {\n heading?: string;\n content?: ReactNode;\n };\n}\n\ninterface AdaptRowListProps {\n items: AdaptRowItemProps[];\n}\n\nconst AdaptRowItem = (props: AdaptRowItemProps) => {\n const { label, hide, loading, ...restProps } = props;\n if (hide) {\n return null;\n }\n\n const rowProps = loading\n ? {\n ...restProps,\n suffix: {\n label: ,\n },\n }\n : restProps;\n\n return {label}
;\n};\n\nAdaptRowItem.defaultProps = {\n loading: false,\n hide: false,\n};\n\nexport const AdaptRowList = (props: AdaptRowListProps) => {\n const { items } = props;\n const visibleItems = items.filter((item) => !item.hide);\n const len = visibleItems.length;\n\n return (\n \n {visibleItems.map((item, index) => (\n \n ))}\n \n );\n};\n\nexport const processSimpleTableItems = (\n items: SimpleTableItem[],\n loading?: boolean,\n) =>\n items.map((item, index: number) => {\n if (loading) {\n return {\n id: index.toString(),\n ...item,\n value: ,\n };\n }\n\n return { id: index.toString(), ...item };\n });\n\nexport const getSimpleTableLoadingRows = (numLoadingRows: number) =>\n Array(numLoadingRows)\n .fill('')\n .map((_, index: number) => ({\n id: index.toString(),\n label: ,\n value: ,\n }));\n\nexport const processAdaptRowItems = (items: any[], globolProps: any) => {\n const processedItems = items.map((item, index: number) => {\n const { label, suffixLabel, hide, ...rest } = item;\n if (!hide) {\n return {\n key: index.toString(),\n ...(globolProps || {}),\n label,\n suffix: {\n label: suffixLabel,\n },\n ...rest,\n };\n }\n return null;\n });\n\n return compact(processedItems);\n};\n\nexport default AdaptRowItem;\n","import React, { AllHTMLAttributes, ComponentProps, useEffect } from 'react';\nimport { Controller, UseControllerOptions } from 'react-hook-form';\nimport { Input as AdaptInput } from '@angellist/adapt';\nimport isRequired from './util/isRequired';\nimport onNumberInputFilter from './util/onNumberInputFilter';\nimport { formatToNumber } from '../../utils/number';\nimport FieldLoader from '../FieldLoader';\n\ntype NativeInputProps = AllHTMLAttributes;\n\ntype NumberInputProps = Pick, 'prefix'> & {\n label?: string;\n name: string;\n isRequired?: boolean;\n placeholder?: string | number;\n defaultValue?: string | number;\n maxLength?: number;\n decimalsLimit?: number;\n type?: 'percentage' | 'number';\n onChange?: (e: number | '' | '-') => void;\n onBlur?: NativeInputProps['onBlur'];\n onKeyUp?: NativeInputProps['onKeyUp'];\n step?: NativeInputProps['step'];\n min?: number;\n max?: number;\n compact?: boolean;\n inputMode?: 'numeric' | 'decimal';\n autoFocus?: boolean;\n shouldUnregister?: boolean;\n suffix?: any;\n allowNegative?: boolean;\n description?: string;\n};\n\nexport type OtherProps = {\n isLoading?: boolean;\n error?: string;\n disabled?: boolean;\n};\n\nexport type Props = NumberInputProps &\n OtherProps &\n Omit;\n\nconst useInputValue = (\n controlledValue: string | number,\n options: {\n isDecimalMode: boolean;\n allowNegative: boolean;\n },\n) => {\n // Issue: After adapt 46.2.1 release, the input value is not allowing decimal values (.)\n // so added local state to handle the input value\n const { isDecimalMode, allowNegative } = options;\n const [inputValue, setInputValue] = React.useState(\n controlledValue,\n );\n useEffect(() => {\n if (\n isDecimalMode &&\n inputValue !== controlledValue &&\n !inputValue?.toString().endsWith('.')\n ) {\n setInputValue(controlledValue);\n }\n }, [controlledValue]);\n\n const getControlledValue = (userValue: string) => {\n if (isDecimalMode) {\n setInputValue(userValue);\n }\n let sanitizedVal;\n if (!allowNegative && userValue.includes('-')) {\n sanitizedVal = userValue.replace('-', '');\n } else {\n sanitizedVal = userValue;\n }\n const numberValue =\n sanitizedVal === '-' ? '-' : formatToNumber(sanitizedVal);\n\n return numberValue;\n };\n\n return {\n value: isDecimalMode ? inputValue : controlledValue,\n getControlledValue,\n };\n};\n\nexport const NumberInput = ({\n control,\n defaultValue,\n name,\n isRequired: isRequiredProp,\n rules,\n disabled,\n error,\n onChange,\n isLoading,\n inputMode = 'decimal',\n autoFocus,\n decimalsLimit = 2,\n shouldUnregister,\n allowNegative = false,\n ...providedInputProps\n}: Props) => {\n if (isLoading) {\n return ;\n }\n const isDecimalMode = inputMode === 'decimal';\n const maxDecimals = isDecimalMode ? decimalsLimit : 0;\n\n return (\n {\n const { value, getControlledValue } = useInputValue(field.value ?? '', {\n isDecimalMode,\n allowNegative,\n });\n\n const handleOnChange = (val: string) => {\n const numberValue = getControlledValue(val);\n field.onChange(numberValue);\n if (onChange) {\n onChange(numberValue);\n }\n };\n\n return (\n onNumberInputFilter(v, maxDecimals)}\n autoFocus={autoFocus}\n />\n );\n }}\n />\n );\n};\n\nexport default NumberInput;\n","import React, { ReactNode } from 'react';\nimport { DropdownItem } from 'reactstrap';\nimport { Button, TextButton } from '@angellist/adapt';\n\nimport { ModalActions } from '../../types';\nimport useModal from '../hooks/useModal';\n\ntype Props = {\n buttonType?: 'link' | 'button' | 'dropdown-item';\n buttonProps?: any;\n label: string;\n modalActions?: ModalActions;\n modalComponent: any;\n modalProps?: any;\n buttonIcon?: ReactNode;\n};\n\nconst AdaptModalButton = (props: Props) => {\n const {\n buttonType = 'button',\n modalActions,\n modalProps,\n label,\n modalComponent: ModalComponent,\n buttonProps = {},\n buttonIcon,\n } = props;\n const modalState = modalActions ?? useModal();\n const { modal, modalKey, openModal, closeModal } = modalState;\n\n const handlePress = () => openModal();\n\n return (\n <>\n {buttonType === 'link' && (\n \n )}\n {buttonType === 'button' && (\n \n )}\n {buttonType === 'dropdown-item' && (\n \n {buttonIcon}\n {label}\n \n )}\n {modal && (\n \n )}\n >\n );\n};\n\nexport default AdaptModalButton;\n"],"names":["AdaptRowItem","props","label","hide","loading","restProps","rowProps","jsx","RowLoader","Row","AdaptRowList","items","visibleItems","item","len","Stack","index","processSimpleTableItems","getSimpleTableLoadingRows","numLoadingRows","_","processAdaptRowItems","globolProps","processedItems","suffixLabel","rest","compact","useInputValue","controlledValue","options","isDecimalMode","allowNegative","inputValue","setInputValue","React","useEffect","userValue","sanitizedVal","formatToNumber","NumberInput","control","defaultValue","name","isRequiredProp","rules","disabled","error","onChange","isLoading","inputMode","autoFocus","decimalsLimit","shouldUnregister","providedInputProps","FieldLoader","maxDecimals","Controller","field","value","getControlledValue","handleOnChange","val","numberValue","AdaptInput","isRequired","v","onNumberInputFilter","AdaptModalButton","buttonType","modalActions","modalProps","ModalComponent","buttonProps","buttonIcon","modalState","useModal","modal","modalKey","openModal","closeModal","handlePress","jsxs","Fragment","TextButton","Button","DropdownItem"],"mappings":"meA0BM,MAAAA,EAAgBC,GAA6B,CACjD,KAAM,CAAE,MAAAC,EAAO,KAAAC,EAAM,QAAAC,EAAS,GAAGC,CAAc,EAAAJ,EAC/C,GAAIE,EACK,OAAA,KAGT,MAAMG,EAAWF,EACb,CACE,GAAGC,EACH,OAAQ,CACN,MAAOE,EAAAA,IAACC,EAAU,CAAA,MAAO,GAAK,CAAA,CAChC,CAEF,EAAAH,EAEJ,OAAQE,EAAAA,IAAAE,EAAA,CAAK,GAAGH,EAAW,SAAMJ,CAAA,CAAA,CACnC,EAEAF,EAAa,aAAe,CAC1B,QAAS,GACT,KAAM,EACR,EAEa,MAAAU,EAAgBT,GAA6B,CAClD,KAAA,CAAE,MAAAU,CAAU,EAAAV,EACZW,EAAeD,EAAM,OAAQE,GAAS,CAACA,EAAK,IAAI,EAChDC,EAAMF,EAAa,OAGvB,OAAAL,MAACQ,GAAM,IAAI,IACR,WAAa,IAAI,CAACF,EAAMG,IACvBT,EAAA,IAACP,EAAA,CAEC,QAASc,IAAQE,EAAQ,EACxB,GAAGH,CAAA,EAFCA,EAAK,KAAOG,CAIpB,CAA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