@korsolutions/ui 0.0.64 → 0.0.66

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 (117) hide show
  1. package/dist/module/components/button/button.js +44 -0
  2. package/dist/module/components/button/button.js.map +1 -0
  3. package/dist/module/components/button/index.js +1 -8
  4. package/dist/module/components/button/index.js.map +1 -1
  5. package/dist/module/components/button/variants/default.js +15 -10
  6. package/dist/module/components/button/variants/default.js.map +1 -1
  7. package/dist/module/components/button/variants/ghost.js +19 -4
  8. package/dist/module/components/button/variants/ghost.js.map +1 -1
  9. package/dist/module/components/button/variants/secondary.js +19 -4
  10. package/dist/module/components/button/variants/secondary.js.map +1 -1
  11. package/dist/module/components/combobox/components/combobox-content.js +32 -0
  12. package/dist/module/components/combobox/components/combobox-content.js.map +1 -0
  13. package/dist/module/components/combobox/components/combobox-empty.js +20 -0
  14. package/dist/module/components/combobox/components/combobox-empty.js.map +1 -0
  15. package/dist/module/components/combobox/components/combobox-option.js +56 -0
  16. package/dist/module/components/combobox/components/combobox-option.js.map +1 -0
  17. package/dist/module/components/combobox/components/combobox-overlay.js +20 -0
  18. package/dist/module/components/combobox/components/combobox-overlay.js.map +1 -0
  19. package/dist/module/components/combobox/components/combobox-portal.js +29 -0
  20. package/dist/module/components/combobox/components/combobox-portal.js.map +1 -0
  21. package/dist/module/components/combobox/components/combobox-root.js +79 -0
  22. package/dist/module/components/combobox/components/combobox-root.js.map +1 -0
  23. package/dist/module/components/combobox/components/combobox-trigger.js +67 -0
  24. package/dist/module/components/combobox/components/combobox-trigger.js.map +1 -0
  25. package/dist/module/components/combobox/context.js +12 -0
  26. package/dist/module/components/combobox/context.js.map +1 -0
  27. package/dist/module/components/combobox/index.js +19 -0
  28. package/dist/module/components/combobox/index.js.map +1 -0
  29. package/dist/module/components/combobox/types.js +4 -0
  30. package/dist/module/components/combobox/types.js.map +1 -0
  31. package/dist/module/components/combobox/variants/default.js +106 -0
  32. package/dist/module/components/combobox/variants/default.js.map +1 -0
  33. package/dist/module/components/combobox/variants/index.js +7 -0
  34. package/dist/module/components/combobox/variants/index.js.map +1 -0
  35. package/dist/module/components/index.js +1 -0
  36. package/dist/module/components/index.js.map +1 -1
  37. package/dist/module/hooks/use-organized-children.js.map +1 -1
  38. package/dist/typescript/src/components/button/{components/button-root.d.ts → button.d.ts} +4 -4
  39. package/dist/typescript/src/components/button/button.d.ts.map +1 -0
  40. package/dist/typescript/src/components/button/index.d.ts +1 -11
  41. package/dist/typescript/src/components/button/index.d.ts.map +1 -1
  42. package/dist/typescript/src/components/button/types.d.ts +6 -6
  43. package/dist/typescript/src/components/button/types.d.ts.map +1 -1
  44. package/dist/typescript/src/components/button/variants/default.d.ts +1 -1
  45. package/dist/typescript/src/components/button/variants/default.d.ts.map +1 -1
  46. package/dist/typescript/src/components/button/variants/ghost.d.ts +1 -1
  47. package/dist/typescript/src/components/button/variants/ghost.d.ts.map +1 -1
  48. package/dist/typescript/src/components/button/variants/secondary.d.ts +1 -1
  49. package/dist/typescript/src/components/button/variants/secondary.d.ts.map +1 -1
  50. package/dist/typescript/src/components/combobox/components/combobox-content.d.ts +8 -0
  51. package/dist/typescript/src/components/combobox/components/combobox-content.d.ts.map +1 -0
  52. package/dist/typescript/src/components/combobox/components/combobox-empty.d.ts +6 -0
  53. package/dist/typescript/src/components/combobox/components/combobox-empty.d.ts.map +1 -0
  54. package/dist/typescript/src/components/combobox/components/combobox-option.d.ts +8 -0
  55. package/dist/typescript/src/components/combobox/components/combobox-option.d.ts.map +1 -0
  56. package/dist/typescript/src/components/combobox/components/combobox-overlay.d.ts +8 -0
  57. package/dist/typescript/src/components/combobox/components/combobox-overlay.d.ts.map +1 -0
  58. package/dist/typescript/src/components/combobox/components/combobox-portal.d.ts +6 -0
  59. package/dist/typescript/src/components/combobox/components/combobox-portal.d.ts.map +1 -0
  60. package/dist/typescript/src/components/combobox/components/combobox-root.d.ts +19 -0
  61. package/dist/typescript/src/components/combobox/components/combobox-root.d.ts.map +1 -0
  62. package/dist/typescript/src/components/combobox/components/combobox-trigger.d.ts +6 -0
  63. package/dist/typescript/src/components/combobox/components/combobox-trigger.d.ts.map +1 -0
  64. package/dist/typescript/src/components/combobox/context.d.ts +25 -0
  65. package/dist/typescript/src/components/combobox/context.d.ts.map +1 -0
  66. package/dist/typescript/src/components/combobox/index.d.ts +25 -0
  67. package/dist/typescript/src/components/combobox/index.d.ts.map +1 -0
  68. package/dist/typescript/src/components/combobox/types.d.ts +21 -0
  69. package/dist/typescript/src/components/combobox/types.d.ts.map +1 -0
  70. package/dist/typescript/src/components/combobox/variants/default.d.ts +3 -0
  71. package/dist/typescript/src/components/combobox/variants/default.d.ts.map +1 -0
  72. package/dist/typescript/src/components/combobox/variants/index.d.ts +5 -0
  73. package/dist/typescript/src/components/combobox/variants/index.d.ts.map +1 -0
  74. package/dist/typescript/src/components/index.d.ts +1 -0
  75. package/dist/typescript/src/components/index.d.ts.map +1 -1
  76. package/dist/typescript/src/hooks/use-organized-children.d.ts +1 -1
  77. package/dist/typescript/src/hooks/use-organized-children.d.ts.map +1 -1
  78. package/package.json +1 -1
  79. package/src/components/button/button.tsx +85 -0
  80. package/src/components/button/index.ts +1 -13
  81. package/src/components/button/types.ts +10 -6
  82. package/src/components/button/variants/default.tsx +12 -6
  83. package/src/components/button/variants/ghost.tsx +18 -2
  84. package/src/components/button/variants/secondary.tsx +18 -2
  85. package/src/components/combobox/components/combobox-content.tsx +51 -0
  86. package/src/components/combobox/components/combobox-empty.tsx +28 -0
  87. package/src/components/combobox/components/combobox-option.tsx +81 -0
  88. package/src/components/combobox/components/combobox-overlay.tsx +36 -0
  89. package/src/components/combobox/components/combobox-portal.tsx +33 -0
  90. package/src/components/combobox/components/combobox-root.tsx +152 -0
  91. package/src/components/combobox/components/combobox-trigger.tsx +96 -0
  92. package/src/components/combobox/context.ts +40 -0
  93. package/src/components/combobox/index.ts +26 -0
  94. package/src/components/combobox/types.ts +23 -0
  95. package/src/components/combobox/variants/default.tsx +102 -0
  96. package/src/components/combobox/variants/index.ts +5 -0
  97. package/src/components/index.ts +1 -0
  98. package/src/hooks/use-organized-children.tsx +1 -1
  99. package/dist/module/components/button/components/button-label.js +0 -18
  100. package/dist/module/components/button/components/button-label.js.map +0 -1
  101. package/dist/module/components/button/components/button-root.js +0 -60
  102. package/dist/module/components/button/components/button-root.js.map +0 -1
  103. package/dist/module/components/button/components/button-spinner.js +0 -15
  104. package/dist/module/components/button/components/button-spinner.js.map +0 -1
  105. package/dist/module/components/button/context.js +0 -12
  106. package/dist/module/components/button/context.js.map +0 -1
  107. package/dist/typescript/src/components/button/components/button-label.d.ts +0 -9
  108. package/dist/typescript/src/components/button/components/button-label.d.ts.map +0 -1
  109. package/dist/typescript/src/components/button/components/button-root.d.ts.map +0 -1
  110. package/dist/typescript/src/components/button/components/button-spinner.d.ts +0 -8
  111. package/dist/typescript/src/components/button/components/button-spinner.d.ts.map +0 -1
  112. package/dist/typescript/src/components/button/context.d.ts +0 -8
  113. package/dist/typescript/src/components/button/context.d.ts.map +0 -1
  114. package/src/components/button/components/button-label.tsx +0 -25
  115. package/src/components/button/components/button-root.tsx +0 -76
  116. package/src/components/button/components/button-spinner.tsx +0 -14
  117. package/src/components/button/context.ts +0 -17
@@ -0,0 +1,96 @@
1
+ import React, { useEffect, useRef } from "react";
2
+ import { StyleSheet, TextInput, type TextInputProps } from "react-native";
3
+ import type { TextInputRef } from "../../../types/element.types";
4
+ import { measureLayoutPosition } from "../../../utils/normalize-layout";
5
+ import { useCombobox } from "../context";
6
+ import type { ComboboxTriggerState } from "../types";
7
+
8
+ export interface ComboboxTriggerProps {
9
+ placeholder?: string;
10
+ }
11
+
12
+ const calculateState = (
13
+ isDisabled: boolean,
14
+ isOpen: boolean,
15
+ ): ComboboxTriggerState => {
16
+ if (isDisabled) return "disabled";
17
+ if (isOpen) return "focused";
18
+ return "default";
19
+ };
20
+
21
+ export function ComboboxTrigger(props: ComboboxTriggerProps) {
22
+ const combobox = useCombobox();
23
+ const triggerRef = useRef<TextInputRef>(null);
24
+
25
+ const triggerState = calculateState(combobox.isDisabled, combobox.isOpen);
26
+ const selectedOption = combobox.options.find(
27
+ (option) => option.value === combobox.value,
28
+ );
29
+
30
+ const displayValue = combobox.isOpen
31
+ ? combobox.searchQuery
32
+ : selectedOption
33
+ ? typeof selectedOption.label === "string"
34
+ ? selectedOption.label
35
+ : selectedOption.value
36
+ : "";
37
+
38
+ const open = () => {
39
+ if (combobox.isDisabled) return;
40
+ combobox.setSearchQuery("");
41
+ requestAnimationFrame(() => {
42
+ measureLayoutPosition(triggerRef.current, (layout) => {
43
+ combobox.setTriggerPosition(layout);
44
+ combobox.setIsOpen(true);
45
+ });
46
+ });
47
+ };
48
+
49
+ useEffect(() => {
50
+ triggerRef.current?.setNativeProps({ text: displayValue });
51
+ }, [displayValue]);
52
+
53
+ useEffect(() => {
54
+ if (!combobox.isOpen) {
55
+ triggerRef.current?.blur();
56
+ }
57
+ }, [combobox.isOpen]);
58
+
59
+ const triggerStyles = combobox.styles?.trigger;
60
+ const composedProps: TextInputProps = {
61
+ ...triggerStyles?.default,
62
+ ...triggerStyles?.[triggerState],
63
+ ...props,
64
+ style: StyleSheet.flatten([
65
+ triggerStyles?.default?.style,
66
+ triggerStyles?.[triggerState]?.style,
67
+ ]),
68
+ };
69
+
70
+ const composedStyle = StyleSheet.flatten([
71
+ triggerStyles?.default?.style,
72
+ triggerStyles?.[triggerState]?.style,
73
+ ]);
74
+
75
+ return (
76
+ <TextInput
77
+ {...composedProps}
78
+ ref={triggerRef}
79
+ value={undefined}
80
+ onChange={undefined}
81
+ onChangeText={(text) => {
82
+ if (combobox.isDisabled) return;
83
+ combobox.setSearchQuery(text);
84
+ if (!combobox.isOpen) {
85
+ open();
86
+ }
87
+ }}
88
+ onFocus={() => {
89
+ if (!combobox.isOpen) {
90
+ open();
91
+ }
92
+ }}
93
+ style={composedStyle}
94
+ />
95
+ );
96
+ }
@@ -0,0 +1,40 @@
1
+ import { createContext, type Dispatch, useContext } from "react";
2
+ import type { LayoutRectangle } from "react-native";
3
+ import type { LayoutPosition } from "../../hooks";
4
+ import type { ComboboxOption, ComboboxState, ComboboxStyles } from "./types";
5
+
6
+ export interface ComboboxContext {
7
+ value?: string;
8
+ onChange?: (value: string) => void;
9
+
10
+ isOpen: boolean;
11
+ setIsOpen: Dispatch<React.SetStateAction<boolean>>;
12
+ triggerPosition: LayoutPosition;
13
+ setTriggerPosition: Dispatch<React.SetStateAction<LayoutPosition>>;
14
+ contentLayout: LayoutRectangle;
15
+ setContentLayout: Dispatch<React.SetStateAction<LayoutRectangle>>;
16
+ options: Array<ComboboxOption>;
17
+ setOptions: Dispatch<React.SetStateAction<Array<ComboboxOption>>>;
18
+
19
+ searchQuery: string;
20
+ setSearchQuery: Dispatch<React.SetStateAction<string>>;
21
+
22
+ filter: (value: string, query: string) => boolean;
23
+
24
+ isDisabled: boolean;
25
+
26
+ state: ComboboxState;
27
+ styles: ComboboxStyles;
28
+ }
29
+
30
+ export const ComboboxContext = createContext<ComboboxContext | undefined>(
31
+ undefined,
32
+ );
33
+
34
+ export const useCombobox = () => {
35
+ const context = useContext(ComboboxContext);
36
+ if (!context) {
37
+ throw new Error("useCombobox must be used within a ComboboxProvider");
38
+ }
39
+ return context;
40
+ };
@@ -0,0 +1,26 @@
1
+ import { ComboboxContent } from "./components/combobox-content";
2
+ import { ComboboxEmpty } from "./components/combobox-empty";
3
+ import { ComboboxOption } from "./components/combobox-option";
4
+ import { ComboboxOverlay } from "./components/combobox-overlay";
5
+ import { ComboboxPortal } from "./components/combobox-portal";
6
+ import { ComboboxRoot } from "./components/combobox-root";
7
+ import { ComboboxTrigger } from "./components/combobox-trigger";
8
+
9
+ export const Combobox = {
10
+ Root: ComboboxRoot,
11
+ Trigger: ComboboxTrigger,
12
+ Portal: ComboboxPortal,
13
+ Overlay: ComboboxOverlay,
14
+ Content: ComboboxContent,
15
+ Option: ComboboxOption,
16
+ Empty: ComboboxEmpty,
17
+ };
18
+
19
+ export type { ComboboxContentProps } from "./components/combobox-content";
20
+ export type { ComboboxEmptyProps } from "./components/combobox-empty";
21
+ export type { ComboboxOptionProps } from "./components/combobox-option";
22
+ export type { ComboboxOverlayProps } from "./components/combobox-overlay";
23
+ export type { ComboboxPortalProps } from "./components/combobox-portal";
24
+ export type { ComboboxRootProps } from "./components/combobox-root";
25
+ export type { ComboboxTriggerProps } from "./components/combobox-trigger";
26
+ export type { ComboboxStyles } from "./types";
@@ -0,0 +1,23 @@
1
+ import type { TextInputProps, TextStyle } from "react-native";
2
+ import type { ComboboxContentProps } from "./components/combobox-content";
3
+ import type { ComboboxOverlayProps } from "./components/combobox-overlay";
4
+ import type { ComboboxRootProps } from "./components/combobox-root";
5
+
6
+ export type ComboboxState = "default" | "disabled";
7
+ export type ComboboxTriggerState = ComboboxState | "focused";
8
+ export type ComboboxOptionState = ComboboxState | "hovered" | "selected";
9
+
10
+ export interface ComboboxStyles {
11
+ root?: Partial<Record<ComboboxState, ComboboxRootProps["style"]>>;
12
+ trigger?: Partial<Record<ComboboxTriggerState, TextInputProps>>;
13
+ overlay?: Partial<Record<ComboboxState, ComboboxOverlayProps["style"]>>;
14
+ content?: Partial<Record<ComboboxState, ComboboxContentProps["style"]>>;
15
+ option?: Partial<Record<ComboboxOptionState, TextStyle>>;
16
+ empty?: Partial<Record<ComboboxState, TextStyle>>;
17
+ }
18
+
19
+ export interface ComboboxOption {
20
+ value: string;
21
+ label: React.ReactNode;
22
+ keywords?: string[];
23
+ }
@@ -0,0 +1,102 @@
1
+ import { Platform } from "react-native";
2
+ import { useThemedStyles } from "../../../utils/use-themed-styles";
3
+ import { type ComboboxStyles } from "../types";
4
+
5
+ export function useComboboxVariantDefault(): ComboboxStyles {
6
+ return useThemedStyles(
7
+ ({ colors, radius, fontFamily, fontSize }): ComboboxStyles => ({
8
+ root: {
9
+ default: {},
10
+ disabled: {},
11
+ },
12
+ trigger: {
13
+ default: {
14
+ placeholderTextColor: colors.mutedForeground,
15
+ editable: true,
16
+ style: {
17
+ borderWidth: 1,
18
+ borderColor: colors.border,
19
+ borderRadius: radius,
20
+ backgroundColor: colors.surface,
21
+ justifyContent: "center",
22
+ paddingVertical: 4,
23
+ paddingHorizontal: 16,
24
+ minHeight: 48,
25
+ fontFamily,
26
+ fontSize,
27
+ color: colors.foreground,
28
+ outlineWidth: 0,
29
+ pointerEvents: "auto",
30
+ ...Platform.select({
31
+ web: {
32
+ outline: "none",
33
+ },
34
+ }),
35
+ },
36
+ },
37
+ focused: {
38
+ style: {
39
+ borderColor: colors.primary,
40
+ },
41
+ },
42
+ disabled: {
43
+ editable: false,
44
+ style: {
45
+ backgroundColor: colors.muted,
46
+ color: colors.mutedForeground,
47
+ pointerEvents: "none",
48
+ },
49
+ },
50
+ },
51
+ overlay: {
52
+ default: {
53
+ zIndex: 999,
54
+ },
55
+ disabled: {},
56
+ },
57
+ content: {
58
+ default: {
59
+ backgroundColor: colors.surface,
60
+ borderRadius: radius,
61
+ borderWidth: 1,
62
+ borderColor: colors.border,
63
+ padding: 4,
64
+ gap: 4,
65
+ zIndex: 1000,
66
+ maxHeight: 256,
67
+ },
68
+ disabled: {},
69
+ },
70
+ option: {
71
+ default: {
72
+ paddingVertical: 12,
73
+ paddingHorizontal: 16,
74
+ fontFamily,
75
+ fontSize,
76
+ color: colors.foreground,
77
+ borderRadius: radius / 2,
78
+ },
79
+ disabled: {
80
+ color: colors.mutedForeground,
81
+ },
82
+ selected: {
83
+ backgroundColor: colors.muted,
84
+ },
85
+ hovered: {
86
+ backgroundColor: colors.muted,
87
+ },
88
+ },
89
+ empty: {
90
+ default: {
91
+ paddingVertical: 12,
92
+ paddingHorizontal: 16,
93
+ fontFamily,
94
+ fontSize,
95
+ color: colors.mutedForeground,
96
+ textAlign: "center",
97
+ },
98
+ disabled: {},
99
+ },
100
+ }),
101
+ );
102
+ }
@@ -0,0 +1,5 @@
1
+ import { useComboboxVariantDefault } from "./default";
2
+
3
+ export const ComboboxVariants = {
4
+ default: useComboboxVariantDefault,
5
+ };
@@ -5,6 +5,7 @@ export * from "./badge";
5
5
  export * from "./button";
6
6
  export * from "./calendar";
7
7
  export * from "./card";
8
+ export * from "./combobox";
8
9
  export * from "./checkbox";
9
10
  export * from "./empty";
10
11
  export * from "./field";
@@ -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,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
- };