@capytale/meta-player 0.8.2 → 0.8.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/.prettierrc.json +4 -4
- package/LICENSE +674 -674
- package/README.md +12 -12
- package/eslint.config.js +28 -28
- package/index.html +15 -15
- package/package.json +60 -60
- package/public/themes/lara-dark-blue/theme.css +7015 -7015
- package/public/themes/lara-light-blue/theme.css +7005 -7005
- package/src/App.tsx +139 -139
- package/src/AppRedux.css +39 -39
- package/src/MetaPlayer.tsx +170 -170
- package/src/activityJs.ts +7 -7
- package/src/app/createAppSlice.ts +6 -6
- package/src/app/hooks.ts +12 -12
- package/src/app/store.ts +52 -52
- package/src/app.module.scss +80 -80
- package/src/demo.tsx +87 -87
- package/src/external/prime.ts +5 -5
- package/src/features/activityData/ExitWarning.ts +28 -28
- package/src/features/activityData/IsAntiCheatExitDetectionDisabledSetter.tsx +19 -19
- package/src/features/activityData/IsDirtySetter.tsx +17 -17
- package/src/features/activityData/MetaPlayerOptionsSetter.tsx +41 -41
- package/src/features/activityData/activityDataSlice.ts +256 -256
- package/src/features/activityData/activityJsData.ts +82 -82
- package/src/features/activityData/hooks.ts +34 -34
- package/src/features/activityData/metaPlayerOptions.ts +23 -23
- package/src/features/activityData/uiState.ts +20 -20
- package/src/features/activityJS/ActivityJSProvider.tsx +339 -339
- package/src/features/activityJS/AfterResetAction.tsx +23 -23
- package/src/features/activityJS/AfterSaveAction.tsx +23 -23
- package/src/features/activityJS/BeforeResetAction.tsx +23 -23
- package/src/features/activityJS/BeforeSaveAction.tsx +23 -23
- package/src/features/activityJS/Saver.tsx +167 -167
- package/src/features/activityJS/hooks.ts +85 -85
- package/src/features/activityJS/internal-hooks.ts +96 -96
- package/src/features/activityJS/saverSlice.ts +96 -96
- package/src/features/activitySettings/ActivitySettingsSetter.tsx +21 -21
- package/src/features/activitySettings/hooks.ts +12 -12
- package/src/features/activitySettings/index.tsx +43 -43
- package/src/features/activitySettings/store.ts +108 -108
- package/src/features/activitySettings/style.module.scss +8 -8
- package/src/features/activitySettings/types.ts +140 -140
- package/src/features/activitySettings/ui.tsx +299 -299
- package/src/features/functionalities/AttachedFilesFunctionality.ts +23 -23
- package/src/features/functionalities/PreviewDialog.tsx +83 -83
- package/src/features/functionalities/functionalitiesSlice.ts +98 -98
- package/src/features/functionalities/hooks.ts +70 -70
- package/src/features/layout/hooks.ts +7 -7
- package/src/features/layout/layoutSlice.ts +90 -90
- package/src/features/navbar/activity-info/index.tsx +54 -54
- package/src/features/navbar/activity-info/style.module.scss +38 -38
- package/src/features/navbar/activity-menu/ActivityQuickActions.tsx +57 -57
- package/src/features/navbar/activity-menu/index.tsx +154 -153
- package/src/features/navbar/activity-menu/style.module.scss +7 -7
- package/src/features/navbar/capytale-menu/CloneDialog.tsx +75 -75
- package/src/features/navbar/capytale-menu/Countdown.tsx +312 -312
- package/src/features/navbar/capytale-menu/CountdownAndSaveButton.tsx +115 -115
- package/src/features/navbar/capytale-menu/index.tsx +260 -260
- package/src/features/navbar/capytale-menu/style.module.scss +8 -8
- package/src/features/navbar/index.tsx +39 -39
- package/src/features/navbar/navbarSlice.ts +79 -79
- package/src/features/navbar/review-navbar/GradingNav.tsx +128 -128
- package/src/features/navbar/review-navbar/index.tsx +18 -18
- package/src/features/navbar/review-navbar/style.module.scss +22 -22
- package/src/features/navbar/sidebars/ActivitySidebarActions.tsx +57 -57
- package/src/features/navbar/sidebars/AttachedFilesSidebarContent.module.scss +43 -43
- package/src/features/navbar/sidebars/AttachedFilesSidebarContent.tsx +181 -181
- package/src/features/navbar/sidebars/SettingsSidebarContent.tsx +192 -192
- package/src/features/navbar/sidebars/style.module.scss +15 -15
- package/src/features/navbar/student-utils.ts +11 -11
- package/src/features/navbar/style.module.scss +65 -65
- package/src/features/pedago/InstructionsEditor.tsx +102 -102
- package/src/features/pedago/PdfEditor.tsx +91 -91
- package/src/features/pedago/PedagoCommands.tsx +353 -353
- package/src/features/pedago/SharedNotesEditor.tsx +144 -144
- package/src/features/pedago/index.tsx +207 -204
- package/src/features/pedago/style.module.scss +233 -233
- package/src/features/theming/ThemeSwitcher.tsx +51 -51
- package/src/features/theming/hooks.ts +6 -6
- package/src/features/theming/themingSlice.ts +93 -93
- package/src/features/toast.tsx +38 -38
- package/src/hooks/index.ts +16 -16
- package/src/index.css +132 -132
- package/src/index.ts +90 -90
- package/src/logo.svg +1 -1
- package/src/my_json_data.js +4146 -4146
- package/src/settings.ts +6 -6
- package/src/types.ts +9 -9
- package/src/utils/ButtonDoubleIcon.tsx +35 -35
- package/src/utils/CardSelector.tsx +41 -41
- package/src/utils/ErrorBoundary.tsx +41 -41
- package/src/utils/PopupButton.tsx +134 -134
- package/src/utils/activity.ts +8 -8
- package/src/utils/breakpoints.ts +4 -4
- package/src/utils/capytale.ts +10 -10
- package/src/utils/clipboard.ts +11 -11
- package/src/utils/download.ts +7 -7
- package/src/utils/equality.ts +32 -32
- package/src/utils/server-clock.ts +42 -42
- package/src/utils/style.module.scss +45 -45
- package/src/utils/useFullscreen.ts +65 -65
- package/src/vite-env.d.ts +1 -1
- package/tsconfig.json +28 -28
- package/tsconfig.node.json +9 -9
- package/vite.config.ts +11 -11
package/src/settings.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const settings = {
|
|
2
|
-
STATEMENT_MAX_SIZE: 2000000, // 2 MB
|
|
3
|
-
TOOLTIP_SHOW_DELAY: 500,
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
export default settings;
|
|
1
|
+
const settings = {
|
|
2
|
+
STATEMENT_MAX_SIZE: 2000000, // 2 MB
|
|
3
|
+
TOOLTIP_SHOW_DELAY: 500,
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export default settings;
|
package/src/types.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export type AntiCheatOptions = {
|
|
2
|
-
preserveDom: boolean;
|
|
3
|
-
hasIframes: boolean;
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
export type UIOptions = {
|
|
7
|
-
closePedagoByDefault: boolean;
|
|
8
|
-
noWorkflow: boolean;
|
|
9
|
-
noSaveForStudents: boolean;
|
|
1
|
+
export type AntiCheatOptions = {
|
|
2
|
+
preserveDom: boolean;
|
|
3
|
+
hasIframes: boolean;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export type UIOptions = {
|
|
7
|
+
closePedagoByDefault: boolean;
|
|
8
|
+
noWorkflow: boolean;
|
|
9
|
+
noSaveForStudents: boolean;
|
|
10
10
|
};
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { Button, ButtonProps } from "primereact/button";
|
|
2
|
-
import React from "react";
|
|
3
|
-
|
|
4
|
-
type ButtonDoubleIconProps = Exclude<
|
|
5
|
-
ButtonProps,
|
|
6
|
-
"icon" | "children" | "iconPos"
|
|
7
|
-
> & {
|
|
8
|
-
leftIcon: string;
|
|
9
|
-
rightIcon: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const ButtonDoubleIcon: React.FC<ButtonDoubleIconProps> = function ({
|
|
13
|
-
label,
|
|
14
|
-
leftIcon,
|
|
15
|
-
rightIcon,
|
|
16
|
-
...props
|
|
17
|
-
}) {
|
|
18
|
-
return (
|
|
19
|
-
<Button {...props}>
|
|
20
|
-
<span
|
|
21
|
-
className={"p-button-icon p-c p-button-icon-left " + leftIcon}
|
|
22
|
-
data-pc-section="icon"
|
|
23
|
-
></span>
|
|
24
|
-
<span className="p-button-label p-c" data-pc-section="label">
|
|
25
|
-
{label}
|
|
26
|
-
</span>
|
|
27
|
-
<span
|
|
28
|
-
className={"p-button-icon p-c p-button-icon-right " + rightIcon}
|
|
29
|
-
data-pc-section="icon"
|
|
30
|
-
></span>
|
|
31
|
-
</Button>
|
|
32
|
-
);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export default ButtonDoubleIcon;
|
|
1
|
+
import { Button, ButtonProps } from "primereact/button";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
type ButtonDoubleIconProps = Exclude<
|
|
5
|
+
ButtonProps,
|
|
6
|
+
"icon" | "children" | "iconPos"
|
|
7
|
+
> & {
|
|
8
|
+
leftIcon: string;
|
|
9
|
+
rightIcon: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const ButtonDoubleIcon: React.FC<ButtonDoubleIconProps> = function ({
|
|
13
|
+
label,
|
|
14
|
+
leftIcon,
|
|
15
|
+
rightIcon,
|
|
16
|
+
...props
|
|
17
|
+
}) {
|
|
18
|
+
return (
|
|
19
|
+
<Button {...props}>
|
|
20
|
+
<span
|
|
21
|
+
className={"p-button-icon p-c p-button-icon-left " + leftIcon}
|
|
22
|
+
data-pc-section="icon"
|
|
23
|
+
></span>
|
|
24
|
+
<span className="p-button-label p-c" data-pc-section="label">
|
|
25
|
+
{label}
|
|
26
|
+
</span>
|
|
27
|
+
<span
|
|
28
|
+
className={"p-button-icon p-c p-button-icon-right " + rightIcon}
|
|
29
|
+
data-pc-section="icon"
|
|
30
|
+
></span>
|
|
31
|
+
</Button>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default ButtonDoubleIcon;
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { RadioButton } from "primereact/radiobutton";
|
|
2
|
-
import styles from "./style.module.scss";
|
|
3
|
-
|
|
4
|
-
type CardSelectorProps<ValueType> = {
|
|
5
|
-
options: { title: string; description: string; value: ValueType }[];
|
|
6
|
-
selected?: ValueType | null;
|
|
7
|
-
onChange: (value: ValueType) => void | Promise<void>;
|
|
8
|
-
};
|
|
9
|
-
const CardSelector = function <ValueType>(props: CardSelectorProps<ValueType>) {
|
|
10
|
-
return (
|
|
11
|
-
<>
|
|
12
|
-
<div className={styles.cardSelector}>
|
|
13
|
-
{props.options.map((option) => (
|
|
14
|
-
<div
|
|
15
|
-
className={styles.cardSelectorOption}
|
|
16
|
-
data-selected={props.selected === option.value}
|
|
17
|
-
role="button"
|
|
18
|
-
aria-label={`Sélectionner l'option ${option.title}`}
|
|
19
|
-
onClick={() => {
|
|
20
|
-
props.onChange(option.value);
|
|
21
|
-
}}
|
|
22
|
-
>
|
|
23
|
-
<div className={styles.cardSelectorOptionRadio}>
|
|
24
|
-
<RadioButton checked={props.selected === option.value} />
|
|
25
|
-
</div>
|
|
26
|
-
<div className={styles.cardSelectorOptionContent}>
|
|
27
|
-
<div className={styles.cardSelectorOptionTitle}>
|
|
28
|
-
{option.title}
|
|
29
|
-
</div>
|
|
30
|
-
<div className={styles.cardSelectorOptionDescription}>
|
|
31
|
-
{option.description}
|
|
32
|
-
</div>
|
|
33
|
-
</div>
|
|
34
|
-
</div>
|
|
35
|
-
))}
|
|
36
|
-
</div>
|
|
37
|
-
</>
|
|
38
|
-
);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export default CardSelector;
|
|
1
|
+
import { RadioButton } from "primereact/radiobutton";
|
|
2
|
+
import styles from "./style.module.scss";
|
|
3
|
+
|
|
4
|
+
type CardSelectorProps<ValueType> = {
|
|
5
|
+
options: { title: string; description: string; value: ValueType }[];
|
|
6
|
+
selected?: ValueType | null;
|
|
7
|
+
onChange: (value: ValueType) => void | Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
const CardSelector = function <ValueType>(props: CardSelectorProps<ValueType>) {
|
|
10
|
+
return (
|
|
11
|
+
<>
|
|
12
|
+
<div className={styles.cardSelector}>
|
|
13
|
+
{props.options.map((option) => (
|
|
14
|
+
<div
|
|
15
|
+
className={styles.cardSelectorOption}
|
|
16
|
+
data-selected={props.selected === option.value}
|
|
17
|
+
role="button"
|
|
18
|
+
aria-label={`Sélectionner l'option ${option.title}`}
|
|
19
|
+
onClick={() => {
|
|
20
|
+
props.onChange(option.value);
|
|
21
|
+
}}
|
|
22
|
+
>
|
|
23
|
+
<div className={styles.cardSelectorOptionRadio}>
|
|
24
|
+
<RadioButton checked={props.selected === option.value} />
|
|
25
|
+
</div>
|
|
26
|
+
<div className={styles.cardSelectorOptionContent}>
|
|
27
|
+
<div className={styles.cardSelectorOptionTitle}>
|
|
28
|
+
{option.title}
|
|
29
|
+
</div>
|
|
30
|
+
<div className={styles.cardSelectorOptionDescription}>
|
|
31
|
+
{option.description}
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
))}
|
|
36
|
+
</div>
|
|
37
|
+
</>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default CardSelector;
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { Component, ErrorInfo, PropsWithChildren, ReactNode } from "react";
|
|
2
|
-
|
|
3
|
-
type ErrorBoundaryProps = PropsWithChildren<{
|
|
4
|
-
fallback: ReactNode;
|
|
5
|
-
}>;
|
|
6
|
-
type ErrorBoundaryState = {
|
|
7
|
-
hasError: boolean;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export class ErrorBoundary extends Component<
|
|
11
|
-
ErrorBoundaryProps,
|
|
12
|
-
ErrorBoundaryState
|
|
13
|
-
> {
|
|
14
|
-
constructor(props: ErrorBoundaryProps) {
|
|
15
|
-
super(props);
|
|
16
|
-
this.state = { hasError: false };
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
static getDerivedStateFromError(_error: Error) {
|
|
20
|
-
// Update state so the next render will show the fallback UI.
|
|
21
|
-
return { hasError: true };
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
componentDidCatch(error: Error, info: ErrorInfo) {
|
|
25
|
-
// Example "componentStack":
|
|
26
|
-
// in ComponentThatThrows (created by App)
|
|
27
|
-
// in ErrorBoundary (created by App)
|
|
28
|
-
// in div (created by App)
|
|
29
|
-
// in App
|
|
30
|
-
console.error(error, info.componentStack);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
render() {
|
|
34
|
-
if (this.state.hasError) {
|
|
35
|
-
// You can render any custom fallback UI
|
|
36
|
-
return this.props.fallback;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return this.props.children;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
1
|
+
import { Component, ErrorInfo, PropsWithChildren, ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
type ErrorBoundaryProps = PropsWithChildren<{
|
|
4
|
+
fallback: ReactNode;
|
|
5
|
+
}>;
|
|
6
|
+
type ErrorBoundaryState = {
|
|
7
|
+
hasError: boolean;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export class ErrorBoundary extends Component<
|
|
11
|
+
ErrorBoundaryProps,
|
|
12
|
+
ErrorBoundaryState
|
|
13
|
+
> {
|
|
14
|
+
constructor(props: ErrorBoundaryProps) {
|
|
15
|
+
super(props);
|
|
16
|
+
this.state = { hasError: false };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static getDerivedStateFromError(_error: Error) {
|
|
20
|
+
// Update state so the next render will show the fallback UI.
|
|
21
|
+
return { hasError: true };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
componentDidCatch(error: Error, info: ErrorInfo) {
|
|
25
|
+
// Example "componentStack":
|
|
26
|
+
// in ComponentThatThrows (created by App)
|
|
27
|
+
// in ErrorBoundary (created by App)
|
|
28
|
+
// in div (created by App)
|
|
29
|
+
// in App
|
|
30
|
+
console.error(error, info.componentStack);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
render() {
|
|
34
|
+
if (this.state.hasError) {
|
|
35
|
+
// You can render any custom fallback UI
|
|
36
|
+
return this.props.fallback;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return this.props.children;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -1,135 +1,135 @@
|
|
|
1
|
-
import { Button, ButtonProps } from "primereact/button";
|
|
2
|
-
import { MenuItem } from "primereact/menuitem";
|
|
3
|
-
import { TieredMenu } from "primereact/tieredmenu";
|
|
4
|
-
import { useMountEffect } from "primereact/hooks";
|
|
5
|
-
import {
|
|
6
|
-
IconType,
|
|
7
|
-
ObjectUtils,
|
|
8
|
-
UniqueComponentId,
|
|
9
|
-
classNames,
|
|
10
|
-
} from "primereact/utils";
|
|
11
|
-
import {
|
|
12
|
-
CSSProperties,
|
|
13
|
-
KeyboardEventHandler,
|
|
14
|
-
MouseEventHandler,
|
|
15
|
-
ReactNode,
|
|
16
|
-
useRef,
|
|
17
|
-
useState,
|
|
18
|
-
} from "react";
|
|
19
|
-
import { Tooltip } from "primereact/tooltip";
|
|
20
|
-
import { TooltipOptions } from "primereact/tooltip/tooltipoptions";
|
|
21
|
-
|
|
22
|
-
type PopupButtonProps = {
|
|
23
|
-
id?: string;
|
|
24
|
-
icon?: IconType<ButtonProps>;
|
|
25
|
-
buttonClassName?: string;
|
|
26
|
-
disabled?: boolean;
|
|
27
|
-
buttonProps?: ButtonProps;
|
|
28
|
-
size?: "small" | "large";
|
|
29
|
-
severity?: "secondary" | "success" | "info" | "warning" | "danger" | "help";
|
|
30
|
-
outlined?: boolean;
|
|
31
|
-
text?: boolean;
|
|
32
|
-
raised?: boolean;
|
|
33
|
-
unstyled?: boolean;
|
|
34
|
-
onButtonKeydown?: KeyboardEventHandler<HTMLButtonElement>;
|
|
35
|
-
model?: MenuItem[];
|
|
36
|
-
appendTo?: HTMLElement | "self" | (() => HTMLElement) | null;
|
|
37
|
-
tooltip?: ReactNode;
|
|
38
|
-
menuStyle?: CSSProperties;
|
|
39
|
-
autoZIndex?: boolean;
|
|
40
|
-
baseZIndex?: number;
|
|
41
|
-
menuClassName?: string;
|
|
42
|
-
tooltipOptions?: TooltipOptions;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const PopupButton: React.FC<PopupButtonProps> = ({
|
|
46
|
-
id,
|
|
47
|
-
icon,
|
|
48
|
-
buttonClassName,
|
|
49
|
-
disabled,
|
|
50
|
-
buttonProps,
|
|
51
|
-
size,
|
|
52
|
-
severity,
|
|
53
|
-
outlined,
|
|
54
|
-
text,
|
|
55
|
-
raised,
|
|
56
|
-
unstyled,
|
|
57
|
-
onButtonKeydown,
|
|
58
|
-
model,
|
|
59
|
-
appendTo,
|
|
60
|
-
tooltip,
|
|
61
|
-
menuStyle,
|
|
62
|
-
autoZIndex,
|
|
63
|
-
baseZIndex,
|
|
64
|
-
menuClassName,
|
|
65
|
-
tooltipOptions,
|
|
66
|
-
...props
|
|
67
|
-
}: PopupButtonProps) => {
|
|
68
|
-
const [idState, setIdState] = useState(id);
|
|
69
|
-
useMountEffect(() => {
|
|
70
|
-
if (!idState) {
|
|
71
|
-
setIdState(UniqueComponentId());
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
const [overlayVisibleState, _setOverlayVisibleState] =
|
|
76
|
-
useState<boolean>(false);
|
|
77
|
-
const menuRef = useRef(null);
|
|
78
|
-
const elementRef = useRef(null);
|
|
79
|
-
|
|
80
|
-
const hasTooltip = ObjectUtils.isNotEmpty(tooltip);
|
|
81
|
-
|
|
82
|
-
const onDropdownButtonClick: MouseEventHandler<HTMLButtonElement> = (
|
|
83
|
-
event,
|
|
84
|
-
) => {
|
|
85
|
-
menuRef && (menuRef.current as any)?.toggle(event);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const menuId = idState + "_overlay";
|
|
89
|
-
|
|
90
|
-
return (
|
|
91
|
-
<>
|
|
92
|
-
<div {...props}>
|
|
93
|
-
<Button
|
|
94
|
-
type="button"
|
|
95
|
-
className={classNames(buttonClassName)}
|
|
96
|
-
icon={icon}
|
|
97
|
-
onClick={onDropdownButtonClick}
|
|
98
|
-
disabled={disabled}
|
|
99
|
-
aria-expanded={overlayVisibleState}
|
|
100
|
-
aria-haspopup="true"
|
|
101
|
-
aria-controls={menuId}
|
|
102
|
-
{...buttonProps}
|
|
103
|
-
size={size}
|
|
104
|
-
severity={severity}
|
|
105
|
-
outlined={outlined}
|
|
106
|
-
text={text}
|
|
107
|
-
raised={raised}
|
|
108
|
-
onKeyDown={onButtonKeydown}
|
|
109
|
-
unstyled={unstyled}
|
|
110
|
-
/>
|
|
111
|
-
<TieredMenu
|
|
112
|
-
ref={menuRef}
|
|
113
|
-
popup={true}
|
|
114
|
-
unstyled={unstyled}
|
|
115
|
-
model={model}
|
|
116
|
-
appendTo={appendTo}
|
|
117
|
-
id={menuId}
|
|
118
|
-
style={menuStyle}
|
|
119
|
-
autoZIndex={autoZIndex}
|
|
120
|
-
baseZIndex={baseZIndex}
|
|
121
|
-
className={menuClassName}
|
|
122
|
-
/>
|
|
123
|
-
</div>
|
|
124
|
-
{hasTooltip && (
|
|
125
|
-
<Tooltip
|
|
126
|
-
target={elementRef}
|
|
127
|
-
content={tooltip}
|
|
128
|
-
{...tooltipOptions}
|
|
129
|
-
/>
|
|
130
|
-
)}
|
|
131
|
-
</>
|
|
132
|
-
);
|
|
133
|
-
};
|
|
134
|
-
|
|
1
|
+
import { Button, ButtonProps } from "primereact/button";
|
|
2
|
+
import { MenuItem } from "primereact/menuitem";
|
|
3
|
+
import { TieredMenu } from "primereact/tieredmenu";
|
|
4
|
+
import { useMountEffect } from "primereact/hooks";
|
|
5
|
+
import {
|
|
6
|
+
IconType,
|
|
7
|
+
ObjectUtils,
|
|
8
|
+
UniqueComponentId,
|
|
9
|
+
classNames,
|
|
10
|
+
} from "primereact/utils";
|
|
11
|
+
import {
|
|
12
|
+
CSSProperties,
|
|
13
|
+
KeyboardEventHandler,
|
|
14
|
+
MouseEventHandler,
|
|
15
|
+
ReactNode,
|
|
16
|
+
useRef,
|
|
17
|
+
useState,
|
|
18
|
+
} from "react";
|
|
19
|
+
import { Tooltip } from "primereact/tooltip";
|
|
20
|
+
import { TooltipOptions } from "primereact/tooltip/tooltipoptions";
|
|
21
|
+
|
|
22
|
+
type PopupButtonProps = {
|
|
23
|
+
id?: string;
|
|
24
|
+
icon?: IconType<ButtonProps>;
|
|
25
|
+
buttonClassName?: string;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
buttonProps?: ButtonProps;
|
|
28
|
+
size?: "small" | "large";
|
|
29
|
+
severity?: "secondary" | "success" | "info" | "warning" | "danger" | "help";
|
|
30
|
+
outlined?: boolean;
|
|
31
|
+
text?: boolean;
|
|
32
|
+
raised?: boolean;
|
|
33
|
+
unstyled?: boolean;
|
|
34
|
+
onButtonKeydown?: KeyboardEventHandler<HTMLButtonElement>;
|
|
35
|
+
model?: MenuItem[];
|
|
36
|
+
appendTo?: HTMLElement | "self" | (() => HTMLElement) | null;
|
|
37
|
+
tooltip?: ReactNode;
|
|
38
|
+
menuStyle?: CSSProperties;
|
|
39
|
+
autoZIndex?: boolean;
|
|
40
|
+
baseZIndex?: number;
|
|
41
|
+
menuClassName?: string;
|
|
42
|
+
tooltipOptions?: TooltipOptions;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const PopupButton: React.FC<PopupButtonProps> = ({
|
|
46
|
+
id,
|
|
47
|
+
icon,
|
|
48
|
+
buttonClassName,
|
|
49
|
+
disabled,
|
|
50
|
+
buttonProps,
|
|
51
|
+
size,
|
|
52
|
+
severity,
|
|
53
|
+
outlined,
|
|
54
|
+
text,
|
|
55
|
+
raised,
|
|
56
|
+
unstyled,
|
|
57
|
+
onButtonKeydown,
|
|
58
|
+
model,
|
|
59
|
+
appendTo,
|
|
60
|
+
tooltip,
|
|
61
|
+
menuStyle,
|
|
62
|
+
autoZIndex,
|
|
63
|
+
baseZIndex,
|
|
64
|
+
menuClassName,
|
|
65
|
+
tooltipOptions,
|
|
66
|
+
...props
|
|
67
|
+
}: PopupButtonProps) => {
|
|
68
|
+
const [idState, setIdState] = useState(id);
|
|
69
|
+
useMountEffect(() => {
|
|
70
|
+
if (!idState) {
|
|
71
|
+
setIdState(UniqueComponentId());
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const [overlayVisibleState, _setOverlayVisibleState] =
|
|
76
|
+
useState<boolean>(false);
|
|
77
|
+
const menuRef = useRef(null);
|
|
78
|
+
const elementRef = useRef(null);
|
|
79
|
+
|
|
80
|
+
const hasTooltip = ObjectUtils.isNotEmpty(tooltip);
|
|
81
|
+
|
|
82
|
+
const onDropdownButtonClick: MouseEventHandler<HTMLButtonElement> = (
|
|
83
|
+
event,
|
|
84
|
+
) => {
|
|
85
|
+
menuRef && (menuRef.current as any)?.toggle(event);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const menuId = idState + "_overlay";
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<>
|
|
92
|
+
<div {...props}>
|
|
93
|
+
<Button
|
|
94
|
+
type="button"
|
|
95
|
+
className={classNames(buttonClassName)}
|
|
96
|
+
icon={icon}
|
|
97
|
+
onClick={onDropdownButtonClick}
|
|
98
|
+
disabled={disabled}
|
|
99
|
+
aria-expanded={overlayVisibleState}
|
|
100
|
+
aria-haspopup="true"
|
|
101
|
+
aria-controls={menuId}
|
|
102
|
+
{...buttonProps}
|
|
103
|
+
size={size}
|
|
104
|
+
severity={severity}
|
|
105
|
+
outlined={outlined}
|
|
106
|
+
text={text}
|
|
107
|
+
raised={raised}
|
|
108
|
+
onKeyDown={onButtonKeydown}
|
|
109
|
+
unstyled={unstyled}
|
|
110
|
+
/>
|
|
111
|
+
<TieredMenu
|
|
112
|
+
ref={menuRef}
|
|
113
|
+
popup={true}
|
|
114
|
+
unstyled={unstyled}
|
|
115
|
+
model={model}
|
|
116
|
+
appendTo={appendTo}
|
|
117
|
+
id={menuId}
|
|
118
|
+
style={menuStyle}
|
|
119
|
+
autoZIndex={autoZIndex}
|
|
120
|
+
baseZIndex={baseZIndex}
|
|
121
|
+
className={menuClassName}
|
|
122
|
+
/>
|
|
123
|
+
</div>
|
|
124
|
+
{hasTooltip && (
|
|
125
|
+
<Tooltip
|
|
126
|
+
target={elementRef}
|
|
127
|
+
content={tooltip}
|
|
128
|
+
{...tooltipOptions}
|
|
129
|
+
/>
|
|
130
|
+
)}
|
|
131
|
+
</>
|
|
132
|
+
);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
135
|
export default PopupButton;
|
package/src/utils/activity.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export function getIdFromUrl() {
|
|
2
|
-
const params = new URLSearchParams(window.location.search);
|
|
3
|
-
const id = params.get("id");
|
|
4
|
-
if (id !== null) {
|
|
5
|
-
return parseInt(id, 10);
|
|
6
|
-
}
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
1
|
+
export function getIdFromUrl() {
|
|
2
|
+
const params = new URLSearchParams(window.location.search);
|
|
3
|
+
const id = params.get("id");
|
|
4
|
+
if (id !== null) {
|
|
5
|
+
return parseInt(id, 10);
|
|
6
|
+
}
|
|
7
|
+
return null;
|
|
8
|
+
}
|
package/src/utils/breakpoints.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export const SM = 576;
|
|
2
|
-
export const MD = 768;
|
|
3
|
-
export const ML = 850;
|
|
4
|
-
export const LG = 992;
|
|
1
|
+
export const SM = 576;
|
|
2
|
+
export const MD = 768;
|
|
3
|
+
export const ML = 850;
|
|
4
|
+
export const LG = 992;
|
|
5
5
|
export const XL = 1200;
|
package/src/utils/capytale.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import httpClient from '@capytale/activity.js/backend/capytale/http';
|
|
2
|
-
|
|
3
|
-
// Definit le endpoint de l'API
|
|
4
|
-
const myActivitiesApiEp = '/web/c-hdls/api/my-activities';
|
|
5
|
-
|
|
6
|
-
export async function apiCloneActivity(nid: number | string, title?: string) {
|
|
7
|
-
return httpClient.postGetJsonAsync<any>(
|
|
8
|
-
myActivitiesApiEp,
|
|
9
|
-
{ action: 'clone', nid, title },
|
|
10
|
-
)
|
|
1
|
+
import httpClient from '@capytale/activity.js/backend/capytale/http';
|
|
2
|
+
|
|
3
|
+
// Definit le endpoint de l'API
|
|
4
|
+
const myActivitiesApiEp = '/web/c-hdls/api/my-activities';
|
|
5
|
+
|
|
6
|
+
export async function apiCloneActivity(nid: number | string, title?: string) {
|
|
7
|
+
return httpClient.postGetJsonAsync<any>(
|
|
8
|
+
myActivitiesApiEp,
|
|
9
|
+
{ action: 'clone', nid, title },
|
|
10
|
+
)
|
|
11
11
|
}
|
package/src/utils/clipboard.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export async function copyToClipboard(
|
|
2
|
-
text: string,
|
|
3
|
-
callback?: (success: boolean, error?: any) => any,
|
|
4
|
-
) {
|
|
5
|
-
try {
|
|
6
|
-
await navigator.clipboard.writeText(text);
|
|
7
|
-
callback?.(true);
|
|
8
|
-
} catch (err) {
|
|
9
|
-
callback?.(false, err);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
1
|
+
export async function copyToClipboard(
|
|
2
|
+
text: string,
|
|
3
|
+
callback?: (success: boolean, error?: any) => any,
|
|
4
|
+
) {
|
|
5
|
+
try {
|
|
6
|
+
await navigator.clipboard.writeText(text);
|
|
7
|
+
callback?.(true);
|
|
8
|
+
} catch (err) {
|
|
9
|
+
callback?.(false, err);
|
|
10
|
+
}
|
|
11
|
+
}
|
package/src/utils/download.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export function downloadFile(url: string, name?: string) {
|
|
2
|
-
const a = document.createElement("a");
|
|
3
|
-
a.href = url;
|
|
4
|
-
a.download = name || url.split("/").pop() || "download";
|
|
5
|
-
document.body.appendChild(a);
|
|
6
|
-
a.click();
|
|
7
|
-
document.body.removeChild(a);
|
|
1
|
+
export function downloadFile(url: string, name?: string) {
|
|
2
|
+
const a = document.createElement("a");
|
|
3
|
+
a.href = url;
|
|
4
|
+
a.download = name || url.split("/").pop() || "download";
|
|
5
|
+
document.body.appendChild(a);
|
|
6
|
+
a.click();
|
|
7
|
+
document.body.removeChild(a);
|
|
8
8
|
}
|