@process.co/ui 0.0.9 → 0.0.11
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 +365 -282
- package/css/ui.css +176 -7
- package/dist/components/dev/index.cjs +486 -0
- package/dist/components/dev/index.cjs.map +1 -0
- package/dist/components/dev/index.d.cts +88 -0
- package/dist/components/dev/index.d.ts +88 -0
- package/dist/components/dev/index.js +474 -0
- package/dist/components/dev/index.js.map +1 -0
- package/dist/components/fields/index.cjs +452 -78
- package/dist/components/fields/index.cjs.map +1 -1
- package/dist/components/fields/index.d.cts +1 -1
- package/dist/components/fields/index.d.ts +1 -1
- package/dist/components/fields/index.js +435 -68
- package/dist/components/fields/index.js.map +1 -1
- package/dist/{index-nu_JyZnb.d.cts → index-B-kAG1RW.d.cts} +204 -18
- package/dist/{index-nu_JyZnb.d.ts → index-B-kAG1RW.d.ts} +204 -18
- package/dist/index.cjs +413 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +414 -26
- package/dist/index.js.map +1 -1
- package/package.json +11 -1
package/dist/index.cjs
CHANGED
|
@@ -4880,21 +4880,21 @@ function cn() {
|
|
|
4880
4880
|
return twMerge(clsx(inputs));
|
|
4881
4881
|
}
|
|
4882
4882
|
// src/components/ui/button.tsx
|
|
4883
|
-
var buttonVariants = cva("
|
|
4883
|
+
var buttonVariants = cva("uii:inline-flex uii:items-center uii:justify-center uii:gap-2 uii:whitespace-nowrap uii:rounded-sm uii:text-sm uii:font-medium uii:transition-[color,box-shadow] uii:disabled:pointer-events-none uii:disabled:opacity-50 uii:[&_svg]:pointer-events-none uii:[&_svg:not([class*=size-])]:size-4 uii:shrink-0 uii:[&_svg]:shrink-0 uii:outline-none uii:focus-visible:border-ring uii:focus-visible:ring-ring/50 uii:focus-visible:ring-[3px] uii:aria-invalid:ring-destructive/20 uii:dark:aria-invalid:ring-destructive/40 uii:aria-invalid:border-destructive uii:cursor-pointer", {
|
|
4884
4884
|
variants: {
|
|
4885
4885
|
variant: {
|
|
4886
|
-
default: "
|
|
4887
|
-
destructive: "
|
|
4888
|
-
outline: "
|
|
4889
|
-
secondary: "
|
|
4890
|
-
ghost: "
|
|
4891
|
-
link: "
|
|
4886
|
+
default: "uii:bg-primary uii:text-primary-foreground uii:shadow-xs uii:hover:bg-primary/90 uii:select-none",
|
|
4887
|
+
destructive: "uii:bg-destructive uii:text-white uii:shadow-xs uii:hover:bg-destructive/90 uii:focus-visible:ring-destructive/20 uii:dark:focus-visible:ring-destructive/40",
|
|
4888
|
+
outline: "uii:border uii:border-input uii:bg-background uii:shadow-xs uii:hover:bg-accent uii:hover:text-accent-foreground",
|
|
4889
|
+
secondary: "uii:bg-secondary uii:text-secondary-foreground uii:shadow-xs uii:hover:bg-secondary/80",
|
|
4890
|
+
ghost: "uii:hover:bg-accent uii:hover:text-accent-foreground",
|
|
4891
|
+
link: "uii:text-primary uii:underline-offset-4 uii:hover:underline"
|
|
4892
4892
|
},
|
|
4893
4893
|
size: {
|
|
4894
|
-
default: "
|
|
4895
|
-
sm: "
|
|
4896
|
-
lg: "
|
|
4897
|
-
icon: "
|
|
4894
|
+
default: "uii:h-9 uii:px-4 uii:py-2 uii:has-[>svg]:px-3",
|
|
4895
|
+
sm: "uii:h-8 uii:rounded-sm uii:gap-1.5 uii:px-3 uii:has-[>svg]:px-2.5",
|
|
4896
|
+
lg: "uii:h-10 uii:rounded-sm uii:px-6 uii:has-[>svg]:px-4",
|
|
4897
|
+
icon: "uii:size-9"
|
|
4898
4898
|
}
|
|
4899
4899
|
},
|
|
4900
4900
|
defaultVariants: {
|
|
@@ -5124,18 +5124,39 @@ __export(fields_exports, {
|
|
|
5124
5124
|
TemplateFieldProvider: function() {
|
|
5125
5125
|
return TemplateFieldProvider;
|
|
5126
5126
|
},
|
|
5127
|
+
computeExtendedType: function() {
|
|
5128
|
+
return computeExtendedType;
|
|
5129
|
+
},
|
|
5130
|
+
filterOperatorsByType: function() {
|
|
5131
|
+
return filterOperatorsByType;
|
|
5132
|
+
},
|
|
5133
|
+
getNumberConstants: function() {
|
|
5134
|
+
return getNumberConstants;
|
|
5135
|
+
},
|
|
5127
5136
|
getOperatorsForType: function() {
|
|
5128
5137
|
return getOperatorsForType;
|
|
5129
5138
|
},
|
|
5139
|
+
getStringConstants: function() {
|
|
5140
|
+
return getStringConstants;
|
|
5141
|
+
},
|
|
5130
5142
|
intersectTypes: function() {
|
|
5131
5143
|
return intersectTypes;
|
|
5132
5144
|
},
|
|
5133
5145
|
parseInferSyntax: function() {
|
|
5134
5146
|
return parseInferSyntax;
|
|
5135
5147
|
},
|
|
5148
|
+
parseInferredTypes: function() {
|
|
5149
|
+
return parseInferredTypes;
|
|
5150
|
+
},
|
|
5136
5151
|
useAllInferredTypes: function() {
|
|
5137
5152
|
return useAllInferredTypes;
|
|
5138
5153
|
},
|
|
5154
|
+
useClearAllInferredTypes: function() {
|
|
5155
|
+
return useClearAllInferredTypes;
|
|
5156
|
+
},
|
|
5157
|
+
useClearInferredType: function() {
|
|
5158
|
+
return useClearInferredType;
|
|
5159
|
+
},
|
|
5139
5160
|
useFieldPath: function() {
|
|
5140
5161
|
return useFieldPath;
|
|
5141
5162
|
},
|
|
@@ -5170,8 +5191,53 @@ __export(fields_exports, {
|
|
|
5170
5191
|
return useTemplateFieldContext;
|
|
5171
5192
|
}
|
|
5172
5193
|
});
|
|
5194
|
+
var DevContext = React2.createContext(null);
|
|
5195
|
+
function useResolvedExpectedType(expectedType, devCtx) {
|
|
5196
|
+
var inferredTypes = devCtx === null || devCtx === void 0 ? void 0 : devCtx.inferredTypes;
|
|
5197
|
+
return React2__namespace.useMemo(function() {
|
|
5198
|
+
var _match_;
|
|
5199
|
+
if (!expectedType) return "any";
|
|
5200
|
+
if (!expectedType.startsWith("$infer<")) {
|
|
5201
|
+
return expectedType;
|
|
5202
|
+
}
|
|
5203
|
+
var match = expectedType.match(/^\$infer<(.+)>$/);
|
|
5204
|
+
if (!match) return expectedType;
|
|
5205
|
+
var content = ((_match_ = match[1]) === null || _match_ === void 0 ? void 0 : _match_.trim()) || "";
|
|
5206
|
+
if (content.startsWith("[") && content.endsWith("]")) {
|
|
5207
|
+
var arrayContent = content.slice(1, -1);
|
|
5208
|
+
var fieldNames = arrayContent.split(",").map(function(s) {
|
|
5209
|
+
return s.trim().replace(/^["']|["']$/g, "");
|
|
5210
|
+
}).filter(Boolean);
|
|
5211
|
+
if (!inferredTypes) {
|
|
5212
|
+
return "Subscribing to: ".concat(fieldNames.join(", "));
|
|
5213
|
+
}
|
|
5214
|
+
var types = fieldNames.map(function(name) {
|
|
5215
|
+
return inferredTypes[name];
|
|
5216
|
+
}).filter(function(t) {
|
|
5217
|
+
return !!t && t.length > 0;
|
|
5218
|
+
});
|
|
5219
|
+
if (types.length === 0) {
|
|
5220
|
+
return "Waiting for: ".concat(fieldNames.join(", "));
|
|
5221
|
+
}
|
|
5222
|
+
return types.length === 1 ? types[0] : types.join(" & ");
|
|
5223
|
+
}
|
|
5224
|
+
if (!content.includes("|") && /^[a-zA-Z_][a-zA-Z0-9_\-]*$/.test(content)) {
|
|
5225
|
+
if (!inferredTypes) {
|
|
5226
|
+
return "Subscribing to: ".concat(content);
|
|
5227
|
+
}
|
|
5228
|
+
var resolvedType = inferredTypes[content];
|
|
5229
|
+
return resolvedType || "Waiting for: ".concat(content);
|
|
5230
|
+
}
|
|
5231
|
+
return content;
|
|
5232
|
+
}, [
|
|
5233
|
+
expectedType,
|
|
5234
|
+
inferredTypes
|
|
5235
|
+
]);
|
|
5236
|
+
}
|
|
5173
5237
|
function Input(param) {
|
|
5174
5238
|
var fieldName = param.fieldName, label = param.label, value = param.value, onChange = param.onChange, _param_disabled = param.disabled, disabled = _param_disabled === void 0 ? false : _param_disabled, placeholder = param.placeholder, _param_expectedType = param.expectedType, expectedType = _param_expectedType === void 0 ? "string" : _param_expectedType, _param_required = param.required, required = _param_required === void 0 ? false : _param_required, _param_hasRequiredError = param.hasRequiredError, hasRequiredError = _param_hasRequiredError === void 0 ? false : _param_hasRequiredError, className = param.className, editorClassName = param.editorClassName;
|
|
5239
|
+
var devCtx = React2.useContext(DevContext);
|
|
5240
|
+
var resolvedExpectedType = useResolvedExpectedType(expectedType, devCtx);
|
|
5175
5241
|
var displayValue = React2__namespace.useMemo(function() {
|
|
5176
5242
|
if (value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && "expression" in value) {
|
|
5177
5243
|
return value.expression || "";
|
|
@@ -5199,6 +5265,7 @@ function Input(param) {
|
|
|
5199
5265
|
onChange
|
|
5200
5266
|
]);
|
|
5201
5267
|
var showError = hasRequiredError || required && !displayValue;
|
|
5268
|
+
var isWaiting = resolvedExpectedType.startsWith("Waiting for:") || resolvedExpectedType.startsWith("Subscribing to:");
|
|
5202
5269
|
return /* @__PURE__ */ React2__namespace.createElement("div", {
|
|
5203
5270
|
className: cn("uii:mb-2", className)
|
|
5204
5271
|
}, /* @__PURE__ */ React2__namespace.createElement("div", {
|
|
@@ -5206,9 +5273,10 @@ function Input(param) {
|
|
|
5206
5273
|
}, /* @__PURE__ */ React2__namespace.createElement("label", {
|
|
5207
5274
|
htmlFor: fieldName,
|
|
5208
5275
|
className: "uii:text-xs uii:font-bold uii:text-muted-foreground"
|
|
5209
|
-
}, label, ":"),
|
|
5210
|
-
className: "uii:-mt-2 uii:inline-flex uii:px-1 uii:py-0.5 uii:
|
|
5211
|
-
|
|
5276
|
+
}, label, ":"), resolvedExpectedType !== "$.interface.timer" && /* @__PURE__ */ React2__namespace.createElement("span", {
|
|
5277
|
+
className: cn("uii:-mt-2 uii:inline-flex uii:px-1 uii:py-0.5 uii:rounded-sm uii:text-[10px] uii:font-mono uii:font-light uii:max-w-[300px] uii:truncate", isWaiting ? "uii:bg-yellow-100 uii:text-yellow-700" : "uii:bg-gray-200 uii:text-muted-foreground"),
|
|
5278
|
+
title: resolvedExpectedType
|
|
5279
|
+
}, resolvedExpectedType), showError && /* @__PURE__ */ React2__namespace.createElement("span", {
|
|
5212
5280
|
className: "uii:-mt-2 uii:inline-flex uii:px-1 uii:py-0.5 uii:bg-red-100 uii:text-red-600 uii:rounded-sm uii:text-[10px] uii:font-medium"
|
|
5213
5281
|
}, "Required")), /* @__PURE__ */ React2__namespace.createElement("div", {
|
|
5214
5282
|
className: "uii:mt-0.5"
|
|
@@ -5305,8 +5373,52 @@ function SelectScrollDownButton(_param) {
|
|
|
5305
5373
|
}));
|
|
5306
5374
|
}
|
|
5307
5375
|
// src/components/fields/Select.tsx
|
|
5376
|
+
function useResolvedExpectedType2(expectedType, devCtx) {
|
|
5377
|
+
var inferredTypes = devCtx === null || devCtx === void 0 ? void 0 : devCtx.inferredTypes;
|
|
5378
|
+
return React2__namespace.useMemo(function() {
|
|
5379
|
+
var _match_;
|
|
5380
|
+
if (!expectedType) return "any";
|
|
5381
|
+
if (!expectedType.startsWith("$infer<")) {
|
|
5382
|
+
return expectedType;
|
|
5383
|
+
}
|
|
5384
|
+
var match = expectedType.match(/^\$infer<(.+)>$/);
|
|
5385
|
+
if (!match) return expectedType;
|
|
5386
|
+
var content = ((_match_ = match[1]) === null || _match_ === void 0 ? void 0 : _match_.trim()) || "";
|
|
5387
|
+
if (content.startsWith("[") && content.endsWith("]")) {
|
|
5388
|
+
var arrayContent = content.slice(1, -1);
|
|
5389
|
+
var fieldNames = arrayContent.split(",").map(function(s) {
|
|
5390
|
+
return s.trim().replace(/^["']|["']$/g, "");
|
|
5391
|
+
}).filter(Boolean);
|
|
5392
|
+
if (!inferredTypes) {
|
|
5393
|
+
return "Subscribing to: ".concat(fieldNames.join(", "));
|
|
5394
|
+
}
|
|
5395
|
+
var types = fieldNames.map(function(name) {
|
|
5396
|
+
return inferredTypes[name];
|
|
5397
|
+
}).filter(function(t) {
|
|
5398
|
+
return !!t && t.length > 0;
|
|
5399
|
+
});
|
|
5400
|
+
if (types.length === 0) {
|
|
5401
|
+
return "Waiting for: ".concat(fieldNames.join(", "));
|
|
5402
|
+
}
|
|
5403
|
+
return types.length === 1 ? types[0] : types.join(" & ");
|
|
5404
|
+
}
|
|
5405
|
+
if (!content.includes("|") && /^[a-zA-Z_][a-zA-Z0-9_\-]*$/.test(content)) {
|
|
5406
|
+
if (!inferredTypes) {
|
|
5407
|
+
return "Subscribing to: ".concat(content);
|
|
5408
|
+
}
|
|
5409
|
+
var resolvedType = inferredTypes[content];
|
|
5410
|
+
return resolvedType || "Waiting for: ".concat(content);
|
|
5411
|
+
}
|
|
5412
|
+
return content;
|
|
5413
|
+
}, [
|
|
5414
|
+
expectedType,
|
|
5415
|
+
inferredTypes
|
|
5416
|
+
]);
|
|
5417
|
+
}
|
|
5308
5418
|
function Select2(param) {
|
|
5309
5419
|
var fieldName = param.fieldName, label = param.label, value = param.value, onChange = param.onChange, rawOptions = param.options, _param_disabled = param.disabled, disabled = _param_disabled === void 0 ? false : _param_disabled, placeholder = param.placeholder, _param_expectedType = param.expectedType, expectedType = _param_expectedType === void 0 ? "string" : _param_expectedType, _param_required = param.required, required = _param_required === void 0 ? false : _param_required, _param_hasRequiredError = param.hasRequiredError, hasRequiredError = _param_hasRequiredError === void 0 ? false : _param_hasRequiredError, className = param.className, children = param.children;
|
|
5420
|
+
var devCtx = React2.useContext(DevContext);
|
|
5421
|
+
var resolvedExpectedType = useResolvedExpectedType2(expectedType, devCtx);
|
|
5310
5422
|
var _React2__namespace_useState = _sliced_to_array(React2__namespace.useState(false), 2), isExpressionMode = _React2__namespace_useState[0], setIsExpressionMode = _React2__namespace_useState[1];
|
|
5311
5423
|
var _React2__namespace_useState1 = _sliced_to_array(React2__namespace.useState(""), 2), expressionValue = _React2__namespace_useState1[0], setExpressionValue = _React2__namespace_useState1[1];
|
|
5312
5424
|
var options = React2__namespace.useMemo(function() {
|
|
@@ -5395,6 +5507,7 @@ function Select2(param) {
|
|
|
5395
5507
|
},
|
|
5396
5508
|
hasError: showError
|
|
5397
5509
|
};
|
|
5510
|
+
var isWaiting = resolvedExpectedType.startsWith("Waiting for:") || resolvedExpectedType.startsWith("Subscribing to:");
|
|
5398
5511
|
return /* @__PURE__ */ React2__namespace.createElement("div", {
|
|
5399
5512
|
className: cn("uii:mb-2", className)
|
|
5400
5513
|
}, /* @__PURE__ */ React2__namespace.createElement("div", {
|
|
@@ -5402,9 +5515,10 @@ function Select2(param) {
|
|
|
5402
5515
|
}, /* @__PURE__ */ React2__namespace.createElement("label", {
|
|
5403
5516
|
htmlFor: fieldName,
|
|
5404
5517
|
className: "uii:text-xs uii:font-bold uii:text-muted-foreground"
|
|
5405
|
-
}, label, ":"),
|
|
5406
|
-
className: "uii:-mt-2 uii:inline-flex uii:px-1 uii:py-0.5 uii:
|
|
5407
|
-
|
|
5518
|
+
}, label, ":"), resolvedExpectedType !== "$.interface.timer" && /* @__PURE__ */ React2__namespace.createElement("span", {
|
|
5519
|
+
className: cn("uii:-mt-2 uii:inline-flex uii:px-1 uii:py-0.5 uii:rounded-sm uii:text-[10px] uii:font-mono uii:font-light uii:max-w-[300px] uii:truncate", isWaiting ? "uii:bg-yellow-100 uii:text-yellow-700" : "uii:bg-gray-200 uii:text-muted-foreground"),
|
|
5520
|
+
title: resolvedExpectedType
|
|
5521
|
+
}, resolvedExpectedType), showError && /* @__PURE__ */ React2__namespace.createElement("span", {
|
|
5408
5522
|
className: "uii:-mt-2 uii:inline-flex uii:px-1 uii:py-0.5 uii:bg-red-100 uii:text-red-600 uii:rounded-sm uii:text-[10px] uii:font-medium"
|
|
5409
5523
|
}, "Required")), /* @__PURE__ */ React2__namespace.createElement("div", {
|
|
5410
5524
|
className: "uii:mt-0.5"
|
|
@@ -5474,6 +5588,137 @@ function Select2(param) {
|
|
|
5474
5588
|
}, opt.node ? opt.node : /* @__PURE__ */ React2__namespace.createElement(React2__namespace.Fragment, null, opt.label));
|
|
5475
5589
|
})))));
|
|
5476
5590
|
}
|
|
5591
|
+
// src/components/template-editor/operatorTypes.ts
|
|
5592
|
+
function parseInferredTypes(typeStr) {
|
|
5593
|
+
var result = {
|
|
5594
|
+
baseTypes: [],
|
|
5595
|
+
stringConstants: [],
|
|
5596
|
+
numberConstants: [],
|
|
5597
|
+
hasConstants: false,
|
|
5598
|
+
rawTypes: []
|
|
5599
|
+
};
|
|
5600
|
+
if (!typeStr || typeStr === "any" || typeStr === "unknown") {
|
|
5601
|
+
result.baseTypes = [
|
|
5602
|
+
"any"
|
|
5603
|
+
];
|
|
5604
|
+
result.rawTypes = [
|
|
5605
|
+
"any"
|
|
5606
|
+
];
|
|
5607
|
+
return result;
|
|
5608
|
+
}
|
|
5609
|
+
var types = typeStr.split("|").map(function(t) {
|
|
5610
|
+
return t.trim();
|
|
5611
|
+
}).filter(Boolean);
|
|
5612
|
+
var baseTypesSet = /* @__PURE__ */ new Set();
|
|
5613
|
+
var rawTypesSet = /* @__PURE__ */ new Set();
|
|
5614
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5615
|
+
try {
|
|
5616
|
+
for(var _iterator = types[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5617
|
+
var t = _step.value;
|
|
5618
|
+
rawTypesSet.add(t);
|
|
5619
|
+
var stringLiteralMatch = t.match(/^["'](.*)["']$/);
|
|
5620
|
+
if (stringLiteralMatch && stringLiteralMatch[1] !== void 0) {
|
|
5621
|
+
result.stringConstants.push(stringLiteralMatch[1]);
|
|
5622
|
+
baseTypesSet.add("string");
|
|
5623
|
+
result.hasConstants = true;
|
|
5624
|
+
continue;
|
|
5625
|
+
}
|
|
5626
|
+
if (/^-?\d+(\.\d+)?$/.test(t)) {
|
|
5627
|
+
result.numberConstants.push(parseFloat(t));
|
|
5628
|
+
baseTypesSet.add("number");
|
|
5629
|
+
result.hasConstants = true;
|
|
5630
|
+
continue;
|
|
5631
|
+
}
|
|
5632
|
+
if (t === "true" || t === "false") {
|
|
5633
|
+
baseTypesSet.add("boolean");
|
|
5634
|
+
result.hasConstants = true;
|
|
5635
|
+
continue;
|
|
5636
|
+
}
|
|
5637
|
+
baseTypesSet.add(t);
|
|
5638
|
+
}
|
|
5639
|
+
} catch (err) {
|
|
5640
|
+
_didIteratorError = true;
|
|
5641
|
+
_iteratorError = err;
|
|
5642
|
+
} finally{
|
|
5643
|
+
try {
|
|
5644
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5645
|
+
_iterator.return();
|
|
5646
|
+
}
|
|
5647
|
+
} finally{
|
|
5648
|
+
if (_didIteratorError) {
|
|
5649
|
+
throw _iteratorError;
|
|
5650
|
+
}
|
|
5651
|
+
}
|
|
5652
|
+
}
|
|
5653
|
+
result.baseTypes = Array.from(baseTypesSet);
|
|
5654
|
+
result.rawTypes = Array.from(rawTypesSet);
|
|
5655
|
+
return result;
|
|
5656
|
+
}
|
|
5657
|
+
function computeExtendedType(inferredType, opDef) {
|
|
5658
|
+
if (opDef.narrowsTo === "never") {
|
|
5659
|
+
return "never";
|
|
5660
|
+
}
|
|
5661
|
+
var parsed = parseInferredTypes(inferredType);
|
|
5662
|
+
var matchingLiterals = [];
|
|
5663
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5664
|
+
try {
|
|
5665
|
+
for(var _iterator = parsed.rawTypes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5666
|
+
var t = _step.value;
|
|
5667
|
+
if (opDef.narrowsTo === "string") {
|
|
5668
|
+
if (t === "string") ;
|
|
5669
|
+
else if (/^["'].*["']$/.test(t)) {
|
|
5670
|
+
matchingLiterals.push(t);
|
|
5671
|
+
}
|
|
5672
|
+
} else if (opDef.narrowsTo === "number") {
|
|
5673
|
+
if (t === "number") ;
|
|
5674
|
+
else if (/^-?\d+(\.\d+)?$/.test(t)) {
|
|
5675
|
+
matchingLiterals.push(t);
|
|
5676
|
+
}
|
|
5677
|
+
} else if (opDef.narrowsTo === "boolean") {
|
|
5678
|
+
if (t === "boolean") ;
|
|
5679
|
+
else if (t === "true" || t === "false") {
|
|
5680
|
+
matchingLiterals.push(t);
|
|
5681
|
+
}
|
|
5682
|
+
}
|
|
5683
|
+
}
|
|
5684
|
+
} catch (err) {
|
|
5685
|
+
_didIteratorError = true;
|
|
5686
|
+
_iteratorError = err;
|
|
5687
|
+
} finally{
|
|
5688
|
+
try {
|
|
5689
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5690
|
+
_iterator.return();
|
|
5691
|
+
}
|
|
5692
|
+
} finally{
|
|
5693
|
+
if (_didIteratorError) {
|
|
5694
|
+
throw _iteratorError;
|
|
5695
|
+
}
|
|
5696
|
+
}
|
|
5697
|
+
}
|
|
5698
|
+
var result = _to_consumable_array(matchingLiterals);
|
|
5699
|
+
if (opDef.extendsWithBase || matchingLiterals.length === 0) {
|
|
5700
|
+
if (!result.includes(opDef.narrowsTo)) {
|
|
5701
|
+
result.push(opDef.narrowsTo);
|
|
5702
|
+
}
|
|
5703
|
+
}
|
|
5704
|
+
return result.length > 0 ? result.join(" | ") : opDef.narrowsTo;
|
|
5705
|
+
}
|
|
5706
|
+
function filterOperatorsByType(operators, inferredType) {
|
|
5707
|
+
var parsed = parseInferredTypes(inferredType);
|
|
5708
|
+
var baseTypes = parsed.baseTypes;
|
|
5709
|
+
return operators.filter(function(op) {
|
|
5710
|
+
if (op.types.includes("any")) return true;
|
|
5711
|
+
return op.types.some(function(t) {
|
|
5712
|
+
return baseTypes.includes(t) || baseTypes.includes("any");
|
|
5713
|
+
});
|
|
5714
|
+
});
|
|
5715
|
+
}
|
|
5716
|
+
function getStringConstants(inferredType) {
|
|
5717
|
+
return parseInferredTypes(inferredType).stringConstants;
|
|
5718
|
+
}
|
|
5719
|
+
function getNumberConstants(inferredType) {
|
|
5720
|
+
return parseInferredTypes(inferredType).numberConstants;
|
|
5721
|
+
}
|
|
5477
5722
|
// src/components/fields/index.tsx
|
|
5478
5723
|
function useTemplateFieldContext() {
|
|
5479
5724
|
return {
|
|
@@ -5509,7 +5754,18 @@ function NestedFieldProvider(param) {
|
|
|
5509
5754
|
}
|
|
5510
5755
|
var InferredTypesContext = React2.createContext(null);
|
|
5511
5756
|
function useInferredTypes() {
|
|
5512
|
-
|
|
5757
|
+
var devContext = React2.useContext(DevContext);
|
|
5758
|
+
var realContext = React2.useContext(InferredTypesContext);
|
|
5759
|
+
if (devContext) {
|
|
5760
|
+
return {
|
|
5761
|
+
inferredTypes: devContext.inferredTypes,
|
|
5762
|
+
setInferredType: devContext.setInferredType,
|
|
5763
|
+
getInferredType: devContext.getInferredType,
|
|
5764
|
+
clearInferredType: devContext.clearInferredType,
|
|
5765
|
+
clearAllInferredTypes: devContext.clearAllInferredTypes
|
|
5766
|
+
};
|
|
5767
|
+
}
|
|
5768
|
+
return realContext;
|
|
5513
5769
|
}
|
|
5514
5770
|
function InferredTypesProvider(param) {
|
|
5515
5771
|
var children = param.children;
|
|
@@ -5639,43 +5895,175 @@ function NodePropertyProvider(param) {
|
|
|
5639
5895
|
return /* @__PURE__ */ React2__namespace.default.createElement(React2__namespace.default.Fragment, null, children);
|
|
5640
5896
|
}
|
|
5641
5897
|
function useIsInNodePropertyProvider() {
|
|
5642
|
-
|
|
5898
|
+
var devContext = React2.useContext(DevContext);
|
|
5899
|
+
return devContext !== null;
|
|
5643
5900
|
}
|
|
5644
5901
|
function useNodeProperty(key) {
|
|
5902
|
+
var devContext = React2.useContext(DevContext);
|
|
5903
|
+
var _React2_useState = _sliced_to_array(React2.useState(function() {
|
|
5904
|
+
var _devContext_data;
|
|
5905
|
+
return devContext === null || devContext === void 0 ? void 0 : (_devContext_data = devContext.data) === null || _devContext_data === void 0 ? void 0 : _devContext_data[key];
|
|
5906
|
+
}), 2), devValue = _React2_useState[0], setDevValue = _React2_useState[1];
|
|
5907
|
+
React2__namespace.default.useEffect(function() {
|
|
5908
|
+
if (devContext) {
|
|
5909
|
+
setDevValue(devContext.data[key]);
|
|
5910
|
+
}
|
|
5911
|
+
}, [
|
|
5912
|
+
devContext,
|
|
5913
|
+
key
|
|
5914
|
+
]);
|
|
5915
|
+
var devSetter = React2.useCallback(function(value) {
|
|
5916
|
+
if (devContext) {
|
|
5917
|
+
devContext.setProperty(key, value);
|
|
5918
|
+
setDevValue(value);
|
|
5919
|
+
}
|
|
5920
|
+
}, [
|
|
5921
|
+
devContext,
|
|
5922
|
+
key
|
|
5923
|
+
]);
|
|
5645
5924
|
var noopSetter = React2.useCallback(function() {
|
|
5646
|
-
console.warn('[useNodeProperty]
|
|
5925
|
+
console.warn('[useNodeProperty] No provider - cannot set "'.concat(key, '"'));
|
|
5647
5926
|
}, [
|
|
5648
5927
|
key
|
|
5649
5928
|
]);
|
|
5929
|
+
if (devContext) {
|
|
5930
|
+
return [
|
|
5931
|
+
devValue,
|
|
5932
|
+
devSetter
|
|
5933
|
+
];
|
|
5934
|
+
}
|
|
5650
5935
|
return [
|
|
5651
5936
|
void 0,
|
|
5652
5937
|
noopSetter
|
|
5653
5938
|
];
|
|
5654
5939
|
}
|
|
5655
5940
|
function useNodeProperties() {
|
|
5941
|
+
var devContext = React2.useContext(DevContext);
|
|
5942
|
+
var _React2_useState = _sliced_to_array(React2.useState(function() {
|
|
5943
|
+
var _devContext_data;
|
|
5944
|
+
return (_devContext_data = devContext === null || devContext === void 0 ? void 0 : devContext.data) !== null && _devContext_data !== void 0 ? _devContext_data : {};
|
|
5945
|
+
}), 2), devData = _React2_useState[0], setDevData = _React2_useState[1];
|
|
5946
|
+
React2__namespace.default.useEffect(function() {
|
|
5947
|
+
if (devContext) {
|
|
5948
|
+
setDevData(_object_spread({}, devContext.data));
|
|
5949
|
+
}
|
|
5950
|
+
}, [
|
|
5951
|
+
devContext,
|
|
5952
|
+
devContext === null || devContext === void 0 ? void 0 : devContext.data
|
|
5953
|
+
]);
|
|
5954
|
+
var devSetter = React2.useCallback(function(updates) {
|
|
5955
|
+
if (devContext) {
|
|
5956
|
+
Object.entries(updates).forEach(function(param) {
|
|
5957
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
|
|
5958
|
+
devContext.setProperty(key, value);
|
|
5959
|
+
});
|
|
5960
|
+
setDevData(function(prev) {
|
|
5961
|
+
return _object_spread({}, prev, updates);
|
|
5962
|
+
});
|
|
5963
|
+
}
|
|
5964
|
+
}, [
|
|
5965
|
+
devContext
|
|
5966
|
+
]);
|
|
5656
5967
|
var noopSetter = React2.useCallback(function() {
|
|
5657
|
-
console.warn("[useNodeProperties]
|
|
5968
|
+
console.warn("[useNodeProperties] No provider - cannot set properties");
|
|
5658
5969
|
}, []);
|
|
5970
|
+
if (devContext) {
|
|
5971
|
+
return [
|
|
5972
|
+
devData,
|
|
5973
|
+
devSetter
|
|
5974
|
+
];
|
|
5975
|
+
}
|
|
5659
5976
|
return [
|
|
5660
5977
|
{},
|
|
5661
5978
|
noopSetter
|
|
5662
5979
|
];
|
|
5663
5980
|
}
|
|
5664
5981
|
function useInferredType(fieldName) {
|
|
5982
|
+
var devContext = React2.useContext(DevContext);
|
|
5983
|
+
var _React2_useState = _sliced_to_array(React2.useState(function() {
|
|
5984
|
+
var _devContext_inferredTypes;
|
|
5985
|
+
return devContext === null || devContext === void 0 ? void 0 : (_devContext_inferredTypes = devContext.inferredTypes) === null || _devContext_inferredTypes === void 0 ? void 0 : _devContext_inferredTypes[fieldName];
|
|
5986
|
+
}), 2), devInferredType = _React2_useState[0], setDevInferredType = _React2_useState[1];
|
|
5987
|
+
React2__namespace.default.useEffect(function() {
|
|
5988
|
+
if (devContext) {
|
|
5989
|
+
setDevInferredType(devContext.inferredTypes[fieldName]);
|
|
5990
|
+
}
|
|
5991
|
+
}, [
|
|
5992
|
+
devContext,
|
|
5993
|
+
fieldName,
|
|
5994
|
+
devContext === null || devContext === void 0 ? void 0 : devContext.inferredTypes
|
|
5995
|
+
]);
|
|
5996
|
+
if (devContext) {
|
|
5997
|
+
return devInferredType;
|
|
5998
|
+
}
|
|
5665
5999
|
return void 0;
|
|
5666
6000
|
}
|
|
5667
6001
|
function useSetInferredType() {
|
|
6002
|
+
var devContext = React2.useContext(DevContext);
|
|
5668
6003
|
return React2.useCallback(function(fieldName, type) {
|
|
5669
|
-
|
|
5670
|
-
|
|
6004
|
+
if (devContext) {
|
|
6005
|
+
devContext.setInferredType(fieldName, type);
|
|
6006
|
+
} else {
|
|
6007
|
+
console.warn('[useSetInferredType] No provider - cannot set "'.concat(fieldName, '" to "').concat(type, '"'));
|
|
6008
|
+
}
|
|
6009
|
+
}, [
|
|
6010
|
+
devContext
|
|
6011
|
+
]);
|
|
6012
|
+
}
|
|
6013
|
+
function useClearInferredType() {
|
|
6014
|
+
var devContext = React2.useContext(DevContext);
|
|
6015
|
+
return React2.useCallback(function(fieldName) {
|
|
6016
|
+
if (devContext) {
|
|
6017
|
+
devContext.clearInferredType(fieldName);
|
|
6018
|
+
} else {
|
|
6019
|
+
console.warn('[useClearInferredType] No provider - cannot clear "'.concat(fieldName, '"'));
|
|
6020
|
+
}
|
|
6021
|
+
}, [
|
|
6022
|
+
devContext
|
|
6023
|
+
]);
|
|
6024
|
+
}
|
|
6025
|
+
function useClearAllInferredTypes() {
|
|
6026
|
+
var devContext = React2.useContext(DevContext);
|
|
6027
|
+
return React2.useCallback(function() {
|
|
6028
|
+
if (devContext) {
|
|
6029
|
+
devContext.clearAllInferredTypes();
|
|
6030
|
+
} else {
|
|
6031
|
+
console.warn("[useClearAllInferredTypes] No provider - cannot clear all types");
|
|
6032
|
+
}
|
|
6033
|
+
}, [
|
|
6034
|
+
devContext
|
|
6035
|
+
]);
|
|
5671
6036
|
}
|
|
5672
6037
|
function useAllInferredTypes() {
|
|
6038
|
+
var devContext = React2.useContext(DevContext);
|
|
6039
|
+
var _React2_useState = _sliced_to_array(React2.useState(function() {
|
|
6040
|
+
var _devContext_inferredTypes;
|
|
6041
|
+
return (_devContext_inferredTypes = devContext === null || devContext === void 0 ? void 0 : devContext.inferredTypes) !== null && _devContext_inferredTypes !== void 0 ? _devContext_inferredTypes : {};
|
|
6042
|
+
}), 2), devTypes = _React2_useState[0], setDevTypes = _React2_useState[1];
|
|
6043
|
+
React2__namespace.default.useEffect(function() {
|
|
6044
|
+
if (devContext) {
|
|
6045
|
+
setDevTypes(_object_spread({}, devContext.inferredTypes));
|
|
6046
|
+
}
|
|
6047
|
+
}, [
|
|
6048
|
+
devContext,
|
|
6049
|
+
devContext === null || devContext === void 0 ? void 0 : devContext.inferredTypes
|
|
6050
|
+
]);
|
|
6051
|
+
if (devContext) {
|
|
6052
|
+
return devTypes;
|
|
6053
|
+
}
|
|
5673
6054
|
return {};
|
|
5674
6055
|
}
|
|
5675
6056
|
function useSetProperty() {
|
|
6057
|
+
var devContext = React2.useContext(DevContext);
|
|
5676
6058
|
return React2.useCallback(function(key, value) {
|
|
5677
|
-
|
|
5678
|
-
|
|
6059
|
+
if (devContext) {
|
|
6060
|
+
devContext.setProperty(key, value);
|
|
6061
|
+
} else {
|
|
6062
|
+
console.warn('[useSetProperty] No provider - cannot set "'.concat(key, '"'));
|
|
6063
|
+
}
|
|
6064
|
+
}, [
|
|
6065
|
+
devContext
|
|
6066
|
+
]);
|
|
5679
6067
|
}
|
|
5680
6068
|
function useFieldValidation() {
|
|
5681
6069
|
var setFieldRequired = React2.useCallback(function(fieldName, required) {
|