@mapples/render 1.1.0 → 1.1.2

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 CHANGED
@@ -126,18 +126,17 @@ The main component for rendering component trees from definitions.
126
126
 
127
127
  #### `RenderProvider`
128
128
 
129
- Provider component that makes registered components and assets available to the render system.
129
+ Provider component that makes registered components available to the render system.
130
130
 
131
131
  **Props:**
132
132
 
133
133
  - `components: RegisteredComponents` - Map of registered components
134
- - `assets?: AnyObject` - Optional map of asset refs to values (e.g. images, fonts) for resolving `ref(type:id:name)` in component props
135
134
  - `children: ReactNode` - Child components
136
135
 
137
136
  **Example:**
138
137
 
139
138
  ```tsx
140
- <RenderProvider components={registeredComponents} assets={assets}>
139
+ <RenderProvider components={registeredComponents}>
141
140
  <App />
142
141
  </RenderProvider>
143
142
  ```
@@ -6,7 +6,7 @@ import { RenderProps } from '../types';
6
6
  * definition and renders it using either a custom render component or the default
7
7
  * RenderComponent implementation.
8
8
  *
9
- * @param {RenderProps} props - The render props
9
+ * @param props - The render props
10
10
  *
11
11
  * @example
12
12
  * ```tsx
@@ -7,7 +7,7 @@ import RenderComponent from './RenderComponent';
7
7
  * definition and renders it using either a custom render component or the default
8
8
  * RenderComponent implementation.
9
9
  *
10
- * @param {RenderProps} props - The render props
10
+ * @param props - The render props
11
11
  *
12
12
  * @example
13
13
  * ```tsx
@@ -10,14 +10,15 @@ import { RenderComponentType } from '../types';
10
10
  * The component is memoized for performance optimization to prevent unnecessary
11
11
  * re-renders when props haven't changed.
12
12
  *
13
- * @param {RenderComponentType} props - The component definition
14
- * @param {string} props.type - The component type name (must be registered)
15
- * @param {AnyObject & { zIndex?: number }} props.props - Component props
16
- * @param {DataProps} [props.dataProps] - Optional data property bindings
17
- * @param {string[]} props.children - Array of child component IDs
18
- * @param {ChildComponents} props.childComponents - Map of child components
13
+ * @param props - The component definition
14
+ * @param props.type - The component type name (must be registered in the render context)
15
+ * @param props.props - Component props including optional `zIndex`
16
+ * @param props.dataProps - Optional data property bindings
17
+ * @param props.refProps - Optional map of ref property names to asset reference strings
18
+ * @param props.children - Array of child component IDs
19
+ * @param props.childComponents - Map of child components keyed by their IDs
19
20
  *
20
- * @returns {JSX.Element | null} The rendered component or null if component type not found
21
+ * @returns The rendered component, or `null` if the component type is not registered
21
22
  *
22
23
  * @example
23
24
  * ```tsx
@@ -32,8 +33,6 @@ import { RenderComponentType } from '../types';
32
33
  *
33
34
  * <RenderComponent {...componentDef} />
34
35
  * ```
35
- *
36
- * @throws {Error} If the component type is not registered in the render context
37
36
  */
38
37
  declare const RenderComponent: FC<RenderComponentType>;
39
38
  export default RenderComponent;
@@ -1 +1 @@
1
- {"version":3,"file":"RenderComponent.d.ts","sourceRoot":"","sources":["../../src/components/RenderComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAQ,MAAM,OAAO,CAAC;AAQjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,QAAA,MAAM,eAAe,EAAE,EAAE,CAAC,mBAAmB,CAsC5C,CAAC;AAQF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"RenderComponent.d.ts","sourceRoot":"","sources":["../../src/components/RenderComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAiB,MAAM,OAAO,CAAC;AAU1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,QAAA,MAAM,eAAe,EAAE,EAAE,CAAC,mBAAmB,CA+E5C,CAAC;AAQF,eAAe,eAAe,CAAC"}
@@ -1,6 +1,8 @@
1
- import { memo } from 'react';
2
- import { useDataProps } from '@mapples/state';
3
- import { map } from 'lodash';
1
+ import { memo, useMemo } from 'react';
2
+ import { useActionStore } from '@mapples/action';
3
+ import { isThis, parseThis } from '@mapples/inlang';
4
+ import { useDataProps, useDataState } from '@mapples/state';
5
+ import { isPlainObject, map, mapValues } from 'lodash';
4
6
  import { useRender } from '../hooks';
5
7
  import useConditionalStyled from '../hooks/useConditionalStyled';
6
8
  import useRefProps from '../hooks/useRefProps';
@@ -14,14 +16,15 @@ import useRefProps from '../hooks/useRefProps';
14
16
  * The component is memoized for performance optimization to prevent unnecessary
15
17
  * re-renders when props haven't changed.
16
18
  *
17
- * @param {RenderComponentType} props - The component definition
18
- * @param {string} props.type - The component type name (must be registered)
19
- * @param {AnyObject & { zIndex?: number }} props.props - Component props
20
- * @param {DataProps} [props.dataProps] - Optional data property bindings
21
- * @param {string[]} props.children - Array of child component IDs
22
- * @param {ChildComponents} props.childComponents - Map of child components
19
+ * @param props - The component definition
20
+ * @param props.type - The component type name (must be registered in the render context)
21
+ * @param props.props - Component props including optional `zIndex`
22
+ * @param props.dataProps - Optional data property bindings
23
+ * @param props.refProps - Optional map of ref property names to asset reference strings
24
+ * @param props.children - Array of child component IDs
25
+ * @param props.childComponents - Map of child components keyed by their IDs
23
26
  *
24
- * @returns {JSX.Element | null} The rendered component or null if component type not found
27
+ * @returns The rendered component, or `null` if the component type is not registered
25
28
  *
26
29
  * @example
27
30
  * ```tsx
@@ -36,14 +39,45 @@ import useRefProps from '../hooks/useRefProps';
36
39
  *
37
40
  * <RenderComponent {...componentDef} />
38
41
  * ```
39
- *
40
- * @throws {Error} If the component type is not registered in the render context
41
42
  */
42
- const RenderComponent = ({ type, props, dataProps, children, refProps, childComponents, }) => {
43
+ const RenderComponent = ({ type, props, dataProps, actionProps, children, refProps, childComponents, }) => {
43
44
  const { components } = useRender();
44
45
  const propsWithData = useDataProps(dataProps);
45
46
  const resolvedRefProps = useRefProps(refProps);
46
47
  const propsWithConditional = useConditionalStyled(props);
48
+ const { getValue } = useDataState();
49
+ const actionStore = useActionStore();
50
+ // Turn each `actionProps` entry into a handler that emits onto the action
51
+ // store. `dataProp` resolves from state (or an event arg for `"this"`);
52
+ // `staticData` is a literal payload merged in last so author-time config —
53
+ // e.g. a navigation target — survives regardless of state.
54
+ const mappedActionProps = useMemo(() => mapValues(actionProps, (actionProp) => {
55
+ return (...originalEventData) => {
56
+ const dataProp = actionProp?.dataProp || '';
57
+ let resolved;
58
+ if (isThis(dataProp)) {
59
+ const [, indexStr] = parseThis(dataProp);
60
+ const index = indexStr ? parseInt(indexStr) : 0;
61
+ resolved = originalEventData[!isNaN(index) ? index : 0];
62
+ }
63
+ else if (dataProp) {
64
+ resolved = getValue({ key: dataProp, active: true });
65
+ }
66
+ const data = actionProp?.staticData
67
+ ? {
68
+ ...(isPlainObject(resolved)
69
+ ? resolved
70
+ : {}),
71
+ ...actionProp.staticData,
72
+ }
73
+ : resolved;
74
+ actionStore.next({
75
+ time: Date.now(),
76
+ type: actionProp?.type,
77
+ payload: { originalEventData, data },
78
+ });
79
+ };
80
+ }), [actionProps, actionStore, getValue]);
47
81
  const Component = components[type].Component;
48
82
  if (!Component) {
49
83
  return null;
@@ -52,7 +86,7 @@ const RenderComponent = ({ type, props, dataProps, children, refProps, childComp
52
86
  const renderComponentProps = childComponents[child];
53
87
  return (<RenderComponentMemorized {...renderComponentProps} key={renderComponentProps.id}/>);
54
88
  };
55
- return (<Component {...propsWithConditional} {...propsWithData} {...resolvedRefProps}>
89
+ return (<Component {...propsWithConditional} {...propsWithData} {...resolvedRefProps} {...mappedActionProps}>
56
90
  {map(children, renderChildren)}
57
91
  </Component>);
58
92
  };
@@ -1 +1 @@
1
- {"version":3,"file":"RenderComponent.js","sourceRoot":"","sources":["../../src/components/RenderComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAM,IAAI,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,oBAAoB,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AAM,oBAAoB,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;QACpD,OAAO,CACL,CAAC,wBAAwB,CACvB,IAAI,oBAAoB,CAAC,CACzB,GAAG,CAAC,CAAC,oBAAoB,CAAC,EAAE,CAAC,EAC7B,CACH,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CACL,CAAC,SAAS,CACR,IAAI,oBAAoB,CAAC,CACzB,IAAI,aAAa,CAAC,CAClB,IAAI,gBAAgB,CAAC,CACrB,IAAI,iBAAiB,CAAC,CAEtB;MAAA,CAAC,GAAG,CAAC,QAAQ,EAAE,cAAc,CAAC,CAChC;IAAA,EAAE,SAAS,CAAC,CACb,CAAC;AACJ,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,wBAAwB,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC;AAEvD,eAAe,eAAe,CAAC"}
@@ -7,10 +7,10 @@ import { RenderContextType } from '../types';
7
7
  * to all child components through React context. It's essential for the render
8
8
  * system to function properly as it makes components available for dynamic rendering.
9
9
  *
10
- * @param {PropsWithChildren<RenderContextType>} props - The component props
11
- * @param {RegisteredComponents} props.components - Map of registered components
12
- * @param {AnyObject} [props.assets] - Optional map of asset refs (ref(type:id:name)) to values
13
- * @param {ReactNode} props.children - Child components to render
10
+ * @param props - The component props
11
+ * @param props.components - Map of registered components available for rendering
12
+ * @param props.assets - Map of asset references (e.g. images, icons) resolved by `useRefProps`
13
+ * @param props.children - Child components to render
14
14
  *
15
15
  * @example
16
16
  * ```tsx
@@ -6,10 +6,10 @@ import { RenderContextProvider } from '../context';
6
6
  * to all child components through React context. It's essential for the render
7
7
  * system to function properly as it makes components available for dynamic rendering.
8
8
  *
9
- * @param {PropsWithChildren<RenderContextType>} props - The component props
10
- * @param {RegisteredComponents} props.components - Map of registered components
11
- * @param {AnyObject} [props.assets] - Optional map of asset refs (ref(type:id:name)) to values
12
- * @param {ReactNode} props.children - Child components to render
9
+ * @param props - The component props
10
+ * @param props.components - Map of registered components available for rendering
11
+ * @param props.assets - Map of asset references (e.g. images, icons) resolved by `useRefProps`
12
+ * @param props.children - Child components to render
13
13
  *
14
14
  * @example
15
15
  * ```tsx
@@ -1,5 +1,32 @@
1
1
  import { StateCondition } from '../types';
2
+ /**
3
+ * React context for render-level state conditions.
4
+ *
5
+ * Carries a map of named {@link StateCondition} objects that drive conditional
6
+ * styling inside the render tree. The value is `undefined` when no state has
7
+ * been provided (i.e. when the component is rendered outside a
8
+ * {@link RenderStateContextProvider}).
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * const state = useContext(RenderStateContext);
13
+ * const condition = state?.['isActive'];
14
+ * ```
15
+ */
2
16
  declare const RenderStateContext: import("react").Context<Record<string, StateCondition> | undefined>;
17
+ /**
18
+ * Provider component for {@link RenderStateContext}.
19
+ *
20
+ * Wrap a subtree with this provider to supply state conditions used for
21
+ * conditional styling and rendering.
22
+ *
23
+ * @example
24
+ * ```tsx
25
+ * <RenderStateContextProvider value={stateConditions}>
26
+ * <RenderComponent {...componentDef} />
27
+ * </RenderStateContextProvider>
28
+ * ```
29
+ */
3
30
  export declare const RenderStateContextProvider: import("react").Provider<Record<string, StateCondition> | undefined>;
4
31
  export default RenderStateContext;
5
32
  //# sourceMappingURL=RenderStateContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RenderStateContext.d.ts","sourceRoot":"","sources":["../../src/context/RenderStateContext.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,QAAA,MAAM,kBAAkB,qEAEZ,CAAC;AAEb,eAAO,MAAM,0BAA0B,sEAA8B,CAAC;AAEtE,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"RenderStateContext.d.ts","sourceRoot":"","sources":["../../src/context/RenderStateContext.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,kBAAkB,qEAEZ,CAAC;AAEb;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,0BAA0B,sEAA8B,CAAC;AAEtE,eAAe,kBAAkB,CAAC"}
@@ -1,5 +1,32 @@
1
1
  import { createContext } from 'react';
2
+ /**
3
+ * React context for render-level state conditions.
4
+ *
5
+ * Carries a map of named {@link StateCondition} objects that drive conditional
6
+ * styling inside the render tree. The value is `undefined` when no state has
7
+ * been provided (i.e. when the component is rendered outside a
8
+ * {@link RenderStateContextProvider}).
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * const state = useContext(RenderStateContext);
13
+ * const condition = state?.['isActive'];
14
+ * ```
15
+ */
2
16
  const RenderStateContext = createContext(undefined);
17
+ /**
18
+ * Provider component for {@link RenderStateContext}.
19
+ *
20
+ * Wrap a subtree with this provider to supply state conditions used for
21
+ * conditional styling and rendering.
22
+ *
23
+ * @example
24
+ * ```tsx
25
+ * <RenderStateContextProvider value={stateConditions}>
26
+ * <RenderComponent {...componentDef} />
27
+ * </RenderStateContextProvider>
28
+ * ```
29
+ */
3
30
  export const RenderStateContextProvider = RenderStateContext.Provider;
4
31
  export default RenderStateContext;
5
32
  //# sourceMappingURL=RenderStateContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RenderStateContext.js","sourceRoot":"","sources":["../../src/context/RenderStateContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAItC,MAAM,kBAAkB,GAAG,aAAa,CAEtC,SAAS,CAAC,CAAC;AAEb,MAAM,CAAC,MAAM,0BAA0B,GAAG,kBAAkB,CAAC,QAAQ,CAAC;AAEtE,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"RenderStateContext.js","sourceRoot":"","sources":["../../src/context/RenderStateContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAItC;;;;;;;;;;;;;GAaG;AACH,MAAM,kBAAkB,GAAG,aAAa,CAEtC,SAAS,CAAC,CAAC;AAEb;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,kBAAkB,CAAC,QAAQ,CAAC;AAEtE,eAAe,kBAAkB,CAAC"}
@@ -5,7 +5,7 @@
5
5
  * context data. It should be used within components that are wrapped by
6
6
  * a RenderProvider.
7
7
  *
8
- * @returns {RenderContextType} The render context containing registered components
8
+ * @returns The render context containing registered components
9
9
  *
10
10
  * @example
11
11
  * ```tsx
@@ -17,7 +17,7 @@
17
17
  * };
18
18
  * ```
19
19
  *
20
- * @throws {Error} If used outside of a RenderProvider context
20
+ * @throws If used outside of a RenderProvider context
21
21
  */
22
22
  declare const useRender: () => import("..").RenderContextType;
23
23
  export default useRender;
@@ -7,7 +7,7 @@ import { RenderContext } from '../context';
7
7
  * context data. It should be used within components that are wrapped by
8
8
  * a RenderProvider.
9
9
  *
10
- * @returns {RenderContextType} The render context containing registered components
10
+ * @returns The render context containing registered components
11
11
  *
12
12
  * @example
13
13
  * ```tsx
@@ -19,7 +19,7 @@ import { RenderContext } from '../context';
19
19
  * };
20
20
  * ```
21
21
  *
22
- * @throws {Error} If used outside of a RenderProvider context
22
+ * @throws If used outside of a RenderProvider context
23
23
  */
24
24
  const useRender = () => {
25
25
  return useContext(RenderContext);
package/dist/index.d.ts CHANGED
@@ -1,11 +1,3 @@
1
- /**
2
- * @packageDocumentation
3
- * @module @mapples/render
4
- *
5
- * Dynamic component rendering from JSON-like definitions. Register components,
6
- * provide optional assets, and render trees from RenderComponentType with
7
- * data binding and action props support.
8
- */
9
1
  export * from './types';
10
2
  export * from './context';
11
3
  export * from './components';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,11 +1,3 @@
1
- /**
2
- * @packageDocumentation
3
- * @module @mapples/render
4
- *
5
- * Dynamic component rendering from JSON-like definitions. Register components,
6
- * provide optional assets, and render trees from RenderComponentType with
7
- * data binding and action props support.
8
- */
9
1
  export * from './types';
10
2
  export * from './context';
11
3
  export * from './components';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
@@ -14,12 +14,18 @@ export type ChildComponents = Record<string, RenderComponentType>;
14
14
  * Configuration for action properties that define component interactions.
15
15
  *
16
16
  * @interface ActionProps
17
- * @property {string} [type] - The type of action to perform
18
- * @property {string} [dataProp] - The data property key to bind to this action
17
+ * @property [type] - The type of action to perform
18
+ * @property [dataProp] - The data property key to bind to this action
19
+ * @property [staticData] - Literal payload merged into the emitted
20
+ * `Action.payload.data` (wins over `dataProp` resolution). Use this for
21
+ * configuration that is known at author time and must not be resolved from
22
+ * state — e.g. a navigation target (`{ routeName }`). `dataProp` stays for
23
+ * genuine state binding.
19
24
  */
20
25
  export interface ActionProps {
21
26
  type?: string;
22
27
  dataProp?: string;
28
+ staticData?: Record<string, unknown>;
23
29
  }
24
30
  /**
25
31
  * A map of action properties indexed by their names.
@@ -28,7 +34,7 @@ export interface ActionProps {
28
34
  export type ActionPropsMap = Partial<Record<string, ActionProps>>;
29
35
  /**
30
36
  * A map of ref properties indexed by their names.
31
- * Each entry has ref link in format ref(assetType:uuid:name)
37
+ * Each entry has a ref link in the format ref(assetType:uuid:name)
32
38
  */
33
39
  export type RefPropsMap = Partial<Record<string, string>>;
34
40
  /**
@@ -36,14 +42,15 @@ export type RefPropsMap = Partial<Record<string, string>>;
36
42
  * This is the core type used throughout the render system.
37
43
  *
38
44
  * @interface RenderComponentType
39
- * @property {string} id - Unique identifier for this component instance
40
- * @property {string} type - The component type name (must be registered in components)
41
- * @property {AnyObject & { zIndex?: number }} props - Component props including optional zIndex
42
- * @property {AnyObject} [_canvasProps] - Optional drag-and-drop configuration for canvas interactions
43
- * @property {string[]} children - Array of child component IDs
44
- * @property {ChildComponents} childComponents - Map of child components by their IDs
45
- * @property {DataProps} [dataProps] - Optional data property bindings
46
- * @property {ActionPropsMap} [actionProps] - Optional action property configurations
45
+ * @property id - Unique identifier for this component instance
46
+ * @property type - The component type name (must be registered in components)
47
+ * @property props - Component props including optional zIndex
48
+ * @property [_canvasProps] - Optional drag-and-drop configuration for canvas interactions
49
+ * @property children - Array of child component IDs
50
+ * @property childComponents - Map of child components by their IDs
51
+ * @property [dataProps] - Optional data property bindings
52
+ * @property [actionProps] - Optional action property configurations
53
+ * @property [refProps] - Optional map of ref property names to asset reference strings (format: `ref(assetType:uuid:name)`)
47
54
  */
48
55
  export interface RenderComponentType {
49
56
  id: string;
@@ -66,9 +73,9 @@ export interface RenderComponentType {
66
73
  * used by the state package's condition system.
67
74
  *
68
75
  * @interface StateCondition
69
- * @property {string} name - The name identifier for this condition
70
- * @property {string} condition - The condition string (e.g., "user.age::eq::18")
71
- * @property {string} id - Unique identifier for this condition instance
76
+ * @property name - The name identifier for this condition
77
+ * @property condition - The condition string (e.g., "user.age::eq::18")
78
+ * @property id - Unique identifier for this condition instance
72
79
  * @public
73
80
  */
74
81
  export interface StateCondition {
@@ -81,7 +88,7 @@ export interface StateCondition {
81
88
  * Extends ChildComponents with a special 'root' component.
82
89
  *
83
90
  * @interface RenderDom
84
- * @property {RenderComponentType} root - The root component of the render tree
91
+ * @property root - The root component of the render tree
85
92
  */
86
93
  export interface RenderDom {
87
94
  root: RenderComponentType;
@@ -91,19 +98,19 @@ export interface RenderDom {
91
98
  * Props for the main Render component.
92
99
  *
93
100
  * @type RenderProps
94
- * @property {RenderComponentType} root - The root component to render
95
- * @property {FC<RenderComponentType>} [CustomRenderComponent] - Optional custom render component to override default rendering
101
+ * @property root - The root component to render
102
+ * @property [CustomRenderComponent] - Optional custom render component to override default rendering
96
103
  */
97
104
  export type RenderProps = Pick<RenderDom, 'root' | 'state'> & {
98
105
  CustomRenderComponent?: FC<RenderComponentType>;
99
106
  };
100
107
  /**
101
108
  * Context type for the render system.
102
- * Provides access to registered components and assets throughout the component tree.
109
+ * Provides access to registered components throughout the component tree.
103
110
  *
104
111
  * @interface RenderContextType
105
- * @property {RegisteredComponents} components - Map of registered components available for rendering
106
- * @property {AnyObject} assets - Map of asset refs (e.g. ref(type:id:name)) to values for resolving in component props
112
+ * @property components - Map of registered components available for rendering
113
+ * @property assets - Map of resolved asset values keyed by their ref strings (format: `ref(assetType:uuid:name)`)
107
114
  */
108
115
  export interface RenderContextType {
109
116
  components: RegisteredComponents;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAE3B,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEjE;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE5C;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;AAElE;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B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M,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CACxC;AAED;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG;IAC5D,qBAAqB,CAAC,EAAE,EAAE,CAAC,mBAAmB,CAAC,CAAC;CACjD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,oBAAoB,CAAC;IACjC,MAAM,EAAE,SAAS,CAAC;CACnB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapples/render",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {