@lax-wp/design-system 0.13.33-beta.4 → 0.13.33-beta.6
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.
- package/dist/components/forms/base-input-field/BaseInputField.cjs.js +2 -2
- package/dist/components/forms/base-input-field/BaseInputField.cjs.js.map +1 -1
- package/dist/components/forms/base-input-field/BaseInputField.es.js +20 -20
- package/dist/components/forms/base-input-field/BaseInputField.es.js.map +1 -1
- package/dist/components/forms/creatable-select/CreatableSelect.cjs.js +1 -1
- package/dist/components/forms/creatable-select/CreatableSelect.cjs.js.map +1 -1
- package/dist/components/forms/creatable-select/CreatableSelect.es.js +7 -7
- package/dist/components/forms/creatable-select/CreatableSelect.es.js.map +1 -1
- package/dist/components/forms/currency-input/CurrencyInputField.cjs.js +1 -1
- package/dist/components/forms/currency-input/CurrencyInputField.cjs.js.map +1 -1
- package/dist/components/forms/currency-input/CurrencyInputField.es.js +12 -12
- package/dist/components/forms/currency-input/CurrencyInputField.es.js.map +1 -1
- package/dist/components/forms/date-time-field/DateTimeField.cjs.js +1 -1
- package/dist/components/forms/date-time-field/DateTimeField.cjs.js.map +1 -1
- package/dist/components/forms/date-time-field/DateTimeField.es.js +1 -1
- package/dist/components/forms/date-time-field/DateTimeField.es.js.map +1 -1
- package/dist/components/forms/dynamic-data-input/DynamicDataInput.cjs.js +1 -1
- package/dist/components/forms/dynamic-data-input/DynamicDataInput.cjs.js.map +1 -1
- package/dist/components/forms/dynamic-data-input/DynamicDataInput.es.js +7 -7
- package/dist/components/forms/dynamic-data-input/DynamicDataInput.es.js.map +1 -1
- package/dist/components/forms/dynamic-data-input/DynamicDataInputField.cjs.js +1 -1
- package/dist/components/forms/dynamic-data-input/DynamicDataInputField.cjs.js.map +1 -1
- package/dist/components/forms/dynamic-data-input/DynamicDataInputField.es.js +1 -1
- package/dist/components/forms/dynamic-data-input/DynamicDataInputField.es.js.map +1 -1
- package/dist/components/forms/formula-input/FormulaInput.cjs.js +1 -1
- package/dist/components/forms/formula-input/FormulaInput.cjs.js.map +1 -1
- package/dist/components/forms/formula-input/FormulaInput.es.js +10 -10
- package/dist/components/forms/formula-input/FormulaInput.es.js.map +1 -1
- package/dist/components/forms/input-field/InputField.cjs.js.map +1 -1
- package/dist/components/forms/input-field/InputField.es.js.map +1 -1
- package/dist/components/forms/master-data-input/MasterDataInputField.cjs.js +1 -1
- package/dist/components/forms/master-data-input/MasterDataInputField.cjs.js.map +1 -1
- package/dist/components/forms/master-data-input/MasterDataInputField.es.js +1 -1
- package/dist/components/forms/master-data-input/MasterDataInputField.es.js.map +1 -1
- package/dist/components/forms/percentage-input/PercentageInputField.cjs.js +2 -2
- package/dist/components/forms/percentage-input/PercentageInputField.cjs.js.map +1 -1
- package/dist/components/forms/percentage-input/PercentageInputField.es.js +19 -19
- package/dist/components/forms/percentage-input/PercentageInputField.es.js.map +1 -1
- package/dist/components/forms/select-field/SelectField.cjs.js +2 -2
- package/dist/components/forms/select-field/SelectField.cjs.js.map +1 -1
- package/dist/components/forms/select-field/SelectField.es.js +1 -1
- package/dist/components/forms/select-field/SelectField.es.js.map +1 -1
- package/dist/components/forms/text-area-field/TextAreaField.cjs.js +1 -1
- package/dist/components/forms/text-area-field/TextAreaField.cjs.js.map +1 -1
- package/dist/components/forms/text-area-field/TextAreaField.es.js +14 -14
- package/dist/components/forms/text-area-field/TextAreaField.es.js.map +1 -1
- package/dist/components/forms/toggle/Toggle.cjs.js +1 -1
- package/dist/components/forms/toggle/Toggle.cjs.js.map +1 -1
- package/dist/components/forms/toggle/Toggle.es.js +62 -56
- package/dist/components/forms/toggle/Toggle.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MasterDataInputField.es.js","sources":["../../../../src/components/forms/master-data-input/MasterDataInputField.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport cn from \"classnames\";\nimport { forwardRef, useEffect, useRef, useState } from \"react\";\nimport { Tooltip as AntTooltip } from \"antd\";\nimport { useTranslation } from 'react-i18next';\nimport { Typography } from \"../../data-display/typography/Typography\";\nimport { Label } from \"../../data-display/label/Label\";\nimport type { LabelType } from \"../../data-display/label/Label\";\nimport {\n BoltOutlined,\n CloseRounded,\n NoteAddOutlined,\n TableChartRounded,\n} from \"@mui/icons-material\";\nimport { AIExtractedIndicator } from \"../../icons/AIExtractedIndicator\";\nimport { AIStarIcon } from \"../../icons/AIStarIcon\";\nimport { HelpIcon } from \"../../icons/HelpIcon\";\nimport Tooltip from \"../../tooltip/Tooltip\";\nimport IconButton from \"../../button/IconButton\";\nimport { InputLabel } from \"../shared/InputLabel\";\nimport {\n getConfidenceScoreBadgeClass,\n getConfidenceScoreBadgeColor,\n getConfidenceScoreBadgeFill,\n getConfidenceScoreBadgeTextColor,\n shouldShowConfidenceScore,\n} from \"../../../utils/confidenceScoreUtils\";\nimport { CloseIcon, CloseSmallIcon } from \"../../icon\";\n\n/**\n * Confidence score type\n */\nexport type ConfidenceScoreType = \"low\" | \"medium\" | \"high\";\n\nexport type SourceMetaBBox = {\n b: number;\n l: number;\n r: number;\n t: number;\n};\n\nexport type SourceMetaItem = {\n bbox: SourceMetaBBox;\n confidence_score?: number;\n is_primary?: boolean;\n match_score?: number;\n match_type?: string;\n page_height: number;\n page_width: number;\n source_page: number;\n source_text?: string;\n};\n\n/**\n * Risk details interface for risk analysis integration\n */\nexport interface RiskDetails {\n color?: string;\n description?: string;\n hexBgColor?: string;\n hexBorderColor?: string;\n [key: string]: any;\n}\n\n/**\n * Risk details card component props - generic to allow consumer-specific risk types\n */\nexport interface RiskDetailsCardProps<T = any> {\n riskDetails: T;\n maxWidth?: string;\n showAllRisksSuggestions?: boolean;\n}\n\n/**\n * Props for the MasterDataModal component\n */\nexport interface MasterDataModalProps {\n isVisible: boolean;\n onSelected?: (masterDataValue: any, masterDataRow?: any) => void;\n onClose: () => void;\n masterDataColumnName?: string;\n masterDataFilters?: any;\n masterDataName?: string;\n masterDataId: string | null;\n showFilters?: boolean;\n}\n\n/**\n * Props for the MasterDataInputField component\n */\nexport interface MasterDataInputFieldProps {\n /** Unique identifier for the input */\n id: string;\n /** Label text to display above the input */\n label: string;\n /** Placeholder text for the input */\n placeholder?: string;\n /** Current value of the input */\n value: any;\n /** Callback function called when value changes */\n onChange: (value: any, masterDataRowValue?: any) => void;\n /** Error message to display below the input */\n errorMessage?: string;\n /** Callback to set error message */\n setErrorMessage: (message: string) => void;\n /** Callback to remove error message */\n removeErrorMessage: () => void;\n /** Default value for the input */\n defaultValue?: any;\n /** Whether the field is required */\n required?: boolean;\n /** Whether the required indicator shows as conditional (yellow instead of red) */\n isRequiredConditional?: boolean;\n /** Name of the master data source */\n masterDataName: string;\n /** Column name in the master data */\n masterDataColumnName: string;\n /** Formula for computing master data value */\n masterDataFormula?: string;\n /** Filters for master data */\n masterDataFilters?: any;\n /** Tags/labels to display next to the label */\n tags?: (string | LabelType)[];\n /** Index for array fields */\n index?: number;\n /** Tooltip text for the help icon */\n tooltip?: string;\n /** Whether to preserve original case in the label */\n originalCase?: boolean;\n /** Color for the input text */\n color?: string;\n /** Whether this is a GTN (Global Term Name) field */\n isGTN?: boolean;\n /** GTN field name for document integration */\n gtnName?: any;\n /** Whether the value was AI extracted */\n isAiExtracted?: boolean;\n /** Confidence percentage shown as a badge */\n confidenceScore?: number;\n /** Confidence classification for badge styling */\n confidenceType?: ConfidenceScoreType;\n /** Optional tooltip content for confidence badge */\n confidenceTooltip?: React.ReactNode;\n /** Source meta for confidence score */\n sourceMeta?: SourceMetaItem[];\n /** Handler fired when confidence score badge is clicked */\n onConfidenceScoreClick?: (sourceMeta: SourceMetaItem[]) => void;\n /** Reference data for formula computation */\n reference?: any;\n /** Whether the input is disabled */\n disabled?: boolean;\n /** Additional CSS classes for the label */\n labelClassName?: string;\n /** Whether this is a live field */\n isLiveField?: boolean;\n /** Callback function called when input loses focus */\n onBlur?: () => void;\n /** Handler for adding GTN to document */\n onAddGTNToDocument?: (keyValuePair: { key: string; value: string }) => void;\n /** Risk details data */\n riskDetails?: RiskDetails;\n /** Whether risk analysis is open */\n isRiskAnalysisOpen?: boolean;\n /** Custom risk details card component */\n RiskDetailsCard?: React.ComponentType<RiskDetailsCardProps<any>>;\n /** Primary color shades for styling */\n primaryColorShades?: Record<number, string>;\n /** Callback to set disable actions state */\n setDisableActions?: (disabled: boolean) => void;\n /** Toast function for deprecated field warning */\n showDeprecatedFieldWarning?: () => void;\n /** Master data modal component */\n MasterDataModal?: React.ComponentType<MasterDataModalProps>;\n /** Function to parse master data formula */\n parseMasterDataFormula?: (formula: string, row: any) => string;\n}\n\n/**\n * A highly customizable master data input component with label, validation, and styling support.\n * Features master data modal integration, GTN support, risk analysis support,\n * and comprehensive prop support for various use cases.\n *\n * @example\n * ```tsx\n * <MasterDataInputField\n * id=\"master-field\"\n * label=\"Master Field\"\n * value={fieldValue}\n * onChange={(value, rowValue) => setFieldValue(value)}\n * setErrorMessage={(msg) => setError(msg)}\n * removeErrorMessage={() => setError('')}\n * masterDataName=\"customers\"\n * masterDataColumnName=\"name\"\n * required\n * />\n * ```\n */\nexport const MasterDataInputField = forwardRef<\n HTMLInputElement,\n MasterDataInputFieldProps\n>(\n (\n {\n id,\n label,\n placeholder,\n value,\n onChange,\n errorMessage,\n defaultValue,\n required = false,\n isRequiredConditional = false,\n masterDataName,\n masterDataColumnName,\n masterDataFormula,\n masterDataFilters,\n tags,\n index,\n tooltip = \"\",\n originalCase = false,\n color = \"\",\n isGTN = false,\n labelClassName,\n gtnName = null,\n isAiExtracted = false,\n confidenceScore,\n confidenceType = \"high\",\n confidenceTooltip,\n sourceMeta = [],\n onConfidenceScoreClick,\n disabled = false,\n reference = {},\n isLiveField = false,\n onBlur,\n onAddGTNToDocument,\n riskDetails,\n isRiskAnalysisOpen = false,\n RiskDetailsCard,\n primaryColorShades,\n setDisableActions,\n showDeprecatedFieldWarning,\n MasterDataModal,\n parseMasterDataFormula,\n },\n ref\n ) => {\n const { t } = useTranslation();\n const [isHovered, setIsHovered] = useState(false);\n const [inputValue, setInputValue] = useState<string | null>(null);\n const [showMasterDataModal, setShowMasterDataModal] = useState(false);\n const [suggestion, setSuggestion] = useState(\"\");\n const [masterDataRowValue, setMasterDataRowValue] = useState<any>(null);\n const [isTextOverflowing, setIsTextOverflowing] = useState(false);\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n // Use forwarded ref or internal ref\n const combinedRef = (ref as React.RefObject<HTMLInputElement>) || inputRef;\n\n // Check if text is overflowing\n useEffect(() => {\n const checkOverflow = () => {\n const input = combinedRef.current || inputRef.current;\n if (input) {\n setIsTextOverflowing(input.scrollWidth > input.clientWidth);\n }\n };\n\n checkOverflow();\n // Recheck on window resize\n window.addEventListener('resize', checkOverflow);\n return () => window.removeEventListener('resize', checkOverflow);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [inputValue, value]);\n\n useEffect(() => {\n setInputValue(value);\n }, [index, value]);\n\n useEffect(() => {\n if (inputValue !== null && inputValue !== value) {\n onChange(inputValue, masterDataRowValue);\n }\n }, [inputValue, masterDataRowValue]);\n\n const toggleMasterDataModal = () => {\n if (showMasterDataModal) {\n setDisableActions?.(false);\n } else {\n setDisableActions?.(true);\n }\n setShowMasterDataModal(!showMasterDataModal);\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (event.keyCode === 9 || event.key === \"Enter\") {\n const currentRef = combinedRef.current || inputRef.current;\n if (currentRef) {\n setInputValue(suggestion);\n currentRef.blur();\n }\n }\n };\n\n const handleSetMasterData = (masterDataValue: any, masterDataRow?: any) => {\n let _value = masterDataValue;\n\n if (masterDataFormula && parseMasterDataFormula) {\n _value = parseMasterDataFormula(masterDataFormula, masterDataRow);\n }\n\n setSuggestion(\"\");\n setInputValue(_value);\n toggleMasterDataModal();\n setMasterDataRowValue(masterDataRow);\n };\n\n const handleClear = () => {\n setInputValue(\"\");\n setMasterDataRowValue(null);\n };\n\n const handleAddGTNToDocument = (_value: string) => {\n if (onAddGTNToDocument && gtnName) {\n const keyValuePair = {\n key: gtnName,\n value: _value,\n };\n onAddGTNToDocument(keyValuePair);\n }\n };\n\n const getClassName = (): string => {\n const baseClasses =\n \"border h-8 text-sm rounded-lg block w-full p-2.5 pr-16 font-inter font-medium\";\n const borderColor = errorMessage\n ? \"border-red-300\"\n : isRiskAnalysisOpen && riskDetails?.color\n ? `border-${riskDetails?.color}-300`\n : \"border-gray-300 dark:border-black-600\";\n const placeholderColor = `placeholder:text-neutral-900 dark:placeholder:text-black-400`;\n const backgroundColor = `${\n isRiskAnalysisOpen && riskDetails?.color\n ? `bg-${riskDetails?.color}-50`\n : \"dark:bg-black-600 \"\n } ${color ? color : \"text-neutral-900 dark:text-black-200\"}`;\n\n return `${baseClasses} ${borderColor} ${backgroundColor} ${placeholderColor}`;\n };\n\n const resolveMasterDataValue = () => {\n if (inputValue !== null) {\n return inputValue;\n }\n if (masterDataFormula && parseMasterDataFormula) {\n return parseMasterDataFormula(masterDataFormula, reference);\n }\n\n return value;\n };\n\n useEffect(() => {\n if (showMasterDataModal && !masterDataName) {\n showDeprecatedFieldWarning?.();\n setShowMasterDataModal(false);\n }\n }, [showMasterDataModal, masterDataName, showDeprecatedFieldWarning]);\n\n return (\n <div\n className={cn(\n `flex gap-0.5 w-full relative`,\n isHovered && isGTN\n ? \"border rounded-lg border-primary-100 p-1\"\n : \"\",\n { \"error-field\": !!errorMessage }\n )}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n >\n {isGTN && !isHovered ? (\n <div className=\"w-1 h-1 bg-primary-600 rounded-full animate-blink mt-1.5\" />\n ) : null}\n\n <div className={cn(`flex flex-col w-full`)}>\n <label\n htmlFor=\"text\"\n className={`text-xs font-medium text-gray-600 inline-flex items-center gap-1 ${\n !originalCase ? \"capitalize\" : \"\"\n } ${labelClassName || \"\"}`}\n >\n <div className=\"grid w-full grid-cols-[minmax(0,1fr)_auto] items-start gap-x-1\">\n <div className=\"inline-flex min-w-0 items-center gap-1 flex-wrap\">\n <InputLabel label={label || \"\"} required={required || false} isRequiredConditional={isRequiredConditional || false} />\n {isLiveField && (\n <BoltOutlined\n sx={{\n fontSize: 16,\n color: \"var(--color-primary-600)\",\n rotate: \"15deg\",\n }}\n />\n )}\n {isAiExtracted && !shouldShowConfidenceScore(confidenceScore) && <AIExtractedIndicator />}\n <Label labels={tags} />\n {tooltip && (\n <Tooltip\n placement=\"top\"\n title={`${tooltip}${masterDataFormula ? ` | ${masterDataFormula}` : \"\"}`}\n >\n <div className=\"cursor-pointer\">\n <HelpIcon />\n </div>\n </Tooltip>\n )}\n </div>\n\n <div className=\"flex items-center gap-1 justify-self-end\">\n {(shouldShowConfidenceScore(confidenceScore) && confidenceType) ? (\n <Tooltip\n placement=\"top-end\"\n title={confidenceTooltip ?? \"\"}\n hideTooltip={confidenceTooltip === undefined || confidenceTooltip === null}\n className=\"cursor-pointer\"\n >\n <div\n className={cn(\n \"inline-flex min-w-[50px] items-center gap-1 rounded-md px-1 py-0.5\",\n getConfidenceScoreBadgeClass(confidenceType)\n )}\n onClick={() => onConfidenceScoreClick?.(sourceMeta)}\n >\n <AIStarIcon\n size={12}\n fill={getConfidenceScoreBadgeColor(confidenceType)}\n fillSecondary={getConfidenceScoreBadgeFill(confidenceType)}\n />\n <span className={cn(\"text-xs font-medium leading-4\", getConfidenceScoreBadgeTextColor(confidenceType))}>\n {confidenceScore}%\n </span>\n </div>\n </Tooltip>\n ) : null}\n {isGTN && isHovered && onAddGTNToDocument ? (\n <button\n id=\"btn-master-data-input-add-to-document\"\n className=\"cursor-pointer\"\n onClick={() => handleAddGTNToDocument(value?.toString() || \"\")}\n type=\"button\"\n >\n <AntTooltip placement=\"top\" title={t(\"Add to document\")}>\n <NoteAddOutlined\n sx={{\n fontSize: 16,\n color:\n primaryColorShades?.[600] || \"var(--color-primary-600)\",\n }}\n />\n </AntTooltip>\n </button>\n ) : null}\n </div>\n </div>\n </label>\n <label className=\"relative block mt-1\">\n <Tooltip\n title={isTextOverflowing ? resolveMasterDataValue() : \"\"}\n >\n <input\n id={id}\n ref={combinedRef}\n required={required}\n placeholder={placeholder}\n className={getClassName()}\n onChange={(e) => {\n onChange(e.target.value, masterDataRowValue);\n setInputValue(e.target?.value);\n }}\n onKeyDown={handleKeyDown}\n value={resolveMasterDataValue()}\n defaultValue={defaultValue}\n disabled={true}\n autoComplete=\"off\"\n onBlur={onBlur}\n />\n </Tooltip>\n\n <IconButton\n id={`btn-dynamic-data-input-rx-cross`}\n onClick={handleClear}\n className=\"absolute inset-y-0 right-1 flex items-center px-2 focus:border-transparent\"\n variant=\"ghost\"\n disabled={disabled}\n >\n <CloseIcon className=\"w-6 h-6 text-neutral-500 dark:text-neutral-400 w-sm h-sm\" />\n </IconButton>\n\n <IconButton\n id={`btn-dynamic-data-input-ai-outline-pic-center`}\n onClick={toggleMasterDataModal}\n className=\"absolute inset-y-0 right-8 flex items-center px-2 focus:border-transparent\"\n variant=\"ghost\"\n disabled={disabled}\n >\n <TableChartRounded\n className=\"text-neutral-500 dark:text-neutral-400 w-sm h-sm\"\n />\n </IconButton>\n </label>\n\n {errorMessage && (\n <Typography\n className=\"text-error-500 mt-1\"\n appearance=\"custom\"\n size=\"extra-small\"\n variant=\"medium\"\n >\n {errorMessage}\n </Typography>\n )}\n\n {showMasterDataModal && MasterDataModal && (\n <MasterDataModal\n isVisible={showMasterDataModal}\n onSelected={handleSetMasterData}\n onClose={toggleMasterDataModal}\n masterDataColumnName={masterDataColumnName}\n masterDataFilters={masterDataFilters}\n masterDataName={masterDataName}\n masterDataId={masterDataName}\n showFilters\n />\n )}\n </div>\n\n {isHovered &&\n riskDetails &&\n isRiskAnalysisOpen &&\n RiskDetailsCard && (\n <div\n role=\"tooltip\"\n tabIndex={0}\n className=\"absolute left-0 right-0 top-[95%] mt-1 z-50 bg-white dark:bg-black-600 rounded-xl\"\n onClick={(e) => e.stopPropagation()}\n onMouseDown={(e) => e.preventDefault()}\n onKeyDown={(e) => {\n if (e.key === \"Escape\") {\n setIsHovered(false);\n }\n }}\n >\n <RiskDetailsCard riskDetails={riskDetails} />\n </div>\n )}\n </div>\n );\n }\n);\n\nMasterDataInputField.displayName = \"MasterDataInputField\";\n\n"],"names":["MasterDataInputField","forwardRef","id","label","placeholder","value","onChange","errorMessage","defaultValue","required","isRequiredConditional","masterDataName","masterDataColumnName","masterDataFormula","masterDataFilters","tags","index","tooltip","originalCase","color","isGTN","labelClassName","gtnName","isAiExtracted","confidenceScore","confidenceType","confidenceTooltip","sourceMeta","onConfidenceScoreClick","disabled","reference","isLiveField","onBlur","onAddGTNToDocument","riskDetails","isRiskAnalysisOpen","RiskDetailsCard","primaryColorShades","setDisableActions","showDeprecatedFieldWarning","MasterDataModal","parseMasterDataFormula","ref","t","useTranslation","isHovered","setIsHovered","useState","inputValue","setInputValue","showMasterDataModal","setShowMasterDataModal","suggestion","setSuggestion","masterDataRowValue","setMasterDataRowValue","isTextOverflowing","setIsTextOverflowing","inputRef","useRef","combinedRef","useEffect","checkOverflow","input","toggleMasterDataModal","handleKeyDown","event","currentRef","handleSetMasterData","masterDataValue","masterDataRow","_value","handleClear","handleAddGTNToDocument","getClassName","baseClasses","borderColor","placeholderColor","backgroundColor","resolveMasterDataValue","jsxs","cn","jsx","InputLabel","BoltOutlined","shouldShowConfidenceScore","AIExtractedIndicator","Label","Tooltip","HelpIcon","getConfidenceScoreBadgeClass","AIStarIcon","getConfidenceScoreBadgeColor","getConfidenceScoreBadgeFill","getConfidenceScoreBadgeTextColor","AntTooltip","NoteAddOutlined","e","IconButton","CloseIcon","TableChartRounded","Typography"],"mappings":";;;;;;;;;;;;;;;;AAqMO,MAAMA,KAAuBC;AAAA,EAIlC,CACE;AAAA,IACE,IAAAC;AAAA,IACA,OAAAC;AAAA,IACA,aAAAC;AAAA,IACA,OAAAC;AAAA,IACA,UAAAC;AAAA,IACA,cAAAC;AAAA,IACA,cAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IAC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M;AAChB,gBAAIA,EAAE,QAAQ,YACZnD,EAAa,EAAK;AAAA,cAEtB;AAAA,cAEA,UAAA,gBAAAoC,EAAC9C,KAAgB,aAAAF,EAAA,CAA0B;AAAA,YAAA;AAAA,UAAA;AAAA,QAC7C;AAAA,MAAA;AAAA,IAAA;AAAA,EAIV;AACF;AAEAlC,GAAqB,cAAc;"}
|
|
1
|
+
{"version":3,"file":"MasterDataInputField.es.js","sources":["../../../../src/components/forms/master-data-input/MasterDataInputField.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport cn from \"classnames\";\nimport { forwardRef, useEffect, useRef, useState } from \"react\";\nimport { Tooltip as AntTooltip } from \"antd\";\nimport { useTranslation } from 'react-i18next';\nimport { Typography } from \"../../data-display/typography/Typography\";\nimport { Label } from \"../../data-display/label/Label\";\nimport type { LabelType } from \"../../data-display/label/Label\";\nimport {\n BoltOutlined,\n CloseRounded,\n NoteAddOutlined,\n TableChartRounded,\n} from \"@mui/icons-material\";\nimport { AIExtractedIndicator } from \"../../icons/AIExtractedIndicator\";\nimport { AIStarIcon } from \"../../icons/AIStarIcon\";\nimport { HelpIcon } from \"../../icons/HelpIcon\";\nimport Tooltip from \"../../tooltip/Tooltip\";\nimport IconButton from \"../../button/IconButton\";\nimport { InputLabel } from \"../shared/InputLabel\";\nimport {\n getConfidenceScoreBadgeClass,\n getConfidenceScoreBadgeColor,\n getConfidenceScoreBadgeFill,\n getConfidenceScoreBadgeTextColor,\n shouldShowConfidenceScore,\n} from \"../../../utils/confidenceScoreUtils\";\nimport { CloseIcon, CloseSmallIcon } from \"../../icon\";\n\n/**\n * Confidence score type\n */\nexport type ConfidenceScoreType = \"low\" | \"medium\" | \"high\";\n\nexport type SourceMetaBBox = {\n b: number;\n l: number;\n r: number;\n t: number;\n};\n\nexport type SourceMetaItem = {\n bbox: SourceMetaBBox;\n confidence_score?: number;\n is_primary?: boolean;\n match_score?: number;\n match_type?: string;\n page_height: number;\n page_width: number;\n source_page: number;\n source_text?: string;\n};\n\n/**\n * Risk details interface for risk analysis integration\n */\nexport interface RiskDetails {\n color?: string;\n description?: string;\n hexBgColor?: string;\n hexBorderColor?: string;\n [key: string]: any;\n}\n\n/**\n * Risk details card component props - generic to allow consumer-specific risk types\n */\nexport interface RiskDetailsCardProps<T = any> {\n riskDetails: T;\n maxWidth?: string;\n showAllRisksSuggestions?: boolean;\n}\n\n/**\n * Props for the MasterDataModal component\n */\nexport interface MasterDataModalProps {\n isVisible: boolean;\n onSelected?: (masterDataValue: any, masterDataRow?: any) => void;\n onClose: () => void;\n masterDataColumnName?: string;\n masterDataFilters?: any;\n masterDataName?: string;\n masterDataId: string | null;\n showFilters?: boolean;\n}\n\n/**\n * Props for the MasterDataInputField component\n */\nexport interface MasterDataInputFieldProps {\n /** Unique identifier for the input */\n id: string;\n /** Label text to display above the input */\n label: string;\n /** Placeholder text for the input */\n placeholder?: string;\n /** Current value of the input */\n value: any;\n /** Callback function called when value changes */\n onChange: (value: any, masterDataRowValue?: any) => void;\n /** Error message to display below the input */\n errorMessage?: string;\n /** Callback to set error message */\n setErrorMessage: (message: string) => void;\n /** Callback to remove error message */\n removeErrorMessage: () => void;\n /** Default value for the input */\n defaultValue?: any;\n /** Whether the field is required */\n required?: boolean;\n /** Whether the required indicator shows as conditional (yellow instead of red) */\n isRequiredConditional?: boolean;\n /** Name of the master data source */\n masterDataName: string;\n /** Column name in the master data */\n masterDataColumnName: string;\n /** Formula for computing master data value */\n masterDataFormula?: string;\n /** Filters for master data */\n masterDataFilters?: any;\n /** Tags/labels to display next to the label */\n tags?: (string | LabelType)[];\n /** Index for array fields */\n index?: number;\n /** Tooltip text for the help icon */\n tooltip?: string;\n /** Whether to preserve original case in the label */\n originalCase?: boolean;\n /** Color for the input text */\n color?: string;\n /** Whether this is a GTN (Global Term Name) field */\n isGTN?: boolean;\n /** GTN field name for document integration */\n gtnName?: any;\n /** Whether the value was AI extracted */\n isAiExtracted?: boolean;\n /** Confidence percentage shown as a badge */\n confidenceScore?: number;\n /** Confidence classification for badge styling */\n confidenceType?: ConfidenceScoreType;\n /** Optional tooltip content for confidence badge */\n confidenceTooltip?: React.ReactNode;\n /** Source meta for confidence score */\n sourceMeta?: SourceMetaItem[];\n /** Handler fired when confidence score badge is clicked */\n onConfidenceScoreClick?: (sourceMeta: SourceMetaItem[]) => void;\n /** Reference data for formula computation */\n reference?: any;\n /** Whether the input is disabled */\n disabled?: boolean;\n /** Additional CSS classes for the label */\n labelClassName?: string;\n /** Whether this is a live field */\n isLiveField?: boolean;\n /** Callback function called when input loses focus */\n onBlur?: () => void;\n /** Handler for adding GTN to document */\n onAddGTNToDocument?: (keyValuePair: { key: string; value: string }) => void;\n /** Risk details data */\n riskDetails?: RiskDetails;\n /** Whether risk analysis is open */\n isRiskAnalysisOpen?: boolean;\n /** Custom risk details card component */\n RiskDetailsCard?: React.ComponentType<RiskDetailsCardProps<any>>;\n /** Primary color shades for styling */\n primaryColorShades?: Record<number, string>;\n /** Callback to set disable actions state */\n setDisableActions?: (disabled: boolean) => void;\n /** Toast function for deprecated field warning */\n showDeprecatedFieldWarning?: () => void;\n /** Master data modal component */\n MasterDataModal?: React.ComponentType<MasterDataModalProps>;\n /** Function to parse master data formula */\n parseMasterDataFormula?: (formula: string, row: any) => string;\n}\n\n/**\n * A highly customizable master data input component with label, validation, and styling support.\n * Features master data modal integration, GTN support, risk analysis support,\n * and comprehensive prop support for various use cases.\n *\n * @example\n * ```tsx\n * <MasterDataInputField\n * id=\"master-field\"\n * label=\"Master Field\"\n * value={fieldValue}\n * onChange={(value, rowValue) => setFieldValue(value)}\n * setErrorMessage={(msg) => setError(msg)}\n * removeErrorMessage={() => setError('')}\n * masterDataName=\"customers\"\n * masterDataColumnName=\"name\"\n * required\n * />\n * ```\n */\nexport const MasterDataInputField = forwardRef<\n HTMLInputElement,\n MasterDataInputFieldProps\n>(\n (\n {\n id,\n label,\n placeholder,\n value,\n onChange,\n errorMessage,\n defaultValue,\n required = false,\n isRequiredConditional = false,\n masterDataName,\n masterDataColumnName,\n masterDataFormula,\n masterDataFilters,\n tags,\n index,\n tooltip = \"\",\n originalCase = false,\n color = \"\",\n isGTN = false,\n labelClassName,\n gtnName = null,\n isAiExtracted = false,\n confidenceScore,\n confidenceType = \"high\",\n confidenceTooltip,\n sourceMeta = [],\n onConfidenceScoreClick,\n disabled = false,\n reference = {},\n isLiveField = false,\n onBlur,\n onAddGTNToDocument,\n riskDetails,\n isRiskAnalysisOpen = false,\n RiskDetailsCard,\n primaryColorShades,\n setDisableActions,\n showDeprecatedFieldWarning,\n MasterDataModal,\n parseMasterDataFormula,\n },\n ref\n ) => {\n const { t } = useTranslation();\n const [isHovered, setIsHovered] = useState(false);\n const [inputValue, setInputValue] = useState<string | null>(null);\n const [showMasterDataModal, setShowMasterDataModal] = useState(false);\n const [suggestion, setSuggestion] = useState(\"\");\n const [masterDataRowValue, setMasterDataRowValue] = useState<any>(null);\n const [isTextOverflowing, setIsTextOverflowing] = useState(false);\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n // Use forwarded ref or internal ref\n const combinedRef = (ref as React.RefObject<HTMLInputElement>) || inputRef;\n\n // Check if text is overflowing\n useEffect(() => {\n const checkOverflow = () => {\n const input = combinedRef.current || inputRef.current;\n if (input) {\n setIsTextOverflowing(input.scrollWidth > input.clientWidth);\n }\n };\n\n checkOverflow();\n // Recheck on window resize\n window.addEventListener('resize', checkOverflow);\n return () => window.removeEventListener('resize', checkOverflow);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [inputValue, value]);\n\n useEffect(() => {\n setInputValue(value);\n }, [index, value]);\n\n useEffect(() => {\n if (inputValue !== null && inputValue !== value) {\n onChange(inputValue, masterDataRowValue);\n }\n }, [inputValue, masterDataRowValue]);\n\n const toggleMasterDataModal = () => {\n if (showMasterDataModal) {\n setDisableActions?.(false);\n } else {\n setDisableActions?.(true);\n }\n setShowMasterDataModal(!showMasterDataModal);\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (event.keyCode === 9 || event.key === \"Enter\") {\n const currentRef = combinedRef.current || inputRef.current;\n if (currentRef) {\n setInputValue(suggestion);\n currentRef.blur();\n }\n }\n };\n\n const handleSetMasterData = (masterDataValue: any, masterDataRow?: any) => {\n let _value = masterDataValue;\n\n if (masterDataFormula && parseMasterDataFormula) {\n _value = parseMasterDataFormula(masterDataFormula, masterDataRow);\n }\n\n setSuggestion(\"\");\n setInputValue(_value);\n toggleMasterDataModal();\n setMasterDataRowValue(masterDataRow);\n };\n\n const handleClear = () => {\n setInputValue(\"\");\n setMasterDataRowValue(null);\n };\n\n const handleAddGTNToDocument = (_value: string) => {\n if (onAddGTNToDocument && gtnName) {\n const keyValuePair = {\n key: gtnName,\n value: _value,\n };\n onAddGTNToDocument(keyValuePair);\n }\n };\n\n const getClassName = (): string => {\n const baseClasses =\n \"border h-8 text-sm rounded-lg block w-full p-2.5 pr-16 font-inter font-medium\";\n const borderColor = errorMessage\n ? \"border-red-300\"\n : isRiskAnalysisOpen && riskDetails?.color\n ? `border-${riskDetails?.color}-300`\n : \"border-gray-300 dark:border-black-600\";\n const placeholderColor = `placeholder:text-neutral-900 dark:placeholder:text-black-400`;\n const backgroundColor = `${\n isRiskAnalysisOpen && riskDetails?.color\n ? `bg-${riskDetails?.color}-50`\n : \"dark:bg-black-600 \"\n } ${color ? color : \"text-neutral-900 dark:text-black-200\"}`;\n\n return `${baseClasses} ${borderColor} ${backgroundColor} ${placeholderColor}`;\n };\n\n const resolveMasterDataValue = () => {\n if (inputValue !== null) {\n return inputValue;\n }\n if (masterDataFormula && parseMasterDataFormula) {\n return parseMasterDataFormula(masterDataFormula, reference);\n }\n\n return value;\n };\n\n useEffect(() => {\n if (showMasterDataModal && !masterDataName) {\n showDeprecatedFieldWarning?.();\n setShowMasterDataModal(false);\n }\n }, [showMasterDataModal, masterDataName, showDeprecatedFieldWarning]);\n\n return (\n <div\n className={cn(\n `flex gap-0.5 w-full relative`,\n isHovered && isGTN\n ? \"border rounded-lg border-primary-100 p-1\"\n : \"\",\n { \"error-field\": !!errorMessage }\n )}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n >\n {isGTN && !isHovered ? (\n <div className=\"w-1 h-1 bg-primary-600 rounded-full animate-blink mt-1.5\" />\n ) : null}\n\n <div className={cn(`flex flex-col w-full`)}>\n <label\n htmlFor=\"text\"\n className={`text-xs font-medium text-gray-600 inline-flex items-center gap-1 ${\n !originalCase ? \"capitalize\" : \"\"\n } ${labelClassName || \"\"}`}\n >\n <div className=\"grid w-full grid-cols-[minmax(0,1fr)_auto] items-start gap-x-1\">\n <div className=\"inline-flex min-w-0 items-center gap-1 flex-wrap\">\n <InputLabel label={label || \"\"} required={required || false} isRequiredConditional={isRequiredConditional || false} />\n {isLiveField && (\n <BoltOutlined\n sx={{\n fontSize: 16,\n color: \"var(--color-primary-600)\",\n rotate: \"15deg\",\n }}\n />\n )}\n {isAiExtracted && !shouldShowConfidenceScore(confidenceScore) && <AIExtractedIndicator />}\n <Label labels={tags} />\n {tooltip && (\n <Tooltip\n placement=\"top\"\n title={`${tooltip}${masterDataFormula ? ` | ${masterDataFormula}` : \"\"}`}\n >\n <div className=\"cursor-pointer\">\n <HelpIcon className=\"w-icon-sm h-icon-sm\" />\n </div>\n </Tooltip>\n )}\n </div>\n\n <div className=\"flex items-center gap-1 justify-self-end\">\n {(shouldShowConfidenceScore(confidenceScore) && confidenceType) ? (\n <Tooltip\n placement=\"top-end\"\n title={confidenceTooltip ?? \"\"}\n hideTooltip={confidenceTooltip === undefined || confidenceTooltip === null}\n className=\"cursor-pointer\"\n >\n <div\n className={cn(\n \"inline-flex min-w-[50px] items-center gap-1 rounded-md px-1 py-0.5\",\n getConfidenceScoreBadgeClass(confidenceType)\n )}\n onClick={() => onConfidenceScoreClick?.(sourceMeta)}\n >\n <AIStarIcon\n size={12}\n fill={getConfidenceScoreBadgeColor(confidenceType)}\n fillSecondary={getConfidenceScoreBadgeFill(confidenceType)}\n />\n <span className={cn(\"text-xs font-medium leading-4\", getConfidenceScoreBadgeTextColor(confidenceType))}>\n {confidenceScore}%\n </span>\n </div>\n </Tooltip>\n ) : null}\n {isGTN && isHovered && onAddGTNToDocument ? (\n <button\n id=\"btn-master-data-input-add-to-document\"\n className=\"cursor-pointer\"\n onClick={() => handleAddGTNToDocument(value?.toString() || \"\")}\n type=\"button\"\n >\n <AntTooltip placement=\"top\" title={t(\"Add to document\")}>\n <NoteAddOutlined\n sx={{\n fontSize: 16,\n color:\n primaryColorShades?.[600] || \"var(--color-primary-600)\",\n }}\n />\n </AntTooltip>\n </button>\n ) : null}\n </div>\n </div>\n </label>\n <label className=\"relative block mt-1\">\n <Tooltip\n title={isTextOverflowing ? resolveMasterDataValue() : \"\"}\n >\n <input\n id={id}\n ref={combinedRef}\n required={required}\n placeholder={placeholder}\n className={getClassName()}\n onChange={(e) => {\n onChange(e.target.value, masterDataRowValue);\n setInputValue(e.target?.value);\n }}\n onKeyDown={handleKeyDown}\n value={resolveMasterDataValue()}\n defaultValue={defaultValue}\n disabled={true}\n autoComplete=\"off\"\n onBlur={onBlur}\n />\n </Tooltip>\n\n <IconButton\n id={`btn-dynamic-data-input-rx-cross`}\n onClick={handleClear}\n className=\"absolute inset-y-0 right-1 flex items-center px-2 focus:border-transparent\"\n variant=\"ghost\"\n disabled={disabled}\n >\n <CloseIcon className=\"w-6 h-6 text-neutral-500 dark:text-neutral-400 w-sm h-sm\" />\n </IconButton>\n\n <IconButton\n id={`btn-dynamic-data-input-ai-outline-pic-center`}\n onClick={toggleMasterDataModal}\n className=\"absolute inset-y-0 right-8 flex items-center px-2 focus:border-transparent\"\n variant=\"ghost\"\n disabled={disabled}\n >\n <TableChartRounded\n className=\"text-neutral-500 dark:text-neutral-400 w-sm h-sm\"\n />\n </IconButton>\n </label>\n\n {errorMessage && (\n <Typography\n className=\"text-error-500 mt-1\"\n appearance=\"custom\"\n size=\"extra-small\"\n variant=\"medium\"\n >\n {errorMessage}\n </Typography>\n )}\n\n {showMasterDataModal && MasterDataModal && (\n <MasterDataModal\n isVisible={showMasterDataModal}\n onSelected={handleSetMasterData}\n onClose={toggleMasterDataModal}\n masterDataColumnName={masterDataColumnName}\n masterDataFilters={masterDataFilters}\n masterDataName={masterDataName}\n masterDataId={masterDataName}\n showFilters\n />\n )}\n </div>\n\n {isHovered &&\n riskDetails &&\n isRiskAnalysisOpen &&\n RiskDetailsCard && (\n <div\n role=\"tooltip\"\n tabIndex={0}\n className=\"absolute left-0 right-0 top-[95%] mt-1 z-50 bg-white dark:bg-black-600 rounded-xl\"\n onClick={(e) => e.stopPropagation()}\n onMouseDown={(e) => e.preventDefault()}\n onKeyDown={(e) => {\n if (e.key === \"Escape\") {\n setIsHovered(false);\n }\n }}\n >\n <RiskDetailsCard riskDetails={riskDetails} />\n </div>\n )}\n </div>\n );\n }\n);\n\nMasterDataInputField.displayName = \"MasterDataInputField\";\n\n"],"names":["MasterDataInputField","forwardRef","id","label","placeholder","value","onChange","errorMessage","defaultValue","required","isRequiredConditional","masterDataName","masterDataColumnName","masterDataFormula","masterDataFilters","tags","index","tooltip","originalCase","color","isGTN","labelClassName","gtnName","isAiExtracted","confidenceScore","confidenceType","confidenceTooltip","sourceMeta","onConfidenceScoreClick","disabled","reference","isLiveField","onBlur","onAddGTNToDocument","riskDetails","isRiskAnalysisOpen","RiskDetailsCard","primaryColorShades","setDisableActions","showDeprecatedFieldWarning","MasterDataModal","parseMasterDataFormula","ref","t","useTranslation","isHovered","setIsHovered","useState","inputValue","setInputValue","showMasterDataModal","setShowMasterDataModal","suggestion","setSuggestion","masterDataRowValue","setMasterDataRowValue","isTextOverflowing","setIsTextOverflowing","inputRef","useRef","combinedRef","useEffect","checkOverflow","input","toggleMasterDataModal","handleKeyDown","event","currentRef","handleSetMasterData","masterDataValue","masterDataRow","_value","handleClear","handleAddGTNToDocument","getClassName","baseClasses","borderColor","placeholderColor","backgroundColor","resolveMasterDataValue","jsxs","cn","jsx","InputLabel","BoltOutlined","shouldShowConfidenceScore","AIExtractedIndicator","Label","Tooltip","HelpIcon","getConfidenceScoreBadgeClass","AIStarIcon","getConfidenceScoreBadgeColor","getConfidenceScoreBadgeFill","getConfidenceScoreBadgeTextColor","AntTooltip","NoteAddOutlined","e","IconButton","CloseIcon","TableChartRounded","Typography"],"mappings":";;;;;;;;;;;;;;;;AAqMO,MAAMA,KAAuBC;AAAA,EAIlC,CACE;AAAA,IACE,IAAAC;AAAA,IACA,OAAAC;AAAA,IACA,aAAAC;AAAA,IACA,OAAAC;AAAA,IACA,UAAAC;AAAA,IACA,cAAAC;AAAA,IACA,cAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,uBAAAC,IAAwB;AAAA,IACxB,gBAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,MAAAC;AAAA,IACA,OAAAC;AAAA,IACA,SAAAC,IAAU;AAAA,IACV,cAAAC,KAAe;AAAA,IACf,OAAAC,IAAQ;AAAA,IACR,OAAAC,IAAQ;AAAA,IACR,gBAAAC;AAAA,IACA,SAAAC,IAAU;AAAA,IACV,eAAAC,KAAgB;AAAA,IAChB,iBAAAC;AAAA,IACA,gBAAAC,IAAiB;AAAA,IACjB,mBAAAC;AAAA,IACA,YAAAC,KAAa,CAAA;AAAA,IACb,wBAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,WAAAC,KAAY,CAAA;AAAA,IACZ,aAAAC,KAAc;AAAA,IACd,QAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,aAAAC;AAAA,IACA,oBAAAC,IAAqB;AAAA,IACrB,iBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,4BAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,wBAAAC;AAAA,EAAA,GAEFC,OACG;AACH,UAAM,EAAE,GAAAC,GAAA,IAAMC,GAAA,GACR,CAACC,GAAWC,CAAY,IAAIC,EAAS,EAA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AA,cAAA;AAAA,gBACC,WAAWU;AAAA,gBACX,YAAYkB;AAAA,gBACZ,SAASJ;AAAA,gBACT,sBAAApD;AAAA,gBACA,mBAAAE;AAAA,gBACA,gBAAAH;AAAA,gBACA,cAAcA;AAAA,gBACd,aAAW;AAAA,cAAA;AAAA,YAAA;AAAA,UACb,GAEJ;AAAA,UAECkC,KACCX,KACAC,KACAC,KACE,gBAAA8C;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,MAAK;AAAA,cACL,UAAU;AAAA,cACV,WAAU;AAAA,cACV,SAAS,CAACe,MAAMA,EAAE,gBAAA;AAAA,cAClB,aAAa,CAACA,MAAMA,EAAE,eAAA;AAAA,cACtB,WAAW,CAACA,MAAM;AAChB,gBAAIA,EAAE,QAAQ,YACZnD,EAAa,EAAK;AAAA,cAEtB;AAAA,cAEA,UAAA,gBAAAoC,EAAC9C,KAAgB,aAAAF,EAAA,CAA0B;AAAA,YAAA;AAAA,UAAA;AAAA,QAC7C;AAAA,MAAA;AAAA,IAAA;AAAA,EAIV;AACF;AAEAlC,GAAqB,cAAc;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("../../../_virtual/index.cjs.js"),C=require("react"),T=require("antd"),G=require("react-i18next"),D=require("../../data-display/typography/Typography.cjs.js"),ee=require("../../data-display/label/Label.cjs.js"),$=require("@mui/icons-material"),te=require("../../icons/AIExtractedIndicator.cjs.js"),re=require("../../icons/AIStarIcon.cjs.js"),le=require("../../icons/HelpIcon.cjs.js"),_=require("../../tooltip/Tooltip.cjs.js"),l=require("../../../utils/confidenceScoreUtils.cjs.js"),ae=require("../shared/InputLabel.cjs.js"),z=C.forwardRef(({id:c,label:i,value:o,onChange:j,errorMessage:d,defaultValue:u,disabled:P,max:F,min:L,required:x=!1,isRequiredConditional:A=!1,bg:B,tags:E,color:H,className:M,originalCase:y=!1,tooltip:v,simpleMode:K=!1,inputFieldClassName:O="",isAiExtracted:R=!1,confidenceScore:m,confidenceType:a="high",confidenceTooltip:p,sourceMeta:U=[],onConfidenceScoreClick:J,isGTN:f=!1,gtnName:Q=null,inputStyle:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("../../../_virtual/index.cjs.js"),C=require("react"),T=require("antd"),G=require("react-i18next"),D=require("../../data-display/typography/Typography.cjs.js"),ee=require("../../data-display/label/Label.cjs.js"),$=require("@mui/icons-material"),te=require("../../icons/AIExtractedIndicator.cjs.js"),re=require("../../icons/AIStarIcon.cjs.js"),le=require("../../icons/HelpIcon.cjs.js"),_=require("../../tooltip/Tooltip.cjs.js"),l=require("../../../utils/confidenceScoreUtils.cjs.js"),ae=require("../shared/InputLabel.cjs.js"),z=C.forwardRef(({id:c,label:i,value:o,onChange:j,errorMessage:d,defaultValue:u,disabled:P,max:F,min:L,required:x=!1,isRequiredConditional:A=!1,bg:B,tags:E,color:H,className:M,originalCase:y=!1,tooltip:v,simpleMode:K=!1,inputFieldClassName:O="",isAiExtracted:R=!1,confidenceScore:m,confidenceType:a="high",confidenceTooltip:p,sourceMeta:U=[],onConfidenceScoreClick:J,isGTN:f=!1,gtnName:Q=null,inputStyle:N,withDollarSign:V=!0,labelClassName:k,isLiveField:W=!1,onBlur:I,onAddGTNToDocument:b,riskDetails:r,isRiskAnalysisOpen:g=!1,RiskDetailsCard:w,placeholder:X,...S},q)=>{const{t:Y}=G.useTranslation(),[n,h]=C.useState(!1),Z=t=>{b&&b({key:Q,value:t})};return K?e.jsxs("label",{id:c,className:`mb-1 text-xs font-medium text-gray-600 dark:text-neutral-200 inline-flex items-center gap-1 ${y?"":"capitalize"} ${k||""}`,children:[V&&e.jsx("span",{className:"absolute inset-y-0 left-1 flex items-center pl-3",children:"$"}),e.jsx("input",{...S,ref:q,onBlur:I,type:"number",required:x,className:s(O,"pl-8 h-8"),onChange:t=>{j(t.target.value)},value:o,...u&&!o?{defaultValue:u}:{},id:c||i,style:N,autoComplete:"off"})]}):e.jsxs("div",{className:s("flex gap-0.5 relative",n&&f?"border rounded-lg border-primary-100 bg-primary-50 p-1":""),onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),children:[f&&!n?e.jsx("div",{className:"w-1 h-1 bg-primary-600 rounded-full animate-blink mt-1.5"}):null,e.jsxs("div",{className:s("w-full flex flex-col",M),children:[e.jsx("label",{htmlFor:"text",className:`mb-1 text-xs font-medium text-gray-600 dark:text-neutral-300 inline-flex items-center gap-1 ${y?"":"uppercase"} ${k||""}`,children:e.jsxs("div",{className:"grid w-full grid-cols-[minmax(0,1fr)_auto] items-start gap-x-1",children:[e.jsxs("div",{className:"inline-flex min-w-0 items-center gap-1 flex-wrap dark:text-black-300",children:[e.jsx(ae.InputLabel,{label:i||"",required:x||!1,isRequiredConditional:A||!1}),W&&e.jsx($.BoltOutlined,{sx:{fontSize:16,color:"var(--color-primary-600)",rotate:"15deg"}}),R&&!l.shouldShowConfidenceScore(m)&&e.jsx(te.AIExtractedIndicator,{}),e.jsx(ee.Label,{labels:E}),v&&e.jsx(_,{placement:"top",title:v,children:e.jsx("div",{className:"cursor-pointer",children:e.jsx(le.HelpIcon,{className:"w-icon-sm h-icon-sm"})})})]}),e.jsxs("div",{className:"flex items-center gap-1 justify-self-end",children:[l.shouldShowConfidenceScore(m)&&a?e.jsx(_,{placement:"top-end",title:p??"",hideTooltip:p==null,className:"cursor-pointer",children:e.jsxs("div",{className:s("inline-flex min-w-[50px] items-center gap-1 rounded-md px-1 py-0.5",l.getConfidenceScoreBadgeClass(a)),onClick:()=>J?.(U),children:[e.jsx(re.AIStarIcon,{size:12,fill:l.getConfidenceScoreBadgeColor(a),fillSecondary:l.getConfidenceScoreBadgeFill(a)}),e.jsxs("span",{className:s("text-xs font-medium leading-4",l.getConfidenceScoreBadgeTextColor(a)),children:[m,"%"]})]})}):null,f&&n&&b?e.jsx("button",{id:"btn-percentage-input-add-to-document",className:"cursor-pointer",onClick:()=>Z(o?.toString()),type:"button",children:e.jsx(T.Tooltip,{placement:"top",title:Y("Add to document"),children:e.jsx($.NoteAddOutlined,{className:"text-primary-600",sx:{fontSize:16}})})}):null]})]})}),e.jsxs("label",{className:"relative block",children:[e.jsx("input",{...S,ref:q,onBlur:I,type:"number",required:x,disabled:P,min:L,max:F,className:`border ${d?"border-red-300":g&&r?.color?`border-${r.color}-300`:"border-gray-300"} ${B} h-8 text-gray-900 dark:bg-black-600 dark:text-neutral-200 text-sm rounded-lg focus:outline-none focus:ring-0 focus:border-[var(--color-primary-600)] dark:focus:border-[var(--color-primary-400)] focus:shadow-[0_0_0_1.5px_var(--color-primary-100)] dark:focus:shadow-[0_0_0_1.5px_var(--color-primary-950)] block w-full p-2.5 font-inter font-medium
|
|
2
2
|
disabled:bg-neutral-50 dark:disabled:!bg-black-800 dark:disabled:placeholder:!text-black-400
|
|
3
3
|
${g&&r?.color&&`bg-${r.color}-50`}
|
|
4
4
|
${H||""}
|
|
5
|
-
`,onChange:t=>{j(t.target.value)},value:o,defaultValue:u,id:c||i,style:
|
|
5
|
+
`,onChange:t=>{j(t.target.value)},value:o,defaultValue:u,id:c||i,style:N,autoComplete:"off",placeholder:X}),e.jsx("span",{className:"absolute inset-y-0 right-3 flex items-center z-[1000px] h-full dark:text-black-100",children:"%"})]}),d&&e.jsx(D.Typography,{className:"text-error-500 mt-1",appearance:"custom",size:"extra-small",variant:"medium",children:d})]}),n&&r&&g&&w&&e.jsx("div",{role:"tooltip",tabIndex:0,className:"absolute left-0 right-0 top-[95%] mt-1 z-50 bg-white dark:bg-black-600 rounded-xl",onClick:t=>t.stopPropagation(),onMouseDown:t=>t.preventDefault(),onKeyDown:t=>{t.key==="Escape"&&h(!1)},children:e.jsx(w,{riskDetails:r})})]})});z.displayName="PercentageInputField";exports.PercentageInputField=z;
|
|
6
6
|
//# sourceMappingURL=PercentageInputField.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PercentageInputField.cjs.js","sources":["../../../../src/components/forms/percentage-input/PercentageInputField.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport cn from \"classnames\";\nimport { forwardRef, useState } from \"react\";\nimport { Tooltip as AntTooltip } from \"antd\";\nimport { useTranslation } from 'react-i18next';\nimport { Typography } from \"../../data-display/typography/Typography\";\nimport { Label } from \"../../data-display/label/Label\";\nimport type { LabelType } from \"../../data-display/label/Label\";\nimport { BoltOutlined, NoteAddOutlined } from \"@mui/icons-material\";\nimport { AIExtractedIndicator } from \"../../icons/AIExtractedIndicator\";\nimport { AIStarIcon } from \"../../icons/AIStarIcon\";\nimport { HelpIcon } from \"../../icons/HelpIcon\";\nimport Tooltip from \"../../tooltip/Tooltip\";\nimport {\n getConfidenceScoreBadgeClass,\n getConfidenceScoreBadgeColor,\n getConfidenceScoreBadgeFill,\n getConfidenceScoreBadgeTextColor,\n shouldShowConfidenceScore,\n} from \"../../../utils/confidenceScoreUtils\";\nimport { InputLabel } from \"../shared/InputLabel\";\n\n/**\n * Confidence score type\n */\nexport type ConfidenceScoreType = \"low\" | \"medium\" | \"high\";\n\nexport type SourceMetaBBox = {\n b: number;\n l: number;\n r: number;\n t: number;\n};\n\nexport type SourceMetaItem = {\n bbox: SourceMetaBBox;\n confidence_score?: number;\n is_primary?: boolean;\n match_score?: number;\n match_type?: string;\n page_height: number;\n page_width: number;\n source_page: number;\n source_text?: string;\n};\n\n/**\n * Risk details interface for risk analysis integration\n */\nexport interface RiskDetails {\n color?: string;\n description?: string;\n hexBgColor?: string;\n hexBorderColor?: string;\n [key: string]: any;\n}\n\n/**\n * Risk details card component props - generic to allow consumer-specific risk types\n */\nexport interface RiskDetailsCardProps<T = any> {\n riskDetails: T;\n maxWidth?: string;\n showAllRisksSuggestions?: boolean;\n}\n\n/**\n * Props for the PercentageInputField component\n */\nexport interface PercentageInputFieldProps {\n /** Unique identifier for the input */\n id: string;\n /** Label text to display above the input */\n label?: string;\n /** Current value of the input */\n value: string;\n /** Callback function called when value changes */\n onChange: (data: any) => void;\n /** Error message to display below the input */\n errorMessage?: string;\n /** Default value for the input */\n defaultValue?: string;\n /** Whether the input is disabled */\n disabled?: boolean;\n /** Maximum value allowed */\n max?: number;\n /** Minimum value allowed */\n min?: number;\n /** Whether the field is required */\n required?: boolean;\n /** Whether the required indicator shows as conditional (yellow instead of red) */\n isRequiredConditional?: boolean;\n /** Background color class */\n bg?: string;\n /** Tags/labels to display next to the label */\n tags?: (string | LabelType)[];\n /** Text color class */\n color?: string;\n /** Additional CSS classes for the wrapper */\n className?: string;\n /** Whether to preserve original case in the label */\n originalCase?: boolean;\n /** Tooltip text for the help icon */\n tooltip?: string;\n /** Whether to use simple mode (inline label style) */\n simpleMode?: boolean;\n /** Additional CSS classes for the input field */\n inputFieldClassName?: string;\n /** Whether the value was AI extracted */\n isAiExtracted?: boolean;\n /** Confidence percentage shown as a badge */\n confidenceScore?: number;\n /** Confidence classification for badge styling */\n confidenceType?: ConfidenceScoreType;\n /** Optional tooltip content for confidence badge */\n confidenceTooltip?: React.ReactNode;\n /** Source meta for confidence score */\n sourceMeta?: SourceMetaItem[];\n /** Handler fired when confidence score badge is clicked */\n onConfidenceScoreClick?: (sourceMeta: SourceMetaItem[]) => void;\n /** Whether this is a GTN (Global Term Name) field */\n isGTN?: boolean;\n /** GTN field name for document integration */\n gtnName?: any;\n /** Inline styles for the input element */\n inputStyle?: React.CSSProperties;\n /** Whether to show dollar sign (for simpleMode) */\n withDollarSign?: boolean;\n /** Additional CSS classes for the label */\n labelClassName?: string;\n /** Whether this is a live field */\n isLiveField?: boolean;\n /** Callback function called when input loses focus */\n onBlur?: () => void;\n /** Handler for adding GTN to document */\n onAddGTNToDocument?: (keyValuePair: { key: string; value: string }) => void;\n /** Risk details data */\n riskDetails?: RiskDetails;\n /** Whether risk analysis is open */\n isRiskAnalysisOpen?: boolean;\n /** Custom risk details card component */\n RiskDetailsCard?: React.ComponentType<RiskDetailsCardProps<any>>;\n /** Input placeholder */\n placeholder?: string\n}\n\n/**\n * A highly customizable percentage input component with label, validation, and styling support.\n * Features GTN integration, risk analysis support, AI extraction indicator, and comprehensive prop support.\n *\n * @example\n * ```tsx\n * <PercentageInputField\n * id=\"discount\"\n * label=\"Discount Percentage\"\n * value={discount}\n * onChange={(value) => setDiscount(value)}\n * required\n * />\n * ```\n */\nexport const PercentageInputField = forwardRef<\n HTMLInputElement,\n PercentageInputFieldProps\n>(\n (\n {\n id,\n label,\n value,\n onChange,\n errorMessage,\n defaultValue,\n disabled,\n max,\n min,\n required = false,\n isRequiredConditional = false,\n bg,\n tags,\n color,\n className,\n originalCase = false,\n tooltip,\n simpleMode = false,\n inputFieldClassName = \"\",\n isAiExtracted = false,\n confidenceScore,\n confidenceType = \"high\",\n confidenceTooltip,\n sourceMeta = [],\n onConfidenceScoreClick,\n isGTN = false,\n gtnName = null,\n inputStyle,\n withDollarSign = true,\n labelClassName,\n isLiveField = false,\n onBlur,\n onAddGTNToDocument,\n riskDetails,\n isRiskAnalysisOpen = false,\n RiskDetailsCard,\n placeholder,\n ...props\n },\n ref\n ) => {\n const { t } = useTranslation();\n const [isHovered, setIsHovered] = useState(false);\n\n const handleAddGTNToDocument = (_value: string) => {\n if (onAddGTNToDocument) {\n const keyValuePair = {\n key: gtnName,\n value: _value,\n };\n onAddGTNToDocument(keyValuePair);\n }\n };\n\n // Simple mode rendering\n if (simpleMode) {\n return (\n <label\n id={id}\n className={`mb-1 text-xs font-medium text-gray-600 dark:text-neutral-200 inline-flex items-center gap-1 ${\n !originalCase ? \"capitalize\" : \"\"\n } ${labelClassName || \"\"}`}\n >\n {withDollarSign && (\n <span className=\"absolute inset-y-0 left-1 flex items-center pl-3\">\n {\"$\"}\n </span>\n )}\n <input\n {...props}\n ref={ref}\n onBlur={onBlur}\n type=\"number\"\n required={required}\n className={cn(inputFieldClassName, \"pl-8 h-8\")}\n onChange={(e) => {\n onChange(e.target.value);\n }}\n value={value}\n {...(defaultValue && !value ? { defaultValue: defaultValue } : {})}\n id={id || label}\n style={inputStyle}\n autoComplete=\"off\"\n />\n </label>\n );\n }\n\n // Full mode rendering\n return (\n <div\n className={cn(\n \"flex gap-0.5 relative\",\n isHovered && isGTN\n ? \"border rounded-lg border-primary-100 bg-primary-50 p-1\"\n : \"\"\n )}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n >\n {isGTN && !isHovered ? (\n <div className=\"w-1 h-1 bg-primary-600 rounded-full animate-blink mt-1.5\" />\n ) : null}\n <div className={cn(\"w-full flex flex-col\", className)}>\n <label\n htmlFor=\"text\"\n className={`mb-1 text-xs font-medium text-gray-600 dark:text-neutral-300 inline-flex items-center gap-1 ${\n !originalCase ? \"uppercase\" : \"\"\n } ${labelClassName || \"\"}`}\n >\n <div className=\"grid w-full grid-cols-[minmax(0,1fr)_auto] items-start gap-x-1\">\n <div className=\"inline-flex min-w-0 items-center gap-1 flex-wrap dark:text-black-300\">\n <InputLabel label={label || \"\"} required={required || false} isRequiredConditional={isRequiredConditional || false} />\n {isLiveField && (\n <BoltOutlined\n sx={{\n fontSize: 16,\n color: \"var(--color-primary-600)\",\n rotate: \"15deg\",\n }}\n />\n )}\n {isAiExtracted && !shouldShowConfidenceScore(confidenceScore) && <AIExtractedIndicator />}\n <Label labels={tags} />\n {tooltip && (\n <Tooltip placement=\"top\" title={tooltip}>\n <div className=\"cursor-pointer\">\n <HelpIcon />\n </div>\n </Tooltip>\n )}\n </div>\n\n <div className=\"flex items-center gap-1 justify-self-end\">\n {(shouldShowConfidenceScore(confidenceScore) && confidenceType) ? (\n <Tooltip\n placement=\"top-end\"\n title={confidenceTooltip ?? \"\"}\n hideTooltip={confidenceTooltip === undefined || confidenceTooltip === null}\n className=\"cursor-pointer\"\n >\n <div\n className={cn(\n \"inline-flex min-w-[50px] items-center gap-1 rounded-md px-1 py-0.5\",\n getConfidenceScoreBadgeClass(confidenceType)\n )}\n onClick={() => onConfidenceScoreClick?.(sourceMeta)}\n >\n <AIStarIcon\n size={12}\n fill={getConfidenceScoreBadgeColor(confidenceType)}\n fillSecondary={getConfidenceScoreBadgeFill(confidenceType)}\n />\n <span className={cn(\"text-xs font-medium leading-4\", getConfidenceScoreBadgeTextColor(confidenceType))}>\n {confidenceScore}%\n </span>\n </div>\n </Tooltip>\n ) : null}\n {isGTN && isHovered && onAddGTNToDocument ? (\n <button\n id=\"btn-percentage-input-add-to-document\"\n className=\"cursor-pointer\"\n onClick={() => handleAddGTNToDocument(value?.toString())}\n type=\"button\"\n >\n <AntTooltip placement=\"top\" title={t(\"Add to document\")}>\n <NoteAddOutlined\n className=\"text-primary-600\"\n sx={{ fontSize: 16 }}\n />\n </AntTooltip>\n </button>\n ) : null}\n </div>\n </div>\n </label>\n <label className=\"relative block\">\n <input\n {...props}\n ref={ref}\n onBlur={onBlur}\n type=\"number\"\n required={required}\n disabled={disabled}\n min={min}\n max={max}\n className={`border ${\n errorMessage\n ? \"border-red-300\"\n : isRiskAnalysisOpen && riskDetails?.color\n ? `border-${riskDetails.color}-300`\n : \"border-gray-300\"\n } ${bg} h-8 text-gray-900 dark:bg-black-600 dark:text-neutral-200 text-sm rounded-lg focus:outline-none focus:ring-0 focus:border-[var(--color-primary-600)] dark:focus:border-[var(--color-primary-400)] focus:shadow-[0_0_0_1.5px_var(--color-primary-100)] dark:focus:shadow-[0_0_0_1.5px_var(--color-primary-950)] block w-full p-2.5 font-inter font-medium \n disabled:bg-neutral-50 dark:disabled:!bg-black-800 dark:disabled:placeholder:!text-black-400\n ${\n isRiskAnalysisOpen &&\n riskDetails?.color &&\n `bg-${riskDetails.color}-50`\n }\n ${color || \"\"}\n `}\n onChange={(e) => {\n onChange(e.target.value);\n }}\n value={value}\n defaultValue={defaultValue}\n id={id || label}\n style={inputStyle}\n autoComplete=\"off\"\n placeholder={placeholder}\n />\n <span className=\"absolute inset-y-0 right-3 flex items-center z-[1000px] h-full dark:text-black-100\">\n %\n </span>\n </label>\n {errorMessage && (\n <Typography\n className=\"text-error-500 mt-1\"\n appearance=\"custom\"\n size=\"extra-small\"\n variant=\"medium\"\n >\n {errorMessage}\n </Typography>\n )}\n </div>\n\n {isHovered &&\n riskDetails &&\n isRiskAnalysisOpen &&\n RiskDetailsCard && (\n <div\n role=\"tooltip\"\n tabIndex={0}\n className=\"absolute left-0 right-0 top-[95%] mt-1 z-50 bg-white dark:bg-black-600 rounded-xl\"\n onClick={(e) => e.stopPropagation()}\n onMouseDown={(e) => e.preventDefault()}\n onKeyDown={(e) => {\n if (e.key === \"Escape\") {\n setIsHovered(false);\n }\n }}\n >\n <RiskDetailsCard riskDetails={riskDetails} />\n </div>\n )}\n </div>\n );\n }\n);\n\nPercentageInputField.displayName = \"PercentageInputField\";\n"],"names":["PercentageInputField","forwardRef","id","label","value","onChange","errorMessage","defaultValue","disabled","max","min","required","isRequiredConditional","bg","tags","color","className","originalCase","tooltip","simpleMode","inputFieldClassName","isAiExtracted","confidenceScore","confidenceType","confidenceTooltip","sourceMeta","onConfidenceScoreClick","isGTN","gtnName","inputStyle","withDollarSign","labelClassName","isLiveField","onBlur","onAddGTNToDocument","riskDetails","isRiskAnalysisOpen","RiskDetailsCard","placeholder","props","ref","t","useTranslation","isHovered","setIsHovered","useState","handleAddGTNToDocument","_value","jsxs","jsx","cn","e","InputLabel","BoltOutlined","shouldShowConfidenceScore","AIExtractedIndicator","Label","Tooltip","HelpIcon","getConfidenceScoreBadgeClass","AIStarIcon","getConfidenceScoreBadgeColor","getConfidenceScoreBadgeFill","getConfidenceScoreBadgeTextColor","AntTooltip","NoteAddOutlined","Typography"],"mappings":"2oBAiKaA,EAAuBC,EAAAA,WAIlC,CACE,CACE,GAAAC,EACA,MAAAC,EACA,MAAAC,EACA,SAAAC,EACA,aAAAC,EACA,aAAAC,EACA,SAAAC,EACA,IAAAC,EACA,IAAAC,EACA,SAAAC,EAAW,GACX,sBAAAC,EAAwB,GACxB,GAAAC,EACA,KAAAC,EACA,MAAAC,EACA,UAAAC,EACA,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AAAA,WAAA,CACC,UAAU,sBACV,WAAW,SACX,KAAK,cACL,QAAQ,SAEP,SAAA5D,CAAA,CAAA,CACH,EAEJ,EAECqC,GACCR,GACAC,GACAC,GACEY,EAAAA,IAAC,MAAA,CACC,KAAK,UACL,SAAU,EACV,UAAU,oFACV,QAAUE,GAAMA,EAAE,gBAAA,EAClB,YAAcA,GAAMA,EAAE,eAAA,EACtB,UAAYA,GAAM,CACZA,EAAE,MAAQ,UACZP,EAAa,EAAK,CAEtB,EAEA,SAAAK,EAAAA,IAACZ,GAAgB,YAAAF,CAAA,CAA0B,CAAA,CAAA,CAC7C,CAAA,CAAA,CAIV,CACF,EAEAnC,EAAqB,YAAc"}
|
|
1
|
+
{"version":3,"file":"PercentageInputField.cjs.js","sources":["../../../../src/components/forms/percentage-input/PercentageInputField.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport cn from \"classnames\";\nimport { forwardRef, useState } from \"react\";\nimport { Tooltip as AntTooltip } from \"antd\";\nimport { useTranslation } from 'react-i18next';\nimport { Typography } from \"../../data-display/typography/Typography\";\nimport { Label } from \"../../data-display/label/Label\";\nimport type { LabelType } from \"../../data-display/label/Label\";\nimport { BoltOutlined, NoteAddOutlined } from \"@mui/icons-material\";\nimport { AIExtractedIndicator } from \"../../icons/AIExtractedIndicator\";\nimport { AIStarIcon } from \"../../icons/AIStarIcon\";\nimport { HelpIcon } from \"../../icons/HelpIcon\";\nimport Tooltip from \"../../tooltip/Tooltip\";\nimport {\n getConfidenceScoreBadgeClass,\n getConfidenceScoreBadgeColor,\n getConfidenceScoreBadgeFill,\n getConfidenceScoreBadgeTextColor,\n shouldShowConfidenceScore,\n} from \"../../../utils/confidenceScoreUtils\";\nimport { InputLabel } from \"../shared/InputLabel\";\n\n/**\n * Confidence score type\n */\nexport type ConfidenceScoreType = \"low\" | \"medium\" | \"high\";\n\nexport type SourceMetaBBox = {\n b: number;\n l: number;\n r: number;\n t: number;\n};\n\nexport type SourceMetaItem = {\n bbox: SourceMetaBBox;\n confidence_score?: number;\n is_primary?: boolean;\n match_score?: number;\n match_type?: string;\n page_height: number;\n page_width: number;\n source_page: number;\n source_text?: string;\n};\n\n/**\n * Risk details interface for risk analysis integration\n */\nexport interface RiskDetails {\n color?: string;\n description?: string;\n hexBgColor?: string;\n hexBorderColor?: string;\n [key: string]: any;\n}\n\n/**\n * Risk details card component props - generic to allow consumer-specific risk types\n */\nexport interface RiskDetailsCardProps<T = any> {\n riskDetails: T;\n maxWidth?: string;\n showAllRisksSuggestions?: boolean;\n}\n\n/**\n * Props for the PercentageInputField component\n */\nexport interface PercentageInputFieldProps {\n /** Unique identifier for the input */\n id: string;\n /** Label text to display above the input */\n label?: string;\n /** Current value of the input */\n value: string;\n /** Callback function called when value changes */\n onChange: (data: any) => void;\n /** Error message to display below the input */\n errorMessage?: string;\n /** Default value for the input */\n defaultValue?: string;\n /** Whether the input is disabled */\n disabled?: boolean;\n /** Maximum value allowed */\n max?: number;\n /** Minimum value allowed */\n min?: number;\n /** Whether the field is required */\n required?: boolean;\n /** Whether the required indicator shows as conditional (yellow instead of red) */\n isRequiredConditional?: boolean;\n /** Background color class */\n bg?: string;\n /** Tags/labels to display next to the label */\n tags?: (string | LabelType)[];\n /** Text color class */\n color?: string;\n /** Additional CSS classes for the wrapper */\n className?: string;\n /** Whether to preserve original case in the label */\n originalCase?: boolean;\n /** Tooltip text for the help icon */\n tooltip?: string;\n /** Whether to use simple mode (inline label style) */\n simpleMode?: boolean;\n /** Additional CSS classes for the input field */\n inputFieldClassName?: string;\n /** Whether the value was AI extracted */\n isAiExtracted?: boolean;\n /** Confidence percentage shown as a badge */\n confidenceScore?: number;\n /** Confidence classification for badge styling */\n confidenceType?: ConfidenceScoreType;\n /** Optional tooltip content for confidence badge */\n confidenceTooltip?: React.ReactNode;\n /** Source meta for confidence score */\n sourceMeta?: SourceMetaItem[];\n /** Handler fired when confidence score badge is clicked */\n onConfidenceScoreClick?: (sourceMeta: SourceMetaItem[]) => void;\n /** Whether this is a GTN (Global Term Name) field */\n isGTN?: boolean;\n /** GTN field name for document integration */\n gtnName?: any;\n /** Inline styles for the input element */\n inputStyle?: React.CSSProperties;\n /** Whether to show dollar sign (for simpleMode) */\n withDollarSign?: boolean;\n /** Additional CSS classes for the label */\n labelClassName?: string;\n /** Whether this is a live field */\n isLiveField?: boolean;\n /** Callback function called when input loses focus */\n onBlur?: () => void;\n /** Handler for adding GTN to document */\n onAddGTNToDocument?: (keyValuePair: { key: string; value: string }) => void;\n /** Risk details data */\n riskDetails?: RiskDetails;\n /** Whether risk analysis is open */\n isRiskAnalysisOpen?: boolean;\n /** Custom risk details card component */\n RiskDetailsCard?: React.ComponentType<RiskDetailsCardProps<any>>;\n /** Input placeholder */\n placeholder?: string\n}\n\n/**\n * A highly customizable percentage input component with label, validation, and styling support.\n * Features GTN integration, risk analysis support, AI extraction indicator, and comprehensive prop support.\n *\n * @example\n * ```tsx\n * <PercentageInputField\n * id=\"discount\"\n * label=\"Discount Percentage\"\n * value={discount}\n * onChange={(value) => setDiscount(value)}\n * required\n * />\n * ```\n */\nexport const PercentageInputField = forwardRef<\n HTMLInputElement,\n PercentageInputFieldProps\n>(\n (\n {\n id,\n label,\n value,\n onChange,\n errorMessage,\n defaultValue,\n disabled,\n max,\n min,\n required = false,\n isRequiredConditional = false,\n bg,\n tags,\n color,\n className,\n originalCase = false,\n tooltip,\n simpleMode = false,\n inputFieldClassName = \"\",\n isAiExtracted = false,\n confidenceScore,\n confidenceType = \"high\",\n confidenceTooltip,\n sourceMeta = [],\n onConfidenceScoreClick,\n isGTN = false,\n gtnName = null,\n inputStyle,\n withDollarSign = true,\n labelClassName,\n isLiveField = false,\n onBlur,\n onAddGTNToDocument,\n riskDetails,\n isRiskAnalysisOpen = false,\n RiskDetailsCard,\n placeholder,\n ...props\n },\n ref\n ) => {\n const { t } = useTranslation();\n const [isHovered, setIsHovered] = useState(false);\n\n const handleAddGTNToDocument = (_value: string) => {\n if (onAddGTNToDocument) {\n const keyValuePair = {\n key: gtnName,\n value: _value,\n };\n onAddGTNToDocument(keyValuePair);\n }\n };\n\n // Simple mode rendering\n if (simpleMode) {\n return (\n <label\n id={id}\n className={`mb-1 text-xs font-medium text-gray-600 dark:text-neutral-200 inline-flex items-center gap-1 ${\n !originalCase ? \"capitalize\" : \"\"\n } ${labelClassName || \"\"}`}\n >\n {withDollarSign && (\n <span className=\"absolute inset-y-0 left-1 flex items-center pl-3\">\n {\"$\"}\n </span>\n )}\n <input\n {...props}\n ref={ref}\n onBlur={onBlur}\n type=\"number\"\n required={required}\n className={cn(inputFieldClassName, \"pl-8 h-8\")}\n onChange={(e) => {\n onChange(e.target.value);\n }}\n value={value}\n {...(defaultValue && !value ? { defaultValue: defaultValue } : {})}\n id={id || label}\n style={inputStyle}\n autoComplete=\"off\"\n />\n </label>\n );\n }\n\n // Full mode rendering\n return (\n <div\n className={cn(\n \"flex gap-0.5 relative\",\n isHovered && isGTN\n ? \"border rounded-lg border-primary-100 bg-primary-50 p-1\"\n : \"\"\n )}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n >\n {isGTN && !isHovered ? (\n <div className=\"w-1 h-1 bg-primary-600 rounded-full animate-blink mt-1.5\" />\n ) : null}\n <div className={cn(\"w-full flex flex-col\", className)}>\n <label\n htmlFor=\"text\"\n className={`mb-1 text-xs font-medium text-gray-600 dark:text-neutral-300 inline-flex items-center gap-1 ${\n !originalCase ? \"uppercase\" : \"\"\n } ${labelClassName || \"\"}`}\n >\n <div className=\"grid w-full grid-cols-[minmax(0,1fr)_auto] items-start gap-x-1\">\n <div className=\"inline-flex min-w-0 items-center gap-1 flex-wrap dark:text-black-300\">\n <InputLabel label={label || \"\"} required={required || false} isRequiredConditional={isRequiredConditional || false} />\n {isLiveField && (\n <BoltOutlined\n sx={{\n fontSize: 16,\n color: \"var(--color-primary-600)\",\n rotate: \"15deg\",\n }}\n />\n )}\n {isAiExtracted && !shouldShowConfidenceScore(confidenceScore) && <AIExtractedIndicator />}\n <Label labels={tags} />\n {tooltip && (\n <Tooltip placement=\"top\" title={tooltip}>\n <div className=\"cursor-pointer\">\n <HelpIcon className=\"w-icon-sm h-icon-sm\" />\n </div>\n </Tooltip>\n )}\n </div>\n\n <div className=\"flex items-center gap-1 justify-self-end\">\n {(shouldShowConfidenceScore(confidenceScore) && confidenceType) ? (\n <Tooltip\n placement=\"top-end\"\n title={confidenceTooltip ?? \"\"}\n hideTooltip={confidenceTooltip === undefined || confidenceTooltip === null}\n className=\"cursor-pointer\"\n >\n <div\n className={cn(\n \"inline-flex min-w-[50px] items-center gap-1 rounded-md px-1 py-0.5\",\n getConfidenceScoreBadgeClass(confidenceType)\n )}\n onClick={() => onConfidenceScoreClick?.(sourceMeta)}\n >\n <AIStarIcon\n size={12}\n fill={getConfidenceScoreBadgeColor(confidenceType)}\n fillSecondary={getConfidenceScoreBadgeFill(confidenceType)}\n />\n <span className={cn(\"text-xs font-medium leading-4\", getConfidenceScoreBadgeTextColor(confidenceType))}>\n {confidenceScore}%\n </span>\n </div>\n </Tooltip>\n ) : null}\n {isGTN && isHovered && onAddGTNToDocument ? (\n <button\n id=\"btn-percentage-input-add-to-document\"\n className=\"cursor-pointer\"\n onClick={() => handleAddGTNToDocument(value?.toString())}\n type=\"button\"\n >\n <AntTooltip placement=\"top\" title={t(\"Add to document\")}>\n <NoteAddOutlined\n className=\"text-primary-600\"\n sx={{ fontSize: 16 }}\n />\n </AntTooltip>\n </button>\n ) : null}\n </div>\n </div>\n </label>\n <label className=\"relative block\">\n <input\n {...props}\n ref={ref}\n onBlur={onBlur}\n type=\"number\"\n required={required}\n disabled={disabled}\n min={min}\n max={max}\n className={`border ${\n errorMessage\n ? \"border-red-300\"\n : isRiskAnalysisOpen && riskDetails?.color\n ? `border-${riskDetails.color}-300`\n : \"border-gray-300\"\n } ${bg} h-8 text-gray-900 dark:bg-black-600 dark:text-neutral-200 text-sm rounded-lg focus:outline-none focus:ring-0 focus:border-[var(--color-primary-600)] dark:focus:border-[var(--color-primary-400)] focus:shadow-[0_0_0_1.5px_var(--color-primary-100)] dark:focus:shadow-[0_0_0_1.5px_var(--color-primary-950)] block w-full p-2.5 font-inter font-medium \n disabled:bg-neutral-50 dark:disabled:!bg-black-800 dark:disabled:placeholder:!text-black-400\n ${\n isRiskAnalysisOpen &&\n riskDetails?.color &&\n `bg-${riskDetails.color}-50`\n }\n ${color || \"\"}\n `}\n onChange={(e) => {\n onChange(e.target.value);\n }}\n value={value}\n defaultValue={defaultValue}\n id={id || label}\n style={inputStyle}\n autoComplete=\"off\"\n placeholder={placeholder}\n />\n <span className=\"absolute inset-y-0 right-3 flex items-center z-[1000px] h-full dark:text-black-100\">\n %\n </span>\n </label>\n {errorMessage && (\n <Typography\n className=\"text-error-500 mt-1\"\n appearance=\"custom\"\n size=\"extra-small\"\n variant=\"medium\"\n >\n {errorMessage}\n </Typography>\n )}\n </div>\n\n {isHovered &&\n riskDetails &&\n isRiskAnalysisOpen &&\n RiskDetailsCard && (\n <div\n role=\"tooltip\"\n tabIndex={0}\n className=\"absolute left-0 right-0 top-[95%] mt-1 z-50 bg-white dark:bg-black-600 rounded-xl\"\n onClick={(e) => e.stopPropagation()}\n onMouseDown={(e) => e.preventDefault()}\n onKeyDown={(e) => {\n if (e.key === \"Escape\") {\n setIsHovered(false);\n }\n }}\n >\n <RiskDetailsCard riskDetails={riskDetails} />\n </div>\n )}\n </div>\n );\n }\n);\n\nPercentageInputField.displayName = \"PercentageInputField\";\n"],"names":["PercentageInputField","forwardRef","id","label","value","onChange","errorMessage","defaultValue","disabled","max","min","required","isRequiredConditional","bg","tags","color","className","originalCase","tooltip","simpleMode","inputFieldClassName","isAiExtracted","confidenceScore","confidenceType","confidenceTooltip","sourceMeta","onConfidenceScoreClick","isGTN","gtnName","inputStyle","withDollarSign","labelClassName","isLiveField","onBlur","onAddGTNToDocument","riskDetails","isRiskAnalysisOpen","RiskDetailsCard","placeholder","props","ref","t","useTranslation","isHovered","setIsHovered","useState","handleAddGTNToDocument","_value","jsxs","jsx","cn","e","InputLabel","BoltOutlined","shouldShowConfidenceScore","AIExtractedIndicator","Label","Tooltip","HelpIcon","getConfidenceScoreBadgeClass","AIStarIcon","getConfidenceScoreBadgeColor","getConfidenceScoreBadgeFill","getConfidenceScoreBadgeTextColor","AntTooltip","NoteAddOutlined","Typography"],"mappings":"2oBAiKaA,EAAuBC,EAAAA,WAIlC,CACE,CACE,GAAAC,EACA,MAAAC,EACA,MAAAC,EACA,SAAAC,EACA,aAAAC,EACA,aAAAC,EACA,SAAAC,EACA,IAAAC,EACA,IAAAC,EACA,SAAAC,EAAW,GACX,sBAAAC,EAAwB,GACxB,GAAAC,EACA,KAAAC,EACA,MAAAC,EACA,UAAAC,EACA,aAAAC,EAAe,GACf,QAAAC,EACA,WAAAC,EAAa,GACb,oBAAAC,EAAsB,GACtB,cAAAC,EAAgB,GAChB,gBAAAC,EACA,eAAAC,EAAiB,OACjB,kBAAAC,EACA,WAAAC,EAAa,CAAA,EACb,uBAAAC,EACA,MAAAC,EAAQ,GACR,QAAAC,EAAU,KACV,WAAAC,EACA,eAAAC,EAAiB,GACjB,eAAAC,EACA,YAAAC,EAAc,GACd,OAAAC,EACA,mBAAAC,EACA,YAAAC,EACA,mBAAAC,EAAqB,GACrB,gBAAAC,EACA,YAAAC,EACA,GAAGC,CAAA,EAELC,IACG,CACH,KAAM,CAAE,EAAAC,CAAA,EAAMC,iBAAA,EACR,CAACC,EAAWC,CAAY,EAAIC,EAAAA,SAAS,EAAK,EAE1CC,EAA0BC,GAAmB,CAC7Cb,GAKFA,EAJqB,CACnB,IAAKN,EACL,MAAOmB,CAAA,CAEsB,CAEnC,EAGA,OAAI5B,EAEA6B,EAAAA,KAAC,QAAA,CACC,GAAA9C,EACA,UAAW,+FACRe,EAA8B,GAAf,YAClB,IAAIc,GAAkB,EAAE,GAEvB,SAAA,CAAAD,GACCmB,EAAAA,IAAC,OAAA,CAAK,UAAU,mDACb,SAAA,IACH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A,IAAAE,EACA,IAAAD,EACA,UAAW,UACTH,EACI,iBACA8B,GAAsBD,GAAa,MACnC,UAAUA,EAAY,KAAK,OAC3B,iBACN,IAAItB,CAAE;AAAA;AAAA,gBAGJuB,GACAD,GAAa,OACb,MAAMA,EAAY,KAAK,KACzB;AAAA,gBACEpB,GAAS,EAAE;AAAA,gBAEb,SAAWoC,GAAM,CACf9C,EAAS8C,EAAE,OAAO,KAAK,CACzB,EACA,MAAA/C,EACA,aAAAG,EACA,GAAIL,GAAMC,EACV,MAAO0B,EACP,aAAa,MACb,YAAAS,CAAA,CAAA,EAEFW,EAAAA,IAAC,OAAA,CAAK,UAAU,qFAAqF,SAAA,GAAA,CAErG,CAAA,EACF,EACC3C,GACC2C,EAAAA,IAACiB,EAAAA,WAAA,CACC,UAAU,sBACV,WAAW,SACX,KAAK,cACL,QAAQ,SAEP,SAAA5D,CAAA,CAAA,CACH,EAEJ,EAECqC,GACCR,GACAC,GACAC,GACEY,EAAAA,IAAC,MAAA,CACC,KAAK,UACL,SAAU,EACV,UAAU,oFACV,QAAUE,GAAMA,EAAE,gBAAA,EAClB,YAAcA,GAAMA,EAAE,eAAA,EACtB,UAAYA,GAAM,CACZA,EAAE,MAAQ,UACZP,EAAa,EAAK,CAEtB,EAEA,SAAAK,EAAAA,IAACZ,GAAgB,YAAAF,CAAA,CAA0B,CAAA,CAAA,CAC7C,CAAA,CAAA,CAIV,CACF,EAEAnC,EAAqB,YAAc"}
|
|
@@ -10,15 +10,15 @@ import { AIExtractedIndicator as le } from "../../icons/AIExtractedIndicator.es.
|
|
|
10
10
|
import { AIStarIcon as ae } from "../../icons/AIStarIcon.es.js";
|
|
11
11
|
import { HelpIcon as oe } from "../../icons/HelpIcon.es.js";
|
|
12
12
|
import _ from "../../tooltip/Tooltip.es.js";
|
|
13
|
-
import { shouldShowConfidenceScore as z, getConfidenceScoreBadgeFill as ne, getConfidenceScoreBadgeColor as ie, getConfidenceScoreBadgeTextColor as
|
|
14
|
-
import { InputLabel as
|
|
13
|
+
import { shouldShowConfidenceScore as z, getConfidenceScoreBadgeFill as ne, getConfidenceScoreBadgeColor as ie, getConfidenceScoreBadgeTextColor as me, getConfidenceScoreBadgeClass as se } from "../../../utils/confidenceScoreUtils.es.js";
|
|
14
|
+
import { InputLabel as de } from "../shared/InputLabel.es.js";
|
|
15
15
|
const ce = Z(
|
|
16
16
|
({
|
|
17
|
-
id:
|
|
18
|
-
label:
|
|
17
|
+
id: m,
|
|
18
|
+
label: s,
|
|
19
19
|
value: n,
|
|
20
20
|
onChange: y,
|
|
21
|
-
errorMessage:
|
|
21
|
+
errorMessage: d,
|
|
22
22
|
defaultValue: c,
|
|
23
23
|
disabled: P,
|
|
24
24
|
max: B,
|
|
@@ -30,7 +30,7 @@ const ce = Z(
|
|
|
30
30
|
color: L,
|
|
31
31
|
className: A,
|
|
32
32
|
originalCase: v = !1,
|
|
33
|
-
tooltip:
|
|
33
|
+
tooltip: N,
|
|
34
34
|
simpleMode: K = !1,
|
|
35
35
|
inputFieldClassName: M = "",
|
|
36
36
|
isAiExtracted: q = !1,
|
|
@@ -41,7 +41,7 @@ const ce = Z(
|
|
|
41
41
|
onConfidenceScoreClick: O,
|
|
42
42
|
isGTN: x = !1,
|
|
43
43
|
gtnName: Q = null,
|
|
44
|
-
inputStyle:
|
|
44
|
+
inputStyle: k,
|
|
45
45
|
withDollarSign: U = !0,
|
|
46
46
|
labelClassName: w,
|
|
47
47
|
isLiveField: V = !1,
|
|
@@ -62,7 +62,7 @@ const ce = Z(
|
|
|
62
62
|
return K ? /* @__PURE__ */ t(
|
|
63
63
|
"label",
|
|
64
64
|
{
|
|
65
|
-
id:
|
|
65
|
+
id: m,
|
|
66
66
|
className: `mb-1 text-xs font-medium text-gray-600 dark:text-neutral-200 inline-flex items-center gap-1 ${v ? "" : "capitalize"} ${w || ""}`,
|
|
67
67
|
children: [
|
|
68
68
|
U && /* @__PURE__ */ e("span", { className: "absolute inset-y-0 left-1 flex items-center pl-3", children: "$" }),
|
|
@@ -80,8 +80,8 @@ const ce = Z(
|
|
|
80
80
|
},
|
|
81
81
|
value: n,
|
|
82
82
|
...c && !n ? { defaultValue: c } : {},
|
|
83
|
-
id:
|
|
84
|
-
style:
|
|
83
|
+
id: m || s,
|
|
84
|
+
style: k,
|
|
85
85
|
autoComplete: "off"
|
|
86
86
|
}
|
|
87
87
|
)
|
|
@@ -106,7 +106,7 @@ const ce = Z(
|
|
|
106
106
|
className: `mb-1 text-xs font-medium text-gray-600 dark:text-neutral-300 inline-flex items-center gap-1 ${v ? "" : "uppercase"} ${w || ""}`,
|
|
107
107
|
children: /* @__PURE__ */ t("div", { className: "grid w-full grid-cols-[minmax(0,1fr)_auto] items-start gap-x-1", children: [
|
|
108
108
|
/* @__PURE__ */ t("div", { className: "inline-flex min-w-0 items-center gap-1 flex-wrap dark:text-black-300", children: [
|
|
109
|
-
/* @__PURE__ */ e(
|
|
109
|
+
/* @__PURE__ */ e(de, { label: s || "", required: p || !1, isRequiredConditional: j || !1 }),
|
|
110
110
|
V && /* @__PURE__ */ e(
|
|
111
111
|
re,
|
|
112
112
|
{
|
|
@@ -119,7 +119,7 @@ const ce = Z(
|
|
|
119
119
|
),
|
|
120
120
|
q && !z(f) && /* @__PURE__ */ e(le, {}),
|
|
121
121
|
/* @__PURE__ */ e(ee, { labels: H }),
|
|
122
|
-
|
|
122
|
+
N && /* @__PURE__ */ e(_, { placement: "top", title: N, children: /* @__PURE__ */ e("div", { className: "cursor-pointer", children: /* @__PURE__ */ e(oe, { className: "w-icon-sm h-icon-sm" }) }) })
|
|
123
123
|
] }),
|
|
124
124
|
/* @__PURE__ */ t("div", { className: "flex items-center gap-1 justify-self-end", children: [
|
|
125
125
|
z(f) && a ? /* @__PURE__ */ e(
|
|
@@ -134,7 +134,7 @@ const ce = Z(
|
|
|
134
134
|
{
|
|
135
135
|
className: o(
|
|
136
136
|
"inline-flex min-w-[50px] items-center gap-1 rounded-md px-1 py-0.5",
|
|
137
|
-
|
|
137
|
+
se(a)
|
|
138
138
|
),
|
|
139
139
|
onClick: () => O?.(J),
|
|
140
140
|
children: [
|
|
@@ -146,7 +146,7 @@ const ce = Z(
|
|
|
146
146
|
fillSecondary: ne(a)
|
|
147
147
|
}
|
|
148
148
|
),
|
|
149
|
-
/* @__PURE__ */ t("span", { className: o("text-xs font-medium leading-4",
|
|
149
|
+
/* @__PURE__ */ t("span", { className: o("text-xs font-medium leading-4", me(a)), children: [
|
|
150
150
|
f,
|
|
151
151
|
"%"
|
|
152
152
|
] })
|
|
@@ -187,7 +187,7 @@ const ce = Z(
|
|
|
187
187
|
disabled: P,
|
|
188
188
|
min: F,
|
|
189
189
|
max: B,
|
|
190
|
-
className: `border ${
|
|
190
|
+
className: `border ${d ? "border-red-300" : g && l?.color ? `border-${l.color}-300` : "border-gray-300"} ${E} h-8 text-gray-900 dark:bg-black-600 dark:text-neutral-200 text-sm rounded-lg focus:outline-none focus:ring-0 focus:border-[var(--color-primary-600)] dark:focus:border-[var(--color-primary-400)] focus:shadow-[0_0_0_1.5px_var(--color-primary-100)] dark:focus:shadow-[0_0_0_1.5px_var(--color-primary-950)] block w-full p-2.5 font-inter font-medium
|
|
191
191
|
disabled:bg-neutral-50 dark:disabled:!bg-black-800 dark:disabled:placeholder:!text-black-400
|
|
192
192
|
${g && l?.color && `bg-${l.color}-50`}
|
|
193
193
|
${L || ""}
|
|
@@ -197,22 +197,22 @@ const ce = Z(
|
|
|
197
197
|
},
|
|
198
198
|
value: n,
|
|
199
199
|
defaultValue: c,
|
|
200
|
-
id:
|
|
201
|
-
style:
|
|
200
|
+
id: m || s,
|
|
201
|
+
style: k,
|
|
202
202
|
autoComplete: "off",
|
|
203
203
|
placeholder: W
|
|
204
204
|
}
|
|
205
205
|
),
|
|
206
206
|
/* @__PURE__ */ e("span", { className: "absolute inset-y-0 right-3 flex items-center z-[1000px] h-full dark:text-black-100", children: "%" })
|
|
207
207
|
] }),
|
|
208
|
-
|
|
208
|
+
d && /* @__PURE__ */ e(
|
|
209
209
|
D,
|
|
210
210
|
{
|
|
211
211
|
className: "text-error-500 mt-1",
|
|
212
212
|
appearance: "custom",
|
|
213
213
|
size: "extra-small",
|
|
214
214
|
variant: "medium",
|
|
215
|
-
children:
|
|
215
|
+
children: d
|
|
216
216
|
}
|
|
217
217
|
)
|
|
218
218
|
] }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PercentageInputField.es.js","sources":["../../../../src/components/forms/percentage-input/PercentageInputField.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport cn from \"classnames\";\nimport { forwardRef, useState } from \"react\";\nimport { Tooltip as AntTooltip } from \"antd\";\nimport { useTranslation } from 'react-i18next';\nimport { Typography } from \"../../data-display/typography/Typography\";\nimport { Label } from \"../../data-display/label/Label\";\nimport type { LabelType } from \"../../data-display/label/Label\";\nimport { BoltOutlined, NoteAddOutlined } from \"@mui/icons-material\";\nimport { AIExtractedIndicator } from \"../../icons/AIExtractedIndicator\";\nimport { AIStarIcon } from \"../../icons/AIStarIcon\";\nimport { HelpIcon } from \"../../icons/HelpIcon\";\nimport Tooltip from \"../../tooltip/Tooltip\";\nimport {\n getConfidenceScoreBadgeClass,\n getConfidenceScoreBadgeColor,\n getConfidenceScoreBadgeFill,\n getConfidenceScoreBadgeTextColor,\n shouldShowConfidenceScore,\n} from \"../../../utils/confidenceScoreUtils\";\nimport { InputLabel } from \"../shared/InputLabel\";\n\n/**\n * Confidence score type\n */\nexport type ConfidenceScoreType = \"low\" | \"medium\" | \"high\";\n\nexport type SourceMetaBBox = {\n b: number;\n l: number;\n r: number;\n t: number;\n};\n\nexport type SourceMetaItem = {\n bbox: SourceMetaBBox;\n confidence_score?: number;\n is_primary?: boolean;\n match_score?: number;\n match_type?: string;\n page_height: number;\n page_width: number;\n source_page: number;\n source_text?: string;\n};\n\n/**\n * Risk details interface for risk analysis integration\n */\nexport interface RiskDetails {\n color?: string;\n description?: string;\n hexBgColor?: string;\n hexBorderColor?: string;\n [key: string]: any;\n}\n\n/**\n * Risk details card component props - generic to allow consumer-specific risk types\n */\nexport interface RiskDetailsCardProps<T = any> {\n riskDetails: T;\n maxWidth?: string;\n showAllRisksSuggestions?: boolean;\n}\n\n/**\n * Props for the PercentageInputField component\n */\nexport interface PercentageInputFieldProps {\n /** Unique identifier for the input */\n id: string;\n /** Label text to display above the input */\n label?: string;\n /** Current value of the input */\n value: string;\n /** Callback function called when value changes */\n onChange: (data: any) => void;\n /** Error message to display below the input */\n errorMessage?: string;\n /** Default value for the input */\n defaultValue?: string;\n /** Whether the input is disabled */\n disabled?: boolean;\n /** Maximum value allowed */\n max?: number;\n /** Minimum value allowed */\n min?: number;\n /** Whether the field is required */\n required?: boolean;\n /** Whether the required indicator shows as conditional (yellow instead of red) */\n isRequiredConditional?: boolean;\n /** Background color class */\n bg?: string;\n /** Tags/labels to display next to the label */\n tags?: (string | LabelType)[];\n /** Text color class */\n color?: string;\n /** Additional CSS classes for the wrapper */\n className?: string;\n /** Whether to preserve original case in the label */\n originalCase?: boolean;\n /** Tooltip text for the help icon */\n tooltip?: string;\n /** Whether to use simple mode (inline label style) */\n simpleMode?: boolean;\n /** Additional CSS classes for the input field */\n inputFieldClassName?: string;\n /** Whether the value was AI extracted */\n isAiExtracted?: boolean;\n /** Confidence percentage shown as a badge */\n confidenceScore?: number;\n /** Confidence classification for badge styling */\n confidenceType?: ConfidenceScoreType;\n /** Optional tooltip content for confidence badge */\n confidenceTooltip?: React.ReactNode;\n /** Source meta for confidence score */\n sourceMeta?: SourceMetaItem[];\n /** Handler fired when confidence score badge is clicked */\n onConfidenceScoreClick?: (sourceMeta: SourceMetaItem[]) => void;\n /** Whether this is a GTN (Global Term Name) field */\n isGTN?: boolean;\n /** GTN field name for document integration */\n gtnName?: any;\n /** Inline styles for the input element */\n inputStyle?: React.CSSProperties;\n /** Whether to show dollar sign (for simpleMode) */\n withDollarSign?: boolean;\n /** Additional CSS classes for the label */\n labelClassName?: string;\n /** Whether this is a live field */\n isLiveField?: boolean;\n /** Callback function called when input loses focus */\n onBlur?: () => void;\n /** Handler for adding GTN to document */\n onAddGTNToDocument?: (keyValuePair: { key: string; value: string }) => void;\n /** Risk details data */\n riskDetails?: RiskDetails;\n /** Whether risk analysis is open */\n isRiskAnalysisOpen?: boolean;\n /** Custom risk details card component */\n RiskDetailsCard?: React.ComponentType<RiskDetailsCardProps<any>>;\n /** Input placeholder */\n placeholder?: string\n}\n\n/**\n * A highly customizable percentage input component with label, validation, and styling support.\n * Features GTN integration, risk analysis support, AI extraction indicator, and comprehensive prop support.\n *\n * @example\n * ```tsx\n * <PercentageInputField\n * id=\"discount\"\n * label=\"Discount Percentage\"\n * value={discount}\n * onChange={(value) => setDiscount(value)}\n * required\n * />\n * ```\n */\nexport const PercentageInputField = forwardRef<\n HTMLInputElement,\n PercentageInputFieldProps\n>(\n (\n {\n id,\n label,\n value,\n onChange,\n errorMessage,\n defaultValue,\n disabled,\n max,\n min,\n required = false,\n isRequiredConditional = false,\n bg,\n tags,\n color,\n className,\n originalCase = false,\n tooltip,\n simpleMode = false,\n inputFieldClassName = \"\",\n isAiExtracted = false,\n confidenceScore,\n confidenceType = \"high\",\n confidenceTooltip,\n sourceMeta = [],\n onConfidenceScoreClick,\n isGTN = false,\n gtnName = null,\n inputStyle,\n withDollarSign = true,\n labelClassName,\n isLiveField = false,\n onBlur,\n onAddGTNToDocument,\n riskDetails,\n isRiskAnalysisOpen = false,\n RiskDetailsCard,\n placeholder,\n ...props\n },\n ref\n ) => {\n const { t } = useTranslation();\n const [isHovered, setIsHovered] = useState(false);\n\n const handleAddGTNToDocument = (_value: string) => {\n if (onAddGTNToDocument) {\n const keyValuePair = {\n key: gtnName,\n value: _value,\n };\n onAddGTNToDocument(keyValuePair);\n }\n };\n\n // Simple mode rendering\n if (simpleMode) {\n return (\n <label\n id={id}\n className={`mb-1 text-xs font-medium text-gray-600 dark:text-neutral-200 inline-flex items-center gap-1 ${\n !originalCase ? \"capitalize\" : \"\"\n } ${labelClassName || \"\"}`}\n >\n {withDollarSign && (\n <span className=\"absolute inset-y-0 left-1 flex items-center pl-3\">\n {\"$\"}\n </span>\n )}\n <input\n {...props}\n ref={ref}\n onBlur={onBlur}\n type=\"number\"\n required={required}\n className={cn(inputFieldClassName, \"pl-8 h-8\")}\n onChange={(e) => {\n onChange(e.target.value);\n }}\n value={value}\n {...(defaultValue && !value ? { defaultValue: defaultValue } : {})}\n id={id || label}\n style={inputStyle}\n autoComplete=\"off\"\n />\n </label>\n );\n }\n\n // Full mode rendering\n return (\n <div\n className={cn(\n \"flex gap-0.5 relative\",\n isHovered && isGTN\n ? \"border rounded-lg border-primary-100 bg-primary-50 p-1\"\n : \"\"\n )}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n >\n {isGTN && !isHovered ? (\n <div className=\"w-1 h-1 bg-primary-600 rounded-full animate-blink mt-1.5\" />\n ) : null}\n <div className={cn(\"w-full flex flex-col\", className)}>\n <label\n htmlFor=\"text\"\n className={`mb-1 text-xs font-medium text-gray-600 dark:text-neutral-300 inline-flex items-center gap-1 ${\n !originalCase ? \"uppercase\" : \"\"\n } ${labelClassName || \"\"}`}\n >\n <div className=\"grid w-full grid-cols-[minmax(0,1fr)_auto] items-start gap-x-1\">\n <div className=\"inline-flex min-w-0 items-center gap-1 flex-wrap dark:text-black-300\">\n <InputLabel label={label || \"\"} required={required || false} isRequiredConditional={isRequiredConditional || false} />\n {isLiveField && (\n <BoltOutlined\n sx={{\n fontSize: 16,\n color: \"var(--color-primary-600)\",\n rotate: \"15deg\",\n }}\n />\n )}\n {isAiExtracted && !shouldShowConfidenceScore(confidenceScore) && <AIExtractedIndicator />}\n <Label labels={tags} />\n {tooltip && (\n <Tooltip placement=\"top\" title={tooltip}>\n <div className=\"cursor-pointer\">\n <HelpIcon />\n </div>\n </Tooltip>\n )}\n </div>\n\n <div className=\"flex items-center gap-1 justify-self-end\">\n {(shouldShowConfidenceScore(confidenceScore) && confidenceType) ? (\n <Tooltip\n placement=\"top-end\"\n title={confidenceTooltip ?? \"\"}\n hideTooltip={confidenceTooltip === undefined || confidenceTooltip === null}\n className=\"cursor-pointer\"\n >\n <div\n className={cn(\n \"inline-flex min-w-[50px] items-center gap-1 rounded-md px-1 py-0.5\",\n getConfidenceScoreBadgeClass(confidenceType)\n )}\n onClick={() => onConfidenceScoreClick?.(sourceMeta)}\n >\n <AIStarIcon\n size={12}\n fill={getConfidenceScoreBadgeColor(confidenceType)}\n fillSecondary={getConfidenceScoreBadgeFill(confidenceType)}\n />\n <span className={cn(\"text-xs font-medium leading-4\", getConfidenceScoreBadgeTextColor(confidenceType))}>\n {confidenceScore}%\n </span>\n </div>\n </Tooltip>\n ) : null}\n {isGTN && isHovered && onAddGTNToDocument ? (\n <button\n id=\"btn-percentage-input-add-to-document\"\n className=\"cursor-pointer\"\n onClick={() => handleAddGTNToDocument(value?.toString())}\n type=\"button\"\n >\n <AntTooltip placement=\"top\" title={t(\"Add to document\")}>\n <NoteAddOutlined\n className=\"text-primary-600\"\n sx={{ fontSize: 16 }}\n />\n </AntTooltip>\n </button>\n ) : null}\n </div>\n </div>\n </label>\n <label className=\"relative block\">\n <input\n {...props}\n ref={ref}\n onBlur={onBlur}\n type=\"number\"\n required={required}\n disabled={disabled}\n min={min}\n max={max}\n className={`border ${\n errorMessage\n ? \"border-red-300\"\n : isRiskAnalysisOpen && riskDetails?.color\n ? `border-${riskDetails.color}-300`\n : \"border-gray-300\"\n } ${bg} h-8 text-gray-900 dark:bg-black-600 dark:text-neutral-200 text-sm rounded-lg focus:outline-none focus:ring-0 focus:border-[var(--color-primary-600)] dark:focus:border-[var(--color-primary-400)] focus:shadow-[0_0_0_1.5px_var(--color-primary-100)] dark:focus:shadow-[0_0_0_1.5px_var(--color-primary-950)] block w-full p-2.5 font-inter font-medium \n disabled:bg-neutral-50 dark:disabled:!bg-black-800 dark:disabled:placeholder:!text-black-400\n ${\n isRiskAnalysisOpen &&\n riskDetails?.color &&\n `bg-${riskDetails.color}-50`\n }\n ${color || \"\"}\n `}\n onChange={(e) => {\n onChange(e.target.value);\n }}\n value={value}\n defaultValue={defaultValue}\n id={id || label}\n style={inputStyle}\n autoComplete=\"off\"\n placeholder={placeholder}\n />\n <span className=\"absolute inset-y-0 right-3 flex items-center z-[1000px] h-full dark:text-black-100\">\n %\n </span>\n </label>\n {errorMessage && (\n <Typography\n className=\"text-error-500 mt-1\"\n appearance=\"custom\"\n size=\"extra-small\"\n variant=\"medium\"\n >\n {errorMessage}\n </Typography>\n )}\n </div>\n\n {isHovered &&\n riskDetails &&\n isRiskAnalysisOpen &&\n RiskDetailsCard && (\n <div\n role=\"tooltip\"\n tabIndex={0}\n className=\"absolute left-0 right-0 top-[95%] mt-1 z-50 bg-white dark:bg-black-600 rounded-xl\"\n onClick={(e) => e.stopPropagation()}\n onMouseDown={(e) => e.preventDefault()}\n onKeyDown={(e) => {\n if (e.key === \"Escape\") {\n setIsHovered(false);\n }\n }}\n >\n <RiskDetailsCard riskDetails={riskDetails} />\n </div>\n )}\n </div>\n );\n }\n);\n\nPercentageInputField.displayName = \"PercentageInputField\";\n"],"names":["PercentageInputField","forwardRef","id","label","value","onChange","errorMessage","defaultValue","disabled","max","min","required","isRequiredConditional","bg","tags","color","className","originalCase","tooltip","simpleMode","inputFieldClassName","isAiExtracted","confidenceScore","confidenceType","confidenceTooltip","sourceMeta","onConfidenceScoreClick","isGTN","gtnName","inputStyle","withDollarSign","labelClassName","isLiveField","onBlur","onAddGTNToDocument","riskDetails","isRiskAnalysisOpen","RiskDetailsCard","placeholder","props","ref","t","useTranslation","isHovered","setIsHovered","useState","handleAddGTNToDocument","_value","jsxs","jsx","cn","e","InputLabel","BoltOutlined","shouldShowConfidenceScore","AIExtractedIndicator","Label","Tooltip","HelpIcon","getConfidenceScoreBadgeClass","AIStarIcon","getConfidenceScoreBadgeColor","getConfidenceScoreBadgeFill","getConfidenceScoreBadgeTextColor","AntTooltip","NoteAddOutlined","Typography"],"m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V,OAAO0B;AAAA,kBACP,cAAa;AAAA,kBACb,aAAAS;AAAA,gBAAA;AAAA,cAAA;AAAA,cAEF,gBAAAW,EAAC,QAAA,EAAK,WAAU,sFAAqF,UAAA,IAAA,CAErG;AAAA,YAAA,GACF;AAAA,YACC3C,KACC,gBAAA2C;AAAA,cAACiB;AAAA,cAAA;AAAA,gBACC,WAAU;AAAA,gBACV,YAAW;AAAA,gBACX,MAAK;AAAA,gBACL,SAAQ;AAAA,gBAEP,UAAA5D;AAAA,cAAA;AAAA,YAAA;AAAA,UACH,GAEJ;AAAA,UAECqC,KACCR,KACAC,KACAC,KACE,gBAAAY;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,MAAK;AAAA,cACL,UAAU;AAAA,cACV,WAAU;AAAA,cACV,SAAS,CAACE,MAAMA,EAAE,gBAAA;AAAA,cAClB,aAAa,CAACA,MAAMA,EAAE,eAAA;AAAA,cACtB,WAAW,CAACA,MAAM;AAChB,gBAAIA,EAAE,QAAQ,YACZP,EAAa,EAAK;AAAA,cAEtB;AAAA,cAEA,UAAA,gBAAAK,EAACZ,KAAgB,aAAAF,EAAA,CAA0B;AAAA,YAAA;AAAA,UAAA;AAAA,QAC7C;AAAA,MAAA;AAAA,IAAA;AAAA,EAIV;AACF;AAEAnC,GAAqB,cAAc;"}
|
|
1
|
+
{"version":3,"file":"PercentageInputField.es.js","sources":["../../../../src/components/forms/percentage-input/PercentageInputField.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport cn from \"classnames\";\nimport { forwardRef, useState } from \"react\";\nimport { Tooltip as AntTooltip } from \"antd\";\nimport { useTranslation } from 'react-i18next';\nimport { Typography } from \"../../data-display/typography/Typography\";\nimport { Label } from \"../../data-display/label/Label\";\nimport type { LabelType } from \"../../data-display/label/Label\";\nimport { BoltOutlined, NoteAddOutlined } from \"@mui/icons-material\";\nimport { AIExtractedIndicator } from \"../../icons/AIExtractedIndicator\";\nimport { AIStarIcon } from \"../../icons/AIStarIcon\";\nimport { HelpIcon } from \"../../icons/HelpIcon\";\nimport Tooltip from \"../../tooltip/Tooltip\";\nimport {\n getConfidenceScoreBadgeClass,\n getConfidenceScoreBadgeColor,\n getConfidenceScoreBadgeFill,\n getConfidenceScoreBadgeTextColor,\n shouldShowConfidenceScore,\n} from \"../../../utils/confidenceScoreUtils\";\nimport { InputLabel } from \"../shared/InputLabel\";\n\n/**\n * Confidence score type\n */\nexport type ConfidenceScoreType = \"low\" | \"medium\" | \"high\";\n\nexport type SourceMetaBBox = {\n b: number;\n l: number;\n r: number;\n t: number;\n};\n\nexport type SourceMetaItem = {\n bbox: SourceMetaBBox;\n confidence_score?: number;\n is_primary?: boolean;\n match_score?: number;\n match_type?: string;\n page_height: number;\n page_width: number;\n source_page: number;\n source_text?: string;\n};\n\n/**\n * Risk details interface for risk analysis integration\n */\nexport interface RiskDetails {\n color?: string;\n description?: string;\n hexBgColor?: string;\n hexBorderColor?: string;\n [key: string]: any;\n}\n\n/**\n * Risk details card component props - generic to allow consumer-specific risk types\n */\nexport interface RiskDetailsCardProps<T = any> {\n riskDetails: T;\n maxWidth?: string;\n showAllRisksSuggestions?: boolean;\n}\n\n/**\n * Props for the PercentageInputField component\n */\nexport interface PercentageInputFieldProps {\n /** Unique identifier for the input */\n id: string;\n /** Label text to display above the input */\n label?: string;\n /** Current value of the input */\n value: string;\n /** Callback function called when value changes */\n onChange: (data: any) => void;\n /** Error message to display below the input */\n errorMessage?: string;\n /** Default value for the input */\n defaultValue?: string;\n /** Whether the input is disabled */\n disabled?: boolean;\n /** Maximum value allowed */\n max?: number;\n /** Minimum value allowed */\n min?: number;\n /** Whether the field is required */\n required?: boolean;\n /** Whether the required indicator shows as conditional (yellow instead of red) */\n isRequiredConditional?: boolean;\n /** Background color class */\n bg?: string;\n /** Tags/labels to display next to the label */\n tags?: (string | LabelType)[];\n /** Text color class */\n color?: string;\n /** Additional CSS classes for the wrapper */\n className?: string;\n /** Whether to preserve original case in the label */\n originalCase?: boolean;\n /** Tooltip text for the help icon */\n tooltip?: string;\n /** Whether to use simple mode (inline label style) */\n simpleMode?: boolean;\n /** Additional CSS classes for the input field */\n inputFieldClassName?: string;\n /** Whether the value was AI extracted */\n isAiExtracted?: boolean;\n /** Confidence percentage shown as a badge */\n confidenceScore?: number;\n /** Confidence classification for badge styling */\n confidenceType?: ConfidenceScoreType;\n /** Optional tooltip content for confidence badge */\n confidenceTooltip?: React.ReactNode;\n /** Source meta for confidence score */\n sourceMeta?: SourceMetaItem[];\n /** Handler fired when confidence score badge is clicked */\n onConfidenceScoreClick?: (sourceMeta: SourceMetaItem[]) => void;\n /** Whether this is a GTN (Global Term Name) field */\n isGTN?: boolean;\n /** GTN field name for document integration */\n gtnName?: any;\n /** Inline styles for the input element */\n inputStyle?: React.CSSProperties;\n /** Whether to show dollar sign (for simpleMode) */\n withDollarSign?: boolean;\n /** Additional CSS classes for the label */\n labelClassName?: string;\n /** Whether this is a live field */\n isLiveField?: boolean;\n /** Callback function called when input loses focus */\n onBlur?: () => void;\n /** Handler for adding GTN to document */\n onAddGTNToDocument?: (keyValuePair: { key: string; value: string }) => void;\n /** Risk details data */\n riskDetails?: RiskDetails;\n /** Whether risk analysis is open */\n isRiskAnalysisOpen?: boolean;\n /** Custom risk details card component */\n RiskDetailsCard?: React.ComponentType<RiskDetailsCardProps<any>>;\n /** Input placeholder */\n placeholder?: string\n}\n\n/**\n * A highly customizable percentage input component with label, validation, and styling support.\n * Features GTN integration, risk analysis support, AI extraction indicator, and comprehensive prop support.\n *\n * @example\n * ```tsx\n * <PercentageInputField\n * id=\"discount\"\n * label=\"Discount Percentage\"\n * value={discount}\n * onChange={(value) => setDiscount(value)}\n * required\n * />\n * ```\n */\nexport const PercentageInputField = forwardRef<\n HTMLInputElement,\n PercentageInputFieldProps\n>(\n (\n {\n id,\n label,\n value,\n onChange,\n errorMessage,\n defaultValue,\n disabled,\n max,\n min,\n required = false,\n isRequiredConditional = false,\n bg,\n tags,\n color,\n className,\n originalCase = false,\n tooltip,\n simpleMode = false,\n inputFieldClassName = \"\",\n isAiExtracted = false,\n confidenceScore,\n confidenceType = \"high\",\n confidenceTooltip,\n sourceMeta = [],\n onConfidenceScoreClick,\n isGTN = false,\n gtnName = null,\n inputStyle,\n withDollarSign = true,\n labelClassName,\n isLiveField = false,\n onBlur,\n onAddGTNToDocument,\n riskDetails,\n isRiskAnalysisOpen = false,\n RiskDetailsCard,\n placeholder,\n ...props\n },\n ref\n ) => {\n const { t } = useTranslation();\n const [isHovered, setIsHovered] = useState(false);\n\n const handleAddGTNToDocument = (_value: string) => {\n if (onAddGTNToDocument) {\n const keyValuePair = {\n key: gtnName,\n value: _value,\n };\n onAddGTNToDocument(keyValuePair);\n }\n };\n\n // Simple mode rendering\n if (simpleMode) {\n return (\n <label\n id={id}\n className={`mb-1 text-xs font-medium text-gray-600 dark:text-neutral-200 inline-flex items-center gap-1 ${\n !originalCase ? \"capitalize\" : \"\"\n } ${labelClassName || \"\"}`}\n >\n {withDollarSign && (\n <span className=\"absolute inset-y-0 left-1 flex items-center pl-3\">\n {\"$\"}\n </span>\n )}\n <input\n {...props}\n ref={ref}\n onBlur={onBlur}\n type=\"number\"\n required={required}\n className={cn(inputFieldClassName, \"pl-8 h-8\")}\n onChange={(e) => {\n onChange(e.target.value);\n }}\n value={value}\n {...(defaultValue && !value ? { defaultValue: defaultValue } : {})}\n id={id || label}\n style={inputStyle}\n autoComplete=\"off\"\n />\n </label>\n );\n }\n\n // Full mode rendering\n return (\n <div\n className={cn(\n \"flex gap-0.5 relative\",\n isHovered && isGTN\n ? \"border rounded-lg border-primary-100 bg-primary-50 p-1\"\n : \"\"\n )}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n >\n {isGTN && !isHovered ? (\n <div className=\"w-1 h-1 bg-primary-600 rounded-full animate-blink mt-1.5\" />\n ) : null}\n <div className={cn(\"w-full flex flex-col\", className)}>\n <label\n htmlFor=\"text\"\n className={`mb-1 text-xs font-medium text-gray-600 dark:text-neutral-300 inline-flex items-center gap-1 ${\n !originalCase ? \"uppercase\" : \"\"\n } ${labelClassName || \"\"}`}\n >\n <div className=\"grid w-full grid-cols-[minmax(0,1fr)_auto] items-start gap-x-1\">\n <div className=\"inline-flex min-w-0 items-center gap-1 flex-wrap dark:text-black-300\">\n <InputLabel label={label || \"\"} required={required || false} isRequiredConditional={isRequiredConditional || false} />\n {isLiveField && (\n <BoltOutlined\n sx={{\n fontSize: 16,\n color: \"var(--color-primary-600)\",\n rotate: \"15deg\",\n }}\n />\n )}\n {isAiExtracted && !shouldShowConfidenceScore(confidenceScore) && <AIExtractedIndicator />}\n <Label labels={tags} />\n {tooltip && (\n <Tooltip placement=\"top\" title={tooltip}>\n <div className=\"cursor-pointer\">\n <HelpIcon className=\"w-icon-sm h-icon-sm\" />\n </div>\n </Tooltip>\n )}\n </div>\n\n <div className=\"flex items-center gap-1 justify-self-end\">\n {(shouldShowConfidenceScore(confidenceScore) && confidenceType) ? (\n <Tooltip\n placement=\"top-end\"\n title={confidenceTooltip ?? \"\"}\n hideTooltip={confidenceTooltip === undefined || confidenceTooltip === null}\n className=\"cursor-pointer\"\n >\n <div\n className={cn(\n \"inline-flex min-w-[50px] items-center gap-1 rounded-md px-1 py-0.5\",\n getConfidenceScoreBadgeClass(confidenceType)\n )}\n onClick={() => onConfidenceScoreClick?.(sourceMeta)}\n >\n <AIStarIcon\n size={12}\n fill={getConfidenceScoreBadgeColor(confidenceType)}\n fillSecondary={getConfidenceScoreBadgeFill(confidenceType)}\n />\n <span className={cn(\"text-xs font-medium leading-4\", getConfidenceScoreBadgeTextColor(confidenceType))}>\n {confidenceScore}%\n </span>\n </div>\n </Tooltip>\n ) : null}\n {isGTN && isHovered && onAddGTNToDocument ? (\n <button\n id=\"btn-percentage-input-add-to-document\"\n className=\"cursor-pointer\"\n onClick={() => handleAddGTNToDocument(value?.toString())}\n type=\"button\"\n >\n <AntTooltip placement=\"top\" title={t(\"Add to document\")}>\n <NoteAddOutlined\n className=\"text-primary-600\"\n sx={{ fontSize: 16 }}\n />\n </AntTooltip>\n </button>\n ) : null}\n </div>\n </div>\n </label>\n <label className=\"relative block\">\n <input\n {...props}\n ref={ref}\n onBlur={onBlur}\n type=\"number\"\n required={required}\n disabled={disabled}\n min={min}\n max={max}\n className={`border ${\n errorMessage\n ? \"border-red-300\"\n : isRiskAnalysisOpen && riskDetails?.color\n ? `border-${riskDetails.color}-300`\n : \"border-gray-300\"\n } ${bg} h-8 text-gray-900 dark:bg-black-600 dark:text-neutral-200 text-sm rounded-lg focus:outline-none focus:ring-0 focus:border-[var(--color-primary-600)] dark:focus:border-[var(--color-primary-400)] focus:shadow-[0_0_0_1.5px_var(--color-primary-100)] dark:focus:shadow-[0_0_0_1.5px_var(--color-primary-950)] block w-full p-2.5 font-inter font-medium \n disabled:bg-neutral-50 dark:disabled:!bg-black-800 dark:disabled:placeholder:!text-black-400\n ${\n isRiskAnalysisOpen &&\n riskDetails?.color &&\n `bg-${riskDetails.color}-50`\n }\n ${color || \"\"}\n `}\n onChange={(e) => {\n onChange(e.target.value);\n }}\n value={value}\n defaultValue={defaultValue}\n id={id || label}\n style={inputStyle}\n autoComplete=\"off\"\n placeholder={placeholder}\n />\n <span className=\"absolute inset-y-0 right-3 flex items-center z-[1000px] h-full dark:text-black-100\">\n %\n </span>\n </label>\n {errorMessage && (\n <Typography\n className=\"text-error-500 mt-1\"\n appearance=\"custom\"\n size=\"extra-small\"\n variant=\"medium\"\n >\n {errorMessage}\n </Typography>\n )}\n </div>\n\n {isHovered &&\n riskDetails &&\n isRiskAnalysisOpen &&\n RiskDetailsCard && (\n <div\n role=\"tooltip\"\n tabIndex={0}\n className=\"absolute left-0 right-0 top-[95%] mt-1 z-50 bg-white dark:bg-black-600 rounded-xl\"\n onClick={(e) => e.stopPropagation()}\n onMouseDown={(e) => e.preventDefault()}\n onKeyDown={(e) => {\n if (e.key === \"Escape\") {\n setIsHovered(false);\n }\n }}\n >\n <RiskDetailsCard riskDetails={riskDetails} />\n </div>\n )}\n </div>\n );\n }\n);\n\nPercentageInputField.displayName = \"PercentageInputField\";\n"],"names":["PercentageInputField","forwardRef","id","label","value","onChange","errorMessage","defaultValue","disabled","max","min","required","isRequiredConditional","bg","tags","color","className","originalCase","tooltip","simpleMode","inputFieldClassName","isAiExtracted","confidenceScore","confidenceType","confidenceTooltip","sourceMeta","onConfidenceScoreClick","isGTN","gtnName","inputStyle","withDollarSign","labelClassName","isLiveField","onBlur","onAddGTNToDocument","riskDetails","isRiskAnalysisOpen","RiskDetailsCard","placeholder","props","ref","t","useTranslation","isHovered","setIsHovered","useState","handleAddGTNToDocument","_value","jsxs","jsx","cn","e","InputLabel","BoltOutlined","shouldShowConfidenceScore","AIExtractedIndicator","Label","Tooltip","HelpIcon","getConfidenceScoreBadgeClass","AIStarIcon","getConfidenceScoreBadgeColor","getConfidenceScoreBadgeFill","getConfidenceScoreBadgeTextColor","AntTooltip","NoteAddOutlined","Typography"],"mappings":";;;;;;;;;;;;;;AAiKO,MAAMA,KAAuBC;AAAA,EAIlC,CACE;AAAA,IACE,IAAAC;AAAA,IACA,OAAAC;AAAA,IACA,OAAAC;AAAA,IACA,UAAAC;AAAA,IACA,cAAAC;AAAA,IACA,cAAAC;AAAA,IACA,UAAAC;AAAA,IACA,KAAAC;AAAA,IACA,KAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,uBAAAC,IAAwB;AAAA,IACxB,IAAAC;AAAA,IACA,MAAAC;AAAA,IACA,OAAAC;AAAA,IACA,WAAAC;AAAA,IACA,cAAAC,IAAe;AAAA,IACf,SAAAC;AAAA,IACA,YAAAC,IAAa;AAAA,IACb,qBAAAC,IAAsB;AAAA,IACtB,eAAAC,IAAgB;AAAA,IAChB,iBAAAC;AAAA,IACA,gBAAAC,IAAiB;AAAA,IACjB,mBAAAC;AAAA,IACA,YAAAC,IAAa,CAAA;AAAA,IACb,wBAAAC;AAAA,IACA,OAAAC,IAAQ;AAAA,IACR,SAAAC,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ZP,EAAa,EAAK;AAAA,cAEtB;AAAA,cAEA,UAAA,gBAAAK,EAACZ,KAAgB,aAAAF,EAAA,CAA0B;AAAA,YAAA;AAAA,UAAA;AAAA,QAC7C;AAAA,MAAA;AAAA,IAAA;AAAA,EAIV;AACF;AAEAnC,GAAqB,cAAc;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),M=require("antd");;/* empty css */const j=require("../../../_virtual/index.cjs.js"),Ae=require("lodash/debounce"),u=require("react"),Pe=require("react-i18next"),X=require("../../data-display/typography/Typography.cjs.js"),Be=require("../../icons/HelpIcon.cjs.js"),De=require("../../data-display/label/Label.cjs.js"),Le=require("../../data-display/tag/Tag.cjs.js"),W=require("@mui/icons-material"),_e=require("../../icons/AIExtractedIndicator.cjs.js"),ze=require("../../icons/AIStarIcon.cjs.js"),Te=require("../shared/InputLabel.cjs.js"),k=require("../../tooltip/Tooltip.cjs.js"),h=require("../../../utils/confidenceScoreUtils.cjs.js"),Fe={sm:"[&_.ant-select-selector]:!min-h-6",md:"[&_.ant-select-selector]:!min-h-8",lg:"[&_.ant-select-selector]:!min-h-10"},Me=i=>Array.isArray(i)?i.map(n=>typeof n=="string"||typeof n=="number"?n:n.value):i||null,Oe=i=>i.filter((n,r,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),M=require("antd");;/* empty css */const j=require("../../../_virtual/index.cjs.js"),Ae=require("lodash/debounce"),u=require("react"),Pe=require("react-i18next"),X=require("../../data-display/typography/Typography.cjs.js"),Be=require("../../icons/HelpIcon.cjs.js"),De=require("../../data-display/label/Label.cjs.js"),Le=require("../../data-display/tag/Tag.cjs.js"),W=require("@mui/icons-material"),_e=require("../../icons/AIExtractedIndicator.cjs.js"),ze=require("../../icons/AIStarIcon.cjs.js"),Te=require("../shared/InputLabel.cjs.js"),k=require("../../tooltip/Tooltip.cjs.js"),h=require("../../../utils/confidenceScoreUtils.cjs.js"),Fe={sm:"[&_.ant-select-selector]:!min-h-6",md:"[&_.ant-select-selector]:!min-h-8",lg:"[&_.ant-select-selector]:!min-h-10"},Me=i=>Array.isArray(i)?i.map(n=>typeof n=="string"||typeof n=="number"?n:n.value):i||null,Oe=i=>i.filter((n,r,s)=>s.findIndex(m=>m.value===n.value&&m.label===n.label)===r),He=({options:i,value:n,defaultValue:r})=>i?.length?Oe(i.map(s=>({...s,color:s.color}))):Array.isArray(n)&&n.length&&typeof n[0]=="object"&&"label"in n[0]?n.map(s=>({label:String(s?.label||""),value:String(s?.value||""),color:s?.color})):n&&typeof n=="object"&&"label"in n?[{label:String(n.label||""),value:String(n.value||""),color:n?.color}]:Array.isArray(r)&&r.length&&typeof r[0]=="object"&&"label"in r[0]?r.map(s=>({label:String(s?.label||""),value:String(s?.value||""),color:s?.color})):r&&typeof r=="object"&&"label"in r?[{label:String(r.label||""),value:String(r.value||""),color:r?.color}]:[],Ke=({hasExistingData:i})=>t.jsx("div",{className:"!w-full px-3 py-1.5",children:i?t.jsx(M.Skeleton,{paragraph:{rows:1,width:"100%"}}):t.jsx(M.Skeleton,{})}),Re=({showSelectAll:i,mode:n,options:r,searchValue:s,handleSelectAll:m,isAllSelected:y,menu:q,isLoading:E,hasExistingData:C,t:v})=>t.jsxs(t.Fragment,{children:[i&&n==="multiple"&&r.length>0&&s.trim().length===0&&t.jsx("div",{role:"button",tabIndex:0,className:"px-3 py-2 border-b border-gray-200 dark:border-gray-600 cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700",onClick:b=>{b.stopPropagation(),m()},onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),m())},children:t.jsx(X.Typography,{size:"small",variant:"semibold",className:"text-primary-600 dark:text-primary-300",appearance:"custom",children:v(y?"Deselect all":"Select all")})}),q,E&&t.jsx(Ke,{hasExistingData:C})]}),Y=u.forwardRef(({label:i,value:n,mode:r,errorMessage:s,selectOptions:m=[],required:y=!1,tags:q,className:E,onInputChange:C,tooltip:v,originalCase:b=!1,isAiExtracted:G=!1,confidenceScore:A,confidenceType:S="high",confidenceTooltip:P,sourceMeta:V=[],onConfidenceScoreClick:ee,isGTN:B=!1,gtnName:te=null,onChange:g,onSearch:w,debounceTimeout:O=500,filterOption:le=!0,onScroll:re,isLoading:ae=!1,allowClear:ne=!0,autoClearSearchValue:se=!0,fullOpacityLabel:$e=!1,showAllTags:oe=!1,customTagRender:ce,inputStyles:Je,disabled:D=!1,showSelectAll:ie=!1,labelClassName:ue,riskDetails:d,isRiskAnalysisOpen:f=!1,RiskDetailsCard:H,AddToDocumentIcon:Ue,primaryColorShades:Ze,UserAvatar:K,onAddGTNToDocument:R,isRequiredConditional:de,isLiveField:pe=!1,labelExtra:me,inputEmphasis:L="default",inputSize:be="md",...x},fe)=>{const{t:$}=Pe.useTranslation(),[N,_]=u.useState(!1),ge=L==="modified"&&!s&&!(f&&d?.color),xe=L==="deleted"&&!s&&!(f&&d?.color),he=L==="success"&&!s&&!(f&&d?.color),ye=u.useRef(null),[J,ve]=u.useState(!1),[Se,je]=u.useState("");u.useEffect(()=>{const e="select-field-scrollbar-styles";if(document.getElementById(e))return;const l=document.createElement("style");l.id=e,l.textContent=`
|
|
2
2
|
[class*="virtual-list-scrollbar"]:not([class*="thumb"]) {
|
|
3
3
|
width: 8px !important;
|
|
4
4
|
background: transparent !important;
|
|
@@ -10,5 +10,5 @@
|
|
|
10
10
|
.dark [class*="virtual-list-scrollbar-thumb"] {
|
|
11
11
|
background: #454545 !important;
|
|
12
12
|
}
|
|
13
|
-
`,document.head.appendChild(l)},[]);const Ce=()=>{if(R){let e="";
|
|
13
|
+
`,document.head.appendChild(l)},[]);const Ce=()=>{if(R){let e="";o==null?e="":typeof o=="string"||typeof o=="number"?e=String(o):Array.isArray(o)?e=o.map(a=>typeof a=="object"&&a!==null&&"value"in a?a.value:a).join(", "):typeof o=="object"&&"value"in o&&(e=String(o.value)),R({key:te,value:e})}},o=Me(n),U=u.useMemo(()=>w?Ae(w,O):null,[w,O]),we=(e,l)=>{if(ye.current&&x.id){const a=document.getElementById(x.id);if(a){const c=Array.isArray(l)?l.map(F=>F.value):l?.value;a.dataset.selectedValue=JSON.stringify(c);const z=new Event("change",{bubbles:!0});Object.defineProperty(z,"target",{writable:!1,value:a}),a.dispatchEvent(z);const T=new CustomEvent("pilot-change",{bubbles:!0,detail:{selector:`#${x.id}`,value:c,type:"change"}});a.dispatchEvent(T)}}if(r==="tags"){const a=Array.isArray(e)?e:[e];g?.(a?.map(c=>({label:c,value:c})))}else g?.(l)},p=He({options:m,value:n,defaultValue:x?.defaultValue}),Ne=u.useMemo(()=>p.length>0||o!=null,[p,o]),Z=u.useMemo(()=>{if(!r||r!=="multiple"||p.length===0)return!1;const e=Array.isArray(o)?o:[];return p.map(a=>a.value).every(a=>e.some(c=>typeof c=="object"&&c!==null&&"value"in c?String(c.value)===String(a):String(c)===String(a)))},[o,p,r]),Ie=()=>{!r||r!=="multiple"||!g||g(Z?[]:p)},Q=u.useCallback(e=>{if(!e)return;const l=new Event("submit",{bubbles:!0,cancelable:!0});e.dispatchEvent(l);const a=e.querySelector('button[type="submit"]');a&&a.click()},[]),ke=u.useCallback(e=>{if(e.key==="Enter"&&!J&&(e.preventDefault(),e.stopPropagation(),o)){const l=e.currentTarget.closest("form");Q(l)}},[J,o,Q]),qe=u.useCallback(e=>{const{label:l,value:a,onClose:c}=e,T=p.find(I=>String(I.value)===String(a))?.color||"primary",F=I=>{I.preventDefault(),I.stopPropagation()};return t.jsx("div",{className:"cursor-pointer me-1 inline-flex",children:t.jsx(Le.Tag,{label:l,color:T,className:"!px-0.5 !py-0 !rounded",size:"md",onMouseDown:F,onClick:D?void 0:c,isHashColor:!0,removable:!0,onRemove:c})})},[p,D]),Ee=u.useCallback(e=>{je(e),(C||U)?.(e)},[C,U]);return t.jsxs("div",{ref:fe,className:j("flex gap-0.5 w-full relative",N&&B?"border rounded-lg border-primary-100 bg-primary-50 p-1":""),onMouseEnter:()=>_(!0),onMouseLeave:()=>_(!1),id:x.id,children:[B&&!N?t.jsx("div",{className:"w-1 h-1 bg-primary-600 rounded-full animate-blink mt-1.5"}):null,t.jsxs("div",{className:j("w-full flex flex-col gap-1 risk-analysis-select-field",E),onMouseDown:e=>e.stopPropagation(),onKeyDownCapture:ke,role:"group","aria-labelledby":i?"select-field-label":void 0,children:[i?t.jsx("label",{id:"select-field-label",htmlFor:"label",className:`text-xs font-medium text-gray-600 dark:text-black-300 inline-flex items-center gap-1 ${b?"":"capitalize"} ${ue||""}`,children:t.jsxs("div",{className:"grid w-full grid-cols-[minmax(0,1fr)_auto] items-start gap-x-1",children:[t.jsxs("div",{className:"inline-flex min-w-0 items-center gap-1 flex-wrap",children:[t.jsx(Te.InputLabel,{label:i||"",required:y||!1,isRequiredConditional:de||!1}),pe&&t.jsx(W.BoltOutlined,{className:"!text-base text-primary-600 rotate-[15deg]"}),G&&!h.shouldShowConfidenceScore(A)&&t.jsx(_e.AIExtractedIndicator,{}),t.jsx(De.Label,{labels:q}),v&&t.jsx(k,{placement:"top",title:v,children:t.jsx("div",{className:"cursor-pointer",role:"button",tabIndex:0,onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&e.preventDefault()},children:t.jsx(Be.HelpIcon,{className:"w-icon-sm h-icon-sm"})})}),me]}),t.jsxs("div",{className:"flex items-center gap-1 justify-self-end",children:[h.shouldShowConfidenceScore(A)&&S?t.jsx(k,{placement:"top-end",title:P??"",hideTooltip:P==null,className:"cursor-pointer",children:t.jsxs("div",{className:j("inline-flex min-w-12 items-center gap-1 rounded-md px-1 py-0.5",h.getConfidenceScoreBadgeClass(S)),onClick:()=>ee?.(V),children:[t.jsx(ze.AIStarIcon,{size:12,fill:h.getConfidenceScoreBadgeColor(S),fillSecondary:h.getConfidenceScoreBadgeFill(S)}),t.jsxs("span",{className:j("text-xs font-medium leading-4",h.getConfidenceScoreBadgeTextColor(S)),children:[A,"%"]})]})}):null,B&&N?t.jsx("button",{id:"btn-select-field-base-add-to-document",className:"cursor-pointer",onClick:Ce,type:"button",children:t.jsx(k,{placement:"top",title:$("Add to document"),children:t.jsx(W.NoteAddOutlined,{className:"!text-base text-primary-600"})})}):null]})]})}):null,t.jsx(M.Select,{onOpenChange:ve,disabled:D,className:j("w-full h-8 flex items-center justify-center text-black-900 dark:text-black-200 text-sm",Fe[be],s&&y?"ant-select-status-error":"",f&&d?.color?"risk-select-field":"",ge?"select-field-emphasis-modified":xe?"select-field-emphasis-deleted":he?"select-field-emphasis-success":""),classNames:{popup:{root:"!z-[5001]"}},style:{width:"100%","--risk-color":f&&d?.hexBgColor?d?.hexBgColor:"","--risk-border-color":f&&d?.hexBorderColor?d?.hexBorderColor:""},"aria-required":y,mode:r,value:o,onChange:we,filterOption:w?le:(e,l)=>(l?.label||"")?.toLowerCase()?.includes(e?.toLowerCase()),showSearch:!0,onSearch:Ee||void 0,onPopupScroll:re,popupClassName:"select-field-dropdown-popup",popupRender:e=>t.jsx(Re,{showSelectAll:ie,mode:r,options:p,searchValue:Se,handleSelectAll:Ie,isAllSelected:Z,menu:e,isLoading:ae,hasExistingData:Ne,t:$}),options:p.map(({label:e,value:l,color:a,...c})=>({label:String(e),value:String(l),key:String(l),id:String(l),color:a,...c})),optionRender:e=>{const l=e?.data?.fullname;if(l&&K){const[a,c]=l.split(" ");return t.jsxs("div",{className:"flex items-center justify-start gap-1",children:[t.jsx(K,{firstName:a,lastName:c,profilePic:e?.data?.url||"",size:"xs",enablePopper:!0,userId:e?.data?.value}),t.jsx("span",{className:"ml-2",children:e.label})]})}return t.jsx("span",{children:e.label})},autoClearSearchValue:se,onClear:()=>g&&g(r==="tags"||r==="multiple"?[]:null),maxTagCount:r==="tags"&&oe?void 0:"responsive",maxTagPlaceholder:e=>t.jsx(k,{placement:"top",title:e.length>3?e.slice(0,3).map(({label:l})=>l).join(", ")+"...":e.map(({label:l})=>l).join(", "),children:t.jsxs("span",{children:["+",e.length," more"]})}),tagRender:ce||qe,allowClear:ne,...x}),s&&t.jsx(X.Typography,{className:"text-error-500",appearance:"custom",size:"extra-small",variant:"medium",children:s})]}),N&&d&&f&&H&&t.jsx("div",{role:"tooltip",tabIndex:0,className:"absolute left-0 right-0 top-[95%] mt-1 z-50 bg-white dark:bg-black-600 rounded-xl",onClick:e=>e.stopPropagation(),onMouseDown:e=>e.preventDefault(),onKeyDown:e=>{e.key==="Escape"&&_(!1)},children:t.jsx(H,{riskDetails:d})})]})});Y.displayName="SelectField";exports.SelectField=Y;
|
|
14
14
|
//# sourceMappingURL=SelectField.cjs.js.map
|