Skip to content

Commit 50f4146

Browse files
committed
update JSX types, styled components as
1 parent 0a6fe48 commit 50f4146

5 files changed

Lines changed: 42 additions & 30 deletions

File tree

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@
3333
"babel-jest": "^26.3.0",
3434
"babel-plugin-jsx-dom-expressions": "~0.20.8",
3535
"coveralls": "^3.1.0",
36-
"dom-expressions": "0.20.8",
37-
"hyper-dom-expressions": "0.20.8",
36+
"dom-expressions": "0.20.10",
37+
"hyper-dom-expressions": "0.20.10",
3838
"jest": "~26.4.2",
3939
"jest-ts-webcompat-resolver": "^1.0.0",
4040
"lerna": "^3.22.1",
41-
"lit-dom-expressions": "0.20.8",
41+
"lit-dom-expressions": "0.20.10",
4242
"ncp": "2.0.0",
4343
"npm-run-all": "^4.1.5",
4444
"rimraf": "^3.0.2",

packages/solid-styled-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"test:types": "tsc --project tsconfig.test.json"
2424
},
2525
"dependencies": {
26-
"csstype": "^2.6.2",
26+
"csstype": "^3.0.3",
2727
"goober": "1.8.0"
2828
},
2929
"peerDependencies": {

packages/solid-styled-components/src/index.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { css, CSSAttribute } from "goober";
2-
import { assignProps, createContext, useContext } from "solid-js";
2+
import { assignProps, splitProps, createContext, useContext } from "solid-js";
33
import { spread, createComponent } from "solid-js/dom";
44

55
export { css, glob, extractCss } from "goober";
@@ -25,34 +25,33 @@ type StyledTemplateArgs<T> = [
2525
];
2626

2727
export function styled<T extends keyof JSX.IntrinsicElements>(tag: T | ((props: any) => any)) {
28-
return <P>(...args: StyledTemplateArgs<P & { theme?: any; className?: any }>) => {
28+
return <P>(...args: StyledTemplateArgs<P & { theme?: any; as?: keyof JSX.IntrinsicElements; className?: any }>) => {
2929
return (
30-
props: P & JSX.IntrinsicElements[T] & { theme?: any; className?: any }
30+
props: P & JSX.IntrinsicElements[T] & { theme?: any; as?: keyof JSX.IntrinsicElements; className?: any }
3131
): JSX.Element => {
32-
const newProps = assignProps({}, props);
33-
props.theme = useContext(ThemeContext);
34-
Object.defineProperty(newProps, "className", {
35-
get() {
32+
const clone = assignProps({}, props, {
33+
theme: useContext(ThemeContext),
34+
get className(): string {
3635
const pClassName = props.className,
3736
append = "className" in props && /^go[0-9]+/.test(pClassName!);
3837

3938
// Call `css` with the append flag and pass the props
4039
let className = css.apply(
41-
{ target: this.target, o: append, p: props },
40+
{ target: (this as any).target, o: append, p: newProps },
4241
args as [any, ...any[]]
4342
);
4443

4544
return [pClassName, className].filter(Boolean).join(" ");
46-
},
47-
configurable: true,
48-
enumerable: true
45+
}
4946
});
47+
const [local, newProps] = splitProps(clone, ["as"]);
48+
const createTag = local.as || tag;
5049

5150
let el;
52-
if (typeof tag === "function") {
53-
el = tag(newProps);
51+
if (typeof createTag === "function") {
52+
el = createTag(newProps);
5453
} else {
55-
el = document.createElement(tag);
54+
el = document.createElement(createTag as any);
5655
spread(el, newProps);
5756
}
5857

packages/solid/src/rendering/jsx.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ declare global {
77
*/
88

99
namespace JSX {
10-
type Element = Node | ArrayElement | FunctionElement | string | number | boolean | null | undefined;
10+
type Element =
11+
| Node
12+
| ArrayElement
13+
| FunctionElement
14+
| string
15+
| number
16+
| boolean
17+
| null
18+
| undefined;
1119

1220
interface ArrayElement extends Array<Element> {}
1321
interface FunctionElement {
@@ -1949,6 +1957,11 @@ declare global {
19491957
itemType?: string;
19501958
itemId?: string;
19511959
itemRef?: string;
1960+
1961+
// others
1962+
align?: "start" | "end" | "center" | "baseline" | "stretch" | "left" | "right";
1963+
part?: string;
1964+
exportparts?: string;
19521965
}
19531966

19541967
// HTML Elements
@@ -2719,7 +2732,7 @@ declare global {
27192732
AnimationAdditionSVGAttributes {
27202733
path?: string;
27212734
keyPoints?: string;
2722-
rotate?: number | string |"auto" | "auto-reverse";
2735+
rotate?: number | string | "auto" | "auto-reverse";
27232736
origin?: "default";
27242737
}
27252738

@@ -3409,4 +3422,4 @@ declare global {
34093422
}
34103423
}
34113424

3412-
export {};
3425+
export {};

0 commit comments

Comments
 (0)