@retray-dev/ui-kit 1.7.0 → 2.3.0
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/COMPONENTS.md +258 -54
- package/README.md +6 -5
- package/dist/index.d.mts +113 -44
- package/dist/index.d.ts +113 -44
- package/dist/index.js +802 -324
- package/dist/index.mjs +794 -323
- package/package.json +6 -2
- package/src/components/Alert/Alert.tsx +24 -12
- package/src/components/AlertBanner/AlertBanner.tsx +83 -0
- package/src/components/AlertBanner/index.ts +2 -0
- package/src/components/Avatar/Avatar.tsx +1 -0
- package/src/components/Badge/Badge.tsx +44 -8
- package/src/components/Button/Button.tsx +12 -5
- package/src/components/Card/Card.tsx +86 -9
- package/src/components/Chip/Chip.tsx +173 -0
- package/src/components/Chip/index.ts +2 -0
- package/src/components/ConfirmDialog/ConfirmDialog.tsx +87 -0
- package/src/components/ConfirmDialog/index.ts +2 -0
- package/src/components/CurrencyDisplay/CurrencyDisplay.tsx +4 -2
- package/src/components/CurrencyInput/CurrencyInput.tsx +9 -1
- package/src/components/EmptyState/EmptyState.tsx +42 -7
- package/src/components/Input/Input.tsx +102 -21
- package/src/components/LabelValue/LabelValue.tsx +47 -0
- package/src/components/LabelValue/index.ts +2 -0
- package/src/components/ListItem/ListItem.tsx +121 -0
- package/src/components/ListItem/index.ts +2 -0
- package/src/components/MonthPicker/MonthPicker.tsx +92 -0
- package/src/components/MonthPicker/index.ts +2 -0
- package/src/components/Select/Select.tsx +189 -125
- package/src/components/Slider/Slider.tsx +64 -100
- package/src/components/Switch/Switch.tsx +25 -21
- package/src/components/Textarea/Textarea.tsx +12 -2
- package/src/components/Toggle/Toggle.tsx +13 -6
- package/src/index.ts +8 -2
- package/src/theme/ThemeProvider.tsx +11 -8
- package/src/theme/colors.ts +19 -18
- package/src/theme/types.ts +2 -0
- package/src/components/Alert/index.ts +0 -2
- package/src/components/CurrencyInputLarge/CurrencyInputLarge.tsx +0 -66
- package/src/components/CurrencyInputLarge/index.ts +0 -1
|
@@ -83,15 +83,22 @@ export function Toggle({
|
|
|
83
83
|
return prop
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
if (
|
|
86
|
+
if (pressed) {
|
|
87
|
+
const active = renderProp(activeIcon)
|
|
88
|
+
if (active) return <>{active}</>
|
|
89
|
+
return (
|
|
90
|
+
<View style={[styles.checkContainer, { borderColor: colors.primary, backgroundColor: colors.primary }]}>
|
|
91
|
+
<Text style={[styles.checkMark, { color: colors.primaryForeground }]}>✓</Text>
|
|
92
|
+
</View>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
87
95
|
|
|
88
|
-
const
|
|
89
|
-
if (
|
|
96
|
+
const custom = renderProp(icon)
|
|
97
|
+
if (custom) return <>{custom}</>
|
|
90
98
|
|
|
99
|
+
// Default: empty circle to signal an action is available
|
|
91
100
|
return (
|
|
92
|
-
<View style={[styles.checkContainer, { borderColor: colors.
|
|
93
|
-
<Text style={[styles.checkMark, { color: colors.primary }]}>✓</Text>
|
|
94
|
-
</View>
|
|
101
|
+
<View style={[styles.checkContainer, { borderColor: colors.mutedForeground }]} />
|
|
95
102
|
)
|
|
96
103
|
}
|
|
97
104
|
|
package/src/index.ts
CHANGED
|
@@ -13,7 +13,7 @@ export * from './components/Separator'
|
|
|
13
13
|
export * from './components/Spinner'
|
|
14
14
|
export * from './components/Skeleton'
|
|
15
15
|
export * from './components/Avatar'
|
|
16
|
-
export * from './components/
|
|
16
|
+
export * from './components/AlertBanner'
|
|
17
17
|
export * from './components/Progress'
|
|
18
18
|
export * from './components/EmptyState'
|
|
19
19
|
export * from './components/Textarea'
|
|
@@ -29,4 +29,10 @@ export * from './components/Select'
|
|
|
29
29
|
export * from './components/Toast'
|
|
30
30
|
export * from './components/CurrencyInput'
|
|
31
31
|
export * from './components/CurrencyDisplay'
|
|
32
|
-
|
|
32
|
+
// CurrencyInputLarge is deprecated — use <CurrencyInput size="large" /> instead
|
|
33
|
+
export { CurrencyInput as CurrencyInputLarge } from './components/CurrencyInput'
|
|
34
|
+
export * from './components/ListItem'
|
|
35
|
+
export * from './components/Chip'
|
|
36
|
+
export * from './components/ConfirmDialog'
|
|
37
|
+
export * from './components/LabelValue'
|
|
38
|
+
export * from './components/MonthPicker'
|
|
@@ -11,11 +11,10 @@ const ThemeContext = createContext<ThemeContextValue>({
|
|
|
11
11
|
export interface ThemeProviderProps {
|
|
12
12
|
children: React.ReactNode
|
|
13
13
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* dark: { primary: '#818cf8', primaryForeground: '#fff' } }
|
|
14
|
+
* Optional full-palette overrides per scheme. Supply a partial or full `ThemeColors` object
|
|
15
|
+
* for `light` and/or `dark` to override the defaults.
|
|
16
|
+
* @example
|
|
17
|
+
* { light: { primary: '#6366f1', card: '#fff' }, dark: { primary: '#818cf8' } }
|
|
19
18
|
*/
|
|
20
19
|
theme?: Theme
|
|
21
20
|
/**
|
|
@@ -31,8 +30,8 @@ export function ThemeProvider({ children, theme, colorScheme = 'system' }: Theme
|
|
|
31
30
|
|
|
32
31
|
const colors = useMemo<ThemeColors>(() => {
|
|
33
32
|
const base = resolvedScheme === 'dark' ? defaultDark : defaultLight
|
|
34
|
-
const
|
|
35
|
-
return { ...base, ...
|
|
33
|
+
const override = resolvedScheme === 'dark' ? theme?.dark : theme?.light
|
|
34
|
+
return override ? { ...base, ...override } : base
|
|
36
35
|
}, [resolvedScheme, theme])
|
|
37
36
|
|
|
38
37
|
return (
|
|
@@ -43,5 +42,9 @@ export function ThemeProvider({ children, theme, colorScheme = 'system' }: Theme
|
|
|
43
42
|
}
|
|
44
43
|
|
|
45
44
|
export function useTheme(): ThemeContextValue {
|
|
46
|
-
|
|
45
|
+
const context = useContext(ThemeContext)
|
|
46
|
+
if (!context) {
|
|
47
|
+
throw new Error('useTheme must be used within a ThemeProvider')
|
|
48
|
+
}
|
|
49
|
+
return context
|
|
47
50
|
}
|
package/src/theme/colors.ts
CHANGED
|
@@ -1,45 +1,46 @@
|
|
|
1
1
|
import { ThemeColors } from './types'
|
|
2
2
|
|
|
3
|
+
// Full, explicit theme palettes. No derivation — palettes are direct and fully customizable.
|
|
3
4
|
export const defaultLight: ThemeColors = {
|
|
4
5
|
background: '#ffffff',
|
|
5
6
|
foreground: '#171717',
|
|
6
7
|
card: '#ffffff',
|
|
7
8
|
cardForeground: '#171717',
|
|
8
9
|
primary: '#1a1a1a',
|
|
9
|
-
primaryForeground: '#
|
|
10
|
-
secondary: '#
|
|
11
|
-
secondaryForeground: '#
|
|
12
|
-
muted: '#
|
|
13
|
-
mutedForeground: '#
|
|
14
|
-
accent: '#
|
|
15
|
-
accentForeground: '#
|
|
10
|
+
primaryForeground: '#ffffff',
|
|
11
|
+
secondary: '#f1f1f1',
|
|
12
|
+
secondaryForeground: '#171717',
|
|
13
|
+
muted: '#f1f1f1',
|
|
14
|
+
mutedForeground: '#a2a2a2',
|
|
15
|
+
accent: '#e4e4e4',
|
|
16
|
+
accentForeground: '#171717',
|
|
16
17
|
destructive: '#ef4444',
|
|
17
|
-
destructiveForeground: '#
|
|
18
|
+
destructiveForeground: '#1a1a1a',
|
|
18
19
|
border: '#e5e5e5',
|
|
19
20
|
input: '#e5e5e5',
|
|
20
|
-
ring: '#
|
|
21
|
+
ring: '#1a1a1a',
|
|
21
22
|
success: '#16a34a',
|
|
22
|
-
successForeground: '#
|
|
23
|
+
successForeground: '#1a1a1a',
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
export const defaultDark: ThemeColors = {
|
|
26
27
|
background: '#171717',
|
|
27
28
|
foreground: '#fafafa',
|
|
28
|
-
card: '#
|
|
29
|
+
card: '#222222',
|
|
29
30
|
cardForeground: '#fafafa',
|
|
30
31
|
primary: '#fafafa',
|
|
31
32
|
primaryForeground: '#1a1a1a',
|
|
32
|
-
secondary: '#
|
|
33
|
+
secondary: '#323232',
|
|
33
34
|
secondaryForeground: '#fafafa',
|
|
34
|
-
muted: '#
|
|
35
|
-
mutedForeground: '#
|
|
36
|
-
accent: '#
|
|
35
|
+
muted: '#323232',
|
|
36
|
+
mutedForeground: '#888888',
|
|
37
|
+
accent: '#323232',
|
|
37
38
|
accentForeground: '#fafafa',
|
|
38
39
|
destructive: '#dc2626',
|
|
39
|
-
destructiveForeground: '#
|
|
40
|
+
destructiveForeground: '#1a1a1a',
|
|
40
41
|
border: '#2a2a2a',
|
|
41
42
|
input: '#2a2a2a',
|
|
42
|
-
ring: '#
|
|
43
|
+
ring: '#fafafa',
|
|
43
44
|
success: '#22c55e',
|
|
44
|
-
successForeground: '#
|
|
45
|
+
successForeground: '#1a1a1a',
|
|
45
46
|
}
|
package/src/theme/types.ts
CHANGED
|
@@ -20,6 +20,8 @@ export type ThemeColors = {
|
|
|
20
20
|
successForeground: string
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
// Theme overrides: consumers may supply partial or full `ThemeColors` objects
|
|
24
|
+
// for `theme.light` / `theme.dark` to override only the tokens they want.
|
|
23
25
|
export type Theme = {
|
|
24
26
|
light?: Partial<ThemeColors>
|
|
25
27
|
dark?: Partial<ThemeColors>
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { ViewStyle } from 'react-native'
|
|
3
|
-
import { Input } from '../Input'
|
|
4
|
-
|
|
5
|
-
export interface CurrencyInputLargeProps {
|
|
6
|
-
value?: string
|
|
7
|
-
onChangeText?: (formatted: string) => void
|
|
8
|
-
/** Called with the parsed numeric value (no separators, no prefix). */
|
|
9
|
-
onChangeValue?: (raw: number) => void
|
|
10
|
-
/** Symbol prepended to the formatted value. Defaults to `'$'`. */
|
|
11
|
-
prefix?: string
|
|
12
|
-
/** Character used to separate groups of three digits. Defaults to `'.'`. */
|
|
13
|
-
thousandsSeparator?: '.' | ','
|
|
14
|
-
label?: string
|
|
15
|
-
/** Red helper text; also changes input border to destructive color. */
|
|
16
|
-
error?: string
|
|
17
|
-
hint?: string
|
|
18
|
-
placeholder?: string
|
|
19
|
-
editable?: boolean
|
|
20
|
-
containerStyle?: ViewStyle
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function formatCurrency(raw: string, separator: '.' | ','): string {
|
|
24
|
-
const digits = raw.replace(/\D/g, '')
|
|
25
|
-
if (!digits) return ''
|
|
26
|
-
return digits.replace(/\B(?=(\d{3})+(?!\d))/g, separator)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function CurrencyInputLarge({
|
|
30
|
-
value,
|
|
31
|
-
onChangeText,
|
|
32
|
-
onChangeValue,
|
|
33
|
-
prefix = '$',
|
|
34
|
-
thousandsSeparator = '.',
|
|
35
|
-
label,
|
|
36
|
-
error,
|
|
37
|
-
hint,
|
|
38
|
-
placeholder,
|
|
39
|
-
editable,
|
|
40
|
-
containerStyle,
|
|
41
|
-
}: CurrencyInputLargeProps) {
|
|
42
|
-
const handleChange = (text: string) => {
|
|
43
|
-
const withoutPrefix = prefix && text.startsWith(prefix) ? text.slice(prefix.length) : text
|
|
44
|
-
const formatted = formatCurrency(withoutPrefix, thousandsSeparator)
|
|
45
|
-
const display = formatted ? `${prefix}${formatted}` : ''
|
|
46
|
-
onChangeText?.(display)
|
|
47
|
-
const separatorRegex = new RegExp(`\\${thousandsSeparator}`, 'g')
|
|
48
|
-
const raw = parseFloat(formatted.replace(separatorRegex, '') || '0')
|
|
49
|
-
onChangeValue?.(isNaN(raw) ? 0 : raw)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return (
|
|
53
|
-
<Input
|
|
54
|
-
value={value}
|
|
55
|
-
onChangeText={handleChange}
|
|
56
|
-
keyboardType="numeric"
|
|
57
|
-
label={label}
|
|
58
|
-
error={error}
|
|
59
|
-
hint={hint}
|
|
60
|
-
placeholder={placeholder ?? `${prefix}0`}
|
|
61
|
-
editable={editable}
|
|
62
|
-
containerStyle={containerStyle}
|
|
63
|
-
style={{ fontSize: 36 }}
|
|
64
|
-
/>
|
|
65
|
-
)
|
|
66
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './CurrencyInputLarge'
|