gwchq-textjam 0.2.31 → 0.2.32

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/dist/index.js CHANGED
@@ -346790,10 +346790,10 @@ __webpack_require__.r(__webpack_exports__);
346790
346790
 
346791
346791
  // EXPORTS
346792
346792
  __webpack_require__.d(__webpack_exports__, {
346793
- Tab: () => (/* reexport */ Tab),
346794
- TabList: () => (/* reexport */ TabList),
346795
- TabPanel: () => (/* reexport */ TabPanel),
346796
- Tabs: () => (/* reexport */ Tabs),
346793
+ Tab: () => (/* reexport */ components_Tab),
346794
+ TabList: () => (/* reexport */ components_TabList),
346795
+ TabPanel: () => (/* reexport */ components_TabPanel),
346796
+ Tabs: () => (/* reexport */ components_Tabs),
346797
346797
  resetIdCounter: () => (/* reexport */ uuid_reset)
346798
346798
  });
346799
346799
 
@@ -346942,13 +346942,6 @@ function count_getTabsCount(children) {
346942
346942
  });
346943
346943
  return tabCount;
346944
346944
  }
346945
- function count_getPanelsCount(children) {
346946
- var panelCount = 0;
346947
- childrenDeepMap_deepForEach(children, function (child) {
346948
- if (elementTypes_isTabPanel(child)) panelCount++;
346949
- });
346950
- return panelCount;
346951
- }
346952
346945
  ;// ./node_modules/react-tabs/esm/components/UncontrolledTabs.js
346953
346946
  var _excluded = ["children", "className", "disabledTabClassName", "domRef", "focus", "forceRenderTabPanel", "onSelect", "selectedIndex", "selectedTabClassName", "selectedTabPanelClassName", "environment", "disableUpDownKeys"];
346954
346947
 
@@ -346956,10 +346949,6 @@ function UncontrolledTabs_extends() { UncontrolledTabs_extends = Object.assign |
346956
346949
 
346957
346950
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
346958
346951
 
346959
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
346960
-
346961
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
346962
-
346963
346952
 
346964
346953
 
346965
346954
 
@@ -346995,219 +346984,135 @@ function determineCanUseActiveElement(environment) {
346995
346984
  // Refer to the following resources:
346996
346985
  // http://stackoverflow.com/a/10982960/369687
346997
346986
  // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/12733599
346987
+ // istanbul ignore next
346998
346988
  canUseActiveElement = false;
346999
346989
  }
347000
346990
  }
347001
346991
 
347002
- var UncontrolledTabs = /*#__PURE__*/function (_Component) {
347003
- _inheritsLoose(UncontrolledTabs, _Component);
347004
-
347005
- function UncontrolledTabs() {
347006
- var _this;
347007
-
347008
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
347009
- args[_key] = arguments[_key];
347010
- }
347011
-
347012
- _this = _Component.call.apply(_Component, [this].concat(args)) || this;
347013
- _this.tabNodes = [];
347014
-
347015
- _this.handleKeyDown = function (e) {
347016
- var _this$props = _this.props,
347017
- direction = _this$props.direction,
347018
- disableUpDownKeys = _this$props.disableUpDownKeys;
347019
-
347020
- if (_this.isTabFromContainer(e.target)) {
347021
- var index = _this.props.selectedIndex;
347022
- var preventDefault = false;
347023
- var useSelectedIndex = false;
347024
-
347025
- if (e.keyCode === 32 || e.keyCode === 13) {
347026
- preventDefault = true;
347027
- useSelectedIndex = false;
347028
-
347029
- _this.handleClick(e);
347030
- }
347031
-
347032
- if (e.keyCode === 37 || !disableUpDownKeys && e.keyCode === 38) {
347033
- // Select next tab to the left, validate if up arrow is not disabled
347034
- if (direction === 'rtl') {
347035
- index = _this.getNextTab(index);
347036
- } else {
347037
- index = _this.getPrevTab(index);
347038
- }
347039
-
347040
- preventDefault = true;
347041
- useSelectedIndex = true;
347042
- } else if (e.keyCode === 39 || !disableUpDownKeys && e.keyCode === 40) {
347043
- // Select next tab to the right, validate if down arrow is not disabled
347044
- if (direction === 'rtl') {
347045
- index = _this.getPrevTab(index);
347046
- } else {
347047
- index = _this.getNextTab(index);
347048
- }
347049
-
347050
- preventDefault = true;
347051
- useSelectedIndex = true;
347052
- } else if (e.keyCode === 35) {
347053
- // Select last tab (End key)
347054
- index = _this.getLastTab();
347055
- preventDefault = true;
347056
- useSelectedIndex = true;
347057
- } else if (e.keyCode === 36) {
347058
- // Select first tab (Home key)
347059
- index = _this.getFirstTab();
347060
- preventDefault = true;
347061
- useSelectedIndex = true;
347062
- } // This prevents scrollbars from moving around
347063
-
347064
-
347065
- if (preventDefault) {
347066
- e.preventDefault();
347067
- } // Only use the selected index in the state if we're not using the tabbed index
347068
-
347069
-
347070
- if (useSelectedIndex) {
347071
- _this.setSelected(index, e);
347072
- }
347073
- }
347074
- };
347075
-
347076
- _this.handleClick = function (e) {
347077
- var node = e.target;
347078
-
347079
- do {
347080
- if (_this.isTabFromContainer(node)) {
347081
- if (isTabDisabled(node)) {
347082
- return;
347083
- }
347084
-
347085
- var index = [].slice.call(node.parentNode.children).filter(isTabNode).indexOf(node);
347086
-
347087
- _this.setSelected(index, e);
347088
-
347089
- return;
347090
- }
347091
- } while ((node = node.parentNode) != null);
347092
- };
346992
+ var defaultProps = {
346993
+ className: 'react-tabs',
346994
+ focus: false
346995
+ };
346996
+ var propTypes = false ? 0 : {};
347093
346997
 
347094
- return _this;
347095
- }
346998
+ var UncontrolledTabs = function UncontrolledTabs(props) {
346999
+ var tabNodes = (0,external_react_.useRef)([]);
347000
+ var tabIds = (0,external_react_.useRef)([]);
347001
+ var panelIds = (0,external_react_.useRef)([]);
347096
347002
 
347097
- var _proto = UncontrolledTabs.prototype;
347003
+ var _ref = (0,external_react_.useRef)();
347098
347004
 
347099
- _proto.setSelected = function setSelected(index, event) {
347005
+ function setSelected(index, event) {
347100
347006
  // Check index boundary
347101
- if (index < 0 || index >= this.getTabsCount()) return;
347102
- var _this$props2 = this.props,
347103
- onSelect = _this$props2.onSelect,
347104
- selectedIndex = _this$props2.selectedIndex; // Call change event handler
347007
+ if (index < 0 || index >= getTabsCount()) return;
347008
+ var onSelect = props.onSelect,
347009
+ selectedIndex = props.selectedIndex; // Call change event handler
347105
347010
 
347106
347011
  onSelect(index, selectedIndex, event);
347107
- };
347012
+ }
347108
347013
 
347109
- _proto.getNextTab = function getNextTab(index) {
347110
- var count = this.getTabsCount(); // Look for non-disabled tab from index to the last tab on the right
347014
+ function getNextTab(index) {
347015
+ var count = getTabsCount(); // Look for non-disabled tab from index to the last tab on the right
347111
347016
 
347112
347017
  for (var i = index + 1; i < count; i++) {
347113
- if (!isTabDisabled(this.getTab(i))) {
347018
+ if (!isTabDisabled(getTab(i))) {
347114
347019
  return i;
347115
347020
  }
347116
347021
  } // If no tab found, continue searching from first on left to index
347117
347022
 
347118
347023
 
347119
347024
  for (var _i = 0; _i < index; _i++) {
347120
- if (!isTabDisabled(this.getTab(_i))) {
347025
+ if (!isTabDisabled(getTab(_i))) {
347121
347026
  return _i;
347122
347027
  }
347123
- } // No tabs are disabled, return index
347028
+ } // All tabs are disabled, return index
347029
+
347030
+ /* istanbul ignore next */
347124
347031
 
347125
347032
 
347126
347033
  return index;
347127
- };
347034
+ }
347128
347035
 
347129
- _proto.getPrevTab = function getPrevTab(index) {
347036
+ function getPrevTab(index) {
347130
347037
  var i = index; // Look for non-disabled tab from index to first tab on the left
347131
347038
 
347132
347039
  while (i--) {
347133
- if (!isTabDisabled(this.getTab(i))) {
347040
+ if (!isTabDisabled(getTab(i))) {
347134
347041
  return i;
347135
347042
  }
347136
347043
  } // If no tab found, continue searching from last tab on right to index
347137
347044
 
347138
347045
 
347139
- i = this.getTabsCount();
347046
+ i = getTabsCount();
347140
347047
 
347141
347048
  while (i-- > index) {
347142
- if (!isTabDisabled(this.getTab(i))) {
347049
+ if (!isTabDisabled(getTab(i))) {
347143
347050
  return i;
347144
347051
  }
347145
- } // No tabs are disabled, return index
347052
+ } // All tabs are disabled, return index
347053
+
347054
+ /* istanbul ignore next */
347146
347055
 
347147
347056
 
347148
347057
  return index;
347149
- };
347058
+ }
347150
347059
 
347151
- _proto.getFirstTab = function getFirstTab() {
347152
- var count = this.getTabsCount(); // Look for non disabled tab from the first tab
347060
+ function getFirstTab() {
347061
+ var count = getTabsCount(); // Look for non disabled tab from the first tab
347153
347062
 
347154
347063
  for (var i = 0; i < count; i++) {
347155
- if (!isTabDisabled(this.getTab(i))) {
347064
+ if (!isTabDisabled(getTab(i))) {
347156
347065
  return i;
347157
347066
  }
347158
347067
  }
347068
+ /* istanbul ignore next */
347069
+
347159
347070
 
347160
347071
  return null;
347161
- };
347072
+ }
347162
347073
 
347163
- _proto.getLastTab = function getLastTab() {
347164
- var i = this.getTabsCount(); // Look for non disabled tab from the last tab
347074
+ function getLastTab() {
347075
+ var i = getTabsCount(); // Look for non disabled tab from the last tab
347165
347076
 
347166
347077
  while (i--) {
347167
- if (!isTabDisabled(this.getTab(i))) {
347078
+ if (!isTabDisabled(getTab(i))) {
347168
347079
  return i;
347169
347080
  }
347170
347081
  }
347082
+ /* istanbul ignore next */
347083
+
347171
347084
 
347172
347085
  return null;
347173
- };
347086
+ }
347174
347087
 
347175
- _proto.getTabsCount = function getTabsCount() {
347176
- var children = this.props.children;
347088
+ function getTabsCount() {
347089
+ var children = props.children;
347177
347090
  return count_getTabsCount(children);
347178
- };
347179
-
347180
- _proto.getPanelsCount = function getPanelsCount() {
347181
- var children = this.props.children;
347182
- return count_getPanelsCount(children);
347183
- };
347184
-
347185
- _proto.getTab = function getTab(index) {
347186
- return this.tabNodes["tabs-" + index];
347187
- };
347091
+ }
347188
347092
 
347189
- _proto.getChildren = function getChildren() {
347190
- var _this2 = this;
347093
+ function getTab(index) {
347094
+ return tabNodes.current["tabs-" + index];
347095
+ }
347191
347096
 
347097
+ function getChildren() {
347192
347098
  var index = 0;
347193
- var _this$props3 = this.props,
347194
- children = _this$props3.children,
347195
- disabledTabClassName = _this$props3.disabledTabClassName,
347196
- focus = _this$props3.focus,
347197
- forceRenderTabPanel = _this$props3.forceRenderTabPanel,
347198
- selectedIndex = _this$props3.selectedIndex,
347199
- selectedTabClassName = _this$props3.selectedTabClassName,
347200
- selectedTabPanelClassName = _this$props3.selectedTabPanelClassName,
347201
- environment = _this$props3.environment;
347202
- this.tabIds = this.tabIds || [];
347203
- this.panelIds = this.panelIds || [];
347204
- var diff = this.tabIds.length - this.getTabsCount(); // Add ids if new tabs have been added
347099
+ var children = props.children,
347100
+ disabledTabClassName = props.disabledTabClassName,
347101
+ focus = props.focus,
347102
+ forceRenderTabPanel = props.forceRenderTabPanel,
347103
+ selectedIndex = props.selectedIndex,
347104
+ selectedTabClassName = props.selectedTabClassName,
347105
+ selectedTabPanelClassName = props.selectedTabPanelClassName,
347106
+ environment = props.environment;
347107
+ tabIds.current = tabIds.current || [];
347108
+ panelIds.current = panelIds.current || [];
347109
+ var diff = tabIds.current.length - getTabsCount(); // Add ids if new tabs have been added
347205
347110
  // Don't bother removing ids, just keep them in case they are added again
347206
347111
  // This is more efficient, and keeps the uuid counter under control
347207
347112
 
347208
347113
  while (diff++ < 0) {
347209
- this.tabIds.push(uuid());
347210
- this.panelIds.push(uuid());
347114
+ tabIds.current.push(uuid());
347115
+ panelIds.current.push(uuid());
347211
347116
  } // Map children to dynamically setup refs
347212
347117
 
347213
347118
 
@@ -347224,10 +347129,11 @@ var UncontrolledTabs = /*#__PURE__*/function (_Component) {
347224
347129
  determineCanUseActiveElement(environment);
347225
347130
  }
347226
347131
 
347227
- if (canUseActiveElement) {
347132
+ var env = environment || (typeof window !== 'undefined' ? window : undefined);
347133
+
347134
+ if (canUseActiveElement && env) {
347228
347135
  wasTabFocused = external_react_["default"].Children.toArray(child.props.children).filter(elementTypes_isTab).some(function (tab, i) {
347229
- var env = environment || (typeof window !== 'undefined' ? window : undefined);
347230
- return env && env.document.activeElement === _this2.getTab(i);
347136
+ return env.document.activeElement === getTab(i);
347231
347137
  });
347232
347138
  }
347233
347139
 
@@ -347237,10 +347143,10 @@ var UncontrolledTabs = /*#__PURE__*/function (_Component) {
347237
347143
  var selected = selectedIndex === listIndex;
347238
347144
  var props = {
347239
347145
  tabRef: function tabRef(node) {
347240
- _this2.tabNodes[key] = node;
347146
+ tabNodes.current[key] = node;
347241
347147
  },
347242
- id: _this2.tabIds[listIndex],
347243
- panelId: _this2.panelIds[listIndex],
347148
+ id: tabIds.current[listIndex],
347149
+ panelId: panelIds.current[listIndex],
347244
347150
  selected: selected,
347245
347151
  focus: selected && (focus || wasTabFocused)
347246
347152
  };
@@ -347251,27 +347157,116 @@ var UncontrolledTabs = /*#__PURE__*/function (_Component) {
347251
347157
  })
347252
347158
  });
347253
347159
  } else if (elementTypes_isTabPanel(child)) {
347254
- var props = {
347255
- id: _this2.panelIds[index],
347256
- tabId: _this2.tabIds[index],
347160
+ var _props = {
347161
+ id: panelIds.current[index],
347162
+ tabId: tabIds.current[index],
347257
347163
  selected: selectedIndex === index
347258
347164
  };
347259
- if (forceRenderTabPanel) props.forceRender = forceRenderTabPanel;
347260
- if (selectedTabPanelClassName) props.selectedClassName = selectedTabPanelClassName;
347165
+ if (forceRenderTabPanel) _props.forceRender = forceRenderTabPanel;
347166
+ if (selectedTabPanelClassName) _props.selectedClassName = selectedTabPanelClassName;
347261
347167
  index++;
347262
- result = /*#__PURE__*/(0,external_react_.cloneElement)(child, props);
347168
+ result = /*#__PURE__*/(0,external_react_.cloneElement)(child, _props);
347263
347169
  }
347264
347170
 
347265
347171
  return result;
347266
347172
  });
347267
- };
347173
+ }
347174
+
347175
+ function handleKeyDown(e) {
347176
+ var direction = props.direction,
347177
+ disableUpDownKeys = props.disableUpDownKeys;
347268
347178
 
347179
+ if (isTabFromContainer(e.target)) {
347180
+ var index = props.selectedIndex;
347181
+ var preventDefault = false;
347182
+ var useSelectedIndex = false;
347183
+
347184
+ if (e.code === 'Space' || e.keyCode === 32
347185
+ /* space */
347186
+ || e.code === 'Enter' || e.keyCode === 13
347187
+ /* enter */
347188
+ ) {
347189
+ preventDefault = true;
347190
+ useSelectedIndex = false;
347191
+ handleClick(e);
347192
+ } // keyCode is deprecated and only used here for IE
347193
+
347194
+
347195
+ if (e.code === 'ArrowLeft' || e.keyCode === 37
347196
+ /* arrow left */
347197
+ || !disableUpDownKeys && (e.keyCode === 38 || e.code === 'ArrowUp')
347198
+ /* arrow up */
347199
+ ) {
347200
+ // Select next tab to the left, validate if up arrow is not disabled
347201
+ if (direction === 'rtl') {
347202
+ index = getNextTab(index);
347203
+ } else {
347204
+ index = getPrevTab(index);
347205
+ }
347206
+
347207
+ preventDefault = true;
347208
+ useSelectedIndex = true;
347209
+ } else if (e.code === 'ArrowRight' || e.keyCode === 39
347210
+ /* arrow right */
347211
+ || !disableUpDownKeys && (e.keyCode === 40 || e.code === 'ArrowDown')
347212
+ /* arrow down */
347213
+ ) {
347214
+ // Select next tab to the right, validate if down arrow is not disabled
347215
+ if (direction === 'rtl') {
347216
+ index = getPrevTab(index);
347217
+ } else {
347218
+ index = getNextTab(index);
347219
+ }
347220
+
347221
+ preventDefault = true;
347222
+ useSelectedIndex = true;
347223
+ } else if (e.keyCode === 35 || e.code === 'End') {
347224
+ // Select last tab (End key)
347225
+ index = getLastTab();
347226
+ preventDefault = true;
347227
+ useSelectedIndex = true;
347228
+ } else if (e.keyCode === 36 || e.code === 'Home') {
347229
+ // Select first tab (Home key)
347230
+ index = getFirstTab();
347231
+ preventDefault = true;
347232
+ useSelectedIndex = true;
347233
+ } // This prevents scrollbars from moving around
347234
+
347235
+
347236
+ if (preventDefault) {
347237
+ e.preventDefault();
347238
+ } // Only use the selected index in the state if we're not using the tabbed index
347239
+
347240
+
347241
+ if (useSelectedIndex) {
347242
+ setSelected(index, e);
347243
+ }
347244
+ }
347245
+ }
347246
+
347247
+ function handleClick(e) {
347248
+ var node = e.target;
347249
+
347250
+ do {
347251
+ if (isTabFromContainer(node)) {
347252
+ if (isTabDisabled(node)) {
347253
+ return;
347254
+ }
347255
+
347256
+ var index = [].slice.call(node.parentNode.children).filter(isTabNode).indexOf(node);
347257
+ setSelected(index, e);
347258
+ return;
347259
+ }
347260
+ } while ((node = node.parentNode) != null);
347261
+ }
347269
347262
  /**
347270
347263
  * Determine if a node from event.target is a Tab element for the current Tabs container.
347271
347264
  * If the clicked element is not a Tab, it returns false.
347272
347265
  * If it finds another Tabs container between the Tab and `this`, it returns false.
347273
347266
  */
347274
- _proto.isTabFromContainer = function isTabFromContainer(node) {
347267
+
347268
+
347269
+ function isTabFromContainer(node) {
347275
347270
  // return immediately if the clicked element is not a Tab.
347276
347271
  if (!isTabNode(node)) {
347277
347272
  return false;
@@ -347281,62 +347276,45 @@ var UncontrolledTabs = /*#__PURE__*/function (_Component) {
347281
347276
  var nodeAncestor = node.parentElement;
347282
347277
 
347283
347278
  do {
347284
- if (nodeAncestor === this.node) return true;
347279
+ if (nodeAncestor === _ref.current) return true;
347285
347280
  if (nodeAncestor.getAttribute('data-rttabs')) break;
347286
347281
  nodeAncestor = nodeAncestor.parentElement;
347287
347282
  } while (nodeAncestor);
347288
347283
 
347289
347284
  return false;
347290
- };
347291
-
347292
- _proto.render = function render() {
347293
- var _this3 = this;
347294
-
347295
- // Delete all known props, so they don't get added to DOM
347296
- var _this$props4 = this.props,
347297
- children = _this$props4.children,
347298
- className = _this$props4.className,
347299
- disabledTabClassName = _this$props4.disabledTabClassName,
347300
- domRef = _this$props4.domRef,
347301
- focus = _this$props4.focus,
347302
- forceRenderTabPanel = _this$props4.forceRenderTabPanel,
347303
- onSelect = _this$props4.onSelect,
347304
- selectedIndex = _this$props4.selectedIndex,
347305
- selectedTabClassName = _this$props4.selectedTabClassName,
347306
- selectedTabPanelClassName = _this$props4.selectedTabPanelClassName,
347307
- environment = _this$props4.environment,
347308
- disableUpDownKeys = _this$props4.disableUpDownKeys,
347309
- attributes = _objectWithoutPropertiesLoose(_this$props4, _excluded);
347310
-
347311
- return /*#__PURE__*/external_react_["default"].createElement("div", UncontrolledTabs_extends({}, attributes, {
347312
- className: (0,clsx_m/* default */.A)(className),
347313
- onClick: this.handleClick,
347314
- onKeyDown: this.handleKeyDown,
347315
- ref: function ref(node) {
347316
- _this3.node = node;
347317
- if (domRef) domRef(node);
347318
- },
347319
- "data-rttabs": true
347320
- }), this.getChildren());
347321
- };
347322
-
347323
- return UncontrolledTabs;
347324
- }(external_react_.Component);
347285
+ }
347325
347286
 
347326
- UncontrolledTabs.defaultProps = {
347327
- className: 'react-tabs',
347328
- focus: false
347287
+ var children = props.children,
347288
+ className = props.className,
347289
+ disabledTabClassName = props.disabledTabClassName,
347290
+ domRef = props.domRef,
347291
+ focus = props.focus,
347292
+ forceRenderTabPanel = props.forceRenderTabPanel,
347293
+ onSelect = props.onSelect,
347294
+ selectedIndex = props.selectedIndex,
347295
+ selectedTabClassName = props.selectedTabClassName,
347296
+ selectedTabPanelClassName = props.selectedTabPanelClassName,
347297
+ environment = props.environment,
347298
+ disableUpDownKeys = props.disableUpDownKeys,
347299
+ attributes = _objectWithoutPropertiesLoose(props, _excluded);
347300
+
347301
+ return /*#__PURE__*/external_react_["default"].createElement("div", UncontrolledTabs_extends({}, attributes, {
347302
+ className: (0,clsx_m/* default */.A)(className),
347303
+ onClick: handleClick,
347304
+ onKeyDown: handleKeyDown,
347305
+ ref: function ref(node) {
347306
+ _ref.current = node;
347307
+ if (domRef) domRef(node);
347308
+ },
347309
+ "data-rttabs": true
347310
+ }), getChildren());
347329
347311
  };
347330
347312
 
347313
+ UncontrolledTabs.defaultProps = defaultProps;
347331
347314
  UncontrolledTabs.propTypes = false ? 0 : {};
347315
+ /* harmony default export */ const components_UncontrolledTabs = (UncontrolledTabs);
347332
347316
  ;// ./node_modules/react-tabs/esm/components/Tabs.js
347333
- var Tabs_excluded = ["children", "defaultIndex", "defaultFocus"];
347334
-
347335
- function Tabs_objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
347336
-
347337
- function Tabs_inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; Tabs_setPrototypeOf(subClass, superClass); }
347338
-
347339
- function Tabs_setPrototypeOf(o, p) { Tabs_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return Tabs_setPrototypeOf(o, p); }
347317
+ function Tabs_extends() { Tabs_extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return Tabs_extends.apply(this, arguments); }
347340
347318
 
347341
347319
 
347342
347320
 
@@ -347345,115 +347323,106 @@ function Tabs_setPrototypeOf(o, p) { Tabs_setPrototypeOf = Object.setPrototypeOf
347345
347323
 
347346
347324
  var MODE_CONTROLLED = 0;
347347
347325
  var MODE_UNCONTROLLED = 1;
347326
+ var Tabs_propTypes = false ? 0 : {};
347327
+ var Tabs_defaultProps = {
347328
+ defaultFocus: false,
347329
+ focusTabOnClick: true,
347330
+ forceRenderTabPanel: false,
347331
+ selectedIndex: null,
347332
+ defaultIndex: null,
347333
+ environment: null,
347334
+ disableUpDownKeys: false
347335
+ };
347348
347336
 
347349
- var Tabs = /*#__PURE__*/function (_Component) {
347350
- Tabs_inheritsLoose(Tabs, _Component);
347337
+ var getModeFromProps = function getModeFromProps(props) {
347338
+ return props.selectedIndex === null ? MODE_UNCONTROLLED : MODE_CONTROLLED;
347339
+ };
347351
347340
 
347352
- function Tabs(props) {
347353
- var _this;
347341
+ var checkForIllegalModeChange = function checkForIllegalModeChange(props, mode) {
347342
+ if (false) {}
347343
+ };
347344
+ /**
347345
+ * State:
347346
+ * mode: Initialized only once from props and never changes
347347
+ * selectedIndex: null if controlled mode, otherwise initialized with prop defaultIndex, changed on selection of tabs, has effect to ensure it never gets out of bound
347348
+ * focus: Because we never remove focus from the Tabs this state is only used to indicate that we should focus the current tab.
347349
+ * It is initialized from the prop defaultFocus, and after the first render it is reset back to false. Later it can become true again when using keys to navigate the tabs.
347350
+ */
347354
347351
 
347355
- _this = _Component.call(this, props) || this;
347356
347352
 
347357
- _this.handleSelected = function (index, last, event) {
347358
- var onSelect = _this.props.onSelect;
347359
- var mode = _this.state.mode; // Call change event handler
347353
+ var Tabs = function Tabs(props) {
347354
+ var children = props.children,
347355
+ defaultFocus = props.defaultFocus,
347356
+ defaultIndex = props.defaultIndex,
347357
+ focusTabOnClick = props.focusTabOnClick,
347358
+ onSelect = props.onSelect;
347360
347359
 
347361
- if (typeof onSelect === 'function') {
347362
- // Check if the change event handler cancels the tab change
347363
- if (onSelect(index, last, event) === false) return;
347364
- }
347360
+ var _useState = (0,external_react_.useState)(defaultFocus),
347361
+ focus = _useState[0],
347362
+ setFocus = _useState[1];
347365
347363
 
347366
- var state = {
347367
- // Set focus if the change was triggered from the keyboard
347368
- focus: event.type === 'keydown'
347369
- };
347364
+ var _useState2 = (0,external_react_.useState)(getModeFromProps(props)),
347365
+ mode = _useState2[0];
347370
347366
 
347371
- if (mode === MODE_UNCONTROLLED) {
347372
- // Update selected index
347373
- state.selectedIndex = index;
347374
- }
347367
+ var _useState3 = (0,external_react_.useState)(mode === MODE_UNCONTROLLED ? defaultIndex || 0 : null),
347368
+ selectedIndex = _useState3[0],
347369
+ setSelectedIndex = _useState3[1];
347375
347370
 
347376
- _this.setState(state);
347377
- };
347371
+ (0,external_react_.useEffect)(function () {
347372
+ // Reset focus after initial render, see comment above
347373
+ setFocus(false);
347374
+ }, []);
347378
347375
 
347379
- _this.state = Tabs.copyPropsToState(_this.props, {}, props.defaultFocus);
347380
- return _this;
347376
+ if (mode === MODE_UNCONTROLLED) {
347377
+ // Ensure that we handle removed tabs and don't let selectedIndex get out of bounds
347378
+ var tabsCount = count_getTabsCount(children);
347379
+ (0,external_react_.useEffect)(function () {
347380
+ if (selectedIndex != null) {
347381
+ var maxTabIndex = Math.max(0, tabsCount - 1);
347382
+ setSelectedIndex(Math.min(selectedIndex, maxTabIndex));
347383
+ }
347384
+ }, [tabsCount]);
347381
347385
  }
347382
347386
 
347383
- Tabs.getDerivedStateFromProps = function getDerivedStateFromProps(props, state) {
347384
- return Tabs.copyPropsToState(props, state);
347385
- };
347386
-
347387
- Tabs.getModeFromProps = function getModeFromProps(props) {
347388
- return props.selectedIndex === null ? MODE_UNCONTROLLED : MODE_CONTROLLED;
347389
- };
347390
-
347391
- // preserve the existing selectedIndex from state.
347392
- // If the state has not selectedIndex, default to the defaultIndex or 0
347393
- Tabs.copyPropsToState = function copyPropsToState(props, state, focus) {
347394
- if (focus === void 0) {
347395
- focus = false;
347396
- }
347397
-
347398
- if (false) {}
347387
+ checkForIllegalModeChange(props, mode);
347399
347388
 
347400
- var newState = {
347401
- focus: focus,
347402
- mode: Tabs.getModeFromProps(props)
347403
- };
347389
+ var handleSelected = function handleSelected(index, last, event) {
347390
+ // Call change event handler
347391
+ if (typeof onSelect === 'function') {
347392
+ // Check if the change event handler cancels the tab change
347393
+ if (onSelect(index, last, event) === false) return;
347394
+ } // Always set focus on tabs unless it is disabled
347404
347395
 
347405
- if (newState.mode === MODE_UNCONTROLLED) {
347406
- var maxTabIndex = Math.max(0, count_getTabsCount(props.children) - 1);
347407
- var selectedIndex = null;
347408
347396
 
347409
- if (state.selectedIndex != null) {
347410
- selectedIndex = Math.min(state.selectedIndex, maxTabIndex);
347411
- } else {
347412
- selectedIndex = props.defaultIndex || 0;
347413
- }
347414
-
347415
- newState.selectedIndex = selectedIndex;
347397
+ if (focusTabOnClick) {
347398
+ setFocus(true);
347416
347399
  }
347417
347400
 
347418
- return newState;
347401
+ if (mode === MODE_UNCONTROLLED) {
347402
+ // Update selected index
347403
+ setSelectedIndex(index);
347404
+ }
347419
347405
  };
347420
347406
 
347421
- var _proto = Tabs.prototype;
347422
-
347423
- _proto.render = function render() {
347424
- var _this$props = this.props,
347425
- children = _this$props.children,
347426
- defaultIndex = _this$props.defaultIndex,
347427
- defaultFocus = _this$props.defaultFocus,
347428
- props = Tabs_objectWithoutPropertiesLoose(_this$props, Tabs_excluded);
347407
+ var subProps = Tabs_extends({}, props);
347429
347408
 
347430
- var _this$state = this.state,
347431
- focus = _this$state.focus,
347432
- selectedIndex = _this$state.selectedIndex;
347433
- props.focus = focus;
347434
- props.onSelect = this.handleSelected;
347409
+ subProps.focus = focus;
347410
+ subProps.onSelect = handleSelected;
347435
347411
 
347436
- if (selectedIndex != null) {
347437
- props.selectedIndex = selectedIndex;
347438
- }
347439
-
347440
- return /*#__PURE__*/external_react_["default"].createElement(UncontrolledTabs, props, children);
347441
- };
347442
-
347443
- return Tabs;
347444
- }(external_react_.Component);
347412
+ if (selectedIndex != null) {
347413
+ subProps.selectedIndex = selectedIndex;
347414
+ }
347445
347415
 
347446
- Tabs.defaultProps = {
347447
- defaultFocus: false,
347448
- forceRenderTabPanel: false,
347449
- selectedIndex: null,
347450
- defaultIndex: null,
347451
- environment: null,
347452
- disableUpDownKeys: false
347416
+ delete subProps.defaultFocus;
347417
+ delete subProps.defaultIndex;
347418
+ delete subProps.focusTabOnClick;
347419
+ return /*#__PURE__*/external_react_["default"].createElement(components_UncontrolledTabs, subProps, children);
347453
347420
  };
347454
347421
 
347455
347422
  Tabs.propTypes = false ? 0 : {};
347423
+ Tabs.defaultProps = Tabs_defaultProps;
347456
347424
  Tabs.tabsRole = 'Tabs';
347425
+ /* harmony default export */ const components_Tabs = (Tabs);
347457
347426
  ;// ./node_modules/react-tabs/esm/components/TabList.js
347458
347427
  var TabList_excluded = ["children", "className"];
347459
347428
 
@@ -347461,44 +347430,29 @@ function TabList_extends() { TabList_extends = Object.assign || function (target
347461
347430
 
347462
347431
  function TabList_objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
347463
347432
 
347464
- function TabList_inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; TabList_setPrototypeOf(subClass, superClass); }
347465
-
347466
- function TabList_setPrototypeOf(o, p) { TabList_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return TabList_setPrototypeOf(o, p); }
347467
-
347468
-
347469
-
347470
-
347471
-
347472
- var TabList = /*#__PURE__*/function (_Component) {
347473
- TabList_inheritsLoose(TabList, _Component);
347474
-
347475
- function TabList() {
347476
- return _Component.apply(this, arguments) || this;
347477
- }
347478
347433
 
347479
- var _proto = TabList.prototype;
347480
347434
 
347481
- _proto.render = function render() {
347482
- var _this$props = this.props,
347483
- children = _this$props.children,
347484
- className = _this$props.className,
347485
- attributes = TabList_objectWithoutPropertiesLoose(_this$props, TabList_excluded);
347486
347435
 
347487
- return /*#__PURE__*/external_react_["default"].createElement("ul", TabList_extends({}, attributes, {
347488
- className: (0,clsx_m/* default */.A)(className),
347489
- role: "tablist"
347490
- }), children);
347491
- };
347436
+ var TabList_defaultProps = {
347437
+ className: 'react-tabs__tab-list'
347438
+ };
347439
+ var TabList_propTypes = false ? 0 : {};
347492
347440
 
347493
- return TabList;
347494
- }(external_react_.Component);
347441
+ var TabList = function TabList(props) {
347442
+ var children = props.children,
347443
+ className = props.className,
347444
+ attributes = TabList_objectWithoutPropertiesLoose(props, TabList_excluded);
347495
347445
 
347496
- TabList.defaultProps = {
347497
- className: 'react-tabs__tab-list'
347446
+ return /*#__PURE__*/external_react_["default"].createElement("ul", TabList_extends({}, attributes, {
347447
+ className: (0,clsx_m/* default */.A)(className),
347448
+ role: "tablist"
347449
+ }), children);
347498
347450
  };
347499
347451
 
347500
- TabList.propTypes = false ? 0 : {};
347501
347452
  TabList.tabsRole = 'TabList';
347453
+ TabList.propTypes = false ? 0 : {};
347454
+ TabList.defaultProps = TabList_defaultProps;
347455
+ /* harmony default export */ const components_TabList = (TabList);
347502
347456
  ;// ./node_modules/react-tabs/esm/components/Tab.js
347503
347457
  var Tab_excluded = ["children", "className", "disabled", "disabledClassName", "focus", "id", "panelId", "selected", "selectedClassName", "tabIndex", "tabRef"];
347504
347458
 
@@ -347506,80 +347460,11 @@ function Tab_extends() { Tab_extends = Object.assign || function (target) { for
347506
347460
 
347507
347461
  function Tab_objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
347508
347462
 
347509
- function Tab_inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; Tab_setPrototypeOf(subClass, superClass); }
347510
-
347511
- function Tab_setPrototypeOf(o, p) { Tab_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return Tab_setPrototypeOf(o, p); }
347512
-
347513
347463
 
347514
347464
 
347515
347465
 
347516
347466
  var DEFAULT_CLASS = 'react-tabs__tab';
347517
-
347518
- var Tab = /*#__PURE__*/function (_Component) {
347519
- Tab_inheritsLoose(Tab, _Component);
347520
-
347521
- function Tab() {
347522
- return _Component.apply(this, arguments) || this;
347523
- }
347524
-
347525
- var _proto = Tab.prototype;
347526
-
347527
- _proto.componentDidMount = function componentDidMount() {
347528
- this.checkFocus();
347529
- };
347530
-
347531
- _proto.componentDidUpdate = function componentDidUpdate() {
347532
- this.checkFocus();
347533
- };
347534
-
347535
- _proto.checkFocus = function checkFocus() {
347536
- var _this$props = this.props,
347537
- selected = _this$props.selected,
347538
- focus = _this$props.focus;
347539
-
347540
- if (selected && focus) {
347541
- this.node.focus();
347542
- }
347543
- };
347544
-
347545
- _proto.render = function render() {
347546
- var _cx,
347547
- _this = this;
347548
-
347549
- var _this$props2 = this.props,
347550
- children = _this$props2.children,
347551
- className = _this$props2.className,
347552
- disabled = _this$props2.disabled,
347553
- disabledClassName = _this$props2.disabledClassName,
347554
- focus = _this$props2.focus,
347555
- id = _this$props2.id,
347556
- panelId = _this$props2.panelId,
347557
- selected = _this$props2.selected,
347558
- selectedClassName = _this$props2.selectedClassName,
347559
- tabIndex = _this$props2.tabIndex,
347560
- tabRef = _this$props2.tabRef,
347561
- attributes = Tab_objectWithoutPropertiesLoose(_this$props2, Tab_excluded);
347562
-
347563
- return /*#__PURE__*/external_react_["default"].createElement("li", Tab_extends({}, attributes, {
347564
- className: (0,clsx_m/* default */.A)(className, (_cx = {}, _cx[selectedClassName] = selected, _cx[disabledClassName] = disabled, _cx)),
347565
- ref: function ref(node) {
347566
- _this.node = node;
347567
- if (tabRef) tabRef(node);
347568
- },
347569
- role: "tab",
347570
- id: id,
347571
- "aria-selected": selected ? 'true' : 'false',
347572
- "aria-disabled": disabled ? 'true' : 'false',
347573
- "aria-controls": panelId,
347574
- tabIndex: tabIndex || (selected ? '0' : null),
347575
- "data-rttab": true
347576
- }), children);
347577
- };
347578
-
347579
- return Tab;
347580
- }(external_react_.Component);
347581
-
347582
- Tab.defaultProps = {
347467
+ var DEFAULT_PROPS = {
347583
347468
  className: DEFAULT_CLASS,
347584
347469
  disabledClassName: DEFAULT_CLASS + "--disabled",
347585
347470
  focus: false,
@@ -347588,9 +347473,51 @@ Tab.defaultProps = {
347588
347473
  selected: false,
347589
347474
  selectedClassName: DEFAULT_CLASS + "--selected"
347590
347475
  };
347476
+ var Tab_propTypes = false ? 0 : {};
347477
+
347478
+ var Tab = function Tab(props) {
347479
+ var _cx;
347480
+
347481
+ var nodeRef = (0,external_react_.useRef)();
347482
+
347483
+ var children = props.children,
347484
+ className = props.className,
347485
+ disabled = props.disabled,
347486
+ disabledClassName = props.disabledClassName,
347487
+ focus = props.focus,
347488
+ id = props.id,
347489
+ panelId = props.panelId,
347490
+ selected = props.selected,
347491
+ selectedClassName = props.selectedClassName,
347492
+ tabIndex = props.tabIndex,
347493
+ tabRef = props.tabRef,
347494
+ attributes = Tab_objectWithoutPropertiesLoose(props, Tab_excluded);
347495
+
347496
+ (0,external_react_.useEffect)(function () {
347497
+ if (selected && focus) {
347498
+ nodeRef.current.focus();
347499
+ }
347500
+ }, [selected, focus]);
347501
+ return /*#__PURE__*/external_react_["default"].createElement("li", Tab_extends({}, attributes, {
347502
+ className: (0,clsx_m/* default */.A)(className, (_cx = {}, _cx[selectedClassName] = selected, _cx[disabledClassName] = disabled, _cx)),
347503
+ ref: function ref(node) {
347504
+ nodeRef.current = node;
347505
+ if (tabRef) tabRef(node);
347506
+ },
347507
+ role: "tab",
347508
+ id: id,
347509
+ "aria-selected": selected ? 'true' : 'false',
347510
+ "aria-disabled": disabled ? 'true' : 'false',
347511
+ "aria-controls": panelId,
347512
+ tabIndex: tabIndex || (selected ? '0' : null),
347513
+ "data-rttab": true
347514
+ }), children);
347515
+ };
347591
347516
 
347592
347517
  Tab.propTypes = false ? 0 : {};
347593
347518
  Tab.tabsRole = 'Tab';
347519
+ Tab.defaultProps = DEFAULT_PROPS;
347520
+ /* harmony default export */ const components_Tab = (Tab);
347594
347521
  ;// ./node_modules/react-tabs/esm/components/TabPanel.js
347595
347522
  var TabPanel_excluded = ["children", "className", "forceRender", "id", "selected", "selectedClassName", "tabId"];
347596
347523
 
@@ -347598,56 +347525,41 @@ function TabPanel_extends() { TabPanel_extends = Object.assign || function (targ
347598
347525
 
347599
347526
  function TabPanel_objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
347600
347527
 
347601
- function TabPanel_inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; TabPanel_setPrototypeOf(subClass, superClass); }
347602
-
347603
- function TabPanel_setPrototypeOf(o, p) { TabPanel_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return TabPanel_setPrototypeOf(o, p); }
347604
-
347605
347528
 
347606
347529
 
347607
347530
 
347608
347531
  var TabPanel_DEFAULT_CLASS = 'react-tabs__tab-panel';
347609
-
347610
- var TabPanel = /*#__PURE__*/function (_Component) {
347611
- TabPanel_inheritsLoose(TabPanel, _Component);
347612
-
347613
- function TabPanel() {
347614
- return _Component.apply(this, arguments) || this;
347615
- }
347616
-
347617
- var _proto = TabPanel.prototype;
347618
-
347619
- _proto.render = function render() {
347620
- var _cx;
347621
-
347622
- var _this$props = this.props,
347623
- children = _this$props.children,
347624
- className = _this$props.className,
347625
- forceRender = _this$props.forceRender,
347626
- id = _this$props.id,
347627
- selected = _this$props.selected,
347628
- selectedClassName = _this$props.selectedClassName,
347629
- tabId = _this$props.tabId,
347630
- attributes = TabPanel_objectWithoutPropertiesLoose(_this$props, TabPanel_excluded);
347631
-
347632
- return /*#__PURE__*/external_react_["default"].createElement("div", TabPanel_extends({}, attributes, {
347633
- className: (0,clsx_m/* default */.A)(className, (_cx = {}, _cx[selectedClassName] = selected, _cx)),
347634
- role: "tabpanel",
347635
- id: id,
347636
- "aria-labelledby": tabId
347637
- }), forceRender || selected ? children : null);
347638
- };
347639
-
347640
- return TabPanel;
347641
- }(external_react_.Component);
347642
-
347643
- TabPanel.defaultProps = {
347532
+ var TabPanel_defaultProps = {
347644
347533
  className: TabPanel_DEFAULT_CLASS,
347645
347534
  forceRender: false,
347646
347535
  selectedClassName: TabPanel_DEFAULT_CLASS + "--selected"
347647
347536
  };
347537
+ var TabPanel_propTypes = false ? 0 : {};
347538
+
347539
+ var TabPanel = function TabPanel(props) {
347540
+ var _cx;
347541
+
347542
+ var children = props.children,
347543
+ className = props.className,
347544
+ forceRender = props.forceRender,
347545
+ id = props.id,
347546
+ selected = props.selected,
347547
+ selectedClassName = props.selectedClassName,
347548
+ tabId = props.tabId,
347549
+ attributes = TabPanel_objectWithoutPropertiesLoose(props, TabPanel_excluded);
347550
+
347551
+ return /*#__PURE__*/external_react_["default"].createElement("div", TabPanel_extends({}, attributes, {
347552
+ className: (0,clsx_m/* default */.A)(className, (_cx = {}, _cx[selectedClassName] = selected, _cx)),
347553
+ role: "tabpanel",
347554
+ id: id,
347555
+ "aria-labelledby": tabId
347556
+ }), forceRender || selected ? children : null);
347557
+ };
347648
347558
 
347649
- TabPanel.propTypes = false ? 0 : {};
347650
347559
  TabPanel.tabsRole = 'TabPanel';
347560
+ TabPanel.propTypes = false ? 0 : {};
347561
+ TabPanel.defaultProps = TabPanel_defaultProps;
347562
+ /* harmony default export */ const components_TabPanel = (TabPanel);
347651
347563
  ;// ./node_modules/react-tabs/esm/index.js
347652
347564
 
347653
347565
 
@@ -369284,6 +369196,7 @@ const node_html_parser_1 = __webpack_require__(36192);
369284
369196
  const classnames_1 = __importDefault(__webpack_require__(46942));
369285
369197
  const react_router_dom_1 = __webpack_require__(92648);
369286
369198
  const EditorSlice_1 = __webpack_require__(68512);
369199
+ const externalLinkHelper_1 = __webpack_require__(31615);
369287
369200
  const open_in_new_tab_svg_1 = __importDefault(__webpack_require__(86936));
369288
369201
  const stores_1 = __webpack_require__(32132);
369289
369202
  const ProjectTypes_1 = __webpack_require__(27130);
@@ -369324,6 +369237,7 @@ function HtmlRunner() {
369324
369237
  const [searchParams, setSearchParams] = (0, react_router_dom_1.useSearchParams)();
369325
369238
  // Using BroadcastChannel to communicate between the main app and the preview tab
369326
369239
  const broadcastChannel = (0, react_1.useRef)(null);
369240
+ const [iframeKey, setIframeKey] = (0, react_1.useState)(0);
369327
369241
  (0, react_1.useEffect)(() => {
369328
369242
  broadcastChannel.current = new BroadcastChannel(BROADCAST_CHANNEL);
369329
369243
  return () => {
@@ -369369,22 +369283,29 @@ function HtmlRunner() {
369369
369283
  };
369370
369284
  }
369371
369285
  }, [isPreviewMode]);
369372
- (0, react_1.useEffect)(() => {
369373
- const handleReloadMessage = (event) => {
369374
- if (event.data?.msg !== "RELOAD")
369375
- return;
369376
- const nextPage = event.data?.payload?.linkTo;
369377
- if (typeof nextPage !== "string")
369378
- return;
369379
- dispatch((0, EditorSlice_1.setPage)(nextPage));
369380
- dispatch((0, EditorSlice_1.triggerCodeRun)());
369381
- };
369382
- window.addEventListener("message", handleReloadMessage);
369383
- return () => window.removeEventListener("message", handleReloadMessage);
369384
- }, [dispatch]);
369286
+ const showModal = () => {
369287
+ dispatch((0, EditorSlice_1.showErrorModal)());
369288
+ eventListener();
369289
+ };
369290
+ const { externalLink, setExternalLink, handleAllowedExternalLink, handleRegularExternalLink, handleExternalLinkError, } = (0, externalLinkHelper_1.useExternalLinkState)(showModal);
369291
+ const eventListener = () => {
369292
+ window.addEventListener("message", (event) => {
369293
+ if (typeof event.data?.msg === "string") {
369294
+ if (event.data?.msg === "ERROR: External link") {
369295
+ handleExternalLinkError();
369296
+ }
369297
+ else if (event.data?.msg === "Allowed external link") {
369298
+ handleAllowedExternalLink(event.data.payload.linkTo);
369299
+ }
369300
+ else {
369301
+ handleRegularExternalLink(event.data.payload.linkTo);
369302
+ }
369303
+ }
369304
+ });
369305
+ };
369385
369306
  const iframeReload = () => {
369386
369307
  const iframe = output.current?.contentDocument;
369387
- const filePath = (0, helpers_1.getFilenameFromIFrame)(iframe);
369308
+ const filePath = (0, helpers_1.getFilenameFromIFrame)(iframe) ?? externalLink;
369388
369309
  if (runningFilePath !== filePath) {
369389
369310
  setRunningFilePath(filePath);
369390
369311
  }
@@ -369394,11 +369315,9 @@ function HtmlRunner() {
369394
369315
  linkElement.addEventListener("click", (e) => {
369395
369316
  const href = linkElement.getAttribute("href");
369396
369317
  const target = linkElement.getAttribute("target");
369397
- if (!href || target !== "_blank" || (0, helpers_1.isExternalUrl)(href))
369398
- return;
369399
- // block in-iframe navigation for internal html links with target="_blank"
369318
+ // block in-iframe navigation for links with target="_blank" and .html href
369400
369319
  // and open them in a preview tab
369401
- if (href?.includes(".html")) {
369320
+ if (target === "_blank" && href?.includes(".html")) {
369402
369321
  e.preventDefault();
369403
369322
  e.stopImmediatePropagation();
369404
369323
  openPreview(`/${href}`);
@@ -369406,13 +369325,17 @@ function HtmlRunner() {
369406
369325
  }, true);
369407
369326
  });
369408
369327
  }
369328
+ setExternalLink(null);
369409
369329
  };
369410
369330
  (0, react_1.useEffect)(() => {
369331
+ eventListener();
369411
369332
  dispatch((0, EditorSlice_1.loadingRunner)(EditorTypes_1.RunnerType.HTML));
369412
369333
  dispatch((0, EditorSlice_1.setLoadedRunner)(EditorTypes_1.RunnerType.HTML));
369413
369334
  }, []);
369414
369335
  (0, react_1.useEffect)(() => {
369415
369336
  if (codeRunTriggered) {
369337
+ // Set unique key to force iframe remount
369338
+ setIframeKey((prev) => prev + 1);
369416
369339
  runCode();
369417
369340
  if (!isPreviewMode) {
369418
369341
  broadcastChannel.current?.postMessage({
@@ -369432,31 +369355,42 @@ function HtmlRunner() {
369432
369355
  const fileToRun = page ?? defaultPreviewFilePath;
369433
369356
  setRunningFilePath(fileToRun);
369434
369357
  dispatch((0, EditorSlice_1.setError)(null));
369435
- const entryPoint = (0, helpers_1.getEntryPoint)(projectComponents, fileToRun);
369436
- if (!entryPoint) {
369437
- dispatch((0, EditorSlice_1.setError)(fileToRun === helpers_1.DEFAULT_ENTRY_FILE_PATH && !isPreviewMode
369438
- ? {
369439
- type: Errors_1.ErrorType.ENTRY_FILE_NOT_FOUND,
369440
- details: {
369441
- fileName: helpers_1.DEFAULT_ENTRY_FILE_NAME,
369442
- },
369443
- }
369444
- : {
369445
- type: Errors_1.ErrorType.PAGE_NOT_FOUND,
369446
- }));
369447
- dispatch((0, EditorSlice_1.codeRunHandled)());
369448
- return;
369449
- }
369450
- const indexPage = (0, node_html_parser_1.parse)(entryPoint.content);
369451
- const body = indexPage.querySelector("body") || indexPage;
369452
- const htmlRoot = indexPage.querySelector("html") ?? indexPage;
369453
- body.insertAdjacentHTML("afterbegin", scripts_1.disableLocalStorageScript);
369454
- htmlRoot.insertAdjacentHTML("afterbegin", scripts_1.consoleOverrideScript);
369455
- const { content } = await (0, fileParsers_1.resolveAndRewriteHtmlImports)(indexPage.toString(), projectComponents, entryPoint.path, page ?? entryPoint.path);
369456
- if (output.current) {
369457
- output.current.srcdoc = content;
369358
+ if (!externalLink) {
369359
+ const entryPoint = (0, helpers_1.getEntryPoint)(projectComponents, fileToRun);
369360
+ if (!entryPoint) {
369361
+ dispatch((0, EditorSlice_1.setError)(fileToRun === helpers_1.DEFAULT_ENTRY_FILE_PATH && !isPreviewMode
369362
+ ? {
369363
+ type: Errors_1.ErrorType.ENTRY_FILE_NOT_FOUND,
369364
+ details: {
369365
+ fileName: helpers_1.DEFAULT_ENTRY_FILE_NAME,
369366
+ },
369367
+ }
369368
+ : {
369369
+ type: Errors_1.ErrorType.PAGE_NOT_FOUND,
369370
+ }));
369371
+ dispatch((0, EditorSlice_1.codeRunHandled)());
369372
+ return;
369373
+ }
369374
+ const indexPage = (0, node_html_parser_1.parse)(entryPoint.content);
369375
+ const body = indexPage.querySelector("body") || indexPage;
369376
+ const htmlRoot = indexPage.querySelector("html") ?? indexPage;
369377
+ body.insertAdjacentHTML("afterbegin", scripts_1.disableLocalStorageScript);
369378
+ htmlRoot.insertAdjacentHTML("afterbegin", scripts_1.consoleOverrideScript);
369379
+ const { content } = await (0, fileParsers_1.resolveAndRewriteHtmlImports)(indexPage.toString(), projectComponents, entryPoint.path, page ?? entryPoint.path);
369380
+ if (output.current?.contentWindow?.document) {
369381
+ const doc = output.current.contentWindow.document;
369382
+ doc.open();
369383
+ doc.write(content);
369384
+ doc.close();
369385
+ }
369386
+ if (codeRunTriggered) {
369387
+ dispatch((0, EditorSlice_1.codeRunHandled)());
369388
+ }
369458
369389
  }
369459
- if (codeRunTriggered) {
369390
+ else {
369391
+ if (output.current) {
369392
+ output.current.src = externalLink;
369393
+ }
369460
369394
  dispatch((0, EditorSlice_1.codeRunHandled)());
369461
369395
  }
369462
369396
  };
@@ -369496,7 +369430,7 @@ function HtmlRunner() {
369496
369430
  const iframeClasses = (0, classnames_1.default)(styles_module_scss_1.default.iframe, {
369497
369431
  [styles_module_scss_1.default.codeHasBeenRun]: codeHasBeenRun,
369498
369432
  });
369499
- return ((0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.htmlrunnerContainer, children: [(0, jsx_runtime_1.jsx)(OutputTabPanel_1.OutputTabPanel, { title: "Preview", icon: preview_svg_1.default, readOnly: readOnly, extraTabContent: codeHasBeenRun && openInNewTabLink, tabPanelClassName: styles_module_scss_1.default.previewHtml, children: error ? ((0, jsx_runtime_1.jsx)("div", { className: iframeClasses, children: (0, jsx_runtime_1.jsx)(NotFoundPage_1.NotFoundPage, {}) })) : ((0, jsx_runtime_1.jsx)("iframe", { className: iframeClasses, sandbox: "allow-scripts allow-same-origin allow-modals allow-popups allow-popups-to-escape-sandbox", referrerPolicy: "strict-origin-when-cross-origin", allow: "\n accelerometer 'none';\n camera 'none';\n encrypted-media;\n fullscreen;\n picture-in-picture;\n geolocation 'none';\n gyroscope 'none';\n magnetometer 'none';\n microphone 'none';\n midi 'none';\n payment 'none';\n usb 'none';\n ", id: "output-frame", title: "HTML Output Preview", ref: output, onLoad: iframeReload })) }), !isPreviewMode && ((0, jsx_runtime_1.jsx)(ResizableWithHandle_1.default, { "data-testid": "proj-console-container", handleDirection: "top", defaultHeight: "50%", className: styles_module_scss_1.default.resizeContainer, handleClassName: styles_module_scss_1.default.resizeHandleContainer, children: (0, jsx_runtime_1.jsx)(OutputTabPanel_1.OutputTabPanel, { title: "Console", icon: console_svg_1.default, readOnly: readOnly, children: (0, jsx_runtime_1.jsx)(HtmlConsole_1.default, { consoleLogs: consoleLogs }) }) }))] }));
369433
+ return ((0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.htmlrunnerContainer, children: [(0, jsx_runtime_1.jsx)(OutputTabPanel_1.OutputTabPanel, { title: "Preview", icon: preview_svg_1.default, readOnly: readOnly, extraTabContent: codeHasBeenRun && openInNewTabLink, tabPanelClassName: styles_module_scss_1.default.previewHtml, children: error ? ((0, jsx_runtime_1.jsx)("div", { className: iframeClasses, children: (0, jsx_runtime_1.jsx)(NotFoundPage_1.NotFoundPage, {}) })) : ((0, jsx_runtime_1.jsx)("iframe", { className: iframeClasses, sandbox: "allow-scripts allow-same-origin allow-modals allow-popups", referrerPolicy: "strict-origin-when-cross-origin", allow: "\n accelerometer 'none';\n camera 'none';\n encrypted-media;\n fullscreen;\n picture-in-picture;\n geolocation 'none';\n gyroscope 'none';\n magnetometer 'none';\n microphone 'none';\n midi 'none';\n payment 'none';\n usb 'none';\n ", id: "output-frame", title: "HTML Output Preview", ref: output, onLoad: iframeReload, src: "about:blank" }, iframeKey)) }), !isPreviewMode && ((0, jsx_runtime_1.jsx)(ResizableWithHandle_1.default, { "data-testid": "proj-console-container", handleDirection: "top", defaultHeight: "50%", className: styles_module_scss_1.default.resizeContainer, handleClassName: styles_module_scss_1.default.resizeHandleContainer, children: (0, jsx_runtime_1.jsx)(OutputTabPanel_1.OutputTabPanel, { title: "Console", icon: console_svg_1.default, readOnly: readOnly, children: (0, jsx_runtime_1.jsx)(HtmlConsole_1.default, { consoleLogs: consoleLogs }) }) }))] }));
369500
369434
  }
369501
369435
  exports["default"] = HtmlRunner;
369502
369436
 
@@ -369575,7 +369509,6 @@ const node_html_parser_1 = __webpack_require__(36192);
369575
369509
  const ProjectTypes_1 = __webpack_require__(27130);
369576
369510
  const binaryStore_1 = __webpack_require__(5060);
369577
369511
  const projectHelpers_1 = __webpack_require__(2610);
369578
- const helpers_1 = __webpack_require__(1108);
369579
369512
  /** Normalizes CSS paths
369580
369513
  * Treats paths without leading / or ./ or ../ as relative to current file
369581
369514
  * E.g. 'image.png' will be treated as './image.png'
@@ -369629,7 +369562,9 @@ const getMimeType = (filePath, fallback = "application/octet-stream") => {
369629
369562
  };
369630
369563
  /** Check if a URL is external, blob, or data */
369631
369564
  const isExternalOrDataUrl = (url) => {
369632
- return (url.startsWith("blob:") || (0, helpers_1.isExternalUrl)(url) || url.startsWith("data:"));
369565
+ return (url.startsWith("blob:") ||
369566
+ /^(https?:)?\/\//.test(url) ||
369567
+ url.startsWith("data:"));
369633
369568
  };
369634
369569
  async function replaceAsync(input, regex, replacer) {
369635
369570
  let result = "";
@@ -369806,12 +369741,7 @@ async function rewriteSources(indexPage, components, baseFilePath, propName, blo
369806
369741
  const nodes = indexPage.querySelectorAll(`[${propName}]`);
369807
369742
  for (const node of nodes) {
369808
369743
  const raw = node.getAttribute(propName);
369809
- if (!raw)
369810
- continue;
369811
- // For external links with target="_blank", add noopener and noreferrer for security
369812
- if ((0, helpers_1.isExternalUrl)(raw) && node.getAttribute("target") === "_blank")
369813
- node.setAttribute("rel", "noopener noreferrer");
369814
- if (isExternalOrDataUrl(raw))
369744
+ if (!raw || isExternalOrDataUrl(raw))
369815
369745
  continue;
369816
369746
  if ((0, projectHelpers_1.parseFileName)(raw).extension === ProjectTypes_1.ProjectFileExtension.HTML &&
369817
369747
  propName === "href") {
@@ -369864,7 +369794,7 @@ async function resolveAndRewriteHtmlImports(html, projectComponents, baseFilePat
369864
369794
 
369865
369795
 
369866
369796
  Object.defineProperty(exports, "__esModule", ({ value: true }));
369867
- exports.isExternalUrl = exports.getFilenameFromIFrame = exports.getEntryPoint = exports.DEFAULT_ENTRY_FILE_PATH = exports.DEFAULT_ENTRY_FILE_NAME = void 0;
369797
+ exports.getFilenameFromIFrame = exports.getEntryPoint = exports.DEFAULT_ENTRY_FILE_PATH = exports.DEFAULT_ENTRY_FILE_NAME = void 0;
369868
369798
  const ProjectTypes_1 = __webpack_require__(27130);
369869
369799
  exports.DEFAULT_ENTRY_FILE_NAME = "index.html";
369870
369800
  exports.DEFAULT_ENTRY_FILE_PATH = `/${exports.DEFAULT_ENTRY_FILE_NAME}`;
@@ -369875,10 +369805,6 @@ const getEntryPoint = (components, filePath) => {
369875
369805
  exports.getEntryPoint = getEntryPoint;
369876
369806
  const getFilenameFromIFrame = (iframe) => iframe?.querySelector("meta[filename]")?.getAttribute("filename") ?? null;
369877
369807
  exports.getFilenameFromIFrame = getFilenameFromIFrame;
369878
- const isExternalUrl = (url) => {
369879
- return /^(https?:)?\/\//.test(url);
369880
- };
369881
- exports.isExternalUrl = isExternalUrl;
369882
369808
 
369883
369809
 
369884
369810
  /***/ }),
@@ -376659,6 +376585,57 @@ const downloadProjectFile = async (file, fileName) => {
376659
376585
  exports.downloadProjectFile = downloadProjectFile;
376660
376586
 
376661
376587
 
376588
+ /***/ }),
376589
+
376590
+ /***/ 31615:
376591
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
376592
+
376593
+
376594
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
376595
+ exports.matchingRegexes = exports.allowedInternalLinks = exports.allowedExternalLinks = exports.useExternalLinkState = void 0;
376596
+ const react_1 = __webpack_require__(51649);
376597
+ const react_redux_1 = __webpack_require__(14062);
376598
+ const EditorSlice_1 = __webpack_require__(68512);
376599
+ const Errors_1 = __webpack_require__(20339);
376600
+ const domain = "https://rpf.io/";
376601
+ const host = window?.location?.origin || "http://localhost:3011";
376602
+ const rpfDomain = new RegExp(`^${domain}`);
376603
+ const hostDomain = new RegExp(`^${host}`);
376604
+ const allowedInternalLinks = [new RegExp(`^#[a-zA-Z0-9]+`)];
376605
+ exports.allowedInternalLinks = allowedInternalLinks;
376606
+ const allowedExternalLinks = [rpfDomain, hostDomain];
376607
+ exports.allowedExternalLinks = allowedExternalLinks;
376608
+ const useExternalLinkState = (showModal) => {
376609
+ const dispatch = (0, react_redux_1.useDispatch)();
376610
+ const [externalLink, setExternalLink] = (0, react_1.useState)(null);
376611
+ const handleAllowedExternalLink = (linkTo) => {
376612
+ setExternalLink(linkTo);
376613
+ dispatch((0, EditorSlice_1.triggerCodeRun)());
376614
+ };
376615
+ const handleRegularExternalLink = (linkTo) => {
376616
+ setExternalLink(null);
376617
+ dispatch((0, EditorSlice_1.setPage)(linkTo));
376618
+ dispatch((0, EditorSlice_1.triggerCodeRun)());
376619
+ };
376620
+ const handleExternalLinkError = () => {
376621
+ dispatch((0, EditorSlice_1.setError)({ type: Errors_1.ErrorType.EXTERNAL_LINK }));
376622
+ showModal();
376623
+ };
376624
+ return {
376625
+ externalLink,
376626
+ setExternalLink,
376627
+ handleAllowedExternalLink,
376628
+ handleRegularExternalLink,
376629
+ handleExternalLinkError,
376630
+ };
376631
+ };
376632
+ exports.useExternalLinkState = useExternalLinkState;
376633
+ const matchingRegexes = (regexArray, testString) => {
376634
+ return regexArray.some((reg) => reg.test(testString));
376635
+ };
376636
+ exports.matchingRegexes = matchingRegexes;
376637
+
376638
+
376662
376639
  /***/ }),
376663
376640
 
376664
376641
  /***/ 65404:
package/dist/style.css CHANGED
@@ -33,13 +33,11 @@
33
33
  }
34
34
 
35
35
  .react-tabs__tab:focus {
36
- box-shadow: 0 0 5px hsl(208, 99%, 50%);
37
- border-color: hsl(208, 99%, 50%);
38
36
  outline: none;
39
37
  }
40
38
 
41
39
  .react-tabs__tab:focus:after {
42
- content: "";
40
+ content: '';
43
41
  position: absolute;
44
42
  height: 5px;
45
43
  left: -4px;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gwchq-textjam",
3
3
  "description": "Embeddable React editor used in Raspberry Pi text-based projects.",
4
- "version": "0.2.31",
4
+ "version": "0.2.32",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/GirlsFirst/gwchq-textjam",
7
7
  "author": "Girls Who Code HQ",