@cleartrip/ct-design-field 5.6.0 → 5.7.0-SNAPSHOT-native-main.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Field.d.ts.map +1 -1
- package/dist/Field.native.d.ts +6 -0
- package/dist/Field.native.d.ts.map +1 -0
- package/dist/Input.d.ts.map +1 -1
- package/dist/Label.d.ts.map +1 -1
- package/dist/TextAreaInput.d.ts.map +1 -1
- package/dist/ct-design-field.browser.cjs.js +3 -3
- package/dist/ct-design-field.browser.cjs.js.map +1 -1
- package/dist/ct-design-field.browser.esm.js +3 -3
- package/dist/ct-design-field.browser.esm.js.map +1 -1
- package/dist/ct-design-field.cjs.js +79 -94
- package/dist/ct-design-field.cjs.js.map +1 -1
- package/dist/ct-design-field.esm.js +79 -94
- package/dist/ct-design-field.esm.js.map +1 -1
- package/dist/ct-design-field.umd.js +82 -97
- package/dist/ct-design-field.umd.js.map +1 -1
- package/dist/style.d.ts +0 -10
- package/dist/style.d.ts.map +1 -1
- package/dist/variants/Phone/index.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/Field.native.tsx +204 -0
- package/src/Field.tsx +19 -4
- package/src/Input.tsx +36 -39
- package/src/Label.tsx +30 -13
- package/src/TextAreaInput.tsx +27 -27
- package/src/style.ts +7 -3
- package/src/variants/Phone/Prefix/index.tsx +7 -7
- package/src/variants/Phone/index.tsx +6 -19
|
@@ -5,10 +5,10 @@ import { makeStyles, useStyles, useWebMergeStyles } from '@cleartrip/ct-design-s
|
|
|
5
5
|
import { Container } from '@cleartrip/ct-design-container';
|
|
6
6
|
import { TypographyVariant, Typography, TypographyColor } from '@cleartrip/ct-design-typography';
|
|
7
7
|
import { css } from '@emotion/css';
|
|
8
|
+
import { useTheme } from '@cleartrip/ct-design-theme';
|
|
8
9
|
import { __rest } from 'tslib';
|
|
9
10
|
import { Divider } from '@cleartrip/ct-design-divider';
|
|
10
11
|
import { ONLY_NUMERIC } from '@cleartrip/ct-design-common-constants';
|
|
11
|
-
import { useTheme } from '@cleartrip/ct-design-theme';
|
|
12
12
|
import { isIOS } from '@cleartrip/ct-design-common-utils';
|
|
13
13
|
import useMergeRefs from '@cleartrip/ct-design-use-merge-refs';
|
|
14
14
|
import { DottedLoader } from '@cleartrip/ct-design-dotted-loader';
|
|
@@ -26,13 +26,14 @@ var FieldType;
|
|
|
26
26
|
})(FieldType || (FieldType = {}));
|
|
27
27
|
|
|
28
28
|
const getFieldContainerBorderStyle = ({ theme, hasError, focus, disabled, }) => {
|
|
29
|
+
const borderWidth = theme.border.width.md;
|
|
29
30
|
if (hasError) {
|
|
30
|
-
return { borderStyle: 'solid', borderColor: theme.color.border.warning, borderWidth
|
|
31
|
+
return { borderStyle: 'solid', borderColor: theme.color.border.warning, borderWidth };
|
|
31
32
|
}
|
|
32
33
|
if (focus && !disabled) {
|
|
33
|
-
return { borderStyle: 'solid', borderColor: theme.color.border.primary, borderWidth
|
|
34
|
+
return { borderStyle: 'solid', borderColor: theme.color.border.primary, borderWidth };
|
|
34
35
|
}
|
|
35
|
-
return { borderStyle: 'solid', borderColor: theme.color.border.disabledDark, borderWidth
|
|
36
|
+
return { borderStyle: 'solid', borderColor: theme.color.border.disabledDark, borderWidth };
|
|
36
37
|
};
|
|
37
38
|
const getFieldSpacingAndHeight = ({ isLabeledPlaceholder, theme, variant, focus, value, disabledPlaceHolder, customSpacingTop = 4, }) => {
|
|
38
39
|
const isFieldNotEmpty = focus || value.length > 0;
|
|
@@ -274,26 +275,19 @@ const styles$4 = css `
|
|
|
274
275
|
outline: none;
|
|
275
276
|
}
|
|
276
277
|
`;
|
|
277
|
-
const staticStyles$5 = makeStyles((
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
lineHeight: theme.typography.lineHeight[24],
|
|
286
|
-
},
|
|
287
|
-
};
|
|
288
|
-
});
|
|
289
|
-
const InputFieldCore$1 = forwardRef(({ value, disabled, styleConfig, onChange, onFocus, onBlur, onKeyDown, onSelect, onPressIn, placeholder, autoFocus, readOnly, type, inputMode, autoCapitalize, fieldTypographyVariant, variant, prefix, focus, placeholderType, id, maxLength, }, forwardedRef) => {
|
|
278
|
+
const staticStyles$5 = makeStyles(() => ({
|
|
279
|
+
root: {
|
|
280
|
+
border: 'none',
|
|
281
|
+
outline: 'none',
|
|
282
|
+
},
|
|
283
|
+
}));
|
|
284
|
+
const InputFieldCore$1 = forwardRef(({ value, disabled, styleConfig, onChange, onFocus, onBlur, onKeyDown, onSelect, onPressIn, placeholder, autoFocus, readOnly, type, inputMode, autoCapitalize, fieldTypographyVariant, variant, focus, placeholderType, prefix, cursorColor, id, maxLength, }, forwardedRef) => {
|
|
285
|
+
const theme = useTheme();
|
|
290
286
|
const inputRef = useRef(null);
|
|
291
|
-
const { field = [] } = styleConfig !== null && styleConfig !== void 0 ? styleConfig : {};
|
|
287
|
+
const { field = [], root = [] } = styleConfig !== null && styleConfig !== void 0 ? styleConfig : {};
|
|
292
288
|
const isPrefixComponent = isValidElement(prefix);
|
|
293
289
|
const disabledPlaceHolder = !(placeholder === null || placeholder === void 0 ? void 0 : placeholder.length);
|
|
294
|
-
const
|
|
295
|
-
root: getTypographyVariant(theme, fieldTypographyVariant !== null && fieldTypographyVariant !== void 0 ? fieldTypographyVariant : 'HM2'),
|
|
296
|
-
}), [fieldTypographyVariant]);
|
|
290
|
+
const inputPlaceholder = placeholderType === 'labeled' && focus ? '' : placeholder;
|
|
297
291
|
const fieldStyles = useStyles((theme) => {
|
|
298
292
|
return {
|
|
299
293
|
root: getFieldStyles({
|
|
@@ -309,7 +303,10 @@ const InputFieldCore$1 = forwardRef(({ value, disabled, styleConfig, onChange, o
|
|
|
309
303
|
}),
|
|
310
304
|
};
|
|
311
305
|
}, [disabled, variant, focus, value, type, isPrefixComponent, disabledPlaceHolder]);
|
|
312
|
-
const
|
|
306
|
+
const typographyStyles = useStyles((theme) => ({
|
|
307
|
+
root: fieldTypographyVariant ? getTypographyVariant(theme, fieldTypographyVariant) : {},
|
|
308
|
+
}), [fieldTypographyVariant]);
|
|
309
|
+
const mergedStyles = useWebMergeStyles([staticStyles$5.root, styles$4, fieldStyles.root, typographyStyles.root, ...root, ...field], [fieldStyles.root, typographyStyles.root, root, field]);
|
|
313
310
|
useImperativeHandle(forwardedRef, () => ({
|
|
314
311
|
focus: () => {
|
|
315
312
|
var _a;
|
|
@@ -336,6 +333,7 @@ const InputFieldCore$1 = forwardRef(({ value, disabled, styleConfig, onChange, o
|
|
|
336
333
|
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.setSelectionRange(start, end);
|
|
337
334
|
},
|
|
338
335
|
},
|
|
336
|
+
preventDefault: () => event.preventDefault(),
|
|
339
337
|
});
|
|
340
338
|
}, [onChange]);
|
|
341
339
|
const handleOnFocus = useCallback((event) => {
|
|
@@ -412,21 +410,7 @@ const InputFieldCore$1 = forwardRef(({ value, disabled, styleConfig, onChange, o
|
|
|
412
410
|
preventDefault: () => event.preventDefault(),
|
|
413
411
|
});
|
|
414
412
|
}, [onPressIn]);
|
|
415
|
-
|
|
416
|
-
onChange: handleOnChange,
|
|
417
|
-
onFocus: handleOnFocus,
|
|
418
|
-
onBlur: handleOnBlur,
|
|
419
|
-
onKeyDown: handleOnKeyDown,
|
|
420
|
-
onSelect: handleOnSelect,
|
|
421
|
-
onMouseDown: handleOnPressIn,
|
|
422
|
-
placeholder,
|
|
423
|
-
autoFocus,
|
|
424
|
-
readOnly,
|
|
425
|
-
type,
|
|
426
|
-
inputMode,
|
|
427
|
-
autoCapitalize,
|
|
428
|
-
};
|
|
429
|
-
return (jsx("input", Object.assign({ maxLength: maxLength, id: id, ref: inputRef, value: value, disabled: disabled, className: mergedStyles }, webProps)));
|
|
413
|
+
return (jsx("input", { maxLength: maxLength, id: id, ref: inputRef, value: value, disabled: disabled, readOnly: readOnly, className: mergedStyles, style: { caretColor: cursorColor || theme.color.text.primary }, onChange: handleOnChange, onFocus: handleOnFocus, onBlur: handleOnBlur, onKeyDown: handleOnKeyDown, onSelect: handleOnSelect, onMouseDown: handleOnPressIn, placeholder: inputPlaceholder, autoFocus: autoFocus, type: type, inputMode: inputMode, autoCapitalize: autoCapitalize }));
|
|
430
414
|
});
|
|
431
415
|
InputFieldCore$1.displayName = 'InputFieldCore';
|
|
432
416
|
|
|
@@ -435,11 +419,16 @@ const staticStyles$4 = makeStyles((theme) => {
|
|
|
435
419
|
root: {
|
|
436
420
|
position: 'absolute',
|
|
437
421
|
paddingLeft: theme.spacing[4],
|
|
422
|
+
paddingRight: theme.spacing[4],
|
|
438
423
|
width: '100%',
|
|
439
424
|
height: '100%',
|
|
440
425
|
display: 'flex',
|
|
441
|
-
transform: [{ translateY: 0 }],
|
|
442
426
|
top: 16,
|
|
427
|
+
pointerEvents: 'none',
|
|
428
|
+
boxSizing: 'border-box',
|
|
429
|
+
},
|
|
430
|
+
rootSM: {
|
|
431
|
+
top: 8,
|
|
443
432
|
},
|
|
444
433
|
};
|
|
445
434
|
});
|
|
@@ -448,29 +437,37 @@ const FieldLabelWrapper = ({ variant, type, value, focus = false, placeholder, p
|
|
|
448
437
|
const { placeholderLabel = [], placeholderTypography = {} } = placeholderStyleConfig !== null && placeholderStyleConfig !== void 0 ? placeholderStyleConfig : {};
|
|
449
438
|
const shiftPlaceholder = placeholderType === 'floating';
|
|
450
439
|
const isPrefixComponent = isValidElement(prefix);
|
|
440
|
+
const fieldType = type !== null && type !== void 0 ? type : FieldType.TEXT;
|
|
451
441
|
const baseStyles = useStyles((theme) => ({
|
|
452
442
|
root: getFieldPlaceholderStyles({
|
|
453
443
|
theme,
|
|
454
444
|
isFocused: focus,
|
|
455
445
|
disabled,
|
|
456
446
|
variant: variant !== null && variant !== void 0 ? variant : 'md',
|
|
457
|
-
fieldType
|
|
447
|
+
fieldType,
|
|
458
448
|
isPrefixComponent,
|
|
459
449
|
shiftPlaceholder,
|
|
460
450
|
}),
|
|
461
451
|
}), [focus, disabled, variant, type, isPrefixComponent, shiftPlaceholder]);
|
|
462
|
-
const labelStyles = useWebMergeStyles([
|
|
452
|
+
const labelStyles = useWebMergeStyles([
|
|
453
|
+
staticStyles$4.root,
|
|
454
|
+
variant === FieldVariant.SM ? staticStyles$4.rootSM : undefined,
|
|
455
|
+
baseStyles.root,
|
|
456
|
+
...placeholderLabel,
|
|
457
|
+
], [variant, baseStyles.root, placeholderLabel]);
|
|
463
458
|
if (placeholderType === 'default' || !focus) {
|
|
464
459
|
return null;
|
|
465
460
|
}
|
|
466
461
|
if (variant === FieldVariant.SM) {
|
|
467
|
-
if (value.length)
|
|
462
|
+
if (value.length) {
|
|
468
463
|
return null;
|
|
469
|
-
|
|
464
|
+
}
|
|
465
|
+
return (jsx("label", { className: labelStyles, htmlFor: id, children: jsx(Typography, { variant: 'B2', color: 'tertiary', styleConfig: placeholderTypography, children: placeholder }) }));
|
|
470
466
|
}
|
|
471
|
-
if (
|
|
467
|
+
if (fieldType === FieldType.PHONE && value.length) {
|
|
472
468
|
return null;
|
|
473
|
-
|
|
469
|
+
}
|
|
470
|
+
const typographyVariant = fieldType === FieldType.PHONE ? 'B1' : focus ? 'B3' : 'B1';
|
|
474
471
|
return (jsx("label", { className: labelStyles, htmlFor: id, children: jsx(Typography, { variant: typographyVariant, color: 'tertiary', styleConfig: placeholderTypography, children: placeholder }) }));
|
|
475
472
|
};
|
|
476
473
|
|
|
@@ -492,14 +489,13 @@ const staticStyles$3 = makeStyles((theme) => {
|
|
|
492
489
|
},
|
|
493
490
|
};
|
|
494
491
|
});
|
|
495
|
-
const InputFieldCore = forwardRef(({ value, disabled, styleConfig, onChange, onFocus, onBlur, onKeyDown, onSelect, onPressIn, placeholder, autoFocus, readOnly, type, inputMode, autoCapitalize, fieldTypographyVariant, variant,
|
|
492
|
+
const InputFieldCore = forwardRef(({ value, disabled, styleConfig, onChange, onFocus, onBlur, onKeyDown, onSelect, onPressIn, placeholder, autoFocus, readOnly, type, inputMode, autoCapitalize, fieldTypographyVariant, variant, focus, placeholderType, prefix, cursorColor, id, maxLength, }, forwardedRef) => {
|
|
493
|
+
const theme = useTheme();
|
|
496
494
|
const inputRef = useRef(null);
|
|
497
|
-
const { field = [] } = styleConfig !== null && styleConfig !== void 0 ? styleConfig : {};
|
|
495
|
+
const { field = [], root = [] } = styleConfig !== null && styleConfig !== void 0 ? styleConfig : {};
|
|
498
496
|
const isPrefixComponent = isValidElement(prefix);
|
|
499
497
|
const disabledPlaceHolder = !(placeholder === null || placeholder === void 0 ? void 0 : placeholder.length);
|
|
500
|
-
const
|
|
501
|
-
root: getTypographyVariant(theme, fieldTypographyVariant !== null && fieldTypographyVariant !== void 0 ? fieldTypographyVariant : 'HM2'),
|
|
502
|
-
}), [fieldTypographyVariant]);
|
|
498
|
+
const inputPlaceholder = placeholderType === 'labeled' && focus ? '' : placeholder;
|
|
503
499
|
const fieldStyles = useStyles((theme) => {
|
|
504
500
|
return {
|
|
505
501
|
root: getFieldStyles({
|
|
@@ -515,7 +511,10 @@ const InputFieldCore = forwardRef(({ value, disabled, styleConfig, onChange, onF
|
|
|
515
511
|
}),
|
|
516
512
|
};
|
|
517
513
|
}, [disabled, variant, focus, value, type, isPrefixComponent, disabledPlaceHolder]);
|
|
518
|
-
const
|
|
514
|
+
const typographyStyles = useStyles((theme) => ({
|
|
515
|
+
root: fieldTypographyVariant ? getTypographyVariant(theme, fieldTypographyVariant) : {},
|
|
516
|
+
}), [fieldTypographyVariant]);
|
|
517
|
+
const mergedStyles = useWebMergeStyles([staticStyles$3.root, styles$3, fieldStyles.root, typographyStyles.root, ...root, ...field], [fieldStyles.root, typographyStyles.root, root, field]);
|
|
519
518
|
useImperativeHandle(forwardedRef, () => ({
|
|
520
519
|
focus: () => {
|
|
521
520
|
var _a;
|
|
@@ -542,6 +541,7 @@ const InputFieldCore = forwardRef(({ value, disabled, styleConfig, onChange, onF
|
|
|
542
541
|
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.setSelectionRange(start, end);
|
|
543
542
|
},
|
|
544
543
|
},
|
|
544
|
+
preventDefault: () => event.preventDefault(),
|
|
545
545
|
});
|
|
546
546
|
}, [onChange]);
|
|
547
547
|
const handleOnFocus = useCallback((event) => {
|
|
@@ -618,21 +618,7 @@ const InputFieldCore = forwardRef(({ value, disabled, styleConfig, onChange, onF
|
|
|
618
618
|
preventDefault: () => event.preventDefault(),
|
|
619
619
|
});
|
|
620
620
|
}, [onPressIn]);
|
|
621
|
-
|
|
622
|
-
onChange: handleOnChange,
|
|
623
|
-
onFocus: handleOnFocus,
|
|
624
|
-
onBlur: handleOnBlur,
|
|
625
|
-
onKeyDown: handleOnKeyDown,
|
|
626
|
-
onSelect: handleOnSelect,
|
|
627
|
-
onMouseDown: handleOnPressIn,
|
|
628
|
-
placeholder,
|
|
629
|
-
autoFocus,
|
|
630
|
-
readOnly,
|
|
631
|
-
type,
|
|
632
|
-
inputMode,
|
|
633
|
-
autoCapitalize,
|
|
634
|
-
};
|
|
635
|
-
return (jsx("textarea", Object.assign({ maxLength: maxLength, id: id, ref: inputRef, value: value, disabled: disabled, className: mergedStyles }, webProps)));
|
|
621
|
+
return (jsx("textarea", { maxLength: maxLength, id: id, ref: inputRef, value: value, disabled: disabled, readOnly: readOnly, className: mergedStyles, style: { caretColor: cursorColor || theme.color.text.primary }, onChange: handleOnChange, onFocus: handleOnFocus, onBlur: handleOnBlur, onKeyDown: handleOnKeyDown, onSelect: handleOnSelect, onMouseDown: handleOnPressIn, placeholder: inputPlaceholder, autoFocus: autoFocus, inputMode: inputMode, autoCapitalize: autoCapitalize }));
|
|
636
622
|
});
|
|
637
623
|
InputFieldCore.displayName = 'TextArea';
|
|
638
624
|
|
|
@@ -642,10 +628,11 @@ const staticStyles$2 = makeStyles((theme) => {
|
|
|
642
628
|
flex: 1,
|
|
643
629
|
flexShrink: 1,
|
|
644
630
|
display: 'flex',
|
|
645
|
-
alignItems: '
|
|
631
|
+
alignItems: 'stretch',
|
|
646
632
|
justifyContent: 'center',
|
|
647
633
|
position: 'relative',
|
|
648
634
|
height: '100%',
|
|
635
|
+
minHeight: 0,
|
|
649
636
|
},
|
|
650
637
|
promptBox: {
|
|
651
638
|
paddingLeft: theme.spacing[4],
|
|
@@ -661,7 +648,18 @@ const staticStyles$2 = makeStyles((theme) => {
|
|
|
661
648
|
justifyContent: 'center',
|
|
662
649
|
alignItems: 'center',
|
|
663
650
|
},
|
|
664
|
-
|
|
651
|
+
prefixSlot: {
|
|
652
|
+
display: 'flex',
|
|
653
|
+
flexDirection: 'row',
|
|
654
|
+
alignItems: 'stretch',
|
|
655
|
+
alignSelf: 'stretch',
|
|
656
|
+
flexShrink: 0,
|
|
657
|
+
},
|
|
658
|
+
suffixSlot: {
|
|
659
|
+
display: 'flex',
|
|
660
|
+
flexDirection: 'row',
|
|
661
|
+
alignItems: 'center',
|
|
662
|
+
alignSelf: 'stretch',
|
|
665
663
|
flexShrink: 0,
|
|
666
664
|
},
|
|
667
665
|
fieldContainer: {
|
|
@@ -676,7 +674,7 @@ const staticStyles$2 = makeStyles((theme) => {
|
|
|
676
674
|
},
|
|
677
675
|
};
|
|
678
676
|
});
|
|
679
|
-
const Field = forwardRef(({ prefix, onBlur, onFocus, onChange, onKeyDown, onPressIn, onSelect, value, autoCapitalize, autoFocus = false, disabled, inputMode, placeholder, prefixGap: _prefixGap, prompt, readOnly, placeholderType = 'default', suffix, suffixGap: _suffixGap, type, variant, styleConfig = {}, fieldTypographyVariant, id, maxLength, numberOfLines, showSoftInputOnFocus, customSpacingTop, }, ref) => {
|
|
677
|
+
const Field = forwardRef(({ prefix, onBlur, onFocus, onChange, onKeyDown, onPressIn, onSelect, value, autoCapitalize, autoFocus = false, disabled, inputMode, placeholder, prefixGap: _prefixGap, prompt, readOnly, placeholderType = 'default', suffix, suffixGap: _suffixGap, type, variant, styleConfig = {}, fieldTypographyVariant, id, maxLength, numberOfLines, showSoftInputOnFocus, customSpacingTop, cursorColor, }, ref) => {
|
|
680
678
|
const [focus, setFocus] = useState(autoFocus);
|
|
681
679
|
const _isFocused = focus || value.length > 0;
|
|
682
680
|
const { promptStyles } = styleConfig || {};
|
|
@@ -694,13 +692,13 @@ const Field = forwardRef(({ prefix, onBlur, onFocus, onChange, onKeyDown, onPres
|
|
|
694
692
|
const InputField = numberOfLines && numberOfLines > 1 ? InputFieldCore : InputFieldCore$1;
|
|
695
693
|
return (jsxs(Box, { boxSize: 'micro', styleConfig: styleConfig, children: [jsxs(Container, { styleConfig: {
|
|
696
694
|
root: [fieldContainerStyles.root, staticStyles$2.fieldContainer, ...(styleConfig.fieldContainer || [])],
|
|
697
|
-
}, children: [isValidElement(prefix) && (jsx(Container, { styleConfig: { root: [staticStyles$2.
|
|
695
|
+
}, children: [isValidElement(prefix) && (jsx(Container, { styleConfig: { root: [staticStyles$2.prefixSlot] }, children: cloneElement(prefix, { focus }) })), jsxs(Container, { styleConfig: { root: [staticStyles$2.fieldWrapper, ...(styleConfig.field || [])] }, children: [jsx(FieldLabelWrapper, { id: id, variant: variant, type: type, value: value, focus: _isFocused, placeholder: placeholder, placeholderType: placeholderType, disabled: disabled, styleConfig: styleConfig, prefix: prefix }), jsx(InputField, { id: id, ref: ref, value: value, disabled: disabled, placeholder: placeholder, placeholderType: placeholderType, autoFocus: autoFocus, readOnly: readOnly, type: type, inputMode: inputMode, autoCapitalize: autoCapitalize, fieldTypographyVariant: fieldTypographyVariant, styleConfig: styleConfig, focus: _isFocused, prefix: prefix, cursorColor: cursorColor, onChange: onChange, onSelect: onSelect, onPressIn: onPressIn, onFocus: (e) => {
|
|
698
696
|
setFocus(true);
|
|
699
697
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
|
|
700
698
|
}, onBlur: (e) => {
|
|
701
699
|
setFocus(false);
|
|
702
700
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
|
|
703
|
-
}, onKeyDown: onKeyDown, maxLength: maxLength, numberOfLines: numberOfLines, showSoftInputOnFocus: showSoftInputOnFocus, customSpacingTop: customSpacingTop })] }), isValidElement(suffix) && (jsx(Container, { styleConfig: { root: [staticStyles$2.
|
|
701
|
+
}, onKeyDown: onKeyDown, maxLength: maxLength, numberOfLines: numberOfLines, showSoftInputOnFocus: showSoftInputOnFocus, customSpacingTop: customSpacingTop })] }), isValidElement(suffix) && (jsx(Container, { styleConfig: { root: [staticStyles$2.suffixSlot] }, children: cloneElement(suffix, { focus }) }))] }), (promptIcon || promptMessage) && (jsxs(Box, { boxSize: 'pico', horizontal: true, styleConfig: {
|
|
704
702
|
root: [staticStyles$2.promptBox, ...((promptStyles === null || promptStyles === void 0 ? void 0 : promptStyles.promptBox) || [])],
|
|
705
703
|
}, children: [promptIcon && (jsx(Container, { styleConfig: { root: [staticStyles$2.promptIcon, ...((promptStyles === null || promptStyles === void 0 ? void 0 : promptStyles.promptIconContainer) || [])] }, children: promptIcon })), promptMessage && (jsx(Typography, { variant: 'B3', color: hasError ? 'warning' : 'success', styleConfig: promptStyles === null || promptStyles === void 0 ? void 0 : promptStyles.promptMessageTypography, children: promptMessage }))] }))] }));
|
|
706
704
|
});
|
|
@@ -709,10 +707,12 @@ Field.displayName = 'Field';
|
|
|
709
707
|
const styles$2 = makeStyles((theme) => {
|
|
710
708
|
return {
|
|
711
709
|
wrapper: {
|
|
710
|
+
height: '100%',
|
|
712
711
|
alignItems: 'center',
|
|
713
712
|
justifyContent: 'center',
|
|
714
713
|
flexDirection: 'row',
|
|
715
|
-
paddingLeft:
|
|
714
|
+
paddingLeft: theme.spacing[4],
|
|
715
|
+
paddingRight: theme.spacing[2],
|
|
716
716
|
},
|
|
717
717
|
flagContainer: {
|
|
718
718
|
display: 'flex',
|
|
@@ -722,12 +722,10 @@ const styles$2 = makeStyles((theme) => {
|
|
|
722
722
|
height: theme.size[6],
|
|
723
723
|
width: theme.size[6],
|
|
724
724
|
},
|
|
725
|
-
countryCode: {
|
|
726
|
-
alignSelf: 'flex-start',
|
|
727
|
-
},
|
|
728
725
|
divider: {
|
|
729
726
|
borderRightWidth: 1,
|
|
730
|
-
|
|
727
|
+
alignSelf: 'center',
|
|
728
|
+
height: theme.size[6],
|
|
731
729
|
borderRightColor: theme.color.background.disabledDark,
|
|
732
730
|
},
|
|
733
731
|
disabledColor: {
|
|
@@ -753,27 +751,26 @@ const PhoneFieldPrefix = ({ countryCode, disabled = false, flagIcon, onDropdownC
|
|
|
753
751
|
return;
|
|
754
752
|
onDropdownClick === null || onDropdownClick === void 0 ? void 0 : onDropdownClick();
|
|
755
753
|
};
|
|
756
|
-
return (jsxs(Box, { boxSize: 'micro', styleConfig: { root: [styles$2.wrapper] }, onClick: onClick, children: [jsxs(Container, { styleConfig: {
|
|
754
|
+
return (jsxs(Box, { horizontal: true, boxSize: 'micro', styleConfig: { root: [styles$2.wrapper] }, onClick: onClick, children: [jsxs(Container, { styleConfig: {
|
|
757
755
|
root: [styles$2.container],
|
|
758
|
-
}, children: [flagIcon && jsx(Container, { styleConfig: { root: [styles$2.flagContainer] }, children: flagIcon }), jsx(Typography, { variant: 'B1', color: disabled ? 'disabled' : 'primary',
|
|
756
|
+
}, children: [flagIcon && jsx(Container, { styleConfig: { root: [styles$2.flagContainer] }, children: flagIcon }), jsx(Typography, { variant: 'B1', color: disabled ? 'disabled' : 'primary', children: countryCode }), showDropdownIcon && (jsx(DownChevronV2, { color: disabled ? styles$2.disabledColor.color : styles$2.enabledColor.color }))] }), jsx(Divider, { dividerWidth: 1, dividerLength: 0, orientation: 'vertical', styleConfig: { root: [styles$2.divider] } })] }));
|
|
759
757
|
};
|
|
760
758
|
|
|
761
759
|
const styles$1 = makeStyles((theme) => {
|
|
762
760
|
return {
|
|
763
761
|
fieldConfig: {
|
|
764
762
|
flex: 1,
|
|
763
|
+
minWidth: 0,
|
|
765
764
|
paddingTop: 0,
|
|
766
765
|
paddingBottom: 0,
|
|
767
766
|
paddingVertical: 0,
|
|
768
|
-
|
|
769
|
-
|
|
767
|
+
paddingLeft: 0,
|
|
768
|
+
lineHeight: theme.typography.lineHeight[24],
|
|
770
769
|
},
|
|
771
770
|
};
|
|
772
771
|
});
|
|
773
772
|
const PhoneField = forwardRef((_a, forwardedRef) => {
|
|
774
|
-
var _b;
|
|
775
773
|
var { flagIcon, countryCode, showDropdownIcon, onDropdownClick, disabled, max, onChange, styleConfig } = _a, rest = __rest(_a, ["flagIcon", "countryCode", "showDropdownIcon", "onDropdownClick", "disabled", "max", "onChange", "styleConfig"]);
|
|
776
|
-
const [prefixWidth, setPrefixWidth] = useState(0);
|
|
777
774
|
const handleChange = (event) => {
|
|
778
775
|
const value = event.target.value;
|
|
779
776
|
const isValidValue = value ? new RegExp(ONLY_NUMERIC).test(value) : true;
|
|
@@ -781,19 +778,7 @@ const PhoneField = forwardRef((_a, forwardedRef) => {
|
|
|
781
778
|
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
782
779
|
}
|
|
783
780
|
};
|
|
784
|
-
|
|
785
|
-
return {
|
|
786
|
-
placeholderStyles: {
|
|
787
|
-
marginLeft: prefixWidth,
|
|
788
|
-
},
|
|
789
|
-
};
|
|
790
|
-
}, [prefixWidth]);
|
|
791
|
-
return (jsx(Field, Object.assign({}, rest, { type: FieldType.PHONE, ref: forwardedRef, disabled: disabled, onChange: handleChange, prefix: jsx("div", { ref: (ref) => { var _a; return setPrefixWidth((_a = ref === null || ref === void 0 ? void 0 : ref.getBoundingClientRect().width) !== null && _a !== void 0 ? _a : 0); }, children: jsx(PhoneFieldPrefix, { flagIcon: flagIcon, countryCode: countryCode, showDropdownIcon: showDropdownIcon, onDropdownClick: onDropdownClick, disabled: disabled }) }), inputMode: 'numeric', styleConfig: Object.assign({ field: [styles$1.fieldConfig, ...((styleConfig === null || styleConfig === void 0 ? void 0 : styleConfig.field) || [])], placeholder: {
|
|
792
|
-
placeholderLabel: [
|
|
793
|
-
customPlaceHolderStyling.placeholderStyles,
|
|
794
|
-
...(((_b = styleConfig === null || styleConfig === void 0 ? void 0 : styleConfig.placeholder) === null || _b === void 0 ? void 0 : _b.placeholderLabel) || []),
|
|
795
|
-
],
|
|
796
|
-
} }, styleConfig) })));
|
|
781
|
+
return (jsx(Field, Object.assign({}, rest, { type: FieldType.PHONE, ref: forwardedRef, disabled: disabled, onChange: handleChange, prefix: jsx("div", { style: { display: 'flex', flexDirection: 'row', alignItems: 'center', height: '100%', flexShrink: 0 }, children: jsx(PhoneFieldPrefix, { flagIcon: flagIcon, countryCode: countryCode, showDropdownIcon: showDropdownIcon, onDropdownClick: onDropdownClick, disabled: disabled }) }), inputMode: 'numeric', styleConfig: Object.assign({ field: [styles$1.fieldConfig, ...((styleConfig === null || styleConfig === void 0 ? void 0 : styleConfig.field) || [])] }, styleConfig) })));
|
|
797
782
|
});
|
|
798
783
|
PhoneField.displayName = 'PhoneField';
|
|
799
784
|
|