@ledgerhq/lumen-ui-rnative 0.1.36 → 0.1.38
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/Animations/Pulse/Pulse.mdx +1 -1
- package/dist/module/lib/Animations/Spin/Spin.mdx +1 -1
- package/dist/module/lib/Components/AddressInput/AddressInput.mdx +1 -1
- package/dist/module/lib/Components/AmountDisplay/AmountDisplay.js +68 -39
- package/dist/module/lib/Components/AmountDisplay/AmountDisplay.js.map +1 -1
- package/dist/module/lib/Components/AmountDisplay/AmountDisplay.mdx +7 -1
- package/dist/module/lib/Components/AmountDisplay/AmountDisplay.stories.js +24 -0
- package/dist/module/lib/Components/AmountDisplay/AmountDisplay.stories.js.map +1 -1
- package/dist/module/lib/Components/AmountDisplay/types.js.map +1 -1
- package/dist/module/lib/Components/AmountInput/AmountInput.js +109 -72
- package/dist/module/lib/Components/AmountInput/AmountInput.js.map +1 -1
- package/dist/module/lib/Components/AmountInput/AmountInput.mdx +13 -1
- package/dist/module/lib/Components/AmountInput/AmountInput.stories.js +53 -0
- package/dist/module/lib/Components/AmountInput/AmountInput.stories.js.map +1 -1
- package/dist/module/lib/Components/Avatar/Avatar.js +6 -5
- package/dist/module/lib/Components/Avatar/Avatar.js.map +1 -1
- package/dist/module/lib/Components/Avatar/Avatar.mdx +3 -1
- package/dist/module/lib/Components/Avatar/Avatar.test.js +10 -13
- package/dist/module/lib/Components/Avatar/Avatar.test.js.map +1 -1
- package/dist/module/lib/Components/Banner/Banner.mdx +1 -1
- package/dist/module/lib/Components/BottomSheet/BottomSheet.mdx +1 -1
- package/dist/module/lib/Components/Button/Button.mdx +1 -1
- package/dist/module/lib/Components/Card/Card.stories.js +4 -9
- package/dist/module/lib/Components/Card/Card.stories.js.map +1 -1
- package/dist/module/lib/Components/CardButton/CardButton.mdx +1 -1
- package/dist/module/lib/Components/Checkbox/Checkbox.mdx +1 -1
- package/dist/module/lib/Components/Divider/Divider.mdx +1 -1
- package/dist/module/lib/Components/DotIcon/DotIcon.js +51 -27
- package/dist/module/lib/Components/DotIcon/DotIcon.js.map +1 -1
- package/dist/module/lib/Components/DotIcon/DotIcon.mdx +92 -0
- package/dist/module/lib/Components/DotIcon/DotIcon.stories.js +57 -0
- package/dist/module/lib/Components/DotIcon/DotIcon.stories.js.map +1 -1
- package/dist/module/lib/Components/DotIndicator/DotIndicator.js +5 -5
- package/dist/module/lib/Components/DotIndicator/DotIndicator.js.map +1 -1
- package/dist/module/lib/Components/DotIndicator/DotIndicator.mdx +4 -4
- package/dist/module/lib/Components/DotIndicator/DotIndicator.stories.js +3 -3
- package/dist/module/lib/Components/DotIndicator/DotIndicator.test.js +12 -2
- package/dist/module/lib/Components/DotIndicator/DotIndicator.test.js.map +1 -1
- package/dist/module/lib/Components/DotSymbol/DotSymbol.js +59 -34
- package/dist/module/lib/Components/DotSymbol/DotSymbol.js.map +1 -1
- package/dist/module/lib/Components/DotSymbol/DotSymbol.mdx +79 -2
- package/dist/module/lib/Components/DotSymbol/DotSymbol.stories.js +60 -0
- package/dist/module/lib/Components/DotSymbol/DotSymbol.stories.js.map +1 -1
- package/dist/module/lib/Components/IconButton/IconButton.mdx +1 -1
- package/dist/module/lib/Components/InteractiveIcon/InteractiveIcon.mdx +1 -1
- package/dist/module/lib/Components/Label/Label.js +1 -1
- package/dist/module/lib/Components/Link/Link.mdx +1 -1
- package/dist/module/lib/Components/MediaBanner/MediaBanner.mdx +1 -1
- package/dist/module/lib/Components/MediaButton/MediaButton.js +19 -19
- package/dist/module/lib/Components/MediaButton/MediaButton.js.map +1 -1
- package/dist/module/lib/Components/MediaButton/MediaButton.mdx +5 -5
- package/dist/module/lib/Components/MediaButton/MediaButton.stories.js +17 -17
- package/dist/module/lib/Components/MediaButton/MediaButton.stories.js.map +1 -1
- package/dist/module/lib/Components/MediaButton/MediaButton.test.js +4 -4
- package/dist/module/lib/Components/MediaButton/MediaButton.test.js.map +1 -1
- package/dist/module/lib/Components/MediaImage/MediaImage.js +24 -6
- package/dist/module/lib/Components/MediaImage/MediaImage.js.map +1 -1
- package/dist/module/lib/Components/MediaImage/MediaImage.mdx +1 -1
- package/dist/module/lib/Components/MediaImage/MediaImage.stories.js +47 -0
- package/dist/module/lib/Components/MediaImage/MediaImage.stories.js.map +1 -1
- package/dist/module/lib/Components/NavBar/CoinCapsule.js +2 -2
- package/dist/module/lib/Components/NavBar/CoinCapsule.js.map +1 -1
- package/dist/module/lib/Components/NavBar/NavBar.js +2 -2
- package/dist/module/lib/Components/NavBar/NavBar.js.map +1 -1
- package/dist/module/lib/Components/NavBar/NavBar.mdx +2 -2
- package/dist/module/lib/Components/NavBar/NavBar.stories.js +1 -1
- package/dist/module/lib/Components/NavBar/NavBar.stories.js.map +1 -1
- package/dist/module/lib/Components/NavBar/NavBar.test.js +3 -3
- package/dist/module/lib/Components/NavBar/NavBar.test.js.map +1 -1
- package/dist/module/lib/Components/OptionList/OptionList.mdx +1 -1
- package/dist/module/lib/Components/OptionList/OptionList.stories.js +4 -4
- package/dist/module/lib/Components/OptionList/OptionList.stories.js.map +1 -1
- package/dist/module/lib/Components/PageIndicator/PageIndicator.js +13 -8
- package/dist/module/lib/Components/PageIndicator/PageIndicator.js.map +1 -1
- package/dist/module/lib/Components/PageIndicator/PageIndicator.test.js +58 -0
- package/dist/module/lib/Components/PageIndicator/PageIndicator.test.js.map +1 -1
- package/dist/module/lib/Components/SearchInput/SearchInput.mdx +1 -1
- package/dist/module/lib/Components/SegmentedControl/SegmentedControl.mdx +1 -1
- package/dist/module/lib/Components/Spinner/Spinner.mdx +1 -1
- package/dist/module/lib/Components/Spot/Spot.mdx +1 -1
- package/dist/module/lib/Components/Stepper/Stepper.mdx +1 -1
- package/dist/module/lib/Components/Subheader/Subheader.mdx +1 -1
- package/dist/module/lib/Components/Switch/Switch.mdx +1 -1
- package/dist/module/lib/Components/TabBar/TabBar.mdx +1 -1
- package/dist/module/lib/Components/TextInput/TextInput.mdx +1 -1
- package/dist/module/lib/Components/ThemeProvider/ThemeProvider.js +2 -5
- package/dist/module/lib/Components/ThemeProvider/ThemeProvider.js.map +1 -1
- package/dist/module/lib/Components/Tile/Tile.mdx +1 -1
- package/dist/module/lib/Components/Tooltip/Tooltip.mdx +1 -1
- package/dist/module/lib/Components/index.js +0 -1
- package/dist/module/lib/Components/index.js.map +1 -1
- package/dist/module/lib/Symbols/Icons/Lightbulb.js +3 -3
- package/dist/module/lib/Symbols/Icons/Lightbulb.js.map +1 -1
- package/dist/typescript/src/lib/Components/AmountDisplay/AmountDisplay.d.ts +1 -1
- package/dist/typescript/src/lib/Components/AmountDisplay/AmountDisplay.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/AmountDisplay/index.d.ts +1 -1
- package/dist/typescript/src/lib/Components/AmountDisplay/index.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/AmountDisplay/types.d.ts +10 -3
- package/dist/typescript/src/lib/Components/AmountDisplay/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/AmountInput/AmountInput.d.ts +1 -1
- package/dist/typescript/src/lib/Components/AmountInput/AmountInput.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/AmountInput/types.d.ts +12 -0
- package/dist/typescript/src/lib/Components/AmountInput/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/Avatar/Avatar.d.ts +1 -1
- package/dist/typescript/src/lib/Components/Avatar/Avatar.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/DotIcon/DotIcon.d.ts +3 -2
- package/dist/typescript/src/lib/Components/DotIcon/DotIcon.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/DotIcon/types.d.ts +7 -1
- package/dist/typescript/src/lib/Components/DotIcon/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/DotIndicator/types.d.ts +2 -2
- package/dist/typescript/src/lib/Components/DotSymbol/DotSymbol.d.ts +1 -1
- package/dist/typescript/src/lib/Components/DotSymbol/DotSymbol.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/DotSymbol/types.d.ts +7 -1
- package/dist/typescript/src/lib/Components/DotSymbol/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/Label/Label.d.ts +1 -1
- package/dist/typescript/src/lib/Components/MediaButton/MediaButton.d.ts +5 -5
- package/dist/typescript/src/lib/Components/MediaButton/MediaButton.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/MediaButton/types.d.ts +6 -6
- package/dist/typescript/src/lib/Components/MediaButton/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/MediaImage/MediaImage.d.ts +1 -1
- package/dist/typescript/src/lib/Components/MediaImage/MediaImage.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/MediaImage/types.d.ts +7 -1
- package/dist/typescript/src/lib/Components/MediaImage/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/NavBar/CoinCapsule.d.ts +1 -1
- package/dist/typescript/src/lib/Components/NavBar/CoinCapsule.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/NavBar/NavBar.d.ts +1 -1
- package/dist/typescript/src/lib/Components/NavBar/NavBar.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/NavBar/types.d.ts +3 -3
- package/dist/typescript/src/lib/Components/NavBar/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/PageIndicator/PageIndicator.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/ThemeProvider/ThemeProvider.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/index.d.ts +0 -1
- package/dist/typescript/src/lib/Components/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/lib/Animations/Pulse/Pulse.mdx +1 -1
- package/src/lib/Animations/Spin/Spin.mdx +1 -1
- package/src/lib/Components/AddressInput/AddressInput.mdx +1 -1
- package/src/lib/Components/AmountDisplay/AmountDisplay.mdx +7 -1
- package/src/lib/Components/AmountDisplay/AmountDisplay.stories.tsx +18 -0
- package/src/lib/Components/AmountDisplay/AmountDisplay.tsx +71 -40
- package/src/lib/Components/AmountDisplay/index.ts +5 -1
- package/src/lib/Components/AmountDisplay/types.ts +12 -3
- package/src/lib/Components/AmountInput/AmountInput.mdx +13 -1
- package/src/lib/Components/AmountInput/AmountInput.stories.tsx +68 -1
- package/src/lib/Components/AmountInput/AmountInput.tsx +118 -75
- package/src/lib/Components/AmountInput/types.ts +14 -0
- package/src/lib/Components/Avatar/Avatar.mdx +3 -1
- package/src/lib/Components/Avatar/Avatar.test.tsx +16 -18
- package/src/lib/Components/Avatar/Avatar.tsx +9 -8
- package/src/lib/Components/Banner/Banner.mdx +1 -1
- package/src/lib/Components/BottomSheet/BottomSheet.mdx +1 -1
- package/src/lib/Components/Button/Button.mdx +1 -1
- package/src/lib/Components/Card/Card.stories.tsx +1 -3
- package/src/lib/Components/CardButton/CardButton.mdx +1 -1
- package/src/lib/Components/Checkbox/Checkbox.mdx +1 -1
- package/src/lib/Components/Divider/Divider.mdx +1 -1
- package/src/lib/Components/DotIcon/DotIcon.mdx +92 -0
- package/src/lib/Components/DotIcon/DotIcon.stories.tsx +43 -0
- package/src/lib/Components/DotIcon/DotIcon.tsx +35 -15
- package/src/lib/Components/DotIcon/types.ts +7 -1
- package/src/lib/Components/DotIndicator/DotIndicator.mdx +4 -4
- package/src/lib/Components/DotIndicator/DotIndicator.stories.tsx +2 -2
- package/src/lib/Components/DotIndicator/DotIndicator.test.tsx +12 -2
- package/src/lib/Components/DotIndicator/DotIndicator.tsx +5 -5
- package/src/lib/Components/DotIndicator/types.ts +2 -2
- package/src/lib/Components/DotSymbol/DotSymbol.mdx +79 -2
- package/src/lib/Components/DotSymbol/DotSymbol.stories.tsx +32 -0
- package/src/lib/Components/DotSymbol/DotSymbol.tsx +46 -25
- package/src/lib/Components/DotSymbol/types.ts +7 -1
- package/src/lib/Components/IconButton/IconButton.mdx +1 -1
- package/src/lib/Components/InteractiveIcon/InteractiveIcon.mdx +1 -1
- package/src/lib/Components/Label/Label.tsx +1 -1
- package/src/lib/Components/Link/Link.mdx +1 -1
- package/src/lib/Components/MediaBanner/MediaBanner.mdx +1 -1
- package/src/lib/Components/MediaButton/MediaButton.mdx +5 -5
- package/src/lib/Components/MediaButton/MediaButton.stories.tsx +29 -15
- package/src/lib/Components/MediaButton/MediaButton.test.tsx +4 -4
- package/src/lib/Components/MediaButton/MediaButton.tsx +35 -22
- package/src/lib/Components/MediaButton/types.ts +6 -6
- package/src/lib/Components/MediaImage/MediaImage.mdx +1 -1
- package/src/lib/Components/MediaImage/MediaImage.stories.tsx +21 -0
- package/src/lib/Components/MediaImage/MediaImage.tsx +14 -2
- package/src/lib/Components/MediaImage/types.ts +7 -1
- package/src/lib/Components/NavBar/CoinCapsule.tsx +2 -2
- package/src/lib/Components/NavBar/NavBar.mdx +2 -2
- package/src/lib/Components/NavBar/NavBar.stories.tsx +3 -1
- package/src/lib/Components/NavBar/NavBar.test.tsx +3 -3
- package/src/lib/Components/NavBar/NavBar.tsx +2 -2
- package/src/lib/Components/NavBar/types.ts +3 -3
- package/src/lib/Components/OptionList/OptionList.mdx +1 -1
- package/src/lib/Components/OptionList/OptionList.stories.tsx +4 -4
- package/src/lib/Components/PageIndicator/PageIndicator.test.tsx +78 -0
- package/src/lib/Components/PageIndicator/PageIndicator.tsx +15 -7
- package/src/lib/Components/SearchInput/SearchInput.mdx +1 -1
- package/src/lib/Components/SegmentedControl/SegmentedControl.mdx +1 -1
- package/src/lib/Components/Spinner/Spinner.mdx +1 -1
- package/src/lib/Components/Spot/Spot.mdx +1 -1
- package/src/lib/Components/Stepper/Stepper.mdx +1 -1
- package/src/lib/Components/Subheader/Subheader.mdx +1 -1
- package/src/lib/Components/Switch/Switch.mdx +1 -1
- package/src/lib/Components/TabBar/TabBar.mdx +1 -1
- package/src/lib/Components/TextInput/TextInput.mdx +1 -1
- package/src/lib/Components/ThemeProvider/ThemeProvider.tsx +1 -4
- package/src/lib/Components/Tile/Tile.mdx +1 -1
- package/src/lib/Components/Tooltip/Tooltip.mdx +1 -1
- package/src/lib/Components/index.ts +0 -1
- package/src/lib/Symbols/Icons/Lightbulb.tsx +3 -3
- package/dist/module/lib/Components/Select/GlobalSelectBottomSheet.js +0 -155
- package/dist/module/lib/Components/Select/GlobalSelectBottomSheet.js.map +0 -1
- package/dist/module/lib/Components/Select/GlobalSelectContext.js +0 -78
- package/dist/module/lib/Components/Select/GlobalSelectContext.js.map +0 -1
- package/dist/module/lib/Components/Select/Select.js +0 -366
- package/dist/module/lib/Components/Select/Select.js.map +0 -1
- package/dist/module/lib/Components/Select/Select.mdx +0 -596
- package/dist/module/lib/Components/Select/Select.stories.js +0 -304
- package/dist/module/lib/Components/Select/Select.stories.js.map +0 -1
- package/dist/module/lib/Components/Select/Select.test.js +0 -123
- package/dist/module/lib/Components/Select/Select.test.js.map +0 -1
- package/dist/module/lib/Components/Select/SelectContext.js +0 -38
- package/dist/module/lib/Components/Select/SelectContext.js.map +0 -1
- package/dist/module/lib/Components/Select/index.js +0 -6
- package/dist/module/lib/Components/Select/index.js.map +0 -1
- package/dist/module/lib/Components/Select/types.js +0 -4
- package/dist/module/lib/Components/Select/types.js.map +0 -1
- package/dist/typescript/src/lib/Components/Select/GlobalSelectBottomSheet.d.ts +0 -20
- package/dist/typescript/src/lib/Components/Select/GlobalSelectBottomSheet.d.ts.map +0 -1
- package/dist/typescript/src/lib/Components/Select/GlobalSelectContext.d.ts +0 -44
- package/dist/typescript/src/lib/Components/Select/GlobalSelectContext.d.ts.map +0 -1
- package/dist/typescript/src/lib/Components/Select/Select.d.ts +0 -52
- package/dist/typescript/src/lib/Components/Select/Select.d.ts.map +0 -1
- package/dist/typescript/src/lib/Components/Select/SelectContext.d.ts +0 -36
- package/dist/typescript/src/lib/Components/Select/SelectContext.d.ts.map +0 -1
- package/dist/typescript/src/lib/Components/Select/index.d.ts +0 -4
- package/dist/typescript/src/lib/Components/Select/index.d.ts.map +0 -1
- package/dist/typescript/src/lib/Components/Select/types.d.ts +0 -130
- package/dist/typescript/src/lib/Components/Select/types.d.ts.map +0 -1
- package/src/lib/Components/Select/GlobalSelectBottomSheet.tsx +0 -180
- package/src/lib/Components/Select/GlobalSelectContext.tsx +0 -103
- package/src/lib/Components/Select/Select.mdx +0 -596
- package/src/lib/Components/Select/Select.stories.tsx +0 -266
- package/src/lib/Components/Select/Select.test.tsx +0 -117
- package/src/lib/Components/Select/Select.tsx +0 -469
- package/src/lib/Components/Select/SelectContext.tsx +0 -68
- package/src/lib/Components/Select/index.ts +0 -3
- package/src/lib/Components/Select/types.ts +0 -149
|
@@ -15,6 +15,12 @@ const renderWithProvider = (component: React.ReactElement) => {
|
|
|
15
15
|
);
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
+
const wrapWithProvider = (component: React.ReactElement) => (
|
|
19
|
+
<ThemeProvider themes={ledgerLiveThemes} colorScheme='dark' locale='en'>
|
|
20
|
+
{component}
|
|
21
|
+
</ThemeProvider>
|
|
22
|
+
);
|
|
23
|
+
|
|
18
24
|
describe('PageIndicator Component', () => {
|
|
19
25
|
describe('Rendering', () => {
|
|
20
26
|
it('should render with required props', () => {
|
|
@@ -161,6 +167,78 @@ describe('PageIndicator Component', () => {
|
|
|
161
167
|
});
|
|
162
168
|
});
|
|
163
169
|
|
|
170
|
+
describe('Re-rendering', () => {
|
|
171
|
+
// Regression: dot/strip styles must update when currentPage changes.
|
|
172
|
+
// One bug has produced the same broken-on-update symptom:
|
|
173
|
+
// 1. Wrapping in Animated.createAnimatedComponent(Box) — Box flattens
|
|
174
|
+
// style arrays via StyleSheet.flatten, which snapshots reanimated
|
|
175
|
+
// animated styles and stops updates.
|
|
176
|
+
// Initial render looked correct in both cases — only re-render exposed
|
|
177
|
+
// the issue, which is what the tests below exercise.
|
|
178
|
+
it('updates the rendered tree when currentPage changes', () => {
|
|
179
|
+
const { rerender } = renderWithProvider(
|
|
180
|
+
<PageIndicator
|
|
181
|
+
testID='page-indicator'
|
|
182
|
+
currentPage={1}
|
|
183
|
+
totalPages={5}
|
|
184
|
+
/>,
|
|
185
|
+
);
|
|
186
|
+
const treeBefore = JSON.stringify(screen.toJSON());
|
|
187
|
+
|
|
188
|
+
rerender(
|
|
189
|
+
wrapWithProvider(
|
|
190
|
+
<PageIndicator
|
|
191
|
+
testID='page-indicator'
|
|
192
|
+
currentPage={3}
|
|
193
|
+
totalPages={5}
|
|
194
|
+
/>,
|
|
195
|
+
),
|
|
196
|
+
);
|
|
197
|
+
const treeAfter = JSON.stringify(screen.toJSON());
|
|
198
|
+
|
|
199
|
+
expect(treeAfter).not.toEqual(treeBefore);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it('updates the active dot style when currentPage changes', () => {
|
|
203
|
+
type Node = {
|
|
204
|
+
type: string;
|
|
205
|
+
props: { style?: unknown };
|
|
206
|
+
children: Node[] | null;
|
|
207
|
+
};
|
|
208
|
+
const getDotStyles = (): unknown[] => {
|
|
209
|
+
const root = screen.toJSON() as Node | null;
|
|
210
|
+
if (!root?.children) throw new Error('Expected container children');
|
|
211
|
+
const viewport = root.children[0];
|
|
212
|
+
if (!viewport?.children) throw new Error('Expected viewport children');
|
|
213
|
+
const strip = viewport.children[0];
|
|
214
|
+
if (!strip?.children) throw new Error('Expected strip children');
|
|
215
|
+
return strip.children.map((dot) => dot.props.style);
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
const { rerender } = renderWithProvider(
|
|
219
|
+
<PageIndicator
|
|
220
|
+
testID='page-indicator'
|
|
221
|
+
currentPage={1}
|
|
222
|
+
totalPages={5}
|
|
223
|
+
/>,
|
|
224
|
+
);
|
|
225
|
+
const stylesBefore = JSON.stringify(getDotStyles());
|
|
226
|
+
|
|
227
|
+
rerender(
|
|
228
|
+
wrapWithProvider(
|
|
229
|
+
<PageIndicator
|
|
230
|
+
testID='page-indicator'
|
|
231
|
+
currentPage={3}
|
|
232
|
+
totalPages={5}
|
|
233
|
+
/>,
|
|
234
|
+
),
|
|
235
|
+
);
|
|
236
|
+
const stylesAfter = JSON.stringify(getDotStyles());
|
|
237
|
+
|
|
238
|
+
expect(stylesAfter).not.toEqual(stylesBefore);
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
|
|
164
242
|
describe('Props', () => {
|
|
165
243
|
it('should accept ref prop', () => {
|
|
166
244
|
const ref = createRef<ComponentRef<typeof PageIndicator>>();
|
|
@@ -12,7 +12,6 @@ import { useTimingConfig } from '../../Animations/useTimingConfig';
|
|
|
12
12
|
import { Box } from '../Utility';
|
|
13
13
|
import type { PageIndicatorProps } from './types';
|
|
14
14
|
|
|
15
|
-
const AnimatedBox = Animated.createAnimatedComponent(Box);
|
|
16
15
|
const MAX_VISIBLE_DOTS = 4;
|
|
17
16
|
|
|
18
17
|
const useDotAnimation = ({
|
|
@@ -33,14 +32,20 @@ const useDotAnimation = ({
|
|
|
33
32
|
|
|
34
33
|
useEffect(() => {
|
|
35
34
|
colorProgress.value = withTiming(isActive ? 1 : 0, timingConfig);
|
|
36
|
-
return () => cancelAnimation(colorProgress);
|
|
37
35
|
}, [isActive, colorProgress, timingConfig]);
|
|
38
36
|
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
return () => cancelAnimation(colorProgress);
|
|
39
|
+
}, [colorProgress]);
|
|
40
|
+
|
|
39
41
|
useEffect(() => {
|
|
40
42
|
shrinkProgress.value = withTiming(isShrunk ? 1 : 0, timingConfig);
|
|
41
|
-
return () => cancelAnimation(shrinkProgress);
|
|
42
43
|
}, [isShrunk, shrinkProgress, timingConfig]);
|
|
43
44
|
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
return () => cancelAnimation(shrinkProgress);
|
|
47
|
+
}, [shrinkProgress]);
|
|
48
|
+
|
|
44
49
|
const animatedStyle = useAnimatedStyle(() => {
|
|
45
50
|
const backgroundColor = interpolateColor(
|
|
46
51
|
colorProgress.value,
|
|
@@ -102,8 +107,11 @@ const useStripAnimation = ({
|
|
|
102
107
|
|
|
103
108
|
useEffect(() => {
|
|
104
109
|
translateX.value = withTiming(-offset * dotWidth, timingConfig);
|
|
110
|
+
}, [offset, dotWidth, translateX, timingConfig]);
|
|
111
|
+
|
|
112
|
+
useEffect(() => {
|
|
105
113
|
return () => cancelAnimation(translateX);
|
|
106
|
-
}, [
|
|
114
|
+
}, [translateX]);
|
|
107
115
|
|
|
108
116
|
const stripAnimatedStyle = useAnimatedStyle(
|
|
109
117
|
() => ({
|
|
@@ -157,7 +165,7 @@ const PageIndicatorDot = ({
|
|
|
157
165
|
const styles = useDotStyles();
|
|
158
166
|
const { animatedStyle } = useDotAnimation({ isActive, isShrunk });
|
|
159
167
|
|
|
160
|
-
return <
|
|
168
|
+
return <Animated.View style={[styles.dot, animatedStyle]} />;
|
|
161
169
|
};
|
|
162
170
|
|
|
163
171
|
/**
|
|
@@ -202,7 +210,7 @@ export const PageIndicator = ({
|
|
|
202
210
|
{...props}
|
|
203
211
|
>
|
|
204
212
|
<Box style={[styles.viewport, { width: viewportWidth }]}>
|
|
205
|
-
<
|
|
213
|
+
<Animated.View style={[styles.strip, stripAnimatedStyle]}>
|
|
206
214
|
{dotIndexes.map((index) => (
|
|
207
215
|
<PageIndicatorDot
|
|
208
216
|
key={index}
|
|
@@ -210,7 +218,7 @@ export const PageIndicator = ({
|
|
|
210
218
|
isShrunk={isShrunk(index)}
|
|
211
219
|
/>
|
|
212
220
|
))}
|
|
213
|
-
</
|
|
221
|
+
</Animated.View>
|
|
214
222
|
</Box>
|
|
215
223
|
</Box>
|
|
216
224
|
);
|
|
@@ -3,7 +3,6 @@ import { createSafeContext } from '@ledgerhq/lumen-utils-shared';
|
|
|
3
3
|
import { I18nProvider } from '../../../i18n';
|
|
4
4
|
import { LumenStyleSheetProvider } from '../../../styles';
|
|
5
5
|
|
|
6
|
-
import { GlobalSelectProvider } from '../Select/GlobalSelectContext';
|
|
7
6
|
import { GlobalTooltipProvider } from '../Tooltip/GlobalTooltipContext';
|
|
8
7
|
import type { ThemeProviderProps } from './types';
|
|
9
8
|
|
|
@@ -19,9 +18,7 @@ const ThemeProvider = ({
|
|
|
19
18
|
<ThemeContextProvider value={{}}>
|
|
20
19
|
<LumenStyleSheetProvider colorScheme={colorScheme} themes={themes}>
|
|
21
20
|
<I18nProvider locale={locale}>
|
|
22
|
-
<
|
|
23
|
-
<GlobalTooltipProvider>{children}</GlobalTooltipProvider>
|
|
24
|
-
</GlobalSelectProvider>
|
|
21
|
+
<GlobalTooltipProvider>{children}</GlobalTooltipProvider>
|
|
25
22
|
</I18nProvider>
|
|
26
23
|
</LumenStyleSheetProvider>
|
|
27
24
|
</ThemeContextProvider>
|
|
@@ -33,13 +33,13 @@ import createIcon from '../../Components/Icon/createIcon';
|
|
|
33
33
|
*/
|
|
34
34
|
export const Lightbulb = createIcon(
|
|
35
35
|
'Lightbulb',
|
|
36
|
-
<Svg width={24} height={24} fill='currentColor' viewBox='0 0
|
|
36
|
+
<Svg width={24} height={24} fill='currentColor' viewBox='0 0 16 16'>
|
|
37
37
|
<Path
|
|
38
38
|
stroke='currentColor'
|
|
39
39
|
strokeLinecap='round'
|
|
40
40
|
strokeLinejoin='round'
|
|
41
|
-
strokeWidth={1.
|
|
42
|
-
d='
|
|
41
|
+
strokeWidth={1.3}
|
|
42
|
+
d='M10 10.127H6m7.333-6.794.794-.793M2.667 10l-.794.793m1.46-8.126-.793-.794M13.333 10l.794.793M14 6.667h1.127m-14.254 0H2M6 12h3.913m-4.22-2.07a3.99 3.99 0 0 1-1.646-3.906c.266-1.738 1.713-3.125 3.466-3.33a3.997 3.997 0 0 1 4.484 3.967c0 1.346-.674 2.54-1.7 3.265a.67.67 0 0 0-.307.553v1.84c0 .92-.747 1.667-1.667 1.667h-.666a1.663 1.663 0 0 1-1.667-1.667v-1.842a.71.71 0 0 0-.307-.566z'
|
|
43
43
|
/>
|
|
44
44
|
</Svg>,
|
|
45
45
|
);
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { useCallback, useEffect } from 'react';
|
|
4
|
-
import { Pressable } from 'react-native';
|
|
5
|
-
import { useStyleSheet } from "../../../styles/index.js";
|
|
6
|
-
import { Check } from "../../Symbols/index.js";
|
|
7
|
-
import { BottomSheet, BottomSheetHeader, BottomSheetView, useBottomSheetRef } from "../BottomSheet/index.js";
|
|
8
|
-
import { Divider } from "../Divider/index.js";
|
|
9
|
-
import { Box, Text } from "../Utility/index.js";
|
|
10
|
-
import { useGlobalSelectSafeContext } from "./GlobalSelectContext.js";
|
|
11
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
12
|
-
const useStyles = () => {
|
|
13
|
-
return useStyleSheet(t => ({
|
|
14
|
-
bottomSheetView: {
|
|
15
|
-
paddingHorizontal: t.spacings.s8
|
|
16
|
-
},
|
|
17
|
-
groupLabel: {
|
|
18
|
-
marginBottom: t.spacings.s4,
|
|
19
|
-
paddingHorizontal: t.spacings.s8,
|
|
20
|
-
paddingTop: t.spacings.s8,
|
|
21
|
-
color: t.colors.text.muted,
|
|
22
|
-
...t.typographies.body3SemiBold
|
|
23
|
-
},
|
|
24
|
-
item: {
|
|
25
|
-
flexDirection: 'row',
|
|
26
|
-
alignItems: 'center',
|
|
27
|
-
borderRadius: t.borderRadius.sm,
|
|
28
|
-
padding: t.spacings.s8,
|
|
29
|
-
backgroundColor: t.colors.bg.baseTransparent
|
|
30
|
-
},
|
|
31
|
-
itemPressed: {
|
|
32
|
-
backgroundColor: t.colors.bg.baseTransparentPressed
|
|
33
|
-
},
|
|
34
|
-
itemDisabled: {
|
|
35
|
-
opacity: 0.5
|
|
36
|
-
},
|
|
37
|
-
itemLabel: {
|
|
38
|
-
flex: 1,
|
|
39
|
-
color: t.colors.text.base,
|
|
40
|
-
...t.typographies.body2
|
|
41
|
-
},
|
|
42
|
-
itemLabelDisabled: {
|
|
43
|
-
color: t.colors.text.disabled
|
|
44
|
-
}
|
|
45
|
-
}), []);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* BottomSheet component that displays select options.
|
|
50
|
-
* This should be placed at the root level inside GestureHandlerRootView.
|
|
51
|
-
*
|
|
52
|
-
* @see {@link https://ldls.vercel.app/?path=/docs/components-select-overview--docs Storybook}
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* import { GlobalSelectProvider, GlobalSelectBottomSheet } from '@ledgerhq/lumen-ui-rnative';
|
|
56
|
-
*
|
|
57
|
-
* function App() {
|
|
58
|
-
* return (
|
|
59
|
-
* <GestureHandlerRootView>
|
|
60
|
-
* <YourAppContent />
|
|
61
|
-
* <GlobalSelectBottomSheet />
|
|
62
|
-
* </GestureHandlerRootView>
|
|
63
|
-
* );
|
|
64
|
-
* }
|
|
65
|
-
*/
|
|
66
|
-
export const GlobalSelectBottomSheet = () => {
|
|
67
|
-
const bottomSheetRef = useBottomSheetRef();
|
|
68
|
-
const styles = useStyles();
|
|
69
|
-
/**
|
|
70
|
-
* This is the only component that subscribes to currentSelect
|
|
71
|
-
* All other components use refs to avoid re-renders
|
|
72
|
-
*/
|
|
73
|
-
const {
|
|
74
|
-
currentSelect,
|
|
75
|
-
hideSelectRef
|
|
76
|
-
} = useGlobalSelectSafeContext({
|
|
77
|
-
consumerName: 'useGlobalSelectBottomSheetContext',
|
|
78
|
-
contextRequired: true
|
|
79
|
-
});
|
|
80
|
-
useEffect(() => {
|
|
81
|
-
if (currentSelect) {
|
|
82
|
-
bottomSheetRef.current?.present();
|
|
83
|
-
} else {
|
|
84
|
-
bottomSheetRef.current?.dismiss();
|
|
85
|
-
}
|
|
86
|
-
}, [currentSelect, bottomSheetRef]);
|
|
87
|
-
const handleClose = useCallback(() => {
|
|
88
|
-
currentSelect?.setOpen?.(false);
|
|
89
|
-
hideSelectRef.current();
|
|
90
|
-
}, [hideSelectRef, currentSelect]);
|
|
91
|
-
const handleSelectItem = useCallback(value => {
|
|
92
|
-
if (currentSelect) {
|
|
93
|
-
currentSelect.onSelectValue(value);
|
|
94
|
-
currentSelect.setOpen?.(false);
|
|
95
|
-
hideSelectRef.current();
|
|
96
|
-
}
|
|
97
|
-
}, [currentSelect, hideSelectRef]);
|
|
98
|
-
return /*#__PURE__*/_jsx(BottomSheet, {
|
|
99
|
-
ref: bottomSheetRef,
|
|
100
|
-
snapPoints: null,
|
|
101
|
-
backdropPressBehavior: "close",
|
|
102
|
-
onClose: handleClose,
|
|
103
|
-
maxDynamicContentSize: "fullWithOffset",
|
|
104
|
-
enableDynamicSizing: true,
|
|
105
|
-
enablePanDownToClose: true,
|
|
106
|
-
children: /*#__PURE__*/_jsx(BottomSheetView, {
|
|
107
|
-
style: styles.bottomSheetView,
|
|
108
|
-
children: currentSelect && /*#__PURE__*/_jsxs(_Fragment, {
|
|
109
|
-
children: [currentSelect.label && /*#__PURE__*/_jsx(BottomSheetHeader, {
|
|
110
|
-
title: currentSelect.label,
|
|
111
|
-
density: "compact"
|
|
112
|
-
}), /*#__PURE__*/_jsx(Box, {
|
|
113
|
-
lx: {
|
|
114
|
-
gap: 's4'
|
|
115
|
-
},
|
|
116
|
-
children: currentSelect.items.map((item, index) => {
|
|
117
|
-
if (item.type === 'separator') {
|
|
118
|
-
return /*#__PURE__*/_jsx(Divider, {
|
|
119
|
-
lx: {
|
|
120
|
-
marginVertical: 's4',
|
|
121
|
-
marginHorizontal: 's8'
|
|
122
|
-
}
|
|
123
|
-
}, `separator-${index}`);
|
|
124
|
-
}
|
|
125
|
-
if (item.type === 'group-label') {
|
|
126
|
-
return /*#__PURE__*/_jsx(Text, {
|
|
127
|
-
style: styles.groupLabel,
|
|
128
|
-
children: item.label
|
|
129
|
-
}, `label-${index}`);
|
|
130
|
-
}
|
|
131
|
-
const isSelected = currentSelect.selectedValue === item.value;
|
|
132
|
-
return /*#__PURE__*/_jsx(Pressable, {
|
|
133
|
-
disabled: item.disabled,
|
|
134
|
-
onPress: () => handleSelectItem(item.value),
|
|
135
|
-
children: ({
|
|
136
|
-
pressed
|
|
137
|
-
}) => /*#__PURE__*/_jsxs(Box, {
|
|
138
|
-
style: [styles.item, pressed && styles.itemPressed, item.disabled && styles.itemDisabled],
|
|
139
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
140
|
-
style: [styles.itemLabel, item.disabled && styles.itemLabelDisabled],
|
|
141
|
-
numberOfLines: 1,
|
|
142
|
-
children: item.label
|
|
143
|
-
}), isSelected && /*#__PURE__*/_jsx(Check, {
|
|
144
|
-
size: 24,
|
|
145
|
-
color: "active"
|
|
146
|
-
})]
|
|
147
|
-
})
|
|
148
|
-
}, item.value);
|
|
149
|
-
})
|
|
150
|
-
})]
|
|
151
|
-
})
|
|
152
|
-
})
|
|
153
|
-
});
|
|
154
|
-
};
|
|
155
|
-
//# sourceMappingURL=GlobalSelectBottomSheet.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useCallback","useEffect","Pressable","useStyleSheet","Check","BottomSheet","BottomSheetHeader","BottomSheetView","useBottomSheetRef","Divider","Box","Text","useGlobalSelectSafeContext","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","useStyles","t","bottomSheetView","paddingHorizontal","spacings","s8","groupLabel","marginBottom","s4","paddingTop","color","colors","text","muted","typographies","body3SemiBold","item","flexDirection","alignItems","borderRadius","sm","padding","backgroundColor","bg","baseTransparent","itemPressed","baseTransparentPressed","itemDisabled","opacity","itemLabel","flex","base","body2","itemLabelDisabled","disabled","GlobalSelectBottomSheet","bottomSheetRef","styles","currentSelect","hideSelectRef","consumerName","contextRequired","current","present","dismiss","handleClose","setOpen","handleSelectItem","value","onSelectValue","ref","snapPoints","backdropPressBehavior","onClose","maxDynamicContentSize","enableDynamicSizing","enablePanDownToClose","children","style","label","title","density","lx","gap","items","map","index","type","marginVertical","marginHorizontal","isSelected","selectedValue","onPress","pressed","numberOfLines","size"],"sourceRoot":"../../../../../src","sources":["lib/Components/Select/GlobalSelectBottomSheet.tsx"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,SAAS,QAAQ,OAAO;AAC9C,SAASC,SAAS,QAAQ,cAAc;AACxC,SAASC,aAAa,QAAQ,0BAAiB;AAC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QAAS;cACxBsC,OAAO,EAAEA,CAAA,KAAMzB,gBAAgB,CAAC/B,IAAI,CAACgC,KAAK,CAAE;cAAAS,QAAA,EAE3CA,CAAC;gBAAEgB;cAAQ,CAAC,kBACX5E,KAAA,CAACN,GAAG;gBACFmE,KAAK,EAAE,CACLrB,MAAM,CAACrB,IAAI,EACXyD,OAAO,IAAIpC,MAAM,CAACZ,WAAW,EAC7BT,IAAI,CAACkB,QAAQ,IAAIG,MAAM,CAACV,YAAY,CACpC;gBAAA8B,QAAA,gBAEF9D,IAAA,CAACH,IAAI;kBACHkE,KAAK,EAAE,CACLrB,MAAM,CAACR,SAAS,EAChBb,IAAI,CAACkB,QAAQ,IAAIG,MAAM,CAACJ,iBAAiB,CACzC;kBACFyC,aAAa,EAAE,CAAE;kBAAAjB,QAAA,EAEhBzC,IAAI,CAAC2C;gBAAK,CACP,CAAC,EACNW,UAAU,iBAAI3E,IAAA,CAACV,KAAK;kBAAC0F,IAAI,EAAE,EAAG;kBAACjE,KAAK,EAAC;gBAAQ,CAAE,CAAC;cAAA,CAC9C;YACN,GAvBIM,IAAI,CAACgC,KAwBD,CAAC;UAEhB,CAAC;QAAC,CACC,CAAC;MAAA,CACN;IACH,CACc;EAAC,CACP,CAAC;AAElB,CAAC","ignoreList":[]}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { createSafeContext } from '@ledgerhq/lumen-utils-shared';
|
|
4
|
-
import { useState, useRef, useMemo } from 'react';
|
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
const [GlobalSelectContextProvider, _useGlobalSelectSafeContext] = createSafeContext('GlobalSelectContext');
|
|
7
|
-
export const useGlobalSelectSafeContext = _useGlobalSelectSafeContext;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Hook that provides select actions without subscribing to state changes.
|
|
11
|
-
* This prevents unnecessary re-renders when selects open/close.
|
|
12
|
-
*
|
|
13
|
-
* Use this hook in components that only need to show/hide selects
|
|
14
|
-
* but don't need to know which select is currently active.
|
|
15
|
-
*/
|
|
16
|
-
export const useSelectActions = () => {
|
|
17
|
-
const context = useGlobalSelectSafeContext({
|
|
18
|
-
consumerName: 'useSelectActions',
|
|
19
|
-
contextRequired: true
|
|
20
|
-
});
|
|
21
|
-
return useMemo(() => ({
|
|
22
|
-
showSelect: context.showSelectRef.current,
|
|
23
|
-
hideSelect: context.hideSelectRef.current
|
|
24
|
-
}), [context.showSelectRef, context.hideSelectRef]);
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Global provider for the select bottom sheet system.
|
|
28
|
-
* This should wrap your app at the root level and include GlobalSelectBottomSheet.
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* import { GlobalSelectProvider, GlobalSelectBottomSheet } from '@ledgerhq/lumen-ui-rnative';
|
|
32
|
-
*
|
|
33
|
-
* function App() {
|
|
34
|
-
* return (
|
|
35
|
-
* <GlobalSelectProvider>
|
|
36
|
-
* <YourAppContent />
|
|
37
|
-
* <GlobalSelectBottomSheet />
|
|
38
|
-
* </GlobalSelectProvider>
|
|
39
|
-
* );
|
|
40
|
-
* }
|
|
41
|
-
*/
|
|
42
|
-
export const GlobalSelectProvider = ({
|
|
43
|
-
children
|
|
44
|
-
}) => {
|
|
45
|
-
const [currentSelect, setCurrentSelect] = useState(null);
|
|
46
|
-
const showSelectRef = useRef(() => {
|
|
47
|
-
return;
|
|
48
|
-
});
|
|
49
|
-
const hideSelectRef = useRef(() => {
|
|
50
|
-
return;
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Update the ref implementations when needed
|
|
55
|
-
* These closures capture the current setCurrentSelect
|
|
56
|
-
*/
|
|
57
|
-
showSelectRef.current = data => {
|
|
58
|
-
setCurrentSelect(data);
|
|
59
|
-
};
|
|
60
|
-
hideSelectRef.current = () => {
|
|
61
|
-
setCurrentSelect(null);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Memoize the context value - only currentSelect changes cause re-renders
|
|
66
|
-
* The refs themselves never change
|
|
67
|
-
*/
|
|
68
|
-
const contextValue = useMemo(() => ({
|
|
69
|
-
currentSelect,
|
|
70
|
-
showSelectRef,
|
|
71
|
-
hideSelectRef
|
|
72
|
-
}), [currentSelect]);
|
|
73
|
-
return /*#__PURE__*/_jsx(GlobalSelectContextProvider, {
|
|
74
|
-
value: contextValue,
|
|
75
|
-
children: children
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
//# sourceMappingURL=GlobalSelectContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["createSafeContext","useState","useRef","useMemo","jsx","_jsx","GlobalSelectContextProvider","_useGlobalSelectSafeContext","useGlobalSelectSafeContext","useSelectActions","context","consumerName","contextRequired","showSelect","showSelectRef","current","hideSelect","hideSelectRef","GlobalSelectProvider","children","currentSelect","setCurrentSelect","data","contextValue","value"],"sourceRoot":"../../../../../src","sources":["lib/Components/Select/GlobalSelectContext.tsx"],"mappings":";;AAAA,SAASA,iBAAiB,QAAQ,8BAA8B;AAEhE,SAASC,QAAQ,EAAEC,MAAM,EAAEC,OAAO,QAAQ,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA;AASlD,MAAM,CAACC,2BAA2B,EAAEC,2BAA2B,CAAC,GAC9DP,iBAAiB,CAAsC,qBAAqB,CAAC;AAE/E,OAAO,MAAMQ,0BAA0B,GAAGD,2BAA2B;;AAErE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,gBAAgB,GAAGA,CAAA,KAG3B;EACH,MAAMC,OAAO,GAAGF,0BAA0B,CAAC;IACzCG,YAAY,EAAE,kBAAkB;IAChCC,eAAe,EAAE;EACnB,CAAC,CAAC;EAEF,OAAOT,OAAO,CACZ,OAAO;IACLU,UAAU,EAAEH,OAAO,CAACI,aAAa,CAACC,OAAO;IACzCC,UAAU,EAAEN,OAAO,C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