@zealicsolutions/web-ui 1.0.140-beta.85 → 1.0.140-beta.87
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/cjs/containers/hooks/index.d.ts +5 -0
- package/dist/cjs/containers/hooks/useContainerDataScope.d.ts +20 -0
- package/dist/cjs/containers/hooks/useEmptyDataState.d.ts +36 -0
- package/dist/cjs/containers/hooks/useEmptyStateFiltering.d.ts +62 -0
- package/dist/cjs/containers/hooks/useEmptyStateVisibility.d.ts +37 -0
- package/dist/cjs/containers/hooks/useVisibleItems.d.ts +18 -0
- package/dist/cjs/containers/types/types.d.ts +1 -1
- package/dist/cjs/contexts/OrganismContext/OrganismContext.d.ts +23 -0
- package/dist/cjs/contexts/OrganismContext/OrganismContextProvider.d.ts +9 -1
- package/dist/cjs/index.js +7 -7
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/containers/Container.js +2 -2
- package/dist/esm/containers/Container.js.map +1 -1
- package/dist/esm/containers/FormOrganismItem.js +1 -1
- package/dist/esm/containers/OrganismItem.js +1 -1
- package/dist/esm/containers/OrganismItem.js.map +1 -1
- package/dist/esm/containers/hooks/index.d.ts +5 -0
- package/dist/esm/containers/hooks/useContainerDataScope.d.ts +20 -0
- package/dist/esm/containers/hooks/useContainerDataScope.js +2 -0
- package/dist/esm/containers/hooks/useContainerDataScope.js.map +1 -0
- package/dist/esm/containers/hooks/useEmptyDataState.d.ts +36 -0
- package/dist/esm/containers/hooks/useEmptyStateFiltering.d.ts +62 -0
- package/dist/esm/containers/hooks/useEmptyStateFiltering.js +2 -0
- package/dist/esm/containers/hooks/useEmptyStateFiltering.js.map +1 -0
- package/dist/esm/containers/hooks/useEmptyStateVisibility.d.ts +37 -0
- package/dist/esm/containers/hooks/useVisibleItems.d.ts +18 -0
- package/dist/esm/containers/hooks/useVisibleItems.js +2 -0
- package/dist/esm/containers/hooks/useVisibleItems.js.map +1 -0
- package/dist/esm/containers/types/types.d.ts +1 -1
- package/dist/esm/contexts/OrganismContext/OrganismContext.d.ts +23 -0
- package/dist/esm/contexts/OrganismContext/OrganismContext.js +1 -1
- package/dist/esm/contexts/OrganismContext/OrganismContext.js.map +1 -1
- package/dist/esm/contexts/OrganismContext/OrganismContextProvider.d.ts +9 -1
- package/dist/esm/contexts/OrganismContext/OrganismContextProvider.js +1 -1
- package/dist/esm/contexts/OrganismContext/OrganismContextProvider.js.map +1 -1
- package/dist/esm/contexts/ReplicatorRegistryContext/ReplicatorRegistryContext.js.map +1 -1
- package/dist/esm/contexts/ReplicatorRegistryContext/ReplicatorRegistryContextProvider.js.map +1 -1
- package/dist/esm/molecules/BaseMolecule.js.map +1 -1
- package/dist/esm/molecules/Button/hooks/useButtonAction.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
export { useCheckCondition } from './useCheckCondition';
|
|
2
|
+
export { useContainerDataScope } from './useContainerDataScope';
|
|
3
|
+
export { useEmptyDataState, isEmptyOrganismData } from './useEmptyDataState';
|
|
4
|
+
export { useEmptyStateFiltering, isEmptyStateContainer, getEmptyStateReplicatorFieldId, isArrayFieldEmptyAtScope, } from './useEmptyStateFiltering';
|
|
5
|
+
export { useEmptyStateVisibility, isArrayFieldEmpty } from './useEmptyStateVisibility';
|
|
2
6
|
export { useFormOrganismItem } from './useFormOrganismItem';
|
|
3
7
|
export { useStateModifierHandler } from './useStateModifierHandler';
|
|
8
|
+
export { useVisibleItems } from './useVisibleItems';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PathSegment } from '../../contexts/ContainerRuntimeContext/types';
|
|
2
|
+
export type UseContainerDataScopeParams = {
|
|
3
|
+
/**
|
|
4
|
+
* Current nested path segments from the container hierarchy
|
|
5
|
+
*/
|
|
6
|
+
nestedPathSegments: PathSegment[];
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Hook that resolves the current data scope for a container.
|
|
10
|
+
*
|
|
11
|
+
* The data scope is determined by:
|
|
12
|
+
* 1. If inside a replicator (parentContext has itemDataByDmfId) - use parent's item data
|
|
13
|
+
* 2. Otherwise - navigate from data root using nestedPathSegments
|
|
14
|
+
*
|
|
15
|
+
* This is used to check if array fields are empty at the current nesting level.
|
|
16
|
+
*
|
|
17
|
+
* @param params - Parameters containing path segments
|
|
18
|
+
* @returns Current data scope as a record, or undefined if no data
|
|
19
|
+
*/
|
|
20
|
+
export declare const useContainerDataScope: ({ nestedPathSegments, }: UseContainerDataScopeParams) => Record<string, unknown> | undefined;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Response shape from organism data API.
|
|
3
|
+
* Empty data is identified when viewType is null and data is empty object.
|
|
4
|
+
*/
|
|
5
|
+
export type OrganismDataResponse = {
|
|
6
|
+
viewType: string | null;
|
|
7
|
+
data: Record<string, unknown>;
|
|
8
|
+
metadata: Record<string, unknown>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Hook to detect if organism data represents an empty state.
|
|
12
|
+
*
|
|
13
|
+
* Empty data is identified when:
|
|
14
|
+
* - viewType is null AND
|
|
15
|
+
* - data object is empty or undefined
|
|
16
|
+
*
|
|
17
|
+
* @param organismData - The data response from the backend
|
|
18
|
+
* @returns boolean indicating if the data represents an empty state
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* // Empty data response from backend
|
|
23
|
+
* const emptyResponse = { viewType: null, data: {}, metadata: {} };
|
|
24
|
+
* const isEmpty = useEmptyDataState(emptyResponse); // true
|
|
25
|
+
*
|
|
26
|
+
* // Non-empty data response
|
|
27
|
+
* const dataResponse = { viewType: 'data_grid', data: { rows: [...] }, metadata: {} };
|
|
28
|
+
* const isEmpty = useEmptyDataState(dataResponse); // false
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare const useEmptyDataState: (organismData: unknown) => boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Helper function to check if data is empty (non-hook version).
|
|
34
|
+
* Useful for one-off checks outside of React components.
|
|
35
|
+
*/
|
|
36
|
+
export declare const isEmptyOrganismData: (organismData: unknown) => boolean;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { DmfId, PathSegment } from '../../contexts/ContainerRuntimeContext/types';
|
|
2
|
+
import { ContainerComponentProps, Molecule } from '../types/types';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if an item is an empty_state container.
|
|
5
|
+
*/
|
|
6
|
+
export declare const isEmptyStateContainer: (item: ContainerComponentProps | Molecule) => boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Gets the replicatorFieldId from an empty_state container.
|
|
9
|
+
*/
|
|
10
|
+
export declare const getEmptyStateReplicatorFieldId: (item: ContainerComponentProps | Molecule) => DmfId | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Checks if a specific array field is empty at the given scope.
|
|
13
|
+
*/
|
|
14
|
+
export declare const isArrayFieldEmptyAtScope: (scope: Record<string, unknown> | undefined, replicatorFieldId: DmfId) => boolean;
|
|
15
|
+
export type UseEmptyStateFilteringParams = {
|
|
16
|
+
/**
|
|
17
|
+
* All container items (before visibility filtering)
|
|
18
|
+
*/
|
|
19
|
+
containerItems: (ContainerComponentProps | Molecule)[] | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Items already filtered by visibility
|
|
22
|
+
*/
|
|
23
|
+
visibleItems: (ContainerComponentProps | Molecule)[];
|
|
24
|
+
/**
|
|
25
|
+
* Current nested path segments for data scope resolution
|
|
26
|
+
*/
|
|
27
|
+
nestedPathSegments: PathSegment[];
|
|
28
|
+
};
|
|
29
|
+
export type EmptyStateFilterResult = {
|
|
30
|
+
/**
|
|
31
|
+
* Items filtered based on empty state logic
|
|
32
|
+
*/
|
|
33
|
+
filteredItems: (ContainerComponentProps | Molecule)[];
|
|
34
|
+
/**
|
|
35
|
+
* Set of replicatorFieldIds that have their empty state currently showing
|
|
36
|
+
*/
|
|
37
|
+
showingEmptyStateForFields: Set<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Whether organism-level empty state is showing
|
|
40
|
+
*/
|
|
41
|
+
showOrganismLevelEmptyState: boolean;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Hook that filters container items based on empty state logic.
|
|
45
|
+
*
|
|
46
|
+
* **Design Mode (isConfigurationMode=true):**
|
|
47
|
+
* - All containers including empty_state are visible for editing
|
|
48
|
+
* - Preview mode via popover can simulate empty data state
|
|
49
|
+
*
|
|
50
|
+
* **Runtime Mode (isConfigurationMode=false):**
|
|
51
|
+
* - empty_state containers shown based on actual data emptiness
|
|
52
|
+
* - With replicatorFieldId: shows when that array is empty
|
|
53
|
+
* - Without replicatorFieldId: shows when organism data is empty
|
|
54
|
+
*
|
|
55
|
+
* When an empty_state is shown (runtime or preview):
|
|
56
|
+
* - If it has replicatorFieldId: hides sibling replicator with same fieldId
|
|
57
|
+
* - If no replicatorFieldId: hides all containers after it
|
|
58
|
+
*
|
|
59
|
+
* @param params - Parameters for filtering
|
|
60
|
+
* @returns Filtered items and empty state visibility info
|
|
61
|
+
*/
|
|
62
|
+
export declare const useEmptyStateFiltering: ({ containerItems, visibleItems, nestedPathSegments, }: UseEmptyStateFilteringParams) => EmptyStateFilterResult;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { DmfId, PathSegment } from '../../contexts/ContainerRuntimeContext/types';
|
|
2
|
+
export type EmptyStateConfig = {
|
|
3
|
+
/**
|
|
4
|
+
* The replicatorFieldId this empty state is associated with.
|
|
5
|
+
* If undefined, applies to entire organism data.
|
|
6
|
+
*/
|
|
7
|
+
replicatorFieldId?: DmfId;
|
|
8
|
+
/**
|
|
9
|
+
* Current nested path segments from the container context.
|
|
10
|
+
*/
|
|
11
|
+
nestedPathSegments?: PathSegment[];
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Hook to determine if an empty_state container should be visible.
|
|
15
|
+
*
|
|
16
|
+
* Logic:
|
|
17
|
+
* - If replicatorFieldId is NOT set → check if entire organism data is empty
|
|
18
|
+
* - If replicatorFieldId IS set → check if that specific array field is empty at current path
|
|
19
|
+
*
|
|
20
|
+
* @param config - Configuration with replicatorFieldId and nestedPathSegments
|
|
21
|
+
* @returns Object with visibility info and preview state management
|
|
22
|
+
*/
|
|
23
|
+
export declare const useEmptyStateVisibility: (config: EmptyStateConfig) => {
|
|
24
|
+
shouldShow: boolean;
|
|
25
|
+
reason: "preview";
|
|
26
|
+
} | {
|
|
27
|
+
shouldShow: boolean | undefined;
|
|
28
|
+
reason: "organism_empty" | "has_data";
|
|
29
|
+
} | {
|
|
30
|
+
shouldShow: boolean;
|
|
31
|
+
reason: "array_empty" | "has_items";
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Check if a specific array field is empty at the given path.
|
|
35
|
+
* Non-hook version for use outside React components.
|
|
36
|
+
*/
|
|
37
|
+
export declare const isArrayFieldEmpty: (dataRoot: Record<string, unknown>, nestedPathSegments: PathSegment[], replicatorFieldId: DmfId) => boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ContainerComponentProps, Molecule } from '../types/types';
|
|
2
|
+
export type UseVisibleItemsParams = {
|
|
3
|
+
/**
|
|
4
|
+
* Array of container items or molecules to filter
|
|
5
|
+
*/
|
|
6
|
+
items: (ContainerComponentProps | Molecule)[] | undefined;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Hook that filters container items based on visibility state.
|
|
10
|
+
*
|
|
11
|
+
* Checks both:
|
|
12
|
+
* - `config.props.visible` - static visibility from configuration
|
|
13
|
+
* - `stateObject[id].visible` - dynamic visibility from state
|
|
14
|
+
*
|
|
15
|
+
* @param params - Parameters containing items to filter
|
|
16
|
+
* @returns Filtered array of visible items
|
|
17
|
+
*/
|
|
18
|
+
export declare const useVisibleItems: ({ items }: UseVisibleItemsParams) => any[];
|
|
@@ -4,7 +4,7 @@ import { ValidationMode } from 'react-hook-form';
|
|
|
4
4
|
import { SizesTypes } from 'theme';
|
|
5
5
|
import type { AnyObject, Nullable, StylesType } from '../../typescript';
|
|
6
6
|
import { Molecule } from './moleculeTypes';
|
|
7
|
-
export type ContainerType = 'default' | 'row' | 'column' | 'slider' | 'form' | 'form_purpose' | 'form_step' | 'dynamic' | 'journey_driven' | 'journey_driven_step' | 'replicator';
|
|
7
|
+
export type ContainerType = 'default' | 'row' | 'column' | 'slider' | 'form' | 'form_purpose' | 'form_step' | 'dynamic' | 'journey_driven' | 'journey_driven_step' | 'replicator' | 'empty_state';
|
|
8
8
|
export type ContainerTemplateType = 'row_content_container';
|
|
9
9
|
export type WrappedContainerType = Extract<ContainerType, 'form' | 'form_step' | 'replicator'>;
|
|
10
10
|
export type DmfId = string;
|
|
@@ -61,5 +61,28 @@ export type OrganismContextType = {
|
|
|
61
61
|
loadRecordData?: (args: {
|
|
62
62
|
rwoRecordId: string;
|
|
63
63
|
}) => Promise<Record<string, unknown>>;
|
|
64
|
+
/**
|
|
65
|
+
* Indicates whether the organism has empty data from the backend.
|
|
66
|
+
* Used by containers to determine if empty_state container should be shown.
|
|
67
|
+
* When true, containers after empty_state are not rendered.
|
|
68
|
+
*/
|
|
69
|
+
isEmptyDataState?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Forces empty state display for design preview purposes.
|
|
72
|
+
* When true, empty_state containers are shown regardless of actual data.
|
|
73
|
+
* Used by the designer to preview how the organism looks with no data.
|
|
74
|
+
*/
|
|
75
|
+
forceEmptyStatePreview?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Array of replicatorFieldIds for which empty states are being previewed.
|
|
78
|
+
* Use '__organism__' for the organism-level empty state (no replicatorFieldId).
|
|
79
|
+
* This allows granular control over which nested empty states to show in designer.
|
|
80
|
+
*/
|
|
81
|
+
previewingEmptyStates?: string[];
|
|
82
|
+
/**
|
|
83
|
+
* Callback to toggle preview of a specific empty state in designer.
|
|
84
|
+
* @param replicatorFieldId - The field ID to toggle, or '__organism__' for organism-level
|
|
85
|
+
*/
|
|
86
|
+
toggleEmptyStatePreview?: (replicatorFieldId: string) => void;
|
|
64
87
|
};
|
|
65
88
|
export declare const OrganismContext: React.Context<OrganismContextType>;
|
|
@@ -55,5 +55,13 @@ export type OrganismContextProviderProps = React.PropsWithChildren<{} & Partial<
|
|
|
55
55
|
loadRecordData: (args: {
|
|
56
56
|
rwoRecordId: string;
|
|
57
57
|
}) => Promise<Record<string, unknown>>;
|
|
58
|
+
/** Indicates organism has empty data from backend */
|
|
59
|
+
isEmptyDataState: boolean;
|
|
60
|
+
/** Forces empty state preview for designer mode */
|
|
61
|
+
forceEmptyStatePreview: boolean;
|
|
62
|
+
/** Array of replicatorFieldIds being previewed */
|
|
63
|
+
previewingEmptyStates: string[];
|
|
64
|
+
/** Callback to toggle empty state preview */
|
|
65
|
+
toggleEmptyStatePreview: (replicatorFieldId: string) => void;
|
|
58
66
|
}>>;
|
|
59
|
-
export declare const OrganismContextProvider: ({ initItems, children, submitHandler, formId, validations, editable, isPreview, organismBodyId, isFormInEditMode, organismMetadata, organismInfo, localStateObject, isConfigurationMode, onConfigurationItemHandler, selectedConfigurationItemId, currentStyleProperties, currentContentProperties, onInternalNavigation, routing, prefillData, loadRecordData, }: OrganismContextProviderProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
67
|
+
export declare const OrganismContextProvider: ({ initItems, children, submitHandler, formId, validations, editable, isPreview, organismBodyId, isFormInEditMode, organismMetadata, organismInfo, localStateObject, isConfigurationMode, onConfigurationItemHandler, selectedConfigurationItemId, currentStyleProperties, currentContentProperties, onInternalNavigation, routing, prefillData, loadRecordData, isEmptyDataState, forceEmptyStatePreview, previewingEmptyStates, toggleEmptyStatePreview, }: OrganismContextProviderProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|