@plumeria/react 0.0.0-stage → 22.2.5
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/LICENSE +21 -0
- package/lib/styled.d.ts +116 -0
- package/package.json +40 -3
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) zss-labs contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/lib/styled.d.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions. Without runtime implementation.
|
|
3
|
+
* Bundler plugin required.
|
|
4
|
+
* ```ts
|
|
5
|
+
* type styled = { [T in keyof JSX.IntrinsicElements]: <const R>(rule: R) => StyledComponent<T, R> };
|
|
6
|
+
* ```
|
|
7
|
+
*/
|
|
8
|
+
import type {
|
|
9
|
+
ComponentPropsWithRef,
|
|
10
|
+
JSX,
|
|
11
|
+
JSXElementConstructor,
|
|
12
|
+
ReactElement,
|
|
13
|
+
} from 'react';
|
|
14
|
+
import type {
|
|
15
|
+
AtomicClassNameFor,
|
|
16
|
+
AtomicStyle,
|
|
17
|
+
CSSProperties,
|
|
18
|
+
Style,
|
|
19
|
+
} from '@plumeria/core';
|
|
20
|
+
|
|
21
|
+
type NestedKey = `:${string}` | `[${string}` | `@${string}`;
|
|
22
|
+
|
|
23
|
+
type Dynamic<T, P> = {
|
|
24
|
+
[K in keyof T]: K extends NestedKey
|
|
25
|
+
? Dynamic<T[K], P>
|
|
26
|
+
: T[K] | ((props: P) => T[K]);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type StyledRule<P> = Dynamic<CSSProperties, P>;
|
|
30
|
+
|
|
31
|
+
type Reads<R> =
|
|
32
|
+
R extends AtomicClassNameFor<string, infer V>
|
|
33
|
+
? Reads<V>
|
|
34
|
+
: R extends (props: infer A) => any
|
|
35
|
+
? A
|
|
36
|
+
: R extends object
|
|
37
|
+
? { [K in keyof R]: Reads<R[K]> }[keyof R]
|
|
38
|
+
: never;
|
|
39
|
+
|
|
40
|
+
type Intersect<U> = (U extends any ? (x: U) => void : never) extends (
|
|
41
|
+
x: infer I,
|
|
42
|
+
) => void
|
|
43
|
+
? I
|
|
44
|
+
: never;
|
|
45
|
+
|
|
46
|
+
export type StyledPropsOf<R> = [Reads<R>] extends [never]
|
|
47
|
+
? {}
|
|
48
|
+
: Intersect<Reads<R>>;
|
|
49
|
+
|
|
50
|
+
export interface JSXRegister {}
|
|
51
|
+
|
|
52
|
+
type Framework = JSXRegister extends {
|
|
53
|
+
IntrinsicElements: infer I;
|
|
54
|
+
Element: infer E;
|
|
55
|
+
}
|
|
56
|
+
? { intrinsic: I; element: E; useReactProps: false }
|
|
57
|
+
: {
|
|
58
|
+
intrinsic: JSX.IntrinsicElements;
|
|
59
|
+
element: ReactElement;
|
|
60
|
+
useReactProps: true;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
type Intrinsic = Framework['intrinsic'];
|
|
64
|
+
|
|
65
|
+
export type StyledTarget =
|
|
66
|
+
| keyof Intrinsic
|
|
67
|
+
| (Framework['useReactProps'] extends true
|
|
68
|
+
? JSXElementConstructor<any>
|
|
69
|
+
: (props: any) => any);
|
|
70
|
+
|
|
71
|
+
type PropsOf<T> = Framework['useReactProps'] extends true
|
|
72
|
+
? T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>
|
|
73
|
+
? ComponentPropsWithRef<T>
|
|
74
|
+
: never
|
|
75
|
+
: T extends keyof Intrinsic
|
|
76
|
+
? Intrinsic[T]
|
|
77
|
+
: T extends (props: infer P) => any
|
|
78
|
+
? P
|
|
79
|
+
: never;
|
|
80
|
+
|
|
81
|
+
type Known<T> = {
|
|
82
|
+
[K in keyof T as string extends K ? never : K]: T[K];
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export type StyledProps<T extends StyledTarget, P> = P &
|
|
86
|
+
Omit<
|
|
87
|
+
Framework['useReactProps'] extends true ? PropsOf<T> : Known<PropsOf<T>>,
|
|
88
|
+
keyof P | 'sx'
|
|
89
|
+
> & {
|
|
90
|
+
sx?: Style;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
declare const styledBrand: unique symbol;
|
|
94
|
+
|
|
95
|
+
type Branded = { readonly [styledBrand]: unknown };
|
|
96
|
+
|
|
97
|
+
export type StyledComponent<T extends StyledTarget, R> = ((
|
|
98
|
+
props: StyledProps<T, StyledPropsOf<R>>,
|
|
99
|
+
) => Framework['element']) & {
|
|
100
|
+
readonly [styledBrand]: R;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export type StyledFactory<T extends StyledTarget> = {
|
|
104
|
+
<const R extends StyledRule<never>>(
|
|
105
|
+
rule: R,
|
|
106
|
+
): StyledComponent<T, AtomicStyle<R>>;
|
|
107
|
+
new (rule: never): never;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export type styled = {
|
|
111
|
+
<C extends ((props: any) => any) & Branded>(component: C): StyledFactory<C>;
|
|
112
|
+
} & {
|
|
113
|
+
[T in keyof Intrinsic & string]: StyledFactory<T>;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const styled: styled;
|
package/package.json
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/react",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "22.2.5",
|
|
4
|
+
"description": "Styled components for Plumeria, compiled to the sx prop",
|
|
5
|
+
"author": "zss-labs",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://plumeria.dev",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/zss-labs/plumeria.git",
|
|
11
|
+
"directory": "packages/react"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/zss-labs/plumeria/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"plumeria",
|
|
18
|
+
"react",
|
|
19
|
+
"styled",
|
|
20
|
+
"css-in-js",
|
|
21
|
+
"atomic-css",
|
|
22
|
+
"zero-runtime",
|
|
23
|
+
"type-safe",
|
|
24
|
+
"typescript"
|
|
25
|
+
],
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./lib/styled.d.ts"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"types": "./lib/styled.d.ts",
|
|
32
|
+
"files": [
|
|
33
|
+
"lib/"
|
|
34
|
+
],
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/react": "^19.3.0",
|
|
37
|
+
"@plumeria/core": "22.3.0"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public",
|
|
41
|
+
"provenance": true
|
|
42
|
+
}
|
|
6
43
|
}
|
package/README.md
DELETED