@openedx/paragon 21.12.0 → 21.12.1

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 (88) hide show
  1. package/dist/Container/index.js +6 -2
  2. package/dist/Container/index.js.map +1 -1
  3. package/dist/Dropdown/index.js.map +1 -1
  4. package/dist/Form/FormSwitch.js +3 -0
  5. package/dist/Form/FormSwitch.js.map +1 -1
  6. package/dist/Hyperlink/index.js +7 -6
  7. package/dist/Hyperlink/index.js.map +1 -1
  8. package/dist/Icon/index.js +17 -10
  9. package/dist/Icon/index.js.map +1 -1
  10. package/dist/IconButton/index.js +1 -1
  11. package/dist/IconButton/index.js.map +1 -1
  12. package/dist/Layout/index.js.map +1 -1
  13. package/dist/Modal/ModalDialog.js +3 -0
  14. package/dist/Modal/ModalDialog.js.map +1 -1
  15. package/dist/Modal/index.js +11 -6
  16. package/dist/Modal/index.js.map +1 -1
  17. package/dist/Popover/index.js +8 -8
  18. package/dist/Popover/index.js.map +1 -1
  19. package/dist/ProductTour/Checkpoint.js +10 -8
  20. package/dist/ProductTour/Checkpoint.js.map +1 -1
  21. package/dist/ProductTour/messages.js +16 -0
  22. package/dist/SearchField/SearchFieldAdvanced.js +12 -7
  23. package/dist/SearchField/SearchFieldAdvanced.js.map +1 -1
  24. package/dist/SearchField/SearchFieldLabel.js +3 -3
  25. package/dist/SearchField/SearchFieldLabel.js.map +1 -1
  26. package/dist/SearchField/index.js +0 -1
  27. package/dist/SearchField/index.js.map +1 -1
  28. package/dist/Tabs/index.js +13 -13
  29. package/dist/Tabs/index.js.map +1 -1
  30. package/dist/hooks/useIndexOfLastVisibleChild.js +33 -38
  31. package/dist/hooks/useIndexOfLastVisibleChild.js.map +1 -1
  32. package/dist/i18n/messages/ar.json +2 -1
  33. package/dist/i18n/messages/ca.json +2 -1
  34. package/dist/i18n/messages/es_419.json +2 -1
  35. package/dist/i18n/messages/es_AR.json +2 -1
  36. package/dist/i18n/messages/es_ES.json +2 -1
  37. package/dist/i18n/messages/fr.json +2 -1
  38. package/dist/i18n/messages/he.json +2 -1
  39. package/dist/i18n/messages/id.json +2 -1
  40. package/dist/i18n/messages/it_IT.json +2 -1
  41. package/dist/i18n/messages/ko_KR.json +2 -1
  42. package/dist/i18n/messages/pl.json +2 -1
  43. package/dist/i18n/messages/pt_BR.json +2 -1
  44. package/dist/i18n/messages/pt_PT.json +2 -1
  45. package/dist/i18n/messages/ru.json +2 -1
  46. package/dist/i18n/messages/th.json +2 -1
  47. package/dist/i18n/messages/tr_TR.json +2 -1
  48. package/dist/i18n/messages/uk.json +2 -1
  49. package/dist/i18n/messages/zh_CN.json +2 -1
  50. package/package.json +1 -1
  51. package/src/Container/index.jsx +4 -0
  52. package/src/Dropdown/index.jsx +4 -0
  53. package/src/Form/FormSwitch.jsx +3 -0
  54. package/src/Hyperlink/index.jsx +7 -6
  55. package/src/Icon/index.jsx +17 -10
  56. package/src/IconButton/index.jsx +1 -1
  57. package/src/Layout/index.jsx +1 -4
  58. package/src/Modal/ModalDialog.jsx +3 -0
  59. package/src/Modal/index.jsx +11 -6
  60. package/src/Popover/README.md +0 -1
  61. package/src/Popover/index.jsx +11 -11
  62. package/src/ProductTour/Checkpoint.jsx +9 -6
  63. package/src/ProductTour/messages.js +16 -0
  64. package/src/SearchField/SearchFieldAdvanced.jsx +12 -7
  65. package/src/SearchField/SearchFieldLabel.jsx +3 -3
  66. package/src/SearchField/index.jsx +0 -1
  67. package/src/Tabs/index.jsx +19 -13
  68. package/src/hooks/tests/useIndexOfLastVisibleChild.test.jsx +3 -3
  69. package/src/hooks/useIndexOfLastVisibleChild.jsx +36 -38
  70. package/src/hooks/useIndexOfLastVisibleChild.mdx +3 -3
  71. package/src/i18n/messages/ar.json +2 -1
  72. package/src/i18n/messages/ca.json +2 -1
  73. package/src/i18n/messages/es_419.json +2 -1
  74. package/src/i18n/messages/es_AR.json +2 -1
  75. package/src/i18n/messages/es_ES.json +2 -1
  76. package/src/i18n/messages/fr.json +2 -1
  77. package/src/i18n/messages/he.json +2 -1
  78. package/src/i18n/messages/id.json +2 -1
  79. package/src/i18n/messages/it_IT.json +2 -1
  80. package/src/i18n/messages/ko_KR.json +2 -1
  81. package/src/i18n/messages/pl.json +2 -1
  82. package/src/i18n/messages/pt_BR.json +2 -1
  83. package/src/i18n/messages/pt_PT.json +2 -1
  84. package/src/i18n/messages/ru.json +2 -1
  85. package/src/i18n/messages/th.json +2 -1
  86. package/src/i18n/messages/tr_TR.json +2 -1
  87. package/src/i18n/messages/uk.json +2 -1
  88. package/src/i18n/messages/zh_CN.json +2 -1
@@ -8,7 +8,7 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typ
8
8
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
9
9
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
10
10
  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; }
11
- import React, { useEffect, useMemo, useRef } from 'react';
11
+ import React, { useEffect, useMemo, useRef, useState, useCallback } from 'react';
12
12
  import classNames from 'classnames';
13
13
  import PropTypes from 'prop-types';
14
14
  import BaseTabs from 'react-bootstrap/Tabs';
@@ -27,11 +27,11 @@ function Tabs(_ref) {
27
27
  activeKey
28
28
  } = _ref,
29
29
  props = _objectWithoutProperties(_ref, _excluded);
30
- const containerElementRef = useRef(null);
30
+ const [containerElementRef, setContainerElementRef] = useState(null);
31
31
  const overflowElementRef = useRef(null);
32
- const indexOfLastVisibleChild = useIndexOfLastVisibleChild(containerElementRef.current?.children[0], overflowElementRef.current?.parentNode);
32
+ const indexOfLastVisibleChild = useIndexOfLastVisibleChild(containerElementRef?.firstChild, overflowElementRef.current?.parentNode);
33
33
  useEffect(() => {
34
- if (containerElementRef.current) {
34
+ if (containerElementRef) {
35
35
  const observer = new MutationObserver(mutations => {
36
36
  mutations.forEach(mutation => {
37
37
  // React-Bootstrap attribute 'data-rb-event-key' is responsible for the tab identification
@@ -40,8 +40,8 @@ function Tabs(_ref) {
40
40
  const isActive = mutation.target.getAttribute('aria-selected') === 'true';
41
41
  // datakey attribute is added manually to the dropdown
42
42
  // elements so that they correspond to the native tabs' eventKey
43
- const element = containerElementRef.current.querySelector(`[datakey='${eventKey}']`);
44
- const moreTab = containerElementRef.current.querySelector('.pgn__tab_more');
43
+ const element = containerElementRef.querySelector(`[datakey='${eventKey}']`);
44
+ const moreTab = containerElementRef.querySelector('.pgn__tab_more');
45
45
  if (isActive) {
46
46
  element?.classList.add('active');
47
47
  // Here we add active class to the 'More Tab' if element exists in the dropdown
@@ -55,7 +55,7 @@ function Tabs(_ref) {
55
55
  }
56
56
  });
57
57
  });
58
- observer.observe(containerElementRef.current, {
58
+ observer.observe(containerElementRef, {
59
59
  attributes: true,
60
60
  subtree: true,
61
61
  attributeFilter: ['aria-selected']
@@ -63,16 +63,16 @@ function Tabs(_ref) {
63
63
  return () => observer.disconnect();
64
64
  }
65
65
  return undefined;
66
- }, []);
66
+ }, [containerElementRef]);
67
67
  useEffect(() => {
68
68
  if (overflowElementRef.current?.parentNode) {
69
69
  overflowElementRef.current.parentNode.tabIndex = -1;
70
70
  }
71
71
  }, [overflowElementRef.current?.parentNode]);
72
- const handleDropdownTabClick = eventKey => {
73
- const hiddenTab = containerElementRef.current.querySelector(`[data-rb-event-key='${eventKey}']`);
72
+ const handleDropdownTabClick = useCallback(eventKey => {
73
+ const hiddenTab = containerElementRef.querySelector(`[data-rb-event-key='${eventKey}']`);
74
74
  hiddenTab.click();
75
- };
75
+ }, [containerElementRef]);
76
76
  const tabsChildren = useMemo(() => {
77
77
  const indexOfOverflowStart = indexOfLastVisibleChild + 1;
78
78
  const handleDropdownKeyPress = (e, eventKey) => {
@@ -151,9 +151,9 @@ function Tabs(_ref) {
151
151
  }, overflowChildren))
152
152
  }));
153
153
  return childrenList;
154
- }, [activeKey, children, defaultActiveKey, indexOfLastVisibleChild, moreTabText]);
154
+ }, [activeKey, children, defaultActiveKey, indexOfLastVisibleChild, moreTabText, handleDropdownTabClick]);
155
155
  return /*#__PURE__*/React.createElement("div", {
156
- ref: containerElementRef
156
+ ref: setContainerElementRef
157
157
  }, /*#__PURE__*/React.createElement(BaseTabs, _extends({
158
158
  defaultActiveKey: defaultActiveKey,
159
159
  activeKey: activeKey
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["React","useEffect","useMemo","useRef","classNames","PropTypes","BaseTabs","TabsDeprecated","Bubble","Dropdown","useIndexOfLastVisibleChild","Tab","MORE_TAB_TEXT","Tabs","_ref","children","className","moreTabText","defaultActiveKey","activeKey","props","_objectWithoutProperties","_excluded","containerElementRef","overflowElementRef","indexOfLastVisibleChild","current","parentNode","observer","MutationObserver","mutations","forEach","mutation","eventKey","target","getAttribute","isActive","element","querySelector","moreTab","classList","add","remove","observe","attributes","subtree","attributeFilter","disconnect","undefined","tabIndex","handleDropdownTabClick","hiddenTab","click","tabsChildren","indexOfOverflowStart","handleDropdownKeyPress","e","key","childrenList","Children","map","child","index","type","name","process","env","NODE_ENV","console","error","isValidElement","_child$props","title","notification","tabClassName","rest","_excluded2","newTitle","createElement","Fragment","variant","role","expandable","tabClass","modifiedTab","cloneElement","_objectSpread","moreTabHasNotification","overflowChildren","slice","overflowChild","Item","as","onClick","onKeyPress","disabled","datakey","active","splice","length","ref","Toggle","id","Menu","_extends","propTypes","oneOf","node","isRequired","string","defaultProps","Deprecated","default","TabContainer","TabContent","TabPane"],"sources":["../../src/Tabs/index.jsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef } from 'react';\nimport classNames from 'classnames';\nimport PropTypes from 'prop-types';\nimport BaseTabs from 'react-bootstrap/Tabs';\nimport TabsDeprecated from './deprecated';\nimport Bubble from '../Bubble';\nimport Dropdown from '../Dropdown';\nimport useIndexOfLastVisibleChild from '../hooks/useIndexOfLastVisibleChild';\nimport Tab from './Tab';\n\nexport const MORE_TAB_TEXT = 'More...';\n\nfunction Tabs({\n children,\n className,\n moreTabText = MORE_TAB_TEXT,\n defaultActiveKey,\n activeKey,\n ...props\n}) {\n const containerElementRef = useRef(null);\n const overflowElementRef = useRef(null);\n const indexOfLastVisibleChild = useIndexOfLastVisibleChild(\n containerElementRef.current?.children[0],\n overflowElementRef.current?.parentNode,\n );\n\n useEffect(() => {\n if (containerElementRef.current) {\n const observer = new MutationObserver((mutations => {\n mutations.forEach(mutation => {\n // React-Bootstrap attribute 'data-rb-event-key' is responsible for the tab identification\n const eventKey = mutation.target.getAttribute('data-rb-event-key');\n // React-Bootstrap attribute 'aria-selected' is responsible for selected/unselected state\n const isActive = mutation.target.getAttribute('aria-selected') === 'true';\n // datakey attribute is added manually to the dropdown\n // elements so that they correspond to the native tabs' eventKey\n const element = containerElementRef.current.querySelector(`[datakey='${eventKey}']`);\n const moreTab = containerElementRef.current.querySelector('.pgn__tab_more');\n if (isActive) {\n element?.classList.add('active');\n // Here we add active class to the 'More Tab' if element exists in the dropdown\n if (element) {\n moreTab.classList.add('active');\n } else {\n moreTab.classList.remove('active');\n }\n } else {\n element?.classList.remove('active');\n }\n });\n }));\n observer.observe(containerElementRef.current, {\n attributes: true, subtree: true, attributeFilter: ['aria-selected'],\n });\n return () => observer.disconnect();\n }\n return undefined;\n }, []);\n\n useEffect(() => {\n if (overflowElementRef.current?.parentNode) {\n overflowElementRef.current.parentNode.tabIndex = -1;\n }\n }, [overflowElementRef.current?.parentNode]);\n\n const handleDropdownTabClick = (eventKey) => {\n const hiddenTab = containerElementRef.current.querySelector(`[data-rb-event-key='${eventKey}']`);\n hiddenTab.click();\n };\n\n const tabsChildren = useMemo(() => {\n const indexOfOverflowStart = indexOfLastVisibleChild + 1;\n const handleDropdownKeyPress = (e, eventKey) => {\n if (e.key === 'Enter') {\n handleDropdownTabClick(eventKey);\n }\n };\n const childrenList = React.Children.map(children, (child, index) => {\n if (child?.type?.name !== 'Tab' && process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.error(\n `Tabs children can only be of type Tab. ${children[index]} was passed instead.`,\n );\n }\n if (!React.isValidElement(child)) {\n return child;\n }\n const {\n title, notification, tabClassName, ...rest\n } = child.props;\n let newTitle;\n if (notification) {\n newTitle = (\n <>\n {title}\n <Bubble\n variant=\"error\"\n role=\"status\"\n className=\"pgn__tab-notification\"\n aria-live=\"polite\"\n expandable\n >\n {notification}\n </Bubble>\n </>\n );\n } else {\n newTitle = title;\n }\n const tabClass = index > indexOfLastVisibleChild ? 'pgn__tab_invisible' : '';\n const modifiedTab = React.cloneElement(child, {\n ...rest,\n title: newTitle,\n tabClassName: classNames(tabClass, tabClassName),\n });\n return modifiedTab;\n });\n let moreTabHasNotification = false;\n const overflowChildren = childrenList.slice(indexOfOverflowStart)\n .map(overflowChild => {\n if (!moreTabHasNotification && overflowChild.props.notification) {\n moreTabHasNotification = true;\n }\n return (\n <Dropdown.Item\n as=\"li\"\n tabIndex=\"0\"\n key={`${overflowChild.props.eventKey}overflow`}\n onClick={() => handleDropdownTabClick(overflowChild.props.eventKey)}\n onKeyPress={(e) => handleDropdownKeyPress(e, overflowChild.props.eventKey)}\n disabled={overflowChild.props.disabled}\n datakey={overflowChild.props.eventKey}\n className={classNames({\n active: overflowChild.props.eventKey === defaultActiveKey || overflowChild.props.eventKey === activeKey,\n }, 'pgn__tabs__dropdown-item')}\n >\n {overflowChild.props.title}\n </Dropdown.Item>\n );\n });\n\n childrenList.splice(indexOfOverflowStart, 0, (<Tab\n key=\"moreTabKey\"\n tabClassName={classNames(!overflowChildren.length && 'pgn__tab_invisible', 'pgn__tab_more')}\n title={(\n <Dropdown ref={overflowElementRef}>\n <Dropdown.Toggle\n variant=\"link\"\n className=\"nav-link\"\n id=\"pgn__tab-toggle\"\n >\n {moreTabText}\n {moreTabHasNotification && (\n <Bubble\n variant=\"error\"\n role=\"status\"\n className=\"pgn__tab-notification\"\n />\n )}\n </Dropdown.Toggle>\n <Dropdown.Menu as=\"ul\" className=\"dropdown-menu-right\">{overflowChildren}</Dropdown.Menu>\n </Dropdown>\n )}\n />\n ));\n return childrenList;\n }, [activeKey, children, defaultActiveKey, indexOfLastVisibleChild, moreTabText]);\n\n return (\n <div ref={containerElementRef}>\n <BaseTabs\n defaultActiveKey={defaultActiveKey}\n activeKey={activeKey}\n {...props}\n className={classNames(className, 'pgn__tabs')}\n >\n {tabsChildren}\n </BaseTabs>\n </div>\n );\n}\n\nTabs.propTypes = {\n /** Specifies variant to use. */\n variant: PropTypes.oneOf(['tabs', 'pills', 'inverse-tabs', 'inverse-pills', 'button-group']),\n /** Specifies elements that is processed to create tabs. */\n children: PropTypes.node.isRequired,\n /** Specifies class name to append to the base element. */\n className: PropTypes.string,\n /** Specifies text for the 'More' tab. */\n moreTabText: PropTypes.string,\n /** Specifies default active tab (uncontrolled usage). */\n defaultActiveKey: PropTypes.string,\n /** Specifies active tab (controlled usage). */\n activeKey: PropTypes.string,\n};\n\nTabs.defaultProps = {\n variant: 'tabs',\n className: undefined,\n moreTabText: MORE_TAB_TEXT,\n defaultActiveKey: undefined,\n activeKey: undefined,\n};\n\nTabs.Deprecated = TabsDeprecated;\n\nexport default Tabs;\nexport { Tab };\nexport { default as TabContainer } from 'react-bootstrap/TabContainer';\nexport { default as TabContent } from 'react-bootstrap/TabContent';\nexport { default as TabPane } from 'react-bootstrap/TabPane';\n"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AO,EAAE3E,SAAS,CAACqG,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,CAAC,CAAC;EAC5F;EACA3F,QAAQ,EAAEV,SAAS,CAACsG,IAAI,CAACC,UAAU;EACnC;EACA5F,SAAS,EAAEX,SAAS,CAACwG,MAAM;EAC3B;EACA5F,WAAW,EAAEZ,SAAS,CAACwG,MAAM;EAC7B;EACA3F,gBAAgB,EAAEb,SAAS,CAACwG,MAAM;EAClC;EACA1F,SAAS,EAAEd,SAAS,CAACwG;AACvB,CAAC;AAEDhG,IAAI,CAACiG,YAAY,GAAG;EAClB9B,OAAO,EAAE,MAAM;EACfhE,SAAS,EAAEgC,SAAS;EACpB/B,WAAW,EAAEL,aAAa;EAC1BM,gBAAgB,EAAE8B,SAAS;EAC3B7B,SAAS,EAAE6B;AACb,CAAC;AAEDnC,IAAI,CAACkG,UAAU,GAAGxG,cAAc;AAEhC,eAAeM,IAAI;AACnB,SAASF,GAAG;AACZ,SAASqG,OAAO,IAAIC,YAAY,QAAQ,8BAA8B;AACtE,SAASD,OAAO,IAAIE,UAAU,QAAQ,4BAA4B;AAClE,SAASF,OAAO,IAAIG,OAAO,QAAQ,yBAAyB"}
1
+ {"version":3,"file":"index.js","names":["React","useEffect","useMemo","useRef","useState","useCallback","classNames","PropTypes","BaseTabs","TabsDeprecated","Bubble","Dropdown","useIndexOfLastVisibleChild","Tab","MORE_TAB_TEXT","Tabs","_ref","children","className","moreTabText","defaultActiveKey","activeKey","props","_objectWithoutProperties","_excluded","containerElementRef","setContainerElementRef","overflowElementRef","indexOfLastVisibleChild","firstChild","current","parentNode","observer","MutationObserver","mutations","forEach","mutation","eventKey","target","getAttribute","isActive","element","querySelector","moreTab","classList","add","remove","observe","attributes","subtree","attributeFilter","disconnect","undefined","tabIndex","handleDropdownTabClick","hiddenTab","click","tabsChildren","indexOfOverflowStart","handleDropdownKeyPress","e","key","childrenList","Children","map","child","index","type","name","process","env","NODE_ENV","console","error","isValidElement","_child$props","title","notification","tabClassName","rest","_excluded2","newTitle","createElement","Fragment","variant","role","expandable","tabClass","modifiedTab","cloneElement","_objectSpread","moreTabHasNotification","overflowChildren","slice","overflowChild","Item","as","onClick","onKeyPress","disabled","datakey","active","splice","length","ref","Toggle","id","Menu","_extends","propTypes","oneOf","node","isRequired","string","defaultProps","Deprecated","default","TabContainer","TabContent","TabPane"],"sources":["../../src/Tabs/index.jsx"],"sourcesContent":["import React, {\n useEffect,\n useMemo,\n useRef,\n useState,\n useCallback,\n} from 'react';\nimport classNames from 'classnames';\nimport PropTypes from 'prop-types';\nimport BaseTabs from 'react-bootstrap/Tabs';\nimport TabsDeprecated from './deprecated';\nimport Bubble from '../Bubble';\nimport Dropdown from '../Dropdown';\nimport useIndexOfLastVisibleChild from '../hooks/useIndexOfLastVisibleChild';\nimport Tab from './Tab';\n\nexport const MORE_TAB_TEXT = 'More...';\n\nfunction Tabs({\n children,\n className,\n moreTabText = MORE_TAB_TEXT,\n defaultActiveKey,\n activeKey,\n ...props\n}) {\n const [containerElementRef, setContainerElementRef] = useState(null);\n const overflowElementRef = useRef(null);\n const indexOfLastVisibleChild = useIndexOfLastVisibleChild(\n containerElementRef?.firstChild,\n overflowElementRef.current?.parentNode,\n );\n\n useEffect(() => {\n if (containerElementRef) {\n const observer = new MutationObserver((mutations => {\n mutations.forEach(mutation => {\n // React-Bootstrap attribute 'data-rb-event-key' is responsible for the tab identification\n const eventKey = mutation.target.getAttribute('data-rb-event-key');\n // React-Bootstrap attribute 'aria-selected' is responsible for selected/unselected state\n const isActive = mutation.target.getAttribute('aria-selected') === 'true';\n // datakey attribute is added manually to the dropdown\n // elements so that they correspond to the native tabs' eventKey\n const element = containerElementRef.querySelector(`[datakey='${eventKey}']`);\n const moreTab = containerElementRef.querySelector('.pgn__tab_more');\n if (isActive) {\n element?.classList.add('active');\n // Here we add active class to the 'More Tab' if element exists in the dropdown\n if (element) {\n moreTab.classList.add('active');\n } else {\n moreTab.classList.remove('active');\n }\n } else {\n element?.classList.remove('active');\n }\n });\n }));\n observer.observe(containerElementRef, {\n attributes: true, subtree: true, attributeFilter: ['aria-selected'],\n });\n return () => observer.disconnect();\n }\n return undefined;\n }, [containerElementRef]);\n\n useEffect(() => {\n if (overflowElementRef.current?.parentNode) {\n overflowElementRef.current.parentNode.tabIndex = -1;\n }\n }, [overflowElementRef.current?.parentNode]);\n\n const handleDropdownTabClick = useCallback((eventKey) => {\n const hiddenTab = containerElementRef.querySelector(`[data-rb-event-key='${eventKey}']`);\n hiddenTab.click();\n }, [containerElementRef]);\n\n const tabsChildren = useMemo(() => {\n const indexOfOverflowStart = indexOfLastVisibleChild + 1;\n const handleDropdownKeyPress = (e, eventKey) => {\n if (e.key === 'Enter') {\n handleDropdownTabClick(eventKey);\n }\n };\n const childrenList = React.Children.map(children, (child, index) => {\n if (child?.type?.name !== 'Tab' && process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.error(\n `Tabs children can only be of type Tab. ${children[index]} was passed instead.`,\n );\n }\n if (!React.isValidElement(child)) {\n return child;\n }\n const {\n title, notification, tabClassName, ...rest\n } = child.props;\n let newTitle;\n if (notification) {\n newTitle = (\n <>\n {title}\n <Bubble\n variant=\"error\"\n role=\"status\"\n className=\"pgn__tab-notification\"\n aria-live=\"polite\"\n expandable\n >\n {notification}\n </Bubble>\n </>\n );\n } else {\n newTitle = title;\n }\n const tabClass = index > indexOfLastVisibleChild ? 'pgn__tab_invisible' : '';\n const modifiedTab = React.cloneElement(child, {\n ...rest,\n title: newTitle,\n tabClassName: classNames(tabClass, tabClassName),\n });\n return modifiedTab;\n });\n let moreTabHasNotification = false;\n const overflowChildren = childrenList.slice(indexOfOverflowStart)\n .map(overflowChild => {\n if (!moreTabHasNotification && overflowChild.props.notification) {\n moreTabHasNotification = true;\n }\n return (\n <Dropdown.Item\n as=\"li\"\n tabIndex=\"0\"\n key={`${overflowChild.props.eventKey}overflow`}\n onClick={() => handleDropdownTabClick(overflowChild.props.eventKey)}\n onKeyPress={(e) => handleDropdownKeyPress(e, overflowChild.props.eventKey)}\n disabled={overflowChild.props.disabled}\n datakey={overflowChild.props.eventKey}\n className={classNames({\n active: overflowChild.props.eventKey === defaultActiveKey || overflowChild.props.eventKey === activeKey,\n }, 'pgn__tabs__dropdown-item')}\n >\n {overflowChild.props.title}\n </Dropdown.Item>\n );\n });\n\n childrenList.splice(indexOfOverflowStart, 0, (<Tab\n key=\"moreTabKey\"\n tabClassName={classNames(!overflowChildren.length && 'pgn__tab_invisible', 'pgn__tab_more')}\n title={(\n <Dropdown ref={overflowElementRef}>\n <Dropdown.Toggle\n variant=\"link\"\n className=\"nav-link\"\n id=\"pgn__tab-toggle\"\n >\n {moreTabText}\n {moreTabHasNotification && (\n <Bubble\n variant=\"error\"\n role=\"status\"\n className=\"pgn__tab-notification\"\n />\n )}\n </Dropdown.Toggle>\n <Dropdown.Menu as=\"ul\" className=\"dropdown-menu-right\">{overflowChildren}</Dropdown.Menu>\n </Dropdown>\n )}\n />\n ));\n return childrenList;\n }, [activeKey, children, defaultActiveKey, indexOfLastVisibleChild, moreTabText, handleDropdownTabClick]);\n\n return (\n <div ref={setContainerElementRef}>\n <BaseTabs\n defaultActiveKey={defaultActiveKey}\n activeKey={activeKey}\n {...props}\n className={classNames(className, 'pgn__tabs')}\n >\n {tabsChildren}\n </BaseTabs>\n </div>\n );\n}\n\nTabs.propTypes = {\n /** Specifies variant to use. */\n variant: PropTypes.oneOf(['tabs', 'pills', 'inverse-tabs', 'inverse-pills', 'button-group']),\n /** Specifies elements that is processed to create tabs. */\n children: PropTypes.node.isRequired,\n /** Specifies class name to append to the base element. */\n className: PropTypes.string,\n /** Specifies text for the 'More' tab. */\n moreTabText: PropTypes.string,\n /** Specifies default active tab (uncontrolled usage). */\n defaultActiveKey: PropTypes.string,\n /** Specifies active tab (controlled usage). */\n activeKey: PropTypes.string,\n};\n\nTabs.defaultProps = {\n variant: 'tabs',\n className: undefined,\n moreTabText: MORE_TAB_TEXT,\n defaultActiveKey: undefined,\n activeKey: undefined,\n};\n\nTabs.Deprecated = TabsDeprecated;\n\nexport default Tabs;\nexport { Tab };\nexport { default as TabContainer } from 'react-bootstrap/TabContainer';\nexport { default as TabContent } from 'react-bootstrap/TabContent';\nexport { default as TabPane } from 'react-bootstrap/TabPane';\n"],"mappings":";;;;;;;;;;AAAA,OAAOA,KAAK,IACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,EACRC,WAAW,QACN,OAAO;AACd,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,QAAQ,MAAM,sBAAsB;AAC3C,OAAOC,cAAc,MAAM,cAAc;AACzC,OAAOC,MAAM,MAAM,WAAW;AAC9B,OAAOC,QAAQ,MAAM,aAAa;AAClC,OAAOC,0BAA0B,MAAM,qCAAqC;AAC5E,OAAOC,GAAG,MAAM,OAAO;AAEvB,OAAO,MAAMC,aAAa,GAAG,SAAS;AAEtC,SAASC,IAAIA,CAAAC,IAAA,EAOV;EAAA,IAPW;MACZC,QAAQ;MACRC,SAAS;MACTC,WAAW,GAAGL,aAAa;MAC3BM,gBAAgB;MAChBC;IAEF,CAAC,GAAAL,IAAA;IADIM,KAAK,GAAAC,wBAAA,CAAAP,IAAA,EAAAQ,SAAA;EAER,MAAM,CAACC,mBAAmB,EAAEC,sBAAsB,CAAC,GAAGtB,QAAQ,CAAC,IAAI,CAAC;EACpE,MAAMuB,kBAAkB,GAAGxB,MAAM,CAAC,IAAI,CAAC;EACvC,MAAMyB,uBAAuB,GAAGhB,0BAA0B,CACxDa,mBAAmB,EAAEI,UAAU,EAC/BF,kBAAkB,CAACG,OAAO,EAAEC,UAC9B,CAAC;EAED9B,SAAS,CAAC,MAAM;IACd,IAAIwB,mBAAmB,EAAE;MACvB,MAAMO,QAAQ,GAAG,IAAIC,gBAAgB,CAAEC,SAAS,IAAI;QAClDA,SAAS,CAACC,OAAO,CAACC,QAAQ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AAA,CAAAkF,aAAA,CAAC1E,QAAQ,EAAAoG,QAAA;IACPxF,gBAAgB,EAAEA,gBAAiB;IACnCC,SAAS,EAAEA;EAAU,GACjBC,KAAK;IACTJ,SAAS,EAAEZ,UAAU,CAACY,SAAS,EAAE,WAAW;EAAE,IAE7CuC,YACO,CACP,CAAC;AAEV;AAEA1C,IAAI,CAAC8F,SAAS,GAAG;EACf;EACAzB,OAAO,EAAE7E,SAAS,CAACuG,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,CAAC,CAAC;EAC5F;EACA7F,QAAQ,EAAEV,SAAS,CAACwG,IAAI,CAACC,UAAU;EACnC;EACA9F,SAAS,EAAEX,SAAS,CAAC0G,MAAM;EAC3B;EACA9F,WAAW,EAAEZ,SAAS,CAAC0G,MAAM;EAC7B;EACA7F,gBAAgB,EAAEb,SAAS,CAAC0G,MAAM;EAClC;EACA5F,SAAS,EAAEd,SAAS,CAAC0G;AACvB,CAAC;AAEDlG,IAAI,CAACmG,YAAY,GAAG;EAClB9B,OAAO,EAAE,MAAM;EACflE,SAAS,EAAEkC,SAAS;EACpBjC,WAAW,EAAEL,aAAa;EAC1BM,gBAAgB,EAAEgC,SAAS;EAC3B/B,SAAS,EAAE+B;AACb,CAAC;AAEDrC,IAAI,CAACoG,UAAU,GAAG1G,cAAc;AAEhC,eAAeM,IAAI;AACnB,SAASF,GAAG;AACZ,SAASuG,OAAO,IAAIC,YAAY,QAAQ,8BAA8B;AACtE,SAASD,OAAO,IAAIE,UAAU,QAAQ,4BAA4B;AAClE,SAASF,OAAO,IAAIG,OAAO,QAAQ,yBAAyB"}
@@ -1,5 +1,4 @@
1
1
  import { useLayoutEffect, useState } from 'react';
2
- import useWindowSize from './useWindowSize';
3
2
 
4
3
  /**
5
4
  * This hook will find the index of the last child of a containing element
@@ -9,48 +8,44 @@ import useWindowSize from './useWindowSize';
9
8
  * @param {Element} containerElementRef - container element
10
9
  * @param {Element} overflowElementRef - overflow element
11
10
  *
12
- * The hook returns an array containing:
13
- * [indexOfLastVisibleChild, containerElementRef, overflowElementRef]
14
- *
15
- * indexOfLastVisibleChild - the index of the last visible child
16
- * containerElementRef - a ref to be added to the containing html node
17
- * overflowElementRef - a ref to be added to an html node inside the container
18
- * that is likely to be used to contain a "More" type dropdown or other
19
- * mechanism to reveal hidden children. The width of this element is always
20
- * included when determining which children will fit or not. Usage of this ref
21
- * is optional.
11
+ * The hook returns the index of the last visible child.
22
12
  */
23
13
  const useIndexOfLastVisibleChild = (containerElementRef, overflowElementRef) => {
24
14
  const [indexOfLastVisibleChild, setIndexOfLastVisibleChild] = useState(-1);
25
- const windowSize = useWindowSize();
26
15
  useLayoutEffect(() => {
27
- if (!containerElementRef) {
28
- return;
16
+ function updateLastVisibleChildIndex() {
17
+ // Get array of child nodes from NodeList form
18
+ const childNodesArr = Array.prototype.slice.call(containerElementRef.children);
19
+ const {
20
+ nextIndexOfLastVisibleChild
21
+ } = childNodesArr
22
+ // filter out the overflow element
23
+ .filter(childNode => childNode !== overflowElementRef)
24
+ // sum the widths to find the last visible element's index
25
+ .reduce((acc, childNode, index) => {
26
+ acc.sumWidth += childNode.getBoundingClientRect().width;
27
+ if (acc.sumWidth <= containerElementRef.getBoundingClientRect().width) {
28
+ acc.nextIndexOfLastVisibleChild = index;
29
+ }
30
+ return acc;
31
+ }, {
32
+ // Include the overflow element's width to begin with. Doing this means
33
+ // sometimes we'll show a dropdown with one item in it when it would fit,
34
+ // but allowing this case dramatically simplifies the calculations we need
35
+ // to do above.
36
+ sumWidth: overflowElementRef ? overflowElementRef.getBoundingClientRect().width : 0,
37
+ nextIndexOfLastVisibleChild: -1
38
+ });
39
+ setIndexOfLastVisibleChild(nextIndexOfLastVisibleChild);
40
+ }
41
+ if (containerElementRef) {
42
+ updateLastVisibleChildIndex();
43
+ const resizeObserver = new ResizeObserver(() => updateLastVisibleChildIndex());
44
+ resizeObserver.observe(containerElementRef);
45
+ return () => resizeObserver.disconnect();
29
46
  }
30
- // Get array of child nodes from NodeList form
31
- const childNodesArr = Array.prototype.slice.call(containerElementRef.children);
32
- const {
33
- nextIndexOfLastVisibleChild
34
- } = childNodesArr
35
- // filter out the overflow element
36
- .filter(childNode => childNode !== overflowElementRef)
37
- // sum the widths to find the last visible element's index
38
- .reduce((acc, childNode, index) => {
39
- acc.sumWidth += childNode.getBoundingClientRect().width;
40
- if (acc.sumWidth <= containerElementRef.getBoundingClientRect().width) {
41
- acc.nextIndexOfLastVisibleChild = index;
42
- }
43
- return acc;
44
- }, {
45
- // Include the overflow element's width to begin with. Doing this means
46
- // sometimes we'll show a dropdown with one item in it when it would fit,
47
- // but allowing this case dramatically simplifies the calculations we need
48
- // to do above.
49
- sumWidth: overflowElementRef ? overflowElementRef.getBoundingClientRect().width : 0,
50
- nextIndexOfLastVisibleChild: -1
51
- });
52
- setIndexOfLastVisibleChild(nextIndexOfLastVisibleChild);
53
- }, [windowSize, containerElementRef, overflowElementRef]);
47
+ return undefined;
48
+ }, [containerElementRef, overflowElementRef]);
54
49
  return indexOfLastVisibleChild;
55
50
  };
56
51
  export default useIndexOfLastVisibleChild;
@@ -1 +1 @@
1
- {"version":3,"file":"useIndexOfLastVisibleChild.js","names":["useLayoutEffect","useState","useWindowSize","useIndexOfLastVisibleChild","containerElementRef","overflowElementRef","indexOfLastVisibleChild","setIndexOfLastVisibleChild","windowSize","childNodesArr","Array","prototype","slice","call","children","nextIndexOfLastVisibleChild","filter","childNode","reduce","acc","index","sumWidth","getBoundingClientRect","width"],"sources":["../../src/hooks/useIndexOfLastVisibleChild.jsx"],"sourcesContent":["import { useLayoutEffect, useState } from 'react';\n\nimport useWindowSize from './useWindowSize';\n\n/**\n * This hook will find the index of the last child of a containing element\n * that fits within its bounding rectangle. This is done by summing the widths\n * of the children until they exceed the width of the container.\n *\n * @param {Element} containerElementRef - container element\n * @param {Element} overflowElementRef - overflow element\n *\n * The hook returns an array containing:\n * [indexOfLastVisibleChild, containerElementRef, overflowElementRef]\n *\n * indexOfLastVisibleChild - the index of the last visible child\n * containerElementRef - a ref to be added to the containing html node\n * overflowElementRef - a ref to be added to an html node inside the container\n * that is likely to be used to contain a \"More\" type dropdown or other\n * mechanism to reveal hidden children. The width of this element is always\n * included when determining which children will fit or not. Usage of this ref\n * is optional.\n */\nconst useIndexOfLastVisibleChild = (containerElementRef, overflowElementRef) => {\n const [indexOfLastVisibleChild, setIndexOfLastVisibleChild] = useState(-1);\n const windowSize = useWindowSize();\n\n useLayoutEffect(() => {\n if (!containerElementRef) {\n return;\n }\n // Get array of child nodes from NodeList form\n const childNodesArr = Array.prototype.slice.call(containerElementRef.children);\n const { nextIndexOfLastVisibleChild } = childNodesArr\n // filter out the overflow element\n .filter(childNode => childNode !== overflowElementRef)\n // sum the widths to find the last visible element's index\n .reduce((acc, childNode, index) => {\n acc.sumWidth += childNode.getBoundingClientRect().width;\n if (acc.sumWidth <= containerElementRef.getBoundingClientRect().width) {\n acc.nextIndexOfLastVisibleChild = index;\n }\n return acc;\n }, {\n // Include the overflow element's width to begin with. Doing this means\n // sometimes we'll show a dropdown with one item in it when it would fit,\n // but allowing this case dramatically simplifies the calculations we need\n // to do above.\n sumWidth: overflowElementRef ? overflowElementRef.getBoundingClientRect().width : 0,\n nextIndexOfLastVisibleChild: -1,\n });\n\n setIndexOfLastVisibleChild(nextIndexOfLastVisibleChild);\n }, [windowSize, containerElementRef, overflowElementRef]);\n\n return indexOfLastVisibleChild;\n};\n\nexport default useIndexOfLastVisibleChild;\n"],"mappings":"AAAA,SAASA,eAAe,EAAEC,QAAQ,QAAQ,OAAO;AAEjD,OAAOC,aAAa,MAAM,iBAAiB;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,0BAA0B,GAAGA,CAACC,mBAAmB,EAAEC,kBAAkB,KAAK;EAC9E,MAAM,CAACC,uBAAuB,EAAEC,0BAA0B,CAAC,GAAGN,QAAQ,CAAC,CAAC,CAAC,CAAC;EAC1E,MAAMO,UAAU,GAAGN,aAAa,CAAC,CAAC;EAElCF,eAAe,CAAC,MAAM;IACpB,IAAI,CAACI,mBAAmB,EAAE;MACxB;IACF;IACA;IACA,MAAMK,aAAa,GAAGC,KAAK,CAACC,SAAS,CAACC,KAAK,CAACC,IAAI,CAACT,mBAAmB,CAACU,QAAQ,CAAC;IAC9E,MAAM;MAAEC;IAA4B,CAAC,GAAGN;IACtC;IAAA,CACCO,MAAM,CAACC,SAAS,IAAIA,SAAS,KAAKZ,kBAAkB;IACrD;IAAA,CACCa,MAAM,CAAC,CAACC,GAAG,EAAEF,SAAS,EAAEG,KAAK,KAAK;MACjCD,GAAG,CAACE,QAAQ,IAAIJ,SAAS,CAACK,qBAAqB,CAAC,CAAC,CAACC,KAAK;MACvD,IAAIJ,GAAG,CAACE,QAAQ,IAAIjB,mBAAmB,CAACkB,qBAAqB,CAAC,CAAC,CAACC,KAAK,EAAE;QACrEJ,GAAG,CAACJ,2BAA2B,GAAGK,KAAK;MACzC;MACA,OAAOD,GAAG;IACZ,CAAC,EAAE;MACD;MACA;MACA;MACA;MACAE,QAAQ,EAAEhB,kBAAkB,GAAGA,kBAAkB,CAACiB,qBAAqB,CAAC,CAAC,CAACC,KAAK,GAAG,CAAC;MACnFR,2BAA2B,EAAE,CAAC;IAChC,CAAC,CAAC;IAEJR,0BAA0B,CAACQ,2BAA2B,CAAC;EACzD,CAAC,EAAE,CAACP,UAAU,EAAEJ,mBAAmB,EAAEC,kBAAkB,CAAC,CAAC;EAEzD,OAAOC,uBAAuB;AAChC,CAAC;AAED,eAAeH,0BAA0B"}
1
+ {"version":3,"file":"useIndexOfLastVisibleChild.js","names":["useLayoutEffect","useState","useIndexOfLastVisibleChild","containerElementRef","overflowElementRef","indexOfLastVisibleChild","setIndexOfLastVisibleChild","updateLastVisibleChildIndex","childNodesArr","Array","prototype","slice","call","children","nextIndexOfLastVisibleChild","filter","childNode","reduce","acc","index","sumWidth","getBoundingClientRect","width","resizeObserver","ResizeObserver","observe","disconnect","undefined"],"sources":["../../src/hooks/useIndexOfLastVisibleChild.jsx"],"sourcesContent":["import { useLayoutEffect, useState } from 'react';\n\n/**\n * This hook will find the index of the last child of a containing element\n * that fits within its bounding rectangle. This is done by summing the widths\n * of the children until they exceed the width of the container.\n *\n * @param {Element} containerElementRef - container element\n * @param {Element} overflowElementRef - overflow element\n *\n * The hook returns the index of the last visible child.\n */\nconst useIndexOfLastVisibleChild = (containerElementRef, overflowElementRef) => {\n const [indexOfLastVisibleChild, setIndexOfLastVisibleChild] = useState(-1);\n\n useLayoutEffect(() => {\n function updateLastVisibleChildIndex() {\n // Get array of child nodes from NodeList form\n const childNodesArr = Array.prototype.slice.call(containerElementRef.children);\n const { nextIndexOfLastVisibleChild } = childNodesArr\n // filter out the overflow element\n .filter(childNode => childNode !== overflowElementRef)\n // sum the widths to find the last visible element's index\n .reduce((acc, childNode, index) => {\n acc.sumWidth += childNode.getBoundingClientRect().width;\n if (acc.sumWidth <= containerElementRef.getBoundingClientRect().width) {\n acc.nextIndexOfLastVisibleChild = index;\n }\n return acc;\n }, {\n // Include the overflow element's width to begin with. Doing this means\n // sometimes we'll show a dropdown with one item in it when it would fit,\n // but allowing this case dramatically simplifies the calculations we need\n // to do above.\n sumWidth: overflowElementRef ? overflowElementRef.getBoundingClientRect().width : 0,\n nextIndexOfLastVisibleChild: -1,\n });\n\n setIndexOfLastVisibleChild(nextIndexOfLastVisibleChild);\n }\n\n if (containerElementRef) {\n updateLastVisibleChildIndex();\n\n const resizeObserver = new ResizeObserver(() => updateLastVisibleChildIndex());\n resizeObserver.observe(containerElementRef);\n\n return () => resizeObserver.disconnect();\n }\n\n return undefined;\n }, [containerElementRef, overflowElementRef]);\n\n return indexOfLastVisibleChild;\n};\n\nexport default useIndexOfLastVisibleChild;\n"],"mappings":"AAAA,SAASA,eAAe,EAAEC,QAAQ,QAAQ,OAAO;;AAEjD;AACA;A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AAC,CAAC;IAC1C;IAEA,OAAOC,SAAS;EAClB,CAAC,EAAE,CAACxB,mBAAmB,EAAEC,kBAAkB,CAAC,CAAC;EAE7C,OAAOC,uBAAuB;AAChC,CAAC;AAED,eAAeH,0BAA0B"}
@@ -28,5 +28,6 @@
28
28
  "pgn.FormAutosuggest.iconButtonClosed": "إغلاق قائمة الخيارات",
29
29
  "pgn.FormAutosuggest.iconButtonOpened": "فتح قائمة الخيارات",
30
30
  "pgn.Toast.closeLabel": "إغلاق ",
31
- "pgn.ProductTour.Checkpoint.position-text": "Top of step {step}"
31
+ "pgn.ProductTour.Checkpoint.top-position-text": "Top of step {step}",
32
+ "pgn.ProductTour.Checkpoint.bottom-position-text": "Bottom of step {step}"
32
33
  }
@@ -28,5 +28,6 @@
28
28
  "pgn.FormAutosuggest.iconButtonClosed": "Close the options menu",
29
29
  "pgn.FormAutosuggest.iconButtonOpened": "Open the options menu",
30
30
  "pgn.Toast.closeLabel": "Close",
31
- "pgn.ProductTour.Checkpoint.position-text": "Top of step {step}"
31
+ "pgn.ProductTour.Checkpoint.top-position-text": "Top of step {step}",
32
+ "pgn.ProductTour.Checkpoint.bottom-position-text": "Bottom of step {step}"
32
33
  }
@@ -28,5 +28,6 @@
28
28
  "pgn.FormAutosuggest.iconButtonClosed": "Cerrar el menú de opciones",
29
29
  "pgn.FormAutosuggest.iconButtonOpened": "Abre el menú de opciones",
30
30
  "pgn.Toast.closeLabel": "Cerrar",
31
- "pgn.ProductTour.Checkpoint.position-text": "Top of step {step}"
31
+ "pgn.ProductTour.Checkpoint.top-position-text": "Top of step {step}",
32
+ "pgn.ProductTour.Checkpoint.bottom-position-text": "Bottom of step {step}"
32
33
  }
@@ -28,5 +28,6 @@
28
28
  "pgn.FormAutosuggest.iconButtonClosed": "Cerrar el menú de opciones",
29
29
  "pgn.FormAutosuggest.iconButtonOpened": "Abre el menú de opciones",
30
30
  "pgn.Toast.closeLabel": "Cerrar",
31
- "pgn.ProductTour.Checkpoint.position-text": "Top of step {step}"
31
+ "pgn.ProductTour.Checkpoint.top-position-text": "Top of step {step}",
32
+ "pgn.ProductTour.Checkpoint.bottom-position-text": "Bottom of step {step}"
32
33
  }
@@ -28,5 +28,6 @@
28
28
  "pgn.FormAutosuggest.iconButtonClosed": "Cerrar el menú de opciones",
29
29
  "pgn.FormAutosuggest.iconButtonOpened": "Abre el menú de opciones",
30
30
  "pgn.Toast.closeLabel": "Cerrar",
31
- "pgn.ProductTour.Checkpoint.position-text": "Top of step {step}"
31
+ "pgn.ProductTour.Checkpoint.top-position-text": "Top of step {step}",
32
+ "pgn.ProductTour.Checkpoint.bottom-position-text": "Bottom of step {step}"
32
33
  }
@@ -28,5 +28,6 @@
28
28
  "pgn.FormAutosuggest.iconButtonClosed": "Close the options menu",
29
29
  "pgn.FormAutosuggest.iconButtonOpened": "Open the options menu",
30
30
  "pgn.Toast.closeLabel": "Close",
31
- "pgn.ProductTour.Checkpoint.position-text": "Top of step {step}"
31
+ "pgn.ProductTour.Checkpoint.top-position-text": "Top of step {step}",
32
+ "pgn.ProductTour.Checkpoint.bottom-position-text": "Bottom of step {step}"
32
33
  }
@@ -28,5 +28,6 @@
28
28
  "pgn.FormAutosuggest.iconButtonClosed": "Close the options menu",
29
29
  "pgn.FormAutosuggest.iconButtonOpened": "Open the options menu",
30
30
  "pgn.Toast.closeLabel": "Close",
31
- "pgn.ProductTour.Checkpoint.position-text": "Top of step {step}"
31
+ "pgn.ProductTour.Checkpoint.top-position-text": "Top of step {step}",
32
+ "pgn.ProductTour.Checkpoint.bottom-position-text": "Bottom of step {step}"
32
33
  }
@@ -28,5 +28,6 @@
28
28
  "pgn.FormAutosuggest.iconButtonClosed": "Close the options menu",
29
29
  "pgn.FormAutosuggest.iconButtonOpened": "Open the options menu",
30
30
  "pgn.Toast.closeLabel": "Close",
31
- "pgn.ProductTour.Checkpoint.position-text": "Top of step {step}"
31
+ "pgn.ProductTour.Checkpoint.top-position-text": "Top of step {step}",
32
+ "pgn.ProductTour.Checkpoint.bottom-position-text": "Bottom of step {step}"
32
33
  }
@@ -28,5 +28,6 @@
28
28
  "pgn.FormAutosuggest.iconButtonClosed": "Close the options menu",
29
29
  "pgn.FormAutosuggest.iconButtonOpened": "Open the options menu",
30
30
  "pgn.Toast.closeLabel": "Chiudi",
31
- "pgn.ProductTour.Checkpoint.position-text": "Top of step {step}"
31
+ "pgn.ProductTour.Checkpoint.top-position-text": "Top of step {step}",
32
+ "pgn.ProductTour.Checkpoint.bottom-position-text": "Bottom of step {step}"
32
33
  }
@@ -28,5 +28,6 @@
28
28
  "pgn.FormAutosuggest.iconButtonClosed": "Close the options menu",
29
29
  "pgn.FormAutosuggest.iconButtonOpened": "Open the options menu",
30
30
  "pgn.Toast.closeLabel": "Close",
31
- "pgn.ProductTour.Checkpoint.position-text": "Top of step {step}"
31
+ "pgn.ProductTour.Checkpoint.top-position-text": "Top of step {step}",
32
+ "pgn.ProductTour.Checkpoint.bottom-position-text": "Bottom of step {step}"
32
33
  }
@@ -28,5 +28,6 @@
28
28
  "pgn.FormAutosuggest.iconButtonClosed": "Close the options menu",
29
29
  "pgn.FormAutosuggest.iconButtonOpened": "Open the options menu",
30
30
  "pgn.Toast.closeLabel": "Zamknij",
31
- "pgn.ProductTour.Checkpoint.position-text": "Top of step {step}"
31
+ "pgn.ProductTour.Checkpoint.top-position-text": "Top of step {step}",
32
+ "pgn.ProductTour.Checkpoint.bottom-position-text": "Bottom of step {step}"
32
33
  }
@@ -28,5 +28,6 @@
28
28
  "pgn.FormAutosuggest.iconButtonClosed": "Close the options menu",
29
29
  "pgn.FormAutosuggest.iconButtonOpened": "Open the options menu",
30
30
  "pgn.Toast.closeLabel": "Close",
31
- "pgn.ProductTour.Checkpoint.position-text": "Top of step {step}"
31
+ "pgn.ProductTour.Checkpoint.top-position-text": "Top of step {step}",
32
+ "pgn.ProductTour.Checkpoint.bottom-position-text": "Bottom of step {step}"
32
33
  }
@@ -28,5 +28,6 @@
28
28
  "pgn.FormAutosuggest.iconButtonClosed": "Fechar o menu de opções",
29
29
  "pgn.FormAutosuggest.iconButtonOpened": "Abrir o menu de opções",
30
30
  "pgn.Toast.closeLabel": "Fechar",
31
- "pgn.ProductTour.Checkpoint.position-text": "Top of step {step}"
31
+ "pgn.ProductTour.Checkpoint.top-position-text": "Top of step {step}",
32
+ "pgn.ProductTour.Checkpoint.bottom-position-text": "Bottom of step {step}"
32
33
  }
@@ -28,5 +28,6 @@
28
28
  "pgn.FormAutosuggest.iconButtonClosed": "Close the options menu",
29
29
  "pgn.FormAutosuggest.iconButtonOpened": "Open the options menu",
30
30
  "pgn.Toast.closeLabel": "Close",
31
- "pgn.ProductTour.Checkpoint.position-text": "Top of step {step}"
31
+ "pgn.ProductTour.Checkpoint.top-position-text": "Top of step {step}",
32
+ "pgn.ProductTour.Checkpoint.bottom-position-text": "Bottom of step {step}"
32
33
  }
@@ -28,5 +28,6 @@
28
28
  "pgn.FormAutosuggest.iconButtonClosed": "Close the options menu",
29
29
  "pgn.FormAutosuggest.iconButtonOpened": "Open the options menu",
30
30
  "pgn.Toast.closeLabel": "Close",
31
- "pgn.ProductTour.Checkpoint.position-text": "Top of step {step}"
31
+ "pgn.ProductTour.Checkpoint.top-position-text": "Top of step {step}",
32
+ "pgn.ProductTour.Checkpoint.bottom-position-text": "Bottom of step {step}"
32
33
  }
@@ -28,5 +28,6 @@
28
28
  "pgn.FormAutosuggest.iconButtonClosed": "Seçenekler menüsünü kapat",
29
29
  "pgn.FormAutosuggest.iconButtonOpened": "Seçenekler menüsünü aç",
30
30
  "pgn.Toast.closeLabel": "Kapat",
31
- "pgn.ProductTour.Checkpoint.position-text": "Top of step {step}"
31
+ "pgn.ProductTour.Checkpoint.top-position-text": "Top of step {step}",
32
+ "pgn.ProductTour.Checkpoint.bottom-position-text": "Bottom of step {step}"
32
33
  }
@@ -28,5 +28,6 @@
28
28
  "pgn.FormAutosuggest.iconButtonClosed": "Close the options menu",
29
29
  "pgn.FormAutosuggest.iconButtonOpened": "Open the options menu",
30
30
  "pgn.Toast.closeLabel": "Close",
31
- "pgn.ProductTour.Checkpoint.position-text": "Top of step {step}"
31
+ "pgn.ProductTour.Checkpoint.top-position-text": "Top of step {step}",
32
+ "pgn.ProductTour.Checkpoint.bottom-position-text": "Bottom of step {step}"
32
33
  }
@@ -28,5 +28,6 @@
28
28
  "pgn.FormAutosuggest.iconButtonClosed": "Close the options menu",
29
29
  "pgn.FormAutosuggest.iconButtonOpened": "Open the options menu",
30
30
  "pgn.Toast.closeLabel": "Close",
31
- "pgn.ProductTour.Checkpoint.position-text": "Top of step {step}"
31
+ "pgn.ProductTour.Checkpoint.top-position-text": "Top of step {step}",
32
+ "pgn.ProductTour.Checkpoint.bottom-position-text": "Bottom of step {step}"
32
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openedx/paragon",
3
- "version": "21.12.0",
3
+ "version": "21.12.1",
4
4
  "description": "Accessible, responsive UI component library based on Bootstrap.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -28,11 +28,14 @@ Container.propTypes = {
28
28
  ...RBContainer.propTypes,
29
29
  /** Override the base element */
30
30
  as: PropTypes.elementType,
31
+ /** Specifies the contents of the container */
31
32
  children: PropTypes.node,
32
33
  /** Fill all available space at any breakpoint */
33
34
  fluid: PropTypes.bool,
34
35
  /** Set the maximum width for the container */
35
36
  size: PropTypes.oneOf(Object.keys(SIZE_CLASS_NAMES)),
37
+ /** Overrides underlying component base CSS class name */
38
+ bsPrefix: PropTypes.string,
36
39
  };
37
40
 
38
41
  Container.defaultProps = {
@@ -40,6 +43,7 @@ Container.defaultProps = {
40
43
  children: undefined,
41
44
  fluid: true,
42
45
  size: undefined,
46
+ bsPrefix: 'container',
43
47
  };
44
48
 
45
49
  export default Container;
@@ -69,6 +69,7 @@ const Dropdown = React.forwardRef(
69
69
  );
70
70
  },
71
71
  );
72
+
72
73
  Dropdown.propTypes = {
73
74
  autoClose: PropTypes.oneOfType([
74
75
  PropTypes.string,
@@ -79,6 +80,7 @@ Dropdown.propTypes = {
79
80
  show: PropTypes.bool,
80
81
  variant: PropTypes.oneOf(['light', 'dark']),
81
82
  };
83
+
82
84
  Dropdown.defaultProps = {
83
85
  autoClose: true,
84
86
  className: '',
@@ -127,9 +129,11 @@ Dropdown.Item = React.forwardRef(
127
129
  );
128
130
  },
129
131
  );
132
+
130
133
  Dropdown.Item.propTypes = {
131
134
  className: PropTypes.string,
132
135
  };
136
+
133
137
  Dropdown.Item.defaultProps = {
134
138
  className: undefined,
135
139
  };
@@ -79,8 +79,11 @@ FormSwitch.propTypes = {
79
79
  children: PropTypes.node.isRequired,
80
80
  /** Specifies class name to append to the base element. */
81
81
  className: PropTypes.string,
82
+ /** Specifies class name to append to the label element. */
82
83
  labelClassName: PropTypes.string,
84
+ /** Specifies helper text to display below the switch. */
83
85
  helperText: PropTypes.node,
86
+ /** Determines whether the label should float to the left when the switch is active. */
84
87
  floatLabelLeft: PropTypes.bool,
85
88
  };
86
89
 
@@ -101,18 +101,19 @@ Hyperlink.propTypes = {
101
101
  children: PropTypes.node.isRequired,
102
102
  /** Custom class names for the hyperlink */
103
103
  className: PropTypes.string,
104
- /** specifies where the link should open. The default behavior is `_self`, which means that the URL will be loaded into the same browsing context as the current one. If the target is `_blank` (opening a new window) `rel='noopener'` will be added to the anchor tag to prevent any potential [reverse tabnabbing attack](https://www.owasp.org/index.php/Reverse_Tabnabbing).
105
- */
104
+ /** specifies where the link should open. The default behavior is `_self`, which means that the URL will be
105
+ * loaded into the same browsing context as the current one.
106
+ * If the target is `_blank` (opening a new window) `rel='noopener'` will be added to the anchor tag to prevent
107
+ * any potential [reverse tabnabbing attack](https://www.owasp.org/index.php/Reverse_Tabnabbing).
108
+ */
106
109
  target: PropTypes.string,
107
110
  /** specifies the callback function when the link is clicked */
108
111
  onClick: PropTypes.func,
109
- // eslint-disable-next-line max-len
110
112
  /** specifies the text for links with a `_blank` target (which loads the URL in a new browsing context). */
111
113
  externalLinkAlternativeText: isRequiredIf(
112
114
  PropTypes.string,
113
115
  props => props.target === '_blank',
114
116
  ),
115
- // eslint-disable-next-line max-len
116
117
  /** specifies the title for links with a `_blank` target (which loads the URL in a new browsing context). */
117
118
  externalLinkTitle: isRequiredIf(
118
119
  PropTypes.string,
@@ -120,9 +121,9 @@ Hyperlink.propTypes = {
120
121
  ),
121
122
  /** type of hyperlink */
122
123
  variant: PropTypes.oneOf(['default', 'muted', 'brand']),
123
- /** specify the link style. By default it will be underlined. */
124
+ /** specify the link style. By default, it will be underlined. */
124
125
  isInline: PropTypes.bool,
125
- /** specify if we need to show launch Icon. By default it will be visible. */
126
+ /** specify if we need to show launch Icon. By default, it will be visible. */
126
127
  showLaunchIcon: PropTypes.bool,
127
128
  };
128
129
 
@@ -70,28 +70,35 @@ function Icon({
70
70
  }
71
71
 
72
72
  Icon.propTypes = {
73
- // eslint-disable-next-line max-len
74
- /** An icon component to render. Example import of a Paragon icon component: `import { Check } from '@edx/paragon/dist/icon';` */
73
+ /**
74
+ * An icon component to render.
75
+ * Example import of a Paragon icon component: `import { Check } from '@edx/paragon/icons';`
76
+ */
75
77
  src: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
76
78
  /** HTML element attributes to pass through to the underlying svg element */
77
79
  svgAttrs: PropTypes.shape({
78
80
  'aria-label': PropTypes.string,
79
81
  'aria-labelledby': PropTypes.string,
80
82
  }),
81
- // eslint-disable-next-line max-len
82
- /** the `id` property of the Icon element, by default this value is generated with the `newId` function with the `prefix` of `Icon`. */
83
+ /**
84
+ * the `id` property of the Icon element, by default this value is generated
85
+ * with the `newId` function with the `prefix` of `Icon`.
86
+ */
83
87
  id: PropTypes.string,
84
- // eslint-disable-next-line max-len
85
88
  /** The size of the icon. */
86
89
  size: PropTypes.oneOf(['xs', 'sm', 'md', 'lg']),
87
- // eslint-disable-next-line max-len
88
90
  /** A class name that will define what the Icon looks like. */
89
91
  className: PropTypes.string,
90
- // eslint-disable-next-line max-len
91
- /** a boolean that determines the value of `aria-hidden` attribute on the Icon span, this value is `true` by default. */
92
+ /**
93
+ * a boolean that determines the value of `aria-hidden` attribute on the Icon span,
94
+ * this value is `true` by default.
95
+ */
92
96
  hidden: PropTypes.bool,
93
- // eslint-disable-next-line max-len
94
- /** a string or an element that will be used on a secondary span leveraging the `sr-only` style for screenreader only text, this value is `undefined` by default. This value is recommended for use unless the Icon is being used in a way that is purely decorative or provides no additional context for screen reader users. This field should be thought of the same way an `alt` attribute would be used for `image` tags.
97
+ /**
98
+ * a string or an element that will be used on a secondary span leveraging the `sr-only` style
99
+ * for screenreader only text, this value is `undefined` by default. This value is recommended for use unless
100
+ * the Icon is being used in a way that is purely decorative or provides no additional context for screen
101
+ * reader users. This field should be thought of the same way an `alt` attribute would be used for `image` tags.
95
102
  */
96
103
  screenReaderText: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
97
104
  };
@@ -87,7 +87,7 @@ IconButton.propTypes = {
87
87
  alt: PropTypes.string.isRequired,
88
88
  /** Changes icon styles for dark background */
89
89
  invertColors: PropTypes.bool,
90
- /** Accepts a React fontawesome icon. https://fontawesome.com/how-to-use/on-the-web/using-with/react */
90
+ /** Accepts a React fontawesome icon. */
91
91
  icon: PropTypes.shape({
92
92
  prefix: PropTypes.string,
93
93
  iconName: PropTypes.string,
@@ -84,9 +84,6 @@ SIZES.forEach(size => {
84
84
  Layout.defaultProps[size] = sizeDefaultProps;
85
85
  });
86
86
 
87
- export {
88
- Col,
89
- Row,
90
- };
87
+ export { Col, Row };
91
88
  Layout.Element = LayoutElement;
92
89
  export default Layout;