@json-render/react-native 0.9.0 → 0.10.0

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/dist/index.d.mts CHANGED
@@ -1,12 +1,75 @@
1
- export { StateContextValue, StateProvider, StateProviderProps, useStateBinding, useStateStore, useStateValue } from '@internal/react-state';
2
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
2
  import { ReactNode, ComponentType } from 'react';
4
- import { VisibilityCondition, VisibilityContext, ActionHandler, ResolvedAction, ActionBinding, ActionConfirm, ValidationFunction, ValidationResult, ValidationConfig, Catalog, InferCatalogComponents, InferComponentProps, InferCatalogActions, InferActionParams, StateModel, UIElement, SchemaDefinition, Spec, StateStore, FlatElement } from '@json-render/core';
3
+ import { StateStore, StateModel, VisibilityCondition, VisibilityContext, ActionHandler, ResolvedAction, ActionBinding, ActionConfirm, ValidationFunction, ValidationResult, ValidationConfig, Catalog, InferCatalogComponents, InferComponentProps, InferCatalogActions, InferActionParams, UIElement, SchemaDefinition, Spec, FlatElement } from '@json-render/core';
5
4
  export { Spec, StateModel, StateStore, createStateStore } from '@json-render/core';
6
5
  export { ElementTreeSchema, ElementTreeSpec, ReactNativeSchema, ReactNativeSpec, elementTreeSchema, schema } from './schema.mjs';
7
6
  export { ActionDefinition, ComponentDefinition, standardActionDefinitions, standardComponentDefinitions } from './catalog.mjs';
8
7
  import 'zod';
9
8
 
9
+ /**
10
+ * State context value
11
+ */
12
+ interface StateContextValue {
13
+ /** The current state model */
14
+ state: StateModel;
15
+ /** Get a value by path */
16
+ get: (path: string) => unknown;
17
+ /** Set a value by path */
18
+ set: (path: string, value: unknown) => void;
19
+ /** Update multiple values at once */
20
+ update: (updates: Record<string, unknown>) => void;
21
+ /** Return the live state snapshot from the underlying store (not the React render snapshot). */
22
+ getSnapshot: () => StateModel;
23
+ }
24
+ /**
25
+ * Props for StateProvider
26
+ */
27
+ interface StateProviderProps {
28
+ /**
29
+ * External store that owns the state. When provided, the provider operates
30
+ * in **controlled mode** — `initialState` and `onStateChange` are ignored
31
+ * and the store is the single source of truth.
32
+ */
33
+ store?: StateStore;
34
+ /** Initial state model (used only in uncontrolled mode) */
35
+ initialState?: StateModel;
36
+ /**
37
+ * Callback when state changes (used only in uncontrolled mode).
38
+ * Called once per `set` or `update` with all changed entries.
39
+ */
40
+ onStateChange?: (changes: Array<{
41
+ path: string;
42
+ value: unknown;
43
+ }>) => void;
44
+ children: ReactNode;
45
+ }
46
+ /**
47
+ * Provider for state model context.
48
+ *
49
+ * Supports two modes:
50
+ * - **Controlled**: pass a `store` prop (e.g. backed by Redux / Zustand).
51
+ * - **Uncontrolled** (default): omit `store` and optionally pass
52
+ * `initialState` / `onStateChange`.
53
+ */
54
+ declare function StateProvider({ store: externalStore, initialState, onStateChange, children, }: StateProviderProps): react_jsx_runtime.JSX.Element;
55
+ /**
56
+ * Hook to access the state context
57
+ */
58
+ declare function useStateStore(): StateContextValue;
59
+ /**
60
+ * Hook to get a value from the state model
61
+ */
62
+ declare function useStateValue<T>(path: string): T | undefined;
63
+ /**
64
+ * Hook to get and set a value from the state model (like useState).
65
+ *
66
+ * @deprecated Use {@link useBoundProp} with `$bindState` expressions instead.
67
+ * `useStateBinding` takes a raw state path string, while `useBoundProp` works
68
+ * with the renderer's `bindings` map and supports both `$bindState` and
69
+ * `$bindItem` expressions.
70
+ */
71
+ declare function useStateBinding<T>(path: string): [T | undefined, (value: T) => void];
72
+
10
73
  /**
11
74
  * Visibility context value
12
75
  */
@@ -559,4 +622,4 @@ declare function useUIStream({ api, onComplete, onError, fetch: fetchFn, validat
559
622
  */
560
623
  declare function flatToTree(elements: FlatElement[]): Spec;
561
624
 
562
- export { type ActionContextValue, type ActionFn, ActionProvider, type ActionProviderProps, type Actions, type ComponentContext, type ComponentFn, type ComponentMap, type ComponentRegistry, type ComponentRenderProps, type ComponentRenderer, type Components, ConfirmDialog, type ConfirmDialogProps, type CreateRendererProps, type DefineRegistryResult, type FieldValidationState, JSONUIProvider, type JSONUIProviderProps, type PendingConfirmation, Renderer, type RendererProps, RepeatScopeProvider, type RepeatScopeValue, type SetState, type UseUIStreamOptions, type UseUIStreamReturn, type ValidationContextValue, ValidationProvider, type ValidationProviderProps, type VisibilityContextValue, VisibilityProvider, type VisibilityProviderProps, createRenderer, createStandardActionHandlers, defineRegistry, flatToTree, standardComponents, useAction, useActions, useBoundProp, useFieldValidation, useIsVisible, useRepeatScope, useUIStream, useValidation, useVisibility };
625
+ export { type ActionContextValue, type ActionFn, ActionProvider, type ActionProviderProps, type Actions, type ComponentContext, type ComponentFn, type ComponentMap, type ComponentRegistry, type ComponentRenderProps, type ComponentRenderer, type Components, ConfirmDialog, type ConfirmDialogProps, type CreateRendererProps, type DefineRegistryResult, type FieldValidationState, JSONUIProvider, type JSONUIProviderProps, type PendingConfirmation, Renderer, type RendererProps, RepeatScopeProvider, type RepeatScopeValue, type SetState, type StateContextValue, StateProvider, type StateProviderProps, type UseUIStreamOptions, type UseUIStreamReturn, type ValidationContextValue, ValidationProvider, type ValidationProviderProps, type VisibilityContextValue, VisibilityProvider, type VisibilityProviderProps, createRenderer, createStandardActionHandlers, defineRegistry, flatToTree, standardComponents, useAction, useActions, useBoundProp, useFieldValidation, useIsVisible, useRepeatScope, useStateBinding, useStateStore, useStateValue, useUIStream, useValidation, useVisibility };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,75 @@
1
- export { StateContextValue, StateProvider, StateProviderProps, useStateBinding, useStateStore, useStateValue } from '@internal/react-state';
2
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
2
  import { ReactNode, ComponentType } from 'react';
4
- import { VisibilityCondition, VisibilityContext, ActionHandler, ResolvedAction, ActionBinding, ActionConfirm, ValidationFunction, ValidationResult, ValidationConfig, Catalog, InferCatalogComponents, InferComponentProps, InferCatalogActions, InferActionParams, StateModel, UIElement, SchemaDefinition, Spec, StateStore, FlatElement } from '@json-render/core';
3
+ import { StateStore, StateModel, VisibilityCondition, VisibilityContext, ActionHandler, ResolvedAction, ActionBinding, ActionConfirm, ValidationFunction, ValidationResult, ValidationConfig, Catalog, InferCatalogComponents, InferComponentProps, InferCatalogActions, InferActionParams, UIElement, SchemaDefinition, Spec, FlatElement } from '@json-render/core';
5
4
  export { Spec, StateModel, StateStore, createStateStore } from '@json-render/core';
6
5
  export { ElementTreeSchema, ElementTreeSpec, ReactNativeSchema, ReactNativeSpec, elementTreeSchema, schema } from './schema.js';
7
6
  export { ActionDefinition, ComponentDefinition, standardActionDefinitions, standardComponentDefinitions } from './catalog.js';
8
7
  import 'zod';
9
8
 
9
+ /**
10
+ * State context value
11
+ */
12
+ interface StateContextValue {
13
+ /** The current state model */
14
+ state: StateModel;
15
+ /** Get a value by path */
16
+ get: (path: string) => unknown;
17
+ /** Set a value by path */
18
+ set: (path: string, value: unknown) => void;
19
+ /** Update multiple values at once */
20
+ update: (updates: Record<string, unknown>) => void;
21
+ /** Return the live state snapshot from the underlying store (not the React render snapshot). */
22
+ getSnapshot: () => StateModel;
23
+ }
24
+ /**
25
+ * Props for StateProvider
26
+ */
27
+ interface StateProviderProps {
28
+ /**
29
+ * External store that owns the state. When provided, the provider operates
30
+ * in **controlled mode** — `initialState` and `onStateChange` are ignored
31
+ * and the store is the single source of truth.
32
+ */
33
+ store?: StateStore;
34
+ /** Initial state model (used only in uncontrolled mode) */
35
+ initialState?: StateModel;
36
+ /**
37
+ * Callback when state changes (used only in uncontrolled mode).
38
+ * Called once per `set` or `update` with all changed entries.
39
+ */
40
+ onStateChange?: (changes: Array<{
41
+ path: string;
42
+ value: unknown;
43
+ }>) => void;
44
+ children: ReactNode;
45
+ }
46
+ /**
47
+ * Provider for state model context.
48
+ *
49
+ * Supports two modes:
50
+ * - **Controlled**: pass a `store` prop (e.g. backed by Redux / Zustand).
51
+ * - **Uncontrolled** (default): omit `store` and optionally pass
52
+ * `initialState` / `onStateChange`.
53
+ */
54
+ declare function StateProvider({ store: externalStore, initialState, onStateChange, children, }: StateProviderProps): react_jsx_runtime.JSX.Element;
55
+ /**
56
+ * Hook to access the state context
57
+ */
58
+ declare function useStateStore(): StateContextValue;
59
+ /**
60
+ * Hook to get a value from the state model
61
+ */
62
+ declare function useStateValue<T>(path: string): T | undefined;
63
+ /**
64
+ * Hook to get and set a value from the state model (like useState).
65
+ *
66
+ * @deprecated Use {@link useBoundProp} with `$bindState` expressions instead.
67
+ * `useStateBinding` takes a raw state path string, while `useBoundProp` works
68
+ * with the renderer's `bindings` map and supports both `$bindState` and
69
+ * `$bindItem` expressions.
70
+ */
71
+ declare function useStateBinding<T>(path: string): [T | undefined, (value: T) => void];
72
+
10
73
  /**
11
74
  * Visibility context value
12
75
  */
@@ -559,4 +622,4 @@ declare function useUIStream({ api, onComplete, onError, fetch: fetchFn, validat
559
622
  */
560
623
  declare function flatToTree(elements: FlatElement[]): Spec;
561
624
 
562
- export { type ActionContextValue, type ActionFn, ActionProvider, type ActionProviderProps, type Actions, type ComponentContext, type ComponentFn, type ComponentMap, type ComponentRegistry, type ComponentRenderProps, type ComponentRenderer, type Components, ConfirmDialog, type ConfirmDialogProps, type CreateRendererProps, type DefineRegistryResult, type FieldValidationState, JSONUIProvider, type JSONUIProviderProps, type PendingConfirmation, Renderer, type RendererProps, RepeatScopeProvider, type RepeatScopeValue, type SetState, type UseUIStreamOptions, type UseUIStreamReturn, type ValidationContextValue, ValidationProvider, type ValidationProviderProps, type VisibilityContextValue, VisibilityProvider, type VisibilityProviderProps, createRenderer, createStandardActionHandlers, defineRegistry, flatToTree, standardComponents, useAction, useActions, useBoundProp, useFieldValidation, useIsVisible, useRepeatScope, useUIStream, useValidation, useVisibility };
625
+ export { type ActionContextValue, type ActionFn, ActionProvider, type ActionProviderProps, type Actions, type ComponentContext, type ComponentFn, type ComponentMap, type ComponentRegistry, type ComponentRenderProps, type ComponentRenderer, type Components, ConfirmDialog, type ConfirmDialogProps, type CreateRendererProps, type DefineRegistryResult, type FieldValidationState, JSONUIProvider, type JSONUIProviderProps, type PendingConfirmation, Renderer, type RendererProps, RepeatScopeProvider, type RepeatScopeValue, type SetState, type StateContextValue, StateProvider, type StateProviderProps, type UseUIStreamOptions, type UseUIStreamReturn, type ValidationContextValue, ValidationProvider, type ValidationProviderProps, type VisibilityContextValue, VisibilityProvider, type VisibilityProviderProps, createRenderer, createStandardActionHandlers, defineRegistry, flatToTree, standardComponents, useAction, useActions, useBoundProp, useFieldValidation, useIsVisible, useRepeatScope, useStateBinding, useStateStore, useStateValue, useUIStream, useValidation, useVisibility };