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

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