@myunisoft/design-system 1.2.5-rev157.1 → 1.2.5-rev157.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/dist/components/DocumentComposer/NoSectionsPlaceholder/index.d.ts +4 -0
- package/dist/components/DocumentComposer/Treeview/slots/LabelInputSlot.d.ts +1 -0
- package/dist/components/DocumentComposer/Treeview/types.d.ts +2 -2
- package/dist/components/DocumentComposer/hooks/useSectionsMap.d.ts +5 -0
- package/dist/components/DocumentComposer/hooks/useTemporarySection.d.ts +10 -10
- package/dist/components/DocumentComposer/index.d.ts +3 -3
- package/dist/components/DocumentComposer/types.d.ts +20 -9
- package/dist/components/DocumentComposer/utils/getSectionMenuItems.d.ts +14 -0
- package/dist/components/DocumentComposer/utils/sectionHelpers.d.ts +10 -0
- package/dist/index.js +3 -3
- package/package.json +2 -2
- package/dist/components/DocumentComposer/EmptySummary/index.d.ts +0 -4
- package/dist/components/DocumentComposer/hooks/useDragValidation.d.ts +0 -14
- package/dist/components/DocumentComposer/hooks/useSummaryItemsMap.d.ts +0 -5
- package/dist/components/DocumentComposer/utils/getSummaryItemMenuItems.d.ts +0 -9
- package/dist/components/DocumentComposer/utils/summaryHelpers.d.ts +0 -12
|
@@ -8,4 +8,5 @@ export declare const LabelInputSlot: import("react").ForwardRefExoticComponent<I
|
|
|
8
8
|
onTemporarySectionCancel?: () => void;
|
|
9
9
|
onItemLabelChange?: (itemId: string, newLabel: string) => void;
|
|
10
10
|
apiRef?: RichTreeViewProApiRef;
|
|
11
|
+
onEditingEnd?: () => void;
|
|
11
12
|
} & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RichTreeViewProApiRef } from '@mui/x-tree-view-pro';
|
|
2
|
-
import type {
|
|
2
|
+
import type { TemporarySection } from '../hooks/useTemporarySection';
|
|
3
3
|
export type ItemPositionParams = {
|
|
4
4
|
itemId: string;
|
|
5
5
|
oldPosition: {
|
|
@@ -31,7 +31,7 @@ export type TreeviewProps<T> = {
|
|
|
31
31
|
canMoveItemToNewPosition: (params: ItemPositionParams) => boolean;
|
|
32
32
|
onItemPositionChange: (params: ItemPositionParams) => void;
|
|
33
33
|
onItemLabelChange: (itemId: string, newLabel: string) => void;
|
|
34
|
-
temporaryItem:
|
|
34
|
+
temporaryItem: TemporarySection | null;
|
|
35
35
|
isTemporaryItem: (itemId: string) => boolean;
|
|
36
36
|
onTemporarySectionValidation: (label: string) => void;
|
|
37
37
|
onTemporarySectionCancel: () => void;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import type { RichTreeViewProApiRef } from '@mui/x-tree-view-pro';
|
|
2
|
-
import type {
|
|
3
|
-
export type
|
|
2
|
+
import type { DocumentSection } from '../types';
|
|
3
|
+
export type TemporarySection = Pick<DocumentSection, 'id' | 'parentId'> & {
|
|
4
4
|
parentVisible: boolean;
|
|
5
5
|
};
|
|
6
6
|
type UseTemporarySectionParams = {
|
|
7
7
|
apiRef: RichTreeViewProApiRef;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
getSectionById: (sectionId: string) => DocumentSection | null;
|
|
9
|
+
onSubsectionCreate?: (parentId: string | null, title: string) => string | Promise<string>;
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
12
|
* Flow:
|
|
13
13
|
* 1. User triggers `create(parentId)` from context menu
|
|
14
|
-
* 2. A temporary
|
|
15
|
-
* 3. User types a
|
|
14
|
+
* 2. A temporary section appears in the tree in edit mode
|
|
15
|
+
* 3. User types a title and presses Enter → `validate()` is called
|
|
16
16
|
* 4. User presses Escape or leaves empty → `cancel()` is called
|
|
17
17
|
*/
|
|
18
|
-
export declare const useTemporarySection: ({ apiRef,
|
|
19
|
-
|
|
18
|
+
export declare const useTemporarySection: ({ apiRef, getSectionById, onSubsectionCreate }: UseTemporarySectionParams) => {
|
|
19
|
+
temporarySection: TemporarySection | null;
|
|
20
20
|
create: (parentId: string) => void;
|
|
21
|
-
validate: (
|
|
21
|
+
validate: (title: string) => Promise<void>;
|
|
22
22
|
cancel: () => void;
|
|
23
|
-
isTemporary: (
|
|
23
|
+
isTemporary: (sectionId: string) => boolean;
|
|
24
24
|
};
|
|
25
25
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { DocumentComposerCallbacks, DocumentComposerCustomProps,
|
|
1
|
+
import type { DocumentComposerCallbacks, DocumentComposerCustomProps, DocumentSection } from './types';
|
|
2
2
|
type DocumentComposerProps = {
|
|
3
|
-
|
|
3
|
+
sections?: DocumentSection[];
|
|
4
4
|
} & DocumentComposerCallbacks & DocumentComposerCustomProps;
|
|
5
|
-
declare const DocumentComposer: ({
|
|
5
|
+
declare const DocumentComposer: ({ sections, onSectionOrderChange, onSectionTitleChange, onSectionDelete, onSectionVisibilityChange, onSubsectionCreate, noSectionsPlaceholder, isLoading, getSectionRenamePermission, getSectionDeletePermission, getSectionReorderPermission, getSubsectionCreatePermission, getSectionVisibilityPermission }: DocumentComposerProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export default DocumentComposer;
|
|
@@ -1,24 +1,35 @@
|
|
|
1
1
|
import type { ItemPositionParams } from './Treeview/types';
|
|
2
|
-
export type
|
|
2
|
+
export type DocumentSection = {
|
|
3
3
|
id: string;
|
|
4
4
|
title: string;
|
|
5
5
|
visible: boolean;
|
|
6
6
|
parentId: string | null;
|
|
7
|
-
sections?:
|
|
7
|
+
sections?: DocumentSection[] | null;
|
|
8
8
|
};
|
|
9
9
|
export type ItemDisplayOrder = {
|
|
10
10
|
id: string;
|
|
11
11
|
displayOrder: number;
|
|
12
12
|
};
|
|
13
13
|
export type DocumentComposerCustomProps = {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
/** Content displayed when there are no sections */
|
|
15
|
+
noSectionsPlaceholder?: string | React.ReactNode;
|
|
16
|
+
/** Show a loading state that prevents rendering the sections */
|
|
16
17
|
isLoading?: boolean;
|
|
18
|
+
/** Returns whether section title can be edited (double-click + "Renommer" menu). Defaults to `() => true`. */
|
|
19
|
+
getSectionRenamePermission?: (section: DocumentSection) => boolean;
|
|
20
|
+
/** Returns whether section can be deleted ("Supprimer" menu). Defaults to `() => true`. */
|
|
21
|
+
getSectionDeletePermission?: (section: DocumentSection) => boolean;
|
|
22
|
+
/** Returns whether section can be reordered via drag & drop. Defaults to `() => true`. */
|
|
23
|
+
getSectionReorderPermission?: (section: DocumentSection) => boolean;
|
|
24
|
+
/** Returns whether a subsection can be created under this section. Defaults to `() => true`. */
|
|
25
|
+
getSubsectionCreatePermission?: (section: DocumentSection) => boolean;
|
|
26
|
+
/** Returns whether section visibility can be toggled. Defaults to `() => true`. */
|
|
27
|
+
getSectionVisibilityPermission?: (section: DocumentSection) => boolean;
|
|
17
28
|
};
|
|
18
29
|
export type DocumentComposerCallbacks = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
30
|
+
onSectionOrderChange?: (params: ItemPositionParams) => void;
|
|
31
|
+
onSectionTitleChange?: (sectionId: string, newTitle: string) => void;
|
|
32
|
+
onSectionDelete?: (sectionId: string) => void;
|
|
33
|
+
onSectionVisibilityChange?: (sectionId: string, visible: boolean) => void;
|
|
34
|
+
onSubsectionCreate?: (parentId: string | null, title: string) => string | Promise<string>;
|
|
24
35
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ScheduleMenuAction } from '../Treeview/types';
|
|
2
|
+
import type { DocumentSection } from '../types';
|
|
3
|
+
type MenuItemCallbacks = {
|
|
4
|
+
onRename: (sectionId: string) => void;
|
|
5
|
+
onDelete: (sectionId: string) => void;
|
|
6
|
+
onCreateSubsection: (parentId: string) => void;
|
|
7
|
+
};
|
|
8
|
+
type SectionMenuCapabilities = {
|
|
9
|
+
canRename: boolean;
|
|
10
|
+
canDelete: boolean;
|
|
11
|
+
canCreateSubsection: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare const getSectionMenuItems: (section: DocumentSection, callbacks: MenuItemCallbacks, scheduleMenuAction: ScheduleMenuAction, capabilities: SectionMenuCapabilities) => React.ReactNode[];
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DocumentSection } from '../types';
|
|
2
|
+
export declare const getAllExpandableSectionIds: (sections: DocumentSection[]) => string[];
|
|
3
|
+
export declare const getAllSectionsFlat: (sections: DocumentSection[]) => DocumentSection[];
|
|
4
|
+
export declare const isRootSection: (section: DocumentSection) => boolean;
|
|
5
|
+
export declare const hasSectionMenu: (_section: DocumentSection) => boolean;
|
|
6
|
+
export declare const isSectionVisible: (section: DocumentSection) => boolean;
|
|
7
|
+
export declare const getSectionChildren: (section: DocumentSection) => DocumentSection[] | undefined;
|
|
8
|
+
export declare const getSectionId: (section: DocumentSection) => string;
|
|
9
|
+
export declare const getSectionTitle: (section: DocumentSection) => string;
|
|
10
|
+
export declare const getSectionIcon: (section: DocumentSection) => import("react/jsx-runtime").JSX.Element | null;
|