@controleonline/ui-common 1.2.70

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.
Files changed (203) hide show
  1. package/.github/agents/developer.agent.md +30 -0
  2. package/.github/agents/devops.agent.md +30 -0
  3. package/.github/agents/qa.agent.md +30 -0
  4. package/.github/agents/security.agent.md +30 -0
  5. package/.github/workflows/npmjs.yml +35 -0
  6. package/.github/workflows/pull-request-checks.yml +19 -0
  7. package/.scrutinizer.yml +24 -0
  8. package/FUNDING.yml +1 -0
  9. package/package.json +28 -0
  10. package/src/api/fetch.js +74 -0
  11. package/src/api/index.js +155 -0
  12. package/src/api/localDB.js +131 -0
  13. package/src/api/queue.js +66 -0
  14. package/src/react/assets/tap.mp3 +0 -0
  15. package/src/react/components/AddImportModal.js +157 -0
  16. package/src/react/components/AddImportModal.styles.js +81 -0
  17. package/src/react/components/BackgroundRuntimeBridge.js +219 -0
  18. package/src/react/components/BottomNavigationBar.config.js +238 -0
  19. package/src/react/components/BottomNavigationBar.js +120 -0
  20. package/src/react/components/BottomNavigationBar.styles.js +110 -0
  21. package/src/react/components/CategoryForm.js +572 -0
  22. package/src/react/components/CategoryForm.styles.js +334 -0
  23. package/src/react/components/ConfirmModal.js +24 -0
  24. package/src/react/components/ConfirmModal.styles.js +43 -0
  25. package/src/react/components/ContextHelpButton.js +69 -0
  26. package/src/react/components/ContextHelpButton.styles.js +62 -0
  27. package/src/react/components/DefaultProvider.native.js +848 -0
  28. package/src/react/components/DefaultProvider.styles.js +21 -0
  29. package/src/react/components/DefaultProvider.web.js +909 -0
  30. package/src/react/components/DeliveryPushBridge.native.js +314 -0
  31. package/src/react/components/DeliveryPushBridge.web.js +5 -0
  32. package/src/react/components/DeviceAlertSoundService.js +499 -0
  33. package/src/react/components/EntityLogContent.js +909 -0
  34. package/src/react/components/EntityLogContent.styles.js +400 -0
  35. package/src/react/components/EventBus.js +12 -0
  36. package/src/react/components/KioskModeBridge.js +65 -0
  37. package/src/react/components/LauncherModeBridge.js +47 -0
  38. package/src/react/components/LinkedOrderProductsTab.js +388 -0
  39. package/src/react/components/LinkedOrderProductsTab.styles.js +180 -0
  40. package/src/react/components/ManagerPushBridge.native.js +345 -0
  41. package/src/react/components/MessageService.js +314 -0
  42. package/src/react/components/Paywall/Google.js +89 -0
  43. package/src/react/components/PrintService.js +778 -0
  44. package/src/react/components/ProductCatalogCacheService.js +45 -0
  45. package/src/react/components/RemoteCheckoutService.js +292 -0
  46. package/src/react/components/RuntimeBottomNavigationBar.js +151 -0
  47. package/src/react/components/RuntimeInfoFooter.js +214 -0
  48. package/src/react/components/RuntimeInfoFooter.styles.js +56 -0
  49. package/src/react/components/SystemErrorToast.js +29 -0
  50. package/src/react/components/SystemErrorToast.styles.js +38 -0
  51. package/src/react/components/TouchFeedbackProvider.js +65 -0
  52. package/src/react/components/UnifiedPaymentBar.js +155 -0
  53. package/src/react/components/UnifiedPaymentBar.styles.js +174 -0
  54. package/src/react/components/WebsocketListener.native.js +487 -0
  55. package/src/react/components/WebsocketListener.web.js +102 -0
  56. package/src/react/components/inputs/IdInput.js +49 -0
  57. package/src/react/components/inputs/IdInput.styles.js +26 -0
  58. package/src/react/components/inputs/InvoiceDueDateFilterInput.js +74 -0
  59. package/src/react/components/inputs/InvoiceDueDateFilterInput.styles.js +34 -0
  60. package/src/react/components/inputs/InvoiceDueDateRangeFilterInput.js +115 -0
  61. package/src/react/components/inputs/InvoiceDueDateRangeFilterInput.styles.js +39 -0
  62. package/src/react/components/lists/CategoriesList.js +56 -0
  63. package/src/react/components/lists/PaymentTypeList.js +55 -0
  64. package/src/react/components/lists/ReceiverList.js +56 -0
  65. package/src/react/components/lists/SelectList.styles.js +18 -0
  66. package/src/react/components/lists/StatusList.js +55 -0
  67. package/src/react/components/lists/WalletList.js +54 -0
  68. package/src/react/components/radio/Spotify.js +144 -0
  69. package/src/react/components/radio/Spotify.styles.js +32 -0
  70. package/src/react/components/radio/YouTube.js +82 -0
  71. package/src/react/components/radio/YouTube.styles.js +16 -0
  72. package/src/react/components/toastConfig.js +16 -0
  73. package/src/react/config/deviceConfigBootstrap.js +571 -0
  74. package/src/react/index.js +4 -0
  75. package/src/react/localStorage.js +30 -0
  76. package/src/react/pages/EntityLogPage.js +124 -0
  77. package/src/react/pages/EntityLogPage.styles.js +17 -0
  78. package/src/react/pages/GenericLogPage.js +760 -0
  79. package/src/react/pages/GenericLogPage.styles.js +401 -0
  80. package/src/react/pages/Imports.js +361 -0
  81. package/src/react/pages/Imports.styles.js +223 -0
  82. package/src/react/pages/SettingsPage/PaymentTypesByWalletTab.js +462 -0
  83. package/src/react/pages/SettingsPage/index.js +1171 -0
  84. package/src/react/pages/SettingsPage/index.styles.js +122 -0
  85. package/src/react/print/jobs.js +147 -0
  86. package/src/react/print/providers/local.js +53 -0
  87. package/src/react/print/providers/remote.js +81 -0
  88. package/src/react/print/selection.js +296 -0
  89. package/src/react/print/usePrintButtonController.js +474 -0
  90. package/src/react/router/routes.js +42 -0
  91. package/src/react/services/NetworkPrinterService.native.js +391 -0
  92. package/src/react/services/NetworkPrinterService.web.js +15 -0
  93. package/src/react/stores/index.js +128 -0
  94. package/src/react/stores/storeErrorBridge.js +36 -0
  95. package/src/react/utils/backgroundRuntimeRegistration.js +69 -0
  96. package/src/react/utils/cashPayment.js +87 -0
  97. package/src/react/utils/commercialDocumentOrders.js +269 -0
  98. package/src/react/utils/dateRangeFilter.js +264 -0
  99. package/src/react/utils/deviceRuntime.js +193 -0
  100. package/src/react/utils/entityDisplay.js +231 -0
  101. package/src/react/utils/entityLog.js +649 -0
  102. package/src/react/utils/fileUrl.js +102 -0
  103. package/src/react/utils/frontendDebugLog.js +45 -0
  104. package/src/react/utils/googleMapsConfig.js +49 -0
  105. package/src/react/utils/importStatus.js +100 -0
  106. package/src/react/utils/invoiceDueDateMessages.js +14 -0
  107. package/src/react/utils/invoicePresentation.js +46 -0
  108. package/src/react/utils/logSettings.js +143 -0
  109. package/src/react/utils/maintenanceSettings.js +53 -0
  110. package/src/react/utils/managerOrderNotifications.js +523 -0
  111. package/src/react/utils/mapNavigation.js +76 -0
  112. package/src/react/utils/menuCatalogConfig.js +8 -0
  113. package/src/react/utils/menuCatalogDownload.js +157 -0
  114. package/src/react/utils/networkCameraDevices.js +175 -0
  115. package/src/react/utils/networkDeviceProfiles.js +135 -0
  116. package/src/react/utils/normalizedCatalogDownload.js +157 -0
  117. package/src/react/utils/notificationNavigation.js +94 -0
  118. package/src/react/utils/notificationSound.js +42 -0
  119. package/src/react/utils/paymentDevices.js +397 -0
  120. package/src/react/utils/paymentGatewayExecution.js +91 -0
  121. package/src/react/utils/paymentOptions.js +88 -0
  122. package/src/react/utils/peopleDisplay.js +39 -0
  123. package/src/react/utils/printerDevices.js +465 -0
  124. package/src/react/utils/remotePayment.js +61 -0
  125. package/src/react/utils/runtimeFooter.js +475 -0
  126. package/src/react/utils/runtimeLanguage.js +50 -0
  127. package/src/react/utils/runtimeMenu.js +224 -0
  128. package/src/react/utils/screenMetrics.js +30 -0
  129. package/src/react/utils/shopConfig.js +294 -0
  130. package/src/react/utils/shopFranchises.js +114 -0
  131. package/src/react/utils/socketRuntimePipeline.js +454 -0
  132. package/src/react/utils/spoolAckTracker.js +77 -0
  133. package/src/react/utils/storeColumns.js +427 -0
  134. package/src/react/utils/systemErrorChannel.js +109 -0
  135. package/src/react/utils/systemErrorMessage.js +67 -0
  136. package/src/react/utils/toastPresentation.js +53 -0
  137. package/src/react/utils/websocketSharedRuntime.js +826 -0
  138. package/src/store/acl/getters.js +4 -0
  139. package/src/store/acl/index.js +19 -0
  140. package/src/store/acl/mutation_types.js +4 -0
  141. package/src/store/acl/mutations.js +17 -0
  142. package/src/store/address/city.js +22 -0
  143. package/src/store/categories/category_file/index.js +25 -0
  144. package/src/store/categories/index.js +93 -0
  145. package/src/store/configs/customActions.js +131 -0
  146. package/src/store/configs/index.js +25 -0
  147. package/src/store/connections/customActions.js +26 -0
  148. package/src/store/connections/index.js +124 -0
  149. package/src/store/device/index.js +22 -0
  150. package/src/store/device_config/customActions.js +190 -0
  151. package/src/store/device_config/index.js +28 -0
  152. package/src/store/entity_log/customActions.js +63 -0
  153. package/src/store/entity_log/index.js +25 -0
  154. package/src/store/extra/data.js +85 -0
  155. package/src/store/extra/fields.js +88 -0
  156. package/src/store/file/actions.js +27 -0
  157. package/src/store/file/index.js +24 -0
  158. package/src/store/imports/index.js +88 -0
  159. package/src/store/print/customActions.js +251 -0
  160. package/src/store/print/index.js +28 -0
  161. package/src/store/printer/customActions.js +54 -0
  162. package/src/store/printer/index.js +26 -0
  163. package/src/store/runtime_debug/customActions.js +71 -0
  164. package/src/store/runtime_debug/index.js +30 -0
  165. package/src/store/status/index.js +65 -0
  166. package/src/store/timezones/index.js +43 -0
  167. package/src/store/websocket/customActions.js +24 -0
  168. package/src/store/websocket/index.js +28 -0
  169. package/src/tests/react/components/LauncherModeBridge.test.js +93 -0
  170. package/src/tests/react/config/deviceConfigBootstrap.test.js +337 -0
  171. package/src/tests/react/print/localPrintProvider.test.js +45 -0
  172. package/src/tests/react/utils/backgroundRuntimeRegistration.test.js +123 -0
  173. package/src/tests/react/utils/cashPayment.test.js +41 -0
  174. package/src/tests/react/utils/dateRangeFilter.test.mjs +29 -0
  175. package/src/tests/react/utils/entityDisplay.test.js +18 -0
  176. package/src/tests/react/utils/googleMapsConfig.test.js +32 -0
  177. package/src/tests/react/utils/importStatus.test.js +85 -0
  178. package/src/tests/react/utils/invoicePresentation.test.mjs +40 -0
  179. package/src/tests/react/utils/managerOrderNotifications.test.js +127 -0
  180. package/src/tests/react/utils/mapNavigation.test.js +58 -0
  181. package/src/tests/react/utils/notificationNavigation.test.js +39 -0
  182. package/src/tests/react/utils/notificationSound.test.js +27 -0
  183. package/src/tests/react/utils/paymentDevices.test.js +88 -0
  184. package/src/tests/react/utils/runtimeFooter.test.js +429 -0
  185. package/src/tests/react/utils/runtimeLanguage.test.js +80 -0
  186. package/src/tests/react/utils/runtimeMenu.test.js +174 -0
  187. package/src/tests/react/utils/shopFranchises.test.js +82 -0
  188. package/src/tests/react/utils/socketRuntimePipeline.test.js +124 -0
  189. package/src/tests/react/utils/spoolAckTracker.test.js +40 -0
  190. package/src/tests/react/utils/storeErrorBridge.test.js +66 -0
  191. package/src/tests/react/utils/systemErrorChannel.test.js +58 -0
  192. package/src/tests/react/utils/systemErrorMessage.test.js +59 -0
  193. package/src/tests/react/utils/toastPresentation.test.js +75 -0
  194. package/src/tests/react/utils/translate.test.mjs +396 -0
  195. package/src/tests/react/utils/websocketSharedRuntime.test.js +245 -0
  196. package/src/utils/apiEntryPoint.js +31 -0
  197. package/src/utils/appDomain.js +50 -0
  198. package/src/utils/config.js +14 -0
  199. package/src/utils/formatter.js +419 -0
  200. package/src/utils/integrationConfigs.js +79 -0
  201. package/src/utils/methods.js +23 -0
  202. package/src/utils/oauth.js +42 -0
  203. package/src/utils/translate.js +620 -0
@@ -0,0 +1,56 @@
1
+ import { StyleSheet } from 'react-native'
2
+
3
+ const styles = StyleSheet.create({
4
+ shell: {
5
+ width: '100%',
6
+ },
7
+ container: {
8
+ minHeight: 22,
9
+ borderTopWidth: StyleSheet.hairlineWidth,
10
+ justifyContent: 'center',
11
+ paddingHorizontal: 16,
12
+ paddingVertical: 4,
13
+ },
14
+ containerExpanded: {
15
+ paddingVertical: 6,
16
+ },
17
+ primaryRow: {
18
+ flexDirection: 'row',
19
+ alignItems: 'center',
20
+ justifyContent: 'center',
21
+ },
22
+ statusDotWrap: {
23
+ minWidth: 22,
24
+ marginRight: 8,
25
+ alignItems: 'center',
26
+ justifyContent: 'center',
27
+ },
28
+ loadingWrap: {
29
+ minWidth: 22,
30
+ marginLeft: 8,
31
+ alignItems: 'center',
32
+ justifyContent: 'center',
33
+ },
34
+ statusDot: {
35
+ width: 7,
36
+ height: 7,
37
+ borderRadius: 999,
38
+ flexShrink: 0,
39
+ },
40
+ primaryText: {
41
+ flex: 1,
42
+ fontSize: 10,
43
+ lineHeight: 12,
44
+ textAlign: 'center',
45
+ fontWeight: '500',
46
+ },
47
+ debugText: {
48
+ fontSize: 9,
49
+ lineHeight: 11,
50
+ textAlign: 'center',
51
+ fontWeight: '500',
52
+ marginTop: 2,
53
+ },
54
+ })
55
+
56
+ export default styles
@@ -0,0 +1,29 @@
1
+ import React, {useMemo} from 'react';
2
+ import {Text, View} from 'react-native';
3
+ import Icon from 'react-native-vector-icons/MaterialIcons';
4
+
5
+ import styles from './SystemErrorToast.styles';
6
+ import {resolveSystemErrorMessage} from '@controleonline/ui-common/src/react/utils/systemErrorMessage';
7
+
8
+ const SystemErrorToast = ({error}) => {
9
+ const message = useMemo(() => resolveSystemErrorMessage(error), [error]);
10
+
11
+ if (!message) {
12
+ return null;
13
+ }
14
+
15
+ return (
16
+ <View style={styles.container}>
17
+ <View style={styles.header}>
18
+ <View style={styles.iconWrap}>
19
+ <Icon name="error-outline" size={16} color="#DC2626" />
20
+ </View>
21
+ </View>
22
+ <View style={styles.copyWrap}>
23
+ <Text style={styles.text}>{message}</Text>
24
+ </View>
25
+ </View>
26
+ );
27
+ };
28
+
29
+ export default SystemErrorToast;
@@ -0,0 +1,38 @@
1
+ import {StyleSheet} from 'react-native';
2
+
3
+ const styles = StyleSheet.create({
4
+ container: {
5
+ flex: 1,
6
+ flexDirection: 'row',
7
+ alignItems: 'flex-start',
8
+ gap: 12,
9
+ paddingVertical: 2,
10
+ },
11
+ header: {
12
+ paddingTop: 1,
13
+ },
14
+ iconWrap: {
15
+ width: 26,
16
+ height: 26,
17
+ borderRadius: 13,
18
+ backgroundColor: '#FEE2E2',
19
+ alignItems: 'center',
20
+ justifyContent: 'center',
21
+ flexShrink: 0,
22
+ borderWidth: 1,
23
+ borderColor: '#FCA5A5',
24
+ },
25
+ copyWrap: {
26
+ flex: 1,
27
+ minWidth: 0,
28
+ paddingTop: 2,
29
+ },
30
+ text: {
31
+ color: '#111827',
32
+ fontSize: 13,
33
+ fontWeight: '700',
34
+ lineHeight: 20,
35
+ },
36
+ });
37
+
38
+ export default styles;
@@ -0,0 +1,65 @@
1
+ import React, { createContext, useContext, useEffect, useState } from 'react'
2
+ import { Vibration, Platform, TouchableOpacity, Pressable } from 'react-native'
3
+ import { Audio } from 'expo-audio'
4
+
5
+ const TouchFeedbackContext = createContext({
6
+ soundEnabled: true,
7
+ vibrationEnabled: true,
8
+ })
9
+
10
+ export function useTouchFeedback() {
11
+ return useContext(TouchFeedbackContext)
12
+ }
13
+
14
+ function withFeedback(Component) {
15
+ return function Wrapped(props) {
16
+ const { soundEnabled, vibrationEnabled } = useTouchFeedback()
17
+
18
+ const handlePressIn = async e => {
19
+ if (vibrationEnabled && Platform.OS !== 'web') Vibration.vibrate(10)
20
+
21
+ if (soundEnabled) {
22
+ try {
23
+ const { sound } = await Audio.Sound.createAsync(
24
+ require('../assets/tap.mp3')
25
+ )
26
+ await sound.playAsync()
27
+ sound.unloadAsync()
28
+ } catch (err) {
29
+ console.warn('Erro ao tocar som', err)
30
+ }
31
+ }
32
+
33
+ props.onPressIn?.(e)
34
+ }
35
+
36
+ return <Component {...props} onPressIn={handlePressIn} />
37
+ }
38
+ }
39
+
40
+ if (!global.__touchFeedbackPatched) {
41
+ global.TouchableOpacity = withFeedback(TouchableOpacity)
42
+ global.Pressable = withFeedback(Pressable)
43
+ global.__touchFeedbackPatched = true
44
+ }
45
+
46
+ export default function TouchFeedbackProvider({ children }) {
47
+ const [soundEnabled, setSoundEnabled] = useState(true)
48
+ const [vibrationEnabled, setVibrationEnabled] = useState(true)
49
+
50
+ useEffect(() => {
51
+ try {
52
+ const sound = localStorage.getItem('sound')
53
+ if (sound !== null) setSoundEnabled(sound === 'true')
54
+
55
+ const vibration = localStorage.getItem('vibration')
56
+ if (vibration !== null) setVibrationEnabled(vibration === 'true')
57
+ } catch {}
58
+ }, [])
59
+
60
+ return (
61
+ <TouchFeedbackContext.Provider value={{ soundEnabled, vibrationEnabled }}>
62
+ {children}
63
+ </TouchFeedbackContext.Provider>
64
+ )
65
+ }
@@ -0,0 +1,155 @@
1
+ import React, {useMemo} from 'react';
2
+ import {ActivityIndicator, Text, TouchableOpacity, View} from 'react-native';
3
+ import Icon from 'react-native-vector-icons/MaterialIcons';
4
+
5
+ import Formatter from '@controleonline/ui-common/src/utils/formatter';
6
+
7
+ import createStyles, {resolveActionPalette} from './UnifiedPaymentBar.styles';
8
+
9
+ const getStatusPresentation = (theme, totalAmount, paidAmount, pendingAmount) => {
10
+ if (pendingAmount <= 0.009 && totalAmount > 0) {
11
+ return {
12
+ label: 'Pago',
13
+ color: theme?.success || '#16A34A',
14
+ icon: 'check-circle',
15
+ };
16
+ }
17
+
18
+ if (paidAmount > 0.009) {
19
+ return {
20
+ label: 'Saldo pendente',
21
+ color: theme?.warning || '#D97706',
22
+ icon: 'schedule',
23
+ };
24
+ }
25
+
26
+ return {
27
+ label: 'Aguardando pagamento',
28
+ color: theme?.primary || '#1D4ED8',
29
+ icon: 'payments',
30
+ };
31
+ };
32
+
33
+ const withAlpha = (hex, alpha) => {
34
+ const normalized = String(hex || '').trim();
35
+ if (
36
+ !normalized.startsWith('#') ||
37
+ (normalized.length !== 7 && normalized.length !== 4)
38
+ ) {
39
+ return hex;
40
+ }
41
+
42
+ if (normalized.length === 4) {
43
+ const [r, g, b] = normalized.slice(1).split('');
44
+ return `#${r}${r}${g}${g}${b}${b}${alpha}`;
45
+ }
46
+
47
+ return `${normalized}${alpha}`;
48
+ };
49
+
50
+ export default function UnifiedPaymentBar({
51
+ actions = [],
52
+ bottomOffset = 0,
53
+ paidAmount = 0,
54
+ pendingAmount = 0,
55
+ theme,
56
+ title = '',
57
+ totalAmount = 0,
58
+ }) {
59
+ const styles = useMemo(() => createStyles(theme), [theme]);
60
+ const resolvedTotalAmount = Number(totalAmount || 0);
61
+ const resolvedPaidAmount = Number(paidAmount || 0);
62
+ const resolvedPendingAmount = Math.max(Number(pendingAmount || 0), 0);
63
+ const status = getStatusPresentation(
64
+ theme,
65
+ resolvedTotalAmount,
66
+ resolvedPaidAmount,
67
+ resolvedPendingAmount,
68
+ );
69
+ const visibleActions = Array.isArray(actions) ? actions.filter(Boolean) : [];
70
+
71
+ return (
72
+ <View style={[styles.wrapper, {bottom: bottomOffset + 12}]}>
73
+ <View style={styles.card}>
74
+ <View style={[styles.headerRow, !title && styles.headerRowCompact]}>
75
+ {title ? <Text style={styles.title}>{title}</Text> : null}
76
+ <View
77
+ style={[
78
+ styles.statusBadge,
79
+ {
80
+ borderColor: status.color,
81
+ backgroundColor: withAlpha(status.color, '18'),
82
+ },
83
+ ]}>
84
+ <Icon color={status.color} name={status.icon} size={14} />
85
+ <Text style={[styles.statusText, {color: status.color}]}>
86
+ {status.label}
87
+ </Text>
88
+ </View>
89
+ </View>
90
+
91
+ <View style={styles.metricsRow}>
92
+ <View style={[styles.metricCard, styles.metricCardSingle]}>
93
+ <Text style={styles.metricLabel}>Pendente</Text>
94
+ <Text style={[styles.metricValue, styles.metricValueStrong]}>
95
+ {Formatter.formatMoney(resolvedPendingAmount)}
96
+ </Text>
97
+ </View>
98
+ </View>
99
+
100
+ {visibleActions.length > 0 && (
101
+ <View
102
+ style={[
103
+ styles.actionsRow,
104
+ visibleActions.length === 1 && styles.actionsRowSingle,
105
+ ]}>
106
+ {visibleActions.map(action => {
107
+ const key =
108
+ action?.key ||
109
+ `${action?.label || 'action'}-${action?.variant || 'primary'}`;
110
+ const disabled = !!action?.disabled;
111
+ const palette = resolveActionPalette(
112
+ theme,
113
+ action?.variant || 'primary',
114
+ disabled,
115
+ );
116
+
117
+ return (
118
+ <TouchableOpacity
119
+ key={key}
120
+ disabled={disabled}
121
+ onPress={action?.onPress}
122
+ style={[
123
+ styles.actionButton,
124
+ visibleActions.length === 1 && styles.actionButtonSingle,
125
+ {
126
+ backgroundColor: palette.backgroundColor,
127
+ borderColor: palette.borderColor,
128
+ },
129
+ ]}>
130
+ {action?.loading ? (
131
+ <ActivityIndicator color={palette.textColor} />
132
+ ) : (
133
+ <>
134
+ {action?.icon ? (
135
+ <Icon
136
+ color={palette.textColor}
137
+ name={action.icon}
138
+ size={18}
139
+ />
140
+ ) : null}
141
+ <Text
142
+ style={[styles.actionLabel, {color: palette.textColor}]}>
143
+ {action?.label}
144
+ </Text>
145
+ </>
146
+ )}
147
+ </TouchableOpacity>
148
+ );
149
+ })}
150
+ </View>
151
+ )}
152
+ </View>
153
+ </View>
154
+ );
155
+ }
@@ -0,0 +1,174 @@
1
+ import {StyleSheet} from 'react-native';
2
+
3
+ const withAlpha = (hex, alpha) => {
4
+ const normalized = String(hex || '').trim();
5
+ if (
6
+ !normalized.startsWith('#') ||
7
+ (normalized.length !== 7 && normalized.length !== 4)
8
+ ) {
9
+ return hex;
10
+ }
11
+
12
+ if (normalized.length === 4) {
13
+ const [r, g, b] = normalized.slice(1).split('');
14
+ return `#${r}${r}${g}${g}${b}${b}${alpha}`;
15
+ }
16
+
17
+ return `${normalized}${alpha}`;
18
+ };
19
+
20
+ export const resolveActionPalette = (
21
+ theme,
22
+ variant = 'primary',
23
+ disabled = false,
24
+ ) => {
25
+ const primaryColor = theme?.primary || '#1D4ED8';
26
+ const successColor = theme?.success || '#16A34A';
27
+ const surfaceColor = theme?.surface || '#FFFFFF';
28
+ const borderColor = theme?.cardBorder || '#D6DEE8';
29
+ const mutedColor = theme?.muted || '#64748B';
30
+
31
+ const palettes = {
32
+ primary: {
33
+ backgroundColor: primaryColor,
34
+ borderColor: primaryColor,
35
+ textColor: theme?.onPrimary || '#FFFFFF',
36
+ },
37
+ success: {
38
+ backgroundColor: successColor,
39
+ borderColor: successColor,
40
+ textColor: '#FFFFFF',
41
+ },
42
+ outline: {
43
+ backgroundColor: surfaceColor,
44
+ borderColor,
45
+ textColor: theme?.text || '#0F172A',
46
+ },
47
+ };
48
+
49
+ const palette = palettes[variant] || palettes.primary;
50
+
51
+ if (!disabled) {
52
+ return palette;
53
+ }
54
+
55
+ return {
56
+ backgroundColor: withAlpha(palette.backgroundColor, '66'),
57
+ borderColor: withAlpha(palette.borderColor, '66'),
58
+ textColor: withAlpha(palette.textColor || mutedColor, 'B3'),
59
+ };
60
+ };
61
+
62
+ const createStyles = theme =>
63
+ StyleSheet.create({
64
+ wrapper: {
65
+ position: 'absolute',
66
+ left: 12,
67
+ right: 12,
68
+ zIndex: 60,
69
+ },
70
+ card: {
71
+ borderRadius: 18,
72
+ borderWidth: 1,
73
+ borderColor: theme?.cardBorder || '#D6DEE8',
74
+ backgroundColor: theme?.surface || '#FFFFFF',
75
+ paddingHorizontal: 14,
76
+ paddingVertical: 12,
77
+ shadowColor: '#0F172A',
78
+ shadowOpacity: 0.16,
79
+ shadowRadius: 10,
80
+ shadowOffset: {width: 0, height: 4},
81
+ elevation: 8,
82
+ },
83
+ headerRow: {
84
+ flexDirection: 'row',
85
+ alignItems: 'center',
86
+ justifyContent: 'space-between',
87
+ gap: 10,
88
+ },
89
+ headerRowCompact: {
90
+ justifyContent: 'flex-end',
91
+ },
92
+ title: {
93
+ color: theme?.text || '#0F172A',
94
+ fontSize: 16,
95
+ fontWeight: '800',
96
+ },
97
+ statusBadge: {
98
+ flexDirection: 'row',
99
+ alignItems: 'center',
100
+ gap: 6,
101
+ borderRadius: 999,
102
+ borderWidth: 1,
103
+ paddingHorizontal: 10,
104
+ paddingVertical: 6,
105
+ },
106
+ statusText: {
107
+ fontSize: 12,
108
+ fontWeight: '800',
109
+ },
110
+ metricsRow: {
111
+ marginTop: 12,
112
+ width: '100%',
113
+ },
114
+ metricCard: {
115
+ flex: 1,
116
+ borderRadius: 14,
117
+ borderWidth: 1,
118
+ borderColor: theme?.cardBorder || '#D6DEE8',
119
+ backgroundColor: theme?.background || '#F8FAFC',
120
+ paddingHorizontal: 10,
121
+ paddingVertical: 9,
122
+ },
123
+ metricCardSingle: {
124
+ flex: 1,
125
+ alignSelf: 'stretch',
126
+ },
127
+ metricLabel: {
128
+ color: theme?.muted || '#64748B',
129
+ fontSize: 11,
130
+ fontWeight: '700',
131
+ textTransform: 'uppercase',
132
+ },
133
+ metricValue: {
134
+ marginTop: 4,
135
+ color: theme?.text || '#0F172A',
136
+ fontSize: 14,
137
+ fontWeight: '800',
138
+ },
139
+ metricValueStrong: {
140
+ color: theme?.primary || '#1D4ED8',
141
+ },
142
+ actionsRow: {
143
+ marginTop: 12,
144
+ flexDirection: 'row',
145
+ gap: 10,
146
+ },
147
+ actionsRowSingle: {
148
+ flexDirection: 'column',
149
+ alignItems: 'stretch',
150
+ },
151
+ actionButton: {
152
+ flex: 1,
153
+ flexBasis: 0,
154
+ minHeight: 48,
155
+ borderRadius: 14,
156
+ borderWidth: 1,
157
+ alignItems: 'center',
158
+ justifyContent: 'center',
159
+ flexDirection: 'row',
160
+ gap: 8,
161
+ paddingHorizontal: 12,
162
+ },
163
+ actionButtonSingle: {
164
+ flex: 0,
165
+ width: '100%',
166
+ alignSelf: 'stretch',
167
+ },
168
+ actionLabel: {
169
+ fontSize: 14,
170
+ fontWeight: '800',
171
+ },
172
+ });
173
+
174
+ export default createStyles;