@korsolutions/ui 0.0.52 → 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 +3 -3
- package/dist/module/components/alert/components/alert-description.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/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.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/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 +2 -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/provider.tsx +23 -5
- 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,8 +1,16 @@
|
|
|
1
|
-
import type { SafeAreaInsets } from "@/safe-area";
|
|
2
1
|
import { useMemo } from "react";
|
|
3
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
useWindowDimensions,
|
|
4
|
+
type DisplayMetrics,
|
|
5
|
+
type LayoutRectangle,
|
|
6
|
+
type ViewStyle,
|
|
7
|
+
} from "react-native";
|
|
8
|
+
import type { SafeAreaInsets } from "../safe-area";
|
|
4
9
|
|
|
5
|
-
type UseRelativePositionArgs = Omit<
|
|
10
|
+
type UseRelativePositionArgs = Omit<
|
|
11
|
+
GetContentStyleArgs,
|
|
12
|
+
"triggerPosition" | "contentLayout" | "dimensions"
|
|
13
|
+
> & {
|
|
6
14
|
triggerPosition: LayoutPosition | null;
|
|
7
15
|
contentLayout: LayoutRectangle | null;
|
|
8
16
|
};
|
|
@@ -40,7 +48,17 @@ export function useRelativePosition({
|
|
|
40
48
|
});
|
|
41
49
|
|
|
42
50
|
return style;
|
|
43
|
-
}, [
|
|
51
|
+
}, [
|
|
52
|
+
align,
|
|
53
|
+
preferredSide,
|
|
54
|
+
alignOffset,
|
|
55
|
+
insets,
|
|
56
|
+
triggerPosition,
|
|
57
|
+
contentLayout,
|
|
58
|
+
dimensions.width,
|
|
59
|
+
dimensions.height,
|
|
60
|
+
sideOffset,
|
|
61
|
+
]);
|
|
44
62
|
}
|
|
45
63
|
|
|
46
64
|
export interface LayoutPosition {
|
|
@@ -62,8 +80,18 @@ interface GetSidePositionArgs extends GetPositionArgs {
|
|
|
62
80
|
sideOffset: number;
|
|
63
81
|
}
|
|
64
82
|
|
|
65
|
-
export const DEFAULT_LAYOUT: LayoutRectangle = {
|
|
66
|
-
|
|
83
|
+
export const DEFAULT_LAYOUT: LayoutRectangle = {
|
|
84
|
+
x: 0,
|
|
85
|
+
y: 0,
|
|
86
|
+
width: 0,
|
|
87
|
+
height: 0,
|
|
88
|
+
};
|
|
89
|
+
export const DEFAULT_POSITION: LayoutPosition = {
|
|
90
|
+
height: 0,
|
|
91
|
+
width: 0,
|
|
92
|
+
pageX: 0,
|
|
93
|
+
pageY: 0,
|
|
94
|
+
};
|
|
67
95
|
|
|
68
96
|
interface GetSideArgs {
|
|
69
97
|
preferredSide: "top" | "bottom";
|
|
@@ -75,7 +103,15 @@ interface GetSideArgs {
|
|
|
75
103
|
dimensions: DisplayMetrics;
|
|
76
104
|
}
|
|
77
105
|
|
|
78
|
-
function getSide({
|
|
106
|
+
function getSide({
|
|
107
|
+
preferredSide,
|
|
108
|
+
insetTop,
|
|
109
|
+
insetBottom,
|
|
110
|
+
positionTop,
|
|
111
|
+
positionBottom,
|
|
112
|
+
contentLayout,
|
|
113
|
+
dimensions,
|
|
114
|
+
}: GetSideArgs) {
|
|
79
115
|
if (preferredSide === "bottom") {
|
|
80
116
|
const spaceBelow = dimensions.height - insetBottom - positionBottom;
|
|
81
117
|
if (spaceBelow >= contentLayout.height) {
|
|
@@ -98,11 +134,20 @@ function getSide({ preferredSide, insetTop, insetBottom, positionTop, positionBo
|
|
|
98
134
|
return "top";
|
|
99
135
|
}
|
|
100
136
|
|
|
101
|
-
function getSidePosition({
|
|
137
|
+
function getSidePosition({
|
|
138
|
+
preferredSide,
|
|
139
|
+
triggerPosition,
|
|
140
|
+
contentLayout,
|
|
141
|
+
sideOffset,
|
|
142
|
+
insets,
|
|
143
|
+
dimensions,
|
|
144
|
+
}: GetSidePositionArgs) {
|
|
102
145
|
const insetTop = insets?.top ?? 0;
|
|
103
146
|
const insetBottom = insets?.bottom ?? 0;
|
|
104
|
-
const positionTop =
|
|
105
|
-
|
|
147
|
+
const positionTop =
|
|
148
|
+
triggerPosition?.pageY - sideOffset - contentLayout.height;
|
|
149
|
+
const positionBottom =
|
|
150
|
+
triggerPosition.pageY + triggerPosition.height + sideOffset;
|
|
106
151
|
|
|
107
152
|
const side = getSide({
|
|
108
153
|
preferredSide,
|
|
@@ -116,12 +161,18 @@ function getSidePosition({ preferredSide, triggerPosition, contentLayout, sideOf
|
|
|
116
161
|
|
|
117
162
|
if (side === "top") {
|
|
118
163
|
return {
|
|
119
|
-
top: Math.min(
|
|
164
|
+
top: Math.min(
|
|
165
|
+
Math.max(insetTop, positionTop),
|
|
166
|
+
dimensions.height - insetBottom - contentLayout.height,
|
|
167
|
+
),
|
|
120
168
|
};
|
|
121
169
|
}
|
|
122
170
|
|
|
123
171
|
return {
|
|
124
|
-
top: Math.min(
|
|
172
|
+
top: Math.min(
|
|
173
|
+
dimensions.height - insetBottom - contentLayout.height,
|
|
174
|
+
positionBottom,
|
|
175
|
+
),
|
|
125
176
|
};
|
|
126
177
|
}
|
|
127
178
|
|
|
@@ -130,16 +181,33 @@ interface GetAlignPositionArgs extends GetPositionArgs {
|
|
|
130
181
|
alignOffset: number;
|
|
131
182
|
}
|
|
132
183
|
|
|
133
|
-
function getAlignPosition({
|
|
184
|
+
function getAlignPosition({
|
|
185
|
+
align,
|
|
186
|
+
contentLayout,
|
|
187
|
+
triggerPosition,
|
|
188
|
+
alignOffset,
|
|
189
|
+
insets,
|
|
190
|
+
dimensions,
|
|
191
|
+
}: GetAlignPositionArgs) {
|
|
134
192
|
const insetLeft = insets?.left ?? 0;
|
|
135
193
|
const insetRight = insets?.right ?? 0;
|
|
136
194
|
const maxContentWidth = dimensions.width - insetLeft - insetRight;
|
|
137
195
|
|
|
138
196
|
const contentWidth = Math.min(contentLayout.width, maxContentWidth);
|
|
139
197
|
|
|
140
|
-
let left = getLeftPosition(
|
|
198
|
+
let left = getLeftPosition(
|
|
199
|
+
align,
|
|
200
|
+
triggerPosition.pageX,
|
|
201
|
+
triggerPosition.width,
|
|
202
|
+
contentWidth,
|
|
203
|
+
alignOffset,
|
|
204
|
+
insetLeft,
|
|
205
|
+
insetRight,
|
|
206
|
+
dimensions,
|
|
207
|
+
);
|
|
141
208
|
|
|
142
|
-
const doesCollide =
|
|
209
|
+
const doesCollide =
|
|
210
|
+
left < insetLeft || left + contentWidth > dimensions.width - insetRight;
|
|
143
211
|
if (doesCollide) {
|
|
144
212
|
const spaceLeft = left - insetLeft;
|
|
145
213
|
const spaceRight = dimensions.width - insetRight - (left + contentWidth);
|
|
@@ -149,7 +217,10 @@ function getAlignPosition({ align, contentLayout, triggerPosition, alignOffset,
|
|
|
149
217
|
} else if (spaceRight >= contentWidth) {
|
|
150
218
|
left = dimensions.width - insetRight - contentWidth;
|
|
151
219
|
} else {
|
|
152
|
-
const centeredPosition = Math.max(
|
|
220
|
+
const centeredPosition = Math.max(
|
|
221
|
+
insetLeft,
|
|
222
|
+
(dimensions.width - contentWidth - insetRight) / 2,
|
|
223
|
+
);
|
|
153
224
|
left = centeredPosition;
|
|
154
225
|
}
|
|
155
226
|
}
|
|
@@ -177,10 +248,15 @@ function getLeftPosition(
|
|
|
177
248
|
if (align === "end") {
|
|
178
249
|
left = triggerPageX + triggerWidth - contentWidth;
|
|
179
250
|
}
|
|
180
|
-
return Math.max(
|
|
251
|
+
return Math.max(
|
|
252
|
+
insetLeft,
|
|
253
|
+
Math.min(left + alignOffset, dimensions.width - contentWidth - insetRight),
|
|
254
|
+
);
|
|
181
255
|
}
|
|
182
256
|
|
|
183
|
-
type GetContentStyleArgs = GetPositionArgs &
|
|
257
|
+
type GetContentStyleArgs = GetPositionArgs &
|
|
258
|
+
GetSidePositionArgs &
|
|
259
|
+
GetAlignPositionArgs;
|
|
184
260
|
|
|
185
261
|
function getContentStyle(args: GetContentStyleArgs): ViewStyle {
|
|
186
262
|
return {
|
package/src/index.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { SafeAreaProvider, type SafeAreaInsets } from "@/safe-area";
|
|
2
|
-
import { ThemeProvider, type ThemeProviderProps } from "@/themes";
|
|
3
1
|
import { AsyncAlertDialogManager } from "./components/alert-dialog/async-alert-dialog";
|
|
4
2
|
import { PortalHost } from "./components/portal";
|
|
5
3
|
import { type PortalHostProps } from "./components/portal/portal.constants";
|
|
6
4
|
import { ToastContainer } from "./components/toast/manager";
|
|
5
|
+
import { SafeAreaProvider, type SafeAreaInsets } from "./safe-area";
|
|
6
|
+
import { ThemeProvider, type ThemeProviderProps } from "./themes";
|
|
7
7
|
|
|
8
8
|
export interface ProviderProps {
|
|
9
9
|
children: React.ReactNode;
|
|
@@ -12,7 +12,12 @@ export interface ProviderProps {
|
|
|
12
12
|
safeAreaInsets?: SafeAreaInsets;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export const UIProvider = ({
|
|
15
|
+
export const UIProvider = ({
|
|
16
|
+
children,
|
|
17
|
+
portalContainer,
|
|
18
|
+
theme,
|
|
19
|
+
safeAreaInsets,
|
|
20
|
+
}: ProviderProps) => {
|
|
16
21
|
return (
|
|
17
22
|
<SafeAreaProvider insets={safeAreaInsets}>
|
|
18
23
|
<ThemeProvider theme={theme}>
|
package/src/themes/provider.tsx
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
type PropsWithChildren,
|
|
4
|
+
useContext,
|
|
5
|
+
useEffect,
|
|
6
|
+
useState,
|
|
7
|
+
} from "react";
|
|
3
8
|
import { useColorScheme } from "react-native";
|
|
9
|
+
import type { DeepPartial } from "../types/util.types";
|
|
4
10
|
import { defaultThemeAssets } from "./default";
|
|
5
|
-
import type {
|
|
11
|
+
import type {
|
|
12
|
+
Colors,
|
|
13
|
+
ColorScheme,
|
|
14
|
+
FontFamily,
|
|
15
|
+
FontSize,
|
|
16
|
+
LetterSpacing,
|
|
17
|
+
Radius,
|
|
18
|
+
ThemeAssets,
|
|
19
|
+
} from "./types";
|
|
6
20
|
import { mergeThemeAssets } from "./utils";
|
|
7
21
|
|
|
8
22
|
interface ThemeContext {
|
|
@@ -25,9 +39,13 @@ export const ThemeProvider = (props: ThemeProviderProps) => {
|
|
|
25
39
|
const { children, theme } = props;
|
|
26
40
|
|
|
27
41
|
const systemColorScheme = useColorScheme();
|
|
28
|
-
const [colorScheme, setColorScheme] = useState<ColorScheme>(
|
|
42
|
+
const [colorScheme, setColorScheme] = useState<ColorScheme>(
|
|
43
|
+
systemColorScheme === "dark" ? "dark" : "light",
|
|
44
|
+
);
|
|
29
45
|
|
|
30
|
-
const themeAssets = theme
|
|
46
|
+
const themeAssets = theme
|
|
47
|
+
? mergeThemeAssets(defaultThemeAssets, theme)
|
|
48
|
+
: defaultThemeAssets;
|
|
31
49
|
|
|
32
50
|
const colors = themeAssets.colors[colorScheme];
|
|
33
51
|
|
package/src/themes/utils.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import type { DeepPartial } from "
|
|
1
|
+
import type { DeepPartial } from "../types/util.types";
|
|
2
2
|
import type { ThemeAssets } from "./types";
|
|
3
3
|
|
|
4
|
-
export function mergeThemeAssets(
|
|
4
|
+
export function mergeThemeAssets(
|
|
5
|
+
base: ThemeAssets,
|
|
6
|
+
override: DeepPartial<ThemeAssets>,
|
|
7
|
+
): ThemeAssets {
|
|
5
8
|
return {
|
|
6
9
|
colors: {
|
|
7
10
|
light: { ...base.colors.light, ...override.colors?.light },
|
package/src/utils/input-utils.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import type { TextInputRef } from "@/types/element.types";
|
|
2
1
|
import { Platform } from "react-native";
|
|
2
|
+
import type { TextInputRef } from "../types/element.types";
|
|
3
3
|
|
|
4
|
-
export function setInnerInputValue(
|
|
4
|
+
export function setInnerInputValue(
|
|
5
|
+
element: HTMLInputElement | TextInputRef,
|
|
6
|
+
value: string,
|
|
7
|
+
) {
|
|
5
8
|
if (Platform.OS === "web") {
|
|
6
9
|
(element as HTMLInputElement).value = value;
|
|
7
10
|
} else {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { LayoutPosition } from "@/hooks";
|
|
2
1
|
import type { HostInstance, LayoutRectangle } from "react-native";
|
|
2
|
+
import type { LayoutPosition } from "../hooks";
|
|
3
3
|
|
|
4
4
|
export const normalizeLayout = (layout: LayoutRectangle) => {
|
|
5
5
|
const _layout = { ...layout };
|
|
@@ -21,7 +21,10 @@ const isValidNumber = (value: unknown): value is number => {
|
|
|
21
21
|
return isValid;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
export const measureLayoutPosition = (
|
|
24
|
+
export const measureLayoutPosition = (
|
|
25
|
+
ref: HostInstance | null,
|
|
26
|
+
callback: (layout: LayoutPosition) => void,
|
|
27
|
+
) => {
|
|
25
28
|
ref?.measureInWindow((pageX, pageY, width, height) => {
|
|
26
29
|
callback({
|
|
27
30
|
height: isValidNumber(height) ? height : 0,
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import { useTheme } from "
|
|
2
|
-
import type {
|
|
1
|
+
import { useTheme } from "../themes";
|
|
2
|
+
import type {
|
|
3
|
+
Colors,
|
|
4
|
+
FontFamily,
|
|
5
|
+
FontSize,
|
|
6
|
+
LetterSpacing,
|
|
7
|
+
Radius,
|
|
8
|
+
} from "../themes/types";
|
|
3
9
|
|
|
4
10
|
interface CallbackProps {
|
|
5
11
|
colors: Colors;
|
|
@@ -9,7 +15,9 @@ interface CallbackProps {
|
|
|
9
15
|
fontSize: FontSize;
|
|
10
16
|
}
|
|
11
17
|
|
|
12
|
-
export const useThemedStyles = <T>(
|
|
18
|
+
export const useThemedStyles = <T>(
|
|
19
|
+
callback: (props: CallbackProps) => T,
|
|
20
|
+
): T => {
|
|
13
21
|
const theme = useTheme();
|
|
14
22
|
return callback({
|
|
15
23
|
colors: theme.colors,
|
package/tsconfig.json
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"customConditions": [
|
|
3
|
+
"customConditions": [
|
|
4
|
+
"dev-source",
|
|
5
|
+
"react-native",
|
|
6
|
+
"react-native-strict-api"
|
|
7
|
+
],
|
|
4
8
|
"allowJs": true,
|
|
5
9
|
"esModuleInterop": true,
|
|
6
10
|
"jsx": "react-native",
|
|
7
|
-
"lib": [
|
|
11
|
+
"lib": [
|
|
12
|
+
"DOM",
|
|
13
|
+
"ESNext"
|
|
14
|
+
],
|
|
8
15
|
"module": "preserve",
|
|
9
16
|
"moduleDetection": "force",
|
|
10
17
|
"moduleResolution": "bundler",
|
|
@@ -24,9 +31,9 @@
|
|
|
24
31
|
"noUncheckedIndexedAccess": true,
|
|
25
32
|
"noUnusedLocals": true,
|
|
26
33
|
"noUnusedParameters": true,
|
|
27
|
-
"paths": {
|
|
28
|
-
"@/*": ["./src/*"]
|
|
29
|
-
}
|
|
30
34
|
},
|
|
31
|
-
"exclude": [
|
|
32
|
-
|
|
35
|
+
"exclude": [
|
|
36
|
+
"node_modules",
|
|
37
|
+
"dist"
|
|
38
|
+
]
|
|
39
|
+
}
|