@animus-ui/core 0.1.1-fffe37d2.0 → 0.2.0-beta.2

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 (49) hide show
  1. package/ANIMUS_ARCHITECTURE.md +173 -0
  2. package/CHANGELOG.md +80 -8
  3. package/CLAUDE.md +1240 -0
  4. package/dist/Animus.d.ts +77 -63
  5. package/dist/AnimusConfig.d.ts +8 -8
  6. package/dist/AnimusExtended.d.ts +76 -0
  7. package/dist/__fixtures__/testConfig.d.ts +153 -153
  8. package/dist/compatTheme.d.ts +28 -20
  9. package/dist/config.d.ts +2321 -2193
  10. package/dist/createAnimus.d.ts +2 -2
  11. package/dist/index.d.ts +1084 -1019
  12. package/dist/index.js +2006 -0
  13. package/dist/legacy/compose.d.ts +2 -2
  14. package/dist/legacy/config.d.ts +86 -85
  15. package/dist/legacy/core.d.ts +12 -12
  16. package/dist/legacy/create.d.ts +2 -2
  17. package/dist/legacy/createCss.d.ts +2 -2
  18. package/dist/legacy/createParser.d.ts +2 -9
  19. package/dist/legacy/createStates.d.ts +2 -2
  20. package/dist/legacy/createTransform.d.ts +2 -2
  21. package/dist/legacy/createVariant.d.ts +2 -2
  22. package/dist/legacy/responsive.d.ts +14 -14
  23. package/dist/properties/getStylePropNames.d.ts +1 -1
  24. package/dist/properties/orderPropNames.d.ts +6 -6
  25. package/dist/properties/styledOptions.d.ts +20 -20
  26. package/dist/scales/createScale.d.ts +6 -3
  27. package/dist/scales/lookupScaleValue.d.ts +3 -3
  28. package/dist/styles/createParser.d.ts +2 -9
  29. package/dist/styles/createPropertyStyle.d.ts +4 -3
  30. package/dist/styles/createStylist.d.ts +2 -2
  31. package/dist/styles/responsive.d.ts +14 -14
  32. package/dist/transforms/border.d.ts +1 -1
  33. package/dist/transforms/grid.d.ts +4 -4
  34. package/dist/transforms/index.d.ts +4 -4
  35. package/dist/transforms/size.d.ts +2 -2
  36. package/dist/transforms/utils.d.ts +2 -1
  37. package/dist/types/config.d.ts +50 -44
  38. package/dist/types/properties.d.ts +23 -26
  39. package/dist/types/props.d.ts +34 -43
  40. package/dist/types/scales.d.ts +2 -2
  41. package/dist/types/shared.d.ts +4 -4
  42. package/dist/types/theme.d.ts +17 -17
  43. package/dist/types/utils.d.ts +4 -4
  44. package/jest.config.js +1 -0
  45. package/package.json +11 -9
  46. package/rollup.config.js +2 -2
  47. package/tsconfig.json +4 -2
  48. package/dist/index.cjs.js +0 -1
  49. package/dist/index.esm.js +0 -1
@@ -0,0 +1,173 @@
1
+ # Animus.ts Architecture Explanation
2
+
3
+ ## Core Concept
4
+
5
+ Animus is a **type-state machine** that guides you through building styled components step-by-step. It uses TypeScript's type system to enforce that you configure your components in a specific order, making it impossible to make mistakes.
6
+
7
+ ## The Unique Architecture
8
+
9
+ The most interesting aspect is the **backwards inheritance chain**:
10
+
11
+ ```
12
+ Animus → AnimusWithBase → AnimusWithVariants → AnimusWithStates → AnimusWithSystem → AnimusWithAll
13
+ ```
14
+
15
+ Each class extends the one *after* it in the chain, which seems backwards but is actually brilliant. Here's why:
16
+
17
+ - `Animus` (the starting point) inherits from `AnimusWithBase`
18
+ - `AnimusWithBase` inherits from `AnimusWithVariants`
19
+ - And so on...
20
+
21
+ This means the first class has access to all the methods defined in later classes, but those methods only become *available* to use when you reach the right stage.
22
+
23
+ ## How It Works - Step by Step
24
+
25
+ ### 1. Starting Point: `Animus` (lines 331-349)
26
+ ```typescript
27
+ const builder = new Animus(propRegistry, groupRegistry);
28
+ ```
29
+ - Takes your prop definitions and group configurations
30
+ - Only exposes the `.styles()` method
31
+ - Creates a parser for your props automatically
32
+
33
+ ### 2. After calling `.styles()`: `AnimusWithBase` (lines 287-329)
34
+ ```typescript
35
+ builder.styles({ padding: '20px', color: 'blue' })
36
+ ```
37
+ - Now you can call `.variant()` to add design variations
38
+ - The base styles are locked in
39
+
40
+ ### 3. After calling `.variant()`: `AnimusWithVariants` (lines 226-285)
41
+ ```typescript
42
+ .variant({
43
+ prop: 'size',
44
+ variants: {
45
+ small: { fontSize: '14px' },
46
+ large: { fontSize: '20px' }
47
+ }
48
+ })
49
+ ```
50
+ - Can add multiple variants
51
+ - Now `.states()` method becomes available
52
+
53
+ ### 4. After calling `.states()`: `AnimusWithStates` (lines 184-224)
54
+ ```typescript
55
+ .states({
56
+ disabled: { opacity: 0.5, cursor: 'not-allowed' },
57
+ loading: { cursor: 'wait' }
58
+ })
59
+ ```
60
+ - Defines boolean states (props that are true/false)
61
+ - Unlocks `.groups()` method
62
+
63
+ ### 5. After calling `.groups()`: `AnimusWithSystem` (lines 140-182)
64
+ ```typescript
65
+ .groups({ spacing: true, colors: true })
66
+ ```
67
+ - Enables predefined groups of props
68
+ - Now you can add custom props with `.props()`
69
+
70
+ ### 6. Final Stage: `AnimusWithAll` (lines 24-138)
71
+ This is where the magic happens. You can now:
72
+
73
+ - `.asElement('button')` - Create a styled HTML element
74
+ - `.asComponent(MyComponent)` - Style an existing React component
75
+ - `.build()` - Get the raw styling function
76
+ - `.extend()` - Create variations of your styled component
77
+
78
+ ## Key Features
79
+
80
+ ### Type Safety Throughout
81
+ The 8 generic parameters track everything:
82
+ - `PropRegistry` - All your prop definitions
83
+ - `GroupRegistry` - Prop groupings
84
+ - `BaseParser` - How props convert to CSS
85
+ - `BaseStyles` - Your base CSS
86
+ - `Variants` - Design variations
87
+ - `States` - Boolean state styles
88
+ - `ActiveGroups` - Which groups are enabled
89
+ - `CustomProps` - Additional custom props
90
+
91
+ ### Smart Prop Forwarding (lines 76-87)
92
+ ```typescript
93
+ shouldForwardProp: (prop) =>
94
+ isPropValid(prop) && !propNames.includes(prop)
95
+ ```
96
+ - System props (like `spacing`, `colors`) are consumed and turned into styles
97
+ - Valid HTML attributes are passed through
98
+ - Invalid props are filtered out
99
+
100
+ ### The Build Process (lines 99-137)
101
+ When you call `.build()`, it:
102
+ 1. Merges your parser config with custom props
103
+ 2. Creates a stylist that combines all your configurations
104
+ 3. Returns a function that generates CSS objects
105
+ 4. Handles variants, states, and system props automatically
106
+
107
+ ### Extension System
108
+ The `.extend()` method creates an `AnimusExtended` instance that can break the rules - you can modify any part of the configuration in any order. This provides an escape hatch when needed.
109
+
110
+ ## Why This Design?
111
+
112
+ 1. **Impossible to Misuse** - You can't call methods in the wrong order
113
+ 2. **Perfect IntelliSense** - Your IDE knows exactly what methods are available at each step
114
+ 3. **Type Safe** - All configurations are fully typed
115
+ 4. **Flexible When Needed** - The extend system provides flexibility
116
+ 5. **Clean API** - The forced order mirrors how we think about styling (base → variants → states → props)
117
+
118
+ ## Example Usage
119
+
120
+ ```typescript
121
+ const Button = animus
122
+ .styles({
123
+ padding: '10px 20px',
124
+ borderRadius: '4px'
125
+ })
126
+ .variant({
127
+ prop: 'variant',
128
+ variants: {
129
+ primary: { background: 'blue', color: 'white' },
130
+ secondary: { background: 'gray', color: 'black' }
131
+ }
132
+ })
133
+ .states({
134
+ disabled: { opacity: 0.6 }
135
+ })
136
+ .asElement('button');
137
+
138
+ // Usage:
139
+ <Button variant="primary" disabled>Click me</Button>
140
+ ```
141
+
142
+ ## The Backwards Inheritance Explained
143
+
144
+ The backwards inheritance pattern is the key innovation. Instead of:
145
+ - Base class with few methods → Derived class with more methods (traditional OOP)
146
+
147
+ Animus does:
148
+ - Starting class that inherits everything → But methods are selectively exposed
149
+
150
+ This creates a "progressive revelation" pattern where:
151
+ 1. You start with minimal options (just `.styles()`)
152
+ 2. Each method call returns a new class instance
153
+ 3. That new instance exposes the next logical methods
154
+ 4. Invalid sequences are impossible at the type level
155
+
156
+ ## Integration with Emotion
157
+
158
+ Animus builds on top of Emotion (a CSS-in-JS library):
159
+ - Uses `@emotion/styled` to create the actual styled components
160
+ - Uses `@emotion/is-prop-valid` to filter props intelligently
161
+ - The final output is a standard Emotion styled component
162
+ - Full compatibility with themes, SSR, and other Emotion features
163
+
164
+ ## Performance Considerations
165
+
166
+ - All type checking happens at compile time - zero runtime overhead
167
+ - The inheritance chain is resolved during build
168
+ - Final components are standard Emotion components
169
+ - Parser and stylist are created once and reused
170
+
171
+ ## Summary
172
+
173
+ This architecture ensures that every styled component is configured correctly, with all the power of CSS-in-JS but none of the footguns! The type-state machine pattern combined with backwards inheritance creates a unique developer experience where the API guides you to success.
package/CHANGELOG.md CHANGED
@@ -3,61 +3,133 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [0.1.1-beta.6](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.5...@animus-ui/core@0.1.1-beta.6) (2022-01-11)
6
+ # [0.2.0-beta.2](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.2.0-beta.0...@animus-ui/core@0.2.0-beta.2) (2025-07-01)
7
7
 
8
8
  **Note:** Version bump only for package @animus-ui/core
9
9
 
10
+ # 0.2.0-beta.1 (2025-06-15)
10
11
 
12
+ ### Features
11
13
 
14
+ - Implement layered documentation and file-based governance voting ([7cdb599](https://github.com/codecaaron/animus/commit/7cdb5995e94d26059bfdd3ec01279fc4e4b45d40))
12
15
 
16
+ ## 0.1.1-beta.1 (2022-01-09)
13
17
 
14
- ## [0.1.1-beta.5](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.4...@animus-ui/core@0.1.1-beta.5) (2022-01-09)
18
+ ## 0.1.1-beta.0 (2022-01-09)
19
+
20
+ # [0.2.0-beta.0](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.26...@animus-ui/core@0.2.0-beta.0) (2025-06-13)
21
+
22
+ ### Features
23
+
24
+ - Implement layered documentation and file-based governance voting ([7cdb599](https://github.com/codecaaron/animus/commit/7cdb5995e94d26059bfdd3ec01279fc4e4b45d40))
25
+
26
+ ## [0.1.1-beta.26](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.25...@animus-ui/core@0.1.1-beta.26) (2025-05-29)
15
27
 
16
28
  **Note:** Version bump only for package @animus-ui/core
17
29
 
30
+ ## [0.1.1-beta.25](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.24...@animus-ui/core@0.1.1-beta.25) (2025-05-29)
18
31
 
32
+ **Note:** Version bump only for package @animus-ui/core
19
33
 
34
+ ## [0.1.1-beta.24](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.23...@animus-ui/core@0.1.1-beta.24) (2023-03-15)
20
35
 
36
+ **Note:** Version bump only for package @animus-ui/core
21
37
 
22
- ## [0.1.1-beta.4](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.3...@animus-ui/core@0.1.1-beta.4) (2022-01-09)
38
+ ## [0.1.1-beta.23](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.22...@animus-ui/core@0.1.1-beta.23) (2023-03-15)
23
39
 
24
40
  **Note:** Version bump only for package @animus-ui/core
25
41
 
42
+ ## [0.1.1-beta.22](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.21...@animus-ui/core@0.1.1-beta.22) (2023-03-13)
26
43
 
44
+ **Note:** Version bump only for package @animus-ui/core
27
45
 
46
+ ## [0.1.1-beta.21](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.20...@animus-ui/core@0.1.1-beta.21) (2022-03-25)
28
47
 
48
+ **Note:** Version bump only for package @animus-ui/core
29
49
 
30
- ## [0.1.1-beta.3](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.2...@animus-ui/core@0.1.1-beta.3) (2022-01-09)
50
+ ## [0.1.1-beta.20](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.19...@animus-ui/core@0.1.1-beta.20) (2022-02-14)
31
51
 
32
52
  **Note:** Version bump only for package @animus-ui/core
33
53
 
54
+ ## [0.1.1-beta.19](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.18...@animus-ui/core@0.1.1-beta.19) (2022-02-14)
34
55
 
56
+ **Note:** Version bump only for package @animus-ui/core
35
57
 
58
+ ## [0.1.1-beta.18](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.17...@animus-ui/core@0.1.1-beta.18) (2022-02-11)
36
59
 
60
+ **Note:** Version bump only for package @animus-ui/core
37
61
 
38
- ## 0.1.1-beta.2 (2022-01-09)
62
+ ## [0.1.1-beta.17](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.16...@animus-ui/core@0.1.1-beta.17) (2022-02-02)
39
63
 
64
+ **Note:** Version bump only for package @animus-ui/core
40
65
 
66
+ ## [0.1.1-beta.16](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.15...@animus-ui/core@0.1.1-beta.16) (2022-02-02)
41
67
 
42
- ## 0.1.1-beta.1 (2022-01-09)
68
+ **Note:** Version bump only for package @animus-ui/core
43
69
 
70
+ ## [0.1.1-beta.15](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.14...@animus-ui/core@0.1.1-beta.15) (2022-01-26)
44
71
 
72
+ **Note:** Version bump only for package @animus-ui/core
45
73
 
46
- ## 0.1.1-beta.0 (2022-01-09)
74
+ ## [0.1.1-beta.14](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.13...@animus-ui/core@0.1.1-beta.14) (2022-01-24)
47
75
 
48
76
  **Note:** Version bump only for package @animus-ui/core
49
77
 
78
+ ## [0.1.1-beta.13](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.12...@animus-ui/core@0.1.1-beta.13) (2022-01-24)
50
79
 
80
+ **Note:** Version bump only for package @animus-ui/core
51
81
 
82
+ ## [0.1.1-beta.12](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.11...@animus-ui/core@0.1.1-beta.12) (2022-01-24)
52
83
 
84
+ **Note:** Version bump only for package @animus-ui/core
53
85
 
54
- ## [0.1.1-beta.1](https://github.com/codecaaron/animus/compare/v0.1.1-beta.0...v0.1.1-beta.1) (2022-01-09)
86
+ ## [0.1.1-beta.11](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.10...@animus-ui/core@0.1.1-beta.11) (2022-01-24)
55
87
 
56
88
  **Note:** Version bump only for package @animus-ui/core
57
89
 
90
+ ## [0.1.1-beta.10](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.9...@animus-ui/core@0.1.1-beta.10) (2022-01-23)
91
+
92
+ **Note:** Version bump only for package @animus-ui/core
58
93
 
94
+ ## [0.1.1-beta.9](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.8...@animus-ui/core@0.1.1-beta.9) (2022-01-18)
59
95
 
96
+ **Note:** Version bump only for package @animus-ui/core
97
+
98
+ ## [0.1.1-beta.8](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.7...@animus-ui/core@0.1.1-beta.8) (2022-01-16)
99
+
100
+ **Note:** Version bump only for package @animus-ui/core
60
101
 
102
+ ## [0.1.1-beta.7](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.6...@animus-ui/core@0.1.1-beta.7) (2022-01-16)
103
+
104
+ **Note:** Version bump only for package @animus-ui/core
105
+
106
+ ## [0.1.1-beta.6](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.5...@animus-ui/core@0.1.1-beta.6) (2022-01-11)
107
+
108
+ **Note:** Version bump only for package @animus-ui/core
109
+
110
+ ## [0.1.1-beta.5](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.4...@animus-ui/core@0.1.1-beta.5) (2022-01-09)
111
+
112
+ **Note:** Version bump only for package @animus-ui/core
113
+
114
+ ## [0.1.1-beta.4](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.3...@animus-ui/core@0.1.1-beta.4) (2022-01-09)
115
+
116
+ **Note:** Version bump only for package @animus-ui/core
117
+
118
+ ## [0.1.1-beta.3](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.2...@animus-ui/core@0.1.1-beta.3) (2022-01-09)
119
+
120
+ **Note:** Version bump only for package @animus-ui/core
121
+
122
+ ## 0.1.1-beta.2 (2022-01-09)
123
+
124
+ ## 0.1.1-beta.1 (2022-01-09)
125
+
126
+ ## 0.1.1-beta.0 (2022-01-09)
127
+
128
+ **Note:** Version bump only for package @animus-ui/core
129
+
130
+ ## [0.1.1-beta.1](https://github.com/codecaaron/animus/compare/v0.1.1-beta.0...v0.1.1-beta.1) (2022-01-09)
131
+
132
+ **Note:** Version bump only for package @animus-ui/core
61
133
 
62
134
  ## 0.1.1-beta.0 (2022-01-09)
63
135