@korsolutions/ui 0.0.34 → 0.0.36

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 (100) hide show
  1. package/dist/module/components/checkbox/checkbox.js +36 -0
  2. package/dist/module/components/checkbox/checkbox.js.map +1 -0
  3. package/dist/module/components/checkbox/index.js +5 -0
  4. package/dist/module/components/checkbox/index.js.map +1 -0
  5. package/dist/module/components/checkbox/variants/default.js +70 -0
  6. package/dist/module/components/checkbox/variants/default.js.map +1 -0
  7. package/dist/module/components/checkbox/variants/index.js +9 -0
  8. package/dist/module/components/checkbox/variants/index.js.map +1 -0
  9. package/dist/module/components/checkbox/variants/outlined.js +85 -0
  10. package/dist/module/components/checkbox/variants/outlined.js.map +1 -0
  11. package/dist/module/components/index.js +1 -0
  12. package/dist/module/components/index.js.map +1 -1
  13. package/dist/module/components/tabs/tabs.js +7 -7
  14. package/dist/module/components/tabs/tabs.js.map +1 -1
  15. package/dist/module/primitives/checkbox/checkbox-context.js +12 -0
  16. package/dist/module/primitives/checkbox/checkbox-context.js.map +1 -0
  17. package/dist/module/primitives/checkbox/checkbox-description.js +24 -0
  18. package/dist/module/primitives/checkbox/checkbox-description.js.map +1 -0
  19. package/dist/module/primitives/checkbox/checkbox-indicator.js +38 -0
  20. package/dist/module/primitives/checkbox/checkbox-indicator.js.map +1 -0
  21. package/dist/module/primitives/checkbox/checkbox-root.js +56 -0
  22. package/dist/module/primitives/checkbox/checkbox-root.js.map +1 -0
  23. package/dist/module/primitives/checkbox/checkbox-title.js +24 -0
  24. package/dist/module/primitives/checkbox/checkbox-title.js.map +1 -0
  25. package/dist/module/primitives/checkbox/index.js +14 -0
  26. package/dist/module/primitives/checkbox/index.js.map +1 -0
  27. package/dist/module/primitives/checkbox/types.js +4 -0
  28. package/dist/module/primitives/checkbox/types.js.map +1 -0
  29. package/dist/module/primitives/index.js +1 -0
  30. package/dist/module/primitives/index.js.map +1 -1
  31. package/dist/module/primitives/tabs/index.js +1 -1
  32. package/dist/module/primitives/tabs/index.js.map +1 -1
  33. package/dist/module/primitives/tabs/tabs-context.js +2 -2
  34. package/dist/module/primitives/tabs/tabs-context.js.map +1 -1
  35. package/dist/module/primitives/tabs/tabs-root.js +5 -5
  36. package/dist/module/primitives/tabs/tabs-root.js.map +1 -1
  37. package/dist/module/primitives/tabs/tabs-trigger-text.js.map +1 -1
  38. package/dist/module/primitives/tabs/tabs-trigger.js +2 -2
  39. package/dist/module/primitives/tabs/tabs-trigger.js.map +1 -1
  40. package/dist/typescript/src/components/checkbox/checkbox.d.ts +13 -0
  41. package/dist/typescript/src/components/checkbox/checkbox.d.ts.map +1 -0
  42. package/dist/typescript/src/components/checkbox/index.d.ts +3 -0
  43. package/dist/typescript/src/components/checkbox/index.d.ts.map +1 -0
  44. package/dist/typescript/src/components/checkbox/variants/default.d.ts +3 -0
  45. package/dist/typescript/src/components/checkbox/variants/default.d.ts.map +1 -0
  46. package/dist/typescript/src/components/checkbox/variants/index.d.ts +5 -0
  47. package/dist/typescript/src/components/checkbox/variants/index.d.ts.map +1 -0
  48. package/dist/typescript/src/components/checkbox/variants/outlined.d.ts +3 -0
  49. package/dist/typescript/src/components/checkbox/variants/outlined.d.ts.map +1 -0
  50. package/dist/typescript/src/components/index.d.ts +1 -0
  51. package/dist/typescript/src/components/index.d.ts.map +1 -1
  52. package/dist/typescript/src/components/tabs/tabs.d.ts +8 -8
  53. package/dist/typescript/src/components/tabs/tabs.d.ts.map +1 -1
  54. package/dist/typescript/src/primitives/checkbox/checkbox-context.d.ts +11 -0
  55. package/dist/typescript/src/primitives/checkbox/checkbox-context.d.ts.map +1 -0
  56. package/dist/typescript/src/primitives/checkbox/checkbox-description.d.ts +8 -0
  57. package/dist/typescript/src/primitives/checkbox/checkbox-description.d.ts.map +1 -0
  58. package/dist/typescript/src/primitives/checkbox/checkbox-indicator.d.ts +7 -0
  59. package/dist/typescript/src/primitives/checkbox/checkbox-indicator.d.ts.map +1 -0
  60. package/dist/typescript/src/primitives/checkbox/checkbox-root.d.ts +13 -0
  61. package/dist/typescript/src/primitives/checkbox/checkbox-root.d.ts.map +1 -0
  62. package/dist/typescript/src/primitives/checkbox/checkbox-title.d.ts +8 -0
  63. package/dist/typescript/src/primitives/checkbox/checkbox-title.d.ts.map +1 -0
  64. package/dist/typescript/src/primitives/checkbox/index.d.ts +16 -0
  65. package/dist/typescript/src/primitives/checkbox/index.d.ts.map +1 -0
  66. package/dist/typescript/src/primitives/checkbox/types.d.ts +10 -0
  67. package/dist/typescript/src/primitives/checkbox/types.d.ts.map +1 -0
  68. package/dist/typescript/src/primitives/index.d.ts +1 -0
  69. package/dist/typescript/src/primitives/index.d.ts.map +1 -1
  70. package/dist/typescript/src/primitives/tabs/index.d.ts +2 -2
  71. package/dist/typescript/src/primitives/tabs/tabs-context.d.ts +1 -1
  72. package/dist/typescript/src/primitives/tabs/tabs-context.d.ts.map +1 -1
  73. package/dist/typescript/src/primitives/tabs/tabs-list.d.ts +1 -1
  74. package/dist/typescript/src/primitives/tabs/tabs-root.d.ts +2 -2
  75. package/dist/typescript/src/primitives/tabs/tabs-root.d.ts.map +1 -1
  76. package/dist/typescript/src/primitives/tabs/tabs-trigger-text.d.ts +1 -1
  77. package/dist/typescript/src/primitives/tabs/tabs-trigger-text.d.ts.map +1 -1
  78. package/dist/typescript/src/primitives/tabs/tabs-trigger.d.ts.map +1 -1
  79. package/package.json +1 -1
  80. package/src/components/checkbox/checkbox.tsx +32 -0
  81. package/src/components/checkbox/index.ts +2 -0
  82. package/src/components/checkbox/variants/default.tsx +66 -0
  83. package/src/components/checkbox/variants/index.ts +7 -0
  84. package/src/components/checkbox/variants/outlined.tsx +82 -0
  85. package/src/components/index.ts +1 -0
  86. package/src/components/tabs/tabs.tsx +15 -15
  87. package/src/primitives/checkbox/checkbox-context.tsx +19 -0
  88. package/src/primitives/checkbox/checkbox-description.tsx +21 -0
  89. package/src/primitives/checkbox/checkbox-indicator.tsx +34 -0
  90. package/src/primitives/checkbox/checkbox-root.tsx +66 -0
  91. package/src/primitives/checkbox/checkbox-title.tsx +21 -0
  92. package/src/primitives/checkbox/index.ts +17 -0
  93. package/src/primitives/checkbox/types.ts +11 -0
  94. package/src/primitives/index.ts +1 -0
  95. package/src/primitives/tabs/index.ts +2 -2
  96. package/src/primitives/tabs/tabs-context.tsx +3 -3
  97. package/src/primitives/tabs/tabs-list.tsx +1 -1
  98. package/src/primitives/tabs/tabs-root.tsx +7 -7
  99. package/src/primitives/tabs/tabs-trigger-text.tsx +2 -6
  100. package/src/primitives/tabs/tabs-trigger.tsx +5 -17
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import { Text, type TextProps, type StyleProp, type TextStyle } from "react-native";
3
+ import { useCheckboxContext } from "./checkbox-context";
4
+
5
+ export interface CheckboxPrimitiveDescriptionProps extends TextProps {
6
+ children: React.ReactNode;
7
+ style?: StyleProp<TextStyle>;
8
+ }
9
+
10
+ export function CheckboxDescription(props: CheckboxPrimitiveDescriptionProps) {
11
+ const { children, style, ...textProps } = props;
12
+ const { state, styles } = useCheckboxContext();
13
+
14
+ const calculatedStyle = [styles?.description?.default, styles?.description?.[state], style];
15
+
16
+ return (
17
+ <Text {...textProps} style={calculatedStyle}>
18
+ {children}
19
+ </Text>
20
+ );
21
+ }
@@ -0,0 +1,34 @@
1
+ import React from "react";
2
+ import { Text, View, type StyleProp, type ViewProps, type ViewStyle } from "react-native";
3
+ import { useCheckboxContext } from "./checkbox-context";
4
+ import type { CheckboxState } from "./types";
5
+
6
+ export interface CheckboxPrimitiveIndicatorProps extends ViewProps {
7
+ style?: StyleProp<ViewStyle>;
8
+ }
9
+
10
+ const calculateState = (rootState: CheckboxState, checked: boolean): CheckboxState => {
11
+ if (rootState === "disabled") {
12
+ return "disabled";
13
+ }
14
+ if (checked) {
15
+ return "checked";
16
+ }
17
+ return rootState;
18
+ };
19
+
20
+ export function CheckboxIndicator(props: CheckboxPrimitiveIndicatorProps) {
21
+ const { style, ...viewProps } = props;
22
+ const { checked, state, styles } = useCheckboxContext();
23
+
24
+ const indicatorState = calculateState(state, checked);
25
+
26
+ const calculatedStyle = [styles?.indicator?.default, styles?.indicator?.[indicatorState], style];
27
+ const checkmarkStyle = [styles?.checkmark?.default, styles?.checkmark?.[indicatorState]];
28
+
29
+ return (
30
+ <View {...viewProps} style={calculatedStyle}>
31
+ {checked && <Text style={checkmarkStyle}>✓</Text>}
32
+ </View>
33
+ );
34
+ }
@@ -0,0 +1,66 @@
1
+ import React, { useState } from "react";
2
+ import { Pressable, type PressableProps, type StyleProp, type ViewStyle } from "react-native";
3
+ import { CheckboxPrimitiveContext } from "./checkbox-context";
4
+ import type { CheckboxState, CheckboxStyles } from "./types";
5
+
6
+ export interface CheckboxPrimitiveRootProps extends Omit<PressableProps, "children"> {
7
+ children: React.ReactNode;
8
+ checked: boolean;
9
+ onChange: (checked: boolean) => void;
10
+ disabled?: boolean;
11
+ style?: StyleProp<ViewStyle>;
12
+ styles?: CheckboxStyles;
13
+ }
14
+
15
+ const calculateState = (checked: boolean, disabled: boolean | undefined, isHovered: boolean): CheckboxState => {
16
+ if (disabled) {
17
+ return "disabled";
18
+ }
19
+ if (isHovered) {
20
+ return "hovered";
21
+ }
22
+ if (checked) {
23
+ return "checked";
24
+ }
25
+ return "default";
26
+ };
27
+
28
+ export function CheckboxRoot(props: CheckboxPrimitiveRootProps) {
29
+ const { children, checked, onChange, disabled, style, styles, ...pressableProps } = props;
30
+ const [isHovered, setIsHovered] = useState(false);
31
+
32
+ const state = calculateState(checked, disabled, isHovered);
33
+
34
+ const handlePress = () => {
35
+ if (!disabled) {
36
+ onChange(!checked);
37
+ }
38
+ };
39
+
40
+ const calculatedStyle = [styles?.root?.default, styles?.root?.[state], style];
41
+
42
+ const contextValue = React.useMemo(
43
+ () => ({
44
+ checked,
45
+ disabled,
46
+ state,
47
+ styles,
48
+ }),
49
+ [checked, disabled, state, styles]
50
+ );
51
+
52
+ return (
53
+ <CheckboxPrimitiveContext.Provider value={contextValue}>
54
+ <Pressable
55
+ {...pressableProps}
56
+ disabled={disabled}
57
+ onPress={handlePress}
58
+ onHoverIn={() => setIsHovered(true)}
59
+ onHoverOut={() => setIsHovered(false)}
60
+ style={calculatedStyle}
61
+ >
62
+ {children}
63
+ </Pressable>
64
+ </CheckboxPrimitiveContext.Provider>
65
+ );
66
+ }
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import { Text, type TextProps, type StyleProp, type TextStyle } from "react-native";
3
+ import { useCheckboxContext } from "./checkbox-context";
4
+
5
+ export interface CheckboxPrimitiveTitleProps extends TextProps {
6
+ children: React.ReactNode;
7
+ style?: StyleProp<TextStyle>;
8
+ }
9
+
10
+ export function CheckboxTitle(props: CheckboxPrimitiveTitleProps) {
11
+ const { children, style, ...textProps } = props;
12
+ const { state, styles } = useCheckboxContext();
13
+
14
+ const calculatedStyle = [styles?.title?.default, styles?.title?.[state], style];
15
+
16
+ return (
17
+ <Text {...textProps} style={calculatedStyle}>
18
+ {children}
19
+ </Text>
20
+ );
21
+ }
@@ -0,0 +1,17 @@
1
+ import { CheckboxRoot } from "./checkbox-root";
2
+ import { CheckboxIndicator } from "./checkbox-indicator";
3
+ import { CheckboxTitle } from "./checkbox-title";
4
+ import { CheckboxDescription } from "./checkbox-description";
5
+
6
+ export const CheckboxPrimitive = {
7
+ Root: CheckboxRoot,
8
+ Indicator: CheckboxIndicator,
9
+ Title: CheckboxTitle,
10
+ Description: CheckboxDescription,
11
+ };
12
+
13
+ export type { CheckboxPrimitiveRootProps } from "./checkbox-root";
14
+ export type { CheckboxPrimitiveIndicatorProps } from "./checkbox-indicator";
15
+ export type { CheckboxPrimitiveTitleProps } from "./checkbox-title";
16
+ export type { CheckboxPrimitiveDescriptionProps } from "./checkbox-description";
17
+ export * from "./types";
@@ -0,0 +1,11 @@
1
+ import type { StyleProp, TextStyle, ViewStyle } from "react-native";
2
+
3
+ export type CheckboxState = "default" | "checked" | "disabled" | "hovered";
4
+
5
+ export interface CheckboxStyles {
6
+ root?: Partial<Record<CheckboxState, StyleProp<ViewStyle>>>;
7
+ indicator?: Partial<Record<CheckboxState, StyleProp<ViewStyle>>>;
8
+ checkmark?: Partial<Record<CheckboxState, StyleProp<TextStyle>>>;
9
+ title?: Partial<Record<CheckboxState, StyleProp<TextStyle>>>;
10
+ description?: Partial<Record<CheckboxState, StyleProp<TextStyle>>>;
11
+ }
@@ -13,3 +13,4 @@ export * from "./popover";
13
13
  export * from "./portal";
14
14
  export * from "./calendar";
15
15
  export * from "./tabs";
16
+ export * from "./checkbox";
@@ -1,5 +1,5 @@
1
- import { TabsRoot } from "./tabs-root";
2
1
  import { TabsList } from "./tabs-list";
2
+ import { TabsRoot } from "./tabs-root";
3
3
  import { TabsTrigger } from "./tabs-trigger";
4
4
  import { TabsTriggerText } from "./tabs-trigger-text";
5
5
 
@@ -10,8 +10,8 @@ export const TabsPrimitive = {
10
10
  TriggerText: TabsTriggerText,
11
11
  };
12
12
 
13
- export type { TabsPrimitiveRootProps } from "./tabs-root";
14
13
  export type { TabsPrimitiveListProps } from "./tabs-list";
14
+ export type { TabsPrimitiveRootProps } from "./tabs-root";
15
15
  export type { TabsPrimitiveTriggerProps } from "./tabs-trigger";
16
16
  export type { TabsPrimitiveTriggerTextProps } from "./tabs-trigger-text";
17
17
  export * from "./types";
@@ -1,16 +1,16 @@
1
- import React from "react";
1
+ import React, { useContext } from "react";
2
2
  import type { TabsStyles } from "./types";
3
3
 
4
4
  export interface TabsPrimitiveContextValue {
5
5
  value: string;
6
- onValueChange: (value: string) => void;
6
+ onChange: (value: string) => void;
7
7
  styles?: TabsStyles;
8
8
  }
9
9
 
10
10
  export const TabsPrimitiveContext = React.createContext<TabsPrimitiveContextValue | null>(null);
11
11
 
12
12
  export const useTabsContext = () => {
13
- const context = React.useContext(TabsPrimitiveContext);
13
+ const context = useContext(TabsPrimitiveContext);
14
14
  if (!context) {
15
15
  throw new Error("Tabs compound components must be used within TabsPrimitive.Root");
16
16
  }
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { View, type ViewProps, type StyleProp, type ViewStyle } from "react-native";
2
+ import { View, type StyleProp, type ViewProps, type ViewStyle } from "react-native";
3
3
  import { useTabsContext } from "./tabs-context";
4
4
 
5
5
  export interface TabsPrimitiveListProps extends ViewProps {
@@ -1,26 +1,26 @@
1
- import React from "react";
2
- import { View, type ViewProps, type StyleProp, type ViewStyle } from "react-native";
1
+ import React, { useMemo } from "react";
2
+ import { View, type StyleProp, type ViewProps, type ViewStyle } from "react-native";
3
3
  import { TabsPrimitiveContext } from "./tabs-context";
4
4
  import type { TabsStyles } from "./types";
5
5
 
6
6
  export interface TabsPrimitiveRootProps extends Omit<ViewProps, "children"> {
7
7
  children: React.ReactNode;
8
8
  value: string;
9
- onValueChange: (value: string) => void;
9
+ onChange: (value: string) => void;
10
10
  style?: StyleProp<ViewStyle>;
11
11
  styles?: TabsStyles;
12
12
  }
13
13
 
14
14
  export function TabsRoot(props: TabsPrimitiveRootProps) {
15
- const { children, value, onValueChange, styles, style, ...viewProps } = props;
15
+ const { children, value, onChange, styles, style, ...viewProps } = props;
16
16
 
17
- const contextValue = React.useMemo(
17
+ const contextValue = useMemo(
18
18
  () => ({
19
19
  value,
20
- onValueChange,
20
+ onChange,
21
21
  styles,
22
22
  }),
23
- [value, onValueChange, styles]
23
+ [value, onChange, styles]
24
24
  );
25
25
 
26
26
  return (
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { Text, type TextProps, type StyleProp, type TextStyle } from "react-native";
2
+ import { Text, type StyleProp, type TextProps, type TextStyle } from "react-native";
3
3
  import { useTabsContext } from "./tabs-context";
4
4
 
5
5
  export interface TabsPrimitiveTriggerTextProps extends TextProps {
@@ -16,11 +16,7 @@ export function TabsTriggerText(props: TabsPrimitiveTriggerTextProps) {
16
16
  const isActive = value === triggerValue;
17
17
  const state = isDisabled ? "disabled" : isActive ? "active" : "default";
18
18
 
19
- const calculatedStyle = [
20
- styles?.triggerText?.default,
21
- styles?.triggerText?.[state],
22
- style,
23
- ];
19
+ const calculatedStyle = [styles?.triggerText?.default, styles?.triggerText?.[state], style];
24
20
 
25
21
  return (
26
22
  <Text {...textProps} style={calculatedStyle}>
@@ -10,10 +10,7 @@ export interface TabsPrimitiveTriggerProps extends PressableProps {
10
10
  style?: StyleProp<ViewStyle>;
11
11
  }
12
12
 
13
- const calculateState = (
14
- isActive: boolean,
15
- isDisabled: boolean | undefined
16
- ): TabsState => {
13
+ const calculateState = (isActive: boolean, isDisabled: boolean | undefined): TabsState => {
17
14
  if (isDisabled) {
18
15
  return "disabled";
19
16
  }
@@ -25,30 +22,21 @@ const calculateState = (
25
22
 
26
23
  export function TabsTrigger(props: TabsPrimitiveTriggerProps) {
27
24
  const { children, value: triggerValue, isDisabled, style, ...pressableProps } = props;
28
- const { value, onValueChange, styles } = useTabsContext();
25
+ const { value, onChange, styles } = useTabsContext();
29
26
 
30
27
  const isActive = value === triggerValue;
31
28
  const state = calculateState(isActive, isDisabled);
32
29
 
33
30
  const handlePress = () => {
34
31
  if (!isDisabled) {
35
- onValueChange(triggerValue);
32
+ onChange(triggerValue);
36
33
  }
37
34
  };
38
35
 
39
- const calculatedStyle = [
40
- styles?.trigger?.default,
41
- styles?.trigger?.[state],
42
- style,
43
- ];
36
+ const calculatedStyle = [styles?.trigger?.default, styles?.trigger?.[state], style];
44
37
 
45
38
  return (
46
- <Pressable
47
- {...pressableProps}
48
- disabled={isDisabled}
49
- onPress={handlePress}
50
- style={calculatedStyle}
51
- >
39
+ <Pressable {...pressableProps} disabled={isDisabled} onPress={handlePress} style={calculatedStyle}>
52
40
  {children}
53
41
  </Pressable>
54
42
  );