@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.
Files changed (51) hide show
  1. package/dist/components/forms/base-input-field/BaseInputField.cjs.js +2 -2
  2. package/dist/components/forms/base-input-field/BaseInputField.cjs.js.map +1 -1
  3. package/dist/components/forms/base-input-field/BaseInputField.es.js +20 -20
  4. package/dist/components/forms/base-input-field/BaseInputField.es.js.map +1 -1
  5. package/dist/components/forms/creatable-select/CreatableSelect.cjs.js +1 -1
  6. package/dist/components/forms/creatable-select/CreatableSelect.cjs.js.map +1 -1
  7. package/dist/components/forms/creatable-select/CreatableSelect.es.js +7 -7
  8. package/dist/components/forms/creatable-select/CreatableSelect.es.js.map +1 -1
  9. package/dist/components/forms/currency-input/CurrencyInputField.cjs.js +1 -1
  10. package/dist/components/forms/currency-input/CurrencyInputField.cjs.js.map +1 -1
  11. package/dist/components/forms/currency-input/CurrencyInputField.es.js +12 -12
  12. package/dist/components/forms/currency-input/CurrencyInputField.es.js.map +1 -1
  13. package/dist/components/forms/date-time-field/DateTimeField.cjs.js +1 -1
  14. package/dist/components/forms/date-time-field/DateTimeField.cjs.js.map +1 -1
  15. package/dist/components/forms/date-time-field/DateTimeField.es.js +1 -1
  16. package/dist/components/forms/date-time-field/DateTimeField.es.js.map +1 -1
  17. package/dist/components/forms/dynamic-data-input/DynamicDataInput.cjs.js +1 -1
  18. package/dist/components/forms/dynamic-data-input/DynamicDataInput.cjs.js.map +1 -1
  19. package/dist/components/forms/dynamic-data-input/DynamicDataInput.es.js +7 -7
  20. package/dist/components/forms/dynamic-data-input/DynamicDataInput.es.js.map +1 -1
  21. package/dist/components/forms/dynamic-data-input/DynamicDataInputField.cjs.js +1 -1
  22. package/dist/components/forms/dynamic-data-input/DynamicDataInputField.cjs.js.map +1 -1
  23. package/dist/components/forms/dynamic-data-input/DynamicDataInputField.es.js +1 -1
  24. package/dist/components/forms/dynamic-data-input/DynamicDataInputField.es.js.map +1 -1
  25. package/dist/components/forms/formula-input/FormulaInput.cjs.js +1 -1
  26. package/dist/components/forms/formula-input/FormulaInput.cjs.js.map +1 -1
  27. package/dist/components/forms/formula-input/FormulaInput.es.js +10 -10
  28. package/dist/components/forms/formula-input/FormulaInput.es.js.map +1 -1
  29. package/dist/components/forms/input-field/InputField.cjs.js.map +1 -1
  30. package/dist/components/forms/input-field/InputField.es.js.map +1 -1
  31. package/dist/components/forms/master-data-input/MasterDataInputField.cjs.js +1 -1
  32. package/dist/components/forms/master-data-input/MasterDataInputField.cjs.js.map +1 -1
  33. package/dist/components/forms/master-data-input/MasterDataInputField.es.js +1 -1
  34. package/dist/components/forms/master-data-input/MasterDataInputField.es.js.map +1 -1
  35. package/dist/components/forms/percentage-input/PercentageInputField.cjs.js +2 -2
  36. package/dist/components/forms/percentage-input/PercentageInputField.cjs.js.map +1 -1
  37. package/dist/components/forms/percentage-input/PercentageInputField.es.js +19 -19
  38. package/dist/components/forms/percentage-input/PercentageInputField.es.js.map +1 -1
  39. package/dist/components/forms/select-field/SelectField.cjs.js +2 -2
  40. package/dist/components/forms/select-field/SelectField.cjs.js.map +1 -1
  41. package/dist/components/forms/select-field/SelectField.es.js +1 -1
  42. package/dist/components/forms/select-field/SelectField.es.js.map +1 -1
  43. package/dist/components/forms/text-area-field/TextAreaField.cjs.js +1 -1
  44. package/dist/components/forms/text-area-field/TextAreaField.cjs.js.map +1 -1
  45. package/dist/components/forms/text-area-field/TextAreaField.es.js +14 -14
  46. package/dist/components/forms/text-area-field/TextAreaField.es.js.map +1 -1
  47. package/dist/components/forms/toggle/Toggle.cjs.js +1 -1
  48. package/dist/components/forms/toggle/Toggle.cjs.js.map +1 -1
  49. package/dist/components/forms/toggle/Toggle.es.js +62 -56
  50. package/dist/components/forms/toggle/Toggle.es.js.map +1 -1
  51. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"DynamicDataInputField.cjs.js","sources":["../../../../src/components/forms/dynamic-data-input/DynamicDataInputField.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 { BoltOutlined, CloseRounded, NoteAddOutlined, TableChartRounded } 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\";\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 DynamicDataModal component\n */\nexport interface DynamicDataModalProps {\n isVisible: boolean;\n onSelect: (data: string | number | readonly string[] | undefined) => void;\n onClose: () => void;\n dataKey: string;\n dataSource: string;\n}\n\n/**\n * Props for the DynamicDataInputField component\n */\nexport interface DynamicDataInputFieldProps {\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 /** Color for the input text */\n color?: string;\n /** Current value of the input */\n value: string | number | readonly string[] | undefined;\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 /** Tags/labels to display next to the label */\n tags?: (string | LabelType)[];\n /** Error message to display below the input */\n errorMessage?: string;\n /** Default value for the input */\n defaultValue?: string | number | readonly string[] | undefined;\n /** Data source for dynamic data */\n dataSource: string;\n /** Data key for dynamic data */\n dataKey: string;\n /** Tooltip text for the help icon */\n tooltip?: string;\n /** Whether this is a GTN (Global Term Name) field */\n isGTN?: boolean;\n /** GTN field name for document integration */\n gtnName?: 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 the input is disabled */\n disabled?: boolean;\n /** Callback function called when value changes */\n onChange: (value: string | number | readonly string[] | undefined) => void;\n /** Additional CSS classes for the label */\n labelClassName?: string;\n /** Whether this is a live field */\n isLiveField?: boolean;\n /** Whether to preserve original case in the label */\n originalCase?: boolean;\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 /** Whether recording is active (for pilot context) */\n isRecording?: boolean;\n /** Whether playback is active (for pilot context) */\n isPlaying?: boolean;\n /** Callback to set disable actions state */\n setDisableActions?: (disabled: boolean) => void;\n /** Toast function for deprecated field warning */\n showDeprecatedFieldWarning?: () => void;\n /** Dynamic data modal component */\n DynamicDataModal?: React.ComponentType<DynamicDataModalProps>;\n}\n\n/**\n * A highly customizable dynamic data input component with label, validation, and styling support.\n * Features dynamic data modal integration, GTN support, risk analysis support,\n * and comprehensive prop support for various use cases.\n *\n * @example\n * ```tsx\n * <DynamicDataInputField\n * id=\"dynamic-field\"\n * label=\"Dynamic Field\"\n * value={fieldValue}\n * onChange={(value) => setFieldValue(value)}\n * dataSource=\"sourceTable\"\n * dataKey=\"fieldKey\"\n * required\n * />\n * ```\n */\nexport const DynamicDataInputField = forwardRef<\n HTMLInputElement,\n DynamicDataInputFieldProps\n>(\n (\n {\n id,\n label,\n placeholder,\n value,\n onChange,\n errorMessage,\n defaultValue,\n required = false,\n isRequiredConditional = false,\n dataSource,\n dataKey,\n tags,\n tooltip = \"\",\n originalCase = false,\n color = \"\",\n isGTN = false,\n gtnName,\n isAiExtracted = false,\n confidenceScore,\n confidenceType = \"high\",\n confidenceTooltip,\n sourceMeta = [],\n onConfidenceScoreClick,\n labelClassName,\n disabled = false,\n isLiveField = false,\n onAddGTNToDocument,\n riskDetails,\n isRiskAnalysisOpen = false,\n RiskDetailsCard,\n primaryColorShades,\n isRecording: _isRecording = false,\n isPlaying: _isPlaying = false,\n setDisableActions,\n showDeprecatedFieldWarning,\n DynamicDataModal,\n },\n ref\n ) => {\n const { t } = useTranslation();\n const [isHovered, setIsHovered] = useState(false);\n const [inputValue, setInputValue] = useState<\n string | number | readonly string[] | undefined\n >(value);\n const [showDynamicDataModal, setShowDynamicDataModal] = 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 const toggleDynamicDataModal = () => {\n if (showDynamicDataModal) {\n setDisableActions?.(false);\n } else {\n setDisableActions?.(true);\n }\n setShowDynamicDataModal(!showDynamicDataModal);\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 if (inputValue !== null) {\n onChange(inputValue);\n }\n setInputValue(inputValue);\n currentRef.blur();\n }\n }\n };\n\n const handleClear = () => {\n setInputValue(\"\");\n onChange(\"\");\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 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 : \"bg-gray-200 dark:bg-black-600 \"\n } ${color ? color : \"text-neutral-900 dark:text-black-200\"}`;\n\n return `${baseClasses} ${borderColor} ${backgroundColor} ${placeholderColor}`;\n };\n\n useEffect(() => {\n if (showDynamicDataModal && !dataSource) {\n showDeprecatedFieldWarning?.();\n setShowDynamicDataModal(false);\n }\n }, [showDynamicDataModal, dataSource, showDeprecatedFieldWarning]);\n\n // Sync inputValue with value prop\n useEffect(() => {\n setInputValue(value);\n }, [value]);\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 bg-primary-50 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 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-dynamic-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 <input\n id={id}\n ref={combinedRef}\n required={required}\n placeholder={placeholder}\n className={getClassName()}\n onChange={(e) => {\n onChange(e.target.value);\n setInputValue(e.target?.value);\n }}\n onKeyDown={handleKeyDown}\n value={inputValue !== null ? inputValue : value}\n defaultValue={defaultValue}\n disabled={true}\n />\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 <CloseRounded\n className=\"text-neutral-900 dark:text-black-300 w-xs h-xs\"\n />\n </IconButton>\n\n <IconButton\n id={`btn-dynamic-data-input-ai-outline-pic-center`}\n onClick={toggleDynamicDataModal}\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-900 dark:text-black-300 w-xs h-xs\"\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 {showDynamicDataModal && DynamicDataModal && (\n <DynamicDataModal\n isVisible={showDynamicDataModal}\n onSelect={(data) => {\n onChange(data);\n setInputValue(data);\n }}\n onClose={toggleDynamicDataModal}\n dataKey={dataKey}\n dataSource={dataSource}\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\nDynamicDataInputField.displayName = \"DynamicDataInputField\";\n\n"],"names":["DynamicDataInputField","forwardRef","id","label","placeholder","value","onChange","errorMessage","defaultValue","required","isRequiredConditional","dataSource","dataKey","tags","tooltip","originalCase","color","isGTN","gtnName","isAiExtracted","confidenceScore","confidenceType","confidenceTooltip","sourceMeta","onConfidenceScoreClick","labelClassName","disabled","isLiveField","onAddGTNToDocument","riskDetails","isRiskAnalysisOpen","RiskDetailsCard","primaryColorShades","_isRecording","_isPlaying","setDisableActions","showDeprecatedFieldWarning","DynamicDataModal","ref","t","useTranslation","isHovered","setIsHovered","useState","inputValue","setInputValue","showDynamicDataModal","setShowDynamicDataModal","inputRef","useRef","combinedRef","toggleDynamicDataModal","handleKeyDown","event","currentRef","handleClear","handleAddGTNToDocument","_value","getClassName","baseClasses","borderColor","placeholderColor","backgroundColor","useEffect","jsxs","cn","jsx","InputLabel","BoltOutlined","shouldShowConfidenceScore","AIExtractedIndicator","Label","Tooltip","HelpIcon","getConfidenceScoreBadgeClass","AIStarIcon","getConfidenceScoreBadgeColor","getConfidenceScoreBadgeFill","getConfidenceScoreBadgeTextColor","AntTooltip","NoteAddOutlined","e","IconButton","CloseRounded","TableChartRounded","Typography","data"],"mappings":"0rBA8KaA,EAAwBC,EAAAA,WAInC,CACE,CACE,GAAAC,EACA,MAAAC,EACA,YAAAC,EACA,MAAAC,EACA,SAAAC,EACA,aAAAC,EACA,aAAAC,EACA,SAAAC,EAAW,GACX,sBAAAC,EAAwB,GACxB,WAAAC,EACA,QAAAC,E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AAAwB,EAAAA,IAACnC,GAAgB,YAAAF,CAAA,CAA0B,CAAA,CAAA,CAC7C,CAAA,CAAA,CAIV,CACF,EAEA7B,EAAsB,YAAc"}
1
+ {"version":3,"file":"DynamicDataInputField.cjs.js","sources":["../../../../src/components/forms/dynamic-data-input/DynamicDataInputField.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 { BoltOutlined, CloseRounded, NoteAddOutlined, TableChartRounded } 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\";\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 DynamicDataModal component\n */\nexport interface DynamicDataModalProps {\n isVisible: boolean;\n onSelect: (data: string | number | readonly string[] | undefined) => void;\n onClose: () => void;\n dataKey: string;\n dataSource: string;\n}\n\n/**\n * Props for the DynamicDataInputField component\n */\nexport interface DynamicDataInputFieldProps {\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 /** Color for the input text */\n color?: string;\n /** Current value of the input */\n value: string | number | readonly string[] | undefined;\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 /** Tags/labels to display next to the label */\n tags?: (string | LabelType)[];\n /** Error message to display below the input */\n errorMessage?: string;\n /** Default value for the input */\n defaultValue?: string | number | readonly string[] | undefined;\n /** Data source for dynamic data */\n dataSource: string;\n /** Data key for dynamic data */\n dataKey: string;\n /** Tooltip text for the help icon */\n tooltip?: string;\n /** Whether this is a GTN (Global Term Name) field */\n isGTN?: boolean;\n /** GTN field name for document integration */\n gtnName?: 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 the input is disabled */\n disabled?: boolean;\n /** Callback function called when value changes */\n onChange: (value: string | number | readonly string[] | undefined) => void;\n /** Additional CSS classes for the label */\n labelClassName?: string;\n /** Whether this is a live field */\n isLiveField?: boolean;\n /** Whether to preserve original case in the label */\n originalCase?: boolean;\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 /** Whether recording is active (for pilot context) */\n isRecording?: boolean;\n /** Whether playback is active (for pilot context) */\n isPlaying?: boolean;\n /** Callback to set disable actions state */\n setDisableActions?: (disabled: boolean) => void;\n /** Toast function for deprecated field warning */\n showDeprecatedFieldWarning?: () => void;\n /** Dynamic data modal component */\n DynamicDataModal?: React.ComponentType<DynamicDataModalProps>;\n}\n\n/**\n * A highly customizable dynamic data input component with label, validation, and styling support.\n * Features dynamic data modal integration, GTN support, risk analysis support,\n * and comprehensive prop support for various use cases.\n *\n * @example\n * ```tsx\n * <DynamicDataInputField\n * id=\"dynamic-field\"\n * label=\"Dynamic Field\"\n * value={fieldValue}\n * onChange={(value) => setFieldValue(value)}\n * dataSource=\"sourceTable\"\n * dataKey=\"fieldKey\"\n * required\n * />\n * ```\n */\nexport const DynamicDataInputField = forwardRef<\n HTMLInputElement,\n DynamicDataInputFieldProps\n>(\n (\n {\n id,\n label,\n placeholder,\n value,\n onChange,\n errorMessage,\n defaultValue,\n required = false,\n isRequiredConditional = false,\n dataSource,\n dataKey,\n tags,\n tooltip = \"\",\n originalCase = false,\n color = \"\",\n isGTN = false,\n gtnName,\n isAiExtracted = false,\n confidenceScore,\n confidenceType = \"high\",\n confidenceTooltip,\n sourceMeta = [],\n onConfidenceScoreClick,\n labelClassName,\n disabled = false,\n isLiveField = false,\n onAddGTNToDocument,\n riskDetails,\n isRiskAnalysisOpen = false,\n RiskDetailsCard,\n primaryColorShades,\n isRecording: _isRecording = false,\n isPlaying: _isPlaying = false,\n setDisableActions,\n showDeprecatedFieldWarning,\n DynamicDataModal,\n },\n ref\n ) => {\n const { t } = useTranslation();\n const [isHovered, setIsHovered] = useState(false);\n const [inputValue, setInputValue] = useState<\n string | number | readonly string[] | undefined\n >(value);\n const [showDynamicDataModal, setShowDynamicDataModal] = 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 const toggleDynamicDataModal = () => {\n if (showDynamicDataModal) {\n setDisableActions?.(false);\n } else {\n setDisableActions?.(true);\n }\n setShowDynamicDataModal(!showDynamicDataModal);\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 if (inputValue !== null) {\n onChange(inputValue);\n }\n setInputValue(inputValue);\n currentRef.blur();\n }\n }\n };\n\n const handleClear = () => {\n setInputValue(\"\");\n onChange(\"\");\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 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 : \"bg-gray-200 dark:bg-black-600 \"\n } ${color ? color : \"text-neutral-900 dark:text-black-200\"}`;\n\n return `${baseClasses} ${borderColor} ${backgroundColor} ${placeholderColor}`;\n };\n\n useEffect(() => {\n if (showDynamicDataModal && !dataSource) {\n showDeprecatedFieldWarning?.();\n setShowDynamicDataModal(false);\n }\n }, [showDynamicDataModal, dataSource, showDeprecatedFieldWarning]);\n\n // Sync inputValue with value prop\n useEffect(() => {\n setInputValue(value);\n }, [value]);\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 bg-primary-50 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 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-dynamic-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 <input\n id={id}\n ref={combinedRef}\n required={required}\n placeholder={placeholder}\n className={getClassName()}\n onChange={(e) => {\n onChange(e.target.value);\n setInputValue(e.target?.value);\n }}\n onKeyDown={handleKeyDown}\n value={inputValue !== null ? inputValue : value}\n defaultValue={defaultValue}\n disabled={true}\n />\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 <CloseRounded\n className=\"text-neutral-900 dark:text-black-300 w-xs h-xs\"\n />\n </IconButton>\n\n <IconButton\n id={`btn-dynamic-data-input-ai-outline-pic-center`}\n onClick={toggleDynamicDataModal}\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-900 dark:text-black-300 w-xs h-xs\"\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 {showDynamicDataModal && DynamicDataModal && (\n <DynamicDataModal\n isVisible={showDynamicDataModal}\n onSelect={(data) => {\n onChange(data);\n setInputValue(data);\n }}\n onClose={toggleDynamicDataModal}\n dataKey={dataKey}\n dataSource={dataSource}\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\nDynamicDataInputField.displayName = \"DynamicDataInputField\";\n\n"],"names":["DynamicDataInputField","forwardRef","id","label","placeholder","value","onChange","errorMessage","defaultValue","required","isRequiredConditional","dataSource","dataKey","tags","tooltip","originalCase","color","isGTN","gtnName","isAiExtracted","confidenceScore","confidenceType","confidenceTooltip","sourceMeta","onConfidenceScoreClick","labelClassName","disabled","isLiveField","onAddGTNToDocument","riskDetails","isRiskAnalysisOpen","RiskDetailsCard","primaryColorShades","_isRecording","_isPlaying","setDisableActions","showDeprecatedFieldWarning","DynamicDataModal","ref","t","useTranslation","isHovered","setIsHovered","useState","inputValue","setInputValue","showDynamicDataModal","setShowDynamicDataModal","inputRef","useRef","combinedRef","toggleDynamicDataModal","handleKeyDown","event","currentRef","handleClear","handleAddGTNToDocument","_value","getClassName","baseClasses","borderColor","placeholderColor","backgroundColor","useEffect","jsxs","cn","jsx","InputLabel","BoltOutlined","shouldShowConfidenceScore","AIExtractedIndicator","Label","Tooltip","HelpIcon","getConfidenceScoreBadgeClass","AIStarIcon","getConfidenceScoreBadgeColor","getConfidenceScoreBadgeFill","getConfidenceScoreBadgeTextColor","AntTooltip","NoteAddOutlined","e","IconButton","CloseRounded","TableChartRounded","Typography","data"],"mappings":"0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AAA,IAAC,MAAA,CACC,KAAK,UACL,SAAU,EACV,UAAU,oFACV,QAAUe,GAAMA,EAAE,gBAAA,EAClB,YAAcA,GAAMA,EAAE,eAAA,EACtB,UAAYA,GAAM,CACZA,EAAE,MAAQ,UACZvC,EAAa,EAAK,CAEtB,EAEA,SAAAwB,EAAAA,IAACnC,GAAgB,YAAAF,CAAA,CAA0B,CAAA,CAAA,CAC7C,CAAA,CAAA,CAIV,CACF,EAEA7B,EAAsB,YAAc"}
@@ -107,7 +107,7 @@ const Ie = ie(
107
107
  ),
108
108
  U && !K(x) && /* @__PURE__ */ e(ge, {}),
109
109
  /* @__PURE__ */ e(fe, { labels: O }),
110
- N && /* @__PURE__ */ e(F, { placement: "top", title: N, children: /* @__PURE__ */ e("div", { className: "cursor-pointer", children: /* @__PURE__ */ e(ye, {}) }) })
110
+ N && /* @__PURE__ */ e(F, { placement: "top", title: N, children: /* @__PURE__ */ e("div", { className: "cursor-pointer", children: /* @__PURE__ */ e(ye, { className: "w-icon-sm h-icon-sm" }) }) })
111
111
  ] }),
112
112
  /* @__PURE__ */ l("div", { className: "flex items-center gap-1 justify-self-end", children: [
113
113
  K(x) && n ? /* @__PURE__ */ e(
@@ -1 +1 @@
1
- {"version":3,"file":"DynamicDataInputField.es.js","sources":["../../../../src/components/forms/dynamic-data-input/DynamicDataInputField.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 { BoltOutlined, CloseRounded, NoteAddOutlined, TableChartRounded } 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\";\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 DynamicDataModal component\n */\nexport interface DynamicDataModalProps {\n isVisible: boolean;\n onSelect: (data: string | number | readonly string[] | undefined) => void;\n onClose: () => void;\n dataKey: string;\n dataSource: string;\n}\n\n/**\n * Props for the DynamicDataInputField component\n */\nexport interface DynamicDataInputFieldProps {\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 /** Color for the input text */\n color?: string;\n /** Current value of the input */\n value: string | number | readonly string[] | undefined;\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 /** Tags/labels to display next to the label */\n tags?: (string | LabelType)[];\n /** Error message to display below the input */\n errorMessage?: string;\n /** Default value for the input */\n defaultValue?: string | number | readonly string[] | undefined;\n /** Data source for dynamic data */\n dataSource: string;\n /** Data key for dynamic data */\n dataKey: string;\n /** Tooltip text for the help icon */\n tooltip?: string;\n /** Whether this is a GTN (Global Term Name) field */\n isGTN?: boolean;\n /** GTN field name for document integration */\n gtnName?: 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 the input is disabled */\n disabled?: boolean;\n /** Callback function called when value changes */\n onChange: (value: string | number | readonly string[] | undefined) => void;\n /** Additional CSS classes for the label */\n labelClassName?: string;\n /** Whether this is a live field */\n isLiveField?: boolean;\n /** Whether to preserve original case in the label */\n originalCase?: boolean;\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 /** Whether recording is active (for pilot context) */\n isRecording?: boolean;\n /** Whether playback is active (for pilot context) */\n isPlaying?: boolean;\n /** Callback to set disable actions state */\n setDisableActions?: (disabled: boolean) => void;\n /** Toast function for deprecated field warning */\n showDeprecatedFieldWarning?: () => void;\n /** Dynamic data modal component */\n DynamicDataModal?: React.ComponentType<DynamicDataModalProps>;\n}\n\n/**\n * A highly customizable dynamic data input component with label, validation, and styling support.\n * Features dynamic data modal integration, GTN support, risk analysis support,\n * and comprehensive prop support for various use cases.\n *\n * @example\n * ```tsx\n * <DynamicDataInputField\n * id=\"dynamic-field\"\n * label=\"Dynamic Field\"\n * value={fieldValue}\n * onChange={(value) => setFieldValue(value)}\n * dataSource=\"sourceTable\"\n * dataKey=\"fieldKey\"\n * required\n * />\n * ```\n */\nexport const DynamicDataInputField = forwardRef<\n HTMLInputElement,\n DynamicDataInputFieldProps\n>(\n (\n {\n id,\n label,\n placeholder,\n value,\n onChange,\n errorMessage,\n defaultValue,\n required = false,\n isRequiredConditional = false,\n dataSource,\n dataKey,\n tags,\n tooltip = \"\",\n originalCase = false,\n color = \"\",\n isGTN = false,\n gtnName,\n isAiExtracted = false,\n confidenceScore,\n confidenceType = \"high\",\n confidenceTooltip,\n sourceMeta = [],\n onConfidenceScoreClick,\n labelClassName,\n disabled = false,\n isLiveField = false,\n onAddGTNToDocument,\n riskDetails,\n isRiskAnalysisOpen = false,\n RiskDetailsCard,\n primaryColorShades,\n isRecording: _isRecording = false,\n isPlaying: _isPlaying = false,\n setDisableActions,\n showDeprecatedFieldWarning,\n DynamicDataModal,\n },\n ref\n ) => {\n const { t } = useTranslation();\n const [isHovered, setIsHovered] = useState(false);\n const [inputValue, setInputValue] = useState<\n string | number | readonly string[] | undefined\n >(value);\n const [showDynamicDataModal, setShowDynamicDataModal] = 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 const toggleDynamicDataModal = () => {\n if (showDynamicDataModal) {\n setDisableActions?.(false);\n } else {\n setDisableActions?.(true);\n }\n setShowDynamicDataModal(!showDynamicDataModal);\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 if (inputValue !== null) {\n onChange(inputValue);\n }\n setInputValue(inputValue);\n currentRef.blur();\n }\n }\n };\n\n const handleClear = () => {\n setInputValue(\"\");\n onChange(\"\");\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 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 : \"bg-gray-200 dark:bg-black-600 \"\n } ${color ? color : \"text-neutral-900 dark:text-black-200\"}`;\n\n return `${baseClasses} ${borderColor} ${backgroundColor} ${placeholderColor}`;\n };\n\n useEffect(() => {\n if (showDynamicDataModal && !dataSource) {\n showDeprecatedFieldWarning?.();\n setShowDynamicDataModal(false);\n }\n }, [showDynamicDataModal, dataSource, showDeprecatedFieldWarning]);\n\n // Sync inputValue with value prop\n useEffect(() => {\n setInputValue(value);\n }, [value]);\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 bg-primary-50 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 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-dynamic-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 <input\n id={id}\n ref={combinedRef}\n required={required}\n placeholder={placeholder}\n className={getClassName()}\n onChange={(e) => {\n onChange(e.target.value);\n setInputValue(e.target?.value);\n }}\n onKeyDown={handleKeyDown}\n value={inputValue !== null ? inputValue : value}\n defaultValue={defaultValue}\n disabled={true}\n />\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 <CloseRounded\n className=\"text-neutral-900 dark:text-black-300 w-xs h-xs\"\n />\n </IconButton>\n\n <IconButton\n id={`btn-dynamic-data-input-ai-outline-pic-center`}\n onClick={toggleDynamicDataModal}\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-900 dark:text-black-300 w-xs h-xs\"\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 {showDynamicDataModal && DynamicDataModal && (\n <DynamicDataModal\n isVisible={showDynamicDataModal}\n onSelect={(data) => {\n onChange(data);\n setInputValue(data);\n }}\n onClose={toggleDynamicDataModal}\n dataKey={dataKey}\n dataSource={dataSource}\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\nDynamicDataInputField.displayName = \"DynamicDataInputField\";\n\n"],"names":["DynamicDataInputField","forwardRef","id","label","placeholder","value","onChange","errorMessage","defaultValue","required","isRequiredConditional","dataSource","dataKey","tags","tooltip","originalCase","color","isGTN","gtnName","isAiExtracted","confidenceScore","confidenceType","confidenceTooltip","sourceMeta","onConfidenceScoreClick","labelClassName","disabled","isLiveField","onAddGTNToDocument","riskDetails","isRiskAnalysisOpen","RiskDetailsCard","primaryColorShades","_isRecording","_isPlaying","setDisableActions","showDeprecatedFieldWarning","DynamicDataModal","ref","t","useTranslation","isHovered","setIsHovered","useState","inputValue","setInputValue","showDynamicDataModal","setShowDynamicDataModal","inputRef","useRef","combinedRef","toggleDynamicDataModal","handleKeyDown","event","currentRef","handleClear","handleAddGTNToDocument","_value","getClassName","baseClasses","borderColor","placeholderColor","backgroundColor","useEffect","jsxs","cn","jsx","InputLabel","BoltOutlined","shouldShowConfidenceScore","AIExtractedIndicator","Label","Tooltip","HelpIcon","getConfidenceScoreBadgeClass","AIStarIcon","getConfidenceScoreBadgeColor","getConfidenceScoreBadgeFill","getConfidenceScoreBadgeTextColor","AntTooltip","NoteAddOutlined","e","IconButton","CloseRounded","TableChartRounded","Typography","data"],"mappings":";;;;;;;;;;;;;;;AA8KO,MAAMA,KAAwBC;AAAA,EAInC,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,YAAAC;AAAA,IACA,SAAAC;AAAA,IACA,MAAAC;AAAA,IACA,SAAAC,IAAU;AAAA,IACV,cAAAC,IAAe;AAAA,IACf,OAAAC,IAAQ;AAAA,IACR,OAAAC,IAAQ;AAAA,IACR,SAAAC;AAAA,IACA,eAAAC,IAAgB;AAAA,IAChB,iBAAAC;AAAA,IACA,gBAAAC,IAAiB;AAAA,IACjB,mBAAAC;AAAA,IACA,YAAAC,IAAa,CAAA;AAAA,IACb,wBAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,aAAAC,IAAc;AAA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AA;AAAA,kBACC,IAAI;AAAA,kBACJ,SAAS/B;AAAA,kBACT,WAAU;AAAA,kBACV,SAAQ;AAAA,kBACR,UAAAzB;AAAA,kBAEA,UAAA,gBAAAwC;AAAA,oBAACkB;AAAA,oBAAA;AAAA,sBACC,WAAU;AAAA,oBAAA;AAAA,kBAAA;AAAA,gBACZ;AAAA,cAAA;AAAA,YACF,GACF;AAAA,YAEC7E,KACC,gBAAA2D;AAAA,cAACmB;AAAA,cAAA;AAAA,gBACC,WAAU;AAAA,gBACV,YAAW;AAAA,gBACX,MAAK;AAAA,gBACL,SAAQ;AAAA,gBAEP,UAAA9E;AAAA,cAAA;AAAA,YAAA;AAAA,YAIJuC,KAAwBT,KACvB,gBAAA6B;AAAA,cAAC7B;AAAA,cAAA;AAAA,gBACC,WAAWS;AAAA,gBACX,UAAU,CAACwC,MAAS;AAClB,kBAAAhF,EAASgF,CAAI,GACbzC,EAAcyC,CAAI;AAAA,gBACpB;AAAA,gBACA,SAASnC;AAAA,gBACT,SAAAvC;AAAA,gBACA,YAAAD;AAAA,cAAA;AAAA,YAAA;AAAA,UACF,GAEJ;AAAA,UAEC8B,KACCZ,KACAC,KACAC,KACE,gBAAAmC;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,YACZvC,EAAa,EAAK;AAAA,cAEtB;AAAA,cAEA,UAAA,gBAAAwB,EAACnC,KAAgB,aAAAF,EAAA,CAA0B;AAAA,YAAA;AAAA,UAAA;AAAA,QAC7C;AAAA,MAAA;AAAA,IAAA;AAAA,EAIV;AACF;AAEA7B,GAAsB,cAAc;"}
1
+ {"version":3,"file":"DynamicDataInputField.es.js","sources":["../../../../src/components/forms/dynamic-data-input/DynamicDataInputField.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 { BoltOutlined, CloseRounded, NoteAddOutlined, TableChartRounded } 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\";\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 DynamicDataModal component\n */\nexport interface DynamicDataModalProps {\n isVisible: boolean;\n onSelect: (data: string | number | readonly string[] | undefined) => void;\n onClose: () => void;\n dataKey: string;\n dataSource: string;\n}\n\n/**\n * Props for the DynamicDataInputField component\n */\nexport interface DynamicDataInputFieldProps {\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 /** Color for the input text */\n color?: string;\n /** Current value of the input */\n value: string | number | readonly string[] | undefined;\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 /** Tags/labels to display next to the label */\n tags?: (string | LabelType)[];\n /** Error message to display below the input */\n errorMessage?: string;\n /** Default value for the input */\n defaultValue?: string | number | readonly string[] | undefined;\n /** Data source for dynamic data */\n dataSource: string;\n /** Data key for dynamic data */\n dataKey: string;\n /** Tooltip text for the help icon */\n tooltip?: string;\n /** Whether this is a GTN (Global Term Name) field */\n isGTN?: boolean;\n /** GTN field name for document integration */\n gtnName?: 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 the input is disabled */\n disabled?: boolean;\n /** Callback function called when value changes */\n onChange: (value: string | number | readonly string[] | undefined) => void;\n /** Additional CSS classes for the label */\n labelClassName?: string;\n /** Whether this is a live field */\n isLiveField?: boolean;\n /** Whether to preserve original case in the label */\n originalCase?: boolean;\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 /** Whether recording is active (for pilot context) */\n isRecording?: boolean;\n /** Whether playback is active (for pilot context) */\n isPlaying?: boolean;\n /** Callback to set disable actions state */\n setDisableActions?: (disabled: boolean) => void;\n /** Toast function for deprecated field warning */\n showDeprecatedFieldWarning?: () => void;\n /** Dynamic data modal component */\n DynamicDataModal?: React.ComponentType<DynamicDataModalProps>;\n}\n\n/**\n * A highly customizable dynamic data input component with label, validation, and styling support.\n * Features dynamic data modal integration, GTN support, risk analysis support,\n * and comprehensive prop support for various use cases.\n *\n * @example\n * ```tsx\n * <DynamicDataInputField\n * id=\"dynamic-field\"\n * label=\"Dynamic Field\"\n * value={fieldValue}\n * onChange={(value) => setFieldValue(value)}\n * dataSource=\"sourceTable\"\n * dataKey=\"fieldKey\"\n * required\n * />\n * ```\n */\nexport const DynamicDataInputField = forwardRef<\n HTMLInputElement,\n DynamicDataInputFieldProps\n>(\n (\n {\n id,\n label,\n placeholder,\n value,\n onChange,\n errorMessage,\n defaultValue,\n required = false,\n isRequiredConditional = false,\n dataSource,\n dataKey,\n tags,\n tooltip = \"\",\n originalCase = false,\n color = \"\",\n isGTN = false,\n gtnName,\n isAiExtracted = false,\n confidenceScore,\n confidenceType = \"high\",\n confidenceTooltip,\n sourceMeta = [],\n onConfidenceScoreClick,\n labelClassName,\n disabled = false,\n isLiveField = false,\n onAddGTNToDocument,\n riskDetails,\n isRiskAnalysisOpen = false,\n RiskDetailsCard,\n primaryColorShades,\n isRecording: _isRecording = false,\n isPlaying: _isPlaying = false,\n setDisableActions,\n showDeprecatedFieldWarning,\n DynamicDataModal,\n },\n ref\n ) => {\n const { t } = useTranslation();\n const [isHovered, setIsHovered] = useState(false);\n const [inputValue, setInputValue] = useState<\n string | number | readonly string[] | undefined\n >(value);\n const [showDynamicDataModal, setShowDynamicDataModal] = 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 const toggleDynamicDataModal = () => {\n if (showDynamicDataModal) {\n setDisableActions?.(false);\n } else {\n setDisableActions?.(true);\n }\n setShowDynamicDataModal(!showDynamicDataModal);\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 if (inputValue !== null) {\n onChange(inputValue);\n }\n setInputValue(inputValue);\n currentRef.blur();\n }\n }\n };\n\n const handleClear = () => {\n setInputValue(\"\");\n onChange(\"\");\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 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 : \"bg-gray-200 dark:bg-black-600 \"\n } ${color ? color : \"text-neutral-900 dark:text-black-200\"}`;\n\n return `${baseClasses} ${borderColor} ${backgroundColor} ${placeholderColor}`;\n };\n\n useEffect(() => {\n if (showDynamicDataModal && !dataSource) {\n showDeprecatedFieldWarning?.();\n setShowDynamicDataModal(false);\n }\n }, [showDynamicDataModal, dataSource, showDeprecatedFieldWarning]);\n\n // Sync inputValue with value prop\n useEffect(() => {\n setInputValue(value);\n }, [value]);\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 bg-primary-50 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 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-dynamic-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 <input\n id={id}\n ref={combinedRef}\n required={required}\n placeholder={placeholder}\n className={getClassName()}\n onChange={(e) => {\n onChange(e.target.value);\n setInputValue(e.target?.value);\n }}\n onKeyDown={handleKeyDown}\n value={inputValue !== null ? inputValue : value}\n defaultValue={defaultValue}\n disabled={true}\n />\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 <CloseRounded\n className=\"text-neutral-900 dark:text-black-300 w-xs h-xs\"\n />\n </IconButton>\n\n <IconButton\n id={`btn-dynamic-data-input-ai-outline-pic-center`}\n onClick={toggleDynamicDataModal}\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-900 dark:text-black-300 w-xs h-xs\"\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 {showDynamicDataModal && DynamicDataModal && (\n <DynamicDataModal\n isVisible={showDynamicDataModal}\n onSelect={(data) => {\n onChange(data);\n setInputValue(data);\n }}\n onClose={toggleDynamicDataModal}\n dataKey={dataKey}\n dataSource={dataSource}\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\nDynamicDataInputField.displayName = \"DynamicDataInputField\";\n\n"],"names":["DynamicDataInputField","forwardRef","id","label","placeholder","value","onChange","errorMessage","defaultValue","required","isRequiredConditional","dataSource","dataKey","tags","tooltip","originalCase","color","isGTN","gtnName","isAiExtracted","confidenceScore","confidenceType","confidenceTooltip","sourceMeta","onConfidenceScoreClick","labelClassName","disabled","isLiveField","onAddGTNToDocument","riskDetails","isRiskAnalysisOpen","RiskDetailsCard","primaryColorShades","_isRecording","_isPlaying","setDisableActions","showDeprecatedFieldWarning","DynamicDataModal","ref","t","useTranslation","isHovered","setIsHovered","useState","inputValue","setInputValue","showDynamicDataModal","setShowDynamicDataModal","inputRef","useRef","combinedRef","toggleDynamicDataModal","handleKeyDown","event","currentRef","handleClear","handleAddGTNToDocument","_value","getClassName","baseClasses","borderColor","placeholderColor","backgroundColor","useEffect","jsxs","cn","jsx","InputLabel","BoltOutlined","shouldShowConfidenceScore","AIExtractedIndicator","Label","Tooltip","HelpIcon","getConfidenceScoreBadgeClass","AIStarIcon","getConfidenceScoreBadgeColor","getConfidenceScoreBadgeFill","getConfidenceScoreBadgeTextColor","AntTooltip","NoteAddOutlined","e","IconButton","CloseRounded","TableChartRounded","Typography","data"],"mappings":";;;;;;;;;;;;;;;AA8KO,MAAMA,KAAwBC;AAAA,EAInC,CACE;AAAA,IACE,IAAAC;AAAA,IACA,OAAAC;AAAA,IACA,aAAAC;AAAA,IACA,OAAAC;AAAA,IACA,UAAAC;AAAA,IACA,cAAAC;AAAA,IACA,cAAAC;AAAA,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ACL,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,YACZvC,EAAa,EAAK;AAAA,cAEtB;AAAA,cAEA,UAAA,gBAAAwB,EAACnC,KAAgB,aAAAF,EAAA,CAA0B;AAAA,YAAA;AAAA,UAAA;AAAA,QAC7C;AAAA,MAAA;AAAA,IAAA;AAAA,EAIV;AACF;AAEA7B,GAAsB,cAAc;"}
@@ -1,2 +1,2 @@
1
- "use strict";const s=require("react/jsx-runtime"),F=require("../../../_virtual/index.cjs.js"),e=require("react"),ee=require("react-contenteditable"),te=require("react-dom"),z=require("@mui/icons-material"),B=require("../../data-display/typography/Typography.cjs.js"),re=require("../../button/IconButton.cjs.js"),se=require("../../tooltip/Tooltip.cjs.js"),ne=require("../../icons/HelpIcon.cjs.js"),oe=require("../../../hooks/useOutsideClick.cjs.js"),I=require("./utils.cjs.js"),ae=require("../shared/InputLabel.cjs.js"),ce=require("../../../node_modules/@popperjs/core/lib/popper.cjs.js"),le=({value:u="",onChange:b,onFocus:q,onBlur:T,label:v,id:L,required:M,tooltip:D,placeholder:K,disabled:p,errorMessage:y,width:H="100%",suggestions:S=[],showRawValue:U=!1})=>{const c=e.useRef(null),R=e.useRef(null),m=e.useRef(null),j=e.useRef([]),g=e.useRef(null),[a,f]=e.useState(!1),[C,A]=e.useState(""),[d,w]=e.useState(0),[x,$]=e.useState(U),E=e.useRef(a),N=e.useRef([]),V=e.useRef(d),P=e.useRef(u);e.useEffect(()=>{E.current=a},[a]),e.useEffect(()=>{V.current=d},[d]),e.useEffect(()=>{P.current=u},[u]),oe.useOutsideClick({ref:m,handler:()=>{a&&f(!1)}});const h=e.useMemo(()=>{if(!C)return S;const t=C.toLowerCase();return S.filter(r=>r.toLowerCase().includes(t))},[S,C]);e.useEffect(()=>{N.current=h},[h]),e.useEffect(()=>{w(0)},[h]),e.useEffect(()=>{a&&j.current[d]&&j.current[d]?.scrollIntoView({block:"nearest",behavior:"smooth"})},[d,a]),e.useEffect(()=>{if(a&&R.current&&m.current)return g.current=ce.createPopper(R.current,m.current,{placement:"bottom-start",strategy:"fixed",modifiers:[{name:"flip",options:{fallbackPlacements:["top-start","bottom-start"]}},{name:"preventOverflow",options:{boundary:"viewport",padding:8}},{name:"offset",options:{offset:[0,4]}}]}),()=>{g.current&&(g.current.destroy(),g.current=null)}},[a]);const W=e.useCallback(t=>{const r=I.convertFromPills(t.target.value);b(r);const n=I.getTextBeforeCursor(),l=n.lastIndexOf("@");if(l!==-1){const i=n.slice(l+1);i.includes(" ")?f(!1):(A(i),f(!0))}else f(!1)},[b]),G=e.useCallback(()=>{c.current&&(c.current.isFocused=!0),q?.()},[q]),J=e.useCallback(t=>{c.current&&(c.current.isFocused=!1);const r=t.relatedTarget;r&&m.current?.contains(r)||(setTimeout(()=>{f(!1)},200),T?.())},[T]),k=e.useCallback(t=>{if(!c.current)return;const r=P.current,n=r.lastIndexOf("@");if(n!==-1){const i=r.slice(n+1).search(/\s/);let o;i===-1?o=r.length:o=n+1+i;const Y=r.slice(0,n),Z=r.slice(o),_=`${Y}{{${t}}}${Z}`;b(_),f(!1),A(""),setTimeout(()=>{c.current?.focus()},0)}},[b]),O=e.useCallback(t=>{const r=E.current,n=N.current,l=V.current;if(t.key==="Enter"){t.preventDefault(),t.stopPropagation(),r&&n.length>0&&n[l]&&k(n[l]);return}if(r&&n.length>0){const{key:i}=t;if(["ArrowDown","ArrowUp","Escape","Tab"].includes(i))switch(t.preventDefault(),t.stopPropagation(),i){case"ArrowDown":w(o=>o<n.length-1?o+1:o);break;case"ArrowUp":w(o=>o>0?o-1:0);break;case"Escape":f(!1);break;case"Tab":n[l]&&k(n[l]);break}}},[k]),Q=e.useCallback(t=>{t.preventDefault();const r=t.clipboardData.getData("text/plain");document.execCommand("insertText",!1,r)},[]),X=e.useMemo(()=>x?u:I.convertToPills(u),[u,x]);return s.jsxs("div",{className:"w-full",children:[v&&s.jsxs("div",{className:"text-xs font-medium text-gray-600 inline-flex items-center gap-1 font-inter text-left whitespace-nowrap flex-wrap",children:[s.jsx(ae.InputLabel,{label:v||"",required:M||!1}),D&&s.jsx(se,{placement:"top",title:D,children:s.jsx("div",{className:"cursor-pointer",children:s.jsx(ne.HelpIcon,{})})})]}),s.jsxs("div",{className:"relative",ref:R,children:[u?.trim()?null:s.jsx("div",{className:"absolute top-0 left-0 w-full h-full text-gray-400 flex items-center cursor-text px-3 z-50",onClick:()=>c.current?.focus(),children:s.jsx(B.Typography,{size:"extra-small",variant:"medium",children:K})}),s.jsxs("div",{className:"relative",children:[s.jsx(ee,{innerRef:c,className:F("min-h-[42px] rounded-lg p-2.5","text-sm font-inter block font-medium border text-gray-900 dark:text-white whitespace-normal break-words text-left",p?"bg-neutral-100 dark:bg-black-800":"bg-white dark:bg-black-800",!p&&"pr-[60px]",y?"!border-error-500":"border-gray-300 dark:border-black-600 focus:ring-blue-500 focus:border-blue-500","cursor-text"),style:{width:H,wordBreak:"break-word"},html:X,onChange:p?()=>null:W,onFocus:G,onBlur:J,onKeyDownCapture:O,onKeyDown:O,onPaste:Q,disabled:p,id:L}),!p&&s.jsx("div",{className:"absolute right-0 top-0 bottom-0 flex items-center align-middle justify-center p-3 gap-2",children:s.jsx(re,{tooltip:x?"Show Formatted":"Show Raw Value",variant:"ghost",onClick:()=>$(!x),children:x?s.jsx(z.VisibilityOutlined,{sx:{fontSize:18}}):s.jsx(z.VisibilityOffOutlined,{sx:{fontSize:18}})})})]}),a&&h.length>0&&te.createPortal(s.jsx("div",{ref:m,className:"z-[3000] bg-white dark:bg-black-800 border border-gray-300 dark:border-black-600 rounded-lg shadow-lg max-h-60 overflow-y-auto min-w-[200px]",onMouseDown:t=>{t.preventDefault()},children:h.map((t,r)=>s.jsx("div",{ref:n=>j.current[r]=n,className:F("px-3 py-2 cursor-pointer text-sm font-inter",r===d?"bg-primary-100 dark:bg-primary-900 text-primary-700 dark:text-primary-300":"hover:bg-gray-100 dark:hover:bg-black-700 text-gray-900 dark:text-white"),onClick:()=>k(t),onMouseEnter:()=>w(r),children:t},t))}),document.body)]}),y&&s.jsx("div",{className:"pt-1",children:s.jsx(B.Typography,{className:"text-error-500",size:"extra-small",variant:"medium",appearance:"custom",children:y})})]})},ie=e.memo(le);module.exports=ie;
1
+ "use strict";const s=require("react/jsx-runtime"),F=require("../../../_virtual/index.cjs.js"),e=require("react"),ee=require("react-contenteditable"),te=require("react-dom"),z=require("@mui/icons-material"),B=require("../../data-display/typography/Typography.cjs.js"),re=require("../../button/IconButton.cjs.js"),se=require("../../tooltip/Tooltip.cjs.js"),ne=require("../../icons/HelpIcon.cjs.js"),oe=require("../../../hooks/useOutsideClick.cjs.js"),I=require("./utils.cjs.js"),ae=require("../shared/InputLabel.cjs.js"),ce=require("../../../node_modules/@popperjs/core/lib/popper.cjs.js"),le=({value:u="",onChange:b,onFocus:q,onBlur:T,label:v,id:L,required:M,tooltip:D,placeholder:K,disabled:p,errorMessage:y,width:H="100%",suggestions:S=[],showRawValue:U=!1})=>{const c=e.useRef(null),R=e.useRef(null),m=e.useRef(null),j=e.useRef([]),g=e.useRef(null),[a,f]=e.useState(!1),[C,N]=e.useState(""),[d,w]=e.useState(0),[x,$]=e.useState(U),A=e.useRef(a),E=e.useRef([]),V=e.useRef(d),P=e.useRef(u);e.useEffect(()=>{A.current=a},[a]),e.useEffect(()=>{V.current=d},[d]),e.useEffect(()=>{P.current=u},[u]),oe.useOutsideClick({ref:m,handler:()=>{a&&f(!1)}});const h=e.useMemo(()=>{if(!C)return S;const t=C.toLowerCase();return S.filter(r=>r.toLowerCase().includes(t))},[S,C]);e.useEffect(()=>{E.current=h},[h]),e.useEffect(()=>{w(0)},[h]),e.useEffect(()=>{a&&j.current[d]&&j.current[d]?.scrollIntoView({block:"nearest",behavior:"smooth"})},[d,a]),e.useEffect(()=>{if(a&&R.current&&m.current)return g.current=ce.createPopper(R.current,m.current,{placement:"bottom-start",strategy:"fixed",modifiers:[{name:"flip",options:{fallbackPlacements:["top-start","bottom-start"]}},{name:"preventOverflow",options:{boundary:"viewport",padding:8}},{name:"offset",options:{offset:[0,4]}}]}),()=>{g.current&&(g.current.destroy(),g.current=null)}},[a]);const W=e.useCallback(t=>{const r=I.convertFromPills(t.target.value);b(r);const n=I.getTextBeforeCursor(),l=n.lastIndexOf("@");if(l!==-1){const i=n.slice(l+1);i.includes(" ")?f(!1):(N(i),f(!0))}else f(!1)},[b]),G=e.useCallback(()=>{c.current&&(c.current.isFocused=!0),q?.()},[q]),J=e.useCallback(t=>{c.current&&(c.current.isFocused=!1);const r=t.relatedTarget;r&&m.current?.contains(r)||(setTimeout(()=>{f(!1)},200),T?.())},[T]),k=e.useCallback(t=>{if(!c.current)return;const r=P.current,n=r.lastIndexOf("@");if(n!==-1){const i=r.slice(n+1).search(/\s/);let o;i===-1?o=r.length:o=n+1+i;const Y=r.slice(0,n),Z=r.slice(o),_=`${Y}{{${t}}}${Z}`;b(_),f(!1),N(""),setTimeout(()=>{c.current?.focus()},0)}},[b]),O=e.useCallback(t=>{const r=A.current,n=E.current,l=V.current;if(t.key==="Enter"){t.preventDefault(),t.stopPropagation(),r&&n.length>0&&n[l]&&k(n[l]);return}if(r&&n.length>0){const{key:i}=t;if(["ArrowDown","ArrowUp","Escape","Tab"].includes(i))switch(t.preventDefault(),t.stopPropagation(),i){case"ArrowDown":w(o=>o<n.length-1?o+1:o);break;case"ArrowUp":w(o=>o>0?o-1:0);break;case"Escape":f(!1);break;case"Tab":n[l]&&k(n[l]);break}}},[k]),Q=e.useCallback(t=>{t.preventDefault();const r=t.clipboardData.getData("text/plain");document.execCommand("insertText",!1,r)},[]),X=e.useMemo(()=>x?u:I.convertToPills(u),[u,x]);return s.jsxs("div",{className:"w-full",children:[v&&s.jsxs("div",{className:"text-xs font-medium text-gray-600 inline-flex items-center gap-1 font-inter text-left whitespace-nowrap flex-wrap",children:[s.jsx(ae.InputLabel,{label:v||"",required:M||!1}),D&&s.jsx(se,{placement:"top",title:D,children:s.jsx("div",{className:"cursor-pointer",children:s.jsx(ne.HelpIcon,{className:"w-icon-sm h-icon-sm"})})})]}),s.jsxs("div",{className:"relative",ref:R,children:[u?.trim()?null:s.jsx("div",{className:"absolute top-0 left-0 w-full h-full text-gray-400 flex items-center cursor-text px-3 z-50",onClick:()=>c.current?.focus(),children:s.jsx(B.Typography,{size:"extra-small",variant:"medium",children:K})}),s.jsxs("div",{className:"relative",children:[s.jsx(ee,{innerRef:c,className:F("min-h-[42px] rounded-lg p-2.5","text-sm font-inter block font-medium border text-gray-900 dark:text-white whitespace-normal break-words text-left",p?"bg-neutral-100 dark:bg-black-800":"bg-white dark:bg-black-800",!p&&"pr-[60px]",y?"!border-error-500":"border-gray-300 dark:border-black-600 focus:ring-blue-500 focus:border-blue-500","cursor-text"),style:{width:H,wordBreak:"break-word"},html:X,onChange:p?()=>null:W,onFocus:G,onBlur:J,onKeyDownCapture:O,onKeyDown:O,onPaste:Q,disabled:p,id:L}),!p&&s.jsx("div",{className:"absolute right-0 top-0 bottom-0 flex items-center align-middle justify-center p-3 gap-2",children:s.jsx(re,{tooltip:x?"Show Formatted":"Show Raw Value",variant:"ghost",onClick:()=>$(!x),children:x?s.jsx(z.VisibilityOutlined,{sx:{fontSize:18}}):s.jsx(z.VisibilityOffOutlined,{sx:{fontSize:18}})})})]}),a&&h.length>0&&te.createPortal(s.jsx("div",{ref:m,className:"z-[3000] bg-white dark:bg-black-800 border border-gray-300 dark:border-black-600 rounded-lg shadow-lg max-h-60 overflow-y-auto min-w-[200px]",onMouseDown:t=>{t.preventDefault()},children:h.map((t,r)=>s.jsx("div",{ref:n=>j.current[r]=n,className:F("px-3 py-2 cursor-pointer text-sm font-inter",r===d?"bg-primary-100 dark:bg-primary-900 text-primary-700 dark:text-primary-300":"hover:bg-gray-100 dark:hover:bg-black-700 text-gray-900 dark:text-white"),onClick:()=>k(t),onMouseEnter:()=>w(r),children:t},t))}),document.body)]}),y&&s.jsx("div",{className:"pt-1",children:s.jsx(B.Typography,{className:"text-error-500",size:"extra-small",variant:"medium",appearance:"custom",children:y})})]})},ie=e.memo(le);module.exports=ie;
2
2
  //# sourceMappingURL=FormulaInput.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FormulaInput.cjs.js","sources":["../../../../src/components/forms/formula-input/FormulaInput.tsx"],"sourcesContent":["import { Instance as PopperInstance, createPopper } from '@popperjs/core';\nimport cn from 'classnames';\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport ContentEditable, { ContentEditableEvent } from 'react-contenteditable';\nimport { createPortal } from 'react-dom';\nimport { VisibilityOffOutlined, VisibilityOutlined } from '@mui/icons-material';\n\nimport { Typography } from '../../data-display/typography/Typography';\nimport IconButton from '../../button/IconButton';\nimport Tooltip from '../../tooltip/Tooltip';\nimport { HelpIcon } from '../../icons/HelpIcon';\nimport { useOutsideClick } from '../../../hooks/useOutsideClick';\nimport { convertFromPills, convertToPills, getTextBeforeCursor } from './utils';\nimport { InputLabel } from '../shared/InputLabel';\n\nexport interface FormulaInputProps {\n /** Current value of the input */\n value: string;\n /** Callback when value changes */\n onChange: (value: string) => void;\n /** Callback when input receives focus */\n onFocus?: () => void;\n /** Callback when input loses focus */\n onBlur?: () => void;\n /** Label for the input field */\n label?: string;\n /** Unique identifier for the input */\n id: string;\n /** Whether the field is required */\n required?: boolean;\n /** Tooltip text displayed next to the label */\n tooltip?: string;\n /** Placeholder text */\n placeholder?: string;\n /** Whether the input is disabled */\n disabled?: boolean;\n /** Error message to display */\n errorMessage?: string;\n /** Width of the input */\n width?: string;\n /** List of suggestions for autocomplete */\n suggestions?: string[];\n /** Whether to show the raw value instead of pills */\n showRawValue?: boolean;\n}\n\n/**\n * FormulaInput component for entering formulas with variable suggestions\n * Variables are displayed as pills and can be inserted using @ trigger\n */\nconst FormulaInput: React.FC<FormulaInputProps> = ({\n value = '',\n onChange,\n onFocus,\n onBlur,\n label,\n id,\n required: isRequired,\n tooltip,\n placeholder,\n disabled,\n errorMessage,\n width = '100%',\n suggestions = [],\n showRawValue: showRawValueProp = false,\n}) => {\n const contentRef = useRef<HTMLElement & { isFocused?: boolean }>(null);\n const inputWrapperRef = useRef<HTMLDivElement>(null);\n const suggestionMenuRef = useRef<HTMLDivElement>(null);\n const suggestionRefs = useRef<(HTMLDivElement | null)[]>([]);\n const popperInstanceRef = useRef<PopperInstance | null>(null);\n const [showSuggestions, setShowSuggestions] = useState(false);\n const [searchTerm, setSearchTerm] = useState('');\n const [selectedIndex, setSelectedIndex] = useState(0);\n const [showRawValue, setShowRawValue] = useState(showRawValueProp);\n\n // Use refs to track current state for event handlers\n const showSuggestionsRef = useRef(showSuggestions);\n const filteredSuggestionsRef = useRef<string[]>([]);\n const selectedIndexRef = useRef(selectedIndex);\n const valueRef = useRef(value);\n\n // Keep refs in sync with state\n useEffect(() => {\n showSuggestionsRef.current = showSuggestions;\n }, [showSuggestions]);\n\n useEffect(() => {\n selectedIndexRef.current = selectedIndex;\n }, [selectedIndex]);\n\n useEffect(() => {\n valueRef.current = value;\n }, [value]);\n\n // Close suggestions when clicking outside\n useOutsideClick({\n ref: suggestionMenuRef,\n handler: () => {\n if (showSuggestions) {\n setShowSuggestions(false);\n }\n },\n });\n\n // Filter suggestions based on search term\n const filteredSuggestions = useMemo(() => {\n if (!searchTerm) return suggestions;\n\n const lowerSearchTerm = searchTerm.toLowerCase();\n return suggestions.filter((suggestion) => suggestion.toLowerCase().includes(lowerSearchTerm));\n }, [suggestions, searchTerm]);\n\n // Keep filtered suggestions ref in sync\n useEffect(() => {\n filteredSuggestionsRef.current = filteredSuggestions;\n }, [filteredSuggestions]);\n\n // Reset selected index when filtered suggestions change\n useEffect(() => {\n setSelectedIndex(0);\n }, [filteredSuggestions]);\n\n // Scroll selected suggestion into view\n useEffect(() => {\n if (showSuggestions && suggestionRefs.current[selectedIndex]) {\n suggestionRefs.current[selectedIndex]?.scrollIntoView({\n block: 'nearest',\n behavior: 'smooth',\n });\n }\n }, [selectedIndex, showSuggestions]);\n\n // Setup Popper for dynamic positioning\n useEffect(() => {\n if (showSuggestions && inputWrapperRef.current && suggestionMenuRef.current) {\n // Create popper instance with auto placement\n popperInstanceRef.current = createPopper(inputWrapperRef.current, suggestionMenuRef.current, {\n placement: 'bottom-start',\n strategy: 'fixed',\n modifiers: [\n {\n name: 'flip',\n options: {\n fallbackPlacements: ['top-start', 'bottom-start'],\n },\n },\n {\n name: 'preventOverflow',\n options: {\n boundary: 'viewport',\n padding: 8,\n },\n },\n {\n name: 'offset',\n options: {\n offset: [0, 4],\n },\n },\n ],\n });\n\n return () => {\n if (popperInstanceRef.current) {\n popperInstanceRef.current.destroy();\n popperInstanceRef.current = null;\n }\n };\n }\n }, [showSuggestions]);\n\n const handleChange = useCallback(\n (event: ContentEditableEvent) => {\n const rawValue = convertFromPills(event.target.value);\n onChange(rawValue);\n\n // Check if user typed @ (trigger for suggestions)\n const textBeforeCursor = getTextBeforeCursor();\n const lastAtSymbol = textBeforeCursor.lastIndexOf('@');\n\n if (lastAtSymbol !== -1) {\n // Get text after the @ symbol\n const textAfterAt = textBeforeCursor.slice(lastAtSymbol + 1);\n\n // Check if there's a space after @, which would end the suggestion context\n const hasSpace = textAfterAt.includes(' ');\n\n if (!hasSpace) {\n // We're in suggestion mode - show suggestions filtered by text after @\n setSearchTerm(textAfterAt);\n setShowSuggestions(true);\n } else {\n setShowSuggestions(false);\n }\n } else {\n setShowSuggestions(false);\n }\n },\n [onChange],\n );\n\n const handleFocus = useCallback(() => {\n if (contentRef.current) {\n contentRef.current.isFocused = true;\n }\n onFocus?.();\n }, [onFocus]);\n\n const handleBlur = useCallback(\n (event: React.FocusEvent) => {\n if (contentRef.current) {\n contentRef.current.isFocused = false;\n }\n\n // Check if the blur is due to clicking on a suggestion\n const relatedTarget = event.relatedTarget as HTMLElement;\n if (relatedTarget && suggestionMenuRef.current?.contains(relatedTarget)) {\n // Don't close suggestions if clicking on a suggestion\n return;\n }\n\n // Delay closing suggestions to allow click events to register\n setTimeout(() => {\n setShowSuggestions(false);\n }, 200);\n onBlur?.();\n },\n [onBlur],\n );\n\n const insertSuggestion = useCallback(\n (suggestion: string) => {\n if (!contentRef.current) return;\n\n // IMPORTANT: Use the value prop (not innerText) to preserve existing {{}} syntax\n // innerText only shows display text and loses the {{}} markers from pills\n const currentValue = valueRef.current;\n\n // Find the last occurrence of @ (trigger symbol) in the raw value\n const lastAtSymbol = currentValue.lastIndexOf('@');\n\n if (lastAtSymbol !== -1) {\n // Find where the @ trigger ends (space or end of string)\n const afterAt = currentValue.slice(lastAtSymbol + 1);\n const spaceIndex = afterAt.search(/\\s/);\n\n let endPosition: number;\n if (spaceIndex === -1) {\n // No space found, the incomplete variable goes to the end\n endPosition = currentValue.length;\n } else {\n // Space found, replace up to the space\n endPosition = lastAtSymbol + 1 + spaceIndex;\n }\n\n // Build the new value preserving all existing {{}} syntax\n // Replace @searchTerm with {{suggestion}}\n const beforeAt = currentValue.slice(0, lastAtSymbol);\n const afterCursor = currentValue.slice(endPosition);\n const newValue = `${beforeAt}{{${suggestion}}}${afterCursor}`;\n\n // Update through onChange\n onChange(newValue);\n\n // Close suggestions\n setShowSuggestions(false);\n setSearchTerm('');\n\n // Refocus the input after React updates\n setTimeout(() => {\n contentRef.current?.focus();\n }, 0);\n }\n },\n [onChange],\n );\n\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n // Use refs to get the latest state values to avoid stale closures\n const isShowingSuggestions = showSuggestionsRef.current;\n const currentFilteredSuggestions = filteredSuggestionsRef.current;\n const currentSelectedIndex = selectedIndexRef.current;\n\n // Always prevent Enter key to avoid creating new lines/divs\n if (event.key === 'Enter') {\n event.preventDefault();\n event.stopPropagation();\n\n // If suggestions are showing, select the current suggestion\n if (isShowingSuggestions && currentFilteredSuggestions.length > 0 && currentFilteredSuggestions[currentSelectedIndex]) {\n insertSuggestion(currentFilteredSuggestions[currentSelectedIndex]);\n }\n return;\n }\n\n // When suggestions are visible, intercept navigation keys immediately\n if (isShowingSuggestions && currentFilteredSuggestions.length > 0) {\n const { key } = event;\n\n // Prevent default for all navigation keys when suggestions are shown\n if (['ArrowDown', 'ArrowUp', 'Escape', 'Tab'].includes(key)) {\n event.preventDefault();\n event.stopPropagation();\n\n switch (key) {\n case 'ArrowDown':\n setSelectedIndex((prev) => (prev < currentFilteredSuggestions.length - 1 ? prev + 1 : prev));\n break;\n case 'ArrowUp':\n setSelectedIndex((prev) => (prev > 0 ? prev - 1 : 0));\n break;\n case 'Escape':\n setShowSuggestions(false);\n break;\n case 'Tab':\n if (currentFilteredSuggestions[currentSelectedIndex]) {\n insertSuggestion(currentFilteredSuggestions[currentSelectedIndex]);\n }\n break;\n }\n }\n }\n },\n [insertSuggestion],\n );\n\n const handlePaste = useCallback((event: React.ClipboardEvent<HTMLDivElement>) => {\n event.preventDefault();\n const text = event.clipboardData.getData('text/plain');\n document.execCommand('insertText', false, text);\n }, []);\n\n const displayValue = useMemo(() => {\n if (showRawValue) {\n return value;\n }\n return convertToPills(value);\n }, [value, showRawValue]);\n\n return (\n <div className='w-full'>\n {label && (\n <div className='text-xs font-medium text-gray-600 inline-flex items-center gap-1 font-inter text-left whitespace-nowrap flex-wrap'>\n <InputLabel label={label || \"\"} required={isRequired || false} />\n {tooltip && (\n <Tooltip placement='top' title={tooltip}>\n <div className='cursor-pointer'>\n <HelpIcon />\n </div>\n </Tooltip>\n )}\n </div>\n )}\n\n <div className='relative' ref={inputWrapperRef}>\n {!value?.trim() ? (\n <div\n className='absolute top-0 left-0 w-full h-full text-gray-400 flex items-center cursor-text px-3 z-50'\n onClick={() => contentRef.current?.focus()}\n >\n <Typography size='extra-small' variant='medium'>\n {placeholder}\n </Typography>\n </div>\n ) : null}\n\n <div className='relative'>\n <ContentEditable\n innerRef={contentRef}\n className={cn(\n 'min-h-[42px] rounded-lg p-2.5',\n 'text-sm font-inter block font-medium border text-gray-900 dark:text-white whitespace-normal break-words text-left',\n disabled ? 'bg-neutral-100 dark:bg-black-800' : 'bg-white dark:bg-black-800',\n !disabled && 'pr-[60px]',\n errorMessage ? '!border-error-500' : 'border-gray-300 dark:border-black-600 focus:ring-blue-500 focus:border-blue-500',\n 'cursor-text',\n )}\n style={{\n width: width,\n wordBreak: 'break-word',\n }}\n html={displayValue}\n onChange={!disabled ? handleChange : () => null}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDownCapture={handleKeyDown}\n onKeyDown={handleKeyDown}\n onPaste={handlePaste}\n disabled={disabled}\n id={id}\n />\n\n {!disabled && (\n <div className='absolute right-0 top-0 bottom-0 flex items-center align-middle justify-center p-3 gap-2'>\n <IconButton tooltip={showRawValue ? 'Show Formatted' : 'Show Raw Value'} variant='ghost' onClick={() => setShowRawValue(!showRawValue)}>\n {showRawValue ? <VisibilityOutlined sx={{ fontSize: 18 }} /> : <VisibilityOffOutlined sx={{ fontSize: 18 }} />}\n </IconButton>\n </div>\n )}\n </div>\n\n {showSuggestions &&\n filteredSuggestions.length > 0 &&\n createPortal(\n <div\n ref={suggestionMenuRef}\n className='z-[3000] bg-white dark:bg-black-800 border border-gray-300 dark:border-black-600 rounded-lg shadow-lg max-h-60 overflow-y-auto min-w-[200px]'\n onMouseDown={(e) => {\n // Prevent blur when clicking on suggestions\n e.preventDefault();\n }}\n >\n {filteredSuggestions.map((suggestion, index) => (\n <div\n key={suggestion}\n ref={(el) => (suggestionRefs.current[index] = el)}\n className={cn(\n 'px-3 py-2 cursor-pointer text-sm font-inter',\n index === selectedIndex\n ? 'bg-primary-100 dark:bg-primary-900 text-primary-700 dark:text-primary-300'\n : 'hover:bg-gray-100 dark:hover:bg-black-700 text-gray-900 dark:text-white',\n )}\n onClick={() => insertSuggestion(suggestion)}\n onMouseEnter={() => setSelectedIndex(index)}\n >\n {suggestion}\n </div>\n ))}\n </div>,\n document.body,\n )}\n </div>\n\n {errorMessage && (\n <div className='pt-1'>\n <Typography className='text-error-500' size='extra-small' variant='medium' appearance='custom'>\n {errorMessage}\n </Typography>\n </div>\n )}\n </div>\n );\n};\n\nexport default React.memo(FormulaInput);\n\n\n\n"],"names":["FormulaInput","value","onChange","onFocus","onBlur","label","id","isRequired","tooltip","placeholder","disabled","errorMessage","width","suggestions","showRawValueProp","contentRef","useRef","inputWrapperRef","suggestionMenuRef","suggestionRefs","popperInstanceRef","showSuggestions","setShowSuggestions","useState","searchTerm","setSearchTerm","selectedIndex","setSelectedIndex","showRawValue","setShowRawValue","showSuggestionsRef","filteredSuggestionsRef","selectedIndexRef","valueRef","useEffect","useOutsideClick","filteredSuggestions","useMemo","lowerSearchTerm","suggestion","createPopper","handleChange","useCallback","event","rawValue","convertFromPills","textBeforeCursor","getTextBeforeCursor","lastAtSymbol","textAfterAt","handleFocus","handleBlur","relatedTarget","insertSuggestion","currentValue","spaceIndex","endPosition","beforeAt","afterCursor","newValue","handleKeyDown","isShowingSuggestions","currentFilteredSuggestions","currentSelectedIndex","key","prev","handlePaste","text","displayValue","convertToPills","jsxs","jsx","InputLabel","Tooltip","HelpIcon","Typography","ContentEditable","cn","IconButton","VisibilityOutlined","VisibilityOffOutlined","createPortal","e","index","el","FormulaInput$1","React"],"mappings":"4kBAkDMA,GAA4C,CAAC,CACjD,MAAAC,EAAQ,GACR,SAAAC,EACA,QAAAC,EACA,OAAAC,EACA,MAAAC,EACA,GAAAC,EACA,SAAUC,EACV,QAAAC,EACA,YAAAC,EACA,SAAAC,EACA,aAAAC,EACA,MAAAC,EAAQ,OACR,YAAAC,EAAc,CAAA,EACd,aAAcC,EAAmB,EACnC,IAAM,CACJ,MAAMC,EAAaC,EAAAA,OAA8C,IAAI,EAC/DC,EAAkBD,EAAAA,OAAuB,IAAI,EAC7CE,EAAoBF,EAAAA,OAAuB,IAAI,EAC/CG,EAAiBH,EAAAA,OAAkC,EAAE,EACrDI,EAAoBJ,EAAAA,OAA8B,IAAI,EACtD,CAACK,EAAiBC,CAAkB,EAAIC,EAAAA,SAAS,E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,EAAY"}
1
+ {"version":3,"file":"FormulaInput.cjs.js","sources":["../../../../src/components/forms/formula-input/FormulaInput.tsx"],"sourcesContent":["import { Instance as PopperInstance, createPopper } from '@popperjs/core';\nimport cn from 'classnames';\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport ContentEditable, { ContentEditableEvent } from 'react-contenteditable';\nimport { createPortal } from 'react-dom';\nimport { VisibilityOffOutlined, VisibilityOutlined } from '@mui/icons-material';\n\nimport { Typography } from '../../data-display/typography/Typography';\nimport IconButton from '../../button/IconButton';\nimport Tooltip from '../../tooltip/Tooltip';\nimport { HelpIcon } from '../../icons/HelpIcon';\nimport { useOutsideClick } from '../../../hooks/useOutsideClick';\nimport { convertFromPills, convertToPills, getTextBeforeCursor } from './utils';\nimport { InputLabel } from '../shared/InputLabel';\n\nexport interface FormulaInputProps {\n /** Current value of the input */\n value: string;\n /** Callback when value changes */\n onChange: (value: string) => void;\n /** Callback when input receives focus */\n onFocus?: () => void;\n /** Callback when input loses focus */\n onBlur?: () => void;\n /** Label for the input field */\n label?: string;\n /** Unique identifier for the input */\n id: string;\n /** Whether the field is required */\n required?: boolean;\n /** Tooltip text displayed next to the label */\n tooltip?: string;\n /** Placeholder text */\n placeholder?: string;\n /** Whether the input is disabled */\n disabled?: boolean;\n /** Error message to display */\n errorMessage?: string;\n /** Width of the input */\n width?: string;\n /** List of suggestions for autocomplete */\n suggestions?: string[];\n /** Whether to show the raw value instead of pills */\n showRawValue?: boolean;\n}\n\n/**\n * FormulaInput component for entering formulas with variable suggestions\n * Variables are displayed as pills and can be inserted using @ trigger\n */\nconst FormulaInput: React.FC<FormulaInputProps> = ({\n value = '',\n onChange,\n onFocus,\n onBlur,\n label,\n id,\n required: isRequired,\n tooltip,\n placeholder,\n disabled,\n errorMessage,\n width = '100%',\n suggestions = [],\n showRawValue: showRawValueProp = false,\n}) => {\n const contentRef = useRef<HTMLElement & { isFocused?: boolean }>(null);\n const inputWrapperRef = useRef<HTMLDivElement>(null);\n const suggestionMenuRef = useRef<HTMLDivElement>(null);\n const suggestionRefs = useRef<(HTMLDivElement | null)[]>([]);\n const popperInstanceRef = useRef<PopperInstance | null>(null);\n const [showSuggestions, setShowSuggestions] = useState(false);\n const [searchTerm, setSearchTerm] = useState('');\n const [selectedIndex, setSelectedIndex] = useState(0);\n const [showRawValue, setShowRawValue] = useState(showRawValueProp);\n\n // Use refs to track current state for event handlers\n const showSuggestionsRef = useRef(showSuggestions);\n const filteredSuggestionsRef = useRef<string[]>([]);\n const selectedIndexRef = useRef(selectedIndex);\n const valueRef = useRef(value);\n\n // Keep refs in sync with state\n useEffect(() => {\n showSuggestionsRef.current = showSuggestions;\n }, [showSuggestions]);\n\n useEffect(() => {\n selectedIndexRef.current = selectedIndex;\n }, [selectedIndex]);\n\n useEffect(() => {\n valueRef.current = value;\n }, [value]);\n\n // Close suggestions when clicking outside\n useOutsideClick({\n ref: suggestionMenuRef,\n handler: () => {\n if (showSuggestions) {\n setShowSuggestions(false);\n }\n },\n });\n\n // Filter suggestions based on search term\n const filteredSuggestions = useMemo(() => {\n if (!searchTerm) return suggestions;\n\n const lowerSearchTerm = searchTerm.toLowerCase();\n return suggestions.filter((suggestion) => suggestion.toLowerCase().includes(lowerSearchTerm));\n }, [suggestions, searchTerm]);\n\n // Keep filtered suggestions ref in sync\n useEffect(() => {\n filteredSuggestionsRef.current = filteredSuggestions;\n }, [filteredSuggestions]);\n\n // Reset selected index when filtered suggestions change\n useEffect(() => {\n setSelectedIndex(0);\n }, [filteredSuggestions]);\n\n // Scroll selected suggestion into view\n useEffect(() => {\n if (showSuggestions && suggestionRefs.current[selectedIndex]) {\n suggestionRefs.current[selectedIndex]?.scrollIntoView({\n block: 'nearest',\n behavior: 'smooth',\n });\n }\n }, [selectedIndex, showSuggestions]);\n\n // Setup Popper for dynamic positioning\n useEffect(() => {\n if (showSuggestions && inputWrapperRef.current && suggestionMenuRef.current) {\n // Create popper instance with auto placement\n popperInstanceRef.current = createPopper(inputWrapperRef.current, suggestionMenuRef.current, {\n placement: 'bottom-start',\n strategy: 'fixed',\n modifiers: [\n {\n name: 'flip',\n options: {\n fallbackPlacements: ['top-start', 'bottom-start'],\n },\n },\n {\n name: 'preventOverflow',\n options: {\n boundary: 'viewport',\n padding: 8,\n },\n },\n {\n name: 'offset',\n options: {\n offset: [0, 4],\n },\n },\n ],\n });\n\n return () => {\n if (popperInstanceRef.current) {\n popperInstanceRef.current.destroy();\n popperInstanceRef.current = null;\n }\n };\n }\n }, [showSuggestions]);\n\n const handleChange = useCallback(\n (event: ContentEditableEvent) => {\n const rawValue = convertFromPills(event.target.value);\n onChange(rawValue);\n\n // Check if user typed @ (trigger for suggestions)\n const textBeforeCursor = getTextBeforeCursor();\n const lastAtSymbol = textBeforeCursor.lastIndexOf('@');\n\n if (lastAtSymbol !== -1) {\n // Get text after the @ symbol\n const textAfterAt = textBeforeCursor.slice(lastAtSymbol + 1);\n\n // Check if there's a space after @, which would end the suggestion context\n const hasSpace = textAfterAt.includes(' ');\n\n if (!hasSpace) {\n // We're in suggestion mode - show suggestions filtered by text after @\n setSearchTerm(textAfterAt);\n setShowSuggestions(true);\n } else {\n setShowSuggestions(false);\n }\n } else {\n setShowSuggestions(false);\n }\n },\n [onChange],\n );\n\n const handleFocus = useCallback(() => {\n if (contentRef.current) {\n contentRef.current.isFocused = true;\n }\n onFocus?.();\n }, [onFocus]);\n\n const handleBlur = useCallback(\n (event: React.FocusEvent) => {\n if (contentRef.current) {\n contentRef.current.isFocused = false;\n }\n\n // Check if the blur is due to clicking on a suggestion\n const relatedTarget = event.relatedTarget as HTMLElement;\n if (relatedTarget && suggestionMenuRef.current?.contains(relatedTarget)) {\n // Don't close suggestions if clicking on a suggestion\n return;\n }\n\n // Delay closing suggestions to allow click events to register\n setTimeout(() => {\n setShowSuggestions(false);\n }, 200);\n onBlur?.();\n },\n [onBlur],\n );\n\n const insertSuggestion = useCallback(\n (suggestion: string) => {\n if (!contentRef.current) return;\n\n // IMPORTANT: Use the value prop (not innerText) to preserve existing {{}} syntax\n // innerText only shows display text and loses the {{}} markers from pills\n const currentValue = valueRef.current;\n\n // Find the last occurrence of @ (trigger symbol) in the raw value\n const lastAtSymbol = currentValue.lastIndexOf('@');\n\n if (lastAtSymbol !== -1) {\n // Find where the @ trigger ends (space or end of string)\n const afterAt = currentValue.slice(lastAtSymbol + 1);\n const spaceIndex = afterAt.search(/\\s/);\n\n let endPosition: number;\n if (spaceIndex === -1) {\n // No space found, the incomplete variable goes to the end\n endPosition = currentValue.length;\n } else {\n // Space found, replace up to the space\n endPosition = lastAtSymbol + 1 + spaceIndex;\n }\n\n // Build the new value preserving all existing {{}} syntax\n // Replace @searchTerm with {{suggestion}}\n const beforeAt = currentValue.slice(0, lastAtSymbol);\n const afterCursor = currentValue.slice(endPosition);\n const newValue = `${beforeAt}{{${suggestion}}}${afterCursor}`;\n\n // Update through onChange\n onChange(newValue);\n\n // Close suggestions\n setShowSuggestions(false);\n setSearchTerm('');\n\n // Refocus the input after React updates\n setTimeout(() => {\n contentRef.current?.focus();\n }, 0);\n }\n },\n [onChange],\n );\n\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n // Use refs to get the latest state values to avoid stale closures\n const isShowingSuggestions = showSuggestionsRef.current;\n const currentFilteredSuggestions = filteredSuggestionsRef.current;\n const currentSelectedIndex = selectedIndexRef.current;\n\n // Always prevent Enter key to avoid creating new lines/divs\n if (event.key === 'Enter') {\n event.preventDefault();\n event.stopPropagation();\n\n // If suggestions are showing, select the current suggestion\n if (isShowingSuggestions && currentFilteredSuggestions.length > 0 && currentFilteredSuggestions[currentSelectedIndex]) {\n insertSuggestion(currentFilteredSuggestions[currentSelectedIndex]);\n }\n return;\n }\n\n // When suggestions are visible, intercept navigation keys immediately\n if (isShowingSuggestions && currentFilteredSuggestions.length > 0) {\n const { key } = event;\n\n // Prevent default for all navigation keys when suggestions are shown\n if (['ArrowDown', 'ArrowUp', 'Escape', 'Tab'].includes(key)) {\n event.preventDefault();\n event.stopPropagation();\n\n switch (key) {\n case 'ArrowDown':\n setSelectedIndex((prev) => (prev < currentFilteredSuggestions.length - 1 ? prev + 1 : prev));\n break;\n case 'ArrowUp':\n setSelectedIndex((prev) => (prev > 0 ? prev - 1 : 0));\n break;\n case 'Escape':\n setShowSuggestions(false);\n break;\n case 'Tab':\n if (currentFilteredSuggestions[currentSelectedIndex]) {\n insertSuggestion(currentFilteredSuggestions[currentSelectedIndex]);\n }\n break;\n }\n }\n }\n },\n [insertSuggestion],\n );\n\n const handlePaste = useCallback((event: React.ClipboardEvent<HTMLDivElement>) => {\n event.preventDefault();\n const text = event.clipboardData.getData('text/plain');\n document.execCommand('insertText', false, text);\n }, []);\n\n const displayValue = useMemo(() => {\n if (showRawValue) {\n return value;\n }\n return convertToPills(value);\n }, [value, showRawValue]);\n\n return (\n <div className='w-full'>\n {label && (\n <div className='text-xs font-medium text-gray-600 inline-flex items-center gap-1 font-inter text-left whitespace-nowrap flex-wrap'>\n <InputLabel label={label || \"\"} required={isRequired || false} />\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\n <div className='relative' ref={inputWrapperRef}>\n {!value?.trim() ? (\n <div\n className='absolute top-0 left-0 w-full h-full text-gray-400 flex items-center cursor-text px-3 z-50'\n onClick={() => contentRef.current?.focus()}\n >\n <Typography size='extra-small' variant='medium'>\n {placeholder}\n </Typography>\n </div>\n ) : null}\n\n <div className='relative'>\n <ContentEditable\n innerRef={contentRef}\n className={cn(\n 'min-h-[42px] rounded-lg p-2.5',\n 'text-sm font-inter block font-medium border text-gray-900 dark:text-white whitespace-normal break-words text-left',\n disabled ? 'bg-neutral-100 dark:bg-black-800' : 'bg-white dark:bg-black-800',\n !disabled && 'pr-[60px]',\n errorMessage ? '!border-error-500' : 'border-gray-300 dark:border-black-600 focus:ring-blue-500 focus:border-blue-500',\n 'cursor-text',\n )}\n style={{\n width: width,\n wordBreak: 'break-word',\n }}\n html={displayValue}\n onChange={!disabled ? handleChange : () => null}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDownCapture={handleKeyDown}\n onKeyDown={handleKeyDown}\n onPaste={handlePaste}\n disabled={disabled}\n id={id}\n />\n\n {!disabled && (\n <div className='absolute right-0 top-0 bottom-0 flex items-center align-middle justify-center p-3 gap-2'>\n <IconButton tooltip={showRawValue ? 'Show Formatted' : 'Show Raw Value'} variant='ghost' onClick={() => setShowRawValue(!showRawValue)}>\n {showRawValue ? <VisibilityOutlined sx={{ fontSize: 18 }} /> : <VisibilityOffOutlined sx={{ fontSize: 18 }} />}\n </IconButton>\n </div>\n )}\n </div>\n\n {showSuggestions &&\n filteredSuggestions.length > 0 &&\n createPortal(\n <div\n ref={suggestionMenuRef}\n className='z-[3000] bg-white dark:bg-black-800 border border-gray-300 dark:border-black-600 rounded-lg shadow-lg max-h-60 overflow-y-auto min-w-[200px]'\n onMouseDown={(e) => {\n // Prevent blur when clicking on suggestions\n e.preventDefault();\n }}\n >\n {filteredSuggestions.map((suggestion, index) => (\n <div\n key={suggestion}\n ref={(el) => (suggestionRefs.current[index] = el)}\n className={cn(\n 'px-3 py-2 cursor-pointer text-sm font-inter',\n index === selectedIndex\n ? 'bg-primary-100 dark:bg-primary-900 text-primary-700 dark:text-primary-300'\n : 'hover:bg-gray-100 dark:hover:bg-black-700 text-gray-900 dark:text-white',\n )}\n onClick={() => insertSuggestion(suggestion)}\n onMouseEnter={() => setSelectedIndex(index)}\n >\n {suggestion}\n </div>\n ))}\n </div>,\n document.body,\n )}\n </div>\n\n {errorMessage && (\n <div className='pt-1'>\n <Typography className='text-error-500' size='extra-small' variant='medium' appearance='custom'>\n {errorMessage}\n </Typography>\n </div>\n )}\n </div>\n );\n};\n\nexport default React.memo(FormulaInput);\n\n\n\n"],"names":["FormulaInput","value","onChange","onFocus","onBlur","label","id","isRequired","tooltip","placeholder","disabled","errorMessage","width","suggestions","showRawValueProp","contentRef","useRef","inputWrapperRef","suggestionMenuRef","suggestionRefs","popperInstanceRef","showSuggestions","setShowSuggestions","useState","searchTerm","setSearchTerm","selectedIndex","setSelectedIndex","showRawValue","setShowRawValue","showSuggestionsRef","filteredSuggestionsRef","selectedIndexRef","valueRef","useEffect","useOutsideClick","filteredSuggestions","useMemo","lowerSearchTerm","suggestion","createPopper","handleChange","useCallback","event","rawValue","convertFromPills","textBeforeCursor","getTextBeforeCursor","lastAtSymbol","textAfterAt","handleFocus","handleBlur","relatedTarget","insertSuggestion","currentValue","spaceIndex","endPosition","beforeAt","afterCursor","newValue","handleKeyDown","isShowingSuggestions","currentFilteredSuggestions","currentSelectedIndex","key","prev","handlePaste","text","displayValue","convertToPills","jsxs","jsx","InputLabel","Tooltip","HelpIcon","Typography","ContentEditable","cn","IconButton","VisibilityOutlined","VisibilityOffOutlined","createPortal","e","index","el","FormulaInput$1","React"],"mappings":"4kBAkDMA,GAA4C,CAAC,CACjD,MAAAC,EAAQ,GACR,SAAAC,EACA,QAAAC,EACA,OAAAC,EACA,MAAAC,EACA,GAAAC,EACA,SAAUC,EACV,QAAAC,EACA,YAAAC,EACA,SAAAC,EACA,aAAAC,EACA,MAAAC,EAAQ,OACR,YAAAC,EAAc,CAAA,EACd,aAAcC,EAAmB,EACnC,IAAM,CACJ,MAAMC,EAAaC,EAAAA,OAA8C,IAAI,EAC/DC,EAAkBD,EAAAA,OAAuB,IAAI,EAC7CE,EAAoBF,EAAAA,OAAuB,IAAI,EAC/CG,EAAiBH,EAAAA,OAAkC,EAAE,EACrDI,EAAoBJ,EAAAA,OAA8B,IAAI,EACtD,CAACK,EAAiBC,CAAkB,EAAIC,EAAAA,SAAS,EAAK,EACtD,CAACC,EAAYC,CAAa,EAAIF,EAAAA,SAAS,EAAE,EACzC,CAACG,EAAeC,CAAgB,EAAIJ,EAAAA,SAAS,CAAC,EAC9C,CAACK,EAAcC,CAAe,EAAIN,EAAAA,SAAST,CAAgB,E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ACR,iBAAkBS,EAClB,UAAWA,EACX,QAASM,EACT,SAAAxD,EACA,GAAAJ,CAAA,CAAA,EAGD,CAACI,GACA6D,EAAAA,IAAC,MAAA,CAAI,UAAU,0FACb,SAAAA,MAACO,GAAA,CAAW,QAASlD,EAAe,iBAAmB,iBAAkB,QAAQ,QAAQ,QAAS,IAAMC,EAAgB,CAACD,CAAY,EAClI,WAAe2C,MAACQ,EAAAA,mBAAA,CAAmB,GAAI,CAAE,SAAU,EAAA,CAAG,CAAG,EAAKR,MAACS,EAAAA,uBAAsB,GAAI,CAAE,SAAU,EAAA,CAAG,CAAG,EAC9G,CAAA,CACF,CAAA,EAEJ,EAEC3D,GACCe,EAAoB,OAAS,GAC7B6C,GAAAA,aACEV,EAAAA,IAAC,MAAA,CACC,IAAKrD,EACL,UAAU,+IACV,YAAcgE,GAAM,CAElBA,EAAE,eAAA,CACJ,EAEC,SAAA9C,EAAoB,IAAI,CAACG,EAAY4C,IACpCZ,EAAAA,IAAC,MAAA,CAEC,IAAMa,GAAQjE,EAAe,QAAQgE,CAAK,EAAIC,EAC9C,UAAWP,EACT,8CACAM,IAAUzD,EACN,4EACA,yEAAA,EAEN,QAAS,IAAM2B,EAAiBd,CAAU,EAC1C,aAAc,IAAMZ,EAAiBwD,CAAK,EAEzC,SAAA5C,CAAA,EAXIA,CAAA,CAaR,CAAA,CAAA,EAEH,SAAS,IAAA,CACX,EACJ,EAEC5B,GACC4D,EAAAA,IAAC,MAAA,CAAI,UAAU,OACb,eAACI,EAAAA,WAAA,CAAW,UAAU,iBAAiB,KAAK,cAAc,QAAQ,SAAS,WAAW,SACnF,WACH,CAAA,CACF,CAAA,EAEJ,CAEJ,EAEAU,GAAeC,EAAM,KAAKtF,EAAY"}
@@ -28,7 +28,7 @@ const be = ({
28
28
  suggestions: T = [],
29
29
  showRawValue: G = !1
30
30
  }) => {
31
- const c = a(null), C = a(null), g = a(null), D = a([]), k = a(null), [s, f] = v(!1), [N, O] = v(""), [m, y] = v(0), [b, J] = v(G), z = a(s), E = a([]), B = a(m), $ = a(u);
31
+ const c = a(null), N = a(null), g = a(null), C = a([]), k = a(null), [s, f] = v(!1), [D, O] = v(""), [m, y] = v(0), [b, J] = v(G), z = a(s), E = a([]), B = a(m), $ = a(u);
32
32
  d(() => {
33
33
  z.current = s;
34
34
  }, [s]), d(() => {
@@ -42,22 +42,22 @@ const be = ({
42
42
  }
43
43
  });
44
44
  const w = L(() => {
45
- if (!N) return T;
46
- const e = N.toLowerCase();
45
+ if (!D) return T;
46
+ const e = D.toLowerCase();
47
47
  return T.filter((t) => t.toLowerCase().includes(e));
48
- }, [T, N]);
48
+ }, [T, D]);
49
49
  d(() => {
50
50
  E.current = w;
51
51
  }, [w]), d(() => {
52
52
  y(0);
53
53
  }, [w]), d(() => {
54
- s && D.current[m] && D.current[m]?.scrollIntoView({
54
+ s && C.current[m] && C.current[m]?.scrollIntoView({
55
55
  block: "nearest",
56
56
  behavior: "smooth"
57
57
  });
58
58
  }, [m, s]), d(() => {
59
- if (s && C.current && g.current)
60
- return k.current = ge(C.current, g.current, {
59
+ if (s && N.current && g.current)
60
+ return k.current = ge(N.current, g.current, {
61
61
  placement: "bottom-start",
62
62
  strategy: "fixed",
63
63
  modifiers: [
@@ -158,9 +158,9 @@ const be = ({
158
158
  return /* @__PURE__ */ R("div", { className: "w-full", children: [
159
159
  P && /* @__PURE__ */ R("div", { className: "text-xs font-medium text-gray-600 inline-flex items-center gap-1 font-inter text-left whitespace-nowrap flex-wrap", children: [
160
160
  /* @__PURE__ */ o(he, { label: P || "", required: U || !1 }),
161
- F && /* @__PURE__ */ o(ie, { placement: "top", title: F, children: /* @__PURE__ */ o("div", { className: "cursor-pointer", children: /* @__PURE__ */ o(ue, {}) }) })
161
+ F && /* @__PURE__ */ o(ie, { placement: "top", title: F, children: /* @__PURE__ */ o("div", { className: "cursor-pointer", children: /* @__PURE__ */ o(ue, { className: "w-icon-sm h-icon-sm" }) }) })
162
162
  ] }),
163
- /* @__PURE__ */ R("div", { className: "relative", ref: C, children: [
163
+ /* @__PURE__ */ R("div", { className: "relative", ref: N, children: [
164
164
  u?.trim() ? null : /* @__PURE__ */ o(
165
165
  "div",
166
166
  {
@@ -211,7 +211,7 @@ const be = ({
211
211
  children: w.map((e, t) => /* @__PURE__ */ o(
212
212
  "div",
213
213
  {
214
- ref: (r) => D.current[t] = r,
214
+ ref: (r) => C.current[t] = r,
215
215
  className: K(
216
216
  "px-3 py-2 cursor-pointer text-sm font-inter",
217
217
  t === m ? "bg-primary-100 dark:bg-primary-900 text-primary-700 dark:text-primary-300" : "hover:bg-gray-100 dark:hover:bg-black-700 text-gray-900 dark:text-white"