@pyreon/rocketstyle 0.24.5 → 0.24.6

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 (60) hide show
  1. package/package.json +8 -10
  2. package/src/__tests__/attrs-overloads.test.ts +0 -97
  3. package/src/__tests__/attrs.test.ts +0 -190
  4. package/src/__tests__/cache-key-boolean-collision.test.ts +0 -54
  5. package/src/__tests__/chaining.test.ts +0 -86
  6. package/src/__tests__/collection.test.ts +0 -35
  7. package/src/__tests__/compose.test.ts +0 -36
  8. package/src/__tests__/context.test.ts +0 -200
  9. package/src/__tests__/createLocalProvider.test.ts +0 -280
  10. package/src/__tests__/dimensions.test.ts +0 -183
  11. package/src/__tests__/e2e-styler.test.ts +0 -299
  12. package/src/__tests__/hooks.test.ts +0 -178
  13. package/src/__tests__/isRocketComponent.test.ts +0 -48
  14. package/src/__tests__/memo-cap.test.ts +0 -174
  15. package/src/__tests__/minimal-theme.test.ts +0 -62
  16. package/src/__tests__/misc.test.ts +0 -204
  17. package/src/__tests__/native-marker.test.ts +0 -9
  18. package/src/__tests__/providerConsumer.test.ts +0 -183
  19. package/src/__tests__/reactive-props-preservation.test.ts +0 -195
  20. package/src/__tests__/rocketstyle.browser.test.tsx +0 -481
  21. package/src/__tests__/rocketstyleIntegration.test.ts +0 -711
  22. package/src/__tests__/theme-integration.test.tsx +0 -254
  23. package/src/__tests__/themeUtils.test.ts +0 -463
  24. package/src/cache/LocalThemeManager.ts +0 -14
  25. package/src/cache/index.ts +0 -3
  26. package/src/constants/booleanTags.ts +0 -32
  27. package/src/constants/defaultDimensions.ts +0 -23
  28. package/src/constants/index.ts +0 -59
  29. package/src/context/context.ts +0 -70
  30. package/src/context/createLocalProvider.ts +0 -97
  31. package/src/context/localContext.ts +0 -37
  32. package/src/env.d.ts +0 -6
  33. package/src/hoc/index.ts +0 -3
  34. package/src/hoc/rocketstyleAttrsHoc.ts +0 -76
  35. package/src/hooks/index.ts +0 -4
  36. package/src/hooks/usePseudoState.ts +0 -79
  37. package/src/hooks/useTheme.ts +0 -48
  38. package/src/index.ts +0 -95
  39. package/src/init.ts +0 -93
  40. package/src/isRocketComponent.ts +0 -16
  41. package/src/rocketstyle.ts +0 -640
  42. package/src/types/attrs.ts +0 -23
  43. package/src/types/config.ts +0 -48
  44. package/src/types/configuration.ts +0 -69
  45. package/src/types/dimensions.ts +0 -109
  46. package/src/types/hoc.ts +0 -5
  47. package/src/types/pseudo.ts +0 -19
  48. package/src/types/rocketComponent.ts +0 -24
  49. package/src/types/rocketstyle.ts +0 -220
  50. package/src/types/styles.ts +0 -61
  51. package/src/types/theme.ts +0 -18
  52. package/src/types/utils.ts +0 -98
  53. package/src/utils/attrs.ts +0 -181
  54. package/src/utils/chaining.ts +0 -58
  55. package/src/utils/collection.ts +0 -9
  56. package/src/utils/compose.ts +0 -11
  57. package/src/utils/dimensions.ts +0 -126
  58. package/src/utils/statics.ts +0 -44
  59. package/src/utils/styles.ts +0 -18
  60. package/src/utils/theme.ts +0 -211
@@ -1,254 +0,0 @@
1
- /**
2
- * Theme + Rocketstyle integration tests.
3
- *
4
- * Tests mode switching, reactive dimension props, and dimension CSS computation
5
- * through the rocketstyle pipeline using test-utils helpers.
6
- */
7
- import {
8
- ThemeCapture,
9
- getComputedTheme,
10
- initTestConfig,
11
- withThemeContext,
12
- } from '@pyreon/test-utils'
13
- import rocketstyle from '../init'
14
- import { getThemeByMode, themeModeCallback } from '../utils/theme'
15
-
16
- let cleanup: () => void
17
- beforeAll(() => {
18
- cleanup = initTestConfig()
19
- })
20
- afterAll(() => cleanup())
21
-
22
- /**
23
- * Base component that filters internal props and returns a VNode-like object.
24
- */
25
- const BaseComponent: any = ({ children, $rocketstyle, $rocketstate, ...rest }: any) => ({
26
- type: 'div',
27
- props: rest,
28
- children,
29
- key: null,
30
- $rocketstyle: typeof $rocketstyle === 'function' ? $rocketstyle() : $rocketstyle,
31
- $rocketstate: typeof $rocketstate === 'function' ? $rocketstate() : $rocketstate,
32
- })
33
- BaseComponent.displayName = 'BaseComponent'
34
-
35
- // ─── theme integration — mode switching ───────────────────────────────────────
36
-
37
- describe('theme integration — mode switching', () => {
38
- it('rocketstyle component with m(light, dark) resolves light value by default', () => {
39
- const Comp: any = rocketstyle()({
40
- name: 'ModeSwitchComp',
41
- component: ThemeCapture,
42
- }).theme((_t: any, m: any) => ({
43
- color: m('light-blue', 'dark-blue'),
44
- backgroundColor: m('#fff', '#111'),
45
- }))
46
-
47
- const theme = getComputedTheme(Comp, {}, { mode: 'light' })
48
- expect(theme.color).toBe('light-blue')
49
- expect(theme.backgroundColor).toBe('#fff')
50
- })
51
-
52
- it('switching to dark mode resolves dark values', () => {
53
- const Comp: any = rocketstyle()({
54
- name: 'DarkModeComp',
55
- component: ThemeCapture,
56
- }).theme((_t: any, m: any) => ({
57
- color: m('light-text', 'dark-text'),
58
- backgroundColor: m('white', 'black'),
59
- }))
60
-
61
- const lightTheme = getComputedTheme(Comp, {}, { mode: 'light' })
62
- expect(lightTheme.color).toBe('light-text')
63
- expect(lightTheme.backgroundColor).toBe('white')
64
-
65
- const darkTheme = getComputedTheme(Comp, {}, { mode: 'dark' })
66
- expect(darkTheme.color).toBe('dark-text')
67
- expect(darkTheme.backgroundColor).toBe('black')
68
- })
69
-
70
- it('getThemeByMode resolves mode callbacks in nested objects', () => {
71
- const cb = themeModeCallback('#f0f0f0', '#1a1a1a')
72
- const result: any = getThemeByMode(
73
- { surface: { bg: cb, border: '1px solid' } },
74
- 'dark',
75
- )
76
- expect(result.surface.bg).toBe('#1a1a1a')
77
- expect(result.surface.border).toBe('1px solid')
78
- })
79
-
80
- it('dimension theme with mode callback resolves per mode', () => {
81
- const Comp: any = rocketstyle()({
82
- name: 'DimModeComp',
83
- component: ThemeCapture,
84
- })
85
- .theme((_t: any, m: any) => ({
86
- color: m('black', 'white'),
87
- }))
88
- .states((_t: any, m: any) => ({
89
- primary: {
90
- backgroundColor: m('blue', 'navy'),
91
- },
92
- }))
93
-
94
- const lightTheme = getComputedTheme(Comp, { state: 'primary' }, { mode: 'light' })
95
- expect(lightTheme.color).toBe('black')
96
- expect(lightTheme.backgroundColor).toBe('blue')
97
-
98
- const darkTheme = getComputedTheme(Comp, { state: 'primary' }, { mode: 'dark' })
99
- expect(darkTheme.color).toBe('white')
100
- expect(darkTheme.backgroundColor).toBe('navy')
101
- })
102
- })
103
-
104
- // ─── theme integration — pseudo props reactive ───────────────────────────────
105
-
106
- describe('theme integration — pseudo props reactive', () => {
107
- it('different state values produce different computed themes', () => {
108
- const Comp: any = rocketstyle()({
109
- name: 'PseudoComp',
110
- component: ThemeCapture,
111
- })
112
- .theme({ color: 'default-color', bg: 'default-bg' })
113
- .states({
114
- active: { color: 'active-color' },
115
- disabled: { color: 'disabled-color', bg: 'disabled-bg' },
116
- })
117
-
118
- const defaultTheme = getComputedTheme(Comp)
119
- expect(defaultTheme.color).toBe('default-color')
120
- expect(defaultTheme.bg).toBe('default-bg')
121
-
122
- const activeTheme = getComputedTheme(Comp, { state: 'active' })
123
- expect(activeTheme.color).toBe('active-color')
124
- expect(activeTheme.bg).toBe('default-bg')
125
-
126
- const disabledTheme = getComputedTheme(Comp, { state: 'disabled' })
127
- expect(disabledTheme.color).toBe('disabled-color')
128
- expect(disabledTheme.bg).toBe('disabled-bg')
129
- })
130
-
131
- it('boolean dimension prop resolves to the matching state theme', () => {
132
- const Comp: any = rocketstyle({ useBooleans: true })({
133
- name: 'BoolPseudoComp',
134
- component: ThemeCapture,
135
- })
136
- .theme({ color: 'black' })
137
- .states({
138
- primary: { color: 'blue' },
139
- secondary: { color: 'green' },
140
- })
141
-
142
- // boolean shorthand: `primary={true}` → state='primary' (requires useBooleans: true)
143
- const theme = getComputedTheme(Comp, { primary: true })
144
- expect(theme.color).toBe('blue')
145
- })
146
-
147
- it('$rocketstate tracks active dimension values', () => {
148
- const Comp: any = rocketstyle()({
149
- name: 'StateTrackComp',
150
- component: ThemeCapture,
151
- }).states({
152
- primary: { color: 'blue' },
153
- secondary: { color: 'green' },
154
- })
155
-
156
- const vnode1 = withThemeContext(() => Comp({ state: 'primary' }))
157
- expect(vnode1.$rocketstate.state).toBe('primary')
158
-
159
- const vnode2 = withThemeContext(() => Comp({ state: 'secondary' }))
160
- expect(vnode2.$rocketstate.state).toBe('secondary')
161
- })
162
- })
163
-
164
- // ─── theme integration — dimension props ──────────────────────────────────────
165
-
166
- describe('theme integration — dimension props', () => {
167
- it('state="primary" applies correct dimension CSS', () => {
168
- const Comp: any = rocketstyle()({
169
- name: 'DimPrimaryComp',
170
- component: ThemeCapture,
171
- })
172
- .theme({ color: 'default', fontSize: 14 })
173
- .states({
174
- primary: { color: 'primary-blue', fontWeight: 'bold' },
175
- danger: { color: 'danger-red' },
176
- })
177
-
178
- const theme = getComputedTheme(Comp, { state: 'primary' })
179
- expect(theme.color).toBe('primary-blue')
180
- expect(theme.fontWeight).toBe('bold')
181
- expect(theme.fontSize).toBe(14) // inherited from base theme
182
- })
183
-
184
- it('changing state prop produces different computed theme', () => {
185
- const Comp: any = rocketstyle()({
186
- name: 'ChangeDimComp',
187
- component: ThemeCapture,
188
- })
189
- .theme({ color: 'black' })
190
- .states({
191
- primary: { color: 'blue' },
192
- danger: { color: 'red' },
193
- })
194
-
195
- const primaryTheme = getComputedTheme(Comp, { state: 'primary' })
196
- expect(primaryTheme.color).toBe('blue')
197
-
198
- const dangerTheme = getComputedTheme(Comp, { state: 'danger' })
199
- expect(dangerTheme.color).toBe('red')
200
- })
201
-
202
- it('multiple dimensions combine correctly', () => {
203
- const Comp: any = rocketstyle()({
204
- name: 'MultiDimIntComp',
205
- component: ThemeCapture,
206
- })
207
- .theme({ color: 'black', fontSize: 14, padding: 4 })
208
- .states({ primary: { color: 'blue' } })
209
- .sizes({ large: { fontSize: 20, padding: 12 } })
210
-
211
- const theme = getComputedTheme(Comp, {
212
- state: 'primary',
213
- size: 'large',
214
- })
215
- expect(theme.color).toBe('blue')
216
- expect(theme.fontSize).toBe(20)
217
- expect(theme.padding).toBe(12)
218
- })
219
-
220
- it('modifier transform derives from accumulated dimension themes', () => {
221
- const Comp: any = rocketstyle()({
222
- name: 'ModTransformComp',
223
- component: ThemeCapture,
224
- })
225
- .theme({ backgroundColor: '#0070f3', color: '#fff' })
226
- .states({ danger: { backgroundColor: '#dc3545' } })
227
- .modifiers({
228
- outlined: (acc: any) => ({
229
- color: acc.backgroundColor,
230
- backgroundColor: 'transparent',
231
- }),
232
- })
233
-
234
- const theme = getComputedTheme(Comp, {
235
- state: 'danger',
236
- modifier: 'outlined',
237
- })
238
- expect(theme.color).toBe('#dc3545')
239
- expect(theme.backgroundColor).toBe('transparent')
240
- })
241
-
242
- it('no dimension props returns base theme only', () => {
243
- const Comp: any = rocketstyle()({
244
- name: 'BaseOnlyComp',
245
- component: ThemeCapture,
246
- })
247
- .theme({ color: 'base-color', bg: 'base-bg' })
248
- .states({ primary: { color: 'blue' } })
249
-
250
- const theme = getComputedTheme(Comp)
251
- expect(theme.color).toBe('base-color')
252
- expect(theme.bg).toBe('base-bg')
253
- })
254
- })