@lockin90/ui-native 1.0.1 → 2.1.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.
Files changed (155) hide show
  1. package/lib/commonjs/components/AuroraBackground.js +63 -35
  2. package/lib/commonjs/components/AuroraBackground.js.map +1 -1
  3. package/lib/commonjs/components/Avatar.js +2 -1
  4. package/lib/commonjs/components/Avatar.js.map +1 -1
  5. package/lib/commonjs/components/BrandMark.js +7 -2
  6. package/lib/commonjs/components/BrandMark.js.map +1 -1
  7. package/lib/commonjs/components/FocalPointPicker.js +2 -1
  8. package/lib/commonjs/components/FocalPointPicker.js.map +1 -1
  9. package/lib/commonjs/components/Gauge.js +2 -1
  10. package/lib/commonjs/components/Gauge.js.map +1 -1
  11. package/lib/commonjs/components/Icon.js +1 -0
  12. package/lib/commonjs/components/Icon.js.map +1 -1
  13. package/lib/commonjs/components/Menu.js +2 -1
  14. package/lib/commonjs/components/Menu.js.map +1 -1
  15. package/lib/commonjs/components/Modal.js +2 -1
  16. package/lib/commonjs/components/Modal.js.map +1 -1
  17. package/lib/commonjs/components/PasswordInput.js +3 -3
  18. package/lib/commonjs/components/PasswordInput.js.map +1 -1
  19. package/lib/commonjs/components/PhaseWheel.js +2 -1
  20. package/lib/commonjs/components/PhaseWheel.js.map +1 -1
  21. package/lib/commonjs/components/PkChart.js +1 -1
  22. package/lib/commonjs/components/PkChart.js.map +1 -1
  23. package/lib/commonjs/components/Popover.js +2 -1
  24. package/lib/commonjs/components/Popover.js.map +1 -1
  25. package/lib/commonjs/components/ProGate.js +2 -1
  26. package/lib/commonjs/components/ProGate.js.map +1 -1
  27. package/lib/commonjs/components/RestTimer.js +2 -1
  28. package/lib/commonjs/components/RestTimer.js.map +1 -1
  29. package/lib/commonjs/components/Ring.js +2 -1
  30. package/lib/commonjs/components/Ring.js.map +1 -1
  31. package/lib/commonjs/components/SegmentedTabs.js +2 -1
  32. package/lib/commonjs/components/SegmentedTabs.js.map +1 -1
  33. package/lib/commonjs/components/Select.js +7 -1
  34. package/lib/commonjs/components/Select.js.map +1 -1
  35. package/lib/commonjs/components/ShareCard.js +2 -1
  36. package/lib/commonjs/components/ShareCard.js.map +1 -1
  37. package/lib/commonjs/components/Sheet.js +2 -1
  38. package/lib/commonjs/components/Sheet.js.map +1 -1
  39. package/lib/commonjs/components/TabBar.js +2 -1
  40. package/lib/commonjs/components/TabBar.js.map +1 -1
  41. package/lib/commonjs/components/TagInput.js +86 -42
  42. package/lib/commonjs/components/TagInput.js.map +1 -1
  43. package/lib/commonjs/components/Toggle.js +2 -1
  44. package/lib/commonjs/components/Toggle.js.map +1 -1
  45. package/lib/commonjs/components/Tooltip.js +2 -1
  46. package/lib/commonjs/components/Tooltip.js.map +1 -1
  47. package/lib/commonjs/internal/absoluteFill.js +18 -0
  48. package/lib/commonjs/internal/absoluteFill.js.map +1 -0
  49. package/lib/module/components/AuroraBackground.js +64 -36
  50. package/lib/module/components/AuroraBackground.js.map +1 -1
  51. package/lib/module/components/Avatar.js +2 -1
  52. package/lib/module/components/Avatar.js.map +1 -1
  53. package/lib/module/components/BrandMark.js +7 -2
  54. package/lib/module/components/BrandMark.js.map +1 -1
  55. package/lib/module/components/FocalPointPicker.js +2 -1
  56. package/lib/module/components/FocalPointPicker.js.map +1 -1
  57. package/lib/module/components/Gauge.js +2 -1
  58. package/lib/module/components/Gauge.js.map +1 -1
  59. package/lib/module/components/Icon.js +2 -1
  60. package/lib/module/components/Icon.js.map +1 -1
  61. package/lib/module/components/Menu.js +2 -1
  62. package/lib/module/components/Menu.js.map +1 -1
  63. package/lib/module/components/Modal.js +2 -1
  64. package/lib/module/components/Modal.js.map +1 -1
  65. package/lib/module/components/PasswordInput.js +3 -3
  66. package/lib/module/components/PasswordInput.js.map +1 -1
  67. package/lib/module/components/PhaseWheel.js +2 -1
  68. package/lib/module/components/PhaseWheel.js.map +1 -1
  69. package/lib/module/components/PkChart.js +1 -1
  70. package/lib/module/components/PkChart.js.map +1 -1
  71. package/lib/module/components/Popover.js +2 -1
  72. package/lib/module/components/Popover.js.map +1 -1
  73. package/lib/module/components/ProGate.js +2 -1
  74. package/lib/module/components/ProGate.js.map +1 -1
  75. package/lib/module/components/RestTimer.js +2 -1
  76. package/lib/module/components/RestTimer.js.map +1 -1
  77. package/lib/module/components/Ring.js +2 -1
  78. package/lib/module/components/Ring.js.map +1 -1
  79. package/lib/module/components/SegmentedTabs.js +2 -1
  80. package/lib/module/components/SegmentedTabs.js.map +1 -1
  81. package/lib/module/components/Select.js +7 -1
  82. package/lib/module/components/Select.js.map +1 -1
  83. package/lib/module/components/ShareCard.js +2 -1
  84. package/lib/module/components/ShareCard.js.map +1 -1
  85. package/lib/module/components/Sheet.js +2 -1
  86. package/lib/module/components/Sheet.js.map +1 -1
  87. package/lib/module/components/TabBar.js +2 -1
  88. package/lib/module/components/TabBar.js.map +1 -1
  89. package/lib/module/components/TagInput.js +82 -41
  90. package/lib/module/components/TagInput.js.map +1 -1
  91. package/lib/module/components/Toggle.js +2 -1
  92. package/lib/module/components/Toggle.js.map +1 -1
  93. package/lib/module/components/Tooltip.js +2 -1
  94. package/lib/module/components/Tooltip.js.map +1 -1
  95. package/lib/module/internal/absoluteFill.js +14 -0
  96. package/lib/module/internal/absoluteFill.js.map +1 -0
  97. package/lib/typescript/components/AuroraBackground.d.ts.map +1 -1
  98. package/lib/typescript/components/Avatar.d.ts.map +1 -1
  99. package/lib/typescript/components/BrandMark.d.ts +4 -1
  100. package/lib/typescript/components/BrandMark.d.ts.map +1 -1
  101. package/lib/typescript/components/FocalPointPicker.d.ts.map +1 -1
  102. package/lib/typescript/components/Gauge.d.ts.map +1 -1
  103. package/lib/typescript/components/Icon.d.ts +1 -1
  104. package/lib/typescript/components/Icon.d.ts.map +1 -1
  105. package/lib/typescript/components/Menu.d.ts.map +1 -1
  106. package/lib/typescript/components/Modal.d.ts.map +1 -1
  107. package/lib/typescript/components/PasswordInput.d.ts +7 -4
  108. package/lib/typescript/components/PasswordInput.d.ts.map +1 -1
  109. package/lib/typescript/components/PhaseWheel.d.ts.map +1 -1
  110. package/lib/typescript/components/PkChart.d.ts.map +1 -1
  111. package/lib/typescript/components/Popover.d.ts.map +1 -1
  112. package/lib/typescript/components/ProGate.d.ts.map +1 -1
  113. package/lib/typescript/components/RestTimer.d.ts.map +1 -1
  114. package/lib/typescript/components/Ring.d.ts.map +1 -1
  115. package/lib/typescript/components/SegmentedTabs.d.ts.map +1 -1
  116. package/lib/typescript/components/Select.d.ts +6 -1
  117. package/lib/typescript/components/Select.d.ts.map +1 -1
  118. package/lib/typescript/components/ShareCard.d.ts.map +1 -1
  119. package/lib/typescript/components/Sheet.d.ts.map +1 -1
  120. package/lib/typescript/components/TabBar.d.ts.map +1 -1
  121. package/lib/typescript/components/TagInput.d.ts +21 -8
  122. package/lib/typescript/components/TagInput.d.ts.map +1 -1
  123. package/lib/typescript/components/Toggle.d.ts.map +1 -1
  124. package/lib/typescript/components/Tooltip.d.ts.map +1 -1
  125. package/lib/typescript/internal/absoluteFill.d.ts +8 -0
  126. package/lib/typescript/internal/absoluteFill.d.ts.map +1 -0
  127. package/package.json +1 -1
  128. package/src/components/AuroraBackground.tsx +39 -18
  129. package/src/components/Avatar.tsx +2 -1
  130. package/src/components/BrandMark.tsx +10 -4
  131. package/src/components/FocalPointPicker.tsx +2 -1
  132. package/src/components/Gauge.tsx +2 -1
  133. package/src/components/Icon.tsx +3 -0
  134. package/src/components/Menu.tsx +2 -1
  135. package/src/components/Modal.tsx +2 -1
  136. package/src/components/PasswordInput.tsx +9 -6
  137. package/src/components/PhaseWheel.tsx +2 -1
  138. package/src/components/PkChart.tsx +2 -1
  139. package/src/components/Popover.tsx +2 -1
  140. package/src/components/ProGate.tsx +2 -1
  141. package/src/components/RestTimer.tsx +2 -1
  142. package/src/components/Ring.tsx +2 -1
  143. package/src/components/SegmentedTabs.tsx +2 -1
  144. package/src/components/Select.tsx +10 -1
  145. package/src/components/ShareCard.tsx +2 -1
  146. package/src/components/Sheet.tsx +2 -1
  147. package/src/components/TabBar.tsx +2 -1
  148. package/src/components/TagInput.tsx +84 -44
  149. package/src/components/Toggle.tsx +2 -1
  150. package/src/components/Tooltip.tsx +2 -1
  151. package/src/components/__tests__/BrandMark.test.tsx +17 -0
  152. package/src/components/__tests__/CodeInput.test.tsx +81 -25
  153. package/src/components/__tests__/PasswordInput.test.tsx +19 -0
  154. package/src/components/__tests__/Select.test.tsx +22 -0
  155. package/src/internal/absoluteFill.ts +11 -0
@@ -1,46 +1,90 @@
1
1
  import { describe, expect, test } from 'vitest';
2
- import { CodeInput, spreadCodeAcrossBoxes } from '../TagInput';
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
- * component spreads it across the remaining boxes and moves focus after the
7
- * last written char. The spread math lives in the pure helper
8
- * `spreadCodeAcrossBoxes` (extracted from `onBoxChange` — press/typing events
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('spreadCodeAcrossBoxes (paste spread math)', () => {
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(spreadCodeAcrossBoxes(['', '', '', '', '', ''], 0, '123456', 6)).toEqual({
14
- code: '123456',
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('a mid-code paste fills from that box on and keeps earlier digits', () => {
20
- expect(spreadCodeAcrossBoxes(['1', '2', '', '', '', ''], 2, '345', 6)).toEqual({
21
- code: '12345',
22
- focusIndex: 5,
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('overflow past the last box is dropped and focus clamps to the last box', () => {
27
- expect(spreadCodeAcrossBoxes(['1', '2', '3', '4', '', ''], 4, '789XYZ', 6)).toEqual({
28
- code: '123478',
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('pasting over existing digits overwrites them', () => {
34
- expect(spreadCodeAcrossBoxes(['9', '9', '9', '9', '9', '9'], 1, '00', 6)).toEqual({
35
- code: '900999',
36
- focusIndex: 3,
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('does not mutate the incoming chars', () => {
41
- const chars = ['1', '', ''];
42
- spreadCodeAcrossBoxes(chars, 0, '456', 3);
43
- expect(chars).toEqual(['1', '', '']);
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;