@mapples/render 1.0.5 → 1.1.1
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/components/Render.d.ts +1 -1
- package/dist/components/Render.js +1 -1
- package/dist/components/RenderComponent.d.ts +8 -9
- package/dist/components/RenderComponent.d.ts.map +1 -1
- package/dist/components/RenderComponent.js +48 -14
- package/dist/components/RenderComponent.js.map +1 -1
- package/dist/components/RenderProvider.d.ts +4 -3
- package/dist/components/RenderProvider.d.ts.map +1 -1
- package/dist/components/RenderProvider.js +4 -3
- package/dist/components/RenderProvider.js.map +1 -1
- package/dist/context/RenderStateContext.d.ts +27 -0
- package/dist/context/RenderStateContext.d.ts.map +1 -1
- package/dist/context/RenderStateContext.js +27 -0
- package/dist/context/RenderStateContext.js.map +1 -1
- package/dist/hooks/useRender.d.ts +2 -2
- package/dist/hooks/useRender.js +2 -2
- package/dist/types/index.d.ts +26 -18
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -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
|
|
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
|
|
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
|
|
14
|
-
* @param
|
|
15
|
-
* @param
|
|
16
|
-
* @param
|
|
17
|
-
* @param
|
|
18
|
-
* @param
|
|
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
|
|
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,
|
|
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 {
|
|
3
|
-
import {
|
|
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
|
|
18
|
-
* @param
|
|
19
|
-
* @param
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
22
|
-
* @param
|
|
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
|
|
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;
|
|
1
|
+
{"version":3,"file":"RenderComponent.js","sourceRoot":"","sources":["../../src/components/RenderComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAM,IAAI,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,oBAAoB,MAAM,+BAA+B,CAAC;AACjE,OAAO,WAAW,MAAM,sBAAsB,CAAC;AAG/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,eAAe,GAA4B,CAAC,EAChD,IAAI,EACJ,KAAK,EACL,SAAS,EACT,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,eAAe,GAChB,EAAE,EAAE;IACH,MAAM,EAAE,UAAU,EAAE,GAAG,SAAS,EAAE,CAAC;IACnC,MAAM,aAAa,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IAC9C,MAAM,gBAAgB,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC/C,M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AAI,EAAE,IAAI,CAAC,GAAG,EAAE;gBAChB,IAAI,EAAE,UAAU,EAAE,IAAI;gBACtB,OAAO,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE;aACrC,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC,CAAC,EACJ,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,CAAC,CACrC,CAAC;IAEF,MAAM,SAAS,GAAG,UAAU,CAAC,IAA+B,CAAC,CAAC,SAAS,CAAC;IAExE,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,EAAE;QACvC,MAAM,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,9 +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
|
|
11
|
-
* @param
|
|
12
|
-
* @param
|
|
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
|
|
13
14
|
*
|
|
14
15
|
* @example
|
|
15
16
|
* ```tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderProvider.d.ts","sourceRoot":"","sources":["../../src/components/RenderProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C
|
|
1
|
+
{"version":3,"file":"RenderProvider.d.ts","sourceRoot":"","sources":["../../src/components/RenderProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAU5D,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -6,9 +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
|
|
10
|
-
* @param
|
|
11
|
-
* @param
|
|
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
|
|
12
13
|
*
|
|
13
14
|
* @example
|
|
14
15
|
* ```tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderProvider.js","sourceRoot":"","sources":["../../src/components/RenderProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAGnD
|
|
1
|
+
{"version":3,"file":"RenderProvider.js","sourceRoot":"","sources":["../../src/components/RenderProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAGnD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,cAAc,GAA6C,CAAC,EAChE,UAAU,EACV,QAAQ,EACR,MAAM,GACP,EAAE,EAAE;IACH,OAAO,CACL,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CACnD;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,qBAAqB,CAAC,CACzB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -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
|
|
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
|
|
20
|
+
* @throws If used outside of a RenderProvider context
|
|
21
21
|
*/
|
|
22
22
|
declare const useRender: () => import("..").RenderContextType;
|
|
23
23
|
export default useRender;
|
package/dist/hooks/useRender.js
CHANGED
|
@@ -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
|
|
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
|
|
22
|
+
* @throws If used outside of a RenderProvider context
|
|
23
23
|
*/
|
|
24
24
|
const useRender = () => {
|
|
25
25
|
return useContext(RenderContext);
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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
|
|
18
|
-
* @property
|
|
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
|
|
40
|
-
* @property
|
|
41
|
-
* @property
|
|
42
|
-
* @property
|
|
43
|
-
* @property
|
|
44
|
-
* @property
|
|
45
|
-
* @property
|
|
46
|
-
* @property
|
|
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
|
|
70
|
-
* @property
|
|
71
|
-
* @property
|
|
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
|
|
91
|
+
* @property root - The root component of the render tree
|
|
85
92
|
*/
|
|
86
93
|
export interface RenderDom {
|
|
87
94
|
root: RenderComponentType;
|
|
@@ -91,8 +98,8 @@ export interface RenderDom {
|
|
|
91
98
|
* Props for the main Render component.
|
|
92
99
|
*
|
|
93
100
|
* @type RenderProps
|
|
94
|
-
* @property
|
|
95
|
-
* @property
|
|
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>;
|
|
@@ -102,7 +109,8 @@ export type RenderProps = Pick<RenderDom, 'root' | 'state'> & {
|
|
|
102
109
|
* Provides access to registered components throughout the component tree.
|
|
103
110
|
*
|
|
104
111
|
* @interface RenderContextType
|
|
105
|
-
* @property
|
|
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)`)
|
|
106
114
|
*/
|
|
107
115
|
export interface RenderContextType {
|
|
108
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,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AAC;CACxB;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,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.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"directory": "packages/@mapples/render"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"lodash": "^4.
|
|
23
|
+
"lodash": "^4.18.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"react": ">=18.0.0 <20.0.0",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/lodash": "^4.17.0",
|
|
31
31
|
"@types/react": ">=18.0.0 <20.0.0",
|
|
32
|
-
"typescript": "~
|
|
32
|
+
"typescript": "~6.0.3"
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
35
|
"dist",
|