@plumeria/core 16.5.0 → 17.0.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.
package/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
 
12
12
  ## Installation
13
13
 
14
- `@plumeria/core` contains type definitions only importing it augments React's JSX types so that styleName is accepted on host elements. Styles are compiled away at build time by a bundler integration — [`@plumeria/next-plugin`](https://www.npmjs.com/package/@plumeria/next-plugin) for Next.js, or [`@plumeria/unplugin`](https://www.npmjs.com/package/@plumeria/unplugin) for Vite, Webpack, and others.
14
+ `@plumeria/core` contains type definitions only. Which JSX prop carries styles is declared in your project — one line for the default `styleName`, see [Declaring the styling prop](#declaring-the-styling-prop). Styles are compiled away at build time by a bundler integration — [`@plumeria/next-plugin`](https://www.npmjs.com/package/@plumeria/next-plugin) for Next.js, or [`@plumeria/unplugin`](https://www.npmjs.com/package/@plumeria/unplugin) for Vite, Webpack, and others.
15
15
 
16
16
  ```sh
17
17
  pnpm add -D @plumeria/core
@@ -75,6 +75,41 @@ export default function App({ cond }) {
75
75
  }
76
76
  ```
77
77
 
78
+ ## Declaring the styling prop
79
+
80
+ The prop name is a build-time setting — `styleProp` on the bundler plugin — so `@plumeria/core` declares no prop of its own. Baking one in would let the types and the compiler disagree. Add one file to your project naming the prop you compile with.
81
+
82
+ For the default, `styleName`, reference the declaration that ships with the package:
83
+
84
+ ```ts
85
+ // plumeria.d.ts
86
+ /// <reference types="@plumeria/core/style-name" />
87
+ ```
88
+
89
+ If you renamed the prop, declare that name on React's attribute interfaces instead. `Style` is the type of anything the prop accepts — a style, a conditional, or an array of them:
90
+
91
+ ```ts
92
+ // plumeria.d.ts
93
+ import type { Style } from '@plumeria/core';
94
+
95
+ declare global {
96
+ namespace React {
97
+ interface HTMLAttributes<T> {
98
+ sx?: Style
99
+ }
100
+ interface SVGAttributes<T> {
101
+ sx?: Style
102
+ }
103
+ }
104
+ }
105
+ ```
106
+
107
+ ```tsx
108
+ <div sx={[styles.text, cond && styles.cond]} />
109
+ ```
110
+
111
+ Declaration merging is additive, so several names can coexist during a migration. Whichever you declare has to match what the bundler plugin was given — if they disagree the prop type-checks but is never compiled away.
112
+
78
113
  Explore the [documentation](https://plumeria.dev/) for the core principles, full API reference, and integrations.
79
114
 
80
115
  ## License
package/lib/css.d.ts CHANGED
@@ -9,13 +9,13 @@
9
9
  * type viewTransition = <const T extends ViewTransition>(rule: T) => string;
10
10
  * type marker = (id: string, pseudo: string) => Marker;
11
11
  * type extended = <I extends string, P extends string>(id: I, pseudo: P) => Extended<I, P>;
12
- * type use = (...rules: StyleName[]) => string;
12
+ * type use = (...rules: Style) => string;
13
13
  * ```
14
14
  */
15
15
  declare module '@plumeria/core' {
16
16
  import type {
17
17
  AtomicClassNameFor,
18
- StyleName,
18
+ Style,
19
19
  CSSProperties,
20
20
  CreateStyleValue,
21
21
  CreateReturnType,
@@ -29,18 +29,7 @@ declare module '@plumeria/core' {
29
29
  Extended,
30
30
  } from '#types';
31
31
 
32
- global {
33
- namespace React {
34
- interface HTMLAttributes<T> {
35
- styleName?: StyleName;
36
- }
37
- interface SVGAttributes<T> {
38
- styleName?: StyleName;
39
- }
40
- }
41
- }
42
-
43
- export type { AtomicClassNameFor, StyleName, CSSProperties };
32
+ export type { AtomicClassNameFor, Style, CSSProperties };
44
33
 
45
34
  export const create: create;
46
35
  export type create = <const T extends Record<string, CreateStyleValue>>(
@@ -74,5 +63,5 @@ declare module '@plumeria/core' {
74
63
  ) => Extended<I, P>;
75
64
 
76
65
  export const use: use;
77
- export type use = (...rules: StyleName) => string;
66
+ export type use = (...rules: Style) => string;
78
67
  }
package/lib/csstypes.d.ts CHANGED
@@ -295,7 +295,16 @@ type columns = columnWidth | columnCount;
295
295
  type columnSpan = 'none' | 'all';
296
296
  type columnWidth = 'auto' | number | StableString;
297
297
  type compositeOperator = 'add' | 'subtract' | 'intersect' | 'exclude';
298
- type contain = 'none' | 'strict' | 'content' | StableString;
298
+ type contain =
299
+ | 'none'
300
+ | 'strict'
301
+ | 'content'
302
+ | 'size'
303
+ | 'inline-size'
304
+ | 'layout'
305
+ | 'style'
306
+ | 'paint'
307
+ | StableString;
299
308
  type container = number | StableString;
300
309
  type containerName = number | StableString;
301
310
  type containerType = 'size' | 'inline-size' | 'normal';
@@ -0,0 +1,12 @@
1
+ import type { Style } from '#types';
2
+
3
+ global {
4
+ namespace React {
5
+ interface HTMLAttributes<T> {
6
+ styleName?: Style;
7
+ }
8
+ interface SVGAttributes<T> {
9
+ styleName?: Style;
10
+ }
11
+ }
12
+ }
package/lib/types.d.ts CHANGED
@@ -73,7 +73,7 @@ type CreateReturnType<T> = Readonly<{
73
73
  : MapNamespace<T[K]>;
74
74
  }>;
75
75
  type Conditional = false | CSSProperties | null | undefined;
76
- type StyleName = Conditional | StyleName[];
76
+ type Style = Conditional | Style[];
77
77
 
78
78
  type CreateStatic = Record<string, string | number>;
79
79
 
@@ -110,7 +110,7 @@ type Extended<
110
110
 
111
111
  export type {
112
112
  AtomicClassNameFor,
113
- StyleName,
113
+ Style,
114
114
  CSSProperties,
115
115
  CreateStyleValue,
116
116
  CreateReturnType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/core",
3
- "version": "16.5.0",
3
+ "version": "17.0.1",
4
4
  "description": "Zero-cost abstraction layer for styling React components.",
5
5
  "author": "Refirst 11",
6
6
  "license": "MIT",
@@ -27,6 +27,9 @@
27
27
  "exports": {
28
28
  ".": {
29
29
  "types": "./lib/css.d.ts"
30
+ },
31
+ "./style-name": {
32
+ "types": "./lib/style-name.d.ts"
30
33
  }
31
34
  },
32
35
  "types": "./lib/css.d.ts",