cpk-ui 0.5.5 → 0.7.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 (130) hide show
  1. package/README.md +80 -147
  2. package/components/modals/AlertDialog/AlertDialog.d.ts.map +1 -1
  3. package/components/modals/AlertDialog/AlertDialog.js +14 -7
  4. package/components/modals/Snackbar/Snackbar.d.ts.map +1 -1
  5. package/components/modals/Snackbar/Snackbar.js +20 -17
  6. package/components/uis/Accordion/AccordionItem.d.ts.map +1 -1
  7. package/components/uis/Accordion/AccordionItem.js +41 -17
  8. package/components/uis/Button/Button.d.ts.map +1 -1
  9. package/components/uis/Button/Button.js +10 -10
  10. package/components/uis/Card/Card.d.ts +2 -1
  11. package/components/uis/Card/Card.d.ts.map +1 -1
  12. package/components/uis/Card/Card.js +12 -3
  13. package/components/uis/Checkbox/Checkbox.d.ts.map +1 -1
  14. package/components/uis/Checkbox/Checkbox.js +1 -1
  15. package/components/uis/CustomPressable/CustomPressable.d.ts.map +1 -1
  16. package/components/uis/CustomPressable/CustomPressable.js +6 -6
  17. package/components/uis/EditText/EditText.d.ts.map +1 -1
  18. package/components/uis/EditText/EditText.js +17 -12
  19. package/components/uis/Fab/Fab.d.ts +2 -2
  20. package/components/uis/Fab/Fab.d.ts.map +1 -1
  21. package/components/uis/Fab/Fab.js +22 -4
  22. package/components/uis/Icon/Icon.d.ts.map +1 -1
  23. package/components/uis/Icon/Icon.js +6 -3
  24. package/components/uis/IconButton/IconButton.d.ts.map +1 -1
  25. package/components/uis/IconButton/IconButton.js +43 -41
  26. package/components/uis/LoadingIndicator/LoadingIndicator.d.ts +2 -1
  27. package/components/uis/LoadingIndicator/LoadingIndicator.d.ts.map +1 -1
  28. package/components/uis/LoadingIndicator/LoadingIndicator.js +4 -4
  29. package/components/uis/RadioGroup/RadioButton.d.ts.map +1 -1
  30. package/components/uis/RadioGroup/RadioButton.js +1 -1
  31. package/components/uis/RadioGroup/RadioGroup.d.ts.map +1 -1
  32. package/components/uis/RadioGroup/RadioGroup.js +16 -3
  33. package/components/uis/Rating/Rating.d.ts.map +1 -1
  34. package/components/uis/Rating/Rating.js +23 -19
  35. package/components/uis/SegmentedControl/SegmentedControl.d.ts.map +1 -1
  36. package/components/uis/SegmentedControl/SegmentedControl.js +1 -1
  37. package/components/uis/StatusbarBrightness/StatusBarBrightness.d.ts +2 -2
  38. package/components/uis/StatusbarBrightness/StatusBarBrightness.d.ts.map +1 -1
  39. package/components/uis/StatusbarBrightness/StatusBarBrightness.js +1 -1
  40. package/components/uis/SwitchToggle/SwitchToggle.d.ts.map +1 -1
  41. package/components/uis/SwitchToggle/SwitchToggle.js +1 -1
  42. package/hooks/useHoverState.d.ts +8 -0
  43. package/hooks/useHoverState.d.ts.map +1 -0
  44. package/hooks/useHoverState.js +16 -0
  45. package/package.json +18 -6
  46. package/providers/ThemeProvider.d.ts.map +1 -1
  47. package/providers/ThemeProvider.js +0 -1
  48. package/providers/index.d.ts.map +1 -1
  49. package/providers/index.js +3 -2
  50. package/components/uis/Icon/selection.json +0 -1
  51. package/src/components/common/ErrorBoundary/ErrorBoundary.tsx +0 -75
  52. package/src/components/modals/AlertDialog/AlertDialog.stories.tsx +0 -216
  53. package/src/components/modals/AlertDialog/AlertDialog.test.tsx +0 -251
  54. package/src/components/modals/AlertDialog/AlertDialog.tsx +0 -356
  55. package/src/components/modals/Snackbar/Snackbar.stories.tsx +0 -182
  56. package/src/components/modals/Snackbar/Snackbar.test.tsx +0 -319
  57. package/src/components/modals/Snackbar/Snackbar.tsx +0 -260
  58. package/src/components/modals/Snackbar/const.ts +0 -4
  59. package/src/components/uis/Accordion/Accordion.stories.tsx +0 -167
  60. package/src/components/uis/Accordion/Accordion.test.tsx +0 -272
  61. package/src/components/uis/Accordion/Accordion.tsx +0 -109
  62. package/src/components/uis/Accordion/AccordionItem.tsx +0 -306
  63. package/src/components/uis/Button/Button.stories.tsx +0 -218
  64. package/src/components/uis/Button/Button.test.tsx +0 -694
  65. package/src/components/uis/Button/Button.tsx +0 -440
  66. package/src/components/uis/Card/Card.test.tsx +0 -146
  67. package/src/components/uis/Card/Card.tsx +0 -102
  68. package/src/components/uis/Checkbox/Checkbox.stories.tsx +0 -216
  69. package/src/components/uis/Checkbox/Checkbox.test.tsx +0 -267
  70. package/src/components/uis/Checkbox/Checkbox.tsx +0 -225
  71. package/src/components/uis/CustomPressable/CustomPressable.tsx +0 -48
  72. package/src/components/uis/EditText/EditText.stories.tsx +0 -124
  73. package/src/components/uis/EditText/EditText.test.tsx +0 -477
  74. package/src/components/uis/EditText/EditText.tsx +0 -593
  75. package/src/components/uis/Fab/Fab.stories.tsx +0 -133
  76. package/src/components/uis/Fab/Fab.test.tsx +0 -110
  77. package/src/components/uis/Fab/Fab.tsx +0 -168
  78. package/src/components/uis/Hr/Hr.test.tsx +0 -26
  79. package/src/components/uis/Hr/Hr.tsx +0 -19
  80. package/src/components/uis/Icon/Icon.stories.tsx +0 -98
  81. package/src/components/uis/Icon/Icon.test.tsx +0 -49
  82. package/src/components/uis/Icon/Icon.tsx +0 -3819
  83. package/src/components/uis/IconButton/IconButton.test.tsx +0 -204
  84. package/src/components/uis/IconButton/IconButton.tsx +0 -279
  85. package/src/components/uis/LoadingIndicator/LoadingIndicator.tsx +0 -126
  86. package/src/components/uis/LoadingIndicator/LodingIndicator.stories.tsx +0 -81
  87. package/src/components/uis/PinchZoom/PinchZoom.stories.tsx +0 -266
  88. package/src/components/uis/PinchZoom/PinchZoom.test.tsx +0 -113
  89. package/src/components/uis/PinchZoom/PinchZoom.tsx +0 -424
  90. package/src/components/uis/RadioGroup/RadioButton.tsx +0 -193
  91. package/src/components/uis/RadioGroup/RadioGroup.stories.tsx +0 -188
  92. package/src/components/uis/RadioGroup/RadioGroup.test.tsx +0 -354
  93. package/src/components/uis/RadioGroup/RadioGroup.tsx +0 -109
  94. package/src/components/uis/Rating/Rating.test.tsx +0 -98
  95. package/src/components/uis/Rating/Rating.tsx +0 -200
  96. package/src/components/uis/SegmentedControl/SegmentedControl.stories.tsx +0 -546
  97. package/src/components/uis/SegmentedControl/SegmentedControl.test.tsx +0 -274
  98. package/src/components/uis/SegmentedControl/SegmentedControl.tsx +0 -232
  99. package/src/components/uis/StatusbarBrightness/StatusBarBrightness.test.tsx +0 -41
  100. package/src/components/uis/StatusbarBrightness/StatusBarBrightness.tsx +0 -26
  101. package/src/components/uis/Styled/StyledComponents.tsx +0 -217
  102. package/src/components/uis/SwitchToggle/SwitchToggle.stories.tsx +0 -75
  103. package/src/components/uis/SwitchToggle/SwitchToggle.test.tsx +0 -149
  104. package/src/components/uis/SwitchToggle/SwitchToggle.tsx +0 -309
  105. package/src/components/uis/Typography/Typography.stories.tsx +0 -149
  106. package/src/components/uis/Typography/Typography.test.tsx +0 -58
  107. package/src/components/uis/Typography/Typography.tsx +0 -386
  108. package/src/hooks/index.ts +0 -2
  109. package/src/hooks/useAnimations.ts +0 -71
  110. package/src/hooks/useDebouncedColorScheme.tsx +0 -30
  111. package/src/hooks/useOptimizedStyles.ts +0 -22
  112. package/src/hooks/usePerformance.ts +0 -93
  113. package/src/index.tsx +0 -38
  114. package/src/providers/ThemeProvider.tsx +0 -177
  115. package/src/providers/index.tsx +0 -130
  116. package/src/test/testUtils.tsx +0 -101
  117. package/src/types/common.ts +0 -77
  118. package/src/types/index.ts +0 -1
  119. package/src/types/kstyled.d.ts +0 -6
  120. package/src/utils/accessibility.ts +0 -110
  121. package/src/utils/colors.ts +0 -151
  122. package/src/utils/createCtx.tsx +0 -26
  123. package/src/utils/guards.ts +0 -93
  124. package/src/utils/index.ts +0 -2
  125. package/src/utils/performanceTest.ts +0 -174
  126. package/src/utils/platform.ts +0 -69
  127. package/src/utils/theme.ts +0 -38
  128. package/test/testUtils.d.ts +0 -113
  129. package/test/testUtils.d.ts.map +0 -1
  130. package/test/testUtils.js +0 -65
@@ -1,266 +0,0 @@
1
- import {action} from '@storybook/addon-actions';
2
- import type {Meta, StoryObj} from '@storybook/react';
3
- import React from 'react';
4
- import {Image, Text, View} from 'react-native';
5
- import {css} from 'kstyled';
6
-
7
- import {withThemeProvider} from '../../../../.storybook/decorators';
8
- import {PinchZoom} from './PinchZoom';
9
-
10
- const meta = {
11
- title: 'PinchZoom',
12
- component: PinchZoom,
13
- parameters: {
14
- docs: {
15
- description: {
16
- component: `
17
- A powerful PinchZoom component that enables pinch-to-zoom and pan gestures for images and content.
18
-
19
- ## Features
20
- - **Pinch to Zoom**: Two-finger pinch gesture for zooming in/out
21
- - **Pan Gesture**: Single-finger drag to move zoomed content
22
- - **Momentum Scrolling**: Smooth deceleration after pan gesture release
23
- - **Boundary Detection**: Prevents excessive panning beyond content bounds
24
- - **Customizable Constraints**: Control overflow behavior on X and Y axes
25
- - **Programmatic Control**: Imperative API to set scale and translation values
26
-
27
- ## Props
28
- - \`onScaleChanged\`: Callback fired when zoom scale changes
29
- - \`onTranslateChanged\`: Callback fired when content position changes
30
- - \`onRelease\`: Callback fired after gesture animation completes (decay or snap-back)
31
- - \`allowEmpty\`: When \`true\`, allows unrestricted overflow on specific axes (x/y). When \`false\` or undefined, clamps translation to content bounds
32
- - \`fixOverflowAfterRelease\`: Auto-snap to bounds after release (default: true). When \`false\`, \`onRelease\` fires immediately without snap animation
33
- - \`style\`: Custom view style. **Warning**: Passing \`transform\` in style will disable pinch-zoom. Use a wrapper View for custom transforms
34
-
35
- ## Usage
36
- \`\`\`tsx
37
- <PinchZoom
38
- onScaleChanged={(scale) => console.log('Scale:', scale)}
39
- onTranslateChanged={({x, y}) => console.log('Position:', x, y)}
40
- onRelease={() => console.log('Released')}
41
- >
42
- <Image
43
- source={{uri: 'https://example.com/image.jpg'}}
44
- style={{width: 300, height: 300}}
45
- />
46
- </PinchZoom>
47
- \`\`\`
48
-
49
- ## Imperative API
50
- \`\`\`tsx
51
- const pinchZoomRef = useRef<PinchZoomRef>(null);
52
-
53
- // Set zoom and position programmatically
54
- pinchZoomRef.current?.setValues({
55
- scale: 2,
56
- translate: {x: 50, y: 50}
57
- });
58
- \`\`\`
59
- `,
60
- },
61
- },
62
- },
63
- argTypes: {
64
- fixOverflowAfterRelease: {
65
- control: 'boolean',
66
- description: 'Automatically snap content back to bounds after gesture release',
67
- defaultValue: true,
68
- },
69
- },
70
- decorators: [withThemeProvider],
71
- } satisfies Meta<typeof PinchZoom>;
72
-
73
- export default meta;
74
-
75
- type Story = StoryObj<typeof meta>;
76
-
77
- export const WithImage: Story = {
78
- args: {
79
- onScaleChanged: action('onScaleChanged'),
80
- onTranslateChanged: action('onTranslateChanged'),
81
- onRelease: action('onRelease'),
82
- fixOverflowAfterRelease: true,
83
- },
84
- render: (args) => (
85
- <View
86
- style={css`
87
- flex: 1;
88
- justify-content: center;
89
- align-items: center;
90
- background-color: #f5f5f5;
91
- `}
92
- >
93
- <PinchZoom {...args}>
94
- <Image
95
- source={{
96
- uri: 'https://picsum.photos/300/300',
97
- }}
98
- style={css`
99
- width: 300px;
100
- height: 300px;
101
- border-radius: 8px;
102
- `}
103
- />
104
- </PinchZoom>
105
- </View>
106
- ),
107
- };
108
-
109
- export const WithColorBox: Story = {
110
- args: {
111
- onScaleChanged: action('onScaleChanged'),
112
- onTranslateChanged: action('onTranslateChanged'),
113
- onRelease: action('onRelease'),
114
- fixOverflowAfterRelease: true,
115
- },
116
- render: (args) => (
117
- <View
118
- style={css`
119
- flex: 1;
120
- justify-content: center;
121
- align-items: center;
122
- background-color: #f5f5f5;
123
- `}
124
- >
125
- <PinchZoom {...args}>
126
- <View
127
- style={css`
128
- width: 250px;
129
- height: 250px;
130
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
131
- border-radius: 16px;
132
- justify-content: center;
133
- align-items: center;
134
- shadow-color: #000;
135
- shadow-offset: 0px 4px;
136
- shadow-opacity: 0.3;
137
- shadow-radius: 8px;
138
- elevation: 5;
139
- `}
140
- >
141
- <Text
142
- style={css`
143
- color: white;
144
- font-size: 24px;
145
- font-weight: bold;
146
- `}
147
- >
148
- Pinch to Zoom
149
- </Text>
150
- <Text
151
- style={css`
152
- color: rgba(255, 255, 255, 0.9);
153
- font-size: 14px;
154
- margin-top: 8px;
155
- `}
156
- >
157
- Try pinching and dragging!
158
- </Text>
159
- </View>
160
- </PinchZoom>
161
- </View>
162
- ),
163
- };
164
-
165
- export const WithoutBoundarySnap: Story = {
166
- args: {
167
- onScaleChanged: action('onScaleChanged'),
168
- onTranslateChanged: action('onTranslateChanged'),
169
- onRelease: action('onRelease'),
170
- fixOverflowAfterRelease: false,
171
- },
172
- render: (args) => (
173
- <View
174
- style={css`
175
- flex: 1;
176
- justify-content: center;
177
- align-items: center;
178
- background-color: #f5f5f5;
179
- `}
180
- >
181
- <PinchZoom {...args}>
182
- <Image
183
- source={{
184
- uri: 'https://picsum.photos/300/400',
185
- }}
186
- style={css`
187
- width: 300px;
188
- height: 400px;
189
- border-radius: 8px;
190
- `}
191
- />
192
- </PinchZoom>
193
- <Text
194
- style={css`
195
- position: absolute;
196
- bottom: 40px;
197
- color: #666;
198
- font-size: 12px;
199
- `}
200
- >
201
- fixOverflowAfterRelease = false
202
- </Text>
203
- </View>
204
- ),
205
- };
206
-
207
- export const WithCustomStyle: Story = {
208
- args: {
209
- onScaleChanged: action('onScaleChanged'),
210
- onTranslateChanged: action('onTranslateChanged'),
211
- onRelease: action('onRelease'),
212
- fixOverflowAfterRelease: true,
213
- },
214
- render: (args) => (
215
- <View
216
- style={css`
217
- flex: 1;
218
- justify-content: center;
219
- align-items: center;
220
- background-color: #1a1a1a;
221
- `}
222
- >
223
- <PinchZoom
224
- {...args}
225
- style={css`
226
- border-width: 3px;
227
- border-color: #667eea;
228
- border-radius: 12px;
229
- overflow: hidden;
230
- `}
231
- >
232
- <View
233
- style={css`
234
- width: 280px;
235
- height: 280px;
236
- background-color: #2d2d2d;
237
- justify-content: center;
238
- align-items: center;
239
- padding: 20px;
240
- `}
241
- >
242
- <Text
243
- style={css`
244
- color: #667eea;
245
- font-size: 20px;
246
- font-weight: bold;
247
- text-align: center;
248
- `}
249
- >
250
- Custom Styled
251
- </Text>
252
- <Text
253
- style={css`
254
- color: #999;
255
- font-size: 14px;
256
- text-align: center;
257
- margin-top: 12px;
258
- `}
259
- >
260
- This PinchZoom has custom border and background styles
261
- </Text>
262
- </View>
263
- </PinchZoom>
264
- </View>
265
- ),
266
- };
@@ -1,113 +0,0 @@
1
- import '@testing-library/jest-native/extend-expect';
2
-
3
- import React, {type ReactElement} from 'react';
4
- import {Text, View} from 'react-native';
5
- import type {RenderAPI} from '@testing-library/react-native';
6
- import {fireEvent, render} from '@testing-library/react-native';
7
-
8
- import {createComponent} from '../../../../test/testUtils';
9
- import {PinchZoom} from './PinchZoom';
10
- import type {PinchZoomProps} from './PinchZoom';
11
-
12
- let testingLib: RenderAPI;
13
-
14
- const Component = ({props}: {props?: PinchZoomProps}): ReactElement =>
15
- createComponent(
16
- <PinchZoom {...props}>
17
- <View testID="child-view">
18
- <Text>Test Child</Text>
19
- </View>
20
- </PinchZoom>,
21
- );
22
-
23
- describe('[PinchZoom]', () => {
24
- it('should render without crashing', () => {
25
- testingLib = render(Component({}));
26
-
27
- const json = testingLib.toJSON();
28
- expect(json).toBeTruthy();
29
- });
30
-
31
- it('should render children correctly', () => {
32
- testingLib = render(Component({}));
33
-
34
- expect(testingLib.getByTestId('child-view')).toBeTruthy();
35
- expect(testingLib.getByText('Test Child')).toBeTruthy();
36
- });
37
-
38
- it('should render with custom testID', () => {
39
- testingLib = render(Component({props: {testID: 'custom-pinch-zoom'}}));
40
-
41
- expect(testingLib.getByTestId('custom-pinch-zoom')).toBeTruthy();
42
- });
43
-
44
- it('should call onScaleChanged callback', () => {
45
- const onScaleChanged = jest.fn();
46
- testingLib = render(Component({props: {onScaleChanged}}));
47
-
48
- // Note: Actual scale changes would require gesture simulation
49
- // which is complex in unit tests. This test verifies the prop is passed.
50
- expect(onScaleChanged).toBeDefined();
51
- });
52
-
53
- it('should call onTranslateChanged callback', () => {
54
- const onTranslateChanged = jest.fn();
55
- testingLib = render(Component({props: {onTranslateChanged}}));
56
-
57
- // Note: Actual translation changes would require gesture simulation
58
- // which is complex in unit tests. This test verifies the prop is passed.
59
- expect(onTranslateChanged).toBeDefined();
60
- });
61
-
62
- it('should call onRelease callback', () => {
63
- const onRelease = jest.fn();
64
- testingLib = render(Component({props: {onRelease}}));
65
-
66
- expect(onRelease).toBeDefined();
67
- });
68
-
69
- it('should render with custom style', () => {
70
- const customStyle = {backgroundColor: 'red', width: 300, height: 300};
71
- testingLib = render(Component({props: {style: customStyle}}));
72
-
73
- const container = testingLib.getByTestId('pinch-zoom-container');
74
- expect(container).toHaveStyle(customStyle);
75
- });
76
-
77
- it('should accept fixOverflowAfterRelease prop', () => {
78
- testingLib = render(Component({props: {fixOverflowAfterRelease: false}}));
79
-
80
- expect(testingLib.getByTestId('pinch-zoom-container')).toBeTruthy();
81
- });
82
-
83
- it('should accept allowEmpty prop', () => {
84
- testingLib = render(
85
- Component({props: {allowEmpty: {x: true, y: false}}}),
86
- );
87
-
88
- expect(testingLib.getByTestId('pinch-zoom-container')).toBeTruthy();
89
- });
90
-
91
- it('should render with all props combined', () => {
92
- const onScaleChanged = jest.fn();
93
- const onTranslateChanged = jest.fn();
94
- const onRelease = jest.fn();
95
-
96
- testingLib = render(
97
- Component({
98
- props: {
99
- testID: 'full-props-test',
100
- style: {backgroundColor: 'blue'},
101
- onScaleChanged,
102
- onTranslateChanged,
103
- onRelease,
104
- fixOverflowAfterRelease: true,
105
- allowEmpty: {x: false, y: true},
106
- },
107
- }),
108
- );
109
-
110
- expect(testingLib.getByTestId('full-props-test')).toBeTruthy();
111
- expect(testingLib.getByTestId('child-view')).toBeTruthy();
112
- });
113
- });