@helpwave/hightide-native 0.0.1 → 0.0.2
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/README.md +56 -0
- package/package.json +3 -3
- package/src/components/chat/ChatAttachmentCard.tsx +97 -0
- package/src/components/chat/ChatConversationList.tsx +68 -0
- package/src/components/chat/ChatConversationRow.tsx +145 -0
- package/src/components/chat/ChatDateDivider.tsx +45 -0
- package/src/components/chat/ChatMessageBubble.tsx +102 -0
- package/src/components/chat/ChatMessageCard.tsx +107 -0
- package/src/components/chat/ChatMessageComposer.tsx +110 -0
- package/src/components/chat/ChatMessageList.tsx +59 -0
- package/src/components/chat/ChatQuickReplyChip.tsx +71 -0
- package/src/components/chat/ChatSystemLine.tsx +57 -0
- package/src/components/chat/ChatThreadHeader.tsx +80 -0
- package/src/components/chat/index.ts +11 -0
- package/src/components/index.ts +4 -7
- package/src/components/menu/Menu.tsx +51 -0
- package/src/components/menu/MenuActionItem.tsx +85 -0
- package/src/components/menu/MenuItem.tsx +63 -0
- package/src/components/menu/MenuNavigationItem.tsx +85 -0
- package/src/components/menu/index.ts +4 -0
- package/src/components/{Button → user-interaction}/Button.tsx +22 -29
- package/src/components/{Checkbox → user-interaction}/Checkbox.tsx +14 -11
- package/src/components/{IconButton → user-interaction}/IconButton.tsx +17 -25
- package/src/components/{Input → user-interaction}/Input.tsx +15 -11
- package/src/components/{MultiSelect → user-interaction}/MultiSelect.tsx +34 -9
- package/src/components/{Select → user-interaction}/Select.tsx +33 -8
- package/src/components/user-interaction/index.ts +6 -0
- package/src/components/{Chip → visualization-and-display}/Chip.tsx +17 -13
- package/src/theme/resolvers/button.ts +7 -5
- package/src/theme/resolvers/chat.ts +384 -0
- package/src/theme/resolvers/checkbox.ts +5 -4
- package/src/theme/resolvers/chip.ts +7 -5
- package/src/theme/resolvers/iconButton.ts +6 -4
- package/src/theme/resolvers/index.ts +2 -0
- package/src/theme/resolvers/input.ts +6 -4
- package/src/theme/resolvers/menu.ts +112 -0
- package/src/theme/resolvers/multiSelect.ts +20 -19
- package/src/theme/resolvers/select.ts +16 -15
- package/src/theme/themes/createTheme.ts +4 -0
- package/src/theme/types/button.ts +7 -30
- package/src/theme/types/chat.ts +141 -0
- package/src/theme/types/checkbox.ts +5 -14
- package/src/theme/types/chip.ts +7 -30
- package/src/theme/types/components.ts +4 -0
- package/src/theme/types/iconButton.ts +6 -20
- package/src/theme/types/index.ts +2 -0
- package/src/theme/types/input.ts +5 -15
- package/src/theme/types/menu.ts +50 -0
- package/src/theme/types/multiSelect.ts +17 -39
- package/src/theme/types/resolver.ts +43 -1
- package/src/theme/types/select.ts +18 -55
- package/src/components/Button/index.ts +0 -1
- package/src/components/Checkbox/index.ts +0 -1
- package/src/components/IconButton/index.ts +0 -1
- package/src/components/Input/index.ts +0 -1
- package/src/components/MultiSelect/index.ts +0 -1
- package/src/components/Select/index.ts +0 -1
- /package/src/components/{Chip → visualization-and-display}/index.ts +0 -0
|
@@ -10,11 +10,15 @@ import {
|
|
|
10
10
|
Text,
|
|
11
11
|
type PressableProps,
|
|
12
12
|
type StyleProp,
|
|
13
|
-
type TextStyle,
|
|
14
13
|
type ViewStyle
|
|
15
14
|
} from 'react-native'
|
|
16
15
|
import { useTheme } from '../../global-contexts/theme'
|
|
17
|
-
import type {
|
|
16
|
+
import type {
|
|
17
|
+
ButtonState,
|
|
18
|
+
ButtonStyle,
|
|
19
|
+
ButtonTextStyle,
|
|
20
|
+
StyleOverwrite
|
|
21
|
+
} from '../../theme'
|
|
18
22
|
|
|
19
23
|
export type ButtonSize = ElementSize
|
|
20
24
|
|
|
@@ -32,8 +36,8 @@ export type ButtonProps = Omit<PressableProps, 'children' | 'style'> & {
|
|
|
32
36
|
coloringStyle?: ButtonColoringStyle,
|
|
33
37
|
children?: ReactNode,
|
|
34
38
|
style?: StyleProp<ViewStyle>,
|
|
35
|
-
buttonStyle?:
|
|
36
|
-
textStyle?:
|
|
39
|
+
buttonStyle?: StyleOverwrite<ButtonState, ButtonStyle>,
|
|
40
|
+
textStyle?: StyleOverwrite<ButtonState, ButtonTextStyle>,
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
type PressableInteraction = {
|
|
@@ -55,25 +59,15 @@ export const Button = forwardRef<React.ComponentRef<typeof Pressable>, ButtonPro
|
|
|
55
59
|
}, ref) {
|
|
56
60
|
const { theme } = useTheme()
|
|
57
61
|
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const resolvedButton = theme.components.button.button(state)
|
|
70
|
-
const resolvedText = theme.components.button.text(state)
|
|
71
|
-
|
|
72
|
-
return {
|
|
73
|
-
button: typeof buttonStyle === 'function' ? buttonStyle(resolvedButton) : [resolvedButton, buttonStyle],
|
|
74
|
-
text: typeof textStyle === 'function' ? textStyle(resolvedText) : [resolvedText, textStyle],
|
|
75
|
-
}
|
|
76
|
-
}
|
|
62
|
+
const resolveState = (interaction: PressableInteraction): ButtonState => ({
|
|
63
|
+
size,
|
|
64
|
+
color,
|
|
65
|
+
coloringStyle,
|
|
66
|
+
isDisabled: !!disabled,
|
|
67
|
+
isPressed: interaction.pressed,
|
|
68
|
+
isHovered: !!interaction.hovered,
|
|
69
|
+
isFocused: !!interaction.focused,
|
|
70
|
+
})
|
|
77
71
|
|
|
78
72
|
return (
|
|
79
73
|
<Pressable
|
|
@@ -81,17 +75,16 @@ export const Button = forwardRef<React.ComponentRef<typeof Pressable>, ButtonPro
|
|
|
81
75
|
ref={ref}
|
|
82
76
|
disabled={disabled}
|
|
83
77
|
style={(pressableState) => {
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return [resolved.button, style]
|
|
78
|
+
const state = resolveState(pressableState as PressableInteraction)
|
|
79
|
+
return [theme.components.button.button(state, buttonStyle), style]
|
|
88
80
|
}}
|
|
89
81
|
>
|
|
90
82
|
{(pressableState) => {
|
|
91
|
-
const
|
|
83
|
+
const state = resolveState(pressableState as PressableInteraction)
|
|
84
|
+
const resolvedText = theme.components.button.text(state, textStyle)
|
|
92
85
|
|
|
93
86
|
if (typeof children === 'string' || typeof children === 'number') {
|
|
94
|
-
return <Text style={
|
|
87
|
+
return <Text style={resolvedText}>{children}</Text>
|
|
95
88
|
}
|
|
96
89
|
|
|
97
90
|
return children
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useControlledState, useEventCallbackStabilizer } from '@helpwave/hightide-utils/hooks'
|
|
2
2
|
import { Check, Minus } from 'lucide-react-native'
|
|
3
|
-
import { useCallback } from 'react'
|
|
3
|
+
import { useCallback, useMemo } from 'react'
|
|
4
4
|
import {
|
|
5
5
|
Pressable,
|
|
6
6
|
type PressableProps,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from 'react-native'
|
|
10
10
|
import { Icon } from '../../icons/Icon'
|
|
11
11
|
import { useTheme } from '../../global-contexts/theme'
|
|
12
|
-
import type { CheckboxSize, CheckboxState, CheckboxStyle } from '../../theme'
|
|
12
|
+
import type { CheckboxSize, CheckboxState, CheckboxStyle, StyleOverwrite } from '../../theme'
|
|
13
13
|
import type { FormFieldDataHandling, FormFieldInteractionStates } from '../../types/formField'
|
|
14
14
|
|
|
15
15
|
export type { CheckboxSize }
|
|
@@ -24,7 +24,7 @@ export type CheckboxProps = Omit<PressableProps, 'children' | 'style'>
|
|
|
24
24
|
alwaysShowCheckIcon?: boolean,
|
|
25
25
|
isRounded?: boolean,
|
|
26
26
|
style?: StyleProp<ViewStyle>,
|
|
27
|
-
checkboxStyle?:
|
|
27
|
+
checkboxStyle?: StyleOverwrite<CheckboxState, CheckboxStyle>,
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export const Checkbox = ({
|
|
@@ -60,7 +60,7 @@ export const Checkbox = ({
|
|
|
60
60
|
defaultValue: initialValue,
|
|
61
61
|
})
|
|
62
62
|
|
|
63
|
-
const state: CheckboxState
|
|
63
|
+
const state = useMemo((): CheckboxState => ({
|
|
64
64
|
size,
|
|
65
65
|
isChecked: value,
|
|
66
66
|
isIndeterminate: indeterminate,
|
|
@@ -68,13 +68,16 @@ export const Checkbox = ({
|
|
|
68
68
|
isDisabled: disabled,
|
|
69
69
|
isRounded,
|
|
70
70
|
alwaysShowCheckIcon,
|
|
71
|
-
}
|
|
71
|
+
}), [alwaysShowCheckIcon, disabled, indeterminate, invalid, isRounded, size, value])
|
|
72
72
|
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
const resolvedCheckboxStyle = useMemo(
|
|
74
|
+
() => theme.components.checkbox.checkbox(state, checkboxStyle),
|
|
75
|
+
[theme, state, checkboxStyle]
|
|
76
|
+
)
|
|
77
|
+
const resolvedIcon = useMemo(
|
|
78
|
+
() => theme.components.checkbox.icon(state),
|
|
79
|
+
[theme, state]
|
|
80
|
+
)
|
|
78
81
|
|
|
79
82
|
return (
|
|
80
83
|
<Pressable
|
|
@@ -91,7 +94,7 @@ export const Checkbox = ({
|
|
|
91
94
|
}
|
|
92
95
|
props.onPress?.(event)
|
|
93
96
|
}}
|
|
94
|
-
style={[
|
|
97
|
+
style={[resolvedCheckboxStyle, style]}
|
|
95
98
|
>
|
|
96
99
|
{resolvedIcon.visible && (
|
|
97
100
|
indeterminate
|
|
@@ -8,7 +8,7 @@ import { forwardRef, type ReactNode } from 'react'
|
|
|
8
8
|
import { Pressable, type PressableProps, type StyleProp, type ViewStyle } from 'react-native'
|
|
9
9
|
import { Icon } from '../../icons/Icon'
|
|
10
10
|
import { useTheme } from '../../global-contexts/theme'
|
|
11
|
-
import type { IconButtonState, IconButtonStyle } from '../../theme'
|
|
11
|
+
import type { IconButtonState, IconButtonStyle, StyleOverwrite } from '../../theme'
|
|
12
12
|
|
|
13
13
|
export type IconButtonSize = ElementSize
|
|
14
14
|
|
|
@@ -21,7 +21,7 @@ export type IconButtonProps = Omit<PressableProps, 'children' | 'style'> & {
|
|
|
21
21
|
children?: ReactNode,
|
|
22
22
|
accessibilityLabel: string,
|
|
23
23
|
style?: StyleProp<ViewStyle>,
|
|
24
|
-
buttonStyle?:
|
|
24
|
+
buttonStyle?: StyleOverwrite<IconButtonState, IconButtonStyle>,
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
type PressableInteraction = {
|
|
@@ -45,25 +45,15 @@ export const IconButton = forwardRef<React.ComponentRef<typeof Pressable>, IconB
|
|
|
45
45
|
}, ref) {
|
|
46
46
|
const { theme } = useTheme()
|
|
47
47
|
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const resolvedButton = theme.components.iconButton.button(state)
|
|
60
|
-
const resolvedIcon = theme.components.iconButton.icon(state)
|
|
61
|
-
|
|
62
|
-
return {
|
|
63
|
-
button: typeof buttonStyle === 'function' ? buttonStyle(resolvedButton) : [resolvedButton, buttonStyle],
|
|
64
|
-
icon: resolvedIcon,
|
|
65
|
-
}
|
|
66
|
-
}
|
|
48
|
+
const resolveState = (interaction: PressableInteraction): IconButtonState => ({
|
|
49
|
+
size,
|
|
50
|
+
color,
|
|
51
|
+
coloringStyle,
|
|
52
|
+
isDisabled: !!disabled,
|
|
53
|
+
isPressed: interaction.pressed,
|
|
54
|
+
isHovered: !!interaction.hovered,
|
|
55
|
+
isFocused: !!interaction.focused,
|
|
56
|
+
})
|
|
67
57
|
|
|
68
58
|
return (
|
|
69
59
|
<Pressable
|
|
@@ -73,14 +63,16 @@ export const IconButton = forwardRef<React.ComponentRef<typeof Pressable>, IconB
|
|
|
73
63
|
accessibilityRole="button"
|
|
74
64
|
accessibilityLabel={accessibilityLabel}
|
|
75
65
|
style={(pressableState) => {
|
|
76
|
-
const
|
|
77
|
-
return [
|
|
66
|
+
const state = resolveState(pressableState as PressableInteraction)
|
|
67
|
+
return [theme.components.iconButton.button(state, buttonStyle), style]
|
|
78
68
|
}}
|
|
79
69
|
>
|
|
80
70
|
{(pressableState) => {
|
|
81
|
-
const
|
|
71
|
+
const state = resolveState(pressableState as PressableInteraction)
|
|
72
|
+
const resolvedIcon = theme.components.iconButton.icon(state)
|
|
73
|
+
|
|
82
74
|
if (icon) {
|
|
83
|
-
return <Icon icon={icon} size={iconSize ?? size} color={
|
|
75
|
+
return <Icon icon={icon} size={iconSize ?? size} color={resolvedIcon.color} />
|
|
84
76
|
}
|
|
85
77
|
return children
|
|
86
78
|
}}
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
useDelay,
|
|
4
4
|
type UseDelayOptionsResolved
|
|
5
5
|
} from '@helpwave/hightide-utils/hooks'
|
|
6
|
-
import { forwardRef } from 'react'
|
|
6
|
+
import { forwardRef, useMemo } from 'react'
|
|
7
7
|
import { TextInput, type StyleProp, type TextInputProps, type TextStyle } from 'react-native'
|
|
8
8
|
import { useTheme } from '../../global-contexts/theme'
|
|
9
|
-
import type { InputState, InputStyle } from '../../theme'
|
|
9
|
+
import type { InputState, InputStyle, StyleOverwrite } from '../../theme'
|
|
10
10
|
import type { FormFieldDataHandling, FormFieldInteractionStates } from '../../types/formField'
|
|
11
11
|
|
|
12
12
|
export type EditCompleteOptionsResolved = {
|
|
@@ -31,7 +31,7 @@ export type InputProps = Omit<TextInputProps, 'value' | 'style'>
|
|
|
31
31
|
editCompleteOptions?: EditCompleteOptions,
|
|
32
32
|
initialValue?: string,
|
|
33
33
|
style?: StyleProp<TextStyle>,
|
|
34
|
-
inputStyle?:
|
|
34
|
+
inputStyle?: StyleOverwrite<InputState, InputStyle>,
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export const Input = forwardRef<TextInput, InputProps>(function Input({
|
|
@@ -68,16 +68,20 @@ export const Input = forwardRef<TextInput, InputProps>(function Input({
|
|
|
68
68
|
disabled: !afterDelay || disabled || readOnly,
|
|
69
69
|
})
|
|
70
70
|
|
|
71
|
-
const state: InputState
|
|
71
|
+
const state = useMemo((): InputState => ({
|
|
72
72
|
isDisabled: disabled,
|
|
73
73
|
isInvalid: invalid,
|
|
74
74
|
isReadOnly: readOnly,
|
|
75
|
-
}
|
|
75
|
+
}), [disabled, invalid, readOnly])
|
|
76
76
|
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
const resolvedInputStyle = useMemo(
|
|
78
|
+
() => theme.components.input.input(state, inputStyle),
|
|
79
|
+
[theme, state, inputStyle]
|
|
80
|
+
)
|
|
81
|
+
const placeholderColor = useMemo(
|
|
82
|
+
() => theme.components.input.placeholderColor(state),
|
|
83
|
+
[theme, state]
|
|
84
|
+
)
|
|
81
85
|
|
|
82
86
|
return (
|
|
83
87
|
<TextInput
|
|
@@ -106,8 +110,8 @@ export const Input = forwardRef<TextInput, InputProps>(function Input({
|
|
|
106
110
|
clearTimer()
|
|
107
111
|
}
|
|
108
112
|
}}
|
|
109
|
-
placeholderTextColor={
|
|
110
|
-
style={[
|
|
113
|
+
placeholderTextColor={placeholderColor}
|
|
114
|
+
style={[resolvedInputStyle, style]}
|
|
111
115
|
accessibilityState={{ disabled, selected: required }}
|
|
112
116
|
/>
|
|
113
117
|
)
|
|
@@ -10,12 +10,12 @@ import {
|
|
|
10
10
|
type StyleProp,
|
|
11
11
|
type ViewStyle
|
|
12
12
|
} from 'react-native'
|
|
13
|
-
import { Chip } from '../Chip/Chip'
|
|
14
13
|
import { Icon } from '../../icons/Icon'
|
|
15
14
|
import { useMultiSelect, type UseMultiSelectOption } from '../../hooks/useMultiSelect'
|
|
16
15
|
import { useTheme } from '../../global-contexts/theme'
|
|
17
16
|
import type { MultiSelectState } from '../../theme'
|
|
18
17
|
import type { FormFieldDataHandling, FormFieldInteractionStates } from '../../types/formField'
|
|
18
|
+
import { Chip } from '../visualization-and-display'
|
|
19
19
|
|
|
20
20
|
export type MultiSelectOption = UseMultiSelectOption
|
|
21
21
|
|
|
@@ -60,23 +60,48 @@ export const MultiSelect = ({
|
|
|
60
60
|
.map((option) => option.label ?? option.id)
|
|
61
61
|
}, [multiSelect, options])
|
|
62
62
|
|
|
63
|
-
const state: MultiSelectState
|
|
63
|
+
const state = useMemo((): MultiSelectState => ({
|
|
64
64
|
isDisabled: disabled,
|
|
65
65
|
isReadOnly: readOnly,
|
|
66
66
|
isInvalid: invalid,
|
|
67
67
|
isOpen: multiSelect.isOpen,
|
|
68
68
|
hasSelections: selectedLabels.length > 0,
|
|
69
69
|
hasValue: selectedLabels.length > 0,
|
|
70
|
-
}
|
|
70
|
+
}), [disabled, invalid, multiSelect.isOpen, readOnly, selectedLabels.length])
|
|
71
71
|
|
|
72
72
|
const multiSelectTheme = theme.components.multiSelect
|
|
73
73
|
|
|
74
|
+
const resolvedTriggerStyle = useMemo(
|
|
75
|
+
() => multiSelectTheme.trigger(state),
|
|
76
|
+
[multiSelectTheme, state]
|
|
77
|
+
)
|
|
78
|
+
const resolvedTriggerTextStyle = useMemo(
|
|
79
|
+
() => multiSelectTheme.triggerText(state),
|
|
80
|
+
[multiSelectTheme, state]
|
|
81
|
+
)
|
|
82
|
+
const resolvedOverlayStyle = useMemo(
|
|
83
|
+
() => multiSelectTheme.overlay(state),
|
|
84
|
+
[multiSelectTheme, state]
|
|
85
|
+
)
|
|
86
|
+
const resolvedMenuStyle = useMemo(
|
|
87
|
+
() => multiSelectTheme.menu(state),
|
|
88
|
+
[multiSelectTheme, state]
|
|
89
|
+
)
|
|
90
|
+
const resolvedSearchStyle = useMemo(
|
|
91
|
+
() => multiSelectTheme.search(state),
|
|
92
|
+
[multiSelectTheme, state]
|
|
93
|
+
)
|
|
94
|
+
const searchPlaceholderColor = useMemo(
|
|
95
|
+
() => multiSelectTheme.searchPlaceholderColor(state),
|
|
96
|
+
[multiSelectTheme, state]
|
|
97
|
+
)
|
|
98
|
+
|
|
74
99
|
return (
|
|
75
100
|
<View style={style}>
|
|
76
101
|
<Pressable
|
|
77
102
|
disabled={!interactive}
|
|
78
103
|
onPress={() => multiSelect.toggleOpen()}
|
|
79
|
-
style={
|
|
104
|
+
style={resolvedTriggerStyle}
|
|
80
105
|
>
|
|
81
106
|
{selectedLabels.length > 0
|
|
82
107
|
? (
|
|
@@ -88,7 +113,7 @@ export const MultiSelect = ({
|
|
|
88
113
|
))}
|
|
89
114
|
</View>
|
|
90
115
|
)
|
|
91
|
-
: <Text style={
|
|
116
|
+
: <Text style={resolvedTriggerTextStyle}>{placeholder}</Text>}
|
|
92
117
|
</Pressable>
|
|
93
118
|
|
|
94
119
|
<Modal
|
|
@@ -98,11 +123,11 @@ export const MultiSelect = ({
|
|
|
98
123
|
onRequestClose={() => multiSelect.setIsOpen(false)}
|
|
99
124
|
>
|
|
100
125
|
<Pressable
|
|
101
|
-
style={
|
|
126
|
+
style={resolvedOverlayStyle}
|
|
102
127
|
onPress={() => multiSelect.setIsOpen(false)}
|
|
103
128
|
>
|
|
104
129
|
<Pressable
|
|
105
|
-
style={
|
|
130
|
+
style={resolvedMenuStyle}
|
|
106
131
|
onPress={(event) => event.stopPropagation()}
|
|
107
132
|
>
|
|
108
133
|
{showSearch && (
|
|
@@ -110,8 +135,8 @@ export const MultiSelect = ({
|
|
|
110
135
|
value={multiSelect.searchQuery}
|
|
111
136
|
onChangeText={multiSelect.setSearchQuery}
|
|
112
137
|
placeholder="Search…"
|
|
113
|
-
placeholderTextColor={
|
|
114
|
-
style={
|
|
138
|
+
placeholderTextColor={searchPlaceholderColor}
|
|
139
|
+
style={resolvedSearchStyle}
|
|
115
140
|
/>
|
|
116
141
|
)}
|
|
117
142
|
<FlatList
|
|
@@ -58,24 +58,49 @@ export const Select = ({
|
|
|
58
58
|
return selected?.label ?? placeholder
|
|
59
59
|
}, [options, placeholder, select.value])
|
|
60
60
|
|
|
61
|
-
const state: SelectState
|
|
61
|
+
const state = useMemo((): SelectState => ({
|
|
62
62
|
isDisabled: disabled,
|
|
63
63
|
isReadOnly: readOnly,
|
|
64
64
|
isInvalid: invalid,
|
|
65
65
|
isOpen: select.isOpen,
|
|
66
66
|
hasValue: !!select.value,
|
|
67
|
-
}
|
|
67
|
+
}), [disabled, invalid, readOnly, select.isOpen, select.value])
|
|
68
68
|
|
|
69
69
|
const selectTheme = theme.components.select
|
|
70
70
|
|
|
71
|
+
const resolvedTriggerStyle = useMemo(
|
|
72
|
+
() => selectTheme.trigger(state),
|
|
73
|
+
[selectTheme, state]
|
|
74
|
+
)
|
|
75
|
+
const resolvedTriggerTextStyle = useMemo(
|
|
76
|
+
() => selectTheme.triggerText(state),
|
|
77
|
+
[selectTheme, state]
|
|
78
|
+
)
|
|
79
|
+
const resolvedOverlayStyle = useMemo(
|
|
80
|
+
() => selectTheme.overlay(state),
|
|
81
|
+
[selectTheme, state]
|
|
82
|
+
)
|
|
83
|
+
const resolvedMenuStyle = useMemo(
|
|
84
|
+
() => selectTheme.menu(state),
|
|
85
|
+
[selectTheme, state]
|
|
86
|
+
)
|
|
87
|
+
const resolvedSearchStyle = useMemo(
|
|
88
|
+
() => selectTheme.search(state),
|
|
89
|
+
[selectTheme, state]
|
|
90
|
+
)
|
|
91
|
+
const searchPlaceholderColor = useMemo(
|
|
92
|
+
() => selectTheme.searchPlaceholderColor(state),
|
|
93
|
+
[selectTheme, state]
|
|
94
|
+
)
|
|
95
|
+
|
|
71
96
|
return (
|
|
72
97
|
<View style={style}>
|
|
73
98
|
<Pressable
|
|
74
99
|
disabled={!interactive}
|
|
75
100
|
onPress={() => select.toggleOpen()}
|
|
76
|
-
style={
|
|
101
|
+
style={resolvedTriggerStyle}
|
|
77
102
|
>
|
|
78
|
-
<Text style={
|
|
103
|
+
<Text style={resolvedTriggerTextStyle}>
|
|
79
104
|
{selectedLabel}
|
|
80
105
|
</Text>
|
|
81
106
|
</Pressable>
|
|
@@ -87,11 +112,11 @@ export const Select = ({
|
|
|
87
112
|
onRequestClose={() => select.setIsOpen(false)}
|
|
88
113
|
>
|
|
89
114
|
<Pressable
|
|
90
|
-
style={
|
|
115
|
+
style={resolvedOverlayStyle}
|
|
91
116
|
onPress={() => select.setIsOpen(false)}
|
|
92
117
|
>
|
|
93
118
|
<Pressable
|
|
94
|
-
style={
|
|
119
|
+
style={resolvedMenuStyle}
|
|
95
120
|
onPress={(event) => event.stopPropagation()}
|
|
96
121
|
>
|
|
97
122
|
{showSearch && (
|
|
@@ -99,8 +124,8 @@ export const Select = ({
|
|
|
99
124
|
value={select.searchQuery}
|
|
100
125
|
onChangeText={select.setSearchQuery}
|
|
101
126
|
placeholder="Search…"
|
|
102
|
-
placeholderTextColor={
|
|
103
|
-
style={
|
|
127
|
+
placeholderTextColor={searchPlaceholderColor}
|
|
128
|
+
style={resolvedSearchStyle}
|
|
104
129
|
/>
|
|
105
130
|
)}
|
|
106
131
|
<FlatList
|
|
@@ -4,17 +4,16 @@ import {
|
|
|
4
4
|
type ColoringType,
|
|
5
5
|
type ElementSize
|
|
6
6
|
} from '@helpwave/hightide-design'
|
|
7
|
-
import type
|
|
7
|
+
import { useMemo, type ReactNode } from 'react'
|
|
8
8
|
import {
|
|
9
9
|
Text,
|
|
10
10
|
View,
|
|
11
11
|
type StyleProp,
|
|
12
|
-
type TextStyle,
|
|
13
12
|
type ViewProps,
|
|
14
13
|
type ViewStyle
|
|
15
14
|
} from 'react-native'
|
|
16
15
|
import { useTheme } from '../../global-contexts/theme'
|
|
17
|
-
import type { ChipState, ChipStyle, ChipTextStyle } from '../../theme'
|
|
16
|
+
import type { ChipState, ChipStyle, ChipTextStyle, StyleOverwrite } from '../../theme'
|
|
18
17
|
|
|
19
18
|
export type ChipSize = ElementSize
|
|
20
19
|
|
|
@@ -32,8 +31,8 @@ export type ChipProps = Omit<ViewProps, 'children' | 'style'> & {
|
|
|
32
31
|
size?: ChipSize,
|
|
33
32
|
children?: ReactNode,
|
|
34
33
|
style?: StyleProp<ViewStyle>,
|
|
35
|
-
chipStyle?:
|
|
36
|
-
textStyle?:
|
|
34
|
+
chipStyle?: StyleOverwrite<ChipState, ChipStyle>,
|
|
35
|
+
textStyle?: StyleOverwrite<ChipState, ChipTextStyle>,
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
export const Chip = ({
|
|
@@ -47,24 +46,29 @@ export const Chip = ({
|
|
|
47
46
|
...props
|
|
48
47
|
}: ChipProps) => {
|
|
49
48
|
const { theme } = useTheme()
|
|
50
|
-
|
|
49
|
+
|
|
50
|
+
const state = useMemo((): ChipState => ({
|
|
51
51
|
size,
|
|
52
52
|
color,
|
|
53
53
|
coloringStyle,
|
|
54
|
-
}
|
|
54
|
+
}), [size, color, coloringStyle])
|
|
55
55
|
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
const resolvedChipStyle = useMemo(
|
|
57
|
+
() => theme.components.chip.chip(state, chipStyle),
|
|
58
|
+
[theme, state, chipStyle]
|
|
59
|
+
)
|
|
60
|
+
const resolvedTextStyle = useMemo(
|
|
61
|
+
() => theme.components.chip.text(state, textStyle),
|
|
62
|
+
[theme, state, textStyle]
|
|
63
|
+
)
|
|
60
64
|
|
|
61
65
|
return (
|
|
62
66
|
<View
|
|
63
67
|
{...props}
|
|
64
|
-
style={[
|
|
68
|
+
style={[resolvedChipStyle, style]}
|
|
65
69
|
>
|
|
66
70
|
{typeof children === 'string' || typeof children === 'number'
|
|
67
|
-
? <Text style={
|
|
71
|
+
? <Text style={resolvedTextStyle}>{children}</Text>
|
|
68
72
|
: children}
|
|
69
73
|
</View>
|
|
70
74
|
)
|
|
@@ -6,7 +6,9 @@ import {
|
|
|
6
6
|
type ElementSize,
|
|
7
7
|
type SemanticColors
|
|
8
8
|
} from '@helpwave/hightide-design'
|
|
9
|
-
import type {
|
|
9
|
+
import type { ViewStyle, TextStyle } from 'react-native'
|
|
10
|
+
import type { ButtonState, ButtonTheme } from '../types'
|
|
11
|
+
import { createStyleResolver } from '../types/resolver'
|
|
10
12
|
import { isOutlineColoringStyle, resolveColoringStyles } from './coloring'
|
|
11
13
|
|
|
12
14
|
const buttonFontSizes: Record<ElementSize, number> = {
|
|
@@ -35,7 +37,7 @@ export const createButtonTheme = ({
|
|
|
35
37
|
const sizing = componentLayouts.element[size]
|
|
36
38
|
const outlinePadding = isOutlineColoringStyle(coloringStyle)
|
|
37
39
|
|
|
38
|
-
const button:
|
|
40
|
+
const button: ViewStyle = {
|
|
39
41
|
flexDirection: 'row',
|
|
40
42
|
alignItems: 'center',
|
|
41
43
|
justifyContent: 'center',
|
|
@@ -51,7 +53,7 @@ export const createButtonTheme = ({
|
|
|
51
53
|
opacity: state.isDisabled ? 0.6 : 1,
|
|
52
54
|
}
|
|
53
55
|
|
|
54
|
-
const text:
|
|
56
|
+
const text: TextStyle = {
|
|
55
57
|
color: resolved.color,
|
|
56
58
|
fontSize: buttonFontSizes[size],
|
|
57
59
|
fontWeight: '600',
|
|
@@ -61,8 +63,8 @@ export const createButtonTheme = ({
|
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
return {
|
|
64
|
-
button: (state) => resolveState(state).button,
|
|
65
|
-
text: (state) => resolveState(state).text,
|
|
66
|
+
button: createStyleResolver((state) => resolveState(state).button),
|
|
67
|
+
text: createStyleResolver((state) => resolveState(state).text),
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
|