@tailorkit/react 0.1.0-beta.39 → 0.1.0-beta.40
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/index.js +52 -4
- package/dist/primitives.d.ts +4 -0
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { useEffect as useEffect2, useId as useId2, useMemo as useMemo3, useState
|
|
|
6
6
|
// src/primitives.tsx
|
|
7
7
|
import { buildPrimitiveCss } from "@tailorkit/client-core";
|
|
8
8
|
import { createContext, useContext, useId, useMemo } from "react";
|
|
9
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
var PrimitiveThemeContext = createContext(null);
|
|
11
11
|
var usePrimitiveNodeId = () => {
|
|
12
12
|
const id = useId();
|
|
@@ -33,6 +33,50 @@ var Primitive = ({
|
|
|
33
33
|
children
|
|
34
34
|
] });
|
|
35
35
|
};
|
|
36
|
+
var isStringValue = (value) => typeof value === "string";
|
|
37
|
+
var isPressCallback = (value) => typeof value === "function";
|
|
38
|
+
var Pressable = ({
|
|
39
|
+
props,
|
|
40
|
+
children
|
|
41
|
+
}) => {
|
|
42
|
+
const context = useContext(PrimitiveThemeContext);
|
|
43
|
+
const nodeId = usePrimitiveNodeId();
|
|
44
|
+
const displays = {
|
|
45
|
+
box: "block",
|
|
46
|
+
flex: "flex",
|
|
47
|
+
grid: "grid",
|
|
48
|
+
inline: "inline-flex"
|
|
49
|
+
};
|
|
50
|
+
const { ariaLabel, layout, onPress } = props;
|
|
51
|
+
const display = layout === "box" || layout === "flex" || layout === "grid" ? displays[layout] : displays.inline;
|
|
52
|
+
const disabled = props.disabled === true;
|
|
53
|
+
const css = context ? buildPrimitiveCss({
|
|
54
|
+
display,
|
|
55
|
+
nodeId,
|
|
56
|
+
pressable: true,
|
|
57
|
+
props,
|
|
58
|
+
theme: context.theme,
|
|
59
|
+
viewId: context.viewId
|
|
60
|
+
}) : "";
|
|
61
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
62
|
+
css === "" ? null : /* @__PURE__ */ jsx("style", { "data-tailorkit-node-style": nodeId, children: css }),
|
|
63
|
+
/* @__PURE__ */ jsx(
|
|
64
|
+
"button",
|
|
65
|
+
{
|
|
66
|
+
"aria-label": isStringValue(ariaLabel) ? ariaLabel : void 0,
|
|
67
|
+
"data-tailorkit-node": nodeId,
|
|
68
|
+
disabled,
|
|
69
|
+
onClick: () => {
|
|
70
|
+
if (!disabled && isPressCallback(onPress)) {
|
|
71
|
+
onPress();
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
type: "button",
|
|
75
|
+
children
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
] });
|
|
79
|
+
};
|
|
36
80
|
var primitives = {
|
|
37
81
|
Box: ({
|
|
38
82
|
props,
|
|
@@ -49,7 +93,11 @@ var primitives = {
|
|
|
49
93
|
Inline: ({
|
|
50
94
|
props,
|
|
51
95
|
children
|
|
52
|
-
}) => /* @__PURE__ */ jsx(Primitive, { display: "inline", element: "span", props, children })
|
|
96
|
+
}) => /* @__PURE__ */ jsx(Primitive, { display: "inline", element: "span", props, children }),
|
|
97
|
+
Pressable: ({
|
|
98
|
+
props,
|
|
99
|
+
children
|
|
100
|
+
}) => /* @__PURE__ */ jsx(Pressable, { props, children })
|
|
53
101
|
};
|
|
54
102
|
|
|
55
103
|
// src/remote-view.tsx
|
|
@@ -60,7 +108,7 @@ import {
|
|
|
60
108
|
} from "@tailorkit/client-core";
|
|
61
109
|
import {
|
|
62
110
|
Component,
|
|
63
|
-
Fragment,
|
|
111
|
+
Fragment as Fragment2,
|
|
64
112
|
createElement,
|
|
65
113
|
createContext as createContext2,
|
|
66
114
|
memo,
|
|
@@ -177,7 +225,7 @@ var RemoteNodeView = ({
|
|
|
177
225
|
/* @__PURE__ */ jsx2(RemoteView, { nodeId: child.id }, child.id)
|
|
178
226
|
));
|
|
179
227
|
if (node.kind === "fragment") {
|
|
180
|
-
return createElement(
|
|
228
|
+
return createElement(Fragment2, { key: node.id }, ...childElements);
|
|
181
229
|
}
|
|
182
230
|
return /* @__PURE__ */ jsx2(RemoteElementView, { node, ctx });
|
|
183
231
|
};
|
package/dist/primitives.d.ts
CHANGED
|
@@ -23,6 +23,10 @@ export declare const primitives: {
|
|
|
23
23
|
props: PrimitiveProps;
|
|
24
24
|
children?: ReactNode;
|
|
25
25
|
}) => import("react").JSX.Element;
|
|
26
|
+
readonly Pressable: ({ props, children, }: {
|
|
27
|
+
props: PrimitiveProps;
|
|
28
|
+
children?: ReactNode;
|
|
29
|
+
}) => import("react").JSX.Element;
|
|
26
30
|
};
|
|
27
31
|
export type PrimitiveStyle = CSSProperties;
|
|
28
32
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailorkit/react",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.40",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
"@floating-ui/react-dom": "^2.1.9",
|
|
48
48
|
"@nanostores/react": "2.0.1",
|
|
49
49
|
"@standard-schema/spec": "^1.1.0",
|
|
50
|
-
"@tailorkit/app": "0.1.0-beta.
|
|
51
|
-
"@tailorkit/client-core": "0.1.0-beta.
|
|
52
|
-
"@tailorkit/client-platform": "0.1.0-beta.
|
|
53
|
-
"@tailorkit/core": "0.1.0-beta.
|
|
54
|
-
"@tailorkit/sandbox": "0.1.0-beta.
|
|
50
|
+
"@tailorkit/app": "0.1.0-beta.40",
|
|
51
|
+
"@tailorkit/client-core": "0.1.0-beta.40",
|
|
52
|
+
"@tailorkit/client-platform": "0.1.0-beta.40",
|
|
53
|
+
"@tailorkit/core": "0.1.0-beta.40",
|
|
54
|
+
"@tailorkit/sandbox": "0.1.0-beta.40",
|
|
55
55
|
"nanostores": "1.5.5"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|