@process.co/ui 0.0.13 → 0.0.15
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 +29 -0
- package/css/ui.css +154 -182
- package/css/ui.d.ts +4 -0
- package/dist/components/dev/index.cjs +273 -460
- package/dist/components/dev/index.cjs.map +1 -1
- package/dist/components/dev/index.js +268 -454
- package/dist/components/dev/index.js.map +1 -1
- package/dist/components/fields/index.cjs +8339 -4903
- package/dist/components/fields/index.cjs.map +1 -1
- package/dist/components/fields/index.d.cts +4 -1
- package/dist/components/fields/index.d.ts +4 -1
- package/dist/components/fields/index.js +8311 -4883
- package/dist/components/fields/index.js.map +1 -1
- package/dist/{index-Bfh9REtO.d.cts → index-19C2gVyr.d.cts} +245 -150
- package/dist/{index-Bfh9REtO.d.ts → index-19C2gVyr.d.ts} +245 -150
- package/dist/index.cjs +10046 -5335
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -12
- package/dist/index.d.ts +5 -12
- package/dist/index.js +9966 -5256
- package/dist/index.js.map +1 -1
- package/package.json +7 -2
|
@@ -1,486 +1,299 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
|
|
3
|
+
var React2 = require('react');
|
|
4
|
+
|
|
5
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
|
+
|
|
7
|
+
var React2__default = /*#__PURE__*/_interopDefault(React2);
|
|
8
|
+
|
|
9
|
+
// src/components/dev/DevProvider.tsx
|
|
10
|
+
var DevContext = React2.createContext(null);
|
|
11
|
+
function useDevContext() {
|
|
12
|
+
return React2.useContext(DevContext);
|
|
6
13
|
}
|
|
7
|
-
function
|
|
8
|
-
|
|
14
|
+
function useNodeProperty(fieldName) {
|
|
15
|
+
const devCtx = useDevContext();
|
|
16
|
+
if (devCtx) {
|
|
17
|
+
const value = devCtx.getProperty(fieldName);
|
|
18
|
+
const setValue = React2.useCallback((newValue) => {
|
|
19
|
+
devCtx.setProperty(fieldName, newValue);
|
|
20
|
+
}, [devCtx, fieldName]);
|
|
21
|
+
return [value, setValue];
|
|
22
|
+
}
|
|
23
|
+
console.warn(`useNodeProperty('${fieldName}') called outside of DevProvider - returning undefined`);
|
|
24
|
+
const [localValue, setLocalValue] = React2.useState(void 0);
|
|
25
|
+
return [localValue, setLocalValue];
|
|
9
26
|
}
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
return obj;
|
|
27
|
+
function useInferredTypes() {
|
|
28
|
+
const devCtx = useDevContext();
|
|
29
|
+
if (devCtx) {
|
|
30
|
+
return {
|
|
31
|
+
inferredTypes: devCtx.inferredTypes,
|
|
32
|
+
setInferredType: devCtx.setInferredType,
|
|
33
|
+
getInferredType: devCtx.getInferredType
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
22
37
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
_d = true;
|
|
37
|
-
_e = err;
|
|
38
|
-
} finally{
|
|
39
|
-
try {
|
|
40
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
41
|
-
} finally{
|
|
42
|
-
if (_d) throw _e;
|
|
38
|
+
function DevProvider({
|
|
39
|
+
children,
|
|
40
|
+
storageKey = "process-dev",
|
|
41
|
+
initialData = {},
|
|
42
|
+
persist = true,
|
|
43
|
+
nodeId = "dev-node-1"
|
|
44
|
+
}) {
|
|
45
|
+
const [data, setData] = React2.useState(() => {
|
|
46
|
+
if (persist && typeof window !== "undefined") {
|
|
47
|
+
try {
|
|
48
|
+
const stored = localStorage.getItem(`${storageKey}:data`);
|
|
49
|
+
if (stored) {
|
|
50
|
+
return { ...initialData, ...JSON.parse(stored) };
|
|
43
51
|
}
|
|
52
|
+
} catch (e) {
|
|
53
|
+
console.warn("DevProvider: Failed to load from localStorage", e);
|
|
54
|
+
}
|
|
44
55
|
}
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
var ownKeys = Object.keys(source);
|
|
54
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
55
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
56
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
57
|
-
}));
|
|
56
|
+
return initialData;
|
|
57
|
+
});
|
|
58
|
+
const [inferredTypes, setInferredTypesState] = React2.useState(() => {
|
|
59
|
+
if (persist && typeof window !== "undefined") {
|
|
60
|
+
try {
|
|
61
|
+
const stored = localStorage.getItem(`${storageKey}:inferredTypes`);
|
|
62
|
+
if (stored) {
|
|
63
|
+
return JSON.parse(stored);
|
|
58
64
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
65
|
+
} catch (e) {
|
|
66
|
+
console.warn("DevProvider: Failed to load inferredTypes from localStorage", e);
|
|
67
|
+
}
|
|
62
68
|
}
|
|
63
|
-
return
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
keys.push.apply(keys, symbols);
|
|
69
|
+
return {};
|
|
70
|
+
});
|
|
71
|
+
React2.useEffect(() => {
|
|
72
|
+
if (persist && typeof window !== "undefined") {
|
|
73
|
+
try {
|
|
74
|
+
localStorage.setItem(`${storageKey}:data`, JSON.stringify(data));
|
|
75
|
+
} catch (e) {
|
|
76
|
+
console.warn("DevProvider: Failed to save data to localStorage", e);
|
|
77
|
+
}
|
|
75
78
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
85
|
-
});
|
|
79
|
+
}, [data, storageKey, persist]);
|
|
80
|
+
React2.useEffect(() => {
|
|
81
|
+
if (persist && typeof window !== "undefined") {
|
|
82
|
+
try {
|
|
83
|
+
localStorage.setItem(`${storageKey}:inferredTypes`, JSON.stringify(inferredTypes));
|
|
84
|
+
} catch (e) {
|
|
85
|
+
console.warn("DevProvider: Failed to save inferredTypes to localStorage", e);
|
|
86
|
+
}
|
|
86
87
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
88
|
+
}, [inferredTypes, storageKey, persist]);
|
|
89
|
+
const setProperty = React2.useCallback((key, value2) => {
|
|
90
|
+
setData((prev) => ({ ...prev, [key]: value2 }));
|
|
91
|
+
}, []);
|
|
92
|
+
const getProperty = React2.useCallback((key) => {
|
|
93
|
+
return data[key];
|
|
94
|
+
}, [data]);
|
|
95
|
+
const setInferredType = React2.useCallback((fieldName, type) => {
|
|
96
|
+
setInferredTypesState((prev) => ({ ...prev, [fieldName]: type }));
|
|
97
|
+
}, []);
|
|
98
|
+
const getInferredType = React2.useCallback((fieldName) => {
|
|
99
|
+
return inferredTypes[fieldName];
|
|
100
|
+
}, [inferredTypes]);
|
|
101
|
+
const clearInferredType = React2.useCallback((fieldName) => {
|
|
102
|
+
setInferredTypesState((prev) => {
|
|
103
|
+
const { [fieldName]: _, ...rest } = prev;
|
|
104
|
+
return rest;
|
|
105
|
+
});
|
|
106
|
+
}, []);
|
|
107
|
+
const clearAllInferredTypes = React2.useCallback(() => {
|
|
108
|
+
setInferredTypesState({});
|
|
109
|
+
}, []);
|
|
110
|
+
const clearAll = React2.useCallback(() => {
|
|
111
|
+
setData({});
|
|
112
|
+
setInferredTypesState({});
|
|
113
|
+
if (persist && typeof window !== "undefined") {
|
|
114
|
+
localStorage.removeItem(`${storageKey}:data`);
|
|
115
|
+
localStorage.removeItem(`${storageKey}:inferredTypes`);
|
|
101
116
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
117
|
+
}, [storageKey, persist]);
|
|
118
|
+
const exportData = React2.useCallback(() => {
|
|
119
|
+
return JSON.stringify({ data, inferredTypes }, null, 2);
|
|
120
|
+
}, [data, inferredTypes]);
|
|
121
|
+
const importData = React2.useCallback((json) => {
|
|
122
|
+
try {
|
|
123
|
+
const parsed = JSON.parse(json);
|
|
124
|
+
if (parsed.data) setData(parsed.data);
|
|
125
|
+
if (parsed.inferredTypes) setInferredTypesState(parsed.inferredTypes);
|
|
126
|
+
} catch (e) {
|
|
127
|
+
console.error("DevProvider: Failed to import data", e);
|
|
113
128
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
129
|
+
}, []);
|
|
130
|
+
const value = React2.useMemo(() => ({
|
|
131
|
+
data,
|
|
132
|
+
setProperty,
|
|
133
|
+
getProperty,
|
|
134
|
+
inferredTypes,
|
|
135
|
+
setInferredType,
|
|
136
|
+
getInferredType,
|
|
137
|
+
clearInferredType,
|
|
138
|
+
clearAllInferredTypes,
|
|
139
|
+
nodeId,
|
|
140
|
+
clearAll,
|
|
141
|
+
exportData,
|
|
142
|
+
importData
|
|
143
|
+
}), [data, setProperty, getProperty, inferredTypes, setInferredType, getInferredType, clearInferredType, clearAllInferredTypes, nodeId, clearAll, exportData, importData]);
|
|
144
|
+
return /* @__PURE__ */ React2__default.default.createElement(DevContext.Provider, { value }, children);
|
|
118
145
|
}
|
|
119
|
-
function
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
146
|
+
function DevToolbar({ className }) {
|
|
147
|
+
const devCtx = useDevContext();
|
|
148
|
+
const [showData, setShowData] = React2.useState(false);
|
|
149
|
+
const [showTypeEditor, setShowTypeEditor] = React2.useState(false);
|
|
150
|
+
const [newTypeKey, setNewTypeKey] = React2.useState("");
|
|
151
|
+
const [newTypeValue, setNewTypeValue] = React2.useState("");
|
|
152
|
+
if (!devCtx) {
|
|
153
|
+
return /* @__PURE__ */ React2__default.default.createElement("div", { className }, "DevToolbar: Not inside DevProvider");
|
|
154
|
+
}
|
|
155
|
+
const handleAddType = () => {
|
|
156
|
+
if (newTypeKey.trim() && newTypeValue.trim()) {
|
|
157
|
+
devCtx.setInferredType(newTypeKey.trim(), newTypeValue.trim());
|
|
158
|
+
setNewTypeKey("");
|
|
159
|
+
setNewTypeValue("");
|
|
126
160
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
"@swc/helpers - typeof";
|
|
135
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
136
|
-
}
|
|
137
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
138
|
-
if (!o) return;
|
|
139
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
140
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
141
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
142
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
143
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
144
|
-
}
|
|
145
|
-
var React2 = require('react');
|
|
146
|
-
function _interopDefault(e) {
|
|
147
|
-
return e && e.__esModule ? e : {
|
|
148
|
-
default: e
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
var React2__default = /*#__PURE__*/ _interopDefault(React2);
|
|
152
|
-
// src/components/dev/DevProvider.tsx
|
|
153
|
-
var DevContext = React2.createContext(null);
|
|
154
|
-
function useDevContext() {
|
|
155
|
-
return React2.useContext(DevContext);
|
|
156
|
-
}
|
|
157
|
-
function useNodeProperty(fieldName) {
|
|
158
|
-
var devCtx = useDevContext();
|
|
159
|
-
if (devCtx) {
|
|
160
|
-
var value = devCtx.getProperty(fieldName);
|
|
161
|
-
var setValue = React2.useCallback(function(newValue) {
|
|
162
|
-
devCtx.setProperty(fieldName, newValue);
|
|
163
|
-
}, [
|
|
164
|
-
devCtx,
|
|
165
|
-
fieldName
|
|
166
|
-
]);
|
|
167
|
-
return [
|
|
168
|
-
value,
|
|
169
|
-
setValue
|
|
170
|
-
];
|
|
161
|
+
};
|
|
162
|
+
const handleRemoveType = (key) => {
|
|
163
|
+
devCtx.clearInferredType(key);
|
|
164
|
+
};
|
|
165
|
+
const handleClearAllTypes = () => {
|
|
166
|
+
if (confirm("Clear all inferred types?")) {
|
|
167
|
+
devCtx.clearAllInferredTypes();
|
|
171
168
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
169
|
+
};
|
|
170
|
+
return /* @__PURE__ */ React2__default.default.createElement("div", { className: `${className || ""} uii:border uii:rounded-lg uii:p-4 uii:bg-gray-50 dark:uii:bg-gray-900` }, /* @__PURE__ */ React2__default.default.createElement("div", { className: "uii:flex uii:items-center uii:gap-4 uii:mb-2 uii:flex-wrap" }, /* @__PURE__ */ React2__default.default.createElement("span", { className: "uii:font-semibold uii:text-sm" }, "\u{1F6E0}\uFE0F Dev Mode"), /* @__PURE__ */ React2__default.default.createElement("span", { className: "uii:text-xs uii:text-gray-500" }, "Node: ", devCtx.nodeId), /* @__PURE__ */ React2__default.default.createElement(
|
|
171
|
+
"button",
|
|
172
|
+
{
|
|
173
|
+
onClick: () => setShowData(!showData),
|
|
174
|
+
className: "uii:text-xs uii:px-2 uii:py-1 uii:bg-blue-100 dark:uii:bg-blue-900 uii:rounded hover:uii:bg-blue-200"
|
|
175
|
+
},
|
|
176
|
+
showData ? "Hide" : "Show",
|
|
177
|
+
" Data"
|
|
178
|
+
), /* @__PURE__ */ React2__default.default.createElement(
|
|
179
|
+
"button",
|
|
180
|
+
{
|
|
181
|
+
onClick: () => setShowTypeEditor(!showTypeEditor),
|
|
182
|
+
className: "uii:text-xs uii:px-2 uii:py-1 uii:bg-purple-100 dark:uii:bg-purple-900 uii:rounded hover:uii:bg-purple-200"
|
|
183
|
+
},
|
|
184
|
+
showTypeEditor ? "Hide" : "Spoof",
|
|
185
|
+
" Types"
|
|
186
|
+
), /* @__PURE__ */ React2__default.default.createElement(
|
|
187
|
+
"button",
|
|
188
|
+
{
|
|
189
|
+
onClick: () => {
|
|
190
|
+
const json = devCtx.exportData();
|
|
191
|
+
navigator.clipboard.writeText(json);
|
|
192
|
+
alert("Data copied to clipboard!");
|
|
193
|
+
},
|
|
194
|
+
className: "uii:text-xs uii:px-2 uii:py-1 uii:bg-green-100 dark:uii:bg-green-900 uii:rounded hover:uii:bg-green-200"
|
|
195
|
+
},
|
|
196
|
+
"Export"
|
|
197
|
+
), /* @__PURE__ */ React2__default.default.createElement(
|
|
198
|
+
"button",
|
|
199
|
+
{
|
|
200
|
+
onClick: () => {
|
|
201
|
+
const json = prompt("Paste JSON data:");
|
|
202
|
+
if (json) devCtx.importData(json);
|
|
203
|
+
},
|
|
204
|
+
className: "uii:text-xs uii:px-2 uii:py-1 uii:bg-yellow-100 dark:uii:bg-yellow-900 uii:rounded hover:uii:bg-yellow-200"
|
|
205
|
+
},
|
|
206
|
+
"Import"
|
|
207
|
+
), /* @__PURE__ */ React2__default.default.createElement(
|
|
208
|
+
"button",
|
|
209
|
+
{
|
|
210
|
+
onClick: () => {
|
|
211
|
+
if (confirm("Clear all data?")) devCtx.clearAll();
|
|
212
|
+
},
|
|
213
|
+
className: "uii:text-xs uii:px-2 uii:py-1 uii:bg-red-100 dark:uii:bg-red-900 uii:rounded hover:uii:bg-red-200"
|
|
214
|
+
},
|
|
215
|
+
"Clear"
|
|
216
|
+
)), showTypeEditor && /* @__PURE__ */ React2__default.default.createElement("div", { className: "uii:mt-3 uii:p-3 uii:bg-purple-50 dark:uii:bg-purple-950 uii:rounded-lg uii:border uii:border-purple-200 dark:uii:border-purple-800" }, /* @__PURE__ */ React2__default.default.createElement("div", { className: "uii:text-xs uii:font-medium uii:mb-2 uii:text-purple-700 dark:uii:text-purple-300" }, "Spoof Inferred Types (simulate external field types)"), /* @__PURE__ */ React2__default.default.createElement("div", { className: "uii:flex uii:gap-2 uii:mb-2 uii:flex-wrap" }, /* @__PURE__ */ React2__default.default.createElement(
|
|
217
|
+
"input",
|
|
218
|
+
{
|
|
219
|
+
type: "text",
|
|
220
|
+
placeholder: "Field name (e.g., switchExpression)",
|
|
221
|
+
value: newTypeKey,
|
|
222
|
+
onChange: (e) => setNewTypeKey(e.target.value),
|
|
223
|
+
className: "uii:text-xs uii:px-2 uii:py-1 uii:border uii:rounded uii:flex-1 uii:min-w-[150px] uii:bg-white dark:uii:bg-gray-800"
|
|
187
224
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
return _object_spread({}, initialData, JSON.parse(stored));
|
|
198
|
-
}
|
|
199
|
-
} catch (e) {
|
|
200
|
-
console.warn("DevProvider: Failed to load from localStorage", e);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
return initialData;
|
|
204
|
-
}), 2), data = _React2_useState[0], setData = _React2_useState[1];
|
|
205
|
-
var _React2_useState1 = _sliced_to_array(React2.useState(function() {
|
|
206
|
-
if (persist && typeof window !== "undefined") {
|
|
207
|
-
try {
|
|
208
|
-
var stored = localStorage.getItem("".concat(storageKey, ":inferredTypes"));
|
|
209
|
-
if (stored) {
|
|
210
|
-
return JSON.parse(stored);
|
|
211
|
-
}
|
|
212
|
-
} catch (e) {
|
|
213
|
-
console.warn("DevProvider: Failed to load inferredTypes from localStorage", e);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
return {};
|
|
217
|
-
}), 2), inferredTypes = _React2_useState1[0], setInferredTypesState = _React2_useState1[1];
|
|
218
|
-
React2.useEffect(function() {
|
|
219
|
-
if (persist && typeof window !== "undefined") {
|
|
220
|
-
try {
|
|
221
|
-
localStorage.setItem("".concat(storageKey, ":data"), JSON.stringify(data));
|
|
222
|
-
} catch (e) {
|
|
223
|
-
console.warn("DevProvider: Failed to save data to localStorage", e);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}, [
|
|
227
|
-
data,
|
|
228
|
-
storageKey,
|
|
229
|
-
persist
|
|
230
|
-
]);
|
|
231
|
-
React2.useEffect(function() {
|
|
232
|
-
if (persist && typeof window !== "undefined") {
|
|
233
|
-
try {
|
|
234
|
-
localStorage.setItem("".concat(storageKey, ":inferredTypes"), JSON.stringify(inferredTypes));
|
|
235
|
-
} catch (e) {
|
|
236
|
-
console.warn("DevProvider: Failed to save inferredTypes to localStorage", e);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}, [
|
|
240
|
-
inferredTypes,
|
|
241
|
-
storageKey,
|
|
242
|
-
persist
|
|
243
|
-
]);
|
|
244
|
-
var setProperty = React2.useCallback(function(key, value2) {
|
|
245
|
-
setData(function(prev) {
|
|
246
|
-
return _object_spread_props(_object_spread({}, prev), _define_property({}, key, value2));
|
|
247
|
-
});
|
|
248
|
-
}, []);
|
|
249
|
-
var getProperty = React2.useCallback(function(key) {
|
|
250
|
-
return data[key];
|
|
251
|
-
}, [
|
|
252
|
-
data
|
|
253
|
-
]);
|
|
254
|
-
var setInferredType = React2.useCallback(function(fieldName, type) {
|
|
255
|
-
setInferredTypesState(function(prev) {
|
|
256
|
-
return _object_spread_props(_object_spread({}, prev), _define_property({}, fieldName, type));
|
|
257
|
-
});
|
|
258
|
-
}, []);
|
|
259
|
-
var getInferredType = React2.useCallback(function(fieldName) {
|
|
260
|
-
return inferredTypes[fieldName];
|
|
261
|
-
}, [
|
|
262
|
-
inferredTypes
|
|
263
|
-
]);
|
|
264
|
-
var clearInferredType = React2.useCallback(function(fieldName) {
|
|
265
|
-
setInferredTypesState(function(prev) {
|
|
266
|
-
var _ = prev[fieldName], rest = _object_without_properties(prev, [
|
|
267
|
-
fieldName
|
|
268
|
-
].map(_to_property_key));
|
|
269
|
-
return rest;
|
|
270
|
-
});
|
|
271
|
-
}, []);
|
|
272
|
-
var clearAllInferredTypes = React2.useCallback(function() {
|
|
273
|
-
setInferredTypesState({});
|
|
274
|
-
}, []);
|
|
275
|
-
var clearAll = React2.useCallback(function() {
|
|
276
|
-
setData({});
|
|
277
|
-
setInferredTypesState({});
|
|
278
|
-
if (persist && typeof window !== "undefined") {
|
|
279
|
-
localStorage.removeItem("".concat(storageKey, ":data"));
|
|
280
|
-
localStorage.removeItem("".concat(storageKey, ":inferredTypes"));
|
|
281
|
-
}
|
|
282
|
-
}, [
|
|
283
|
-
storageKey,
|
|
284
|
-
persist
|
|
285
|
-
]);
|
|
286
|
-
var exportData = React2.useCallback(function() {
|
|
287
|
-
return JSON.stringify({
|
|
288
|
-
data: data,
|
|
289
|
-
inferredTypes: inferredTypes
|
|
290
|
-
}, null, 2);
|
|
291
|
-
}, [
|
|
292
|
-
data,
|
|
293
|
-
inferredTypes
|
|
294
|
-
]);
|
|
295
|
-
var importData = React2.useCallback(function(json) {
|
|
296
|
-
try {
|
|
297
|
-
var parsed = JSON.parse(json);
|
|
298
|
-
if (parsed.data) setData(parsed.data);
|
|
299
|
-
if (parsed.inferredTypes) setInferredTypesState(parsed.inferredTypes);
|
|
300
|
-
} catch (e) {
|
|
301
|
-
console.error("DevProvider: Failed to import data", e);
|
|
302
|
-
}
|
|
303
|
-
}, []);
|
|
304
|
-
var value = React2.useMemo(function() {
|
|
305
|
-
return {
|
|
306
|
-
data: data,
|
|
307
|
-
setProperty: setProperty,
|
|
308
|
-
getProperty: getProperty,
|
|
309
|
-
inferredTypes: inferredTypes,
|
|
310
|
-
setInferredType: setInferredType,
|
|
311
|
-
getInferredType: getInferredType,
|
|
312
|
-
clearInferredType: clearInferredType,
|
|
313
|
-
clearAllInferredTypes: clearAllInferredTypes,
|
|
314
|
-
nodeId: nodeId,
|
|
315
|
-
clearAll: clearAll,
|
|
316
|
-
exportData: exportData,
|
|
317
|
-
importData: importData
|
|
318
|
-
};
|
|
319
|
-
}, [
|
|
320
|
-
data,
|
|
321
|
-
setProperty,
|
|
322
|
-
getProperty,
|
|
323
|
-
inferredTypes,
|
|
324
|
-
setInferredType,
|
|
325
|
-
getInferredType,
|
|
326
|
-
clearInferredType,
|
|
327
|
-
clearAllInferredTypes,
|
|
328
|
-
nodeId,
|
|
329
|
-
clearAll,
|
|
330
|
-
exportData,
|
|
331
|
-
importData
|
|
332
|
-
]);
|
|
333
|
-
return /* @__PURE__ */ React2__default.default.createElement(DevContext.Provider, {
|
|
334
|
-
value: value
|
|
335
|
-
}, children);
|
|
336
|
-
}
|
|
337
|
-
function DevToolbar(param) {
|
|
338
|
-
var className = param.className;
|
|
339
|
-
var devCtx = useDevContext();
|
|
340
|
-
var _React2_useState = _sliced_to_array(React2.useState(false), 2), showData = _React2_useState[0], setShowData = _React2_useState[1];
|
|
341
|
-
var _React2_useState1 = _sliced_to_array(React2.useState(false), 2), showTypeEditor = _React2_useState1[0], setShowTypeEditor = _React2_useState1[1];
|
|
342
|
-
var _React2_useState2 = _sliced_to_array(React2.useState(""), 2), newTypeKey = _React2_useState2[0], setNewTypeKey = _React2_useState2[1];
|
|
343
|
-
var _React2_useState3 = _sliced_to_array(React2.useState(""), 2), newTypeValue = _React2_useState3[0], setNewTypeValue = _React2_useState3[1];
|
|
344
|
-
if (!devCtx) {
|
|
345
|
-
return /* @__PURE__ */ React2__default.default.createElement("div", {
|
|
346
|
-
className: className
|
|
347
|
-
}, "DevToolbar: Not inside DevProvider");
|
|
225
|
+
), /* @__PURE__ */ React2__default.default.createElement(
|
|
226
|
+
"input",
|
|
227
|
+
{
|
|
228
|
+
type: "text",
|
|
229
|
+
placeholder: "Type (e.g., string | number)",
|
|
230
|
+
value: newTypeValue,
|
|
231
|
+
onChange: (e) => setNewTypeValue(e.target.value),
|
|
232
|
+
onKeyDown: (e) => e.key === "Enter" && handleAddType(),
|
|
233
|
+
className: "uii:text-xs uii:px-2 uii:py-1 uii:border uii:rounded uii:flex-1 uii:min-w-[200px] uii:bg-white dark:uii:bg-gray-800"
|
|
348
234
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
onClick:
|
|
374
|
-
|
|
375
|
-
},
|
|
376
|
-
className: "uii:text-xs uii:px-2 uii:py-1 uii:bg-blue-100 dark:uii:bg-blue-900 uii:rounded hover:uii:bg-blue-200"
|
|
377
|
-
}, showData ? "Hide" : "Show", " Data"), /* @__PURE__ */ React2__default.default.createElement("button", {
|
|
378
|
-
onClick: function() {
|
|
379
|
-
return setShowTypeEditor(!showTypeEditor);
|
|
380
|
-
},
|
|
381
|
-
className: "uii:text-xs uii:px-2 uii:py-1 uii:bg-purple-100 dark:uii:bg-purple-900 uii:rounded hover:uii:bg-purple-200"
|
|
382
|
-
}, showTypeEditor ? "Hide" : "Spoof", " Types"), /* @__PURE__ */ React2__default.default.createElement("button", {
|
|
383
|
-
onClick: function() {
|
|
384
|
-
var json = devCtx.exportData();
|
|
385
|
-
navigator.clipboard.writeText(json);
|
|
386
|
-
alert("Data copied to clipboard!");
|
|
387
|
-
},
|
|
388
|
-
className: "uii:text-xs uii:px-2 uii:py-1 uii:bg-green-100 dark:uii:bg-green-900 uii:rounded hover:uii:bg-green-200"
|
|
389
|
-
}, "Export"), /* @__PURE__ */ React2__default.default.createElement("button", {
|
|
390
|
-
onClick: function() {
|
|
391
|
-
var json = prompt("Paste JSON data:");
|
|
392
|
-
if (json) devCtx.importData(json);
|
|
393
|
-
},
|
|
394
|
-
className: "uii:text-xs uii:px-2 uii:py-1 uii:bg-yellow-100 dark:uii:bg-yellow-900 uii:rounded hover:uii:bg-yellow-200"
|
|
395
|
-
}, "Import"), /* @__PURE__ */ React2__default.default.createElement("button", {
|
|
396
|
-
onClick: function() {
|
|
397
|
-
if (confirm("Clear all data?")) devCtx.clearAll();
|
|
398
|
-
},
|
|
399
|
-
className: "uii:text-xs uii:px-2 uii:py-1 uii:bg-red-100 dark:uii:bg-red-900 uii:rounded hover:uii:bg-red-200"
|
|
400
|
-
}, "Clear")), showTypeEditor && /* @__PURE__ */ React2__default.default.createElement("div", {
|
|
401
|
-
className: "uii:mt-3 uii:p-3 uii:bg-purple-50 dark:uii:bg-purple-950 uii:rounded-lg uii:border uii:border-purple-200 dark:uii:border-purple-800"
|
|
402
|
-
}, /* @__PURE__ */ React2__default.default.createElement("div", {
|
|
403
|
-
className: "uii:text-xs uii:font-medium uii:mb-2 uii:text-purple-700 dark:uii:text-purple-300"
|
|
404
|
-
}, "Spoof Inferred Types (simulate external field types)"), /* @__PURE__ */ React2__default.default.createElement("div", {
|
|
405
|
-
className: "uii:flex uii:gap-2 uii:mb-2 uii:flex-wrap"
|
|
406
|
-
}, /* @__PURE__ */ React2__default.default.createElement("input", {
|
|
407
|
-
type: "text",
|
|
408
|
-
placeholder: "Field name (e.g., switchExpression)",
|
|
409
|
-
value: newTypeKey,
|
|
410
|
-
onChange: function(e) {
|
|
411
|
-
return setNewTypeKey(e.target.value);
|
|
412
|
-
},
|
|
413
|
-
className: "uii:text-xs uii:px-2 uii:py-1 uii:border uii:rounded uii:flex-1 uii:min-w-[150px] uii:bg-white dark:uii:bg-gray-800"
|
|
414
|
-
}), /* @__PURE__ */ React2__default.default.createElement("input", {
|
|
415
|
-
type: "text",
|
|
416
|
-
placeholder: "Type (e.g., string | number)",
|
|
417
|
-
value: newTypeValue,
|
|
418
|
-
onChange: function(e) {
|
|
419
|
-
return setNewTypeValue(e.target.value);
|
|
235
|
+
), /* @__PURE__ */ React2__default.default.createElement(
|
|
236
|
+
"button",
|
|
237
|
+
{
|
|
238
|
+
onClick: handleAddType,
|
|
239
|
+
disabled: !newTypeKey.trim() || !newTypeValue.trim(),
|
|
240
|
+
className: "uii:text-xs uii:px-3 uii:py-1 uii:bg-purple-500 uii:text-white uii:rounded hover:uii:bg-purple-600 disabled:uii:opacity-50 disabled:uii:cursor-not-allowed"
|
|
241
|
+
},
|
|
242
|
+
"Add"
|
|
243
|
+
)), Object.keys(devCtx.inferredTypes).length > 0 && /* @__PURE__ */ React2__default.default.createElement("div", { className: "uii:mt-2" }, /* @__PURE__ */ React2__default.default.createElement("div", { className: "uii:flex uii:items-center uii:justify-between uii:mb-1" }, /* @__PURE__ */ React2__default.default.createElement("span", { className: "uii:text-xs uii:text-gray-500" }, "Current inferred types:"), /* @__PURE__ */ React2__default.default.createElement(
|
|
244
|
+
"button",
|
|
245
|
+
{
|
|
246
|
+
onClick: handleClearAllTypes,
|
|
247
|
+
className: "uii:text-xs uii:px-2 uii:py-0.5 uii:bg-red-100 dark:uii:bg-red-900 uii:text-red-700 dark:uii:text-red-300 uii:rounded hover:uii:bg-red-200"
|
|
248
|
+
},
|
|
249
|
+
"Clear All"
|
|
250
|
+
)), /* @__PURE__ */ React2__default.default.createElement("div", { className: "uii:space-y-1" }, Object.entries(devCtx.inferredTypes).map(([key, value]) => value && /* @__PURE__ */ React2__default.default.createElement(
|
|
251
|
+
"div",
|
|
252
|
+
{
|
|
253
|
+
key,
|
|
254
|
+
className: "uii:flex uii:items-center uii:gap-2 uii:text-xs uii:bg-white dark:uii:bg-gray-800 uii:px-2 uii:py-1 uii:rounded"
|
|
255
|
+
},
|
|
256
|
+
/* @__PURE__ */ React2__default.default.createElement(
|
|
257
|
+
"button",
|
|
258
|
+
{
|
|
259
|
+
onClick: () => {
|
|
260
|
+
navigator.clipboard.writeText(key);
|
|
420
261
|
},
|
|
421
|
-
|
|
422
|
-
|
|
262
|
+
className: "uii:text-gray-400 hover:uii:text-purple-600 uii:text-xs",
|
|
263
|
+
title: "Copy field name"
|
|
264
|
+
},
|
|
265
|
+
"\u{1F4CB}"
|
|
266
|
+
),
|
|
267
|
+
/* @__PURE__ */ React2__default.default.createElement(
|
|
268
|
+
"span",
|
|
269
|
+
{
|
|
270
|
+
className: "uii:font-mono uii:text-purple-600 dark:uii:text-purple-400 uii:cursor-pointer uii:truncate uii:max-w-[300px]",
|
|
271
|
+
onClick: () => {
|
|
272
|
+
navigator.clipboard.writeText(key);
|
|
423
273
|
},
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
className: "uii:text-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
}, Object.entries(devCtx.inferredTypes).map(function(param) {
|
|
441
|
-
var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
|
|
442
|
-
return value && /* @__PURE__ */ React2__default.default.createElement("div", {
|
|
443
|
-
key: key,
|
|
444
|
-
className: "uii:flex uii:items-center uii:gap-2 uii:text-xs uii:bg-white dark:uii:bg-gray-800 uii:px-2 uii:py-1 uii:rounded"
|
|
445
|
-
}, /* @__PURE__ */ React2__default.default.createElement("button", {
|
|
446
|
-
onClick: function() {
|
|
447
|
-
navigator.clipboard.writeText(key);
|
|
448
|
-
},
|
|
449
|
-
className: "uii:text-gray-400 hover:uii:text-purple-600 uii:text-xs",
|
|
450
|
-
title: "Copy field name"
|
|
451
|
-
}, "\uD83D\uDCCB"), /* @__PURE__ */ React2__default.default.createElement("span", {
|
|
452
|
-
className: "uii:font-mono uii:text-purple-600 dark:uii:text-purple-400 uii:cursor-pointer uii:truncate uii:max-w-[300px]",
|
|
453
|
-
onClick: function() {
|
|
454
|
-
navigator.clipboard.writeText(key);
|
|
455
|
-
},
|
|
456
|
-
title: key
|
|
457
|
-
}, key), /* @__PURE__ */ React2__default.default.createElement("span", {
|
|
458
|
-
className: "uii:text-gray-400"
|
|
459
|
-
}, "\u2192"), /* @__PURE__ */ React2__default.default.createElement("span", {
|
|
460
|
-
className: "uii:font-mono uii:text-gray-600 dark:uii:text-gray-300 uii:flex-1 uii:truncate"
|
|
461
|
-
}, value), /* @__PURE__ */ React2__default.default.createElement("button", {
|
|
462
|
-
onClick: function() {
|
|
463
|
-
return handleRemoveType(key);
|
|
464
|
-
},
|
|
465
|
-
className: "uii:text-red-500 hover:uii:text-red-700 uii:text-xs",
|
|
466
|
-
title: "Remove"
|
|
467
|
-
}, "\u2715"));
|
|
468
|
-
})))), showData && /* @__PURE__ */ React2__default.default.createElement("div", {
|
|
469
|
-
className: "uii:mt-2"
|
|
470
|
-
}, /* @__PURE__ */ React2__default.default.createElement("div", {
|
|
471
|
-
className: "uii:text-xs uii:mb-1 uii:font-medium"
|
|
472
|
-
}, "Data:"), /* @__PURE__ */ React2__default.default.createElement("pre", {
|
|
473
|
-
className: "uii:text-xs uii:bg-gray-100 dark:uii:bg-gray-800 uii:p-2 uii:rounded uii:overflow-auto uii:max-h-48"
|
|
474
|
-
}, JSON.stringify(devCtx.data, null, 2)), /* @__PURE__ */ React2__default.default.createElement("div", {
|
|
475
|
-
className: "uii:text-xs uii:mb-1 uii:mt-2 uii:font-medium"
|
|
476
|
-
}, "Inferred Types:"), /* @__PURE__ */ React2__default.default.createElement("pre", {
|
|
477
|
-
className: "uii:text-xs uii:bg-gray-100 dark:uii:bg-gray-800 uii:p-2 uii:rounded uii:overflow-auto uii:max-h-24"
|
|
478
|
-
}, JSON.stringify(devCtx.inferredTypes, null, 2))));
|
|
274
|
+
title: key
|
|
275
|
+
},
|
|
276
|
+
key
|
|
277
|
+
),
|
|
278
|
+
/* @__PURE__ */ React2__default.default.createElement("span", { className: "uii:text-gray-400" }, "\u2192"),
|
|
279
|
+
/* @__PURE__ */ React2__default.default.createElement("span", { className: "uii:font-mono uii:text-gray-600 dark:uii:text-gray-300 uii:flex-1 uii:truncate" }, value),
|
|
280
|
+
/* @__PURE__ */ React2__default.default.createElement(
|
|
281
|
+
"button",
|
|
282
|
+
{
|
|
283
|
+
onClick: () => handleRemoveType(key),
|
|
284
|
+
className: "uii:text-red-500 hover:uii:text-red-700 uii:text-xs",
|
|
285
|
+
title: "Remove"
|
|
286
|
+
},
|
|
287
|
+
"\u2715"
|
|
288
|
+
)
|
|
289
|
+
))))), showData && /* @__PURE__ */ React2__default.default.createElement("div", { className: "uii:mt-2" }, /* @__PURE__ */ React2__default.default.createElement("div", { className: "uii:text-xs uii:mb-1 uii:font-medium" }, "Data:"), /* @__PURE__ */ React2__default.default.createElement("pre", { className: "uii:text-xs uii:bg-gray-100 dark:uii:bg-gray-800 uii:p-2 uii:rounded uii:overflow-auto uii:max-h-48" }, JSON.stringify(devCtx.data, null, 2)), /* @__PURE__ */ React2__default.default.createElement("div", { className: "uii:text-xs uii:mb-1 uii:mt-2 uii:font-medium" }, "Inferred Types:"), /* @__PURE__ */ React2__default.default.createElement("pre", { className: "uii:text-xs uii:bg-gray-100 dark:uii:bg-gray-800 uii:p-2 uii:rounded uii:overflow-auto uii:max-h-24" }, JSON.stringify(devCtx.inferredTypes, null, 2))));
|
|
479
290
|
}
|
|
291
|
+
|
|
480
292
|
exports.DevContext = DevContext;
|
|
481
293
|
exports.DevProvider = DevProvider;
|
|
482
294
|
exports.DevToolbar = DevToolbar;
|
|
483
295
|
exports.useDevContext = useDevContext;
|
|
484
296
|
exports.useInferredTypes = useInferredTypes;
|
|
485
|
-
exports.useNodeProperty = useNodeProperty;
|
|
297
|
+
exports.useNodeProperty = useNodeProperty;
|
|
298
|
+
//# sourceMappingURL=index.cjs.map
|
|
486
299
|
//# sourceMappingURL=index.cjs.map
|