@helpwave/hightide-native 0.0.2 → 0.0.6
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/package.json +4 -3
- package/src/components/chat/ChatAttachmentCard.tsx +26 -13
- package/src/components/chat/ChatConversationList.tsx +12 -8
- package/src/components/chat/ChatConversationRow.tsx +21 -13
- package/src/components/chat/ChatDateDivider.tsx +18 -8
- package/src/components/chat/ChatMessageBubble.tsx +23 -13
- package/src/components/chat/ChatMessageCard.tsx +25 -14
- package/src/components/chat/ChatMessageComposer.tsx +14 -9
- package/src/components/chat/ChatMessageList.tsx +12 -5
- package/src/components/chat/ChatQuickReplyChip.tsx +7 -6
- package/src/components/chat/ChatSystemLine.tsx +21 -10
- package/src/components/chat/ChatThreadHeader.tsx +19 -9
- package/src/components/menu/Menu.tsx +16 -6
- package/src/components/menu/MenuActionItem.tsx +10 -5
- package/src/components/menu/MenuItem.tsx +16 -6
- package/src/components/menu/MenuNavigationItem.tsx +11 -6
- package/src/components/user-interaction/Button.tsx +18 -11
- package/src/components/user-interaction/Checkbox.tsx +26 -7
- package/src/components/user-interaction/IconButton.tsx +23 -9
- package/src/components/user-interaction/Input.tsx +22 -5
- package/src/components/user-interaction/MultiSelect.tsx +14 -7
- package/src/components/user-interaction/Select.tsx +11 -4
- package/src/components/visualization-and-display/Chip.tsx +21 -9
- package/src/components/visualization-and-display/Icon.tsx +27 -0
- package/src/components/visualization-and-display/index.ts +1 -0
- package/src/global-contexts/HightideContext.ts +4 -1
- package/src/global-contexts/HightideProvider.tsx +21 -9
- package/src/global-contexts/hightide-config/HightideConfigUtils.ts +15 -12
- package/src/global-contexts/localization/LocalizationProvider.tsx +3 -1
- package/src/global-contexts/localization/forward-exports.ts +1 -0
- package/src/global-contexts/theme/ThemeContext.ts +11 -6
- package/src/global-contexts/theme/ThemeProvider.tsx +34 -37
- package/src/hooks/useMultiSelect.ts +1 -0
- package/src/hooks/useNativeKeyValueStore.ts +7 -1
- package/src/hooks/useSelect.ts +1 -0
- package/src/theme/resolvers/button.ts +33 -20
- package/src/theme/resolvers/chat.ts +370 -336
- package/src/theme/resolvers/checkbox.ts +22 -18
- package/src/theme/resolvers/chip.ts +27 -19
- package/src/theme/resolvers/coloring.ts +21 -17
- package/src/theme/resolvers/iconButton.ts +25 -17
- package/src/theme/resolvers/input.ts +25 -18
- package/src/theme/resolvers/menu.ts +37 -29
- package/src/theme/resolvers/multiSelect.ts +20 -16
- package/src/theme/resolvers/select.ts +20 -16
- package/src/theme/themes/createTheme.ts +42 -17
- package/src/theme/themes/nativeThemes.ts +7 -6
- package/src/theme/types/color.ts +60 -0
- package/src/theme/types/components/button.ts +30 -0
- package/src/theme/types/components/chat.ts +198 -0
- package/src/theme/types/{checkbox.ts → components/checkbox.ts} +11 -5
- package/src/theme/types/components/chip.ts +30 -0
- package/src/theme/types/{components.ts → components/hightide.ts} +22 -1
- package/src/theme/types/components/iconButton.ts +30 -0
- package/src/theme/types/components/index.ts +10 -0
- package/src/theme/types/components/input.ts +19 -0
- package/src/theme/types/{menu.ts → components/menu.ts} +21 -14
- package/src/theme/types/{multiSelect.ts → components/multiSelect.ts} +13 -9
- package/src/theme/types/{select.ts → components/select.ts} +18 -11
- package/src/theme/types/decoration.ts +11 -0
- package/src/theme/types/index.ts +4 -9
- package/src/theme/types/layout.ts +46 -0
- package/src/theme/types/theme.ts +14 -10
- package/src/theme/types/typography.ts +18 -0
- package/src/icons/Icon.tsx +0 -35
- package/src/icons/index.ts +0 -1
- package/src/theme/types/button.ts +0 -18
- package/src/theme/types/chat.ts +0 -141
- package/src/theme/types/chip.ts +0 -18
- package/src/theme/types/iconButton.ts +0 -20
- package/src/theme/types/input.ts +0 -15
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Fragment,
|
|
3
|
+
useMemo,
|
|
4
|
+
type ReactNode
|
|
5
|
+
} from 'react'
|
|
2
6
|
import {
|
|
3
7
|
Pressable,
|
|
4
8
|
Text,
|
|
@@ -7,13 +11,14 @@ import {
|
|
|
7
11
|
type StyleProp,
|
|
8
12
|
type ViewStyle
|
|
9
13
|
} from 'react-native'
|
|
10
|
-
|
|
14
|
+
|
|
15
|
+
import { useTheme } from '../../global-contexts/theme/ThemeContext'
|
|
11
16
|
import type {
|
|
12
17
|
MenuActionItemLabelStyle,
|
|
13
18
|
MenuActionItemState,
|
|
14
|
-
MenuActionItemStyle
|
|
15
|
-
|
|
16
|
-
} from '../../theme'
|
|
19
|
+
MenuActionItemStyle
|
|
20
|
+
} from '../../theme/types/components/menu'
|
|
21
|
+
import type { StyleOverwrite } from '../../theme/types/resolver'
|
|
17
22
|
|
|
18
23
|
export type MenuActionItemProps = Omit<PressableProps, 'children' | 'style'> & {
|
|
19
24
|
label: string,
|
|
@@ -1,12 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
useMemo,
|
|
3
|
+
type ReactNode
|
|
4
|
+
} from 'react'
|
|
5
|
+
import {
|
|
6
|
+
Text,
|
|
7
|
+
View,
|
|
8
|
+
type StyleProp,
|
|
9
|
+
type ViewProps,
|
|
10
|
+
type ViewStyle
|
|
11
|
+
} from 'react-native'
|
|
12
|
+
|
|
13
|
+
import { useTheme } from '../../global-contexts/theme/ThemeContext'
|
|
4
14
|
import type {
|
|
5
15
|
MenuItemLabelStyle,
|
|
6
16
|
MenuItemStyle,
|
|
7
|
-
MenuItemValueStyle
|
|
8
|
-
|
|
9
|
-
} from '../../theme'
|
|
17
|
+
MenuItemValueStyle
|
|
18
|
+
} from '../../theme/types/components/menu'
|
|
19
|
+
import type { StyleOverwrite } from '../../theme/types/resolver'
|
|
10
20
|
|
|
11
21
|
export type MenuItemProps = Omit<ViewProps, 'style'> & {
|
|
12
22
|
label: string,
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
Fragment,
|
|
3
|
+
useMemo,
|
|
4
|
+
type ReactNode
|
|
5
|
+
} from 'react'
|
|
3
6
|
import {
|
|
4
7
|
Pressable,
|
|
5
8
|
Text,
|
|
@@ -8,13 +11,15 @@ import {
|
|
|
8
11
|
type StyleProp,
|
|
9
12
|
type ViewStyle
|
|
10
13
|
} from 'react-native'
|
|
11
|
-
import {
|
|
14
|
+
import { ChevronRight } from 'lucide-react-native'
|
|
15
|
+
|
|
16
|
+
import { useTheme } from '../../global-contexts/theme/ThemeContext'
|
|
12
17
|
import type {
|
|
13
18
|
MenuActionItemLabelStyle,
|
|
14
19
|
MenuActionItemState,
|
|
15
|
-
MenuActionItemStyle
|
|
16
|
-
|
|
17
|
-
} from '../../theme'
|
|
20
|
+
MenuActionItemStyle
|
|
21
|
+
} from '../../theme/types/components/menu'
|
|
22
|
+
import type { StyleOverwrite } from '../../theme/types/resolver'
|
|
18
23
|
|
|
19
24
|
export type MenuNavigationItemProps = Omit<PressableProps, 'children' | 'style'> & {
|
|
20
25
|
label: string,
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
type ElementSize
|
|
6
|
-
} from '@helpwave/hightide-design'
|
|
7
|
-
import { forwardRef, type ReactNode } from 'react'
|
|
2
|
+
forwardRef,
|
|
3
|
+
type ReactNode
|
|
4
|
+
} from 'react'
|
|
8
5
|
import {
|
|
9
6
|
Pressable,
|
|
10
7
|
Text,
|
|
@@ -12,20 +9,30 @@ import {
|
|
|
12
9
|
type StyleProp,
|
|
13
10
|
type ViewStyle
|
|
14
11
|
} from 'react-native'
|
|
15
|
-
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
coloringTypes,
|
|
15
|
+
type ColoringType
|
|
16
|
+
} from '@helpwave/hightide-design/helpers'
|
|
17
|
+
import type {
|
|
18
|
+
ButtonColoringStyle,
|
|
19
|
+
ElementSize
|
|
20
|
+
} from '@helpwave/hightide-design/types'
|
|
21
|
+
|
|
22
|
+
import { useTheme } from '../../global-contexts/theme/ThemeContext'
|
|
16
23
|
import type {
|
|
17
24
|
ButtonState,
|
|
18
25
|
ButtonStyle,
|
|
19
|
-
ButtonTextStyle
|
|
20
|
-
|
|
21
|
-
} from '../../theme'
|
|
26
|
+
ButtonTextStyle
|
|
27
|
+
} from '../../theme/types/components/button'
|
|
28
|
+
import type { StyleOverwrite } from '../../theme/types/resolver'
|
|
22
29
|
|
|
23
30
|
export type ButtonSize = ElementSize
|
|
24
31
|
|
|
25
32
|
export type ButtonColor = ColoringType
|
|
26
33
|
|
|
27
34
|
export const ButtonUtil = {
|
|
28
|
-
colors:
|
|
35
|
+
colors: coloringTypes,
|
|
29
36
|
sizes: ['xs', 'sm', 'md', 'lg'] as const satisfies readonly ElementSize[],
|
|
30
37
|
coloringStyles: ['outline', 'solid', 'text', 'tonal', 'tonal-outline'] as const satisfies readonly ButtonColoringStyle[],
|
|
31
38
|
}
|
|
@@ -1,16 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
useCallback,
|
|
3
|
+
useMemo
|
|
4
|
+
} from 'react'
|
|
4
5
|
import {
|
|
5
6
|
Pressable,
|
|
6
7
|
type PressableProps,
|
|
7
8
|
type StyleProp,
|
|
8
9
|
type ViewStyle
|
|
9
10
|
} from 'react-native'
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
import {
|
|
12
|
+
Check,
|
|
13
|
+
Minus
|
|
14
|
+
} from 'lucide-react-native'
|
|
15
|
+
|
|
16
|
+
import {
|
|
17
|
+
useControlledState,
|
|
18
|
+
useEventCallbackStabilizer
|
|
19
|
+
} from '@helpwave/hightide-utils/hooks'
|
|
20
|
+
|
|
21
|
+
import { Icon } from '../visualization-and-display/Icon'
|
|
22
|
+
import { useTheme } from '../../global-contexts/theme/ThemeContext'
|
|
23
|
+
import type {
|
|
24
|
+
CheckboxSize,
|
|
25
|
+
CheckboxState,
|
|
26
|
+
CheckboxStyle
|
|
27
|
+
} from '../../theme/types/components/checkbox'
|
|
28
|
+
import type { StyleOverwrite } from '../../theme/types/resolver'
|
|
29
|
+
import type {
|
|
30
|
+
FormFieldDataHandling,
|
|
31
|
+
FormFieldInteractionStates
|
|
32
|
+
} from '../../types/formField'
|
|
14
33
|
|
|
15
34
|
export type { CheckboxSize }
|
|
16
35
|
|
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
forwardRef,
|
|
3
|
+
type ReactNode
|
|
4
|
+
} from 'react'
|
|
5
|
+
import {
|
|
6
|
+
Pressable,
|
|
7
|
+
type PressableProps,
|
|
8
|
+
type StyleProp,
|
|
9
|
+
type ViewStyle
|
|
10
|
+
} from 'react-native'
|
|
6
11
|
import type { LucideIcon } from 'lucide-react-native'
|
|
7
|
-
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
|
|
13
|
+
import type { ColoringType } from '@helpwave/hightide-design/helpers'
|
|
14
|
+
import type {
|
|
15
|
+
ButtonColoringStyle,
|
|
16
|
+
ElementSize
|
|
17
|
+
} from '@helpwave/hightide-design/types'
|
|
18
|
+
|
|
19
|
+
import { Icon } from '../visualization-and-display/Icon'
|
|
20
|
+
import { useTheme } from '../../global-contexts/theme/ThemeContext'
|
|
21
|
+
import type {
|
|
22
|
+
IconButtonState,
|
|
23
|
+
IconButtonStyle
|
|
24
|
+
} from '../../theme/types/components/iconButton'
|
|
25
|
+
import type { StyleOverwrite } from '../../theme/types/resolver'
|
|
12
26
|
|
|
13
27
|
export type IconButtonSize = ElementSize
|
|
14
28
|
|
|
@@ -1,13 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useMemo
|
|
4
|
+
} from 'react'
|
|
5
|
+
import {
|
|
6
|
+
TextInput,
|
|
7
|
+
type StyleProp,
|
|
8
|
+
type TextInputProps,
|
|
9
|
+
type TextStyle
|
|
10
|
+
} from 'react-native'
|
|
11
|
+
|
|
1
12
|
import {
|
|
2
13
|
useControlledState,
|
|
3
14
|
useDelay,
|
|
4
15
|
type UseDelayOptionsResolved
|
|
5
16
|
} from '@helpwave/hightide-utils/hooks'
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
17
|
+
|
|
18
|
+
import { useTheme } from '../../global-contexts/theme/ThemeContext'
|
|
19
|
+
import type {
|
|
20
|
+
InputState,
|
|
21
|
+
InputStyle
|
|
22
|
+
} from '../../theme/types/components/input'
|
|
23
|
+
import type { StyleOverwrite } from '../../theme/types/resolver'
|
|
24
|
+
import type {
|
|
25
|
+
FormFieldDataHandling,
|
|
26
|
+
FormFieldInteractionStates
|
|
27
|
+
} from '../../types/formField'
|
|
11
28
|
|
|
12
29
|
export type EditCompleteOptionsResolved = {
|
|
13
30
|
onBlur: boolean,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Check } from 'lucide-react-native'
|
|
2
1
|
import { useMemo } from 'react'
|
|
3
2
|
import {
|
|
4
3
|
FlatList,
|
|
@@ -10,12 +9,20 @@ import {
|
|
|
10
9
|
type StyleProp,
|
|
11
10
|
type ViewStyle
|
|
12
11
|
} from 'react-native'
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import {
|
|
12
|
+
import { Check } from 'lucide-react-native'
|
|
13
|
+
|
|
14
|
+
import { Chip } from '../visualization-and-display/Chip'
|
|
15
|
+
import { Icon } from '../visualization-and-display/Icon'
|
|
16
|
+
import { useTheme } from '../../global-contexts/theme/ThemeContext'
|
|
17
|
+
import {
|
|
18
|
+
useMultiSelect,
|
|
19
|
+
type UseMultiSelectOption
|
|
20
|
+
} from '../../hooks/useMultiSelect'
|
|
21
|
+
import type { MultiSelectState } from '../../theme/types/components/multiSelect'
|
|
22
|
+
import type {
|
|
23
|
+
FormFieldDataHandling,
|
|
24
|
+
FormFieldInteractionStates
|
|
25
|
+
} from '../../types/formField'
|
|
19
26
|
|
|
20
27
|
export type MultiSelectOption = UseMultiSelectOption
|
|
21
28
|
|
|
@@ -9,10 +9,17 @@ import {
|
|
|
9
9
|
type StyleProp,
|
|
10
10
|
type ViewStyle
|
|
11
11
|
} from 'react-native'
|
|
12
|
-
|
|
13
|
-
import { useTheme } from '../../global-contexts/theme'
|
|
14
|
-
import
|
|
15
|
-
|
|
12
|
+
|
|
13
|
+
import { useTheme } from '../../global-contexts/theme/ThemeContext'
|
|
14
|
+
import {
|
|
15
|
+
useSelect,
|
|
16
|
+
type UseSelectOption
|
|
17
|
+
} from '../../hooks/useSelect'
|
|
18
|
+
import type { SelectState } from '../../theme/types/components/select'
|
|
19
|
+
import type {
|
|
20
|
+
FormFieldDataHandling,
|
|
21
|
+
FormFieldInteractionStates
|
|
22
|
+
} from '../../types/formField'
|
|
16
23
|
|
|
17
24
|
export type SelectOption<T extends string = string> = UseSelectOption & {
|
|
18
25
|
value?: T,
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
type ElementSize
|
|
6
|
-
} from '@helpwave/hightide-design'
|
|
7
|
-
import { useMemo, type ReactNode } from 'react'
|
|
2
|
+
useMemo,
|
|
3
|
+
type ReactNode
|
|
4
|
+
} from 'react'
|
|
8
5
|
import {
|
|
9
6
|
Text,
|
|
10
7
|
View,
|
|
@@ -12,15 +9,30 @@ import {
|
|
|
12
9
|
type ViewProps,
|
|
13
10
|
type ViewStyle
|
|
14
11
|
} from 'react-native'
|
|
15
|
-
|
|
16
|
-
import
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
coloringTypes,
|
|
15
|
+
type ColoringType
|
|
16
|
+
} from '@helpwave/hightide-design/helpers'
|
|
17
|
+
import type {
|
|
18
|
+
ChipColoringStyle,
|
|
19
|
+
ElementSize
|
|
20
|
+
} from '@helpwave/hightide-design/types'
|
|
21
|
+
|
|
22
|
+
import { useTheme } from '../../global-contexts/theme/ThemeContext'
|
|
23
|
+
import type {
|
|
24
|
+
ChipState,
|
|
25
|
+
ChipStyle,
|
|
26
|
+
ChipTextStyle
|
|
27
|
+
} from '../../theme/types/components/chip'
|
|
28
|
+
import type { StyleOverwrite } from '../../theme/types/resolver'
|
|
17
29
|
|
|
18
30
|
export type ChipSize = ElementSize
|
|
19
31
|
|
|
20
32
|
export type ChipColor = ColoringType
|
|
21
33
|
|
|
22
34
|
export const ChipUtil = {
|
|
23
|
-
colors:
|
|
35
|
+
colors: coloringTypes,
|
|
24
36
|
sizes: ['xs', 'sm', 'md', 'lg'] as const satisfies readonly ElementSize[],
|
|
25
37
|
coloringStyles: ['solid', 'tonal', 'outline', 'tonal-outline'] as const satisfies readonly ChipColoringStyle[],
|
|
26
38
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { LucideIcon } from 'lucide-react-native'
|
|
2
|
+
|
|
3
|
+
import type { ElementSize } from '@helpwave/hightide-design/types'
|
|
4
|
+
|
|
5
|
+
import { useTheme } from '../../global-contexts/theme/ThemeContext'
|
|
6
|
+
|
|
7
|
+
export type IconProps = {
|
|
8
|
+
icon: LucideIcon,
|
|
9
|
+
size?: ElementSize,
|
|
10
|
+
color?: string,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const Icon = ({
|
|
14
|
+
icon: IconComponent,
|
|
15
|
+
size = 'md',
|
|
16
|
+
color,
|
|
17
|
+
}: IconProps) => {
|
|
18
|
+
const { theme } = useTheme()
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<IconComponent
|
|
22
|
+
size={theme.layout.icon[size].size}
|
|
23
|
+
strokeWidth={theme.layout.icon[size].strokeWidth}
|
|
24
|
+
color={color}
|
|
25
|
+
/>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
@@ -1,14 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
useMemo,
|
|
3
|
+
type PropsWithChildren
|
|
4
|
+
} from 'react'
|
|
5
|
+
|
|
4
6
|
import { useLocalization } from '@helpwave/hightide-utils/context/localization'
|
|
7
|
+
import { hightideTranslation } from '@helpwave/hightide-utils/i18n'
|
|
8
|
+
import { ArrayUtil } from '@helpwave/hightide-utils/utils'
|
|
9
|
+
|
|
5
10
|
import { HightideContext } from './HightideContext'
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
LocalizationProvider,
|
|
13
|
+
type LocalizationProviderProps
|
|
14
|
+
} from './localization/LocalizationProvider'
|
|
15
|
+
import { useTheme } from './theme/ThemeContext'
|
|
16
|
+
import {
|
|
17
|
+
ThemeProvider,
|
|
18
|
+
type ThemeProviderProps
|
|
19
|
+
} from './theme/ThemeProvider'
|
|
20
|
+
import {
|
|
21
|
+
TranslationProvider,
|
|
22
|
+
type TranslationProviderProps
|
|
23
|
+
} from './translation/forward-exports'
|
|
12
24
|
|
|
13
25
|
export type HightideProviderProps = PropsWithChildren & {
|
|
14
26
|
theme?: Omit<ThemeProviderProps, 'children'>,
|
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { SupportedThemesConfig } from '@helpwave/hightide-utils/context'
|
|
2
|
+
|
|
3
|
+
import type { SupportedLocalesConfig } from '../localization/forward-exports'
|
|
4
|
+
import { themes } from '../../theme/themes/nativeThemes'
|
|
5
|
+
import type { Theme } from '../../theme/types/theme'
|
|
3
6
|
|
|
4
7
|
export const HightideConfigUtils = {
|
|
5
|
-
defaultSupportedLocales:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
defaultSupportedThemes:
|
|
10
|
-
{
|
|
11
|
-
theme: 'light',
|
|
8
|
+
defaultSupportedLocales: {
|
|
9
|
+
'de-DE': { localName: 'Deutsch' },
|
|
10
|
+
'en-US': { localName: 'English (US)' },
|
|
11
|
+
} as const satisfies SupportedLocalesConfig,
|
|
12
|
+
defaultSupportedThemes: {
|
|
13
|
+
light: {
|
|
12
14
|
nameTranslations: {
|
|
13
15
|
'de-DE': 'Hell',
|
|
14
16
|
'en-US': 'Light',
|
|
15
17
|
},
|
|
18
|
+
theme: themes.light
|
|
16
19
|
},
|
|
17
|
-
{
|
|
18
|
-
theme: 'dark',
|
|
20
|
+
dark: {
|
|
19
21
|
nameTranslations: {
|
|
20
22
|
'de-DE': 'Dunkel',
|
|
21
23
|
'en-US': 'Dark',
|
|
22
24
|
},
|
|
25
|
+
theme: themes.dark,
|
|
23
26
|
},
|
|
24
|
-
|
|
27
|
+
} as const satisfies SupportedThemesConfig<Theme>,
|
|
25
28
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { PropsWithChildren } from 'react'
|
|
2
|
+
|
|
2
3
|
import {
|
|
3
4
|
LocalizationProvider as LocalizationProviderBase,
|
|
4
5
|
type LocalizationProviderProps as LocalizationProviderPropsBase
|
|
5
6
|
} from '@helpwave/hightide-utils/context/localization'
|
|
6
|
-
|
|
7
|
+
|
|
7
8
|
import { HightideConfigUtils } from '../hightide-config/HightideConfigUtils'
|
|
9
|
+
import { useNativeKeyValueStore } from '../../hooks/useNativeKeyValueStore'
|
|
8
10
|
|
|
9
11
|
export type LocalizationProviderProps = PropsWithChildren
|
|
10
12
|
& Omit<LocalizationProviderPropsBase, 'store' | 'fallbackLocale' | 'supportedLocales'>
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
useContext
|
|
4
|
+
} from 'react'
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
ThemeConfigValue,
|
|
8
|
+
ThemeInformation
|
|
9
|
+
} from './forward-exports'
|
|
10
|
+
import type { Theme } from '../../theme/types/theme'
|
|
4
11
|
|
|
5
12
|
export type { ThemeInformation }
|
|
6
13
|
|
|
7
|
-
export type ThemeContextValue =
|
|
8
|
-
themeMode: ThemeMode,
|
|
9
|
-
theme: DesignTheme,
|
|
14
|
+
export type ThemeContextValue = ThemeConfigValue<Theme> & {
|
|
10
15
|
isInitialized: boolean,
|
|
11
16
|
}
|
|
12
17
|
|
|
@@ -1,25 +1,32 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
useEffect,
|
|
3
|
+
useMemo,
|
|
4
|
+
useState,
|
|
5
|
+
type PropsWithChildren
|
|
6
|
+
} from 'react'
|
|
2
7
|
import { Appearance } from 'react-native'
|
|
3
|
-
|
|
4
|
-
import {
|
|
8
|
+
|
|
9
|
+
import type { SupportedThemesConfig } from '@helpwave/hightide-utils/context'
|
|
10
|
+
|
|
5
11
|
import { HightideConfigUtils } from '../hightide-config/HightideConfigUtils'
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
import {
|
|
13
|
+
ThemeContext,
|
|
14
|
+
useTheme,
|
|
15
|
+
type ThemeContextValue
|
|
16
|
+
} from './ThemeContext'
|
|
17
|
+
import {
|
|
18
|
+
useCreateThemeConfig,
|
|
19
|
+
type SystemTheme
|
|
20
|
+
} from './forward-exports'
|
|
21
|
+
import { useNativeKeyValueStore } from '../../hooks/useNativeKeyValueStore'
|
|
22
|
+
import type { ThemeMode } from '../../theme/themes/nativeThemes'
|
|
23
|
+
import type { Theme } from '../../theme/types/theme'
|
|
9
24
|
|
|
10
|
-
export type ThemeProviderProps = PropsWithChildren & {
|
|
11
|
-
theme?:
|
|
12
|
-
systemTheme?: SystemTheme,
|
|
25
|
+
export type ThemeProviderProps<T> = PropsWithChildren & {
|
|
26
|
+
theme?: ThemeMode | null,
|
|
13
27
|
fallbackTheme?: ThemeMode,
|
|
14
|
-
supportedThemes?:
|
|
15
|
-
onChangedTheme?: (
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const resolveThemeMode = (theme: string): ThemeMode => {
|
|
19
|
-
if (theme in themes) {
|
|
20
|
-
return theme as ThemeMode
|
|
21
|
-
}
|
|
22
|
-
return 'light'
|
|
28
|
+
supportedThemes?: SupportedThemesConfig<T>,
|
|
29
|
+
onChangedTheme?: (themeMode: string) => void,
|
|
23
30
|
}
|
|
24
31
|
|
|
25
32
|
export const useThemeMode = (): ThemeMode => {
|
|
@@ -34,7 +41,7 @@ const detectNativeSystemTheme = (): SystemTheme | undefined => {
|
|
|
34
41
|
return undefined
|
|
35
42
|
}
|
|
36
43
|
|
|
37
|
-
const useNativeSystemTheme = (enabled: boolean) => {
|
|
44
|
+
const useNativeSystemTheme = (enabled: boolean = true) => {
|
|
38
45
|
const [systemTheme, setSystemTheme] = useState<SystemTheme | undefined>(() =>
|
|
39
46
|
(enabled ? detectNativeSystemTheme() : undefined))
|
|
40
47
|
|
|
@@ -57,13 +64,11 @@ export const ThemeProvider = ({
|
|
|
57
64
|
children,
|
|
58
65
|
theme,
|
|
59
66
|
fallbackTheme = 'light',
|
|
60
|
-
systemTheme: systemThemeOverride,
|
|
61
67
|
supportedThemes = HightideConfigUtils.defaultSupportedThemes,
|
|
62
68
|
onChangedTheme,
|
|
63
|
-
}: ThemeProviderProps) => {
|
|
69
|
+
}: ThemeProviderProps<Theme>) => {
|
|
64
70
|
const store = useNativeKeyValueStore()
|
|
65
|
-
const
|
|
66
|
-
const systemTheme = systemThemeOverride ?? detectedSystemTheme
|
|
71
|
+
const systemTheme = useNativeSystemTheme()
|
|
67
72
|
|
|
68
73
|
const themeConfig = useCreateThemeConfig({
|
|
69
74
|
store,
|
|
@@ -74,27 +79,19 @@ export const ThemeProvider = ({
|
|
|
74
79
|
onChangedTheme,
|
|
75
80
|
})
|
|
76
81
|
|
|
77
|
-
const
|
|
78
|
-
const themeMode = resolveThemeMode(themeConfig.theme)
|
|
79
|
-
|
|
82
|
+
const contextValue = useMemo((): ThemeContextValue => {
|
|
80
83
|
return {
|
|
81
|
-
|
|
84
|
+
preferredThemeMode: themeConfig.preferredThemeMode,
|
|
82
85
|
setTheme: themeConfig.setTheme,
|
|
83
86
|
supportedThemes: themeConfig.supportedThemes,
|
|
84
|
-
themeMode,
|
|
85
|
-
theme:
|
|
87
|
+
themeMode: themeConfig.themeMode,
|
|
88
|
+
theme: themeConfig.theme,
|
|
86
89
|
isInitialized: store.isInitialized,
|
|
87
90
|
}
|
|
88
|
-
}, [
|
|
89
|
-
store.isInitialized,
|
|
90
|
-
themeConfig.preferredTheme,
|
|
91
|
-
themeConfig.setTheme,
|
|
92
|
-
themeConfig.supportedThemes,
|
|
93
|
-
themeConfig.theme,
|
|
94
|
-
])
|
|
91
|
+
}, [store.isInitialized, themeConfig.preferredThemeMode, themeConfig.setTheme, themeConfig.supportedThemes, themeConfig.theme, themeConfig.themeMode])
|
|
95
92
|
|
|
96
93
|
return (
|
|
97
|
-
<ThemeContext.Provider value={
|
|
94
|
+
<ThemeContext.Provider value={contextValue}>
|
|
98
95
|
{children}
|
|
99
96
|
</ThemeContext.Provider>
|
|
100
97
|
)
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
useEffect,
|
|
3
|
+
useMemo,
|
|
4
|
+
useRef,
|
|
5
|
+
useState
|
|
6
|
+
} from 'react'
|
|
2
7
|
import AsyncStorage from '@react-native-async-storage/async-storage'
|
|
8
|
+
|
|
3
9
|
import type { SimpleValueStore } from '@helpwave/hightide-utils/hooks'
|
|
4
10
|
|
|
5
11
|
const storagePrefix = '@helpwave/hightide/'
|