@myunisoft/design-system 1.3.0 → 1.3.1-rev157-3
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/assets/I18n/locales/en.d.ts +16 -0
- package/dist/assets/I18n/locales/fr.d.ts +16 -0
- package/dist/components/DocumentComposer/Treeview/CustomTreeItem.d.ts +1 -1
- package/dist/components/DocumentComposer/Treeview/slots/LabelInputSlot.d.ts +1 -1
- package/dist/components/DocumentComposer/Treeview/types.d.ts +1 -1
- 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 +1 -1
- package/dist/components/DocumentComposer/hooks/useTemporarySection.d.ts +7 -2
- package/dist/components/DocumentComposer/hooks/useUnsavedChangesGuard.d.ts +19 -0
- package/dist/components/DocumentComposer/index.d.ts +1 -1
- package/dist/components/DocumentComposer/types/index.d.ts +2 -0
- package/dist/components/DocumentComposer/types/props.d.ts +67 -0
- package/dist/components/DocumentComposer/types/section.d.ts +33 -0
- package/dist/components/DocumentComposer/utils/sectionHelpers.d.ts +0 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -3
- package/package.json +8 -5
|
@@ -35,6 +35,22 @@ declare const _default: {
|
|
|
35
35
|
addColumn: string;
|
|
36
36
|
restoreInitial: string;
|
|
37
37
|
};
|
|
38
|
+
documentComposer: {
|
|
39
|
+
createSection: string;
|
|
40
|
+
deleteSection: {
|
|
41
|
+
title: string;
|
|
42
|
+
content: string;
|
|
43
|
+
cancel: string;
|
|
44
|
+
confirm: string;
|
|
45
|
+
};
|
|
46
|
+
unsavedChanges: {
|
|
47
|
+
title: string;
|
|
48
|
+
content: string;
|
|
49
|
+
saveAndQuit: string;
|
|
50
|
+
cancel: string;
|
|
51
|
+
quitWithoutSaving: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
38
54
|
dashboard: {
|
|
39
55
|
ba: {
|
|
40
56
|
linkTo: string;
|
|
@@ -35,6 +35,22 @@ declare const _default: {
|
|
|
35
35
|
addColumn: string;
|
|
36
36
|
restoreInitial: string;
|
|
37
37
|
};
|
|
38
|
+
documentComposer: {
|
|
39
|
+
createSection: string;
|
|
40
|
+
deleteSection: {
|
|
41
|
+
title: string;
|
|
42
|
+
content: string;
|
|
43
|
+
cancel: string;
|
|
44
|
+
confirm: string;
|
|
45
|
+
};
|
|
46
|
+
unsavedChanges: {
|
|
47
|
+
title: string;
|
|
48
|
+
content: string;
|
|
49
|
+
saveAndQuit: string;
|
|
50
|
+
cancel: string;
|
|
51
|
+
quitWithoutSaving: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
38
54
|
dashboard: {
|
|
39
55
|
ba: {
|
|
40
56
|
linkTo: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RichTreeViewProApiRef, TreeItemProps } from '@mui/x-tree-view-pro';
|
|
2
2
|
import type { TreeviewProps } from './types';
|
|
3
|
-
type TreeItemCallbacks<T extends Record<string, unknown>> = Pick<TreeviewProps<T>, 'isSectionItem' | 'isVisibleItem' | 'getIconItem' | 'hasItemMenu' | 'getMenuItems' | 'isSectionDraggable' | 'onItemVisibilityChange' | 'isTemporaryItem' | 'onTemporarySectionValidation' | 'onTemporarySectionCancel' | 'onItemLabelChange' | 'hiddenSectionTooltip' | 'visibleIconTooltip' | 'hiddenIconTooltip'> & {
|
|
3
|
+
type TreeItemCallbacks<T extends Record<string, unknown>> = Pick<TreeviewProps<T>, 'isSectionItem' | 'isVisibleItem' | 'getIconItem' | 'hasItemMenu' | 'getMenuItems' | 'isSectionDraggable' | 'onItemVisibilityChange' | 'temporaryItem' | 'isTemporaryItem' | 'onTemporarySectionValidation' | 'onTemporarySectionCancel' | 'onItemLabelChange' | 'hiddenSectionTooltip' | 'visibleIconTooltip' | 'hiddenIconTooltip'> & {
|
|
4
4
|
apiRef: RichTreeViewProApiRef;
|
|
5
5
|
onEditingChange?: (itemId: string | null) => void;
|
|
6
6
|
};
|
|
@@ -3,7 +3,7 @@ import type { RichTreeViewProApiRef } from '@mui/x-tree-view-pro';
|
|
|
3
3
|
export declare const LabelInputSlot: import("react").ForwardRefExoticComponent<InputHTMLAttributes<HTMLInputElement> & {
|
|
4
4
|
ownerState?: unknown;
|
|
5
5
|
itemId?: string;
|
|
6
|
-
|
|
6
|
+
isEditing?: boolean;
|
|
7
7
|
onTemporarySectionValidation?: (label: string) => void;
|
|
8
8
|
onTemporarySectionCancel?: () => void;
|
|
9
9
|
onItemLabelChange?: (itemId: string, newLabel: string) => void;
|
|
@@ -40,7 +40,7 @@ export type TreeviewProps<T> = {
|
|
|
40
40
|
onTemporarySectionCancel: () => void;
|
|
41
41
|
defaultExpandedItems: string[];
|
|
42
42
|
checkboxSelection?: boolean;
|
|
43
|
-
|
|
43
|
+
onItemSelect?: (itemId: string | null) => void;
|
|
44
44
|
} & CustomTreeviewItemProps<T>;
|
|
45
45
|
export type TreeviewItemProps<T> = {
|
|
46
46
|
itemId: string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SectionContent } from '../types';
|
|
2
|
+
type SectionEditorPanelProps = {
|
|
3
|
+
content: SectionContent;
|
|
4
|
+
onChange: (content: SectionContent) => void;
|
|
5
|
+
};
|
|
6
|
+
export declare const SectionEditorPanel: ({ content, onChange }: SectionEditorPanelProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SectionEditorPanel } from './SectionEditorPanel';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type UseDeleteConfirmationParams = {
|
|
2
|
+
onSectionDelete?: (sectionId: string) => void;
|
|
3
|
+
/** When true, delete immediately without showing confirmation */
|
|
4
|
+
skipConfirmation?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare const useDeleteConfirmation: ({ onSectionDelete, skipConfirmation }: UseDeleteConfirmationParams) => {
|
|
7
|
+
deleteItemId: string | null;
|
|
8
|
+
requestDelete: (sectionId: string) => void;
|
|
9
|
+
confirmDelete: () => void;
|
|
10
|
+
cancelDelete: () => void;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -3,7 +3,7 @@ import type { DocumentSection } from '../types';
|
|
|
3
3
|
type UseDragVisualFeedbackParams = {
|
|
4
4
|
containerRef: RefObject<HTMLDivElement | null>;
|
|
5
5
|
getSectionById: (sectionId: string) => DocumentSection | null;
|
|
6
|
-
isValidDropTarget?: (draggedSection: DocumentSection, targetSection: DocumentSection | null) => boolean;
|
|
6
|
+
isValidDropTarget?: (draggedSection: DocumentSection, targetSection: DocumentSection | null, newIndex: number) => boolean;
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
9
|
* Provides visual feedback during drag-and-drop by graying out invalid drop targets.
|
|
@@ -2,6 +2,8 @@ import type { RichTreeViewProApiRef } from '@mui/x-tree-view-pro';
|
|
|
2
2
|
import type { DocumentSection } from '../types';
|
|
3
3
|
export type TemporarySection = Pick<DocumentSection, 'id' | 'parentId'> & {
|
|
4
4
|
parentVisible: boolean;
|
|
5
|
+
/** When undefined = editing mode (input), when defined = optimistic mode (waiting for server) */
|
|
6
|
+
title?: string;
|
|
5
7
|
};
|
|
6
8
|
type UseTemporarySectionParams = {
|
|
7
9
|
apiRef: RichTreeViewProApiRef;
|
|
@@ -12,14 +14,17 @@ type UseTemporarySectionParams = {
|
|
|
12
14
|
/**
|
|
13
15
|
* Flow:
|
|
14
16
|
* 1. User triggers `create(parentId)` from context menu
|
|
15
|
-
* 2. A temporary section appears in the tree in edit mode
|
|
17
|
+
* 2. A temporary section appears in the tree in edit mode (title = undefined)
|
|
16
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
|
|
17
21
|
* 4. User presses Escape or leaves empty → `cancel()` is called
|
|
22
|
+
* 5. Server responds → temporary section is cleared, real section replaces it
|
|
18
23
|
*/
|
|
19
24
|
export declare const useTemporarySection: ({ apiRef, getSectionById, onSectionCreate, scrollToBottom }: UseTemporarySectionParams) => {
|
|
20
25
|
temporarySection: TemporarySection | null;
|
|
21
26
|
create: (parentId?: string | null) => void;
|
|
22
|
-
validate: (title: string) =>
|
|
27
|
+
validate: (title: string) => void;
|
|
23
28
|
cancel: () => void;
|
|
24
29
|
isTemporary: (sectionId: string) => boolean;
|
|
25
30
|
};
|
|
@@ -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 {};
|
|
@@ -2,5 +2,5 @@ import type { DocumentComposerCallbacks, DocumentComposerCustomProps, DocumentSe
|
|
|
2
2
|
type DocumentComposerProps = {
|
|
3
3
|
sections?: DocumentSection[];
|
|
4
4
|
} & DocumentComposerCallbacks & DocumentComposerCustomProps;
|
|
5
|
-
declare const DocumentComposer: ({ sections, onSectionOrderChange, onSectionTitleChange, onSectionDelete, onSectionVisibilityChange, onSectionCreate,
|
|
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
6
|
export default DocumentComposer;
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
* Defaults to `() => true`.
|
|
48
|
+
*/
|
|
49
|
+
isValidDropTarget?: (draggedSection: DocumentSection, targetSection: DocumentSection | null, newIndex: number) => boolean;
|
|
50
|
+
sectionContent?: SectionContent;
|
|
51
|
+
isLoadingSectionContent?: boolean;
|
|
52
|
+
selectedSectionId?: string | null;
|
|
53
|
+
/** If not provided, deletion proceeds without confirmation */
|
|
54
|
+
renderDeleteConfirmation?: (props: DeleteConfirmationRenderProps) => ReactNode;
|
|
55
|
+
/** If not provided, navigation proceeds without confirmation (discards changes) */
|
|
56
|
+
renderUnsavedChangesConfirmation?: (props: UnsavedChangesRenderProps) => ReactNode;
|
|
57
|
+
};
|
|
58
|
+
export type DocumentComposerCallbacks = {
|
|
59
|
+
onSectionOrderChange?: (params: ItemPositionParams) => void;
|
|
60
|
+
onSectionTitleChange?: (sectionId: string, newTitle: string) => void;
|
|
61
|
+
onSectionDelete?: (sectionId: string) => void;
|
|
62
|
+
onSectionVisibilityChange?: (sectionId: string, visible: boolean) => void;
|
|
63
|
+
onSectionCreate?: (parentId: string | null, title: string) => string | Promise<string>;
|
|
64
|
+
onSectionSelect?: (sectionId: string | null) => void;
|
|
65
|
+
/** Used by unsaved changes modal "Save and quit" action */
|
|
66
|
+
onSectionContentSave?: () => Promise<void>;
|
|
67
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -7,4 +7,3 @@ export declare const isSectionVisible: (section: DocumentSection) => boolean;
|
|
|
7
7
|
export declare const getSectionChildren: (section: DocumentSection) => DocumentSection[] | undefined;
|
|
8
8
|
export declare const getSectionId: (section: DocumentSection) => string;
|
|
9
9
|
export declare const getSectionTitle: (section: DocumentSection) => string;
|
|
10
|
-
export declare const getSectionIcon: (section: DocumentSection) => import("react/jsx-runtime").JSX.Element | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,9 @@ export { default as BackgroundLoader } from './components/BackgroundLoader';
|
|
|
7
7
|
export { default as BadgeAdd } from './components/BadgeAdd';
|
|
8
8
|
export { default as Checkbox } from './components/basics/Checkbox';
|
|
9
9
|
export { default as ExpandButton } from './components/basics/ExpandButton';
|
|
10
|
+
export { default as DocumentComposer } from './components/DocumentComposer';
|
|
11
|
+
export type { CellFormat, ContentBlock, DeleteConfirmationRenderProps, SectionContent, TableCell, TableContentBlock, TableRow, TableValue, UnsavedChangesRenderProps } from './components/DocumentComposer/types';
|
|
12
|
+
export { CellFormat as CellFormatEnum } from './components/DocumentComposer/types';
|
|
10
13
|
export * from './components/basics/Icon/';
|
|
11
14
|
export * from './components/basics/Icon/Icons-material';
|
|
12
15
|
export { default as Snackbar } from './components/basics/Snackbar';
|