@instructure/quiz-core 22.10.1 → 22.11.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 (41) hide show
  1. package/es/banks/api/banks.js +18 -97
  2. package/es/banks/components/SharingModal/index.js +6 -3
  3. package/es/banks/components/SharingModal/presenter.js +207 -131
  4. package/es/building/api/items.js +120 -24
  5. package/es/building/api/quizEntries.js +78 -15
  6. package/es/building/components/resources/quizEntry/QuizEntryShow/presenter.js +11 -2
  7. package/es/common/actions/sharedBanks.js +13 -1
  8. package/es/common/actions/sharingModal.js +7 -0
  9. package/es/common/components/resources/quiz/AddContent/Body/index.js +1 -1
  10. package/es/common/components/resources/quiz/AddContent/Body/presenter.js +129 -141
  11. package/es/common/components/resources/quiz/AddContent/Popover/presenter.js +126 -119
  12. package/es/common/components/shared/InteractionTypes/index.js +1 -4
  13. package/es/common/components/shared/InteractionTypes/presenter.js +1 -3
  14. package/es/common/middleware/sharedBanksMiddleware.js +243 -0
  15. package/es/common/records/Item.js +2 -1
  16. package/es/common/records/QuizEntry.js +7 -0
  17. package/es/common/reducers/sharingModal.js +17 -0
  18. package/es/common/util/useRemoteComponent.js +127 -0
  19. package/es/configureStore.js +4 -1
  20. package/es/index.js +3 -2
  21. package/lib/banks/api/banks.js +17 -96
  22. package/lib/banks/components/SharingModal/index.js +5 -2
  23. package/lib/banks/components/SharingModal/presenter.js +205 -129
  24. package/lib/building/api/items.js +120 -23
  25. package/lib/building/api/quizEntries.js +78 -14
  26. package/lib/building/components/resources/quizEntry/QuizEntryShow/presenter.js +10 -1
  27. package/lib/common/actions/sharedBanks.js +13 -1
  28. package/lib/common/actions/sharingModal.js +13 -0
  29. package/lib/common/components/resources/quiz/AddContent/Body/index.js +1 -1
  30. package/lib/common/components/resources/quiz/AddContent/Body/presenter.js +132 -141
  31. package/lib/common/components/resources/quiz/AddContent/Popover/presenter.js +127 -119
  32. package/lib/common/components/shared/InteractionTypes/index.js +1 -4
  33. package/lib/common/components/shared/InteractionTypes/presenter.js +1 -3
  34. package/lib/common/middleware/sharedBanksMiddleware.js +250 -0
  35. package/lib/common/records/Item.js +2 -1
  36. package/lib/common/records/QuizEntry.js +7 -0
  37. package/lib/common/reducers/sharingModal.js +23 -0
  38. package/lib/common/util/useRemoteComponent.js +134 -0
  39. package/lib/configureStore.js +4 -1
  40. package/lib/index.js +22 -0
  41. package/package.json +8 -8
@@ -1,143 +1,137 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
4
- import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
5
- import _inherits from "@babel/runtime/helpers/esm/inherits";
6
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
7
- var _dec, _class, _AddContentBody;
8
- function _callSuper(_this, derived, args) {
9
- function isNativeReflectConstruct() {
10
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
11
- if (Reflect.construct.sham) return false;
12
- if (typeof Proxy === "function") return true;
13
- try {
14
- return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
15
- } catch (e) {
16
- return false;
17
- }
18
- }
19
- derived = _getPrototypeOf(derived);
20
- return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args));
21
- }
22
1
  /** @jsx jsx */
23
- import { Component } from 'react';
24
- import PropTypes from 'prop-types';
25
- import ImmutablePropTypes from 'react-immutable-proptypes';
26
- import first from 'lodash/first';
27
- import { IconBankLine } from '@instructure/ui-icons';
28
- import { IconButton } from '@instructure/ui-buttons';
2
+ import { jsx } from '@instructure/emotion';
3
+ import { BUILD_TRAY_OPEN, BUILD_TRAY_POSITION, BUILD_TRAY_STIMULUS_ID, withStyleOverrides } from '@instructure/quiz-common';
4
+ import t from '@instructure/quiz-i18n/es/format-message';
5
+ import { Button, IconButton } from '@instructure/ui-buttons';
29
6
  import { Grid } from '@instructure/ui-grid';
30
- import { View } from '@instructure/ui-view';
7
+ import { IconAiSolid, IconBankLine } from '@instructure/ui-icons';
31
8
  import { Text } from '@instructure/ui-text';
32
- import { jsx } from '@instructure/emotion';
9
+ import { View } from '@instructure/ui-view';
10
+ import first from 'lodash/first';
11
+ import PropTypes from 'prop-types';
12
+ import React, { useCallback } from 'react';
13
+ import ImmutablePropTypes from 'react-immutable-proptypes';
33
14
  import InteractionTypes from '../../../../shared/InteractionTypes';
34
- import t from '@instructure/quiz-i18n/es/format-message';
35
- import { BUILD_TRAY_OPEN, BUILD_TRAY_POSITION, BUILD_TRAY_STIMULUS_ID, withStyleOverrides } from '@instructure/quiz-common';
36
15
  import generateStyle from './styles';
37
16
  import generateComponentTheme from './theme';
38
- export var AddContentBody = (_dec = withStyleOverrides(generateStyle, generateComponentTheme), _dec(_class = (_AddContentBody = /*#__PURE__*/function (_Component) {
39
- function AddContentBody() {
40
- var _this2;
41
- _classCallCheck(this, AddContentBody);
42
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
43
- args[_key] = arguments[_key];
17
+ function UnstyledAddContentBody(_ref) {
18
+ var allowStimulusCreation = _ref.allowStimulusCreation,
19
+ createItem = _ref.createItem,
20
+ createStimulus = _ref.createStimulus,
21
+ editingQuizEntry = _ref.editingQuizEntry,
22
+ interactionTypes = _ref.interactionTypes,
23
+ _ref$onOpenBankTray = _ref.onOpenBankTray,
24
+ onOpenBankTray = _ref$onOpenBankTray === void 0 ? function () {} : _ref$onOpenBankTray,
25
+ _ref$onAddItem = _ref.onAddItem,
26
+ onAddItem = _ref$onAddItem === void 0 ? function () {} : _ref$onAddItem,
27
+ parentEntryId = _ref.parentEntryId,
28
+ position = _ref.position,
29
+ quizEntryWithErrorsShowing = _ref.quizEntryWithErrorsShowing,
30
+ quizId = _ref.quizId,
31
+ screenreaderNotification = _ref.screenreaderNotification,
32
+ setNextQuizEntry = _ref.setNextQuizEntry,
33
+ setUi = _ref.setUi,
34
+ _ref$showHeaderText = _ref.showHeaderText,
35
+ showHeaderText = _ref$showHeaderText === void 0 ? true : _ref$showHeaderText,
36
+ stimulusId = _ref.stimulusId,
37
+ styles = _ref.styles,
38
+ _ref$slotProps = _ref.slotProps,
39
+ slotProps = _ref$slotProps === void 0 ? {} : _ref$slotProps;
40
+ var openBankTray = useCallback(function () {
41
+ onOpenBankTray();
42
+ setUi(BUILD_TRAY_OPEN, true);
43
+ setUi(BUILD_TRAY_POSITION, position);
44
+ setUi(BUILD_TRAY_STIMULUS_ID, parentEntryId);
45
+ }, [onOpenBankTray, setUi, position, parentEntryId]);
46
+ var addStimulus = useCallback(function (isPassage) {
47
+ if (editingQuizEntry) {
48
+ setNextQuizEntry(null, quizId, position);
49
+ } else {
50
+ createStimulus(quizId, position, isPassage);
44
51
  }
45
- _this2 = _callSuper(this, AddContentBody, [].concat(args));
46
- // ==============================
47
- // ACTIONS
48
- // ==============================
49
- _defineProperty(_this2, "openBankTray", function () {
50
- _this2.props.onOpenBankTray();
51
- _this2.props.setUi(BUILD_TRAY_OPEN, true);
52
- _this2.props.setUi(BUILD_TRAY_POSITION, _this2.props.position);
53
- _this2.props.setUi(BUILD_TRAY_STIMULUS_ID, _this2.props.parentEntryId);
54
- });
55
- _defineProperty(_this2, "addStimulus", function (isPassage) {
56
- if (_this2.props.editingQuizEntry) {
57
- _this2.props.setNextQuizEntry(null, _this2.props.quizId, _this2.props.position);
58
- } else {
59
- _this2.props.createStimulus(_this2.props.quizId, _this2.props.position, isPassage);
60
- }
61
- _this2.props.onAddItem();
62
- });
63
- _defineProperty(_this2, "addItem", function (interactionTypeData) {
64
- if (_this2.props.quizEntryWithErrorsShowing) {
65
- _this2.props.screenreaderNotification(t('Question {itemPosition, number} cannot be saved due to invalid input data', {
66
- itemPosition: Math.ceil(_this2.props.quizEntryWithErrorsShowing.position)
67
- }));
52
+ onAddItem();
53
+ }, [editingQuizEntry, setNextQuizEntry, quizId, position, createStimulus, onAddItem]);
54
+ var addItem = useCallback(function (interactionTypeData) {
55
+ if (quizEntryWithErrorsShowing) {
56
+ screenreaderNotification(t('Question {itemPosition, number} cannot be saved due to invalid input data', {
57
+ itemPosition: Math.ceil(quizEntryWithErrorsShowing.position)
58
+ }));
59
+ } else {
60
+ if (editingQuizEntry) {
61
+ setNextQuizEntry(interactionTypeData, quizId, position, stimulusId, parentEntryId);
68
62
  } else {
69
- var _this2$props = _this2.props,
70
- quizId = _this2$props.quizId,
71
- position = _this2$props.position,
72
- stimulusId = _this2$props.stimulusId,
73
- parentEntryId = _this2$props.parentEntryId;
74
- if (_this2.props.editingQuizEntry) {
75
- _this2.props.setNextQuizEntry(interactionTypeData, quizId, position, stimulusId, parentEntryId);
76
- } else {
77
- var defaultInteractionData = interactionTypeData.getDefaultInteractionData();
78
- var scoringData = interactionTypeData.getDefaultScoringData(defaultInteractionData);
79
- _this2.props.createItem(quizId, position, {
80
- id: interactionTypeData.id,
81
- interactionData: defaultInteractionData,
82
- itemBody: interactionTypeData.itemBody,
83
- properties: interactionTypeData.defaultProperties,
84
- scoringAlgorithm: interactionTypeData.scoringAlgorithmDefault,
85
- scoringData: scoringData,
86
- userResponseType: first(interactionTypeData.userResponseTypeOptions)
87
- }, parentEntryId, stimulusId);
88
- }
63
+ var defaultInteractionData = interactionTypeData.getDefaultInteractionData();
64
+ var scoringData = interactionTypeData.getDefaultScoringData(defaultInteractionData);
65
+ createItem(quizId, position, {
66
+ id: interactionTypeData.id,
67
+ interactionData: defaultInteractionData,
68
+ itemBody: interactionTypeData.itemBody,
69
+ properties: interactionTypeData.defaultProperties,
70
+ scoringAlgorithm: interactionTypeData.scoringAlgorithmDefault,
71
+ scoringData: scoringData,
72
+ userResponseType: first(interactionTypeData.userResponseTypeOptions)
73
+ }, parentEntryId, stimulusId);
89
74
  }
90
- _this2.props.onAddItem();
91
- });
92
- // ==============================
93
- // RENDERING
94
- // ==============================
95
- _defineProperty(_this2, "renderBankButton", function () {
96
- return jsx(IconButton, {
97
- size: "large",
98
- onClick: _this2.openBankTray,
99
- "data-automation": "sdk-add-banked-content-button",
100
- screenReaderLabel: t('Add banked content')
101
- }, jsx(IconBankLine, null));
102
- });
103
- _defineProperty(_this2, "renderPopoverHeader", function () {
104
- var text = _this2.props.showHeaderText ? t('Insert Content') : '';
105
- return jsx("div", {
106
- css: _this2.props.styles.popoverHeaderBox
107
- }, jsx("div", {
108
- css: _this2.props.styles.popoverHeader
109
- }, jsx(Grid, {
110
- vAlign: "middle",
111
- colSpacing: "none",
112
- rowSpacing: "none"
113
- }, jsx(Grid.Row, null, jsx(Grid.Col, null, jsx(Text, {
114
- color: "primary"
115
- }, text)), jsx(Grid.Col, {
116
- width: "auto"
117
- }, _this2.renderBankButton())))));
118
- });
119
- return _this2;
120
- }
121
- _inherits(AddContentBody, _Component);
122
- return _createClass(AddContentBody, [{
123
- key: "render",
124
- value: function render() {
125
- return jsx("div", {
126
- css: this.props.styles.popoverContent,
127
- role: "dialog",
128
- "aria-label": t('Insert Content')
129
- }, this.renderPopoverHeader(), jsx(View, {
130
- padding: "small"
131
- }, jsx(InteractionTypes, {
132
- columns: 2,
133
- addItem: this.addItem,
134
- addStimulus: this.addStimulus,
135
- allowStimulusCreation: this.props.allowStimulusCreation,
136
- types: this.props.interactionTypes
137
- })));
138
75
  }
139
- }]);
140
- }(Component), _defineProperty(_AddContentBody, "displayName", 'AddContentBody'), _defineProperty(_AddContentBody, "componentId", "Quizzes".concat(_AddContentBody.displayName)), _defineProperty(_AddContentBody, "propTypes", {
76
+ onAddItem();
77
+ }, [quizEntryWithErrorsShowing, screenreaderNotification, editingQuizEntry, setNextQuizEntry, quizId, position, stimulusId, parentEntryId, createItem, onAddItem]);
78
+ var renderBankButton = function renderBankButton() {
79
+ return jsx(IconButton, {
80
+ size: "large",
81
+ onClick: openBankTray,
82
+ "data-automation": "sdk-add-banked-content-button",
83
+ screenReaderLabel: t('Add banked content')
84
+ }, jsx(IconBankLine, null));
85
+ };
86
+ var renderPopoverHeader = function renderPopoverHeader() {
87
+ var _slotProps$quizGenera, _slotProps$quizGenera2, _slotProps$quizGenera3;
88
+ var text = showHeaderText ? t('Insert Content') : '';
89
+ return jsx("div", {
90
+ css: styles.popoverHeaderBox
91
+ }, jsx("div", {
92
+ css: styles.popoverHeader
93
+ }, jsx(Grid, {
94
+ vAlign: "middle",
95
+ colSpacing: "none",
96
+ rowSpacing: "none"
97
+ }, jsx(Grid.Row, null, jsx(Grid.Col, null, jsx(Text, {
98
+ color: "primary"
99
+ }, text)), jsx(Grid.Col, {
100
+ width: "auto"
101
+ }, renderBankButton())))), ((_slotProps$quizGenera = slotProps.quizGenerationButton) === null || _slotProps$quizGenera === void 0 ? void 0 : _slotProps$quizGenera.visible) && jsx(View, {
102
+ as: "div",
103
+ padding: "x-small 0 small"
104
+ }, jsx(Button, {
105
+ color: "ai-primary",
106
+ display: "block",
107
+ renderIcon: IconAiSolid,
108
+ onClick: (_slotProps$quizGenera2 = slotProps.quizGenerationButton) === null || _slotProps$quizGenera2 === void 0 ? void 0 : _slotProps$quizGenera2.onClick,
109
+ disabled: (_slotProps$quizGenera3 = slotProps.quizGenerationButton) === null || _slotProps$quizGenera3 === void 0 ? void 0 : _slotProps$quizGenera3.disabled
110
+ }, t('Generate with AI'))));
111
+ };
112
+ return jsx("div", {
113
+ css: styles.popoverContent,
114
+ role: "dialog",
115
+ "aria-label": t('Insert Content')
116
+ }, renderPopoverHeader(), jsx(View, {
117
+ padding: "small"
118
+ }, jsx(InteractionTypes, {
119
+ columns: 2,
120
+ addItem: addItem,
121
+ addStimulus: addStimulus,
122
+ allowStimulusCreation: allowStimulusCreation,
123
+ types: interactionTypes
124
+ })));
125
+ }
126
+ export var AddContentBody = withStyleOverrides(generateStyle, generateComponentTheme)(UnstyledAddContentBody);
127
+ export var quizGenerationButtonPropTypes = PropTypes.shape({
128
+ onClick: PropTypes.func.isRequired,
129
+ visible: PropTypes.bool,
130
+ disabled: PropTypes.bool
131
+ });
132
+ AddContentBody.displayName = 'AddContentBody';
133
+ AddContentBody.componentId = "Quizzes".concat(AddContentBody.displayName);
134
+ AddContentBody.propTypes = {
141
135
  allowStimulusCreation: PropTypes.bool.isRequired,
142
136
  createItem: PropTypes.func.isRequired,
143
137
  createStimulus: PropTypes.func.isRequired,
@@ -154,15 +148,9 @@ export var AddContentBody = (_dec = withStyleOverrides(generateStyle, generateCo
154
148
  setUi: PropTypes.func.isRequired,
155
149
  showHeaderText: PropTypes.bool,
156
150
  stimulusId: PropTypes.string,
157
- styles: PropTypes.object
158
- }), _defineProperty(_AddContentBody, "defaultProps", {
159
- editingQuizEntry: void 0,
160
- interactionTypes: void 0,
161
- onAddItem: Function.prototype,
162
- parentEntryId: void 0,
163
- onOpenBankTray: Function.prototype,
164
- quizEntryWithErrorsShowing: void 0,
165
- showHeaderText: true,
166
- stimulusId: void 0
167
- }), _AddContentBody)) || _class);
151
+ styles: PropTypes.object,
152
+ slotProps: PropTypes.shape({
153
+ quizGenerationButton: quizGenerationButtonPropTypes
154
+ })
155
+ };
168
156
  export default AddContentBody;
@@ -1,125 +1,135 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
4
- import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
5
- import _inherits from "@babel/runtime/helpers/esm/inherits";
6
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
7
- var _dec, _class, _AddContentPopover;
8
- function _callSuper(_this, derived, args) {
9
- function isNativeReflectConstruct() {
10
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
11
- if (Reflect.construct.sham) return false;
12
- if (typeof Proxy === "function") return true;
13
- try {
14
- return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
15
- } catch (e) {
16
- return false;
17
- }
18
- }
19
- derived = _getPrototypeOf(derived);
20
- return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args));
21
- }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
22
4
  /** @jsx jsx */
23
- import { Component } from 'react';
24
- import PropTypes from 'prop-types';
25
- import { Popover } from '@instructure/ui-popover';
26
5
  import { jsx } from '@instructure/emotion';
6
+ import { DELETED_QUIZ_ENTRY, withStyleOverrides } from '@instructure/quiz-common';
7
+ import { Popover } from '@instructure/ui-popover';
8
+ import PropTypes from 'prop-types';
9
+ import React, { useCallback, useEffect, useRef } from 'react';
10
+ import { bindActionCreators } from 'redux';
11
+ import { createBulkItems } from '../../../../../../building/api/items';
12
+ import { createBulkQuizEntries } from '../../../../../../building/api/quizEntries';
13
+ import { addAlert } from '../../../../../../common/actions/alerts';
14
+ import { connect } from '../../../../../../common/react-redux';
27
15
  import CustomPropTypes from '../../../../../util/CustomPropTypes';
28
16
  import { onPhone, onTablet } from '../../../../../util/windowChecks';
29
- import AddContentButton from '../Button';
30
17
  import AddContentBody from '../Body';
31
- import { DELETED_QUIZ_ENTRY, withStyleOverrides } from '@instructure/quiz-common';
18
+ import AddContentButton from '../Button';
32
19
  import generateStyle from './styles';
33
20
  import generateComponentTheme from './theme';
34
- export var AddContentPopover = (_dec = withStyleOverrides(generateStyle, generateComponentTheme), _dec(_class = (_AddContentPopover = /*#__PURE__*/function (_Component) {
35
- function AddContentPopover() {
36
- var _this2;
37
- _classCallCheck(this, AddContentPopover);
38
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
39
- args[_key] = arguments[_key];
21
+ import { quizGenerationButtonPropTypes } from '../Body/presenter';
22
+ function UnstyledAddContentPopover(_ref) {
23
+ var _ref$allowStimulusCre = _ref.allowStimulusCreation,
24
+ allowStimulusCreation = _ref$allowStimulusCre === void 0 ? true : _ref$allowStimulusCre,
25
+ clearUi = _ref.clearUi,
26
+ isEditing = _ref.isEditing,
27
+ _ref$isMobile = _ref.isMobile,
28
+ isMobile = _ref$isMobile === void 0 ? onPhone() || onTablet() : _ref$isMobile,
29
+ openAddContentModal = _ref.openAddContentModal,
30
+ _ref$parentEntryId = _ref.parentEntryId,
31
+ parentEntryId = _ref$parentEntryId === void 0 ? null : _ref$parentEntryId,
32
+ position = _ref.position,
33
+ quizId = _ref.quizId,
34
+ shouldFocus = _ref.shouldFocus,
35
+ _ref$stimulusId = _ref.stimulusId,
36
+ stimulusId = _ref$stimulusId === void 0 ? null : _ref$stimulusId,
37
+ switchOffEditing = _ref.switchOffEditing,
38
+ switchOnEditing = _ref.switchOnEditing,
39
+ _ref$useStimulusTrigg = _ref.useStimulusTrigger,
40
+ useStimulusTrigger = _ref$useStimulusTrigg === void 0 ? false : _ref$useStimulusTrigg,
41
+ styles = _ref.styles,
42
+ _ref$slotProps = _ref.slotProps,
43
+ slotProps = _ref$slotProps === void 0 ? {} : _ref$slotProps;
44
+ var popoverTrigger = useRef(null);
45
+ useEffect(function () {
46
+ if (shouldFocus) {
47
+ setTimeout(function () {
48
+ if (popoverTrigger.current) popoverTrigger.current.focus();
49
+ clearUi(DELETED_QUIZ_ENTRY);
50
+ }, 100);
40
51
  }
41
- _this2 = _callSuper(this, AddContentPopover, [].concat(args));
42
- _defineProperty(_this2, "showContent", function () {
43
- _this2.props.switchOnEditing();
44
- });
45
- _defineProperty(_this2, "hideContent", function () {
46
- _this2.props.switchOffEditing();
47
- });
48
- _defineProperty(_this2, "storePopoverTriggerRef", function (b) {
49
- _this2.popoverTrigger = b;
50
- });
51
- _defineProperty(_this2, "renderPopoverButton", function () {
52
- return jsx(Popover, {
53
- on: "click",
54
- onShowContent: _this2.showContent,
55
- onHideContent: _this2.hideContent,
56
- isShowingContent: _this2.props.isEditing,
57
- shouldCloseOnEscape: true,
58
- shouldContainFocus: true,
59
- renderTrigger: _this2.renderAddContentButton()
60
- }, jsx(AddContentBody, {
61
- allowStimulusCreation: _this2.props.allowStimulusCreation,
62
- onOpenBankTray: _this2.props.switchOffEditing,
63
- onAddItem: _this2.props.switchOffEditing,
64
- parentEntryId: _this2.props.parentEntryId,
65
- position: _this2.props.position,
66
- quizId: _this2.props.quizId,
67
- stimulusId: _this2.props.stimulusId
68
- }));
69
- });
70
- _defineProperty(_this2, "openAddContentModal", function () {
71
- _this2.props.openAddContentModal({
72
- allowStimulusCreation: _this2.props.allowStimulusCreation,
73
- parentEntryId: _this2.props.parentEntryId,
74
- position: _this2.props.position,
75
- quizId: _this2.props.quizId,
76
- stimulusId: _this2.props.stimulusId
77
- });
78
- });
79
- return _this2;
52
+ }, [shouldFocus, clearUi]);
53
+ function handleGenerateWithAiClick() {
54
+ var _slotProps$quizGenera, _slotProps$quizGenera2;
55
+ slotProps === null || slotProps === void 0 || (_slotProps$quizGenera = slotProps.quizGenerationButton) === null || _slotProps$quizGenera === void 0 || (_slotProps$quizGenera2 = _slotProps$quizGenera.onClick) === null || _slotProps$quizGenera2 === void 0 || _slotProps$quizGenera2.call(_slotProps$quizGenera);
56
+ switchOffEditing();
80
57
  }
81
- _inherits(AddContentPopover, _Component);
82
- return _createClass(AddContentPopover, [{
83
- key: "componentDidUpdate",
84
- value: function componentDidUpdate() {
85
- var _this3 = this;
86
- if (this.props.shouldFocus) {
87
- setTimeout(function () {
88
- _this3.popoverTrigger && _this3.popoverTrigger.focus();
89
- _this3.props.clearUi(DELETED_QUIZ_ENTRY);
90
- }, 100); // force after modal attempt to refocus delete button
58
+ var showContent = useCallback(function () {
59
+ switchOnEditing();
60
+ }, [switchOnEditing]);
61
+ var hideContent = useCallback(function () {
62
+ switchOffEditing();
63
+ }, [switchOffEditing]);
64
+ var storePopoverTriggerRef = useCallback(function (b) {
65
+ popoverTrigger.current = b;
66
+ }, []);
67
+ var renderAddContentButton = function renderAddContentButton() {
68
+ var onClick = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
69
+ return jsx(AddContentButton, {
70
+ ref: storePopoverTriggerRef,
71
+ onClick: onClick,
72
+ isEditing: isEditing,
73
+ useStimulusTrigger: useStimulusTrigger
74
+ });
75
+ };
76
+ var renderPopoverButton = function renderPopoverButton() {
77
+ return jsx(Popover, {
78
+ on: "click",
79
+ onShowContent: showContent,
80
+ onHideContent: hideContent,
81
+ isShowingContent: isEditing,
82
+ shouldCloseOnEscape: true,
83
+ shouldContainFocus: true,
84
+ renderTrigger: renderAddContentButton()
85
+ }, jsx(AddContentBody, {
86
+ allowStimulusCreation: allowStimulusCreation,
87
+ onOpenBankTray: switchOffEditing,
88
+ onAddItem: switchOffEditing,
89
+ parentEntryId: parentEntryId,
90
+ position: position,
91
+ quizId: quizId,
92
+ stimulusId: stimulusId,
93
+ slotProps: {
94
+ quizGenerationButton: _objectSpread(_objectSpread({}, (slotProps === null || slotProps === void 0 ? void 0 : slotProps.quizGenerationButton) || {}), {}, {
95
+ onClick: handleGenerateWithAiClick
96
+ })
91
97
  }
92
- }
93
- }, {
94
- key: "renderAddContentButton",
95
- value: function renderAddContentButton() {
96
- var onClick = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
97
- return jsx(AddContentButton, {
98
- ref: this.storePopoverTriggerRef,
99
- onClick: onClick,
100
- isEditing: this.props.isEditing,
101
- useStimulusTrigger: this.props.useStimulusTrigger
102
- });
103
- }
104
- }, {
105
- key: "renderModalButton",
106
- value: function renderModalButton() {
107
- return this.renderAddContentButton(this.openAddContentModal);
108
- }
109
- }, {
110
- key: "render",
111
- value: function render() {
112
- var borderLine = this.props.useStimulusTrigger ? null : jsx("div", {
113
- css: this.props.styles.borderLine
114
- });
115
- var button = this.props.isMobile ? this.renderModalButton() : this.renderPopoverButton();
116
- return jsx("div", {
117
- css: this.props.styles.wrapper,
118
- "data-automation": "sdk-build-add-content"
119
- }, borderLine, button);
120
- }
121
- }]);
122
- }(Component), _defineProperty(_AddContentPopover, "displayName", 'AddContentPopover'), _defineProperty(_AddContentPopover, "componentId", "Quizzes".concat(_AddContentPopover.displayName)), _defineProperty(_AddContentPopover, "propTypes", {
98
+ }));
99
+ };
100
+ var openAddContentModalHandler = useCallback(function () {
101
+ openAddContentModal({
102
+ allowStimulusCreation: allowStimulusCreation,
103
+ parentEntryId: parentEntryId,
104
+ position: position,
105
+ quizId: quizId,
106
+ stimulusId: stimulusId
107
+ });
108
+ }, [openAddContentModal, allowStimulusCreation, parentEntryId, position, quizId, stimulusId]);
109
+ var renderModalButton = function renderModalButton() {
110
+ return renderAddContentButton(openAddContentModalHandler);
111
+ };
112
+ var borderLine = useStimulusTrigger ? null : jsx("div", {
113
+ css: styles.borderLine
114
+ });
115
+ var button = isMobile ? renderModalButton() : renderPopoverButton();
116
+ return jsx("div", {
117
+ css: styles.wrapper,
118
+ "data-automation": "sdk-build-add-content"
119
+ }, borderLine, button);
120
+ }
121
+ var AddContentPopoverWithStyles = withStyleOverrides(generateStyle, generateComponentTheme)(UnstyledAddContentPopover);
122
+ var mapDispatchToProps = function mapDispatchToProps(dispatch) {
123
+ return {
124
+ addAlert: addAlert,
125
+ createBulkItems: bindActionCreators(createBulkItems, dispatch),
126
+ createBulkQuizEntries: bindActionCreators(createBulkQuizEntries, dispatch)
127
+ };
128
+ };
129
+ export var AddContentPopover = connect(null, mapDispatchToProps)(AddContentPopoverWithStyles);
130
+ AddContentPopover.displayName = 'AddContentPopover';
131
+ AddContentPopover.componentId = "Quizzes".concat(AddContentPopover.displayName);
132
+ AddContentPopover.propTypes = {
123
133
  appContainer: CustomPropTypes.selectors.isRequired,
124
134
  allowStimulusCreation: PropTypes.bool,
125
135
  clearUi: PropTypes.func.isRequired,
@@ -134,12 +144,9 @@ export var AddContentPopover = (_dec = withStyleOverrides(generateStyle, generat
134
144
  switchOffEditing: PropTypes.func.isRequired,
135
145
  switchOnEditing: PropTypes.func.isRequired,
136
146
  useStimulusTrigger: PropTypes.bool,
137
- styles: PropTypes.object
138
- }), _defineProperty(_AddContentPopover, "defaultProps", {
139
- allowStimulusCreation: true,
140
- isMobile: onPhone() || onTablet(),
141
- parentEntryId: null,
142
- stimulusId: null,
143
- useStimulusTrigger: false
144
- }), _AddContentPopover)) || _class);
147
+ styles: PropTypes.object,
148
+ slotProps: PropTypes.shape({
149
+ quizGenerationButton: quizGenerationButtonPropTypes
150
+ })
151
+ };
145
152
  export default AddContentPopover;
@@ -1,9 +1,6 @@
1
1
  import { connect } from '../../../react-redux';
2
2
  import InteractionTypes from './presenter';
3
- import { featureOn } from '../../../../common/util/featureCheck';
4
3
  function mapStateToProps(state) {
5
- return {
6
- allowPassageCreation: featureOn('passage')
7
- };
4
+ return {};
8
5
  }
9
6
  export default connect(mapStateToProps)(InteractionTypes);
@@ -146,7 +146,7 @@ export var InteractionTypes = (_dec = withStyleOverrides(generateStyle, generate
146
146
  }, _this2.renderInteractionTypeButton({
147
147
  name: 'Stimulus',
148
148
  slug: 'stimulus'
149
- })), _this2.props.allowPassageCreation && jsx(Grid.Col, {
149
+ })), jsx(Grid.Col, {
150
150
  width: 12 / _this2.props.columns,
151
151
  key: "passage"
152
152
  }, _this2.renderInteractionTypeButton({
@@ -174,12 +174,10 @@ export var InteractionTypes = (_dec = withStyleOverrides(generateStyle, generate
174
174
  addItem: PropTypes.func.isRequired,
175
175
  addStimulus: PropTypes.func.isRequired,
176
176
  allowStimulusCreation: PropTypes.bool,
177
- allowPassageCreation: PropTypes.bool,
178
177
  types: ImmutablePropTypes.list,
179
178
  styles: PropTypes.object
180
179
  }), _defineProperty(_InteractionTypes, "defaultProps", {
181
180
  allowStimulusCreation: true,
182
- allowPassageCreation: false,
183
181
  types: List()
184
182
  }), _InteractionTypes)) || _class);
185
183
  export default InteractionTypes;