@ledgerhq/lumen-ui-rnative 0.1.63 → 0.1.65
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/core/AmountDisplay/AmountDisplay.js +19 -11
- package/dist/module/lib/Components/core/AmountDisplay/AmountDisplay.js.map +1 -1
- package/dist/module/lib/Components/core/AmountDisplay/AmountDisplay.test.js +113 -4
- package/dist/module/lib/Components/core/AmountDisplay/AmountDisplay.test.js.map +1 -1
- package/dist/module/lib/Components/core/BottomSheet/BottomSheet.stories.js +51 -0
- package/dist/module/lib/Components/core/BottomSheet/BottomSheet.stories.js.map +1 -1
- package/dist/module/lib/Components/core/CardButton/CardButton.js +2 -0
- package/dist/module/lib/Components/core/CardButton/CardButton.js.map +1 -1
- package/dist/module/lib/Components/core/CardButton/CardButton.mdx +4 -0
- package/dist/module/lib/Components/core/CardButton/CardButton.stories.js +1 -0
- package/dist/module/lib/Components/core/CardButton/CardButton.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Link/Link.figma.js +2 -1
- package/dist/module/lib/Components/core/Link/Link.figma.js.map +1 -1
- package/dist/module/lib/Components/core/Link/Link.js +5 -3
- package/dist/module/lib/Components/core/Link/Link.js.map +1 -1
- package/dist/module/lib/Components/core/Link/Link.mdx +3 -2
- package/dist/module/lib/Components/core/Link/Link.stories.js +4 -1
- package/dist/module/lib/Components/core/Link/Link.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Link/Link.test.js +2 -2
- package/dist/module/lib/Components/core/Link/Link.test.js.map +1 -1
- package/dist/module/lib/Components/core/MenuList/MenuList.js +93 -7
- package/dist/module/lib/Components/core/MenuList/MenuList.js.map +1 -1
- package/dist/module/lib/Components/core/MenuList/MenuList.mdx +14 -1
- package/dist/module/lib/Components/core/MenuList/MenuList.stories.js +39 -2
- package/dist/module/lib/Components/core/MenuList/MenuList.stories.js.map +1 -1
- package/dist/module/lib/Components/core/MenuList/MenuList.test.js +60 -2
- package/dist/module/lib/Components/core/MenuList/MenuList.test.js.map +1 -1
- package/dist/module/lib/Components/core/SegmentedControl/SegmentedControl.js +1 -1
- package/dist/module/lib/Components/core/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/module/lib/Components/core/Stepper/Stepper.js +76 -30
- package/dist/module/lib/Components/core/Stepper/Stepper.js.map +1 -1
- package/dist/module/lib/Components/core/Stepper/Stepper.mdx +37 -16
- package/dist/module/lib/Components/core/Stepper/Stepper.stories.js +102 -2
- package/dist/module/lib/Components/core/Stepper/Stepper.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Stepper/Stepper.test.js +32 -1
- package/dist/module/lib/Components/core/Stepper/Stepper.test.js.map +1 -1
- package/dist/module/lib/Components/core/Timeline/Timeline.figma.js +83 -0
- package/dist/module/lib/Components/core/Timeline/Timeline.figma.js.map +1 -0
- package/dist/module/lib/Components/core/Timeline/Timeline.js +464 -0
- package/dist/module/lib/Components/core/Timeline/Timeline.js.map +1 -0
- package/dist/module/lib/Components/core/Timeline/Timeline.mdx +49 -0
- package/dist/module/lib/Components/core/Timeline/Timeline.stories.js +289 -0
- package/dist/module/lib/Components/core/Timeline/Timeline.stories.js.map +1 -0
- package/dist/module/lib/Components/core/Timeline/Timeline.test.js +234 -0
- package/dist/module/lib/Components/core/Timeline/Timeline.test.js.map +1 -0
- package/dist/module/lib/Components/core/Timeline/index.js +5 -0
- package/dist/module/lib/Components/core/Timeline/index.js.map +1 -0
- package/dist/module/lib/Components/core/Timeline/types.js +4 -0
- package/dist/module/lib/Components/core/Timeline/types.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/Toast.figma.js +39 -0
- package/dist/module/lib/Components/core/Toast/Toast.figma.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/Toast.js +138 -0
- package/dist/module/lib/Components/core/Toast/Toast.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/Toast.mdx +203 -0
- package/dist/module/lib/Components/core/Toast/Toast.stories.js +238 -0
- package/dist/module/lib/Components/core/Toast/Toast.stories.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/Toast.test.js +203 -0
- package/dist/module/lib/Components/core/Toast/Toast.test.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/Toaster.js +147 -0
- package/dist/module/lib/Components/core/Toast/Toaster.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/Toaster.test.js +732 -0
- package/dist/module/lib/Components/core/Toast/Toaster.test.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastAccessibility.js +70 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastAccessibility.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastCollapse.js +33 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastCollapse.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastGesture.js +224 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastGesture.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastMotion.js +82 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastMotion.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastViewportStyles.js +21 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastViewportStyles.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/index.js +7 -0
- package/dist/module/lib/Components/core/Toast/index.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/types.js +4 -0
- package/dist/module/lib/Components/core/Toast/types.js.map +1 -0
- package/dist/module/lib/Components/core/index.js +2 -0
- package/dist/module/lib/Components/core/index.js.map +1 -1
- package/dist/typescript/src/lib/Components/core/AmountDisplay/AmountDisplay.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/CardButton/CardButton.d.ts +2 -0
- package/dist/typescript/src/lib/Components/core/CardButton/CardButton.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/Link/Link.d.ts +1 -1
- package/dist/typescript/src/lib/Components/core/Link/Link.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/Link/types.d.ts +1 -1
- package/dist/typescript/src/lib/Components/core/Link/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/MenuList/MenuList.d.ts +12 -2
- package/dist/typescript/src/lib/Components/core/MenuList/MenuList.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/MenuList/types.d.ts +26 -7
- package/dist/typescript/src/lib/Components/core/MenuList/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/Stepper/Stepper.d.ts +4 -3
- package/dist/typescript/src/lib/Components/core/Stepper/Stepper.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/Stepper/types.d.ts +12 -2
- package/dist/typescript/src/lib/Components/core/Stepper/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/Timeline/Timeline.d.ts +56 -0
- package/dist/typescript/src/lib/Components/core/Timeline/Timeline.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Timeline/index.d.ts +3 -0
- package/dist/typescript/src/lib/Components/core/Timeline/index.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Timeline/types.d.ts +109 -0
- package/dist/typescript/src/lib/Components/core/Timeline/types.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/Toast.d.ts +24 -0
- package/dist/typescript/src/lib/Components/core/Toast/Toast.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/Toaster.d.ts +35 -0
- package/dist/typescript/src/lib/Components/core/Toast/Toaster.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastAccessibility.d.ts +17 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastAccessibility.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastCollapse.d.ts +19 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastCollapse.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastGesture.d.ts +14 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastGesture.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastMotion.d.ts +15 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastMotion.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastViewportStyles.d.ts +21 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastViewportStyles.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/index.d.ts +5 -0
- package/dist/typescript/src/lib/Components/core/Toast/index.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/types.d.ts +75 -0
- package/dist/typescript/src/lib/Components/core/Toast/types.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/index.d.ts +2 -0
- package/dist/typescript/src/lib/Components/core/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/lib/Components/core/AmountDisplay/AmountDisplay.test.tsx +138 -4
- package/src/lib/Components/core/AmountDisplay/AmountDisplay.tsx +13 -6
- package/src/lib/Components/core/BottomSheet/BottomSheet.stories.tsx +51 -0
- package/src/lib/Components/core/CardButton/CardButton.mdx +4 -0
- package/src/lib/Components/core/CardButton/CardButton.stories.tsx +1 -0
- package/src/lib/Components/core/CardButton/CardButton.tsx +2 -0
- package/src/lib/Components/core/Link/Link.figma.tsx +1 -0
- package/src/lib/Components/core/Link/Link.mdx +3 -2
- package/src/lib/Components/core/Link/Link.stories.tsx +3 -2
- package/src/lib/Components/core/Link/Link.test.tsx +2 -0
- package/src/lib/Components/core/Link/Link.tsx +3 -1
- package/src/lib/Components/core/Link/types.ts +1 -1
- package/src/lib/Components/core/MenuList/MenuList.mdx +14 -1
- package/src/lib/Components/core/MenuList/MenuList.stories.tsx +30 -2
- package/src/lib/Components/core/MenuList/MenuList.test.tsx +72 -2
- package/src/lib/Components/core/MenuList/MenuList.tsx +94 -11
- package/src/lib/Components/core/MenuList/types.ts +29 -7
- package/src/lib/Components/core/SegmentedControl/SegmentedControl.tsx +1 -1
- package/src/lib/Components/core/Stepper/Stepper.mdx +37 -16
- package/src/lib/Components/core/Stepper/Stepper.stories.tsx +50 -2
- package/src/lib/Components/core/Stepper/Stepper.test.tsx +29 -1
- package/src/lib/Components/core/Stepper/Stepper.tsx +73 -32
- package/src/lib/Components/core/Stepper/types.ts +12 -2
- package/src/lib/Components/core/Timeline/Timeline.figma.tsx +79 -0
- package/src/lib/Components/core/Timeline/Timeline.mdx +49 -0
- package/src/lib/Components/core/Timeline/Timeline.stories.tsx +250 -0
- package/src/lib/Components/core/Timeline/Timeline.test.tsx +275 -0
- package/src/lib/Components/core/Timeline/Timeline.tsx +576 -0
- package/src/lib/Components/core/Timeline/index.ts +2 -0
- package/src/lib/Components/core/Timeline/types.ts +124 -0
- package/src/lib/Components/core/Toast/Toast.figma.tsx +36 -0
- package/src/lib/Components/core/Toast/Toast.mdx +203 -0
- package/src/lib/Components/core/Toast/Toast.stories.tsx +260 -0
- package/src/lib/Components/core/Toast/Toast.test.tsx +181 -0
- package/src/lib/Components/core/Toast/Toast.tsx +163 -0
- package/src/lib/Components/core/Toast/Toaster.test.tsx +687 -0
- package/src/lib/Components/core/Toast/Toaster.tsx +157 -0
- package/src/lib/Components/core/Toast/hooks/useToastAccessibility.ts +82 -0
- package/src/lib/Components/core/Toast/hooks/useToastCollapse.ts +38 -0
- package/src/lib/Components/core/Toast/hooks/useToastGesture.ts +83 -0
- package/src/lib/Components/core/Toast/hooks/useToastMotion.ts +71 -0
- package/src/lib/Components/core/Toast/hooks/useToastViewportStyles.ts +45 -0
- package/src/lib/Components/core/Toast/index.ts +4 -0
- package/src/lib/Components/core/Toast/types.ts +94 -0
- package/src/lib/Components/core/index.ts +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/Components/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/Components/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/lumen-ui-rnative",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.65",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"!**/*.tsbuildinfo"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@ledgerhq/lumen-utils-shared": "0.1.
|
|
52
|
+
"@ledgerhq/lumen-utils-shared": "0.1.15",
|
|
53
53
|
"@types/d3-scale": "^4.0.9",
|
|
54
54
|
"@types/d3-shape": "^3.1.8",
|
|
55
55
|
"d3-scale": "^4.0.2",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"@types/react": "^19.0.0",
|
|
65
65
|
"@gorhom/bottom-sheet": "^5.0.0",
|
|
66
|
-
"@ledgerhq/lumen-design-core": "0.1.
|
|
66
|
+
"@ledgerhq/lumen-design-core": "0.1.31",
|
|
67
67
|
"react": "^19.0.0",
|
|
68
68
|
"react-native": "~0.81.6",
|
|
69
69
|
"react-native-gesture-handler": ">=2.0.0",
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { describe, it, expect } from '@jest/globals';
|
|
1
|
+
import { afterEach, describe, it, expect, jest } from '@jest/globals';
|
|
2
2
|
import { ledgerLiveThemes } from '@ledgerhq/lumen-design-core';
|
|
3
|
-
import { render, screen } from '@testing-library/react-native';
|
|
3
|
+
import { cleanup, render, screen } from '@testing-library/react-native';
|
|
4
|
+
import { useRef } from 'react';
|
|
4
5
|
import { ThemeProvider } from '../ThemeProvider/ThemeProvider';
|
|
5
6
|
import { AmountDisplay } from './AmountDisplay';
|
|
6
7
|
import type { FormattedValue } from './types';
|
|
7
8
|
|
|
8
|
-
const TestWrapper: React.FC<{
|
|
9
|
-
|
|
9
|
+
const TestWrapper: React.FC<{
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
themes?: typeof ledgerLiveThemes;
|
|
12
|
+
}> = ({ children, themes = ledgerLiveThemes }) => (
|
|
13
|
+
<ThemeProvider themes={themes} colorScheme='dark' locale='en'>
|
|
10
14
|
{children}
|
|
11
15
|
</ThemeProvider>
|
|
12
16
|
);
|
|
@@ -332,4 +336,134 @@ describe('AmountDisplay', () => {
|
|
|
332
336
|
});
|
|
333
337
|
});
|
|
334
338
|
});
|
|
339
|
+
|
|
340
|
+
describe('re-rendering a mounted instance', () => {
|
|
341
|
+
afterEach(() => {
|
|
342
|
+
// Unmount first: restoring a spied hook on a mounted tree breaks the
|
|
343
|
+
// hook order of any late re-render
|
|
344
|
+
cleanup();
|
|
345
|
+
jest.restoreAllMocks();
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
it('updates the digit strips when the value changes while animating', () => {
|
|
349
|
+
const { rerender } = render(
|
|
350
|
+
<TestWrapper>
|
|
351
|
+
<AmountDisplay
|
|
352
|
+
value={1234.56}
|
|
353
|
+
formatter={createFormatter()}
|
|
354
|
+
animate={true}
|
|
355
|
+
/>
|
|
356
|
+
</TestWrapper>,
|
|
357
|
+
);
|
|
358
|
+
|
|
359
|
+
expect(getDigitStripValues()).toEqual([1, 2, 3, 4, 5, 6]);
|
|
360
|
+
|
|
361
|
+
rerender(
|
|
362
|
+
<TestWrapper>
|
|
363
|
+
<AmountDisplay
|
|
364
|
+
value={9876.54}
|
|
365
|
+
formatter={createFormatter({
|
|
366
|
+
integerPart: '9876',
|
|
367
|
+
decimalPart: '54',
|
|
368
|
+
})}
|
|
369
|
+
animate={true}
|
|
370
|
+
/>
|
|
371
|
+
</TestWrapper>,
|
|
372
|
+
);
|
|
373
|
+
|
|
374
|
+
expect(getDigitStripValues()).toEqual([9, 8, 7, 6, 5, 4]);
|
|
375
|
+
getDigitStripWidths().forEach((width) => {
|
|
376
|
+
expect(typeof width).not.toBe('number');
|
|
377
|
+
});
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
it('keeps the digit strip geometry correct when animate is toggled', () => {
|
|
381
|
+
const formatter = createFormatter();
|
|
382
|
+
const tree = (animate: boolean) => (
|
|
383
|
+
<TestWrapper>
|
|
384
|
+
<AmountDisplay
|
|
385
|
+
value={1234.56}
|
|
386
|
+
formatter={formatter}
|
|
387
|
+
animate={animate}
|
|
388
|
+
/>
|
|
389
|
+
</TestWrapper>
|
|
390
|
+
);
|
|
391
|
+
|
|
392
|
+
const { rerender } = render(tree(true));
|
|
393
|
+
rerender(tree(false));
|
|
394
|
+
|
|
395
|
+
expect(getDigitStripValues()).toEqual([1, 2, 3, 4, 5, 6]);
|
|
396
|
+
getDigitStripWidths().forEach((width) => {
|
|
397
|
+
expect(typeof width).toBe('number');
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
rerender(tree(true));
|
|
401
|
+
|
|
402
|
+
expect(getDigitStripValues()).toEqual([1, 2, 3, 4, 5, 6]);
|
|
403
|
+
getDigitStripWidths().forEach((width) => {
|
|
404
|
+
expect(typeof width).not.toBe('number');
|
|
405
|
+
});
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
it('swaps between bullets and digits when hidden is toggled', () => {
|
|
409
|
+
const formatter = createFormatter();
|
|
410
|
+
const tree = (isHidden: boolean) => (
|
|
411
|
+
<TestWrapper>
|
|
412
|
+
<AmountDisplay
|
|
413
|
+
value={1234.56}
|
|
414
|
+
formatter={formatter}
|
|
415
|
+
hidden={isHidden}
|
|
416
|
+
/>
|
|
417
|
+
</TestWrapper>
|
|
418
|
+
);
|
|
419
|
+
|
|
420
|
+
const { rerender } = render(tree(false));
|
|
421
|
+
rerender(tree(true));
|
|
422
|
+
|
|
423
|
+
expect(screen.getByText('••••', hidden)).toBeTruthy();
|
|
424
|
+
expect(getDigitStripValues()).toEqual([]);
|
|
425
|
+
|
|
426
|
+
rerender(tree(false));
|
|
427
|
+
|
|
428
|
+
expect(screen.queryByText('••••', hidden)).toBeNull();
|
|
429
|
+
expect(getDigitStripValues()).toEqual([1, 2, 3, 4, 5, 6]);
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
it('does not restart digit animations when an equivalent theme object is passed', () => {
|
|
433
|
+
const Reanimated = jest.requireMock('react-native-reanimated') as {
|
|
434
|
+
useSharedValue: (initial: unknown) => { value: unknown };
|
|
435
|
+
withTiming: (
|
|
436
|
+
toValue: unknown,
|
|
437
|
+
config?: { duration?: number },
|
|
438
|
+
) => unknown;
|
|
439
|
+
};
|
|
440
|
+
// The global mock creates a new shared value on every render, which
|
|
441
|
+
// would re-run the digit-strip effect regardless of the timing config
|
|
442
|
+
const useStableSharedValue = (initial: unknown): { value: unknown } =>
|
|
443
|
+
useRef({ value: initial }).current;
|
|
444
|
+
jest
|
|
445
|
+
.spyOn(Reanimated, 'useSharedValue')
|
|
446
|
+
.mockImplementation(useStableSharedValue);
|
|
447
|
+
const withTiming = jest.spyOn(Reanimated, 'withTiming');
|
|
448
|
+
// Pulse also reschedules when the theme object changes, so only the
|
|
449
|
+
// digit-strip duration is tracked
|
|
450
|
+
const digitStripAnimations = () =>
|
|
451
|
+
withTiming.mock.calls.filter(([, config]) => config?.duration === 700);
|
|
452
|
+
|
|
453
|
+
const formatter = createFormatter();
|
|
454
|
+
const tree = () => (
|
|
455
|
+
<TestWrapper themes={{ ...ledgerLiveThemes }}>
|
|
456
|
+
<AmountDisplay value={1234.56} formatter={formatter} animate={true} />
|
|
457
|
+
</TestWrapper>
|
|
458
|
+
);
|
|
459
|
+
|
|
460
|
+
const { rerender } = render(tree());
|
|
461
|
+
expect(digitStripAnimations().length).toBeGreaterThan(0);
|
|
462
|
+
|
|
463
|
+
withTiming.mockClear();
|
|
464
|
+
rerender(tree());
|
|
465
|
+
|
|
466
|
+
expect(digitStripAnimations()).toEqual([]);
|
|
467
|
+
});
|
|
468
|
+
});
|
|
335
469
|
});
|
|
@@ -10,7 +10,7 @@ import Animated, {
|
|
|
10
10
|
import { useCommonTranslation } from '../../../../i18n';
|
|
11
11
|
import type { LumenTypographyTokenName } from '../../../../styles';
|
|
12
12
|
import { useStyleSheet } from '../../../../styles';
|
|
13
|
-
import { RuntimeConstants } from '../../../utils';
|
|
13
|
+
import { RuntimeConstants, useGet } from '../../../utils';
|
|
14
14
|
import { Pulse } from '../../animations/Pulse';
|
|
15
15
|
import { useTimingConfig } from '../../animations/useTimingConfig';
|
|
16
16
|
import { Box } from '../../primitives';
|
|
@@ -135,11 +135,13 @@ const useAnimatedDigitStrip = ({
|
|
|
135
135
|
duration: 700,
|
|
136
136
|
easing: 'easeInOut',
|
|
137
137
|
});
|
|
138
|
+
// Avoid restarting withTiming when theme rebuilds a new config object
|
|
139
|
+
const getTimingConfig = useGet(timingConfig);
|
|
138
140
|
|
|
139
141
|
useEffect(() => {
|
|
140
142
|
if (animate) {
|
|
141
|
-
translateY.value = withTiming(-value * lineHeight,
|
|
142
|
-
width.value = withTiming(targetWidth,
|
|
143
|
+
translateY.value = withTiming(-value * lineHeight, getTimingConfig());
|
|
144
|
+
width.value = withTiming(targetWidth, getTimingConfig());
|
|
143
145
|
} else {
|
|
144
146
|
translateY.value = -value * lineHeight;
|
|
145
147
|
width.value = targetWidth;
|
|
@@ -151,7 +153,7 @@ const useAnimatedDigitStrip = ({
|
|
|
151
153
|
animate,
|
|
152
154
|
width,
|
|
153
155
|
targetWidth,
|
|
154
|
-
|
|
156
|
+
getTimingConfig,
|
|
155
157
|
]);
|
|
156
158
|
|
|
157
159
|
const animatedStyle = useAnimatedStyle(
|
|
@@ -185,6 +187,7 @@ const DigitStrip = memo(
|
|
|
185
187
|
|
|
186
188
|
return (
|
|
187
189
|
<Animated.View
|
|
190
|
+
collapsable={false}
|
|
188
191
|
style={{
|
|
189
192
|
height: lineHeight,
|
|
190
193
|
width: animate ? width : targetWidth,
|
|
@@ -203,7 +206,10 @@ const DigitStrip = memo(
|
|
|
203
206
|
alignItems: 'center',
|
|
204
207
|
}}
|
|
205
208
|
>
|
|
206
|
-
<Animated.View
|
|
209
|
+
<Animated.View
|
|
210
|
+
collapsable={false}
|
|
211
|
+
style={[animatedStyle, { alignItems: 'center' }]}
|
|
212
|
+
>
|
|
207
213
|
{DIGITS.map((d) => (
|
|
208
214
|
<Text
|
|
209
215
|
allowFontScaling={false}
|
|
@@ -236,8 +242,9 @@ const DigitStripList = memo(
|
|
|
236
242
|
);
|
|
237
243
|
}
|
|
238
244
|
return (
|
|
245
|
+
// Remount when animate flips so width stays either SharedValue or number
|
|
239
246
|
<DigitStrip
|
|
240
|
-
key={key}
|
|
247
|
+
key={`${key}-${animate}`}
|
|
241
248
|
value={Number(item.value) as DigitStripProps['value']}
|
|
242
249
|
animate={animate}
|
|
243
250
|
textStyle={textStyle}
|
|
@@ -2,7 +2,9 @@ import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
|
2
2
|
import type { FC } from 'react';
|
|
3
3
|
import { useEffect, useState } from 'react';
|
|
4
4
|
import { Box, RadialGradient, Text } from '../../primitives';
|
|
5
|
+
import { Bell, Settings, Trash, Unlink } from '../../symbols';
|
|
5
6
|
import { Button } from '../Button';
|
|
7
|
+
import { MenuList, MenuListItem, MenuListSwitchItem } from '../MenuList';
|
|
6
8
|
import { SearchInput } from '../SearchInput';
|
|
7
9
|
import { Spot } from '../Spot';
|
|
8
10
|
import { BottomSheet } from './BottomSheet';
|
|
@@ -935,3 +937,52 @@ export const WithFooter: Story = {
|
|
|
935
937
|
);
|
|
936
938
|
},
|
|
937
939
|
};
|
|
940
|
+
|
|
941
|
+
export const WithMenuList: Story = {
|
|
942
|
+
args: {
|
|
943
|
+
snapPoints: null,
|
|
944
|
+
enableDynamicSizing: true,
|
|
945
|
+
},
|
|
946
|
+
render: (args) => {
|
|
947
|
+
const bottomSheetRef = useBottomSheetRef();
|
|
948
|
+
|
|
949
|
+
return (
|
|
950
|
+
<Box
|
|
951
|
+
lx={{
|
|
952
|
+
height: 's320',
|
|
953
|
+
width: 'full',
|
|
954
|
+
alignItems: 'center',
|
|
955
|
+
justifyContent: 'center',
|
|
956
|
+
paddingTop: 's32',
|
|
957
|
+
}}
|
|
958
|
+
>
|
|
959
|
+
<Button size='sm' onPress={() => bottomSheetRef.current?.present()}>
|
|
960
|
+
Toggle open
|
|
961
|
+
</Button>
|
|
962
|
+
<BottomSheet {...args} ref={bottomSheetRef}>
|
|
963
|
+
<BottomSheetView>
|
|
964
|
+
<BottomSheetHeader
|
|
965
|
+
title='Device Options'
|
|
966
|
+
density='compact'
|
|
967
|
+
description='Manage this device'
|
|
968
|
+
/>
|
|
969
|
+
<MenuList>
|
|
970
|
+
<MenuListItem label='Rename device' icon={Settings} />
|
|
971
|
+
<MenuListItem label='Unlink device' icon={Unlink} />
|
|
972
|
+
<MenuListSwitchItem
|
|
973
|
+
label='Notifications'
|
|
974
|
+
icon={Bell}
|
|
975
|
+
defaultChecked
|
|
976
|
+
/>
|
|
977
|
+
<MenuListItem
|
|
978
|
+
label='Remove device'
|
|
979
|
+
icon={Trash}
|
|
980
|
+
appearance='red'
|
|
981
|
+
/>
|
|
982
|
+
</MenuList>
|
|
983
|
+
</BottomSheetView>
|
|
984
|
+
</BottomSheet>
|
|
985
|
+
</Box>
|
|
986
|
+
);
|
|
987
|
+
},
|
|
988
|
+
};
|
|
@@ -97,6 +97,8 @@ const useStyles = ({
|
|
|
97
97
|
*
|
|
98
98
|
* It supports different appearances. Takes only the necessary width based on content. The chevron can be hidden if needed.
|
|
99
99
|
*
|
|
100
|
+
* @deprecated Use Card instead.
|
|
101
|
+
*
|
|
100
102
|
* @see {@link https://ldls-react-native.vercel.app/?path=/docs/rnative-cardbutton--docs Guidelines}
|
|
101
103
|
*
|
|
102
104
|
* @warning The `lx` prop should only be used for layout adjustments like margins or positioning.
|
|
@@ -13,7 +13,7 @@ import { CustomTabs, Tab } from '../../../../../.storybook/components';
|
|
|
13
13
|
|
|
14
14
|
## Introduction
|
|
15
15
|
|
|
16
|
-
Links are essential navigation elements that direct users to internal screens or external resources. This React Native implementation provides
|
|
16
|
+
Links are essential navigation elements that direct users to internal screens or external resources. This React Native implementation provides appearances, optional underline decoration, and predefined sizing options. Links use React Native's Linking API to open URLs across mobile platforms.
|
|
17
17
|
|
|
18
18
|
> View in [Figma](https://www.figma.com/design/JxaLVMTWirCpU0rsbZ30k7/2.-Components-Library?node-id=770-11743&p=f).
|
|
19
19
|
|
|
@@ -34,10 +34,11 @@ Links are essential navigation elements that direct users to internal screens or
|
|
|
34
34
|
|
|
35
35
|
### Appearance
|
|
36
36
|
|
|
37
|
-
There are
|
|
37
|
+
There are three link appearance variants:
|
|
38
38
|
|
|
39
39
|
- **base** (default): Standard link with base text color and pressed states
|
|
40
40
|
- **accent**: Interactive accent color for emphasis
|
|
41
|
+
- **gray**: Muted color for less important actions
|
|
41
42
|
|
|
42
43
|
<Canvas of={LinkStories.AppearanceShowcase} />
|
|
43
44
|
|
|
@@ -19,7 +19,7 @@ const meta = {
|
|
|
19
19
|
argTypes: {
|
|
20
20
|
appearance: {
|
|
21
21
|
control: 'select',
|
|
22
|
-
options: ['base', 'accent'],
|
|
22
|
+
options: ['base', 'accent', 'gray'],
|
|
23
23
|
description: 'The visual style appearance of the link',
|
|
24
24
|
},
|
|
25
25
|
size: {
|
|
@@ -55,7 +55,7 @@ const meta = {
|
|
|
55
55
|
|
|
56
56
|
export default meta;
|
|
57
57
|
type Story = StoryObj<typeof Link>;
|
|
58
|
-
type LinkAppearance = 'base' | 'accent';
|
|
58
|
+
type LinkAppearance = 'base' | 'accent' | 'gray';
|
|
59
59
|
|
|
60
60
|
export const Base: Story = {
|
|
61
61
|
args: {
|
|
@@ -158,6 +158,7 @@ export const AppearanceShowcase: Story = {
|
|
|
158
158
|
const appearances: { name: string; appearance: LinkAppearance }[] = [
|
|
159
159
|
{ name: 'Base', appearance: 'base' },
|
|
160
160
|
{ name: 'Accent', appearance: 'accent' },
|
|
161
|
+
{ name: 'Gray', appearance: 'gray' },
|
|
161
162
|
];
|
|
162
163
|
|
|
163
164
|
return (
|
|
@@ -74,6 +74,7 @@ describe('Link Component', () => {
|
|
|
74
74
|
it.each([
|
|
75
75
|
['base', colors.text.base],
|
|
76
76
|
['accent', colors.text.interactive],
|
|
77
|
+
['gray', colors.text.muted],
|
|
77
78
|
])(
|
|
78
79
|
'should apply %s appearance with correct text color',
|
|
79
80
|
(appearance, expectedColor) => {
|
|
@@ -142,6 +143,7 @@ describe('Link Component', () => {
|
|
|
142
143
|
it.each([
|
|
143
144
|
['base', colors.text.base, colors.text.basePressed],
|
|
144
145
|
['accent', colors.text.interactive, colors.text.interactivePressed],
|
|
146
|
+
['gray', colors.text.muted, colors.text.mutedPressed],
|
|
145
147
|
])(
|
|
146
148
|
'should apply the %s pressed color while pressed',
|
|
147
149
|
(appearance, restingColor, pressedColor) => {
|
|
@@ -46,11 +46,13 @@ const useStyles = ({ appearance, size, underline, pressed }: StyleParams) => {
|
|
|
46
46
|
const textColors: Record<Appearance, string> = {
|
|
47
47
|
base: t.colors.text.base,
|
|
48
48
|
accent: t.colors.text.interactive,
|
|
49
|
+
gray: t.colors.text.muted,
|
|
49
50
|
};
|
|
50
51
|
|
|
51
52
|
const pressedTextColors: Record<Appearance, string> = {
|
|
52
53
|
base: t.colors.text.basePressed,
|
|
53
54
|
accent: t.colors.text.interactivePressed,
|
|
55
|
+
gray: t.colors.text.mutedPressed,
|
|
54
56
|
};
|
|
55
57
|
|
|
56
58
|
const color = pressed
|
|
@@ -87,7 +89,7 @@ const useStyles = ({ appearance, size, underline, pressed }: StyleParams) => {
|
|
|
87
89
|
};
|
|
88
90
|
|
|
89
91
|
/**
|
|
90
|
-
* A customizable link component that supports
|
|
92
|
+
* A customizable link component that supports multiple color appearances, optional underline, sizes, icons, and external link handling.
|
|
91
93
|
* Opens URLs using React Native's Linking API.
|
|
92
94
|
*
|
|
93
95
|
* Rendered as a `Text`, so it can be nested inside a paragraph of text and flows
|
|
@@ -40,9 +40,18 @@ Set `disabled` on individual `MenuListItem`s to prevent interaction. The label a
|
|
|
40
40
|
|
|
41
41
|
<Canvas of={MenuListStories.DisabledShowcase} />
|
|
42
42
|
|
|
43
|
+
### Switch item
|
|
44
|
+
|
|
45
|
+
Use `MenuListSwitchItem` for a toggleable action. It renders a label, an optional leading icon, and a trailing `Switch`. Pressing anywhere on the item toggles the switch.
|
|
46
|
+
|
|
47
|
+
`MenuListSwitchItem` supports controlled (`checked` / `onCheckedChange`) and uncontrolled (`defaultChecked`) usage, same as `Switch`.
|
|
48
|
+
|
|
49
|
+
<Canvas of={MenuListStories.SwitchItemShowcase} />
|
|
50
|
+
<Controls of={MenuListStories.SwitchItemShowcase} />
|
|
51
|
+
|
|
43
52
|
## Accessibility
|
|
44
53
|
|
|
45
|
-
Each `MenuListItem` has `accessibilityRole='button'` and sets `accessibilityState={{ disabled }}` to reflect its interaction state to assistive technologies.
|
|
54
|
+
Each `MenuListItem` has `accessibilityRole='button'` and sets `accessibilityState={{ disabled }}` to reflect its interaction state to assistive technologies. `MenuListSwitchItem` uses `accessibilityRole='switch'` and additionally reflects `checked` in its `accessibilityState`.
|
|
46
55
|
|
|
47
56
|
</Tab>
|
|
48
57
|
|
|
@@ -62,5 +71,9 @@ Each `MenuListItem` has `accessibilityRole='button'` and sets `accessibilityStat
|
|
|
62
71
|
|
|
63
72
|
<Source of={MenuListStories.DisabledShowcase} />
|
|
64
73
|
|
|
74
|
+
### Switch Item
|
|
75
|
+
|
|
76
|
+
<Source of={MenuListStories.SwitchItemShowcase} />
|
|
77
|
+
|
|
65
78
|
</Tab>
|
|
66
79
|
</CustomTabs>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-native-web-vite';
|
|
2
2
|
import { Box } from '../../primitives';
|
|
3
3
|
import { Settings, Trash, Unlink } from '../../symbols';
|
|
4
|
-
import { MenuList, MenuListItem } from './MenuList';
|
|
4
|
+
import { MenuList, MenuListItem, MenuListSwitchItem } from './MenuList';
|
|
5
5
|
|
|
6
6
|
const iconMap = {
|
|
7
7
|
None: undefined,
|
|
@@ -14,7 +14,7 @@ const meta = {
|
|
|
14
14
|
id: 'rnative-menulist',
|
|
15
15
|
title: 'Core/MenuList',
|
|
16
16
|
component: MenuList,
|
|
17
|
-
subcomponents: { MenuListItem },
|
|
17
|
+
subcomponents: { MenuListItem, MenuListSwitchItem },
|
|
18
18
|
parameters: {
|
|
19
19
|
docs: {
|
|
20
20
|
source: { language: 'tsx', format: true, type: 'dynamic' },
|
|
@@ -87,6 +87,34 @@ export const AppearanceShowcase: Story = {
|
|
|
87
87
|
),
|
|
88
88
|
};
|
|
89
89
|
|
|
90
|
+
export const SwitchItemShowcase: StoryObj<typeof MenuListSwitchItem> = {
|
|
91
|
+
parameters: {
|
|
92
|
+
layout: 'centered',
|
|
93
|
+
backgrounds: { default: 'light' },
|
|
94
|
+
},
|
|
95
|
+
argTypes: {
|
|
96
|
+
icon: {
|
|
97
|
+
options: Object.keys(iconMap),
|
|
98
|
+
mapping: iconMap,
|
|
99
|
+
control: { type: 'select' },
|
|
100
|
+
},
|
|
101
|
+
onCheckedChange: { action: 'checkedChange' },
|
|
102
|
+
},
|
|
103
|
+
args: {
|
|
104
|
+
label: 'Notifications',
|
|
105
|
+
disabled: false,
|
|
106
|
+
defaultChecked: false,
|
|
107
|
+
icon: Settings,
|
|
108
|
+
},
|
|
109
|
+
render: (args) => (
|
|
110
|
+
<Box lx={{ width: 's320' }}>
|
|
111
|
+
<MenuList>
|
|
112
|
+
<MenuListSwitchItem {...args} />
|
|
113
|
+
</MenuList>
|
|
114
|
+
</Box>
|
|
115
|
+
),
|
|
116
|
+
};
|
|
117
|
+
|
|
90
118
|
export const DisabledShowcase: Story = {
|
|
91
119
|
parameters: {
|
|
92
120
|
layout: 'centered',
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { describe, it, expect, jest } from '@jest/globals';
|
|
2
2
|
import { ledgerLiveThemes } from '@ledgerhq/lumen-design-core';
|
|
3
|
-
import { render, fireEvent } from '@testing-library/react-native';
|
|
3
|
+
import { render, fireEvent, waitFor } from '@testing-library/react-native';
|
|
4
4
|
import { View } from 'react-native';
|
|
5
5
|
import { ThemeProvider } from '../ThemeProvider/ThemeProvider';
|
|
6
|
-
import { MenuList, MenuListItem } from './MenuList';
|
|
6
|
+
import { MenuList, MenuListItem, MenuListSwitchItem } from './MenuList';
|
|
7
7
|
import type { IconComponent } from './types';
|
|
8
8
|
|
|
9
9
|
const TestIcon: IconComponent = ({ size, color }) => (
|
|
@@ -133,3 +133,73 @@ describe('MenuListItem', () => {
|
|
|
133
133
|
expect(getByTestId('icon').props.accessibilityLabel).toBe('error');
|
|
134
134
|
});
|
|
135
135
|
});
|
|
136
|
+
|
|
137
|
+
describe('MenuListSwitchItem', () => {
|
|
138
|
+
it('renders the label', () => {
|
|
139
|
+
const { getByText } = render(
|
|
140
|
+
<TestWrapper>
|
|
141
|
+
<MenuListSwitchItem label='Notifications' />
|
|
142
|
+
</TestWrapper>,
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
expect(getByText('Notifications')).toBeTruthy();
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('uncontrolled: toggles checked state on press', async () => {
|
|
149
|
+
const { getByRole } = render(
|
|
150
|
+
<TestWrapper>
|
|
151
|
+
<MenuListSwitchItem label='Notifications' defaultChecked={false} />
|
|
152
|
+
</TestWrapper>,
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
const item = getByRole('switch');
|
|
156
|
+
expect(item.props.accessibilityState?.checked).toBe(false);
|
|
157
|
+
|
|
158
|
+
fireEvent.press(item);
|
|
159
|
+
|
|
160
|
+
await waitFor(() =>
|
|
161
|
+
expect(item.props.accessibilityState?.checked).toBe(true),
|
|
162
|
+
);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('controlled: calls onCheckedChange but state is controlled by parent', async () => {
|
|
166
|
+
const onCheckedChange = jest.fn();
|
|
167
|
+
const { getByRole } = render(
|
|
168
|
+
<TestWrapper>
|
|
169
|
+
<MenuListSwitchItem
|
|
170
|
+
label='Notifications'
|
|
171
|
+
checked={false}
|
|
172
|
+
onCheckedChange={onCheckedChange}
|
|
173
|
+
/>
|
|
174
|
+
</TestWrapper>,
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
fireEvent.press(getByRole('switch'));
|
|
178
|
+
|
|
179
|
+
await waitFor(() => expect(onCheckedChange).toHaveBeenCalledWith(true));
|
|
180
|
+
await waitFor(() =>
|
|
181
|
+
expect(getByRole('switch').props.accessibilityState?.checked).toBe(false),
|
|
182
|
+
);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('does not toggle when disabled', async () => {
|
|
186
|
+
const onCheckedChange = jest.fn();
|
|
187
|
+
const { getByRole } = render(
|
|
188
|
+
<TestWrapper>
|
|
189
|
+
<MenuListSwitchItem
|
|
190
|
+
label='Notifications'
|
|
191
|
+
disabled
|
|
192
|
+
defaultChecked={false}
|
|
193
|
+
onCheckedChange={onCheckedChange}
|
|
194
|
+
/>
|
|
195
|
+
</TestWrapper>,
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
const item = getByRole('switch');
|
|
199
|
+
expect(item.props.accessibilityState?.disabled).toBe(true);
|
|
200
|
+
|
|
201
|
+
fireEvent.press(item);
|
|
202
|
+
|
|
203
|
+
await waitFor(() => expect(onCheckedChange).not.toHaveBeenCalled());
|
|
204
|
+
});
|
|
205
|
+
});
|