@korsolutions/ui 0.0.36 → 0.0.38

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.
Files changed (124) hide show
  1. package/dist/module/components/alert-dialog/alert-dialog.js +41 -0
  2. package/dist/module/components/alert-dialog/alert-dialog.js.map +1 -0
  3. package/dist/module/components/alert-dialog/async-alert-dialog.js +117 -0
  4. package/dist/module/components/alert-dialog/async-alert-dialog.js.map +1 -0
  5. package/dist/module/components/alert-dialog/index.js +6 -0
  6. package/dist/module/components/alert-dialog/index.js.map +1 -0
  7. package/dist/module/components/alert-dialog/variants/default.js +93 -0
  8. package/dist/module/components/alert-dialog/variants/default.js.map +1 -0
  9. package/dist/module/components/alert-dialog/variants/index.js +7 -0
  10. package/dist/module/components/alert-dialog/variants/index.js.map +1 -0
  11. package/dist/module/components/checkbox/checkbox.js +4 -4
  12. package/dist/module/components/checkbox/checkbox.js.map +1 -1
  13. package/dist/module/components/index.js +1 -0
  14. package/dist/module/components/index.js.map +1 -1
  15. package/dist/module/index.js +2 -1
  16. package/dist/module/index.js.map +1 -1
  17. package/dist/module/primitives/alert-dialog/alert-dialog-action.js +34 -0
  18. package/dist/module/primitives/alert-dialog/alert-dialog-action.js.map +1 -0
  19. package/dist/module/primitives/alert-dialog/alert-dialog-cancel.js +34 -0
  20. package/dist/module/primitives/alert-dialog/alert-dialog-cancel.js.map +1 -0
  21. package/dist/module/primitives/alert-dialog/alert-dialog-content.js +23 -0
  22. package/dist/module/primitives/alert-dialog/alert-dialog-content.js.map +1 -0
  23. package/dist/module/primitives/alert-dialog/alert-dialog-description.js +23 -0
  24. package/dist/module/primitives/alert-dialog/alert-dialog-description.js.map +1 -0
  25. package/dist/module/primitives/alert-dialog/alert-dialog-footer.js +23 -0
  26. package/dist/module/primitives/alert-dialog/alert-dialog-footer.js.map +1 -0
  27. package/dist/module/primitives/alert-dialog/alert-dialog-overlay.js +26 -0
  28. package/dist/module/primitives/alert-dialog/alert-dialog-overlay.js.map +1 -0
  29. package/dist/module/primitives/alert-dialog/alert-dialog-portal.js +20 -0
  30. package/dist/module/primitives/alert-dialog/alert-dialog-portal.js.map +1 -0
  31. package/dist/module/primitives/alert-dialog/alert-dialog-root.js +22 -0
  32. package/dist/module/primitives/alert-dialog/alert-dialog-root.js.map +1 -0
  33. package/dist/module/primitives/alert-dialog/alert-dialog-title.js +23 -0
  34. package/dist/module/primitives/alert-dialog/alert-dialog-title.js.map +1 -0
  35. package/dist/module/primitives/alert-dialog/alert-dialog-trigger.js +28 -0
  36. package/dist/module/primitives/alert-dialog/alert-dialog-trigger.js.map +1 -0
  37. package/dist/module/primitives/alert-dialog/context.js +12 -0
  38. package/dist/module/primitives/alert-dialog/context.js.map +1 -0
  39. package/dist/module/primitives/alert-dialog/index.js +26 -0
  40. package/dist/module/primitives/alert-dialog/index.js.map +1 -0
  41. package/dist/module/primitives/alert-dialog/types.js +4 -0
  42. package/dist/module/primitives/alert-dialog/types.js.map +1 -0
  43. package/dist/module/primitives/checkbox/checkbox-indicator.js +3 -3
  44. package/dist/module/primitives/checkbox/checkbox-indicator.js.map +1 -1
  45. package/dist/module/primitives/checkbox/checkbox-root.js +12 -12
  46. package/dist/module/primitives/checkbox/checkbox-root.js.map +1 -1
  47. package/dist/module/primitives/index.js +1 -0
  48. package/dist/module/primitives/index.js.map +1 -1
  49. package/dist/module/primitives/popover/popover-portal.js +1 -1
  50. package/dist/module/primitives/popover/popover-portal.js.map +1 -1
  51. package/dist/typescript/src/components/alert-dialog/alert-dialog.d.ts +15 -0
  52. package/dist/typescript/src/components/alert-dialog/alert-dialog.d.ts.map +1 -0
  53. package/dist/typescript/src/components/alert-dialog/async-alert-dialog.d.ts +19 -0
  54. package/dist/typescript/src/components/alert-dialog/async-alert-dialog.d.ts.map +1 -0
  55. package/dist/typescript/src/components/alert-dialog/index.d.ts +4 -0
  56. package/dist/typescript/src/components/alert-dialog/index.d.ts.map +1 -0
  57. package/dist/typescript/src/components/alert-dialog/variants/default.d.ts +3 -0
  58. package/dist/typescript/src/components/alert-dialog/variants/default.d.ts.map +1 -0
  59. package/dist/typescript/src/components/alert-dialog/variants/index.d.ts +4 -0
  60. package/dist/typescript/src/components/alert-dialog/variants/index.d.ts.map +1 -0
  61. package/dist/typescript/src/components/checkbox/checkbox.d.ts +3 -3
  62. package/dist/typescript/src/components/checkbox/checkbox.d.ts.map +1 -1
  63. package/dist/typescript/src/components/index.d.ts +1 -0
  64. package/dist/typescript/src/components/index.d.ts.map +1 -1
  65. package/dist/typescript/src/index.d.ts.map +1 -1
  66. package/dist/typescript/src/primitives/alert-dialog/alert-dialog-action.d.ts +8 -0
  67. package/dist/typescript/src/primitives/alert-dialog/alert-dialog-action.d.ts.map +1 -0
  68. package/dist/typescript/src/primitives/alert-dialog/alert-dialog-cancel.d.ts +8 -0
  69. package/dist/typescript/src/primitives/alert-dialog/alert-dialog-cancel.d.ts.map +1 -0
  70. package/dist/typescript/src/primitives/alert-dialog/alert-dialog-content.d.ts +8 -0
  71. package/dist/typescript/src/primitives/alert-dialog/alert-dialog-content.d.ts.map +1 -0
  72. package/dist/typescript/src/primitives/alert-dialog/alert-dialog-description.d.ts +8 -0
  73. package/dist/typescript/src/primitives/alert-dialog/alert-dialog-description.d.ts.map +1 -0
  74. package/dist/typescript/src/primitives/alert-dialog/alert-dialog-footer.d.ts +8 -0
  75. package/dist/typescript/src/primitives/alert-dialog/alert-dialog-footer.d.ts.map +1 -0
  76. package/dist/typescript/src/primitives/alert-dialog/alert-dialog-overlay.d.ts +7 -0
  77. package/dist/typescript/src/primitives/alert-dialog/alert-dialog-overlay.d.ts.map +1 -0
  78. package/dist/typescript/src/primitives/alert-dialog/alert-dialog-portal.d.ts +7 -0
  79. package/dist/typescript/src/primitives/alert-dialog/alert-dialog-portal.d.ts.map +1 -0
  80. package/dist/typescript/src/primitives/alert-dialog/alert-dialog-root.d.ts +8 -0
  81. package/dist/typescript/src/primitives/alert-dialog/alert-dialog-root.d.ts.map +1 -0
  82. package/dist/typescript/src/primitives/alert-dialog/alert-dialog-title.d.ts +8 -0
  83. package/dist/typescript/src/primitives/alert-dialog/alert-dialog-title.d.ts.map +1 -0
  84. package/dist/typescript/src/primitives/alert-dialog/alert-dialog-trigger.d.ts +154 -0
  85. package/dist/typescript/src/primitives/alert-dialog/alert-dialog-trigger.d.ts.map +1 -0
  86. package/dist/typescript/src/primitives/alert-dialog/context.d.ts +10 -0
  87. package/dist/typescript/src/primitives/alert-dialog/context.d.ts.map +1 -0
  88. package/dist/typescript/src/primitives/alert-dialog/index.d.ts +33 -0
  89. package/dist/typescript/src/primitives/alert-dialog/index.d.ts.map +1 -0
  90. package/dist/typescript/src/primitives/alert-dialog/types.d.ts +13 -0
  91. package/dist/typescript/src/primitives/alert-dialog/types.d.ts.map +1 -0
  92. package/dist/typescript/src/primitives/checkbox/checkbox-context.d.ts +3 -3
  93. package/dist/typescript/src/primitives/checkbox/checkbox-context.d.ts.map +1 -1
  94. package/dist/typescript/src/primitives/checkbox/checkbox-root.d.ts +3 -3
  95. package/dist/typescript/src/primitives/checkbox/checkbox-root.d.ts.map +1 -1
  96. package/dist/typescript/src/primitives/index.d.ts +1 -0
  97. package/dist/typescript/src/primitives/index.d.ts.map +1 -1
  98. package/package.json +1 -1
  99. package/src/components/alert-dialog/alert-dialog.tsx +38 -0
  100. package/src/components/alert-dialog/async-alert-dialog.tsx +121 -0
  101. package/src/components/alert-dialog/index.ts +3 -0
  102. package/src/components/alert-dialog/variants/default.tsx +82 -0
  103. package/src/components/alert-dialog/variants/index.ts +5 -0
  104. package/src/components/checkbox/checkbox.tsx +5 -5
  105. package/src/components/index.ts +1 -0
  106. package/src/index.tsx +2 -0
  107. package/src/primitives/alert-dialog/alert-dialog-action.tsx +27 -0
  108. package/src/primitives/alert-dialog/alert-dialog-cancel.tsx +27 -0
  109. package/src/primitives/alert-dialog/alert-dialog-content.tsx +21 -0
  110. package/src/primitives/alert-dialog/alert-dialog-description.tsx +21 -0
  111. package/src/primitives/alert-dialog/alert-dialog-footer.tsx +21 -0
  112. package/src/primitives/alert-dialog/alert-dialog-overlay.tsx +25 -0
  113. package/src/primitives/alert-dialog/alert-dialog-portal.tsx +20 -0
  114. package/src/primitives/alert-dialog/alert-dialog-root.tsx +25 -0
  115. package/src/primitives/alert-dialog/alert-dialog-title.tsx +21 -0
  116. package/src/primitives/alert-dialog/alert-dialog-trigger.tsx +27 -0
  117. package/src/primitives/alert-dialog/context.ts +18 -0
  118. package/src/primitives/alert-dialog/index.ts +34 -0
  119. package/src/primitives/alert-dialog/types.ts +13 -0
  120. package/src/primitives/checkbox/checkbox-context.tsx +3 -3
  121. package/src/primitives/checkbox/checkbox-indicator.tsx +3 -3
  122. package/src/primitives/checkbox/checkbox-root.tsx +14 -15
  123. package/src/primitives/index.ts +1 -0
  124. package/src/primitives/popover/popover-portal.tsx +1 -1
package/src/index.tsx CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ThemeProvider } from "@/themes";
2
+ import { AsyncAlertDialogManager } from "./components/alert-dialog/async-alert-dialog";
2
3
  import { ToastContainer } from "./components/toast/toast-manager";
3
4
  import { PortalHost } from "./primitives/portal";
4
5
  import { type PortalHostProps } from "./primitives/portal/portal.constants";
@@ -15,6 +16,7 @@ export const UniversalUIProvider = ({ children, portalContainer }: ProviderProps
15
16
  <ToastContainer />
16
17
  {children}
17
18
  <PortalHost container={portalContainer} />
19
+ <AsyncAlertDialogManager />
18
20
  </ThemeProvider>
19
21
  );
20
22
  };
@@ -0,0 +1,27 @@
1
+ import React from "react";
2
+ import { Pressable, Text, type PressableProps, type StyleProp, type ViewStyle } from "react-native";
3
+ import { useAlertDialog } from "./context";
4
+
5
+ export interface AlertDialogPrimitiveActionProps extends PressableProps {
6
+ children: React.ReactNode;
7
+ style?: StyleProp<ViewStyle>;
8
+ }
9
+
10
+ export function AlertDialogAction(props: AlertDialogPrimitiveActionProps) {
11
+ const { children, style, onPress, ...pressableProps } = props;
12
+ const { styles, setIsOpen } = useAlertDialog();
13
+
14
+ const handlePress: PressableProps["onPress"] = (event) => {
15
+ onPress?.(event);
16
+ setIsOpen(false);
17
+ };
18
+
19
+ const calculatedStyle = [styles?.action, style];
20
+ const textStyle = styles?.actionText;
21
+
22
+ return (
23
+ <Pressable {...pressableProps} style={calculatedStyle} onPress={handlePress}>
24
+ <Text style={textStyle}>{children}</Text>
25
+ </Pressable>
26
+ );
27
+ }
@@ -0,0 +1,27 @@
1
+ import React from "react";
2
+ import { Pressable, Text, type PressableProps, type StyleProp, type ViewStyle } from "react-native";
3
+ import { useAlertDialog } from "./context";
4
+
5
+ export interface AlertDialogPrimitiveCancelProps extends PressableProps {
6
+ children: React.ReactNode;
7
+ style?: StyleProp<ViewStyle>;
8
+ }
9
+
10
+ export function AlertDialogCancel(props: AlertDialogPrimitiveCancelProps) {
11
+ const { children, style, onPress, ...pressableProps } = props;
12
+ const { styles, setIsOpen } = useAlertDialog();
13
+
14
+ const handlePress: PressableProps["onPress"] = (event) => {
15
+ onPress?.(event);
16
+ setIsOpen(false);
17
+ };
18
+
19
+ const calculatedStyle = [styles?.cancel, style];
20
+ const textStyle = styles?.cancelText;
21
+
22
+ return (
23
+ <Pressable {...pressableProps} style={calculatedStyle} onPress={handlePress}>
24
+ <Text style={textStyle}>{children}</Text>
25
+ </Pressable>
26
+ );
27
+ }
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import { View, type StyleProp, type ViewProps, type ViewStyle } from "react-native";
3
+ import { useAlertDialog } from "./context";
4
+
5
+ export interface AlertDialogPrimitiveContentProps extends ViewProps {
6
+ children: React.ReactNode;
7
+ style?: StyleProp<ViewStyle>;
8
+ }
9
+
10
+ export function AlertDialogContent(props: AlertDialogPrimitiveContentProps) {
11
+ const { children, style, ...viewProps } = props;
12
+ const { styles } = useAlertDialog();
13
+
14
+ const calculatedStyle = [styles?.content, style];
15
+
16
+ return (
17
+ <View {...viewProps} style={calculatedStyle}>
18
+ {children}
19
+ </View>
20
+ );
21
+ }
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import { Text, type StyleProp, type TextProps, type TextStyle } from "react-native";
3
+ import { useAlertDialog } from "./context";
4
+
5
+ export interface AlertDialogPrimitiveDescriptionProps extends TextProps {
6
+ children: React.ReactNode;
7
+ style?: StyleProp<TextStyle>;
8
+ }
9
+
10
+ export function AlertDialogDescription(props: AlertDialogPrimitiveDescriptionProps) {
11
+ const { children, style, ...textProps } = props;
12
+ const { styles } = useAlertDialog();
13
+
14
+ const calculatedStyle = [styles?.description, style];
15
+
16
+ return (
17
+ <Text {...textProps} style={calculatedStyle}>
18
+ {children}
19
+ </Text>
20
+ );
21
+ }
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import { View, type StyleProp, type ViewProps, type ViewStyle } from "react-native";
3
+ import { useAlertDialog } from "./context";
4
+
5
+ export interface AlertDialogPrimitiveFooterProps extends ViewProps {
6
+ children: React.ReactNode;
7
+ style?: StyleProp<ViewStyle>;
8
+ }
9
+
10
+ export function AlertDialogFooter(props: AlertDialogPrimitiveFooterProps) {
11
+ const { children, style, ...viewProps } = props;
12
+ const { styles } = useAlertDialog();
13
+
14
+ const calculatedStyle = [styles?.footer, style];
15
+
16
+ return (
17
+ <View {...viewProps} style={calculatedStyle}>
18
+ {children}
19
+ </View>
20
+ );
21
+ }
@@ -0,0 +1,25 @@
1
+ import React from "react";
2
+ import { Pressable, type PressableProps, type StyleProp, type ViewStyle } from "react-native";
3
+ import { useAlertDialog } from "./context";
4
+
5
+ export interface AlertDialogPrimitiveOverlayProps extends PressableProps {
6
+ style?: StyleProp<ViewStyle>;
7
+ }
8
+
9
+ export function AlertDialogOverlay(props: AlertDialogPrimitiveOverlayProps) {
10
+ const { style, ...pressableProps } = props;
11
+ const { styles, setIsOpen } = useAlertDialog();
12
+
13
+ const calculatedStyle = [styles?.overlay, style];
14
+
15
+ return (
16
+ <Pressable
17
+ {...pressableProps}
18
+ style={calculatedStyle}
19
+ onPress={() => setIsOpen(false)}
20
+ accessible={true}
21
+ accessibilityRole="button"
22
+ accessibilityLabel="Close alert dialog"
23
+ />
24
+ );
25
+ }
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import { Portal } from "../portal";
3
+ import { AlertDialogPrimitiveContext, useAlertDialog } from "./context";
4
+
5
+ interface AlertDialogPortalProps {
6
+ children: React.ReactNode;
7
+ }
8
+
9
+ export function AlertDialogPortal(props: AlertDialogPortalProps) {
10
+ const alertDialog = useAlertDialog();
11
+
12
+ if (!alertDialog.isOpen) {
13
+ return null;
14
+ }
15
+ return (
16
+ <Portal name="alert-dialog-content">
17
+ <AlertDialogPrimitiveContext.Provider value={alertDialog}>{props.children}</AlertDialogPrimitiveContext.Provider>
18
+ </Portal>
19
+ );
20
+ }
@@ -0,0 +1,25 @@
1
+ import React, { useMemo, useState } from "react";
2
+ import { AlertDialogPrimitiveContext } from "./context";
3
+ import type { AlertDialogStyles } from "./types";
4
+
5
+ export interface AlertDialogPrimitiveRootProps {
6
+ children: React.ReactNode;
7
+
8
+ styles?: AlertDialogStyles;
9
+ }
10
+
11
+ export function AlertDialogRoot(props: AlertDialogPrimitiveRootProps) {
12
+ const { children, styles } = props;
13
+ const [isOpen, setIsOpen] = useState(false);
14
+
15
+ const contextValue = useMemo(
16
+ () => ({
17
+ isOpen,
18
+ setIsOpen,
19
+ styles,
20
+ }),
21
+ [isOpen, styles]
22
+ );
23
+
24
+ return <AlertDialogPrimitiveContext.Provider value={contextValue}>{children}</AlertDialogPrimitiveContext.Provider>;
25
+ }
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import { Text, type StyleProp, type TextProps, type TextStyle } from "react-native";
3
+ import { useAlertDialog } from "./context";
4
+
5
+ export interface AlertDialogPrimitiveTitleProps extends TextProps {
6
+ children: React.ReactNode;
7
+ style?: StyleProp<TextStyle>;
8
+ }
9
+
10
+ export function AlertDialogTitle(props: AlertDialogPrimitiveTitleProps) {
11
+ const { children, style, ...textProps } = props;
12
+ const { styles } = useAlertDialog();
13
+
14
+ const calculatedStyle = [styles?.title, style];
15
+
16
+ return (
17
+ <Text {...textProps} style={calculatedStyle}>
18
+ {children}
19
+ </Text>
20
+ );
21
+ }
@@ -0,0 +1,27 @@
1
+ import type { ViewRef } from "@/types/element.types";
2
+ import React from "react";
3
+ import { type PressableProps } from "react-native";
4
+ import { useAlertDialog } from "./context";
5
+
6
+ export interface AlertDialogPrimitiveTriggerProps extends PressableProps {
7
+ children: React.ReactElement<React.RefAttributes<ViewRef> & PressableProps>;
8
+ }
9
+
10
+ export function AlertDialogTrigger(props: AlertDialogPrimitiveTriggerProps) {
11
+ const { onPress } = props;
12
+ const { isOpen, setIsOpen } = useAlertDialog();
13
+
14
+ const handlePress: PressableProps["onPress"] = (event) => {
15
+ onPress?.(event);
16
+ setIsOpen(true);
17
+ };
18
+
19
+ return React.cloneElement(props.children, {
20
+ onPress: handlePress,
21
+ role: "button",
22
+ accessible: true,
23
+ accessibilityRole: "button",
24
+ accessibilityState: { expanded: isOpen },
25
+ ...props.children.props,
26
+ });
27
+ }
@@ -0,0 +1,18 @@
1
+ import React, { createContext, useContext, type Dispatch } from "react";
2
+ import type { AlertDialogStyles } from "./types";
3
+
4
+ export interface AlertDialogPrimitiveContextValue {
5
+ isOpen: boolean;
6
+ setIsOpen: Dispatch<React.SetStateAction<boolean>>;
7
+ styles?: AlertDialogStyles;
8
+ }
9
+
10
+ export const AlertDialogPrimitiveContext = createContext<AlertDialogPrimitiveContextValue | null>(null);
11
+
12
+ export const useAlertDialog = () => {
13
+ const context = useContext(AlertDialogPrimitiveContext);
14
+ if (!context) {
15
+ throw new Error("AlertDialog compound components must be used within AlertDialogPrimitive.Root");
16
+ }
17
+ return context;
18
+ };
@@ -0,0 +1,34 @@
1
+ import { AlertDialogAction } from "./alert-dialog-action";
2
+ import { AlertDialogCancel } from "./alert-dialog-cancel";
3
+ import { AlertDialogContent } from "./alert-dialog-content";
4
+ import { AlertDialogDescription } from "./alert-dialog-description";
5
+ import { AlertDialogFooter } from "./alert-dialog-footer";
6
+ import { AlertDialogOverlay } from "./alert-dialog-overlay";
7
+ import { AlertDialogPortal } from "./alert-dialog-portal";
8
+ import { AlertDialogRoot } from "./alert-dialog-root";
9
+ import { AlertDialogTitle } from "./alert-dialog-title";
10
+ import { AlertDialogTrigger } from "./alert-dialog-trigger";
11
+
12
+ export const AlertDialogPrimitive = {
13
+ Root: AlertDialogRoot,
14
+ Trigger: AlertDialogTrigger,
15
+ Portal: AlertDialogPortal,
16
+ Overlay: AlertDialogOverlay,
17
+ Content: AlertDialogContent,
18
+ Title: AlertDialogTitle,
19
+ Description: AlertDialogDescription,
20
+ Footer: AlertDialogFooter,
21
+ Action: AlertDialogAction,
22
+ Cancel: AlertDialogCancel,
23
+ };
24
+
25
+ export type { AlertDialogPrimitiveActionProps } from "./alert-dialog-action";
26
+ export type { AlertDialogPrimitiveCancelProps } from "./alert-dialog-cancel";
27
+ export type { AlertDialogPrimitiveContentProps } from "./alert-dialog-content";
28
+ export type { AlertDialogPrimitiveDescriptionProps } from "./alert-dialog-description";
29
+ export type { AlertDialogPrimitiveFooterProps } from "./alert-dialog-footer";
30
+ export type { AlertDialogPrimitiveOverlayProps } from "./alert-dialog-overlay";
31
+ export type { AlertDialogPrimitiveRootProps } from "./alert-dialog-root";
32
+ export type { AlertDialogPrimitiveTitleProps } from "./alert-dialog-title";
33
+ export type { AlertDialogPrimitiveTriggerProps } from "./alert-dialog-trigger";
34
+ export * from "./types";
@@ -0,0 +1,13 @@
1
+ import type { StyleProp, TextStyle, ViewStyle } from "react-native";
2
+
3
+ export interface AlertDialogStyles {
4
+ overlay?: StyleProp<ViewStyle>;
5
+ content?: StyleProp<ViewStyle>;
6
+ title?: StyleProp<TextStyle>;
7
+ description?: StyleProp<TextStyle>;
8
+ footer?: StyleProp<ViewStyle>;
9
+ action?: StyleProp<ViewStyle>;
10
+ actionText?: StyleProp<TextStyle>;
11
+ cancel?: StyleProp<ViewStyle>;
12
+ cancelText?: StyleProp<TextStyle>;
13
+ }
@@ -1,9 +1,9 @@
1
1
  import React from "react";
2
- import type { CheckboxStyles, CheckboxState } from "./types";
2
+ import type { CheckboxState, CheckboxStyles } from "./types";
3
3
 
4
4
  export interface CheckboxPrimitiveContextValue {
5
- checked: boolean;
6
- disabled?: boolean;
5
+ value: boolean;
6
+ isDisabled?: boolean;
7
7
  state: CheckboxState;
8
8
  styles?: CheckboxStyles;
9
9
  }
@@ -19,16 +19,16 @@ const calculateState = (rootState: CheckboxState, checked: boolean): CheckboxSta
19
19
 
20
20
  export function CheckboxIndicator(props: CheckboxPrimitiveIndicatorProps) {
21
21
  const { style, ...viewProps } = props;
22
- const { checked, state, styles } = useCheckboxContext();
22
+ const { value, state, styles } = useCheckboxContext();
23
23
 
24
- const indicatorState = calculateState(state, checked);
24
+ const indicatorState = calculateState(state, value);
25
25
 
26
26
  const calculatedStyle = [styles?.indicator?.default, styles?.indicator?.[indicatorState], style];
27
27
  const checkmarkStyle = [styles?.checkmark?.default, styles?.checkmark?.[indicatorState]];
28
28
 
29
29
  return (
30
30
  <View {...viewProps} style={calculatedStyle}>
31
- {checked && <Text style={checkmarkStyle}>✓</Text>}
31
+ {value && <Text style={checkmarkStyle}>✓</Text>}
32
32
  </View>
33
33
  );
34
34
  }
@@ -5,35 +5,34 @@ import type { CheckboxState, CheckboxStyles } from "./types";
5
5
 
6
6
  export interface CheckboxPrimitiveRootProps extends Omit<PressableProps, "children"> {
7
7
  children: React.ReactNode;
8
- checked: boolean;
9
- onChange: (checked: boolean) => void;
10
- disabled?: boolean;
8
+ value: boolean;
9
+ onChange: (value: boolean) => void;
10
+ isDisabled?: boolean;
11
11
  style?: StyleProp<ViewStyle>;
12
12
  styles?: CheckboxStyles;
13
13
  }
14
14
 
15
- const calculateState = (checked: boolean, disabled: boolean | undefined, isHovered: boolean): CheckboxState => {
16
- if (disabled) {
15
+ const calculateState = (value: boolean, isDisabled: boolean | undefined, isHovered: boolean): CheckboxState => {
16
+ if (isDisabled) {
17
17
  return "disabled";
18
18
  }
19
19
  if (isHovered) {
20
20
  return "hovered";
21
21
  }
22
- if (checked) {
22
+ if (value) {
23
23
  return "checked";
24
24
  }
25
25
  return "default";
26
26
  };
27
27
 
28
28
  export function CheckboxRoot(props: CheckboxPrimitiveRootProps) {
29
- const { children, checked, onChange, disabled, style, styles, ...pressableProps } = props;
29
+ const { children, value, onChange, isDisabled, style, styles, ...pressableProps } = props;
30
30
  const [isHovered, setIsHovered] = useState(false);
31
31
 
32
- const state = calculateState(checked, disabled, isHovered);
33
-
32
+ const state = calculateState(value, isDisabled, isHovered);
34
33
  const handlePress = () => {
35
- if (!disabled) {
36
- onChange(!checked);
34
+ if (!isDisabled) {
35
+ onChange(!value);
37
36
  }
38
37
  };
39
38
 
@@ -41,19 +40,19 @@ export function CheckboxRoot(props: CheckboxPrimitiveRootProps) {
41
40
 
42
41
  const contextValue = React.useMemo(
43
42
  () => ({
44
- checked,
45
- disabled,
43
+ value,
44
+ isDisabled,
46
45
  state,
47
46
  styles,
48
47
  }),
49
- [checked, disabled, state, styles]
48
+ [value, isDisabled, state, styles]
50
49
  );
51
50
 
52
51
  return (
53
52
  <CheckboxPrimitiveContext.Provider value={contextValue}>
54
53
  <Pressable
55
54
  {...pressableProps}
56
- disabled={disabled}
55
+ disabled={isDisabled}
57
56
  onPress={handlePress}
58
57
  onHoverIn={() => setIsHovered(true)}
59
58
  onHoverOut={() => setIsHovered(false)}
@@ -14,3 +14,4 @@ export * from "./portal";
14
14
  export * from "./calendar";
15
15
  export * from "./tabs";
16
16
  export * from "./checkbox";
17
+ export * from "./alert-dialog";
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { Portal } from "../portal";
3
- import { usePopover, PopoverContext } from "./context";
3
+ import { PopoverContext, usePopover } from "./context";
4
4
 
5
5
  export interface PopoverPortalProps {
6
6
  children?: React.ReactNode;