Skip to content

Commit 82d808b

Browse files
committed
rename method
1 parent 2bd21f0 commit 82d808b

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

packages/components/src/DateTimeInput.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ it('onSubmit works correctly', async () => {
159159
unmount();
160160
});
161161

162-
describe('normalizePastedText', () => {
162+
describe('normalizeText', () => {
163163
it('replaces T separator with space for ISO 8601 format', async () => {
164164
const user = userEvent.setup();
165165
const onChange = jest.fn();

packages/components/src/DateTimeInput.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ export const DateTimeInput = React.forwardRef<
6767
const [selection, setSelection] = useState<SelectionSegment>();
6868

6969
/**
70-
* Normalize pasted text by:
70+
* Normalize text by:
7171
* - Replacing 'T' with space to support ISO 8601 format
7272
* - Removing timezone information (e.g., "EDT", "+05:00", "Z")
7373
* - Adding zero-width space separators in the nanosecond part
74-
* @param text The pasted text
74+
* @param text The text
7575
* @returns The normalized text
7676
*/
77-
const normalizePastedText = useCallback((text: string): string => {
77+
const normalizeText = useCallback((text: string): string => {
7878
// Replace first 'T' separator with space for ISO 8601 format (without global flag to preserve 'T' in timezone like EDT)
7979
let normalized = text.replace(/T/, ' ');
8080

@@ -97,15 +97,15 @@ export const DateTimeInput = React.forwardRef<
9797
// Apply normalization to handle raw unformatted values (e.g., with timezone info)
9898
useEffect(() => {
9999
if (defaultValue.length > 0) {
100-
const normalized = normalizePastedText(defaultValue);
100+
const normalized = normalizeText(defaultValue);
101101
setValue(normalized);
102102
// Notify parent with the normalized value (without separators)
103103
onChange(fixIncompleteValue(removeSeparators(normalized)));
104104
} else {
105105
setValue('');
106106
onChange('');
107107
}
108-
}, [defaultValue, normalizePastedText, onChange]);
108+
}, [defaultValue, normalizeText, onChange]);
109109

110110
const handleChange = useCallback(
111111
(newValue: string): void => {
@@ -134,7 +134,7 @@ export const DateTimeInput = React.forwardRef<
134134
className={classNames(className)}
135135
example={EXAMPLES}
136136
getNextSegmentValue={getNextSegmentValue}
137-
normalizePastedText={normalizePastedText}
137+
normalizePastedText={normalizeText}
138138
onChange={handleChange}
139139
onSelect={setSelection}
140140
onSubmit={onSubmit}

0 commit comments

Comments
 (0)