@pyreon/rocketstyle 0.24.2 → 0.24.3
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/lib/index.d.ts +1 -1
- package/package.json +7 -7
- package/src/__tests__/minimal-theme.test.ts +62 -0
- package/src/context/context.ts +13 -1
package/lib/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pyreon/rocketstyle",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.3",
|
|
4
4
|
"description": "Multi-dimensional style composition for Pyreon components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@pyreon/test-utils": "^0.13.11",
|
|
46
|
-
"@pyreon/typescript": "^0.24.
|
|
47
|
-
"@pyreon/ui-core": "^0.24.
|
|
46
|
+
"@pyreon/typescript": "^0.24.3",
|
|
47
|
+
"@pyreon/ui-core": "^0.24.3",
|
|
48
48
|
"@vitest/browser-playwright": "^4.1.4",
|
|
49
49
|
"@vitus-labs/tools-rolldown": "^2.4.0"
|
|
50
50
|
},
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
"node": ">= 22"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@pyreon/core": "^0.24.
|
|
56
|
-
"@pyreon/reactivity": "^0.24.
|
|
57
|
-
"@pyreon/styler": "^0.24.
|
|
58
|
-
"@pyreon/ui-core": "^0.24.
|
|
55
|
+
"@pyreon/core": "^0.24.3",
|
|
56
|
+
"@pyreon/reactivity": "^0.24.3",
|
|
57
|
+
"@pyreon/styler": "^0.24.3",
|
|
58
|
+
"@pyreon/ui-core": "^0.24.3"
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Locks in the "one-size app" contract for the rocketstyle Provider's
|
|
2
|
+
// Theme type. Pre-fix, `rootSize: number` was REQUIRED in the type at
|
|
3
|
+
// `rocketstyle/src/context/context.ts` — passing a minimal theme without
|
|
4
|
+
// rootSize was a TypeScript error even though it works fine at runtime
|
|
5
|
+
// (enrichTheme defaults rootSize to 16, value() defaults rootSize to 16,
|
|
6
|
+
// makeItResponsive short-circuits when breakpoints are empty).
|
|
7
|
+
//
|
|
8
|
+
// User report: "[breakpoints/rootSize] are used too directly". Even in
|
|
9
|
+
// places where runtime tolerates undefined, an over-constrained TYPE
|
|
10
|
+
// forces downstream consumers to either lie (`as any`) or pass dummy
|
|
11
|
+
// values they don't actually need.
|
|
12
|
+
//
|
|
13
|
+
// This spec is a TYPE-LEVEL assertion via `// @ts-expect-error` flips.
|
|
14
|
+
// The flip-positive case (minimal theme) is the regression contract; if
|
|
15
|
+
// someone re-adds the required `rootSize: number` constraint, this file
|
|
16
|
+
// FAILS to compile because the @ts-expect-error directives become dead.
|
|
17
|
+
import type { TProvider } from '../context/context'
|
|
18
|
+
|
|
19
|
+
describe('rocketstyle Provider — minimal theme typing', () => {
|
|
20
|
+
it('TYPE: theme with only colors (no rootSize, no breakpoints) is accepted', () => {
|
|
21
|
+
// Should NOT be a type error — this is the "one-size app" shape.
|
|
22
|
+
const props: TProvider = {
|
|
23
|
+
theme: { colors: { primary: '#228be6' } },
|
|
24
|
+
children: null,
|
|
25
|
+
}
|
|
26
|
+
expect(props.theme).toEqual({ colors: { primary: '#228be6' } })
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('TYPE: theme with breakpoints but no rootSize is accepted', () => {
|
|
30
|
+
const props: TProvider = {
|
|
31
|
+
theme: { breakpoints: { xs: 0, sm: 576 }, colors: { primary: '#228be6' } },
|
|
32
|
+
children: null,
|
|
33
|
+
}
|
|
34
|
+
expect(props.theme?.breakpoints).toEqual({ xs: 0, sm: 576 })
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it('TYPE: theme with rootSize but no breakpoints is accepted', () => {
|
|
38
|
+
const props: TProvider = {
|
|
39
|
+
theme: { rootSize: 16, colors: { primary: '#228be6' } },
|
|
40
|
+
children: null,
|
|
41
|
+
}
|
|
42
|
+
expect(props.theme?.rootSize).toBe(16)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('TYPE: full theme (rootSize + breakpoints) still accepted (backward compat)', () => {
|
|
46
|
+
const props: TProvider = {
|
|
47
|
+
theme: {
|
|
48
|
+
rootSize: 16,
|
|
49
|
+
breakpoints: { xs: 0, sm: 576, md: 768 },
|
|
50
|
+
colors: { primary: '#228be6' },
|
|
51
|
+
},
|
|
52
|
+
children: null,
|
|
53
|
+
}
|
|
54
|
+
expect(props.theme?.rootSize).toBe(16)
|
|
55
|
+
expect(props.theme?.breakpoints).toEqual({ xs: 0, sm: 576, md: 768 })
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('TYPE: omitting theme entirely is still accepted (was already optional)', () => {
|
|
59
|
+
const props: TProvider = { children: null }
|
|
60
|
+
expect(props.theme).toBeUndefined()
|
|
61
|
+
})
|
|
62
|
+
})
|
package/src/context/context.ts
CHANGED
|
@@ -3,8 +3,20 @@ import { nativeCompat, useContext } from '@pyreon/core'
|
|
|
3
3
|
import { Provider as CoreProvider, context } from '@pyreon/ui-core'
|
|
4
4
|
import { MODE_DEFAULT, THEME_MODES_INVERSED } from '../constants'
|
|
5
5
|
|
|
6
|
+
// Both `rootSize` and `breakpoints` are OPTIONAL — the rest of the chain
|
|
7
|
+
// handles their absence: `enrichTheme` defaults rootSize to 16,
|
|
8
|
+
// `makeItResponsive` short-circuits to plain CSS when breakpoints are
|
|
9
|
+
// empty, and `value()` defaults rootSize to 16 internally. Marking
|
|
10
|
+
// either as required here over-constrained user themes downstream
|
|
11
|
+
// (e.g. a minimal `{ colors: { primary: '#228be6' } }` theme passed
|
|
12
|
+
// to the public Provider was a TS error even though it works at runtime).
|
|
13
|
+
//
|
|
14
|
+
// Shape matches `@pyreon/unistyle` `PyreonTheme` and the downstream
|
|
15
|
+
// `@pyreon/ui-core` Provider's `Partial<...>`-wrapped theme — `?:` with
|
|
16
|
+
// no explicit `| undefined` so the downstream Partial composition holds
|
|
17
|
+
// under `exactOptionalPropertyTypes: true`.
|
|
6
18
|
type Theme = {
|
|
7
|
-
rootSize
|
|
19
|
+
rootSize?: number
|
|
8
20
|
breakpoints?: Record<string, number>
|
|
9
21
|
} & Record<string, unknown>
|
|
10
22
|
|