@elice/material-exercise 1.230621.0 → 1.230629.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.
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { MaterialExerciseCommonApis, MaterialExerciseCommonProps } from './context';
3
- export declare type MaterialExerciseProps = MaterialExerciseCommonProps;
3
+ export interface MaterialExerciseProps extends MaterialExerciseCommonProps {
4
+ locale?: string;
5
+ }
4
6
  export declare type MaterialExerciseApis = MaterialExerciseCommonApis;
5
- declare const _default: React.ForwardRefExoticComponent<Pick<MaterialExerciseCommonProps & React.RefAttributes<MaterialExerciseCommonApis> & import("@elice/material-shared-utils").MaterialCommponentCommonProps, "key" | keyof MaterialExerciseCommonProps> & React.RefAttributes<MaterialExerciseCommonApis>>;
7
+ declare const _default: React.ForwardRefExoticComponent<Pick<MaterialExerciseProps & React.RefAttributes<MaterialExerciseCommonApis> & import("@elice/material-shared-utils").MaterialCommponentCommonProps, "key" | keyof MaterialExerciseProps> & React.RefAttributes<MaterialExerciseCommonApis>>;
6
8
  export default _default;
@@ -0,0 +1,4 @@
1
+ export declare const en: {
2
+ 'materialExercise.button.referenceDocs': string;
3
+ };
4
+ export declare const ko: typeof en;
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var en = {
6
+ 'materialExercise.button.referenceDocs': 'Reference Docs'
7
+ };
8
+ var ko = {
9
+ 'materialExercise.button.referenceDocs': '언어 레퍼런스'
10
+ };
11
+
12
+ exports.en = en;
13
+ exports.ko = ko;
@@ -2,15 +2,18 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var tslib = require('tslib');
5
6
  var React = require('react');
7
+ var reactIntl = require('react-intl');
6
8
  var apiClient = require('@elice/api-client');
7
9
  var blocks = require('@elice/blocks');
10
+ var icons = require('@elice/icons');
8
11
  var materialSharedUtils = require('@elice/material-shared-utils');
9
12
  var recoil = require('recoil');
10
13
  var stylesheets = require('../../constants/stylesheets.js');
11
14
  var ExerciseFileTabsFileTreeButton = require('./exercise-file-tabs/ExerciseFileTabsFileTreeButton.js');
12
15
  var recoil$1 = require('./context/recoil.js');
13
- require('./context/context.js');
16
+ var context = require('./context/context.js');
14
17
  var recoilTypes = require('./context/recoilTypes.js');
15
18
  var subjects = require('./context/subjects.js');
16
19
  var ExerciseProvider = require('./context/ExerciseProvider.js');
@@ -25,6 +28,7 @@ var ExercisePreview = require('./exercise-preview/ExercisePreview.js');
25
28
  var ExerciseRightpane = require('./exercise-rightpane/ExerciseRightpane.js');
26
29
  var ExerciseRunner = require('./exercise-runner/ExerciseRunner.js');
27
30
  var MaterialExercise_styled = require('./MaterialExercise.styled.js');
31
+ var MaterialExercise_i18n = require('./MaterialExercise.i18n.js');
28
32
 
29
33
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
30
34
 
@@ -37,6 +41,9 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
37
41
  * Material exercise.
38
42
  */
39
43
  var MaterialExercise = React.forwardRef(function (props, ref) {
44
+ var intl = reactIntl.useIntl();
45
+ var _React$useContext = React__default["default"].useContext(context.ExerciseContext),
46
+ onReferenceDocsToggle = _React$useContext.onReferenceDocsToggle;
40
47
  var _useRecoilValue = recoil.useRecoilValue(recoil$1.exerciseContainerSizeState),
41
48
  width = _useRecoilValue.width,
42
49
  height = _useRecoilValue.height;
@@ -69,11 +76,35 @@ var MaterialExercise = React.forwardRef(function (props, ref) {
69
76
  var renderExerciseFileTabs = function renderExerciseFileTabs() {
70
77
  return React__default["default"].createElement(MaterialExercise_styled.StyledExerciseTabsWrap, null, React__default["default"].createElement(ExerciseFileTabsLazy["default"], null));
71
78
  };
79
+ /**
80
+ * reference docs toggle button
81
+ */
82
+ var renderExerciseReferenceDocsToggleButton = function renderExerciseReferenceDocsToggleButton() {
83
+ if (typeof onReferenceDocsToggle !== 'function') {
84
+ return null;
85
+ }
86
+ return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement(blocks.Button, {
87
+ size: "micro",
88
+ role: "navy3",
89
+ style: {
90
+ width: '100%'
91
+ },
92
+ onClick: onReferenceDocsToggle
93
+ }, React__default["default"].createElement(blocks.Icon, {
94
+ icon: icons.eilClassroom
95
+ }), React__default["default"].createElement(blocks.Hspace, {
96
+ width: 0.25
97
+ }), intl.formatMessage({
98
+ id: 'materialExercise.button.referenceDocs'
99
+ })), React__default["default"].createElement(blocks.Hspace, {
100
+ width: 0.5
101
+ }));
102
+ };
72
103
  /**
73
104
  * Menu
74
105
  */
75
106
  var renderExerciseMenu = function renderExerciseMenu() {
76
- return React__default["default"].createElement(MaterialExercise_styled.StyledExerciseTabMenuWrap, null, React__default["default"].createElement(ExerciseMultilangDropdownLazy["default"], null), React__default["default"].createElement(ExerciseMenu["default"], null));
107
+ return React__default["default"].createElement(MaterialExercise_styled.StyledExerciseTabMenuWrap, null, renderExerciseReferenceDocsToggleButton(), React__default["default"].createElement(ExerciseMultilangDropdownLazy["default"], null), React__default["default"].createElement(ExerciseMenu["default"], null));
77
108
  };
78
109
  /**
79
110
  * Code editor and file viewer
@@ -144,10 +175,17 @@ var MaterialExercise = React.forwardRef(function (props, ref) {
144
175
  //
145
176
  //
146
177
  //
147
- var MaterialExercise$1 = materialSharedUtils.withForwardRefMaterial(React.forwardRef(function (props, ref) {
148
- return React__default["default"].createElement(ExerciseProvider["default"], Object.assign({}, props), React__default["default"].createElement(MaterialExercise, Object.assign({}, props, {
178
+ var MaterialExercise$1 = materialSharedUtils.withForwardRefMaterial(React.forwardRef(function (_a, ref) {
179
+ var _a$locale = _a.locale,
180
+ locale = _a$locale === void 0 ? 'en' : _a$locale,
181
+ props = tslib.__rest(_a, ["locale"]);
182
+ return React__default["default"].createElement(reactIntl.IntlProvider, {
183
+ locale: locale,
184
+ defaultLocale: "en",
185
+ messages: locale in MaterialExercise_i18n ? MaterialExercise_i18n[locale] : MaterialExercise_i18n.en
186
+ }, React__default["default"].createElement(ExerciseProvider["default"], Object.assign({}, props), React__default["default"].createElement(MaterialExercise, Object.assign({}, props, {
149
187
  ref: ref
150
- })));
188
+ }))));
151
189
  }), apiClient.config.init, {
152
190
  overrideRecoilScope: true
153
191
  });
@@ -56,6 +56,8 @@ export interface MaterialExerciseCommonProps extends MaterialCommponentCommonPro
56
56
  */
57
57
  readOnlyEditor?: boolean;
58
58
  exerciseImageEmptyOptions?: MaterialExerciseCommonPropExerciseImageEmptyOptions;
59
+ onMultiLangLanguageChange?: MaterialExerciseCommonPropOnMultiLangLanguageChange;
60
+ onReferenceDocsToggle?: () => void;
59
61
  onCodeHelpRequest?: MaterialExerciseCommonPropOnCodeHelpRequest;
60
62
  onDefaultExerciseRoomIdSet?: MaterialExerciseCommonPropOnDefaultExerciseRoomIdSet;
61
63
  onExerciseRoomIdChange?: MaterialExerciseCommonPropOnExerciseRoomIdChange;
@@ -78,6 +80,10 @@ export declare type MaterialExerciseCommonPropOnCodeHelpRequest = (params: {
78
80
  instruction?: string;
79
81
  openFileContent?: string;
80
82
  }) => void;
83
+ /**
84
+ * On multi language change.
85
+ */
86
+ export declare type MaterialExerciseCommonPropOnMultiLangLanguageChange = (language: string) => void;
81
87
  /**
82
88
  * On default exercise room ID set.
83
89
  */
@@ -19,7 +19,8 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
19
19
  var ExerciseMultilangDropdown = function ExerciseMultilangDropdown() {
20
20
  var _React$useContext = React__default["default"].useContext(context.ExerciseContext),
21
21
  materialExerciseId = _React$useContext.materialExerciseId,
22
- exerciseRoomId = _React$useContext.exerciseRoomId;
22
+ exerciseRoomId = _React$useContext.exerciseRoomId,
23
+ onMultiLangLanguageChange = _React$useContext.onMultiLangLanguageChange;
23
24
  var multilangLanguages = recoil.useRecoilValue(recoil$1.exerciseMultilangLanguagesState(materialExerciseId));
24
25
  var _useRecoilState = recoil.useRecoilState(recoil$1.exerciseMultilangEnvironmentState({
25
26
  materialExerciseId: materialExerciseId,
@@ -41,9 +42,12 @@ var ExerciseMultilangDropdown = function ExerciseMultilangDropdown() {
41
42
  placement: "bottom-end",
42
43
  value: multilangEnvironment.language,
43
44
  onChange: function onChange(language) {
44
- return setMultilangEnvironment({
45
+ setMultilangEnvironment({
45
46
  language: language
46
47
  });
48
+ if (typeof onMultiLangLanguageChange === 'function') {
49
+ onMultiLangLanguageChange(language);
50
+ }
47
51
  }
48
52
  }, Object.keys(multilangLanguages).map(function (lang) {
49
53
  return React__default["default"].createElement("option", {
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { MaterialExerciseCommonApis, MaterialExerciseCommonProps } from './context';
3
- export declare type MaterialExerciseProps = MaterialExerciseCommonProps;
3
+ export interface MaterialExerciseProps extends MaterialExerciseCommonProps {
4
+ locale?: string;
5
+ }
4
6
  export declare type MaterialExerciseApis = MaterialExerciseCommonApis;
5
- declare const _default: React.ForwardRefExoticComponent<Pick<MaterialExerciseCommonProps & React.RefAttributes<MaterialExerciseCommonApis> & import("@elice/material-shared-utils").MaterialCommponentCommonProps, "key" | keyof MaterialExerciseCommonProps> & React.RefAttributes<MaterialExerciseCommonApis>>;
7
+ declare const _default: React.ForwardRefExoticComponent<Pick<MaterialExerciseProps & React.RefAttributes<MaterialExerciseCommonApis> & import("@elice/material-shared-utils").MaterialCommponentCommonProps, "key" | keyof MaterialExerciseProps> & React.RefAttributes<MaterialExerciseCommonApis>>;
6
8
  export default _default;
@@ -0,0 +1,4 @@
1
+ export declare const en: {
2
+ 'materialExercise.button.referenceDocs': string;
3
+ };
4
+ export declare const ko: typeof en;
@@ -0,0 +1,8 @@
1
+ var en = {
2
+ 'materialExercise.button.referenceDocs': 'Reference Docs'
3
+ };
4
+ var ko = {
5
+ 'materialExercise.button.referenceDocs': '언어 레퍼런스'
6
+ };
7
+
8
+ export { en, ko };
@@ -1,12 +1,15 @@
1
+ import { __rest } from 'tslib';
1
2
  import React, { forwardRef } from 'react';
3
+ import { useIntl, IntlProvider } from 'react-intl';
2
4
  import { config } from '@elice/api-client';
3
- import { ResizableNext } from '@elice/blocks';
5
+ import { ResizableNext, Button, Icon, Hspace } from '@elice/blocks';
6
+ import { eilClassroom } from '@elice/icons';
4
7
  import { withForwardRefMaterial } from '@elice/material-shared-utils';
5
8
  import { useRecoilValue } from 'recoil';
6
9
  import { MATERIAL_RESIZABLE_COMMON_PROPS } from '../../constants/stylesheets.js';
7
10
  import ExerciseFileTabsFileTreeButton from './exercise-file-tabs/ExerciseFileTabsFileTreeButton.js';
8
11
  import { exerciseContainerSizeState, exerciseState, exerciseFileTreeOpenedState, exercisePreviewTypeState, exercisePreviewDisplayModeState, exerciseMonacoEditorApisState } from './context/recoil.js';
9
- import './context/context.js';
12
+ import { ExerciseContext } from './context/context.js';
10
13
  import { ExercisePreviewType, ExercisePreviewDisplayMode } from './context/recoilTypes.js';
11
14
  import { exerciseRunnerTextSend$ } from './context/subjects.js';
12
15
  import ExerciseProvider from './context/ExerciseProvider.js';
@@ -21,6 +24,8 @@ import ExercisePreview from './exercise-preview/ExercisePreview.js';
21
24
  import ExerciseRightpane from './exercise-rightpane/ExerciseRightpane.js';
22
25
  import ExerciseRunner from './exercise-runner/ExerciseRunner.js';
23
26
  import { StyledExerciseContainer, EXERCISE_PREVIEW_MIN_WIDTH, EXERCISE_HORIZONTAL_RATIO, StyledExerciseMain, StyledxerciseFileTreeContaner, EXERCISE_FILE_TREE_MIN_WIDTH, StyledExerciseFileTreeWrap, StyledExerciseFileAndTabWrap, StyledExerciseTabBar, StyledExerciseTabsWrap, StyledExerciseTabMenuWrap, StyledExerciseFileWrap, StyledExerciseRunnerWrap, EXERCISE_RUNNER_MIN_HEIGHT } from './MaterialExercise.styled.js';
27
+ import * as MaterialExercise_i18n from './MaterialExercise.i18n.js';
28
+ import { en } from './MaterialExercise.i18n.js';
24
29
 
25
30
  //
26
31
  //
@@ -29,6 +34,9 @@ import { StyledExerciseContainer, EXERCISE_PREVIEW_MIN_WIDTH, EXERCISE_HORIZONTA
29
34
  * Material exercise.
30
35
  */
31
36
  var MaterialExercise = forwardRef(function (props, ref) {
37
+ var intl = useIntl();
38
+ var _React$useContext = React.useContext(ExerciseContext),
39
+ onReferenceDocsToggle = _React$useContext.onReferenceDocsToggle;
32
40
  var _useRecoilValue = useRecoilValue(exerciseContainerSizeState),
33
41
  width = _useRecoilValue.width,
34
42
  height = _useRecoilValue.height;
@@ -61,11 +69,35 @@ var MaterialExercise = forwardRef(function (props, ref) {
61
69
  var renderExerciseFileTabs = function renderExerciseFileTabs() {
62
70
  return React.createElement(StyledExerciseTabsWrap, null, React.createElement(ExerciseFileTabsLazy, null));
63
71
  };
72
+ /**
73
+ * reference docs toggle button
74
+ */
75
+ var renderExerciseReferenceDocsToggleButton = function renderExerciseReferenceDocsToggleButton() {
76
+ if (typeof onReferenceDocsToggle !== 'function') {
77
+ return null;
78
+ }
79
+ return React.createElement(React.Fragment, null, React.createElement(Button, {
80
+ size: "micro",
81
+ role: "navy3",
82
+ style: {
83
+ width: '100%'
84
+ },
85
+ onClick: onReferenceDocsToggle
86
+ }, React.createElement(Icon, {
87
+ icon: eilClassroom
88
+ }), React.createElement(Hspace, {
89
+ width: 0.25
90
+ }), intl.formatMessage({
91
+ id: 'materialExercise.button.referenceDocs'
92
+ })), React.createElement(Hspace, {
93
+ width: 0.5
94
+ }));
95
+ };
64
96
  /**
65
97
  * Menu
66
98
  */
67
99
  var renderExerciseMenu = function renderExerciseMenu() {
68
- return React.createElement(StyledExerciseTabMenuWrap, null, React.createElement(ExerciseMultilangDropdownLazy, null), React.createElement(ExerciseMenu, null));
100
+ return React.createElement(StyledExerciseTabMenuWrap, null, renderExerciseReferenceDocsToggleButton(), React.createElement(ExerciseMultilangDropdownLazy, null), React.createElement(ExerciseMenu, null));
69
101
  };
70
102
  /**
71
103
  * Code editor and file viewer
@@ -136,10 +168,17 @@ var MaterialExercise = forwardRef(function (props, ref) {
136
168
  //
137
169
  //
138
170
  //
139
- var MaterialExercise$1 = withForwardRefMaterial(forwardRef(function (props, ref) {
140
- return React.createElement(ExerciseProvider, Object.assign({}, props), React.createElement(MaterialExercise, Object.assign({}, props, {
171
+ var MaterialExercise$1 = withForwardRefMaterial(forwardRef(function (_a, ref) {
172
+ var _a$locale = _a.locale,
173
+ locale = _a$locale === void 0 ? 'en' : _a$locale,
174
+ props = __rest(_a, ["locale"]);
175
+ return React.createElement(IntlProvider, {
176
+ locale: locale,
177
+ defaultLocale: "en",
178
+ messages: locale in MaterialExercise_i18n ? MaterialExercise_i18n[locale] : en
179
+ }, React.createElement(ExerciseProvider, Object.assign({}, props), React.createElement(MaterialExercise, Object.assign({}, props, {
141
180
  ref: ref
142
- })));
181
+ }))));
143
182
  }), config.init, {
144
183
  overrideRecoilScope: true
145
184
  });
@@ -56,6 +56,8 @@ export interface MaterialExerciseCommonProps extends MaterialCommponentCommonPro
56
56
  */
57
57
  readOnlyEditor?: boolean;
58
58
  exerciseImageEmptyOptions?: MaterialExerciseCommonPropExerciseImageEmptyOptions;
59
+ onMultiLangLanguageChange?: MaterialExerciseCommonPropOnMultiLangLanguageChange;
60
+ onReferenceDocsToggle?: () => void;
59
61
  onCodeHelpRequest?: MaterialExerciseCommonPropOnCodeHelpRequest;
60
62
  onDefaultExerciseRoomIdSet?: MaterialExerciseCommonPropOnDefaultExerciseRoomIdSet;
61
63
  onExerciseRoomIdChange?: MaterialExerciseCommonPropOnExerciseRoomIdChange;
@@ -78,6 +80,10 @@ export declare type MaterialExerciseCommonPropOnCodeHelpRequest = (params: {
78
80
  instruction?: string;
79
81
  openFileContent?: string;
80
82
  }) => void;
83
+ /**
84
+ * On multi language change.
85
+ */
86
+ export declare type MaterialExerciseCommonPropOnMultiLangLanguageChange = (language: string) => void;
81
87
  /**
82
88
  * On default exercise room ID set.
83
89
  */
@@ -11,7 +11,8 @@ import '../context/ExerciseProvider.js';
11
11
  var ExerciseMultilangDropdown = function ExerciseMultilangDropdown() {
12
12
  var _React$useContext = React.useContext(ExerciseContext),
13
13
  materialExerciseId = _React$useContext.materialExerciseId,
14
- exerciseRoomId = _React$useContext.exerciseRoomId;
14
+ exerciseRoomId = _React$useContext.exerciseRoomId,
15
+ onMultiLangLanguageChange = _React$useContext.onMultiLangLanguageChange;
15
16
  var multilangLanguages = useRecoilValue(exerciseMultilangLanguagesState(materialExerciseId));
16
17
  var _useRecoilState = useRecoilState(exerciseMultilangEnvironmentState({
17
18
  materialExerciseId: materialExerciseId,
@@ -33,9 +34,12 @@ var ExerciseMultilangDropdown = function ExerciseMultilangDropdown() {
33
34
  placement: "bottom-end",
34
35
  value: multilangEnvironment.language,
35
36
  onChange: function onChange(language) {
36
- return setMultilangEnvironment({
37
+ setMultilangEnvironment({
37
38
  language: language
38
39
  });
40
+ if (typeof onMultiLangLanguageChange === 'function') {
41
+ onMultiLangLanguageChange(language);
42
+ }
39
43
  }
40
44
  }, Object.keys(multilangLanguages).map(function (lang) {
41
45
  return React.createElement("option", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elice/material-exercise",
3
- "version": "1.230621.0",
3
+ "version": "1.230629.0",
4
4
  "description": "User view and editing components of Elice material exercise",
5
5
  "repository": "https://git.elicer.io/elice/frontend/library/elice-material",
6
6
  "license": "UNLICENSED",
@@ -79,9 +79,9 @@
79
79
  "@elice/design-tokens": "^1.220803.0",
80
80
  "@elice/icons": "^1.220803.0",
81
81
  "@elice/markdown": "^1.220803.0",
82
- "@elice/material-shared-types": "1.230621.0",
83
- "@elice/material-shared-utils": "1.230621.0",
84
- "@elice/types": "1.230522.0",
82
+ "@elice/material-shared-types": "1.230629.0",
83
+ "@elice/material-shared-utils": "1.230629.0",
84
+ "@elice/types": "^1.230629.0",
85
85
  "@elice/websocket": "^1.220803.0",
86
86
  "@types/classnames": "^2.3.1",
87
87
  "@types/color": "^3.0.3",
@@ -102,5 +102,5 @@
102
102
  "recoil": "^0.6.1",
103
103
  "styled-components": "^5.2.0"
104
104
  },
105
- "gitHead": "a7459def6aacf5783671a83c0a19a52596fce6f3"
105
+ "gitHead": "2c97cc9d41247bb8fa777b6084bc19c04b50215c"
106
106
  }