@korsolutions/ui 0.0.65 → 0.0.67
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/combobox/components/combobox-content.js +32 -0
- package/dist/module/components/combobox/components/combobox-content.js.map +1 -0
- package/dist/module/components/combobox/components/combobox-empty.js +20 -0
- package/dist/module/components/combobox/components/combobox-empty.js.map +1 -0
- package/dist/module/components/combobox/components/combobox-option.js +56 -0
- package/dist/module/components/combobox/components/combobox-option.js.map +1 -0
- package/dist/module/components/combobox/components/combobox-overlay.js +20 -0
- package/dist/module/components/combobox/components/combobox-overlay.js.map +1 -0
- package/dist/module/components/combobox/components/combobox-portal.js +29 -0
- package/dist/module/components/combobox/components/combobox-portal.js.map +1 -0
- package/dist/module/components/combobox/components/combobox-root.js +79 -0
- package/dist/module/components/combobox/components/combobox-root.js.map +1 -0
- package/dist/module/components/combobox/components/combobox-trigger.js +67 -0
- package/dist/module/components/combobox/components/combobox-trigger.js.map +1 -0
- package/dist/module/components/combobox/context.js +12 -0
- package/dist/module/components/combobox/context.js.map +1 -0
- package/dist/module/components/combobox/index.js +19 -0
- package/dist/module/components/combobox/index.js.map +1 -0
- package/dist/module/components/combobox/types.js +4 -0
- package/dist/module/components/combobox/types.js.map +1 -0
- package/dist/module/components/combobox/variants/default.js +106 -0
- package/dist/module/components/combobox/variants/default.js.map +1 -0
- package/dist/module/components/combobox/variants/index.js +7 -0
- package/dist/module/components/combobox/variants/index.js.map +1 -0
- package/dist/module/components/index.js +1 -0
- package/dist/module/components/index.js.map +1 -1
- package/dist/typescript/src/components/combobox/components/combobox-content.d.ts +8 -0
- package/dist/typescript/src/components/combobox/components/combobox-content.d.ts.map +1 -0
- package/dist/typescript/src/components/combobox/components/combobox-empty.d.ts +6 -0
- package/dist/typescript/src/components/combobox/components/combobox-empty.d.ts.map +1 -0
- package/dist/typescript/src/components/combobox/components/combobox-option.d.ts +8 -0
- package/dist/typescript/src/components/combobox/components/combobox-option.d.ts.map +1 -0
- package/dist/typescript/src/components/combobox/components/combobox-overlay.d.ts +8 -0
- package/dist/typescript/src/components/combobox/components/combobox-overlay.d.ts.map +1 -0
- package/dist/typescript/src/components/combobox/components/combobox-portal.d.ts +6 -0
- package/dist/typescript/src/components/combobox/components/combobox-portal.d.ts.map +1 -0
- package/dist/typescript/src/components/combobox/components/combobox-root.d.ts +19 -0
- package/dist/typescript/src/components/combobox/components/combobox-root.d.ts.map +1 -0
- package/dist/typescript/src/components/combobox/components/combobox-trigger.d.ts +6 -0
- package/dist/typescript/src/components/combobox/components/combobox-trigger.d.ts.map +1 -0
- package/dist/typescript/src/components/combobox/context.d.ts +25 -0
- package/dist/typescript/src/components/combobox/context.d.ts.map +1 -0
- package/dist/typescript/src/components/combobox/index.d.ts +25 -0
- package/dist/typescript/src/components/combobox/index.d.ts.map +1 -0
- package/dist/typescript/src/components/combobox/types.d.ts +21 -0
- package/dist/typescript/src/components/combobox/types.d.ts.map +1 -0
- package/dist/typescript/src/components/combobox/variants/default.d.ts +3 -0
- package/dist/typescript/src/components/combobox/variants/default.d.ts.map +1 -0
- package/dist/typescript/src/components/combobox/variants/index.d.ts +5 -0
- package/dist/typescript/src/components/combobox/variants/index.d.ts.map +1 -0
- package/dist/typescript/src/components/index.d.ts +1 -0
- package/dist/typescript/src/components/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/combobox/components/combobox-content.tsx +51 -0
- package/src/components/combobox/components/combobox-empty.tsx +28 -0
- package/src/components/combobox/components/combobox-option.tsx +81 -0
- package/src/components/combobox/components/combobox-overlay.tsx +36 -0
- package/src/components/combobox/components/combobox-portal.tsx +33 -0
- package/src/components/combobox/components/combobox-root.tsx +152 -0
- package/src/components/combobox/components/combobox-trigger.tsx +98 -0
- package/src/components/combobox/context.ts +40 -0
- package/src/components/combobox/index.ts +26 -0
- package/src/components/combobox/types.ts +23 -0
- package/src/components/combobox/variants/default.tsx +102 -0
- package/src/components/combobox/variants/index.ts +5 -0
- package/src/components/index.ts +1 -0
|
@@ -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
|
+
}
|