@korsolutions/ui 0.0.51 → 0.0.53
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/AGENTS.md +32 -19
- package/dist/module/components/alert/components/alert-description.js.map +1 -1
- package/dist/module/components/button/components/button-label.js.map +1 -1
- package/dist/module/components/index.js +1 -0
- package/dist/module/components/index.js.map +1 -1
- package/dist/module/components/input/numeric-input.js +1 -1
- package/dist/module/components/input/numeric-input.js.map +1 -1
- package/dist/module/components/input/variants/default.js +9 -2
- package/dist/module/components/input/variants/default.js.map +1 -1
- package/dist/module/components/input/variants/secondary.js +9 -2
- package/dist/module/components/input/variants/secondary.js.map +1 -1
- package/dist/module/components/link/variants/default.js.map +1 -1
- package/dist/module/components/menu/components/menu-trigger.js +1 -1
- package/dist/module/components/menu/components/menu-trigger.js.map +1 -1
- package/dist/module/components/phone-input/index.js +4 -0
- package/dist/module/components/phone-input/index.js.map +1 -0
- package/dist/module/components/phone-input/phone-input.js +165 -0
- package/dist/module/components/phone-input/phone-input.js.map +1 -0
- package/dist/module/components/phone-input/types.js +4 -0
- package/dist/module/components/phone-input/types.js.map +1 -0
- package/dist/module/components/phone-input/variants/default.js +128 -0
- package/dist/module/components/phone-input/variants/default.js.map +1 -0
- package/dist/module/components/phone-input/variants/index.js +7 -0
- package/dist/module/components/phone-input/variants/index.js.map +1 -0
- package/dist/module/components/select/components/select-trigger.js +2 -2
- package/dist/module/components/select/components/select-trigger.js.map +1 -1
- package/dist/module/components/tabs/variants/default.js.map +1 -1
- package/dist/module/components/toast/components/toast-icon.js.map +1 -1
- package/dist/module/components/toast/manager.js +2 -2
- package/dist/module/components/toast/manager.js.map +1 -1
- package/dist/module/components/typography/variants/body-lg.js.map +1 -1
- package/dist/module/components/typography/variants/body-md.js.map +1 -1
- package/dist/module/components/typography/variants/body-sm.js.map +1 -1
- package/dist/module/components/typography/variants/heading-lg.js.map +1 -1
- package/dist/module/components/typography/variants/heading-md.js.map +1 -1
- package/dist/module/components/typography/variants/heading-sm.js.map +1 -1
- package/dist/module/data/countries.js +476 -0
- package/dist/module/data/countries.js.map +1 -0
- package/dist/module/hooks/index.js +1 -0
- package/dist/module/hooks/index.js.map +1 -1
- package/dist/module/hooks/use-phone-mask.js +121 -0
- package/dist/module/hooks/use-phone-mask.js.map +1 -0
- package/dist/module/hooks/use-relative-position.js.map +1 -1
- package/dist/module/index.js +2 -2
- package/dist/module/index.js.map +1 -1
- package/dist/module/themes/default/colors.js +28 -28
- package/dist/module/themes/default/colors.js.map +1 -1
- package/dist/module/themes/provider.js.map +1 -1
- package/dist/module/themes/utils.js.map +1 -1
- package/dist/module/utils/input-utils.js.map +1 -1
- package/dist/module/utils/normalize-layout.js.map +1 -1
- package/dist/module/utils/use-themed-styles.js.map +1 -1
- package/dist/typescript/src/components/alert/components/alert-body.d.ts.map +1 -1
- package/dist/typescript/src/components/alert/components/alert-description.d.ts +2 -2
- package/dist/typescript/src/components/alert/components/alert-description.d.ts.map +1 -1
- package/dist/typescript/src/components/alert/components/alert-icon.d.ts.map +1 -1
- package/dist/typescript/src/components/alert/components/alert-root.d.ts.map +1 -1
- package/dist/typescript/src/components/alert/components/alert-title.d.ts.map +1 -1
- package/dist/typescript/src/components/alert/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/alert/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/components/alert/variants/destructive.d.ts +1 -1
- package/dist/typescript/src/components/alert/variants/destructive.d.ts.map +1 -1
- package/dist/typescript/src/components/alert-dialog/components/alert-dialog-trigger.d.ts.map +1 -1
- package/dist/typescript/src/components/alert-dialog/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/alert-dialog/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/components/avatar/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/avatar/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/components/badge/components/badge-root.d.ts.map +1 -1
- package/dist/typescript/src/components/badge/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/badge/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/components/badge/variants/secondary.d.ts +1 -1
- package/dist/typescript/src/components/badge/variants/secondary.d.ts.map +1 -1
- package/dist/typescript/src/components/button/components/button-label.d.ts +2 -1
- package/dist/typescript/src/components/button/components/button-label.d.ts.map +1 -1
- package/dist/typescript/src/components/button/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/button/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/components/button/variants/secondary.d.ts +1 -1
- package/dist/typescript/src/components/button/variants/secondary.d.ts.map +1 -1
- package/dist/typescript/src/components/calendar/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/calendar/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/components/card/card-body.d.ts.map +1 -1
- package/dist/typescript/src/components/card/card-footer.d.ts.map +1 -1
- package/dist/typescript/src/components/card/card-header.d.ts.map +1 -1
- package/dist/typescript/src/components/card/card-root.d.ts.map +1 -1
- package/dist/typescript/src/components/card/card-title.d.ts.map +1 -1
- package/dist/typescript/src/components/card/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/card/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/components/checkbox/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/checkbox/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/components/checkbox/variants/outlined.d.ts +1 -1
- package/dist/typescript/src/components/checkbox/variants/outlined.d.ts.map +1 -1
- package/dist/typescript/src/components/empty/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/empty/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/components/field/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/field/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/components/icon/icon.d.ts.map +1 -1
- package/dist/typescript/src/components/index.d.ts +1 -0
- package/dist/typescript/src/components/index.d.ts.map +1 -1
- package/dist/typescript/src/components/input/input.d.ts.map +1 -1
- package/dist/typescript/src/components/input/numeric-input.d.ts +1 -1
- package/dist/typescript/src/components/input/numeric-input.d.ts.map +1 -1
- package/dist/typescript/src/components/input/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/input/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/components/input/variants/secondary.d.ts +1 -1
- package/dist/typescript/src/components/input/variants/secondary.d.ts.map +1 -1
- package/dist/typescript/src/components/link/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/components/menu/components/menu-trigger.d.ts +1 -1
- package/dist/typescript/src/components/menu/components/menu-trigger.d.ts.map +1 -1
- package/dist/typescript/src/components/menu/context.d.ts.map +1 -1
- package/dist/typescript/src/components/menu/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/menu/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/components/phone-input/index.d.ts +3 -0
- package/dist/typescript/src/components/phone-input/index.d.ts.map +1 -0
- package/dist/typescript/src/components/phone-input/phone-input.d.ts +16 -0
- package/dist/typescript/src/components/phone-input/phone-input.d.ts.map +1 -0
- package/dist/typescript/src/components/phone-input/types.d.ts +15 -0
- package/dist/typescript/src/components/phone-input/types.d.ts.map +1 -0
- package/dist/typescript/src/components/phone-input/variants/default.d.ts +3 -0
- package/dist/typescript/src/components/phone-input/variants/default.d.ts.map +1 -0
- package/dist/typescript/src/components/phone-input/variants/index.d.ts +5 -0
- package/dist/typescript/src/components/phone-input/variants/index.d.ts.map +1 -0
- package/dist/typescript/src/components/popover/components/popover-trigger.d.ts.map +1 -1
- package/dist/typescript/src/components/popover/context.d.ts.map +1 -1
- package/dist/typescript/src/components/popover/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/popover/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/components/popover/variants/unstyled.d.ts +1 -1
- package/dist/typescript/src/components/popover/variants/unstyled.d.ts.map +1 -1
- package/dist/typescript/src/components/progress/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/progress/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/components/select/components/select-trigger.d.ts.map +1 -1
- package/dist/typescript/src/components/select/context.d.ts.map +1 -1
- package/dist/typescript/src/components/select/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/select/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/components/tabs/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/tabs/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/components/tabs/variants/line.d.ts +1 -1
- package/dist/typescript/src/components/tabs/variants/line.d.ts.map +1 -1
- package/dist/typescript/src/components/textarea/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/textarea/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/components/toast/components/toast-icon.d.ts +1 -1
- package/dist/typescript/src/components/toast/components/toast-icon.d.ts.map +1 -1
- package/dist/typescript/src/components/toast/manager.d.ts.map +1 -1
- package/dist/typescript/src/components/typography/variants/body-lg.d.ts.map +1 -1
- package/dist/typescript/src/components/typography/variants/body-md.d.ts.map +1 -1
- package/dist/typescript/src/components/typography/variants/body-sm.d.ts.map +1 -1
- package/dist/typescript/src/components/typography/variants/heading-lg.d.ts.map +1 -1
- package/dist/typescript/src/components/typography/variants/heading-md.d.ts.map +1 -1
- package/dist/typescript/src/components/typography/variants/heading-sm.d.ts.map +1 -1
- package/dist/typescript/src/data/countries.d.ts +17 -0
- package/dist/typescript/src/data/countries.d.ts.map +1 -0
- package/dist/typescript/src/hooks/index.d.ts +1 -0
- package/dist/typescript/src/hooks/index.d.ts.map +1 -1
- package/dist/typescript/src/hooks/use-phone-mask.d.ts +20 -0
- package/dist/typescript/src/hooks/use-phone-mask.d.ts.map +1 -0
- package/dist/typescript/src/hooks/use-relative-position.d.ts +1 -1
- package/dist/typescript/src/hooks/use-relative-position.d.ts.map +1 -1
- package/dist/typescript/src/index.d.ts +2 -2
- package/dist/typescript/src/index.d.ts.map +1 -1
- package/dist/typescript/src/themes/provider.d.ts +1 -1
- package/dist/typescript/src/themes/provider.d.ts.map +1 -1
- package/dist/typescript/src/themes/types.d.ts +1 -1
- package/dist/typescript/src/themes/types.d.ts.map +1 -1
- package/dist/typescript/src/themes/utils.d.ts.map +1 -1
- package/dist/typescript/src/utils/input-utils.d.ts.map +1 -1
- package/dist/typescript/src/utils/normalize-layout.d.ts +1 -1
- package/dist/typescript/src/utils/normalize-layout.d.ts.map +1 -1
- package/dist/typescript/src/utils/use-themed-styles.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/alert/components/alert-body.tsx +1 -1
- package/src/components/alert/components/alert-description.tsx +5 -3
- package/src/components/alert/components/alert-icon.tsx +1 -1
- package/src/components/alert/components/alert-root.tsx +1 -1
- package/src/components/alert/components/alert-title.tsx +2 -2
- package/src/components/alert/variants/default.tsx +2 -2
- package/src/components/alert/variants/destructive.tsx +2 -2
- package/src/components/alert-dialog/components/alert-dialog-trigger.tsx +1 -1
- package/src/components/alert-dialog/variants/default.tsx +2 -2
- package/src/components/avatar/variants/default.tsx +2 -2
- package/src/components/badge/components/badge-label.tsx +1 -1
- package/src/components/badge/components/badge-root.tsx +2 -2
- package/src/components/badge/variants/default.tsx +2 -2
- package/src/components/badge/variants/secondary.tsx +2 -2
- package/src/components/button/components/button-label.tsx +3 -2
- package/src/components/button/variants/default.tsx +3 -3
- package/src/components/button/variants/secondary.tsx +3 -3
- package/src/components/calendar/components/calendar-day.tsx +1 -1
- package/src/components/calendar/components/calendar-nav-button.tsx +1 -1
- package/src/components/calendar/components/calendar-title.tsx +1 -1
- package/src/components/calendar/components/calendar-weeks.tsx +1 -1
- package/src/components/calendar/variants/default.tsx +2 -2
- package/src/components/card/card-body.tsx +2 -2
- package/src/components/card/card-footer.tsx +2 -2
- package/src/components/card/card-header.tsx +2 -2
- package/src/components/card/card-root.tsx +2 -2
- package/src/components/card/card-title.tsx +3 -3
- package/src/components/card/variants/default.tsx +2 -2
- package/src/components/checkbox/variants/default.tsx +2 -2
- package/src/components/checkbox/variants/outlined.tsx +2 -2
- package/src/components/empty/variants/default.tsx +2 -2
- package/src/components/field/variants/default.tsx +2 -2
- package/src/components/icon/icon.tsx +1 -1
- package/src/components/icon/variants/default.tsx +1 -1
- package/src/components/index.ts +1 -0
- package/src/components/input/input.tsx +1 -1
- package/src/components/input/numeric-input.tsx +8 -2
- package/src/components/input/variants/default.tsx +10 -3
- package/src/components/input/variants/secondary.tsx +10 -3
- package/src/components/link/variants/default.tsx +2 -2
- package/src/components/menu/components/menu-content.tsx +1 -1
- package/src/components/menu/components/menu-root.tsx +1 -1
- package/src/components/menu/components/menu-trigger.tsx +40 -38
- package/src/components/menu/context.ts +1 -1
- package/src/components/menu/variants/default.tsx +2 -2
- package/src/components/phone-input/index.ts +2 -0
- package/src/components/phone-input/phone-input.tsx +220 -0
- package/src/components/phone-input/types.ts +20 -0
- package/src/components/phone-input/variants/default.tsx +124 -0
- package/src/components/phone-input/variants/index.ts +5 -0
- package/src/components/popover/components/popover-content.tsx +2 -2
- package/src/components/popover/components/popover-root.tsx +1 -1
- package/src/components/popover/components/popover-trigger.tsx +2 -2
- package/src/components/popover/context.ts +1 -1
- package/src/components/popover/variants/default.tsx +2 -2
- package/src/components/popover/variants/unstyled.tsx +2 -2
- package/src/components/progress/components/progress-indicator.tsx +1 -1
- package/src/components/progress/components/progress-root.tsx +1 -1
- package/src/components/progress/variants/default.tsx +2 -2
- package/src/components/scroll-bar/scroll-bar.tsx +1 -1
- package/src/components/select/components/select-content.tsx +2 -2
- package/src/components/select/components/select-option.tsx +1 -1
- package/src/components/select/components/select-overlay.tsx +1 -1
- package/src/components/select/components/select-root.tsx +2 -2
- package/src/components/select/components/select-trigger.tsx +35 -9
- package/src/components/select/context.ts +1 -1
- package/src/components/select/variants/default.tsx +2 -2
- package/src/components/tabs/variants/default.tsx +2 -2
- package/src/components/tabs/variants/line.tsx +2 -2
- package/src/components/textarea/variants/default.tsx +2 -2
- package/src/components/toast/components/toast-icon.tsx +8 -2
- package/src/components/toast/manager.tsx +11 -4
- package/src/components/toast/variants/danger.tsx +1 -1
- package/src/components/toast/variants/default.tsx +1 -1
- package/src/components/toast/variants/success.tsx +1 -1
- package/src/components/typography/variants/body-lg.tsx +1 -1
- package/src/components/typography/variants/body-md.tsx +1 -1
- package/src/components/typography/variants/body-sm.tsx +1 -1
- package/src/components/typography/variants/heading-lg.tsx +1 -1
- package/src/components/typography/variants/heading-md.tsx +1 -1
- package/src/components/typography/variants/heading-sm.tsx +1 -1
- package/src/data/countries.ts +88 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-phone-mask.ts +183 -0
- package/src/hooks/use-relative-position.ts +94 -18
- package/src/index.tsx +8 -3
- package/src/themes/default/colors.ts +28 -28
- package/src/themes/provider.tsx +23 -5
- package/src/themes/types.ts +1 -1
- package/src/themes/utils.ts +5 -2
- package/src/utils/input-utils.ts +5 -2
- package/src/utils/normalize-layout.ts +5 -2
- package/src/utils/use-themed-styles.ts +11 -3
- package/tsconfig.json +14 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type CalendarStyles } from "
|
|
2
|
-
import { useThemedStyles } from "
|
|
1
|
+
import { type CalendarStyles } from "../..";
|
|
2
|
+
import { useThemedStyles } from "../../../utils/use-themed-styles";
|
|
3
3
|
|
|
4
4
|
export const useCalendarVariantDefault = (): CalendarStyles => {
|
|
5
5
|
return useThemedStyles(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PropsWithRender } from "
|
|
2
|
-
import { calculateComposedStyles } from "
|
|
1
|
+
import type { PropsWithRender } from "../../types/props.types";
|
|
2
|
+
import { calculateComposedStyles } from "../../utils/calculate-styles";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { type StyleProp, View, type ViewStyle } from "react-native";
|
|
5
5
|
import { useCard } from "./context";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PropsWithRender } from "
|
|
2
|
-
import { calculateComposedStyles } from "
|
|
1
|
+
import type { PropsWithRender } from "../../types/props.types";
|
|
2
|
+
import { calculateComposedStyles } from "../../utils/calculate-styles";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { type StyleProp, View, type ViewStyle } from "react-native";
|
|
5
5
|
import { useCard } from "./context";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PropsWithRender } from "
|
|
2
|
-
import { calculateComposedStyles } from "
|
|
1
|
+
import type { PropsWithRender } from "../../types/props.types";
|
|
2
|
+
import { calculateComposedStyles } from "../../utils/calculate-styles";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { type StyleProp, View, type ViewStyle } from "react-native";
|
|
5
5
|
import { useCard } from "./context";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PropsWithRender } from "
|
|
2
|
-
import { calculateComposedStyles } from "
|
|
1
|
+
import type { PropsWithRender } from "../../types/props.types";
|
|
2
|
+
import { calculateComposedStyles } from "../../utils/calculate-styles";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { type StyleProp, View, type ViewStyle } from "react-native";
|
|
5
5
|
import { CardContext } from "./context";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { TextChildren } from "
|
|
2
|
-
import type { PropsWithRender } from "
|
|
3
|
-
import { calculateComposedStyles } from "
|
|
1
|
+
import type { TextChildren } from "../../types/element.types";
|
|
2
|
+
import type { PropsWithRender } from "../../types/props.types";
|
|
3
|
+
import { calculateComposedStyles } from "../../utils/calculate-styles";
|
|
4
4
|
import React from "react";
|
|
5
5
|
import { type StyleProp, Text, type TextStyle } from "react-native";
|
|
6
6
|
import { useCard } from "./context";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type CardStyles } from "
|
|
2
|
-
import { useThemedStyles } from "
|
|
1
|
+
import { type CardStyles } from "../..";
|
|
2
|
+
import { useThemedStyles } from "../../../utils/use-themed-styles";
|
|
3
3
|
|
|
4
4
|
export function useCardVariantDefault(): CardStyles {
|
|
5
5
|
return useThemedStyles(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type CheckboxStyles } from "
|
|
2
|
-
import { useThemedStyles } from "
|
|
1
|
+
import { type CheckboxStyles } from "../..";
|
|
2
|
+
import { useThemedStyles } from "../../../utils/use-themed-styles";
|
|
3
3
|
|
|
4
4
|
export const useCheckboxVariantDefault = (): CheckboxStyles => {
|
|
5
5
|
return useThemedStyles(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type CheckboxStyles } from "
|
|
2
|
-
import { useThemedStyles } from "
|
|
1
|
+
import { type CheckboxStyles } from "../..";
|
|
2
|
+
import { useThemedStyles } from "../../../utils/use-themed-styles";
|
|
3
3
|
|
|
4
4
|
export const useCheckboxVariantOutlined = (): CheckboxStyles => {
|
|
5
5
|
return useThemedStyles(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type EmptyStyles } from "
|
|
2
|
-
import { useThemedStyles } from "
|
|
1
|
+
import { type EmptyStyles } from "../..";
|
|
2
|
+
import { useThemedStyles } from "../../../utils/use-themed-styles";
|
|
3
3
|
|
|
4
4
|
export function useEmptyVariantDefault(): EmptyStyles {
|
|
5
5
|
return useThemedStyles(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type FieldStyles } from "
|
|
2
|
-
import { useThemedStyles } from "
|
|
1
|
+
import { type FieldStyles } from "../..";
|
|
2
|
+
import { useThemedStyles } from "../../../utils/use-themed-styles";
|
|
3
3
|
|
|
4
4
|
export const useFieldVariantDefault = (): FieldStyles => {
|
|
5
5
|
return useThemedStyles(
|
package/src/components/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TextInputRef } from "
|
|
1
|
+
import type { TextInputRef } from "../../types/element.types";
|
|
2
2
|
import { forwardRef, useState } from "react";
|
|
3
3
|
import { StyleSheet, TextInput, type TextInputProps } from "react-native";
|
|
4
4
|
import { useFieldOptional } from "../field/context";
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import { useNumericMask, type NumericMaskFormat } from "@/hooks/use-numeric-mask";
|
|
2
1
|
import React, { useEffect } from "react";
|
|
2
|
+
import {
|
|
3
|
+
useNumericMask,
|
|
4
|
+
type NumericMaskFormat,
|
|
5
|
+
} from "../../hooks/use-numeric-mask";
|
|
3
6
|
import { Input, type InputProps } from "./input";
|
|
4
7
|
import { InputVariants } from "./variants";
|
|
5
8
|
|
|
6
|
-
export interface NumericInputProps extends Omit<
|
|
9
|
+
export interface NumericInputProps extends Omit<
|
|
10
|
+
InputProps,
|
|
11
|
+
"value" | "onChange" | "keyboardType"
|
|
12
|
+
> {
|
|
7
13
|
variant?: keyof typeof InputVariants;
|
|
8
14
|
value?: number | null;
|
|
9
15
|
onChange?: (value: number | null) => void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useThemedStyles } from "
|
|
1
|
+
import { Platform } from "react-native";
|
|
2
|
+
import { useThemedStyles } from "../../../utils/use-themed-styles";
|
|
3
|
+
import { type InputStyles } from "../types";
|
|
3
4
|
|
|
4
5
|
export function useInputVariantDefault(): InputStyles {
|
|
5
6
|
return useThemedStyles(
|
|
@@ -14,11 +15,17 @@ export function useInputVariantDefault(): InputStyles {
|
|
|
14
15
|
backgroundColor: colors.surface,
|
|
15
16
|
paddingVertical: 12,
|
|
16
17
|
paddingHorizontal: 16,
|
|
17
|
-
outlineWidth: 0,
|
|
18
18
|
fontFamily,
|
|
19
19
|
fontSize,
|
|
20
20
|
height: 48,
|
|
21
21
|
color: colors.foreground,
|
|
22
|
+
outlineWidth: 0,
|
|
23
|
+
...Platform.select({
|
|
24
|
+
default: {},
|
|
25
|
+
web: {
|
|
26
|
+
outline: "none",
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
22
29
|
},
|
|
23
30
|
},
|
|
24
31
|
focused: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Platform } from "react-native";
|
|
2
|
+
import { type InputStyles } from "../..";
|
|
3
|
+
import { useThemedStyles } from "../../../utils/use-themed-styles";
|
|
3
4
|
|
|
4
5
|
export function useInputVariantSecondary(): InputStyles {
|
|
5
6
|
return useThemedStyles(
|
|
@@ -14,11 +15,17 @@ export function useInputVariantSecondary(): InputStyles {
|
|
|
14
15
|
backgroundColor: colors.background,
|
|
15
16
|
paddingVertical: 12,
|
|
16
17
|
paddingHorizontal: 16,
|
|
17
|
-
outlineWidth: 0,
|
|
18
18
|
fontFamily,
|
|
19
19
|
fontSize,
|
|
20
20
|
height: 48,
|
|
21
21
|
color: colors.foreground,
|
|
22
|
+
outlineWidth: 0,
|
|
23
|
+
...Platform.select({
|
|
24
|
+
default: {},
|
|
25
|
+
web: {
|
|
26
|
+
outline: "none",
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
22
29
|
},
|
|
23
30
|
},
|
|
24
31
|
focused: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useThemedStyles } from "@/utils/use-themed-styles";
|
|
2
1
|
import { type TextStyle } from "react-native";
|
|
2
|
+
import { useThemedStyles } from "../../../utils/use-themed-styles";
|
|
3
3
|
|
|
4
4
|
export function useLinkVariantDefault(): TextStyle {
|
|
5
5
|
return useThemedStyles(
|
|
@@ -9,6 +9,6 @@ export function useLinkVariantDefault(): TextStyle {
|
|
|
9
9
|
fontFamily,
|
|
10
10
|
textDecorationLine: "underline",
|
|
11
11
|
letterSpacing,
|
|
12
|
-
})
|
|
12
|
+
}),
|
|
13
13
|
);
|
|
14
14
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useRelativePosition } from "
|
|
1
|
+
import { useRelativePosition } from "../../../hooks/use-relative-position";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { type StyleProp, View, type ViewStyle } from "react-native";
|
|
4
4
|
import { useMenu } from "../context";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_LAYOUT, DEFAULT_POSITION, type LayoutPosition } from "
|
|
1
|
+
import { DEFAULT_LAYOUT, DEFAULT_POSITION, type LayoutPosition } from "../../../hooks/use-relative-position";
|
|
2
2
|
import React, { useState } from "react";
|
|
3
3
|
import { type LayoutRectangle } from "react-native";
|
|
4
4
|
import { MenuContext } from "../context";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ViewRef } from "@/types/element.types";
|
|
2
|
-
import { measureLayoutPosition } from "@/utils/normalize-layout";
|
|
3
1
|
import React, { forwardRef, useImperativeHandle, useRef } from "react";
|
|
4
2
|
import { type PressableProps } from "react-native";
|
|
3
|
+
import type { ViewRef } from "../../../types/element.types";
|
|
4
|
+
import { measureLayoutPosition } from "../../../utils/normalize-layout";
|
|
5
5
|
import { useMenu } from "../context";
|
|
6
6
|
|
|
7
7
|
export interface MenuTriggerProps extends PressableProps {
|
|
@@ -13,45 +13,47 @@ export interface MenuTriggerRef {
|
|
|
13
13
|
close: () => void;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export const MenuTrigger = forwardRef<MenuTriggerRef, MenuTriggerProps>(
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
export const MenuTrigger = forwardRef<MenuTriggerRef, MenuTriggerProps>(
|
|
17
|
+
(props, ref) => {
|
|
18
|
+
const menu = useMenu();
|
|
19
|
+
const triggerRef = useRef<ViewRef>(null);
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
const onTriggerPress = async () => {
|
|
22
|
+
if (!menu.isOpen) {
|
|
23
|
+
measureLayoutPosition(triggerRef.current, (layout) => {
|
|
24
|
+
menu.setTriggerPosition(layout);
|
|
25
|
+
menu.setIsOpen(true);
|
|
26
|
+
});
|
|
27
|
+
} else {
|
|
28
|
+
menu.setIsOpen(false);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
useImperativeHandle(ref, () => ({
|
|
33
|
+
open: () => {
|
|
34
|
+
triggerRef.current?.measureInWindow((pageX, pageY, width, height) => {
|
|
35
|
+
menu.setTriggerPosition({
|
|
36
|
+
height,
|
|
37
|
+
width,
|
|
38
|
+
pageX,
|
|
39
|
+
pageY,
|
|
40
|
+
});
|
|
41
|
+
menu.setIsOpen(true);
|
|
39
42
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
close: () => menu.setIsOpen(false),
|
|
44
|
-
}));
|
|
43
|
+
},
|
|
44
|
+
close: () => menu.setIsOpen(false),
|
|
45
|
+
}));
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
47
|
+
return React.cloneElement(props.children, {
|
|
48
|
+
ref: triggerRef,
|
|
49
|
+
onPress: onTriggerPress,
|
|
50
|
+
role: "button",
|
|
51
|
+
accessible: true,
|
|
52
|
+
accessibilityRole: "button",
|
|
53
|
+
accessibilityState: { expanded: menu.isOpen },
|
|
54
|
+
...props.children.props,
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
);
|
|
56
58
|
|
|
57
59
|
MenuTrigger.displayName = "MenuTrigger";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LayoutPosition } from "
|
|
1
|
+
import type { LayoutPosition } from "../../hooks/use-relative-position";
|
|
2
2
|
import { createContext, type Dispatch, useContext } from "react";
|
|
3
3
|
import type { LayoutRectangle } from "react-native";
|
|
4
4
|
import type { MenuStyles } from "./types";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type MenuStyles } from "
|
|
2
|
-
import { useThemedStyles } from "
|
|
1
|
+
import { type MenuStyles } from "../..";
|
|
2
|
+
import { useThemedStyles } from "../../../utils/use-themed-styles";
|
|
3
3
|
|
|
4
4
|
export const useMenuVariantDefault = (): MenuStyles => {
|
|
5
5
|
return useThemedStyles(
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import type { CountryData } from "../../data/countries";
|
|
2
|
+
import { usePhoneMask } from "../../hooks/use-phone-mask";
|
|
3
|
+
import { DEFAULT_LAYOUT, DEFAULT_POSITION, type LayoutPosition, useRelativePosition } from "../../hooks/use-relative-position";
|
|
4
|
+
import type { ViewRef } from "../../types/element.types";
|
|
5
|
+
import { measureLayoutPosition } from "../../utils/normalize-layout";
|
|
6
|
+
import React, { useRef, useState } from "react";
|
|
7
|
+
import {
|
|
8
|
+
Keyboard,
|
|
9
|
+
type LayoutRectangle,
|
|
10
|
+
Platform,
|
|
11
|
+
Pressable,
|
|
12
|
+
ScrollView,
|
|
13
|
+
type StyleProp,
|
|
14
|
+
StyleSheet,
|
|
15
|
+
Text,
|
|
16
|
+
TextInput,
|
|
17
|
+
View,
|
|
18
|
+
type ViewStyle,
|
|
19
|
+
} from "react-native";
|
|
20
|
+
import { Portal } from "../portal";
|
|
21
|
+
import type { PhoneInputState } from "./types";
|
|
22
|
+
import { PhoneInputVariants } from "./variants";
|
|
23
|
+
|
|
24
|
+
export interface PhoneInputProps {
|
|
25
|
+
value?: string;
|
|
26
|
+
onChange?: (value: string) => void;
|
|
27
|
+
defaultCountry?: string;
|
|
28
|
+
countries?: CountryData[];
|
|
29
|
+
placeholder?: string;
|
|
30
|
+
isDisabled?: boolean;
|
|
31
|
+
variant?: keyof typeof PhoneInputVariants;
|
|
32
|
+
style?: StyleProp<ViewStyle>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const calculateState = (isDisabled: boolean, isFocused: boolean): PhoneInputState => {
|
|
36
|
+
if (isDisabled) return "disabled";
|
|
37
|
+
if (isFocused) return "focused";
|
|
38
|
+
return "default";
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export function PhoneInput({
|
|
42
|
+
value,
|
|
43
|
+
onChange,
|
|
44
|
+
defaultCountry = "US",
|
|
45
|
+
countries,
|
|
46
|
+
placeholder,
|
|
47
|
+
isDisabled = false,
|
|
48
|
+
variant = "default",
|
|
49
|
+
style,
|
|
50
|
+
}: PhoneInputProps) {
|
|
51
|
+
const variantStyles = PhoneInputVariants[variant]();
|
|
52
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
53
|
+
const [isPickerOpen, setIsPickerOpen] = useState(false);
|
|
54
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
55
|
+
const [triggerPosition, setTriggerPosition] = useState<LayoutPosition>(DEFAULT_POSITION);
|
|
56
|
+
const [contentLayout, setContentLayout] = useState<LayoutRectangle>(DEFAULT_LAYOUT);
|
|
57
|
+
const triggerRef = useRef<ViewRef>(null);
|
|
58
|
+
|
|
59
|
+
const state = calculateState(isDisabled, isFocused);
|
|
60
|
+
|
|
61
|
+
const phoneMask = usePhoneMask({
|
|
62
|
+
value,
|
|
63
|
+
defaultCountry,
|
|
64
|
+
onChange,
|
|
65
|
+
countries,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const rootStyles = StyleSheet.flatten([variantStyles.root?.default, variantStyles.root?.[state], style]);
|
|
69
|
+
const countryButtonStyles = StyleSheet.flatten([variantStyles.countryButton?.default, variantStyles.countryButton?.[state]]);
|
|
70
|
+
const countryButtonTextStyles = StyleSheet.flatten([variantStyles.countryButtonText?.default, variantStyles.countryButtonText?.[state]]);
|
|
71
|
+
const separatorStyles = StyleSheet.flatten([variantStyles.separator?.default, variantStyles.separator?.[state]]);
|
|
72
|
+
const inputStyles = StyleSheet.flatten([variantStyles.input?.default, variantStyles.input?.[state]]);
|
|
73
|
+
|
|
74
|
+
const openPicker = () => {
|
|
75
|
+
if (isDisabled) return;
|
|
76
|
+
if (Platform.OS !== "web") {
|
|
77
|
+
Keyboard.dismiss();
|
|
78
|
+
}
|
|
79
|
+
measureLayoutPosition(triggerRef.current, (layout) => {
|
|
80
|
+
setTriggerPosition(layout);
|
|
81
|
+
setSearchQuery("");
|
|
82
|
+
setIsPickerOpen(true);
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const closePicker = () => {
|
|
87
|
+
setIsPickerOpen(false);
|
|
88
|
+
setSearchQuery("");
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const selectCountry = (country: CountryData) => {
|
|
92
|
+
phoneMask.setCountry(country.code);
|
|
93
|
+
closePicker();
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const filteredCountries = searchQuery
|
|
97
|
+
? phoneMask.countries.filter((c) => c.name.toLowerCase().includes(searchQuery.toLowerCase()))
|
|
98
|
+
: phoneMask.countries;
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<>
|
|
102
|
+
<View ref={triggerRef} style={rootStyles}>
|
|
103
|
+
<Pressable onPress={openPicker} disabled={isDisabled} style={countryButtonStyles}>
|
|
104
|
+
<Text style={countryButtonTextStyles}>
|
|
105
|
+
{phoneMask.country.flag} +{phoneMask.country.dialCode}
|
|
106
|
+
</Text>
|
|
107
|
+
</Pressable>
|
|
108
|
+
<View style={separatorStyles} />
|
|
109
|
+
<TextInput
|
|
110
|
+
value={phoneMask.displayValue}
|
|
111
|
+
onChangeText={phoneMask.onChangeText}
|
|
112
|
+
keyboardType={phoneMask.keyboardType}
|
|
113
|
+
placeholder={placeholder}
|
|
114
|
+
placeholderTextColor={StyleSheet.flatten(variantStyles.countryButtonText?.disabled)?.color}
|
|
115
|
+
readOnly={isDisabled}
|
|
116
|
+
onFocus={() => setIsFocused(true)}
|
|
117
|
+
onBlur={() => setIsFocused(false)}
|
|
118
|
+
style={inputStyles}
|
|
119
|
+
/>
|
|
120
|
+
</View>
|
|
121
|
+
|
|
122
|
+
{isPickerOpen && (
|
|
123
|
+
<CountryPicker
|
|
124
|
+
countries={filteredCountries}
|
|
125
|
+
selectedCode={phoneMask.country.code}
|
|
126
|
+
searchQuery={searchQuery}
|
|
127
|
+
onSearchChange={setSearchQuery}
|
|
128
|
+
onSelect={selectCountry}
|
|
129
|
+
onClose={closePicker}
|
|
130
|
+
triggerPosition={triggerPosition}
|
|
131
|
+
contentLayout={contentLayout}
|
|
132
|
+
onContentLayout={setContentLayout}
|
|
133
|
+
variantStyles={variantStyles}
|
|
134
|
+
state={state}
|
|
135
|
+
/>
|
|
136
|
+
)}
|
|
137
|
+
</>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
interface CountryPickerProps {
|
|
142
|
+
countries: CountryData[];
|
|
143
|
+
selectedCode: string;
|
|
144
|
+
searchQuery: string;
|
|
145
|
+
onSearchChange: (query: string) => void;
|
|
146
|
+
onSelect: (country: CountryData) => void;
|
|
147
|
+
onClose: () => void;
|
|
148
|
+
triggerPosition: LayoutPosition;
|
|
149
|
+
contentLayout: LayoutRectangle;
|
|
150
|
+
onContentLayout: (layout: LayoutRectangle) => void;
|
|
151
|
+
variantStyles: ReturnType<(typeof PhoneInputVariants)["default"]>;
|
|
152
|
+
state: PhoneInputState;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function CountryPicker({
|
|
156
|
+
countries,
|
|
157
|
+
selectedCode,
|
|
158
|
+
searchQuery,
|
|
159
|
+
onSearchChange,
|
|
160
|
+
onSelect,
|
|
161
|
+
onClose,
|
|
162
|
+
triggerPosition,
|
|
163
|
+
contentLayout,
|
|
164
|
+
onContentLayout,
|
|
165
|
+
variantStyles,
|
|
166
|
+
state,
|
|
167
|
+
}: CountryPickerProps) {
|
|
168
|
+
const positionStyle = useRelativePosition({
|
|
169
|
+
align: "start",
|
|
170
|
+
triggerPosition,
|
|
171
|
+
contentLayout,
|
|
172
|
+
alignOffset: 0,
|
|
173
|
+
preferredSide: "bottom",
|
|
174
|
+
sideOffset: 4,
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
const overlayStyles = StyleSheet.flatten([variantStyles.pickerOverlay?.default, variantStyles.pickerOverlay?.[state]]);
|
|
178
|
+
const contentStyles = StyleSheet.flatten([variantStyles.pickerContent?.default, variantStyles.pickerContent?.[state]]);
|
|
179
|
+
const searchStyles = StyleSheet.flatten([variantStyles.pickerSearch?.default, variantStyles.pickerSearch?.[state]]);
|
|
180
|
+
|
|
181
|
+
return (
|
|
182
|
+
<Portal name="phone-input-country-picker">
|
|
183
|
+
<Pressable onPress={onClose} style={[StyleSheet.absoluteFill, overlayStyles]} />
|
|
184
|
+
<View
|
|
185
|
+
style={[positionStyle, contentStyles, { width: triggerPosition.width }]}
|
|
186
|
+
onLayout={(e) => onContentLayout(e.nativeEvent.layout)}
|
|
187
|
+
pointerEvents="box-none"
|
|
188
|
+
>
|
|
189
|
+
<TextInput
|
|
190
|
+
value={searchQuery}
|
|
191
|
+
onChangeText={onSearchChange}
|
|
192
|
+
placeholder="Search countries..."
|
|
193
|
+
autoFocus
|
|
194
|
+
style={searchStyles}
|
|
195
|
+
/>
|
|
196
|
+
<ScrollView keyboardShouldPersistTaps="handled">
|
|
197
|
+
{countries.map((country) => {
|
|
198
|
+
const isSelected = country.code === selectedCode;
|
|
199
|
+
const optionStyles = StyleSheet.flatten([
|
|
200
|
+
variantStyles.pickerOption?.default,
|
|
201
|
+
isSelected && variantStyles.pickerOption?.selected,
|
|
202
|
+
]);
|
|
203
|
+
const optionTextStyles = StyleSheet.flatten([
|
|
204
|
+
variantStyles.pickerOptionText?.default,
|
|
205
|
+
isSelected && variantStyles.pickerOptionText?.selected,
|
|
206
|
+
]);
|
|
207
|
+
|
|
208
|
+
return (
|
|
209
|
+
<Pressable key={country.code} onPress={() => onSelect(country)} style={optionStyles}>
|
|
210
|
+
<Text style={optionTextStyles}>
|
|
211
|
+
{country.flag} {country.name} +{country.dialCode}
|
|
212
|
+
</Text>
|
|
213
|
+
</Pressable>
|
|
214
|
+
);
|
|
215
|
+
})}
|
|
216
|
+
</ScrollView>
|
|
217
|
+
</View>
|
|
218
|
+
</Portal>
|
|
219
|
+
);
|
|
220
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { StyleProp, TextStyle, ViewStyle } from "react-native";
|
|
2
|
+
|
|
3
|
+
export type PhoneInputState = "default" | "focused" | "disabled";
|
|
4
|
+
|
|
5
|
+
export interface PhoneInputStyles {
|
|
6
|
+
root?: Partial<Record<PhoneInputState, StyleProp<ViewStyle>>>;
|
|
7
|
+
countryButton?: Partial<Record<PhoneInputState, StyleProp<ViewStyle>>>;
|
|
8
|
+
countryButtonText?: Partial<Record<PhoneInputState, StyleProp<TextStyle>>>;
|
|
9
|
+
separator?: Partial<Record<PhoneInputState, StyleProp<ViewStyle>>>;
|
|
10
|
+
input?: Partial<Record<PhoneInputState, StyleProp<TextStyle>>>;
|
|
11
|
+
pickerOverlay?: Partial<Record<PhoneInputState, StyleProp<ViewStyle>>>;
|
|
12
|
+
pickerContent?: Partial<Record<PhoneInputState, StyleProp<ViewStyle>>>;
|
|
13
|
+
pickerOption?: Partial<
|
|
14
|
+
Record<PhoneInputState | "selected", StyleProp<ViewStyle>>
|
|
15
|
+
>;
|
|
16
|
+
pickerOptionText?: Partial<
|
|
17
|
+
Record<PhoneInputState | "selected", StyleProp<TextStyle>>
|
|
18
|
+
>;
|
|
19
|
+
pickerSearch?: Partial<Record<PhoneInputState, StyleProp<TextStyle>>>;
|
|
20
|
+
}
|