@bacon-pos/ui 0.4.0 → 0.5.1

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 (53) hide show
  1. package/lib/commonjs/components/CodeField/CodeField.js +104 -66
  2. package/lib/commonjs/components/CodeField/CodeField.js.map +1 -1
  3. package/lib/commonjs/components/CodeField/CodeField.stories.js +38 -2
  4. package/lib/commonjs/components/CodeField/CodeField.stories.js.map +1 -1
  5. package/lib/commonjs/components/CodeField/CodeField.test.js +28 -0
  6. package/lib/commonjs/components/CodeField/CodeField.test.js.map +1 -1
  7. package/lib/commonjs/components/Keypad/Keypad.js +162 -0
  8. package/lib/commonjs/components/Keypad/Keypad.js.map +1 -0
  9. package/lib/commonjs/components/Keypad/Keypad.stories.js +210 -0
  10. package/lib/commonjs/components/Keypad/Keypad.stories.js.map +1 -0
  11. package/lib/commonjs/components/Keypad/Keypad.test.js +119 -0
  12. package/lib/commonjs/components/Keypad/Keypad.test.js.map +1 -0
  13. package/lib/commonjs/components/Keypad/index.js +13 -0
  14. package/lib/commonjs/components/Keypad/index.js.map +1 -0
  15. package/lib/commonjs/components/index.js +20 -9
  16. package/lib/commonjs/components/index.js.map +1 -1
  17. package/lib/module/components/CodeField/CodeField.js +104 -66
  18. package/lib/module/components/CodeField/CodeField.js.map +1 -1
  19. package/lib/module/components/CodeField/CodeField.stories.js +37 -1
  20. package/lib/module/components/CodeField/CodeField.stories.js.map +1 -1
  21. package/lib/module/components/CodeField/CodeField.test.js +28 -0
  22. package/lib/module/components/CodeField/CodeField.test.js.map +1 -1
  23. package/lib/module/components/Keypad/Keypad.js +158 -0
  24. package/lib/module/components/Keypad/Keypad.js.map +1 -0
  25. package/lib/module/components/Keypad/Keypad.stories.js +206 -0
  26. package/lib/module/components/Keypad/Keypad.stories.js.map +1 -0
  27. package/lib/module/components/Keypad/Keypad.test.js +119 -0
  28. package/lib/module/components/Keypad/Keypad.test.js.map +1 -0
  29. package/lib/module/components/Keypad/index.js +4 -0
  30. package/lib/module/components/Keypad/index.js.map +1 -0
  31. package/lib/module/components/index.js +1 -0
  32. package/lib/module/components/index.js.map +1 -1
  33. package/lib/typescript/commonjs/components/CodeField/CodeField.d.ts +8 -2
  34. package/lib/typescript/commonjs/components/CodeField/CodeField.d.ts.map +1 -1
  35. package/lib/typescript/commonjs/components/Keypad/Keypad.d.ts +54 -0
  36. package/lib/typescript/commonjs/components/Keypad/Keypad.d.ts.map +1 -0
  37. package/lib/typescript/commonjs/components/Keypad/index.d.ts +3 -0
  38. package/lib/typescript/commonjs/components/Keypad/index.d.ts.map +1 -0
  39. package/lib/typescript/commonjs/components/index.d.ts +1 -0
  40. package/lib/typescript/commonjs/components/index.d.ts.map +1 -1
  41. package/lib/typescript/module/components/CodeField/CodeField.d.ts +8 -2
  42. package/lib/typescript/module/components/CodeField/CodeField.d.ts.map +1 -1
  43. package/lib/typescript/module/components/Keypad/Keypad.d.ts +54 -0
  44. package/lib/typescript/module/components/Keypad/Keypad.d.ts.map +1 -0
  45. package/lib/typescript/module/components/Keypad/index.d.ts +3 -0
  46. package/lib/typescript/module/components/Keypad/index.d.ts.map +1 -0
  47. package/lib/typescript/module/components/index.d.ts +1 -0
  48. package/lib/typescript/module/components/index.d.ts.map +1 -1
  49. package/package.json +1 -1
  50. package/src/components/CodeField/CodeField.tsx +108 -65
  51. package/src/components/Keypad/Keypad.tsx +191 -0
  52. package/src/components/Keypad/index.ts +2 -0
  53. package/src/components/index.ts +1 -0
@@ -0,0 +1,206 @@
1
+ "use strict";
2
+
3
+ import { useState } from 'react';
4
+ import { View } from 'react-native';
5
+ import { Keypad } from "./Keypad.js";
6
+ import { CodeInput } from "../CodeInput/CodeInput.js";
7
+ import { Text } from "../Text/Text.js";
8
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
+ const meta = {
10
+ title: 'Components/Keypad',
11
+ component: Keypad
12
+ };
13
+ export default meta;
14
+ /** Login PIN: the keypad drives a dots display above it. */
15
+ export const LoginCode = {
16
+ render: () => {
17
+ const [pin, setPin] = useState('');
18
+ return /*#__PURE__*/_jsx(View, {
19
+ style: {
20
+ padding: 24,
21
+ maxWidth: 360,
22
+ alignItems: 'center',
23
+ gap: 24
24
+ },
25
+ children: /*#__PURE__*/_jsx(Keypad, {
26
+ value: pin,
27
+ onChangeText: setPin,
28
+ maxLength: 4,
29
+ header: /*#__PURE__*/_jsx(View, {
30
+ style: {
31
+ alignItems: 'center'
32
+ },
33
+ children: /*#__PURE__*/_jsx(CodeInput, {
34
+ value: pin,
35
+ onChangeText: setPin,
36
+ length: 4
37
+ })
38
+ })
39
+ })
40
+ });
41
+ }
42
+ };
43
+
44
+ /**
45
+ * Login PIN with reveal — the eye toggle swaps the dots for the entered digits,
46
+ * in the same positions (see CodeInput › RevealPositions).
47
+ */
48
+ export const LoginCodeRevealable = {
49
+ render: () => {
50
+ const [pin, setPin] = useState('');
51
+ return /*#__PURE__*/_jsx(View, {
52
+ style: {
53
+ padding: 24,
54
+ maxWidth: 360,
55
+ alignItems: 'center',
56
+ gap: 24
57
+ },
58
+ children: /*#__PURE__*/_jsx(Keypad, {
59
+ value: pin,
60
+ onChangeText: setPin,
61
+ maxLength: 4,
62
+ header: /*#__PURE__*/_jsx(View, {
63
+ style: {
64
+ alignItems: 'center'
65
+ },
66
+ children: /*#__PURE__*/_jsx(CodeInput, {
67
+ value: pin,
68
+ onChangeText: setPin,
69
+ length: 4,
70
+ revealable: true,
71
+ revealPosition: "right"
72
+ })
73
+ })
74
+ })
75
+ });
76
+ }
77
+ };
78
+
79
+ /** Amount entry: big number header + a "." extra key for decimals. */
80
+ export const AmountEntry = {
81
+ render: () => {
82
+ const [amount, setAmount] = useState('');
83
+ return /*#__PURE__*/_jsx(View, {
84
+ style: {
85
+ padding: 24,
86
+ maxWidth: 360
87
+ },
88
+ children: /*#__PURE__*/_jsx(Keypad, {
89
+ value: amount,
90
+ onChangeText: setAmount,
91
+ extraKey: {
92
+ label: '.',
93
+ value: '.'
94
+ },
95
+ header: /*#__PURE__*/_jsx(View, {
96
+ style: {
97
+ alignItems: 'center',
98
+ paddingVertical: 8
99
+ },
100
+ children: /*#__PURE__*/_jsxs(Text, {
101
+ variant: "h1",
102
+ color: amount ? 'primary' : 'tertiary',
103
+ style: {
104
+ fontSize: 40
105
+ },
106
+ children: ["$", amount || '0.00']
107
+ })
108
+ })
109
+ })
110
+ });
111
+ }
112
+ };
113
+
114
+ /** Extra key as a custom action (e.g. open a modal / redirect). */
115
+ export const ExtraKeyAction = {
116
+ render: () => {
117
+ const [value, setValue] = useState('');
118
+ return /*#__PURE__*/_jsx(View, {
119
+ style: {
120
+ padding: 24,
121
+ maxWidth: 360
122
+ },
123
+ children: /*#__PURE__*/_jsx(Keypad, {
124
+ value: value,
125
+ onChangeText: setValue,
126
+ extraKey: {
127
+ icon: 'user',
128
+ onPress: () => {}
129
+ }
130
+ })
131
+ });
132
+ }
133
+ };
134
+
135
+ /** Fixed width — the pad keeps `width` regardless of the container. */
136
+ export const FixedWidth = {
137
+ render: () => {
138
+ const [value, setValue] = useState('');
139
+ return /*#__PURE__*/_jsx(View, {
140
+ style: {
141
+ padding: 24,
142
+ alignItems: 'center'
143
+ },
144
+ children: /*#__PURE__*/_jsx(Keypad, {
145
+ value: value,
146
+ onChangeText: setValue,
147
+ width: 260
148
+ })
149
+ });
150
+ }
151
+ };
152
+
153
+ /** Full width — with no `width`, the pad fills its parent container (here 480px). */
154
+ export const FullWidthContainer = {
155
+ render: () => {
156
+ const [value, setValue] = useState('');
157
+ return /*#__PURE__*/_jsx(View, {
158
+ style: {
159
+ padding: 24,
160
+ width: 480
161
+ },
162
+ children: /*#__PURE__*/_jsx(Keypad, {
163
+ value: value,
164
+ onChangeText: setValue
165
+ })
166
+ });
167
+ }
168
+ };
169
+
170
+ /** Standalone: no header, no extra key (backspace only in the bottom row). */
171
+ export const Bare = {
172
+ render: () => {
173
+ const [value, setValue] = useState('');
174
+ return /*#__PURE__*/_jsx(View, {
175
+ style: {
176
+ padding: 24,
177
+ maxWidth: 360
178
+ },
179
+ children: /*#__PURE__*/_jsx(Keypad, {
180
+ value: value,
181
+ onChangeText: setValue
182
+ })
183
+ });
184
+ }
185
+ };
186
+
187
+ /** Custom sizing: taller keys, wider gap, larger digits. */
188
+ export const CustomSizing = {
189
+ render: () => {
190
+ const [value, setValue] = useState('');
191
+ return /*#__PURE__*/_jsx(View, {
192
+ style: {
193
+ padding: 24,
194
+ maxWidth: 360
195
+ },
196
+ children: /*#__PURE__*/_jsx(Keypad, {
197
+ value: value,
198
+ onChangeText: setValue,
199
+ keyHeight: 96,
200
+ gap: 12,
201
+ digitSize: 28
202
+ })
203
+ });
204
+ }
205
+ };
206
+ //# sourceMappingURL=Keypad.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useState","View","Keypad","CodeInput","Text","jsx","_jsx","jsxs","_jsxs","meta","title","component","LoginCode","render","pin","setPin","style","padding","maxWidth","alignItems","gap","children","value","onChangeText","maxLength","header","length","LoginCodeRevealable","revealable","revealPosition","AmountEntry","amount","setAmount","extraKey","label","paddingVertical","variant","color","fontSize","ExtraKeyAction","setValue","icon","onPress","FixedWidth","width","FullWidthContainer","Bare","CustomSizing","keyHeight","digitSize"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/Keypad/Keypad.stories.tsx"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,OAAO;AAEhC,SAASC,IAAI,QAAQ,cAAc;AACnC,SAASC,MAAM,QAAQ,aAAU;AACjC,SAASC,SAAS,QAAQ,2BAAwB;AAClD,SAASC,IAAI,QAAQ,iBAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAEpC,MAAMC,IAAI,GAAG;EACXC,KAAK,EAAE,mBAAmB;EAC1BC,SAAS,EAAET;AACb,CAA+B;AAE/B,eAAeO,IAAI;AAGnB;AACA,OAAO,MAAMG,SAAgB,GAAG;EAC9BC,MAAM,EAAEA,CAAA,KA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,QAAQ,EAAE;MAAI,CAAE;MAAAG,QAAA,eAC1Cf,IAAA,CAACJ,MAAM;QAACoB,KAAK,EAAEA,KAAM;QAACC,YAAY,EAAEiB;MAAS,CAAE;IAAC,CAC5C,CAAC;EAEX;AACF,CAAC;;AAED;AACA,OAAO,MAAMO,YAAmB,GAAG;EACjClC,MAAM,EAAEA,CAAA,KAAM;IACZ,MAAM,CAACS,KAAK,EAAEkB,QAAQ,CAAC,GAAGxC,QAAQ,CAAC,EAAE,CAAC;IACtC,oBACEM,IAAA,CAACL,IAAI;MAACe,KAAK,EAAE;QAAEC,OAAO,EAAE,EAAE;QAAEC,QAAQ,EAAE;MAAI,CAAE;MAAAG,QAAA,eAC1Cf,IAAA,CAACJ,MAAM;QAACoB,KAAK,EAAEA,KAAM;QAACC,YAAY,EAAEiB,QAAS;QAACQ,SAAS,EAAE,EAAG;QAAC5B,GAAG,EAAE,EAAG;QAAC6B,SAAS,EAAE;MAAG,CAAE;IAAC,CACnF,CAAC;EAEX;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+
3
+ import { useState } from 'react';
4
+ import { Text } from 'react-native';
5
+ import { render, fireEvent, screen } from '@testing-library/react-native';
6
+ import { ThemeProvider } from "../../theme/index.js";
7
+ import { Keypad } from "./Keypad.js";
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ function wrap(ui) {
10
+ return render(/*#__PURE__*/_jsx(ThemeProvider, {
11
+ children: ui
12
+ }));
13
+ }
14
+ function Controlled(props) {
15
+ const [value, setValue] = useState('');
16
+ return /*#__PURE__*/_jsx(Keypad, {
17
+ ...props,
18
+ value: value,
19
+ onChangeText: setValue,
20
+ header: /*#__PURE__*/_jsx(Text, {
21
+ testID: "value",
22
+ children: value
23
+ })
24
+ });
25
+ }
26
+ describe('Keypad', () => {
27
+ it('renders digits 0–9 and a backspace, no extra key by default', () => {
28
+ wrap(/*#__PURE__*/_jsx(Keypad, {}));
29
+ for (let i = 0; i <= 9; i++) {
30
+ expect(screen.getByLabelText(String(i))).toBeTruthy();
31
+ }
32
+ expect(screen.getByLabelText('Backspace')).toBeTruthy();
33
+ expect(screen.queryByLabelText('action')).toBeNull();
34
+ });
35
+ it('appends the pressed digit to the value', () => {
36
+ const onChangeText = jest.fn();
37
+ wrap(/*#__PURE__*/_jsx(Keypad, {
38
+ value: "12",
39
+ onChangeText: onChangeText
40
+ }));
41
+ fireEvent.press(screen.getByLabelText('3'));
42
+ expect(onChangeText).toHaveBeenCalledWith('123');
43
+ });
44
+ it('backspace removes the last character', () => {
45
+ const onChangeText = jest.fn();
46
+ wrap(/*#__PURE__*/_jsx(Keypad, {
47
+ value: "123",
48
+ onChangeText: onChangeText
49
+ }));
50
+ fireEvent.press(screen.getByLabelText('Backspace'));
51
+ expect(onChangeText).toHaveBeenCalledWith('12');
52
+ });
53
+ it('respects maxLength', () => {
54
+ const onChangeText = jest.fn();
55
+ wrap(/*#__PURE__*/_jsx(Keypad, {
56
+ value: "1234",
57
+ onChangeText: onChangeText,
58
+ maxLength: 4
59
+ }));
60
+ fireEvent.press(screen.getByLabelText('5'));
61
+ expect(onChangeText).not.toHaveBeenCalled();
62
+ });
63
+ it('fires onKeyPress with the raw key even at maxLength', () => {
64
+ const onKeyPress = jest.fn();
65
+ wrap(/*#__PURE__*/_jsx(Keypad, {
66
+ value: "1234",
67
+ onKeyPress: onKeyPress,
68
+ maxLength: 4
69
+ }));
70
+ fireEvent.press(screen.getByLabelText('5'));
71
+ expect(onKeyPress).toHaveBeenCalledWith('5');
72
+ });
73
+ it('extra key with a value appends it', () => {
74
+ const onChangeText = jest.fn();
75
+ wrap(/*#__PURE__*/_jsx(Keypad, {
76
+ value: "1",
77
+ onChangeText: onChangeText,
78
+ extraKey: {
79
+ label: '.',
80
+ value: '.'
81
+ }
82
+ }));
83
+ fireEvent.press(screen.getByLabelText('.'));
84
+ expect(onChangeText).toHaveBeenCalledWith('1.');
85
+ });
86
+ it('extra key with onPress runs the action and does not change the value', () => {
87
+ const onPress = jest.fn();
88
+ const onChangeText = jest.fn();
89
+ wrap(/*#__PURE__*/_jsx(Keypad, {
90
+ value: "1",
91
+ onChangeText: onChangeText,
92
+ extraKey: {
93
+ label: 'x',
94
+ value: '.',
95
+ onPress
96
+ }
97
+ }));
98
+ fireEvent.press(screen.getByLabelText('x'));
99
+ expect(onPress).toHaveBeenCalledTimes(1);
100
+ expect(onChangeText).not.toHaveBeenCalled();
101
+ });
102
+ it('is controllable end-to-end', () => {
103
+ wrap(/*#__PURE__*/_jsx(Controlled, {}));
104
+ fireEvent.press(screen.getByLabelText('9'));
105
+ fireEvent.press(screen.getByLabelText('1'));
106
+ expect(screen.getByTestId('value').props.children).toBe('91');
107
+ });
108
+ it('does not fire callbacks when disabled', () => {
109
+ const onChangeText = jest.fn();
110
+ wrap(/*#__PURE__*/_jsx(Keypad, {
111
+ value: "",
112
+ onChangeText: onChangeText,
113
+ disabled: true
114
+ }));
115
+ fireEvent.press(screen.getByLabelText('1'));
116
+ expect(onChangeText).not.toHaveBeenCalled();
117
+ });
118
+ });
119
+ //# sourceMappingURL=Keypad.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useState","Text","render","fireEvent","screen","ThemeProvider","Keypad","jsx","_jsx","wrap","ui","children","Controlled","props","value","setValue","onChangeText","header","testID","describe","it","i","expect","getByLabelText","String","toBeTruthy","queryByLabelText","toBeNull","jest","fn","press","toHaveBeenCalledWith","maxLength","not","toHaveBeenCalled","onKeyPress","extraKey","label","onPress","toHaveBeenCalledTimes","getByTestId","toBe","disabled"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/Keypad/Keypad.test.tsx"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,OAAO;AAChC,SAASC,IAAI,QAAQ,cAAc;AACnC,SAASC,MAAM,EAAEC,SAAS,EAAEC,MAAM,QAAQ,+BAA+B;AACzE,SAASC,aAAa,QAAQ,sBAAa;AAC3C,SAASC,MAAM,QAA0B,aAAU;AAAC,SAA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,CAAC;IACpBT,SAAS,CAAC2B,KAAK,CAAC1B,MAAM,CAACmB,cAAc,CAAC,GAAG,CAAC,CAAC;IAC3CpB,SAAS,CAAC2B,KAAK,CAAC1B,MAAM,CAACmB,cAAc,CAAC,GAAG,CAAC,CAAC;IAC3CD,MAAM,CAAClB,MAAM,CAACoC,WAAW,CAAC,OAAO,CAAC,CAAC3B,KAAK,CAACF,QAAQ,CAAC,CAAC8B,IAAI,CAAC,IAAI,CAAC;EAC/D,CAAC,CAAC;EAEFrB,EAAE,CAAC,uCAAuC,EAAE,MAAM;IAChD,MAAMJ,YAAY,GAAGY,IAAI,CAACC,EAAE,CAAC,CAAC;IAC9BpB,IAAI,cAACD,IAAA,CAACF,MAAM;MAACQ,KAAK,EAAC,EAAE;MAACE,YAAY,EAAEA,YAAa;MAAC0B,QAAQ;IAAA,CAAE,CAAC,CAAC;IAC9DvC,SAAS,CAAC2B,KAAK,CAAC1B,MAAM,CAACmB,cAAc,CAAC,GAAG,CAAC,CAAC;IAC3CD,MAAM,CAACN,YAAY,CAAC,CAACiB,GAAG,CAACC,gBAAgB,CAAC,CAAC;EAC7C,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export { Keypad } from "./Keypad.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Keypad"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/Keypad/index.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,aAAU","ignoreList":[]}
@@ -12,6 +12,7 @@ export * from "./Dialog/index.js";
12
12
  export * from "./Icon/index.js";
13
13
  export * from "./IconButton/index.js";
14
14
  export * from "./Input/index.js";
15
+ export * from "./Keypad/index.js";
15
16
  export * from "./LinkButton/index.js";
16
17
  export * from "./ProductCard/index.js";
17
18
  export * from "./QuantityStepper/index.js";
@@ -1 +1 @@
1
- {"version":3,"names":[],"sourceRoot":"..\\..\\..\\src","sources":["components/index.ts"],"mappings":";;AAAA,cAAc,mBAAU;AACxB,cAAc,kBAAS;AACvB,cAAc,mBAAU;AACxB,cAAc,iBAAQ;AACtB,cAAc,qBAAY;AAC1B,cAAc,iBAAQ;AACtB,cAAc,sBAAa;AAC3B,cAAc,sBAAa;AAC3B,cAAc,mBAAU;AACxB,cAAc,iBAAQ;AACtB,cAAc,uBAAc;AAC5B,cAAc,kBAAS;AACvB,cAAc,uBAAc;AAC5B,cAAc,wBAAe;AAC7B,cAAc,4BAAmB;AACjC,cAAc,kBAAS;AACvB,cAAc,oBAAW;AACzB,cAAc,oBAAW;AACzB,cAAc,mBAAU;AACxB,cAAc,iBAAQ;AACtB,cAAc,kBAAS","ignoreList":[]}
1
+ {"version":3,"names":[],"sourceRoot":"..\\..\\..\\src","sources":["components/index.ts"],"mappings":";;AAAA,cAAc,mBAAU;AACxB,cAAc,kBAAS;AACvB,cAAc,mBAAU;AACxB,cAAc,iBAAQ;AACtB,cAAc,qBAAY;AAC1B,cAAc,iBAAQ;AACtB,cAAc,sBAAa;AAC3B,cAAc,sBAAa;AAC3B,cAAc,mBAAU;AACxB,cAAc,iBAAQ;AACtB,cAAc,uBAAc;AAC5B,cAAc,kBAAS;AACvB,cAAc,mBAAU;AACxB,cAAc,uBAAc;AAC5B,cAAc,wBAAe;AAC7B,cAAc,4BAAmB;AACjC,cAAc,kBAAS;AACvB,cAAc,oBAAW;AACzB,cAAc,oBAAW;AACzB,cAAc,mBAAU;AACxB,cAAc,iBAAQ;AACtB,cAAc,kBAAS","ignoreList":[]}
@@ -11,12 +11,18 @@ export interface CodeFieldProps {
11
11
  mode?: CodeFieldMode;
12
12
  /** Called once every cell is filled. */
13
13
  onComplete?: (value: string) => void;
14
+ /** Helper text below the cells. Replaced by the error message when `error` is a string. */
15
+ helperText?: string;
16
+ /** Mark the field invalid. Pass a string to show it as the error message. */
17
+ error?: boolean | string;
14
18
  /** Disable input and dim the cells. */
15
19
  disabled?: boolean;
16
20
  /** Focus on mount. */
17
21
  autoFocus?: boolean;
18
- /** Cell width in px (Figma default 126). */
22
+ /** Cell width in px (Figma default 126). Ignored when `fullWidth` is set. */
19
23
  cellWidth?: number;
24
+ /** Stretch the row to 100% of the container; cells share the width evenly. */
25
+ fullWidth?: boolean;
20
26
  /** Cell height in px (Figma default 58). */
21
27
  cellHeight?: number;
22
28
  /** Gap between cells in px (Figma default 24). */
@@ -36,5 +42,5 @@ export interface CodeFieldProps {
36
42
  * backspace-to-previous and type-to-next all work natively. The active cell
37
43
  * shows the lime focus ring. Cell size, gap, font and font size are configurable.
38
44
  */
39
- export declare function CodeField({ value, onChangeText, length, mode, onComplete, disabled, autoFocus, cellWidth, cellHeight, gap, fontFamily, fontSize, accessibilityLabel, style, }: CodeFieldProps): import("react/jsx-runtime").JSX.Element;
45
+ export declare function CodeField({ value, onChangeText, length, mode, onComplete, helperText, error, disabled, autoFocus, cellWidth, fullWidth, cellHeight, gap, fontFamily, fontSize, accessibilityLabel, style, }: CodeFieldProps): import("react/jsx-runtime").JSX.Element;
40
46
  //# sourceMappingURL=CodeField.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CodeField.d.ts","sourceRoot":"","sources":["../../../../../src/components/CodeField/CodeField.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,SAAS,EAEd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAOtB,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,OAAO,GAAG,cAAc,CAAC;AASjE,MAAM,WAAW,cAAc;IAC7B,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,wCAAwC;IACxC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,uCAAuC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sBAAsB;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oCAAoC;IACpC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,YAAY,EACZ,MAAU,EACV,IAAgB,EAChB,UAAU,EACV,QAAgB,EAChB,SAAiB,EACjB,SAAe,EACf,UAAe,EACf,GAAQ,EACR,UAAU,EACV,QAAa,EACb,kBAA2B,EAC3B,KAAK,GACN,EAAE,cAAc,2CAmFhB"}
1
+ {"version":3,"file":"CodeField.d.ts","sourceRoot":"","sources":["../../../../../src/components/CodeField/CodeField.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,SAAS,EAEd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAiBtB,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,OAAO,GAAG,cAAc,CAAC;AASjE,MAAM,WAAW,cAAc;IAC7B,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,wCAAwC;IACxC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,2FAA2F;IAC3F,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6EAA6E;IAC7E,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,uCAAuC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sBAAsB;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oCAAoC;IACpC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,YAAY,EACZ,MAAU,EACV,IAAgB,EAChB,UAAU,EACV,UAAU,EACV,KAAK,EACL,QAAgB,EAChB,SAAiB,EACjB,SAAe,EACf,SAAiB,EACjB,UAAe,EACf,GAAQ,EACR,UAAU,EACV,QAAa,EACb,kBAA2B,EAC3B,KAAK,GACN,EAAE,cAAc,2CA2GhB"}
@@ -0,0 +1,54 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type StyleProp, type ViewStyle } from 'react-native';
3
+ import type { IconName } from '../Icon/icons.generated';
4
+ /** The optional key to the left of 0. Hidden unless provided. */
5
+ export interface KeypadExtraKey {
6
+ /** Short label (e.g. "."). */
7
+ label?: string;
8
+ /** Or an icon. */
9
+ icon?: IconName;
10
+ /** If set, pressing appends this to the value (e.g. "." for decimals). */
11
+ value?: string;
12
+ /** Custom action (open a modal, navigate, …). Overrides `value`. */
13
+ onPress?: () => void;
14
+ /** Content color. */
15
+ color?: string;
16
+ /** Key background color. */
17
+ backgroundColor?: string;
18
+ }
19
+ export interface KeypadProps {
20
+ /** Controlled value being entered. Defaults to ''. */
21
+ value?: string;
22
+ /** Called with the next value on digit / backspace / extra-value press. */
23
+ onChangeText?: (value: string) => void;
24
+ /** Fired on every press with the raw key: '0'–'9', 'backspace', or 'extra'. */
25
+ onKeyPress?: (key: string) => void;
26
+ /** Max length of `value`. */
27
+ maxLength?: number;
28
+ /** Content shown above the keys (dots, amount, anything). Swappable per use case. */
29
+ header?: ReactNode;
30
+ /** The key left of 0. Hidden by default; provide to show and customize it. */
31
+ extraKey?: KeypadExtraKey;
32
+ /** Key height. Defaults to 83. */
33
+ keyHeight?: number;
34
+ /** Gap between keys. Defaults to 8. */
35
+ gap?: number;
36
+ /** Total width. Defaults to full width; the 3 columns split evenly. */
37
+ width?: number;
38
+ /** Digit font size. Defaults to 24. */
39
+ digitSize?: number;
40
+ /** Space between header and keys. Defaults to 24. */
41
+ headerGap?: number;
42
+ /** Disable all keys. */
43
+ disabled?: boolean;
44
+ style?: StyleProp<ViewStyle>;
45
+ }
46
+ /**
47
+ * Numeric keypad — a 3-column pad decoupled from what it drives (bind it to a
48
+ * PIN display, an amount, etc. via `value`/`onChangeText`, and put that display
49
+ * in `header`). Backspace is fixed to the right of 0; the key left of 0 is hidden
50
+ * unless you pass `extraKey` (custom symbol/icon, action and colors). Width,
51
+ * key height, gap and digit size are all configurable.
52
+ */
53
+ export declare function Keypad({ value, onChangeText, onKeyPress, maxLength, header, extraKey, keyHeight, gap, width, digitSize, headerGap, disabled, style, }: KeypadProps): import("react/jsx-runtime").JSX.Element;
54
+ //# sourceMappingURL=Keypad.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Keypad.d.ts","sourceRoot":"","sources":["../../../../../src/components/Keypad/Keypad.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Q,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAQD;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,EACrB,KAAU,EACV,YAAY,EACZ,UAAU,EACV,SAAS,EACT,MAAM,EACN,QAAQ,EACR,SAAc,EACd,GAAO,EACP,KAAK,EACL,SAAc,EACd,SAAc,EACd,QAAgB,EAChB,KAAK,GACN,EAAE,WAAW,2CAgHb"}
@@ -0,0 +1,3 @@
1
+ export { Keypad } from './Keypad';
2
+ export type { KeypadProps, KeypadExtraKey } from './Keypad';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Keypad/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC"}
@@ -10,6 +10,7 @@ export * from './Dialog';
10
10
  export * from './Icon';
11
11
  export * from './IconButton';
12
12
  export * from './Input';
13
+ export * from './Keypad';
13
14
  export * from './LinkButton';
14
15
  export * from './ProductCard';
15
16
  export * from './QuantityStepper';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AAExB,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AAExB,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
@@ -11,12 +11,18 @@ export interface CodeFieldProps {
11
11
  mode?: CodeFieldMode;
12
12
  /** Called once every cell is filled. */
13
13
  onComplete?: (value: string) => void;
14
+ /** Helper text below the cells. Replaced by the error message when `error` is a string. */
15
+ helperText?: string;
16
+ /** Mark the field invalid. Pass a string to show it as the error message. */
17
+ error?: boolean | string;
14
18
  /** Disable input and dim the cells. */
15
19
  disabled?: boolean;
16
20
  /** Focus on mount. */
17
21
  autoFocus?: boolean;
18
- /** Cell width in px (Figma default 126). */
22
+ /** Cell width in px (Figma default 126). Ignored when `fullWidth` is set. */
19
23
  cellWidth?: number;
24
+ /** Stretch the row to 100% of the container; cells share the width evenly. */
25
+ fullWidth?: boolean;
20
26
  /** Cell height in px (Figma default 58). */
21
27
  cellHeight?: number;
22
28
  /** Gap between cells in px (Figma default 24). */
@@ -36,5 +42,5 @@ export interface CodeFieldProps {
36
42
  * backspace-to-previous and type-to-next all work natively. The active cell
37
43
  * shows the lime focus ring. Cell size, gap, font and font size are configurable.
38
44
  */
39
- export declare function CodeField({ value, onChangeText, length, mode, onComplete, disabled, autoFocus, cellWidth, cellHeight, gap, fontFamily, fontSize, accessibilityLabel, style, }: CodeFieldProps): import("react/jsx-runtime").JSX.Element;
45
+ export declare function CodeField({ value, onChangeText, length, mode, onComplete, helperText, error, disabled, autoFocus, cellWidth, fullWidth, cellHeight, gap, fontFamily, fontSize, accessibilityLabel, style, }: CodeFieldProps): import("react/jsx-runtime").JSX.Element;
40
46
  //# sourceMappingURL=CodeField.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CodeField.d.ts","sourceRoot":"","sources":["../../../../../src/components/CodeField/CodeField.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,SAAS,EAEd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAOtB,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,OAAO,GAAG,cAAc,CAAC;AASjE,MAAM,WAAW,cAAc;IAC7B,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,wCAAwC;IACxC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,uCAAuC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sBAAsB;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oCAAoC;IACpC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,YAAY,EACZ,MAAU,EACV,IAAgB,EAChB,UAAU,EACV,QAAgB,EAChB,SAAiB,EACjB,SAAe,EACf,UAAe,EACf,GAAQ,EACR,UAAU,EACV,QAAa,EACb,kBAA2B,EAC3B,KAAK,GACN,EAAE,cAAc,2CAmFhB"}
1
+ {"version":3,"file":"CodeField.d.ts","sourceRoot":"","sources":["../../../../../src/components/CodeField/CodeField.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,SAAS,EAEd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAiBtB,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,OAAO,GAAG,cAAc,CAAC;AASjE,MAAM,WAAW,cAAc;IAC7B,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,wCAAwC;IACxC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,2FAA2F;IAC3F,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6EAA6E;IAC7E,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,uCAAuC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sBAAsB;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oCAAoC;IACpC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,YAAY,EACZ,MAAU,EACV,IAAgB,EAChB,UAAU,EACV,UAAU,EACV,KAAK,EACL,QAAgB,EAChB,SAAiB,EACjB,SAAe,EACf,SAAiB,EACjB,UAAe,EACf,GAAQ,EACR,UAAU,EACV,QAAa,EACb,kBAA2B,EAC3B,KAAK,GACN,EAAE,cAAc,2CA2GhB"}
@@ -0,0 +1,54 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type StyleProp, type ViewStyle } from 'react-native';
3
+ import type { IconName } from '../Icon/icons.generated';
4
+ /** The optional key to the left of 0. Hidden unless provided. */
5
+ export interface KeypadExtraKey {
6
+ /** Short label (e.g. "."). */
7
+ label?: string;
8
+ /** Or an icon. */
9
+ icon?: IconName;
10
+ /** If set, pressing appends this to the value (e.g. "." for decimals). */
11
+ value?: string;
12
+ /** Custom action (open a modal, navigate, …). Overrides `value`. */
13
+ onPress?: () => void;
14
+ /** Content color. */
15
+ color?: string;
16
+ /** Key background color. */
17
+ backgroundColor?: string;
18
+ }
19
+ export interface KeypadProps {
20
+ /** Controlled value being entered. Defaults to ''. */
21
+ value?: string;
22
+ /** Called with the next value on digit / backspace / extra-value press. */
23
+ onChangeText?: (value: string) => void;
24
+ /** Fired on every press with the raw key: '0'–'9', 'backspace', or 'extra'. */
25
+ onKeyPress?: (key: string) => void;
26
+ /** Max length of `value`. */
27
+ maxLength?: number;
28
+ /** Content shown above the keys (dots, amount, anything). Swappable per use case. */
29
+ header?: ReactNode;
30
+ /** The key left of 0. Hidden by default; provide to show and customize it. */
31
+ extraKey?: KeypadExtraKey;
32
+ /** Key height. Defaults to 83. */
33
+ keyHeight?: number;
34
+ /** Gap between keys. Defaults to 8. */
35
+ gap?: number;
36
+ /** Total width. Defaults to full width; the 3 columns split evenly. */
37
+ width?: number;
38
+ /** Digit font size. Defaults to 24. */
39
+ digitSize?: number;
40
+ /** Space between header and keys. Defaults to 24. */
41
+ headerGap?: number;
42
+ /** Disable all keys. */
43
+ disabled?: boolean;
44
+ style?: StyleProp<ViewStyle>;
45
+ }
46
+ /**
47
+ * Numeric keypad — a 3-column pad decoupled from what it drives (bind it to a
48
+ * PIN display, an amount, etc. via `value`/`onChangeText`, and put that display
49
+ * in `header`). Backspace is fixed to the right of 0; the key left of 0 is hidden
50
+ * unless you pass `extraKey` (custom symbol/icon, action and colors). Width,
51
+ * key height, gap and digit size are all configurable.
52
+ */
53
+ export declare function Keypad({ value, onChangeText, onKeyPress, maxLength, header, extraKey, keyHeight, gap, width, digitSize, headerGap, disabled, style, }: KeypadProps): import("react/jsx-runtime").JSX.Element;
54
+ //# sourceMappingURL=Keypad.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Keypad.d.ts","sourceRoot":"","sources":["../../../../../src/components/Keypad/Keypad.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAmB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QD;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,EACrB,KAAU,EACV,YAAY,EACZ,UAAU,EACV,SAAS,EACT,MAAM,EACN,QAAQ,EACR,SAAc,EACd,GAAO,EACP,KAAK,EACL,SAAc,EACd,SAAc,EACd,QAAgB,EAChB,KAAK,GACN,EAAE,WAAW,2CAgHb"}
@@ -0,0 +1,3 @@
1
+ export { Keypad } from './Keypad';
2
+ export type { KeypadProps, KeypadExtraKey } from './Keypad';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Keypad/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC"}
@@ -10,6 +10,7 @@ export * from './Dialog';
10
10
  export * from './Icon';
11
11
  export * from './IconButton';
12
12
  export * from './Input';
13
+ export * from './Keypad';
13
14
  export * from './LinkButton';
14
15
  export * from './ProductCard';
15
16
  export * from './QuantityStepper';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AAExB,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AAExB,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bacon-pos/ui",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "description": "Bacon POS design system — React Native component library",
5
5
  "main": "./lib/commonjs/index.js",
6
6
  "module": "./lib/module/index.js",