@myunisoft/design-system 1.2.6-rev396 → 1.2.7
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/AnchoredPopper/index.d.ts +14 -0
- package/dist/components/DataGrid/components/toolbar/ActionsMenu/index.d.ts +4 -0
- package/dist/components/DataGrid/components/toolbar/buttons/AddButton.d.ts +6 -0
- package/dist/components/DataGrid/components/toolbar/buttons/ExportButton.d.ts +9 -0
- package/dist/components/DataGrid/types/index.d.ts +428 -0
- package/dist/components/DocumentComposer/LoadingSkeleton.d.ts +2 -0
- package/dist/components/DocumentComposer/NoSectionsPlaceholder/index.d.ts +4 -0
- package/dist/components/DocumentComposer/Treeview/CustomTreeItem.d.ts +9 -0
- package/dist/components/DocumentComposer/Treeview/hooks/useTreeItemMenu.d.ts +12 -0
- package/dist/components/DocumentComposer/Treeview/index.d.ts +3 -0
- package/dist/components/DocumentComposer/Treeview/slots/IconContainerSlot.d.ts +10 -0
- package/dist/components/DocumentComposer/Treeview/slots/LabelInputSlot.d.ts +12 -0
- package/dist/components/DocumentComposer/Treeview/slots/LabelSlot.d.ts +20 -0
- package/dist/components/DocumentComposer/Treeview/slots/index.d.ts +3 -0
- package/dist/components/DocumentComposer/Treeview/types.d.ts +50 -0
- package/dist/components/DocumentComposer/components/SectionEditorPanel.d.ts +7 -0
- package/dist/components/DocumentComposer/components/index.d.ts +1 -0
- package/dist/components/DocumentComposer/hooks/useDeleteConfirmation.d.ts +12 -0
- package/dist/components/DocumentComposer/hooks/useDragVisualFeedback.d.ts +15 -0
- package/dist/components/DocumentComposer/hooks/useSectionsMap.d.ts +5 -0
- package/dist/components/DocumentComposer/hooks/useTemporarySection.d.ts +31 -0
- package/dist/components/DocumentComposer/hooks/useUnsavedChangesGuard.d.ts +19 -0
- package/dist/components/DocumentComposer/index.d.ts +6 -0
- package/dist/components/DocumentComposer/types/index.d.ts +2 -0
- package/dist/components/DocumentComposer/types/props.d.ts +69 -0
- package/dist/components/DocumentComposer/types/section.d.ts +33 -0
- package/dist/components/DocumentComposer/types.d.ts +56 -0
- package/dist/components/DocumentComposer/utils/getSectionMenuItems.d.ts +14 -0
- package/dist/components/DocumentComposer/utils/sectionHelpers.d.ts +9 -0
- package/dist/components/Export/index.d.ts +3 -0
- package/dist/components/Export/style/index.d.ts +9 -0
- package/dist/components/Export/types/index.d.ts +30 -0
- package/dist/index.js +3 -3
- package/dist/locale/index.d.ts +7 -0
- package/package.json +117 -117
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { RichTreeViewProApiRef } from '@mui/x-tree-view-pro';
|
|
2
|
+
import type { DocumentSection } from '../types';
|
|
3
|
+
export type TemporarySection = Pick<DocumentSection, 'id' | 'parentId'> & {
|
|
4
|
+
parentVisible: boolean;
|
|
5
|
+
/** When undefined = editing mode (input), when defined = optimistic mode (waiting for server) */
|
|
6
|
+
title?: string;
|
|
7
|
+
};
|
|
8
|
+
type UseTemporarySectionParams = {
|
|
9
|
+
apiRef: RichTreeViewProApiRef;
|
|
10
|
+
getSectionById: (sectionId: string) => DocumentSection | null;
|
|
11
|
+
onSectionCreate?: (parentId: string | null, title: string) => string | Promise<string>;
|
|
12
|
+
scrollToBottom?: () => void;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Flow:
|
|
16
|
+
* 1. User triggers `create(parentId)` from context menu
|
|
17
|
+
* 2. A temporary section appears in the tree in edit mode (title = undefined)
|
|
18
|
+
* 3. User types a title and presses Enter → `validate()` is called
|
|
19
|
+
* - The section transitions to optimistic mode (title = defined)
|
|
20
|
+
* - Server creation is called in background
|
|
21
|
+
* 4. User presses Escape or leaves empty → `cancel()` is called
|
|
22
|
+
* 5. Server responds → temporary section is cleared, real section replaces it
|
|
23
|
+
*/
|
|
24
|
+
export declare const useTemporarySection: ({ apiRef, getSectionById, onSectionCreate, scrollToBottom }: UseTemporarySectionParams) => {
|
|
25
|
+
temporarySection: TemporarySection | null;
|
|
26
|
+
create: (parentId?: string | null) => void;
|
|
27
|
+
validate: (title: string) => void;
|
|
28
|
+
cancel: () => void;
|
|
29
|
+
isTemporary: (sectionId: string) => boolean;
|
|
30
|
+
};
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type UseUnsavedChangesGuardParams = {
|
|
2
|
+
isDirty: boolean;
|
|
3
|
+
selectedSectionId?: string | null;
|
|
4
|
+
onSectionSelect?: (sectionId: string | null) => void;
|
|
5
|
+
onSave?: () => Promise<void>;
|
|
6
|
+
onDirtyReset?: () => void;
|
|
7
|
+
/** When true, navigate immediately without showing confirmation (discards changes) */
|
|
8
|
+
skipConfirmation?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const useUnsavedChangesGuard: ({ isDirty, selectedSectionId, onSectionSelect, onSave, onDirtyReset, skipConfirmation }: UseUnsavedChangesGuardParams) => {
|
|
11
|
+
pendingSectionId: string | null;
|
|
12
|
+
isModalOpen: boolean;
|
|
13
|
+
isSaving: boolean;
|
|
14
|
+
guardedSelect: (sectionId: string | null) => void;
|
|
15
|
+
saveAndQuit: () => Promise<void>;
|
|
16
|
+
quitWithoutSaving: () => void;
|
|
17
|
+
cancelNavigation: () => void;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DocumentComposerCallbacks, DocumentComposerCustomProps, DocumentSection } from './types';
|
|
2
|
+
type DocumentComposerProps = {
|
|
3
|
+
sections?: DocumentSection[];
|
|
4
|
+
} & DocumentComposerCallbacks & DocumentComposerCustomProps;
|
|
5
|
+
declare const DocumentComposer: ({ sections, isLoadingSections, onSectionOrderChange, onSectionTitleChange, onSectionDelete, onSectionVisibilityChange, onSectionCreate, onSectionSelect, onSectionContentSave, noSectionsPlaceholder, getSectionTitleChangePermission, getSectionDeletePermission, getSectionOrderChangePermission, getSectionCreatePermission, getSectionVisibilityChangePermission, hiddenSectionTooltip, visibleIconTooltip, hiddenIconTooltip, renderSectionIcon, isValidDropTarget, sectionContent, isLoadingSectionContent, selectedSectionId, renderDeleteConfirmation, renderUnsavedChangesConfirmation }: DocumentComposerProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export default DocumentComposer;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ItemPositionParams } from '../Treeview/types';
|
|
3
|
+
import type { DocumentSection, SectionContent } from './section';
|
|
4
|
+
export type DeleteConfirmationRenderProps = {
|
|
5
|
+
isOpen: boolean;
|
|
6
|
+
onConfirm: () => void;
|
|
7
|
+
onCancel: () => void;
|
|
8
|
+
};
|
|
9
|
+
export type UnsavedChangesRenderProps = {
|
|
10
|
+
isOpen: boolean;
|
|
11
|
+
isSaving: boolean;
|
|
12
|
+
/** True if onSectionContentSave is provided */
|
|
13
|
+
canSave: boolean;
|
|
14
|
+
onSaveAndQuit: () => void;
|
|
15
|
+
onQuitWithoutSaving: () => void;
|
|
16
|
+
onCancel: () => void;
|
|
17
|
+
};
|
|
18
|
+
export type DocumentComposerLabels = {
|
|
19
|
+
createSection?: string;
|
|
20
|
+
rename?: string;
|
|
21
|
+
delete?: string;
|
|
22
|
+
createSubsection?: string;
|
|
23
|
+
hiddenItemTooltip?: string;
|
|
24
|
+
};
|
|
25
|
+
export type DocumentComposerCustomProps = {
|
|
26
|
+
noSectionsPlaceholder?: string | ReactNode;
|
|
27
|
+
isLoadingSections?: boolean;
|
|
28
|
+
/** Defaults to `() => true` */
|
|
29
|
+
getSectionTitleChangePermission?: (section: DocumentSection) => boolean;
|
|
30
|
+
/** Defaults to `() => true` */
|
|
31
|
+
getSectionDeletePermission?: (section: DocumentSection) => boolean;
|
|
32
|
+
/** Defaults to `() => true` */
|
|
33
|
+
getSectionOrderChangePermission?: (section: DocumentSection) => boolean;
|
|
34
|
+
/** Defaults to `() => true` */
|
|
35
|
+
getSectionCreatePermission?: (section: DocumentSection) => boolean;
|
|
36
|
+
/** Defaults to `() => true` */
|
|
37
|
+
getSectionVisibilityChangePermission?: (section: DocumentSection) => boolean;
|
|
38
|
+
hiddenSectionTooltip?: string;
|
|
39
|
+
visibleIconTooltip?: string;
|
|
40
|
+
hiddenIconTooltip?: string;
|
|
41
|
+
/** Return null for no icon */
|
|
42
|
+
renderSectionIcon?: (section: DocumentSection) => ReactNode;
|
|
43
|
+
/**
|
|
44
|
+
* Determines valid drop targets during drag. Invalid targets are greyed out.
|
|
45
|
+
* `targetSection` is `null` when dropping at root level.
|
|
46
|
+
* `newIndex` is the position where the item would be inserted in the target's children.
|
|
47
|
+
* `isNesting` is `true` when the section is being moved to a new parent (dropped "on" a section),
|
|
48
|
+
* `false` when reordering within the same parent.
|
|
49
|
+
* Defaults to `() => true`.
|
|
50
|
+
*/
|
|
51
|
+
isValidDropTarget?: (draggedSection: DocumentSection, targetSection: DocumentSection | null, newIndex: number, isNesting: boolean) => boolean;
|
|
52
|
+
sectionContent?: SectionContent;
|
|
53
|
+
isLoadingSectionContent?: boolean;
|
|
54
|
+
selectedSectionId?: string | null;
|
|
55
|
+
/** If not provided, deletion proceeds without confirmation */
|
|
56
|
+
renderDeleteConfirmation?: (props: DeleteConfirmationRenderProps) => ReactNode;
|
|
57
|
+
/** If not provided, navigation proceeds without confirmation (discards changes) */
|
|
58
|
+
renderUnsavedChangesConfirmation?: (props: UnsavedChangesRenderProps) => ReactNode;
|
|
59
|
+
};
|
|
60
|
+
export type DocumentComposerCallbacks = {
|
|
61
|
+
onSectionOrderChange?: (params: ItemPositionParams) => void;
|
|
62
|
+
onSectionTitleChange?: (sectionId: string, newTitle: string) => void;
|
|
63
|
+
onSectionDelete?: (sectionId: string) => void;
|
|
64
|
+
onSectionVisibilityChange?: (sectionId: string, visible: boolean) => void;
|
|
65
|
+
onSectionCreate?: (parentId: string | null, title: string) => string | Promise<string>;
|
|
66
|
+
onSectionSelect?: (sectionId: string | null) => void;
|
|
67
|
+
/** Used by unsaved changes modal "Save and quit" action */
|
|
68
|
+
onSectionContentSave?: () => Promise<void>;
|
|
69
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const CellFormat: {
|
|
2
|
+
readonly TEXT: "text";
|
|
3
|
+
readonly AMOUNT: "amount";
|
|
4
|
+
};
|
|
5
|
+
export type CellFormat = (typeof CellFormat)[keyof typeof CellFormat];
|
|
6
|
+
export type TableCell = {
|
|
7
|
+
value: string;
|
|
8
|
+
editable: boolean;
|
|
9
|
+
format: CellFormat;
|
|
10
|
+
};
|
|
11
|
+
export type TableRow = TableCell[];
|
|
12
|
+
export type TableValue = {
|
|
13
|
+
id: string;
|
|
14
|
+
headers: TableRow[];
|
|
15
|
+
rows: TableRow[];
|
|
16
|
+
footers: TableRow[];
|
|
17
|
+
};
|
|
18
|
+
export type TableContentBlock = {
|
|
19
|
+
type: 'table';
|
|
20
|
+
value: TableValue;
|
|
21
|
+
};
|
|
22
|
+
/** Extend this union as new content block types are added */
|
|
23
|
+
export type ContentBlock = TableContentBlock;
|
|
24
|
+
export type SectionContent = ContentBlock[];
|
|
25
|
+
export type DocumentSection = {
|
|
26
|
+
id: string;
|
|
27
|
+
title: string;
|
|
28
|
+
visible: boolean;
|
|
29
|
+
parentId: string | null;
|
|
30
|
+
type?: string;
|
|
31
|
+
hasTables?: boolean;
|
|
32
|
+
sections?: DocumentSection[] | null;
|
|
33
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ItemPositionParams } from './Treeview/types';
|
|
2
|
+
export type DocumentSection = {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
visible: boolean;
|
|
6
|
+
parentId: string | null;
|
|
7
|
+
sections?: DocumentSection[] | null;
|
|
8
|
+
};
|
|
9
|
+
export type DocumentComposerLabels = {
|
|
10
|
+
/** Label for the "Create section" button */
|
|
11
|
+
createSection?: string;
|
|
12
|
+
/** Label for the "Rename" menu item */
|
|
13
|
+
rename?: string;
|
|
14
|
+
/** Label for the "Delete" menu item */
|
|
15
|
+
delete?: string;
|
|
16
|
+
/** Label for the "Create subsection" menu item */
|
|
17
|
+
createSubsection?: string;
|
|
18
|
+
/** Tooltip for hidden item */
|
|
19
|
+
hiddenItemTooltip?: string;
|
|
20
|
+
};
|
|
21
|
+
export type DocumentComposerCustomProps = {
|
|
22
|
+
/** Content displayed when there are no sections */
|
|
23
|
+
noSectionsPlaceholder?: string | React.ReactNode;
|
|
24
|
+
/** Show a loading state that prevents rendering the sections */
|
|
25
|
+
isLoading?: boolean;
|
|
26
|
+
/** Returns whether section title can be edited (double-click + "Renommer" menu). Defaults to `() => true`. */
|
|
27
|
+
getSectionTitleChangePermission?: (section: DocumentSection) => boolean;
|
|
28
|
+
/** Returns whether section can be deleted ("Supprimer" menu). Defaults to `() => true`. */
|
|
29
|
+
getSectionDeletePermission?: (section: DocumentSection) => boolean;
|
|
30
|
+
/** Returns whether section can be reordered via drag & drop. Defaults to `() => true`. */
|
|
31
|
+
getSectionOrderChangePermission?: (section: DocumentSection) => boolean;
|
|
32
|
+
/** Returns whether a section can be created under this section. Defaults to `() => true`. */
|
|
33
|
+
getSectionCreatePermission?: (section: DocumentSection) => boolean;
|
|
34
|
+
/** Returns whether section visibility can be toggled. Defaults to `() => true`. */
|
|
35
|
+
getSectionVisibilityChangePermission?: (section: DocumentSection) => boolean;
|
|
36
|
+
/** Tooltip text displayed when hovering a hidden section label (visible: false) */
|
|
37
|
+
hiddenSectionTooltip?: string;
|
|
38
|
+
/** Tooltip text displayed when hovering the visibility icon of a visible section */
|
|
39
|
+
visibleIconTooltip?: string;
|
|
40
|
+
/** Tooltip text displayed when hovering the visibility icon of a hidden section */
|
|
41
|
+
hiddenIconTooltip?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Determines if `targetSection` is a valid drop location for `draggedSection`.
|
|
44
|
+
* When provided, invalid targets are visually greyed out during drag.
|
|
45
|
+
* Defaults to () => true (all targets valid).
|
|
46
|
+
* @param targetSection - The parent section where the item would be dropped, or `null` if dropping at root level.
|
|
47
|
+
*/
|
|
48
|
+
isValidDropTarget?: (draggedSection: DocumentSection, targetSection: DocumentSection | null) => boolean;
|
|
49
|
+
};
|
|
50
|
+
export type DocumentComposerCallbacks = {
|
|
51
|
+
onSectionOrderChange?: (params: ItemPositionParams) => void;
|
|
52
|
+
onSectionTitleChange?: (sectionId: string, newTitle: string) => void;
|
|
53
|
+
onSectionDelete?: (sectionId: string) => void;
|
|
54
|
+
onSectionVisibilityChange?: (sectionId: string, visible: boolean) => void;
|
|
55
|
+
onSectionCreate?: (parentId: string | null, title: string) => string | Promise<string>;
|
|
56
|
+
};
|
|
@@ -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,9 @@
|
|
|
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;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { GridExportFormat } from "@mui/x-data-grid-pro";
|
|
2
|
+
/**
|
|
3
|
+
* Props for ExportContent component
|
|
4
|
+
*/
|
|
5
|
+
export interface ExportContentProps {
|
|
6
|
+
/**
|
|
7
|
+
* Available export formats
|
|
8
|
+
*/
|
|
9
|
+
exportFormats: GridExportFormat[];
|
|
10
|
+
/**
|
|
11
|
+
* Handler function called when export is triggered
|
|
12
|
+
* @param format - Selected export format
|
|
13
|
+
*/
|
|
14
|
+
onExport: (format: GridExportFormat) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Optional title for the export dialog
|
|
17
|
+
* @default 'Export'
|
|
18
|
+
*/
|
|
19
|
+
title?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Optional label for format selection
|
|
22
|
+
* @default 'Select format:'
|
|
23
|
+
*/
|
|
24
|
+
selectFormatLabel?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Optional label for the export button
|
|
27
|
+
* @default 'Export'
|
|
28
|
+
*/
|
|
29
|
+
exportButtonLabel?: string;
|
|
30
|
+
}
|