@process.co/ui 0.0.6 → 0.0.8

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.
@@ -57,6 +57,7 @@ interface InputProps {
57
57
  declare function Input({ fieldName, label, value, onChange, disabled, placeholder, expectedType, required, hasRequiredError, className, editorClassName, }: InputProps): React$1.JSX.Element;
58
58
 
59
59
  interface SelectOption {
60
+ node?: React$1.ReactNode;
60
61
  value: string;
61
62
  label: string;
62
63
  }
@@ -255,11 +256,129 @@ type TemplateFieldChangeEvent = {
255
256
  inferredType?: string;
256
257
  };
257
258
  };
259
+ /**
260
+ * Context value for sharing inferred types between fields within an element.
261
+ * This enables type propagation via the $infer<...> syntax.
262
+ *
263
+ * ## Usage
264
+ *
265
+ * Publishing field (e.g., switchExpression):
266
+ * - Set expectedType to `$infer<string | number | boolean>`
267
+ * - The field will broadcast its inferred type to the context
268
+ *
269
+ * Subscribing field (e.g., caseExpression):
270
+ * - Set expectedType to `$infer<switchExpression>`
271
+ * - The field will use the inferred type from switchExpression
272
+ *
273
+ * @example
274
+ * ```tsx
275
+ * // In a custom control that needs to filter operators:
276
+ * const ctx = useInferredTypes();
277
+ * const switchType = ctx?.getInferredType('switchExpression') || 'any';
278
+ * const operators = getOperatorsForType(switchType);
279
+ * ```
280
+ */
281
+ interface InferredTypesContextValue {
282
+ /** Map of fieldName → inferred type */
283
+ inferredTypes: Record<string, string>;
284
+ /** Set the inferred type for a field (called by publisher fields) */
285
+ setInferredType: (fieldName: string, type: string) => void;
286
+ /** Get the inferred type for a field (called by subscriber fields) */
287
+ getInferredType: (fieldName: string) => string | undefined;
288
+ }
289
+ /**
290
+ * Context for inferred types.
291
+ * In production, this is provided by PropertiesRender.
292
+ */
293
+ declare const InferredTypesContext: React$1.Context<InferredTypesContextValue | null>;
294
+ /**
295
+ * Hook to access the inferred types context.
296
+ * Returns null when not inside an InferredTypesProvider (e.g., in mock/dev mode).
297
+ *
298
+ * @example
299
+ * ```tsx
300
+ * const ctx = useInferredTypes();
301
+ * const switchType = ctx?.getInferredType('switchExpression') || 'string';
302
+ * ```
303
+ */
304
+ declare function useInferredTypes(): InferredTypesContextValue | null;
305
+ /**
306
+ * Mock provider for inferred types context.
307
+ * In development mode, this is a no-op - just renders children.
308
+ * In production, the real implementation from @repo/ui provides actual type propagation.
309
+ */
310
+ declare function InferredTypesProvider({ children }: {
311
+ children: React.ReactNode;
312
+ }): React$1.JSX.Element;
313
+ /**
314
+ * Compute the intersection of multiple types.
315
+ * Used when subscribing to multiple fields to narrow the expected type.
316
+ *
317
+ * @example
318
+ * intersectTypes(['string | number', 'number']) → 'number'
319
+ */
320
+ declare function intersectTypes(types: (string | undefined)[]): string;
321
+ /**
322
+ * Configuration parsed from the $infer<...> syntax.
323
+ */
324
+ interface InferConfig {
325
+ /** The mode of the field: 'publish', 'subscribe', or 'normal' */
326
+ mode: 'publish' | 'subscribe' | 'normal';
327
+ /** For publish mode: the allowed types (e.g., ['string', 'number', 'boolean']) */
328
+ allowedTypes?: string[];
329
+ /** For subscribe mode: the field name to subscribe to */
330
+ subscribeToField?: string;
331
+ }
332
+ /**
333
+ * Parse the $infer<...> syntax from an expectedType string.
334
+ *
335
+ * @example
336
+ * ```tsx
337
+ * parseInferSyntax('$infer<string | number>')
338
+ * // → { mode: 'publish', allowedTypes: ['string', 'number'] }
339
+ *
340
+ * parseInferSyntax('$infer<switchExpression>')
341
+ * // → { mode: 'subscribe', subscribeToField: 'switchExpression' }
342
+ *
343
+ * parseInferSyntax('string')
344
+ * // → { mode: 'normal' }
345
+ * ```
346
+ */
347
+ declare function parseInferSyntax(expectedType: string | undefined): InferConfig;
348
+ /**
349
+ * Standard operators grouped by compatible types.
350
+ * Use getOperatorsForType() to retrieve operators for a specific type.
351
+ */
352
+ declare const OPERATORS_BY_TYPE: Record<string, Array<{
353
+ value: string;
354
+ label: string;
355
+ }>>;
356
+ /**
357
+ * Get the appropriate operators for a given type.
358
+ * Falls back to 'any' operators for unrecognized types.
359
+ *
360
+ * @example
361
+ * ```tsx
362
+ * const ctx = useInferredTypes();
363
+ * const switchType = ctx?.getInferredType('switchExpression') || 'any';
364
+ * const operators = getOperatorsForType(switchType);
365
+ * // If switchType is 'number', returns numeric operators including <, >, etc.
366
+ * ```
367
+ */
368
+ declare function getOperatorsForType(type: string): Array<{
369
+ value: string;
370
+ label: string;
371
+ }>;
258
372
 
373
+ type index_InferConfig = InferConfig;
374
+ declare const index_InferredTypesContext: typeof InferredTypesContext;
375
+ type index_InferredTypesContextValue = InferredTypesContextValue;
376
+ declare const index_InferredTypesProvider: typeof InferredTypesProvider;
259
377
  declare const index_Input: typeof Input;
260
378
  type index_InputProps = InputProps;
261
379
  declare const index_NestedFieldProvider: typeof NestedFieldProvider;
262
380
  type index_NestedFieldProviderProps = NestedFieldProviderProps;
381
+ declare const index_OPERATORS_BY_TYPE: typeof OPERATORS_BY_TYPE;
263
382
  declare const index_Select: typeof Select;
264
383
  type index_SelectOption = SelectOption;
265
384
  type index_SelectProps = SelectProps;
@@ -270,11 +389,15 @@ type index_TemplateFieldFocusContext = TemplateFieldFocusContext;
270
389
  declare const index_TemplateFieldProvider: typeof TemplateFieldProvider;
271
390
  type index_TemplateFieldProviderProps = TemplateFieldProviderProps;
272
391
  type index_TemplateFieldValidationError = TemplateFieldValidationError;
392
+ declare const index_getOperatorsForType: typeof getOperatorsForType;
393
+ declare const index_intersectTypes: typeof intersectTypes;
394
+ declare const index_parseInferSyntax: typeof parseInferSyntax;
273
395
  declare const index_useFieldPath: typeof useFieldPath;
396
+ declare const index_useInferredTypes: typeof useInferredTypes;
274
397
  declare const index_useIsInTemplateFieldProvider: typeof useIsInTemplateFieldProvider;
275
398
  declare const index_useTemplateFieldContext: typeof useTemplateFieldContext;
276
399
  declare namespace index {
277
- export { index_Input as Input, type index_InputProps as InputProps, index_NestedFieldProvider as NestedFieldProvider, type index_NestedFieldProviderProps as NestedFieldProviderProps, 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_useFieldPath as useFieldPath, index_useIsInTemplateFieldProvider as useIsInTemplateFieldProvider, index_useTemplateFieldContext as useTemplateFieldContext };
400
+ export { type index_InferConfig as InferConfig, index_InferredTypesContext as InferredTypesContext, type index_InferredTypesContextValue as InferredTypesContextValue, index_InferredTypesProvider as InferredTypesProvider, index_Input as Input, type index_InputProps as InputProps, index_NestedFieldProvider as NestedFieldProvider, type index_NestedFieldProviderProps as NestedFieldProviderProps, 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_useFieldPath as useFieldPath, index_useInferredTypes as useInferredTypes, index_useIsInTemplateFieldProvider as useIsInTemplateFieldProvider, index_useTemplateFieldContext as useTemplateFieldContext };
278
401
  }
279
402
 
280
- export { Input as I, NestedFieldProvider as N, 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, type InputProps as j, type SelectProps as k, type SelectOption as l, type SelectRenderProps as m, useTemplateFieldContext as u };
403
+ export { 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, InferredTypesProvider as l, intersectTypes as m, type InferConfig as n, getOperatorsForType as o, parseInferSyntax as p, Input as q, type InputProps as r, type SelectProps as s, type SelectOption as t, useTemplateFieldContext as u, type SelectRenderProps as v };
@@ -57,6 +57,7 @@ interface InputProps {
57
57
  declare function Input({ fieldName, label, value, onChange, disabled, placeholder, expectedType, required, hasRequiredError, className, editorClassName, }: InputProps): React$1.JSX.Element;
58
58
 
59
59
  interface SelectOption {
60
+ node?: React$1.ReactNode;
60
61
  value: string;
61
62
  label: string;
62
63
  }
@@ -255,11 +256,129 @@ type TemplateFieldChangeEvent = {
255
256
  inferredType?: string;
256
257
  };
257
258
  };
259
+ /**
260
+ * Context value for sharing inferred types between fields within an element.
261
+ * This enables type propagation via the $infer<...> syntax.
262
+ *
263
+ * ## Usage
264
+ *
265
+ * Publishing field (e.g., switchExpression):
266
+ * - Set expectedType to `$infer<string | number | boolean>`
267
+ * - The field will broadcast its inferred type to the context
268
+ *
269
+ * Subscribing field (e.g., caseExpression):
270
+ * - Set expectedType to `$infer<switchExpression>`
271
+ * - The field will use the inferred type from switchExpression
272
+ *
273
+ * @example
274
+ * ```tsx
275
+ * // In a custom control that needs to filter operators:
276
+ * const ctx = useInferredTypes();
277
+ * const switchType = ctx?.getInferredType('switchExpression') || 'any';
278
+ * const operators = getOperatorsForType(switchType);
279
+ * ```
280
+ */
281
+ interface InferredTypesContextValue {
282
+ /** Map of fieldName → inferred type */
283
+ inferredTypes: Record<string, string>;
284
+ /** Set the inferred type for a field (called by publisher fields) */
285
+ setInferredType: (fieldName: string, type: string) => void;
286
+ /** Get the inferred type for a field (called by subscriber fields) */
287
+ getInferredType: (fieldName: string) => string | undefined;
288
+ }
289
+ /**
290
+ * Context for inferred types.
291
+ * In production, this is provided by PropertiesRender.
292
+ */
293
+ declare const InferredTypesContext: React$1.Context<InferredTypesContextValue | null>;
294
+ /**
295
+ * Hook to access the inferred types context.
296
+ * Returns null when not inside an InferredTypesProvider (e.g., in mock/dev mode).
297
+ *
298
+ * @example
299
+ * ```tsx
300
+ * const ctx = useInferredTypes();
301
+ * const switchType = ctx?.getInferredType('switchExpression') || 'string';
302
+ * ```
303
+ */
304
+ declare function useInferredTypes(): InferredTypesContextValue | null;
305
+ /**
306
+ * Mock provider for inferred types context.
307
+ * In development mode, this is a no-op - just renders children.
308
+ * In production, the real implementation from @repo/ui provides actual type propagation.
309
+ */
310
+ declare function InferredTypesProvider({ children }: {
311
+ children: React.ReactNode;
312
+ }): React$1.JSX.Element;
313
+ /**
314
+ * Compute the intersection of multiple types.
315
+ * Used when subscribing to multiple fields to narrow the expected type.
316
+ *
317
+ * @example
318
+ * intersectTypes(['string | number', 'number']) → 'number'
319
+ */
320
+ declare function intersectTypes(types: (string | undefined)[]): string;
321
+ /**
322
+ * Configuration parsed from the $infer<...> syntax.
323
+ */
324
+ interface InferConfig {
325
+ /** The mode of the field: 'publish', 'subscribe', or 'normal' */
326
+ mode: 'publish' | 'subscribe' | 'normal';
327
+ /** For publish mode: the allowed types (e.g., ['string', 'number', 'boolean']) */
328
+ allowedTypes?: string[];
329
+ /** For subscribe mode: the field name to subscribe to */
330
+ subscribeToField?: string;
331
+ }
332
+ /**
333
+ * Parse the $infer<...> syntax from an expectedType string.
334
+ *
335
+ * @example
336
+ * ```tsx
337
+ * parseInferSyntax('$infer<string | number>')
338
+ * // → { mode: 'publish', allowedTypes: ['string', 'number'] }
339
+ *
340
+ * parseInferSyntax('$infer<switchExpression>')
341
+ * // → { mode: 'subscribe', subscribeToField: 'switchExpression' }
342
+ *
343
+ * parseInferSyntax('string')
344
+ * // → { mode: 'normal' }
345
+ * ```
346
+ */
347
+ declare function parseInferSyntax(expectedType: string | undefined): InferConfig;
348
+ /**
349
+ * Standard operators grouped by compatible types.
350
+ * Use getOperatorsForType() to retrieve operators for a specific type.
351
+ */
352
+ declare const OPERATORS_BY_TYPE: Record<string, Array<{
353
+ value: string;
354
+ label: string;
355
+ }>>;
356
+ /**
357
+ * Get the appropriate operators for a given type.
358
+ * Falls back to 'any' operators for unrecognized types.
359
+ *
360
+ * @example
361
+ * ```tsx
362
+ * const ctx = useInferredTypes();
363
+ * const switchType = ctx?.getInferredType('switchExpression') || 'any';
364
+ * const operators = getOperatorsForType(switchType);
365
+ * // If switchType is 'number', returns numeric operators including <, >, etc.
366
+ * ```
367
+ */
368
+ declare function getOperatorsForType(type: string): Array<{
369
+ value: string;
370
+ label: string;
371
+ }>;
258
372
 
373
+ type index_InferConfig = InferConfig;
374
+ declare const index_InferredTypesContext: typeof InferredTypesContext;
375
+ type index_InferredTypesContextValue = InferredTypesContextValue;
376
+ declare const index_InferredTypesProvider: typeof InferredTypesProvider;
259
377
  declare const index_Input: typeof Input;
260
378
  type index_InputProps = InputProps;
261
379
  declare const index_NestedFieldProvider: typeof NestedFieldProvider;
262
380
  type index_NestedFieldProviderProps = NestedFieldProviderProps;
381
+ declare const index_OPERATORS_BY_TYPE: typeof OPERATORS_BY_TYPE;
263
382
  declare const index_Select: typeof Select;
264
383
  type index_SelectOption = SelectOption;
265
384
  type index_SelectProps = SelectProps;
@@ -270,11 +389,15 @@ type index_TemplateFieldFocusContext = TemplateFieldFocusContext;
270
389
  declare const index_TemplateFieldProvider: typeof TemplateFieldProvider;
271
390
  type index_TemplateFieldProviderProps = TemplateFieldProviderProps;
272
391
  type index_TemplateFieldValidationError = TemplateFieldValidationError;
392
+ declare const index_getOperatorsForType: typeof getOperatorsForType;
393
+ declare const index_intersectTypes: typeof intersectTypes;
394
+ declare const index_parseInferSyntax: typeof parseInferSyntax;
273
395
  declare const index_useFieldPath: typeof useFieldPath;
396
+ declare const index_useInferredTypes: typeof useInferredTypes;
274
397
  declare const index_useIsInTemplateFieldProvider: typeof useIsInTemplateFieldProvider;
275
398
  declare const index_useTemplateFieldContext: typeof useTemplateFieldContext;
276
399
  declare namespace index {
277
- export { index_Input as Input, type index_InputProps as InputProps, index_NestedFieldProvider as NestedFieldProvider, type index_NestedFieldProviderProps as NestedFieldProviderProps, 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_useFieldPath as useFieldPath, index_useIsInTemplateFieldProvider as useIsInTemplateFieldProvider, index_useTemplateFieldContext as useTemplateFieldContext };
400
+ export { type index_InferConfig as InferConfig, index_InferredTypesContext as InferredTypesContext, type index_InferredTypesContextValue as InferredTypesContextValue, index_InferredTypesProvider as InferredTypesProvider, index_Input as Input, type index_InputProps as InputProps, index_NestedFieldProvider as NestedFieldProvider, type index_NestedFieldProviderProps as NestedFieldProviderProps, 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_useFieldPath as useFieldPath, index_useInferredTypes as useInferredTypes, index_useIsInTemplateFieldProvider as useIsInTemplateFieldProvider, index_useTemplateFieldContext as useTemplateFieldContext };
278
401
  }
279
402
 
280
- export { Input as I, NestedFieldProvider as N, 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, type InputProps as j, type SelectProps as k, type SelectOption as l, type SelectRenderProps as m, useTemplateFieldContext as u };
403
+ export { 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, InferredTypesProvider as l, intersectTypes as m, type InferConfig as n, getOperatorsForType as o, parseInferSyntax as p, Input as q, type InputProps as r, type SelectProps as s, type SelectOption as t, useTemplateFieldContext as u, type SelectRenderProps as v };