@process.co/ui 0.0.8 → 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.
@@ -1,403 +0,0 @@
1
- import * as React$1 from 'react';
2
-
3
- interface InputProps {
4
- /**
5
- * Field name/key.
6
- * Used for Yjs field path and validation error tracking.
7
- * When nested inside NestedFieldProvider, the parent path is auto-prepended.
8
- */
9
- fieldName: string;
10
- /** Display label for the field */
11
- label: string;
12
- /** Current value */
13
- value: string | {
14
- expression: string;
15
- type: 'expression';
16
- value?: string;
17
- };
18
- /** Called when value changes */
19
- onChange: (value: string | {
20
- expression: string;
21
- type: 'expression';
22
- }, metadata?: any) => void;
23
- /** Whether the field is disabled */
24
- disabled?: boolean;
25
- /** Placeholder text */
26
- placeholder?: string;
27
- /** Expected return type for validation */
28
- expectedType?: string;
29
- /** Whether this is a required field */
30
- required?: boolean;
31
- /** Whether this field has a required property error (missing value) */
32
- hasRequiredError?: boolean;
33
- /** Custom className for the wrapper */
34
- className?: string;
35
- /** Custom className for the editor container */
36
- editorClassName?: string;
37
- /** Property definition (for richer context) */
38
- propertyDefinition?: any;
39
- }
40
- /**
41
- * Mock Input component for development/design mode.
42
- *
43
- * This is a simplified version that renders a basic input field.
44
- * In production, this is replaced with the real Input from packages/ui
45
- * which includes collaboration, type inference, and expression support.
46
- *
47
- * @example
48
- * ```tsx
49
- * <Input
50
- * fieldName="firstName"
51
- * label="First Name"
52
- * value={value}
53
- * onChange={setValue}
54
- * />
55
- * ```
56
- */
57
- declare function Input({ fieldName, label, value, onChange, disabled, placeholder, expectedType, required, hasRequiredError, className, editorClassName, }: InputProps): React$1.JSX.Element;
58
-
59
- interface SelectOption {
60
- node?: React$1.ReactNode;
61
- value: string;
62
- label: string;
63
- }
64
- interface SelectProps {
65
- /**
66
- * Field name/key.
67
- * Used for Yjs field path and validation error tracking.
68
- * When nested inside NestedFieldProvider, the parent path is auto-prepended.
69
- */
70
- fieldName: string;
71
- /** Display label for the field */
72
- label: string;
73
- /** Current value */
74
- value: string | {
75
- expression: string;
76
- type: 'expression';
77
- value?: string;
78
- };
79
- /** Called when value changes */
80
- onChange: (value: string | {
81
- expression: string;
82
- type: 'expression';
83
- }, metadata?: any) => void;
84
- /** Available options */
85
- options: SelectOption[] | string[];
86
- /** Whether the field is disabled */
87
- disabled?: boolean;
88
- /** Placeholder text */
89
- placeholder?: string;
90
- /** Expected return type for validation */
91
- expectedType?: string;
92
- /** Whether this is a required field */
93
- required?: boolean;
94
- /** Whether this field has a required property error (missing value) */
95
- hasRequiredError?: boolean;
96
- /** Custom className for the wrapper */
97
- className?: string;
98
- /** Property definition (for richer context) */
99
- propertyDefinition?: any;
100
- /**
101
- * Render prop for custom select UI.
102
- * If not provided, uses a basic HTML select.
103
- */
104
- children?: (props: SelectRenderProps) => React$1.ReactNode;
105
- }
106
- interface SelectRenderProps {
107
- value: string;
108
- onChange: (value: string) => void;
109
- onFocus?: () => void;
110
- onBlur?: () => void;
111
- onExpressionClick: () => void;
112
- options: SelectOption[];
113
- localInput: string;
114
- setLocalInput: (value: string) => void;
115
- expressionMode: {
116
- current: 'value' | 'expression';
117
- isExpressionMode: boolean;
118
- isEditorMode: boolean;
119
- isEditing: boolean;
120
- isFullScreen: boolean;
121
- expression: string;
122
- switchToValue: () => void;
123
- switchToExpression: () => void;
124
- switchToEditor: () => void;
125
- clear: () => void;
126
- };
127
- inferredType?: string;
128
- hasTypeMismatch?: boolean;
129
- hasError?: boolean;
130
- }
131
- /**
132
- * Mock Select component for development/design mode.
133
- *
134
- * This is a simplified version that renders a basic select field.
135
- * In production, this is replaced with the real Select from packages/ui
136
- * which includes collaboration, type inference, and expression support.
137
- *
138
- * @example
139
- * ```tsx
140
- * <Select
141
- * fieldName="status"
142
- * label="Status"
143
- * value={value}
144
- * onChange={setValue}
145
- * options={['draft', 'published', 'archived']}
146
- * />
147
- * ```
148
- */
149
- declare function Select({ fieldName, label, value, onChange, options: rawOptions, disabled, placeholder, expectedType, required, hasRequiredError, className, children, }: SelectProps): React$1.JSX.Element;
150
-
151
- /**
152
- * Mock context value (always returns defaults).
153
- * In production, this is replaced with the real context from packages/ui.
154
- */
155
- interface TemplateFieldContextValue {
156
- yDoc: null;
157
- collabUser: null;
158
- awareness: null;
159
- availableNodes: any;
160
- myInterface: any;
161
- typeDeclarations: string;
162
- element: any;
163
- nodeId: string;
164
- onControlFocus: (context: any) => void;
165
- onControlBlur: () => void;
166
- onRecordChange: (change: any) => void;
167
- onValidationChange: (fieldName: string, error: any) => void;
168
- parentFieldPath: string | null;
169
- disabled: boolean;
170
- }
171
- /**
172
- * Mock hook - returns empty context values.
173
- * Components work as basic inputs in development mode.
174
- */
175
- declare function useTemplateFieldContext(): TemplateFieldContextValue;
176
- /**
177
- * Mock hook - always returns false in development mode.
178
- */
179
- declare function useIsInTemplateFieldProvider(): boolean;
180
- /**
181
- * Mock hook - returns the fieldName as-is (no parent path in dev mode).
182
- */
183
- declare function useFieldPath(fieldName: string): string;
184
- /**
185
- * Mock provider - just renders children without context.
186
- */
187
- declare function TemplateFieldProvider({ children }: {
188
- children: React.ReactNode;
189
- }): React$1.JSX.Element;
190
- /**
191
- * Mock provider - just renders children without nesting context.
192
- */
193
- declare function NestedFieldProvider({ children }: {
194
- children: React.ReactNode;
195
- fieldName: string;
196
- }): React$1.JSX.Element;
197
- type TemplateFieldProviderProps = {
198
- children: React.ReactNode;
199
- nodeId?: string;
200
- yDoc?: any;
201
- collabUser?: any;
202
- awareness?: any;
203
- availableNodes?: any;
204
- myInterface?: any;
205
- typeDeclarations?: string;
206
- element?: any;
207
- onControlFocus?: (context: any) => void;
208
- onControlBlur?: () => void;
209
- onRecordChange?: (change: any) => void;
210
- onValidationChange?: (fieldName: string, error: any) => void;
211
- parentFieldPath?: string | null;
212
- disabled?: boolean;
213
- };
214
- type NestedFieldProviderProps = {
215
- children: React.ReactNode;
216
- fieldName: string;
217
- };
218
- type TemplateFieldValidationError = {
219
- hasError: boolean;
220
- hasSyntaxError: boolean;
221
- hasTypeMismatch: boolean;
222
- expectedType?: string;
223
- inferredType?: string;
224
- errorMessage?: string;
225
- willCoerce?: boolean;
226
- };
227
- type TemplateFieldFocusContext = {
228
- nodeId: string;
229
- fieldName: string;
230
- propertyPath: string;
231
- label: string;
232
- expectedType: string;
233
- currentValue: any;
234
- isExpression: boolean;
235
- editorFormat: string;
236
- inferredType?: string;
237
- errors?: any;
238
- selectedNodeId?: string;
239
- selectedNodeName?: string;
240
- elementContext?: any;
241
- userContext?: any;
242
- propertyDefinition?: any;
243
- };
244
- type TemplateFieldChangeEvent = {
245
- type: 'value_change' | 'mode_switch' | 'format_change' | 'field_focus' | 'panel_open' | 'panel_close';
246
- details: {
247
- oldValue?: string;
248
- newValue?: string;
249
- oldMode?: string;
250
- newMode?: string;
251
- description?: string;
252
- hasError?: boolean;
253
- hasTypeMismatch?: boolean;
254
- willCoerce?: boolean;
255
- expectedType?: string;
256
- inferredType?: string;
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
- }>;
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;
377
- declare const index_Input: typeof Input;
378
- type index_InputProps = InputProps;
379
- declare const index_NestedFieldProvider: typeof NestedFieldProvider;
380
- type index_NestedFieldProviderProps = NestedFieldProviderProps;
381
- declare const index_OPERATORS_BY_TYPE: typeof OPERATORS_BY_TYPE;
382
- declare const index_Select: typeof Select;
383
- type index_SelectOption = SelectOption;
384
- type index_SelectProps = SelectProps;
385
- type index_SelectRenderProps = SelectRenderProps;
386
- type index_TemplateFieldChangeEvent = TemplateFieldChangeEvent;
387
- type index_TemplateFieldContextValue = TemplateFieldContextValue;
388
- type index_TemplateFieldFocusContext = TemplateFieldFocusContext;
389
- declare const index_TemplateFieldProvider: typeof TemplateFieldProvider;
390
- type index_TemplateFieldProviderProps = TemplateFieldProviderProps;
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;
395
- declare const index_useFieldPath: typeof useFieldPath;
396
- declare const index_useInferredTypes: typeof useInferredTypes;
397
- declare const index_useIsInTemplateFieldProvider: typeof useIsInTemplateFieldProvider;
398
- declare const index_useTemplateFieldContext: typeof useTemplateFieldContext;
399
- declare namespace index {
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 };
401
- }
402
-
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 };