@hero-design/rn-work-uikit 1.1.0 → 1.2.0-alpha.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/.cursorrules +57 -0
- package/CHANGELOG.md +6 -0
- package/DEVELOPMENT.md +118 -0
- package/eslint.config.js +20 -0
- package/lib/index.js +871 -5
- package/package.json +4 -1
- package/src/__tests__/__snapshots__/index.spec.tsx.snap +90 -115
- package/src/__tests__/theme-export-override.spec.ts +6 -0
- package/src/components/TextInput/ErrorOrHelpText.tsx +58 -0
- package/src/components/TextInput/FloatingLabel.tsx +120 -0
- package/src/components/TextInput/InputComponent.tsx +61 -0
- package/src/components/TextInput/InputRow.tsx +103 -0
- package/src/components/TextInput/MaxLengthMessage.tsx +66 -0
- package/src/components/TextInput/PrefixComponent.tsx +77 -0
- package/src/components/TextInput/StyledTextInput.tsx +134 -0
- package/src/components/TextInput/SuffixComponent.tsx +73 -0
- package/src/components/TextInput/__tests__/ErrorOrHelpText.spec.tsx +20 -0
- package/src/components/TextInput/__tests__/FloatingLabel.spec.tsx +203 -0
- package/src/components/TextInput/__tests__/InputComponent.spec.tsx +39 -0
- package/src/components/TextInput/__tests__/InputRow.spec.tsx +275 -0
- package/src/components/TextInput/__tests__/MaxLengthMessage.spec.tsx +17 -0
- package/src/components/TextInput/__tests__/PrefixComponent.spec.tsx +14 -0
- package/src/components/TextInput/__tests__/StyledTextInput.spec.tsx +114 -0
- package/src/components/TextInput/__tests__/SuffixComponent.spec.tsx +20 -0
- package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +571 -0
- package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +5671 -0
- package/src/components/TextInput/__tests__/getState.spec.tsx +89 -0
- package/src/components/TextInput/__tests__/index.spec.tsx +699 -0
- package/src/components/TextInput/constants.ts +1 -0
- package/src/components/TextInput/index.tsx +327 -0
- package/src/components/TextInput/types.ts +95 -0
- package/src/emotion.d.ts +15 -0
- package/src/index.ts +3 -0
- package/src/jest.d.ts +24 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +15 -8
- package/src/theme/components/textInput.ts +33 -0
- package/src/utils/__tests__/helpers.spec.ts +92 -0
- package/src/utils/helpers.ts +113 -0
- package/testUtils/renderWithTheme.tsx +6 -3
- package/stats/1.1.0/rn-work-uikit-stats.html +0 -4842
package/.cursorrules
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# RN Work UIKit Specific Rules
|
|
2
|
+
|
|
3
|
+
## Package Context
|
|
4
|
+
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.
|
|
5
|
+
|
|
6
|
+
## Testing Rules for RN Work UIKit
|
|
7
|
+
- Write user-behavior focused tests that describe what users see and experience
|
|
8
|
+
- Use descriptive test names like "when user sees an empty input field" instead of "idle state"
|
|
9
|
+
- Group related assertions with explanatory comments about user expectations
|
|
10
|
+
- Focus on user interactions and outcomes rather than implementation details
|
|
11
|
+
- Use `@testing-library/react-native` for all component testing
|
|
12
|
+
- Use `renderWithTheme()` from `../../../../testUtils/renderWithTheme` for components that need theme context
|
|
13
|
+
- Use semantic matchers like `toBeDisabled()`, `toHaveProp()` when available
|
|
14
|
+
- For complex React Native styles, use manual checking when `toHaveStyle()` doesn't work
|
|
15
|
+
- Handle React Native's nested style arrays with `StyleSheet.flatten()` or custom helpers
|
|
16
|
+
- Aim for 100% line coverage on main component files
|
|
17
|
+
- Create dedicated test files for each component (not just integration tests)
|
|
18
|
+
- Test edge cases: undefined props, complex styles, error states
|
|
19
|
+
- Test imperative APIs: ref methods, focus/blur behavior
|
|
20
|
+
- Test accessibility: screen reader support, keyboard navigation
|
|
21
|
+
|
|
22
|
+
## Component Development Rules
|
|
23
|
+
- Import `styled` from `@hero-design/rn` for consistency with base theme
|
|
24
|
+
- Use `useTheme()` hook instead of prop drilling theme
|
|
25
|
+
- Extend base components from `@hero-design/rn` when possible
|
|
26
|
+
- Follow work-specific design patterns and accessibility requirements
|
|
27
|
+
- Use TypeScript strictly - no `any` types without good reason
|
|
28
|
+
- Fix linting errors immediately
|
|
29
|
+
- Use proper React Native components (`Text`, `View`) instead of HTML elements
|
|
30
|
+
|
|
31
|
+
## Documentation Rules
|
|
32
|
+
- Document Props interfaces with JSDoc comments directly on each property: `/** Description */`
|
|
33
|
+
- Use simplified @param comments: `@param props - The component props (see [ComponentName]Props interface for details)`
|
|
34
|
+
- Avoid mentioning implementation details like "memoized component" in JSDoc comments
|
|
35
|
+
- Focus JSDoc comments on what the component does, not how it's implemented
|
|
36
|
+
- Keep type information in the Props interface, not duplicated in @param comments
|
|
37
|
+
|
|
38
|
+
## File Organization
|
|
39
|
+
- Separate large test files by component responsibility
|
|
40
|
+
- Use consistent naming: `ComponentName.spec.tsx`
|
|
41
|
+
- Keep test utilities in `testUtils/` directory at package root
|
|
42
|
+
- Use snapshot testing for visual regression prevention
|
|
43
|
+
- Create README.md files in test directories explaining testing approach
|
|
44
|
+
|
|
45
|
+
## Work-Specific Patterns
|
|
46
|
+
- Components should work with work theme overrides
|
|
47
|
+
- Test with work-specific color palettes and spacing
|
|
48
|
+
- Ensure compatibility with work app requirements
|
|
49
|
+
- Follow work accessibility guidelines
|
|
50
|
+
- Test performance with work-typical data sizes
|
|
51
|
+
|
|
52
|
+
## Quality Gates
|
|
53
|
+
- All tests must pass with 100% coverage on main components
|
|
54
|
+
- No linting errors
|
|
55
|
+
- No TypeScript errors
|
|
56
|
+
- Components must work with both base and work themes
|
|
57
|
+
- Accessibility compliance for work environment
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @hero-design/rn-work-uikit
|
|
2
2
|
|
|
3
|
+
## 1.2.0-alpha.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`c96a992a3d05781029ab5614d465093f9117bd0d`](https://github.com/Thinkei/hero-design/commit/c96a992a3d05781029ab5614d465093f9117bd0d) Thanks [@ttkien](https://github.com/ttkien)! - [TextInput] add TextInput for Work
|
|
8
|
+
|
|
3
9
|
## 1.1.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/DEVELOPMENT.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# RN Work UIKit Development Guide
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
This package contains work-specific React Native components that extend the base `@hero-design/rn` design system. Components here are tailored for work applications with specific themes, accessibility requirements, and interaction patterns.
|
|
5
|
+
|
|
6
|
+
## Development Rules
|
|
7
|
+
|
|
8
|
+
### Component Architecture
|
|
9
|
+
- **Extend Base Components**: Build upon `@hero-design/rn` components when possible
|
|
10
|
+
- **Theme Integration**: Use `useTheme()` hook, import `styled` from `@hero-design/rn`
|
|
11
|
+
- **Work-Specific**: Components should work with work theme overrides and requirements
|
|
12
|
+
- **TypeScript**: Strict typing, no `any` types without good reason
|
|
13
|
+
|
|
14
|
+
### Testing Standards
|
|
15
|
+
- **User-Behavior Focused**: Write tests that describe what users see and experience
|
|
16
|
+
- **Test Structure**: Use descriptive names like "when user sees an empty input field"
|
|
17
|
+
- **Coverage**: Aim for 100% line coverage on main component files
|
|
18
|
+
- **Testing Library**: Use `@testing-library/react-native` exclusively
|
|
19
|
+
- **Theme Testing**: Use `renderWithTheme()` from `../../../../testUtils/renderWithTheme`
|
|
20
|
+
|
|
21
|
+
### Test Patterns
|
|
22
|
+
```typescript
|
|
23
|
+
describe('ComponentName', () => {
|
|
24
|
+
describe('when user encounters [scenario]', () => {
|
|
25
|
+
it('should [expected user experience]', () => {
|
|
26
|
+
// User performs action
|
|
27
|
+
const { getByTestId } = renderWithTheme(<Component />);
|
|
28
|
+
|
|
29
|
+
// User should see expected result
|
|
30
|
+
expect(getByTestId('element')).toBeTruthy();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### File Organization
|
|
37
|
+
```
|
|
38
|
+
src/
|
|
39
|
+
├── components/
|
|
40
|
+
│ └── ComponentName/
|
|
41
|
+
│ ├── index.tsx # Main component
|
|
42
|
+
│ ├── ComponentName.tsx # Implementation
|
|
43
|
+
│ ├── types.ts # TypeScript types
|
|
44
|
+
│ ├── constants.ts # Constants
|
|
45
|
+
│ └── __tests__/
|
|
46
|
+
│ ├── index.spec.tsx # Integration tests
|
|
47
|
+
│ ├── ComponentName.spec.tsx # Unit tests
|
|
48
|
+
│ └── README.md # Test documentation
|
|
49
|
+
├── theme/ # Work-specific theme overrides
|
|
50
|
+
├── testUtils/ # Test utilities
|
|
51
|
+
└── utils/ # Shared utilities
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Testing Checklist
|
|
55
|
+
- [ ] User-behavior focused test names
|
|
56
|
+
- [ ] All props and combinations tested
|
|
57
|
+
- [ ] Edge cases: undefined props, error states
|
|
58
|
+
- [ ] Accessibility: screen readers, keyboard navigation
|
|
59
|
+
- [ ] Imperative APIs: ref methods, focus/blur
|
|
60
|
+
- [ ] Animation states and visibility
|
|
61
|
+
- [ ] Theme compatibility (base + work themes)
|
|
62
|
+
- [ ] Performance with work-typical data
|
|
63
|
+
- [ ] Semantic matchers used where possible
|
|
64
|
+
- [ ] React Native components in tests (not HTML)
|
|
65
|
+
|
|
66
|
+
### Code Quality
|
|
67
|
+
- [ ] No linting errors
|
|
68
|
+
- [ ] No TypeScript errors
|
|
69
|
+
- [ ] 100% test coverage on main components
|
|
70
|
+
- [ ] Accessibility compliance
|
|
71
|
+
- [ ] Performance benchmarks met
|
|
72
|
+
- [ ] Work theme compatibility verified
|
|
73
|
+
|
|
74
|
+
### Common Patterns
|
|
75
|
+
|
|
76
|
+
#### Theme Usage
|
|
77
|
+
```typescript
|
|
78
|
+
import { useTheme } from '../../theme';
|
|
79
|
+
import { styled } from '@hero-design/rn';
|
|
80
|
+
|
|
81
|
+
const StyledComponent = styled.View<{ themeState: State }>(
|
|
82
|
+
({ theme, themeState }) => ({
|
|
83
|
+
backgroundColor: theme.__hd__.componentName.colors.background[themeState],
|
|
84
|
+
})
|
|
85
|
+
);
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
#### Testing Styles
|
|
89
|
+
```typescript
|
|
90
|
+
// For simple styles
|
|
91
|
+
expect(element).toHaveProp('style', { color: '#000000' });
|
|
92
|
+
|
|
93
|
+
// For complex React Native styles
|
|
94
|
+
const flattenedStyle = StyleSheet.flatten(element.props.style);
|
|
95
|
+
expect(flattenedStyle.backgroundColor).toBe('#ffffff');
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
#### Testing Accessibility
|
|
99
|
+
```typescript
|
|
100
|
+
expect(element).toHaveProp('accessibilityElementsHidden', false);
|
|
101
|
+
expect(element).toBeDisabled(); // Use semantic matchers
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Work-Specific Requirements
|
|
105
|
+
- Components must work in work applications
|
|
106
|
+
- Follow work accessibility guidelines
|
|
107
|
+
- Test with work-specific color palettes
|
|
108
|
+
- Ensure performance with work data sizes
|
|
109
|
+
- Maintain compatibility with work app requirements
|
|
110
|
+
|
|
111
|
+
## Getting Started
|
|
112
|
+
1. Create component following file structure
|
|
113
|
+
2. Implement with work theme integration
|
|
114
|
+
3. Write comprehensive tests following patterns
|
|
115
|
+
4. Ensure 100% coverage and quality gates
|
|
116
|
+
5. Document component usage and patterns
|
|
117
|
+
|
|
118
|
+
Remember: Focus on what users experience, not how code works internally.
|
package/eslint.config.js
CHANGED
|
@@ -35,6 +35,26 @@ module.exports = [
|
|
|
35
35
|
'import/no-cycle': 'error',
|
|
36
36
|
'react/no-unused-prop-types': 'warn',
|
|
37
37
|
'react/no-array-index-key': 'warn',
|
|
38
|
+
'@typescript-eslint/no-explicit-any': 'error',
|
|
39
|
+
// Prevent direct imports of styled from emotion packages
|
|
40
|
+
// Use styled from @hero-design/rn instead for proper theme typing
|
|
41
|
+
'no-restricted-imports': [
|
|
42
|
+
'error',
|
|
43
|
+
{
|
|
44
|
+
paths: [
|
|
45
|
+
{
|
|
46
|
+
name: '@emotion/native',
|
|
47
|
+
importNames: ['styled', 'default'],
|
|
48
|
+
message: 'Import styled from @hero-design/rn instead of @emotion/native for proper theme typing',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: '@emotion/react',
|
|
52
|
+
importNames: ['styled', 'default'],
|
|
53
|
+
message: 'Import styled from @hero-design/rn instead of @emotion/react for proper theme typing',
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
],
|
|
38
58
|
},
|
|
39
59
|
},
|
|
40
60
|
];
|