@korsolutions/ui 0.0.63 → 0.0.65
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/module/components/button/button.js +44 -0
- package/dist/module/components/button/button.js.map +1 -0
- package/dist/module/components/button/index.js +1 -8
- package/dist/module/components/button/index.js.map +1 -1
- package/dist/module/components/button/variants/default.js +15 -10
- package/dist/module/components/button/variants/default.js.map +1 -1
- package/dist/module/components/button/variants/ghost.js +19 -4
- package/dist/module/components/button/variants/ghost.js.map +1 -1
- package/dist/module/components/button/variants/secondary.js +19 -4
- package/dist/module/components/button/variants/secondary.js.map +1 -1
- package/dist/module/components/menu/components/menu-trigger.js +2 -7
- package/dist/module/components/menu/components/menu-trigger.js.map +1 -1
- package/dist/module/components/popover/components/popover-trigger.js +3 -8
- package/dist/module/components/popover/components/popover-trigger.js.map +1 -1
- package/dist/module/components/portal/portal.js +5 -4
- package/dist/module/components/portal/portal.js.map +1 -1
- package/dist/module/components/select/components/select-overlay.js +1 -0
- package/dist/module/components/select/components/select-overlay.js.map +1 -1
- package/dist/module/components/select/variants/default.js +5 -2
- package/dist/module/components/select/variants/default.js.map +1 -1
- package/dist/module/hooks/use-is-react-navigation-modal.js +41 -0
- package/dist/module/hooks/use-is-react-navigation-modal.js.map +1 -0
- package/dist/module/hooks/use-organized-children.js.map +1 -1
- package/dist/module/hooks/use-relative-position.js +20 -12
- package/dist/module/hooks/use-relative-position.js.map +1 -1
- package/dist/module/index.js +3 -0
- package/dist/module/index.js.map +1 -1
- package/dist/module/utils/normalize-layout.js +10 -0
- package/dist/module/utils/normalize-layout.js.map +1 -1
- package/dist/typescript/src/components/button/{components/button-root.d.ts → button.d.ts} +4 -4
- package/dist/typescript/src/components/button/button.d.ts.map +1 -0
- package/dist/typescript/src/components/button/index.d.ts +1 -11
- package/dist/typescript/src/components/button/index.d.ts.map +1 -1
- package/dist/typescript/src/components/button/types.d.ts +6 -6
- package/dist/typescript/src/components/button/types.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/ghost.d.ts +1 -1
- package/dist/typescript/src/components/button/variants/ghost.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/menu/components/menu-trigger.d.ts.map +1 -1
- package/dist/typescript/src/components/popover/components/popover-trigger.d.ts +1 -1
- package/dist/typescript/src/components/popover/components/popover-trigger.d.ts.map +1 -1
- package/dist/typescript/src/components/portal/portal.d.ts.map +1 -1
- package/dist/typescript/src/components/select/components/select-overlay.d.ts.map +1 -1
- package/dist/typescript/src/components/select/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/hooks/use-is-react-navigation-modal.d.ts +3 -0
- package/dist/typescript/src/hooks/use-is-react-navigation-modal.d.ts.map +1 -0
- package/dist/typescript/src/hooks/use-organized-children.d.ts +1 -1
- package/dist/typescript/src/hooks/use-organized-children.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/typescript/src/utils/normalize-layout.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/button/button.tsx +85 -0
- package/src/components/button/index.ts +1 -13
- package/src/components/button/types.ts +10 -6
- package/src/components/button/variants/default.tsx +12 -6
- package/src/components/button/variants/ghost.tsx +18 -2
- package/src/components/button/variants/secondary.tsx +18 -2
- package/src/components/menu/components/menu-trigger.tsx +2 -7
- package/src/components/popover/components/popover-trigger.tsx +8 -10
- package/src/components/portal/portal.tsx +4 -3
- package/src/components/select/components/select-overlay.tsx +1 -0
- package/src/components/select/variants/default.tsx +4 -1
- package/src/hooks/use-is-react-navigation-modal.ts +56 -0
- package/src/hooks/use-organized-children.tsx +1 -1
- package/src/hooks/use-relative-position.ts +33 -18
- package/src/index.tsx +4 -0
- package/src/utils/normalize-layout.ts +10 -0
- package/dist/module/components/button/components/button-label.js +0 -18
- package/dist/module/components/button/components/button-label.js.map +0 -1
- package/dist/module/components/button/components/button-root.js +0 -60
- package/dist/module/components/button/components/button-root.js.map +0 -1
- package/dist/module/components/button/components/button-spinner.js +0 -15
- package/dist/module/components/button/components/button-spinner.js.map +0 -1
- package/dist/module/components/button/context.js +0 -12
- package/dist/module/components/button/context.js.map +0 -1
- package/dist/typescript/src/components/button/components/button-label.d.ts +0 -9
- package/dist/typescript/src/components/button/components/button-label.d.ts.map +0 -1
- package/dist/typescript/src/components/button/components/button-root.d.ts.map +0 -1
- package/dist/typescript/src/components/button/components/button-spinner.d.ts +0 -8
- package/dist/typescript/src/components/button/components/button-spinner.d.ts.map +0 -1
- package/dist/typescript/src/components/button/context.d.ts +0 -8
- package/dist/typescript/src/components/button/context.d.ts.map +0 -1
- package/src/components/button/components/button-label.tsx +0 -25
- package/src/components/button/components/button-root.tsx +0 -76
- package/src/components/button/components/button-spinner.tsx +0 -14
- package/src/components/button/context.ts +0 -17
|
@@ -44,7 +44,9 @@ export function useSelectVariantDefault(): SelectStyles {
|
|
|
44
44
|
},
|
|
45
45
|
},
|
|
46
46
|
overlay: {
|
|
47
|
-
default: {
|
|
47
|
+
default: {
|
|
48
|
+
zIndex: 999,
|
|
49
|
+
},
|
|
48
50
|
disabled: {},
|
|
49
51
|
},
|
|
50
52
|
content: {
|
|
@@ -55,6 +57,7 @@ export function useSelectVariantDefault(): SelectStyles {
|
|
|
55
57
|
borderColor: colors.border,
|
|
56
58
|
padding: 4,
|
|
57
59
|
gap: 4,
|
|
60
|
+
zIndex: 1000,
|
|
58
61
|
},
|
|
59
62
|
disabled: {},
|
|
60
63
|
},
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { useEffect, useMemo } from "react";
|
|
2
|
+
|
|
3
|
+
type NavigationContainerRef =
|
|
4
|
+
import("@react-navigation/native").NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>;
|
|
5
|
+
|
|
6
|
+
let useCachedNavigationContainerRef: (() => NavigationContainerRef) | null =
|
|
7
|
+
null;
|
|
8
|
+
|
|
9
|
+
export function useInitializeNavigationContainerRef() {
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
try {
|
|
12
|
+
const expoRouter = require("expo-router");
|
|
13
|
+
if (expoRouter) {
|
|
14
|
+
useCachedNavigationContainerRef = expoRouter.useNavigationContainerRef;
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const reactNavigation = require("@react-navigation/native");
|
|
18
|
+
if (reactNavigation) {
|
|
19
|
+
useCachedNavigationContainerRef =
|
|
20
|
+
reactNavigation.useNavigationContainerRef;
|
|
21
|
+
}
|
|
22
|
+
} catch (error) {
|
|
23
|
+
console.warn(
|
|
24
|
+
"[useIsReactNavigationModal] Failed to load navigation ref:",
|
|
25
|
+
error,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}, []);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const getIsModal = () => {
|
|
32
|
+
const useNavigationContainerRef = useCachedNavigationContainerRef;
|
|
33
|
+
|
|
34
|
+
if (!useNavigationContainerRef) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const navigationRef = useNavigationContainerRef();
|
|
39
|
+
if (!navigationRef) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
const state = navigationRef.getCurrentOptions();
|
|
43
|
+
if (
|
|
44
|
+
state &&
|
|
45
|
+
"presentation" in state &&
|
|
46
|
+
typeof state.presentation === "string"
|
|
47
|
+
) {
|
|
48
|
+
return state.presentation === "modal";
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export function useIsReactNavigationModal() {
|
|
54
|
+
const isModal = useMemo(getIsModal, []);
|
|
55
|
+
return isModal;
|
|
56
|
+
}
|
|
@@ -6,7 +6,7 @@ import { getElementProp } from "../utils/element-utils";
|
|
|
6
6
|
export function useOrganizedChildren(
|
|
7
7
|
children: React.ReactNode,
|
|
8
8
|
textStyle: StyleProp<TextStyle> | undefined,
|
|
9
|
-
iconProps: IconProps | undefined,
|
|
9
|
+
iconProps: IconProps | undefined | null,
|
|
10
10
|
): React.ReactNode {
|
|
11
11
|
const organizedChildren = useMemo(() => {
|
|
12
12
|
if (typeof children === "string") {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
2
|
import {
|
|
3
|
+
Platform,
|
|
3
4
|
useWindowDimensions,
|
|
4
5
|
type DisplayMetrics,
|
|
5
6
|
type LayoutRectangle,
|
|
@@ -7,12 +8,17 @@ import {
|
|
|
7
8
|
} from "react-native";
|
|
8
9
|
import { usePortalOffset } from "../components/portal";
|
|
9
10
|
import { useSafeAreaInsets, type SafeAreaInsets } from "../safe-area";
|
|
11
|
+
import { useIsReactNavigationModal } from "./use-is-react-navigation-modal";
|
|
10
12
|
|
|
11
13
|
type UseRelativePositionArgs = Omit<
|
|
12
14
|
GetContentStyleArgs,
|
|
13
15
|
"dimensions" | "insets"
|
|
14
16
|
>;
|
|
15
17
|
|
|
18
|
+
type GetContentStyleArgs = GetPositionArgs &
|
|
19
|
+
GetSidePositionArgs &
|
|
20
|
+
GetAlignPositionArgs;
|
|
21
|
+
|
|
16
22
|
export function useRelativePosition({
|
|
17
23
|
align,
|
|
18
24
|
triggerPosition,
|
|
@@ -25,6 +31,8 @@ export function useRelativePosition({
|
|
|
25
31
|
const insets = useSafeAreaInsets();
|
|
26
32
|
const portalOffset = usePortalOffset();
|
|
27
33
|
|
|
34
|
+
const isReactNavigationModal = useIsReactNavigationModal();
|
|
35
|
+
|
|
28
36
|
return useMemo(() => {
|
|
29
37
|
const hasLayout =
|
|
30
38
|
triggerPosition.width > 0 &&
|
|
@@ -53,7 +61,7 @@ export function useRelativePosition({
|
|
|
53
61
|
pageY: triggerPosition.pageY - portalOffset.value.y,
|
|
54
62
|
};
|
|
55
63
|
|
|
56
|
-
const
|
|
64
|
+
const args: GetContentStyleArgs = {
|
|
57
65
|
align,
|
|
58
66
|
contentLayout,
|
|
59
67
|
preferredSide,
|
|
@@ -62,7 +70,23 @@ export function useRelativePosition({
|
|
|
62
70
|
insets,
|
|
63
71
|
sideOffset,
|
|
64
72
|
dimensions,
|
|
65
|
-
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const sidePosition = getSidePosition(args);
|
|
76
|
+
const alignPosition = getAlignPosition(args);
|
|
77
|
+
|
|
78
|
+
const style: ViewStyle = {
|
|
79
|
+
position: "absolute",
|
|
80
|
+
...sidePosition,
|
|
81
|
+
...alignPosition,
|
|
82
|
+
// Temporary fix to calculate portal content relative position correctly when rendered in a React Navigation modal.
|
|
83
|
+
top: Platform.select({
|
|
84
|
+
default: sidePosition.top,
|
|
85
|
+
ios: isReactNavigationModal
|
|
86
|
+
? sidePosition.top + insets.top
|
|
87
|
+
: sidePosition.top,
|
|
88
|
+
}),
|
|
89
|
+
};
|
|
66
90
|
|
|
67
91
|
return style;
|
|
68
92
|
}, [
|
|
@@ -76,6 +100,7 @@ export function useRelativePosition({
|
|
|
76
100
|
dimensions.height,
|
|
77
101
|
sideOffset,
|
|
78
102
|
portalOffset,
|
|
103
|
+
isReactNavigationModal,
|
|
79
104
|
]);
|
|
80
105
|
}
|
|
81
106
|
|
|
@@ -181,11 +206,13 @@ function getSidePosition({
|
|
|
181
206
|
};
|
|
182
207
|
}
|
|
183
208
|
|
|
209
|
+
let top = Math.min(
|
|
210
|
+
dimensions.height - insets.bottom - contentLayout.height,
|
|
211
|
+
positionBottom,
|
|
212
|
+
);
|
|
213
|
+
|
|
184
214
|
return {
|
|
185
|
-
top
|
|
186
|
-
dimensions.height - insets.bottom - contentLayout.height,
|
|
187
|
-
positionBottom,
|
|
188
|
-
),
|
|
215
|
+
top,
|
|
189
216
|
};
|
|
190
217
|
}
|
|
191
218
|
|
|
@@ -265,15 +292,3 @@ function getLeftPosition(
|
|
|
265
292
|
),
|
|
266
293
|
);
|
|
267
294
|
}
|
|
268
|
-
|
|
269
|
-
type GetContentStyleArgs = GetPositionArgs &
|
|
270
|
-
GetSidePositionArgs &
|
|
271
|
-
GetAlignPositionArgs;
|
|
272
|
-
|
|
273
|
-
function getContentStyle(args: GetContentStyleArgs): ViewStyle {
|
|
274
|
-
return {
|
|
275
|
-
position: "absolute",
|
|
276
|
-
...getSidePosition(args),
|
|
277
|
-
...getAlignPosition(args),
|
|
278
|
-
};
|
|
279
|
-
}
|
package/src/index.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import { AsyncAlertDialogManager } from "./components/alert-dialog/async-alert-d
|
|
|
2
2
|
import { PortalHost } from "./components/portal";
|
|
3
3
|
import { type PortalHostProps } from "./components/portal/portal.constants";
|
|
4
4
|
import { ToastContainer } from "./components/toast/manager";
|
|
5
|
+
import { useInitializeNavigationContainerRef } from "./hooks/use-is-react-navigation-modal";
|
|
5
6
|
import { SafeAreaProvider, type SafeAreaInsets } from "./safe-area";
|
|
6
7
|
import {
|
|
7
8
|
ThemeProvider,
|
|
@@ -24,6 +25,9 @@ export const UIProvider = ({
|
|
|
24
25
|
safeAreaInsets,
|
|
25
26
|
components,
|
|
26
27
|
}: ProviderProps) => {
|
|
28
|
+
// Temporary fix to calculate portal content relative position correctly when rendered in a React Navigation modal.
|
|
29
|
+
useInitializeNavigationContainerRef();
|
|
30
|
+
|
|
27
31
|
return (
|
|
28
32
|
<SafeAreaProvider insets={safeAreaInsets}>
|
|
29
33
|
<ThemeProvider theme={theme} components={components}>
|
|
@@ -25,6 +25,16 @@ export const measureLayoutPosition = (
|
|
|
25
25
|
ref: HostInstance | null,
|
|
26
26
|
callback: (layout: LayoutPosition) => void,
|
|
27
27
|
) => {
|
|
28
|
+
if (ref && "getBoundingClientRect" in ref) {
|
|
29
|
+
const rect = (ref as unknown as { getBoundingClientRect: () => DOMRect }).getBoundingClientRect();
|
|
30
|
+
callback({
|
|
31
|
+
height: isValidNumber(rect.height) ? rect.height : 0,
|
|
32
|
+
width: isValidNumber(rect.width) ? rect.width : 0,
|
|
33
|
+
pageX: isValidNumber(rect.x) ? rect.x : 0,
|
|
34
|
+
pageY: isValidNumber(rect.y) ? rect.y : 0,
|
|
35
|
+
});
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
28
38
|
ref?.measureInWindow((pageX, pageY, width, height) => {
|
|
29
39
|
callback({
|
|
30
40
|
height: isValidNumber(height) ? height : 0,
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { calculateComposedStyles } from "../../../utils/calculate-styles.js";
|
|
4
|
-
import React from "react";
|
|
5
|
-
import { Text } from "react-native";
|
|
6
|
-
import { useButton } from "../context.js";
|
|
7
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
export function ButtonLabel(props) {
|
|
9
|
-
const button = useButton();
|
|
10
|
-
const calculatedStyle = calculateComposedStyles(button.styles, button.state, "label", props.style);
|
|
11
|
-
const isSelectable = button.state !== "disabled" && button.state !== "loading";
|
|
12
|
-
return /*#__PURE__*/_jsx(Text, {
|
|
13
|
-
selectable: isSelectable,
|
|
14
|
-
style: calculatedStyle,
|
|
15
|
-
children: props.children
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=button-label.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["calculateComposedStyles","React","Text","useButton","jsx","_jsx","ButtonLabel","props","button","calculatedStyle","styles","state","style","isSelectable","selectable","children"],"sourceRoot":"../../../../../src","sources":["components/button/components/button-label.tsx"],"mappings":";;AACA,SAASA,uBAAuB,QAAQ,oCAAiC;AACzE,OAAOC,KAAK,MAAM,OAAO;AACzB,SAAyBC,IAAI,QAAwB,cAAc;AACnE,SAASC,SAAS,QAAQ,eAAY;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAQvC,OAAO,SAASC,WAAWA,CAACC,KAAuB,EAAE;EACnD,MAAMC,MAAM,GAAGL,SAAS,CAAC,CAAC;EAE1B,MAAMM,eAAe,GAAGT,uBAAuB,CAACQ,MAAM,CAACE,MAAM,EAAEF,MAAM,CAACG,KAAK,EAAE,OAAO,EAAEJ,KAAK,CAACK,KAAK,CAAC;EAElG,MAAMC,YAAY,GAAGL,MAAM,CAACG,KAAK,KAAK,UAAU,IAAIH,MAAM,CAACG,KAAK,KAAK,SAAS;EAE9E,oBACEN,IAAA,CAACH,IAAI;IAACY,UAAU,EAAED,YAAa;IAACD,KAAK,EAAEH,eAAgB;IAAAM,QAAA,EACpDR,KAAK,CAACQ;EAAQ,CACX,CAAC;AAEX","ignoreList":[]}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import React, { useState } from "react";
|
|
4
|
-
import { Pressable } from "react-native";
|
|
5
|
-
import { ButtonContext } from "../context.js";
|
|
6
|
-
import { ButtonVariants } from "../variants/index.js";
|
|
7
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
const calculateState = (props, isHovered) => {
|
|
9
|
-
if (props.isDisabled) {
|
|
10
|
-
return "disabled";
|
|
11
|
-
}
|
|
12
|
-
if (props.isLoading) {
|
|
13
|
-
return "loading";
|
|
14
|
-
}
|
|
15
|
-
if (isHovered) {
|
|
16
|
-
return "hovered";
|
|
17
|
-
}
|
|
18
|
-
return "default";
|
|
19
|
-
};
|
|
20
|
-
const cursorValue = state => {
|
|
21
|
-
switch (state) {
|
|
22
|
-
case "disabled":
|
|
23
|
-
return "not-allowed";
|
|
24
|
-
case "loading":
|
|
25
|
-
return "wait";
|
|
26
|
-
default:
|
|
27
|
-
return "pointer";
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
export function ButtonRoot(props) {
|
|
31
|
-
const variantStyles = ButtonVariants[props.variant ?? "default"]();
|
|
32
|
-
const [isHovered, setIsHovered] = useState(false);
|
|
33
|
-
const state = calculateState(props, isHovered);
|
|
34
|
-
const calculatedStyle = [variantStyles.root?.default, variantStyles.root?.[state], props.style];
|
|
35
|
-
const handlePress = event => {
|
|
36
|
-
if (props.isDisabled || props.isLoading) {
|
|
37
|
-
event.preventDefault();
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
props.onPress?.(event);
|
|
41
|
-
};
|
|
42
|
-
const contextValue = {
|
|
43
|
-
state,
|
|
44
|
-
styles: variantStyles
|
|
45
|
-
};
|
|
46
|
-
return /*#__PURE__*/_jsx(ButtonContext.Provider, {
|
|
47
|
-
value: contextValue,
|
|
48
|
-
children: /*#__PURE__*/_jsx(Pressable, {
|
|
49
|
-
...props,
|
|
50
|
-
onPress: handlePress,
|
|
51
|
-
onHoverIn: () => setIsHovered(true),
|
|
52
|
-
onHoverOut: () => setIsHovered(false),
|
|
53
|
-
disabled: props.isDisabled,
|
|
54
|
-
style: [calculatedStyle, {
|
|
55
|
-
cursor: cursorValue(state)
|
|
56
|
-
}]
|
|
57
|
-
})
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=button-root.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","useState","Pressable","ButtonContext","ButtonVariants","jsx","_jsx","calculateState","props","isHovered","isDisabled","isLoading","cursorValue","state","ButtonRoot","variantStyles","variant","setIsHovered","calculatedStyle","root","default","style","handlePress","event","preventDefault","onPress","contextValue","styles","Provider","value","children","onHoverIn","onHoverOut","disabled","cursor"],"sourceRoot":"../../../../../src","sources":["components/button/components/button-root.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,SAAS,QAA+E,cAAc;AAC/G,SAASC,aAAa,QAAQ,eAAY;AAE1C,SAASC,cAAc,QAAQ,sBAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAY7C,MAAMC,cAAc,GAAGA,CAACC,KAAsB,EAAEC,SAAkB,KAAkB;EAClF,IAAID,KAAK,CAACE,UAAU,EAAE;IACpB,OAAO,UAAU;EACnB;EACA,IAAIF,KAAK,CAACG,SAAS,EAAE;IACnB,OAAO,SAAS;EAClB;EACA,IAAIF,SAAS,EAAE;IACb,OAAO,SAAS;EAClB;EACA,OAAO,SAAS;AAClB,CAAC;AAED,MAAMG,WAAW,GAAIC,KAAkB,IAAkB;EACvD,QAAQA,KAAK;IACX,KAAK,UAAU;MACb,OAAO,aAAa;IACtB,KAAK,SAAS;MACZ,OAAO,MAAM;IACf;MACE,OAAO,SAAS;EACpB;AACF,CAAC;AAED,OAAO,SAASC,UAAUA,CAACN,KAAsB,EAAE;EACjD,MAAMO,aAAa,GAAGX,cAAc,CAACI,KAAK,CAACQ,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC;EAClE,MAAM,CAACP,SAAS,EAAEQ,YAAY,CAAC,GAAGhB,QAAQ,CAAC,KAAK,CAAC;EAEjD,MAAMY,KAAK,GAAGN,cAAc,CAACC,KAAK,EAAEC,SAAS,CAAC;EAE9C,MAAMS,eAAe,GAAG,CAACH,aAAa,CAACI,IAAI,EAAEC,OAAO,EAAEL,aAAa,CAACI,IAAI,GAAGN,KAAK,CAAC,EAAEL,KAAK,CAACa,KAAK,CAAC;EAE/F,MAAMC,WAAsC,GAAIC,KAAK,IAAK;IACxD,IAAIf,KAAK,CAACE,UAAU,IAAIF,KAAK,CAACG,SAAS,EAAE;MACvCY,KAAK,CAACC,cAAc,CAAC,CAAC;MACtB;IACF;IACAhB,KAAK,CAACiB,OAAO,GAAGF,KAAK,CAAC;EACxB,CAAC;EAED,MAAMG,YAA2B,GAAG;IAAEb,KAAK;IAAEc,MAAM,EAAEZ;EAAc,CAAC;EAEpE,oBACET,IAAA,CAACH,aAAa,CAACyB,QAAQ;IAACC,KAAK,EAAEH,YAAa;IAAAI,QAAA,eAC1CxB,IAAA,CAACJ,SAAS;MAAA,GACJM,KAAK;MACTiB,OAAO,EAAEH,WAAY;MACrBS,SAAS,EAAEA,CAAA,KAAMd,YAAY,CAAC,IAAI,CAAE;MACpCe,UAAU,EAAEA,CAAA,KAAMf,YAAY,CAAC,KAAK,CAAE;MACtCgB,QAAQ,EAAEzB,KAAK,CAACE,UAAW;MAC3BW,KAAK,EAAE,CACLH,eAAe,EACf;QACEgB,MAAM,EAAEtB,WAAW,CAACC,KAAK;MAC3B,CAAC;IACD,CACH;EAAC,CACoB,CAAC;AAE7B","ignoreList":[]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { ActivityIndicator } from "react-native";
|
|
5
|
-
import { useButton } from "../context.js";
|
|
6
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
export function ButtonSpinner(props) {
|
|
8
|
-
const button = useButton();
|
|
9
|
-
const composedStyle = [button.styles?.spinner?.default?.style, button.styles?.spinner?.[button.state]?.style, props.style];
|
|
10
|
-
return /*#__PURE__*/_jsx(ActivityIndicator, {
|
|
11
|
-
style: composedStyle,
|
|
12
|
-
color: props.color
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=button-spinner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","ActivityIndicator","useButton","jsx","_jsx","ButtonSpinner","props","button","composedStyle","styles","spinner","default","style","state","color"],"sourceRoot":"../../../../../src","sources":["components/button/components/button-spinner.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAqE,cAAc;AAC7G,SAASC,SAAS,QAAQ,eAAY;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAOvC,OAAO,SAASC,aAAaA,CAACC,KAAyB,EAAE;EACvD,MAAMC,MAAM,GAAGL,SAAS,CAAC,CAAC;EAC1B,MAAMM,aAAa,GAAG,CAACD,MAAM,CAACE,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAEC,KAAK,EAAEL,MAAM,CAACE,MAAM,EAAEC,OAAO,GAAGH,MAAM,CAACM,KAAK,CAAC,EAAED,KAAK,EAAEN,KAAK,CAACM,KAAK,CAAC;EAC1H,oBAAOR,IAAA,CAACH,iBAAiB;IAACW,KAAK,EAAEJ,aAAc;IAACM,KAAK,EAAER,KAAK,CAACQ;EAAM,CAAE,CAAC;AACxE","ignoreList":[]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { createContext, useContext } from "react";
|
|
4
|
-
export const ButtonContext = /*#__PURE__*/createContext(undefined);
|
|
5
|
-
export const useButton = () => {
|
|
6
|
-
const context = useContext(ButtonContext);
|
|
7
|
-
if (!context) {
|
|
8
|
-
throw new Error("useButton must be used within a ButtonProvider");
|
|
9
|
-
}
|
|
10
|
-
return context;
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["createContext","useContext","ButtonContext","undefined","useButton","context","Error"],"sourceRoot":"../../../../src","sources":["components/button/context.ts"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,OAAO;AAQjD,OAAO,MAAMC,aAAa,gBAAGF,aAAa,CAA4BG,SAAS,CAAC;AAEhF,OAAO,MAAMC,SAAS,GAAGA,CAAA,KAAM;EAC7B,MAAMC,OAAO,GAAGJ,UAAU,CAACC,aAAa,CAAC;EACzC,IAAI,CAACG,OAAO,EAAE;IACZ,MAAM,IAAIC,KAAK,CAAC,gDAAgD,CAAC;EACnE;EACA,OAAOD,OAAO;AAChB,CAAC","ignoreList":[]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { TextChildren } from "../../../types/element.types";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { type StyleProp, type TextStyle } from "react-native";
|
|
4
|
-
export interface ButtonLabelProps {
|
|
5
|
-
children?: TextChildren;
|
|
6
|
-
style?: StyleProp<TextStyle>;
|
|
7
|
-
}
|
|
8
|
-
export declare function ButtonLabel(props: ButtonLabelProps): React.JSX.Element;
|
|
9
|
-
//# sourceMappingURL=button-label.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"button-label.d.ts","sourceRoot":"","sources":["../../../../../../src/components/button/components/button-label.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,SAAS,EAAQ,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAGpE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,YAAY,CAAC;IAExB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,qBAYlD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"button-root.d.ts","sourceRoot":"","sources":["../../../../../../src/components/button/components/button-root.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,EAA+B,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAGhH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,WAAW,eAAgB,SAAQ,cAAc;IACrD,OAAO,CAAC,EAAE,MAAM,OAAO,cAAc,CAAC;IACtC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE3B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AA0BD,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,qBAmChD"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { type ActivityIndicatorProps, type StyleProp, type ViewStyle } from "react-native";
|
|
3
|
-
export interface ButtonSpinnerProps {
|
|
4
|
-
style?: StyleProp<ViewStyle>;
|
|
5
|
-
color?: ActivityIndicatorProps["color"];
|
|
6
|
-
}
|
|
7
|
-
export declare function ButtonSpinner(props: ButtonSpinnerProps): React.JSX.Element;
|
|
8
|
-
//# sourceMappingURL=button-spinner.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"button-spinner.d.ts","sourceRoot":"","sources":["../../../../../../src/components/button/components/button-spinner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAqB,KAAK,sBAAsB,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAG9G,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,KAAK,CAAC,EAAE,sBAAsB,CAAC,OAAO,CAAC,CAAC;CACzC;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,qBAItD"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ButtonState, ButtonStyles } from "./types";
|
|
2
|
-
export interface ButtonContext {
|
|
3
|
-
state: ButtonState;
|
|
4
|
-
styles?: ButtonStyles;
|
|
5
|
-
}
|
|
6
|
-
export declare const ButtonContext: import("react").Context<ButtonContext | undefined>;
|
|
7
|
-
export declare const useButton: () => ButtonContext;
|
|
8
|
-
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../../src/components/button/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEzD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,WAAW,CAAC;IACnB,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED,eAAO,MAAM,aAAa,oDAAsD,CAAC;AAEjF,eAAO,MAAM,SAAS,qBAMrB,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { TextChildren } from "../../../types/element.types";
|
|
2
|
-
import { calculateComposedStyles } from "../../../utils/calculate-styles";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { type StyleProp, Text, type TextStyle } from "react-native";
|
|
5
|
-
import { useButton } from "../context";
|
|
6
|
-
|
|
7
|
-
export interface ButtonLabelProps {
|
|
8
|
-
children?: TextChildren;
|
|
9
|
-
|
|
10
|
-
style?: StyleProp<TextStyle>;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function ButtonLabel(props: ButtonLabelProps) {
|
|
14
|
-
const button = useButton();
|
|
15
|
-
|
|
16
|
-
const calculatedStyle = calculateComposedStyles(button.styles, button.state, "label", props.style);
|
|
17
|
-
|
|
18
|
-
const isSelectable = button.state !== "disabled" && button.state !== "loading";
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<Text selectable={isSelectable} style={calculatedStyle}>
|
|
22
|
-
{props.children}
|
|
23
|
-
</Text>
|
|
24
|
-
);
|
|
25
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import { Pressable, type CursorValue, type PressableProps, type StyleProp, type ViewStyle } from "react-native";
|
|
3
|
-
import { ButtonContext } from "../context";
|
|
4
|
-
import type { ButtonState } from "../types";
|
|
5
|
-
import { ButtonVariants } from "../variants";
|
|
6
|
-
|
|
7
|
-
export interface ButtonRootProps extends PressableProps {
|
|
8
|
-
variant?: keyof typeof ButtonVariants;
|
|
9
|
-
children?: React.ReactNode;
|
|
10
|
-
|
|
11
|
-
isDisabled?: boolean;
|
|
12
|
-
isLoading?: boolean;
|
|
13
|
-
|
|
14
|
-
style?: StyleProp<ViewStyle>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const calculateState = (props: ButtonRootProps, isHovered: boolean): ButtonState => {
|
|
18
|
-
if (props.isDisabled) {
|
|
19
|
-
return "disabled";
|
|
20
|
-
}
|
|
21
|
-
if (props.isLoading) {
|
|
22
|
-
return "loading";
|
|
23
|
-
}
|
|
24
|
-
if (isHovered) {
|
|
25
|
-
return "hovered";
|
|
26
|
-
}
|
|
27
|
-
return "default";
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const cursorValue = (state: ButtonState): CursorValue => {
|
|
31
|
-
switch (state) {
|
|
32
|
-
case "disabled":
|
|
33
|
-
return "not-allowed" as CursorValue;
|
|
34
|
-
case "loading":
|
|
35
|
-
return "wait" as CursorValue;
|
|
36
|
-
default:
|
|
37
|
-
return "pointer";
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export function ButtonRoot(props: ButtonRootProps) {
|
|
42
|
-
const variantStyles = ButtonVariants[props.variant ?? "default"]();
|
|
43
|
-
const [isHovered, setIsHovered] = useState(false);
|
|
44
|
-
|
|
45
|
-
const state = calculateState(props, isHovered);
|
|
46
|
-
|
|
47
|
-
const calculatedStyle = [variantStyles.root?.default, variantStyles.root?.[state], props.style];
|
|
48
|
-
|
|
49
|
-
const handlePress: PressableProps["onPress"] = (event) => {
|
|
50
|
-
if (props.isDisabled || props.isLoading) {
|
|
51
|
-
event.preventDefault();
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
props.onPress?.(event);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const contextValue: ButtonContext = { state, styles: variantStyles };
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<ButtonContext.Provider value={contextValue}>
|
|
61
|
-
<Pressable
|
|
62
|
-
{...props}
|
|
63
|
-
onPress={handlePress}
|
|
64
|
-
onHoverIn={() => setIsHovered(true)}
|
|
65
|
-
onHoverOut={() => setIsHovered(false)}
|
|
66
|
-
disabled={props.isDisabled}
|
|
67
|
-
style={[
|
|
68
|
-
calculatedStyle,
|
|
69
|
-
{
|
|
70
|
-
cursor: cursorValue(state),
|
|
71
|
-
},
|
|
72
|
-
]}
|
|
73
|
-
/>
|
|
74
|
-
</ButtonContext.Provider>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ActivityIndicator, type ActivityIndicatorProps, type StyleProp, type ViewStyle } from "react-native";
|
|
3
|
-
import { useButton } from "../context";
|
|
4
|
-
|
|
5
|
-
export interface ButtonSpinnerProps {
|
|
6
|
-
style?: StyleProp<ViewStyle>;
|
|
7
|
-
color?: ActivityIndicatorProps["color"];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function ButtonSpinner(props: ButtonSpinnerProps) {
|
|
11
|
-
const button = useButton();
|
|
12
|
-
const composedStyle = [button.styles?.spinner?.default?.style, button.styles?.spinner?.[button.state]?.style, props.style];
|
|
13
|
-
return <ActivityIndicator style={composedStyle} color={props.color} />;
|
|
14
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext } from "react";
|
|
2
|
-
import type { ButtonState, ButtonStyles } from "./types";
|
|
3
|
-
|
|
4
|
-
export interface ButtonContext {
|
|
5
|
-
state: ButtonState;
|
|
6
|
-
styles?: ButtonStyles;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const ButtonContext = createContext<ButtonContext | undefined>(undefined);
|
|
10
|
-
|
|
11
|
-
export const useButton = () => {
|
|
12
|
-
const context = useContext(ButtonContext);
|
|
13
|
-
if (!context) {
|
|
14
|
-
throw new Error("useButton must be used within a ButtonProvider");
|
|
15
|
-
}
|
|
16
|
-
return context;
|
|
17
|
-
};
|