@elice/material-runbox 1.260825.0-runboxusability.13 → 1.260825.0-runboxusability.15

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.
@@ -27,9 +27,10 @@ var MaterialRunbox = function MaterialRunbox(_a) {
27
27
  _a$locale = _a.locale,
28
28
  locale = _a$locale === void 0 ? 'ko' : _a$locale,
29
29
  showMessenger = _a.showMessenger,
30
+ getRunningRunboxLinkProps = _a.getRunningRunboxLinkProps,
30
31
  eliceMaterialRunboxApiConfiguration = _a.eliceMaterialRunboxApiConfiguration,
31
32
  __intl = _a.__intl,
32
- contentProps = tslib.__rest(_a, ["enableAutoShutdownToggle", "enableUrlShare", "locale", "showMessenger", "eliceMaterialRunboxApiConfiguration", "__intl"]);
33
+ contentProps = tslib.__rest(_a, ["enableAutoShutdownToggle", "enableUrlShare", "locale", "showMessenger", "getRunningRunboxLinkProps", "eliceMaterialRunboxApiConfiguration", "__intl"]);
33
34
  return jsxRuntime.jsx(material.ThemeProvider, {
34
35
  theme: theme.runboxDarkTheme,
35
36
  children: jsxRuntime.jsx(intl.RawEliceIntlProvider, {
@@ -39,6 +40,7 @@ var MaterialRunbox = function MaterialRunbox(_a) {
39
40
  enableUrlShare: enableUrlShare,
40
41
  locale: locale,
41
42
  showMessenger: showMessenger,
43
+ getRunningRunboxLinkProps: getRunningRunboxLinkProps,
42
44
  children: jsxRuntime.jsx(MaterialRunboxApiContext.default, {
43
45
  eliceMaterialRunboxApiConfiguration: eliceMaterialRunboxApiConfiguration,
44
46
  children: jsxRuntime.jsx(MaterialRunboxContent.default, Object.assign({}, contentProps))
@@ -26,6 +26,8 @@ export interface MaterialRunboxContentProps extends Pick<MaterialRunboxHeaderPro
26
26
  isTutoring: boolean;
27
27
  /** Used for submit log score tag color. */
28
28
  getAchievementColor?: GetAchievementColor;
29
+ /** Notified when the runbox running (session) ID changes. */
30
+ onRunboxRunningIdChange?: (runboxRunningId: number | null) => void;
29
31
  }
30
32
  declare const MaterialRunboxContent: React.FC<MaterialRunboxContentProps>;
31
33
  export default MaterialRunboxContent;
@@ -52,7 +52,8 @@ var MaterialRunboxContent = function MaterialRunboxContent(_ref) {
52
52
  isTutoring = _ref$isTutoring === void 0 ? false : _ref$isTutoring,
53
53
  _ref$hideTimerPopover = _ref.hideTimerPopover,
54
54
  hideTimerPopover = _ref$hideTimerPopover === void 0 ? false : _ref$hideTimerPopover,
55
- getAchievementColor = _ref.getAchievementColor;
55
+ getAchievementColor = _ref.getAchievementColor,
56
+ onRunboxRunningIdChange = _ref.onRunboxRunningIdChange;
56
57
  var _a;
57
58
  var intl$1 = intl.useRawEliceIntl();
58
59
  var _useMaterialRunboxCon = MaterialRunboxContext.useMaterialRunboxContext(),
@@ -293,6 +294,7 @@ var MaterialRunboxContent = function MaterialRunboxContent(_ref) {
293
294
  });
294
295
  },
295
296
  onRunboxRefetchRequest: refetch,
297
+ onRunboxRunningIdChange: onRunboxRunningIdChange,
296
298
  children: jsxRuntime.jsx(StyledRunboxContainer, {
297
299
  children: jsxRuntime.jsx(muiXSnackbar.SnackbarProvider, {
298
300
  domRoot: snackbarRoot !== null && snackbarRoot !== void 0 ? snackbarRoot : document.body,
@@ -1,4 +1,12 @@
1
1
  import React from 'react';
2
+ import type { RunningRunbox } from '@elice/openapi-client-material-runbox';
3
+ import type { ButtonProps } from '@mui/material';
4
+ type OverlayOwnedButtonProps = 'children' | 'variant' | 'color' | 'startIcon' | 'endIcon' | 'sx' | 'disableRipple' | 'role' | 'tabIndex' | 'ref';
5
+ /**
6
+ * Props for the button reaching the runbox occupying the runtime. Defaults to an `a`;
7
+ * annotate the return type with a `component` of your own to pass its props.
8
+ */
9
+ export type RunningRunboxLinkProps<RootComponent extends React.ElementType = 'a'> = Omit<ButtonProps<RootComponent>, OverlayOwnedButtonProps>;
2
10
  /**
3
11
  * Props to exposed form `<MaterialRunbox />`
4
12
  */
@@ -11,6 +19,8 @@ export interface MaterialRunboxContextValue {
11
19
  locale?: string;
12
20
  /** Show CS messange? */
13
21
  showMessenger?: () => void;
22
+ /** Build the props reaching the occupying runbox. `null` when the host cannot reach it. */
23
+ getRunningRunboxLinkProps?: (runningRunbox: RunningRunbox) => RunningRunboxLinkProps | null;
14
24
  }
15
25
  export interface MaterialRunboxContextProps extends MaterialRunboxContextValue {
16
26
  children?: React.ReactNode;
@@ -4,5 +4,5 @@ export { default as MaterialRunboxControlContextProvider, MaterialRunboxControlC
4
4
  export { default as MaterialRunboxContextProvider, MaterialRunboxContext, useMaterialRunboxContext, } from './MaterialRunboxContext';
5
5
  export type { MaterialRunboxApiContextProps, MaterialRunboxApiContextValue, } from './MaterialRunboxApiContext';
6
6
  export type { MaterialRunboxCommandContextProps, MaterialRunboxCommandContextValue, } from './MaterialRunboxCommandContext';
7
- export type { MaterialRunboxContextProps, MaterialRunboxContextValue, } from './MaterialRunboxContext';
7
+ export type { MaterialRunboxContextProps, MaterialRunboxContextValue, RunningRunboxLinkProps, } from './MaterialRunboxContext';
8
8
  export type { MaterialRunboxControlContextProps, MaterialRunboxControlContextValue, } from './MaterialRunboxControlContext';
@@ -1,2 +1,3 @@
1
1
  export { default as MaterialRunbox } from './MaterialRunbox';
2
2
  export type { MaterialRunboxProps } from './MaterialRunbox';
3
+ export type { RunningRunboxLinkProps } from './contexts';
@@ -16,17 +16,12 @@ var RuntimeChangeMaterialDialog = require('./RuntimeChangeMaterialDialog.js');
16
16
  var terminated = require('../../../assets/terminated.png.js');
17
17
  var en = require('../locales/en.json.js');
18
18
  var ko = require('../locales/ko.json.js');
19
+ var MaterialRunboxContext = require('../contexts/MaterialRunboxContext.js');
19
20
 
20
21
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
21
22
 
22
23
  var React__default = /*#__PURE__*/_interopDefaultCompat(React);
23
24
 
24
- //
25
- //
26
- //
27
- function createLecturePageUrl(args) {
28
- return "/courses/".concat(args.courseId, "/lectures/").concat(args.lectureId, "/lecturepages/").concat(args.lecturePageId);
29
- }
30
25
  //
31
26
  //
32
27
  //
@@ -38,6 +33,8 @@ var RuntimeOverlayConflicted = function RuntimeOverlayConflicted(_ref) {
38
33
  _React$useState2 = _rollupPluginBabelHelpers.slicedToArray(_React$useState, 2),
39
34
  isChangeMaterialDialogOpen = _React$useState2[0],
40
35
  setChangeMaterialDialogOpen = _React$useState2[1];
36
+ var _useMaterialRunboxCon = MaterialRunboxContext.useMaterialRunboxContext(),
37
+ getRunningRunboxLinkProps = _useMaterialRunboxCon.getRunningRunboxLinkProps;
41
38
  var _useQuery = reactQuery.useQuery({
42
39
  queryKey: ['getOrgCourseGet', runningRunbox.courseId],
43
40
  queryFn: function () {
@@ -68,34 +65,49 @@ var RuntimeOverlayConflicted = function RuntimeOverlayConflicted(_ref) {
68
65
  refetchOnWindowFocus: false
69
66
  }),
70
67
  runningCourse = _useQuery.data;
68
+ var runningRunboxLinkProps = React__default.default.useMemo(function () {
69
+ var _a;
70
+ return (_a = getRunningRunboxLinkProps === null || getRunningRunboxLinkProps === void 0 ? void 0 : getRunningRunboxLinkProps(runningRunbox)) !== null && _a !== void 0 ? _a : null;
71
+ }, [getRunningRunboxLinkProps, runningRunbox]);
72
+ /**
73
+ *
74
+ */
71
75
  var renderNavButton = function renderNavButton() {
72
76
  if (!runningCourse) {
73
77
  return null;
74
78
  }
75
- return jsxRuntime.jsx(material.Button, {
79
+ var linkProps = runningRunboxLinkProps ? Object.assign({
80
+ LinkComponent: 'a'
81
+ }, runningRunboxLinkProps) : {
82
+ component: 'div',
83
+ role: 'presentation',
84
+ tabIndex: -1,
85
+ disableRipple: true
86
+ };
87
+ var opensInNewTab = (runningRunboxLinkProps === null || runningRunboxLinkProps === void 0 ? void 0 : runningRunboxLinkProps.target) === '_blank';
88
+ return jsxRuntime.jsx(material.Button, Object.assign({
76
89
  variant: "contained",
77
90
  color: "inherit",
78
91
  startIcon: jsxRuntime.jsx(muiElements.EliceIcon, {
79
92
  icon: proSolidSvgIcons.faLinkSimple,
80
93
  color: "success"
81
94
  }),
82
- endIcon: jsxRuntime.jsx(muiElements.EliceIcon, {
95
+ endIcon: opensInNewTab ? jsxRuntime.jsx(muiElements.EliceIcon, {
83
96
  icon: proSolidSvgIcons.faArrowUpRightFromSquare,
84
97
  color: "inherit"
85
- }),
98
+ }) : null,
86
99
  sx: {
87
100
  width: '32rem',
88
101
  maxWidth: '100%',
89
102
  padding: '1rem',
90
103
  color: 'text.primary',
91
104
  bgcolor: 'grey.100',
105
+ cursor: runningRunboxLinkProps ? 'pointer' : 'default',
92
106
  '&:hover': {
93
- bgcolor: 'grey.200'
107
+ bgcolor: runningRunboxLinkProps ? 'grey.200' : 'grey.100'
94
108
  }
95
- },
96
- LinkComponent: "a",
97
- href: createLecturePageUrl(runningRunbox),
98
- target: "_blank",
109
+ }
110
+ }, linkProps, {
99
111
  children: jsxRuntime.jsxs(material.Stack, {
100
112
  flex: 1,
101
113
  direction: "column",
@@ -108,7 +120,7 @@ var RuntimeOverlayConflicted = function RuntimeOverlayConflicted(_ref) {
108
120
  children: runningRunbox.title
109
121
  })]
110
122
  })
111
- });
123
+ }));
112
124
  };
113
125
  /**
114
126
  *
@@ -23,9 +23,10 @@ var MaterialRunbox = function MaterialRunbox(_a) {
23
23
  _a$locale = _a.locale,
24
24
  locale = _a$locale === void 0 ? 'ko' : _a$locale,
25
25
  showMessenger = _a.showMessenger,
26
+ getRunningRunboxLinkProps = _a.getRunningRunboxLinkProps,
26
27
  eliceMaterialRunboxApiConfiguration = _a.eliceMaterialRunboxApiConfiguration,
27
28
  __intl = _a.__intl,
28
- contentProps = __rest(_a, ["enableAutoShutdownToggle", "enableUrlShare", "locale", "showMessenger", "eliceMaterialRunboxApiConfiguration", "__intl"]);
29
+ contentProps = __rest(_a, ["enableAutoShutdownToggle", "enableUrlShare", "locale", "showMessenger", "getRunningRunboxLinkProps", "eliceMaterialRunboxApiConfiguration", "__intl"]);
29
30
  return jsx(ThemeProvider, {
30
31
  theme: runboxDarkTheme,
31
32
  children: jsx(RawEliceIntlProvider, {
@@ -35,6 +36,7 @@ var MaterialRunbox = function MaterialRunbox(_a) {
35
36
  enableUrlShare: enableUrlShare,
36
37
  locale: locale,
37
38
  showMessenger: showMessenger,
39
+ getRunningRunboxLinkProps: getRunningRunboxLinkProps,
38
40
  children: jsx(MaterialRunboxApiContextProvider, {
39
41
  eliceMaterialRunboxApiConfiguration: eliceMaterialRunboxApiConfiguration,
40
42
  children: jsx(MaterialRunboxContent, Object.assign({}, contentProps))
@@ -26,6 +26,8 @@ export interface MaterialRunboxContentProps extends Pick<MaterialRunboxHeaderPro
26
26
  isTutoring: boolean;
27
27
  /** Used for submit log score tag color. */
28
28
  getAchievementColor?: GetAchievementColor;
29
+ /** Notified when the runbox running (session) ID changes. */
30
+ onRunboxRunningIdChange?: (runboxRunningId: number | null) => void;
29
31
  }
30
32
  declare const MaterialRunboxContent: React.FC<MaterialRunboxContentProps>;
31
33
  export default MaterialRunboxContent;
@@ -44,7 +44,8 @@ var MaterialRunboxContent = function MaterialRunboxContent(_ref) {
44
44
  isTutoring = _ref$isTutoring === void 0 ? false : _ref$isTutoring,
45
45
  _ref$hideTimerPopover = _ref.hideTimerPopover,
46
46
  hideTimerPopover = _ref$hideTimerPopover === void 0 ? false : _ref$hideTimerPopover,
47
- getAchievementColor = _ref.getAchievementColor;
47
+ getAchievementColor = _ref.getAchievementColor,
48
+ onRunboxRunningIdChange = _ref.onRunboxRunningIdChange;
48
49
  var _a;
49
50
  var intl = useRawEliceIntl();
50
51
  var _useMaterialRunboxCon = useMaterialRunboxContext(),
@@ -285,6 +286,7 @@ var MaterialRunboxContent = function MaterialRunboxContent(_ref) {
285
286
  });
286
287
  },
287
288
  onRunboxRefetchRequest: refetch,
289
+ onRunboxRunningIdChange: onRunboxRunningIdChange,
288
290
  children: jsx(StyledRunboxContainer, {
289
291
  children: jsx(SnackbarProvider, {
290
292
  domRoot: snackbarRoot !== null && snackbarRoot !== void 0 ? snackbarRoot : document.body,
@@ -1,4 +1,12 @@
1
1
  import React from 'react';
2
+ import type { RunningRunbox } from '@elice/openapi-client-material-runbox';
3
+ import type { ButtonProps } from '@mui/material';
4
+ type OverlayOwnedButtonProps = 'children' | 'variant' | 'color' | 'startIcon' | 'endIcon' | 'sx' | 'disableRipple' | 'role' | 'tabIndex' | 'ref';
5
+ /**
6
+ * Props for the button reaching the runbox occupying the runtime. Defaults to an `a`;
7
+ * annotate the return type with a `component` of your own to pass its props.
8
+ */
9
+ export type RunningRunboxLinkProps<RootComponent extends React.ElementType = 'a'> = Omit<ButtonProps<RootComponent>, OverlayOwnedButtonProps>;
2
10
  /**
3
11
  * Props to exposed form `<MaterialRunbox />`
4
12
  */
@@ -11,6 +19,8 @@ export interface MaterialRunboxContextValue {
11
19
  locale?: string;
12
20
  /** Show CS messange? */
13
21
  showMessenger?: () => void;
22
+ /** Build the props reaching the occupying runbox. `null` when the host cannot reach it. */
23
+ getRunningRunboxLinkProps?: (runningRunbox: RunningRunbox) => RunningRunboxLinkProps | null;
14
24
  }
15
25
  export interface MaterialRunboxContextProps extends MaterialRunboxContextValue {
16
26
  children?: React.ReactNode;
@@ -4,5 +4,5 @@ export { default as MaterialRunboxControlContextProvider, MaterialRunboxControlC
4
4
  export { default as MaterialRunboxContextProvider, MaterialRunboxContext, useMaterialRunboxContext, } from './MaterialRunboxContext';
5
5
  export type { MaterialRunboxApiContextProps, MaterialRunboxApiContextValue, } from './MaterialRunboxApiContext';
6
6
  export type { MaterialRunboxCommandContextProps, MaterialRunboxCommandContextValue, } from './MaterialRunboxCommandContext';
7
- export type { MaterialRunboxContextProps, MaterialRunboxContextValue, } from './MaterialRunboxContext';
7
+ export type { MaterialRunboxContextProps, MaterialRunboxContextValue, RunningRunboxLinkProps, } from './MaterialRunboxContext';
8
8
  export type { MaterialRunboxControlContextProps, MaterialRunboxControlContextValue, } from './MaterialRunboxControlContext';
@@ -1,2 +1,3 @@
1
1
  export { default as MaterialRunbox } from './MaterialRunbox';
2
2
  export type { MaterialRunboxProps } from './MaterialRunbox';
3
+ export type { RunningRunboxLinkProps } from './contexts';
@@ -12,13 +12,8 @@ import RuntimeChangeMaterialDialog from './RuntimeChangeMaterialDialog.js';
12
12
  import img from '../../../assets/terminated.png.js';
13
13
  import messageEn from '../locales/en.json.js';
14
14
  import messageKo from '../locales/ko.json.js';
15
+ import { useMaterialRunboxContext } from '../contexts/MaterialRunboxContext.js';
15
16
 
16
- //
17
- //
18
- //
19
- function createLecturePageUrl(args) {
20
- return "/courses/".concat(args.courseId, "/lectures/").concat(args.lectureId, "/lecturepages/").concat(args.lecturePageId);
21
- }
22
17
  //
23
18
  //
24
19
  //
@@ -30,6 +25,8 @@ var RuntimeOverlayConflicted = function RuntimeOverlayConflicted(_ref) {
30
25
  _React$useState2 = _slicedToArray(_React$useState, 2),
31
26
  isChangeMaterialDialogOpen = _React$useState2[0],
32
27
  setChangeMaterialDialogOpen = _React$useState2[1];
28
+ var _useMaterialRunboxCon = useMaterialRunboxContext(),
29
+ getRunningRunboxLinkProps = _useMaterialRunboxCon.getRunningRunboxLinkProps;
33
30
  var _useQuery = useQuery({
34
31
  queryKey: ['getOrgCourseGet', runningRunbox.courseId],
35
32
  queryFn: function () {
@@ -60,34 +57,49 @@ var RuntimeOverlayConflicted = function RuntimeOverlayConflicted(_ref) {
60
57
  refetchOnWindowFocus: false
61
58
  }),
62
59
  runningCourse = _useQuery.data;
60
+ var runningRunboxLinkProps = React.useMemo(function () {
61
+ var _a;
62
+ return (_a = getRunningRunboxLinkProps === null || getRunningRunboxLinkProps === void 0 ? void 0 : getRunningRunboxLinkProps(runningRunbox)) !== null && _a !== void 0 ? _a : null;
63
+ }, [getRunningRunboxLinkProps, runningRunbox]);
64
+ /**
65
+ *
66
+ */
63
67
  var renderNavButton = function renderNavButton() {
64
68
  if (!runningCourse) {
65
69
  return null;
66
70
  }
67
- return jsx(Button, {
71
+ var linkProps = runningRunboxLinkProps ? Object.assign({
72
+ LinkComponent: 'a'
73
+ }, runningRunboxLinkProps) : {
74
+ component: 'div',
75
+ role: 'presentation',
76
+ tabIndex: -1,
77
+ disableRipple: true
78
+ };
79
+ var opensInNewTab = (runningRunboxLinkProps === null || runningRunboxLinkProps === void 0 ? void 0 : runningRunboxLinkProps.target) === '_blank';
80
+ return jsx(Button, Object.assign({
68
81
  variant: "contained",
69
82
  color: "inherit",
70
83
  startIcon: jsx(EliceIcon, {
71
84
  icon: faLinkSimple,
72
85
  color: "success"
73
86
  }),
74
- endIcon: jsx(EliceIcon, {
87
+ endIcon: opensInNewTab ? jsx(EliceIcon, {
75
88
  icon: faArrowUpRightFromSquare,
76
89
  color: "inherit"
77
- }),
90
+ }) : null,
78
91
  sx: {
79
92
  width: '32rem',
80
93
  maxWidth: '100%',
81
94
  padding: '1rem',
82
95
  color: 'text.primary',
83
96
  bgcolor: 'grey.100',
97
+ cursor: runningRunboxLinkProps ? 'pointer' : 'default',
84
98
  '&:hover': {
85
- bgcolor: 'grey.200'
99
+ bgcolor: runningRunboxLinkProps ? 'grey.200' : 'grey.100'
86
100
  }
87
- },
88
- LinkComponent: "a",
89
- href: createLecturePageUrl(runningRunbox),
90
- target: "_blank",
101
+ }
102
+ }, linkProps, {
91
103
  children: jsxs(Stack, {
92
104
  flex: 1,
93
105
  direction: "column",
@@ -100,7 +112,7 @@ var RuntimeOverlayConflicted = function RuntimeOverlayConflicted(_ref) {
100
112
  children: runningRunbox.title
101
113
  })]
102
114
  })
103
- });
115
+ }));
104
116
  };
105
117
  /**
106
118
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elice/material-runbox",
3
- "version": "1.260825.0-runboxusability.13",
3
+ "version": "1.260825.0-runboxusability.15",
4
4
  "description": "User view and editing components of Elice material runbox",
5
5
  "repository": {
6
6
  "type": "git",
@@ -37,8 +37,8 @@
37
37
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
38
38
  "react-transition-group": "^4.4.0",
39
39
  "react-use": "^17.0.0",
40
- "@elice/material-shared-types": "1.260825.0-runboxusability.13",
41
- "@elice/material-shared-utils": "1.260825.0-runboxusability.13"
40
+ "@elice/material-shared-types": "1.260825.0-runboxusability.15",
41
+ "@elice/material-shared-utils": "1.260825.0-runboxusability.15"
42
42
  },
43
43
  "dependencies": {
44
44
  "classnames": "^2.2.0",
@@ -56,7 +56,7 @@
56
56
  "@elice/mui-x-snackbar": "^5.250108.0-controllabel.0",
57
57
  "@elice/openapi-client-material-runbox": "1.260826.0-improverunboxusability.1",
58
58
  "@elice/rollup-config": "^1.260406.0",
59
- "@elice/runbox-client": "1.260904.0-runboxiframeerror.2",
59
+ "@elice/runbox-client": "1.260904.0-runboxiframeerror.3",
60
60
  "@elice/types": "1.260608.0",
61
61
  "@emotion/react": "^11.10.0",
62
62
  "@emotion/styled": "^11.10.0",
@@ -77,8 +77,8 @@
77
77
  "react-use": "^17.2.4",
78
78
  "rollup": "^4.0.0",
79
79
  "typescript": "~5.9.3",
80
- "@elice/material-shared-types": "1.260825.0-runboxusability.13",
81
- "@elice/material-shared-utils": "1.260825.0-runboxusability.13"
80
+ "@elice/material-shared-types": "1.260825.0-runboxusability.15",
81
+ "@elice/material-shared-utils": "1.260825.0-runboxusability.15"
82
82
  },
83
83
  "scripts": {
84
84
  "start": "run-s watch",