@vsreact/core 0.0.22 → 0.0.24
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/dist/hostConfig.js +2 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/primitives.d.ts +24 -0
- package/dist/primitives.js +9 -0
- package/dist/tw.js +15 -0
- package/package.json +1 -1
- package/src/hostConfig.ts +2 -0
- package/src/index.ts +4 -2
- package/src/layout.test.tsx +23 -0
- package/src/primitives.tsx +34 -0
- package/src/tw.test.ts +9 -0
- package/src/tw.ts +15 -0
package/dist/hostConfig.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "./runtime";
|
|
2
2
|
import "./bridge";
|
|
3
3
|
/** The SDK version — stamp it on support dumps and analytics. */
|
|
4
|
-
export declare const VERSION = "0.0.
|
|
5
|
-
export { View, Text, Image, TextInput, NativeView } from "./primitives";
|
|
6
|
-
export type { CommonProps, TextProps, ImageProps, TextInputProps, NativeViewProps, } from "./primitives";
|
|
4
|
+
export declare const VERSION = "0.0.24";
|
|
5
|
+
export { View, Text, Image, TextInput, NativeView, Svg, SvgPath } from "./primitives";
|
|
6
|
+
export type { CommonProps, TextProps, ImageProps, TextInputProps, NativeViewProps, SvgProps, SvgPathProps, } from "./primitives";
|
|
7
7
|
export { render, unmount } from "./render";
|
|
8
8
|
export { native } from "./native";
|
|
9
9
|
export { useNativeEvent, useNativeValue, useDebounced, useThrottled, usePrevious, useToggle, useInterval, useHover, useLayoutRect, } from "./hooks";
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import "./runtime";
|
|
4
4
|
import "./bridge";
|
|
5
5
|
/** The SDK version — stamp it on support dumps and analytics. */
|
|
6
|
-
export const VERSION = "0.0.
|
|
7
|
-
export { View, Text, Image, TextInput, NativeView } from "./primitives";
|
|
6
|
+
export const VERSION = "0.0.24";
|
|
7
|
+
export { View, Text, Image, TextInput, NativeView, Svg, SvgPath } from "./primitives";
|
|
8
8
|
export { render, unmount } from "./render";
|
|
9
9
|
export { native } from "./native";
|
|
10
10
|
export { useNativeEvent, useNativeValue, useDebounced, useThrottled, usePrevious, useToggle, useInterval, useHover, useLayoutRect, } from "./hooks";
|
package/dist/primitives.d.ts
CHANGED
|
@@ -73,6 +73,30 @@ export interface ImageProps extends CommonProps {
|
|
|
73
73
|
src: string;
|
|
74
74
|
}
|
|
75
75
|
export declare function Image(props: ImageProps): import("react").ReactElement<ImageProps, string | import("react").JSXElementConstructor<any>>;
|
|
76
|
+
export interface SvgProps extends CommonProps {
|
|
77
|
+
/** "minX minY width height" — path coordinates map from this box onto the
|
|
78
|
+
node's layout frame (like the web's preserveAspectRatio="none"). */
|
|
79
|
+
viewBox: string;
|
|
80
|
+
}
|
|
81
|
+
/** Vector container: lays out like a View, paints its <SvgPath> children
|
|
82
|
+
scaled from viewBox space. Icon sets port directly — rename attributes
|
|
83
|
+
and drop each path's `d` in. */
|
|
84
|
+
export declare function Svg(props: SvgProps): import("react").ReactElement<SvgProps, string | import("react").JSXElementConstructor<any>>;
|
|
85
|
+
export interface SvgPathProps {
|
|
86
|
+
/** SVG path data ("M12 2 L22 22 …") — parsed once and cached. */
|
|
87
|
+
d: string;
|
|
88
|
+
/** Fill color; SVG's default black. "none" for stroke-only paths. */
|
|
89
|
+
fill?: string;
|
|
90
|
+
stroke?: string;
|
|
91
|
+
/** Stroke width in viewBox units (scales with the frame, like SVG). */
|
|
92
|
+
strokeWidth?: number;
|
|
93
|
+
strokeCap?: "butt" | "round" | "square";
|
|
94
|
+
strokeJoin?: "miter" | "round" | "bevel";
|
|
95
|
+
/** Dash pattern in viewBox units, e.g. "4 2". */
|
|
96
|
+
strokeDash?: string;
|
|
97
|
+
fillRule?: "nonzero" | "evenodd";
|
|
98
|
+
}
|
|
99
|
+
export declare function SvgPath(props: SvgPathProps): import("react").ReactElement<SvgPathProps, string | import("react").JSXElementConstructor<any>>;
|
|
76
100
|
export interface TextInputProps extends Omit<CommonProps, "children" | "onChange" | "onSubmit"> {
|
|
77
101
|
value?: string;
|
|
78
102
|
defaultValue?: string;
|
package/dist/primitives.js
CHANGED
|
@@ -8,6 +8,15 @@ export function Text(props) {
|
|
|
8
8
|
export function Image(props) {
|
|
9
9
|
return createElement("vs-image", props);
|
|
10
10
|
}
|
|
11
|
+
/** Vector container: lays out like a View, paints its <SvgPath> children
|
|
12
|
+
scaled from viewBox space. Icon sets port directly — rename attributes
|
|
13
|
+
and drop each path's `d` in. */
|
|
14
|
+
export function Svg(props) {
|
|
15
|
+
return createElement("vs-svg", props);
|
|
16
|
+
}
|
|
17
|
+
export function SvgPath(props) {
|
|
18
|
+
return createElement("vs-svgpath", props);
|
|
19
|
+
}
|
|
11
20
|
export function TextInput({ onChange, onSubmit, ...rest }) {
|
|
12
21
|
return createElement("vs-textinput", {
|
|
13
22
|
...rest,
|
package/dist/tw.js
CHANGED
|
@@ -71,6 +71,21 @@ const staticClasses = {
|
|
|
71
71
|
"cursor-pointer": { cursor: "pointer" },
|
|
72
72
|
"cursor-text": { cursor: "text" },
|
|
73
73
|
"cursor-default": { cursor: "default" },
|
|
74
|
+
"cursor-grab": { cursor: "grab" },
|
|
75
|
+
"cursor-grabbing": { cursor: "grabbing" },
|
|
76
|
+
"cursor-move": { cursor: "move" },
|
|
77
|
+
"cursor-ns-resize": { cursor: "ns-resize" },
|
|
78
|
+
"cursor-ew-resize": { cursor: "ew-resize" },
|
|
79
|
+
"cursor-crosshair": { cursor: "crosshair" },
|
|
80
|
+
"cursor-not-allowed": { cursor: "not-allowed" },
|
|
81
|
+
"pointer-events-none": { pointerEvents: "none" },
|
|
82
|
+
"pointer-events-auto": { pointerEvents: "auto" },
|
|
83
|
+
"border-solid": { borderStyle: "solid" },
|
|
84
|
+
"border-dashed": { borderStyle: "dashed" },
|
|
85
|
+
"border-dotted": { borderStyle: "dotted" },
|
|
86
|
+
"object-contain": { objectFit: "contain" },
|
|
87
|
+
"object-cover": { objectFit: "cover" },
|
|
88
|
+
"object-fill": { objectFit: "fill" },
|
|
74
89
|
shadow: { shadowColor: "#00000066", shadowRadius: 4, shadowOffsetY: 1 },
|
|
75
90
|
"shadow-sm": { shadowColor: "#00000066", shadowRadius: 4, shadowOffsetY: 1 },
|
|
76
91
|
"shadow-md": { shadowColor: "#00000066", shadowRadius: 8, shadowOffsetY: 2 },
|
package/package.json
CHANGED
package/src/hostConfig.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -4,15 +4,17 @@ import "./runtime";
|
|
|
4
4
|
import "./bridge";
|
|
5
5
|
|
|
6
6
|
/** The SDK version — stamp it on support dumps and analytics. */
|
|
7
|
-
export const VERSION = "0.0.
|
|
7
|
+
export const VERSION = "0.0.24";
|
|
8
8
|
|
|
9
|
-
export { View, Text, Image, TextInput, NativeView } from "./primitives";
|
|
9
|
+
export { View, Text, Image, TextInput, NativeView, Svg, SvgPath } from "./primitives";
|
|
10
10
|
export type {
|
|
11
11
|
CommonProps,
|
|
12
12
|
TextProps,
|
|
13
13
|
ImageProps,
|
|
14
14
|
TextInputProps,
|
|
15
15
|
NativeViewProps,
|
|
16
|
+
SvgProps,
|
|
17
|
+
SvgPathProps,
|
|
16
18
|
} from "./primitives";
|
|
17
19
|
export { render, unmount } from "./render";
|
|
18
20
|
export { native } from "./native";
|
package/src/layout.test.tsx
CHANGED
|
@@ -125,3 +125,26 @@ describe("useNativeValue", () => {
|
|
|
125
125
|
expect(seen.at(-1)).toBe(0.8);
|
|
126
126
|
});
|
|
127
127
|
});
|
|
128
|
+
|
|
129
|
+
describe("Svg primitives (0.0.24)", () => {
|
|
130
|
+
test("Svg + SvgPath create their node types with data props", async () => {
|
|
131
|
+
const { Svg, SvgPath } = require("./index");
|
|
132
|
+
render(
|
|
133
|
+
<Svg viewBox="0 0 24 24" style={{ width: 24, height: 24 }}>
|
|
134
|
+
<SvgPath d="M12 2 L22 22 L2 22 Z" fill="#ff0000" />
|
|
135
|
+
<SvgPath d="M2 12 H22" fill="none" stroke="#00ff00" strokeWidth={2} strokeDash="4 2" />
|
|
136
|
+
</Svg>,
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
const creates = allOps().filter((op: any) => op[0] === "create");
|
|
140
|
+
expect(creates.some((op: any) => op[2] === "svg")).toBe(true);
|
|
141
|
+
expect(creates.filter((op: any) => op[2] === "svgpath")).toHaveLength(2);
|
|
142
|
+
|
|
143
|
+
const propOps = allOps().filter((op: any) => op[0] === "setProps");
|
|
144
|
+
const svgProps: any = propOps.find((op: any) => op[2]?.viewBox);
|
|
145
|
+
expect(svgProps[2].viewBox).toBe("0 0 24 24");
|
|
146
|
+
|
|
147
|
+
const pathProps: any = propOps.find((op: any) => op[2]?.strokeDash);
|
|
148
|
+
expect(pathProps[2]).toMatchObject({ d: "M2 12 H22", fill: "none", stroke: "#00ff00", strokeWidth: 2 });
|
|
149
|
+
});
|
|
150
|
+
});
|
package/src/primitives.tsx
CHANGED
|
@@ -85,12 +85,46 @@ export function Text(props: TextProps) {
|
|
|
85
85
|
|
|
86
86
|
export interface ImageProps extends CommonProps {
|
|
87
87
|
src: string;
|
|
88
|
+
/** Style keys also work: objectFit ("contain" default | "cover" | "fill")
|
|
89
|
+
and tintColor (fills the image's alpha with a solid colour). */
|
|
88
90
|
}
|
|
89
91
|
|
|
90
92
|
export function Image(props: ImageProps) {
|
|
91
93
|
return createElement("vs-image", props);
|
|
92
94
|
}
|
|
93
95
|
|
|
96
|
+
export interface SvgProps extends CommonProps {
|
|
97
|
+
/** "minX minY width height" — path coordinates map from this box onto the
|
|
98
|
+
node's layout frame (like the web's preserveAspectRatio="none"). */
|
|
99
|
+
viewBox: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Vector container: lays out like a View, paints its <SvgPath> children
|
|
103
|
+
scaled from viewBox space. Icon sets port directly — rename attributes
|
|
104
|
+
and drop each path's `d` in. */
|
|
105
|
+
export function Svg(props: SvgProps) {
|
|
106
|
+
return createElement("vs-svg", props);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface SvgPathProps {
|
|
110
|
+
/** SVG path data ("M12 2 L22 22 …") — parsed once and cached. */
|
|
111
|
+
d: string;
|
|
112
|
+
/** Fill color; SVG's default black. "none" for stroke-only paths. */
|
|
113
|
+
fill?: string;
|
|
114
|
+
stroke?: string;
|
|
115
|
+
/** Stroke width in viewBox units (scales with the frame, like SVG). */
|
|
116
|
+
strokeWidth?: number;
|
|
117
|
+
strokeCap?: "butt" | "round" | "square";
|
|
118
|
+
strokeJoin?: "miter" | "round" | "bevel";
|
|
119
|
+
/** Dash pattern in viewBox units, e.g. "4 2". */
|
|
120
|
+
strokeDash?: string;
|
|
121
|
+
fillRule?: "nonzero" | "evenodd";
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function SvgPath(props: SvgPathProps) {
|
|
125
|
+
return createElement("vs-svgpath", props);
|
|
126
|
+
}
|
|
127
|
+
|
|
94
128
|
export interface TextInputProps extends Omit<CommonProps, "children" | "onChange" | "onSubmit"> {
|
|
95
129
|
value?: string;
|
|
96
130
|
defaultValue?: string;
|
package/src/tw.test.ts
CHANGED
|
@@ -253,3 +253,12 @@ describe("typography (0.0.22)", () => {
|
|
|
253
253
|
expect(tw("leading-5").style).toEqual({ lineHeight: 20 });
|
|
254
254
|
});
|
|
255
255
|
});
|
|
256
|
+
|
|
257
|
+
describe("input & media classes (0.0.23)", () => {
|
|
258
|
+
test("pointer events, border styles, object fit", () => {
|
|
259
|
+
expect(tw("pointer-events-none").style).toEqual({ pointerEvents: "none" });
|
|
260
|
+
expect(tw("border-dashed").style).toEqual({ borderStyle: "dashed" });
|
|
261
|
+
expect(tw("object-cover").style).toEqual({ objectFit: "cover" });
|
|
262
|
+
expect(tw("cursor-grab").style).toEqual({ cursor: "grab" });
|
|
263
|
+
});
|
|
264
|
+
});
|
package/src/tw.ts
CHANGED
|
@@ -82,6 +82,21 @@ const staticClasses: Record<string, Style> = {
|
|
|
82
82
|
"cursor-pointer": { cursor: "pointer" },
|
|
83
83
|
"cursor-text": { cursor: "text" },
|
|
84
84
|
"cursor-default": { cursor: "default" },
|
|
85
|
+
"cursor-grab": { cursor: "grab" },
|
|
86
|
+
"cursor-grabbing": { cursor: "grabbing" },
|
|
87
|
+
"cursor-move": { cursor: "move" },
|
|
88
|
+
"cursor-ns-resize": { cursor: "ns-resize" },
|
|
89
|
+
"cursor-ew-resize": { cursor: "ew-resize" },
|
|
90
|
+
"cursor-crosshair": { cursor: "crosshair" },
|
|
91
|
+
"cursor-not-allowed": { cursor: "not-allowed" },
|
|
92
|
+
"pointer-events-none": { pointerEvents: "none" },
|
|
93
|
+
"pointer-events-auto": { pointerEvents: "auto" },
|
|
94
|
+
"border-solid": { borderStyle: "solid" },
|
|
95
|
+
"border-dashed": { borderStyle: "dashed" },
|
|
96
|
+
"border-dotted": { borderStyle: "dotted" },
|
|
97
|
+
"object-contain": { objectFit: "contain" },
|
|
98
|
+
"object-cover": { objectFit: "cover" },
|
|
99
|
+
"object-fill": { objectFit: "fill" },
|
|
85
100
|
shadow: { shadowColor: "#00000066", shadowRadius: 4, shadowOffsetY: 1 },
|
|
86
101
|
"shadow-sm": { shadowColor: "#00000066", shadowRadius: 4, shadowOffsetY: 1 },
|
|
87
102
|
"shadow-md": { shadowColor: "#00000066", shadowRadius: 8, shadowOffsetY: 2 },
|