@retray-dev/ui-kit 1.8.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.
@@ -83,15 +83,22 @@ export function Toggle({
83
83
  return prop
84
84
  }
85
85
 
86
- if (!pressed) return renderProp(icon)
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 active = renderProp(activeIcon)
89
- if (active) return <>{active}</>
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.primary }]}>
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/Alert'
16
+ export * from './components/AlertBanner'
17
17
  export * from './components/Progress'
18
18
  export * from './components/EmptyState'
19
19
  export * from './components/Textarea'
@@ -29,7 +29,8 @@ export * from './components/Select'
29
29
  export * from './components/Toast'
30
30
  export * from './components/CurrencyInput'
31
31
  export * from './components/CurrencyDisplay'
32
- export * from './components/CurrencyInputLarge'
32
+ // CurrencyInputLarge is deprecated — use <CurrencyInput size="large" /> instead
33
+ export { CurrencyInput as CurrencyInputLarge } from './components/CurrencyInput'
33
34
  export * from './components/ListItem'
34
35
  export * from './components/Chip'
35
36
  export * from './components/ConfirmDialog'
@@ -11,11 +11,10 @@ const ThemeContext = createContext<ThemeContextValue>({
11
11
  export interface ThemeProviderProps {
12
12
  children: React.ReactNode
13
13
  /**
14
- * Override individual color tokens per scheme. Only provide the tokens you want
15
- * to change the rest fall back to the defaults.
16
- * @example
17
- * { light: { primary: '#6366f1', primaryForeground: '#fff' },
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 overrides = resolvedScheme === 'dark' ? theme?.dark : theme?.light
35
- return { ...base, ...overrides }
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
- return useContext(ThemeContext)
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
  }
@@ -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: '#fafafa',
10
- secondary: '#f5f5f5',
11
- secondaryForeground: '#1a1a1a',
12
- muted: '#f5f5f5',
13
- mutedForeground: '#646464',
14
- accent: '#f5f5f5',
15
- accentForeground: '#1a1a1a',
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: '#fafafa',
18
+ destructiveForeground: '#1a1a1a',
18
19
  border: '#e5e5e5',
19
20
  input: '#e5e5e5',
20
- ring: '#a3a3a3',
21
+ ring: '#1a1a1a',
21
22
  success: '#16a34a',
22
- successForeground: '#ffffff',
23
+ successForeground: '#1a1a1a',
23
24
  }
24
25
 
25
26
  export const defaultDark: ThemeColors = {
26
27
  background: '#171717',
27
28
  foreground: '#fafafa',
28
- card: '#1f1f1f',
29
+ card: '#222222',
29
30
  cardForeground: '#fafafa',
30
31
  primary: '#fafafa',
31
32
  primaryForeground: '#1a1a1a',
32
- secondary: '#2a2a2a',
33
+ secondary: '#323232',
33
34
  secondaryForeground: '#fafafa',
34
- muted: '#2a2a2a',
35
- mutedForeground: '#a3a3a3',
36
- accent: '#2a2a2a',
35
+ muted: '#323232',
36
+ mutedForeground: '#888888',
37
+ accent: '#323232',
37
38
  accentForeground: '#fafafa',
38
39
  destructive: '#dc2626',
39
- destructiveForeground: '#fafafa',
40
+ destructiveForeground: '#1a1a1a',
40
41
  border: '#2a2a2a',
41
42
  input: '#2a2a2a',
42
- ring: '#d4d4d4',
43
+ ring: '#fafafa',
43
44
  success: '#22c55e',
44
- successForeground: '#ffffff',
45
+ successForeground: '#1a1a1a',
45
46
  }
@@ -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'