@edifice.io/react 2.2.2 → 2.2.3-develop-b2school.20250414171310
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/Avatar/Avatar.d.ts +21 -0
- package/dist/components/Avatar/Avatar.js +15 -2
- package/dist/components/AvatarGroup/AvatarGroup.d.ts +24 -0
- package/dist/components/AvatarGroup/AvatarGroup.js +24 -0
- package/dist/components/AvatarGroup/index.d.ts +2 -0
- package/dist/components/Card/Card.d.ts +3 -1
- package/dist/components/Card/CardBody.d.ts +3 -1
- package/dist/components/Card/CardBody.js +4 -2
- package/dist/components/Combobox/Combobox.d.ts +55 -5
- package/dist/components/Combobox/Combobox.js +13 -7
- package/dist/components/Combobox/ComboboxTrigger.d.ts +30 -2
- package/dist/components/Combobox/ComboboxTrigger.js +27 -8
- package/dist/components/Dropdown/Dropdown.d.ts +14 -2
- package/dist/components/Dropdown/Dropdown.js +7 -3
- package/dist/components/Dropdown/DropdownItem.d.ts +5 -1
- package/dist/components/Dropdown/DropdownItem.js +10 -3
- package/dist/components/Dropdown/DropdownTrigger.d.ts +31 -2
- package/dist/components/Dropdown/DropdownTrigger.js +27 -4
- package/dist/components/List/List.d.ts +9 -1
- package/dist/components/List/List.js +9 -9
- package/dist/components/PreventPropagation/PreventPropagation.d.ts +10 -0
- package/dist/components/PreventPropagation/PreventPropagation.js +9 -0
- package/dist/components/PreventPropagation/index.d.ts +2 -0
- package/dist/components/SearchBar/SearchBar.d.ts +1 -1
- package/dist/components/SearchBar/SearchBar.js +3 -1
- package/dist/components/StackedGroup/StackedGroup.d.ts +23 -0
- package/dist/components/StackedGroup/StackedGroup.js +21 -0
- package/dist/components/StackedGroup/index.d.ts +1 -0
- package/dist/components/Switch/Switch.d.ts +29 -0
- package/dist/components/Switch/Switch.js +27 -0
- package/dist/components/Switch/index.d.ts +2 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/editor.js +30 -22
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useCheckable/useCheckable.js +10 -3
- package/dist/hooks/useConf/useConf.d.ts +1 -1
- package/dist/hooks/useConversation/useConversation.d.ts +1 -1
- package/dist/hooks/useConversation/useConversation.js +13 -17
- package/dist/hooks/useDropdown/useDropdown.d.ts +2 -1
- package/dist/hooks/useDropdown/useDropdown.js +5 -3
- package/dist/hooks/useSession/useSession.d.ts +1 -1
- package/dist/hooks/useWorkspaceFolders/index.d.ts +2 -0
- package/dist/hooks/useWorkspaceFolders/useWorkspaceFolders.d.ts +28 -0
- package/dist/hooks/useWorkspaceFolders/useWorkspaceFolders.js +74 -0
- package/dist/icons.js +232 -210
- package/dist/index.d.ts +1 -0
- package/dist/index.js +182 -146
- package/dist/modals.js +16 -14
- package/dist/modules/comments/components/Comment.js +49 -34
- package/dist/modules/comments/components/CommentDeleted.d.ts +1 -0
- package/dist/modules/comments/components/CommentDeleted.js +11 -0
- package/dist/modules/comments/components/CommentForm.d.ts +2 -1
- package/dist/modules/comments/components/CommentForm.js +12 -8
- package/dist/modules/comments/components/CommentList.js +3 -3
- package/dist/modules/comments/components/CommentReplies.d.ts +4 -0
- package/dist/modules/comments/components/CommentReplies.js +33 -0
- package/dist/modules/comments/constants.d.ts +4 -0
- package/dist/modules/comments/constants.js +2 -1
- package/dist/modules/comments/context/Context.d.ts +6 -4
- package/dist/modules/comments/hooks/useCommentReplies.d.ts +12 -0
- package/dist/modules/comments/hooks/useCommentReplies.js +36 -0
- package/dist/modules/comments/hooks/useComments.d.ts +7 -7
- package/dist/modules/comments/hooks/useComments.js +24 -19
- package/dist/modules/comments/hooks/useCommentsContext.d.ts +6 -4
- package/dist/modules/comments/provider/CommentProvider.js +16 -13
- package/dist/modules/comments/types.d.ts +14 -1
- package/dist/modules/editor/components/BubbleMenuEditInformationPane/BubbleMenuEditInformationPane.d.ts +6 -0
- package/dist/modules/editor/components/BubbleMenuEditInformationPane/BubbleMenuEditInformationPane.js +136 -0
- package/dist/modules/editor/components/BubbleMenuEditInformationPane/index.d.ts +1 -0
- package/dist/modules/editor/components/Editor/Editor.d.ts +3 -1
- package/dist/modules/editor/components/Editor/Editor.js +8 -3
- package/dist/modules/editor/components/EditorToolbar/EditorToolbar.js +12 -0
- package/dist/modules/editor/components/NodeView/ConversationHistoryNodeView.d.ts +2 -0
- package/dist/modules/editor/components/NodeView/ConversationHistoryNodeView.js +10 -0
- package/dist/modules/editor/components/NodeView/InformationPaneNodeView.d.ts +2 -0
- package/dist/modules/editor/components/NodeView/InformationPaneNodeView.js +10 -0
- package/dist/modules/editor/components/NodeView/index.d.ts +3 -1
- package/dist/modules/editor/components/Renderer/ConversationHistoryRenderer.d.ts +8 -0
- package/dist/modules/editor/components/Renderer/ConversationHistoryRenderer.js +28 -0
- package/dist/modules/editor/components/Renderer/InformationPaneRenderer.d.ts +3 -0
- package/dist/modules/editor/components/Renderer/InformationPaneRenderer.js +33 -0
- package/dist/modules/editor/components/Renderer/index.d.ts +3 -1
- package/dist/modules/editor/hooks/useTipTapEditor.d.ts +6 -2
- package/dist/modules/editor/hooks/useTipTapEditor.js +4 -2
- package/dist/modules/icons/components/IconFolderAdd.d.ts +7 -0
- package/dist/modules/icons/components/IconFolderAdd.js +13 -0
- package/dist/modules/icons/components/IconFolderDelete.d.ts +7 -0
- package/dist/modules/icons/components/IconFolderDelete.js +12 -0
- package/dist/modules/icons/components/IconGlobe2.d.ts +7 -0
- package/dist/modules/icons/components/IconGlobe2.js +16 -0
- package/dist/modules/icons/components/IconGroupAvatar.d.ts +7 -0
- package/dist/modules/icons/components/IconGroupAvatar.js +12 -0
- package/dist/modules/icons/components/IconInfoRectangle.d.ts +7 -0
- package/dist/modules/icons/components/IconInfoRectangle.js +13 -0
- package/dist/modules/icons/components/IconMailRecall.d.ts +7 -0
- package/dist/modules/icons/components/IconMailRecall.js +13 -0
- package/dist/modules/icons/components/IconQuestionMark.d.ts +7 -0
- package/dist/modules/icons/components/IconQuestionMark.js +13 -0
- package/dist/modules/icons/components/IconReadMail.d.ts +7 -0
- package/dist/modules/icons/components/IconReadMail.js +16 -0
- package/dist/modules/icons/components/IconSignature.d.ts +7 -0
- package/dist/modules/icons/components/IconSignature.js +13 -0
- package/dist/modules/icons/components/IconUndoAll.d.ts +7 -0
- package/dist/modules/icons/components/IconUndoAll.js +14 -0
- package/dist/modules/icons/components/IconUnreadMail.d.ts +7 -0
- package/dist/modules/icons/components/IconUnreadMail.js +16 -0
- package/dist/modules/icons/components/index.d.ts +11 -0
- package/dist/modules/modals/ConfirmModal/ConfirmModal.d.ts +42 -0
- package/dist/modules/modals/ConfirmModal/ConfirmModal.js +36 -0
- package/dist/modules/modals/ConfirmModal/index.d.ts +1 -0
- package/dist/modules/modals/ResourceModal/ResourceModal.d.ts +1 -1
- package/dist/modules/modals/ResourceModal/hooks/useUpdateMutation.d.ts +1 -1
- package/dist/modules/modals/ShareModal/ShareModal.d.ts +1 -1
- package/dist/modules/modals/ShareModal/apps/ShareBlog.d.ts +1 -1
- package/dist/modules/modals/ShareModal/hooks/useShareMutation.d.ts +1 -1
- package/dist/modules/modals/index.d.ts +1 -0
- package/dist/modules/multimedia/WorkspaceFolders/WorkspaceFolders.d.ts +8 -0
- package/dist/modules/multimedia/WorkspaceFolders/WorkspaceFolders.js +31 -0
- package/dist/modules/multimedia/WorkspaceFolders/index.d.ts +1 -0
- package/dist/modules/multimedia/index.d.ts +1 -0
- package/dist/multimedia.js +3 -1
- package/dist/providers/EdificeClientProvider/EdificeClientProvider.context.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/package.json +6 -6
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Color } from 'src/types/color';
|
|
1
2
|
export type AvatarVariants = 'square' | 'rounded' | 'circle';
|
|
2
3
|
export type AvatarSizes = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
3
4
|
export interface AvatarProps extends React.ComponentPropsWithRef<'img'> {
|
|
@@ -26,6 +27,26 @@ export interface AvatarProps extends React.ComponentPropsWithRef<'img'> {
|
|
|
26
27
|
* Optional class for styling purpose
|
|
27
28
|
*/
|
|
28
29
|
className?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Inner border color
|
|
32
|
+
*/
|
|
33
|
+
innerBorderColor?: Color;
|
|
34
|
+
/**
|
|
35
|
+
* Inner border width in pixels
|
|
36
|
+
*/
|
|
37
|
+
innerBorderWidth?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Outer border color
|
|
40
|
+
*/
|
|
41
|
+
outerBorderColor?: Color;
|
|
42
|
+
/**
|
|
43
|
+
* Outer border width in pixels
|
|
44
|
+
*/
|
|
45
|
+
outerBorderWidth?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Outer border offset in pixels
|
|
48
|
+
*/
|
|
49
|
+
outerBorderOffset?: number;
|
|
29
50
|
}
|
|
30
51
|
declare const Avatar: import('react').ForwardRefExoticComponent<Omit<AvatarProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
|
|
31
52
|
export default Avatar;
|
|
@@ -10,6 +10,11 @@ const Avatar = /* @__PURE__ */ forwardRef(({
|
|
|
10
10
|
src,
|
|
11
11
|
imgPlaceholder,
|
|
12
12
|
className,
|
|
13
|
+
innerBorderColor,
|
|
14
|
+
innerBorderWidth,
|
|
15
|
+
outerBorderColor,
|
|
16
|
+
outerBorderWidth,
|
|
17
|
+
outerBorderOffset,
|
|
13
18
|
...restProps
|
|
14
19
|
}, ref) => {
|
|
15
20
|
const placeholder = imgPlaceholder || noAvatar, classes = clsx("avatar", {
|
|
@@ -25,8 +30,16 @@ const Avatar = /* @__PURE__ */ forwardRef(({
|
|
|
25
30
|
rounded: variant === "rounded",
|
|
26
31
|
"rounded-circle": variant === "circle"
|
|
27
32
|
}
|
|
28
|
-
}, className)
|
|
29
|
-
|
|
33
|
+
}, className), style = {
|
|
34
|
+
...outerBorderColor && {
|
|
35
|
+
outline: `${outerBorderWidth}px solid var(--edifice-${outerBorderColor})`,
|
|
36
|
+
outlineOffset: outerBorderOffset
|
|
37
|
+
},
|
|
38
|
+
...innerBorderColor && {
|
|
39
|
+
border: `${innerBorderWidth}px solid var(--edifice-${innerBorderColor})`
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
return /* @__PURE__ */ jsx("div", { ref, className: classes, style, children: /* @__PURE__ */ jsx(Image, { src: src || placeholder, alt, imgPlaceholder: placeholder, ...restProps }) });
|
|
30
43
|
});
|
|
31
44
|
export {
|
|
32
45
|
Avatar as default
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AvatarProps } from '../Avatar';
|
|
2
|
+
export interface AvatarGroupProps extends Omit<AvatarProps, 'src'> {
|
|
3
|
+
/**
|
|
4
|
+
* List of avatar sources
|
|
5
|
+
*/
|
|
6
|
+
src: string[];
|
|
7
|
+
/**
|
|
8
|
+
* Maximum number of avatars to display
|
|
9
|
+
* @default 3
|
|
10
|
+
*/
|
|
11
|
+
maxAvatars?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Overlap between avatars (in pixels)
|
|
14
|
+
* @default 20
|
|
15
|
+
*/
|
|
16
|
+
overlap?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Controls stacking order. When 'rightFirst', rightmost avatar has highest z-index
|
|
19
|
+
* @default 'leftFirst'
|
|
20
|
+
*/
|
|
21
|
+
stackingOrder?: 'leftFirst' | 'rightFirst';
|
|
22
|
+
}
|
|
23
|
+
declare const AvatarGroup: import('react').ForwardRefExoticComponent<Omit<AvatarGroupProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
|
|
24
|
+
export default AvatarGroup;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import StackedGroup from "../StackedGroup/StackedGroup.js";
|
|
5
|
+
import Avatar from "../Avatar/Avatar.js";
|
|
6
|
+
const AvatarGroup = /* @__PURE__ */ forwardRef(({
|
|
7
|
+
src,
|
|
8
|
+
maxAvatars = 3,
|
|
9
|
+
overlap = 20,
|
|
10
|
+
className,
|
|
11
|
+
size = "md",
|
|
12
|
+
variant = "circle",
|
|
13
|
+
alt,
|
|
14
|
+
stackingOrder = "leftFirst",
|
|
15
|
+
...restProps
|
|
16
|
+
}, ref) => {
|
|
17
|
+
const visibleAvatars = src.slice(0, maxAvatars), classes = clsx("avatar-group", className);
|
|
18
|
+
return /* @__PURE__ */ jsx("div", { ref, className: classes, style: {
|
|
19
|
+
display: "flex"
|
|
20
|
+
}, children: /* @__PURE__ */ jsx(StackedGroup, { overlap, stackingOrder, children: visibleAvatars.map((avatarSrc, index) => /* @__PURE__ */ jsx(Avatar, { src: avatarSrc, size, variant, alt: `${alt} ${index + 1}`, ...restProps })) }) });
|
|
21
|
+
});
|
|
22
|
+
export {
|
|
23
|
+
AvatarGroup as default
|
|
24
|
+
};
|
|
@@ -59,8 +59,10 @@ declare const Card: import('react').ForwardRefExoticComponent<CardProps & import
|
|
|
59
59
|
displayName: string;
|
|
60
60
|
};
|
|
61
61
|
Body: {
|
|
62
|
-
({ children, space, flexDirection, }: {
|
|
62
|
+
({ children, gap, space, padding, flexDirection, }: {
|
|
63
|
+
gap?: "0" | "8" | "16" | null;
|
|
63
64
|
space?: "0" | "8" | "16" | null;
|
|
65
|
+
padding?: "0" | "8" | "16" | null;
|
|
64
66
|
flexDirection?: "row" | "column" | null;
|
|
65
67
|
children: ReactNode;
|
|
66
68
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
declare const CardBody: {
|
|
3
|
-
({ children, space, flexDirection, }: {
|
|
3
|
+
({ children, gap, space, padding, flexDirection, }: {
|
|
4
|
+
gap?: "0" | "8" | "16" | null;
|
|
4
5
|
space?: "0" | "8" | "16" | null;
|
|
6
|
+
padding?: "0" | "8" | "16" | null;
|
|
5
7
|
flexDirection?: "row" | "column" | null;
|
|
6
8
|
children: ReactNode;
|
|
7
9
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,12 +2,14 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import clsx from "clsx";
|
|
3
3
|
const CardBody = ({
|
|
4
4
|
children,
|
|
5
|
+
gap = null,
|
|
5
6
|
space = null,
|
|
7
|
+
padding = null,
|
|
6
8
|
flexDirection = "row"
|
|
7
9
|
}) => {
|
|
8
10
|
const cardbody = clsx("card-body", {
|
|
9
|
-
[`p-${space}`]: space,
|
|
10
|
-
[`gap-${space}`]: space,
|
|
11
|
+
[`p-${padding ?? space}`]: space,
|
|
12
|
+
[`gap-${gap ?? space}`]: space,
|
|
11
13
|
"align-items-start": flexDirection === "column",
|
|
12
14
|
"flex-column": flexDirection === "column"
|
|
13
15
|
});
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import { ChangeEvent } from 'react';
|
|
1
|
+
import { ChangeEvent, ReactNode } from 'react';
|
|
2
2
|
export interface ComboboxProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
3
|
-
onSearchResultsChange: (model: (string | number)[]) => void;
|
|
4
3
|
onSearchInputChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
5
4
|
options: OptionListItemType[];
|
|
6
5
|
value: string;
|
|
7
6
|
isLoading: boolean;
|
|
8
7
|
noResult: boolean;
|
|
8
|
+
onSearchResultsChange?: (model: (string | number)[]) => void;
|
|
9
9
|
searchMinLength?: number;
|
|
10
10
|
placeholder?: string;
|
|
11
|
+
variant?: 'outline' | 'ghost';
|
|
12
|
+
renderInputGroup?: ReactNode;
|
|
13
|
+
renderList?: (items: OptionListItemType[]) => ReactNode;
|
|
14
|
+
renderListItem?: (item: OptionListItemType) => ReactNode;
|
|
15
|
+
renderSelectedItems?: ReactNode;
|
|
16
|
+
renderNoResult?: ReactNode;
|
|
17
|
+
hasDefault?: boolean;
|
|
11
18
|
}
|
|
12
19
|
export interface OptionListItemType {
|
|
13
20
|
/**
|
|
@@ -17,15 +24,58 @@ export interface OptionListItemType {
|
|
|
17
24
|
/**
|
|
18
25
|
* Label
|
|
19
26
|
*/
|
|
20
|
-
label
|
|
27
|
+
label?: string;
|
|
21
28
|
/**
|
|
22
29
|
* Add an icon
|
|
23
30
|
*/
|
|
24
31
|
icon?: any;
|
|
32
|
+
/**
|
|
33
|
+
* Display Separator or not
|
|
34
|
+
*/
|
|
35
|
+
withSeparator?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Disable option
|
|
38
|
+
*/
|
|
39
|
+
disabled?: boolean;
|
|
25
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* A component that combines an input field with a dropdown list of selectable options.
|
|
43
|
+
*
|
|
44
|
+
* @component
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* <Combobox
|
|
48
|
+
* onSearchResultsChange={(values) => console.log(values)}
|
|
49
|
+
* onSearchInputChange={(e) => console.log(e.target.value)}
|
|
50
|
+
* options={[{ value: '1', label: 'Option 1' }]}
|
|
51
|
+
* value=""
|
|
52
|
+
* isLoading={false}
|
|
53
|
+
* noResult={false}
|
|
54
|
+
* />
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @param props - The component props
|
|
58
|
+
* @param props.onSearchResultsChange - Callback fired when the selected values change
|
|
59
|
+
* @param props.onSearchInputChange - Callback fired when the search input value changes
|
|
60
|
+
* @param props.options - Array of options to display in the dropdown
|
|
61
|
+
* @param props.value - Current value of the search input
|
|
62
|
+
* @param props.isLoading - Whether the component is in a loading state
|
|
63
|
+
* @param props.noResult - Whether to show a "no results" message
|
|
64
|
+
* @param props.searchMinLength - Minimum number of characters required to trigger search
|
|
65
|
+
* @param props.placeholder - Placeholder text for the input field
|
|
66
|
+
* @param props.variant - Visual variant of the input ('outline' or 'ghost')
|
|
67
|
+
* @param props.renderInputGroup - Custom render function for the input group
|
|
68
|
+
* @param props.renderList - Custom render function for the dropdown list
|
|
69
|
+
* @param props.renderListItem - Custom render function for each option item
|
|
70
|
+
* @param props.renderSelectedItems - Custom render function for selected items
|
|
71
|
+
* @param props.renderNoResult - Custom render function for no results message
|
|
72
|
+
* @param props.hasDefault - Whether to show default options
|
|
73
|
+
*
|
|
74
|
+
* @extends {React.InputHTMLAttributes<HTMLInputElement>}
|
|
75
|
+
*/
|
|
26
76
|
declare const Combobox: {
|
|
27
|
-
({ onSearchResultsChange, onSearchInputChange, options, value, isLoading, noResult, searchMinLength, placeholder, }: ComboboxProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
-
Trigger: ({ placeholder, value, searchMinLength, handleSearchInputChange, }: import('./ComboboxTrigger').ComboboxTriggerProps) => import("react/jsx-runtime").JSX.Element;
|
|
77
|
+
({ onSearchResultsChange, onSearchInputChange, options, value, isLoading, noResult, searchMinLength, placeholder, variant, renderInputGroup, renderList, renderListItem, renderSelectedItems, renderNoResult, }: ComboboxProps): import("react/jsx-runtime").JSX.Element;
|
|
78
|
+
Trigger: ({ placeholder, value, searchMinLength, handleSearchInputChange, renderInputGroup, variant, renderSelectedItems, hasDefault, }: import('./ComboboxTrigger').ComboboxTriggerProps) => import("react/jsx-runtime").JSX.Element;
|
|
29
79
|
displayName: string;
|
|
30
80
|
};
|
|
31
81
|
export default Combobox;
|
|
@@ -12,25 +12,31 @@ const Combobox = ({
|
|
|
12
12
|
isLoading,
|
|
13
13
|
noResult,
|
|
14
14
|
searchMinLength,
|
|
15
|
-
placeholder
|
|
15
|
+
placeholder,
|
|
16
|
+
variant = "outline",
|
|
17
|
+
renderInputGroup,
|
|
18
|
+
renderList,
|
|
19
|
+
renderListItem,
|
|
20
|
+
renderSelectedItems,
|
|
21
|
+
renderNoResult
|
|
16
22
|
}) => {
|
|
17
23
|
const {
|
|
18
24
|
t
|
|
19
25
|
} = useTranslation(), [localValue, setLocalValue] = useState([]);
|
|
20
26
|
useEffect(() => {
|
|
21
|
-
onSearchResultsChange(localValue);
|
|
27
|
+
onSearchResultsChange == null || onSearchResultsChange(localValue);
|
|
22
28
|
}, [localValue]);
|
|
23
29
|
const handleOptionClick = (value2) => {
|
|
24
30
|
setLocalValue([value2]);
|
|
25
31
|
}, renderContent = () => isLoading ? /* @__PURE__ */ jsxs("div", { className: "d-flex align-items-center p-4", children: [
|
|
26
32
|
/* @__PURE__ */ jsx(Loading, { isLoading }),
|
|
27
33
|
/* @__PURE__ */ jsx("span", { className: "ps-4", children: t("explorer.search.pending") })
|
|
28
|
-
] }) : noResult ? /* @__PURE__ */ jsx("div", { className: "p-4", children: t("portal.no.result") }) : options.map((option, index) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
29
|
-
/* @__PURE__ */ jsx(Dropdown.Item, { type: "select", icon: option.icon, onClick: () => handleOptionClick(option.value), children: option.label }),
|
|
30
|
-
index < options.length - 1 && /* @__PURE__ */ jsx(Dropdown.Separator, {})
|
|
34
|
+
] }) : noResult ? renderNoResult || /* @__PURE__ */ jsx("div", { className: "p-4", children: t("portal.no.result") }) : renderList ? renderList(options) : options.map((option, index) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
35
|
+
/* @__PURE__ */ jsx(Dropdown.Item, { type: "select", icon: option.icon, onClick: () => handleOptionClick(option.value), disabled: option.disabled, children: renderListItem ? renderListItem(option) : option.label }),
|
|
36
|
+
(option.withSeparator || option.withSeparator === void 0) && index < options.length - 1 && /* @__PURE__ */ jsx(Dropdown.Separator, {})
|
|
31
37
|
] }, index));
|
|
32
|
-
return /* @__PURE__ */ jsxs(Dropdown, { block: !0, children: [
|
|
33
|
-
/* @__PURE__ */ jsx(Combobox.Trigger, { placeholder, searchMinLength, handleSearchInputChange: onSearchInputChange, value }),
|
|
38
|
+
return /* @__PURE__ */ jsxs(Dropdown, { block: !0, focusOnVisible: !1, openOnSpace: !1, children: [
|
|
39
|
+
/* @__PURE__ */ jsx(Combobox.Trigger, { placeholder, searchMinLength, handleSearchInputChange: onSearchInputChange, value, variant, renderInputGroup, renderSelectedItems, hasDefault: !!options.length }),
|
|
34
40
|
/* @__PURE__ */ jsx(Dropdown.Menu, { children: renderContent() })
|
|
35
41
|
] });
|
|
36
42
|
};
|
|
@@ -1,9 +1,37 @@
|
|
|
1
|
-
import { ChangeEvent } from 'react';
|
|
1
|
+
import { ChangeEvent, ReactNode } from 'react';
|
|
2
2
|
export interface ComboboxTriggerProps extends React.ComponentPropsWithRef<'button'> {
|
|
3
3
|
handleSearchInputChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
4
4
|
value: string;
|
|
5
5
|
searchMinLength?: number;
|
|
6
6
|
placeholder?: string;
|
|
7
|
+
renderInputGroup?: React.ReactNode;
|
|
8
|
+
variant?: 'outline' | 'ghost';
|
|
9
|
+
renderSelectedItems?: ReactNode;
|
|
10
|
+
hasDefault?: boolean;
|
|
7
11
|
}
|
|
8
|
-
|
|
12
|
+
/**
|
|
13
|
+
* A trigger component for the Combobox that handles user input and displays selected items.
|
|
14
|
+
*
|
|
15
|
+
* @component
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <ComboboxTrigger
|
|
19
|
+
* value={searchValue}
|
|
20
|
+
* handleSearchInputChange={(e) => setSearchValue(e.target.value)}
|
|
21
|
+
* placeholder="Search..."
|
|
22
|
+
* />
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @param {object} props - Component props
|
|
26
|
+
* @param {string} [props.placeholder] - Placeholder text for the search input
|
|
27
|
+
* @param {string} [props.value=''] - Current value of the search input
|
|
28
|
+
* @param {number} [props.searchMinLength=3] - Minimum number of characters required before showing dropdown
|
|
29
|
+
* @param {(event: ChangeEvent<HTMLInputElement>) => void} props.handleSearchInputChange - Handler for input change events
|
|
30
|
+
* @param {ReactNode} [props.renderInputGroup] - Optional content to render in the input group (e.g., icons)
|
|
31
|
+
* @param {'outline' | 'ghost'} [props.variant='outline'] - Visual variant of the input
|
|
32
|
+
* @param {ReactNode} [props.renderSelectedItems] - Optional content to render selected items
|
|
33
|
+
*
|
|
34
|
+
* @returns {JSX.Element} A form control containing an input field with optional input group and selected items
|
|
35
|
+
*/
|
|
36
|
+
declare const ComboboxTrigger: ({ placeholder, value, searchMinLength, handleSearchInputChange, renderInputGroup, variant, renderSelectedItems, hasDefault, }: ComboboxTriggerProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
37
|
export default ComboboxTrigger;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect } from "react";
|
|
3
|
+
import clsx from "clsx";
|
|
3
4
|
import { useDropdownContext } from "../Dropdown/DropdownContext.js";
|
|
4
5
|
import Input from "../Input/Input.js";
|
|
5
6
|
import FormControl from "../Form/FormControl.js";
|
|
@@ -7,23 +8,41 @@ const ComboboxTrigger = ({
|
|
|
7
8
|
placeholder,
|
|
8
9
|
value = "",
|
|
9
10
|
searchMinLength = 3,
|
|
10
|
-
handleSearchInputChange
|
|
11
|
+
handleSearchInputChange,
|
|
12
|
+
renderInputGroup,
|
|
13
|
+
variant = "outline",
|
|
14
|
+
renderSelectedItems,
|
|
15
|
+
hasDefault
|
|
11
16
|
}) => {
|
|
12
17
|
const {
|
|
13
18
|
triggerProps,
|
|
14
19
|
itemProps,
|
|
15
20
|
setVisible
|
|
16
|
-
} = useDropdownContext(),
|
|
21
|
+
} = useDropdownContext(), containerProps = {
|
|
17
22
|
...triggerProps,
|
|
23
|
+
className: clsx("d-flex combobox-trigger", renderInputGroup ? "input-group flex-nowrap align-items-start" : "flex-wrap align-items-center", triggerProps.className),
|
|
24
|
+
onClick: (event) => {
|
|
25
|
+
event.stopPropagation();
|
|
26
|
+
}
|
|
27
|
+
}, inputProps = {
|
|
18
28
|
role: "combobox",
|
|
19
|
-
|
|
20
|
-
value.length >= searchMinLength
|
|
29
|
+
onChange: (event) => {
|
|
30
|
+
handleSearchInputChange(event), setVisible(event.target.value.length >= searchMinLength);
|
|
21
31
|
},
|
|
22
|
-
|
|
23
|
-
|
|
32
|
+
onClick: (event) => {
|
|
33
|
+
const input = event.target;
|
|
34
|
+
setVisible(input.value.length >= searchMinLength || !!hasDefault), input.focus();
|
|
35
|
+
}
|
|
36
|
+
}, classNameVariant = variant === "ghost" ? " border-0" : "", classNameInput = clsx(classNameVariant, renderSelectedItems ? "flex-fill w-auto " : "");
|
|
24
37
|
return useEffect(() => {
|
|
25
38
|
setVisible(value.length >= searchMinLength);
|
|
26
|
-
}, [
|
|
39
|
+
}, [value, searchMinLength]), /* @__PURE__ */ jsxs(FormControl, { id: "search", ...containerProps, children: [
|
|
40
|
+
!!renderInputGroup && /* @__PURE__ */ jsx("label", { className: "input-group-text pe-0" + classNameVariant, htmlFor: triggerProps.id, children: renderInputGroup }),
|
|
41
|
+
/* @__PURE__ */ jsxs("div", { className: "d-flex align-items-center flex-wrap flex-fill", children: [
|
|
42
|
+
renderSelectedItems,
|
|
43
|
+
/* @__PURE__ */ jsx(Input, { ...inputProps, className: classNameInput, noValidationIcon: !0, placeholder, size: "md", type: "search", onKeyDown: itemProps.onMenuItemKeyDown })
|
|
44
|
+
] })
|
|
45
|
+
] });
|
|
27
46
|
};
|
|
28
47
|
export {
|
|
29
48
|
ComboboxTrigger as default
|
|
@@ -14,6 +14,10 @@ export interface DropdownProps {
|
|
|
14
14
|
* Default placement with FloatingUI
|
|
15
15
|
*/
|
|
16
16
|
placement?: Placement;
|
|
17
|
+
/**
|
|
18
|
+
* If true, the text will not wrap
|
|
19
|
+
*/
|
|
20
|
+
noWrap?: boolean;
|
|
17
21
|
/**
|
|
18
22
|
* Extra keydown handler for the Dropdown Trigger.
|
|
19
23
|
* Useful for a11y keyboard navigation between a Dropdown element and other elements,
|
|
@@ -28,6 +32,14 @@ export interface DropdownProps {
|
|
|
28
32
|
* Whether the trigger is hovered or not.
|
|
29
33
|
*/
|
|
30
34
|
isTriggerHovered?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Whether to focus the first element when the dropdown is opened.
|
|
37
|
+
*/
|
|
38
|
+
focusOnVisible?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Whether to open the dropdown on space key press.
|
|
41
|
+
*/
|
|
42
|
+
openOnSpace?: boolean;
|
|
31
43
|
}
|
|
32
44
|
export type DropdownMenuOptions = {
|
|
33
45
|
/**
|
|
@@ -53,13 +65,13 @@ export type DropdownMenuOptions = {
|
|
|
53
65
|
type: 'divider';
|
|
54
66
|
};
|
|
55
67
|
declare const Dropdown: {
|
|
56
|
-
({ children, block, overflow, placement, extraTriggerKeyDownHandler, onToggle, isTriggerHovered, }: DropdownProps): import("react/jsx-runtime").JSX.Element;
|
|
68
|
+
({ children, block, overflow, noWrap, placement, extraTriggerKeyDownHandler, onToggle, isTriggerHovered, focusOnVisible, openOnSpace, }: DropdownProps): import("react/jsx-runtime").JSX.Element;
|
|
57
69
|
displayName: string;
|
|
58
70
|
} & {
|
|
59
71
|
Trigger: import('react').ForwardRefExoticComponent<Omit<import('./DropdownTrigger').DropdownTriggerProps, "ref"> & import('react').RefAttributes<HTMLButtonElement>>;
|
|
60
72
|
Menu: import('react').ForwardRefExoticComponent<Omit<import('./DropdownMenu').DropdownMenuProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
|
|
61
73
|
Item: {
|
|
62
|
-
({ type, icon, onClick, children, className, ...restProps }: import('./DropdownItem').DropdownItemProps): import("react/jsx-runtime").JSX.Element;
|
|
74
|
+
({ type, icon, onClick, children, className, minWidth, ...restProps }: import('./DropdownItem').DropdownItemProps): import("react/jsx-runtime").JSX.Element;
|
|
63
75
|
displayName: string;
|
|
64
76
|
};
|
|
65
77
|
Separator: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo, useEffect } from "react";
|
|
3
3
|
import clsx from "clsx";
|
|
4
|
+
import useDropdown from "../../hooks/useDropdown/useDropdown.js";
|
|
4
5
|
import DropdownCheckboxItem from "./DropdownCheckboxItem.js";
|
|
5
6
|
import { DropdownContext } from "./DropdownContext.js";
|
|
6
7
|
import DropdownItem from "./DropdownItem.js";
|
|
@@ -9,16 +10,18 @@ import DropdownMenuGroup from "./DropdownMenuGroup.js";
|
|
|
9
10
|
import DropdownRadioItem from "./DropdownRadioItem.js";
|
|
10
11
|
import DropdownSeparator from "./DropdownSeparator.js";
|
|
11
12
|
import DropdownTrigger from "./DropdownTrigger.js";
|
|
12
|
-
import useDropdown from "../../hooks/useDropdown/useDropdown.js";
|
|
13
13
|
import useClickOutside from "../../hooks/useClickOutside/useClickOutside.js";
|
|
14
14
|
const Root = ({
|
|
15
15
|
children,
|
|
16
16
|
block,
|
|
17
17
|
overflow = !0,
|
|
18
|
+
noWrap,
|
|
18
19
|
placement = "bottom-start",
|
|
19
20
|
extraTriggerKeyDownHandler,
|
|
20
21
|
onToggle,
|
|
21
|
-
isTriggerHovered = !1
|
|
22
|
+
isTriggerHovered = !1,
|
|
23
|
+
focusOnVisible = !0,
|
|
24
|
+
openOnSpace = !0
|
|
22
25
|
}) => {
|
|
23
26
|
const {
|
|
24
27
|
visible,
|
|
@@ -28,7 +31,7 @@ const Root = ({
|
|
|
28
31
|
itemProps,
|
|
29
32
|
itemRefs,
|
|
30
33
|
setVisible
|
|
31
|
-
} = useDropdown(placement, extraTriggerKeyDownHandler, isTriggerHovered), ref = useClickOutside(() => {
|
|
34
|
+
} = useDropdown(placement, extraTriggerKeyDownHandler, isTriggerHovered, focusOnVisible, openOnSpace), ref = useClickOutside(() => {
|
|
32
35
|
setVisible(!1);
|
|
33
36
|
}), value = useMemo(() => ({
|
|
34
37
|
visible,
|
|
@@ -41,6 +44,7 @@ const Root = ({
|
|
|
41
44
|
setVisible
|
|
42
45
|
}), [visible, isFocused, triggerProps, menuProps, itemProps, itemRefs, block, setVisible]), dropdown = clsx("dropdown", {
|
|
43
46
|
"w-100": block,
|
|
47
|
+
"dropdown-nowrap": noWrap,
|
|
44
48
|
overflow
|
|
45
49
|
});
|
|
46
50
|
return useEffect(() => {
|
|
@@ -21,9 +21,13 @@ export interface DropdownItemProps {
|
|
|
21
21
|
* Additional class name
|
|
22
22
|
*/
|
|
23
23
|
className?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Set minimum width in pixels
|
|
26
|
+
*/
|
|
27
|
+
minWidth?: number;
|
|
24
28
|
}
|
|
25
29
|
declare const DropdownItem: {
|
|
26
|
-
({ type, icon, onClick, children, className, ...restProps }: DropdownItemProps): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
({ type, icon, onClick, children, className, minWidth, ...restProps }: DropdownItemProps): import("react/jsx-runtime").JSX.Element;
|
|
27
31
|
displayName: string;
|
|
28
32
|
};
|
|
29
33
|
export default DropdownItem;
|
|
@@ -8,6 +8,7 @@ const DropdownItem = ({
|
|
|
8
8
|
onClick,
|
|
9
9
|
children,
|
|
10
10
|
className,
|
|
11
|
+
minWidth,
|
|
11
12
|
...restProps
|
|
12
13
|
}) => {
|
|
13
14
|
const {
|
|
@@ -19,11 +20,17 @@ const DropdownItem = ({
|
|
|
19
20
|
onMenuItemMouseEnter,
|
|
20
21
|
onMenuItemClick
|
|
21
22
|
} = itemProps, handleOnClick = (event) => {
|
|
22
|
-
onClick == null || onClick(event), type === "action" && (onMenuItemClick(), event.stopPropagation());
|
|
23
|
+
disabled || (onClick == null || onClick(event), type === "action" && (onMenuItemClick(), event.stopPropagation()));
|
|
23
24
|
}, id = useId(), dropdownItem = clsx("dropdown-item", {
|
|
24
25
|
focus: isFocused === id
|
|
25
|
-
},
|
|
26
|
-
|
|
26
|
+
}, {
|
|
27
|
+
"text-gray-600": disabled
|
|
28
|
+
}, className), style = {
|
|
29
|
+
...minWidth && {
|
|
30
|
+
minWidth: `${minWidth}px`
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
return /* @__PURE__ */ jsx("div", { id, role: "menuitem", style, ref: (el) => itemRefs.current[id] = el, tabIndex: isFocused === id ? 0 : -1, className: dropdownItem, "aria-current": isFocused === id, onClick: handleOnClick, onMouseEnter: onMenuItemMouseEnter, onKeyDown: (event) => onMenuItemKeyDown(event, onClick), ...restProps, children: /* @__PURE__ */ jsxs("div", { className: "d-flex gap-8 align-items-center", children: [
|
|
27
34
|
icon,
|
|
28
35
|
children
|
|
29
36
|
] }) });
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { Color } from 'src/types';
|
|
1
2
|
export interface DropdownTriggerProps extends React.ComponentPropsWithRef<'button'> {
|
|
2
3
|
/**
|
|
3
4
|
* Dropdown trigger title
|
|
4
5
|
*/
|
|
5
|
-
label?:
|
|
6
|
+
label?: React.ReactNode;
|
|
6
7
|
/**
|
|
7
8
|
* Add an icon in dropdown trigger
|
|
8
9
|
*/
|
|
@@ -14,7 +15,7 @@ export interface DropdownTriggerProps extends React.ComponentPropsWithRef<'butto
|
|
|
14
15
|
/**
|
|
15
16
|
* Set appearance
|
|
16
17
|
*/
|
|
17
|
-
variant?: 'ghost';
|
|
18
|
+
variant?: 'default' | 'ghost' | 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info';
|
|
18
19
|
/**
|
|
19
20
|
* Button size
|
|
20
21
|
*/
|
|
@@ -31,6 +32,34 @@ export interface DropdownTriggerProps extends React.ComponentPropsWithRef<'butto
|
|
|
31
32
|
* Hide the carret
|
|
32
33
|
*/
|
|
33
34
|
hideCarret?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Make the dropdown trigger a pill
|
|
37
|
+
*/
|
|
38
|
+
pill?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Inner border color
|
|
41
|
+
*/
|
|
42
|
+
innerBorderColor?: Color;
|
|
43
|
+
/**
|
|
44
|
+
* Inner border width in pixels
|
|
45
|
+
*/
|
|
46
|
+
innerBorderWidth?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Outer border color
|
|
49
|
+
*/
|
|
50
|
+
outerBorderColor?: Color;
|
|
51
|
+
/**
|
|
52
|
+
* Outer border width in pixels
|
|
53
|
+
*/
|
|
54
|
+
outerBorderWidth?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Outer border offset in pixels
|
|
57
|
+
*/
|
|
58
|
+
outerBorderOffset?: number;
|
|
59
|
+
/**
|
|
60
|
+
* Use base shade color
|
|
61
|
+
*/
|
|
62
|
+
baseShade?: boolean;
|
|
34
63
|
}
|
|
35
64
|
export type DropdownTriggerType = React.ReactElement<DropdownTriggerProps>;
|
|
36
65
|
declare const DropdownTrigger: import('react').ForwardRefExoticComponent<Omit<DropdownTriggerProps, "ref"> & import('react').RefAttributes<HTMLButtonElement>>;
|
|
@@ -6,11 +6,18 @@ import { useDropdownContext } from "./DropdownContext.js";
|
|
|
6
6
|
const DropdownTrigger = /* @__PURE__ */ forwardRef(({
|
|
7
7
|
label,
|
|
8
8
|
icon,
|
|
9
|
-
variant,
|
|
9
|
+
variant = "default",
|
|
10
10
|
disabled = !1,
|
|
11
11
|
size,
|
|
12
12
|
badgeContent,
|
|
13
13
|
hideCarret = !1,
|
|
14
|
+
pill = !1,
|
|
15
|
+
innerBorderColor,
|
|
16
|
+
innerBorderWidth,
|
|
17
|
+
outerBorderColor,
|
|
18
|
+
outerBorderWidth,
|
|
19
|
+
outerBorderOffset,
|
|
20
|
+
baseShade,
|
|
14
21
|
...restProps
|
|
15
22
|
}, forwardRef2) => {
|
|
16
23
|
const {
|
|
@@ -18,15 +25,31 @@ const DropdownTrigger = /* @__PURE__ */ forwardRef(({
|
|
|
18
25
|
block
|
|
19
26
|
} = useDropdownContext(), className = clsx("dropdown-toggle ", size, variant, {
|
|
20
27
|
"w-100": block
|
|
21
|
-
}, triggerProps.className, restProps.className
|
|
28
|
+
}, triggerProps.className, restProps.className, {
|
|
29
|
+
"rounded-pill": pill
|
|
30
|
+
}, {
|
|
31
|
+
"base-shade": baseShade
|
|
32
|
+
}), style = {
|
|
33
|
+
...outerBorderColor && {
|
|
34
|
+
outline: `${outerBorderWidth}px solid var(--edifice-${outerBorderColor})`,
|
|
35
|
+
outlineOffset: outerBorderOffset
|
|
36
|
+
},
|
|
37
|
+
...innerBorderColor && {
|
|
38
|
+
border: `${innerBorderWidth}px solid var(--edifice-${innerBorderColor})`
|
|
39
|
+
}
|
|
40
|
+
}, mergedProps = {
|
|
22
41
|
...triggerProps,
|
|
23
42
|
...restProps,
|
|
24
|
-
className
|
|
43
|
+
className,
|
|
44
|
+
style
|
|
25
45
|
};
|
|
26
46
|
return /* @__PURE__ */ jsxs("button", { ref: forwardRef2, type: "button", disabled, ...mergedProps, children: [
|
|
27
47
|
icon,
|
|
28
48
|
label,
|
|
29
|
-
badgeContent ? /* @__PURE__ */ jsx(
|
|
49
|
+
badgeContent ? /* @__PURE__ */ jsx(Badge, { variant: {
|
|
50
|
+
level: "info",
|
|
51
|
+
type: "notification"
|
|
52
|
+
}, children: badgeContent }) : !hideCarret && /* @__PURE__ */ jsx(SvgIconRafterUp, { width: 16, height: 16, className: "dropdown-toggle-caret" })
|
|
30
53
|
] });
|
|
31
54
|
});
|
|
32
55
|
export {
|
|
@@ -5,6 +5,10 @@ export type ListProps<T> = {
|
|
|
5
5
|
* Toolbar data items
|
|
6
6
|
*/
|
|
7
7
|
items?: ToolbarItem[];
|
|
8
|
+
/**
|
|
9
|
+
* Checkable list
|
|
10
|
+
*/
|
|
11
|
+
isCheckable?: boolean;
|
|
8
12
|
/**
|
|
9
13
|
* Generic data
|
|
10
14
|
*/
|
|
@@ -17,7 +21,11 @@ export type ListProps<T> = {
|
|
|
17
21
|
* Callback to get selected ids
|
|
18
22
|
*/
|
|
19
23
|
onSelectedItems?: (selectedIds: string[]) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Custom class name
|
|
26
|
+
*/
|
|
27
|
+
className?: string;
|
|
20
28
|
};
|
|
21
29
|
export declare const List: <T extends {
|
|
22
30
|
_id: string;
|
|
23
|
-
}>({ items, data, renderNode, onSelectedItems, }: ListProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
}>({ items, isCheckable, data, renderNode, onSelectedItems, className, }: ListProps<T>) => import("react/jsx-runtime").JSX.Element;
|