@elice/material-runbox 1.260820.1 → 1.260825.0-runboxusability.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/cjs/components/material-runbox/MaterialRunboxContent.js +1 -2
  2. package/cjs/components/material-runbox/MaterialRunboxHeader.js +12 -29
  3. package/cjs/components/material-runbox/actions/MaterialRunboxActionMenu.d.ts +3 -1
  4. package/cjs/components/material-runbox/actions/MaterialRunboxActionMenu.js +17 -1
  5. package/cjs/components/material-runbox/hooks/index.d.ts +2 -0
  6. package/cjs/components/material-runbox/hooks/index.js +6 -0
  7. package/cjs/components/material-runbox/hooks/useOnlineState.d.ts +12 -0
  8. package/cjs/components/material-runbox/hooks/useOnlineState.js +50 -0
  9. package/cjs/components/material-runbox/hooks/useRunboxSessionEndWarning.d.ts +18 -0
  10. package/cjs/components/material-runbox/hooks/useRunboxSessionEndWarning.js +67 -0
  11. package/cjs/components/material-runbox/locales/en.json.js +1 -1
  12. package/cjs/components/material-runbox/locales/ja.json.js +1 -1
  13. package/cjs/components/material-runbox/locales/ko.json.js +1 -1
  14. package/cjs/components/material-runbox/locales/th.json.js +1 -1
  15. package/cjs/components/material-runbox/status/MaterialRunboxStatusButton.d.ts +18 -0
  16. package/cjs/components/material-runbox/status/MaterialRunboxStatusButton.js +88 -0
  17. package/cjs/components/material-runbox/status/MaterialRunboxStatusConnectionItem.d.ts +11 -0
  18. package/cjs/components/material-runbox/status/MaterialRunboxStatusConnectionItem.js +32 -0
  19. package/cjs/components/material-runbox/status/MaterialRunboxStatusPopover.d.ts +17 -0
  20. package/cjs/components/material-runbox/status/MaterialRunboxStatusPopover.js +133 -0
  21. package/cjs/components/material-runbox/status/MaterialRunboxStatusResourceItem.d.ts +11 -0
  22. package/cjs/components/material-runbox/status/MaterialRunboxStatusResourceItem.js +42 -0
  23. package/cjs/components/material-runbox/status/index.d.ts +4 -0
  24. package/cjs/components/material-runbox/status/index.js +9 -0
  25. package/cjs/components/material-runbox/timer/MaterialRunboxQuotaAlmostEndDialog.d.ts +11 -0
  26. package/cjs/components/material-runbox/timer/MaterialRunboxQuotaAlmostEndDialog.js +116 -0
  27. package/cjs/components/material-runbox/timer/MaterialRunboxQuotaAmount.d.ts +13 -0
  28. package/cjs/components/material-runbox/timer/MaterialRunboxQuotaAmount.js +56 -0
  29. package/cjs/components/material-runbox/timer/MaterialRunboxQuotaPerSessionAlmostEndDialog.d.ts +12 -0
  30. package/cjs/components/material-runbox/timer/MaterialRunboxQuotaPerSessionAlmostEndDialog.js +117 -0
  31. package/cjs/components/material-runbox/timer/MaterialRunboxQuotaTimePart.d.ts +15 -0
  32. package/cjs/components/material-runbox/timer/MaterialRunboxQuotaTimePart.js +50 -0
  33. package/cjs/components/material-runbox/timer/MaterialRunboxTimer.d.ts +6 -0
  34. package/cjs/components/material-runbox/timer/MaterialRunboxTimer.js +20 -16
  35. package/cjs/components/material-runbox/timer/MaterialRunboxTimerDetailPopover.js +19 -81
  36. package/es/components/material-runbox/MaterialRunboxContent.js +1 -2
  37. package/es/components/material-runbox/MaterialRunboxHeader.js +13 -30
  38. package/es/components/material-runbox/actions/MaterialRunboxActionMenu.d.ts +3 -1
  39. package/es/components/material-runbox/actions/MaterialRunboxActionMenu.js +19 -3
  40. package/es/components/material-runbox/hooks/index.d.ts +2 -0
  41. package/es/components/material-runbox/hooks/index.js +2 -0
  42. package/es/components/material-runbox/hooks/useOnlineState.d.ts +12 -0
  43. package/es/components/material-runbox/hooks/useOnlineState.js +44 -0
  44. package/es/components/material-runbox/hooks/useRunboxSessionEndWarning.d.ts +18 -0
  45. package/es/components/material-runbox/hooks/useRunboxSessionEndWarning.js +63 -0
  46. package/es/components/material-runbox/locales/en.json.js +1 -1
  47. package/es/components/material-runbox/locales/ja.json.js +1 -1
  48. package/es/components/material-runbox/locales/ko.json.js +1 -1
  49. package/es/components/material-runbox/locales/th.json.js +1 -1
  50. package/es/components/material-runbox/status/MaterialRunboxStatusButton.d.ts +18 -0
  51. package/es/components/material-runbox/status/MaterialRunboxStatusButton.js +80 -0
  52. package/es/components/material-runbox/status/MaterialRunboxStatusConnectionItem.d.ts +11 -0
  53. package/es/components/material-runbox/status/MaterialRunboxStatusConnectionItem.js +28 -0
  54. package/es/components/material-runbox/status/MaterialRunboxStatusPopover.d.ts +17 -0
  55. package/es/components/material-runbox/status/MaterialRunboxStatusPopover.js +129 -0
  56. package/es/components/material-runbox/status/MaterialRunboxStatusResourceItem.d.ts +11 -0
  57. package/es/components/material-runbox/status/MaterialRunboxStatusResourceItem.js +38 -0
  58. package/es/components/material-runbox/status/index.d.ts +4 -0
  59. package/es/components/material-runbox/status/index.js +2 -0
  60. package/es/components/material-runbox/timer/MaterialRunboxQuotaAlmostEndDialog.d.ts +11 -0
  61. package/es/components/material-runbox/timer/MaterialRunboxQuotaAlmostEndDialog.js +112 -0
  62. package/es/components/material-runbox/timer/MaterialRunboxQuotaAmount.d.ts +13 -0
  63. package/es/components/material-runbox/timer/MaterialRunboxQuotaAmount.js +52 -0
  64. package/es/components/material-runbox/timer/MaterialRunboxQuotaPerSessionAlmostEndDialog.d.ts +12 -0
  65. package/es/components/material-runbox/timer/MaterialRunboxQuotaPerSessionAlmostEndDialog.js +113 -0
  66. package/es/components/material-runbox/timer/MaterialRunboxQuotaTimePart.d.ts +15 -0
  67. package/es/components/material-runbox/timer/MaterialRunboxQuotaTimePart.js +46 -0
  68. package/es/components/material-runbox/timer/MaterialRunboxTimer.d.ts +6 -0
  69. package/es/components/material-runbox/timer/MaterialRunboxTimer.js +19 -15
  70. package/es/components/material-runbox/timer/MaterialRunboxTimerDetailPopover.js +15 -77
  71. package/package.json +8 -8
  72. package/cjs/assets/runbox_logo.png.js +0 -7
  73. package/cjs/components/material-runbox/MaterialRunboxFooter.d.ts +0 -4
  74. package/cjs/components/material-runbox/MaterialRunboxFooter.js +0 -64
  75. package/cjs/components/material-runbox/timer/MaterialRunboxAlmostEndSnackbars.d.ts +0 -6
  76. package/cjs/components/material-runbox/timer/MaterialRunboxAlmostEndSnackbars.js +0 -90
  77. package/es/assets/runbox_logo.png.js +0 -3
  78. package/es/components/material-runbox/MaterialRunboxFooter.d.ts +0 -4
  79. package/es/components/material-runbox/MaterialRunboxFooter.js +0 -56
  80. package/es/components/material-runbox/timer/MaterialRunboxAlmostEndSnackbars.d.ts +0 -6
  81. package/es/components/material-runbox/timer/MaterialRunboxAlmostEndSnackbars.js +0 -86
@@ -0,0 +1,129 @@
1
+ import { __rest } from 'tslib';
2
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
+ import { useRawEliceIntl } from '@elice/intl';
4
+ import { EliceIcon } from '@elice/mui-elements';
5
+ import { useEliceRunboxRunning, useEliceRunboxContainerStats } from '@elice/runbox-client';
6
+ import { faWifiSlash, faWifi, faLinkSimple, faLinkSimpleSlash, faMicrochip, faMemory, faArrowUpRight, faArrowDownLeft, faDiscDrive } from '@fortawesome/pro-solid-svg-icons';
7
+ import { Popover, Stack, Divider } from '@mui/material';
8
+ import MaterialRunboxStatusConnectionItem from './MaterialRunboxStatusConnectionItem.js';
9
+ import MaterialRunboxStatusResourceItem from './MaterialRunboxStatusResourceItem.js';
10
+ import { useOnlineState } from '../hooks/useOnlineState.js';
11
+
12
+ //
13
+ //
14
+ //
15
+ var POPOVER_WIDTH = '15.25rem'; // 244px
16
+ //
17
+ //
18
+ //
19
+ var MaterialRunboxStatusPopover = function MaterialRunboxStatusPopover(_a) {
20
+ var open = _a.open,
21
+ onClose = _a.onClose,
22
+ bottomAction = _a.bottomAction,
23
+ props = __rest(_a, ["open", "onClose", "bottomAction"]);
24
+ var intl = useRawEliceIntl();
25
+ var _useEliceRunboxRunnin = useEliceRunboxRunning(),
26
+ status = _useEliceRunboxRunnin.status;
27
+ var online = useOnlineState();
28
+ var contStats = useEliceRunboxContainerStats();
29
+ var stats = contStats ? contStats[contStats.length - 1] : null;
30
+ var isRunboxRunning = status === 'running';
31
+ //
32
+ //
33
+ //
34
+ return jsx(Popover, Object.assign({
35
+ open: open,
36
+ onClose: onClose
37
+ }, props, {
38
+ children: jsxs(Stack, {
39
+ direction: "column",
40
+ padding: "0.75rem 0",
41
+ width: POPOVER_WIDTH,
42
+ bgcolor: "background.paper",
43
+ children: [jsxs(Stack, {
44
+ direction: "column",
45
+ children: [jsx(MaterialRunboxStatusConnectionItem, {
46
+ icon: jsx(EliceIcon, {
47
+ icon: online === false ? faWifiSlash : faWifi
48
+ }),
49
+ label: intl.formatMessage({
50
+ id: 'runbox.status.network'
51
+ }),
52
+ // `online` is undefined while unknown — only mark it down when known offline.
53
+ connected: online !== false
54
+ }), jsx(MaterialRunboxStatusConnectionItem, {
55
+ icon: jsx(EliceIcon, {
56
+ icon: isRunboxRunning ? faLinkSimple : faLinkSimpleSlash
57
+ }),
58
+ label: intl.formatMessage({
59
+ id: isRunboxRunning ? 'runbox.status.runtime.connected' : 'runbox.status.runtime.disconnected'
60
+ }),
61
+ connected: isRunboxRunning
62
+ })]
63
+ }), stats ? jsxs(Fragment, {
64
+ children: [jsx(Divider, {
65
+ sx: {
66
+ margin: '0.75rem'
67
+ }
68
+ }), jsxs(Stack, {
69
+ direction: "column",
70
+ children: [jsx(MaterialRunboxStatusResourceItem, {
71
+ icon: jsx(EliceIcon, {
72
+ icon: faMicrochip
73
+ }),
74
+ label: "CPU",
75
+ value: intl.formatNumber(stats.avgCpu, {
76
+ style: 'percent',
77
+ maximumFractionDigits: 2
78
+ })
79
+ }), jsx(MaterialRunboxStatusResourceItem, {
80
+ icon: jsx(EliceIcon, {
81
+ icon: faMemory
82
+ }),
83
+ label: "Memory",
84
+ value: "".concat(intl.formatDataSize(stats.memCurrent, {
85
+ unitSystem: 'iec',
86
+ maximumFractionDigits: 2
87
+ }), " / ").concat(intl.formatDataSize(stats.memTotal, {
88
+ unitSystem: 'iec',
89
+ maximumFractionDigits: 2
90
+ }))
91
+ }), jsx(MaterialRunboxStatusResourceItem, {
92
+ icon: jsx(EliceIcon, {
93
+ icon: faArrowUpRight
94
+ }),
95
+ label: "UP",
96
+ value: "".concat(intl.formatDataSize(stats.netOutPsec, {
97
+ unitSystem: 'iec'
98
+ }), "/s")
99
+ }), jsx(MaterialRunboxStatusResourceItem, {
100
+ icon: jsx(EliceIcon, {
101
+ icon: faArrowDownLeft
102
+ }),
103
+ label: "DOWN",
104
+ value: "".concat(intl.formatDataSize(stats.netInPsec, {
105
+ unitSystem: 'iec'
106
+ }), "/s")
107
+ }), jsx(MaterialRunboxStatusResourceItem, {
108
+ icon: jsx(EliceIcon, {
109
+ icon: faDiscDrive
110
+ }),
111
+ label: "DISK",
112
+ value: "".concat(intl.formatDataSize(stats.diskCurrent, {
113
+ unitSystem: 'iec',
114
+ maximumFractionDigits: 2
115
+ }), " / ").concat(intl.formatDataSize(stats.diskTotal, {
116
+ unitSystem: 'iec',
117
+ maximumFractionDigits: 2
118
+ }))
119
+ })]
120
+ })]
121
+ }) : null, bottomAction ? jsx(Stack, {
122
+ padding: "0.75rem 0.75rem 0",
123
+ children: bottomAction
124
+ }) : null]
125
+ })
126
+ }));
127
+ };
128
+
129
+ export { MaterialRunboxStatusPopover as default };
@@ -0,0 +1,11 @@
1
+ import type React from 'react';
2
+ export interface MaterialRunboxStatusResourceItemProps {
3
+ /** Leading icon element. */
4
+ icon: React.ReactNode;
5
+ /** Resource label, e.g. `CPU`. */
6
+ label: React.ReactNode;
7
+ /** Formatted value, e.g. `438.33 MiB / 4 GiB`. */
8
+ value: React.ReactNode;
9
+ }
10
+ declare const MaterialRunboxStatusResourceItem: React.FC<MaterialRunboxStatusResourceItemProps>;
11
+ export default MaterialRunboxStatusResourceItem;
@@ -0,0 +1,38 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { Stack, Typography } from '@mui/material';
3
+
4
+ //
5
+ //
6
+ //
7
+ var MaterialRunboxStatusResourceItem = function MaterialRunboxStatusResourceItem(_ref) {
8
+ var icon = _ref.icon,
9
+ label = _ref.label,
10
+ value = _ref.value;
11
+ return jsxs(Stack, {
12
+ direction: "row",
13
+ alignItems: "flex-start",
14
+ gap: "0.75rem",
15
+ padding: "0.375rem 0.75rem",
16
+ children: [jsx(Typography, {
17
+ component: "span",
18
+ display: "inline-flex",
19
+ color: "text.secondary",
20
+ paddingTop: "0.5rem",
21
+ children: icon
22
+ }), jsxs(Stack, {
23
+ direction: "column",
24
+ children: [jsx(Typography, {
25
+ variant: "body2",
26
+ fontWeight: "bold",
27
+ children: label
28
+ }), jsx(Typography, {
29
+ variant: "caption",
30
+ color: "text.secondary",
31
+ fontFamily: "'JetBrains Mono', monospace",
32
+ children: value
33
+ })]
34
+ })]
35
+ });
36
+ };
37
+
38
+ export { MaterialRunboxStatusResourceItem as default };
@@ -0,0 +1,4 @@
1
+ export { default as MaterialRunboxStatusButton } from './MaterialRunboxStatusButton';
2
+ export { default as MaterialRunboxStatusPopover } from './MaterialRunboxStatusPopover';
3
+ export type { MaterialRunboxStatusButtonProps } from './MaterialRunboxStatusButton';
4
+ export type { MaterialRunboxStatusPopoverProps } from './MaterialRunboxStatusPopover';
@@ -0,0 +1,2 @@
1
+ export { default as MaterialRunboxStatusButton } from './MaterialRunboxStatusButton.js';
2
+ export { default as MaterialRunboxStatusPopover } from './MaterialRunboxStatusPopover.js';
@@ -0,0 +1,11 @@
1
+ interface MaterialRunboxQuotaAlmostEndDialogProps {
2
+ open: boolean;
3
+ onClose: () => void;
4
+ }
5
+ /**
6
+ * Warns the learner that the *total* available time is about to run out.
7
+ *
8
+ * Once it does, the practice ends for good — there is no reconnecting.
9
+ */
10
+ declare const MaterialRunboxQuotaAlmostEndDialog: React.FC<MaterialRunboxQuotaAlmostEndDialogProps>;
11
+ export default MaterialRunboxQuotaAlmostEndDialog;
@@ -0,0 +1,112 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { useRawEliceIntl } from '@elice/intl';
3
+ import { useEliceRunboxQuota } from '@elice/runbox-client';
4
+ import { Dialog, DialogTitle, DialogContent, Stack, Card, Typography, Divider, DialogActions, Button } from '@mui/material';
5
+ import { QUOTA_ALMOST_END_MINUTES, QUOTA_PER_SESSION_ALMOST_END_MINUTES } from '../hooks/useRunboxSessionEndWarning.js';
6
+ import MaterialRunboxQuotaAmount from './MaterialRunboxQuotaAmount.js';
7
+
8
+ //
9
+ //
10
+ //
11
+ /**
12
+ * Warns the learner that the *total* available time is about to run out.
13
+ *
14
+ * Once it does, the practice ends for good — there is no reconnecting.
15
+ */
16
+ var MaterialRunboxQuotaAlmostEndDialog = function MaterialRunboxQuotaAlmostEndDialog(_ref) {
17
+ var open = _ref.open,
18
+ onClose = _ref.onClose;
19
+ var intl = useRawEliceIntl();
20
+ var _useEliceRunboxQuota = useEliceRunboxQuota(),
21
+ quotaInfo = _useEliceRunboxQuota.quotaInfo,
22
+ quotaPerSessionInfo = _useEliceRunboxQuota.quotaPerSessionInfo;
23
+ if (quotaInfo.isUnlimited) {
24
+ return null;
25
+ }
26
+ var isQuotaAlmostEnd = quotaInfo.remainingQuota <= QUOTA_ALMOST_END_MINUTES;
27
+ var isQuotaPerSessionAlmostEnd = !quotaPerSessionInfo.isUnlimited && quotaPerSessionInfo.remainingQuota <= QUOTA_PER_SESSION_ALMOST_END_MINUTES;
28
+ return jsxs(Dialog, {
29
+ fullWidth: true,
30
+ maxWidth: "xs",
31
+ open: open,
32
+ onClose: onClose,
33
+ children: [jsx(DialogTitle, {
34
+ children: intl.formatMessage({
35
+ id: 'runbox.timer.almost_end.dialog.quota.title'
36
+ }, {
37
+ time: intl.formatNumber(QUOTA_ALMOST_END_MINUTES, {
38
+ style: 'unit',
39
+ unit: 'minute',
40
+ unitDisplay: 'short'
41
+ })
42
+ })
43
+ }), jsx(DialogContent, {
44
+ children: jsxs(Stack, {
45
+ direction: "column",
46
+ gap: "1.5rem",
47
+ children: [jsxs(Card, {
48
+ sx: {
49
+ bgcolor: 'background.neutral'
50
+ },
51
+ children: [jsxs(Stack, {
52
+ direction: "column",
53
+ gap: "0.5rem",
54
+ padding: "1rem",
55
+ bgcolor: isQuotaAlmostEnd ? 'warning.opacity03' : undefined,
56
+ children: [jsx(Typography, {
57
+ variant: "body2",
58
+ fontWeight: "bold",
59
+ children: intl.formatMessage({
60
+ id: 'runbox.timer.popover.quota.title'
61
+ })
62
+ }), jsx(MaterialRunboxQuotaAmount, {
63
+ remainingQuota: quotaInfo.remainingQuota,
64
+ quota: quotaInfo.quota,
65
+ color: isQuotaAlmostEnd ? 'warning.main' : 'success.main'
66
+ })]
67
+ }), jsx(Divider, {}), jsxs(Stack, {
68
+ direction: "column",
69
+ gap: "0.5rem",
70
+ padding: "1rem",
71
+ bgcolor: isQuotaPerSessionAlmostEnd ? 'warning.opacity03' : undefined,
72
+ children: [jsx(Typography, {
73
+ variant: "body2",
74
+ fontWeight: "bold",
75
+ children: intl.formatMessage({
76
+ id: 'runbox.timer.popover.quota_per_session.title'
77
+ })
78
+ }), quotaPerSessionInfo.isUnlimited ? jsx(Typography, {
79
+ component: "span",
80
+ variant: "h5",
81
+ fontWeight: "extraBold",
82
+ children: intl.formatMessage({
83
+ id: 'runbox.timer.unlimited'
84
+ })
85
+ }) : jsx(MaterialRunboxQuotaAmount, {
86
+ remainingQuota: quotaPerSessionInfo.remainingQuota,
87
+ quota: quotaPerSessionInfo.quota,
88
+ color: isQuotaPerSessionAlmostEnd ? 'warning.main' : 'success.main'
89
+ })]
90
+ })]
91
+ }), jsx(Typography, {
92
+ variant: "body2",
93
+ whiteSpace: "pre-line",
94
+ children: intl.formatMessage({
95
+ id: 'runbox.timer.almost_end.dialog.quota.description'
96
+ })
97
+ })]
98
+ })
99
+ }), jsx(DialogActions, {
100
+ children: jsx(Button, {
101
+ variant: "contained",
102
+ color: "inherit",
103
+ onClick: onClose,
104
+ children: intl.formatMessage({
105
+ id: 'runbox.timer.almost_end.dialog.confirm'
106
+ })
107
+ })
108
+ })]
109
+ });
110
+ };
111
+
112
+ export { MaterialRunboxQuotaAlmostEndDialog as default };
@@ -0,0 +1,13 @@
1
+ export interface MaterialRunboxQuotaAmountProps {
2
+ /** Remaining time, in minutes. */
3
+ remainingQuota: number;
4
+ /** Total granted time, in minutes. */
5
+ quota: number;
6
+ /** Color of the remaining time. */
7
+ color?: string;
8
+ }
9
+ /**
10
+ * Renders `<remaining> / <total>`, e.g. `4시간 11분 / 5시간`.
11
+ */
12
+ declare const MaterialRunboxQuotaAmount: React.FC<MaterialRunboxQuotaAmountProps>;
13
+ export default MaterialRunboxQuotaAmount;
@@ -0,0 +1,52 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { useRawEliceIntl } from '@elice/intl';
3
+ import { Typography, Stack } from '@mui/material';
4
+ import MaterialRunboxQuotaTimePart from './MaterialRunboxQuotaTimePart.js';
5
+ import { getTimeParts } from '../../../utils/time.js';
6
+
7
+ //
8
+ //
9
+ //
10
+ /**
11
+ * Renders `<remaining> / <total>`, e.g. `4시간 11분 / 5시간`.
12
+ */
13
+ var MaterialRunboxQuotaAmount = function MaterialRunboxQuotaAmount(_ref) {
14
+ var remainingQuota = _ref.remainingQuota,
15
+ quota = _ref.quota,
16
+ color = _ref.color;
17
+ var intl = useRawEliceIntl();
18
+ var _getTimeParts = getTimeParts(remainingQuota * 60),
19
+ remainingHours = _getTimeParts.hours,
20
+ remainingMinutes = _getTimeParts.minutes;
21
+ var _getTimeParts2 = getTimeParts(quota * 60),
22
+ totalHours = _getTimeParts2.hours,
23
+ totalMinutes = _getTimeParts2.minutes;
24
+ return jsxs(Typography, {
25
+ variant: "body2",
26
+ children: [jsxs(Stack, {
27
+ component: "span",
28
+ display: "inline-flex",
29
+ direction: "row",
30
+ gap: "0.25rem",
31
+ children: [jsx(MaterialRunboxQuotaTimePart, {
32
+ value: remainingHours,
33
+ unit: "hour",
34
+ color: color
35
+ }), jsx(MaterialRunboxQuotaTimePart, {
36
+ value: remainingMinutes,
37
+ unit: "minute",
38
+ color: color
39
+ })]
40
+ }), " / ", [totalHours > 0 ? intl.formatNumber(totalHours, {
41
+ style: 'unit',
42
+ unit: 'hour',
43
+ unitDisplay: 'short'
44
+ }) : null, totalMinutes > 0 ? intl.formatNumber(totalMinutes, {
45
+ style: 'unit',
46
+ unit: 'minute',
47
+ unitDisplay: 'short'
48
+ }) : null].filter(Boolean).join(' ')]
49
+ });
50
+ };
51
+
52
+ export { MaterialRunboxQuotaAmount as default };
@@ -0,0 +1,12 @@
1
+ interface MaterialRunboxQuotaPerSessionAlmostEndDialogProps {
2
+ open: boolean;
3
+ onClose: () => void;
4
+ }
5
+ /**
6
+ * Warns the learner that the time granted to *this connection* is about to run out.
7
+ *
8
+ * Unlike the total quota, the learner can reconnect and keep going as long as total
9
+ * time is left — so this dialog is about saving work, not about the practice ending.
10
+ */
11
+ declare const MaterialRunboxQuotaPerSessionAlmostEndDialog: React.FC<MaterialRunboxQuotaPerSessionAlmostEndDialogProps>;
12
+ export default MaterialRunboxQuotaPerSessionAlmostEndDialog;
@@ -0,0 +1,113 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { useRawEliceIntl } from '@elice/intl';
3
+ import { useEliceRunboxQuota } from '@elice/runbox-client';
4
+ import { Dialog, DialogTitle, DialogContent, Stack, Card, Typography, Divider, DialogActions, Button } from '@mui/material';
5
+ import { QUOTA_ALMOST_END_MINUTES, QUOTA_PER_SESSION_ALMOST_END_MINUTES } from '../hooks/useRunboxSessionEndWarning.js';
6
+ import MaterialRunboxQuotaAmount from './MaterialRunboxQuotaAmount.js';
7
+
8
+ //
9
+ //
10
+ //
11
+ /**
12
+ * Warns the learner that the time granted to *this connection* is about to run out.
13
+ *
14
+ * Unlike the total quota, the learner can reconnect and keep going as long as total
15
+ * time is left — so this dialog is about saving work, not about the practice ending.
16
+ */
17
+ var MaterialRunboxQuotaPerSessionAlmostEndDialog = function MaterialRunboxQuotaPerSessionAlmostEndDialog(_ref) {
18
+ var open = _ref.open,
19
+ onClose = _ref.onClose;
20
+ var intl = useRawEliceIntl();
21
+ var _useEliceRunboxQuota = useEliceRunboxQuota(),
22
+ quotaInfo = _useEliceRunboxQuota.quotaInfo,
23
+ quotaPerSessionInfo = _useEliceRunboxQuota.quotaPerSessionInfo;
24
+ if (quotaPerSessionInfo.isUnlimited) {
25
+ return null;
26
+ }
27
+ var isQuotaAlmostEnd = !quotaInfo.isUnlimited && quotaInfo.remainingQuota <= QUOTA_ALMOST_END_MINUTES;
28
+ var isQuotaPerSessionAlmostEnd = quotaPerSessionInfo.remainingQuota <= QUOTA_PER_SESSION_ALMOST_END_MINUTES;
29
+ return jsxs(Dialog, {
30
+ fullWidth: true,
31
+ maxWidth: "xs",
32
+ open: open,
33
+ onClose: onClose,
34
+ children: [jsx(DialogTitle, {
35
+ children: intl.formatMessage({
36
+ id: 'runbox.timer.almost_end.dialog.quota_per_session.title'
37
+ }, {
38
+ time: intl.formatNumber(QUOTA_PER_SESSION_ALMOST_END_MINUTES, {
39
+ style: 'unit',
40
+ unit: 'minute',
41
+ unitDisplay: 'short'
42
+ })
43
+ })
44
+ }), jsx(DialogContent, {
45
+ children: jsxs(Stack, {
46
+ direction: "column",
47
+ gap: "1.5rem",
48
+ children: [jsxs(Card, {
49
+ sx: {
50
+ bgcolor: 'background.neutral'
51
+ },
52
+ children: [jsxs(Stack, {
53
+ direction: "column",
54
+ gap: "0.5rem",
55
+ padding: "1rem",
56
+ bgcolor: isQuotaAlmostEnd ? 'warning.opacity03' : undefined,
57
+ children: [jsx(Typography, {
58
+ variant: "body2",
59
+ fontWeight: "bold",
60
+ children: intl.formatMessage({
61
+ id: 'runbox.timer.popover.quota.title'
62
+ })
63
+ }), quotaInfo.isUnlimited ? jsx(Typography, {
64
+ component: "span",
65
+ variant: "h5",
66
+ fontWeight: "extraBold",
67
+ children: intl.formatMessage({
68
+ id: 'runbox.timer.unlimited'
69
+ })
70
+ }) : jsx(MaterialRunboxQuotaAmount, {
71
+ remainingQuota: quotaInfo.remainingQuota,
72
+ quota: quotaInfo.quota,
73
+ color: isQuotaAlmostEnd ? 'warning.main' : 'success.main'
74
+ })]
75
+ }), jsx(Divider, {}), jsxs(Stack, {
76
+ direction: "column",
77
+ gap: "0.5rem",
78
+ padding: "1rem",
79
+ bgcolor: isQuotaPerSessionAlmostEnd ? 'warning.opacity03' : undefined,
80
+ children: [jsx(Typography, {
81
+ variant: "body2",
82
+ fontWeight: "bold",
83
+ children: intl.formatMessage({
84
+ id: 'runbox.timer.popover.quota_per_session.title'
85
+ })
86
+ }), jsx(MaterialRunboxQuotaAmount, {
87
+ remainingQuota: quotaPerSessionInfo.remainingQuota,
88
+ quota: quotaPerSessionInfo.quota,
89
+ color: isQuotaPerSessionAlmostEnd ? 'warning.main' : 'success.main'
90
+ })]
91
+ })]
92
+ }), jsx(Typography, {
93
+ variant: "body2",
94
+ whiteSpace: "pre-line",
95
+ children: intl.formatMessage({
96
+ id: 'runbox.timer.almost_end.dialog.quota_per_session.description'
97
+ })
98
+ })]
99
+ })
100
+ }), jsx(DialogActions, {
101
+ children: jsx(Button, {
102
+ variant: "contained",
103
+ color: "inherit",
104
+ onClick: onClose,
105
+ children: intl.formatMessage({
106
+ id: 'runbox.timer.almost_end.dialog.confirm'
107
+ })
108
+ })
109
+ })]
110
+ });
111
+ };
112
+
113
+ export { MaterialRunboxQuotaPerSessionAlmostEndDialog as default };
@@ -0,0 +1,15 @@
1
+ export interface MaterialRunboxQuotaTimePartProps {
2
+ value: number;
3
+ unit: 'hour' | 'minute';
4
+ color?: string;
5
+ }
6
+ /**
7
+ * A single `4시간` / `11분` part, with the unit rendered smaller than the number.
8
+ *
9
+ * The number and its unit are split with `formatNumberToParts` rather than by hand,
10
+ * because where the unit sits and how it is written differs per locale.
11
+ *
12
+ * Renders nothing when `value` is 0, so `29분` does not come out as `0시간 29분`.
13
+ */
14
+ declare const MaterialRunboxQuotaTimePart: React.FC<MaterialRunboxQuotaTimePartProps>;
15
+ export default MaterialRunboxQuotaTimePart;
@@ -0,0 +1,46 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { useRawEliceIntl } from '@elice/intl';
3
+ import { Typography } from '@mui/material';
4
+
5
+ //
6
+ //
7
+ //
8
+ /**
9
+ * A single `4시간` / `11분` part, with the unit rendered smaller than the number.
10
+ *
11
+ * The number and its unit are split with `formatNumberToParts` rather than by hand,
12
+ * because where the unit sits and how it is written differs per locale.
13
+ *
14
+ * Renders nothing when `value` is 0, so `29분` does not come out as `0시간 29분`.
15
+ */
16
+ var MaterialRunboxQuotaTimePart = function MaterialRunboxQuotaTimePart(_ref) {
17
+ var value = _ref.value,
18
+ unit = _ref.unit,
19
+ color = _ref.color;
20
+ var intl = useRawEliceIntl();
21
+ if (value === 0) {
22
+ return null;
23
+ }
24
+ return jsx(Typography, {
25
+ component: "span",
26
+ variant: "h5",
27
+ fontWeight: "extraBold",
28
+ color: color,
29
+ children: intl.formatNumberToParts(value, {
30
+ style: 'unit',
31
+ unit: unit,
32
+ unitDisplay: 'short'
33
+ }).map(function (part, index) {
34
+ return part.type === 'unit' ? jsx(Typography, {
35
+ component: "span",
36
+ variant: "body2",
37
+ fontWeight: "regular",
38
+ children: part.value
39
+ }, index) : jsx("span", {
40
+ children: part.value
41
+ }, index);
42
+ })
43
+ });
44
+ };
45
+
46
+ export { MaterialRunboxQuotaTimePart as default };
@@ -9,6 +9,12 @@ export interface MaterialRunboxTimerProps {
9
9
  * @default false
10
10
  */
11
11
  hideTimerPopover?: boolean;
12
+ /**
13
+ * Tutoring mode? Session-end warnings are for the learner, not for the tutor
14
+ * looking at their runbox.
15
+ * @default false
16
+ */
17
+ isTutoring?: boolean;
12
18
  }
13
19
  declare const MaterialRunboxTimer: React.FC<MaterialRunboxTimerProps>;
14
20
  export default MaterialRunboxTimer;
@@ -8,14 +8,12 @@ import { EliceIcon } from '@elice/mui-elements';
8
8
  import { useEliceRunboxRunning, useEliceRunboxQuota } from '@elice/runbox-client';
9
9
  import { faTimer } from '@fortawesome/pro-solid-svg-icons';
10
10
  import { Chip, chipClasses, Tooltip, Typography } from '@mui/material';
11
- import MaterialRunboxAlmostEndSnackbars from './MaterialRunboxAlmostEndSnackbars.js';
11
+ import { useRunboxSessionEndWarning, QUOTA_ALMOST_END_MINUTES } from '../hooks/useRunboxSessionEndWarning.js';
12
+ import MaterialRunboxQuotaAlmostEndDialog from './MaterialRunboxQuotaAlmostEndDialog.js';
13
+ import MaterialRunboxQuotaPerSessionAlmostEndDialog from './MaterialRunboxQuotaPerSessionAlmostEndDialog.js';
12
14
  import MaterialRunboxTimerDetailPopover, { QUOTA_POPOVER_NOT_SHOW_ON_START } from './MaterialRunboxTimerDetailPopover.js';
13
15
  import { getTimeParts } from '../../../utils/time.js';
14
16
 
15
- //
16
- //
17
- //
18
- var QUOTA_ALMOST_END_MINUTES = 30;
19
17
  //
20
18
  //
21
19
  //
@@ -37,13 +35,21 @@ var MaterialRunboxTimer = function MaterialRunboxTimer(_ref3) {
37
35
  headerElement = _ref3.headerElement,
38
36
  stopRuntime = _ref3.stopRuntime,
39
37
  _ref3$hideTimerPopove = _ref3.hideTimerPopover,
40
- hideTimerPopover = _ref3$hideTimerPopove === void 0 ? false : _ref3$hideTimerPopove;
38
+ hideTimerPopover = _ref3$hideTimerPopove === void 0 ? false : _ref3$hideTimerPopove,
39
+ _ref3$isTutoring = _ref3.isTutoring,
40
+ isTutoring = _ref3$isTutoring === void 0 ? false : _ref3$isTutoring;
41
41
  var intl = useRawEliceIntl();
42
42
  var _useEliceRunboxRunnin = useEliceRunboxRunning(),
43
43
  status = _useEliceRunboxRunnin.status;
44
44
  var isRunboxRunning = status === 'running';
45
45
  var _useEliceRunboxQuota = useEliceRunboxQuota(),
46
46
  quotaInfo = _useEliceRunboxQuota.quotaInfo;
47
+ var _useRunboxSessionEndW = useRunboxSessionEndWarning({
48
+ runboxId: runboxId,
49
+ disabled: isTutoring || !isRunboxRunning
50
+ }),
51
+ warning = _useRunboxSessionEndW.warning,
52
+ dismiss = _useRunboxSessionEndW.dismiss;
47
53
  var _React$useState = React.useState(false),
48
54
  _React$useState2 = _slicedToArray(_React$useState, 2),
49
55
  isTimerDetailPopoverOpen = _React$useState2[0],
@@ -151,19 +157,17 @@ var MaterialRunboxTimer = function MaterialRunboxTimer(_ref3) {
151
157
  }
152
158
  });
153
159
  };
154
- var renderAlmostEndSnackbars = function renderAlmostEndSnackbars() {
155
- return jsx(MaterialRunboxAlmostEndSnackbars, {
156
- runboxId: runboxId,
157
- onClickDetail: function onClickDetail() {
158
- return setTimerDetailPopoverOpen(true);
159
- }
160
- });
161
- };
162
160
  if (!isRunboxRunning) {
163
161
  return null;
164
162
  }
165
163
  return jsxs(Fragment, {
166
- children: [renderTimer(), renderTimerDetailPopover(), renderAlmostEndSnackbars()]
164
+ children: [renderTimer(), renderTimerDetailPopover(), jsx(MaterialRunboxQuotaAlmostEndDialog, {
165
+ open: warning === 'quota',
166
+ onClose: dismiss
167
+ }), jsx(MaterialRunboxQuotaPerSessionAlmostEndDialog, {
168
+ open: warning === 'quotaPerSession',
169
+ onClose: dismiss
170
+ })]
167
171
  });
168
172
  };
169
173