@lockin90/ui-native 1.0.1 → 2.2.0
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/lib/commonjs/components/AuroraBackground.js +65 -37
- package/lib/commonjs/components/AuroraBackground.js.map +1 -1
- package/lib/commonjs/components/Avatar.js +2 -1
- package/lib/commonjs/components/Avatar.js.map +1 -1
- package/lib/commonjs/components/BrandMark.js +7 -2
- package/lib/commonjs/components/BrandMark.js.map +1 -1
- package/lib/commonjs/components/FocalPointPicker.js +2 -1
- package/lib/commonjs/components/FocalPointPicker.js.map +1 -1
- package/lib/commonjs/components/Gauge.js +2 -1
- package/lib/commonjs/components/Gauge.js.map +1 -1
- package/lib/commonjs/components/Icon.js +1 -0
- package/lib/commonjs/components/Icon.js.map +1 -1
- package/lib/commonjs/components/Menu.js +2 -1
- package/lib/commonjs/components/Menu.js.map +1 -1
- package/lib/commonjs/components/Modal.js +2 -1
- package/lib/commonjs/components/Modal.js.map +1 -1
- package/lib/commonjs/components/PasswordInput.js +3 -3
- package/lib/commonjs/components/PasswordInput.js.map +1 -1
- package/lib/commonjs/components/PhaseWheel.js +2 -1
- package/lib/commonjs/components/PhaseWheel.js.map +1 -1
- package/lib/commonjs/components/PkChart.js +1 -1
- package/lib/commonjs/components/PkChart.js.map +1 -1
- package/lib/commonjs/components/Popover.js +2 -1
- package/lib/commonjs/components/Popover.js.map +1 -1
- package/lib/commonjs/components/ProGate.js +2 -1
- package/lib/commonjs/components/ProGate.js.map +1 -1
- package/lib/commonjs/components/RestTimer.js +2 -1
- package/lib/commonjs/components/RestTimer.js.map +1 -1
- package/lib/commonjs/components/Ring.js +2 -1
- package/lib/commonjs/components/Ring.js.map +1 -1
- package/lib/commonjs/components/SegmentedTabs.js +2 -1
- package/lib/commonjs/components/SegmentedTabs.js.map +1 -1
- package/lib/commonjs/components/Select.js +7 -1
- package/lib/commonjs/components/Select.js.map +1 -1
- package/lib/commonjs/components/ShareCard.js +2 -1
- package/lib/commonjs/components/ShareCard.js.map +1 -1
- package/lib/commonjs/components/Sheet.js +2 -1
- package/lib/commonjs/components/Sheet.js.map +1 -1
- package/lib/commonjs/components/TabBar.js +2 -1
- package/lib/commonjs/components/TabBar.js.map +1 -1
- package/lib/commonjs/components/TagInput.js +86 -42
- package/lib/commonjs/components/TagInput.js.map +1 -1
- package/lib/commonjs/components/Toggle.js +2 -1
- package/lib/commonjs/components/Toggle.js.map +1 -1
- package/lib/commonjs/components/Tooltip.js +2 -1
- package/lib/commonjs/components/Tooltip.js.map +1 -1
- package/lib/commonjs/internal/absoluteFill.js +18 -0
- package/lib/commonjs/internal/absoluteFill.js.map +1 -0
- package/lib/module/components/AuroraBackground.js +66 -38
- package/lib/module/components/AuroraBackground.js.map +1 -1
- package/lib/module/components/Avatar.js +2 -1
- package/lib/module/components/Avatar.js.map +1 -1
- package/lib/module/components/BrandMark.js +7 -2
- package/lib/module/components/BrandMark.js.map +1 -1
- package/lib/module/components/FocalPointPicker.js +2 -1
- package/lib/module/components/FocalPointPicker.js.map +1 -1
- package/lib/module/components/Gauge.js +2 -1
- package/lib/module/components/Gauge.js.map +1 -1
- package/lib/module/components/Icon.js +2 -1
- package/lib/module/components/Icon.js.map +1 -1
- package/lib/module/components/Menu.js +2 -1
- package/lib/module/components/Menu.js.map +1 -1
- package/lib/module/components/Modal.js +2 -1
- package/lib/module/components/Modal.js.map +1 -1
- package/lib/module/components/PasswordInput.js +3 -3
- package/lib/module/components/PasswordInput.js.map +1 -1
- package/lib/module/components/PhaseWheel.js +2 -1
- package/lib/module/components/PhaseWheel.js.map +1 -1
- package/lib/module/components/PkChart.js +1 -1
- package/lib/module/components/PkChart.js.map +1 -1
- package/lib/module/components/Popover.js +2 -1
- package/lib/module/components/Popover.js.map +1 -1
- package/lib/module/components/ProGate.js +2 -1
- package/lib/module/components/ProGate.js.map +1 -1
- package/lib/module/components/RestTimer.js +2 -1
- package/lib/module/components/RestTimer.js.map +1 -1
- package/lib/module/components/Ring.js +2 -1
- package/lib/module/components/Ring.js.map +1 -1
- package/lib/module/components/SegmentedTabs.js +2 -1
- package/lib/module/components/SegmentedTabs.js.map +1 -1
- package/lib/module/components/Select.js +7 -1
- package/lib/module/components/Select.js.map +1 -1
- package/lib/module/components/ShareCard.js +2 -1
- package/lib/module/components/ShareCard.js.map +1 -1
- package/lib/module/components/Sheet.js +2 -1
- package/lib/module/components/Sheet.js.map +1 -1
- package/lib/module/components/TabBar.js +2 -1
- package/lib/module/components/TabBar.js.map +1 -1
- package/lib/module/components/TagInput.js +82 -41
- package/lib/module/components/TagInput.js.map +1 -1
- package/lib/module/components/Toggle.js +2 -1
- package/lib/module/components/Toggle.js.map +1 -1
- package/lib/module/components/Tooltip.js +2 -1
- package/lib/module/components/Tooltip.js.map +1 -1
- package/lib/module/internal/absoluteFill.js +14 -0
- package/lib/module/internal/absoluteFill.js.map +1 -0
- package/lib/typescript/components/AuroraBackground.d.ts.map +1 -1
- package/lib/typescript/components/Avatar.d.ts.map +1 -1
- package/lib/typescript/components/BrandMark.d.ts +4 -1
- package/lib/typescript/components/BrandMark.d.ts.map +1 -1
- package/lib/typescript/components/FocalPointPicker.d.ts.map +1 -1
- package/lib/typescript/components/Gauge.d.ts.map +1 -1
- package/lib/typescript/components/Icon.d.ts +1 -1
- package/lib/typescript/components/Icon.d.ts.map +1 -1
- package/lib/typescript/components/Menu.d.ts.map +1 -1
- package/lib/typescript/components/Modal.d.ts.map +1 -1
- package/lib/typescript/components/PasswordInput.d.ts +7 -4
- package/lib/typescript/components/PasswordInput.d.ts.map +1 -1
- package/lib/typescript/components/PhaseWheel.d.ts.map +1 -1
- package/lib/typescript/components/PkChart.d.ts.map +1 -1
- package/lib/typescript/components/Popover.d.ts.map +1 -1
- package/lib/typescript/components/ProGate.d.ts.map +1 -1
- package/lib/typescript/components/RestTimer.d.ts.map +1 -1
- package/lib/typescript/components/Ring.d.ts.map +1 -1
- package/lib/typescript/components/SegmentedTabs.d.ts.map +1 -1
- package/lib/typescript/components/Select.d.ts +6 -1
- package/lib/typescript/components/Select.d.ts.map +1 -1
- package/lib/typescript/components/ShareCard.d.ts.map +1 -1
- package/lib/typescript/components/Sheet.d.ts.map +1 -1
- package/lib/typescript/components/TabBar.d.ts.map +1 -1
- package/lib/typescript/components/TagInput.d.ts +21 -8
- package/lib/typescript/components/TagInput.d.ts.map +1 -1
- package/lib/typescript/components/Toggle.d.ts.map +1 -1
- package/lib/typescript/components/Tooltip.d.ts.map +1 -1
- package/lib/typescript/internal/absoluteFill.d.ts +8 -0
- package/lib/typescript/internal/absoluteFill.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/components/AuroraBackground.tsx +43 -20
- package/src/components/Avatar.tsx +2 -1
- package/src/components/BrandMark.tsx +10 -4
- package/src/components/FocalPointPicker.tsx +2 -1
- package/src/components/Gauge.tsx +2 -1
- package/src/components/Icon.tsx +3 -0
- package/src/components/Menu.tsx +2 -1
- package/src/components/Modal.tsx +2 -1
- package/src/components/PasswordInput.tsx +9 -6
- package/src/components/PhaseWheel.tsx +2 -1
- package/src/components/PkChart.tsx +2 -1
- package/src/components/Popover.tsx +2 -1
- package/src/components/ProGate.tsx +2 -1
- package/src/components/RestTimer.tsx +2 -1
- package/src/components/Ring.tsx +2 -1
- package/src/components/SegmentedTabs.tsx +2 -1
- package/src/components/Select.tsx +10 -1
- package/src/components/ShareCard.tsx +2 -1
- package/src/components/Sheet.tsx +2 -1
- package/src/components/TabBar.tsx +2 -1
- package/src/components/TagInput.tsx +84 -44
- package/src/components/Toggle.tsx +2 -1
- package/src/components/Tooltip.tsx +2 -1
- package/src/components/__tests__/BrandMark.test.tsx +17 -0
- package/src/components/__tests__/CodeInput.test.tsx +81 -25
- package/src/components/__tests__/PasswordInput.test.tsx +19 -0
- package/src/components/__tests__/Select.test.tsx +22 -0
- package/src/internal/absoluteFill.ts +11 -0
|
@@ -1,46 +1,90 @@
|
|
|
1
1
|
import { describe, expect, test } from 'vitest';
|
|
2
|
-
import { CodeInput,
|
|
2
|
+
import { CodeInput, codeToBoxes, resizeBoxes, spreadDigits, typeIntoBox } from '../TagInput';
|
|
3
3
|
import { findAll, parse, render } from './markup';
|
|
4
4
|
|
|
5
|
-
/* Multi-char paste / iOS SMS autofill lands the whole code in ONE box; the
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* can't be dispatched without a DOM environment). */
|
|
5
|
+
/* Multi-char paste / iOS SMS autofill lands the whole code in ONE box; the component spreads it
|
|
6
|
+
* across the remaining boxes and moves focus after the last written digit. The box math lives in
|
|
7
|
+
* the pure helpers `codeToBoxes` / `spreadDigits` (press/typing events can't be dispatched without a
|
|
8
|
+
* DOM environment). */
|
|
10
9
|
|
|
11
|
-
describe('
|
|
10
|
+
describe('codeToBoxes', () => {
|
|
11
|
+
test('puts one digit per box, padded to the length', () => {
|
|
12
|
+
expect(codeToBoxes('12', 4)).toEqual(['1', '2', '', '']);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('drops non-digits and anything past the last box', () => {
|
|
16
|
+
expect(codeToBoxes('1a2-345', 4)).toEqual(['1', '2', '3', '4']);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe('spreadDigits (paste / autofill)', () => {
|
|
12
21
|
test('a full-length paste into box 0 fills every box and focuses the last', () => {
|
|
13
|
-
expect(
|
|
14
|
-
|
|
22
|
+
expect(spreadDigits(['', '', '', '', '', ''], 0, '123456')).toEqual({
|
|
23
|
+
boxes: ['1', '2', '3', '4', '5', '6'],
|
|
15
24
|
focusIndex: 5,
|
|
16
25
|
});
|
|
17
26
|
});
|
|
18
27
|
|
|
19
|
-
test('
|
|
20
|
-
expect(
|
|
21
|
-
|
|
22
|
-
|
|
28
|
+
test('takes only the digits of a copied "Code: 1234-5678"', () => {
|
|
29
|
+
expect(spreadDigits(Array(8).fill(''), 0, 'Code: 1234-5678').boxes).toEqual([
|
|
30
|
+
'1', '2', '3', '4', '5', '6', '7', '8',
|
|
31
|
+
]);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('keeps earlier boxes, and a gap stays a gap', () => {
|
|
35
|
+
expect(spreadDigits(['1', '', '3', '', ''], 3, '45')).toEqual({
|
|
36
|
+
boxes: ['1', '', '3', '4', '5'],
|
|
37
|
+
focusIndex: 4,
|
|
23
38
|
});
|
|
24
39
|
});
|
|
25
40
|
|
|
26
|
-
test('
|
|
27
|
-
expect(
|
|
28
|
-
|
|
41
|
+
test('digits past the last box are dropped and focus clamps to the last box', () => {
|
|
42
|
+
expect(spreadDigits(['1', '2', '3', '4', '', ''], 4, '789')).toEqual({
|
|
43
|
+
boxes: ['1', '2', '3', '4', '7', '8'],
|
|
29
44
|
focusIndex: 5,
|
|
30
45
|
});
|
|
31
46
|
});
|
|
32
47
|
|
|
33
|
-
test('
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
48
|
+
test('does not mutate the incoming boxes', () => {
|
|
49
|
+
const boxes = ['1', '', ''];
|
|
50
|
+
spreadDigits(boxes, 0, '456');
|
|
51
|
+
expect(boxes).toEqual(['1', '', '']);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe('typeIntoBox (typing)', () => {
|
|
56
|
+
test('a digit fills the box and moves on', () => {
|
|
57
|
+
expect(typeIntoBox(['1', '', ''], 1, '2')).toEqual({ boxes: ['1', '2', ''], focusIndex: 2 });
|
|
38
58
|
});
|
|
39
59
|
|
|
40
|
-
test('
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
60
|
+
test('a digit replaces the box\'s one (it is selected)', () => {
|
|
61
|
+
expect(typeIntoBox(['1', '5', ''], 0, '2')).toEqual({ boxes: ['2', '5', ''], focusIndex: 1 });
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('two digits into box 0 (a short autofill) spread, not collapse', () => {
|
|
65
|
+
expect(typeIntoBox(['', '', ''], 0, '34')).toEqual({ boxes: ['3', '4', ''], focusIndex: 2 });
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('a letter is ignored', () => {
|
|
69
|
+
expect(typeIntoBox(['1', '', ''], 1, 'a')).toBeNull();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test('clearing a middle box leaves a gap, later digits stay put', () => {
|
|
73
|
+
expect(typeIntoBox(['1', '2', '3'], 1, '')).toEqual({ boxes: ['1', '', '3'], focusIndex: 1 });
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('a whole code spreads like a paste', () => {
|
|
77
|
+
expect(typeIntoBox(['', '', ''], 0, '987')).toEqual({ boxes: ['9', '8', '7'], focusIndex: 2 });
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe('resizeBoxes (another length)', () => {
|
|
82
|
+
test('keeps each digit in its place, a gap stays a gap', () => {
|
|
83
|
+
expect(resizeBoxes(['1', '', '3', '4'], 6)).toEqual(['1', '', '3', '4', '', '']);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('drops the boxes past the new length', () => {
|
|
87
|
+
expect(resizeBoxes(['1', '2', '3', '4'], 2)).toEqual(['1', '2']);
|
|
44
88
|
});
|
|
45
89
|
});
|
|
46
90
|
|
|
@@ -59,4 +103,16 @@ describe('CodeInput rendering', () => {
|
|
|
59
103
|
expect(inputs[0].attrs.maxLength).toBe('6');
|
|
60
104
|
for (const box of inputs.slice(1)) expect(box.attrs.maxLength).toBe('1');
|
|
61
105
|
});
|
|
106
|
+
|
|
107
|
+
test('labels each box "Digit N of L" by default', () => {
|
|
108
|
+
const html = render(CodeInput, { length: 8 });
|
|
109
|
+
expect(html).toContain('aria-label="Digit 1 of 8"');
|
|
110
|
+
expect(html).toContain('aria-label="Digit 8 of 8"');
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test("labels each box with the app's digitLabel", () => {
|
|
114
|
+
const html = render(CodeInput, { length: 3, digitLabel: (p: number, l: number) => `Цифра ${p} из ${l}` });
|
|
115
|
+
expect(html).toContain('aria-label="Цифра 2 из 3"');
|
|
116
|
+
expect(html).not.toContain('Digit');
|
|
117
|
+
});
|
|
62
118
|
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { PasswordInput } from '../PasswordInput';
|
|
3
|
+
import { render } from './markup';
|
|
4
|
+
|
|
5
|
+
/* The eye toggle names the action it does now: show while masked, hide while
|
|
6
|
+
* revealed (one string couldn't, so apps' translated label went stale). */
|
|
7
|
+
describe('PasswordInput toggle label', () => {
|
|
8
|
+
test('uses showLabel while masked', () => {
|
|
9
|
+
const html = render(PasswordInput, { showLabel: 'Mostrar', hideLabel: 'Ocultar' });
|
|
10
|
+
expect(html).toContain('aria-label="Mostrar"');
|
|
11
|
+
expect(html).not.toContain('Ocultar');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('uses hideLabel while revealed', () => {
|
|
15
|
+
const html = render(PasswordInput, { defaultVisible: true, showLabel: 'Mostrar', hideLabel: 'Ocultar' });
|
|
16
|
+
expect(html).toContain('aria-label="Ocultar"');
|
|
17
|
+
expect(html).not.toContain('Mostrar');
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { Select } from '../Select';
|
|
3
|
+
import { render } from './markup';
|
|
4
|
+
|
|
5
|
+
const OPTIONS = [
|
|
6
|
+
{ value: 'en', label: 'English' },
|
|
7
|
+
{ value: 'uk', label: 'Українська' },
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
/* The trigger has a name for screen readers even with no visible label (the
|
|
11
|
+
* language picker), not just the selected value. */
|
|
12
|
+
describe('Select trigger name', () => {
|
|
13
|
+
test('takes accessibilityLabel', () => {
|
|
14
|
+
const html = render(Select, { options: OPTIONS, value: 'en', accessibilityLabel: 'Мова' });
|
|
15
|
+
expect(html).toContain('aria-label="Мова"');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('falls back to the visible label', () => {
|
|
19
|
+
const html = render(Select, { options: OPTIONS, value: 'en', label: 'Language' });
|
|
20
|
+
expect(html).toContain('aria-label="Language"');
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// The plain style object to spread for an absolute fill. React Native 0.88
|
|
2
|
+
// removed StyleSheet.absoluteFillObject (spreading it silently drops the
|
|
3
|
+
// positioning), and older versions type StyleSheet.absoluteFill as a
|
|
4
|
+
// registered id that can't be spread.
|
|
5
|
+
export const absoluteFill = {
|
|
6
|
+
position: 'absolute',
|
|
7
|
+
top: 0,
|
|
8
|
+
right: 0,
|
|
9
|
+
bottom: 0,
|
|
10
|
+
left: 0,
|
|
11
|
+
} as const;
|