@ledgerhq/lumen-ui-rnative 0.1.41 → 0.1.42
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/dist/module/lib/Components/Banner/Banner.js +5 -9
- package/dist/module/lib/Components/Banner/Banner.js.map +1 -1
- package/dist/module/lib/Components/SegmentedControl/SegmentedControl.test.js +162 -66
- package/dist/module/lib/Components/SegmentedControl/SegmentedControl.test.js.map +1 -1
- package/dist/module/lib/Components/SegmentedControl/usePillLayout.js +19 -15
- package/dist/module/lib/Components/SegmentedControl/usePillLayout.js.map +1 -1
- package/dist/module/lib/Components/Trend/Trend.js +19 -16
- package/dist/module/lib/Components/Trend/Trend.js.map +1 -1
- package/dist/typescript/src/lib/Components/Banner/Banner.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/Banner/types.d.ts +3 -3
- package/dist/typescript/src/lib/Components/Banner/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/SegmentedControl/usePillLayout.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/Trend/Trend.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/lib/Components/Banner/Banner.tsx +8 -11
- package/src/lib/Components/Banner/types.ts +3 -3
- package/src/lib/Components/SegmentedControl/SegmentedControl.test.tsx +152 -60
- package/src/lib/Components/SegmentedControl/usePillLayout.ts +21 -12
- package/src/lib/Components/Trend/Trend.tsx +24 -22
|
@@ -7,7 +7,6 @@ import { useStyleSheet } from "../../../styles/index.js";
|
|
|
7
7
|
import { InformationFill, CheckmarkCircleFill, WarningFill, DeleteCircleFill, Close } from "../../Symbols/index.js";
|
|
8
8
|
import { IconButton } from "../IconButton/index.js";
|
|
9
9
|
import { Box } from "../Utility/index.js";
|
|
10
|
-
import { Wrap } from "../Wrap/index.js";
|
|
11
10
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
11
|
const iconColorMap = {
|
|
13
12
|
info: 'base',
|
|
@@ -63,6 +62,7 @@ const useStyles = ({
|
|
|
63
62
|
}]),
|
|
64
63
|
actionsWrapper: {
|
|
65
64
|
flexDirection: 'row',
|
|
65
|
+
flexWrap: 'wrap',
|
|
66
66
|
gap: t.spacings.s4
|
|
67
67
|
}
|
|
68
68
|
};
|
|
@@ -153,15 +153,11 @@ export const Banner = ({
|
|
|
153
153
|
numberOfLines: 2,
|
|
154
154
|
children: title
|
|
155
155
|
}), description && /*#__PURE__*/_jsx(View, {
|
|
156
|
-
children: /*#__PURE__*/_jsx(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
style: styles.description,
|
|
160
|
-
numberOfLines: 5,
|
|
161
|
-
children: children
|
|
162
|
-
}),
|
|
156
|
+
children: isTextChildren(description) ? /*#__PURE__*/_jsx(Text, {
|
|
157
|
+
style: styles.description,
|
|
158
|
+
numberOfLines: 5,
|
|
163
159
|
children: description
|
|
164
|
-
})
|
|
160
|
+
}) : description
|
|
165
161
|
})]
|
|
166
162
|
}), (primaryAction || secondaryAction) && /*#__PURE__*/_jsxs(View, {
|
|
167
163
|
style: styles.actionsWrapper,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isTextChildren","StyleSheet","Text","View","useCommonTranslation","useStyleSheet","InformationFill","CheckmarkCircleFill","WarningFill","DeleteCircleFill","Close","IconButton","Box","
|
|
1
|
+
{"version":3,"names":["isTextChildren","StyleSheet","Text","View","useCommonTranslation","useStyleSheet","InformationFill","CheckmarkCircleFill","WarningFill","DeleteCircleFill","Close","IconButton","Box","jsx","_jsx","jsxs","_jsxs","iconColorMap","info","success","warning","error","useStyles","appearance","t","bgColors","colors","bg","surface","root","flexDirection","width","sizes","full","alignItems","gap","spacings","s8","borderRadius","md","padding","s16","backgroundColor","iconWrapper","flexShrink","iconSpacer","typographies","body1SemiBold","overflow","contentWrapper","marginRight","flex","textWrapper","s4","title","flatten","color","text","base","description","body2","actionsWrapper","flexWrap","iconsMap","Banner","primaryAction","secondaryAction","lx","style","onClose","closeAriaLabel","ref","props","styles","IconComponent","iconColor","children","numberOfLines","testID","size","icon","onPress","accessibilityLabel"],"sourceRoot":"../../../../../src","sources":["lib/Components/Banner/Banner.tsx"],"mappings":";;AAAA,SAASA,cAAc,QAAQ,8BAA8B;AAE7D,SAASC,UAAU,EAAEC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AACrD,SAASC,oBAAoB,QAAQ,wBAAe;AACpD,SAASC,aAAa,QAAQ,0BAAiB;AAC/C,SACEC,eAAe,EACfC,mBAAmB,EACnBC,WAAW,EACXC,gBAAgB,EAChBC,KAAK,QACA,wBAAe;AAEtB,SAASC,UAAU,QAAQ,wBAAe;AAC1C,SAASC,GAAG,QAAQ,qBAAY;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAKjC,MAAMC,YAGL,GAAG;EACFC,IAAI,EAAE,MAAM;EACZC,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE,SAAS;EAClBC,KAAK,EAAE;AACT,CAAC;AAED,MAAMC,SAAS,GAAGA,CAAC;EAAEC;AAAuC,CAAC,KAAK;EAChE,OAAOlB,aAAa,CACjBmB,CAAC,IAAK;IACL,MAAMC,QAAoC,GAAG;MAC3CP,IAAI,EAAEM,CAAC,CAACE,MAAM,CAACC,EAAE,CAACC,OAAO;MACzBT,OAAO,EAAEK,CAAC,CAACE,MAAM,CAACC,EAAE,CAACR,OAAO;MAC5BC,OAAO,EAAEI,CAAC,CAACE,MAAM,CAACC,EAAE,CAACP,OAAO;MAC5BC,KAAK,EAAEG,CAAC,CAACE,MAAM,CAACC,EAAE,CAACN;IACrB,CAAC;IAED,OAAO;MACLQ,IAAI,EAAE;QACJC,aAAa,EAAE,KAAK;QACpBC,KAAK,EAAEP,CAAC,CAACQ,KAAK,CAACC,IAAI;QACnBC,UAAU,EAAE,YAAY;QACxBC,GAAG,EAAEX,CAAC,CAACY,QAAQ,CAACC,EAAE;QAClBC,YAAY,EAAEd,CAAC,CAACc,YAAY,CAACC,E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EK,MAAM,CAACxB,cAAe;MAAA2B,QAAA,gBACjC5D,KAAA,CAACb,IAAI;QAACiE,KAAK,EAAEK,MAAM,CAACrB,WAAY;QAAAwB,QAAA,GAC7BtB,KAAK,iBACJxC,IAAA,CAACZ,IAAI;UAACkE,KAAK,EAAEK,MAAM,CAACnB,KAAM;UAACuB,aAAa,EAAE,CAAE;UAAAD,QAAA,EACzCtB;QAAK,CACF,CACP,EACAK,WAAW,iBACV7C,IAAA,CAACX,IAAI;UAAAyE,QAAA,EACF5E,cAAc,CAAC2D,WAAW,CAAC,gBAC1B7C,IAAA,CAACZ,IAAI;YAACkE,KAAK,EAAEK,MAAM,CAACd,WAAY;YAACkB,aAAa,EAAE,CAAE;YAAAD,QAAA,EAC/CjB;UAAW,CACR,CAAC,GAEPA;QACD,CACG,CACP;MAAA,CACG,CAAC,EACN,CAACM,aAAa,IAAIC,eAAe,kBAChClD,KAAA,CAACb,IAAI;QAACiE,KAAK,EAAEK,MAAM,CAACZ,cAAe;QAAAe,QAAA,GAChCX,aAAa,EACbC,eAAe;MAAA,CACZ,CACP;IAAA,CACG,CAAC,EACNG,OAAO,iBACNvD,IAAA,CAACH,UAAU;MACTmE,MAAM,EAAC,qBAAqB;MAC5BvD,UAAU,EAAC,aAAa;MACxBwD,IAAI,EAAC,IAAI;MACTC,IAAI,EAAEtE,KAAM;MACZuE,OAAO,EAAEA,CAAA,KAAMZ,OAAO,CAAC,CAAE;MACzBa,kBAAkB,EAChBZ,cAAc,IAAI9C,CAAC,CAAC,kCAAkC;IACvD,CACF,CACF;EAAA,CACE,CAAC;AAEV,CAAC","ignoreList":[]}
|
|
@@ -16,73 +16,169 @@ const TestWrapper = ({
|
|
|
16
16
|
children: children
|
|
17
17
|
});
|
|
18
18
|
describe('SegmentedControl', () => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
19
|
+
describe('Rendering', () => {
|
|
20
|
+
it('renders segments with labels', () => {
|
|
21
|
+
const {
|
|
22
|
+
getByText
|
|
23
|
+
} = render(/*#__PURE__*/_jsx(TestWrapper, {
|
|
24
|
+
children: /*#__PURE__*/_jsxs(SegmentedControl, {
|
|
25
|
+
selectedValue: "send",
|
|
26
|
+
onSelectedChange: () => {
|
|
27
|
+
/* empty */
|
|
28
|
+
},
|
|
29
|
+
accessibilityLabel: "Transaction type",
|
|
30
|
+
children: [/*#__PURE__*/_jsx(SegmentedControlButton, {
|
|
31
|
+
value: "send",
|
|
32
|
+
children: "Send"
|
|
33
|
+
}), /*#__PURE__*/_jsx(SegmentedControlButton, {
|
|
34
|
+
value: "receive",
|
|
35
|
+
children: "Receive"
|
|
36
|
+
})]
|
|
37
|
+
})
|
|
38
|
+
}));
|
|
39
|
+
expect(getByText('Send')).toBeTruthy();
|
|
40
|
+
expect(getByText('Receive')).toBeTruthy();
|
|
41
|
+
});
|
|
42
|
+
it('renders trailingContent inside segment buttons', () => {
|
|
43
|
+
const {
|
|
44
|
+
getByLabelText
|
|
45
|
+
} = render(/*#__PURE__*/_jsx(TestWrapper, {
|
|
46
|
+
children: /*#__PURE__*/_jsxs(SegmentedControl, {
|
|
47
|
+
selectedValue: "tokens",
|
|
48
|
+
onSelectedChange: () => {
|
|
49
|
+
/* empty */
|
|
50
|
+
},
|
|
51
|
+
accessibilityLabel: "Asset section",
|
|
52
|
+
children: [/*#__PURE__*/_jsx(SegmentedControlButton, {
|
|
53
|
+
value: "tokens",
|
|
54
|
+
trailingContent: /*#__PURE__*/_jsx(DotCount, {
|
|
55
|
+
value: 3,
|
|
56
|
+
accessibilityLabel: "3 tokens"
|
|
57
|
+
}),
|
|
58
|
+
children: "Tokens"
|
|
59
|
+
}), /*#__PURE__*/_jsx(SegmentedControlButton, {
|
|
60
|
+
value: "nfts",
|
|
61
|
+
children: "NFTs"
|
|
62
|
+
})]
|
|
63
|
+
})
|
|
64
|
+
}));
|
|
65
|
+
expect(getByLabelText('3 tokens')).toBeTruthy();
|
|
66
|
+
});
|
|
40
67
|
});
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
children:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
68
|
+
describe('States', () => {
|
|
69
|
+
it('marks the selected segment with accessibilityState', () => {
|
|
70
|
+
const {
|
|
71
|
+
getByTestId
|
|
72
|
+
} = render(/*#__PURE__*/_jsx(TestWrapper, {
|
|
73
|
+
children: /*#__PURE__*/_jsxs(SegmentedControl, {
|
|
74
|
+
selectedValue: "receive",
|
|
75
|
+
onSelectedChange: () => {},
|
|
76
|
+
accessibilityLabel: "Transaction type",
|
|
77
|
+
children: [/*#__PURE__*/_jsx(SegmentedControlButton, {
|
|
78
|
+
value: "send",
|
|
79
|
+
testID: "seg-send",
|
|
80
|
+
children: "Send"
|
|
81
|
+
}), /*#__PURE__*/_jsx(SegmentedControlButton, {
|
|
82
|
+
value: "receive",
|
|
83
|
+
testID: "seg-receive",
|
|
84
|
+
children: "Receive"
|
|
85
|
+
})]
|
|
86
|
+
})
|
|
87
|
+
}));
|
|
88
|
+
expect(getByTestId('seg-send').props.accessibilityState).toMatchObject({
|
|
89
|
+
selected: false
|
|
90
|
+
});
|
|
91
|
+
expect(getByTestId('seg-receive').props.accessibilityState).toMatchObject({
|
|
92
|
+
selected: true
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
it('marks a pre-selected non-first segment as selected on initial render (fixed layout)', () => {
|
|
96
|
+
const {
|
|
97
|
+
getByTestId
|
|
98
|
+
} = render(/*#__PURE__*/_jsx(TestWrapper, {
|
|
99
|
+
children: /*#__PURE__*/_jsxs(SegmentedControl, {
|
|
100
|
+
selectedValue: "blame",
|
|
101
|
+
onSelectedChange: () => {},
|
|
102
|
+
tabLayout: "fixed",
|
|
103
|
+
accessibilityLabel: "File view",
|
|
104
|
+
children: [/*#__PURE__*/_jsx(SegmentedControlButton, {
|
|
105
|
+
value: "preview",
|
|
106
|
+
testID: "seg-preview",
|
|
107
|
+
children: "Preview"
|
|
108
|
+
}), /*#__PURE__*/_jsx(SegmentedControlButton, {
|
|
109
|
+
value: "raw",
|
|
110
|
+
testID: "seg-raw",
|
|
111
|
+
children: "Raw"
|
|
112
|
+
}), /*#__PURE__*/_jsx(SegmentedControlButton, {
|
|
113
|
+
value: "blame",
|
|
114
|
+
testID: "seg-blame",
|
|
115
|
+
children: "Blame"
|
|
116
|
+
})]
|
|
117
|
+
})
|
|
118
|
+
}));
|
|
119
|
+
expect(getByTestId('seg-preview').props.accessibilityState).toMatchObject({
|
|
120
|
+
selected: false
|
|
121
|
+
});
|
|
122
|
+
expect(getByTestId('seg-blame').props.accessibilityState).toMatchObject({
|
|
123
|
+
selected: true
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
it('marks a pre-selected non-first segment as selected on initial render (fit layout)', () => {
|
|
127
|
+
const {
|
|
128
|
+
getByTestId
|
|
129
|
+
} = render(/*#__PURE__*/_jsx(TestWrapper, {
|
|
130
|
+
children: /*#__PURE__*/_jsxs(SegmentedControl, {
|
|
131
|
+
selectedValue: "blame",
|
|
132
|
+
onSelectedChange: () => {},
|
|
133
|
+
tabLayout: "fit",
|
|
134
|
+
accessibilityLabel: "File view",
|
|
135
|
+
children: [/*#__PURE__*/_jsx(SegmentedControlButton, {
|
|
136
|
+
value: "preview",
|
|
137
|
+
testID: "seg-preview",
|
|
138
|
+
children: "Preview"
|
|
139
|
+
}), /*#__PURE__*/_jsx(SegmentedControlButton, {
|
|
140
|
+
value: "raw",
|
|
141
|
+
testID: "seg-raw",
|
|
142
|
+
children: "Raw"
|
|
143
|
+
}), /*#__PURE__*/_jsx(SegmentedControlButton, {
|
|
144
|
+
value: "blame",
|
|
145
|
+
testID: "seg-blame",
|
|
146
|
+
children: "Blame"
|
|
147
|
+
})]
|
|
148
|
+
})
|
|
149
|
+
}));
|
|
150
|
+
expect(getByTestId('seg-preview').props.accessibilityState).toMatchObject({
|
|
151
|
+
selected: false
|
|
152
|
+
});
|
|
153
|
+
expect(getByTestId('seg-blame').props.accessibilityState).toMatchObject({
|
|
154
|
+
selected: true
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
it('can change selection away from a pre-selected non-first segment (fit layout)', () => {
|
|
158
|
+
const onSelectedChange = jest.fn();
|
|
159
|
+
const {
|
|
160
|
+
getByText
|
|
161
|
+
} = render(/*#__PURE__*/_jsx(TestWrapper, {
|
|
162
|
+
children: /*#__PURE__*/_jsxs(SegmentedControl, {
|
|
163
|
+
selectedValue: "blame",
|
|
164
|
+
onSelectedChange: onSelectedChange,
|
|
165
|
+
tabLayout: "fit",
|
|
166
|
+
accessibilityLabel: "File view",
|
|
167
|
+
children: [/*#__PURE__*/_jsx(SegmentedControlButton, {
|
|
168
|
+
value: "preview",
|
|
169
|
+
children: "Preview"
|
|
170
|
+
}), /*#__PURE__*/_jsx(SegmentedControlButton, {
|
|
171
|
+
value: "raw",
|
|
172
|
+
children: "Raw"
|
|
173
|
+
}), /*#__PURE__*/_jsx(SegmentedControlButton, {
|
|
174
|
+
value: "blame",
|
|
175
|
+
children: "Blame"
|
|
176
|
+
})]
|
|
177
|
+
})
|
|
178
|
+
}));
|
|
179
|
+
fireEvent.press(getByText('Preview'));
|
|
180
|
+
expect(onSelectedChange).toHaveBeenCalledWith('preview');
|
|
181
|
+
});
|
|
86
182
|
});
|
|
87
183
|
});
|
|
88
184
|
//# sourceMappingURL=SegmentedControl.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["describe","it","expect","jest","ledgerLiveThemes","render","fireEvent","DotCount","ThemeProvider","SegmentedControl","SegmentedControlButton","jsx","_jsx","jsxs","_jsxs","TestWrapper","children","themes","colorScheme","locale","getByText","selectedValue","onSelectedChange","accessibilityLabel","value","toBeTruthy","
|
|
1
|
+
{"version":3,"names":["describe","it","expect","jest","ledgerLiveThemes","render","fireEvent","DotCount","ThemeProvider","SegmentedControl","SegmentedControlButton","jsx","_jsx","jsxs","_jsxs","TestWrapper","children","themes","colorScheme","locale","getByText","selectedValue","onSelectedChange","accessibilityLabel","value","toBeTruthy","getByLabelText","trailingContent","getByTestId","testID","props","accessibilityState","toMatchObject","selected","tabLayout","fn","press","toHaveBeenCalledWith"],"sourceRoot":"../../../../../src","sources":["lib/Components/SegmentedControl/SegmentedControl.test.tsx"],"mappings":";;AAAA,SAASA,QAAQ,EAAEC,EAAE,EAAEC,MAAM,EAAEC,IAAI,QAAQ,eAAe;AAC1D,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,MAAM,EAAEC,SAAS,QAAQ,+BAA+B;AACjE,SAASC,QAAQ,QAAQ,sBAAa;AACtC,SAASC,aAAa,QAAQ,mCAAgC;AAC9D,SAASC,gBAAgB,EAAEC,sBAAsB,QAAQ,uBAAoB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAE9E,MAAMC,WAAW,GAAGA,CAAC;EAAEC;AAAwC,CAAC,kBAC9DJ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AC,OAAO;YAAAR,QAAA,EAAC;UAAK,CAAwB,CAAC;QAAA,CACpD;MAAC,CACR,CACf,CAAC;MAEDV,SAAS,CAAC8B,KAAK,CAAChB,SAAS,CAAC,SAAS,CAAC,CAAC;MAErClB,MAAM,CAACoB,gBAAgB,CAAC,CAACe,oBAAoB,CAAC,SAAS,CAAC;IAC1D,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React, { Children, isValidElement, useCallback, useEffect, useMemo, useRef } from 'react';
|
|
3
|
+
import React, { Children, isValidElement, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
|
|
5
5
|
import { useTimingConfig } from "../../Animations/useTimingConfig.js";
|
|
6
6
|
export function useSegmentedControlSelectedIndex(selectedValue, children) {
|
|
@@ -14,7 +14,7 @@ export function useSegmentedControlSelectedIndex(selectedValue, children) {
|
|
|
14
14
|
const _worklet_6098626077169_init_data = {
|
|
15
15
|
code: "function usePillLayoutTs1(){const{pillTranslateX,pillWidth,pillHeight}=this.__closure;return{transform:[{translateX:pillTranslateX.value}],width:pillWidth.value,height:pillHeight.value};}",
|
|
16
16
|
location: "/home/runner/work/lumen/lumen/libs/ui-rnative/src/lib/Components/SegmentedControl/usePillLayout.ts",
|
|
17
|
-
sourceMap: "{\"version\":3,\"names\":[\"usePillLayoutTs1\",\"pillTranslateX\",\"pillWidth\",\"pillHeight\",\"__closure\",\"transform\",\"translateX\",\"value\",\"width\",\"height\"],\"sources\":[\"/home/runner/work/lumen/lumen/libs/ui-rnative/src/lib/Components/SegmentedControl/usePillLayout.ts\"],\"mappings\":\"
|
|
17
|
+
sourceMap: "{\"version\":3,\"names\":[\"usePillLayoutTs1\",\"pillTranslateX\",\"pillWidth\",\"pillHeight\",\"__closure\",\"transform\",\"translateX\",\"value\",\"width\",\"height\"],\"sources\":[\"/home/runner/work/lumen/lumen/libs/ui-rnative/src/lib/Components/SegmentedControl/usePillLayout.ts\"],\"mappings\":\"AA+HI,SAAAA,iBAAA,QAAAC,cAAA,CAAAC,SAAA,CAAAC,UAAA,OAAAC,SAAA,OAAO,CACLC,SAAS,CAAE,CAAC,CAAEC,UAAU,CAAEL,cAAc,CAACM,KAAM,CAAC,CAAC,CACjDC,KAAK,CAAEN,SAAS,CAACK,KAAK,CACtBE,MAAM,CAAEN,UAAU,CAACI,KACrB,CAAC\",\"ignoreList\":[]}"
|
|
18
18
|
};
|
|
19
19
|
export function usePillLayout({
|
|
20
20
|
selectedIndex,
|
|
@@ -26,7 +26,9 @@ export function usePillLayout({
|
|
|
26
26
|
const pillWidth = useSharedValue(0);
|
|
27
27
|
const pillHeight = useSharedValue(0);
|
|
28
28
|
const hasLayoutRef = useRef(false);
|
|
29
|
+
const animatePillRef = useRef(false);
|
|
29
30
|
const buttonLayoutsRef = useRef(new Map());
|
|
31
|
+
const [layoutReady, setLayoutReady] = useState(false);
|
|
30
32
|
const timingConfig = useTimingConfig({
|
|
31
33
|
duration: 300,
|
|
32
34
|
easing: 'easeInOut'
|
|
@@ -43,36 +45,38 @@ export function usePillLayout({
|
|
|
43
45
|
pillWidth.value = slotWidth;
|
|
44
46
|
if (!hasLayoutRef.current) {
|
|
45
47
|
hasLayoutRef.current = true;
|
|
46
|
-
|
|
47
|
-
pillTranslateX.value = selectedIndex * slotWidth;
|
|
48
|
-
}
|
|
48
|
+
setLayoutReady(true);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
const registerButtonLayout = useCallback((value, layout) => {
|
|
53
53
|
buttonLayoutsRef.current.set(value, layout);
|
|
54
|
-
if (tabLayout === 'fit' && !hasLayoutRef.current) {
|
|
54
|
+
if (tabLayout === 'fit' && !hasLayoutRef.current && value === selectedValue) {
|
|
55
55
|
hasLayoutRef.current = true;
|
|
56
|
-
|
|
57
|
-
pillTranslateX.value = layout.x;
|
|
58
|
-
pillWidth.value = layout.width;
|
|
59
|
-
}
|
|
56
|
+
setLayoutReady(true);
|
|
60
57
|
}
|
|
61
|
-
}, [tabLayout, selectedValue
|
|
58
|
+
}, [tabLayout, selectedValue]);
|
|
62
59
|
useEffect(() => {
|
|
63
60
|
if (!hasLayoutRef.current) return;
|
|
61
|
+
const skipAnimation = !animatePillRef.current;
|
|
62
|
+
if (skipAnimation) {
|
|
63
|
+
animatePillRef.current = true;
|
|
64
|
+
}
|
|
65
|
+
const config = skipAnimation ? {
|
|
66
|
+
duration: 0
|
|
67
|
+
} : timingConfig;
|
|
64
68
|
if (tabLayout === 'fit') {
|
|
65
69
|
const layout = buttonLayoutsRef.current.get(selectedValue);
|
|
66
70
|
if (layout) {
|
|
67
|
-
pillTranslateX.value = withTiming(layout.x,
|
|
68
|
-
pillWidth.value = withTiming(layout.width,
|
|
71
|
+
pillTranslateX.value = withTiming(layout.x, config);
|
|
72
|
+
pillWidth.value = withTiming(layout.width, config);
|
|
69
73
|
}
|
|
70
74
|
} else {
|
|
71
75
|
if (selectedIndex >= 0 && pillWidth.value > 0) {
|
|
72
|
-
pillTranslateX.value = withTiming(selectedIndex * pillWidth.value,
|
|
76
|
+
pillTranslateX.value = withTiming(selectedIndex * pillWidth.value, config);
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
|
-
}, [selectedIndex, selectedValue, tabLayout, pillWidth, pillTranslateX, timingConfig]);
|
|
79
|
+
}, [selectedIndex, selectedValue, tabLayout, pillWidth, pillTranslateX, timingConfig, layoutReady]);
|
|
76
80
|
const animatedPillStyle = useAnimatedStyle(function usePillLayoutTs1Factory({
|
|
77
81
|
_worklet_6098626077169_init_data,
|
|
78
82
|
pillTranslateX,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Children","isValidElement","useCallback","useEffect","useMemo","useRef","useAnimatedStyle","useSharedValue","withTiming","useTimingConfig","useSegmentedControlSelectedIndex","selectedValue","children","toArray","findIndex","child","props","value","_worklet_6098626077169_init_data","code","location","sourceMap","usePillLayout","selectedIndex","tabLayout","pillTranslateX","pillWidth","pillHeight","hasLayoutRef","buttonLayoutsRef","Map","timingConfig","duration","easing","onLayout","e","width","height","nativeEvent","layout","count","slotWidth","current","registerButtonLayout","set","
|
|
1
|
+
{"version":3,"names":["React","Children","isValidElement","useCallback","useEffect","useMemo","useRef","useState","useAnimatedStyle","useSharedValue","withTiming","useTimingConfig","useSegmentedControlSelectedIndex","selectedValue","children","toArray","findIndex","child","props","value","_worklet_6098626077169_init_data","code","location","sourceMap","usePillLayout","selectedIndex","tabLayout","pillTranslateX","pillWidth","pillHeight","hasLayoutRef","animatePillRef","buttonLayoutsRef","Map","layoutReady","setLayoutReady","timingConfig","duration","easing","onLayout","e","width","height","nativeEvent","layout","count","slotWidth","current","registerButtonLayout","set","skipAnimation","config","get","x","animatedPillStyle","usePillLayoutTs1Factory","_e","global","Error","usePillLayoutTs1","transform","translateX","__closure","__workletHash","__pluginVersion","__initData","__stackDetails"],"sourceRoot":"../../../../../src","sources":["lib/Components/SegmentedControl/usePillLayout.ts"],"mappings":";;AACA,OAAOA,KAAK,IACVC,QAAQ,EACRC,cAAc,EACdC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,OAAO;AAEd,SACEC,gBAAgB,EAChBC,cAAc,EACdC,UAAU,QACL,yBAAyB;AAChC,SAASC,eAAe,QAAQ,qCAAkC;AAGlE,OAAO,SAASC,gCAAgCA,CAC9CC,aAAqB,EACrBC,QAAmB,EACX;EACR,OAAOT,OAAO,CACZ,MACEJ,QAAQ,CAACc,OAAO,CAACD,QAAQ,CAAC,CAACE,SAAS,CAAEC,KAAK,IAAK;IAC9C,IAAI,aAAAf,cAAc,CAACe,KAAK,CAAC,IAAIA,KAAK,CAACC,KAAK,IAAI,IAAI,EAAE;MAChD,OAAQD,KAAK,CAACC,KAAK,CAAwBC,KAAK,KAAKN,a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GAAGG,SAAS,CAACT,KAAK,EAC/BgC,MACF,CAAC;MACH;IACF;EACF,CAAC,EAAE,CACD1B,aAAa,EACbZ,aAAa,EACba,SAAS,EACTE,SAAS,EACTD,cAAc,EACdS,YAAY,EACZF,WAAW,CACZ,CAAC;EAEF,MAAMoB,iBAAiB,GAAG9C,gBAAgB,CACxC,SAAA+C,wBAAA;IAAAnC,gCAAA;IAC4BO,cAAc;IACjCC,SAAS;IACRC;EAAU;IAAA,MAAA2B,EAAA,QAAAC,MAAA,CAAAC,KAAA;IAAA,MAAAC,gBAAA,GAHpBA,CAAA,MAAO;MACLC,SAAS,EAAE,CAAC;QAAEC,UAAU,EAAElC,cAAc,CAACR;MAAM,CAAC,CAAC;MACjDsB,KAAK,EAAEb,SAAS,CAACT,KAAK;MACtBuB,MAAM,EAAEb,UAAU,CAACV;IACrB,CAAC,CAAC;IAAAwC,gBAAA,CAAAG,SAAA;MAH0BnC,cAAc;MACjCC,SAAS;MACRC;IAAU;IAAA8B,gBAAA,CAAAI,aAAA;IAAAJ,gBAAA,CAAAK,eAAA;IAAAL,gBAAA,CAAAM,UAAA,GAAA7C,gCAAA;IAAAuC,gBAAA,CAAAO,cAAA,GAAAV,EAAA;IAAA,OAAAG,gBAAA;EAAA,CAHpB;IAAAvC,gCAAA;IAC4BO,cAAc;IACjCC,SAAS;IACRC;EAAU,IAEpB,CAACF,cAAc,EAAEC,SAAS,EAAEC,UAAU,CACxC,CAAC;EAED,OAAO;IAAEU,QAAQ;IAAEe,iBAAiB;IAAEN;EAAqB,CAAC;AAC9D","ignoreList":[]}
|
|
@@ -4,7 +4,7 @@ import { useDisabledContext } from '@ledgerhq/lumen-utils-shared';
|
|
|
4
4
|
import { StyleSheet } from 'react-native';
|
|
5
5
|
import { useCommonTranslation } from "../../../i18n/index.js";
|
|
6
6
|
import { useStyleSheet } from "../../../styles/index.js";
|
|
7
|
-
import {
|
|
7
|
+
import { TriangleDown, TriangleUp } from "../../Symbols/index.js";
|
|
8
8
|
import { Box, Text } from "../Utility/index.js";
|
|
9
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
10
|
function getVariant(value) {
|
|
@@ -13,6 +13,20 @@ function getVariant(value) {
|
|
|
13
13
|
}
|
|
14
14
|
return value > 0 ? 'positive' : 'negative';
|
|
15
15
|
}
|
|
16
|
+
const iconMap = {
|
|
17
|
+
positive: TriangleUp,
|
|
18
|
+
negative: TriangleDown,
|
|
19
|
+
neutral: null
|
|
20
|
+
};
|
|
21
|
+
const iconSizeMap = {
|
|
22
|
+
md: 16,
|
|
23
|
+
sm: 12
|
|
24
|
+
};
|
|
25
|
+
const iconColorMap = {
|
|
26
|
+
positive: 'success',
|
|
27
|
+
negative: 'error',
|
|
28
|
+
neutral: 'muted'
|
|
29
|
+
};
|
|
16
30
|
export function Trend({
|
|
17
31
|
value,
|
|
18
32
|
size = 'md',
|
|
@@ -36,20 +50,9 @@ export function Trend({
|
|
|
36
50
|
variant,
|
|
37
51
|
disabled
|
|
38
52
|
});
|
|
39
|
-
const Icon =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
neutral: Minus
|
|
43
|
-
}[variant];
|
|
44
|
-
const iconSize = {
|
|
45
|
-
md: 16,
|
|
46
|
-
sm: 12
|
|
47
|
-
}[size];
|
|
48
|
-
const iconColor = {
|
|
49
|
-
positive: 'success',
|
|
50
|
-
negative: 'error',
|
|
51
|
-
neutral: 'muted'
|
|
52
|
-
}[variant];
|
|
53
|
+
const Icon = iconMap[variant];
|
|
54
|
+
const iconSize = iconSizeMap[size];
|
|
55
|
+
const iconColor = iconColorMap[variant];
|
|
53
56
|
const absoluteFormattedValue = `${Math.abs(value).toFixed(2)}%`;
|
|
54
57
|
const formattedValue = value < 0 ? `-${absoluteFormattedValue}` : absoluteFormattedValue;
|
|
55
58
|
return /*#__PURE__*/_jsxs(Box, {
|
|
@@ -63,7 +66,7 @@ export function Trend({
|
|
|
63
66
|
lx: lx,
|
|
64
67
|
style: [styles.container, style],
|
|
65
68
|
...props,
|
|
66
|
-
children: [/*#__PURE__*/_jsx(Icon, {
|
|
69
|
+
children: [Icon && /*#__PURE__*/_jsx(Icon, {
|
|
67
70
|
size: iconSize,
|
|
68
71
|
color: disabled ? 'disabled' : iconColor
|
|
69
72
|
}), /*#__PURE__*/_jsx(Text, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useDisabledContext","StyleSheet","useCommonTranslation","useStyleSheet","
|
|
1
|
+
{"version":3,"names":["useDisabledContext","StyleSheet","useCommonTranslation","useStyleSheet","TriangleDown","TriangleUp","Box","Text","jsx","_jsx","jsxs","_jsxs","getVariant","value","iconMap","positive","negative","neutral","iconSizeMap","md","sm","iconColorMap","Trend","size","lx","disabled","disabledProp","style","props","variant","consumerName","mergeWith","t","styles","useStyles","Icon","iconSize","iconColor","absoluteFormattedValue","Math","abs","toFixed","formattedValue","accessible","accessibilityLabel","accessibilityState","container","children","color","text","colors","success","error","muted","sizeMap","typographies","body3","body2","flexDirection","alignItems","gap","spacings","s2","flatten"],"sourceRoot":"../../../../../src","sources":["lib/Components/Trend/Trend.tsx"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,8BAA8B;AACjE,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,oBAAoB,QAAQ,wBAAe;AAEpD,SAASC,aAAa,QAAQ,0BAAiB;AAC/C,SAASC,YAAY,EAAEC,UAAU,QAAQ,wBAAe;AAExD,SAASC,GAAG,EAAEC,IAAI,QAAQ,qBAAY;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAKvC,SAASC,UAAUA,CAACC,KAAa,EAAgB;EAC/C,IAAIA,KAAK,KAAK,CAAC,EAAE;IACf,OAAO,SAAS;EAClB;EACA,OAAOA,KAAK,GAAG,CAAC,GAAG,UAAU,GAAG,UAAU;AAC5C;AAEA,MAAMC,OAAO,GAAG;EACdC,QAAQ,EAAEV,UAAU;EACpBW,QAAQ,EAAEZ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AAK,EAAEhB,CAAC,CAACkB,MAAM,CAACD,IAAI,CAACxB;IAAS,CAAC,CAC9C;EACH,CAAC;AACH,CAAC,EACD,CAACF,IAAI,EAAEM,OAAO,EAAEJ,QAAQ,CAC1B,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Banner.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/Components/Banner/Banner.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Banner.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/Components/Banner/Banner.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAoF3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,MAAM,GAAI,uHAYpB,WAAW,4CAyDb,CAAC"}
|
|
@@ -8,7 +8,7 @@ export type BannerProps = {
|
|
|
8
8
|
/**
|
|
9
9
|
* The main title of the banner.
|
|
10
10
|
*/
|
|
11
|
-
title?:
|
|
11
|
+
title?: ReactNode;
|
|
12
12
|
/**
|
|
13
13
|
* Optional descriptive text.
|
|
14
14
|
*/
|
|
@@ -16,11 +16,11 @@ export type BannerProps = {
|
|
|
16
16
|
/**
|
|
17
17
|
* Optional primary action.
|
|
18
18
|
*/
|
|
19
|
-
primaryAction?:
|
|
19
|
+
primaryAction?: ReactNode;
|
|
20
20
|
/**
|
|
21
21
|
* Optional secondary action.
|
|
22
22
|
*/
|
|
23
|
-
secondaryAction?:
|
|
23
|
+
secondaryAction?: ReactNode;
|
|
24
24
|
/**
|
|
25
25
|
* Optional close action.
|
|
26
26
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/Components/Banner/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IACtD;;OAEG;IACH,KAAK,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/Components/Banner/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IACtD;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;OAEG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB;;OAEG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B;;OAEG;IACH,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePillLayout.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/Components/SegmentedControl/usePillLayout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,
|
|
1
|
+
{"version":3,"file":"usePillLayout.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/Components/SegmentedControl/usePillLayout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAQN,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAOtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,wBAAgB,gCAAgC,CAC9C,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,SAAS,GAClB,MAAM,CAWR;AAED,KAAK,mBAAmB,GAAG;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,EAAE,KAAK,GAAG,OAAO,CAAC;CAC5B,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAC5B,aAAa,EACb,aAAa,EACb,QAAQ,EACR,SAAS,GACV,EAAE,mBAAmB;kBAcC,iBAAiB,KAAG,IAAI;;;;;;;;kCAiBnC,MAAM,UAAU,YAAY,KAAG,IAAI;EA0D9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Trend.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/Components/Trend/Trend.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Trend.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/Components/Trend/Trend.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AA4B1C,wBAAgB,KAAK,CAAC,EACpB,KAAK,EACL,IAAW,EACX,EAAO,EACP,QAAQ,EAAE,YAAoB,EAC9B,KAAK,EACL,GAAG,KAAK,EACT,EAAE,UAAU,2CAoCZ"}
|
package/package.json
CHANGED
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
import type { IconProps } from '../Icon';
|
|
14
14
|
import { IconButton } from '../IconButton';
|
|
15
15
|
import { Box } from '../Utility';
|
|
16
|
-
import { Wrap } from '../Wrap';
|
|
17
16
|
import type { BannerProps } from './types';
|
|
18
17
|
|
|
19
18
|
type Appearance = NonNullable<BannerProps['appearance']>;
|
|
@@ -82,6 +81,7 @@ const useStyles = ({ appearance }: { appearance: Appearance }) => {
|
|
|
82
81
|
]),
|
|
83
82
|
actionsWrapper: {
|
|
84
83
|
flexDirection: 'row',
|
|
84
|
+
flexWrap: 'wrap',
|
|
85
85
|
gap: t.spacings.s4,
|
|
86
86
|
},
|
|
87
87
|
};
|
|
@@ -169,16 +169,13 @@ export const Banner = ({
|
|
|
169
169
|
)}
|
|
170
170
|
{description && (
|
|
171
171
|
<View>
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
>
|
|
180
|
-
{description}
|
|
181
|
-
</Wrap>
|
|
172
|
+
{isTextChildren(description) ? (
|
|
173
|
+
<Text style={styles.description} numberOfLines={5}>
|
|
174
|
+
{description}
|
|
175
|
+
</Text>
|
|
176
|
+
) : (
|
|
177
|
+
description
|
|
178
|
+
)}
|
|
182
179
|
</View>
|
|
183
180
|
)}
|
|
184
181
|
</View>
|
|
@@ -9,7 +9,7 @@ export type BannerProps = {
|
|
|
9
9
|
/**
|
|
10
10
|
* The main title of the banner.
|
|
11
11
|
*/
|
|
12
|
-
title?:
|
|
12
|
+
title?: ReactNode;
|
|
13
13
|
/**
|
|
14
14
|
* Optional descriptive text.
|
|
15
15
|
*/
|
|
@@ -17,11 +17,11 @@ export type BannerProps = {
|
|
|
17
17
|
/**
|
|
18
18
|
* Optional primary action.
|
|
19
19
|
*/
|
|
20
|
-
primaryAction?:
|
|
20
|
+
primaryAction?: ReactNode;
|
|
21
21
|
/**
|
|
22
22
|
* Optional secondary action.
|
|
23
23
|
*/
|
|
24
|
-
secondaryAction?:
|
|
24
|
+
secondaryAction?: ReactNode;
|
|
25
25
|
/**
|
|
26
26
|
* Optional close action.
|
|
27
27
|
*/
|
|
@@ -12,72 +12,164 @@ const TestWrapper = ({ children }: { children: React.ReactNode }) => (
|
|
|
12
12
|
);
|
|
13
13
|
|
|
14
14
|
describe('SegmentedControl', () => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
15
|
+
describe('Rendering', () => {
|
|
16
|
+
it('renders segments with labels', () => {
|
|
17
|
+
const { getByText } = render(
|
|
18
|
+
<TestWrapper>
|
|
19
|
+
<SegmentedControl
|
|
20
|
+
selectedValue='send'
|
|
21
|
+
onSelectedChange={() => {
|
|
22
|
+
/* empty */
|
|
23
|
+
}}
|
|
24
|
+
accessibilityLabel='Transaction type'
|
|
25
|
+
>
|
|
26
|
+
<SegmentedControlButton value='send'>Send</SegmentedControlButton>
|
|
27
|
+
<SegmentedControlButton value='receive'>
|
|
28
|
+
Receive
|
|
29
|
+
</SegmentedControlButton>
|
|
30
|
+
</SegmentedControl>
|
|
31
|
+
</TestWrapper>,
|
|
32
|
+
);
|
|
33
|
+
expect(getByText('Send')).toBeTruthy();
|
|
34
|
+
expect(getByText('Receive')).toBeTruthy();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('renders trailingContent inside segment buttons', () => {
|
|
38
|
+
const { getByLabelText } = render(
|
|
39
|
+
<TestWrapper>
|
|
40
|
+
<SegmentedControl
|
|
41
|
+
selectedValue='tokens'
|
|
42
|
+
onSelectedChange={() => {
|
|
43
|
+
/* empty */
|
|
44
|
+
}}
|
|
45
|
+
accessibilityLabel='Asset section'
|
|
46
|
+
>
|
|
47
|
+
<SegmentedControlButton
|
|
48
|
+
value='tokens'
|
|
49
|
+
trailingContent={
|
|
50
|
+
<DotCount value={3} accessibilityLabel='3 tokens' />
|
|
51
|
+
}
|
|
52
|
+
>
|
|
53
|
+
Tokens
|
|
54
|
+
</SegmentedControlButton>
|
|
55
|
+
<SegmentedControlButton value='nfts'>NFTs</SegmentedControlButton>
|
|
56
|
+
</SegmentedControl>
|
|
57
|
+
</TestWrapper>,
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
expect(getByLabelText('3 tokens')).toBeTruthy();
|
|
61
|
+
});
|
|
34
62
|
});
|
|
35
63
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
64
|
+
describe('States', () => {
|
|
65
|
+
it('marks the selected segment with accessibilityState', () => {
|
|
66
|
+
const { getByTestId } = render(
|
|
67
|
+
<TestWrapper>
|
|
68
|
+
<SegmentedControl
|
|
69
|
+
selectedValue='receive'
|
|
70
|
+
onSelectedChange={() => {}}
|
|
71
|
+
accessibilityLabel='Transaction type'
|
|
72
|
+
>
|
|
73
|
+
<SegmentedControlButton value='send' testID='seg-send'>
|
|
74
|
+
Send
|
|
75
|
+
</SegmentedControlButton>
|
|
76
|
+
<SegmentedControlButton value='receive' testID='seg-receive'>
|
|
77
|
+
Receive
|
|
78
|
+
</SegmentedControlButton>
|
|
79
|
+
</SegmentedControl>
|
|
80
|
+
</TestWrapper>,
|
|
81
|
+
);
|
|
52
82
|
|
|
53
|
-
|
|
83
|
+
expect(getByTestId('seg-send').props.accessibilityState).toMatchObject({
|
|
84
|
+
selected: false,
|
|
85
|
+
});
|
|
86
|
+
expect(getByTestId('seg-receive').props.accessibilityState).toMatchObject(
|
|
87
|
+
{ selected: true },
|
|
88
|
+
);
|
|
89
|
+
});
|
|
54
90
|
|
|
55
|
-
|
|
56
|
-
|
|
91
|
+
it('marks a pre-selected non-first segment as selected on initial render (fixed layout)', () => {
|
|
92
|
+
const { getByTestId } = render(
|
|
93
|
+
<TestWrapper>
|
|
94
|
+
<SegmentedControl
|
|
95
|
+
selectedValue='blame'
|
|
96
|
+
onSelectedChange={() => {}}
|
|
97
|
+
tabLayout='fixed'
|
|
98
|
+
accessibilityLabel='File view'
|
|
99
|
+
>
|
|
100
|
+
<SegmentedControlButton value='preview' testID='seg-preview'>
|
|
101
|
+
Preview
|
|
102
|
+
</SegmentedControlButton>
|
|
103
|
+
<SegmentedControlButton value='raw' testID='seg-raw'>
|
|
104
|
+
Raw
|
|
105
|
+
</SegmentedControlButton>
|
|
106
|
+
<SegmentedControlButton value='blame' testID='seg-blame'>
|
|
107
|
+
Blame
|
|
108
|
+
</SegmentedControlButton>
|
|
109
|
+
</SegmentedControl>
|
|
110
|
+
</TestWrapper>,
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
expect(getByTestId('seg-preview').props.accessibilityState).toMatchObject(
|
|
114
|
+
{ selected: false },
|
|
115
|
+
);
|
|
116
|
+
expect(getByTestId('seg-blame').props.accessibilityState).toMatchObject({
|
|
117
|
+
selected: true,
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('marks a pre-selected non-first segment as selected on initial render (fit layout)', () => {
|
|
122
|
+
const { getByTestId } = render(
|
|
123
|
+
<TestWrapper>
|
|
124
|
+
<SegmentedControl
|
|
125
|
+
selectedValue='blame'
|
|
126
|
+
onSelectedChange={() => {}}
|
|
127
|
+
tabLayout='fit'
|
|
128
|
+
accessibilityLabel='File view'
|
|
129
|
+
>
|
|
130
|
+
<SegmentedControlButton value='preview' testID='seg-preview'>
|
|
131
|
+
Preview
|
|
132
|
+
</SegmentedControlButton>
|
|
133
|
+
<SegmentedControlButton value='raw' testID='seg-raw'>
|
|
134
|
+
Raw
|
|
135
|
+
</SegmentedControlButton>
|
|
136
|
+
<SegmentedControlButton value='blame' testID='seg-blame'>
|
|
137
|
+
Blame
|
|
138
|
+
</SegmentedControlButton>
|
|
139
|
+
</SegmentedControl>
|
|
140
|
+
</TestWrapper>,
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
expect(getByTestId('seg-preview').props.accessibilityState).toMatchObject(
|
|
144
|
+
{ selected: false },
|
|
145
|
+
);
|
|
146
|
+
expect(getByTestId('seg-blame').props.accessibilityState).toMatchObject({
|
|
147
|
+
selected: true,
|
|
148
|
+
});
|
|
149
|
+
});
|
|
57
150
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
>
|
|
68
|
-
<SegmentedControlButton
|
|
69
|
-
value='tokens'
|
|
70
|
-
trailingContent={
|
|
71
|
-
<DotCount value={3} accessibilityLabel='3 tokens' />
|
|
72
|
-
}
|
|
151
|
+
it('can change selection away from a pre-selected non-first segment (fit layout)', () => {
|
|
152
|
+
const onSelectedChange = jest.fn();
|
|
153
|
+
const { getByText } = render(
|
|
154
|
+
<TestWrapper>
|
|
155
|
+
<SegmentedControl
|
|
156
|
+
selectedValue='blame'
|
|
157
|
+
onSelectedChange={onSelectedChange}
|
|
158
|
+
tabLayout='fit'
|
|
159
|
+
accessibilityLabel='File view'
|
|
73
160
|
>
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
161
|
+
<SegmentedControlButton value='preview'>
|
|
162
|
+
Preview
|
|
163
|
+
</SegmentedControlButton>
|
|
164
|
+
<SegmentedControlButton value='raw'>Raw</SegmentedControlButton>
|
|
165
|
+
<SegmentedControlButton value='blame'>Blame</SegmentedControlButton>
|
|
166
|
+
</SegmentedControl>
|
|
167
|
+
</TestWrapper>,
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
fireEvent.press(getByText('Preview'));
|
|
80
171
|
|
|
81
|
-
|
|
172
|
+
expect(onSelectedChange).toHaveBeenCalledWith('preview');
|
|
173
|
+
});
|
|
82
174
|
});
|
|
83
175
|
});
|
|
@@ -6,6 +6,7 @@ import React, {
|
|
|
6
6
|
useEffect,
|
|
7
7
|
useMemo,
|
|
8
8
|
useRef,
|
|
9
|
+
useState,
|
|
9
10
|
} from 'react';
|
|
10
11
|
import type { LayoutChangeEvent } from 'react-native';
|
|
11
12
|
import {
|
|
@@ -49,7 +50,9 @@ export function usePillLayout({
|
|
|
49
50
|
const pillWidth = useSharedValue(0);
|
|
50
51
|
const pillHeight = useSharedValue(0);
|
|
51
52
|
const hasLayoutRef = useRef(false);
|
|
53
|
+
const animatePillRef = useRef(false);
|
|
52
54
|
const buttonLayoutsRef = useRef(new Map<string, ButtonLayout>());
|
|
55
|
+
const [layoutReady, setLayoutReady] = useState(false);
|
|
53
56
|
|
|
54
57
|
const timingConfig = useTimingConfig({
|
|
55
58
|
duration: 300,
|
|
@@ -67,9 +70,7 @@ export function usePillLayout({
|
|
|
67
70
|
|
|
68
71
|
if (!hasLayoutRef.current) {
|
|
69
72
|
hasLayoutRef.current = true;
|
|
70
|
-
|
|
71
|
-
pillTranslateX.value = selectedIndex * slotWidth;
|
|
72
|
-
}
|
|
73
|
+
setLayoutReady(true);
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
};
|
|
@@ -78,31 +79,38 @@ export function usePillLayout({
|
|
|
78
79
|
(value: string, layout: ButtonLayout): void => {
|
|
79
80
|
buttonLayoutsRef.current.set(value, layout);
|
|
80
81
|
|
|
81
|
-
if (
|
|
82
|
+
if (
|
|
83
|
+
tabLayout === 'fit' &&
|
|
84
|
+
!hasLayoutRef.current &&
|
|
85
|
+
value === selectedValue
|
|
86
|
+
) {
|
|
82
87
|
hasLayoutRef.current = true;
|
|
83
|
-
|
|
84
|
-
pillTranslateX.value = layout.x;
|
|
85
|
-
pillWidth.value = layout.width;
|
|
86
|
-
}
|
|
88
|
+
setLayoutReady(true);
|
|
87
89
|
}
|
|
88
90
|
},
|
|
89
|
-
[tabLayout, selectedValue
|
|
91
|
+
[tabLayout, selectedValue],
|
|
90
92
|
);
|
|
91
93
|
|
|
92
94
|
useEffect(() => {
|
|
93
95
|
if (!hasLayoutRef.current) return;
|
|
94
96
|
|
|
97
|
+
const skipAnimation = !animatePillRef.current;
|
|
98
|
+
if (skipAnimation) {
|
|
99
|
+
animatePillRef.current = true;
|
|
100
|
+
}
|
|
101
|
+
const config = skipAnimation ? { duration: 0 } : timingConfig;
|
|
102
|
+
|
|
95
103
|
if (tabLayout === 'fit') {
|
|
96
104
|
const layout = buttonLayoutsRef.current.get(selectedValue);
|
|
97
105
|
if (layout) {
|
|
98
|
-
pillTranslateX.value = withTiming(layout.x,
|
|
99
|
-
pillWidth.value = withTiming(layout.width,
|
|
106
|
+
pillTranslateX.value = withTiming(layout.x, config);
|
|
107
|
+
pillWidth.value = withTiming(layout.width, config);
|
|
100
108
|
}
|
|
101
109
|
} else {
|
|
102
110
|
if (selectedIndex >= 0 && pillWidth.value > 0) {
|
|
103
111
|
pillTranslateX.value = withTiming(
|
|
104
112
|
selectedIndex * pillWidth.value,
|
|
105
|
-
|
|
113
|
+
config,
|
|
106
114
|
);
|
|
107
115
|
}
|
|
108
116
|
}
|
|
@@ -113,6 +121,7 @@ export function usePillLayout({
|
|
|
113
121
|
pillWidth,
|
|
114
122
|
pillTranslateX,
|
|
115
123
|
timingConfig,
|
|
124
|
+
layoutReady,
|
|
116
125
|
]);
|
|
117
126
|
|
|
118
127
|
const animatedPillStyle = useAnimatedStyle(
|
|
@@ -3,7 +3,7 @@ import { StyleSheet } from 'react-native';
|
|
|
3
3
|
import { useCommonTranslation } from '../../../i18n';
|
|
4
4
|
import type { LumenTextStyle } from '../../../styles';
|
|
5
5
|
import { useStyleSheet } from '../../../styles';
|
|
6
|
-
import {
|
|
6
|
+
import { TriangleDown, TriangleUp } from '../../Symbols';
|
|
7
7
|
import type { IconSize } from '../Icon';
|
|
8
8
|
import { Box, Text } from '../Utility';
|
|
9
9
|
import type { TrendProps } from './types';
|
|
@@ -17,6 +17,23 @@ function getVariant(value: number): TrendVariant {
|
|
|
17
17
|
return value > 0 ? 'positive' : 'negative';
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
const iconMap = {
|
|
21
|
+
positive: TriangleUp,
|
|
22
|
+
negative: TriangleDown,
|
|
23
|
+
neutral: null,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const iconSizeMap: Record<NonNullable<TrendProps['size']>, IconSize> = {
|
|
27
|
+
md: 16,
|
|
28
|
+
sm: 12,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const iconColorMap: Record<TrendVariant, LumenTextStyle['color']> = {
|
|
32
|
+
positive: 'success',
|
|
33
|
+
negative: 'error',
|
|
34
|
+
neutral: 'muted',
|
|
35
|
+
};
|
|
36
|
+
|
|
20
37
|
export function Trend({
|
|
21
38
|
value,
|
|
22
39
|
size = 'md',
|
|
@@ -35,26 +52,9 @@ export function Trend({
|
|
|
35
52
|
|
|
36
53
|
const styles = useStyles({ size, variant, disabled });
|
|
37
54
|
|
|
38
|
-
const Icon =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
neutral: Minus,
|
|
42
|
-
}[variant];
|
|
43
|
-
|
|
44
|
-
const iconSize = (
|
|
45
|
-
{
|
|
46
|
-
md: 16,
|
|
47
|
-
sm: 12,
|
|
48
|
-
} as const
|
|
49
|
-
)[size] as IconSize;
|
|
50
|
-
|
|
51
|
-
const iconColor = (
|
|
52
|
-
{
|
|
53
|
-
positive: 'success',
|
|
54
|
-
negative: 'error',
|
|
55
|
-
neutral: 'muted',
|
|
56
|
-
} as const
|
|
57
|
-
)[variant] as LumenTextStyle['color'];
|
|
55
|
+
const Icon = iconMap[variant];
|
|
56
|
+
const iconSize = iconSizeMap[size];
|
|
57
|
+
const iconColor = iconColorMap[variant];
|
|
58
58
|
|
|
59
59
|
const absoluteFormattedValue = `${Math.abs(value).toFixed(2)}%`;
|
|
60
60
|
const formattedValue =
|
|
@@ -71,7 +71,9 @@ export function Trend({
|
|
|
71
71
|
style={[styles.container, style]}
|
|
72
72
|
{...props}
|
|
73
73
|
>
|
|
74
|
-
|
|
74
|
+
{Icon && (
|
|
75
|
+
<Icon size={iconSize} color={disabled ? 'disabled' : iconColor} />
|
|
76
|
+
)}
|
|
75
77
|
<Text style={styles.text}>{formattedValue}</Text>
|
|
76
78
|
</Box>
|
|
77
79
|
);
|