@openedx/paragon 21.9.0 → 21.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ProductTour/Checkpoint.js +1 -0
- package/dist/ProductTour/Checkpoint.js.map +1 -1
- package/dist/SelectableBox/index.js +9 -5
- package/dist/SelectableBox/index.js.map +1 -1
- package/package.json +1 -1
- package/src/Button/README.md +5 -24
- package/src/DataTable/README.md +1 -1
- package/src/ProductTour/Checkpoint.jsx +1 -0
- package/src/SelectableBox/README.md +103 -71
- package/src/SelectableBox/index.jsx +5 -1
- package/src/SelectableBox/tests/SelectableBox.test.jsx +7 -0
- package/src/Tabs/README.md +54 -0
|
@@ -33,6 +33,7 @@ const Checkpoint = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
33
33
|
// Use the Popper library to translate the Checkpoint to its target's coordinates
|
|
34
34
|
const checkpointPopper = createPopper(targetElement, checkpoint, {
|
|
35
35
|
placement: isMobile ? 'top' : placement,
|
|
36
|
+
strategy: 'fixed',
|
|
36
37
|
modifiers: [{
|
|
37
38
|
name: 'arrow',
|
|
38
39
|
options: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkpoint.js","names":["React","useEffect","useState","useMediaQuery","PropTypes","createPopper","FormattedMessage","breakpoints","CheckpointActionRow","CheckpointBody","CheckpointBreadcrumbs","CheckpointTitle","Checkpoint","forwardRef","_ref","ref","body","index","placement","target","title","totalCheckpoints","props","_objectWithoutProperties","_excluded","checkpointVisible","setCheckpointVisible","isMobile","maxWidth","small","targetElement","document","querySelector","checkpoint","checkpointPopper","modifiers","name","options","padding","offset","tetherOffset","forceUpdate","targetOffset","getBoundingClientRect","top","bottom","global","innerHeight","includes","scrollTo","behavior","button","focus","isLastCheckpoint","isOnlyCheckpoint","createElement","id","className","role","style","visibility","pointerEvents","defaultMessage","value","step","description","currentIndex","_extends","defaultProps","advanceButtonText","dismissButtonText","endButtonText","showDismissButton","undefined","propTypes","node","number","isRequired","onAdvance","func","onDismiss","onEnd","oneOf","string","bool"],"sources":["../../src/ProductTour/Checkpoint.jsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { useMediaQuery } from 'react-responsive';\nimport PropTypes from 'prop-types';\nimport { createPopper } from '@popperjs/core';\nimport { FormattedMessage } from 'react-intl';\n\nimport breakpoints from '../utils/breakpoints';\n\nimport CheckpointActionRow from './CheckpointActionRow';\nimport CheckpointBody from './CheckpointBody';\nimport CheckpointBreadcrumbs from './CheckpointBreadcrumbs';\nimport CheckpointTitle from './CheckpointTitle';\n\nconst Checkpoint = React.forwardRef(({\n body,\n index,\n placement,\n target,\n title,\n totalCheckpoints,\n ...props\n}, ref) => {\n const [checkpointVisible, setCheckpointVisible] = useState(false);\n const isMobile = useMediaQuery({ maxWidth: breakpoints.small.maxWidth });\n\n useEffect(() => {\n const targetElement = document.querySelector(target);\n const checkpoint = document.querySelector('#pgn__checkpoint');\n if (targetElement && checkpoint) {\n // Use the Popper library to translate the Checkpoint to its target's coordinates\n const checkpointPopper = createPopper(targetElement, checkpoint, {\n placement: isMobile ? 'top' : placement,\n modifiers: [\n {\n name: 'arrow',\n options: {\n padding: 25,\n },\n },\n {\n name: 'offset',\n options: {\n offset: [0, 20],\n },\n },\n {\n name: 'preventOverflow',\n options: {\n padding: 20,\n tetherOffset: 35,\n },\n },\n ],\n });\n setCheckpointVisible(true);\n if (checkpointPopper) {\n checkpointPopper.forceUpdate();\n }\n }\n }, [target, isMobile, placement]);\n\n useEffect(() => {\n if (checkpointVisible) {\n // Scroll the Checkpoint into view once its rendered\n const targetElement = document.querySelector(target);\n let targetOffset = targetElement.getBoundingClientRect().top;\n if ((targetOffset < 0) || (targetElement.getBoundingClientRect().bottom > global.innerHeight)) {\n if (placement.includes('top')) {\n if (targetOffset < 0) {\n targetOffset *= -1;\n }\n targetOffset -= 280;\n } else {\n targetOffset -= 80;\n }\n\n global.scrollTo({\n top: targetOffset, behavior: 'smooth',\n });\n }\n\n const button = document.querySelector('.pgn__checkpoint-button_advance');\n button.focus();\n }\n }, [target, checkpointVisible, placement]);\n\n const isLastCheckpoint = index + 1 === totalCheckpoints;\n const isOnlyCheckpoint = totalCheckpoints === 1;\n\n return (\n <div\n id=\"pgn__checkpoint\"\n className=\"pgn__checkpoint\"\n aria-labelledby=\"pgn__checkpoint-title\"\n ref={ref}\n role=\"dialog\"\n style={{ visibility: checkpointVisible ? 'visible' : 'hidden', pointerEvents: checkpointVisible ? 'auto' : 'none' }}\n >\n <span className=\"sr-only\">\n <FormattedMessage\n id=\"pgn.ProductTour.Checkpoint.position-text\"\n defaultMessage=\"Top of step {step}\"\n value={{ step: index + 1 }}\n description=\"Screen-reader message to indicate the user's position in a sequence of checkpoints.\"\n />\n </span>\n {(title || !isOnlyCheckpoint) && (\n <div className=\"pgn__checkpoint-header\">\n <CheckpointTitle>{title}</CheckpointTitle>\n <CheckpointBreadcrumbs currentIndex={index} totalCheckpoints={totalCheckpoints} />\n </div>\n )}\n <CheckpointBody>{body}</CheckpointBody>\n <CheckpointActionRow\n isLastCheckpoint={isLastCheckpoint}\n index={index}\n {...props}\n />\n <div id=\"pgn__checkpoint-arrow\" data-popper-arrow />\n {/* This text is not translated due to Paragon's lack of i18n support */}\n <span className=\"sr-only\">Bottom of step {index + 1}</span>\n </div>\n );\n});\n\nCheckpoint.defaultProps = {\n advanceButtonText: null,\n body: null,\n dismissButtonText: null,\n endButtonText: null,\n placement: 'top',\n title: null,\n showDismissButton: undefined,\n};\n\nCheckpoint.propTypes = {\n /** The text displayed on the button used to advance the tour for the given Checkpoint. */\n advanceButtonText: PropTypes.node,\n /** The text displayed in the body of the Checkpoint */\n body: PropTypes.node,\n /** The text displayed on the button used to dismiss the tour for the given Checkpoint. */\n dismissButtonText: PropTypes.node,\n /** The text displayed on the button used to end the tour for the given Checkpoint. */\n endButtonText: PropTypes.node,\n /** The current index of the given Checkpoint */\n index: PropTypes.number.isRequired,\n /** A function that runs when triggering the `onClick` event of the advance\n * button for the given Checkpoint. */\n onAdvance: PropTypes.func.isRequired,\n /** A function that runs when triggering the `onClick` event of the dismiss\n * button for the given Checkpoint. */\n onDismiss: PropTypes.func.isRequired,\n /** A function that runs when triggering the `onClick` event of the advance\n * button if the given Checkpoint is the only or last Checkpoint in a tour. */\n onEnd: PropTypes.func.isRequired,\n /** A string that dictates the alignment of the Checkpoint around its target. */\n placement: PropTypes.oneOf([\n 'top', 'top-start', 'top-end', 'right-start', 'right', 'right-end',\n 'left-start', 'left', 'left-end', 'bottom', 'bottom-start', 'bottom-end',\n ]),\n /** The CSS selector for the Checkpoint's desired target. */\n target: PropTypes.string.isRequired,\n /** The text displayed in the title of the Checkpoint */\n title: PropTypes.node,\n /** The total number of Checkpoints in a tour */\n totalCheckpoints: PropTypes.number.isRequired,\n /** Enforces visibility of the dismiss button under all circumstances */\n showDismissButton: PropTypes.bool,\n};\n\nexport default Checkpoint;\n"],"mappings":";;;;AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,SAASC,aAAa,QAAQ,kBAAkB;AAChD,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,gBAAgB,QAAQ,YAAY;AAE7C,OAAOC,WAAW,MAAM,sBAAsB;AAE9C,OAAOC,mBAAmB,MAAM,uBAAuB;AACvD,OAAOC,cAAc,MAAM,kBAAkB;AAC7C,OAAOC,qBAAqB,MAAM,yBAAyB;AAC3D,OAAOC,eAAe,MAAM,mBAAmB;AAE/C,MAAMC,UAAU,gBAAGZ,KAAK,CAACa,UAAU,CAAC,CAAAC,IAAA,EAQjCC,GAAG,KAAK;EAAA,IAR0B;MACnCC,IAAI;MACJC,KAAK;MACLC,SAAS;MACTC,MAAM;MACNC,KAAK;MACLC;IAEF,CAAC,GAAAP,IAAA;IADIQ,KAAK,GAAAC,wBAAA,CAAAT,IAAA,EAAAU,SAAA;EAER,MAAM,CAACC,iBAAiB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ACC,UAAU;EAClC;AACF;EACEC,SAAS,EAAE1E,SAAS,CAAC2E,IAAI,CAACF,UAAU;EACpC;AACF;EACEG,SAAS,EAAE5E,SAAS,CAAC2E,IAAI,CAACF,UAAU;EACpC;AACF;EACEI,KAAK,EAAE7E,SAAS,CAAC2E,IAAI,CAACF,UAAU;EAChC;EACA3D,SAAS,EAAEd,SAAS,CAAC8E,KAAK,CAAC,CACzB,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAClE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,CACzE,CAAC;EACF;EACA/D,MAAM,EAAEf,SAAS,CAAC+E,MAAM,CAACN,UAAU;EACnC;EACAzD,KAAK,EAAEhB,SAAS,CAACuE,IAAI;EACrB;EACAtD,gBAAgB,EAAEjB,SAAS,CAACwE,MAAM,CAACC,UAAU;EAC7C;EACAL,iBAAiB,EAAEpE,SAAS,CAACgF;AAC/B,CAAC;AAED,eAAexE,UAAU"}
|
|
1
|
+
{"version":3,"file":"Checkpoint.js","names":["React","useEffect","useState","useMediaQuery","PropTypes","createPopper","FormattedMessage","breakpoints","CheckpointActionRow","CheckpointBody","CheckpointBreadcrumbs","CheckpointTitle","Checkpoint","forwardRef","_ref","ref","body","index","placement","target","title","totalCheckpoints","props","_objectWithoutProperties","_excluded","checkpointVisible","setCheckpointVisible","isMobile","maxWidth","small","targetElement","document","querySelector","checkpoint","checkpointPopper","strategy","modifiers","name","options","padding","offset","tetherOffset","forceUpdate","targetOffset","getBoundingClientRect","top","bottom","global","innerHeight","includes","scrollTo","behavior","button","focus","isLastCheckpoint","isOnlyCheckpoint","createElement","id","className","role","style","visibility","pointerEvents","defaultMessage","value","step","description","currentIndex","_extends","defaultProps","advanceButtonText","dismissButtonText","endButtonText","showDismissButton","undefined","propTypes","node","number","isRequired","onAdvance","func","onDismiss","onEnd","oneOf","string","bool"],"sources":["../../src/ProductTour/Checkpoint.jsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { useMediaQuery } from 'react-responsive';\nimport PropTypes from 'prop-types';\nimport { createPopper } from '@popperjs/core';\nimport { FormattedMessage } from 'react-intl';\n\nimport breakpoints from '../utils/breakpoints';\n\nimport CheckpointActionRow from './CheckpointActionRow';\nimport CheckpointBody from './CheckpointBody';\nimport CheckpointBreadcrumbs from './CheckpointBreadcrumbs';\nimport CheckpointTitle from './CheckpointTitle';\n\nconst Checkpoint = React.forwardRef(({\n body,\n index,\n placement,\n target,\n title,\n totalCheckpoints,\n ...props\n}, ref) => {\n const [checkpointVisible, setCheckpointVisible] = useState(false);\n const isMobile = useMediaQuery({ maxWidth: breakpoints.small.maxWidth });\n\n useEffect(() => {\n const targetElement = document.querySelector(target);\n const checkpoint = document.querySelector('#pgn__checkpoint');\n if (targetElement && checkpoint) {\n // Use the Popper library to translate the Checkpoint to its target's coordinates\n const checkpointPopper = createPopper(targetElement, checkpoint, {\n placement: isMobile ? 'top' : placement,\n strategy: 'fixed',\n modifiers: [\n {\n name: 'arrow',\n options: {\n padding: 25,\n },\n },\n {\n name: 'offset',\n options: {\n offset: [0, 20],\n },\n },\n {\n name: 'preventOverflow',\n options: {\n padding: 20,\n tetherOffset: 35,\n },\n },\n ],\n });\n setCheckpointVisible(true);\n if (checkpointPopper) {\n checkpointPopper.forceUpdate();\n }\n }\n }, [target, isMobile, placement]);\n\n useEffect(() => {\n if (checkpointVisible) {\n // Scroll the Checkpoint into view once its rendered\n const targetElement = document.querySelector(target);\n let targetOffset = targetElement.getBoundingClientRect().top;\n if ((targetOffset < 0) || (targetElement.getBoundingClientRect().bottom > global.innerHeight)) {\n if (placement.includes('top')) {\n if (targetOffset < 0) {\n targetOffset *= -1;\n }\n targetOffset -= 280;\n } else {\n targetOffset -= 80;\n }\n\n global.scrollTo({\n top: targetOffset, behavior: 'smooth',\n });\n }\n\n const button = document.querySelector('.pgn__checkpoint-button_advance');\n button.focus();\n }\n }, [target, checkpointVisible, placement]);\n\n const isLastCheckpoint = index + 1 === totalCheckpoints;\n const isOnlyCheckpoint = totalCheckpoints === 1;\n\n return (\n <div\n id=\"pgn__checkpoint\"\n className=\"pgn__checkpoint\"\n aria-labelledby=\"pgn__checkpoint-title\"\n ref={ref}\n role=\"dialog\"\n style={{ visibility: checkpointVisible ? 'visible' : 'hidden', pointerEvents: checkpointVisible ? 'auto' : 'none' }}\n >\n <span className=\"sr-only\">\n <FormattedMessage\n id=\"pgn.ProductTour.Checkpoint.position-text\"\n defaultMessage=\"Top of step {step}\"\n value={{ step: index + 1 }}\n description=\"Screen-reader message to indicate the user's position in a sequence of checkpoints.\"\n />\n </span>\n {(title || !isOnlyCheckpoint) && (\n <div className=\"pgn__checkpoint-header\">\n <CheckpointTitle>{title}</CheckpointTitle>\n <CheckpointBreadcrumbs currentIndex={index} totalCheckpoints={totalCheckpoints} />\n </div>\n )}\n <CheckpointBody>{body}</CheckpointBody>\n <CheckpointActionRow\n isLastCheckpoint={isLastCheckpoint}\n index={index}\n {...props}\n />\n <div id=\"pgn__checkpoint-arrow\" data-popper-arrow />\n {/* This text is not translated due to Paragon's lack of i18n support */}\n <span className=\"sr-only\">Bottom of step {index + 1}</span>\n </div>\n );\n});\n\nCheckpoint.defaultProps = {\n advanceButtonText: null,\n body: null,\n dismissButtonText: null,\n endButtonText: null,\n placement: 'top',\n title: null,\n showDismissButton: undefined,\n};\n\nCheckpoint.propTypes = {\n /** The text displayed on the button used to advance the tour for the given Checkpoint. */\n advanceButtonText: PropTypes.node,\n /** The text displayed in the body of the Checkpoint */\n body: PropTypes.node,\n /** The text displayed on the button used to dismiss the tour for the given Checkpoint. */\n dismissButtonText: PropTypes.node,\n /** The text displayed on the button used to end the tour for the given Checkpoint. */\n endButtonText: PropTypes.node,\n /** The current index of the given Checkpoint */\n index: PropTypes.number.isRequired,\n /** A function that runs when triggering the `onClick` event of the advance\n * button for the given Checkpoint. */\n onAdvance: PropTypes.func.isRequired,\n /** A function that runs when triggering the `onClick` event of the dismiss\n * button for the given Checkpoint. */\n onDismiss: PropTypes.func.isRequired,\n /** A function that runs when triggering the `onClick` event of the advance\n * button if the given Checkpoint is the only or last Checkpoint in a tour. */\n onEnd: PropTypes.func.isRequired,\n /** A string that dictates the alignment of the Checkpoint around its target. */\n placement: PropTypes.oneOf([\n 'top', 'top-start', 'top-end', 'right-start', 'right', 'right-end',\n 'left-start', 'left', 'left-end', 'bottom', 'bottom-start', 'bottom-end',\n ]),\n /** The CSS selector for the Checkpoint's desired target. */\n target: PropTypes.string.isRequired,\n /** The text displayed in the title of the Checkpoint */\n title: PropTypes.node,\n /** The total number of Checkpoints in a tour */\n totalCheckpoints: PropTypes.number.isRequired,\n /** Enforces visibility of the dismiss button under all circumstances */\n showDismissButton: PropTypes.bool,\n};\n\nexport default Checkpoint;\n"],"mappings":";;;;AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,SAASC,aAAa,QAAQ,kBAAkB;AAChD,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,gBAAgB,QAAQ,YAAY;AAE7C,OAAOC,WAAW,MAAM,sBAAsB;AAE9C,OAAOC,mBAAmB,MAAM,uBAAuB;AACvD,OAAOC,cAAc,MAAM,kBAAkB;AAC7C,OAAOC,qBAAqB,MAAM,yBAAyB;AAC3D,OAAOC,eAAe,MAAM,mBAAmB;AAE/C,MAAMC,UAAU,gBAAGZ,KAAK,CAACa,UAAU,CAAC,CAAAC,IAAA,EAQjCC,GAAG,KAAK;EAAA,IAR0B;MACnCC,IAAI;MACJC,KAAK;MACLC,SAAS;MACTC,MAAM;MACNC,KAAK;MACLC;IAEF,CAAC,GAAAP,IAAA;IADIQ,KAAK,GAAAC,wBAAA,CAAAT,IAAA,EAAAU,SAAA;EAER,MAAM,CAACC,iBAAiB,EAAEC,oBAAoB,CAAC,GAAGxB,QAAQ,CAAC,KAAK,CAAC;EACjE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,SAAS,CAAC4E,IAAI,CAACF,UAAU;EACpC;AACF;EACEG,SAAS,EAAE7E,SAAS,CAAC4E,IAAI,CAACF,UAAU;EACpC;AACF;EACEI,KAAK,EAAE9E,SAAS,CAAC4E,IAAI,CAACF,UAAU;EAChC;EACA5D,SAAS,EAAEd,SAAS,CAAC+E,KAAK,CAAC,CACzB,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAClE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,CACzE,CAAC;EACF;EACAhE,MAAM,EAAEf,SAAS,CAACgF,MAAM,CAACN,UAAU;EACnC;EACA1D,KAAK,EAAEhB,SAAS,CAACwE,IAAI;EACrB;EACAvD,gBAAgB,EAAEjB,SAAS,CAACyE,MAAM,CAACC,UAAU;EAC7C;EACAL,iBAAiB,EAAErE,SAAS,CAACiF;AAC/B,CAAC;AAED,eAAezE,UAAU"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["type", "value", "checked", "children", "isIndeterminate", "isInvalid", "onClick", "onFocus", "inputHidden", "className"];
|
|
1
|
+
const _excluded = ["type", "value", "checked", "children", "isIndeterminate", "isInvalid", "onClick", "onFocus", "inputHidden", "className", "showActiveBoxState"];
|
|
2
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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 _extends.apply(this, arguments); }
|
|
3
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
@@ -26,7 +26,8 @@ const SelectableBox = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
26
26
|
onClick,
|
|
27
27
|
onFocus,
|
|
28
28
|
inputHidden,
|
|
29
|
-
className
|
|
29
|
+
className,
|
|
30
|
+
showActiveBoxState
|
|
30
31
|
} = _ref,
|
|
31
32
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
32
33
|
const inputType = getInputType('SelectableBox', type);
|
|
@@ -68,7 +69,7 @@ const SelectableBox = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
68
69
|
onClick: () => inputRef.current.click(),
|
|
69
70
|
onFocus: onFocus,
|
|
70
71
|
className: classNames('pgn__selectable_box', className, {
|
|
71
|
-
'pgn__selectable_box-active': isChecked() || checked,
|
|
72
|
+
'pgn__selectable_box-active': !inputHidden && !showActiveBoxState ? false : isChecked() || checked,
|
|
72
73
|
'pgn__selectable_box-invalid': isInvalid
|
|
73
74
|
}),
|
|
74
75
|
tabIndex: 0,
|
|
@@ -95,7 +96,9 @@ SelectableBox.propTypes = {
|
|
|
95
96
|
/** Adds errors styles to the `SelectableBox`. */
|
|
96
97
|
isInvalid: PropTypes.bool,
|
|
97
98
|
/** A class that is appended to the base element. */
|
|
98
|
-
className: PropTypes.string
|
|
99
|
+
className: PropTypes.string,
|
|
100
|
+
/** Controls the visibility of the active state for the `SelectableBox`. */
|
|
101
|
+
showActiveBoxState: PropTypes.bool
|
|
99
102
|
};
|
|
100
103
|
SelectableBox.defaultProps = {
|
|
101
104
|
value: undefined,
|
|
@@ -106,7 +109,8 @@ SelectableBox.defaultProps = {
|
|
|
106
109
|
inputHidden: true,
|
|
107
110
|
isIndeterminate: false,
|
|
108
111
|
isInvalid: false,
|
|
109
|
-
className: undefined
|
|
112
|
+
className: undefined,
|
|
113
|
+
showActiveBoxState: true
|
|
110
114
|
};
|
|
111
115
|
SelectableBox.Set = SelectableBoxSet;
|
|
112
116
|
export default SelectableBox;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useRef","useEffect","PropTypes","classNames","SelectableBoxSet","useCheckboxSetContext","useRadioSetContext","getInputType","INPUT_TYPES","SelectableBox","forwardRef","_ref","ref","type","value","checked","children","isIndeterminate","isInvalid","onClick","onFocus","inputHidden","className","props","_objectWithoutProperties","_excluded","inputType","radioValue","checkboxValues","isChecked","includes","inputRef","input","createElement","_objectSpread","hidden","tabIndex","onChange","current","onclick","_extends","role","onKeyPress","click","propTypes","node","isRequired","oneOfType","string","number","bool","oneOf","func","defaultProps","undefined","Set"],"sources":["../../src/SelectableBox/index.jsx"],"sourcesContent":["import React, { useRef, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport SelectableBoxSet from './SelectableBoxSet';\nimport { useCheckboxSetContext } from '../Form/FormCheckboxSetContext';\nimport { useRadioSetContext } from '../Form/FormRadioSetContext';\nimport { getInputType } from './utils';\n\nconst INPUT_TYPES = [\n 'radio',\n 'checkbox',\n];\n\nconst SelectableBox = React.forwardRef(({\n type,\n value,\n checked,\n children,\n isIndeterminate,\n isInvalid,\n onClick,\n onFocus,\n inputHidden,\n className,\n ...props\n}, ref) => {\n const inputType = getInputType('SelectableBox', type);\n const { value: radioValue } = useRadioSetContext();\n const { value: checkboxValues = [] } = useCheckboxSetContext();\n\n const isChecked = () => {\n switch (type) {\n case 'radio':\n return radioValue === value;\n case 'checkbox':\n return checkboxValues.includes(value);\n default:\n return radioValue === value;\n }\n };\n\n const inputRef = useRef(null);\n const input = React.createElement(inputType, {\n value,\n checked,\n hidden: inputHidden,\n ref: inputRef,\n tabIndex: -1,\n onChange: () => {},\n ...(type === 'checkbox' ? { ...props, isIndeterminate } : { ...props }),\n }, null);\n\n useEffect(() => {\n if (onClick && inputRef.current) {\n inputRef.current.onclick = () => onClick(inputRef.current);\n }\n }, [onClick]);\n\n return (\n <div\n role=\"button\"\n onKeyPress={() => inputRef.current.click()}\n onClick={() => inputRef.current.click()}\n onFocus={onFocus}\n className={classNames('pgn__selectable_box', className, {\n 'pgn__selectable_box-active': isChecked() || checked,\n 'pgn__selectable_box-invalid': isInvalid,\n })}\n tabIndex={0}\n ref={ref}\n {...props}\n >\n {input}\n {children}\n </div>\n );\n});\n\nSelectableBox.propTypes = {\n /** Content of the `SelectableBox`. */\n children: PropTypes.node.isRequired,\n /** A value that is passed to the input tag. */\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n /** Controls whether `SelectableBox` is checked. */\n checked: PropTypes.bool,\n /** Indicates the input type: checkbox or radio. */\n type: PropTypes.oneOf(INPUT_TYPES),\n /** Function that is called when the `SelectableBox` is clicked. */\n onClick: PropTypes.func,\n /** Function that is called when the `SelectableBox` is focused. */\n onFocus: PropTypes.func,\n /** Controls display of the input (checkbox or radio button) on the `SelectableBox`. */\n inputHidden: PropTypes.bool,\n /** Indicates a state for the 'checkbox' `type` when `SelectableBox` is neither checked nor unchecked. */\n isIndeterminate: PropTypes.bool,\n /** Adds errors styles to the `SelectableBox`. */\n isInvalid: PropTypes.bool,\n /** A class that is appended to the base element. */\n className: PropTypes.string,\n};\n\nSelectableBox.defaultProps = {\n value: undefined,\n checked: false,\n type: 'radio',\n onClick: () => {},\n onFocus: () => {},\n inputHidden: true,\n isIndeterminate: false,\n isInvalid: false,\n className: undefined,\n};\n\nSelectableBox.Set = SelectableBoxSet;\nexport default SelectableBox;\n"],"mappings":";;;;;;;;;AAAA,OAAOA,KAAK,IAAIC,MAAM,EAAEC,SAAS,QAAQ,OAAO;AAChD,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,SAASC,qBAAqB,QAAQ,gCAAgC;AACtE,SAASC,kBAAkB,QAAQ,6BAA6B;AAChE,SAASC,YAAY,QAAQ,SAAS;AAEtC,MAAMC,WAAW,GAAG,CAClB,OAAO,EACP,UAAU,CACX;AAED,MAAMC,aAAa,gBAAGV,KAAK,CAACW,UAAU,CAAC,CAAAC,IAAA,
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useRef","useEffect","PropTypes","classNames","SelectableBoxSet","useCheckboxSetContext","useRadioSetContext","getInputType","INPUT_TYPES","SelectableBox","forwardRef","_ref","ref","type","value","checked","children","isIndeterminate","isInvalid","onClick","onFocus","inputHidden","className","showActiveBoxState","props","_objectWithoutProperties","_excluded","inputType","radioValue","checkboxValues","isChecked","includes","inputRef","input","createElement","_objectSpread","hidden","tabIndex","onChange","current","onclick","_extends","role","onKeyPress","click","propTypes","node","isRequired","oneOfType","string","number","bool","oneOf","func","defaultProps","undefined","Set"],"sources":["../../src/SelectableBox/index.jsx"],"sourcesContent":["import React, { useRef, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport SelectableBoxSet from './SelectableBoxSet';\nimport { useCheckboxSetContext } from '../Form/FormCheckboxSetContext';\nimport { useRadioSetContext } from '../Form/FormRadioSetContext';\nimport { getInputType } from './utils';\n\nconst INPUT_TYPES = [\n 'radio',\n 'checkbox',\n];\n\nconst SelectableBox = React.forwardRef(({\n type,\n value,\n checked,\n children,\n isIndeterminate,\n isInvalid,\n onClick,\n onFocus,\n inputHidden,\n className,\n showActiveBoxState,\n ...props\n}, ref) => {\n const inputType = getInputType('SelectableBox', type);\n const { value: radioValue } = useRadioSetContext();\n const { value: checkboxValues = [] } = useCheckboxSetContext();\n\n const isChecked = () => {\n switch (type) {\n case 'radio':\n return radioValue === value;\n case 'checkbox':\n return checkboxValues.includes(value);\n default:\n return radioValue === value;\n }\n };\n\n const inputRef = useRef(null);\n const input = React.createElement(inputType, {\n value,\n checked,\n hidden: inputHidden,\n ref: inputRef,\n tabIndex: -1,\n onChange: () => {},\n ...(type === 'checkbox' ? { ...props, isIndeterminate } : { ...props }),\n }, null);\n\n useEffect(() => {\n if (onClick && inputRef.current) {\n inputRef.current.onclick = () => onClick(inputRef.current);\n }\n }, [onClick]);\n\n return (\n <div\n role=\"button\"\n onKeyPress={() => inputRef.current.click()}\n onClick={() => inputRef.current.click()}\n onFocus={onFocus}\n className={classNames('pgn__selectable_box', className, {\n 'pgn__selectable_box-active': (!inputHidden && !showActiveBoxState) ? false : isChecked() || checked,\n 'pgn__selectable_box-invalid': isInvalid,\n })}\n tabIndex={0}\n ref={ref}\n {...props}\n >\n {input}\n {children}\n </div>\n );\n});\n\nSelectableBox.propTypes = {\n /** Content of the `SelectableBox`. */\n children: PropTypes.node.isRequired,\n /** A value that is passed to the input tag. */\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n /** Controls whether `SelectableBox` is checked. */\n checked: PropTypes.bool,\n /** Indicates the input type: checkbox or radio. */\n type: PropTypes.oneOf(INPUT_TYPES),\n /** Function that is called when the `SelectableBox` is clicked. */\n onClick: PropTypes.func,\n /** Function that is called when the `SelectableBox` is focused. */\n onFocus: PropTypes.func,\n /** Controls display of the input (checkbox or radio button) on the `SelectableBox`. */\n inputHidden: PropTypes.bool,\n /** Indicates a state for the 'checkbox' `type` when `SelectableBox` is neither checked nor unchecked. */\n isIndeterminate: PropTypes.bool,\n /** Adds errors styles to the `SelectableBox`. */\n isInvalid: PropTypes.bool,\n /** A class that is appended to the base element. */\n className: PropTypes.string,\n /** Controls the visibility of the active state for the `SelectableBox`. */\n showActiveBoxState: PropTypes.bool,\n};\n\nSelectableBox.defaultProps = {\n value: undefined,\n checked: false,\n type: 'radio',\n onClick: () => {},\n onFocus: () => {},\n inputHidden: true,\n isIndeterminate: false,\n isInvalid: false,\n className: undefined,\n showActiveBoxState: true,\n};\n\nSelectableBox.Set = SelectableBoxSet;\nexport default SelectableBox;\n"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SAAS,CAAC+C,MAAM,EAAE/C,SAAS,CAACgD,MAAM,CAAC,CAAC;EAChE;EACAnC,OAAO,EAAEb,SAAS,CAACiD,IAAI;EACvB;EACAtC,IAAI,EAAEX,SAAS,CAACkD,KAAK,CAAC5C,WAAW,CAAC;EAClC;EACAW,OAAO,EAAEjB,SAAS,CAACmD,IAAI;EACvB;EACAjC,OAAO,EAAElB,SAAS,CAACmD,IAAI;EACvB;EACAhC,WAAW,EAAEnB,SAAS,CAACiD,IAAI;EAC3B;EACAlC,eAAe,EAAEf,SAAS,CAACiD,IAAI;EAC/B;EACAjC,SAAS,EAAEhB,SAAS,CAACiD,IAAI;EACzB;EACA7B,SAAS,EAAEpB,SAAS,CAAC+C,MAAM;EAC3B;EACA1B,kBAAkB,EAAErB,SAAS,CAACiD;AAChC,CAAC;AAED1C,aAAa,CAAC6C,YAAY,GAAG;EAC3BxC,KAAK,EAAEyC,SAAS;EAChBxC,OAAO,EAAE,KAAK;EACdF,IAAI,EAAE,OAAO;EACbM,OAAO,EAAEA,CAAA,KAAM,CAAC,CAAC;EACjBC,OAAO,EAAEA,CAAA,KAAM,CAAC,CAAC;EACjBC,WAAW,EAAE,IAAI;EACjBJ,eAAe,EAAE,KAAK;EACtBC,SAAS,EAAE,KAAK;EAChBI,SAAS,EAAEiC,SAAS;EACpBhC,kBAAkB,EAAE;AACtB,CAAC;AAEDd,aAAa,CAAC+C,GAAG,GAAGpD,gBAAgB;AACpC,eAAeK,aAAa"}
|
package/package.json
CHANGED
package/src/Button/README.md
CHANGED
|
@@ -200,30 +200,11 @@ For link to be `disabled`, it must have href defined with some value.
|
|
|
200
200
|
)}
|
|
201
201
|
```
|
|
202
202
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
<Spinner animation="border" />
|
|
209
|
-
</Button>
|
|
210
|
-
<Button variant="brand" className="mb-2 mr-2 mb-sm-0" aria-label="Loading some stuff">
|
|
211
|
-
<Spinner animation="border" />
|
|
212
|
-
</Button>
|
|
213
|
-
<Button variant="outline-primary" className="mb-2 mr-2 mb-sm-0" aria-label="Loading some stuff">
|
|
214
|
-
<Spinner animation="border" />
|
|
215
|
-
</Button>
|
|
216
|
-
<Button variant="outline-brand" className="mb-2 mr-2 mb-sm-0" aria-label="Loading some stuff">
|
|
217
|
-
<Spinner animation="border" />
|
|
218
|
-
</Button>
|
|
219
|
-
<Button variant="inverse-primary" className="mb-2 mr-2 mb-sm-0" aria-label="Loading some stuff">
|
|
220
|
-
<Spinner animation="border" />
|
|
221
|
-
</Button>
|
|
222
|
-
<Button variant="inverse-brand" className="mb-2 mr-2 mb-sm-0" aria-label="Loading some stuff">
|
|
223
|
-
<Spinner animation="border" />
|
|
224
|
-
</Button>
|
|
225
|
-
</>
|
|
226
|
-
```
|
|
203
|
+
## Stateful buttons
|
|
204
|
+
To implement loading state using a `Button` component, the [StatefulButton](https://paragon-openedx.netlify.app/components/statefulbutton/) component
|
|
205
|
+
is available for use. <br/>
|
|
206
|
+
This specialized component is designed to seamlessly manage and display boot states, providing a more efficient and
|
|
207
|
+
user-friendly experience.
|
|
227
208
|
|
|
228
209
|
***
|
|
229
210
|
|
package/src/DataTable/README.md
CHANGED
|
@@ -30,6 +30,7 @@ const Checkpoint = React.forwardRef(({
|
|
|
30
30
|
// Use the Popper library to translate the Checkpoint to its target's coordinates
|
|
31
31
|
const checkpointPopper = createPopper(targetElement, checkpoint, {
|
|
32
32
|
placement: isMobile ? 'top' : placement,
|
|
33
|
+
strategy: 'fixed',
|
|
33
34
|
modifiers: [
|
|
34
35
|
{
|
|
35
36
|
name: 'arrow',
|
|
@@ -6,9 +6,9 @@ components:
|
|
|
6
6
|
- SelectableBoxSet
|
|
7
7
|
categories:
|
|
8
8
|
- Forms
|
|
9
|
-
status: '
|
|
9
|
+
status: 'Stable'
|
|
10
10
|
designStatus: 'Done'
|
|
11
|
-
devStatus: '
|
|
11
|
+
devStatus: 'Done'
|
|
12
12
|
notes: |
|
|
13
13
|
---
|
|
14
14
|
|
|
@@ -26,7 +26,7 @@ As ``Checkbox``
|
|
|
26
26
|
const allCheeseOptions = ['swiss', 'cheddar', 'pepperjack'];
|
|
27
27
|
const [checkedCheeses, { add, remove, set, clear }] = useCheckboxSetValues(['swiss']);
|
|
28
28
|
|
|
29
|
-
const handleChange = e => {
|
|
29
|
+
const handleChange = (e) => {
|
|
30
30
|
e.target.checked ? add(e.target.value) : remove(e.target.value);
|
|
31
31
|
};
|
|
32
32
|
|
|
@@ -34,35 +34,32 @@ As ``Checkbox``
|
|
|
34
34
|
const isExtraSmall = useMediaQuery({ maxWidth: breakpoints.extraSmall.maxWidth });
|
|
35
35
|
|
|
36
36
|
return (
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
<SelectableBox.Set
|
|
38
|
+
className="bg-light-200 p-3"
|
|
39
|
+
value={checkedCheeses}
|
|
40
|
+
type={type}
|
|
41
|
+
onChange={handleChange}
|
|
42
|
+
name="cheeses"
|
|
43
|
+
columns={isExtraSmall ? 1 : 2}
|
|
44
|
+
ariaLabel="cheese selection"
|
|
45
|
+
>
|
|
46
|
+
<SelectableBox value="swiss" type={type} aria-label="swiss checkbox">
|
|
47
|
+
<h3>It is my first SelectableBox</h3>
|
|
48
|
+
<p>Swiss</p>
|
|
49
|
+
</SelectableBox>
|
|
50
|
+
<SelectableBox value="cheddar" inputHidden={false} type={type} aria-label="cheddar checkbox">
|
|
51
|
+
<h3>Cheddar</h3>
|
|
52
|
+
</SelectableBox>
|
|
53
|
+
<SelectableBox
|
|
54
|
+
value="pepperjack"
|
|
55
|
+
inputHidden={false}
|
|
40
56
|
type={type}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
columns={isExtraSmall ? 1 : 2}
|
|
44
|
-
ariaLabel="cheese selection"
|
|
57
|
+
isInvalid={isInvalid()}
|
|
58
|
+
aria-label="pepperjack checkbox"
|
|
45
59
|
>
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
<p>Swiss</p>
|
|
50
|
-
</div>
|
|
51
|
-
</SelectableBox>
|
|
52
|
-
<SelectableBox value="cheddar" inputHidden={false} type={type} aria-label="cheddar checkbox">
|
|
53
|
-
Cheddar
|
|
54
|
-
</SelectableBox>
|
|
55
|
-
<SelectableBox
|
|
56
|
-
value="pepperjack"
|
|
57
|
-
inputHidden={false}
|
|
58
|
-
type={type}
|
|
59
|
-
isInvalid={isInvalid()}
|
|
60
|
-
aria-label="pepperjack checkbox"
|
|
61
|
-
>
|
|
62
|
-
<h3>Pepperjack</h3>
|
|
63
|
-
</SelectableBox>
|
|
64
|
-
</SelectableBox.Set>
|
|
65
|
-
</div>
|
|
60
|
+
<h3>Pepperjack</h3>
|
|
61
|
+
</SelectableBox>
|
|
62
|
+
</SelectableBox.Set>
|
|
66
63
|
);
|
|
67
64
|
}
|
|
68
65
|
```
|
|
@@ -71,31 +68,27 @@ As ``Checkbox``
|
|
|
71
68
|
|
|
72
69
|
```jsx live
|
|
73
70
|
() => {
|
|
74
|
-
const type = 'radio';
|
|
75
71
|
const [value, setValue] = useState('green');
|
|
76
|
-
const handleChange = e => setValue(e.target.value);
|
|
72
|
+
const handleChange = (e) => setValue(e.target.value);
|
|
77
73
|
const isExtraSmall = useMediaQuery({ maxWidth: breakpoints.extraSmall.maxWidth });
|
|
78
74
|
|
|
79
75
|
return (
|
|
80
76
|
<SelectableBox.Set
|
|
81
|
-
type={type}
|
|
82
77
|
value={value}
|
|
83
78
|
onChange={handleChange}
|
|
84
79
|
name="colors"
|
|
85
80
|
columns={isExtraSmall ? 1 : 3}
|
|
86
81
|
ariaLabel="color selection"
|
|
87
82
|
>
|
|
88
|
-
<SelectableBox value="red"
|
|
89
|
-
<
|
|
90
|
-
|
|
91
|
-
<p>Select me</p>
|
|
92
|
-
</div>
|
|
83
|
+
<SelectableBox value="red" aria-label="red checkbox">
|
|
84
|
+
<h3>It is Red color</h3>
|
|
85
|
+
<p>Select me</p>
|
|
93
86
|
</SelectableBox>
|
|
94
|
-
<SelectableBox value="green" inputHidden={false}
|
|
87
|
+
<SelectableBox value="green" inputHidden={false} aria-label="green radio-button">
|
|
95
88
|
<h3>Green</h3>
|
|
96
89
|
<p>Leaves and grass</p>
|
|
97
90
|
</SelectableBox>
|
|
98
|
-
<SelectableBox value="blue" inputHidden={false}
|
|
91
|
+
<SelectableBox value="blue" inputHidden={false} aria-label="blue radio-button">
|
|
99
92
|
<h3>Blue</h3>
|
|
100
93
|
<p>The sky</p>
|
|
101
94
|
</SelectableBox>
|
|
@@ -103,6 +96,7 @@ As ``Checkbox``
|
|
|
103
96
|
);
|
|
104
97
|
}
|
|
105
98
|
```
|
|
99
|
+
|
|
106
100
|
## As Checkbox
|
|
107
101
|
As ``Checkbox`` with ``isIndeterminate``
|
|
108
102
|
|
|
@@ -117,7 +111,7 @@ As ``Checkbox`` with ``isIndeterminate``
|
|
|
117
111
|
const isIndeterminate = someChecked && !allChecked;
|
|
118
112
|
const isExtraSmall = useMediaQuery({ maxWidth: breakpoints.small.maxWidth });
|
|
119
113
|
|
|
120
|
-
const handleChange = e => {
|
|
114
|
+
const handleChange = (e) => {
|
|
121
115
|
e.target.checked ? add(e.target.value) : remove(e.target.value);
|
|
122
116
|
};
|
|
123
117
|
|
|
@@ -127,18 +121,17 @@ As ``Checkbox`` with ``isIndeterminate``
|
|
|
127
121
|
|
|
128
122
|
return (
|
|
129
123
|
<>
|
|
130
|
-
<
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
</div>
|
|
124
|
+
<SelectableBox
|
|
125
|
+
className="mb-3"
|
|
126
|
+
checked={allChecked}
|
|
127
|
+
isIndeterminate={isIndeterminate}
|
|
128
|
+
onClick={handleCheckAllChange}
|
|
129
|
+
inputHidden={false}
|
|
130
|
+
type={type}
|
|
131
|
+
aria-label="all options checkbox"
|
|
132
|
+
>
|
|
133
|
+
All the cheese
|
|
134
|
+
</SelectableBox>
|
|
142
135
|
<SelectableBox.Set
|
|
143
136
|
value={checkedCheeses}
|
|
144
137
|
type={type}
|
|
@@ -148,13 +141,11 @@ As ``Checkbox`` with ``isIndeterminate``
|
|
|
148
141
|
ariaLabel="cheese selection"
|
|
149
142
|
>
|
|
150
143
|
<SelectableBox value="swiss" type={type} aria-label="swiss checkbox">
|
|
151
|
-
<
|
|
152
|
-
|
|
153
|
-
<p>Swiss</p>
|
|
154
|
-
</div>
|
|
144
|
+
<h3>It is my first SelectableBox</h3>
|
|
145
|
+
<p>Swiss</p>
|
|
155
146
|
</SelectableBox>
|
|
156
147
|
<SelectableBox value="cheddar" inputHidden={false} type={type} aria-label="cheddar checkbox">
|
|
157
|
-
Cheddar
|
|
148
|
+
<h3>Cheddar</h3>
|
|
158
149
|
</SelectableBox>
|
|
159
150
|
<SelectableBox value="pepperjack" inputHidden={false} type={type} aria-label="pepperjack checkbox">
|
|
160
151
|
<h3>Pepperjack</h3>
|
|
@@ -173,16 +164,16 @@ As ``Checkbox`` with ``ariaLabelledby``
|
|
|
173
164
|
const allCheeseOptions = ['swiss', 'cheddar', 'pepperjack'];
|
|
174
165
|
const [checkedCheeses, { add, remove, set, clear }] = useCheckboxSetValues(['swiss']);
|
|
175
166
|
|
|
176
|
-
const handleChange = e => {
|
|
167
|
+
const handleChange = (e) => {
|
|
177
168
|
e.target.checked ? add(e.target.value) : remove(e.target.value);
|
|
178
169
|
};
|
|
179
170
|
|
|
180
171
|
const isExtraSmall = useMediaQuery({ maxWidth: breakpoints.extraSmall.maxWidth });
|
|
181
172
|
|
|
182
173
|
return (
|
|
183
|
-
<
|
|
174
|
+
<Stack className="bg-light-200 p-3">
|
|
184
175
|
<h3 id="cheese selection" className="mb-4">
|
|
185
|
-
Select your favorite cheese
|
|
176
|
+
Select your favorite cheese:
|
|
186
177
|
</h3>
|
|
187
178
|
<SelectableBox.Set
|
|
188
179
|
value={checkedCheeses}
|
|
@@ -193,22 +184,63 @@ As ``Checkbox`` with ``ariaLabelledby``
|
|
|
193
184
|
ariaLabelledby="cheese selection"
|
|
194
185
|
>
|
|
195
186
|
<SelectableBox value="swiss" inputHidden={false} type={type} aria-label="swiss checkbox">
|
|
196
|
-
<h3>
|
|
197
|
-
Swiss
|
|
198
|
-
</h3>
|
|
187
|
+
<h3>Swiss</h3>
|
|
199
188
|
</SelectableBox>
|
|
200
189
|
<SelectableBox value="cheddar" inputHidden={false} type={type} aria-label="cheddar checkbox">
|
|
201
|
-
<h3>
|
|
202
|
-
Cheddar
|
|
203
|
-
</h3>
|
|
190
|
+
<h3>Cheddar</h3>
|
|
204
191
|
</SelectableBox>
|
|
205
192
|
<SelectableBox value="pepperjack" inputHidden={false} type={type} aria-label="pepperjack checkbox">
|
|
206
|
-
<h3>
|
|
207
|
-
Pepperjack
|
|
208
|
-
</h3>
|
|
193
|
+
<h3>Pepperjack</h3>
|
|
209
194
|
</SelectableBox>
|
|
210
195
|
</SelectableBox.Set>
|
|
211
|
-
</
|
|
196
|
+
</Stack>
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Without active outline
|
|
202
|
+
The `showActiveBoxState` property only affects `SelectableBox` that have `inputHidden` set to `false`.
|
|
203
|
+
If a component has no input, the border is always rendered in an active state.
|
|
204
|
+
|
|
205
|
+
```jsx live
|
|
206
|
+
() => {
|
|
207
|
+
const [value, setValue] = useState('apples');
|
|
208
|
+
const handleChange = (e) => setValue(e.target.value);
|
|
209
|
+
const isExtraSmall = useMediaQuery({ maxWidth: breakpoints.extraSmall.maxWidth });
|
|
210
|
+
|
|
211
|
+
return (
|
|
212
|
+
<SelectableBox.Set
|
|
213
|
+
value={value}
|
|
214
|
+
onChange={handleChange}
|
|
215
|
+
name="fruits"
|
|
216
|
+
columns={isExtraSmall ? 1 : 3}
|
|
217
|
+
ariaLabel="fruits selection"
|
|
218
|
+
>
|
|
219
|
+
<SelectableBox
|
|
220
|
+
value="apples"
|
|
221
|
+
inputHidden={false}
|
|
222
|
+
showActiveBoxState={false}
|
|
223
|
+
aria-label="apple radio-button"
|
|
224
|
+
>
|
|
225
|
+
<h3>Apples</h3>
|
|
226
|
+
</SelectableBox>
|
|
227
|
+
<SelectableBox
|
|
228
|
+
value="oranges"
|
|
229
|
+
inputHidden={false}
|
|
230
|
+
showActiveBoxState={false}
|
|
231
|
+
aria-label="orange radio-button"
|
|
232
|
+
>
|
|
233
|
+
<h3>Oranges</h3>
|
|
234
|
+
</SelectableBox>
|
|
235
|
+
<SelectableBox
|
|
236
|
+
value="bananas"
|
|
237
|
+
inputHidden={false}
|
|
238
|
+
showActiveBoxState={false}
|
|
239
|
+
aria-label="banana radio-button"
|
|
240
|
+
>
|
|
241
|
+
<h3>Bananas</h3>
|
|
242
|
+
</SelectableBox>
|
|
243
|
+
</SelectableBox.Set>
|
|
212
244
|
);
|
|
213
245
|
}
|
|
214
246
|
```
|
|
@@ -22,6 +22,7 @@ const SelectableBox = React.forwardRef(({
|
|
|
22
22
|
onFocus,
|
|
23
23
|
inputHidden,
|
|
24
24
|
className,
|
|
25
|
+
showActiveBoxState,
|
|
25
26
|
...props
|
|
26
27
|
}, ref) => {
|
|
27
28
|
const inputType = getInputType('SelectableBox', type);
|
|
@@ -63,7 +64,7 @@ const SelectableBox = React.forwardRef(({
|
|
|
63
64
|
onClick={() => inputRef.current.click()}
|
|
64
65
|
onFocus={onFocus}
|
|
65
66
|
className={classNames('pgn__selectable_box', className, {
|
|
66
|
-
'pgn__selectable_box-active': isChecked() || checked,
|
|
67
|
+
'pgn__selectable_box-active': (!inputHidden && !showActiveBoxState) ? false : isChecked() || checked,
|
|
67
68
|
'pgn__selectable_box-invalid': isInvalid,
|
|
68
69
|
})}
|
|
69
70
|
tabIndex={0}
|
|
@@ -97,6 +98,8 @@ SelectableBox.propTypes = {
|
|
|
97
98
|
isInvalid: PropTypes.bool,
|
|
98
99
|
/** A class that is appended to the base element. */
|
|
99
100
|
className: PropTypes.string,
|
|
101
|
+
/** Controls the visibility of the active state for the `SelectableBox`. */
|
|
102
|
+
showActiveBoxState: PropTypes.bool,
|
|
100
103
|
};
|
|
101
104
|
|
|
102
105
|
SelectableBox.defaultProps = {
|
|
@@ -109,6 +112,7 @@ SelectableBox.defaultProps = {
|
|
|
109
112
|
isIndeterminate: false,
|
|
110
113
|
isInvalid: false,
|
|
111
114
|
className: undefined,
|
|
115
|
+
showActiveBoxState: true,
|
|
112
116
|
};
|
|
113
117
|
|
|
114
118
|
SelectableBox.Set = SelectableBoxSet;
|
|
@@ -100,6 +100,13 @@ describe('<SelectableBox />', () => {
|
|
|
100
100
|
rerender(<SelectableCheckbox inputHidden={false} />);
|
|
101
101
|
expect(inputElement.getAttribute('hidden')).toBeNull();
|
|
102
102
|
});
|
|
103
|
+
it('renders with active state and updates to inactive when showActiveBoxState is false', async () => {
|
|
104
|
+
const { rerender } = render(<SelectableCheckbox inputHidden={false} checked />);
|
|
105
|
+
const selectableBox = screen.getByRole('button');
|
|
106
|
+
expect(selectableBox.classList.contains('pgn__selectable_box-active')).toEqual(true);
|
|
107
|
+
rerender(<SelectableCheckbox inputHidden={false} showActiveBoxState={false} checked />);
|
|
108
|
+
expect(selectableBox.classList.contains('pgn__selectable_box-active')).toEqual(false);
|
|
109
|
+
});
|
|
103
110
|
});
|
|
104
111
|
describe('correct interactions', () => {
|
|
105
112
|
it('correct checkbox state change when checked is changed', () => {
|
package/src/Tabs/README.md
CHANGED
|
@@ -226,6 +226,60 @@ notes: |
|
|
|
226
226
|
</Tabs>
|
|
227
227
|
```
|
|
228
228
|
|
|
229
|
+
## Conditional rendering
|
|
230
|
+
|
|
231
|
+
```jsx live
|
|
232
|
+
() => {
|
|
233
|
+
const librariesEnabled = true;
|
|
234
|
+
const visibleTabs = useMemo(() => {
|
|
235
|
+
const tabs = [];
|
|
236
|
+
|
|
237
|
+
tabs.push(
|
|
238
|
+
<Tab
|
|
239
|
+
key="courses"
|
|
240
|
+
eventKey="courses"
|
|
241
|
+
title="Courses"
|
|
242
|
+
>
|
|
243
|
+
Hello I am the courses panel.
|
|
244
|
+
</Tab>
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
tabs.push(
|
|
248
|
+
<Tab
|
|
249
|
+
key="programs"
|
|
250
|
+
eventKey="programs"
|
|
251
|
+
title="Programs"
|
|
252
|
+
>
|
|
253
|
+
Hello I am the programs panel.
|
|
254
|
+
</Tab>
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
if (librariesEnabled) {
|
|
258
|
+
tabs.push(
|
|
259
|
+
<Tab
|
|
260
|
+
key="libraries"
|
|
261
|
+
eventKey="libraries"
|
|
262
|
+
title="Libraries"
|
|
263
|
+
>
|
|
264
|
+
Hello I am the libraries panel.
|
|
265
|
+
</Tab>
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return tabs;
|
|
270
|
+
}, [librariesEnabled]);
|
|
271
|
+
|
|
272
|
+
return (
|
|
273
|
+
<Tabs
|
|
274
|
+
id="tabs"
|
|
275
|
+
defaultActiveKey="courses"
|
|
276
|
+
>
|
|
277
|
+
{visibleTabs}
|
|
278
|
+
</Tabs>
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
```
|
|
282
|
+
|
|
229
283
|
***
|
|
230
284
|
|
|
231
285
|
## Tabs.Deprecated
|