@myunisoft/design-system 1.2.9-rev396.9 → 1.3.0

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.
@@ -1,5 +1,4 @@
1
1
  declare const BasicExample: () => import("react/jsx-runtime").JSX.Element;
2
2
  declare const CustomOptionExample: () => import("react/jsx-runtime").JSX.Element;
3
3
  declare const ProductExample: () => import("react/jsx-runtime").JSX.Element;
4
- declare const MaxVisibleOptionsExample: () => import("react/jsx-runtime").JSX.Element;
5
- export { BasicExample, CustomOptionExample, ProductExample, MaxVisibleOptionsExample };
4
+ export { BasicExample, CustomOptionExample, ProductExample };
@@ -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;
@@ -0,0 +1,9 @@
1
+ import type { RichTreeViewProApiRef, TreeItemProps } from '@mui/x-tree-view-pro';
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'> & {
4
+ apiRef: RichTreeViewProApiRef;
5
+ onEditingChange?: (itemId: string | null) => void;
6
+ };
7
+ type CustomTreeItemProps<T extends Record<string, unknown>> = TreeItemProps & TreeItemCallbacks<T>;
8
+ export declare const CustomTreeItem: <T extends Record<string, unknown>>(props: CustomTreeItemProps<T>) => import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,12 @@
1
+ export declare const useTreeItemMenu: () => {
2
+ containerRef: import("react").RefObject<HTMLLIElement | null>;
3
+ menuAnchorEl: HTMLElement | null;
4
+ menuPosition: {
5
+ top: number;
6
+ left: number;
7
+ } | null;
8
+ handleMenuClick: (event: React.MouseEvent<HTMLElement>) => void;
9
+ handleMenuClose: () => void;
10
+ scheduleMenuAction: (action: () => void) => void;
11
+ onMenuExited: () => void;
12
+ };
@@ -0,0 +1,3 @@
1
+ import type { TreeviewProps } from './types';
2
+ declare const Treeview: <T extends Record<string, unknown>>(props: TreeviewProps<T>) => import("react/jsx-runtime").JSX.Element;
3
+ export default Treeview;
@@ -0,0 +1,10 @@
1
+ import type { SxProps, Theme } from '@mui/material';
2
+ type IconContainerSlotProps = {
3
+ ownerState?: unknown;
4
+ children?: React.ReactNode;
5
+ sx?: SxProps<Theme>;
6
+ isDraggable?: boolean;
7
+ isVisible?: boolean;
8
+ };
9
+ export declare const IconContainerSlot: import("react").MemoExoticComponent<(props: IconContainerSlotProps) => import("react/jsx-runtime").JSX.Element>;
10
+ export {};
@@ -0,0 +1,12 @@
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> & {
4
+ ownerState?: unknown;
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>>;
@@ -0,0 +1,20 @@
1
+ import type { SxProps, Theme } from '@mui/material';
2
+ type LabelSlotProps = {
3
+ ownerState?: unknown;
4
+ editable?: unknown;
5
+ children?: React.ReactNode;
6
+ sx?: SxProps<Theme>;
7
+ customIcon?: React.ReactNode;
8
+ hasMenu?: boolean;
9
+ isVisible?: boolean;
10
+ isTemporary?: boolean;
11
+ itemId: string;
12
+ menuAnchorEl?: HTMLElement | null;
13
+ onMenuClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
14
+ onItemVisibilityChange?: (itemId: string, visible: boolean) => void;
15
+ hiddenSectionTooltip?: string;
16
+ visibleIconTooltip?: string;
17
+ hiddenIconTooltip?: string;
18
+ };
19
+ export declare const LabelSlot: import("react").MemoExoticComponent<(props: LabelSlotProps) => import("react/jsx-runtime").JSX.Element>;
20
+ export {};
@@ -0,0 +1,3 @@
1
+ export { IconContainerSlot } from './IconContainerSlot';
2
+ export { LabelInputSlot } from './LabelInputSlot';
3
+ export { LabelSlot } from './LabelSlot';
@@ -0,0 +1,50 @@
1
+ import type { RichTreeViewProApiRef } from '@mui/x-tree-view-pro';
2
+ import type { TemporarySection } from '../hooks/useTemporarySection';
3
+ export type ItemPositionParams = {
4
+ itemId: string;
5
+ oldPosition: {
6
+ parentId: string | null;
7
+ index: number;
8
+ };
9
+ newPosition: {
10
+ parentId: string | null;
11
+ index: number;
12
+ };
13
+ };
14
+ export type ScheduleMenuAction = (action: () => void) => void;
15
+ type CustomTreeviewItemProps<T> = {
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;
26
+ };
27
+ export type TreeviewProps<T> = {
28
+ apiRef: RichTreeViewProApiRef;
29
+ items: readonly T[];
30
+ getItemId: (item: T) => string;
31
+ getItemLabel: (item: T) => string;
32
+ getItemChildren: (item: T) => T[] | undefined;
33
+ isSectionDraggable: (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[];
42
+ checkboxSelection?: boolean;
43
+ multiSelect?: boolean;
44
+ } & CustomTreeviewItemProps<T>;
45
+ export type TreeviewItemProps<T> = {
46
+ itemId: string;
47
+ label?: React.ReactNode;
48
+ children?: React.ReactNode;
49
+ } & CustomTreeviewItemProps<T>;
50
+ export {};
@@ -0,0 +1,15 @@
1
+ import { type RefObject } from 'react';
2
+ import type { DocumentSection } from '../types';
3
+ type UseDragVisualFeedbackParams = {
4
+ containerRef: RefObject<HTMLDivElement | null>;
5
+ getSectionById: (sectionId: string) => DocumentSection | null;
6
+ isValidDropTarget?: (draggedSection: DocumentSection, targetSection: DocumentSection | null) => boolean;
7
+ };
8
+ /**
9
+ * Provides visual feedback during drag-and-drop by graying out invalid drop targets.
10
+ *
11
+ * Uses direct DOM manipulation instead of React state to avoid re-rendering
12
+ * all tree items on every drag event.
13
+ */
14
+ export declare const useDragVisualFeedback: ({ containerRef, getSectionById, isValidDropTarget }: UseDragVisualFeedbackParams) => void;
15
+ export {};
@@ -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,26 @@
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
+ onSectionCreate?: (parentId: string | null, title: string) => string | Promise<string>;
10
+ scrollToBottom?: () => void;
11
+ };
12
+ /**
13
+ * Flow:
14
+ * 1. User triggers `create(parentId)` from context menu
15
+ * 2. A temporary section appears in the tree in edit mode
16
+ * 3. User types a title and presses Enter → `validate()` is called
17
+ * 4. User presses Escape or leaves empty → `cancel()` is called
18
+ */
19
+ export declare const useTemporarySection: ({ apiRef, getSectionById, onSectionCreate, scrollToBottom }: UseTemporarySectionParams) => {
20
+ temporarySection: TemporarySection | null;
21
+ create: (parentId?: string | null) => void;
22
+ validate: (title: string) => Promise<void>;
23
+ cancel: () => void;
24
+ isTemporary: (sectionId: string) => boolean;
25
+ };
26
+ 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, onSectionOrderChange, onSectionTitleChange, onSectionDelete, onSectionVisibilityChange, onSectionCreate, noSectionsPlaceholder, isLoading, getSectionTitleChangePermission, getSectionDeletePermission, getSectionOrderChangePermission, getSectionCreatePermission, getSectionVisibilityChangePermission, hiddenSectionTooltip, visibleIconTooltip, hiddenIconTooltip, isValidDropTarget }: DocumentComposerProps) => import("react/jsx-runtime").JSX.Element;
6
+ export default DocumentComposer;
@@ -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,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;