@zealicsolutions/web-ui 1.0.140-beta.84 → 1.0.140-beta.86

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.
Files changed (59) hide show
  1. package/dist/cjs/containers/ReplicatorContainer/ReplicatorFormSetup.d.ts +3 -1
  2. package/dist/cjs/containers/hooks/index.d.ts +5 -0
  3. package/dist/cjs/containers/hooks/useContainerDataScope.d.ts +20 -0
  4. package/dist/cjs/containers/hooks/useEmptyDataState.d.ts +36 -0
  5. package/dist/cjs/containers/hooks/useEmptyStateFiltering.d.ts +57 -0
  6. package/dist/cjs/containers/hooks/useEmptyStateVisibility.d.ts +37 -0
  7. package/dist/cjs/containers/hooks/useVisibleItems.d.ts +18 -0
  8. package/dist/cjs/containers/types/types.d.ts +1 -1
  9. package/dist/cjs/contexts/OrganismContext/OrganismContext.d.ts +23 -0
  10. package/dist/cjs/contexts/OrganismContext/OrganismContextProvider.d.ts +9 -1
  11. package/dist/cjs/index.js +7 -7
  12. package/dist/cjs/index.js.map +1 -1
  13. package/dist/esm/_virtual/index3.js +1 -1
  14. package/dist/esm/_virtual/index4.js +1 -1
  15. package/dist/esm/containers/Container.js +2 -2
  16. package/dist/esm/containers/Container.js.map +1 -1
  17. package/dist/esm/containers/FormOrganismItem.js +1 -1
  18. package/dist/esm/containers/OrganismItem.js +1 -1
  19. package/dist/esm/containers/OrganismItem.js.map +1 -1
  20. package/dist/esm/containers/ReplicatorContainer/ReplicatorFormSetup.d.ts +3 -1
  21. package/dist/esm/containers/ReplicatorContainer/ReplicatorFormSetup.js +1 -1
  22. package/dist/esm/containers/ReplicatorContainer/ReplicatorFormSetup.js.map +1 -1
  23. package/dist/esm/containers/hooks/index.d.ts +5 -0
  24. package/dist/esm/containers/hooks/useContainerDataScope.d.ts +20 -0
  25. package/dist/esm/containers/hooks/useContainerDataScope.js +2 -0
  26. package/dist/esm/containers/hooks/useContainerDataScope.js.map +1 -0
  27. package/dist/esm/containers/hooks/useEmptyDataState.d.ts +36 -0
  28. package/dist/esm/containers/hooks/useEmptyStateFiltering.d.ts +57 -0
  29. package/dist/esm/containers/hooks/useEmptyStateFiltering.js +2 -0
  30. package/dist/esm/containers/hooks/useEmptyStateFiltering.js.map +1 -0
  31. package/dist/esm/containers/hooks/useEmptyStateVisibility.d.ts +37 -0
  32. package/dist/esm/containers/hooks/useVisibleItems.d.ts +18 -0
  33. package/dist/esm/containers/hooks/useVisibleItems.js +2 -0
  34. package/dist/esm/containers/hooks/useVisibleItems.js.map +1 -0
  35. package/dist/esm/containers/types/types.d.ts +1 -1
  36. package/dist/esm/contexts/OrganismContext/OrganismContext.d.ts +23 -0
  37. package/dist/esm/contexts/OrganismContext/OrganismContext.js +1 -1
  38. package/dist/esm/contexts/OrganismContext/OrganismContext.js.map +1 -1
  39. package/dist/esm/contexts/OrganismContext/OrganismContextProvider.d.ts +9 -1
  40. package/dist/esm/contexts/OrganismContext/OrganismContextProvider.js +1 -1
  41. package/dist/esm/contexts/OrganismContext/OrganismContextProvider.js.map +1 -1
  42. package/dist/esm/contexts/ReplicatorRegistryContext/ReplicatorRegistryContext.js.map +1 -1
  43. package/dist/esm/contexts/ReplicatorRegistryContext/ReplicatorRegistryContextProvider.js.map +1 -1
  44. package/dist/esm/molecules/BaseMolecule.js.map +1 -1
  45. package/dist/esm/molecules/Button/hooks/useButtonAction.js.map +1 -1
  46. package/dist/esm/node_modules/@mui/material/esm/Accordion/Accordion.js +1 -1
  47. package/dist/esm/node_modules/@mui/material/esm/Menu/Menu.js +1 -1
  48. package/dist/esm/node_modules/@mui/material/esm/MenuList/MenuList.js +1 -1
  49. package/dist/esm/node_modules/@mui/material/esm/Select/SelectInput.js +1 -1
  50. package/dist/esm/node_modules/@mui/material/esm/SpeedDial/SpeedDial.js +1 -1
  51. package/dist/esm/node_modules/@mui/material/esm/Tabs/Tabs.js +1 -1
  52. package/dist/esm/node_modules/@mui/material/esm/ToggleButtonGroup/ToggleButtonGroup.js +1 -1
  53. package/dist/esm/node_modules/@mui/material/node_modules/react-is/index.js +1 -1
  54. package/dist/esm/node_modules/classnames/index.js +1 -1
  55. package/dist/esm/node_modules/react-slick/lib/arrows.js +1 -1
  56. package/dist/esm/node_modules/react-slick/lib/dots.js +1 -1
  57. package/dist/esm/node_modules/react-slick/lib/inner-slider.js +1 -1
  58. package/dist/esm/node_modules/react-slick/lib/track.js +1 -1
  59. package/package.json +1 -1
@@ -1,5 +1,7 @@
1
1
  import { FC, PropsWithChildren } from 'react';
2
2
  import { PathSegment } from '../../contexts/ContainerRuntimeContext/types';
3
+ /** Default maximum number of replicator instances to prevent performance issues */
4
+ export declare const DEFAULT_MAX_REPLICATOR_INSTANCES = 50;
3
5
  export interface ReplicatorFormSetupProps {
4
6
  /** The replicatorFieldId (pmiObjectId) - used as the field array name */
5
7
  replicatorFieldId: string;
@@ -7,7 +9,7 @@ export interface ReplicatorFormSetupProps {
7
9
  nestedPathSegments?: PathSegment[];
8
10
  /** Minimum instances allowed (defaults to 1 to ensure at least one instance is shown) */
9
11
  minInstances?: number;
10
- /** Maximum instances allowed */
12
+ /** Maximum instances allowed (defaults to 50 to prevent performance issues) */
11
13
  maxInstances?: number;
12
14
  }
13
15
  /**
@@ -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,57 @@
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
+ * Handles nested empty states where each empty_state container can have:
47
+ * - No replicatorFieldId → applies to entire organism (shows when isEmptyDataState)
48
+ * - With replicatorFieldId → applies to that specific array (shows when array is empty)
49
+ *
50
+ * When an empty_state is shown:
51
+ * - If it has replicatorFieldId: hides sibling replicator with same fieldId
52
+ * - If no replicatorFieldId: hides all containers after it
53
+ *
54
+ * @param params - Parameters for filtering
55
+ * @returns Filtered items and empty state visibility info
56
+ */
57
+ 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;