@overmap-ai/blocks 1.0.40-improvements.2 → 1.0.40-phone-input.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.
- package/dist/PhoneNumberInput/CountrySelect.d.ts +11 -0
- package/dist/PhoneNumberInput/FlagComponent.d.ts +2 -0
- package/dist/PhoneNumberInput/InputComponent.d.ts +5 -0
- package/dist/PhoneNumberInput/PhoneNumberInput.d.ts +6 -0
- package/dist/PhoneNumberInput/context.d.ts +4 -0
- package/dist/PhoneNumberInput/index.d.ts +2 -0
- package/dist/PhoneNumberInput/typings.d.ts +9 -0
- package/dist/blocks.js +93 -0
- package/dist/blocks.js.map +1 -1
- package/dist/blocks.umd.cjs +92 -2
- package/dist/blocks.umd.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Country } from 'react-phone-number-input/min';
|
|
2
|
+
export interface CountrySelectProps {
|
|
3
|
+
disabled?: boolean;
|
|
4
|
+
value: Country;
|
|
5
|
+
onChange: (value: Country) => void;
|
|
6
|
+
options: {
|
|
7
|
+
label: string;
|
|
8
|
+
value: Country | undefined;
|
|
9
|
+
}[];
|
|
10
|
+
}
|
|
11
|
+
export declare const CountrySelect: import('react').NamedExoticComponent<CountrySelectProps>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ComponentPropsWithRef } from 'react';
|
|
2
|
+
import { Input } from '../Input';
|
|
3
|
+
export interface InputComponentProps extends ComponentPropsWithRef<typeof Input.Field> {
|
|
4
|
+
}
|
|
5
|
+
export declare const InputComponent: import('react').NamedExoticComponent<InputComponentProps>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ComponentPropsWithRef } from 'react';
|
|
2
|
+
import { default as PhoneInput } from 'react-phone-number-input';
|
|
3
|
+
import { PhoneNumberInputVariantProps } from './typings';
|
|
4
|
+
export interface PhoneNumberInputProps extends Omit<ComponentPropsWithRef<typeof PhoneInput>, "inputComponent" | "flagComponent" | "countrySelectComponent">, PhoneNumberInputVariantProps {
|
|
5
|
+
}
|
|
6
|
+
export declare const PhoneNumberInput: import('react').NamedExoticComponent<PhoneNumberInputProps>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ComponentRadius } from '../Provider';
|
|
2
|
+
import { AccentColorProps } from '../typings';
|
|
3
|
+
export type PhoneNumberInputSize = "xs" | "sm" | "md" | "lg" | "xl";
|
|
4
|
+
export type PhoneNumberInputVariant = "surface" | "soft" | "outline" | "ghost";
|
|
5
|
+
export interface PhoneNumberInputVariantProps extends AccentColorProps {
|
|
6
|
+
size?: PhoneNumberInputSize;
|
|
7
|
+
variant?: PhoneNumberInputVariant;
|
|
8
|
+
radius?: ComponentRadius;
|
|
9
|
+
}
|
package/dist/blocks.js
CHANGED
|
@@ -18,6 +18,9 @@ import { useListItem, useMergeRefs, FloatingNode, FloatingPortal, FloatingOverla
|
|
|
18
18
|
import * as RadixSeparator from "@radix-ui/react-separator";
|
|
19
19
|
import * as RadixOneTimePasswordField from "@radix-ui/react-one-time-password-field";
|
|
20
20
|
import { useErrorBoundary, ErrorBoundary } from "react-error-boundary";
|
|
21
|
+
import PhoneInput from "react-phone-number-input";
|
|
22
|
+
import { PhoneIcon, ChevronDownIcon } from "lucide-react";
|
|
23
|
+
import { getCountryCallingCode } from "react-phone-number-input/min";
|
|
21
24
|
import * as RadixPopover from "@radix-ui/react-popover";
|
|
22
25
|
import * as RadixProgress from "@radix-ui/react-progress";
|
|
23
26
|
import * as RadixRadioGroup from "@radix-ui/react-radio-group";
|
|
@@ -4379,6 +4382,95 @@ const OvermapErrorBoundary = memo((props) => {
|
|
|
4379
4382
|
);
|
|
4380
4383
|
});
|
|
4381
4384
|
OvermapErrorBoundary.displayName = "OvermapErrorBoundary";
|
|
4385
|
+
const PhoneNumberInputContext = createContext({});
|
|
4386
|
+
const FlagComponent = memo((props) => {
|
|
4387
|
+
const { country } = props;
|
|
4388
|
+
return country ? country : /* @__PURE__ */ jsx(PhoneIcon, { size: 16 });
|
|
4389
|
+
});
|
|
4390
|
+
FlagComponent.displayName = "FlagComponent";
|
|
4391
|
+
const CountrySelect = memo((props) => {
|
|
4392
|
+
const { disabled, value, onChange, options } = props;
|
|
4393
|
+
const { radius, size: size2, variant, accentColor } = use(PhoneNumberInputContext);
|
|
4394
|
+
const handleSelect = useCallback(
|
|
4395
|
+
(e) => {
|
|
4396
|
+
onChange(e.target.value);
|
|
4397
|
+
},
|
|
4398
|
+
[onChange]
|
|
4399
|
+
);
|
|
4400
|
+
return /* @__PURE__ */ jsxs(
|
|
4401
|
+
Button,
|
|
4402
|
+
{
|
|
4403
|
+
className: "relative",
|
|
4404
|
+
accentColor,
|
|
4405
|
+
radius,
|
|
4406
|
+
size: size2,
|
|
4407
|
+
variant,
|
|
4408
|
+
disabled,
|
|
4409
|
+
children: [
|
|
4410
|
+
/* @__PURE__ */ jsx(FlagComponent, { country: value, countryName: value, "aria-hidden": "true" }),
|
|
4411
|
+
/* @__PURE__ */ jsx(ChevronDownIcon, { size: 16, "aria-hidden": "true" }),
|
|
4412
|
+
/* @__PURE__ */ jsxs(
|
|
4413
|
+
"select",
|
|
4414
|
+
{
|
|
4415
|
+
disabled,
|
|
4416
|
+
value,
|
|
4417
|
+
onChange: handleSelect,
|
|
4418
|
+
className: "absolute inset-0 text-sm opacity-0",
|
|
4419
|
+
"aria-label": "Select country",
|
|
4420
|
+
children: [
|
|
4421
|
+
/* @__PURE__ */ jsx("option", { value: "", children: "Select a country" }, "default"),
|
|
4422
|
+
options.filter((x) => x.value).map((option, i) => /* @__PURE__ */ jsxs("option", { value: option.value, children: [
|
|
4423
|
+
option.label,
|
|
4424
|
+
" ",
|
|
4425
|
+
option.value && `+${getCountryCallingCode(option.value)}`
|
|
4426
|
+
] }, option.value ?? `empty-${i}`))
|
|
4427
|
+
]
|
|
4428
|
+
}
|
|
4429
|
+
)
|
|
4430
|
+
]
|
|
4431
|
+
}
|
|
4432
|
+
);
|
|
4433
|
+
});
|
|
4434
|
+
CountrySelect.displayName = "CountrySelect";
|
|
4435
|
+
const InputComponent = memo((props) => {
|
|
4436
|
+
const { accentColor, radius, size: size2, variant } = use(PhoneNumberInputContext);
|
|
4437
|
+
return /* @__PURE__ */ jsx(Input.Root, { variant, size: size2, radius, accentColor, children: /* @__PURE__ */ jsx(Input.Field, { ...props }) });
|
|
4438
|
+
});
|
|
4439
|
+
InputComponent.displayName = "InputComponent";
|
|
4440
|
+
const PhoneNumberInput = memo((props) => {
|
|
4441
|
+
const providerContext = useProvider();
|
|
4442
|
+
const {
|
|
4443
|
+
ref,
|
|
4444
|
+
className,
|
|
4445
|
+
size: size2 = "md",
|
|
4446
|
+
variant = "outline",
|
|
4447
|
+
radius = providerContext.radius,
|
|
4448
|
+
accentColor = providerContext.accentColor,
|
|
4449
|
+
...rest
|
|
4450
|
+
} = props;
|
|
4451
|
+
const contextValue = useMemo(
|
|
4452
|
+
() => ({
|
|
4453
|
+
size: size2,
|
|
4454
|
+
variant,
|
|
4455
|
+
radius,
|
|
4456
|
+
accentColor
|
|
4457
|
+
}),
|
|
4458
|
+
[accentColor, radius, size2, variant]
|
|
4459
|
+
);
|
|
4460
|
+
return /* @__PURE__ */ jsx(PhoneNumberInputContext, { value: contextValue, children: /* @__PURE__ */ jsx(
|
|
4461
|
+
PhoneInput,
|
|
4462
|
+
{
|
|
4463
|
+
ref,
|
|
4464
|
+
className: cx(className, "flex gap-1"),
|
|
4465
|
+
flagComponent: FlagComponent,
|
|
4466
|
+
countrySelectComponent: CountrySelect,
|
|
4467
|
+
inputComponent: InputComponent,
|
|
4468
|
+
"data-accent-color": accentColor,
|
|
4469
|
+
...rest
|
|
4470
|
+
}
|
|
4471
|
+
) });
|
|
4472
|
+
});
|
|
4473
|
+
PhoneNumberInput.displayName = "PhoneNumberInput";
|
|
4382
4474
|
const PopoverArrow = memo((props) => {
|
|
4383
4475
|
const { ref, children, className, ...rest } = props;
|
|
4384
4476
|
return /* @__PURE__ */ jsx(RadixPopover.Arrow, { className: cx("fill-(--base-6)", className), ref, ...rest, children });
|
|
@@ -6642,6 +6734,7 @@ export {
|
|
|
6642
6734
|
OverlayTitle,
|
|
6643
6735
|
OverlayTrigger,
|
|
6644
6736
|
OvermapErrorBoundary,
|
|
6737
|
+
PhoneNumberInput,
|
|
6645
6738
|
Popover,
|
|
6646
6739
|
PopoverArrow,
|
|
6647
6740
|
PopoverContent,
|