@pie-element/inline-dropdown 8.3.4-next.3 → 9.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,33 +1,27 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.getAllCorrectResponses = void 0;
9
-
10
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
-
12
8
  var _forEach = _interopRequireDefault(require("lodash/forEach"));
13
-
14
- var getAllCorrectResponses = function getAllCorrectResponses(_ref) {
15
- var choices = _ref.choices,
16
- alternateResponse = _ref.alternateResponse;
9
+ const getAllCorrectResponses = ({
10
+ choices,
11
+ alternateResponse
12
+ }) => {
17
13
  alternateResponse = alternateResponse || {};
18
- var correctAnswers = {};
19
- (0, _forEach["default"])(choices, function (respArea, key) {
14
+ const correctAnswers = {};
15
+ (0, _forEach.default)(choices, (respArea, key) => {
20
16
  if (!correctAnswers[key]) {
21
17
  correctAnswers[key] = [];
22
18
  }
23
-
24
19
  if (respArea) {
25
- respArea.forEach(function (choice) {
20
+ respArea.forEach(choice => {
26
21
  if (choice.correct) {
27
22
  correctAnswers[key].push(choice.value);
28
-
29
23
  if (alternateResponse[key]) {
30
- correctAnswers[key] = [].concat((0, _toConsumableArray2["default"])(correctAnswers[key]), (0, _toConsumableArray2["default"])(alternateResponse[key]));
24
+ correctAnswers[key] = [...correctAnswers[key], ...alternateResponse[key]];
31
25
  }
32
26
  }
33
27
  });
@@ -35,6 +29,5 @@ var getAllCorrectResponses = function getAllCorrectResponses(_ref) {
35
29
  });
36
30
  return correctAnswers;
37
31
  };
38
-
39
32
  exports.getAllCorrectResponses = getAllCorrectResponses;
40
33
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils.js"],"names":["getAllCorrectResponses","choices","alternateResponse","correctAnswers","respArea","key","forEach","choice","correct","push","value"],"mappings":";;;;;;;;;;;AAAA;;AAEO,IAAMA,sBAAsB,GAAG,SAAzBA,sBAAyB,OAAoC;AAAA,MAAjCC,OAAiC,QAAjCA,OAAiC;AAAA,MAAxBC,iBAAwB,QAAxBA,iBAAwB;AACxEA,EAAAA,iBAAiB,GAAGA,iBAAiB,IAAI,EAAzC;AACA,MAAMC,cAAc,GAAG,EAAvB;AAEA,2BAAQF,OAAR,EAAiB,UAACG,QAAD,EAAWC,GAAX,EAAmB;AAClC,QAAI,CAACF,cAAc,CAACE,GAAD,CAAnB,EAA0B;AACxBF,MAAAA,cAAc,CAACE,GAAD,CAAd,GAAsB,EAAtB;AACD;;AAED,QAAID,QAAJ,EAAc;AACZA,MAAAA,QAAQ,CAACE,OAAT,CAAiB,UAACC,MAAD,EAAY;AAC3B,YAAIA,MAAM,CAACC,OAAX,EAAoB;AAClBL,UAAAA,cAAc,CAACE,GAAD,CAAd,CAAoBI,IAApB,CAAyBF,MAAM,CAACG,KAAhC;;AAEA,cAAIR,iBAAiB,CAACG,GAAD,CAArB,EAA4B;AAC1BF,YAAAA,cAAc,CAACE,GAAD,CAAd,iDAA0BF,cAAc,CAACE,GAAD,CAAxC,uCAAkDH,iBAAiB,CAACG,GAAD,CAAnE;AACD;AACF;AACF,OARD;AASD;AACF,GAhBD;AAkBA,SAAOF,cAAP;AACD,CAvBM","sourcesContent":["import forEach from 'lodash/forEach';\n\nexport const getAllCorrectResponses = ({ choices, alternateResponse }) => {\n alternateResponse = alternateResponse || {};\n const correctAnswers = {};\n\n forEach(choices, (respArea, key) => {\n if (!correctAnswers[key]) {\n correctAnswers[key] = [];\n }\n\n if (respArea) {\n respArea.forEach((choice) => {\n if (choice.correct) {\n correctAnswers[key].push(choice.value);\n\n if (alternateResponse[key]) {\n correctAnswers[key] = [...correctAnswers[key], ...alternateResponse[key]];\n }\n }\n });\n }\n });\n\n return correctAnswers;\n};\n"],"file":"utils.js"}
1
+ {"version":3,"file":"utils.js","names":["_forEach","_interopRequireDefault","require","getAllCorrectResponses","choices","alternateResponse","correctAnswers","forEach","respArea","key","choice","correct","push","value","exports"],"sources":["../src/utils.js"],"sourcesContent":["import forEach from 'lodash/forEach';\n\nexport const getAllCorrectResponses = ({ choices, alternateResponse }) => {\n alternateResponse = alternateResponse || {};\n const correctAnswers = {};\n\n forEach(choices, (respArea, key) => {\n if (!correctAnswers[key]) {\n correctAnswers[key] = [];\n }\n\n if (respArea) {\n respArea.forEach((choice) => {\n if (choice.correct) {\n correctAnswers[key].push(choice.value);\n\n if (alternateResponse[key]) {\n correctAnswers[key] = [...correctAnswers[key], ...alternateResponse[key]];\n }\n }\n });\n }\n });\n\n return correctAnswers;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEO,MAAMC,sBAAsB,GAAGA,CAAC;EAAEC,OAAO;EAAEC;AAAkB,CAAC,KAAK;EACxEA,iBAAiB,GAAGA,iBAAiB,IAAI,CAAC,CAAC;EAC3C,MAAMC,cAAc,GAAG,CAAC,CAAC;EAEzB,IAAAC,gBAAO,EAACH,OAAO,EAAE,CAACI,QAAQ,EAAEC,GAAG,KAAK;IAClC,IAAI,CAACH,cAAc,CAACG,GAAG,CAAC,EAAE;MACxBH,cAAc,CAACG,GAAG,CAAC,GAAG,EAAE;IAC1B;IAEA,IAAID,QAAQ,EAAE;MACZA,QAAQ,CAACD,OAAO,CAAEG,MAAM,IAAK;QAC3B,IAAIA,MAAM,CAACC,OAAO,EAAE;UAClBL,cAAc,CAACG,GAAG,CAAC,CAACG,IAAI,CAACF,MAAM,CAACG,KAAK,CAAC;UAEtC,IAAIR,iBAAiB,CAACI,GAAG,CAAC,EAAE;YAC1BH,cAAc,CAACG,GAAG,CAAC,GAAG,CAAC,GAAGH,cAAc,CAACG,GAAG,CAAC,EAAE,GAAGJ,iBAAiB,CAACI,GAAG,CAAC,CAAC;UAC3E;QACF;MACF,CAAC,CAAC;IACJ;EACF,CAAC,CAAC;EAEF,OAAOH,cAAc;AACvB,CAAC;AAACQ,OAAA,CAAAX,sBAAA,GAAAA,sBAAA","ignoreList":[]}
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@pie-element/inline-dropdown-controller",
3
3
  "private": true,
4
- "version": "7.3.3",
4
+ "version": "8.0.0-beta.0",
5
5
  "description": "",
6
6
  "main": "lib/index.js",
7
7
  "module": "src/index.js",
8
8
  "author": "",
9
9
  "license": "ISC",
10
10
  "dependencies": {
11
- "@pie-lib/controller-utils": "0.22.2",
11
+ "@pie-lib/controller-utils": "0.22.4-next.0",
12
12
  "debug": "^3.1.0",
13
13
  "lodash": "^4.17.15",
14
14
  "type-of": "^2.0.1"
package/lib/index.js CHANGED
@@ -1,130 +1,85 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
- exports["default"] = void 0;
9
-
10
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
-
12
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
-
16
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
17
-
18
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
19
-
20
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
21
-
22
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
23
-
24
- var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));
25
-
7
+ exports.default = void 0;
26
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
27
-
28
9
  var _react = _interopRequireDefault(require("react"));
29
-
30
- var _reactDom = _interopRequireDefault(require("react-dom"));
31
-
10
+ var _client = require("react-dom/client");
32
11
  var _piePlayerEvents = require("@pie-framework/pie-player-events");
33
-
34
12
  var _mathRendering = require("@pie-lib/math-rendering");
35
-
36
13
  var _inlineDropdown = _interopRequireDefault(require("./inline-dropdown"));
37
-
38
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
39
-
40
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
41
-
42
- var RootInlineDropdown = /*#__PURE__*/function (_HTMLElement) {
43
- (0, _inherits2["default"])(RootInlineDropdown, _HTMLElement);
44
-
45
- var _super = _createSuper(RootInlineDropdown);
46
-
47
- function RootInlineDropdown() {
48
- var _this;
49
-
50
- (0, _classCallCheck2["default"])(this, RootInlineDropdown);
51
- _this = _super.call(this);
52
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_render", function () {
53
- if (_this._model && _this._session) {
54
- var elem = /*#__PURE__*/_react["default"].createElement(_inlineDropdown["default"], {
55
- model: _this._model,
56
- prompt: _this._model.prompt,
57
- rationale: _this._model.rationale,
58
- teacherInstructions: _this._model.teacherInstructions,
59
- disabled: _this._model.disabled,
60
- displayType: _this._model.displayType,
61
- markup: _this._model.markup,
62
- mode: _this._model.mode,
63
- choices: _this._model.choices,
64
- value: _this._session.value,
65
- feedback: _this._model.feedback,
66
- language: _this._model.language,
67
- onChange: _this.changeSession
14
+ class RootInlineDropdown extends HTMLElement {
15
+ constructor() {
16
+ super();
17
+ (0, _defineProperty2.default)(this, "_render", () => {
18
+ if (this._model && this._session) {
19
+ let elem = /*#__PURE__*/_react.default.createElement(_inlineDropdown.default, {
20
+ model: this._model,
21
+ prompt: this._model.prompt,
22
+ rationale: this._model.rationale,
23
+ teacherInstructions: this._model.teacherInstructions,
24
+ disabled: this._model.disabled,
25
+ displayType: this._model.displayType,
26
+ markup: this._model.markup,
27
+ mode: this._model.mode,
28
+ choices: this._model.choices,
29
+ value: this._session.value,
30
+ feedback: this._model.feedback,
31
+ language: this._model.language,
32
+ onChange: this.changeSession
68
33
  });
69
-
70
- _this.setLangAttribute();
71
-
72
- _reactDom["default"].render(elem, (0, _assertThisInitialized2["default"])(_this), function () {
73
- (0, _mathRendering.renderMath)((0, _assertThisInitialized2["default"])(_this));
34
+ this.setLangAttribute();
35
+ if (!this._root) {
36
+ this._root = (0, _client.createRoot)(this);
37
+ }
38
+ this._root.render(elem);
39
+ queueMicrotask(() => {
40
+ (0, _mathRendering.renderMath)(this);
74
41
  });
75
42
  }
76
43
  });
77
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "dispatchChangedEvent", function () {
78
- _this.dispatchEvent(new _piePlayerEvents.SessionChangedEvent(_this.tagName.toLowerCase(), _this.session && !!_this.session.value));
44
+ (0, _defineProperty2.default)(this, "dispatchChangedEvent", () => {
45
+ this.dispatchEvent(new _piePlayerEvents.SessionChangedEvent(this.tagName.toLowerCase(), this.session && !!this.session.value));
79
46
  });
80
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeSession", function (value) {
81
- _this.session.value = value;
82
-
83
- _this.dispatchChangedEvent();
84
-
85
- _this._render();
47
+ (0, _defineProperty2.default)(this, "changeSession", value => {
48
+ this.session.value = value;
49
+ this.dispatchChangedEvent();
50
+ this._render();
86
51
  });
87
- _this._model = null;
88
- _this._session = null;
89
- return _this;
52
+ this._model = null;
53
+ this._session = null;
54
+ this._root = null;
90
55
  }
91
-
92
- (0, _createClass2["default"])(RootInlineDropdown, [{
93
- key: "model",
94
- set: function set(m) {
95
- this._model = m;
96
- this.dispatchEvent(new _piePlayerEvents.ModelSetEvent(this.tagName.toLowerCase(), this.session && !!this.session.value, !!this._model));
97
-
98
- this._render();
99
- }
100
- }, {
101
- key: "session",
102
- get: function get() {
103
- return this._session;
104
- },
105
- set: function set(s) {
106
- this._session = s;
107
-
108
- this._render();
109
- }
110
- }, {
111
- key: "setLangAttribute",
112
- value: function setLangAttribute() {
113
- var language = this._model && (0, _typeof2["default"])(this._model.language) ? this._model.language : '';
114
- var lang = language ? language.slice(0, 2) : 'en';
115
- this.setAttribute('lang', lang);
116
- }
117
- }, {
118
- key: "connectedCallback",
119
- value: function connectedCallback() {
120
- this.setAttribute('aria-label', 'Inline Dropdown Question');
121
- this.setAttribute('role', 'region');
122
-
123
- this._render();
56
+ set model(m) {
57
+ this._model = m;
58
+ this.dispatchEvent(new _piePlayerEvents.ModelSetEvent(this.tagName.toLowerCase(), this.session && !!this.session.value, !!this._model));
59
+ this._render();
60
+ }
61
+ set session(s) {
62
+ this._session = s;
63
+ this._render();
64
+ }
65
+ get session() {
66
+ return this._session;
67
+ }
68
+ setLangAttribute() {
69
+ const language = this._model && typeof this._model.language ? this._model.language : '';
70
+ const lang = language ? language.slice(0, 2) : 'en';
71
+ this.setAttribute('lang', lang);
72
+ }
73
+ connectedCallback() {
74
+ this.setAttribute('aria-label', 'Inline Dropdown Question');
75
+ this.setAttribute('role', 'region');
76
+ this._render();
77
+ }
78
+ disconnectedCallback() {
79
+ if (this._root) {
80
+ this._root.unmount();
124
81
  }
125
- }]);
126
- return RootInlineDropdown;
127
- }( /*#__PURE__*/(0, _wrapNativeSuper2["default"])(HTMLElement));
128
-
129
- exports["default"] = RootInlineDropdown;
82
+ }
83
+ }
84
+ exports.default = RootInlineDropdown;
130
85
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["RootInlineDropdown","_model","_session","elem","React","createElement","InlineDropdown","model","prompt","rationale","teacherInstructions","disabled","displayType","markup","mode","choices","value","feedback","language","onChange","changeSession","setLangAttribute","ReactDOM","render","dispatchEvent","SessionChangedEvent","tagName","toLowerCase","session","dispatchChangedEvent","_render","m","ModelSetEvent","s","lang","slice","setAttribute","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;IAEqBA,kB;;;;;AACnB,gCAAc;AAAA;;AAAA;AACZ;AADY,gGA6BJ,YAAM;AACd,UAAI,MAAKC,MAAL,IAAe,MAAKC,QAAxB,EAAkC;AAChC,YAAIC,IAAI,gBAAGC,kBAAMC,aAAN,CAAoBC,0BAApB,EAAoC;AAC7CC,UAAAA,KAAK,EAAE,MAAKN,MADiC;AAE7CO,UAAAA,MAAM,EAAE,MAAKP,MAAL,CAAYO,MAFyB;AAG7CC,UAAAA,SAAS,EAAE,MAAKR,MAAL,CAAYQ,SAHsB;AAI7CC,UAAAA,mBAAmB,EAAE,MAAKT,MAAL,CAAYS,mBAJY;AAK7CC,UAAAA,QAAQ,EAAE,MAAKV,MAAL,CAAYU,QALuB;AAM7CC,UAAAA,WAAW,EAAE,MAAKX,MAAL,CAAYW,WANoB;AAO7CC,UAAAA,MAAM,EAAE,MAAKZ,MAAL,CAAYY,MAPyB;AAQ7CC,UAAAA,IAAI,EAAE,MAAKb,MAAL,CAAYa,IAR2B;AAS7CC,UAAAA,OAAO,EAAE,MAAKd,MAAL,CAAYc,OATwB;AAU7CC,UAAAA,KAAK,EAAE,MAAKd,QAAL,CAAcc,KAVwB;AAW7CC,UAAAA,QAAQ,EAAE,MAAKhB,MAAL,CAAYgB,QAXuB;AAY7CC,UAAAA,QAAQ,EAAE,MAAKjB,MAAL,CAAYiB,QAZuB;AAa7CC,UAAAA,QAAQ,EAAE,MAAKC;AAb8B,SAApC,CAAX;;AA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;;;WAsCD,6BAAoB;AAClB,WAAKE,YAAL,CAAkB,YAAlB,EAAgC,0BAAhC;AACA,WAAKA,YAAL,CAAkB,MAAlB,EAA0B,QAA1B;;AAEA,WAAKN,OAAL;AACD;;;kDAvE6CO,W","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport InlineDropdown from './inline-dropdown';\n\nexport default class RootInlineDropdown extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n }\n set model(m) {\n this._model = m;\n this.dispatchEvent(\n new ModelSetEvent(this.tagName.toLowerCase(), this.session && !!this.session.value, !!this._model),\n );\n\n this._render();\n }\n\n set session(s) {\n this._session = s;\n this._render();\n }\n\n get session() {\n return this._session;\n }\n\n setLangAttribute() {\n const language = this._model && typeof this._model.language ? this._model.language : '';\n const lang = language ? language.slice(0, 2) : 'en';\n this.setAttribute('lang', lang);\n }\n\n _render = () => {\n if (this._model && this._session) {\n let elem = React.createElement(InlineDropdown, {\n model: this._model,\n prompt: this._model.prompt,\n rationale: this._model.rationale,\n teacherInstructions: this._model.teacherInstructions,\n disabled: this._model.disabled,\n displayType: this._model.displayType,\n markup: this._model.markup,\n mode: this._model.mode,\n choices: this._model.choices,\n value: this._session.value,\n feedback: this._model.feedback,\n language: this._model.language,\n onChange: this.changeSession,\n });\n\n this.setLangAttribute();\n\n ReactDOM.render(elem, this, () => {\n renderMath(this);\n });\n }\n };\n\n dispatchChangedEvent = () => {\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.session && !!this.session.value));\n };\n\n changeSession = (value) => {\n this.session.value = value;\n this.dispatchChangedEvent();\n this._render();\n };\n\n connectedCallback() {\n this.setAttribute('aria-label', 'Inline Dropdown Question');\n this.setAttribute('role', 'region');\n\n this._render();\n }\n}\n"],"file":"index.js"}
1
+ {"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_client","_piePlayerEvents","_mathRendering","_inlineDropdown","RootInlineDropdown","HTMLElement","constructor","_defineProperty2","default","_model","_session","elem","React","createElement","InlineDropdown","model","prompt","rationale","teacherInstructions","disabled","displayType","markup","mode","choices","value","feedback","language","onChange","changeSession","setLangAttribute","_root","createRoot","render","queueMicrotask","renderMath","dispatchEvent","SessionChangedEvent","tagName","toLowerCase","session","dispatchChangedEvent","_render","m","ModelSetEvent","s","lang","slice","setAttribute","connectedCallback","disconnectedCallback","unmount","exports"],"sources":["../src/index.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport InlineDropdown from './inline-dropdown';\n\nexport default class RootInlineDropdown extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n this._root = null;\n }\n set model(m) {\n this._model = m;\n this.dispatchEvent(\n new ModelSetEvent(this.tagName.toLowerCase(), this.session && !!this.session.value, !!this._model),\n );\n\n this._render();\n }\n\n set session(s) {\n this._session = s;\n this._render();\n }\n\n get session() {\n return this._session;\n }\n\n setLangAttribute() {\n const language = this._model && typeof this._model.language ? this._model.language : '';\n const lang = language ? language.slice(0, 2) : 'en';\n this.setAttribute('lang', lang);\n }\n\n _render = () => {\n if (this._model && this._session) {\n let elem = React.createElement(InlineDropdown, {\n model: this._model,\n prompt: this._model.prompt,\n rationale: this._model.rationale,\n teacherInstructions: this._model.teacherInstructions,\n disabled: this._model.disabled,\n displayType: this._model.displayType,\n markup: this._model.markup,\n mode: this._model.mode,\n choices: this._model.choices,\n value: this._session.value,\n feedback: this._model.feedback,\n language: this._model.language,\n onChange: this.changeSession,\n });\n\n this.setLangAttribute();\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(elem);\n queueMicrotask(() => {\n renderMath(this);\n });\n }\n };\n\n dispatchChangedEvent = () => {\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.session && !!this.session.value));\n };\n\n changeSession = (value) => {\n this.session.value = value;\n this.dispatchChangedEvent();\n this._render();\n };\n\n connectedCallback() {\n this.setAttribute('aria-label', 'Inline Dropdown Question');\n this.setAttribute('role', 'region');\n\n this._render();\n }\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,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAL,sBAAA,CAAAC,OAAA;AAEe,MAAMK,kBAAkB,SAASC,WAAW,CAAC;EAC1DC,WAAWA,CAAA,EAAG;IACZ,KAAK,CAAC,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA,mBA6BA,MAAM;MACd,IAAI,IAAI,CAACC,MAAM,IAAI,IAAI,CAACC,QAAQ,EAAE;QAChC,IAAIC,IAAI,gBAAGC,cAAK,CAACC,aAAa,CAACC,uBAAc,EAAE;UAC7CC,KAAK,EAAE,IAAI,CAACN,MAAM;UAClBO,MAAM,EAAE,IAAI,CAACP,MAAM,CAACO,MAAM;UAC1BC,SAAS,EAAE,IAAI,CAACR,MAAM,CAACQ,SAAS;UAChCC,mBAAmB,EAAE,IAAI,CAACT,MAAM,CAACS,mBAAmB;UACpDC,QAAQ,EAAE,IAAI,CAACV,MAAM,CAACU,QAAQ;UAC9BC,WAAW,EAAE,IAAI,CAACX,MAAM,CAACW,WAAW;UACpCC,MAAM,EAAE,IAAI,CAACZ,MAAM,CAACY,MAAM;UAC1BC,IAAI,EAAE,IAAI,CAACb,MAAM,CAACa,IAAI;UACtBC,OAAO,EAAE,IAAI,CAACd,MAAM,CAACc,OAAO;UAC5BC,KAAK,EAAE,IAAI,CAACd,QAAQ,CAACc,KAAK;UAC1BC,QAAQ,EAAE,IAAI,CAAChB,MAAM,CAACgB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