@process.co/ui 0.0.9 → 0.0.10
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 +349 -284
- package/css/ui.css +0 -7
- package/dist/components/fields/index.cjs +130 -0
- 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 +126 -1
- package/dist/components/fields/index.js.map +1 -1
- package/dist/{index-nu_JyZnb.d.cts → index-DGN9LJqq.d.cts} +149 -2
- package/dist/{index-nu_JyZnb.d.ts → index-DGN9LJqq.d.ts} +149 -2
- package/dist/index.cjs +140 -0
- 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 +140 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -149,6 +149,140 @@ interface SelectRenderProps {
|
|
|
149
149
|
*/
|
|
150
150
|
declare function Select({ fieldName, label, value, onChange, options: rawOptions, disabled, placeholder, expectedType, required, hasRequiredError, className, children, }: SelectProps): React.JSX.Element;
|
|
151
151
|
|
|
152
|
+
/**
|
|
153
|
+
* Shared Operator Type Definitions and Utilities
|
|
154
|
+
*
|
|
155
|
+
* This module provides reusable types and utilities for building
|
|
156
|
+
* query builders with type-aware operators (Switch, IfThenElse, etc.)
|
|
157
|
+
*/
|
|
158
|
+
/**
|
|
159
|
+
* Standard operator types for condition builders.
|
|
160
|
+
* Custom UIs can extend this with their own operators.
|
|
161
|
+
*/
|
|
162
|
+
type BaseOperatorType = 'exists' | 'not_exists' | 'string_equals' | 'string_not_equals' | 'string_is_blank' | 'string_is_not_blank' | 'string_starts_with' | 'string_contains' | 'string_not_contains' | 'string_ends_with' | 'number_equals' | 'number_not_equals' | 'number_gt' | 'number_gte' | 'number_lt' | 'number_lte' | 'boolean_equals' | 'is_null' | 'is_not_null' | 'is_string' | 'is_not_string' | 'is_number' | 'is_not_number' | 'is_true' | 'is_false' | 'is_boolean' | 'is_not_boolean';
|
|
163
|
+
/**
|
|
164
|
+
* Generic operator definition that can be extended with custom operators.
|
|
165
|
+
*
|
|
166
|
+
* @template T - Additional operator types to include (defaults to never)
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* // Using base operators only
|
|
170
|
+
* const operators: OperatorDef[] = [...];
|
|
171
|
+
*
|
|
172
|
+
* // Extending with custom operators
|
|
173
|
+
* type MyOperator = 'expression' | 'custom_op';
|
|
174
|
+
* const operators: OperatorDef<MyOperator>[] = [...];
|
|
175
|
+
*/
|
|
176
|
+
type OperatorDef<T = never> = {
|
|
177
|
+
/** The operator value/key */
|
|
178
|
+
value: BaseOperatorType | T;
|
|
179
|
+
/** Which inferred types this applies to ('any' = always shown) */
|
|
180
|
+
types: string[];
|
|
181
|
+
/** Human-readable label for the operator */
|
|
182
|
+
label: string;
|
|
183
|
+
/** Short label for compact display (optional) */
|
|
184
|
+
shortLabel?: string;
|
|
185
|
+
/** Whether to show the value Input */
|
|
186
|
+
needsValue: boolean;
|
|
187
|
+
/** Type to register for narrowing ('never' = no narrowing) */
|
|
188
|
+
narrowsTo: string;
|
|
189
|
+
/** If true, union narrowed type with base type (e.g., narrowed | string) */
|
|
190
|
+
extendsWithBase?: boolean;
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* Result of parsing an inferred type string.
|
|
194
|
+
*/
|
|
195
|
+
type ParsedTypes = {
|
|
196
|
+
/** Deduplicated base types (string, number, boolean, any, etc.) */
|
|
197
|
+
baseTypes: string[];
|
|
198
|
+
/** Extracted string literal constants */
|
|
199
|
+
stringConstants: string[];
|
|
200
|
+
/** Extracted number literal constants */
|
|
201
|
+
numberConstants: number[];
|
|
202
|
+
/** Whether any literal constants were found */
|
|
203
|
+
hasConstants: boolean;
|
|
204
|
+
/** Original type strings for union building */
|
|
205
|
+
rawTypes: string[];
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* Parse an inferred type string into base types and extract any literal constants.
|
|
209
|
+
*
|
|
210
|
+
* Handles:
|
|
211
|
+
* - Base types: string, number, boolean
|
|
212
|
+
* - Union types: string | number
|
|
213
|
+
* - String literals: "Hans" | "Karl" | "Eddie" | "Theo" | "Fritz" -> treated as string type
|
|
214
|
+
* - Number literals: 1 | 2 | 3 -> treated as number type
|
|
215
|
+
* - Boolean literals: true | false -> treated as boolean type
|
|
216
|
+
*
|
|
217
|
+
* @param typeStr - The inferred type string to parse
|
|
218
|
+
* @returns Parsed type information
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* parseInferredTypes('"Hans" | "Karl" | "Eddie" | "Theo" | "Fritz" | string')
|
|
222
|
+
* // Returns:
|
|
223
|
+
* // {
|
|
224
|
+
* // baseTypes: ['string'],
|
|
225
|
+
* // stringConstants: ['Hans', 'Karl', 'Eddie', 'Theo', 'Fritz'],
|
|
226
|
+
* // numberConstants: [],
|
|
227
|
+
* // hasConstants: true,
|
|
228
|
+
* // rawTypes: ['"Hans"', '"Karl"', '"Eddie"', '"Theo"', '"Fritz"', 'string']
|
|
229
|
+
* // }
|
|
230
|
+
*/
|
|
231
|
+
declare function parseInferredTypes(typeStr: string): ParsedTypes;
|
|
232
|
+
/**
|
|
233
|
+
* Compute the expected type for a value input based on the operator.
|
|
234
|
+
*
|
|
235
|
+
* If `extendsWithBase` is true, the result includes both:
|
|
236
|
+
* - The matching literal types from the inferred type
|
|
237
|
+
* - The base type (to allow arbitrary input)
|
|
238
|
+
*
|
|
239
|
+
* This enables scenarios like:
|
|
240
|
+
* - `string_equals` on `"Hans" | "Karl" | "Eddie" | "Theo" | "Fritz" | string"` → expects `"Hans" | "Karl" | "Eddie" | "Theo" | "Fritz" | string"` (exact match)
|
|
241
|
+
* - `string_starts_with` on `"Hans" | "Karl" | "Eddie" | "Theo" | "Fritz" | string"` → expects `"Hans" | "Karl" | "Eddie" | "Theo" | "Fritz" | string"` (allows partial match)
|
|
242
|
+
*
|
|
243
|
+
* @param inferredType - The inferred type string from the statement
|
|
244
|
+
* @param opDef - The operator definition
|
|
245
|
+
* @returns The computed expected type string
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* const opDef = { narrowsTo: 'string', extendsWithBase: true, ... };
|
|
249
|
+
* computeExtendedType('"Hans" | "Karl" | "Eddie" | "Theo" | "Fritz" | string', opDef);
|
|
250
|
+
* // Returns: '"Hans" | "Karl" | "Eddie" | "Theo" | "Fritz" | string'
|
|
251
|
+
*/
|
|
252
|
+
declare function computeExtendedType<T = never>(inferredType: string, opDef: OperatorDef<T>): string;
|
|
253
|
+
/**
|
|
254
|
+
* Filter operators based on an inferred type.
|
|
255
|
+
* Returns only operators whose `types` include a matching base type.
|
|
256
|
+
*
|
|
257
|
+
* @param operators - Array of operator definitions
|
|
258
|
+
* @param inferredType - The inferred type string to filter by
|
|
259
|
+
* @returns Filtered array of operators
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* const filtered = filterOperatorsByType(OPERATORS, '"Hans" | "Karl" | "Eddie" | "Theo" | "Fritz" | string');
|
|
263
|
+
* // Returns operators with types: ['any'] or types: ['string']
|
|
264
|
+
*/
|
|
265
|
+
declare function filterOperatorsByType<T = never>(operators: OperatorDef<T>[], inferredType: string): OperatorDef<T>[];
|
|
266
|
+
/**
|
|
267
|
+
* Get string constants from an inferred type.
|
|
268
|
+
* Useful for showing constant-based autocomplete options.
|
|
269
|
+
*
|
|
270
|
+
* @param inferredType - The inferred type string
|
|
271
|
+
* @returns Array of string constants
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* getStringConstants('"Hans" | "Karl" | "Eddie" | "Theo" | "Fritz" | string');
|
|
275
|
+
* // Returns: ['Hans', 'Karl', 'Eddie', 'Theo', 'Fritz']
|
|
276
|
+
*/
|
|
277
|
+
declare function getStringConstants(inferredType: string): string[];
|
|
278
|
+
/**
|
|
279
|
+
* Get number constants from an inferred type.
|
|
280
|
+
*
|
|
281
|
+
* @param inferredType - The inferred type string
|
|
282
|
+
* @returns Array of number constants
|
|
283
|
+
*/
|
|
284
|
+
declare function getNumberConstants(inferredType: string): number[];
|
|
285
|
+
|
|
152
286
|
/**
|
|
153
287
|
* Simplified Field Components (Mock/Development Version)
|
|
154
288
|
*
|
|
@@ -399,9 +533,12 @@ interface InferConfig {
|
|
|
399
533
|
* ```
|
|
400
534
|
*/
|
|
401
535
|
declare function parseInferSyntax(expectedType: string | undefined): InferConfig;
|
|
536
|
+
|
|
402
537
|
/**
|
|
403
538
|
* Standard operators grouped by compatible types.
|
|
404
539
|
* Use getOperatorsForType() to retrieve operators for a specific type.
|
|
540
|
+
*
|
|
541
|
+
* @deprecated Use OperatorDef<T> and filterOperatorsByType() for more flexibility
|
|
405
542
|
*/
|
|
406
543
|
declare const OPERATORS_BY_TYPE: Record<string, Array<{
|
|
407
544
|
value: string;
|
|
@@ -411,6 +548,8 @@ declare const OPERATORS_BY_TYPE: Record<string, Array<{
|
|
|
411
548
|
* Get the appropriate operators for a given type.
|
|
412
549
|
* Falls back to 'any' operators for unrecognized types.
|
|
413
550
|
*
|
|
551
|
+
* @deprecated Use OperatorDef<T> and filterOperatorsByType() for more flexibility
|
|
552
|
+
*
|
|
414
553
|
* @example
|
|
415
554
|
* ```tsx
|
|
416
555
|
* const ctx = useInferredTypes();
|
|
@@ -519,6 +658,7 @@ declare function useFieldValidation(): {
|
|
|
519
658
|
validateField: (fieldName: string) => string | null;
|
|
520
659
|
};
|
|
521
660
|
|
|
661
|
+
type index_BaseOperatorType = BaseOperatorType;
|
|
522
662
|
type index_FieldValidationRule = FieldValidationRule;
|
|
523
663
|
type index_InferConfig = InferConfig;
|
|
524
664
|
declare const index_InferredTypesContext: typeof InferredTypesContext;
|
|
@@ -532,6 +672,8 @@ type index_NestedFieldProviderProps = NestedFieldProviderProps;
|
|
|
532
672
|
declare const index_NodePropertyProvider: typeof NodePropertyProvider;
|
|
533
673
|
type index_NodePropertyProviderProps = NodePropertyProviderProps;
|
|
534
674
|
declare const index_OPERATORS_BY_TYPE: typeof OPERATORS_BY_TYPE;
|
|
675
|
+
type index_OperatorDef<T = never> = OperatorDef<T>;
|
|
676
|
+
type index_ParsedTypes = ParsedTypes;
|
|
535
677
|
declare const index_Select: typeof Select;
|
|
536
678
|
type index_SelectOption = SelectOption;
|
|
537
679
|
type index_SelectProps = SelectProps;
|
|
@@ -542,9 +684,14 @@ type index_TemplateFieldFocusContext = TemplateFieldFocusContext;
|
|
|
542
684
|
declare const index_TemplateFieldProvider: typeof TemplateFieldProvider;
|
|
543
685
|
type index_TemplateFieldProviderProps = TemplateFieldProviderProps;
|
|
544
686
|
type index_TemplateFieldValidationError = TemplateFieldValidationError;
|
|
687
|
+
declare const index_computeExtendedType: typeof computeExtendedType;
|
|
688
|
+
declare const index_filterOperatorsByType: typeof filterOperatorsByType;
|
|
689
|
+
declare const index_getNumberConstants: typeof getNumberConstants;
|
|
545
690
|
declare const index_getOperatorsForType: typeof getOperatorsForType;
|
|
691
|
+
declare const index_getStringConstants: typeof getStringConstants;
|
|
546
692
|
declare const index_intersectTypes: typeof intersectTypes;
|
|
547
693
|
declare const index_parseInferSyntax: typeof parseInferSyntax;
|
|
694
|
+
declare const index_parseInferredTypes: typeof parseInferredTypes;
|
|
548
695
|
declare const index_useAllInferredTypes: typeof useAllInferredTypes;
|
|
549
696
|
declare const index_useFieldPath: typeof useFieldPath;
|
|
550
697
|
declare const index_useFieldValidation: typeof useFieldValidation;
|
|
@@ -558,7 +705,7 @@ declare const index_useSetInferredType: typeof useSetInferredType;
|
|
|
558
705
|
declare const index_useSetProperty: typeof useSetProperty;
|
|
559
706
|
declare const index_useTemplateFieldContext: typeof useTemplateFieldContext;
|
|
560
707
|
declare namespace index {
|
|
561
|
-
export { type index_FieldValidationRule as FieldValidationRule, type index_InferConfig as InferConfig, index_InferredTypesContext as InferredTypesContext, type index_InferredTypesContextValue as InferredTypesContextValue, index_InferredTypesProvider as InferredTypesProvider, type index_InferredTypesProviderProps as InferredTypesProviderProps, index_Input as Input, type index_InputProps as InputProps, index_NestedFieldProvider as NestedFieldProvider, type index_NestedFieldProviderProps as NestedFieldProviderProps, index_NodePropertyProvider as NodePropertyProvider, type index_NodePropertyProviderProps as NodePropertyProviderProps, index_OPERATORS_BY_TYPE as OPERATORS_BY_TYPE, index_Select as Select, type index_SelectOption as SelectOption, type index_SelectProps as SelectProps, type index_SelectRenderProps as SelectRenderProps, type index_TemplateFieldChangeEvent as TemplateFieldChangeEvent, type index_TemplateFieldContextValue as TemplateFieldContextValue, type index_TemplateFieldFocusContext as TemplateFieldFocusContext, index_TemplateFieldProvider as TemplateFieldProvider, type index_TemplateFieldProviderProps as TemplateFieldProviderProps, type index_TemplateFieldValidationError as TemplateFieldValidationError, index_getOperatorsForType as getOperatorsForType, index_intersectTypes as intersectTypes, index_parseInferSyntax as parseInferSyntax, index_useAllInferredTypes as useAllInferredTypes, index_useFieldPath as useFieldPath, index_useFieldValidation as useFieldValidation, index_useInferredType as useInferredType, index_useInferredTypes as useInferredTypes, index_useIsInNodePropertyProvider as useIsInNodePropertyProvider, index_useIsInTemplateFieldProvider as useIsInTemplateFieldProvider, index_useNodeProperties as useNodeProperties, index_useNodeProperty as useNodeProperty, index_useSetInferredType as useSetInferredType, index_useSetProperty as useSetProperty, index_useTemplateFieldContext as useTemplateFieldContext };
|
|
708
|
+
export { type index_BaseOperatorType as BaseOperatorType, type index_FieldValidationRule as FieldValidationRule, type index_InferConfig as InferConfig, index_InferredTypesContext as InferredTypesContext, type index_InferredTypesContextValue as InferredTypesContextValue, index_InferredTypesProvider as InferredTypesProvider, type index_InferredTypesProviderProps as InferredTypesProviderProps, index_Input as Input, type index_InputProps as InputProps, index_NestedFieldProvider as NestedFieldProvider, type index_NestedFieldProviderProps as NestedFieldProviderProps, index_NodePropertyProvider as NodePropertyProvider, type index_NodePropertyProviderProps as NodePropertyProviderProps, index_OPERATORS_BY_TYPE as OPERATORS_BY_TYPE, type index_OperatorDef as OperatorDef, type index_ParsedTypes as ParsedTypes, index_Select as Select, type index_SelectOption as SelectOption, type index_SelectProps as SelectProps, type index_SelectRenderProps as SelectRenderProps, type index_TemplateFieldChangeEvent as TemplateFieldChangeEvent, type index_TemplateFieldContextValue as TemplateFieldContextValue, type index_TemplateFieldFocusContext as TemplateFieldFocusContext, index_TemplateFieldProvider as TemplateFieldProvider, type index_TemplateFieldProviderProps as TemplateFieldProviderProps, type index_TemplateFieldValidationError as TemplateFieldValidationError, index_computeExtendedType as computeExtendedType, index_filterOperatorsByType as filterOperatorsByType, index_getNumberConstants as getNumberConstants, index_getOperatorsForType as getOperatorsForType, index_getStringConstants as getStringConstants, index_intersectTypes as intersectTypes, index_parseInferSyntax as parseInferSyntax, index_parseInferredTypes as parseInferredTypes, index_useAllInferredTypes as useAllInferredTypes, index_useFieldPath as useFieldPath, index_useFieldValidation as useFieldValidation, index_useInferredType as useInferredType, index_useInferredTypes as useInferredTypes, index_useIsInNodePropertyProvider as useIsInNodePropertyProvider, index_useIsInTemplateFieldProvider as useIsInTemplateFieldProvider, index_useNodeProperties as useNodeProperties, index_useNodeProperty as useNodeProperty, index_useSetInferredType as useSetInferredType, index_useSetProperty as useSetProperty, index_useTemplateFieldContext as useTemplateFieldContext };
|
|
562
709
|
}
|
|
563
710
|
|
|
564
|
-
export { useSetProperty as A, useFieldValidation as B, Input as C, type InputProps as D, type SelectProps as E, type FieldValidationRule as F, type SelectOption as G, type SelectRenderProps as H, type InferredTypesContextValue as I, NestedFieldProvider as N, OPERATORS_BY_TYPE as O, Select as S, type TemplateFieldContextValue as T, useIsInTemplateFieldProvider as a, useFieldPath as b, TemplateFieldProvider as c, type TemplateFieldProviderProps as d, type NestedFieldProviderProps as e, type TemplateFieldValidationError as f, type TemplateFieldFocusContext as g, type TemplateFieldChangeEvent as h, index as i, InferredTypesContext as j, useInferredTypes as k, type InferredTypesProviderProps as l, InferredTypesProvider as m, intersectTypes as n, type InferConfig as o, parseInferSyntax as p, getOperatorsForType as q, type NodePropertyProviderProps as r, NodePropertyProvider as s, useIsInNodePropertyProvider as t, useTemplateFieldContext as u, useNodeProperty as v, useNodeProperties as w, useInferredType as x, useSetInferredType as y, useAllInferredTypes as z };
|
|
711
|
+
export { useSetProperty as A, useFieldValidation as B, Input as C, type InputProps as D, type SelectProps as E, type FieldValidationRule as F, type SelectOption as G, type SelectRenderProps as H, type InferredTypesContextValue as I, parseInferredTypes as J, computeExtendedType as K, filterOperatorsByType as L, getStringConstants as M, NestedFieldProvider as N, OPERATORS_BY_TYPE as O, getNumberConstants as P, type BaseOperatorType as Q, type OperatorDef as R, Select as S, type TemplateFieldContextValue as T, type ParsedTypes as U, useIsInTemplateFieldProvider as a, useFieldPath as b, TemplateFieldProvider as c, type TemplateFieldProviderProps as d, type NestedFieldProviderProps as e, type TemplateFieldValidationError as f, type TemplateFieldFocusContext as g, type TemplateFieldChangeEvent as h, index as i, InferredTypesContext as j, useInferredTypes as k, type InferredTypesProviderProps as l, InferredTypesProvider as m, intersectTypes as n, type InferConfig as o, parseInferSyntax as p, getOperatorsForType as q, type NodePropertyProviderProps as r, NodePropertyProvider as s, useIsInNodePropertyProvider as t, useTemplateFieldContext as u, useNodeProperty as v, useNodeProperties as w, useInferredType as x, useSetInferredType as y, useAllInferredTypes as z };
|
|
@@ -149,6 +149,140 @@ interface SelectRenderProps {
|
|
|
149
149
|
*/
|
|
150
150
|
declare function Select({ fieldName, label, value, onChange, options: rawOptions, disabled, placeholder, expectedType, required, hasRequiredError, className, children, }: SelectProps): React.JSX.Element;
|
|
151
151
|
|
|
152
|
+
/**
|
|
153
|
+
* Shared Operator Type Definitions and Utilities
|
|
154
|
+
*
|
|
155
|
+
* This module provides reusable types and utilities for building
|
|
156
|
+
* query builders with type-aware operators (Switch, IfThenElse, etc.)
|
|
157
|
+
*/
|
|
158
|
+
/**
|
|
159
|
+
* Standard operator types for condition builders.
|
|
160
|
+
* Custom UIs can extend this with their own operators.
|
|
161
|
+
*/
|
|
162
|
+
type BaseOperatorType = 'exists' | 'not_exists' | 'string_equals' | 'string_not_equals' | 'string_is_blank' | 'string_is_not_blank' | 'string_starts_with' | 'string_contains' | 'string_not_contains' | 'string_ends_with' | 'number_equals' | 'number_not_equals' | 'number_gt' | 'number_gte' | 'number_lt' | 'number_lte' | 'boolean_equals' | 'is_null' | 'is_not_null' | 'is_string' | 'is_not_string' | 'is_number' | 'is_not_number' | 'is_true' | 'is_false' | 'is_boolean' | 'is_not_boolean';
|
|
163
|
+
/**
|
|
164
|
+
* Generic operator definition that can be extended with custom operators.
|
|
165
|
+
*
|
|
166
|
+
* @template T - Additional operator types to include (defaults to never)
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* // Using base operators only
|
|
170
|
+
* const operators: OperatorDef[] = [...];
|
|
171
|
+
*
|
|
172
|
+
* // Extending with custom operators
|
|
173
|
+
* type MyOperator = 'expression' | 'custom_op';
|
|
174
|
+
* const operators: OperatorDef<MyOperator>[] = [...];
|
|
175
|
+
*/
|
|
176
|
+
type OperatorDef<T = never> = {
|
|
177
|
+
/** The operator value/key */
|
|
178
|
+
value: BaseOperatorType | T;
|
|
179
|
+
/** Which inferred types this applies to ('any' = always shown) */
|
|
180
|
+
types: string[];
|
|
181
|
+
/** Human-readable label for the operator */
|
|
182
|
+
label: string;
|
|
183
|
+
/** Short label for compact display (optional) */
|
|
184
|
+
shortLabel?: string;
|
|
185
|
+
/** Whether to show the value Input */
|
|
186
|
+
needsValue: boolean;
|
|
187
|
+
/** Type to register for narrowing ('never' = no narrowing) */
|
|
188
|
+
narrowsTo: string;
|
|
189
|
+
/** If true, union narrowed type with base type (e.g., narrowed | string) */
|
|
190
|
+
extendsWithBase?: boolean;
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* Result of parsing an inferred type string.
|
|
194
|
+
*/
|
|
195
|
+
type ParsedTypes = {
|
|
196
|
+
/** Deduplicated base types (string, number, boolean, any, etc.) */
|
|
197
|
+
baseTypes: string[];
|
|
198
|
+
/** Extracted string literal constants */
|
|
199
|
+
stringConstants: string[];
|
|
200
|
+
/** Extracted number literal constants */
|
|
201
|
+
numberConstants: number[];
|
|
202
|
+
/** Whether any literal constants were found */
|
|
203
|
+
hasConstants: boolean;
|
|
204
|
+
/** Original type strings for union building */
|
|
205
|
+
rawTypes: string[];
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* Parse an inferred type string into base types and extract any literal constants.
|
|
209
|
+
*
|
|
210
|
+
* Handles:
|
|
211
|
+
* - Base types: string, number, boolean
|
|
212
|
+
* - Union types: string | number
|
|
213
|
+
* - String literals: "Hans" | "Karl" | "Eddie" | "Theo" | "Fritz" -> treated as string type
|
|
214
|
+
* - Number literals: 1 | 2 | 3 -> treated as number type
|
|
215
|
+
* - Boolean literals: true | false -> treated as boolean type
|
|
216
|
+
*
|
|
217
|
+
* @param typeStr - The inferred type string to parse
|
|
218
|
+
* @returns Parsed type information
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* parseInferredTypes('"Hans" | "Karl" | "Eddie" | "Theo" | "Fritz" | string')
|
|
222
|
+
* // Returns:
|
|
223
|
+
* // {
|
|
224
|
+
* // baseTypes: ['string'],
|
|
225
|
+
* // stringConstants: ['Hans', 'Karl', 'Eddie', 'Theo', 'Fritz'],
|
|
226
|
+
* // numberConstants: [],
|
|
227
|
+
* // hasConstants: true,
|
|
228
|
+
* // rawTypes: ['"Hans"', '"Karl"', '"Eddie"', '"Theo"', '"Fritz"', 'string']
|
|
229
|
+
* // }
|
|
230
|
+
*/
|
|
231
|
+
declare function parseInferredTypes(typeStr: string): ParsedTypes;
|
|
232
|
+
/**
|
|
233
|
+
* Compute the expected type for a value input based on the operator.
|
|
234
|
+
*
|
|
235
|
+
* If `extendsWithBase` is true, the result includes both:
|
|
236
|
+
* - The matching literal types from the inferred type
|
|
237
|
+
* - The base type (to allow arbitrary input)
|
|
238
|
+
*
|
|
239
|
+
* This enables scenarios like:
|
|
240
|
+
* - `string_equals` on `"Hans" | "Karl" | "Eddie" | "Theo" | "Fritz" | string"` → expects `"Hans" | "Karl" | "Eddie" | "Theo" | "Fritz" | string"` (exact match)
|
|
241
|
+
* - `string_starts_with` on `"Hans" | "Karl" | "Eddie" | "Theo" | "Fritz" | string"` → expects `"Hans" | "Karl" | "Eddie" | "Theo" | "Fritz" | string"` (allows partial match)
|
|
242
|
+
*
|
|
243
|
+
* @param inferredType - The inferred type string from the statement
|
|
244
|
+
* @param opDef - The operator definition
|
|
245
|
+
* @returns The computed expected type string
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* const opDef = { narrowsTo: 'string', extendsWithBase: true, ... };
|
|
249
|
+
* computeExtendedType('"Hans" | "Karl" | "Eddie" | "Theo" | "Fritz" | string', opDef);
|
|
250
|
+
* // Returns: '"Hans" | "Karl" | "Eddie" | "Theo" | "Fritz" | string'
|
|
251
|
+
*/
|
|
252
|
+
declare function computeExtendedType<T = never>(inferredType: string, opDef: OperatorDef<T>): string;
|
|
253
|
+
/**
|
|
254
|
+
* Filter operators based on an inferred type.
|
|
255
|
+
* Returns only operators whose `types` include a matching base type.
|
|
256
|
+
*
|
|
257
|
+
* @param operators - Array of operator definitions
|
|
258
|
+
* @param inferredType - The inferred type string to filter by
|
|
259
|
+
* @returns Filtered array of operators
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* const filtered = filterOperatorsByType(OPERATORS, '"Hans" | "Karl" | "Eddie" | "Theo" | "Fritz" | string');
|
|
263
|
+
* // Returns operators with types: ['any'] or types: ['string']
|
|
264
|
+
*/
|
|
265
|
+
declare function filterOperatorsByType<T = never>(operators: OperatorDef<T>[], inferredType: string): OperatorDef<T>[];
|
|
266
|
+
/**
|
|
267
|
+
* Get string constants from an inferred type.
|
|
268
|
+
* Useful for showing constant-based autocomplete options.
|
|
269
|
+
*
|
|
270
|
+
* @param inferredType - The inferred type string
|
|
271
|
+
* @returns Array of string constants
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* getStringConstants('"Hans" | "Karl" | "Eddie" | "Theo" | "Fritz" | string');
|
|
275
|
+
* // Returns: ['Hans', 'Karl', 'Eddie', 'Theo', 'Fritz']
|
|
276
|
+
*/
|
|
277
|
+
declare function getStringConstants(inferredType: string): string[];
|
|
278
|
+
/**
|
|
279
|
+
* Get number constants from an inferred type.
|
|
280
|
+
*
|
|
281
|
+
* @param inferredType - The inferred type string
|
|
282
|
+
* @returns Array of number constants
|
|
283
|
+
*/
|
|
284
|
+
declare function getNumberConstants(inferredType: string): number[];
|
|
285
|
+
|
|
152
286
|
/**
|
|
153
287
|
* Simplified Field Components (Mock/Development Version)
|
|
154
288
|
*
|
|
@@ -399,9 +533,12 @@ interface InferConfig {
|
|
|
399
533
|
* ```
|
|
400
534
|
*/
|
|
401
535
|
declare function parseInferSyntax(expectedType: string | undefined): InferConfig;
|
|
536
|
+
|
|
402
537
|
/**
|
|
403
538
|
* Standard operators grouped by compatible types.
|
|
404
539
|
* Use getOperatorsForType() to retrieve operators for a specific type.
|
|
540
|
+
*
|
|
541
|
+
* @deprecated Use OperatorDef<T> and filterOperatorsByType() for more flexibility
|
|
405
542
|
*/
|
|
406
543
|
declare const OPERATORS_BY_TYPE: Record<string, Array<{
|
|
407
544
|
value: string;
|
|
@@ -411,6 +548,8 @@ declare const OPERATORS_BY_TYPE: Record<string, Array<{
|
|
|
411
548
|
* Get the appropriate operators for a given type.
|
|
412
549
|
* Falls back to 'any' operators for unrecognized types.
|
|
413
550
|
*
|
|
551
|
+
* @deprecated Use OperatorDef<T> and filterOperatorsByType() for more flexibility
|
|
552
|
+
*
|
|
414
553
|
* @example
|
|
415
554
|
* ```tsx
|
|
416
555
|
* const ctx = useInferredTypes();
|
|
@@ -519,6 +658,7 @@ declare function useFieldValidation(): {
|
|
|
519
658
|
validateField: (fieldName: string) => string | null;
|
|
520
659
|
};
|
|
521
660
|
|
|
661
|
+
type index_BaseOperatorType = BaseOperatorType;
|
|
522
662
|
type index_FieldValidationRule = FieldValidationRule;
|
|
523
663
|
type index_InferConfig = InferConfig;
|
|
524
664
|
declare const index_InferredTypesContext: typeof InferredTypesContext;
|
|
@@ -532,6 +672,8 @@ type index_NestedFieldProviderProps = NestedFieldProviderProps;
|
|
|
532
672
|
declare const index_NodePropertyProvider: typeof NodePropertyProvider;
|
|
533
673
|
type index_NodePropertyProviderProps = NodePropertyProviderProps;
|
|
534
674
|
declare const index_OPERATORS_BY_TYPE: typeof OPERATORS_BY_TYPE;
|
|
675
|
+
type index_OperatorDef<T = never> = OperatorDef<T>;
|
|
676
|
+
type index_ParsedTypes = ParsedTypes;
|
|
535
677
|
declare const index_Select: typeof Select;
|
|
536
678
|
type index_SelectOption = SelectOption;
|
|
537
679
|
type index_SelectProps = SelectProps;
|
|
@@ -542,9 +684,14 @@ type index_TemplateFieldFocusContext = TemplateFieldFocusContext;
|
|
|
542
684
|
declare const index_TemplateFieldProvider: typeof TemplateFieldProvider;
|
|
543
685
|
type index_TemplateFieldProviderProps = TemplateFieldProviderProps;
|
|
544
686
|
type index_TemplateFieldValidationError = TemplateFieldValidationError;
|
|
687
|
+
declare const index_computeExtendedType: typeof computeExtendedType;
|
|
688
|
+
declare const index_filterOperatorsByType: typeof filterOperatorsByType;
|
|
689
|
+
declare const index_getNumberConstants: typeof getNumberConstants;
|
|
545
690
|
declare const index_getOperatorsForType: typeof getOperatorsForType;
|
|
691
|
+
declare const index_getStringConstants: typeof getStringConstants;
|
|
546
692
|
declare const index_intersectTypes: typeof intersectTypes;
|
|
547
693
|
declare const index_parseInferSyntax: typeof parseInferSyntax;
|
|
694
|
+
declare const index_parseInferredTypes: typeof parseInferredTypes;
|
|
548
695
|
declare const index_useAllInferredTypes: typeof useAllInferredTypes;
|
|
549
696
|
declare const index_useFieldPath: typeof useFieldPath;
|
|
550
697
|
declare const index_useFieldValidation: typeof useFieldValidation;
|
|
@@ -558,7 +705,7 @@ declare const index_useSetInferredType: typeof useSetInferredType;
|
|
|
558
705
|
declare const index_useSetProperty: typeof useSetProperty;
|
|
559
706
|
declare const index_useTemplateFieldContext: typeof useTemplateFieldContext;
|
|
560
707
|
declare namespace index {
|
|
561
|
-
export { type index_FieldValidationRule as FieldValidationRule, type index_InferConfig as InferConfig, index_InferredTypesContext as InferredTypesContext, type index_InferredTypesContextValue as InferredTypesContextValue, index_InferredTypesProvider as InferredTypesProvider, type index_InferredTypesProviderProps as InferredTypesProviderProps, index_Input as Input, type index_InputProps as InputProps, index_NestedFieldProvider as NestedFieldProvider, type index_NestedFieldProviderProps as NestedFieldProviderProps, index_NodePropertyProvider as NodePropertyProvider, type index_NodePropertyProviderProps as NodePropertyProviderProps, index_OPERATORS_BY_TYPE as OPERATORS_BY_TYPE, index_Select as Select, type index_SelectOption as SelectOption, type index_SelectProps as SelectProps, type index_SelectRenderProps as SelectRenderProps, type index_TemplateFieldChangeEvent as TemplateFieldChangeEvent, type index_TemplateFieldContextValue as TemplateFieldContextValue, type index_TemplateFieldFocusContext as TemplateFieldFocusContext, index_TemplateFieldProvider as TemplateFieldProvider, type index_TemplateFieldProviderProps as TemplateFieldProviderProps, type index_TemplateFieldValidationError as TemplateFieldValidationError, index_getOperatorsForType as getOperatorsForType, index_intersectTypes as intersectTypes, index_parseInferSyntax as parseInferSyntax, index_useAllInferredTypes as useAllInferredTypes, index_useFieldPath as useFieldPath, index_useFieldValidation as useFieldValidation, index_useInferredType as useInferredType, index_useInferredTypes as useInferredTypes, index_useIsInNodePropertyProvider as useIsInNodePropertyProvider, index_useIsInTemplateFieldProvider as useIsInTemplateFieldProvider, index_useNodeProperties as useNodeProperties, index_useNodeProperty as useNodeProperty, index_useSetInferredType as useSetInferredType, index_useSetProperty as useSetProperty, index_useTemplateFieldContext as useTemplateFieldContext };
|
|
708
|
+
export { type index_BaseOperatorType as BaseOperatorType, type index_FieldValidationRule as FieldValidationRule, type index_InferConfig as InferConfig, index_InferredTypesContext as InferredTypesContext, type index_InferredTypesContextValue as InferredTypesContextValue, index_InferredTypesProvider as InferredTypesProvider, type index_InferredTypesProviderProps as InferredTypesProviderProps, index_Input as Input, type index_InputProps as InputProps, index_NestedFieldProvider as NestedFieldProvider, type index_NestedFieldProviderProps as NestedFieldProviderProps, index_NodePropertyProvider as NodePropertyProvider, type index_NodePropertyProviderProps as NodePropertyProviderProps, index_OPERATORS_BY_TYPE as OPERATORS_BY_TYPE, type index_OperatorDef as OperatorDef, type index_ParsedTypes as ParsedTypes, index_Select as Select, type index_SelectOption as SelectOption, type index_SelectProps as SelectProps, type index_SelectRenderProps as SelectRenderProps, type index_TemplateFieldChangeEvent as TemplateFieldChangeEvent, type index_TemplateFieldContextValue as TemplateFieldContextValue, type index_TemplateFieldFocusContext as TemplateFieldFocusContext, index_TemplateFieldProvider as TemplateFieldProvider, type index_TemplateFieldProviderProps as TemplateFieldProviderProps, type index_TemplateFieldValidationError as TemplateFieldValidationError, index_computeExtendedType as computeExtendedType, index_filterOperatorsByType as filterOperatorsByType, index_getNumberConstants as getNumberConstants, index_getOperatorsForType as getOperatorsForType, index_getStringConstants as getStringConstants, index_intersectTypes as intersectTypes, index_parseInferSyntax as parseInferSyntax, index_parseInferredTypes as parseInferredTypes, index_useAllInferredTypes as useAllInferredTypes, index_useFieldPath as useFieldPath, index_useFieldValidation as useFieldValidation, index_useInferredType as useInferredType, index_useInferredTypes as useInferredTypes, index_useIsInNodePropertyProvider as useIsInNodePropertyProvider, index_useIsInTemplateFieldProvider as useIsInTemplateFieldProvider, index_useNodeProperties as useNodeProperties, index_useNodeProperty as useNodeProperty, index_useSetInferredType as useSetInferredType, index_useSetProperty as useSetProperty, index_useTemplateFieldContext as useTemplateFieldContext };
|
|
562
709
|
}
|
|
563
710
|
|
|
564
|
-
export { useSetProperty as A, useFieldValidation as B, Input as C, type InputProps as D, type SelectProps as E, type FieldValidationRule as F, type SelectOption as G, type SelectRenderProps as H, type InferredTypesContextValue as I, NestedFieldProvider as N, OPERATORS_BY_TYPE as O, Select as S, type TemplateFieldContextValue as T, useIsInTemplateFieldProvider as a, useFieldPath as b, TemplateFieldProvider as c, type TemplateFieldProviderProps as d, type NestedFieldProviderProps as e, type TemplateFieldValidationError as f, type TemplateFieldFocusContext as g, type TemplateFieldChangeEvent as h, index as i, InferredTypesContext as j, useInferredTypes as k, type InferredTypesProviderProps as l, InferredTypesProvider as m, intersectTypes as n, type InferConfig as o, parseInferSyntax as p, getOperatorsForType as q, type NodePropertyProviderProps as r, NodePropertyProvider as s, useIsInNodePropertyProvider as t, useTemplateFieldContext as u, useNodeProperty as v, useNodeProperties as w, useInferredType as x, useSetInferredType as y, useAllInferredTypes as z };
|
|
711
|
+
export { useSetProperty as A, useFieldValidation as B, Input as C, type InputProps as D, type SelectProps as E, type FieldValidationRule as F, type SelectOption as G, type SelectRenderProps as H, type InferredTypesContextValue as I, parseInferredTypes as J, computeExtendedType as K, filterOperatorsByType as L, getStringConstants as M, NestedFieldProvider as N, OPERATORS_BY_TYPE as O, getNumberConstants as P, type BaseOperatorType as Q, type OperatorDef as R, Select as S, type TemplateFieldContextValue as T, type ParsedTypes as U, useIsInTemplateFieldProvider as a, useFieldPath as b, TemplateFieldProvider as c, type TemplateFieldProviderProps as d, type NestedFieldProviderProps as e, type TemplateFieldValidationError as f, type TemplateFieldFocusContext as g, type TemplateFieldChangeEvent as h, index as i, InferredTypesContext as j, useInferredTypes as k, type InferredTypesProviderProps as l, InferredTypesProvider as m, intersectTypes as n, type InferConfig as o, parseInferSyntax as p, getOperatorsForType as q, type NodePropertyProviderProps as r, NodePropertyProvider as s, useIsInNodePropertyProvider as t, useTemplateFieldContext as u, useNodeProperty as v, useNodeProperties as w, useInferredType as x, useSetInferredType as y, useAllInferredTypes as z };
|
package/dist/index.cjs
CHANGED
|
@@ -5124,15 +5124,30 @@ __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
|
},
|
|
@@ -5474,6 +5489,131 @@ function Select2(param) {
|
|
|
5474
5489
|
}, opt.node ? opt.node : /* @__PURE__ */ React2__namespace.createElement(React2__namespace.Fragment, null, opt.label));
|
|
5475
5490
|
})))));
|
|
5476
5491
|
}
|
|
5492
|
+
// src/components/template-editor/operatorTypes.ts
|
|
5493
|
+
function parseInferredTypes(typeStr) {
|
|
5494
|
+
var result = {
|
|
5495
|
+
baseTypes: [],
|
|
5496
|
+
stringConstants: [],
|
|
5497
|
+
numberConstants: [],
|
|
5498
|
+
hasConstants: false,
|
|
5499
|
+
rawTypes: []
|
|
5500
|
+
};
|
|
5501
|
+
if (!typeStr || typeStr === "any" || typeStr === "unknown") {
|
|
5502
|
+
result.baseTypes = [
|
|
5503
|
+
"any"
|
|
5504
|
+
];
|
|
5505
|
+
result.rawTypes = [
|
|
5506
|
+
"any"
|
|
5507
|
+
];
|
|
5508
|
+
return result;
|
|
5509
|
+
}
|
|
5510
|
+
var types = typeStr.split("|").map(function(t) {
|
|
5511
|
+
return t.trim();
|
|
5512
|
+
}).filter(Boolean);
|
|
5513
|
+
var baseTypesSet = /* @__PURE__ */ new Set();
|
|
5514
|
+
var rawTypesSet = /* @__PURE__ */ new Set();
|
|
5515
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5516
|
+
try {
|
|
5517
|
+
for(var _iterator = types[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5518
|
+
var t = _step.value;
|
|
5519
|
+
rawTypesSet.add(t);
|
|
5520
|
+
var stringLiteralMatch = t.match(/^["'](.*)["']$/);
|
|
5521
|
+
if (stringLiteralMatch && stringLiteralMatch[1] !== void 0) {
|
|
5522
|
+
result.stringConstants.push(stringLiteralMatch[1]);
|
|
5523
|
+
baseTypesSet.add("string");
|
|
5524
|
+
result.hasConstants = true;
|
|
5525
|
+
continue;
|
|
5526
|
+
}
|
|
5527
|
+
if (/^-?\d+(\.\d+)?$/.test(t)) {
|
|
5528
|
+
result.numberConstants.push(parseFloat(t));
|
|
5529
|
+
baseTypesSet.add("number");
|
|
5530
|
+
result.hasConstants = true;
|
|
5531
|
+
continue;
|
|
5532
|
+
}
|
|
5533
|
+
if (t === "true" || t === "false") {
|
|
5534
|
+
baseTypesSet.add("boolean");
|
|
5535
|
+
result.hasConstants = true;
|
|
5536
|
+
continue;
|
|
5537
|
+
}
|
|
5538
|
+
baseTypesSet.add(t);
|
|
5539
|
+
}
|
|
5540
|
+
} catch (err) {
|
|
5541
|
+
_didIteratorError = true;
|
|
5542
|
+
_iteratorError = err;
|
|
5543
|
+
} finally{
|
|
5544
|
+
try {
|
|
5545
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5546
|
+
_iterator.return();
|
|
5547
|
+
}
|
|
5548
|
+
} finally{
|
|
5549
|
+
if (_didIteratorError) {
|
|
5550
|
+
throw _iteratorError;
|
|
5551
|
+
}
|
|
5552
|
+
}
|
|
5553
|
+
}
|
|
5554
|
+
result.baseTypes = Array.from(baseTypesSet);
|
|
5555
|
+
result.rawTypes = Array.from(rawTypesSet);
|
|
5556
|
+
return result;
|
|
5557
|
+
}
|
|
5558
|
+
function computeExtendedType(inferredType, opDef) {
|
|
5559
|
+
if (!opDef.extendsWithBase || opDef.narrowsTo === "never") {
|
|
5560
|
+
return opDef.narrowsTo;
|
|
5561
|
+
}
|
|
5562
|
+
var parsed = parseInferredTypes(inferredType);
|
|
5563
|
+
var matchingTypes = [];
|
|
5564
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5565
|
+
try {
|
|
5566
|
+
for(var _iterator = parsed.rawTypes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5567
|
+
var t = _step.value;
|
|
5568
|
+
if (opDef.narrowsTo === "string") {
|
|
5569
|
+
if (t === "string" || /^["'].*["']$/.test(t)) {
|
|
5570
|
+
matchingTypes.push(t);
|
|
5571
|
+
}
|
|
5572
|
+
} else if (opDef.narrowsTo === "number") {
|
|
5573
|
+
if (t === "number" || /^-?\d+(\.\d+)?$/.test(t)) {
|
|
5574
|
+
matchingTypes.push(t);
|
|
5575
|
+
}
|
|
5576
|
+
} else if (opDef.narrowsTo === "boolean") {
|
|
5577
|
+
if (t === "boolean" || t === "true" || t === "false") {
|
|
5578
|
+
matchingTypes.push(t);
|
|
5579
|
+
}
|
|
5580
|
+
}
|
|
5581
|
+
}
|
|
5582
|
+
} catch (err) {
|
|
5583
|
+
_didIteratorError = true;
|
|
5584
|
+
_iteratorError = err;
|
|
5585
|
+
} finally{
|
|
5586
|
+
try {
|
|
5587
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5588
|
+
_iterator.return();
|
|
5589
|
+
}
|
|
5590
|
+
} finally{
|
|
5591
|
+
if (_didIteratorError) {
|
|
5592
|
+
throw _iteratorError;
|
|
5593
|
+
}
|
|
5594
|
+
}
|
|
5595
|
+
}
|
|
5596
|
+
if (opDef.extendsWithBase && !matchingTypes.includes(opDef.narrowsTo)) {
|
|
5597
|
+
matchingTypes.push(opDef.narrowsTo);
|
|
5598
|
+
}
|
|
5599
|
+
return matchingTypes.length > 0 ? matchingTypes.join(" | ") : opDef.narrowsTo;
|
|
5600
|
+
}
|
|
5601
|
+
function filterOperatorsByType(operators, inferredType) {
|
|
5602
|
+
var parsed = parseInferredTypes(inferredType);
|
|
5603
|
+
var baseTypes = parsed.baseTypes;
|
|
5604
|
+
return operators.filter(function(op) {
|
|
5605
|
+
if (op.types.includes("any")) return true;
|
|
5606
|
+
return op.types.some(function(t) {
|
|
5607
|
+
return baseTypes.includes(t) || baseTypes.includes("any");
|
|
5608
|
+
});
|
|
5609
|
+
});
|
|
5610
|
+
}
|
|
5611
|
+
function getStringConstants(inferredType) {
|
|
5612
|
+
return parseInferredTypes(inferredType).stringConstants;
|
|
5613
|
+
}
|
|
5614
|
+
function getNumberConstants(inferredType) {
|
|
5615
|
+
return parseInferredTypes(inferredType).numberConstants;
|
|
5616
|
+
}
|
|
5477
5617
|
// src/components/fields/index.tsx
|
|
5478
5618
|
function useTemplateFieldContext() {
|
|
5479
5619
|
return {
|