@ikatec/nebula-react 1.0.10 → 1.0.11
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/index.d.mts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +45 -18
- package/dist/index.mjs +45 -18
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -15,6 +15,7 @@ import * as SwitchPrimitives from '@radix-ui/react-switch';
|
|
|
15
15
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
16
16
|
import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
|
17
17
|
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
18
|
+
import * as RPNInput from 'react-phone-number-input';
|
|
18
19
|
|
|
19
20
|
declare enum buttonVariantEnum {
|
|
20
21
|
primary = "\n bg-button-primary-background-default\n hover:bg-button-primary-background-hover\n active:bg-button-primary-background-active\n focus:bg-button-primary-background-focus\n focus:ring-button-primary-border-focus\n text-button-primary-text\n ",
|
|
@@ -495,7 +496,13 @@ interface LinkProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
|
495
496
|
}
|
|
496
497
|
declare const Link: React__default.ForwardRefExoticComponent<LinkProps & React__default.RefAttributes<HTMLAnchorElement>>;
|
|
497
498
|
|
|
498
|
-
|
|
499
|
+
type InputPhoneProps = {
|
|
500
|
+
isError?: boolean;
|
|
501
|
+
defaultCountry?: RPNInput.Country;
|
|
502
|
+
onChange: (value: string) => void;
|
|
503
|
+
value?: string | null;
|
|
504
|
+
} & Omit<React__default.InputHTMLAttributes<HTMLInputElement>, 'onChange'>;
|
|
505
|
+
declare function InputPhone({ className, disabled, isError, defaultCountry, value, onChange, ...props }: InputPhoneProps): react_jsx_runtime.JSX.Element;
|
|
499
506
|
|
|
500
507
|
interface SkeletonProps extends React__default.HTMLAttributes<HTMLDivElement> {
|
|
501
508
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ import * as SwitchPrimitives from '@radix-ui/react-switch';
|
|
|
15
15
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
16
16
|
import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
|
17
17
|
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
18
|
+
import * as RPNInput from 'react-phone-number-input';
|
|
18
19
|
|
|
19
20
|
declare enum buttonVariantEnum {
|
|
20
21
|
primary = "\n bg-button-primary-background-default\n hover:bg-button-primary-background-hover\n active:bg-button-primary-background-active\n focus:bg-button-primary-background-focus\n focus:ring-button-primary-border-focus\n text-button-primary-text\n ",
|
|
@@ -495,7 +496,13 @@ interface LinkProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
|
495
496
|
}
|
|
496
497
|
declare const Link: React__default.ForwardRefExoticComponent<LinkProps & React__default.RefAttributes<HTMLAnchorElement>>;
|
|
497
498
|
|
|
498
|
-
|
|
499
|
+
type InputPhoneProps = {
|
|
500
|
+
isError?: boolean;
|
|
501
|
+
defaultCountry?: RPNInput.Country;
|
|
502
|
+
onChange: (value: string) => void;
|
|
503
|
+
value?: string | null;
|
|
504
|
+
} & Omit<React__default.InputHTMLAttributes<HTMLInputElement>, 'onChange'>;
|
|
505
|
+
declare function InputPhone({ className, disabled, isError, defaultCountry, value, onChange, ...props }: InputPhoneProps): react_jsx_runtime.JSX.Element;
|
|
499
506
|
|
|
500
507
|
interface SkeletonProps extends React__default.HTMLAttributes<HTMLDivElement> {
|
|
501
508
|
}
|
package/dist/index.js
CHANGED
|
@@ -3569,26 +3569,53 @@ var PhoneInput = React8__namespace.default.forwardRef(({ className, ...props },
|
|
|
3569
3569
|
});
|
|
3570
3570
|
PhoneInput.displayName = "Input";
|
|
3571
3571
|
function InputPhone({
|
|
3572
|
-
value,
|
|
3573
|
-
onChange,
|
|
3574
3572
|
className,
|
|
3575
3573
|
disabled,
|
|
3576
3574
|
isError = false,
|
|
3577
3575
|
defaultCountry = "BR",
|
|
3576
|
+
value,
|
|
3577
|
+
onChange,
|
|
3578
3578
|
...props
|
|
3579
3579
|
}) {
|
|
3580
|
+
const [valueState, setValueState] = React8.useState("");
|
|
3581
|
+
const [isFirstRender, setIsFirstRender] = React8.useState(true);
|
|
3580
3582
|
const countryCode = defaultCountry ? RPNInput__namespace.getCountryCallingCode(defaultCountry) : null;
|
|
3581
|
-
const
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
return
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3583
|
+
const normalizePhoneNumber = React8.useCallback(
|
|
3584
|
+
(inputValue) => {
|
|
3585
|
+
if (!inputValue) return "";
|
|
3586
|
+
const cleanValue = inputValue.toString().replace(/[^\d+]/g, "");
|
|
3587
|
+
if (!cleanValue) return "";
|
|
3588
|
+
if (cleanValue.startsWith("+")) {
|
|
3589
|
+
return cleanValue;
|
|
3590
|
+
}
|
|
3591
|
+
if (countryCode && cleanValue.startsWith(countryCode)) {
|
|
3592
|
+
return `+${cleanValue}`;
|
|
3593
|
+
}
|
|
3594
|
+
if (countryCode && /^\d{10,11}$/.test(cleanValue)) {
|
|
3595
|
+
return `+${countryCode}${cleanValue}`;
|
|
3596
|
+
}
|
|
3597
|
+
return cleanValue;
|
|
3598
|
+
},
|
|
3599
|
+
[countryCode]
|
|
3600
|
+
);
|
|
3601
|
+
React8.useEffect(() => {
|
|
3602
|
+
if (value !== void 0 && value !== null) {
|
|
3603
|
+
const normalizedValue = normalizePhoneNumber(value);
|
|
3604
|
+
setValueState(normalizedValue);
|
|
3605
|
+
} else {
|
|
3606
|
+
setValueState("");
|
|
3589
3607
|
}
|
|
3590
|
-
|
|
3591
|
-
|
|
3608
|
+
}, [value, normalizePhoneNumber]);
|
|
3609
|
+
const handleChange = React8.useCallback(
|
|
3610
|
+
(newValue) => {
|
|
3611
|
+
setIsFirstRender(false);
|
|
3612
|
+
setValueState(newValue);
|
|
3613
|
+
if (onChange) {
|
|
3614
|
+
onChange(newValue || "");
|
|
3615
|
+
}
|
|
3616
|
+
},
|
|
3617
|
+
[onChange]
|
|
3618
|
+
);
|
|
3592
3619
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3593
3620
|
RPNInput__namespace.default,
|
|
3594
3621
|
{
|
|
@@ -3601,16 +3628,16 @@ function InputPhone({
|
|
|
3601
3628
|
className
|
|
3602
3629
|
),
|
|
3603
3630
|
flagComponent: FlagComponent,
|
|
3604
|
-
limitMaxLength: true,
|
|
3605
3631
|
countrySelectComponent: CountrySelect,
|
|
3606
3632
|
inputComponent: PhoneInput,
|
|
3607
3633
|
disabled,
|
|
3608
|
-
value: valueCorrection,
|
|
3609
|
-
onChange: (newValue) => onChange(newValue ?? ""),
|
|
3610
|
-
defaultCountry,
|
|
3611
|
-
countryCallingCodeEditable: true,
|
|
3612
3634
|
international: true,
|
|
3613
|
-
|
|
3635
|
+
limitMaxLength: true,
|
|
3636
|
+
defaultCountry: isFirstRender && (!value || value === "") ? defaultCountry : valueState ? defaultCountry : void 0,
|
|
3637
|
+
countryCallingCodeEditable: true,
|
|
3638
|
+
...props,
|
|
3639
|
+
value: valueState,
|
|
3640
|
+
onChange: handleChange
|
|
3614
3641
|
}
|
|
3615
3642
|
);
|
|
3616
3643
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -3529,26 +3529,53 @@ var PhoneInput = React8__default.forwardRef(({ className, ...props }, ref) => {
|
|
|
3529
3529
|
});
|
|
3530
3530
|
PhoneInput.displayName = "Input";
|
|
3531
3531
|
function InputPhone({
|
|
3532
|
-
value,
|
|
3533
|
-
onChange,
|
|
3534
3532
|
className,
|
|
3535
3533
|
disabled,
|
|
3536
3534
|
isError = false,
|
|
3537
3535
|
defaultCountry = "BR",
|
|
3536
|
+
value,
|
|
3537
|
+
onChange,
|
|
3538
3538
|
...props
|
|
3539
3539
|
}) {
|
|
3540
|
+
const [valueState, setValueState] = useState("");
|
|
3541
|
+
const [isFirstRender, setIsFirstRender] = useState(true);
|
|
3540
3542
|
const countryCode = defaultCountry ? RPNInput.getCountryCallingCode(defaultCountry) : null;
|
|
3541
|
-
const
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
return
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3543
|
+
const normalizePhoneNumber = useCallback(
|
|
3544
|
+
(inputValue) => {
|
|
3545
|
+
if (!inputValue) return "";
|
|
3546
|
+
const cleanValue = inputValue.toString().replace(/[^\d+]/g, "");
|
|
3547
|
+
if (!cleanValue) return "";
|
|
3548
|
+
if (cleanValue.startsWith("+")) {
|
|
3549
|
+
return cleanValue;
|
|
3550
|
+
}
|
|
3551
|
+
if (countryCode && cleanValue.startsWith(countryCode)) {
|
|
3552
|
+
return `+${cleanValue}`;
|
|
3553
|
+
}
|
|
3554
|
+
if (countryCode && /^\d{10,11}$/.test(cleanValue)) {
|
|
3555
|
+
return `+${countryCode}${cleanValue}`;
|
|
3556
|
+
}
|
|
3557
|
+
return cleanValue;
|
|
3558
|
+
},
|
|
3559
|
+
[countryCode]
|
|
3560
|
+
);
|
|
3561
|
+
useEffect(() => {
|
|
3562
|
+
if (value !== void 0 && value !== null) {
|
|
3563
|
+
const normalizedValue = normalizePhoneNumber(value);
|
|
3564
|
+
setValueState(normalizedValue);
|
|
3565
|
+
} else {
|
|
3566
|
+
setValueState("");
|
|
3549
3567
|
}
|
|
3550
|
-
|
|
3551
|
-
|
|
3568
|
+
}, [value, normalizePhoneNumber]);
|
|
3569
|
+
const handleChange = useCallback(
|
|
3570
|
+
(newValue) => {
|
|
3571
|
+
setIsFirstRender(false);
|
|
3572
|
+
setValueState(newValue);
|
|
3573
|
+
if (onChange) {
|
|
3574
|
+
onChange(newValue || "");
|
|
3575
|
+
}
|
|
3576
|
+
},
|
|
3577
|
+
[onChange]
|
|
3578
|
+
);
|
|
3552
3579
|
return /* @__PURE__ */ jsx(
|
|
3553
3580
|
RPNInput.default,
|
|
3554
3581
|
{
|
|
@@ -3561,16 +3588,16 @@ function InputPhone({
|
|
|
3561
3588
|
className
|
|
3562
3589
|
),
|
|
3563
3590
|
flagComponent: FlagComponent,
|
|
3564
|
-
limitMaxLength: true,
|
|
3565
3591
|
countrySelectComponent: CountrySelect,
|
|
3566
3592
|
inputComponent: PhoneInput,
|
|
3567
3593
|
disabled,
|
|
3568
|
-
value: valueCorrection,
|
|
3569
|
-
onChange: (newValue) => onChange(newValue ?? ""),
|
|
3570
|
-
defaultCountry,
|
|
3571
|
-
countryCallingCodeEditable: true,
|
|
3572
3594
|
international: true,
|
|
3573
|
-
|
|
3595
|
+
limitMaxLength: true,
|
|
3596
|
+
defaultCountry: isFirstRender && (!value || value === "") ? defaultCountry : valueState ? defaultCountry : void 0,
|
|
3597
|
+
countryCallingCodeEditable: true,
|
|
3598
|
+
...props,
|
|
3599
|
+
value: valueState,
|
|
3600
|
+
onChange: handleChange
|
|
3574
3601
|
}
|
|
3575
3602
|
);
|
|
3576
3603
|
}
|