@korsolutions/ui 0.0.93 → 0.0.94
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-list.js +8 -15
- package/dist/module/components/combobox/components/combobox-list.js.map +1 -1
- package/dist/module/components/combobox/components/combobox-option.js +5 -1
- package/dist/module/components/combobox/components/combobox-option.js.map +1 -1
- package/dist/module/components/combobox/components/combobox-root.js +18 -71
- package/dist/module/components/combobox/components/combobox-root.js.map +1 -1
- package/dist/module/components/combobox/components/combobox-trigger.js +11 -31
- package/dist/module/components/combobox/components/combobox-trigger.js.map +1 -1
- package/dist/module/components/combobox/context.js.map +1 -1
- package/dist/module/components/select/components/select-content.js +2 -3
- package/dist/module/components/select/components/select-content.js.map +1 -1
- package/dist/module/components/select/components/select-option.js +2 -2
- package/dist/module/components/select/components/select-option.js.map +1 -1
- package/dist/module/components/select/components/select-overlay.js +2 -3
- package/dist/module/components/select/components/select-overlay.js.map +1 -1
- package/dist/module/components/select/components/select-root.js +3 -3
- package/dist/module/components/select/components/select-root.js.map +1 -1
- package/dist/module/components/select/components/select-trigger.js +3 -4
- package/dist/module/components/select/components/select-trigger.js.map +1 -1
- package/dist/module/components/select/variants/default.js +0 -5
- package/dist/module/components/select/variants/default.js.map +1 -1
- package/dist/module/utils/calculate-styles.js +6 -0
- package/dist/module/utils/calculate-styles.js.map +1 -1
- package/dist/typescript/src/components/combobox/components/combobox-list.d.ts +1 -1
- package/dist/typescript/src/components/combobox/components/combobox-list.d.ts.map +1 -1
- package/dist/typescript/src/components/combobox/components/combobox-option.d.ts.map +1 -1
- package/dist/typescript/src/components/combobox/components/combobox-root.d.ts +8 -25
- package/dist/typescript/src/components/combobox/components/combobox-root.d.ts.map +1 -1
- package/dist/typescript/src/components/combobox/components/combobox-trigger.d.ts +2 -1
- package/dist/typescript/src/components/combobox/components/combobox-trigger.d.ts.map +1 -1
- package/dist/typescript/src/components/combobox/context.d.ts +9 -8
- package/dist/typescript/src/components/combobox/context.d.ts.map +1 -1
- package/dist/typescript/src/components/select/components/select-content.d.ts.map +1 -1
- package/dist/typescript/src/components/select/components/select-option.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/components/select-root.d.ts.map +1 -1
- package/dist/typescript/src/components/select/components/select-trigger.d.ts +2 -2
- package/dist/typescript/src/components/select/components/select-trigger.d.ts.map +1 -1
- package/dist/typescript/src/components/select/types.d.ts +2 -2
- package/dist/typescript/src/components/select/types.d.ts.map +1 -1
- package/dist/typescript/src/components/select/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/utils/calculate-styles.d.ts +2 -0
- package/dist/typescript/src/utils/calculate-styles.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/combobox/components/combobox-list.tsx +9 -17
- package/src/components/combobox/components/combobox-option.tsx +5 -1
- package/src/components/combobox/components/combobox-root.tsx +33 -117
- package/src/components/combobox/components/combobox-trigger.tsx +13 -36
- package/src/components/combobox/context.ts +12 -9
- package/src/components/select/components/select-content.tsx +6 -7
- package/src/components/select/components/select-option.tsx +5 -4
- package/src/components/select/components/select-overlay.tsx +6 -7
- package/src/components/select/components/select-root.tsx +14 -3
- package/src/components/select/components/select-trigger.tsx +12 -12
- package/src/components/select/types.ts +2 -2
- package/src/components/select/variants/default.tsx +0 -5
- package/src/utils/calculate-styles.ts +16 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { type StyleProp, View, type ViewStyle } from "react-native";
|
|
2
|
+
import { type StyleProp, StyleSheet, View, type ViewStyle } from "react-native";
|
|
3
3
|
import { useRelativePosition } from "../../../hooks/use-relative-position";
|
|
4
|
-
import { calculateComposedStyles } from "../../../utils/calculate-styles";
|
|
5
4
|
import { useSelect } from "../context";
|
|
6
5
|
|
|
7
6
|
export interface SelectContentProps {
|
|
@@ -14,12 +13,12 @@ export interface SelectContentProps {
|
|
|
14
13
|
|
|
15
14
|
export function SelectContent(props: SelectContentProps) {
|
|
16
15
|
const select = useSelect();
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
select.
|
|
20
|
-
|
|
16
|
+
|
|
17
|
+
const composedStyles = StyleSheet.flatten([
|
|
18
|
+
select.styles?.content?.default,
|
|
19
|
+
select.styles?.content?.[select.state],
|
|
21
20
|
props.style,
|
|
22
|
-
);
|
|
21
|
+
]);
|
|
23
22
|
|
|
24
23
|
const positionStyle = useRelativePosition({
|
|
25
24
|
align: "start",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useState } from "react";
|
|
2
2
|
import { Pressable, StyleSheet, type PressableProps } from "react-native";
|
|
3
3
|
import type { ElementChildren } from "../../../types/element.types";
|
|
4
|
+
import { extractPressableStyles } from "../../../utils/calculate-styles";
|
|
4
5
|
import { useSelect } from "../context";
|
|
5
6
|
import type { SelectOptionState, SelectState } from "../types";
|
|
6
7
|
|
|
@@ -33,7 +34,7 @@ export function SelectOption(props: SelectOptionProps): React.ReactElement {
|
|
|
33
34
|
const isSelected = select.value === props.value;
|
|
34
35
|
|
|
35
36
|
const optionState = calculateState(select.state, isHovered, isSelected);
|
|
36
|
-
|
|
37
|
+
|
|
37
38
|
useEffect(() => {
|
|
38
39
|
select.setOptions((prev) => {
|
|
39
40
|
if (prev.find((option) => option.value === props.value)) {
|
|
@@ -57,9 +58,9 @@ export function SelectOption(props: SelectOptionProps): React.ReactElement {
|
|
|
57
58
|
onPointerLeave={handlePointerLeave}
|
|
58
59
|
style={(styleProps) =>
|
|
59
60
|
StyleSheet.flatten([
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
extractPressableStyles(select.styles?.option?.default, styleProps),
|
|
62
|
+
extractPressableStyles(select.styles?.option?.[optionState], styleProps),
|
|
63
|
+
extractPressableStyles(props.style, styleProps),
|
|
63
64
|
])
|
|
64
65
|
}
|
|
65
66
|
>
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { calculateComposedStyles } from "../../../utils/calculate-styles";
|
|
2
1
|
import React from "react";
|
|
3
2
|
import { Pressable, type StyleProp, StyleSheet, type ViewStyle } from "react-native";
|
|
4
3
|
import { useSelect } from "../context";
|
|
@@ -16,12 +15,12 @@ export interface SelectOverlayProps {
|
|
|
16
15
|
export function SelectOverlay(props: SelectOverlayProps) {
|
|
17
16
|
const select = useSelect();
|
|
18
17
|
|
|
19
|
-
const composedStyles =
|
|
20
|
-
select.styles,
|
|
21
|
-
select.state,
|
|
22
|
-
"overlay",
|
|
18
|
+
const composedStyles = StyleSheet.flatten([
|
|
19
|
+
select.styles?.overlay?.default,
|
|
20
|
+
select.styles?.overlay?.[select.state],
|
|
23
21
|
props.style,
|
|
24
|
-
|
|
22
|
+
StyleSheet.absoluteFill,
|
|
23
|
+
]);
|
|
25
24
|
|
|
26
25
|
const Component = props.render ?? Pressable;
|
|
27
26
|
return (
|
|
@@ -30,7 +29,7 @@ export function SelectOverlay(props: SelectOverlayProps) {
|
|
|
30
29
|
select.setIsOpen(false);
|
|
31
30
|
}}
|
|
32
31
|
pointerEvents="auto"
|
|
33
|
-
style={
|
|
32
|
+
style={composedStyles}
|
|
34
33
|
>
|
|
35
34
|
{props.children}
|
|
36
35
|
</Component>
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
type LayoutRectangle,
|
|
4
|
+
type StyleProp,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
View,
|
|
7
|
+
type ViewStyle,
|
|
8
|
+
} from "react-native";
|
|
3
9
|
import { DEFAULT_LAYOUT, DEFAULT_POSITION, type LayoutPosition } from "../../../hooks";
|
|
4
10
|
import { useComponentConfig } from "../../../themes/provider";
|
|
5
|
-
import {
|
|
11
|
+
import { mergeStyles } from "../../../utils/calculate-styles";
|
|
6
12
|
import type { Size } from "../../../utils/size-scale";
|
|
7
13
|
import { SelectContext } from "../context";
|
|
8
14
|
import type { SelectOption, SelectState } from "../types";
|
|
@@ -48,7 +54,12 @@ export function SelectRoot(props: SelectRootProps) {
|
|
|
48
54
|
const [options, setOptions] = useState<Array<SelectOption>>([]);
|
|
49
55
|
|
|
50
56
|
const state = calculateState(props);
|
|
51
|
-
|
|
57
|
+
|
|
58
|
+
const composedStyles = StyleSheet.flatten([
|
|
59
|
+
mergedStyles?.root?.default,
|
|
60
|
+
mergedStyles?.root?.[state],
|
|
61
|
+
props.style,
|
|
62
|
+
]);
|
|
52
63
|
|
|
53
64
|
const Component = props.render ?? View;
|
|
54
65
|
return (
|
|
@@ -1,32 +1,26 @@
|
|
|
1
1
|
import React, { useRef } from "react";
|
|
2
2
|
import {
|
|
3
3
|
Pressable,
|
|
4
|
+
StyleSheet,
|
|
4
5
|
Text,
|
|
6
|
+
type PressableProps,
|
|
5
7
|
type StyleProp,
|
|
6
|
-
type TextStyle
|
|
7
|
-
type ViewStyle,
|
|
8
|
+
type TextStyle
|
|
8
9
|
} from "react-native";
|
|
9
10
|
import type { ViewRef } from "../../../types/element.types";
|
|
10
|
-
import {
|
|
11
|
+
import { extractPressableStyles } from "../../../utils/calculate-styles";
|
|
11
12
|
import { measureLayoutPosition } from "../../../utils/normalize-layout";
|
|
12
13
|
import { useSelect } from "../context";
|
|
13
14
|
|
|
14
15
|
export interface SelectTriggerProps {
|
|
15
16
|
placeholder?: string;
|
|
16
|
-
style?:
|
|
17
|
+
style?: PressableProps["style"];
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
export function SelectTrigger(props: SelectTriggerProps) {
|
|
20
21
|
const select = useSelect();
|
|
21
22
|
const triggerRef = useRef<ViewRef>(null);
|
|
22
23
|
|
|
23
|
-
const composedStyles = calculateComposedStyles(
|
|
24
|
-
select.styles,
|
|
25
|
-
select.state,
|
|
26
|
-
"trigger",
|
|
27
|
-
props.style,
|
|
28
|
-
);
|
|
29
|
-
|
|
30
24
|
const onTriggerPress = () => {
|
|
31
25
|
if (!select.isOpen) {
|
|
32
26
|
measureLayoutPosition(triggerRef.current, (layout) => {
|
|
@@ -43,7 +37,13 @@ export function SelectTrigger(props: SelectTriggerProps) {
|
|
|
43
37
|
ref={triggerRef}
|
|
44
38
|
onPress={onTriggerPress}
|
|
45
39
|
disabled={select.isDisabled}
|
|
46
|
-
style={
|
|
40
|
+
style={(styleProp) =>
|
|
41
|
+
StyleSheet.flatten([
|
|
42
|
+
extractPressableStyles(select.styles?.trigger?.default, styleProp),
|
|
43
|
+
extractPressableStyles(select.styles?.trigger?.[select.state], styleProp),
|
|
44
|
+
extractPressableStyles(props.style, styleProp),
|
|
45
|
+
])
|
|
46
|
+
}
|
|
47
47
|
>
|
|
48
48
|
<SelectValue placeholder={props.placeholder} />
|
|
49
49
|
</Pressable>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { TextStyle } from "react-native";
|
|
2
1
|
import type { SelectContentProps } from "./components/select-content";
|
|
2
|
+
import type { SelectOptionProps } from "./components/select-option";
|
|
3
3
|
import type { SelectOverlayProps } from "./components/select-overlay";
|
|
4
4
|
import type { SelectRootProps } from "./components/select-root";
|
|
5
5
|
import type { SelectTriggerProps, SelectValueProps } from "./components/select-trigger";
|
|
@@ -14,7 +14,7 @@ export interface SelectStyles {
|
|
|
14
14
|
placeholder?: Partial<Record<SelectState, SelectValueProps["style"]>>;
|
|
15
15
|
overlay?: Partial<Record<SelectState, SelectOverlayProps["style"]>>;
|
|
16
16
|
content?: Partial<Record<SelectState, SelectContentProps["style"]>>;
|
|
17
|
-
option?: Partial<Record<SelectOptionState,
|
|
17
|
+
option?: Partial<Record<SelectOptionState, SelectOptionProps["style"]>>;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export interface SelectOption {
|
|
@@ -71,15 +71,10 @@ export function useSelectVariantDefault(size: Size): SelectStyles {
|
|
|
71
71
|
default: {
|
|
72
72
|
paddingVertical: s.paddingVertical,
|
|
73
73
|
paddingHorizontal: s.paddingHorizontal,
|
|
74
|
-
fontFamily,
|
|
75
|
-
fontSize: s.fontSize,
|
|
76
|
-
lineHeight: s.lineHeight,
|
|
77
|
-
color: colors.foreground,
|
|
78
74
|
borderRadius: radius / 2,
|
|
79
75
|
cursor: "pointer",
|
|
80
76
|
},
|
|
81
77
|
disabled: {
|
|
82
|
-
color: colors.mutedForeground,
|
|
83
78
|
cursor: "not-allowed" as CursorValue,
|
|
84
79
|
},
|
|
85
80
|
selected: {
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
StyleSheet,
|
|
3
|
+
type PressableProps,
|
|
4
|
+
type PressableStateCallbackType,
|
|
5
|
+
type ViewStyle,
|
|
6
|
+
} from "react-native";
|
|
2
7
|
|
|
3
8
|
export const calculateComposedStyles = <
|
|
4
9
|
TStyle,
|
|
@@ -57,3 +62,13 @@ export const mergeStyles = <TStyle extends Record<string, any>>(
|
|
|
57
62
|
}
|
|
58
63
|
return returnStyles;
|
|
59
64
|
};
|
|
65
|
+
|
|
66
|
+
export const extractPressableStyles = (
|
|
67
|
+
style: PressableProps["style"],
|
|
68
|
+
props: PressableStateCallbackType,
|
|
69
|
+
): ViewStyle => {
|
|
70
|
+
if (typeof style === "function") {
|
|
71
|
+
return style(props) as ViewStyle;
|
|
72
|
+
}
|
|
73
|
+
return style as ViewStyle;
|
|
74
|
+
};
|