@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.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import * as class_variance_authority_types from 'class-variance-authority/types'
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { VariantProps } from 'class-variance-authority';
|
|
4
4
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
5
|
-
export { i as fields } from './index-
|
|
5
|
+
export { i as fields } from './index-B-kAG1RW.cjs';
|
|
6
6
|
|
|
7
7
|
declare const buttonVariants: (props?: ({
|
|
8
8
|
variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | null | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as class_variance_authority_types from 'class-variance-authority/types'
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { VariantProps } from 'class-variance-authority';
|
|
4
4
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
5
|
-
export { i as fields } from './index-
|
|
5
|
+
export { i as fields } from './index-B-kAG1RW.js';
|
|
6
6
|
|
|
7
7
|
declare const buttonVariants: (props?: ({
|
|
8
8
|
variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | null | undefined;
|
package/dist/index.js
CHANGED
|
@@ -158,7 +158,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
158
158
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
159
159
|
}
|
|
160
160
|
import * as React2 from 'react';
|
|
161
|
-
import React2__default, { createContext, useContext, useCallback } from 'react';
|
|
161
|
+
import React2__default, { createContext, useContext, useState, useCallback } from 'react';
|
|
162
162
|
import { Slot } from '@radix-ui/react-slot';
|
|
163
163
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
164
164
|
import { CheckIcon, CircleIcon, ChevronRightIcon, ChevronDownIcon, ChevronUpIcon } from 'lucide-react';
|
|
@@ -4858,21 +4858,21 @@ function cn() {
|
|
|
4858
4858
|
return twMerge(clsx(inputs));
|
|
4859
4859
|
}
|
|
4860
4860
|
// src/components/ui/button.tsx
|
|
4861
|
-
var buttonVariants = cva("
|
|
4861
|
+
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", {
|
|
4862
4862
|
variants: {
|
|
4863
4863
|
variant: {
|
|
4864
|
-
default: "
|
|
4865
|
-
destructive: "
|
|
4866
|
-
outline: "
|
|
4867
|
-
secondary: "
|
|
4868
|
-
ghost: "
|
|
4869
|
-
link: "
|
|
4864
|
+
default: "uii:bg-primary uii:text-primary-foreground uii:shadow-xs uii:hover:bg-primary/90 uii:select-none",
|
|
4865
|
+
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",
|
|
4866
|
+
outline: "uii:border uii:border-input uii:bg-background uii:shadow-xs uii:hover:bg-accent uii:hover:text-accent-foreground",
|
|
4867
|
+
secondary: "uii:bg-secondary uii:text-secondary-foreground uii:shadow-xs uii:hover:bg-secondary/80",
|
|
4868
|
+
ghost: "uii:hover:bg-accent uii:hover:text-accent-foreground",
|
|
4869
|
+
link: "uii:text-primary uii:underline-offset-4 uii:hover:underline"
|
|
4870
4870
|
},
|
|
4871
4871
|
size: {
|
|
4872
|
-
default: "
|
|
4873
|
-
sm: "
|
|
4874
|
-
lg: "
|
|
4875
|
-
icon: "
|
|
4872
|
+
default: "uii:h-9 uii:px-4 uii:py-2 uii:has-[>svg]:px-3",
|
|
4873
|
+
sm: "uii:h-8 uii:rounded-sm uii:gap-1.5 uii:px-3 uii:has-[>svg]:px-2.5",
|
|
4874
|
+
lg: "uii:h-10 uii:rounded-sm uii:px-6 uii:has-[>svg]:px-4",
|
|
4875
|
+
icon: "uii:size-9"
|
|
4876
4876
|
}
|
|
4877
4877
|
},
|
|
4878
4878
|
defaultVariants: {
|
|
@@ -5102,18 +5102,39 @@ __export(fields_exports, {
|
|
|
5102
5102
|
TemplateFieldProvider: function() {
|
|
5103
5103
|
return TemplateFieldProvider;
|
|
5104
5104
|
},
|
|
5105
|
+
computeExtendedType: function() {
|
|
5106
|
+
return computeExtendedType;
|
|
5107
|
+
},
|
|
5108
|
+
filterOperatorsByType: function() {
|
|
5109
|
+
return filterOperatorsByType;
|
|
5110
|
+
},
|
|
5111
|
+
getNumberConstants: function() {
|
|
5112
|
+
return getNumberConstants;
|
|
5113
|
+
},
|
|
5105
5114
|
getOperatorsForType: function() {
|
|
5106
5115
|
return getOperatorsForType;
|
|
5107
5116
|
},
|
|
5117
|
+
getStringConstants: function() {
|
|
5118
|
+
return getStringConstants;
|
|
5119
|
+
},
|
|
5108
5120
|
intersectTypes: function() {
|
|
5109
5121
|
return intersectTypes;
|
|
5110
5122
|
},
|
|
5111
5123
|
parseInferSyntax: function() {
|
|
5112
5124
|
return parseInferSyntax;
|
|
5113
5125
|
},
|
|
5126
|
+
parseInferredTypes: function() {
|
|
5127
|
+
return parseInferredTypes;
|
|
5128
|
+
},
|
|
5114
5129
|
useAllInferredTypes: function() {
|
|
5115
5130
|
return useAllInferredTypes;
|
|
5116
5131
|
},
|
|
5132
|
+
useClearAllInferredTypes: function() {
|
|
5133
|
+
return useClearAllInferredTypes;
|
|
5134
|
+
},
|
|
5135
|
+
useClearInferredType: function() {
|
|
5136
|
+
return useClearInferredType;
|
|
5137
|
+
},
|
|
5117
5138
|
useFieldPath: function() {
|
|
5118
5139
|
return useFieldPath;
|
|
5119
5140
|
},
|
|
@@ -5148,8 +5169,53 @@ __export(fields_exports, {
|
|
|
5148
5169
|
return useTemplateFieldContext;
|
|
5149
5170
|
}
|
|
5150
5171
|
});
|
|
5172
|
+
var DevContext = createContext(null);
|
|
5173
|
+
function useResolvedExpectedType(expectedType, devCtx) {
|
|
5174
|
+
var inferredTypes = devCtx === null || devCtx === void 0 ? void 0 : devCtx.inferredTypes;
|
|
5175
|
+
return React2.useMemo(function() {
|
|
5176
|
+
var _match_;
|
|
5177
|
+
if (!expectedType) return "any";
|
|
5178
|
+
if (!expectedType.startsWith("$infer<")) {
|
|
5179
|
+
return expectedType;
|
|
5180
|
+
}
|
|
5181
|
+
var match = expectedType.match(/^\$infer<(.+)>$/);
|
|
5182
|
+
if (!match) return expectedType;
|
|
5183
|
+
var content = ((_match_ = match[1]) === null || _match_ === void 0 ? void 0 : _match_.trim()) || "";
|
|
5184
|
+
if (content.startsWith("[") && content.endsWith("]")) {
|
|
5185
|
+
var arrayContent = content.slice(1, -1);
|
|
5186
|
+
var fieldNames = arrayContent.split(",").map(function(s) {
|
|
5187
|
+
return s.trim().replace(/^["']|["']$/g, "");
|
|
5188
|
+
}).filter(Boolean);
|
|
5189
|
+
if (!inferredTypes) {
|
|
5190
|
+
return "Subscribing to: ".concat(fieldNames.join(", "));
|
|
5191
|
+
}
|
|
5192
|
+
var types = fieldNames.map(function(name) {
|
|
5193
|
+
return inferredTypes[name];
|
|
5194
|
+
}).filter(function(t) {
|
|
5195
|
+
return !!t && t.length > 0;
|
|
5196
|
+
});
|
|
5197
|
+
if (types.length === 0) {
|
|
5198
|
+
return "Waiting for: ".concat(fieldNames.join(", "));
|
|
5199
|
+
}
|
|
5200
|
+
return types.length === 1 ? types[0] : types.join(" & ");
|
|
5201
|
+
}
|
|
5202
|
+
if (!content.includes("|") && /^[a-zA-Z_][a-zA-Z0-9_\-]*$/.test(content)) {
|
|
5203
|
+
if (!inferredTypes) {
|
|
5204
|
+
return "Subscribing to: ".concat(content);
|
|
5205
|
+
}
|
|
5206
|
+
var resolvedType = inferredTypes[content];
|
|
5207
|
+
return resolvedType || "Waiting for: ".concat(content);
|
|
5208
|
+
}
|
|
5209
|
+
return content;
|
|
5210
|
+
}, [
|
|
5211
|
+
expectedType,
|
|
5212
|
+
inferredTypes
|
|
5213
|
+
]);
|
|
5214
|
+
}
|
|
5151
5215
|
function Input(param) {
|
|
5152
5216
|
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;
|
|
5217
|
+
var devCtx = useContext(DevContext);
|
|
5218
|
+
var resolvedExpectedType = useResolvedExpectedType(expectedType, devCtx);
|
|
5153
5219
|
var displayValue = React2.useMemo(function() {
|
|
5154
5220
|
if (value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && "expression" in value) {
|
|
5155
5221
|
return value.expression || "";
|
|
@@ -5177,6 +5243,7 @@ function Input(param) {
|
|
|
5177
5243
|
onChange
|
|
5178
5244
|
]);
|
|
5179
5245
|
var showError = hasRequiredError || required && !displayValue;
|
|
5246
|
+
var isWaiting = resolvedExpectedType.startsWith("Waiting for:") || resolvedExpectedType.startsWith("Subscribing to:");
|
|
5180
5247
|
return /* @__PURE__ */ React2.createElement("div", {
|
|
5181
5248
|
className: cn("uii:mb-2", className)
|
|
5182
5249
|
}, /* @__PURE__ */ React2.createElement("div", {
|
|
@@ -5184,9 +5251,10 @@ function Input(param) {
|
|
|
5184
5251
|
}, /* @__PURE__ */ React2.createElement("label", {
|
|
5185
5252
|
htmlFor: fieldName,
|
|
5186
5253
|
className: "uii:text-xs uii:font-bold uii:text-muted-foreground"
|
|
5187
|
-
}, label, ":"),
|
|
5188
|
-
className: "uii:-mt-2 uii:inline-flex uii:px-1 uii:py-0.5 uii:
|
|
5189
|
-
|
|
5254
|
+
}, label, ":"), resolvedExpectedType !== "$.interface.timer" && /* @__PURE__ */ React2.createElement("span", {
|
|
5255
|
+
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"),
|
|
5256
|
+
title: resolvedExpectedType
|
|
5257
|
+
}, resolvedExpectedType), showError && /* @__PURE__ */ React2.createElement("span", {
|
|
5190
5258
|
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"
|
|
5191
5259
|
}, "Required")), /* @__PURE__ */ React2.createElement("div", {
|
|
5192
5260
|
className: "uii:mt-0.5"
|
|
@@ -5283,8 +5351,52 @@ function SelectScrollDownButton(_param) {
|
|
|
5283
5351
|
}));
|
|
5284
5352
|
}
|
|
5285
5353
|
// src/components/fields/Select.tsx
|
|
5354
|
+
function useResolvedExpectedType2(expectedType, devCtx) {
|
|
5355
|
+
var inferredTypes = devCtx === null || devCtx === void 0 ? void 0 : devCtx.inferredTypes;
|
|
5356
|
+
return React2.useMemo(function() {
|
|
5357
|
+
var _match_;
|
|
5358
|
+
if (!expectedType) return "any";
|
|
5359
|
+
if (!expectedType.startsWith("$infer<")) {
|
|
5360
|
+
return expectedType;
|
|
5361
|
+
}
|
|
5362
|
+
var match = expectedType.match(/^\$infer<(.+)>$/);
|
|
5363
|
+
if (!match) return expectedType;
|
|
5364
|
+
var content = ((_match_ = match[1]) === null || _match_ === void 0 ? void 0 : _match_.trim()) || "";
|
|
5365
|
+
if (content.startsWith("[") && content.endsWith("]")) {
|
|
5366
|
+
var arrayContent = content.slice(1, -1);
|
|
5367
|
+
var fieldNames = arrayContent.split(",").map(function(s) {
|
|
5368
|
+
return s.trim().replace(/^["']|["']$/g, "");
|
|
5369
|
+
}).filter(Boolean);
|
|
5370
|
+
if (!inferredTypes) {
|
|
5371
|
+
return "Subscribing to: ".concat(fieldNames.join(", "));
|
|
5372
|
+
}
|
|
5373
|
+
var types = fieldNames.map(function(name) {
|
|
5374
|
+
return inferredTypes[name];
|
|
5375
|
+
}).filter(function(t) {
|
|
5376
|
+
return !!t && t.length > 0;
|
|
5377
|
+
});
|
|
5378
|
+
if (types.length === 0) {
|
|
5379
|
+
return "Waiting for: ".concat(fieldNames.join(", "));
|
|
5380
|
+
}
|
|
5381
|
+
return types.length === 1 ? types[0] : types.join(" & ");
|
|
5382
|
+
}
|
|
5383
|
+
if (!content.includes("|") && /^[a-zA-Z_][a-zA-Z0-9_\-]*$/.test(content)) {
|
|
5384
|
+
if (!inferredTypes) {
|
|
5385
|
+
return "Subscribing to: ".concat(content);
|
|
5386
|
+
}
|
|
5387
|
+
var resolvedType = inferredTypes[content];
|
|
5388
|
+
return resolvedType || "Waiting for: ".concat(content);
|
|
5389
|
+
}
|
|
5390
|
+
return content;
|
|
5391
|
+
}, [
|
|
5392
|
+
expectedType,
|
|
5393
|
+
inferredTypes
|
|
5394
|
+
]);
|
|
5395
|
+
}
|
|
5286
5396
|
function Select2(param) {
|
|
5287
5397
|
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;
|
|
5398
|
+
var devCtx = useContext(DevContext);
|
|
5399
|
+
var resolvedExpectedType = useResolvedExpectedType2(expectedType, devCtx);
|
|
5288
5400
|
var _React2_useState = _sliced_to_array(React2.useState(false), 2), isExpressionMode = _React2_useState[0], setIsExpressionMode = _React2_useState[1];
|
|
5289
5401
|
var _React2_useState1 = _sliced_to_array(React2.useState(""), 2), expressionValue = _React2_useState1[0], setExpressionValue = _React2_useState1[1];
|
|
5290
5402
|
var options = React2.useMemo(function() {
|
|
@@ -5373,6 +5485,7 @@ function Select2(param) {
|
|
|
5373
5485
|
},
|
|
5374
5486
|
hasError: showError
|
|
5375
5487
|
};
|
|
5488
|
+
var isWaiting = resolvedExpectedType.startsWith("Waiting for:") || resolvedExpectedType.startsWith("Subscribing to:");
|
|
5376
5489
|
return /* @__PURE__ */ React2.createElement("div", {
|
|
5377
5490
|
className: cn("uii:mb-2", className)
|
|
5378
5491
|
}, /* @__PURE__ */ React2.createElement("div", {
|
|
@@ -5380,9 +5493,10 @@ function Select2(param) {
|
|
|
5380
5493
|
}, /* @__PURE__ */ React2.createElement("label", {
|
|
5381
5494
|
htmlFor: fieldName,
|
|
5382
5495
|
className: "uii:text-xs uii:font-bold uii:text-muted-foreground"
|
|
5383
|
-
}, label, ":"),
|
|
5384
|
-
className: "uii:-mt-2 uii:inline-flex uii:px-1 uii:py-0.5 uii:
|
|
5385
|
-
|
|
5496
|
+
}, label, ":"), resolvedExpectedType !== "$.interface.timer" && /* @__PURE__ */ React2.createElement("span", {
|
|
5497
|
+
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"),
|
|
5498
|
+
title: resolvedExpectedType
|
|
5499
|
+
}, resolvedExpectedType), showError && /* @__PURE__ */ React2.createElement("span", {
|
|
5386
5500
|
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"
|
|
5387
5501
|
}, "Required")), /* @__PURE__ */ React2.createElement("div", {
|
|
5388
5502
|
className: "uii:mt-0.5"
|
|
@@ -5452,6 +5566,137 @@ function Select2(param) {
|
|
|
5452
5566
|
}, opt.node ? opt.node : /* @__PURE__ */ React2.createElement(React2.Fragment, null, opt.label));
|
|
5453
5567
|
})))));
|
|
5454
5568
|
}
|
|
5569
|
+
// src/components/template-editor/operatorTypes.ts
|
|
5570
|
+
function parseInferredTypes(typeStr) {
|
|
5571
|
+
var result = {
|
|
5572
|
+
baseTypes: [],
|
|
5573
|
+
stringConstants: [],
|
|
5574
|
+
numberConstants: [],
|
|
5575
|
+
hasConstants: false,
|
|
5576
|
+
rawTypes: []
|
|
5577
|
+
};
|
|
5578
|
+
if (!typeStr || typeStr === "any" || typeStr === "unknown") {
|
|
5579
|
+
result.baseTypes = [
|
|
5580
|
+
"any"
|
|
5581
|
+
];
|
|
5582
|
+
result.rawTypes = [
|
|
5583
|
+
"any"
|
|
5584
|
+
];
|
|
5585
|
+
return result;
|
|
5586
|
+
}
|
|
5587
|
+
var types = typeStr.split("|").map(function(t) {
|
|
5588
|
+
return t.trim();
|
|
5589
|
+
}).filter(Boolean);
|
|
5590
|
+
var baseTypesSet = /* @__PURE__ */ new Set();
|
|
5591
|
+
var rawTypesSet = /* @__PURE__ */ new Set();
|
|
5592
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5593
|
+
try {
|
|
5594
|
+
for(var _iterator = types[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5595
|
+
var t = _step.value;
|
|
5596
|
+
rawTypesSet.add(t);
|
|
5597
|
+
var stringLiteralMatch = t.match(/^["'](.*)["']$/);
|
|
5598
|
+
if (stringLiteralMatch && stringLiteralMatch[1] !== void 0) {
|
|
5599
|
+
result.stringConstants.push(stringLiteralMatch[1]);
|
|
5600
|
+
baseTypesSet.add("string");
|
|
5601
|
+
result.hasConstants = true;
|
|
5602
|
+
continue;
|
|
5603
|
+
}
|
|
5604
|
+
if (/^-?\d+(\.\d+)?$/.test(t)) {
|
|
5605
|
+
result.numberConstants.push(parseFloat(t));
|
|
5606
|
+
baseTypesSet.add("number");
|
|
5607
|
+
result.hasConstants = true;
|
|
5608
|
+
continue;
|
|
5609
|
+
}
|
|
5610
|
+
if (t === "true" || t === "false") {
|
|
5611
|
+
baseTypesSet.add("boolean");
|
|
5612
|
+
result.hasConstants = true;
|
|
5613
|
+
continue;
|
|
5614
|
+
}
|
|
5615
|
+
baseTypesSet.add(t);
|
|
5616
|
+
}
|
|
5617
|
+
} catch (err) {
|
|
5618
|
+
_didIteratorError = true;
|
|
5619
|
+
_iteratorError = err;
|
|
5620
|
+
} finally{
|
|
5621
|
+
try {
|
|
5622
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5623
|
+
_iterator.return();
|
|
5624
|
+
}
|
|
5625
|
+
} finally{
|
|
5626
|
+
if (_didIteratorError) {
|
|
5627
|
+
throw _iteratorError;
|
|
5628
|
+
}
|
|
5629
|
+
}
|
|
5630
|
+
}
|
|
5631
|
+
result.baseTypes = Array.from(baseTypesSet);
|
|
5632
|
+
result.rawTypes = Array.from(rawTypesSet);
|
|
5633
|
+
return result;
|
|
5634
|
+
}
|
|
5635
|
+
function computeExtendedType(inferredType, opDef) {
|
|
5636
|
+
if (opDef.narrowsTo === "never") {
|
|
5637
|
+
return "never";
|
|
5638
|
+
}
|
|
5639
|
+
var parsed = parseInferredTypes(inferredType);
|
|
5640
|
+
var matchingLiterals = [];
|
|
5641
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5642
|
+
try {
|
|
5643
|
+
for(var _iterator = parsed.rawTypes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5644
|
+
var t = _step.value;
|
|
5645
|
+
if (opDef.narrowsTo === "string") {
|
|
5646
|
+
if (t === "string") ;
|
|
5647
|
+
else if (/^["'].*["']$/.test(t)) {
|
|
5648
|
+
matchingLiterals.push(t);
|
|
5649
|
+
}
|
|
5650
|
+
} else if (opDef.narrowsTo === "number") {
|
|
5651
|
+
if (t === "number") ;
|
|
5652
|
+
else if (/^-?\d+(\.\d+)?$/.test(t)) {
|
|
5653
|
+
matchingLiterals.push(t);
|
|
5654
|
+
}
|
|
5655
|
+
} else if (opDef.narrowsTo === "boolean") {
|
|
5656
|
+
if (t === "boolean") ;
|
|
5657
|
+
else if (t === "true" || t === "false") {
|
|
5658
|
+
matchingLiterals.push(t);
|
|
5659
|
+
}
|
|
5660
|
+
}
|
|
5661
|
+
}
|
|
5662
|
+
} catch (err) {
|
|
5663
|
+
_didIteratorError = true;
|
|
5664
|
+
_iteratorError = err;
|
|
5665
|
+
} finally{
|
|
5666
|
+
try {
|
|
5667
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5668
|
+
_iterator.return();
|
|
5669
|
+
}
|
|
5670
|
+
} finally{
|
|
5671
|
+
if (_didIteratorError) {
|
|
5672
|
+
throw _iteratorError;
|
|
5673
|
+
}
|
|
5674
|
+
}
|
|
5675
|
+
}
|
|
5676
|
+
var result = _to_consumable_array(matchingLiterals);
|
|
5677
|
+
if (opDef.extendsWithBase || matchingLiterals.length === 0) {
|
|
5678
|
+
if (!result.includes(opDef.narrowsTo)) {
|
|
5679
|
+
result.push(opDef.narrowsTo);
|
|
5680
|
+
}
|
|
5681
|
+
}
|
|
5682
|
+
return result.length > 0 ? result.join(" | ") : opDef.narrowsTo;
|
|
5683
|
+
}
|
|
5684
|
+
function filterOperatorsByType(operators, inferredType) {
|
|
5685
|
+
var parsed = parseInferredTypes(inferredType);
|
|
5686
|
+
var baseTypes = parsed.baseTypes;
|
|
5687
|
+
return operators.filter(function(op) {
|
|
5688
|
+
if (op.types.includes("any")) return true;
|
|
5689
|
+
return op.types.some(function(t) {
|
|
5690
|
+
return baseTypes.includes(t) || baseTypes.includes("any");
|
|
5691
|
+
});
|
|
5692
|
+
});
|
|
5693
|
+
}
|
|
5694
|
+
function getStringConstants(inferredType) {
|
|
5695
|
+
return parseInferredTypes(inferredType).stringConstants;
|
|
5696
|
+
}
|
|
5697
|
+
function getNumberConstants(inferredType) {
|
|
5698
|
+
return parseInferredTypes(inferredType).numberConstants;
|
|
5699
|
+
}
|
|
5455
5700
|
// src/components/fields/index.tsx
|
|
5456
5701
|
function useTemplateFieldContext() {
|
|
5457
5702
|
return {
|
|
@@ -5487,7 +5732,18 @@ function NestedFieldProvider(param) {
|
|
|
5487
5732
|
}
|
|
5488
5733
|
var InferredTypesContext = createContext(null);
|
|
5489
5734
|
function useInferredTypes() {
|
|
5490
|
-
|
|
5735
|
+
var devContext = useContext(DevContext);
|
|
5736
|
+
var realContext = useContext(InferredTypesContext);
|
|
5737
|
+
if (devContext) {
|
|
5738
|
+
return {
|
|
5739
|
+
inferredTypes: devContext.inferredTypes,
|
|
5740
|
+
setInferredType: devContext.setInferredType,
|
|
5741
|
+
getInferredType: devContext.getInferredType,
|
|
5742
|
+
clearInferredType: devContext.clearInferredType,
|
|
5743
|
+
clearAllInferredTypes: devContext.clearAllInferredTypes
|
|
5744
|
+
};
|
|
5745
|
+
}
|
|
5746
|
+
return realContext;
|
|
5491
5747
|
}
|
|
5492
5748
|
function InferredTypesProvider(param) {
|
|
5493
5749
|
var children = param.children;
|
|
@@ -5617,43 +5873,175 @@ function NodePropertyProvider(param) {
|
|
|
5617
5873
|
return /* @__PURE__ */ React2__default.createElement(React2__default.Fragment, null, children);
|
|
5618
5874
|
}
|
|
5619
5875
|
function useIsInNodePropertyProvider() {
|
|
5620
|
-
|
|
5876
|
+
var devContext = useContext(DevContext);
|
|
5877
|
+
return devContext !== null;
|
|
5621
5878
|
}
|
|
5622
5879
|
function useNodeProperty(key) {
|
|
5880
|
+
var devContext = useContext(DevContext);
|
|
5881
|
+
var _useState = _sliced_to_array(useState(function() {
|
|
5882
|
+
var _devContext_data;
|
|
5883
|
+
return devContext === null || devContext === void 0 ? void 0 : (_devContext_data = devContext.data) === null || _devContext_data === void 0 ? void 0 : _devContext_data[key];
|
|
5884
|
+
}), 2), devValue = _useState[0], setDevValue = _useState[1];
|
|
5885
|
+
React2__default.useEffect(function() {
|
|
5886
|
+
if (devContext) {
|
|
5887
|
+
setDevValue(devContext.data[key]);
|
|
5888
|
+
}
|
|
5889
|
+
}, [
|
|
5890
|
+
devContext,
|
|
5891
|
+
key
|
|
5892
|
+
]);
|
|
5893
|
+
var devSetter = useCallback(function(value) {
|
|
5894
|
+
if (devContext) {
|
|
5895
|
+
devContext.setProperty(key, value);
|
|
5896
|
+
setDevValue(value);
|
|
5897
|
+
}
|
|
5898
|
+
}, [
|
|
5899
|
+
devContext,
|
|
5900
|
+
key
|
|
5901
|
+
]);
|
|
5623
5902
|
var noopSetter = useCallback(function() {
|
|
5624
|
-
console.warn('[useNodeProperty]
|
|
5903
|
+
console.warn('[useNodeProperty] No provider - cannot set "'.concat(key, '"'));
|
|
5625
5904
|
}, [
|
|
5626
5905
|
key
|
|
5627
5906
|
]);
|
|
5907
|
+
if (devContext) {
|
|
5908
|
+
return [
|
|
5909
|
+
devValue,
|
|
5910
|
+
devSetter
|
|
5911
|
+
];
|
|
5912
|
+
}
|
|
5628
5913
|
return [
|
|
5629
5914
|
void 0,
|
|
5630
5915
|
noopSetter
|
|
5631
5916
|
];
|
|
5632
5917
|
}
|
|
5633
5918
|
function useNodeProperties() {
|
|
5919
|
+
var devContext = useContext(DevContext);
|
|
5920
|
+
var _useState = _sliced_to_array(useState(function() {
|
|
5921
|
+
var _devContext_data;
|
|
5922
|
+
return (_devContext_data = devContext === null || devContext === void 0 ? void 0 : devContext.data) !== null && _devContext_data !== void 0 ? _devContext_data : {};
|
|
5923
|
+
}), 2), devData = _useState[0], setDevData = _useState[1];
|
|
5924
|
+
React2__default.useEffect(function() {
|
|
5925
|
+
if (devContext) {
|
|
5926
|
+
setDevData(_object_spread({}, devContext.data));
|
|
5927
|
+
}
|
|
5928
|
+
}, [
|
|
5929
|
+
devContext,
|
|
5930
|
+
devContext === null || devContext === void 0 ? void 0 : devContext.data
|
|
5931
|
+
]);
|
|
5932
|
+
var devSetter = useCallback(function(updates) {
|
|
5933
|
+
if (devContext) {
|
|
5934
|
+
Object.entries(updates).forEach(function(param) {
|
|
5935
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
|
|
5936
|
+
devContext.setProperty(key, value);
|
|
5937
|
+
});
|
|
5938
|
+
setDevData(function(prev) {
|
|
5939
|
+
return _object_spread({}, prev, updates);
|
|
5940
|
+
});
|
|
5941
|
+
}
|
|
5942
|
+
}, [
|
|
5943
|
+
devContext
|
|
5944
|
+
]);
|
|
5634
5945
|
var noopSetter = useCallback(function() {
|
|
5635
|
-
console.warn("[useNodeProperties]
|
|
5946
|
+
console.warn("[useNodeProperties] No provider - cannot set properties");
|
|
5636
5947
|
}, []);
|
|
5948
|
+
if (devContext) {
|
|
5949
|
+
return [
|
|
5950
|
+
devData,
|
|
5951
|
+
devSetter
|
|
5952
|
+
];
|
|
5953
|
+
}
|
|
5637
5954
|
return [
|
|
5638
5955
|
{},
|
|
5639
5956
|
noopSetter
|
|
5640
5957
|
];
|
|
5641
5958
|
}
|
|
5642
5959
|
function useInferredType(fieldName) {
|
|
5960
|
+
var devContext = useContext(DevContext);
|
|
5961
|
+
var _useState = _sliced_to_array(useState(function() {
|
|
5962
|
+
var _devContext_inferredTypes;
|
|
5963
|
+
return devContext === null || devContext === void 0 ? void 0 : (_devContext_inferredTypes = devContext.inferredTypes) === null || _devContext_inferredTypes === void 0 ? void 0 : _devContext_inferredTypes[fieldName];
|
|
5964
|
+
}), 2), devInferredType = _useState[0], setDevInferredType = _useState[1];
|
|
5965
|
+
React2__default.useEffect(function() {
|
|
5966
|
+
if (devContext) {
|
|
5967
|
+
setDevInferredType(devContext.inferredTypes[fieldName]);
|
|
5968
|
+
}
|
|
5969
|
+
}, [
|
|
5970
|
+
devContext,
|
|
5971
|
+
fieldName,
|
|
5972
|
+
devContext === null || devContext === void 0 ? void 0 : devContext.inferredTypes
|
|
5973
|
+
]);
|
|
5974
|
+
if (devContext) {
|
|
5975
|
+
return devInferredType;
|
|
5976
|
+
}
|
|
5643
5977
|
return void 0;
|
|
5644
5978
|
}
|
|
5645
5979
|
function useSetInferredType() {
|
|
5980
|
+
var devContext = useContext(DevContext);
|
|
5646
5981
|
return useCallback(function(fieldName, type) {
|
|
5647
|
-
|
|
5648
|
-
|
|
5982
|
+
if (devContext) {
|
|
5983
|
+
devContext.setInferredType(fieldName, type);
|
|
5984
|
+
} else {
|
|
5985
|
+
console.warn('[useSetInferredType] No provider - cannot set "'.concat(fieldName, '" to "').concat(type, '"'));
|
|
5986
|
+
}
|
|
5987
|
+
}, [
|
|
5988
|
+
devContext
|
|
5989
|
+
]);
|
|
5990
|
+
}
|
|
5991
|
+
function useClearInferredType() {
|
|
5992
|
+
var devContext = useContext(DevContext);
|
|
5993
|
+
return useCallback(function(fieldName) {
|
|
5994
|
+
if (devContext) {
|
|
5995
|
+
devContext.clearInferredType(fieldName);
|
|
5996
|
+
} else {
|
|
5997
|
+
console.warn('[useClearInferredType] No provider - cannot clear "'.concat(fieldName, '"'));
|
|
5998
|
+
}
|
|
5999
|
+
}, [
|
|
6000
|
+
devContext
|
|
6001
|
+
]);
|
|
6002
|
+
}
|
|
6003
|
+
function useClearAllInferredTypes() {
|
|
6004
|
+
var devContext = useContext(DevContext);
|
|
6005
|
+
return useCallback(function() {
|
|
6006
|
+
if (devContext) {
|
|
6007
|
+
devContext.clearAllInferredTypes();
|
|
6008
|
+
} else {
|
|
6009
|
+
console.warn("[useClearAllInferredTypes] No provider - cannot clear all types");
|
|
6010
|
+
}
|
|
6011
|
+
}, [
|
|
6012
|
+
devContext
|
|
6013
|
+
]);
|
|
5649
6014
|
}
|
|
5650
6015
|
function useAllInferredTypes() {
|
|
6016
|
+
var devContext = useContext(DevContext);
|
|
6017
|
+
var _useState = _sliced_to_array(useState(function() {
|
|
6018
|
+
var _devContext_inferredTypes;
|
|
6019
|
+
return (_devContext_inferredTypes = devContext === null || devContext === void 0 ? void 0 : devContext.inferredTypes) !== null && _devContext_inferredTypes !== void 0 ? _devContext_inferredTypes : {};
|
|
6020
|
+
}), 2), devTypes = _useState[0], setDevTypes = _useState[1];
|
|
6021
|
+
React2__default.useEffect(function() {
|
|
6022
|
+
if (devContext) {
|
|
6023
|
+
setDevTypes(_object_spread({}, devContext.inferredTypes));
|
|
6024
|
+
}
|
|
6025
|
+
}, [
|
|
6026
|
+
devContext,
|
|
6027
|
+
devContext === null || devContext === void 0 ? void 0 : devContext.inferredTypes
|
|
6028
|
+
]);
|
|
6029
|
+
if (devContext) {
|
|
6030
|
+
return devTypes;
|
|
6031
|
+
}
|
|
5651
6032
|
return {};
|
|
5652
6033
|
}
|
|
5653
6034
|
function useSetProperty() {
|
|
6035
|
+
var devContext = useContext(DevContext);
|
|
5654
6036
|
return useCallback(function(key, value) {
|
|
5655
|
-
|
|
5656
|
-
|
|
6037
|
+
if (devContext) {
|
|
6038
|
+
devContext.setProperty(key, value);
|
|
6039
|
+
} else {
|
|
6040
|
+
console.warn('[useSetProperty] No provider - cannot set "'.concat(key, '"'));
|
|
6041
|
+
}
|
|
6042
|
+
}, [
|
|
6043
|
+
devContext
|
|
6044
|
+
]);
|
|
5657
6045
|
}
|
|
5658
6046
|
function useFieldValidation() {
|
|
5659
6047
|
var setFieldRequired = useCallback(function(fieldName, required) {
|