@controleonline/ui-common 1.2.121 → 1.2.123

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.
@@ -1,14 +1,13 @@
1
1
  {
2
- "version": "1.2.120",
2
+ "version": "1.2.121",
3
3
  "rc": 1,
4
- "branch": "rc/1.2.120-rc.1",
5
- "baseMaster": "d88e3ddf8397cc22b4dac04522cb000cf43cfeb8",
4
+ "branch": "rc/1.2.121-rc.1",
5
+ "baseMaster": "662ffc0f2a40a414b3b7ba2b249e15ca62f2cb93",
6
6
  "tasks": [
7
- 128,
8
- 131
7
+ 133
9
8
  ],
10
9
  "frozen": true,
11
10
  "repositories": {
12
- "ControleOnline/ui-common": "7998dc134d7be0e72c864ff0cb6408fd109c561c"
11
+ "ControleOnline/ui-common": "f66e2112a9e5298fd232ba20526d0d7729b9e836"
13
12
  }
14
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@controleonline/ui-common",
3
- "version": "1.2.121",
3
+ "version": "1.2.123",
4
4
  "author": "ControleOnline",
5
5
  "description": "ControleOnline Common Quasar UI Component",
6
6
  "license": "MIT",
@@ -12,16 +12,18 @@ const SystemErrorToast = ({error}) => {
12
12
 
13
13
  const palette = useMemo(
14
14
  () => ({
15
+ // Theme `negative` is the fallback when the toastDanger* tokens are not defined.
15
16
  toastDangerBackground: themeColors.toastDangerBackground,
16
- toastDangerBorder: themeColors.toastDangerBorder,
17
- toastDangerIcon: themeColors.toastDangerIcon,
18
- toastDangerText: themeColors.toastDangerText,
17
+ toastDangerBorder: themeColors.toastDangerBorder || themeColors.negative,
18
+ toastDangerIcon: themeColors.toastDangerIcon || themeColors.negative,
19
+ toastDangerText: themeColors.toastDangerText || themeColors.negative,
19
20
  }),
20
21
  [
21
22
  themeColors.toastDangerBackground,
22
23
  themeColors.toastDangerBorder,
23
24
  themeColors.toastDangerIcon,
24
25
  themeColors.toastDangerText,
26
+ themeColors.negative,
25
27
  ],
26
28
  );
27
29
 
@@ -145,6 +145,8 @@ export default function CashRegisterSummary() {
145
145
  </Text>
146
146
  </View>
147
147
 
148
+ <Text style={styles.sectionTitle}>Por meio de pagamento</Text>
149
+
148
150
  {payments.length === 0 && !loading && (
149
151
  <Text style={styles.empty}>Nenhuma movimentação no período.</Text>
150
152
  )}
@@ -153,20 +155,35 @@ export default function CashRegisterSummary() {
153
155
  const target = buildCashDrilldownNavigation(item, data);
154
156
 
155
157
  return (
156
- <TouchableOpacity
158
+ <View
157
159
  key={`${item.paymentTypeId}-${item.paymentType}`}
158
160
  testID={`cash-payment-${item.paymentTypeId}`}
159
- style={styles.row}
160
- disabled={!target}
161
- activeOpacity={0.8}
162
- onPress={() => target && navigation.navigate(target.routeName, target.params)}>
163
- <View style={styles.rowInfo}>
164
- <Text style={styles.rowTitle}>{item.paymentType}</Text>
165
- <Text style={styles.rowSub}>{item.quantity} lançamentos</Text>
166
- </View>
167
- <Text style={styles.rowValue}>{Formatter.formatMoney(item.balance)}</Text>
168
- {!!target && <Text style={styles.rowChevron}>›</Text>}
169
- </TouchableOpacity>
161
+ style={styles.card}>
162
+ <TouchableOpacity
163
+ style={styles.cardHeader}
164
+ disabled={!target}
165
+ activeOpacity={0.8}
166
+ onPress={() => target && navigation.navigate(target.routeName, target.params)}>
167
+ <View style={styles.rowInfo}>
168
+ <Text style={styles.rowTitle}>{item.paymentType}</Text>
169
+ <Text style={styles.rowSub}>{item.quantity} lançamentos</Text>
170
+ </View>
171
+ <Text style={styles.rowValue}>{Formatter.formatMoney(item.balance)}</Text>
172
+ {!!target && <Text style={styles.rowChevron}>›</Text>}
173
+ </TouchableOpacity>
174
+ {(item.devices || []).map(sub => (
175
+ <View
176
+ key={`pd-${item.paymentTypeId}-${sub.deviceId ?? 'none'}`}
177
+ testID={`cash-payment-${item.paymentTypeId}-device-${sub.deviceId ?? 'none'}`}
178
+ style={styles.subCard}>
179
+ <View style={styles.rowInfo}>
180
+ <Text style={styles.subTitle}>{resolveDeviceLabel(sub)}</Text>
181
+ <Text style={styles.rowSub}>{sub.quantity} lançamentos</Text>
182
+ </View>
183
+ <Text style={styles.subValue}>{Formatter.formatMoney(sub.balance)}</Text>
184
+ </View>
185
+ ))}
186
+ </View>
170
187
  );
171
188
  })}
172
189
 
@@ -180,12 +197,26 @@ export default function CashRegisterSummary() {
180
197
  <View
181
198
  key={`device-${item.deviceId ?? 'none'}`}
182
199
  testID={`cash-device-${item.deviceId ?? 'none'}`}
183
- style={styles.row}>
184
- <View style={styles.rowInfo}>
185
- <Text style={styles.rowTitle}>{resolveDeviceLabel(item)}</Text>
186
- <Text style={styles.rowSub}>{item.quantity} lançamentos</Text>
200
+ style={styles.card}>
201
+ <View style={styles.cardHeader}>
202
+ <View style={styles.rowInfo}>
203
+ <Text style={styles.rowTitle}>{resolveDeviceLabel(item)}</Text>
204
+ <Text style={styles.rowSub}>{item.quantity} lançamentos</Text>
205
+ </View>
206
+ <Text style={styles.rowValue}>{Formatter.formatMoney(item.balance)}</Text>
187
207
  </View>
188
- <Text style={styles.rowValue}>{Formatter.formatMoney(item.balance)}</Text>
208
+ {(item.payments || []).map(sub => (
209
+ <View
210
+ key={`dp-${item.deviceId ?? 'none'}-${sub.paymentTypeId ?? 'none'}`}
211
+ testID={`cash-device-${item.deviceId ?? 'none'}-payment-${sub.paymentTypeId ?? 'none'}`}
212
+ style={styles.subCard}>
213
+ <View style={styles.rowInfo}>
214
+ <Text style={styles.subTitle}>{sub.paymentType}</Text>
215
+ <Text style={styles.rowSub}>{sub.quantity} lançamentos</Text>
216
+ </View>
217
+ <Text style={styles.subValue}>{Formatter.formatMoney(sub.balance)}</Text>
218
+ </View>
219
+ ))}
189
220
  </View>
190
221
  ))}
191
222
 
@@ -229,5 +260,10 @@ const styles = StyleSheet.create({
229
260
  rowTitle: {fontWeight: '700', color: '#0F172A'},
230
261
  rowSub: {color: '#64748B', fontSize: 12},
231
262
  rowValue: {fontWeight: '700', color: '#0F172A'},
263
+ card: {backgroundColor: '#FFFFFF', borderRadius: 10, padding: 14, borderWidth: 1, borderColor: '#E2E8F0', gap: 8},
264
+ cardHeader: {flexDirection: 'row', alignItems: 'center'},
265
+ subCard: {flexDirection: 'row', alignItems: 'center', backgroundColor: '#F1F5F9', borderRadius: 8, paddingVertical: 8, paddingHorizontal: 12},
266
+ subTitle: {fontWeight: '600', color: '#334155'},
267
+ subValue: {fontWeight: '600', color: '#334155'},
232
268
  rowChevron: {marginLeft: 8, fontSize: 22, color: '#94A3B8'},
233
269
  });
@@ -1,24 +1,29 @@
1
+ import {getAllStores} from '@store'
2
+
1
3
  const TOAST_STYLE_KEYS = ['pressable', 'view', 'text', 'indicator']
2
4
 
3
5
  const isPlainObject = value =>
4
6
  value && typeof value === 'object' && !Array.isArray(value)
5
7
 
6
- export const TOAST_ERROR_STYLES = {
7
- pressable: {
8
- backgroundColor: '#FFF7F7',
9
- borderColor: '#FECACA',
10
- borderWidth: 1,
11
- },
12
- indicator: {
13
- backgroundColor: '#DC2626',
14
- },
8
+ // Toast accents come from the theme (`negative` / `warning`), never from fixed RGB (#1484).
9
+ const themeColors = () => {
10
+ try {
11
+ return getAllStores()?.theme?.getters?.colors || {}
12
+ } catch (error) {
13
+ return {}
14
+ }
15
15
  }
16
16
 
17
- export const TOAST_WARNING_STYLES = {
18
- indicator: {
19
- backgroundColor: '#e67e22',
20
- },
21
- }
17
+ export const buildErrorToastStyles = (colors = themeColors()) =>
18
+ colors.negative
19
+ ? {
20
+ pressable: {borderColor: colors.negative, borderWidth: 1},
21
+ indicator: {backgroundColor: colors.negative},
22
+ }
23
+ : {}
24
+
25
+ export const buildWarningToastStyles = (colors = themeColors()) =>
26
+ colors.warning ? {indicator: {backgroundColor: colors.warning}} : {}
22
27
 
23
28
  export const mergeToastStyles = (...styleSets) =>
24
29
  styleSets.reduce((mergedStyles, currentStyleSet) => {
@@ -42,12 +47,12 @@ export const mergeToastStyles = (...styleSets) =>
42
47
 
43
48
  export const withErrorToastStyles = (options = {}) => ({
44
49
  ...options,
45
- styles: mergeToastStyles(TOAST_ERROR_STYLES, options?.styles),
50
+ styles: mergeToastStyles(buildErrorToastStyles(), options?.styles),
46
51
  })
47
52
 
48
53
  export const withWarningToastStyles = (options = {}) => ({
49
54
  ...options,
50
- styles: mergeToastStyles(TOAST_WARNING_STYLES, options?.styles),
55
+ styles: mergeToastStyles(buildWarningToastStyles(), options?.styles),
51
56
  })
52
57
 
53
58
  export default withErrorToastStyles
@@ -1,23 +1,28 @@
1
1
  const {describe, expect, it} = global
2
2
 
3
+ jest.mock('@store', () => ({
4
+ getAllStores: () => ({theme: {getters: {colors: {negative: '#C10015', warning: '#F2C037'}}}}),
5
+ }), {virtual: true})
6
+
3
7
  const {
4
- TOAST_ERROR_STYLES,
5
- TOAST_WARNING_STYLES,
8
+ buildErrorToastStyles,
9
+ buildWarningToastStyles,
6
10
  mergeToastStyles,
7
11
  withErrorToastStyles,
8
12
  withWarningToastStyles,
9
13
  } = require('../../../react/utils/toastPresentation')
10
14
 
11
15
  describe('toastPresentation', () => {
12
- it('keeps the shared error toast on a light, high-contrast panel', () => {
13
- expect(TOAST_ERROR_STYLES.pressable).toMatchObject({
14
- backgroundColor: '#FFF7F7',
15
- borderColor: '#FECACA',
16
- borderWidth: 1,
16
+ it('derives toast accents from the theme negative/warning variables, no fixed RGB (#1484)', () => {
17
+ expect(buildErrorToastStyles({negative: '#C10015'})).toEqual({
18
+ pressable: {borderColor: '#C10015', borderWidth: 1},
19
+ indicator: {backgroundColor: '#C10015'},
17
20
  })
18
- expect(TOAST_ERROR_STYLES.indicator).toMatchObject({
19
- backgroundColor: '#DC2626',
21
+ expect(buildWarningToastStyles({warning: '#F2C037'})).toEqual({
22
+ indicator: {backgroundColor: '#F2C037'},
20
23
  })
24
+ expect(buildErrorToastStyles({})).toEqual({})
25
+ expect(buildWarningToastStyles({})).toEqual({})
21
26
  })
22
27
 
23
28
  it('merges toast style groups without dropping prior sections', () => {
@@ -46,17 +51,16 @@ describe('toastPresentation', () => {
46
51
  })
47
52
  })
48
53
 
49
- it('decorates error and warning toast options with the shared styles', () => {
54
+ it('decorates error and warning toast options with theme-driven styles', () => {
50
55
  expect(withErrorToastStyles({styles: {pressable: {paddingHorizontal: 8}}})).toEqual({
51
56
  styles: {
52
57
  pressable: {
53
- backgroundColor: '#FFF7F7',
54
- borderColor: '#FECACA',
58
+ borderColor: '#C10015',
55
59
  borderWidth: 1,
56
60
  paddingHorizontal: 8,
57
61
  },
58
62
  indicator: {
59
- backgroundColor: '#DC2626',
63
+ backgroundColor: '#C10015',
60
64
  },
61
65
  },
62
66
  })
@@ -64,7 +68,7 @@ describe('toastPresentation', () => {
64
68
  expect(withWarningToastStyles({styles: {text: {fontWeight: '700'}}})).toEqual({
65
69
  styles: {
66
70
  indicator: {
67
- backgroundColor: TOAST_WARNING_STYLES.indicator.backgroundColor,
71
+ backgroundColor: '#F2C037',
68
72
  },
69
73
  text: {
70
74
  fontWeight: '700',
@@ -0,0 +1,14 @@
1
+ import assert from 'node:assert/strict';
2
+ import test from 'node:test';
3
+ import fs from 'node:fs';
4
+
5
+ const read = name => fs.readFileSync(new URL(name, import.meta.url), 'utf8').replace(/\r\n/g, '\n');
6
+
7
+ test('toast error/warning accents come from theme variables, not fixed RGB (#1484)', () => {
8
+ const presentation = read('../../../react/utils/toastPresentation.js');
9
+ assert.match(presentation, /colors\.negative/);
10
+ assert.match(presentation, /colors\.warning/);
11
+ assert.doesNotMatch(presentation, /#(?:DC2626|FFF7F7|FECACA|e67e22)/i);
12
+ const toast = read('../../../react/components/SystemErrorToast.js');
13
+ assert.match(toast, /themeColors\.toastDangerBorder \|\| themeColors\.negative/);
14
+ });