@hero-design/rn-work-uikit 1.8.1 → 1.9.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.
@@ -0,0 +1,64 @@
1
+ ---
2
+ pattern: "**/*.{ts,tsx}"
3
+ description: "Performance optimization rules for React Native components in rn-work-uikit package"
4
+ ---
5
+
6
+ # Performance Optimization Rules for RN Work UIKit
7
+
8
+ ## React Native Performance Best Practices
9
+
10
+ ### Component Optimization
11
+ - Use `React.memo()` for components that receive stable props
12
+ - Implement `useMemo()` for expensive calculations
13
+ - Use `useCallback()` for event handlers passed to child components
14
+ - Avoid creating objects/functions in render methods
15
+ - Prefer `useState` functional updates when state depends on previous state
16
+
17
+ ### List Performance
18
+ - Use `FlatList` or `SectionList` instead of `ScrollView` with `map()`
19
+ - Implement `getItemLayout` for `FlatList` when item heights are known
20
+ - Use `keyExtractor` prop for consistent item identification
21
+ - Implement `removeClippedSubviews` for large lists
22
+ - Use `windowSize` and `initialNumToRender` for performance tuning
23
+
24
+ ### Memory Management
25
+ - Clean up subscriptions in `useEffect` cleanup functions
26
+ - Use `InteractionManager.runAfterInteractions()` for non-critical operations
27
+ - Avoid memory leaks by properly unmounting components
28
+ - Use `React.useRef()` instead of `useState` for mutable values
29
+ - Implement proper error boundaries to prevent crashes
30
+
31
+ ### Animation Performance
32
+ - Use `Animated` API for smooth 60fps animations
33
+ - Prefer `transform` and `opacity` animations over layout changes
34
+ - Use `useNativeDriver: true` when possible
35
+ - Avoid animating `width`, `height`, or `top` properties
36
+ - Use `LayoutAnimation` for list item changes
37
+
38
+ ### Bundle Size Optimization
39
+ - Use dynamic imports for large components (`React.lazy()`)
40
+ - Implement code splitting for feature modules
41
+ - Remove unused dependencies and imports
42
+ - Use tree shaking compatible libraries
43
+ - Optimize asset sizes and formats
44
+
45
+ ### Work-Specific Performance Considerations
46
+ - Test with work-typical data sizes (large datasets, complex forms)
47
+ - Optimize for work app's specific use cases
48
+ - Ensure smooth performance on older devices
49
+ - Test with work theme overrides and custom styling
50
+ - Monitor performance metrics in work environment
51
+
52
+ ### Performance Monitoring
53
+ - Use React DevTools Profiler for component analysis
54
+ - Implement performance logging for critical paths
55
+ - Monitor memory usage during development
56
+ - Test performance on various device types
57
+ - Use Flipper for React Native debugging
58
+
59
+ ### Anti-Patterns to Avoid
60
+ - Don't use `console.log` in production builds
61
+ - Avoid inline object/function creation in render
62
+ - Don't use `setState` in render methods
63
+ - Avoid unnecessary re-renders with proper dependency arrays
64
+ - Don't ignore performance warnings from React Native
@@ -0,0 +1,202 @@
1
+ ---
2
+ pattern: "**/*.{ts,tsx}"
3
+ description: "Work-specific React Native component library rules extending base rn package"
4
+ alwaysApply: false
5
+ ---
6
+
7
+ # RN Work UIKit Specific Rules
8
+
9
+ ## Package Context
10
+ This is the work-specific React Native component library that extends @hero-design/rn with work-focused components like TextInput, specialized themes, and work-specific patterns.
11
+
12
+ ## Component Structure Guidelines
13
+
14
+ ### File Organization
15
+ - **Component files**: `ComponentName/index.tsx` (main component)
16
+ - **Styled components**: `ComponentName/StyledComponentName.tsx` (e.g., `StyledTextInput.tsx`)
17
+ - **Sub-components**: `ComponentName/SubComponent.tsx` (e.g., `FloatingLabel.tsx`, `ErrorOrHelpText.tsx`)
18
+ - **Types**: `ComponentName/types.ts` (if complex types are needed)
19
+ - **Tests**: `ComponentName/__tests__/ComponentName.spec.tsx`
20
+
21
+ ### Component Structure Example
22
+ ```tsx
23
+ // TextInput/index.tsx
24
+ import React, { forwardRef, useCallback } from 'react';
25
+ import type { StyleProp, ViewStyle } from 'react-native';
26
+ import { StyledContainer, StyledBorder, StyledInputWrapper } from './StyledTextInput';
27
+ import { useTheme } from '../../theme';
28
+ import FloatingLabel from './FloatingLabel';
29
+ import InputRow from './InputRow';
30
+ import type { TextInputProps, TextInputHandles } from './types';
31
+
32
+ export interface TextInputProps {
33
+ /** Label for the input field */
34
+ label?: string;
35
+ /** Error message to display */
36
+ error?: string;
37
+ /** Help text to display below input */
38
+ helpText?: string;
39
+ /** Whether the field is required */
40
+ required?: boolean;
41
+ /** Whether the field is disabled */
42
+ disabled?: boolean;
43
+ /** Input value */
44
+ value?: string;
45
+ /** Input variant */
46
+ variant?: 'text' | 'textarea';
47
+ /** Additional style */
48
+ style?: StyleProp<ViewStyle>;
49
+ /** Testing id */
50
+ testID?: string;
51
+ }
52
+
53
+ export const InternalTextInput = forwardRef<TextInputHandles, TextInputProps>(
54
+ ({ label, error, helpText, required, disabled = false, value, variant = 'text', style, testID, ...props }, ref) => {
55
+ const [isFocused, setIsFocused] = React.useState(false);
56
+ const theme = useTheme();
57
+
58
+ const handleFocus = useCallback(() => setIsFocused(true), []);
59
+ const handleBlur = useCallback(() => setIsFocused(false), []);
60
+
61
+ return (
62
+ <StyledContainer
63
+ style={style}
64
+ themeFocused={isFocused}
65
+ themeHasError={!!error}
66
+ testID={testID}
67
+ >
68
+ <StyledBorder themeFocused={isFocused} themeState={getState({ disabled, error })} />
69
+ <StyledInputWrapper>
70
+ {!!label && (
71
+ <FloatingLabel
72
+ label={label}
73
+ variant={variant}
74
+ isFocused={isFocused}
75
+ required={required}
76
+ />
77
+ )}
78
+ <InputRow
79
+ variant={variant}
80
+ nativeInputProps={{
81
+ ...props,
82
+ onFocus: handleFocus,
83
+ onBlur: handleBlur,
84
+ value,
85
+ }}
86
+ />
87
+ <ErrorOrHelpText error={error} helpText={helpText} />
88
+ </StyledInputWrapper>
89
+ </StyledContainer>
90
+ );
91
+ }
92
+ );
93
+ ```
94
+
95
+ ### Styled Component Conventions
96
+ - **Naming**: `const StyledComponentName = styled.View\`\``
97
+ - **Props naming**: Use descriptive names like `themeFocused`, `themeHasError`, `themeState`
98
+ - **Theme access**: Use component-specific theme tokens via `theme.__hd__.componentName.*` instead of global theme tokens
99
+
100
+ ```tsx
101
+ // StyledTextInput.tsx
102
+ import styled from '@emotion/native';
103
+
104
+ interface StyledTextInputProps {
105
+ themeFocused: boolean;
106
+ themeHasError: boolean;
107
+ }
108
+
109
+ const StyledContainer = styled.View<StyledTextInputProps>`
110
+ ${({ theme, themeFocused, themeHasError }) => `
111
+ background-color: ${theme.__hd__.textInput.colors.containerBackground};
112
+ border-color: ${themeFocused
113
+ ? theme.__hd__.textInput.colors.border.focused
114
+ : theme.__hd__.textInput.colors.border.default};
115
+ border-width: ${theme.__hd__.textInput.borderWidth};
116
+ border-radius: ${theme.__hd__.textInput.borderRadius};
117
+ `}
118
+ `;
119
+ ```
120
+
121
+ ## Theme Token Usage
122
+
123
+ ### Adding Theme Tokens
124
+ 1. **Define in theme**: Add new tokens to work-specific theme files
125
+ 2. **Use consistently**: Apply tokens across work components
126
+ 3. **Document usage**: Add JSDoc comments for token purposes
127
+
128
+ ### Theme Token Examples
129
+ ```tsx
130
+ // Using work-specific theme tokens
131
+ background-color: ${theme.__hd__.textInput.colors.containerBackground};
132
+ border-color: ${theme.__hd__.textInput.colors.border.focused};
133
+ border-width: ${theme.__hd__.textInput.borderWidth};
134
+ border-radius: ${theme.__hd__.textInput.borderRadius};
135
+
136
+ // Using global theme tokens when needed
137
+ margin: ${theme.spacing.md}; // Global spacing
138
+ font-family: ${theme.typography.fontFamily}; // Global typography
139
+ ```
140
+
141
+ ### Modifying Theme Tokens
142
+ - **Work-specific changes**: Update work theme files
143
+ - **Component-specific**: Use component theme overrides
144
+ - **Testing**: Verify changes across all work components
145
+
146
+ ## Component Development Rules
147
+
148
+ ### Basic Rules
149
+ - **Prefer functional components with hooks over class components**
150
+ - Import `styled` from `@hero-design/rn` for consistency with base theme
151
+ - Use `useTheme()` hook instead of prop drilling theme
152
+ - Extend base components from `@hero-design/rn` when possible
153
+ - Follow work-specific design patterns and accessibility requirements
154
+ - Use TypeScript strictly - no `any` types without good reason
155
+ - Fix linting errors immediately
156
+ - Use proper React Native components (`Text`, `View`) instead of HTML elements
157
+
158
+ ### Props Interface Guidelines
159
+ ```tsx
160
+ // Good example from TextInput component
161
+ export interface TextInputProps {
162
+ /** Label for the input field */
163
+ label?: string;
164
+ /** Error message to display */
165
+ error?: string;
166
+ /** Help text to display below input */
167
+ helpText?: string;
168
+ /** Whether the field is required */
169
+ required?: boolean;
170
+ /** Whether the field is disabled */
171
+ disabled?: boolean;
172
+ /** Input value */
173
+ value?: string;
174
+ /** Input variant */
175
+ variant?: 'text' | 'textarea';
176
+ /** Additional style */
177
+ style?: StyleProp<ViewStyle>;
178
+ /** Testing id */
179
+ testID?: string;
180
+ }
181
+ ```
182
+
183
+ ## Documentation Rules
184
+ - Document Props interfaces with JSDoc comments directly on each property: `/** Description */`
185
+ - Use simplified @param comments: `@param props - The component props (see [ComponentName]Props interface for details)`
186
+ - Avoid mentioning implementation details like "memoized component" in JSDoc comments
187
+ - Focus JSDoc comments on what the component does, not how it's implemented
188
+ - Keep type information in the Props interface, not duplicated in @param comments
189
+
190
+ ## Work-Specific Patterns
191
+ - Components should work with work theme overrides
192
+ - Test with work-specific color palettes and spacing
193
+ - Ensure compatibility with work app requirements
194
+ - Follow work accessibility guidelines
195
+ - Test performance with work-typical data sizes
196
+
197
+ ## Quality Gates
198
+ - All tests must pass with 100% coverage on main components
199
+ - No linting errors
200
+ - No TypeScript errors
201
+ - Components must work with both base and work themes
202
+ - Accessibility compliance for work environment
@@ -0,0 +1,114 @@
1
+ ---
2
+ pattern: "**/*.spec.{ts,tsx}"
3
+ description: "Comprehensive testing guidelines for React Native components in rn-work-uikit package"
4
+ ---
5
+
6
+ # Testing Guidelines for RN Work UIKit
7
+
8
+ ## Testing Philosophy
9
+ - Write user-behavior focused tests that describe what users see and experience
10
+ - Use descriptive test names like "when user sees an empty input field" instead of "idle state"
11
+ - Group related assertions with explanatory comments about user expectations
12
+ - Focus on user interactions and outcomes rather than implementation details
13
+ - Test the component's public API, not internal implementation
14
+ - Write tests that will catch regressions and ensure reliability
15
+
16
+ ## Testing Tools and Setup
17
+ - Use `@testing-library/react-native` for all component testing
18
+ - Use `renderWithTheme()` from `../../../../testUtils/renderWithTheme` for components that need theme context
19
+ - Use semantic matchers like `toBeDisabled()`, `toHaveProp()` when available
20
+ - For complex React Native styles, use manual checking when `toHaveStyle()` doesn't work
21
+ - Handle React Native's nested style arrays with `StyleSheet.flatten()` or custom helpers
22
+ - Use `jest` for test runner and assertion library
23
+ - Use `@testing-library/jest-native` for additional React Native matchers
24
+
25
+ ## Test Structure and Organization
26
+ - Follow AAA pattern: Arrange, Act, Assert
27
+ - Use `describe` blocks to group related tests
28
+ - Use descriptive `it` statements that explain the expected behavior
29
+ - Keep tests focused and test one thing at a time
30
+ - Use `beforeEach` and `afterEach` for setup and cleanup
31
+ - Mock external dependencies and APIs
32
+ - Use `test.each` for parameterized tests when testing multiple scenarios
33
+
34
+ ## Test Coverage Requirements
35
+ - Aim for 100% line coverage on main component files
36
+ - Create dedicated test files for each component (not just integration tests)
37
+ - Separate large test files by component responsibility
38
+ - Use consistent naming: `ComponentName.spec.tsx`
39
+ - Keep test utilities in `testUtils/` directory at package root
40
+ - Use snapshot testing for visual regression prevention
41
+ - Create README.md files in test directories explaining testing approach
42
+
43
+ ## Component Testing Patterns
44
+ - Test component rendering with different props
45
+ - Test user interactions (press, type, scroll)
46
+ - Test component state changes
47
+ - Test prop changes and their effects
48
+ - Test conditional rendering based on props/state
49
+ - Test component lifecycle methods
50
+ - Test ref forwarding and imperative APIs
51
+
52
+ ## Accessibility Testing
53
+ - Test screen reader support with `getByRole`, `getByLabelText`
54
+ - Test keyboard navigation and focus management
55
+ - Test accessibility props like `accessibilityLabel`, `accessibilityHint`
56
+ - Test accessibility states like `accessibilityState`
57
+ - Test with accessibility tools and screen readers
58
+ - Ensure proper semantic markup and ARIA attributes
59
+
60
+ ## Error Handling and Edge Cases
61
+ - Test error states and error boundaries
62
+ - Test with invalid or missing props
63
+ - Test with extreme values (empty strings, null, undefined)
64
+ - Test component behavior with network failures
65
+ - Test graceful degradation when features are unavailable
66
+ - Test component recovery from error states
67
+
68
+ ## Performance Testing
69
+ - Test component rendering performance with large datasets
70
+ - Test memory leaks and cleanup
71
+ - Test component re-rendering behavior
72
+ - Test with work-typical data sizes
73
+ - Use React DevTools Profiler for performance analysis
74
+ - Test component performance on different device types
75
+
76
+ ## Work-Specific Testing
77
+ - Test with work-specific color palettes and spacing
78
+ - Test component behavior with work theme overrides
79
+ - Test compatibility with work app requirements
80
+ - Test work-specific accessibility guidelines
81
+ - Test performance with work-typical data sizes
82
+ - Test integration with work-specific APIs and services
83
+
84
+ ## Mocking and Test Utilities
85
+ - Mock React Native modules that aren't available in test environment
86
+ - Create custom render functions for common test scenarios
87
+ - Use `jest.mock()` for external dependencies
88
+ - Create test data factories for consistent test data
89
+ - Use `@testing-library/user-event` for user interaction simulation
90
+ - Mock navigation and routing for component tests
91
+
92
+ ## Test Data Management
93
+ - Use consistent test data across tests
94
+ - Create reusable test data factories
95
+ - Use realistic data that matches production scenarios
96
+ - Test with both valid and invalid data
97
+ - Use work-specific data patterns and structures
98
+ - Keep test data minimal but representative
99
+
100
+ ## Integration Testing
101
+ - Test component integration with other components
102
+ - Test component behavior within larger feature flows
103
+ - Test component interaction with global state
104
+ - Test component behavior with routing and navigation
105
+ - Test component behavior with work-specific services
106
+ - Use integration tests sparingly, prefer unit tests
107
+
108
+ ## Continuous Integration
109
+ - Ensure all tests pass in CI environment
110
+ - Use consistent test commands across environments
111
+ - Set up test coverage reporting
112
+ - Use parallel test execution for faster CI runs
113
+ - Ensure tests are deterministic and don't flake
114
+ - Use proper test isolation to avoid test interference
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @hero-design/rn-work-uikit
2
2
 
3
+ ## 1.9.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#4303](https://github.com/Thinkei/hero-design/pull/4303) [`ee5b1d700200af991bb360e3f514f29790e33511`](https://github.com/Thinkei/hero-design/commit/ee5b1d700200af991bb360e3f514f29790e33511) Thanks [@ngvuthanhnhan-eh-hi](https://github.com/ngvuthanhnhan-eh-hi)! - Suppress `lint` warnings in CI Logs
8
+
9
+ - Updated dependencies [[`ee5b1d700200af991bb360e3f514f29790e33511`](https://github.com/Thinkei/hero-design/commit/ee5b1d700200af991bb360e3f514f29790e33511), [`02ecf1c8ab33f3d95dcc2d168d70f11d8c415883`](https://github.com/Thinkei/hero-design/commit/02ecf1c8ab33f3d95dcc2d168d70f11d8c415883)]:
10
+ - @hero-design/react-native-month-year-picker@8.43.2
11
+ - @hero-design/rn@8.112.0
12
+
13
+ ## 1.9.0
14
+
15
+ ### Minor Changes
16
+
17
+ - [#4287](https://github.com/Thinkei/hero-design/pull/4287) [`e7d09c0d84402f39f49d9de984b435de75fda538`](https://github.com/Thinkei/hero-design/commit/e7d09c0d84402f39f49d9de984b435de75fda538) Thanks [@vinhphan-eh](https://github.com/vinhphan-eh)! - [Typography.Body][typography.caption][Typography.Label] Support italic style prop
18
+
19
+ - [#4277](https://github.com/Thinkei/hero-design/pull/4277) [`41d0eb39bb03540a9c2d47c40c79846739ebedcf`](https://github.com/Thinkei/hero-design/commit/41d0eb39bb03540a9c2d47c40c79846739ebedcf) Thanks [@vinhphan-eh](https://github.com/vinhphan-eh)! - [Typography.Title] Support italic style
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies [[`52f1ccb86d7c307f93aa95ccf7b9e11ff97e542a`](https://github.com/Thinkei/hero-design/commit/52f1ccb86d7c307f93aa95ccf7b9e11ff97e542a), [`e7d09c0d84402f39f49d9de984b435de75fda538`](https://github.com/Thinkei/hero-design/commit/e7d09c0d84402f39f49d9de984b435de75fda538), [`41d0eb39bb03540a9c2d47c40c79846739ebedcf`](https://github.com/Thinkei/hero-design/commit/41d0eb39bb03540a9c2d47c40c79846739ebedcf)]:
24
+ - @hero-design/rn@8.111.0
25
+
3
26
  ## 1.8.1
4
27
 
5
28
  ### Patch Changes
Binary file