@12-apps/ui 6.10.0 → 6.11.0

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/form/Textarea/Textarea.tsx","../../src/components/form/Textarea/Textarea.styles.ts","../../src/components/form/Textarea/TextareaRichEditor.tsx"],"sourcesContent":["import {\n alpha,\n Box,\n FormHelperText,\n InputLabel,\n TextareaAutosize } from '@mui/material';\nimport type { Theme } from '@mui/material';\nimport { styled } from '@mui/material';\nimport React, { useState } from 'react';\n\nimport {\n getColorFromTheme,\n textareaEmphasisStyles } from './Textarea.styles';\nimport { TextareaRichEditor } from './TextareaRichEditor';\nimport type { TextareaProps } from './Textarea.types';\n\n// Interface for styled component props\ninterface StyledTextareaProps {\n customVariant?: string;\n customColor?: string;\n customSize?: string;\n glow?: boolean;\n glass?: boolean;\n gradient?: boolean;\n error?: boolean;\n theme?: Theme;\n}\n\n// Glow animation for enhanced visual effects\nconst StyledTextarea = styled(TextareaAutosize, {\n shouldForwardProp: (prop) =>\n !['customVariant', 'customColor', 'customSize', 'glow', 'glass', 'gradient', 'error'].includes(\n prop as string,\n ) })<StyledTextareaProps>(({\n theme,\n customVariant,\n customColor = 'primary',\n customSize = 'md',\n glow,\n glass,\n gradient,\n error }) => {\n if (!theme) return {};\n const colorPalette = getColorFromTheme(theme, customColor);\n const errorColor = theme.palette.error;\n\n const sizeMap = {\n xs: { padding: '6px 8px', fontSize: '0.75rem', minHeight: '60px' },\n sm: { padding: '8px 10px', fontSize: '0.875rem', minHeight: '80px' },\n md: { padding: '10px 12px', fontSize: '1rem', minHeight: '100px' },\n lg: { padding: '12px 14px', fontSize: '1.125rem', minHeight: '120px' },\n xl: { padding: '14px 16px', fontSize: '1.25rem', minHeight: '140px' } };\n\n const baseStyles = {\n width: '100%',\n fontFamily: theme.typography.fontFamily,\n borderRadius: theme.spacing(1),\n border: `2px solid ${error ? errorColor.main : theme.palette.divider}`,\n backgroundColor: theme.palette.background.paper,\n color: theme.palette.text.primary,\n transition: 'all 0.3s ease',\n resize: customVariant === 'resizable' ? 'vertical' : 'none',\n outline: 'none',\n ...sizeMap[customSize as keyof typeof sizeMap],\n\n '&::placeholder': {\n color: theme.palette.text.secondary,\n opacity: 0.7 },\n\n '&:hover': {\n borderColor: error ? errorColor.dark : colorPalette.main,\n backgroundColor: alpha(theme.palette.background.paper, 0.8) },\n\n '&:focus': {\n borderColor: error ? errorColor.main : colorPalette.main,\n backgroundColor: theme.palette.background.paper,\n boxShadow: `0 0 0 3px ${alpha(error ? errorColor.main : colorPalette.main, 0.1)}` } };\n\n // Glass morphism effect\n return {\n ...baseStyles,\n ...textareaEmphasisStyles({ theme, colorPalette, glass, gradient, glow }) };\n});\n\nconst StyledLabel = styled(InputLabel, {\n shouldForwardProp: (prop) => !['glass', 'error'].includes(prop as string) })<{ glass?: boolean; error?: boolean }>(({ theme, glass, error }) => ({\n marginBottom: theme.spacing(1),\n fontWeight: 500,\n color: error ? theme.palette.error.main : theme.palette.text.primary,\n ...(glass && {\n backgroundColor: alpha(theme.palette.background.paper, 0.1),\n backdropFilter: 'blur(10px)',\n padding: '4px 8px',\n borderRadius: '4px',\n border: `1px solid ${alpha(theme.palette.divider, 0.2)}`,\n display: 'inline-block' }) }));\n\n// IconWrapper - replaced with inline Box component for better TypeScript compatibility\n// const IconWrapper = styled(Box)<{ position: 'start' | 'end' }>(({ theme, position }) => {\n// const positionStyles = position === 'start' ? { left: '12px' } : { right: '12px' };\n// return {\n// position: 'absolute' as const,\n// top: '12px',\n// ...positionStyles,\n// color: theme.palette.text.secondary,\n// pointerEvents: 'none' as const,\n// zIndex: 1,\n// };\n// });\n\n// Rich text toolbar styling\n\nconst ICON_GUTTER = '40px';\n\nconst TEXTAREA_DEFAULTS = {\n variant: 'default',\n color: 'primary',\n size: 'md',\n error: false,\n glassLabel: false,\n glow: false,\n glass: false,\n gradient: false,\n iconPosition: 'start',\n minRows: 3 } satisfies Partial<TextareaProps>;\n\n// Strips explicitly-undefined props before the merge, so `prop={undefined}`\n// still falls back to the default as a destructuring default would.\nconst definedProps = (props: TextareaProps): Partial<TextareaProps> =>\n Object.fromEntries(\n Object.entries(props).filter(([, value]) => value !== undefined),\n ) as Partial<TextareaProps>;\n\n// Label above, helper text below — identical for the plain and rich variants,\n// which previously duplicated both.\nconst TextareaShell: React.FC<{\n testId?: string;\n label?: React.ReactNode;\n glassLabel: boolean;\n error: boolean;\n helperText?: React.ReactNode;\n children: React.ReactNode;\n}> = ({ testId, label, glassLabel, error, helperText, children }) => (\n <Box\n sx={{ position: 'relative', width: '100%' }}\n data-testid={testId ? `${testId}-wrapper` : undefined}\n >\n {label && (\n <StyledLabel glass={glassLabel} error={error}>\n {label}\n </StyledLabel>\n )}\n\n {children}\n\n {helperText && (\n <FormHelperText error={error} sx={{ mt: 1 }}>\n {helperText}\n </FormHelperText>\n )}\n </Box>\n);\n\nconst TextareaIcon: React.FC<{\n icon?: React.ReactNode;\n iconPosition: 'start' | 'end';\n}> = ({ icon, iconPosition }) => (\n <Box\n sx={{\n position: 'absolute',\n top: '12px',\n ...(iconPosition === 'start' ? { left: '12px' } : { right: '12px' }),\n color: 'text.secondary',\n pointerEvents: 'none',\n zIndex: 1 }}\n >\n {icon}\n </Box>\n);\n\nexport const Textarea: React.FC<TextareaProps> = (textareaProps) => {\n const {\n variant,\n color,\n size,\n error,\n helperText,\n label,\n glassLabel,\n glow,\n glass,\n gradient,\n icon,\n iconPosition,\n minRows,\n maxRows,\n style,\n 'data-testid': dataTestId,\n dataTestId: dataTestIdCamelCase,\n ...props\n } = { ...TEXTAREA_DEFAULTS, ...definedProps(textareaProps) };\n\n // Read off the props rather than the merged object: the spread widens every\n // key to optional, which would lose what the variant union already proved.\n const { richEditorCopy } = textareaProps;\n\n const [richTextValue, setRichTextValue] = useState('');\n const hasIcon = Boolean(icon);\n const testId = dataTestId || dataTestIdCamelCase;\n\n const textareaStyle = {\n ...style,\n // Same gap either side; only which side it applies to changes. The previous\n // version had `iconPosition === 'start' ? '40px' : '40px'`, a ternary whose\n // two branches were identical.\n ...(hasIcon && {\n [iconPosition === 'start' ? 'paddingLeft' : 'paddingRight']: ICON_GUTTER }) };\n\n // If rich text variant, use the rich text editor\n if (variant === 'rich' && richEditorCopy) {\n return (\n <TextareaShell testId={testId} label={label} glassLabel={glassLabel} error={error} helperText={helperText}>\n <TextareaRichEditor\n copy={richEditorCopy}\n value={richTextValue}\n onChange={setRichTextValue}\n placeholder={props.placeholder}\n error={error}\n glass={glass}\n color={color}\n characterLimit={props.maxLength}\n />\n </TextareaShell>\n );\n }\n\n return (\n <TextareaShell testId={testId} label={label} glassLabel={glassLabel} error={error} helperText={helperText}>\n <Box sx={{ position: 'relative' }}>\n {hasIcon && <TextareaIcon icon={icon} iconPosition={iconPosition} />}\n\n <StyledTextarea\n customVariant={variant}\n customColor={color}\n customSize={size}\n glow={glow}\n glass={glass}\n gradient={gradient}\n error={error}\n minRows={variant === 'autosize' ? minRows : undefined}\n maxRows={variant === 'autosize' ? maxRows : undefined}\n style={textareaStyle}\n aria-label={label || props['aria-label']}\n data-testid={testId}\n {...props}\n />\n </Box>\n </TextareaShell>\n );\n};\n\nTextarea.displayName = 'Textarea';\n","import { alpha, keyframes } from '@mui/material';\nimport type { CSSObject, Theme } from '@mui/material';\n\nconst glowAnimation = keyframes`\n 0% {\n box-shadow: 0 0 5px currentColor;\n }\n 50% {\n box-shadow: 0 0 20px currentColor, 0 0 30px currentColor;\n }\n 100% {\n box-shadow: 0 0 5px currentColor;\n }\n`;\n\n// Ripple animation for buttons (commented out - not currently used)\n// const rippleAnimation = keyframes`\n// 0% {\n// transform: scale(0);\n// opacity: 1;\n// }\n// 100% {\n// transform: scale(4);\n// opacity: 0;\n// }\n// `;\n\n// Float animation for rich text toolbar\nexport const floatAnimation = keyframes`\n 0% {\n transform: translateY(0px);\n }\n 50% {\n transform: translateY(-3px);\n }\n 100% {\n transform: translateY(0px);\n }\n`;\n\ntype ResolvedPalette = {\n main: string;\n dark: string;\n light: string;\n contrastText: string;\n};\n\ntype PartialPalette = { main: string; dark?: string; light?: string; contrastText?: string };\n\n// grey is indexed by weight rather than main/dark/light, so neutral is built by\n// hand. The literals are the MUI grey values, used if the theme omits a weight.\nconst neutralPalette = (theme: Theme): ResolvedPalette => {\n const grey = theme.palette.grey as unknown as Record<number, string>;\n\n return {\n main: grey?.[700] || '#616161',\n dark: grey?.[800] || '#424242',\n light: grey?.[500] || '#9e9e9e',\n contrastText: '#fff',\n };\n};\n\n// Each slot falls back to the palette's own main, then to primary — a custom\n// theme can define main without dark or light.\nconst pick = (...candidates: Array<string | undefined>): string =>\n candidates.find(Boolean) ?? '';\n\nconst withFallbacks = (theme: Theme, palette: PartialPalette): ResolvedPalette => ({\n main: pick(palette?.main, theme.palette.primary.main),\n dark: pick(palette?.dark, palette?.main, theme.palette.primary.dark),\n light: pick(palette?.light, palette?.main, theme.palette.primary.light),\n contrastText: pick(palette?.contrastText, '#fff'),\n});\n\nexport const getColorFromTheme = (theme: Theme, color: string): ResolvedPalette => {\n if (color === 'neutral') return neutralPalette(theme);\n\n const colorMap: Record<string, PartialPalette> = {\n primary: theme.palette.primary,\n secondary: theme.palette.secondary,\n success: theme.palette.success,\n warning: theme.palette.warning,\n info: theme.palette.info,\n danger: theme.palette.error,\n };\n\n return withFallbacks(theme, colorMap[color] || theme.palette.primary);\n};\n\n// glass, gradient and glow are independent flags that each layer styles onto the\n// base. Spelled out here rather than inline so the styled() callback keeps one\n// branch instead of three.\nexport const textareaEmphasisStyles = ({\n theme,\n colorPalette,\n glass,\n gradient,\n glow,\n}: {\n theme: Theme;\n colorPalette: { main: string; light?: string; dark?: string };\n glass?: boolean;\n gradient?: boolean;\n glow?: boolean;\n}): CSSObject => {\nconst glassStyles = glass\n ? {\n backgroundColor: alpha(theme.palette.background.paper, 0.1),\n backdropFilter: 'blur(20px)',\n border: `1px solid ${alpha(theme.palette.divider, 0.2)}`,\n '&:hover': {\n backgroundColor: alpha(theme.palette.background.paper, 0.15),\n backdropFilter: 'blur(25px)',\n },\n '&:focus': {\n backgroundColor: alpha(theme.palette.background.paper, 0.2),\n backdropFilter: 'blur(30px)',\n },\n }\n : {};\n\n// Gradient border effect\nconst gradientStyles = gradient\n ? {\n background: `linear-gradient(${theme.palette.background.paper}, ${theme.palette.background.paper}) padding-box,\n linear-gradient(135deg, ${colorPalette.main}, ${colorPalette.light}) border-box`,\n border: '2px solid transparent',\n '&:focus': {\n background: `linear-gradient(${theme.palette.background.paper}, ${theme.palette.background.paper}) padding-box,\n linear-gradient(135deg, ${colorPalette.main}, ${colorPalette.dark}) border-box`,\n },\n }\n : {};\n\n// Glow effect\nconst glowStyles = glow\n ? {\n animation: `${glowAnimation} 2s ease-in-out infinite`,\n boxShadow: `0 0 10px ${alpha(colorPalette.main, 0.3)}`,\n }\n : {};\n\n return { ...glassStyles, ...gradientStyles, ...glowStyles };\n};\n","import Code from '@mui/icons-material/Code';\nimport FormatBold from '@mui/icons-material/FormatBold';\nimport FormatColorFill from '@mui/icons-material/FormatColorFill';\nimport FormatColorText from '@mui/icons-material/FormatColorText';\nimport FormatItalic from '@mui/icons-material/FormatItalic';\nimport FormatListBulleted from '@mui/icons-material/FormatListBulleted';\nimport FormatListNumbered from '@mui/icons-material/FormatListNumbered';\nimport FormatQuote from '@mui/icons-material/FormatQuote';\nimport FormatUnderlined from '@mui/icons-material/FormatUnderlined';\nimport Link from '@mui/icons-material/Link';\nimport { alpha, Box, Divider, IconButton, Tooltip } from '@mui/material';\nimport type { Theme } from '@mui/material';\nimport { styled } from '@mui/material';\nimport React, { useEffect, useRef, useState } from 'react';\n\nimport { floatAnimation, getColorFromTheme } from './Textarea.styles';\nimport type { RichEditorToolbarCopy } from '../../../copy';\n\nconst RichToolbar = styled(Box)<{ glass?: boolean }>(({ theme, glass }) => ({\n display: 'flex',\n alignItems: 'center',\n gap: theme.spacing(0.5),\n padding: theme.spacing(1),\n borderRadius: `${theme.spacing(1)} ${theme.spacing(1)} 0 0`,\n borderBottom: `1px solid ${theme.palette.divider}`,\n background: glass ? alpha(theme.palette.background.paper, 0.1) : theme.palette.background.paper,\n ...(glass && {\n backdropFilter: 'blur(15px)' }),\n '& .MuiDivider-root': {\n height: 24,\n margin: `0 ${theme.spacing(1)}` } }));\n\nconst ToolbarButton = styled(IconButton, {\n shouldForwardProp: (prop) => prop !== 'active' })<{ active?: boolean }>(({ theme, active }) => ({\n padding: theme.spacing(0.75),\n borderRadius: theme.spacing(0.5),\n color: active ? theme.palette.primary.main : theme.palette.text.secondary,\n backgroundColor: active ? alpha(theme.palette.primary.main, 0.1) : 'transparent',\n transition: 'all 0.2s ease',\n position: 'relative',\n overflow: 'hidden',\n\n '&::before': {\n content: '\"\"',\n position: 'absolute',\n top: '50%',\n left: '50%',\n width: 0,\n height: 0,\n borderRadius: '50%',\n backgroundColor: alpha(theme.palette.primary.main, 0.3),\n transform: 'translate(-50%, -50%)',\n transition: 'width 0.3s, height 0.3s' },\n\n '&:hover': {\n color: theme.palette.primary.main,\n backgroundColor: alpha(theme.palette.primary.main, 0.15),\n transform: 'translateY(-1px)',\n animation: `${floatAnimation} 1.5s ease-in-out infinite`,\n\n '&::before': {\n width: '100%',\n height: '100%' } },\n\n '&:active': {\n transform: 'scale(0.95)' } }));\n\nconst CharacterCount = styled(Box)<{ limit?: number; count: number }>(({ theme, limit, count }) => {\n const isWarning = limit && count > limit * 0.8;\n const isError = limit && count > limit;\n\n return {\n position: 'absolute',\n bottom: theme.spacing(1),\n right: theme.spacing(1),\n fontSize: '0.75rem',\n color: isError\n ? theme.palette.error.main\n : isWarning\n ? theme.palette.warning.main\n : theme.palette.text.secondary,\n padding: '2px 6px',\n borderRadius: theme.spacing(0.5),\n backgroundColor: alpha(theme.palette.background.paper, 0.8),\n backdropFilter: 'blur(10px)',\n transition: 'all 0.3s ease' };\n});\n\nconst ContentEditableDiv = styled('div')<{\n error?: boolean;\n focused?: boolean;\n glass?: boolean;\n customColor?: string;\n theme?: Theme;\n}>(({ theme, error, focused, glass, customColor = 'primary' }) => {\n if (!theme) return {};\n const colorPalette = getColorFromTheme(theme, customColor);\n const errorColor = theme.palette.error;\n\n return {\n minHeight: '120px',\n padding: theme.spacing(1.5),\n borderRadius: `0 0 ${theme.spacing(1)} ${theme.spacing(1)}`,\n border: `2px solid ${error ? errorColor.main : focused ? colorPalette.main : theme.palette.divider}`,\n borderTop: 'none',\n backgroundColor: glass\n ? alpha(theme.palette.background.paper, 0.1)\n : theme.palette.background.paper,\n color: theme.palette.text.primary,\n fontFamily: theme.typography.fontFamily,\n fontSize: '1rem',\n lineHeight: 1.5,\n outline: 'none',\n transition: 'all 0.3s ease',\n cursor: 'text',\n\n ...(glass && {\n backdropFilter: 'blur(20px)' }),\n\n '&:hover': {\n backgroundColor: glass\n ? alpha(theme.palette.background.paper, 0.15)\n : alpha(theme.palette.background.paper, 0.9) },\n\n '&:focus': {\n borderColor: error ? errorColor.main : colorPalette.main,\n boxShadow: `0 0 0 3px ${alpha(error ? errorColor.main : colorPalette.main, 0.1)}` },\n\n '& > *': {\n margin: '0.5em 0' },\n\n '&[contenteditable=\"true\"]:empty::before': {\n content: 'attr(data-placeholder)',\n color: theme.palette.text.secondary,\n opacity: 0.6 } };\n});\n\n// Rich text formatting functions\nconst formatText = (command: string, value?: string) => {\n document.execCommand(command, false, value);\n};\n\n// Editable state: what is typed, how long it is, and which formats apply at the\n// caret. Kept apart from the markup below.\nconst useRichEditorState = ({\n value,\n onChange }: {\n value?: string;\n onChange?: (html: string) => void;\n}) => {\n const [focused, setFocused] = useState(false);\n const [characterCount, setCharacterCount] = useState(0);\n const [activeFormats, setActiveFormats] = useState({\n bold: false,\n italic: false,\n underline: false,\n list: false,\n orderedList: false,\n quote: false,\n code: false });\n const contentRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (contentRef.current && value !== undefined) {\n if (contentRef.current.innerHTML !== value) {\n contentRef.current.innerHTML = value;\n }\n setCharacterCount(contentRef.current.innerText.length);\n }\n }, [value]);\n\n const handleInput = () => {\n if (contentRef.current) {\n const html = contentRef.current.innerHTML;\n onChange?.(html);\n setCharacterCount(contentRef.current.innerText.length);\n updateActiveFormats();\n }\n };\n\n const updateActiveFormats = () => {\n setActiveFormats({\n bold: document.queryCommandState('bold'),\n italic: document.queryCommandState('italic'),\n underline: document.queryCommandState('underline'),\n list: document.queryCommandState('insertUnorderedList'),\n orderedList: document.queryCommandState('insertOrderedList'),\n quote: false,\n code: false });\n };\n\n const handleFormat = (command: string, value?: string) => {\n formatText(command, value);\n updateActiveFormats();\n contentRef.current?.focus();\n };\n\n return {\n focused,\n setFocused,\n characterCount,\n activeFormats,\n contentRef,\n handleInput,\n handleFormat,\n updateActiveFormats };\n};\n\nconst InlineFormatButtons: React.FC<{\n copy: RichEditorToolbarCopy;\n activeFormats: Record<string, boolean>;\n onCommand: (command: string, value?: string) => void;\n}> = ({ copy, activeFormats, onCommand }) => (\n <>\n <Tooltip title={copy.bold} arrow>\n <ToolbarButton\n size=\"small\"\n active={activeFormats.bold}\n onClick={() => onCommand('bold')}\n >\n <FormatBold fontSize=\"small\" />\n </ToolbarButton>\n </Tooltip>\n\n <Tooltip title={copy.italic} arrow>\n <ToolbarButton\n size=\"small\"\n active={activeFormats.italic}\n onClick={() => onCommand('italic')}\n >\n <FormatItalic fontSize=\"small\" />\n </ToolbarButton>\n </Tooltip>\n\n <Tooltip title={copy.underline} arrow>\n <ToolbarButton\n size=\"small\"\n active={activeFormats.underline}\n onClick={() => onCommand('underline')}\n >\n <FormatUnderlined fontSize=\"small\" />\n </ToolbarButton>\n </Tooltip>\n\n </>\n);\n\nconst BlockFormatButtons: React.FC<{\n copy: RichEditorToolbarCopy;\n activeFormats: Record<string, boolean>;\n onCommand: (command: string, value?: string) => void;\n}> = ({ copy, activeFormats, onCommand }) => (\n <>\n <Divider orientation=\"vertical\" flexItem />\n\n <Tooltip title={copy.bulletList} arrow>\n <ToolbarButton\n size=\"small\"\n active={activeFormats.list}\n onClick={() => onCommand('insertUnorderedList')}\n >\n <FormatListBulleted fontSize=\"small\" />\n </ToolbarButton>\n </Tooltip>\n\n <Tooltip title={copy.numberedList} arrow>\n <ToolbarButton\n size=\"small\"\n active={activeFormats.orderedList}\n onClick={() => onCommand('insertOrderedList')}\n >\n <FormatListNumbered fontSize=\"small\" />\n </ToolbarButton>\n </Tooltip>\n\n <Divider orientation=\"vertical\" flexItem />\n\n <Tooltip title={copy.quote} arrow>\n <ToolbarButton size=\"small\" onClick={() => onCommand('formatBlock', 'blockquote')}>\n <FormatQuote fontSize=\"small\" />\n </ToolbarButton>\n </Tooltip>\n\n <Tooltip title={copy.code} arrow>\n <ToolbarButton size=\"small\" onClick={() => onCommand('formatBlock', 'pre')}>\n <Code fontSize=\"small\" />\n </ToolbarButton>\n </Tooltip>\n\n <Divider orientation=\"vertical\" flexItem />\n\n <Tooltip title={copy.insertLink} arrow>\n <ToolbarButton\n size=\"small\"\n onClick={() => {\n const url = window.prompt(copy.linkPrompt);\n if (url) onCommand('createLink', url);\n }}\n >\n <Link fontSize=\"small\" />\n </ToolbarButton>\n </Tooltip>\n\n <Tooltip title={copy.textColor} arrow>\n <ToolbarButton size=\"small\">\n <FormatColorText fontSize=\"small\" />\n </ToolbarButton>\n </Tooltip>\n\n <Tooltip title={copy.backgroundColor} arrow>\n <ToolbarButton size=\"small\">\n <FormatColorFill fontSize=\"small\" />\n </ToolbarButton>\n </Tooltip>\n </>\n);\n\n// The formatting buttons. Split out so the editor body is state, handlers and\n// the editable region.\nconst EditorToolbar: React.FC<{\n copy: RichEditorToolbarCopy;\n glass?: boolean;\n activeFormats: Record<string, boolean>;\n onCommand: (command: string, value?: string) => void;\n}> = ({ copy, glass, activeFormats, onCommand }) => (\n <RichToolbar glass={glass}>\n <InlineFormatButtons copy={copy} activeFormats={activeFormats} onCommand={onCommand} />\n <BlockFormatButtons copy={copy} activeFormats={activeFormats} onCommand={onCommand} />\n </RichToolbar>\n);\n\nexport const TextareaRichEditor: React.FC<{\n /**\n * The ten toolbar buttons' tooltips — which are also their accessible names,\n * since every one of them is a glyph — plus the link prompt. REQUIRED: this\n * package ships no default copy.\n */\n copy: RichEditorToolbarCopy;\n value?: string;\n onChange?: (html: string) => void;\n placeholder?: string;\n error?: boolean;\n glass?: boolean;\n color?: string;\n characterLimit?: number;\n}> = ({ copy, value, onChange, placeholder, error, glass, color, characterLimit }) => {\n const {\n focused,\n setFocused,\n characterCount,\n activeFormats,\n contentRef,\n handleInput,\n handleFormat,\n updateActiveFormats } = useRichEditorState({ value, onChange });\n\n return (\n <Box sx={{ position: 'relative' }}>\n <EditorToolbar copy={copy} glass={glass} activeFormats={activeFormats} onCommand={handleFormat} />\n\n <ContentEditableDiv\n ref={contentRef}\n contentEditable\n data-placeholder={placeholder}\n error={error}\n focused={focused}\n glass={glass}\n customColor={color}\n onFocus={() => setFocused(true)}\n onBlur={() => setFocused(false)}\n onInput={handleInput}\n onKeyUp={updateActiveFormats}\n onMouseUp={updateActiveFormats}\n role=\"textbox\"\n aria-multiline=\"true\"\n aria-label={placeholder || 'Rich text editor'}\n />\n\n {characterLimit && (\n <CharacterCount limit={characterLimit} count={characterCount}>\n {characterCount}\n {characterLimit ? `/${characterLimit}` : ''}\n </CharacterCount>\n )}\n </Box>\n );\n};\n"],"mappings":";;;AAAA;AAAA,EACE,SAAAA;AAAA,EACA,OAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAAwB;AAE1B,SAAS,UAAAC,eAAc;AACvB,SAAgB,YAAAC,iBAAgB;;;ACRhC,SAAS,OAAO,iBAAiB;AAGjC,IAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyBf,IAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuB9B,IAAM,iBAAiB,CAAC,UAAkC;AACxD,QAAM,OAAO,MAAM,QAAQ;AAE3B,SAA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","names":["alpha","Box","styled","useState","alpha","alpha","value","jsx","jsxs","styled","alpha","Box","useState"]}
1
+ {"version":3,"sources":["../../src/components/form/Textarea/Textarea.tsx"],"sourcesContent":["import {\n alpha,\n Box,\n FormHelperText,\n InputLabel,\n TextareaAutosize } from '@mui/material';\nimport type { Theme } from '@mui/material';\nimport { styled } from '@mui/material';\nimport React, { lazy, Suspense, useState } from 'react';\n\nimport {\n getColorFromTheme,\n textareaEmphasisStyles } from './Textarea.styles';\n\n/**\n * The rich editor is LOADED ON DEMAND, not imported (12-51 follow-up).\n *\n * It renders only for `variant === 'rich'`, but a static import made every\n * consumer of a plain `<Textarea>` pay for it — 387 lines of toolbar plus the\n * MUI `Tooltip`, `IconButton` and `Divider` its formatting buttons need. That\n * is not theoretical: an adopting storefront imports this entry for a one-line\n * order note, and `Tooltip` (8.7 KiB) reached its EAGER chunk through here\n * while nothing on that critical path renders a tooltip at all.\n *\n * `variant` is a prop, so the branch cannot be decided at build time and no\n * amount of tree-shaking removes it. A lazy boundary is what expresses \"only\n * the rich variant pays\", and it costs the rich variant one microtask it can\n * afford — it is a text editor a user has already chosen to open, never a\n * first-paint element.\n */\nconst TextareaRichEditor = lazy(async () => ({\n default: (await import('./TextareaRichEditor')).TextareaRichEditor }));\nimport type { TextareaProps } from './Textarea.types';\n\n// Interface for styled component props\ninterface StyledTextareaProps {\n customVariant?: string;\n customColor?: string;\n customSize?: string;\n glow?: boolean;\n glass?: boolean;\n gradient?: boolean;\n error?: boolean;\n theme?: Theme;\n}\n\n// Glow animation for enhanced visual effects\nconst StyledTextarea = styled(TextareaAutosize, {\n shouldForwardProp: (prop) =>\n !['customVariant', 'customColor', 'customSize', 'glow', 'glass', 'gradient', 'error'].includes(\n prop as string,\n ) })<StyledTextareaProps>(({\n theme,\n customVariant,\n customColor = 'primary',\n customSize = 'md',\n glow,\n glass,\n gradient,\n error }) => {\n if (!theme) return {};\n const colorPalette = getColorFromTheme(theme, customColor);\n const errorColor = theme.palette.error;\n\n const sizeMap = {\n xs: { padding: '6px 8px', fontSize: '0.75rem', minHeight: '60px' },\n sm: { padding: '8px 10px', fontSize: '0.875rem', minHeight: '80px' },\n md: { padding: '10px 12px', fontSize: '1rem', minHeight: '100px' },\n lg: { padding: '12px 14px', fontSize: '1.125rem', minHeight: '120px' },\n xl: { padding: '14px 16px', fontSize: '1.25rem', minHeight: '140px' } };\n\n const baseStyles = {\n width: '100%',\n fontFamily: theme.typography.fontFamily,\n borderRadius: theme.spacing(1),\n border: `2px solid ${error ? errorColor.main : theme.palette.divider}`,\n backgroundColor: theme.palette.background.paper,\n color: theme.palette.text.primary,\n transition: 'all 0.3s ease',\n resize: customVariant === 'resizable' ? 'vertical' : 'none',\n outline: 'none',\n ...sizeMap[customSize as keyof typeof sizeMap],\n\n '&::placeholder': {\n color: theme.palette.text.secondary,\n opacity: 0.7 },\n\n '&:hover': {\n borderColor: error ? errorColor.dark : colorPalette.main,\n backgroundColor: alpha(theme.palette.background.paper, 0.8) },\n\n '&:focus': {\n borderColor: error ? errorColor.main : colorPalette.main,\n backgroundColor: theme.palette.background.paper,\n boxShadow: `0 0 0 3px ${alpha(error ? errorColor.main : colorPalette.main, 0.1)}` } };\n\n // Glass morphism effect\n return {\n ...baseStyles,\n ...textareaEmphasisStyles({ theme, colorPalette, glass, gradient, glow }) };\n});\n\nconst StyledLabel = styled(InputLabel, {\n shouldForwardProp: (prop) => !['glass', 'error'].includes(prop as string) })<{ glass?: boolean; error?: boolean }>(({ theme, glass, error }) => ({\n marginBottom: theme.spacing(1),\n fontWeight: 500,\n color: error ? theme.palette.error.main : theme.palette.text.primary,\n ...(glass && {\n backgroundColor: alpha(theme.palette.background.paper, 0.1),\n backdropFilter: 'blur(10px)',\n padding: '4px 8px',\n borderRadius: '4px',\n border: `1px solid ${alpha(theme.palette.divider, 0.2)}`,\n display: 'inline-block' }) }));\n\n// IconWrapper - replaced with inline Box component for better TypeScript compatibility\n// const IconWrapper = styled(Box)<{ position: 'start' | 'end' }>(({ theme, position }) => {\n// const positionStyles = position === 'start' ? { left: '12px' } : { right: '12px' };\n// return {\n// position: 'absolute' as const,\n// top: '12px',\n// ...positionStyles,\n// color: theme.palette.text.secondary,\n// pointerEvents: 'none' as const,\n// zIndex: 1,\n// };\n// });\n\n// Rich text toolbar styling\n\nconst ICON_GUTTER = '40px';\n\nconst TEXTAREA_DEFAULTS = {\n variant: 'default',\n color: 'primary',\n size: 'md',\n error: false,\n glassLabel: false,\n glow: false,\n glass: false,\n gradient: false,\n iconPosition: 'start',\n minRows: 3 } satisfies Partial<TextareaProps>;\n\n// Strips explicitly-undefined props before the merge, so `prop={undefined}`\n// still falls back to the default as a destructuring default would.\nconst definedProps = (props: TextareaProps): Partial<TextareaProps> =>\n Object.fromEntries(\n Object.entries(props).filter(([, value]) => value !== undefined),\n ) as Partial<TextareaProps>;\n\n// Label above, helper text below — identical for the plain and rich variants,\n// which previously duplicated both.\nconst TextareaShell: React.FC<{\n testId?: string;\n label?: React.ReactNode;\n glassLabel: boolean;\n error: boolean;\n helperText?: React.ReactNode;\n children: React.ReactNode;\n}> = ({ testId, label, glassLabel, error, helperText, children }) => (\n <Box\n sx={{ position: 'relative', width: '100%' }}\n data-testid={testId ? `${testId}-wrapper` : undefined}\n >\n {label && (\n <StyledLabel glass={glassLabel} error={error}>\n {label}\n </StyledLabel>\n )}\n\n {children}\n\n {helperText && (\n <FormHelperText error={error} sx={{ mt: 1 }}>\n {helperText}\n </FormHelperText>\n )}\n </Box>\n);\n\nconst TextareaIcon: React.FC<{\n icon?: React.ReactNode;\n iconPosition: 'start' | 'end';\n}> = ({ icon, iconPosition }) => (\n <Box\n sx={{\n position: 'absolute',\n top: '12px',\n ...(iconPosition === 'start' ? { left: '12px' } : { right: '12px' }),\n color: 'text.secondary',\n pointerEvents: 'none',\n zIndex: 1 }}\n >\n {icon}\n </Box>\n);\n\n/**\n * The rich variant, kept out of the main component's body.\n *\n * Two reasons rather than one: the `Suspense` boundary and its props belong\n * together with the lazy import above, and the component that renders every\n * OTHER variant stays inside the size the complexity gate allows without\n * anything being suppressed.\n */\nfunction RichVariant({\n shell,\n editor }: {\n shell: Omit<React.ComponentProps<typeof TextareaShell>, 'children'>;\n editor: React.ComponentProps<typeof TextareaRichEditor>;\n}): React.JSX.Element {\n return (\n <TextareaShell {...shell}>\n {/*\n `null` rather than a spinner: the editor resolves from the same document\n the caller is already rendering, so a fallback would flash for a frame\n and read as a glitch rather than as loading.\n */}\n <Suspense fallback={null}>\n <TextareaRichEditor {...editor} />\n </Suspense>\n </TextareaShell>\n );\n}\n\nexport const Textarea: React.FC<TextareaProps> = (textareaProps) => {\n const {\n variant,\n color,\n size,\n error,\n helperText,\n label,\n glassLabel,\n glow,\n glass,\n gradient,\n icon,\n iconPosition,\n minRows,\n maxRows,\n style,\n 'data-testid': dataTestId,\n dataTestId: dataTestIdCamelCase,\n ...props\n } = { ...TEXTAREA_DEFAULTS, ...definedProps(textareaProps) };\n\n // Read off the props rather than the merged object: the spread widens every\n // key to optional, which would lose what the variant union already proved.\n const { richEditorCopy } = textareaProps;\n\n const [richTextValue, setRichTextValue] = useState('');\n const hasIcon = Boolean(icon);\n const testId = dataTestId || dataTestIdCamelCase;\n\n const textareaStyle = {\n ...style,\n // Same gap either side; only which side it applies to changes. The previous\n // version had `iconPosition === 'start' ? '40px' : '40px'`, a ternary whose\n // two branches were identical.\n ...(hasIcon && {\n [iconPosition === 'start' ? 'paddingLeft' : 'paddingRight']: ICON_GUTTER }) };\n\n // If rich text variant, use the rich text editor\n if (variant === 'rich' && richEditorCopy) {\n return (\n <RichVariant\n shell={{ testId, label, glassLabel, error, helperText }}\n editor={{\n copy: richEditorCopy,\n value: richTextValue,\n onChange: setRichTextValue,\n placeholder: props.placeholder,\n error,\n glass,\n color,\n characterLimit: props.maxLength }}\n />\n );\n }\n\n return (\n <TextareaShell testId={testId} label={label} glassLabel={glassLabel} error={error} helperText={helperText}>\n <Box sx={{ position: 'relative' }}>\n {hasIcon && <TextareaIcon icon={icon} iconPosition={iconPosition} />}\n\n <StyledTextarea\n customVariant={variant}\n customColor={color}\n customSize={size}\n glow={glow}\n glass={glass}\n gradient={gradient}\n error={error}\n minRows={variant === 'autosize' ? minRows : undefined}\n maxRows={variant === 'autosize' ? maxRows : undefined}\n style={textareaStyle}\n aria-label={label || props['aria-label']}\n data-testid={testId}\n {...props}\n />\n </Box>\n </TextareaShell>\n );\n};\n\nTextarea.displayName = 'Textarea';\n"],"mappings":";;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAAwB;AAE1B,SAAS,cAAc;AACvB,SAAgB,MAAM,UAAU,gBAAgB;AAyJ9C,SAKI,KALJ;AAnIF,IAAM,qBAAqB,KAAK,aAAa;AAAA,EAC3C,UAAU,MAAM,OAAO,mCAAsB,GAAG;AAAmB,EAAE;AAgBvE,IAAM,iBAAiB,OAAO,kBAAkB;AAAA,EAC9C,mBAAmB,CAAC,SAClB,CAAC,CAAC,iBAAiB,eAAe,cAAc,QAAQ,SAAS,YAAY,OAAO,EAAE;AAAA,IACpF;AAAA,EACF;AAAE,CAAC,EAAuB,CAAC;AAAA,EAC7B;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAM,MAAM;AACZ,MAAI,CAAC,MAAO,QAAO,CAAC;AACpB,QAAM,eAAe,kBAAkB,OAAO,WAAW;AACzD,QAAM,aAAa,MAAM,QAAQ;AAEjC,QAAM,UAAU;AAAA,IACd,IAAI,EAAE,SAAS,WAAW,UAAU,WAAW,WAAW,OAAO;AAAA,IACjE,IAAI,EAAE,SAAS,YAAY,UAAU,YAAY,WAAW,OAAO;AAAA,IACnE,IAAI,EAAE,SAAS,aAAa,UAAU,QAAQ,WAAW,QAAQ;AAAA,IACjE,IAAI,EAAE,SAAS,aAAa,UAAU,YAAY,WAAW,QAAQ;AAAA,IACrE,IAAI,EAAE,SAAS,aAAa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AC;AAAA;AAAA,QACC,eAAe;AAAA,QACf,aAAa;AAAA,QACb,YAAY;AAAA,QACZ;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,SAAS,YAAY,aAAa,UAAU;AAAA,QAC5C,SAAS,YAAY,aAAa,UAAU;AAAA,QAC5C,OAAO;AAAA,QACP,cAAY,SAAS,MAAM,YAAY;AAAA,QACvC,eAAa;AAAA,QACZ,GAAG;AAAA;AAAA,IACN;AAAA,KACF,GACF;AAEJ;AAEA,SAAS,cAAc;","names":[]}
@@ -1,22 +1,26 @@
1
1
  import React from 'react';
2
- /** `AAAA-MM-DD` (the wire) → `dd/mm/aaaa` (what the merchant reads). */
3
- export declare function isoToBr(iso: string): string;
2
+ /** `AAAA-MM-DD` (the wire) → the mask's own order (what the reader sees). */
3
+ export declare function isoToMasked(iso: string, mask: string): string;
4
4
  /**
5
- * `dd/mm/aaaa` → `AAAA-MM-DD`, but ONLY for a day that exists. `31/02/2026`
6
- * parses fine as three numbers and is not a date, and `Date` would silently
7
- * roll it into March rather than reject it — so the round trip through UTC is
8
- * the check: if the month or day comes back changed, the input was not a day.
5
+ * The mask's order → `AAAA-MM-DD`, but ONLY for a day that exists.
6
+ *
7
+ * `31/02/2026` parses fine as three numbers and is not a date, and `Date` would
8
+ * silently roll it into March rather than reject it — so the round trip through
9
+ * UTC is the check: if the month or day comes back changed, the input was not a
10
+ * day.
9
11
  */
10
- export declare function brToIso(text: string): string;
12
+ export declare function maskedToIso(text: string, mask: string): string;
11
13
  /**
12
- * Digits only, capped at eight, with the separators put back as you type.
14
+ * Digits only, capped at the mask's width, with the separators put back as you
15
+ * type.
13
16
  *
14
17
  * Deriving the whole string from the digits — rather than editing the text in
15
- * place — is what makes backspace behave. Four digits render as `06/08`, not
16
- * `06/08/`, so deleting the first digit of the year removes the trailing
17
- * separator with it instead of leaving a dead keystroke that changes nothing.
18
+ * place — is what makes backspace behave. Four digits of `dd/mm/aaaa` render as
19
+ * `06/08`, not `06/08/`, so deleting the first digit of the year removes the
20
+ * trailing separator with it instead of leaving a dead keystroke that changes
21
+ * nothing.
18
22
  */
19
- export declare function maskBrDate(raw: string): string;
23
+ export declare function maskDate(raw: string, mask: string): string;
20
24
  /**
21
25
  * One end of a day window. The BOUND stays `AAAA-MM-DD` — the form the backend's
22
26
  * inclusive day comparison already speaks, and the form the chip label reads —
@@ -1 +1 @@
1
- {"version":3,"file":"data-views-day-input.d.ts","sourceRoot":"","sources":["../../../../../src/components/data-display/DataViews/data-views-day-input.tsx"],"names":[],"mappings":"AA8BA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAGnD,wEAAwE;AACxE,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG3C;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAW5C;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK9C;AAgCD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,KAAK,EACL,QAAQ,EACR,MAAM,EACN,KAAa,EACb,WAAW,EACX,IAAI,GACL,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,+EAA+E;IAC/E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;;;;OASG;IACH,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAyCpB"}
1
+ {"version":3,"file":"data-views-day-input.d.ts","sourceRoot":"","sources":["../../../../../src/components/data-display/DataViews/data-views-day-input.tsx"],"names":[],"mappings":"AA8BA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAmDnD,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAW7D;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAiB9D;AAED;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAY1D;AAgCD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,KAAK,EACL,QAAQ,EACR,MAAM,EACN,KAAa,EACb,WAAW,EACX,IAAI,GACL,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,+EAA+E;IAC/E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;;;;OASG;IACH,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA2CpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"DateRangePicker.range.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/DateRangePicker/DateRangePicker.range.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,cAAc,EACrB,YAAY,CAAC,EAAE,MAAM,GACpB,eAAe,CAUjB;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,IAAI,uBAAuB,CAYzD;AAED,4EAA4E;AAC5E,wBAAgB,aAAa,CAC3B,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,uBAAuB,EACjC,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,MAAM,CAKR;AAED,iFAAiF;AACjF,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,UAAU,EAAE,EACzB,OAAO,EAAE,iBAAiB,EAC1B,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,kBAAkB,EAAE,CAWtB;AAED,4EAA4E;AAC5E,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,kBAAkB,EAAE,EAC7B,KAAK,EAAE,cAAc,GACpB,MAAM,GAAG,SAAS,CAIpB"}
1
+ {"version":3,"file":"DateRangePicker.range.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/DateRangePicker/DateRangePicker.range.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,cAAc,EACrB,YAAY,CAAC,EAAE,MAAM,GACpB,eAAe,CAUjB;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,IAAI,uBAAuB,CAiBzD;AAED,4EAA4E;AAC5E,wBAAgB,aAAa,CAC3B,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,uBAAuB,EACjC,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,MAAM,CAKR;AAED,iFAAiF;AACjF,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,UAAU,EAAE,EACzB,OAAO,EAAE,iBAAiB,EAC1B,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,kBAAkB,EAAE,CAWtB;AAED,4EAA4E;AAC5E,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,kBAAkB,EAAE,EAC7B,KAAK,EAAE,cAAc,GACpB,MAAM,GAAG,SAAS,CAIpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"Textarea.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/Textarea/Textarea.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAMxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAsKtD,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA+E5C,CAAC"}
1
+ {"version":3,"file":"Textarea.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/Textarea/Textarea.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAmC,MAAM,OAAO,CAAC;AAwBxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAkMtD,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA+E5C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@12-apps/ui",
3
- "version": "6.10.0",
3
+ "version": "6.11.0",
4
4
  "license": "MIT",
5
5
  "packageManager": "pnpm@10.34.5",
6
6
  "type": "module",
@@ -31,44 +31,117 @@ import { TextField } from '@mui/material';
31
31
  import React, { useEffect, useState } from 'react';
32
32
 
33
33
 
34
- /** `AAAA-MM-DD` (the wire) → `dd/mm/aaaa` (what the merchant reads). */
35
- export function isoToBr(iso: string): string {
34
+ /**
35
+ * THE MASK IS THE ORDER, and both halves of this file read it.
36
+ *
37
+ * The placeholder a host supplies (`copy.filters.dayMask` — `dd/mm/aaaa` for
38
+ * pt-BR, `mm/dd/yyyy` for en-US) is not decoration: it tells the reader which
39
+ * segment comes first. Everything below therefore derives the segment order
40
+ * FROM that same string, so the shape on screen and the shape the parser
41
+ * expects cannot disagree.
42
+ *
43
+ * They did disagree, and the failure was silent in the worst direction. The
44
+ * mask/parse pair was hardcoded day-first (the `Br` in the old names was
45
+ * accurate) while the placeholder followed the copy pack — so under `en-US` the
46
+ * field ASKED for `mm/dd/yyyy`, and a reader who typed exactly that got a day
47
+ * of 12 and a month of 31, which is not a date, which commits nothing. No
48
+ * error, no filter, a full list that reads like an answer. The en-US pack's own
49
+ * comment already said the mask "is the shape that gets a date entered
50
+ * backwards"; nothing enforced it.
51
+ */
52
+
53
+ /** What one segment of a mask is, and how many digits it takes. */
54
+ type DaySegment = 'year' | 'month' | 'day';
55
+ const SEGMENT_WIDTH: Readonly<Record<DaySegment, number>> = { year: 4, month: 2, day: 2 };
56
+
57
+ /**
58
+ * The segments a mask asks for, in its own order.
59
+ *
60
+ * Keyed on each token's FIRST letter so one rule covers every spelling a host
61
+ * might use — `aaaa`/`yyyy` for the year, `mm` for the month, `dd`/`tt` for the
62
+ * day. An unreadable mask falls back to day-first rather than throwing: this
63
+ * runs on every keystroke, and a field that renders is recoverable where one
64
+ * that crashes the grid is not.
65
+ */
66
+ function segmentsOf(mask: string): readonly DaySegment[] {
67
+ const tokens = mask.split(/[^A-Za-z]+/).filter(Boolean);
68
+ if (tokens.length !== 3) return ['day', 'month', 'year'];
69
+ const segments = tokens.map((token): DaySegment => {
70
+ const head = token.slice(0, 1).toLowerCase();
71
+ if (head === 'y' || head === 'a') return 'year';
72
+ return head === 'm' ? 'month' : 'day';
73
+ });
74
+ // A mask naming the same segment twice describes no date. Fall back rather
75
+ // than build a parser that can never succeed.
76
+ return new Set(segments).size === 3 ? segments : ['day', 'month', 'year'];
77
+ }
78
+
79
+ /** The separator the mask uses, defaulting to `/`. */
80
+ const separatorOf = (mask: string): string => mask.replace(/[A-Za-z]/g, '').slice(0, 1) || '/';
81
+
82
+ /** `AAAA-MM-DD` (the wire) → the mask's own order (what the reader sees). */
83
+ export function isoToMasked(iso: string, mask: string): string {
36
84
  const parts = /^(\d{4})-(\d{2})-(\d{2})$/.exec(iso);
37
- return parts ? `${parts[3]}/${parts[2]}/${parts[1]}` : '';
85
+ if (!parts) return '';
86
+ const value: Record<DaySegment, string> = {
87
+ year: parts[1] as string,
88
+ month: parts[2] as string,
89
+ day: parts[3] as string,
90
+ };
91
+ return segmentsOf(mask)
92
+ .map((segment) => value[segment])
93
+ .join(separatorOf(mask));
38
94
  }
39
95
 
40
96
  /**
41
- * `dd/mm/aaaa` → `AAAA-MM-DD`, but ONLY for a day that exists. `31/02/2026`
42
- * parses fine as three numbers and is not a date, and `Date` would silently
43
- * roll it into March rather than reject it — so the round trip through UTC is
44
- * the check: if the month or day comes back changed, the input was not a day.
97
+ * The mask's order → `AAAA-MM-DD`, but ONLY for a day that exists.
98
+ *
99
+ * `31/02/2026` parses fine as three numbers and is not a date, and `Date` would
100
+ * silently roll it into March rather than reject it — so the round trip through
101
+ * UTC is the check: if the month or day comes back changed, the input was not a
102
+ * day.
45
103
  */
46
- export function brToIso(text: string): string {
47
- const parts = /^(\d{2})\/(\d{2})\/(\d{4})$/.exec(text);
48
- if (!parts) return '';
49
- const [, dd, mm, yyyy] = parts;
50
- const day = Number(dd);
51
- const month = Number(mm);
52
- const year = Number(yyyy);
104
+ export function maskedToIso(text: string, mask: string): string {
105
+ const segments = segmentsOf(mask);
106
+ const digits = text.replace(/\D/g, '');
107
+ if (digits.length !== 8) return '';
108
+ const value = {} as Record<DaySegment, string>;
109
+ let cursor = 0;
110
+ for (const segment of segments) {
111
+ value[segment] = digits.slice(cursor, cursor + SEGMENT_WIDTH[segment]);
112
+ cursor += SEGMENT_WIDTH[segment];
113
+ }
114
+ const year = Number(value.year);
115
+ const month = Number(value.month);
116
+ const day = Number(value.day);
53
117
  if (year < 1000) return '';
54
118
  const probe = new Date(Date.UTC(year, month - 1, day));
55
119
  if (probe.getUTCMonth() !== month - 1 || probe.getUTCDate() !== day) return '';
56
- return `${yyyy}-${mm}-${dd}`;
120
+ return `${value.year}-${value.month}-${value.day}`;
57
121
  }
58
122
 
59
123
  /**
60
- * Digits only, capped at eight, with the separators put back as you type.
124
+ * Digits only, capped at the mask's width, with the separators put back as you
125
+ * type.
61
126
  *
62
127
  * Deriving the whole string from the digits — rather than editing the text in
63
- * place — is what makes backspace behave. Four digits render as `06/08`, not
64
- * `06/08/`, so deleting the first digit of the year removes the trailing
65
- * separator with it instead of leaving a dead keystroke that changes nothing.
128
+ * place — is what makes backspace behave. Four digits of `dd/mm/aaaa` render as
129
+ * `06/08`, not `06/08/`, so deleting the first digit of the year removes the
130
+ * trailing separator with it instead of leaving a dead keystroke that changes
131
+ * nothing.
66
132
  */
67
- export function maskBrDate(raw: string): string {
133
+ export function maskDate(raw: string, mask: string): string {
134
+ const segments = segmentsOf(mask);
135
+ const separator = separatorOf(mask);
68
136
  const digits = raw.replace(/\D/g, '').slice(0, 8);
69
- if (digits.length <= 2) return digits;
70
- if (digits.length <= 4) return `${digits.slice(0, 2)}/${digits.slice(2)}`;
71
- return `${digits.slice(0, 2)}/${digits.slice(2, 4)}/${digits.slice(4)}`;
137
+ const out: string[] = [];
138
+ let cursor = 0;
139
+ for (const segment of segments) {
140
+ if (cursor >= digits.length) break;
141
+ out.push(digits.slice(cursor, cursor + SEGMENT_WIDTH[segment]));
142
+ cursor += SEGMENT_WIDTH[segment];
143
+ }
144
+ return out.join(separator);
72
145
  }
73
146
 
74
147
  /**
@@ -142,7 +215,7 @@ export function DayBoundInput({
142
215
  mask: string;
143
216
  }): React.JSX.Element {
144
217
  const applied = value ?? '';
145
- const [text, setText] = useState(() => isoToBr(applied));
218
+ const [text, setText] = useState(() => isoToMasked(applied, mask));
146
219
 
147
220
  // The bound is the APPLIED filter; `text` is what is being typed. Re-sync only
148
221
  // when the applied value moved somewhere the text does not already mean — a
@@ -150,8 +223,10 @@ export function DayBoundInput({
150
223
  // guard the field's own write bounces straight back mid-edit and resets the
151
224
  // caret, which is the native control's worst habit reproduced by hand.
152
225
  useEffect(() => {
153
- setText((current) => (brToIso(current) === applied ? current : isoToBr(applied)));
154
- }, [applied]);
226
+ setText((current) =>
227
+ maskedToIso(current, mask) === applied ? current : isoToMasked(applied, mask),
228
+ );
229
+ }, [applied, mask]);
155
230
 
156
231
  return (
157
232
  <TextField
@@ -162,19 +237,19 @@ export function DayBoundInput({
162
237
  placeholder={mask}
163
238
  value={text}
164
239
  onChange={(event) => {
165
- const next = maskBrDate(event.target.value);
240
+ const next = maskDate(event.target.value, mask);
166
241
  setText(next);
167
242
  // Emptying clears the bound. A COMPLETE day applies it. A partial one
168
243
  // does NEITHER — it leaves whatever is applied alone, so typing is never
169
244
  // fought and a half-typed year never reaches the backend.
170
245
  if (next === '') return onChange(undefined);
171
- const iso = brToIso(next);
246
+ const iso = maskedToIso(next, mask);
172
247
  if (iso) onChange(iso);
173
248
  }}
174
249
  // Leaving a half-typed (or impossible) date on screen would show a filter
175
250
  // the list is not actually using. On blur the field snaps back to what IS
176
251
  // applied; a complete date already equals it, so this only ever tidies.
177
- onBlur={() => setText(isoToBr(applied))}
252
+ onBlur={() => setText(isoToMasked(applied, mask))}
178
253
  // The placeholder occupies the space an un-shrunk label would render into.
179
254
  InputLabelProps={{ shrink: true }}
180
255
  inputProps={dayInputProps(testId, describedBy)}
@@ -7,7 +7,7 @@
7
7
  * indistinguishable from one that ignored you. The caller reads
8
8
  * {@link DateRangeStatus} and keeps its own confirm button shut.
9
9
  */
10
- import { isoToBr } from '../../data-display/DataViews/data-views-day-input';
10
+ import { isoToMasked } from '../../data-display/DataViews/data-views-day-input';
11
11
 
12
12
  import { dayCount, isAfterDay } from './DateRangePicker.dates';
13
13
  import type {
@@ -53,6 +53,11 @@ export function resolveDayRange(
53
53
  * moves both halves of the decision to the same place.
54
54
  */
55
55
  export function defaultMessages(): DateRangePickerMessages {
56
+ // ONE mask, read by both the fields and the summary below. They are the same
57
+ // date in the same control, so a summary formatted in a different order from
58
+ // the boxes it summarises is a control arguing with itself — which is what
59
+ // two independent literals eventually become.
60
+ const dayMask = 'dd/mm/yyyy';
56
61
  return {
57
62
  from: 'Start date',
58
63
  to: 'End date',
@@ -60,9 +65,9 @@ export function defaultMessages(): DateRangePickerMessages {
60
65
  incomplete: 'Choose both dates.',
61
66
  reversed: 'The end date must be on or after the start date.',
62
67
  overMax: ({ maxRangeDays }) => `Choose a range of at most ${maxRangeDays} days.`,
63
- summary: ({ from, to }) => `${isoToBr(from)} – ${isoToBr(to)}`,
68
+ summary: ({ from, to }) => `${isoToMasked(from, dayMask)} – ${isoToMasked(to, dayMask)}`,
64
69
  calendarLabel: 'Calendar',
65
- dayMask: 'dd/mm/yyyy',
70
+ dayMask,
66
71
  };
67
72
  }
68
73
 
@@ -6,12 +6,30 @@ import {
6
6
  TextareaAutosize } from '@mui/material';
7
7
  import type { Theme } from '@mui/material';
8
8
  import { styled } from '@mui/material';
9
- import React, { useState } from 'react';
9
+ import React, { lazy, Suspense, useState } from 'react';
10
10
 
11
11
  import {
12
12
  getColorFromTheme,
13
13
  textareaEmphasisStyles } from './Textarea.styles';
14
- import { TextareaRichEditor } from './TextareaRichEditor';
14
+
15
+ /**
16
+ * The rich editor is LOADED ON DEMAND, not imported (12-51 follow-up).
17
+ *
18
+ * It renders only for `variant === 'rich'`, but a static import made every
19
+ * consumer of a plain `<Textarea>` pay for it — 387 lines of toolbar plus the
20
+ * MUI `Tooltip`, `IconButton` and `Divider` its formatting buttons need. That
21
+ * is not theoretical: an adopting storefront imports this entry for a one-line
22
+ * order note, and `Tooltip` (8.7 KiB) reached its EAGER chunk through here
23
+ * while nothing on that critical path renders a tooltip at all.
24
+ *
25
+ * `variant` is a prop, so the branch cannot be decided at build time and no
26
+ * amount of tree-shaking removes it. A lazy boundary is what expresses "only
27
+ * the rich variant pays", and it costs the rich variant one microtask it can
28
+ * afford — it is a text editor a user has already chosen to open, never a
29
+ * first-paint element.
30
+ */
31
+ const TextareaRichEditor = lazy(async () => ({
32
+ default: (await import('./TextareaRichEditor')).TextareaRichEditor }));
15
33
  import type { TextareaProps } from './Textarea.types';
16
34
 
17
35
  // Interface for styled component props
@@ -178,6 +196,34 @@ const TextareaIcon: React.FC<{
178
196
  </Box>
179
197
  );
180
198
 
199
+ /**
200
+ * The rich variant, kept out of the main component's body.
201
+ *
202
+ * Two reasons rather than one: the `Suspense` boundary and its props belong
203
+ * together with the lazy import above, and the component that renders every
204
+ * OTHER variant stays inside the size the complexity gate allows without
205
+ * anything being suppressed.
206
+ */
207
+ function RichVariant({
208
+ shell,
209
+ editor }: {
210
+ shell: Omit<React.ComponentProps<typeof TextareaShell>, 'children'>;
211
+ editor: React.ComponentProps<typeof TextareaRichEditor>;
212
+ }): React.JSX.Element {
213
+ return (
214
+ <TextareaShell {...shell}>
215
+ {/*
216
+ `null` rather than a spinner: the editor resolves from the same document
217
+ the caller is already rendering, so a fallback would flash for a frame
218
+ and read as a glitch rather than as loading.
219
+ */}
220
+ <Suspense fallback={null}>
221
+ <TextareaRichEditor {...editor} />
222
+ </Suspense>
223
+ </TextareaShell>
224
+ );
225
+ }
226
+
181
227
  export const Textarea: React.FC<TextareaProps> = (textareaProps) => {
182
228
  const {
183
229
  variant,
@@ -219,18 +265,18 @@ export const Textarea: React.FC<TextareaProps> = (textareaProps) => {
219
265
  // If rich text variant, use the rich text editor
220
266
  if (variant === 'rich' && richEditorCopy) {
221
267
  return (
222
- <TextareaShell testId={testId} label={label} glassLabel={glassLabel} error={error} helperText={helperText}>
223
- <TextareaRichEditor
224
- copy={richEditorCopy}
225
- value={richTextValue}
226
- onChange={setRichTextValue}
227
- placeholder={props.placeholder}
228
- error={error}
229
- glass={glass}
230
- color={color}
231
- characterLimit={props.maxLength}
232
- />
233
- </TextareaShell>
268
+ <RichVariant
269
+ shell={{ testId, label, glassLabel, error, helperText }}
270
+ editor={{
271
+ copy: richEditorCopy,
272
+ value: richTextValue,
273
+ onChange: setRichTextValue,
274
+ placeholder: props.placeholder,
275
+ error,
276
+ glass,
277
+ color,
278
+ characterLimit: props.maxLength }}
279
+ />
234
280
  );
235
281
  }
236
282
 
@@ -1,78 +0,0 @@
1
- // src/components/data-display/DataViews/data-views-day-input.tsx
2
- import { TextField } from "@mui/material";
3
- import { useEffect, useState } from "react";
4
- import { jsx } from "react/jsx-runtime";
5
- function isoToBr(iso) {
6
- const parts = /^(\d{4})-(\d{2})-(\d{2})$/.exec(iso);
7
- return parts ? `${parts[3]}/${parts[2]}/${parts[1]}` : "";
8
- }
9
- function brToIso(text) {
10
- const parts = /^(\d{2})\/(\d{2})\/(\d{4})$/.exec(text);
11
- if (!parts) return "";
12
- const [, dd, mm, yyyy] = parts;
13
- const day = Number(dd);
14
- const month = Number(mm);
15
- const year = Number(yyyy);
16
- if (year < 1e3) return "";
17
- const probe = new Date(Date.UTC(year, month - 1, day));
18
- if (probe.getUTCMonth() !== month - 1 || probe.getUTCDate() !== day) return "";
19
- return `${yyyy}-${mm}-${dd}`;
20
- }
21
- function maskBrDate(raw) {
22
- const digits = raw.replace(/\D/g, "").slice(0, 8);
23
- if (digits.length <= 2) return digits;
24
- if (digits.length <= 4) return `${digits.slice(0, 2)}/${digits.slice(2)}`;
25
- return `${digits.slice(0, 2)}/${digits.slice(2, 4)}/${digits.slice(4)}`;
26
- }
27
- function dayInputProps(testId, describedBy) {
28
- return {
29
- "data-testid": testId,
30
- maxLength: 10,
31
- inputMode: "numeric",
32
- autoComplete: "off",
33
- ...describedBy ? { "aria-describedby": describedBy } : {}
34
- };
35
- }
36
- function DayBoundInput({
37
- label,
38
- value,
39
- onChange,
40
- testId,
41
- error = false,
42
- describedBy,
43
- mask
44
- }) {
45
- const applied = value ?? "";
46
- const [text, setText] = useState(() => isoToBr(applied));
47
- useEffect(() => {
48
- setText((current) => brToIso(current) === applied ? current : isoToBr(applied));
49
- }, [applied]);
50
- return /* @__PURE__ */ jsx(
51
- TextField,
52
- {
53
- size: "small",
54
- type: "text",
55
- label,
56
- error,
57
- placeholder: mask,
58
- value: text,
59
- onChange: (event) => {
60
- const next = maskBrDate(event.target.value);
61
- setText(next);
62
- if (next === "") return onChange(void 0);
63
- const iso = brToIso(next);
64
- if (iso) onChange(iso);
65
- },
66
- onBlur: () => setText(isoToBr(applied)),
67
- InputLabelProps: { shrink: true },
68
- inputProps: dayInputProps(testId, describedBy),
69
- sx: { width: 165 }
70
- }
71
- );
72
- }
73
-
74
- export {
75
- isoToBr,
76
- DayBoundInput
77
- };
78
- //# sourceMappingURL=chunk-TSG5C7MP.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/data-display/DataViews/data-views-day-input.tsx"],"sourcesContent":["'use client';\n\n/**\n * A day bound as a MASKED `dd/mm/aaaa` text field, replacing `<input type=\"date\">`.\n *\n * The native control is three separate segments wearing one box. Typing a date\n * means filling a segment, being jumped to the next, and starting over — and\n * which segment comes first is the BROWSER's locale, not ours, so the same\n * field reads `dd/mm/aaaa` for one merchant and `mm/dd/yyyy` for the next with\n * nothing in our code saying which. There is no way to type a date as one\n * continuous run of digits, which is how people actually type dates.\n *\n * A mask gives that back: eight digits straight through, separators inserted as\n * you go, backspace walking back through them.\n *\n * Measured, driving both controls in Chromium with the same eight keystrokes\n * (`01072026`, one `keydown` at a time):\n *\n * native → field ends EMPTY, no filter applied, 0 requests\n * masked → field reads `01/07/2026`, filter applied, 1 request\n *\n * The native result is the whole complaint: you type a date and nothing lands.\n *\n * The second half of the fix is WHEN the bound is written. A partially-typed\n * year is itself a valid date — `2026` passes through `0002`, `0020`, `0202` on\n * the way — so committing on every keystroke would send the grid off to fetch\n * years nobody meant. A bound is written only once the text is a WHOLE, real\n * date, which is what keeps the run above at one request rather than four.\n */\nimport { TextField } from '@mui/material';\nimport React, { useEffect, useState } from 'react';\n\n\n/** `AAAA-MM-DD` (the wire) → `dd/mm/aaaa` (what the merchant reads). */\nexport function isoToBr(iso: string): string {\n const parts = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(iso);\n return parts ? `${parts[3]}/${parts[2]}/${parts[1]}` : '';\n}\n\n/**\n * `dd/mm/aaaa` → `AAAA-MM-DD`, but ONLY for a day that exists. `31/02/2026`\n * parses fine as three numbers and is not a date, and `Date` would silently\n * roll it into March rather than reject it — so the round trip through UTC is\n * the check: if the month or day comes back changed, the input was not a day.\n */\nexport function brToIso(text: string): string {\n const parts = /^(\\d{2})\\/(\\d{2})\\/(\\d{4})$/.exec(text);\n if (!parts) return '';\n const [, dd, mm, yyyy] = parts;\n const day = Number(dd);\n const month = Number(mm);\n const year = Number(yyyy);\n if (year < 1000) return '';\n const probe = new Date(Date.UTC(year, month - 1, day));\n if (probe.getUTCMonth() !== month - 1 || probe.getUTCDate() !== day) return '';\n return `${yyyy}-${mm}-${dd}`;\n}\n\n/**\n * Digits only, capped at eight, with the separators put back as you type.\n *\n * Deriving the whole string from the digits — rather than editing the text in\n * place — is what makes backspace behave. Four digits render as `06/08`, not\n * `06/08/`, so deleting the first digit of the year removes the trailing\n * separator with it instead of leaving a dead keystroke that changes nothing.\n */\nexport function maskBrDate(raw: string): string {\n const digits = raw.replace(/\\D/g, '').slice(0, 8);\n if (digits.length <= 2) return digits;\n if (digits.length <= 4) return `${digits.slice(0, 2)}/${digits.slice(2)}`;\n return `${digits.slice(0, 2)}/${digits.slice(2, 4)}/${digits.slice(4)}`;\n}\n\n/**\n * What has to land on the `<input>` itself rather than on the `TextField`.\n *\n * Anything `TextField` does not recognise is spread onto its root `FormControl`\n * div. `inputMode` went up there once: the attribute sat on a non-editable\n * wrapper, meant nothing, and the phone went on offering the letter keyboard\n * for a field that only takes digits (the `dd/mm/aaaa` hint under a QWERTY\n * layout). Only the `<input>` this reaches decides which keypad opens — and the\n * same is true of `aria-describedby`, which on the wrapper points at a\n * description no screen reader will read out for the field.\n *\n * `numeric` and not `tel`: both raise a keypad, but the phone one is a dialler\n * with `+ * #` on it — keys that cannot occur in a date. A paste carrying\n * separators still lands, because the MASK is what filters the text; the keypad\n * only narrows what a thumb can reach for.\n *\n * Autofill off for the same reason: the browser's saved-value strip covers the\n * keypad to suggest names and addresses, none of which are a date, and none of\n * which the mask would keep.\n */\nfunction dayInputProps(testId: string, describedBy: string | undefined) {\n return {\n 'data-testid': testId,\n maxLength: 10,\n inputMode: 'numeric' as const,\n autoComplete: 'off',\n ...(describedBy ? { 'aria-describedby': describedBy } : {}),\n };\n}\n\n/**\n * One end of a day window. The BOUND stays `AAAA-MM-DD` — the form the backend's\n * inclusive day comparison already speaks, and the form the chip label reads —\n * so only the typing surface changes.\n */\nexport function DayBoundInput({\n label,\n value,\n onChange,\n testId,\n error = false,\n describedBy,\n mask,\n}: {\n label: string;\n /** The applied bound, `AAAA-MM-DD`, or undefined when this end is open. */\n value: string | undefined;\n onChange: (bound: string | undefined) => void;\n testId: string;\n /**\n * Paint the field as rejected. It only ever writes a real day by itself, so\n * this is for a caller judging the PAIR: a window whose end precedes its\n * start is two valid days and one impossible period, and the field it was\n * typed into is the only place to say which half is being complained about.\n */\n error?: boolean;\n /** Id of the element carrying that complaint, so it is read WITH the field. */\n describedBy?: string;\n /**\n * The day mask, which IS the placeholder — so the expected ORDER is on\n * screen before the first keystroke rather than discovered by getting it\n * wrong. `dd/mm/aaaa` is one locale's order and one locale's letters.\n *\n * A PROP rather than a context read: this field has two callers, and only\n * one of them is inside DataViews. `DateRangePicker` mounts it standalone\n * with its own message table, so a context read here throws for every host\n * of that picker — which is exactly what it did.\n */\n mask: string;\n}): React.JSX.Element {\n const applied = value ?? '';\n const [text, setText] = useState(() => isoToBr(applied));\n\n // The bound is the APPLIED filter; `text` is what is being typed. Re-sync only\n // when the applied value moved somewhere the text does not already mean — a\n // \"Limpar\", a saved view, the other pill resetting the pair. Without that\n // guard the field's own write bounces straight back mid-edit and resets the\n // caret, which is the native control's worst habit reproduced by hand.\n useEffect(() => {\n setText((current) => (brToIso(current) === applied ? current : isoToBr(applied)));\n }, [applied]);\n\n return (\n <TextField\n size=\"small\"\n type=\"text\"\n label={label}\n error={error}\n placeholder={mask}\n value={text}\n onChange={(event) => {\n const next = maskBrDate(event.target.value);\n setText(next);\n // Emptying clears the bound. A COMPLETE day applies it. A partial one\n // does NEITHER — it leaves whatever is applied alone, so typing is never\n // fought and a half-typed year never reaches the backend.\n if (next === '') return onChange(undefined);\n const iso = brToIso(next);\n if (iso) onChange(iso);\n }}\n // Leaving a half-typed (or impossible) date on screen would show a filter\n // the list is not actually using. On blur the field snaps back to what IS\n // applied; a complete date already equals it, so this only ever tidies.\n onBlur={() => setText(isoToBr(applied))}\n // The placeholder occupies the space an un-shrunk label would render into.\n InputLabelProps={{ shrink: true }}\n inputProps={dayInputProps(testId, describedBy)}\n sx={{ width: 165 }}\n />\n );\n}\n"],"mappings":";AA6BA,SAAS,iBAAiB;AAC1B,SAAgB,WAAW,gBAAgB;AA8HvC;AA1HG,SAAS,QAAQ,KAAqB;AAC3C,QAAM,QAAQ,4BAA4B,KAAK,GAAG;AAClD,SAAO,QAAQ,GAAG,MAAM,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,KAAK;AACzD;AAQO,SAAS,QAAQ,MAAsB;AAC5C,QAAM,QAAQ,8BAA8B,KAAK,IAAI;AACrD,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,CAAC,EAAE,IAAI,IAAI,IAAI,IAAI;AACzB,QAAM,MAAM,OAAO,EAAE;AACrB,QAAM,QAAQ,OAAO,EAAE;AACvB,QAAM,OAAO,OAAO,IAAI;AACxB,MAAI,OAAO,IAAM,QAAO;AACxB,QAAM,QAAQ,IAAI,KAAK,KAAK,IAAI,MAAM,QAAQ,GAAG,GAAG,CAAC;AACrD,MAAI,MAAM,YAAY,MAAM,QAAQ,KAAK,MAAM,WAAW,MAAM,IAAK,QAAO;AAC5E,SAAO,GAAG,IAAI,IAAI,EAAE,IAAI,EAAE;AAC5B;AAUO,SAAS,WAAW,KAAqB;AAC9C,QAAM,SAAS,IAAI,QAAQ,OAAO,EAAE,EAAE,MAAM,GAAG,CAAC;AAChD,MAAI,OAAO,UAAU,EAAG,QAAO;AAC/B,MAAI,OAAO,UAAU,EAAG,QAAO,GAAG,OAAO,MAAM,GAAG,CAAC,CAAC,IAAI,OAAO,MAAM,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