@pie-element/passage 6.0.0-beta.0 → 6.0.0-next.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.
- package/CHANGELOG.md +0 -11
- package/configure/CHANGELOG.md +0 -11
- package/configure/lib/passage.js +11 -11
- package/configure/lib/passage.js.map +1 -1
- package/configure/package.json +7 -7
- package/controller/lib/index.js +3 -3
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/lib/print.js +2 -2
- package/lib/print.js.map +1 -1
- package/lib/stimulus-tabs.js +13 -2
- package/lib/stimulus-tabs.js.map +1 -1
- package/module/configure.js +1 -0
- package/module/controller.js +920 -0
- package/module/demo.js +57 -0
- package/module/element.js +1 -0
- package/module/index.html +21 -0
- package/module/manifest.json +10 -0
- package/module/print-demo.js +95 -0
- package/module/print.html +18 -0
- package/module/print.js +1 -0
- package/package.json +12 -8
package/CHANGELOG.md
CHANGED
|
@@ -3,17 +3,6 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [5.3.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/passage@5.3.2...@pie-element/passage@5.3.3) (2025-11-27)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
### Bug Fixes
|
|
10
|
-
|
|
11
|
-
* bump libs PD-5274, PD-5211, PD-5248 ([7610b25](https://github.com/pie-framework/pie-elements/commit/7610b25423956b6492f33322513b3430051fca77))
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
6
|
## [5.3.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/passage@5.3.1...@pie-element/passage@5.3.2) (2025-10-22)
|
|
18
7
|
|
|
19
8
|
|
package/configure/CHANGELOG.md
CHANGED
|
@@ -3,17 +3,6 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [3.3.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/passage-configure@3.3.2...@pie-element/passage-configure@3.3.3) (2025-11-27)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
### Bug Fixes
|
|
10
|
-
|
|
11
|
-
* bump libs PD-5274, PD-5211, PD-5248 ([7610b25](https://github.com/pie-framework/pie-elements/commit/7610b25423956b6492f33322513b3430051fca77))
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
6
|
## [3.3.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/passage-configure@3.3.1...@pie-element/passage-configure@3.3.2) (2025-10-22)
|
|
18
7
|
|
|
19
8
|
|
package/configure/lib/passage.js
CHANGED
|
@@ -9,7 +9,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
var _configUi = require("@pie-lib/config-ui");
|
|
12
|
-
var
|
|
12
|
+
var _editableHtmlTipTap = _interopRequireWildcard(require("@pie-lib/editable-html-tip-tap"));
|
|
13
13
|
var _styles = require("@mui/material/styles");
|
|
14
14
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
15
15
|
const StyledInputContainer = (0, _styles.styled)(_configUi.InputContainer)(({
|
|
@@ -95,8 +95,8 @@ class PassageComponent extends _react.default.Component {
|
|
|
95
95
|
});
|
|
96
96
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, teacherInstructionsEnabled && /*#__PURE__*/_react.default.createElement(StyledInputContainer, {
|
|
97
97
|
label: teacherInstructions.label
|
|
98
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
99
|
-
activePlugins:
|
|
98
|
+
}, /*#__PURE__*/_react.default.createElement(_editableHtmlTipTap.default, {
|
|
99
|
+
activePlugins: _editableHtmlTipTap.ALL_PLUGINS,
|
|
100
100
|
markup: passages[passageIndex].teacherInstructions || '',
|
|
101
101
|
onChange: value => this.handleChange('teacherInstructions', value),
|
|
102
102
|
nonEmpty: false,
|
|
@@ -112,8 +112,8 @@ class PassageComponent extends _react.default.Component {
|
|
|
112
112
|
pluginProps: getPluginProps(teacherInstructions?.inputConfiguration)
|
|
113
113
|
}), teacherInstructionsError && /*#__PURE__*/_react.default.createElement(ErrorText, null, teacherInstructionsError)), titleEnabled && /*#__PURE__*/_react.default.createElement(StyledInputContainer, {
|
|
114
114
|
label: title.label
|
|
115
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
116
|
-
activePlugins:
|
|
115
|
+
}, /*#__PURE__*/_react.default.createElement(_editableHtmlTipTap.default, {
|
|
116
|
+
activePlugins: _editableHtmlTipTap.ALL_PLUGINS,
|
|
117
117
|
markup: passages[passageIndex].title || '',
|
|
118
118
|
onChange: value => this.handleChange('title', value),
|
|
119
119
|
nonEmpty: false,
|
|
@@ -127,8 +127,8 @@ class PassageComponent extends _react.default.Component {
|
|
|
127
127
|
pluginProps: getPluginProps(title?.inputConfiguration)
|
|
128
128
|
}), titleError && /*#__PURE__*/_react.default.createElement(ErrorText, null, titleError)), subtitleEnabled && /*#__PURE__*/_react.default.createElement(StyledInputContainer, {
|
|
129
129
|
label: subtitle.label
|
|
130
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
131
|
-
activePlugins:
|
|
130
|
+
}, /*#__PURE__*/_react.default.createElement(_editableHtmlTipTap.default, {
|
|
131
|
+
activePlugins: _editableHtmlTipTap.ALL_PLUGINS,
|
|
132
132
|
markup: passages[passageIndex].subtitle || '',
|
|
133
133
|
onChange: value => this.handleChange('subtitle', value),
|
|
134
134
|
nonEmpty: false,
|
|
@@ -142,8 +142,8 @@ class PassageComponent extends _react.default.Component {
|
|
|
142
142
|
pluginProps: getPluginProps(subtitle?.inputConfiguration)
|
|
143
143
|
}), subtitleError && /*#__PURE__*/_react.default.createElement(ErrorText, null, subtitleError)), authorEnabled && /*#__PURE__*/_react.default.createElement(StyledInputContainer, {
|
|
144
144
|
label: author.label
|
|
145
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
146
|
-
activePlugins:
|
|
145
|
+
}, /*#__PURE__*/_react.default.createElement(_editableHtmlTipTap.default, {
|
|
146
|
+
activePlugins: _editableHtmlTipTap.ALL_PLUGINS,
|
|
147
147
|
markup: passages[passageIndex].author || '',
|
|
148
148
|
onChange: value => this.handleChange('author', value),
|
|
149
149
|
nonEmpty: false,
|
|
@@ -157,8 +157,8 @@ class PassageComponent extends _react.default.Component {
|
|
|
157
157
|
pluginProps: getPluginProps(author?.inputConfiguration)
|
|
158
158
|
}), authorError && /*#__PURE__*/_react.default.createElement(ErrorText, null, authorError)), textEnabled && /*#__PURE__*/_react.default.createElement(StyledInputContainer, {
|
|
159
159
|
label: text.label
|
|
160
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
161
|
-
activePlugins:
|
|
160
|
+
}, /*#__PURE__*/_react.default.createElement(_editableHtmlTipTap.default, {
|
|
161
|
+
activePlugins: _editableHtmlTipTap.ALL_PLUGINS,
|
|
162
162
|
markup: passages[passageIndex].text || '',
|
|
163
163
|
onChange: value => this.handleChange('text', value),
|
|
164
164
|
imageSupport: imageSupport,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"passage.js","names":["_react","_interopRequireDefault","require","_propTypes","_configUi","_editableHtml","_interopRequireWildcard","_styles","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","StyledInputContainer","styled","InputContainer","theme","paddingTop","spacing","marginBottom","width","ErrorText","fontSize","typography","color","palette","error","main","PassageComponent","React","Component","constructor","props","_defineProperty2","fieldName","value","model","onModelChanged","passageIndex","passages","length","updatedPassages","render","configuration","imageSupport","uploadSoundSupport","maxImageWidth","maxImageHeight","mathMlOptions","baseInputConfiguration","teacherInstructions","title","subtitle","text","author","errors","teacherInstructionsEnabled","titleEnabled","subtitleEnabled","authorEnabled","textEnabled","passagesErrors","teacherInstructionsError","titleError","subtitleError","authorError","textError","defaultImageMaxWidth","prompt","defaultImageMaxHeight","getPluginProps","customConfiguration","createElement","Fragment","label","activePlugins","ALL_PLUGINS","markup","onChange","handleChange","nonEmpty","languageCharactersProps","language","pluginProps","inputConfiguration","exports","PropTypes","func","isRequired","object","number","_default"],"sources":["../src/passage.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { InputContainer } from '@pie-lib/config-ui';\nimport EditableHtml, { ALL_PLUGINS } from '@pie-lib/editable-html';\nimport { styled } from '@mui/material/styles';\n\nconst StyledInputContainer = styled(InputContainer)(({ theme }) => ({\n paddingTop: theme.spacing(2),\n marginBottom: theme.spacing(2),\n width: '100%',\n}));\n\nconst ErrorText = styled('div')(({ theme }) => ({\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n paddingTop: theme.spacing(1),\n}));\n\nexport class PassageComponent extends React.Component {\n static propTypes = {\n onModelChanged: PropTypes.func.isRequired,\n model: PropTypes.object.isRequired,\n configuration: PropTypes.object.isRequired,\n imageSupport: PropTypes.object.isRequired,\n passageIndex: PropTypes.number.isRequired,\n uploadSoundSupport: PropTypes.object.isRequired,\n };\n\n static defaultProps = {\n passageIndex: 0,\n };\n\n constructor(props) {\n super(props);\n }\n\n handleChange = (fieldName, value) => {\n const { model, onModelChanged, passageIndex } = this.props;\n\n if (!model.passages || passageIndex < 0 || passageIndex >= model.passages.length) {\n return;\n }\n\n const updatedPassages = [...model.passages];\n updatedPassages[passageIndex] = { ...updatedPassages[passageIndex], [fieldName]: value };\n\n onModelChanged({ ...model, passages: updatedPassages });\n };\n\n render() {\n const { model, configuration, imageSupport, passageIndex, uploadSoundSupport } = this.props;\n const {\n maxImageWidth = {},\n maxImageHeight = {},\n mathMlOptions = {},\n baseInputConfiguration = {},\n teacherInstructions = {},\n title = {},\n subtitle = {},\n text = {},\n author = {},\n } = configuration || {};\n const {\n errors = {},\n passages = [],\n teacherInstructionsEnabled,\n titleEnabled,\n subtitleEnabled,\n authorEnabled,\n textEnabled,\n } = model || {};\n\n const { passages: passagesErrors } = errors || {};\n const {\n teacherInstructions: teacherInstructionsError,\n title: titleError,\n subtitle: subtitleError,\n author: authorError,\n text: textError,\n } = (passagesErrors && passagesErrors[passageIndex]) || {};\n\n const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;\n const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;\n\n const getPluginProps = (customConfiguration) => ({ ...baseInputConfiguration, ...customConfiguration });\n\n return (\n <React.Fragment>\n {teacherInstructionsEnabled && (\n <StyledInputContainer label={teacherInstructions.label}>\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n markup={passages[passageIndex].teacherInstructions || ''}\n onChange={(value) => this.handleChange('teacherInstructions', value)}\n nonEmpty={false}\n error={teacherInstructionsError}\n maxImageWidth={(maxImageWidth && maxImageWidth.teacherInstructions) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.teacherInstructions) || defaultImageMaxHeight}\n mathMlOptions={mathMlOptions}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n pluginProps={getPluginProps(teacherInstructions?.inputConfiguration)}\n />\n {teacherInstructionsError && <ErrorText>{teacherInstructionsError}</ErrorText>}\n </StyledInputContainer>\n )}\n\n {titleEnabled && (\n <StyledInputContainer label={title.label}>\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n markup={passages[passageIndex].title || ''}\n onChange={(value) => this.handleChange('title', value)}\n nonEmpty={false}\n error={titleError}\n mathMlOptions={mathMlOptions}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n pluginProps={getPluginProps(title?.inputConfiguration)}\n />\n {titleError && <ErrorText>{titleError}</ErrorText>}\n </StyledInputContainer>\n )}\n\n {subtitleEnabled && (\n <StyledInputContainer label={subtitle.label}>\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n markup={passages[passageIndex].subtitle || ''}\n onChange={(value) => this.handleChange('subtitle', value)}\n nonEmpty={false}\n error={subtitleError}\n mathMlOptions={mathMlOptions}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n pluginProps={getPluginProps(subtitle?.inputConfiguration)}\n />\n {subtitleError && <ErrorText>{subtitleError}</ErrorText>}\n </StyledInputContainer>\n )}\n\n {authorEnabled && (\n <StyledInputContainer label={author.label}>\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n markup={passages[passageIndex].author || ''}\n onChange={(value) => this.handleChange('author', value)}\n nonEmpty={false}\n error={authorError}\n mathMlOptions={mathMlOptions}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n pluginProps={getPluginProps(author?.inputConfiguration)}\n />\n {authorError && <ErrorText>{authorError}</ErrorText>}\n </StyledInputContainer>\n )}\n\n {textEnabled && (\n <StyledInputContainer label={text.label}>\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n markup={passages[passageIndex].text || ''}\n onChange={(value) => this.handleChange('text', value)}\n imageSupport={imageSupport}\n uploadSoundSupport={uploadSoundSupport}\n nonEmpty={false}\n error={textError}\n maxImageWidth={(maxImageWidth && maxImageWidth.text) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.text) || defaultImageMaxHeight}\n mathMlOptions={mathMlOptions}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n pluginProps={getPluginProps(text?.inputConfiguration)}\n />\n {textError && <ErrorText>{textError}</ErrorText>}\n </StyledInputContainer>\n )}\n </React.Fragment>\n );\n }\n}\n\nexport default PassageComponent;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAC,uBAAA,CAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAA8C,SAAAI,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAAA,YAAAA,CAAAE,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IA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tD,KAAK,EAAEwC,SAAU;MACjBpB,aAAa,EAAGA,aAAa,IAAIA,aAAa,CAACO,IAAI,IAAKc,oBAAqB;MAC7EpB,cAAc,EAAGA,cAAc,IAAIA,cAAc,CAACM,IAAI,IAAKgB,qBAAsB;MACjFrB,aAAa,EAAEA,aAAc;MAC7BiC,uBAAuB,EAAE,CAAC;QAAEC,QAAQ,EAAE;MAAU,CAAC,EAAE;QAAEA,QAAQ,EAAE;MAAU,CAAC,CAAE;MAC5EC,WAAW,EAAEb,cAAc,CAACjB,IAAI,EAAE+B,kBAAkB;IAAE,CACvD,CAAC,EACDlB,SAAS,iBAAIhF,MAAA,CAAAkB,OAAA,CAAAoE,aAAA,CAACnD,SAAS,QAAE6C,SAAqB,CAC3B,CAEV,CAAC;EAErB;AACF;AAACmB,OAAA,CAAAzD,gBAAA,GAAAA,gBAAA;AAAA,IAAAK,gBAAA,CAAA7B,OAAA,EA9JYwB,gBAAgB,eACR;EACjBS,cAAc,EAAEiD,kBAAS,CAACC,IAAI,CAACC,UAAU;EACzCpD,KAAK,EAAEkD,kBAAS,CAACG,MAAM,CAACD,UAAU;EAClC7C,aAAa,EAAE2C,kBAAS,CAACG,MAAM,CAACD,UAAU;EAC1C5C,YAAY,EAAE0C,kBAAS,CAACG,MAAM,CAACD,UAAU;EACzClD,YAAY,EAAEgD,kBAAS,CAACI,MAAM,CAACF,UAAU;EACzC3C,kBAAkB,EAAEyC,kBAAS,CAACG,MAAM,CAACD;AACvC,CAAC;AAAA,IAAAvD,gBAAA,CAAA7B,OAAA,EARUwB,gBAAgB,kBAUL;EACpBU,YAAY,EAAE;AAChB,CAAC;AAAA,IAAAqD,QAAA,GAAAN,OAAA,CAAAjF,OAAA,GAoJYwB,gBAAgB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"passage.js","names":["_react","_interopRequireDefault","require","_propTypes","_configUi","_editableHtmlTipTap","_interopRequireWildcard","_styles","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","StyledInputContainer","styled","InputContainer","theme","paddingTop","spacing","marginBottom","width","ErrorText","fontSize","typography","color","palette","error","main","PassageComponent","React","Component","constructor","props","_defineProperty2","fieldName","value","model","onModelChanged","passageIndex","passages","length","updatedPassages","render","configuration","imageSupport","uploadSoundSupport","maxImageWidth","maxImageHeight","mathMlOptions","baseInputConfiguration","teacherInstructions","title","subtitle","text","author","errors","teacherInstructionsEnabled","titleEnabled","subtitleEnabled","authorEnabled","textEnabled","passagesErrors","teacherInstructionsError","titleError","subtitleError","authorError","textError","defaultImageMaxWidth","prompt","defaultImageMaxHeight","getPluginProps","customConfiguration","createElement","Fragment","label","activePlugins","ALL_PLUGINS","markup","onChange","handleChange","nonEmpty","languageCharactersProps","language","pluginProps","inputConfiguration","exports","PropTypes","func","isRequired","object","number","_default"],"sources":["../src/passage.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { InputContainer } from '@pie-lib/config-ui';\nimport EditableHtml, { ALL_PLUGINS } from '@pie-lib/editable-html-tip-tap';\nimport { styled } from '@mui/material/styles';\n\nconst StyledInputContainer = styled(InputContainer)(({ theme }) => ({\n paddingTop: theme.spacing(2),\n marginBottom: theme.spacing(2),\n width: '100%',\n}));\n\nconst ErrorText = styled('div')(({ theme }) => ({\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n paddingTop: theme.spacing(1),\n}));\n\nexport class PassageComponent extends React.Component {\n static propTypes = {\n onModelChanged: PropTypes.func.isRequired,\n model: PropTypes.object.isRequired,\n configuration: PropTypes.object.isRequired,\n imageSupport: PropTypes.object.isRequired,\n passageIndex: PropTypes.number.isRequired,\n uploadSoundSupport: PropTypes.object.isRequired,\n };\n\n static defaultProps = {\n passageIndex: 0,\n };\n\n constructor(props) {\n super(props);\n }\n\n handleChange = (fieldName, value) => {\n const { model, onModelChanged, passageIndex } = this.props;\n\n if (!model.passages || passageIndex < 0 || passageIndex >= model.passages.length) {\n return;\n }\n\n const updatedPassages = [...model.passages];\n updatedPassages[passageIndex] = { ...updatedPassages[passageIndex], [fieldName]: value };\n\n onModelChanged({ ...model, passages: updatedPassages });\n };\n\n render() {\n const { model, configuration, imageSupport, passageIndex, uploadSoundSupport } = this.props;\n const {\n maxImageWidth = {},\n maxImageHeight = {},\n mathMlOptions = {},\n baseInputConfiguration = {},\n teacherInstructions = {},\n title = {},\n subtitle = {},\n text = {},\n author = {},\n } = configuration || {};\n const {\n errors = {},\n passages = [],\n teacherInstructionsEnabled,\n titleEnabled,\n subtitleEnabled,\n authorEnabled,\n textEnabled,\n } = model || {};\n\n const { passages: passagesErrors } = errors || {};\n const {\n teacherInstructions: teacherInstructionsError,\n title: titleError,\n subtitle: subtitleError,\n author: authorError,\n text: textError,\n } = (passagesErrors && passagesErrors[passageIndex]) || {};\n\n const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;\n const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;\n\n const getPluginProps = (customConfiguration) => ({ ...baseInputConfiguration, ...customConfiguration });\n\n return (\n <React.Fragment>\n {teacherInstructionsEnabled && (\n <StyledInputContainer label={teacherInstructions.label}>\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n markup={passages[passageIndex].teacherInstructions || ''}\n onChange={(value) => this.handleChange('teacherInstructions', value)}\n nonEmpty={false}\n error={teacherInstructionsError}\n maxImageWidth={(maxImageWidth && maxImageWidth.teacherInstructions) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.teacherInstructions) || defaultImageMaxHeight}\n mathMlOptions={mathMlOptions}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n pluginProps={getPluginProps(teacherInstructions?.inputConfiguration)}\n />\n {teacherInstructionsError && <ErrorText>{teacherInstructionsError}</ErrorText>}\n </StyledInputContainer>\n )}\n\n {titleEnabled && (\n <StyledInputContainer label={title.label}>\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n markup={passages[passageIndex].title || ''}\n onChange={(value) => this.handleChange('title', value)}\n nonEmpty={false}\n error={titleError}\n mathMlOptions={mathMlOptions}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n pluginProps={getPluginProps(title?.inputConfiguration)}\n />\n {titleError && <ErrorText>{titleError}</ErrorText>}\n </StyledInputContainer>\n )}\n\n {subtitleEnabled && (\n <StyledInputContainer label={subtitle.label}>\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n markup={passages[passageIndex].subtitle || ''}\n onChange={(value) => this.handleChange('subtitle', value)}\n nonEmpty={false}\n error={subtitleError}\n mathMlOptions={mathMlOptions}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n pluginProps={getPluginProps(subtitle?.inputConfiguration)}\n />\n {subtitleError && <ErrorText>{subtitleError}</ErrorText>}\n </StyledInputContainer>\n )}\n\n {authorEnabled && (\n <StyledInputContainer label={author.label}>\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n markup={passages[passageIndex].author || ''}\n onChange={(value) => this.handleChange('author', value)}\n nonEmpty={false}\n error={authorError}\n mathMlOptions={mathMlOptions}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n pluginProps={getPluginProps(author?.inputConfiguration)}\n />\n {authorError && <ErrorText>{authorError}</ErrorText>}\n </StyledInputContainer>\n )}\n\n {textEnabled && (\n <StyledInputContainer label={text.label}>\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n markup={passages[passageIndex].text || ''}\n onChange={(value) => this.handleChange('text', value)}\n imageSupport={imageSupport}\n uploadSoundSupport={uploadSoundSupport}\n nonEmpty={false}\n error={textError}\n maxImageWidth={(maxImageWidth && maxImageWidth.text) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.text) || defaultImageMaxHeight}\n mathMlOptions={mathMlOptions}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n pluginProps={getPluginProps(text?.inputConfiguration)}\n />\n {textError && <ErrorText>{textError}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aAAa,IAAIA,aAAa,CAACO,IAAI,IAAKc,oBAAqB;MAC7EpB,cAAc,EAAGA,cAAc,IAAIA,cAAc,CAACM,IAAI,IAAKgB,qBAAsB;MACjFrB,aAAa,EAAEA,aAAc;MAC7BiC,uBAAuB,EAAE,CAAC;QAAEC,QAAQ,EAAE;MAAU,CAAC,EAAE;QAAEA,QAAQ,EAAE;MAAU,CAAC,CAAE;MAC5EC,WAAW,EAAEb,cAAc,CAACjB,IAAI,EAAE+B,kBAAkB;IAAE,CACvD,CAAC,EACDlB,SAAS,iBAAIhF,MAAA,CAAAkB,OAAA,CAAAoE,aAAA,CAACnD,SAAS,QAAE6C,SAAqB,CAC3B,CAEV,CAAC;EAErB;AACF;AAACmB,OAAA,CAAAzD,gBAAA,GAAAA,gBAAA;AAAA,IAAAK,gBAAA,CAAA7B,OAAA,EA9JYwB,gBAAgB,eACR;EACjBS,cAAc,EAAEiD,kBAAS,CAACC,IAAI,CAACC,UAAU;EACzCpD,KAAK,EAAEkD,kBAAS,CAACG,MAAM,CAACD,UAAU;EAClC7C,aAAa,EAAE2C,kBAAS,CAACG,MAAM,CAACD,UAAU;EAC1C5C,YAAY,EAAE0C,kBAAS,CAACG,MAAM,CAACD,UAAU;EACzClD,YAAY,EAAEgD,kBAAS,CAACI,MAAM,CAACF,UAAU;EACzC3C,kBAAkB,EAAEyC,kBAAS,CAACG,MAAM,CAACD;AACvC,CAAC;AAAA,IAAAvD,gBAAA,CAAA7B,OAAA,EARUwB,gBAAgB,kBAUL;EACpBU,YAAY,EAAE;AAChB,CAAC;AAAA,IAAAqD,QAAA,GAAAN,OAAA,CAAAjF,OAAA,GAoJYwB,gBAAgB","ignoreList":[]}
|
package/configure/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/passage-configure",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.1",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "src/index.js",
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
"@mui/icons-material": "^7.3.4",
|
|
14
14
|
"@mui/material": "^7.3.4",
|
|
15
15
|
"@pie-framework/pie-configure-events": "^1.3.0",
|
|
16
|
-
"@pie-lib/config-ui": "
|
|
17
|
-
"@pie-lib/editable-html": "
|
|
18
|
-
"lodash": "^4.17.
|
|
19
|
-
"prop-types": "^15.
|
|
20
|
-
"react": "18.
|
|
21
|
-
"react-dom": "18.
|
|
16
|
+
"@pie-lib/config-ui": "12.1.1-next.3",
|
|
17
|
+
"@pie-lib/editable-html-tip-tap": "1.1.1-next.3",
|
|
18
|
+
"lodash-es": "^4.17.23",
|
|
19
|
+
"prop-types": "^15.8.1",
|
|
20
|
+
"react": "18.3.1",
|
|
21
|
+
"react-dom": "18.3.1"
|
|
22
22
|
}
|
|
23
23
|
}
|
package/controller/lib/index.js
CHANGED
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.createDefaultModel = createDefaultModel;
|
|
8
8
|
exports.model = model;
|
|
9
9
|
exports.validate = exports.normalize = void 0;
|
|
10
|
-
var
|
|
10
|
+
var _lodashEs = require("lodash-es");
|
|
11
11
|
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
12
12
|
const getContent = html => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');
|
|
13
13
|
const checkNullish = value => value !== null && value !== undefined;
|
|
@@ -67,11 +67,11 @@ const validate = (model = {}, config = {}) => {
|
|
|
67
67
|
err[field] = 'This field is required.';
|
|
68
68
|
}
|
|
69
69
|
});
|
|
70
|
-
if (!(0,
|
|
70
|
+
if (!(0, _lodashEs.isEmpty)(err)) {
|
|
71
71
|
passagesErrors[index] = err;
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
|
-
if (!(0,
|
|
74
|
+
if (!(0, _lodashEs.isEmpty)(passagesErrors)) {
|
|
75
75
|
errors.passages = passagesErrors;
|
|
76
76
|
}
|
|
77
77
|
return errors;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["_lodashEs","require","_defaults","_interopRequireDefault","getContent","html","replace","checkNullish","value","undefined","isEnabled","defaultValue","createDefaultModel","model","Promise","resolve","defaults","normalize","question","exports","normalizeTeacherInstructions","instructions","env","role","mode","session","normalizedQuestion","normalizedPassages","passages","map","passage","index","teacherInstructions","teacherInstructionsEnabled","label","title","titleEnabled","subtitle","subtitleEnabled","author","authorEnabled","text","textEnabled","validate","config","errors","passagesErrors","forEach","err","field","required","isEmpty"],"sources":["../src/index.js"],"sourcesContent":["import { isEmpty } from 'lodash-es';\n\nimport defaults from './defaults';\n\nconst getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nconst checkNullish = (value) => value !== null && value !== undefined;\n\nconst isEnabled = (value, defaultValue) => (checkNullish(value) ? value : defaultValue);\n\nexport function createDefaultModel(model = {}) {\n return new Promise((resolve) => {\n resolve({ ...defaults, ...model });\n });\n}\n\nexport const normalize = (question) => ({ ...defaults, ...question });\n\nconst normalizeTeacherInstructions = (instructions, env) => {\n const { role, mode } = env;\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n return instructions || '';\n }\n\n return '';\n};\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n */\nexport async function model(question, session, env) {\n const normalizedQuestion = normalize(question);\n\n const normalizedPassages = normalizedQuestion.passages.map((passage, index) => ({\n teacherInstructions: isEnabled(passage.teacherInstructionsEnabled, normalizedQuestion.teacherInstructionsEnabled)\n ? normalizeTeacherInstructions(passage.teacherInstructions, env)\n : '',\n label: getContent(passage.title) ? passage.title : `Passage ${index + 1}`,\n title: isEnabled(passage.titleEnabled, normalizedQuestion.titleEnabled) ? passage.title || '' : '',\n subtitle: isEnabled(passage.subtitleEnabled, normalizedQuestion.subtitleEnabled) ? passage.subtitle || '' : '',\n author: isEnabled(passage.authorEnabled, normalizedQuestion.authorEnabled) ? passage.author || '' : '',\n text: isEnabled(passage.textEnabled, normalizedQuestion.textEnabled) ? passage.text || '' : '',\n }));\n\n return {\n ...normalizedQuestion,\n passages: normalizedPassages,\n };\n}\n\nexport const validate = (model = {}, config = {}) => {\n const errors = {};\n const passagesErrors = {};\n\n (model.passages || []).forEach((passage, index) => {\n const err = {};\n\n ['teacherInstructions', 'title', 'subtitle', 'author', 'text'].forEach((field) => {\n if (config[field]?.required && !getContent(passage[field])) {\n err[field] = 'This field is required.';\n }\n });\n\n if (!isEmpty(err)) {\n passagesErrors[index] = err;\n }\n });\n\n if (!isEmpty(passagesErrors)) {\n errors.passages = passagesErrors;\n }\n\n return errors;\n};\n"],"mappings":";;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,MAAMG,UAAU,GAAIC,IAAI,IAAK,CAACA,IAAI,IAAI,EAAE,EAAEC,OAAO,CAAC,oCAAoC,EAAE,EAAE,CAAC;AAE3F,MAAMC,YAAY,GAAIC,KAAK,IAAKA,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAKC,SAAS;AAErE,MAAMC,SAAS,GAAGA,CAACF,KAAK,EAAEG,YAAY,KAAMJ,YAAY,CAACC,KAAK,CAAC,GAAGA,KAAK,GAAGG,YAAa;AAEhF,SAASC,kBAAkBA,CAACC,KAAK,GAAG,CAAC,CAAC,EAAE;EAC7C,OAAO,IAAIC,OAAO,CAAEC,OAAO,IAAK;IAC9BA,OAAO,CAAC;MAAE,GAAGC,iBAAQ;MAAE,GAAGH;IAAM,CAAC,CAAC;EACpC,CAAC,CAAC;AACJ;AAEO,MAAMI,SAAS,GAAIC,QAAQ,KAAM;EAAE,GAAGF,iBAAQ;EAAE,GAAGE;AAAS,CAAC,CAAC;AAACC,OAAA,CAAAF,SAAA,GAAAA,SA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perty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _client = require("react-dom/client");
|
|
10
|
-
var
|
|
10
|
+
var _lodashEs = require("lodash-es");
|
|
11
11
|
var _debug = _interopRequireDefault(require("debug"));
|
|
12
12
|
var _stimulusTabs = _interopRequireDefault(require("./stimulus-tabs"));
|
|
13
13
|
const log = (0, _debug.default)('pie-element:passage:print');
|
|
@@ -39,7 +39,7 @@ class PassagePrint extends HTMLElement {
|
|
|
39
39
|
this._options = null;
|
|
40
40
|
this._session = [];
|
|
41
41
|
this._root = null;
|
|
42
|
-
this._rerender = (0,
|
|
42
|
+
this._rerender = (0, _lodashEs.debounce)(() => {
|
|
43
43
|
if (this._model && this._session) {
|
|
44
44
|
if (this._model.passages && this._model.passages.length > 0) {
|
|
45
45
|
const printPassage = preparePrintPassage(this._model, this._options);
|
package/lib/print.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"print.js","names":["_react","_interopRequireDefault","require","_client","
|
|
1
|
+
{"version":3,"file":"print.js","names":["_react","_interopRequireDefault","require","_client","_lodashEs","_debug","_stimulusTabs","log","debug","checkNullish","value","undefined","isEnabled","defaultValue","preparePrintPassage","model","opts","isInstructor","role","teacherInstructionsEnabled","titleEnabled","authorEnabled","subtitleEnabled","textEnabled","passages","map","passage","index","id","teacherInstructions","label","title","author","subtitle","text","PassagePrint","HTMLElement","constructor","_model","_options","_session","_root","_rerender","debounce","length","printPassage","element","React","createElement","StimulusTabs","disabledTabs","tabs","createRoot","render","leading","trailing","s","options","o","connectedCallback","disconnectedCallback","unmount","exports","default"],"sources":["../src/print.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { debounce } from 'lodash-es';\nimport debug from 'debug';\n\nimport StimulusTabs from './stimulus-tabs';\n\nconst log = debug('pie-element:passage:print');\n\nconst checkNullish = (value) => value !== null && value !== undefined;\n\nconst isEnabled = (value, defaultValue) => (checkNullish(value) ? value : defaultValue);\n\nconst preparePrintPassage = (model, opts) => {\n const isInstructor = opts.role === 'instructor';\n\n // TODO: also update '../../configure/src/defaults.js' and '../../controller/src/defaults.js' when updating defaultValue\n const teacherInstructionsEnabled = isEnabled(model.teacherInstructionsEnabled, true);\n const titleEnabled = isEnabled(model.titleEnabled, true);\n const authorEnabled = isEnabled(model.authorEnabled, false);\n const subtitleEnabled = isEnabled(model.subtitleEnabled, true);\n const textEnabled = isEnabled(model.textEnabled, true);\n\n return model.passages.map((passage, index) => ({\n id: index,\n teacherInstructions: isEnabled(passage.teacherInstructionsEnabled, teacherInstructionsEnabled)\n ? (isInstructor && passage.teacherInstructions) || ''\n : '',\n label: passage.title || `Passage ${index + 1}`,\n title: isEnabled(passage.titleEnabled, titleEnabled) ? passage.title || '' : '',\n author: isEnabled(passage.authorEnabled, authorEnabled) ? passage.author || '' : '',\n subtitle: isEnabled(passage.subtitleEnabled, subtitleEnabled) ? passage.subtitle || '' : '',\n text: isEnabled(passage.textEnabled, textEnabled) ? passage.text || '' : '',\n }));\n};\n\nexport default class PassagePrint extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._options = null;\n this._session = [];\n this._root = null;\n\n this._rerender = debounce(\n () => {\n if (this._model && this._session) {\n if (this._model.passages && this._model.passages.length > 0) {\n const printPassage = preparePrintPassage(this._model, this._options);\n\n const element = React.createElement(StimulusTabs, {\n disabledTabs: true,\n tabs: printPassage,\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(element);\n }\n } else {\n log('skip');\n }\n },\n 50,\n { leading: false, trailing: true },\n );\n }\n\n set model(s) {\n this._model = s;\n this._rerender();\n }\n\n set options(o) {\n this._options = o;\n }\n\n connectedCallback() {}\n\n disconnectedCallback() {\n if (this._root) {\n this._root.unmount();\n }\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAA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AAK,EAAE;YACf,IAAI,CAACA,KAAK,GAAG,IAAAW,kBAAU,EAAC,IAAI,CAAC;UAC/B;UACA,IAAI,CAACX,KAAK,CAACY,MAAM,CAACP,OAAO,CAAC;QAC5B;MACF,CAAC,MAAM;QACLvC,GAAG,CAAC,MAAM,CAAC;MACb;IACF,CAAC,EACD,EAAE,EACF;MAAE+C,OAAO,EAAE,KAAK;MAAEC,QAAQ,EAAE;IAAK,CACnC,CAAC;EACH;EAEA,IAAIxC,KAAKA,CAACyC,CAAC,EAAE;IACX,IAAI,CAAClB,MAAM,GAAGkB,CAAC;IACf,IAAI,CAACd,SAAS,CAAC,CAAC;EAClB;EAEA,IAAIe,OAAOA,CAACC,CAAC,EAAE;IACb,IAAI,CAACnB,QAAQ,GAAGmB,CAAC;EACnB;EAEAC,iBAAiBA,CAAA,EAAG,CAAC;EAErBC,oBAAoBA,CAAA,EAAG;IACrB,IAAI,IAAI,CAACnB,KAAK,EAAE;MACd,IAAI,CAACA,KAAK,CAACoB,OAAO,CAAC,CAAC;IACtB;EACF;AACF;AAACC,OAAA,CAAAC,OAAA,GAAA5B,YAAA","ignoreList":[]}
|
package/lib/stimulus-tabs.js
CHANGED
|
@@ -46,7 +46,14 @@ const TabStyled = (0, _styles.styled)(_Tab.default)(({
|
|
|
46
46
|
background: theme.palette.common.white,
|
|
47
47
|
// replace with color.background() once PD-2801 is DONE
|
|
48
48
|
fontSize: 'inherit',
|
|
49
|
-
|
|
49
|
+
fontFamily: 'Roboto, sans-serif',
|
|
50
|
+
opacity: 0.7,
|
|
51
|
+
color: theme.palette.common.black,
|
|
52
|
+
// remove when PD-2801 is DONE
|
|
53
|
+
'&.Mui-selected': {
|
|
54
|
+
opacity: 1,
|
|
55
|
+
color: theme.palette.common.black
|
|
56
|
+
}
|
|
50
57
|
}));
|
|
51
58
|
class StimulusTabs extends _react.default.Component {
|
|
52
59
|
constructor(...args) {
|
|
@@ -211,7 +218,11 @@ class StimulusTabs extends _react.default.Component {
|
|
|
211
218
|
position: 'sticky',
|
|
212
219
|
top: 0,
|
|
213
220
|
background: _renderUi.color.background(),
|
|
214
|
-
color: _renderUi.color.text()
|
|
221
|
+
color: _renderUi.color.text(),
|
|
222
|
+
fontFamily: 'Roboto, sans-serif',
|
|
223
|
+
'& .MuiTabs-indicator': {
|
|
224
|
+
backgroundColor: '#f50057'
|
|
225
|
+
}
|
|
215
226
|
},
|
|
216
227
|
value: activeTab,
|
|
217
228
|
onChange: this.handleChange
|
package/lib/stimulus-tabs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stimulus-tabs.js","names":["_react","_interopRequireDefault","require","_propTypes","_Tabs","_Tab","_styles","_renderUi","PassagesContainer","styled","flexGrow","backgroundColor","color","background","text","borderCollapse","padding","textAlign","Passage","theme","spacing","PassageTitle","fontSize","PassageSubtitle","PassageAuthor","TabStyled","Tab","palette","common","white","black","StimulusTabs","React","Component","constructor","args","_defineProperty2","default","activeTab","event","setState","setTimeout","tabChangeEvent","CustomEvent","detail","tab","window","dispatchEvent","currentTabId","key","tabs","props","newTabIndex","currentIndex","findIndex","id","length","preventDefault","handleChange","document","getElementById","focus","div","createElement","innerHTML","replace","audio","querySelector","source","setAttribute","getAttribute","removeAttribute","appendChild","renderInstructions","teacherInstructions","disabledTabs","teacherInstructionsDiv","PreviewPrompt","tagName","className","defaultClassName","prompt","Collapsible","labels","hidden","visible","renderTab","role","title","subtitle","Purpose","purpose","dangerouslySetInnerHTML","__html","parsedText","author","render","model","state","extraCSSRules","selectedTab","find","UiLayout","map","Fragment","sx","position","top","value","onChange","label","tabIndex","onFocus","onKeyDown","handleKeyDown","propTypes","PropTypes","arrayOf","shape","number","isRequired","string","bool","object","_default","exports"],"sources":["../src/stimulus-tabs.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Tabs from '@mui/material/Tabs';\nimport Tab from '@mui/material/Tab';\nimport { styled } from '@mui/material/styles';\nimport { Collapsible, color, PreviewPrompt, Purpose, UiLayout } from '@pie-lib/render-ui';\n\nconst PassagesContainer = styled('div')({\n flexGrow: 1,\n backgroundColor: color.background(),\n color: color.text(),\n '&:not(.MathJax) table': {\n borderCollapse: 'collapse',\n },\n '&:not(.MathJax) table td, &:not(.MathJax) table th': {\n padding: '.6em 1em',\n textAlign: 'left',\n },\n});\n\nconst Passage = styled('div')(({ theme }) => ({\n backgroundColor: color.background(),\n color: color.text(),\n padding: theme.spacing(2),\n}));\n\nconst PassageTitle = styled('div')({\n fontSize: '1.75rem',\n});\n\nconst PassageSubtitle = styled('div')({\n fontSize: '1.5rem',\n});\n\nconst PassageAuthor = styled('div')({\n fontSize: '1.25rem',\n});\n\nconst TabStyled = styled(Tab)(({ theme }) => ({\n background: theme.palette.common.white, // replace with color.background() once PD-2801 is DONE\n fontSize: 'inherit',\n color: theme.palette.common.black, // remove when PD-2801 is DONE\n}));\n\nclass StimulusTabs extends React.Component {\n state = {\n activeTab: 0,\n };\n\n handleChange = (event, activeTab) => {\n this.setState(() => ({ activeTab }));\n\n setTimeout(() => {\n const tabChangeEvent = new CustomEvent('pie-ui-passage-tabChanged', {\n detail: { tab: activeTab },\n });\n\n window.dispatchEvent(tabChangeEvent);\n });\n };\n\n handleKeyDown = (event, currentTabId) => {\n const { key } = event;\n const { tabs } = this.props;\n\n let newTabIndex = -1;\n const currentIndex = tabs.findIndex((tab) => tab.id === currentTabId);\n\n switch (key) {\n case 'ArrowRight':\n // Move to the next tab\n newTabIndex = (currentIndex + 1) % tabs.length;\n break;\n case 'ArrowLeft':\n // Move to the previous tab\n newTabIndex = (currentIndex - 1 + tabs.length) % tabs.length;\n break;\n // Commented out ArrowDown and ArrowUp for future vertical tab navigation\n // case 'ArrowDown':\n // // Move to the next tab (for vertical alignment)\n // newTabIndex = (currentIndex + 1) % tabs.length;\n // break;\n // case 'ArrowUp':\n // // Move to the previous tab (for vertical alignment)\n // newTabIndex = (currentIndex - 1 + tabs.length) % tabs.length;\n // break;\n case 'Home':\n // Move to the first tab\n newTabIndex = 0;\n break;\n case 'End':\n // Move to the last tab\n newTabIndex = tabs.length - 1;\n break;\n case 'Enter':\n case ' ':\n // Activate the current tab\n newTabIndex = currentIndex;\n break;\n default:\n break;\n }\n\n if (newTabIndex !== -1) {\n event.preventDefault();\n this.handleChange(event, tabs[newTabIndex].id);\n document.getElementById(`button-${tabs[newTabIndex].id}`).focus();\n }\n };\n\n parsedText = (text = '') => {\n // fix imported audio content for Safari PD-1391\n const div = document.createElement('div');\n div.innerHTML = text.replace(/(<br\\/>\\n)/g, '<br/>');\n\n const audio = div.querySelector('audio');\n\n if (audio) {\n const source = document.createElement('source');\n\n source.setAttribute('type', 'audio/mp3');\n source.setAttribute('src', audio.getAttribute('src'));\n\n audio.removeAttribute('src');\n audio.appendChild(source);\n }\n\n return div.innerHTML;\n };\n\n renderInstructions(teacherInstructions, disabledTabs = false) {\n if (!teacherInstructions) {\n return;\n }\n\n const teacherInstructionsDiv = (\n <PreviewPrompt\n tagName=\"div\"\n className=\"prompt\"\n defaultClassName=\"teacher-instructions\"\n prompt={teacherInstructions}\n />\n );\n\n if (disabledTabs) {\n return teacherInstructionsDiv;\n }\n\n return (\n <Collapsible\n labels={{\n hidden: 'Show Teacher Instructions',\n visible: 'Hide Teacher Instructions',\n }}\n >\n {teacherInstructionsDiv}\n </Collapsible>\n );\n }\n\n renderTab(tab, disabledTabs) {\n return (\n <Passage key={tab.id} id={`tabpanel-${tab.id}`} role=\"tabpanel\" aria-labelledby={`button-${tab.id}`}>\n {this.renderInstructions(tab.teacherInstructions, disabledTabs)}\n\n {(tab.title || tab.subtitle) && (\n <h2>\n {tab.title && (\n <Purpose purpose=\"passage-title\">\n <PassageTitle dangerouslySetInnerHTML={{ __html: this.parsedText(tab.title) }}/>\n </Purpose>\n )}\n {tab.subtitle && (\n <Purpose purpose=\"passage-subtitle\">\n <PassageSubtitle dangerouslySetInnerHTML={{ __html: this.parsedText(tab.subtitle) }}\n />\n </Purpose>\n )}\n </h2>\n )}\n\n {tab.author && (\n <Purpose purpose=\"passage-author\">\n <PassageAuthor className=\"author\" dangerouslySetInnerHTML={{ __html: this.parsedText(tab.author) }}/>\n </Purpose>\n )}\n\n {tab.text && (\n <Purpose purpose=\"passage-text\">\n <div\n key={tab.id}\n className=\"text\"\n dangerouslySetInnerHTML={{ __html: this.parsedText(tab.text) }}\n />\n </Purpose>\n )}\n </Passage>\n );\n }\n\n render() {\n const { model, tabs, disabledTabs } = this.props;\n const { activeTab } = this.state;\n\n if (!tabs?.length) {\n return;\n }\n\n const { extraCSSRules } = model || {};\n const selectedTab = (tabs || []).find((tab) => tab.id === activeTab);\n\n return (\n <UiLayout extraCSSRules={extraCSSRules}>\n <PassagesContainer className=\"passages\">\n {disabledTabs || tabs.length === 1 ? (\n tabs.map((tab) => this.renderTab(tab, disabledTabs))\n ) : (\n <>\n <Tabs\n sx={{ position: 'sticky', top: 0, background: color.background(), color: color.text() }}\n value={activeTab}\n onChange={this.handleChange}\n >\n {tabs.map((tab) => (\n <TabStyled\n key={tab.id}\n id={`button-${tab.id}`}\n label={\n <Purpose purpose=\"passage-label\">\n <span dangerouslySetInnerHTML={{ __html: this.parsedText(tab.label) }}/>\n </Purpose>\n }\n value={tab.id}\n tabIndex={activeTab === tab.id ? 0 : -1}\n aria-controls={`tabpanel-${tab.id}`}\n aria-selected={activeTab === tab.id}\n onFocus={() => this.handleChange(null, tab.id)}\n onKeyDown={(event) => this.handleKeyDown(event, tab.id)}\n />\n ))}\n </Tabs>\n {selectedTab ? this.renderTab(selectedTab, disabledTabs) : null}\n </>\n )}\n </PassagesContainer>\n </UiLayout>\n );\n }\n}\n\nStimulusTabs.propTypes = {\n tabs: PropTypes.arrayOf(\n PropTypes.shape({\n id: PropTypes.number.isRequired,\n label: PropTypes.string.isRequired,\n title: PropTypes.string.isRequired,\n subtitle: PropTypes.string,\n author: PropTypes.string,\n text: PropTypes.string.isRequired,\n teacherInstructions: PropTypes.string,\n }).isRequired,\n ).isRequired,\n disab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kBAAS,CAACK,MAAM;IACxB3G,IAAI,EAAEsG,kBAAS,CAACK,MAAM,CAACD,UAAU;IACjC9C,mBAAmB,EAAE0C,kBAAS,CAACK;EACjC,CAAC,CAAC,CAACD,UACL,CAAC,CAACA,UAAU;EACZ7C,YAAY,EAAEyC,kBAAS,CAACM,IAAI;EAC5BzB,KAAK,EAAEmB,kBAAS,CAACO;AACnB,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAxF,OAAA,GAEaN,YAAY","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"stimulus-tabs.js","names":["_react","_interopRequireDefault","require","_propTypes","_Tabs","_Tab","_styles","_renderUi","PassagesContainer","styled","flexGrow","backgroundColor","color","background","text","borderCollapse","padding","textAlign","Passage","theme","spacing","PassageTitle","fontSize","PassageSubtitle","PassageAuthor","TabStyled","Tab","palette","common","white","fontFamily","opacity","black","StimulusTabs","React","Component","constructor","args","_defineProperty2","default","activeTab","event","setState","setTimeout","tabChangeEvent","CustomEvent","detail","tab","window","dispatchEvent","currentTabId","key","tabs","props","newTabIndex","currentIndex","findIndex","id","length","preventDefault","handleChange","document","getElementById","focus","div","createElement","innerHTML","replace","audio","querySelector","source","setAttribute","getAttribute","removeAttribute","appendChild","renderInstructions","teacherInstructions","disabledTabs","teacherInstructionsDiv","PreviewPrompt","tagName","className","defaultClassName","prompt","Collapsible","labels","hidden","visible","renderTab","role","title","subtitle","Purpose","purpose","dangerouslySetInnerHTML","__html","parsedText","author","render","model","state","extraCSSRules","selectedTab","find","UiLayout","map","Fragment","sx","position","top","value","onChange","label","tabIndex","onFocus","onKeyDown","handleKeyDown","propTypes","PropTypes","arrayOf","shape","number","isRequired","string","bool","object","_default","exports"],"sources":["../src/stimulus-tabs.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Tabs from '@mui/material/Tabs';\nimport Tab from '@mui/material/Tab';\nimport { styled } from '@mui/material/styles';\nimport { Collapsible, color, PreviewPrompt, Purpose, UiLayout } from '@pie-lib/render-ui';\n\nconst PassagesContainer = styled('div')({\n flexGrow: 1,\n backgroundColor: color.background(),\n color: color.text(),\n '&:not(.MathJax) table': {\n borderCollapse: 'collapse',\n },\n '&:not(.MathJax) table td, &:not(.MathJax) table th': {\n padding: '.6em 1em',\n textAlign: 'left',\n },\n});\n\nconst Passage = styled('div')(({ theme }) => ({\n backgroundColor: color.background(),\n color: color.text(),\n padding: theme.spacing(2),\n}));\n\nconst PassageTitle = styled('div')({\n fontSize: '1.75rem',\n});\n\nconst PassageSubtitle = styled('div')({\n fontSize: '1.5rem',\n});\n\nconst PassageAuthor = styled('div')({\n fontSize: '1.25rem',\n});\n\nconst TabStyled = styled(Tab)(({ theme }) => ({\n background: theme.palette.common.white, // replace with color.background() once PD-2801 is DONE\n fontSize: 'inherit',\n fontFamily: 'Roboto, sans-serif',\n opacity: 0.7,\n color: theme.palette.common.black, // remove when PD-2801 is DONE\n '&.Mui-selected': {\n opacity: 1,\n color: theme.palette.common.black,\n }\n}));\n\nclass StimulusTabs extends React.Component {\n state = {\n activeTab: 0,\n };\n\n handleChange = (event, activeTab) => {\n this.setState(() => ({ activeTab }));\n\n setTimeout(() => {\n const tabChangeEvent = new CustomEvent('pie-ui-passage-tabChanged', {\n detail: { tab: activeTab },\n });\n\n window.dispatchEvent(tabChangeEvent);\n });\n };\n\n handleKeyDown = (event, currentTabId) => {\n const { key } = event;\n const { tabs } = this.props;\n\n let newTabIndex = -1;\n const currentIndex = tabs.findIndex((tab) => tab.id === currentTabId);\n\n switch (key) {\n case 'ArrowRight':\n // Move to the next tab\n newTabIndex = (currentIndex + 1) % tabs.length;\n break;\n case 'ArrowLeft':\n // Move to the previous tab\n newTabIndex = (currentIndex - 1 + tabs.length) % tabs.length;\n break;\n // Commented out ArrowDown and ArrowUp for future vertical tab navigation\n // case 'ArrowDown':\n // // Move to the next tab (for vertical alignment)\n // newTabIndex = (currentIndex + 1) % tabs.length;\n // break;\n // case 'ArrowUp':\n // // Move to the previous tab (for vertical alignment)\n // newTabIndex = (currentIndex - 1 + tabs.length) % tabs.length;\n // break;\n case 'Home':\n // Move to the first tab\n newTabIndex = 0;\n break;\n case 'End':\n // Move to the last tab\n newTabIndex = tabs.length - 1;\n break;\n case 'Enter':\n case ' ':\n // Activate the current tab\n newTabIndex = currentIndex;\n break;\n default:\n break;\n }\n\n if (newTabIndex !== -1) {\n event.preventDefault();\n this.handleChange(event, tabs[newTabIndex].id);\n document.getElementById(`button-${tabs[newTabIndex].id}`).focus();\n }\n };\n\n parsedText = (text = '') => {\n // fix imported audio content for Safari PD-1391\n const div = document.createElement('div');\n div.innerHTML = text.replace(/(<br\\/>\\n)/g, '<br/>');\n\n const audio = div.querySelector('audio');\n\n if (audio) {\n const source = document.createElement('source');\n\n source.setAttribute('type', 'audio/mp3');\n source.setAttribute('src', audio.getAttribute('src'));\n\n audio.removeAttribute('src');\n audio.appendChild(source);\n }\n\n return div.innerHTML;\n };\n\n renderInstructions(teacherInstructions, disabledTabs = false) {\n if (!teacherInstructions) {\n return;\n }\n\n const teacherInstructionsDiv = (\n <PreviewPrompt\n tagName=\"div\"\n className=\"prompt\"\n defaultClassName=\"teacher-instructions\"\n prompt={teacherInstructions}\n />\n );\n\n if (disabledTabs) {\n return teacherInstructionsDiv;\n }\n\n return (\n <Collapsible\n labels={{\n hidden: 'Show Teacher Instructions',\n visible: 'Hide Teacher Instructions',\n }}\n >\n {teacherInstructionsDiv}\n </Collapsible>\n );\n }\n\n renderTab(tab, disabledTabs) {\n return (\n <Passage key={tab.id} id={`tabpanel-${tab.id}`} role=\"tabpanel\" aria-labelledby={`button-${tab.id}`}>\n {this.renderInstructions(tab.teacherInstructions, disabledTabs)}\n\n {(tab.title || tab.subtitle) && (\n <h2>\n {tab.title && (\n <Purpose purpose=\"passage-title\">\n <PassageTitle dangerouslySetInnerHTML={{ __html: this.parsedText(tab.title) }}/>\n </Purpose>\n )}\n {tab.subtitle && (\n <Purpose purpose=\"passage-subtitle\">\n <PassageSubtitle dangerouslySetInnerHTML={{ __html: this.parsedText(tab.subtitle) }}\n />\n </Purpose>\n )}\n </h2>\n )}\n\n {tab.author && (\n <Purpose purpose=\"passage-author\">\n <PassageAuthor className=\"author\" dangerouslySetInnerHTML={{ __html: this.parsedText(tab.author) }}/>\n </Purpose>\n )}\n\n {tab.text && (\n <Purpose purpose=\"passage-text\">\n <div\n key={tab.id}\n className=\"text\"\n dangerouslySetInnerHTML={{ __html: this.parsedText(tab.text) }}\n />\n </Purpose>\n )}\n </Passage>\n );\n }\n\n render() {\n const { model, tabs, disabledTabs } = this.props;\n const { activeTab } = this.state;\n\n if (!tabs?.length) {\n return;\n }\n\n const { extraCSSRules } = model || {};\n const selectedTab = (tabs || []).find((tab) => tab.id === activeTab);\n\n return (\n <UiLayout extraCSSRules={extraCSSRules}>\n <PassagesContainer className=\"passages\">\n {disabledTabs || tabs.length === 1 ? (\n tabs.map((tab) => this.renderTab(tab, disabledTabs))\n ) : (\n <>\n <Tabs\n sx={{ \n position: 'sticky', \n top: 0, \n background: color.background(), \n color: color.text(),\n fontFamily: 'Roboto, sans-serif',\n '& .MuiTabs-indicator': {\n backgroundColor: '#f50057',\n }\n }}\n value={activeTab}\n onChange={this.handleChange}\n >\n {tabs.map((tab) => (\n <TabStyled\n key={tab.id}\n id={`button-${tab.id}`}\n label={\n <Purpose purpose=\"passage-label\">\n <span dangerouslySetInnerHTML={{ __html: this.parsedText(tab.label) }}/>\n </Purpose>\n }\n value={tab.id}\n tabIndex={activeTab === tab.id ? 0 : -1}\n aria-controls={`tabpanel-${tab.id}`}\n aria-selected={activeTab === tab.id}\n onFocus={() => this.handleChange(null, tab.id)}\n onKeyDown={(event) => this.handleKeyDown(event, tab.id)}\n />\n ))}\n </Tabs>\n {selectedTab ? this.renderTab(selectedTab, disabledTabs) : null}\n </>\n )}\n </PassagesContainer>\n </UiLayout>\n );\n }\n}\n\nStimulusTabs.propTypes = {\n tabs: PropTypes.arrayOf(\n PropTypes.shape({\n id: PropTypes.number.isRequired,\n label: PropTypes.string.isRequired,\n title: PropTypes.string.isRequired,\n subtitle: PropTypes.string,\n author: PropTypes.string,\n text: PropTypes.string.isRequired,\n teacherInstructions: PropTypes.string,\n }).isRequired,\n ).isRequired,\n disabledTabs: PropTypes.bool,\n model: PropTypes.object,\n};\n\nexport default StimulusTabs;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,IAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAEA,MAAMM,iBAAiB,GAAG,IAAAC,cAAM,EAAC,KAAK,CAAC,CAAC;EACtCC,QAAQ,EAAE,CAAC;EACXC,eAAe,EAAEC,eAAK,CAACC,UAAU,CAAC,CAAC;EACnCD,KAAK,EAAEA,eAAK,CAACE,IAAI,CAAC,CAAC;EACnB,uBAAuB,EAAE;IACvBC,cAAc,EAAE;EAClB,CAAC;EACD,oDAAoD,EAAE;IACpDC,OAAO,EAAE,UAAU;IACnBC,SAAS,EAAE;EACb;AACF,CAAC,CAAC;AAEF,MAAMC,OAAO,GAAG,IAAAT,cAAM,EAAC,KAAK,CAAC,CAAC,CAAC;EAAEU;AAAM,CAAC,MAAM;EAC5CR,eAAe,EAAEC,eAAK,CAACC,UAAU,CAAC,CAAC;EACnCD,KAAK,EAAEA,eAAK,CAACE,IAAI,CAAC,CAAC;EACnBE,OAAO,EAAEG,KAAK,CAACC,OAAO,CAAC,CAAC;AAC1B,CAAC,CAAC,CAAC;AAEH,MAAMC,YAAY,GAAG,IAAAZ,cAAM,EAAC,KAAK,CAAC,CAAC;EACjCa,QAAQ,EAAE;AACZ,CAAC,CAAC;AAEF,MAAMC,eAAe,GAAG,IAAAd,cAAM,EAAC,KAAK,CA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c,WAAW,EAAEzB,YAAY,CAAC,GAAG,IAC3D,CAEa,CACX,CAAC;EAEf;AACF;AAEA5C,YAAY,CAACoF,SAAS,GAAG;EACvBjE,IAAI,EAAEkE,kBAAS,CAACC,OAAO,CACrBD,kBAAS,CAACE,KAAK,CAAC;IACd/D,EAAE,EAAE6D,kBAAS,CAACG,MAAM,CAACC,UAAU;IAC/BV,KAAK,EAAEM,kBAAS,CAACK,MAAM,CAACD,UAAU;IAClChC,KAAK,EAAE4B,kBAAS,CAACK,MAAM,CAACD,UAAU;IAClC/B,QAAQ,EAAE2B,kBAAS,CAACK,MAAM;IAC1B1B,MAAM,EAAEqB,kBAAS,CAACK,MAAM;IACxB7G,IAAI,EAAEwG,kBAAS,CAACK,MAAM,CAACD,UAAU;IACjC9C,mBAAmB,EAAE0C,kBAAS,CAACK;EACjC,CAAC,CAAC,CAACD,UACL,CAAC,CAACA,UAAU;EACZ7C,YAAY,EAAEyC,kBAAS,CAACM,IAAI;EAC5BzB,KAAK,EAAEmB,kBAAS,CAACO;AACnB,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAxF,OAAA,GAEaN,YAAY","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_dll_react_dom as e,_dll_prop_types as t,_dll_mui__material_styles as a,_dll_react as n,_dll_mui__material as i,_dll_mui__icons_material as s}from"../../../@pie-lib/shared-module@^4.0.1/module/index.js";import{_dll_pie_lib__config_ui as o}from"../../../@pie-lib/config-module@^3.0.1/module/index.js";import{_dll_pie_lib__editable_html_tip_tap as l}from"../../../@pie-lib/editable-html-module@^6.1.2/module/index.js";var r,d=e;r=d.createRoot,d.hydrateRoot;var u={};Object.defineProperty(u,"__esModule",{value:!0});class c extends CustomEvent{constructor(e,t=!1){super(c.TYPE,{bubbles:!0,detail:{update:e,reset:t}}),this.update=e,this.reset=t}}c.TYPE="model.updated";var g=u.ModelUpdatedEvent=c;class p extends CustomEvent{constructor(e,t){super(p.TYPE,{bubbles:!0,detail:{src:e,done:t}}),this.src=e,this.done=t}}p.TYPE="delete.image";var h=u.DeleteImageEvent=p;class m extends CustomEvent{constructor(e){super(m.TYPE,{bubbles:!0,detail:e}),this.handler=e}}m.TYPE="insert.image";var b=u.InsertImageEvent=m;class _ extends CustomEvent{constructor(e,t){super(_.TYPE,{bubbles:!0,detail:{src:e,done:t}}),this.src=e,this.done=t}}_.TYPE="delete.sound";var C=u.DeleteSoundEvent=_;class E extends CustomEvent{constructor(e){super(E.TYPE,{bubbles:!0,detail:e}),this.handler=e}}E.TYPE="insert.sound";var f=u.InsertSoundEvent=E;const x=n,S=t,{styled:I}=a,{Button:v}=i,{Dialog:P}=i,{DialogTitle:y}=i,{DialogContent:T}=i,{DialogContentText:R}=i,{DialogActions:q}=i,{RemoveCircle:D}=s,{AddCircle:k}=s,A=I(({label:e,type:t="add",onClick:a})=>{const n="add"===t?k:D;return x.createElement(v,{color:"primary",size:"small",onClick:a},x.createElement(n,{fontSize:"small",color:"primary",style:{marginRight:4}}),e)})({textDecoration:"underline","&:hover":{textDecoration:"underline",backgroundColor:"transparent"},display:"flex",alignItems:"center"}),M=({content:e,cancel:t,title:a,ok:n,open:i,onOk:s,onCancel:o})=>x.createElement(P,{open:i},x.createElement(y,null,a),x.createElement(T,null,x.createElement(R,null,e)),x.createElement(q,null,s&&x.createElement(v,{onClick:s,color:"primary"},n),o&&x.createElement(v,{onClick:o,color:"primary"},t)));M.propTypes={content:S.string.isRequired,title:S.string.isRequired,cancel:S.string.isRequired,ok:S.string.isRequired,open:S.bool.isRequired,onCancel:S.func.isRequired,onOk:S.func.isRequired};const w=n,j=t,{styled:O}=a,{InputContainer:Y}=o,L=l,{ALL_PLUGINS:H}=l;function W(e){let t,a=e[0],n=1;for(;n<e.length;){const i=e[n],s=e[n+1];if(n+=2,("optionalAccess"===i||"optionalCall"===i)&&null==a)return;"access"===i||"optionalAccess"===i?(t=a,a=s(a)):"call"!==i&&"optionalCall"!==i||(a=s((...e)=>a.call(t,...e)),t=void 0)}return a}const z=O(Y)(({theme:e})=>({paddingTop:e.spacing(2),marginBottom:e.spacing(2),width:"100%"})),B=O("div")(({theme:e})=>({fontSize:e.typography.fontSize-2,color:e.palette.error.main,paddingTop:e.spacing(1)}));class $ extends w.Component{static __initStatic(){this.propTypes={onModelChanged:j.func.isRequired,model:j.object.isRequired,configuration:j.object.isRequired,imageSupport:j.object.isRequired,passageIndex:j.number.isRequired,uploadSoundSupport:j.object.isRequired}}static __initStatic2(){this.defaultProps={passageIndex:0}}constructor(e){super(e),$.prototype.__init.call(this)}__init(){this.handleChange=(e,t)=>{const{model:a,onModelChanged:n,passageIndex:i}=this.props;if(!a.passages||i<0||i>=a.passages.length)return;const s=[...a.passages];s[i]={...s[i],[e]:t},n({...a,passages:s})}}render(){const{model:e,configuration:t,imageSupport:a,passageIndex:n,uploadSoundSupport:i}=this.props,{maxImageWidth:s={},maxImageHeight:o={},mathMlOptions:l={},baseInputConfiguration:r={},teacherInstructions:d={},title:u={},subtitle:c={},text:g={},author:p={}}=t||{},{errors:h={},passages:m=[],teacherInstructionsEnabled:b,titleEnabled:_,subtitleEnabled:C,authorEnabled:E,textEnabled:f}=e||{},{passages:x}=h||{},{teacherInstructions:S,title:I,subtitle:v,author:P,text:y}=x&&x[n]||{},T=s&&s.prompt,R=o&&o.prompt,q=e=>({...r,...e});return w.createElement(w.Fragment,null,b&&w.createElement(z,{label:d.label},w.createElement(L,{activePlugins:H,markup:m[n].teacherInstructions||"",onChange:e=>this.handleChange("teacherInstructions",e),nonEmpty:!1,error:S,maxImageWidth:s&&s.teacherInstructions||T,maxImageHeight:o&&o.teacherInstructions||R,mathMlOptions:l,languageCharactersProps:[{language:"spanish"},{language:"special"}],pluginProps:q(W([d,"optionalAccess",e=>e.inputConfiguration]))}),S&&w.createElement(B,null,S)),_&&w.createElement(z,{label:u.label},w.createElement(L,{activePlugins:H,markup:m[n].title||"",onChange:e=>this.handleChange("title",e),nonEmpty:!1,error:I,mathMlOptions:l,languageCharactersProps:[{language:"spanish"},{language:"special"}],pluginProps:q(W([u,"optionalAccess",e=>e.inputConfiguration]))}),I&&w.createElement(B,null,I)),C&&w.createElement(z,{label:c.label},w.createElement(L,{activePlugins:H,markup:m[n].subtitle||"",onChange:e=>this.handleChange("subtitle",e),nonEmpty:!1,error:v,mathMlOptions:l,languageCharactersProps:[{language:"spanish"},{language:"special"}],pluginProps:q(W([c,"optionalAccess",e=>e.inputConfiguration]))}),v&&w.createElement(B,null,v)),E&&w.createElement(z,{label:p.label},w.createElement(L,{activePlugins:H,markup:m[n].author||"",onChange:e=>this.handleChange("author",e),nonEmpty:!1,error:P,mathMlOptions:l,languageCharactersProps:[{language:"spanish"},{language:"special"}],pluginProps:q(W([p,"optionalAccess",e=>e.inputConfiguration]))}),P&&w.createElement(B,null,P)),f&&w.createElement(z,{label:g.label},w.createElement(L,{activePlugins:H,markup:m[n].text||"",onChange:e=>this.handleChange("text",e),imageSupport:a,uploadSoundSupport:i,nonEmpty:!1,error:y,maxImageWidth:s&&s.text||T,maxImageHeight:o&&o.text||R,mathMlOptions:l,languageCharactersProps:[{language:"spanish"},{language:"special"}],pluginProps:q(W([g,"optionalAccess",e=>e.inputConfiguration]))}),y&&w.createElement(B,null,y)))}}$.__initStatic(),$.__initStatic2();const F=n,U=t,{styled:G}=a,{Typography:N}=i,{settings:J}=o,{layout:K}=o,{Panel:Q,toggle:V,dropdown:X}=J,Z=G(N)(({theme:e})=>({paddingTop:e.spacing(2),marginBottom:e.spacing(2)}));class ee extends F.Component{static __initStatic(){this.propTypes={onModelChanged:U.func.isRequired,onConfigurationChanged:U.func,model:U.object.isRequired,configuration:U.object.isRequired,imageSupport:U.object.isRequired,uploadSoundSupport:U.object.isRequired,classes:U.object.isRequired}}constructor(e){super(e),ee.prototype.__init.call(this),ee.prototype.__init2.call(this),ee.prototype.__init3.call(this),ee.prototype.__init4.call(this),this.state={showConfirmationDialog:!1,indexToRemove:-1}}__init(){this.getInnerText=e=>(e||"").replaceAll(/<[^>]*>/g,"")}__init2(){this.onDelete=(e,t,a)=>{let n=e.passages;n.splice(t,1),a({...e,passages:n}),this.setState({showConfirmationDialog:!1,indexToRemove:-1})}}__init3(){this.removeAdditionalPassage=e=>{const{model:t={},onModelChanged:a}=this.props,{passages:n=[]}=t,{teacherInstructions:i="",title:s="",subtitle:o="",author:l="",text:r=""}=n[e];this.getInnerText(i).trim()||this.getInnerText(s).trim()||this.getInnerText(o).trim()||this.getInnerText(l).trim()||this.getInnerText(r).trim()?this.setState({showConfirmationDialog:!0,indexToRemove:e}):this.onDelete(t,e,a)}}__init4(){this.addAdditionalPassage=()=>{const{model:e,onModelChanged:t}=this.props,a=[...e.passages,{teacherInstructions:"",title:"",subtitle:"",author:"",text:""}];t({...e,passages:a})}}render(){const{model:e,configuration:t,imageSupport:a,onConfigurationChanged:n,onModelChanged:i,uploadSoundSupport:s}=this.props,{settingsPanelDisabled:o,language:l={},languageChoices:r={},teacherInstructions:d={},title:u={},subtitle:c={},text:g={},author:p={},additionalPassage:h={}}=t||{},{extraCSSRules:m,passages:b}=e||{},_={titleEnabled:u&&u.settings&&V(u.label),subtitleEnabled:c&&c.settings&&V(c.label),authorEnabled:p&&p.settings&&V(p.label),textEnabled:g&&g.settings&&V(g.label),"additionalPassage.enabled":h&&h.settings&&V(h.label,!0)},C={teacherInstructionsEnabled:d&&d.settings&&V(d.label),"language.enabled":l&&l.settings&&V(l.label,!0),language:l&&l.settings&&l.enabled&&X(r.label,r.options)},E=`${h.label} will be deleted`,{indexToRemove:f,showConfirmationDialog:x}=this.state;return F.createElement(K.ConfigLayout,{extraCSSRules:m,hideSettings:o,settings:F.createElement(Q,{model:e,configuration:t,onChangeModel:e=>i(e),onChangeConfiguration:e=>n(e),groups:{Settings:_,Properties:C}})},b.map((n,o)=>F.createElement(F.Fragment,{key:o},o>0&&F.createElement(Z,{variant:"h5"},h.label),F.createElement($,{imageSupport:a,uploadSoundSupport:s,model:e,configuration:t,passageIndex:o,onModelChanged:i}),o>0&&h.enabled&&F.createElement(A,{type:"remove",label:`Remove ${h.label}`,onClick:()=>this.removeAdditionalPassage(o)}),0===o&&h.enabled&&b.length<2&&F.createElement(A,{label:`Add ${h.label}`,onClick:this.addAdditionalPassage}))),F.createElement(M,{open:x,title:"Warning",content:E,cancel:"Cancel",ok:"Ok",onCancel:()=>this.setState({showConfirmationDialog:!1}),onOk:()=>this.onDelete(e,f,i)}))}}ee.__initStatic();var te={authorEnabled:!0,passages:[{teacherInstructions:"",title:"",subtitle:"",author:"",text:""}],subtitleEnabled:!0,teacherInstructionsEnabled:!0,textEnabled:!0,titleEnabled:!0},ae={baseInputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1},h3:{disabled:!0},blockquote:{disabled:!0},textAlign:{disabled:!0},showParagraphs:{disabled:!1},separateParagraphs:{disabled:!0}},settingsPanelDisabled:!1,title:{settings:!0,label:"Title",inputConfiguration:{audio:{disabled:!0},video:{disabled:!0},image:{disabled:!0},textAlign:{disabled:!1}},required:!0},subtitle:{settings:!0,label:"Subtitle",inputConfiguration:{audio:{disabled:!0},video:{disabled:!0},image:{disabled:!0},textAlign:{disabled:!1}},required:!1},author:{settings:!0,label:"Author",inputConfiguration:{audio:{disabled:!0},video:{disabled:!0},image:{disabled:!0}},required:!1},text:{settings:!0,label:"Text",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1},h3:{disabled:!1},blockquote:{disabled:!1},textAlign:{disabled:!1}},required:!0},teacherInstructions:{settings:!0,label:"Teacher Instructions",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}},required:!1},maxImageWidth:{teacherInstructions:300,text:300},maxImageHeight:{teacherInstructions:300,text:300},mathMlOptions:{mmlOutput:!1,mmlEditing:!1},language:{settings:!1,label:"Specify Language",enabled:!1},languageChoices:{label:"Language Choices",options:[]},additionalPassage:{settings:!0,label:"Additional Passage",enabled:!1}};const ne=n;class ie extends HTMLElement{static __initStatic(){this.createDefaultModel=(e={})=>({...te,...e})}constructor(){super(),this._root=null,this._model=ie.createDefaultModel(),this._configuration=ae}set model(e){this._model=ie.createDefaultModel(e),this.render()}set configuration(e){this._configuration=e,this.render()}connectedCallback(){this.render()}modelChanged(e){this._model=e,this.dispatchEvent(new g(this._model),!0),this.render()}onConfigurationChanged(e){this._configuration=e,this.render()}insertImage(e){this.dispatchEvent(new b(e))}onDeleteImage(e,t){this.dispatchEvent(new h(e,t))}insertSound(e){this.dispatchEvent(new f(e))}onDeleteSound(e,t){this.dispatchEvent(new C(e,t))}render(){if(this._model){const e=ne.createElement(ee,{model:this._model,configuration:this._configuration,onModelChanged:this.modelChanged.bind(this),onConfigurationChanged:this.onConfigurationChanged.bind(this),imageSupport:{add:this.insertImage.bind(this),delete:this.onDeleteImage.bind(this)},uploadSoundSupport:{add:this.insertSound.bind(this),delete:this.onDeleteSound.bind(this)}});this._root||(this._root=r(this)),this._root.render(e)}}disconnectedCallback(){this._root&&this._root.unmount()}}ie.__initStatic();export{ie as default};
|