{"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