@myunisoft/design-system 1.2.6 → 1.2.9-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.
Files changed (26) hide show
  1. package/dist/components/DataGrid/components/toolbar/ActionsMenu/index.d.ts +19 -0
  2. package/dist/components/DataGrid/components/toolbar/CustomGridToolbar.d.ts +4 -1
  3. package/dist/components/DocumentComposer/LoadingSkeleton.d.ts +2 -0
  4. package/dist/components/DocumentComposer/NoSectionsPlaceholder/index.d.ts +4 -0
  5. package/dist/components/DocumentComposer/Treeview/CustomTreeItem.d.ts +2 -1
  6. package/dist/components/DocumentComposer/Treeview/hooks/useTreeItemMenu.d.ts +2 -0
  7. package/dist/components/DocumentComposer/Treeview/slots/LabelInputSlot.d.ts +11 -5
  8. package/dist/components/DocumentComposer/Treeview/slots/LabelSlot.d.ts +3 -0
  9. package/dist/components/DocumentComposer/Treeview/types.d.ts +25 -15
  10. package/dist/components/DocumentComposer/hooks/useSectionsMap.d.ts +5 -0
  11. package/dist/components/DocumentComposer/hooks/useTemporarySection.d.ts +25 -0
  12. package/dist/components/DocumentComposer/index.d.ts +3 -3
  13. package/dist/components/DocumentComposer/types.d.ts +26 -8
  14. package/dist/components/DocumentComposer/utils/getSectionMenuItems.d.ts +14 -0
  15. package/dist/components/DocumentComposer/utils/sectionHelpers.d.ts +10 -0
  16. package/dist/index.d.ts +1 -0
  17. package/dist/index.js +3 -3
  18. package/package.json +121 -117
  19. package/dist/components/DataGrid/DataGrid.d.ts +0 -3
  20. package/dist/components/DataGrid/hooks/useSizing.d.ts +0 -5
  21. package/dist/components/DataGrid/hooks/useSizing.test.d.ts +0 -1
  22. package/dist/components/DocumentComposer/EmptySummary/index.d.ts +0 -4
  23. package/dist/components/DocumentComposer/Treeview/icons/index.d.ts +0 -1
  24. package/dist/components/DocumentComposer/hooks/useDocumentComposer.d.ts +0 -17
  25. package/dist/components/DocumentComposer/icons/index.d.ts +0 -8
  26. package/dist/components/Modal/components/ModalVariantIcon.d.ts +0 -6
@@ -0,0 +1,19 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { GridValidRowModel } from '@mui/x-data-grid-pro';
3
+ export type MenuAction = {
4
+ key: string;
5
+ label: string;
6
+ icon?: ReactNode;
7
+ color?: string;
8
+ disabled?: boolean | ((selectedRows: GridValidRowModel[]) => boolean);
9
+ onClick: (selectedRows: GridValidRowModel[]) => void;
10
+ };
11
+ type ActionsMenuProps = {
12
+ isOpen: boolean;
13
+ anchorEl: HTMLElement | null;
14
+ menuActions: MenuAction[];
15
+ selectedRows: GridValidRowModel[];
16
+ onClose: () => void;
17
+ };
18
+ declare const ActionsMenu: ({ isOpen, anchorEl, menuActions, selectedRows, onClose }: ActionsMenuProps) => import("react/jsx-runtime").JSX.Element;
19
+ export default ActionsMenu;
@@ -7,20 +7,23 @@
7
7
  * Source (MUI v7.x): https://github.com/mui/mui-x/blob/v7.x/packages/x-data-grid/src/components/toolbar/GridToolbar.tsx
8
8
  */
9
9
  import { type GridRowSelectionModel, type GridSlotsComponentsProps, type GridValidRowModel } from '@mui/x-data-grid-pro';
10
+ import { type MenuAction } from './ActionsMenu';
10
11
  import { type IconButtonConfig, type TextButtonConfig } from './ArrayButtons';
11
12
  interface DeleteAction {
12
13
  onDelete: (selectedRowIds: GridRowSelectionModel) => boolean | Promise<boolean>;
13
14
  disabled?: boolean;
14
15
  }
15
16
  interface BulkEditAction {
16
- onBulkEditSave: (selectedIds: GridRowSelectionModel, newRows: GridValidRowModel[]) => boolean | Promise<boolean>;
17
+ onBulkEditSave: (selectedRowIds: GridRowSelectionModel, newRows: GridValidRowModel[]) => boolean | Promise<boolean>;
17
18
  disabled?: boolean;
18
19
  }
19
20
  declare module '@mui/x-data-grid-pro' {
20
21
  interface ToolbarPropsOverrides {
22
+ showSelectedCount?: boolean;
21
23
  customButtons?: CustomToolbarButtonConfig[];
22
24
  deleteAction?: DeleteAction;
23
25
  bulkEditAction?: BulkEditAction;
26
+ menuActions?: MenuAction[];
24
27
  }
25
28
  }
26
29
  interface CustomTextButtonConfig extends Omit<TextButtonConfig, 'onClick'> {
@@ -0,0 +1,2 @@
1
+ export declare const LeftPanelSkeleton: () => import("react/jsx-runtime").JSX.Element;
2
+ export declare const RightPanelSkeleton: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,4 @@
1
+ declare const NoSectionsPlaceholder: ({ noSectionsPlaceholder }: {
2
+ noSectionsPlaceholder?: React.ReactNode;
3
+ }) => import("react/jsx-runtime").JSX.Element;
4
+ export default NoSectionsPlaceholder;
@@ -1,7 +1,8 @@
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' | 'isItemReorderable' | 'onItemVisibilityChange'> & {
3
+ type TreeItemCallbacks<T extends Record<string, unknown>> = Pick<TreeviewProps<T>, 'isSectionItem' | 'isVisibleItem' | 'getIconItem' | 'hasItemMenu' | 'getMenuItems' | 'isItemReorderable' | 'onItemVisibilityChange' | 'isTemporaryItem' | 'onTemporarySectionValidation' | 'onTemporarySectionCancel' | 'onItemLabelChange' | 'hiddenSectionTooltip' | 'visibleIconTooltip' | 'hiddenIconTooltip'> & {
4
4
  apiRef: RichTreeViewProApiRef;
5
+ onEditingChange?: (itemId: string | null) => void;
5
6
  };
6
7
  type CustomTreeItemProps<T extends Record<string, unknown>> = TreeItemProps & TreeItemCallbacks<T>;
7
8
  export declare const CustomTreeItem: <T extends Record<string, unknown>>(props: CustomTreeItemProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -7,6 +7,8 @@ export declare const useTreeItemMenu: () => {
7
7
  } | null;
8
8
  handleMenuClick: (event: React.MouseEvent<HTMLElement>) => void;
9
9
  handleMenuClose: () => void;
10
+ scheduleMenuAction: (action: () => void) => void;
11
+ onMenuExited: () => void;
10
12
  createMouseMoveHandler: (isHovered: boolean, onHoverChange?: (isHovered: boolean) => void) => (e: React.MouseEvent<HTMLDivElement>) => void;
11
13
  createMouseLeaveHandler: (onHoverChange?: (isHovered: boolean) => void) => () => void;
12
14
  };
@@ -1,6 +1,12 @@
1
- type LabelInputSlotProps = {
1
+ import type { InputHTMLAttributes } from 'react';
2
+ import type { RichTreeViewProApiRef } from '@mui/x-tree-view-pro';
3
+ export declare const LabelInputSlot: import("react").ForwardRefExoticComponent<InputHTMLAttributes<HTMLInputElement> & {
2
4
  ownerState?: unknown;
3
- [key: string]: unknown;
4
- };
5
- export declare const LabelInputSlot: import("react").ForwardRefExoticComponent<Omit<LabelInputSlotProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
6
- export {};
5
+ itemId?: string;
6
+ isTemporary?: boolean;
7
+ onTemporarySectionValidation?: (label: string) => void;
8
+ onTemporarySectionCancel?: () => void;
9
+ onItemLabelChange?: (itemId: string, newLabel: string) => void;
10
+ apiRef?: RichTreeViewProApiRef;
11
+ onEditingEnd?: () => void;
12
+ } & import("react").RefAttributes<HTMLInputElement>>;
@@ -11,6 +11,9 @@ type LabelSlotProps = {
11
11
  menuAnchorEl?: HTMLElement | null;
12
12
  onMenuClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
13
13
  onItemVisibilityChange?: (itemId: string, visible: boolean) => void;
14
+ hiddenSectionTooltip?: string;
15
+ visibleIconTooltip?: string;
16
+ hiddenIconTooltip?: string;
14
17
  [key: string]: unknown;
15
18
  };
16
19
  export declare const LabelSlot: {
@@ -1,4 +1,5 @@
1
1
  import type { RichTreeViewProApiRef } from '@mui/x-tree-view-pro';
2
+ import type { TemporarySection } from '../hooks/useTemporarySection';
2
3
  export type ItemPositionParams = {
3
4
  itemId: string;
4
5
  oldPosition: {
@@ -10,27 +11,36 @@ export type ItemPositionParams = {
10
11
  index: number;
11
12
  };
12
13
  };
14
+ export type ScheduleMenuAction = (action: () => void) => void;
13
15
  type CustomTreeviewItemProps<T> = {
14
- hasItemMenu?: (item: T) => boolean;
15
- getMenuItems?: (item: T, apiRef?: RichTreeViewProApiRef) => React.ReactNode[];
16
- isSectionItem?: (item: T) => boolean;
17
- getIconItem?: (item: T) => React.ReactNode;
18
- isItemEditable?: (item: T) => boolean;
19
- isVisibleItem?: (item: T) => boolean;
20
- onItemVisibilityChange?: (itemId: string, visible: boolean) => void;
16
+ hasItemMenu: (item: T) => boolean;
17
+ getMenuItems: (item: T, scheduleMenuAction: ScheduleMenuAction) => React.ReactNode[];
18
+ isSectionItem: (item: T) => boolean;
19
+ getIconItem: (item: T) => React.ReactNode;
20
+ isItemEditable: (item: T) => boolean;
21
+ isVisibleItem: (item: T) => boolean;
22
+ onItemVisibilityChange: (itemId: string, visible: boolean) => void;
23
+ hiddenSectionTooltip?: string;
24
+ visibleIconTooltip?: string;
25
+ hiddenIconTooltip?: string;
21
26
  };
22
27
  export type TreeviewProps<T> = {
28
+ apiRef: RichTreeViewProApiRef;
23
29
  items: readonly T[];
24
- getItemId?: (item: T) => string;
25
- getItemLabel?: (item: T) => string;
26
- getItemChildren?: (item: T) => T[] | undefined;
27
- isItemReorderable?: (itemId: string) => boolean;
28
- canMoveItemToNewPosition?: (params: ItemPositionParams) => boolean;
29
- onItemPositionChange?: (params: ItemPositionParams) => void;
30
- onItemLabelChange?: (itemId: string, newLabel: string) => void;
30
+ getItemId: (item: T) => string;
31
+ getItemLabel: (item: T) => string;
32
+ getItemChildren: (item: T) => T[] | undefined;
33
+ isItemReorderable: (itemId: string) => boolean;
34
+ canMoveItemToNewPosition: (params: ItemPositionParams) => boolean;
35
+ onItemPositionChange: (params: ItemPositionParams) => void;
36
+ onItemLabelChange: (itemId: string, newLabel: string) => void;
37
+ temporaryItem: TemporarySection | null;
38
+ isTemporaryItem: (itemId: string) => boolean;
39
+ onTemporarySectionValidation: (label: string) => void;
40
+ onTemporarySectionCancel: () => void;
41
+ defaultExpandedItems: string[];
31
42
  checkboxSelection?: boolean;
32
43
  multiSelect?: boolean;
33
- defaultExpandedItems?: string[];
34
44
  } & CustomTreeviewItemProps<T>;
35
45
  export type TreeviewItemProps<T> = {
36
46
  itemId: string;
@@ -0,0 +1,5 @@
1
+ import type { DocumentSection } from '../types';
2
+ export declare const useSectionsMap: (sections: DocumentSection[] | undefined) => {
3
+ sectionsMap: Map<string, DocumentSection>;
4
+ getSectionById: (sectionId: string) => DocumentSection | null;
5
+ };
@@ -0,0 +1,25 @@
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
+ };
6
+ type UseTemporarySectionParams = {
7
+ apiRef: RichTreeViewProApiRef;
8
+ getSectionById: (sectionId: string) => DocumentSection | null;
9
+ onSubsectionCreate?: (parentId: string | null, title: string) => string | Promise<string>;
10
+ };
11
+ /**
12
+ * Flow:
13
+ * 1. User triggers `create(parentId)` from context menu
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
+ * 4. User presses Escape or leaves empty → `cancel()` is called
17
+ */
18
+ export declare const useTemporarySection: ({ apiRef, getSectionById, onSubsectionCreate }: UseTemporarySectionParams) => {
19
+ temporarySection: TemporarySection | null;
20
+ create: (parentId: string) => void;
21
+ validate: (title: string) => Promise<void>;
22
+ cancel: () => void;
23
+ isTemporary: (sectionId: string) => boolean;
24
+ };
25
+ export {};
@@ -1,6 +1,6 @@
1
- import type { DocumentComposerCallbacks, DocumentComposerCustomProps, DocumentComposerSummaryItem } from './types';
1
+ import type { DocumentComposerCallbacks, DocumentComposerCustomProps, DocumentSection } from './types';
2
2
  type DocumentComposerProps = {
3
- summary?: DocumentComposerSummaryItem[];
3
+ sections?: DocumentSection[];
4
4
  } & DocumentComposerCallbacks & DocumentComposerCustomProps;
5
- declare const DocumentComposer: ({ summary, onSummaryItemOrderChange, onSummaryItemLabelChange, onSummaryItemDelete, onSummaryItemVisibilityChange, emptySummaryLabel, isLoading }: DocumentComposerProps) => import("react/jsx-runtime").JSX.Element;
5
+ declare const DocumentComposer: ({ sections, onSectionOrderChange, onSectionTitleChange, onSectionDelete, onSectionVisibilityChange, onSubsectionCreate, noSectionsPlaceholder, isLoading, getSectionRenamePermission, getSectionDeletePermission, getSectionReorderPermission, getSubsectionCreatePermission, getSectionVisibilityPermission, hiddenSectionTooltip, visibleIconTooltip, hiddenIconTooltip }: DocumentComposerProps) => import("react/jsx-runtime").JSX.Element;
6
6
  export default DocumentComposer;
@@ -1,23 +1,41 @@
1
1
  import type { ItemPositionParams } from './Treeview/types';
2
- export type DocumentComposerSummaryItem = {
2
+ export type DocumentSection = {
3
3
  id: string;
4
4
  title: string;
5
5
  visible: boolean;
6
6
  parentId: string | null;
7
- sections?: DocumentComposerSummaryItem[] | null;
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
- emptySummaryLabel?: string | React.ReactNode;
15
- /** Show a loading state that blocks the summary */
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;
28
+ /** Tooltip text displayed when hovering a hidden section label (visible: false) */
29
+ hiddenSectionTooltip?: string;
30
+ /** Tooltip text displayed when hovering the visibility icon of a visible section */
31
+ visibleIconTooltip?: string;
32
+ /** Tooltip text displayed when hovering the visibility icon of a hidden section */
33
+ hiddenIconTooltip?: string;
17
34
  };
18
35
  export type DocumentComposerCallbacks = {
19
- onSummaryItemOrderChange?: (params: ItemPositionParams) => void;
20
- onSummaryItemLabelChange?: (itemId: string, newLabel: string) => void;
21
- onSummaryItemDelete?: (itemId: string) => void;
22
- onSummaryItemVisibilityChange?: (itemId: string, visible: boolean) => void;
36
+ onSectionOrderChange?: (params: ItemPositionParams) => void;
37
+ onSectionTitleChange?: (sectionId: string, newTitle: string) => void;
38
+ onSectionDelete?: (sectionId: string) => void;
39
+ onSectionVisibilityChange?: (sectionId: string, visible: boolean) => void;
40
+ onSubsectionCreate?: (parentId: string | null, title: string) => string | Promise<string>;
23
41
  };
@@ -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;
package/dist/index.d.ts CHANGED
@@ -7,6 +7,7 @@ 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';
10
11
  export * from './components/basics/Icon/';
11
12
  export * from './components/basics/Icon/Icons-material';
12
13
  export { default as Snackbar } from './components/basics/Snackbar';