@openedx/paragon 23.14.7 → 23.14.9
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/Chip/constants.js +0 -1
- package/dist/Chip/constants.js.map +1 -1
- package/dist/Container/index.js +0 -1
- package/dist/Container/index.js.map +1 -1
- package/dist/DataTable/CollapsibleButtonGroup.js +0 -1
- package/dist/DataTable/CollapsibleButtonGroup.js.map +1 -1
- package/dist/DataTable/filters/CheckboxFilter.js +1 -1
- package/dist/DataTable/filters/CheckboxFilter.js.map +1 -1
- package/dist/DataTable/index.js +7 -2
- package/dist/DataTable/index.js.map +1 -1
- package/dist/Dropdown/index.js +10 -18
- package/dist/Dropdown/index.js.map +1 -1
- package/dist/Modal/ModalDialogHeader.js +4 -1
- package/dist/Modal/ModalDialogHeader.js.map +1 -1
- package/dist/Modal/ModalLayer.js +7 -12
- package/dist/Modal/ModalLayer.js.map +1 -1
- package/dist/OverflowScroll/data/constants.js +0 -2
- package/dist/ProductTour/index.js +5 -7
- package/dist/ProductTour/index.js.map +1 -1
- package/dist/ProgressBar/utils.js +0 -1
- package/dist/SelectableBox/utils.js +1 -1
- package/dist/Sticky/index.js +1 -2
- package/dist/Sticky/index.js.map +1 -1
- package/dist/asInput/index.js +7 -14
- package/dist/asInput/index.js.map +1 -1
- package/dist/setupTest.js.map +1 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/index.js.map +1 -1
- package/icons/package.json +1 -1
- package/lib/version.js +1 -2
- package/package.json +4 -4
- package/src/Card/CardCarousel/tests/CardCarousel.test.jsx +0 -1
- package/src/Chip/constants.ts +0 -1
- package/src/ChipCarousel/ChipCarousel.test.jsx +9 -11
- package/src/Container/index.tsx +0 -1
- package/src/DataTable/CollapsibleButtonGroup.jsx +0 -1
- package/src/DataTable/README.md +12 -12
- package/src/DataTable/filters/CheckboxFilter.jsx +1 -1
- package/src/DataTable/filters/tests/CheckboxFilter.test.jsx +31 -0
- package/src/DataTable/index.jsx +6 -2
- package/src/DataTable/selection/tests/utils.js +0 -1
- package/src/DataTable/tablecontrolbar.mdx +4 -4
- package/src/DataTable/tablefilters.mdx +8 -8
- package/src/DataTable/tests/DataTable.test.jsx +6 -4
- package/src/DataTable/tests/TableHeaderCell.test.jsx +0 -1
- package/src/DataTable/utils/tests/getTableArgs.test.js +3 -2
- package/src/DataTable/utils/tests/getVisibleColumns.test.js +0 -2
- package/src/Dropdown/index.jsx +11 -16
- package/src/Form/tests/useCheckboxSetValues.test.jsx +17 -9
- package/src/Modal/ModalDialogHeader.tsx +5 -1
- package/src/Modal/ModalLayer.tsx +1 -2
- package/src/Modal/tests/ModalLayer.test.tsx +1 -2
- package/src/OverflowScroll/data/constants.js +0 -2
- package/src/ProductTour/index.jsx +5 -7
- package/src/ProgressBar/utils.js +0 -1
- package/src/SelectableBox/tests/SelectableBox.test.jsx +0 -1
- package/src/SelectableBox/utils.js +1 -1
- package/src/Sticky/index.jsx +1 -1
- package/src/TransitionReplace/README.md +2 -2
- package/src/TransitionReplace/TransitionReplace.test.jsx +1 -1
- package/src/asInput/index.jsx +0 -3
- package/src/hooks/tests/useToggle.test.tsx +4 -5
- package/src/setupTest.ts +0 -1
- package/src/utils/index.ts +0 -1
- package/icons/node_modules/@svgr/babel-plugin-add-jsx-attribute/CHANGELOG.md +0 -50
- package/icons/node_modules/@svgr/babel-plugin-add-jsx-attribute/LICENSE +0 -7
- package/icons/node_modules/@svgr/babel-plugin-add-jsx-attribute/README.md +0 -37
- package/icons/node_modules/@svgr/babel-plugin-add-jsx-attribute/dist/index.d.ts +0 -20
- package/icons/node_modules/@svgr/babel-plugin-add-jsx-attribute/dist/index.js +0 -79
- package/icons/node_modules/@svgr/babel-plugin-add-jsx-attribute/dist/index.js.map +0 -1
- package/icons/node_modules/@svgr/babel-plugin-add-jsx-attribute/package.json +0 -40
- package/icons/node_modules/@svgr/babel-plugin-add-jsx-attribute/tsconfig.json +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useEffect","useState","PropTypes","withDeprecatedProps","DeprTypes","Checkpoint","ProductTour","forwardRef","tours","ref","tourValue","find","tour","enabled","checkpoints","startingIndex","onEscape","onEnd","onAdvance","tourOnAdvance","onBack","tourOnBack","onDismiss","tourOnDismiss","advanceButtonText","tourAdvanceButtonText","dismissAltText","tourDismissAltText","endButtonText","tourEndButtonText","backButtonText","tourBackButtonText","currentCheckpointData","setCurrentCheckpointData","index","setIndex","isTourEnabled","setIsTourEnabled","prunedCheckpoints","setPrunedCheckpoints","title","body","placement","target","pruneCheckpoints","checkpointList","checkpointsWithRenderedTargets","filter","checkpoint","document","querySelector","length","handleEsc","event","key","global","addEventListener","removeEventListener","handleAdvance","handleBack","handleDismiss","handleEnd","checkpointIndex","createElement","totalCheckpoints","defaultProps","propTypes","arrayOf","shape","node","string","func","oneOf","isRequired","bool","number","tourId","hasDismissButtonText","obj","dismissButtonText","deprType","FORMAT","message","expect","propValue","Array","isArray","some","transform","map","updatedTour","warningMessage","console","warn","rest"],"sources":["../../src/ProductTour/index.jsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport withDeprecatedProps, { DeprTypes } from '../withDeprecatedProps';\n\nimport Checkpoint from './Checkpoint';\n\nconst ProductTour = React.forwardRef(({ tours }, ref) => {\n const tourValue = tours.find((tour) => tour.enabled);\n const {\n enabled,\n checkpoints = [],\n startingIndex,\n onEscape,\n onEnd,\n onAdvance: tourOnAdvance,\n onBack: tourOnBack,\n onDismiss: tourOnDismiss,\n advanceButtonText: tourAdvanceButtonText,\n dismissAltText: tourDismissAltText,\n endButtonText: tourEndButtonText,\n backButtonText: tourBackButtonText,\n } = tourValue || {};\n const [currentCheckpointData, setCurrentCheckpointData] = useState(null);\n const [index, setIndex] = useState(0);\n const [isTourEnabled, setIsTourEnabled] = useState(false);\n const [prunedCheckpoints, setPrunedCheckpoints] = useState([]);\n const {\n title,\n body,\n onAdvance,\n onBack,\n onDismiss,\n advanceButtonText,\n dismissAltText,\n endButtonText,\n backButtonText,\n placement,\n target,\n } = currentCheckpointData || {};\n\n /**\n * Takes a list of checkpoints and verifies that each target string provided is\n * an element in the DOM.\n */\n const pruneCheckpoints = (checkpointList) => {\n const checkpointsWithRenderedTargets = checkpointList.filter(\n (checkpoint) => !!document.querySelector(checkpoint.target),\n );\n setPrunedCheckpoints(checkpointsWithRenderedTargets);\n };\n\n useEffect(() => {\n if (enabled && checkpoints) {\n setIsTourEnabled(enabled);\n pruneCheckpoints(checkpoints);\n setIndex(startingIndex || 0);\n }\n }, [enabled, checkpoints, startingIndex]);\n\n useEffect(() => {\n if (isTourEnabled && prunedCheckpoints.length) {\n setCurrentCheckpointData(prunedCheckpoints[index]);\n }\n }, [index, isTourEnabled, prunedCheckpoints]);\n\n useEffect(() => {\n const handleEsc = (event) => {\n if (event.key === 'Escape') {\n setIsTourEnabled(false);\n if (onEscape) {\n onEscape();\n }\n }\n };\n global.addEventListener('keydown', handleEsc);\n\n return () => {\n global.removeEventListener('keydown', handleEsc);\n };\n }, [onEscape]);\n\n if (!tourValue || !currentCheckpointData || !isTourEnabled) {\n return null;\n }\n\n const handleAdvance = () => {\n setIndex(index + 1);\n if (onAdvance) {\n onAdvance();\n } else if (tourOnAdvance) {\n tourOnAdvance();\n }\n };\n\n const handleBack = () => {\n setIndex(index - 1);\n if (onBack) {\n onBack();\n } else if (tourOnBack) {\n tourOnBack();\n }\n };\n\n const handleDismiss = () => {\n setIndex(0);\n setIsTourEnabled(false);\n if (onDismiss) {\n onDismiss();\n } else if (tourOnDismiss) {\n tourOnDismiss();\n }\n setCurrentCheckpointData(null);\n };\n /* eslint-disable */\n /**\n * Takes the final checkpoint array index value and looks for an existing onEnd callback.\n * \n * If an onEnd callback exist on checkpointIndex value and it is the final checkpoint \n * in the array, the onEnd callback will be called for the parent, and individual onEnd object. \n * \n * @param {Integer} checkpointIndex \n */\n /* eslint-enable */\n const handleEnd = (checkpointIndex) => {\n setIndex(0);\n setIsTourEnabled(false);\n if (prunedCheckpoints[checkpointIndex].onEnd) {\n prunedCheckpoints[checkpointIndex].onEnd();\n } else if (onEnd) {\n onEnd(prunedCheckpoints[checkpointIndex]);\n }\n setCurrentCheckpointData(null);\n };\n return (\n <Checkpoint\n advanceButtonText={advanceButtonText || tourAdvanceButtonText}\n body={body}\n currentCheckpointData={currentCheckpointData}\n dismissAltText={dismissAltText || tourDismissAltText}\n endButtonText={endButtonText || tourEndButtonText}\n backButtonText={backButtonText || tourBackButtonText}\n index={index}\n onBack={handleBack}\n onAdvance={handleAdvance}\n onDismiss={handleDismiss}\n onEnd={handleEnd}\n placement={placement}\n target={target}\n title={title}\n totalCheckpoints={prunedCheckpoints.length}\n ref={ref}\n />\n );\n});\n\nProductTour.defaultProps = {\n tours: {\n advanceButtonText: '',\n backButtonText: '',\n checkpoints: {\n advanceButtonText: '',\n backButtonText: '',\n body: '',\n dismissAltText: '',\n endButtonText: '',\n onAdvance: () => {},\n onDismiss: () => {},\n onBack: () => {},\n placement: 'top',\n title: '',\n },\n dismissAltText: '',\n endButtonText: '',\n onBack: () => {},\n onDismiss: () => {},\n onEnd: () => {},\n onEscape: () => {},\n startingIndex: 0,\n },\n};\n\nProductTour.propTypes = {\n tours: PropTypes.arrayOf(PropTypes.shape({\n /** The text displayed on all buttons used to advance the tour. */\n advanceButtonText: PropTypes.node,\n /** The text displayed on all buttons used to go back in the tour */\n backButtonText: PropTypes.string,\n /** An array comprised of checkpoint objects supporting the following values: */\n checkpoints: PropTypes.arrayOf(PropTypes.shape({\n /** The text displayed on the button used to advance the tour for the given Checkpoint\n * (overrides the* `advanceButtonText` defined in the parent tour object). */\n advanceButtonText: PropTypes.node,\n /** The text displayed on the button used to go back in the tour for the given Checkpoint\n * (overrides the* `backButtonText` defined in the parent tour object). */\n backButtonText: PropTypes.string,\n /** The text displayed in the body of the Checkpoint */\n body: PropTypes.node,\n /** The text used in the alt for the icon used to dismiss the tour for the given Checkpoint */\n dismissAltText: PropTypes.string,\n /** The text displayed on the button used to end the tour for the given Checkpoint\n * (overrides the `endButtonText` defined in the parent tour object). */\n endButtonText: PropTypes.node,\n /** A function that runs when triggering the `onClick` event of the advance\n * button for the given Checkpoint. */\n onAdvance: PropTypes.func,\n /** A function that runs when triggering the `onClick` event of the dismiss\n * button for the given Checkpoint (overrides the `onDismiss` function defined in the parent tour object). */\n onDismiss: PropTypes.func,\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,\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 })),\n /** The text used in the alt for the icon used to dismiss the tour for the given Checkpoint */\n dismissAltText: PropTypes.string,\n /** Whether the tour is enabled. If there are multiple tours defined, only one should be enabled at a time. */\n enabled: PropTypes.bool.isRequired,\n /** The text displayed on the button used to end the tour. */\n endButtonText: PropTypes.node,\n /** A function that runs when triggering the `onBack` event of the back button. */\n onBack: PropTypes.func,\n /** A function that runs when triggering the `onClick` event of the dismiss button. */\n onDismiss: PropTypes.func,\n /** A function that runs when triggering the `onClick` event of the end button. */\n onEnd: PropTypes.func,\n /** A function that runs when pressing the Escape key. */\n onEscape: PropTypes.func,\n /** The index of the desired `Checkpoint` to render when the tour starts. */\n startingIndex: PropTypes.number,\n /** The ID of the tour */\n tourId: PropTypes.string.isRequired,\n })),\n};\n\n/**\n * Checks if the given object has a deprecated/legacy `dismissButtonText` property.\n * @param {Object} obj - The object to check\n * @returns {boolean} - True if the object has a deprecated/legacy `dismissButtonText` property, false otherwise\n */\nconst hasDismissButtonText = (obj) => {\n if ('dismissButtonText' in obj && !!obj.dismissButtonText) {\n return true;\n }\n return false;\n};\n\nexport default withDeprecatedProps(ProductTour, 'ProductTour', {\n tours: {\n deprType: DeprTypes.FORMAT,\n message: \"The dismissButtonText options in the 'tours' prop have been moved to 'dismissAltText'.\",\n /**\n * Determines whether the given prop value contains the deprecated/legacy `dismissButtonText` property.\n * @param {Object[]} propValue - The tours prop value to check\n * @returns {boolean} True if the prop value contains the deprecated/legacy `dismissButtonText`\n * property, false otherwise\n */\n expect: (propValue) => {\n if (!Array.isArray(propValue)) {\n return true;\n }\n return !propValue.some((tour) => {\n if (hasDismissButtonText(tour)) {\n return true;\n }\n return Array.isArray(tour.checkpoints)\n && tour.checkpoints.some(hasDismissButtonText);\n });\n },\n /**\n * Transforms the given prop value by updating the\n * deprecated/legacy `dismissButtonText` property to\n * `dismissAltText`, if the prop value is a string. Otherwise,\n * the original `dismissButtonText` property is ignored.\n * @param {Object[]} propValue - The tours prop value to transform\n * @returns {Object[]} The transformed prop value\n */\n transform: (propValue) => {\n const tours = propValue.map((tour) => {\n const updatedTour = { ...tour };\n\n // Replace tour level dismissButtonText with dismissAltText\n if (hasDismissButtonText(tour)) {\n if (typeof tour.dismissButtonText === 'string') {\n updatedTour.dismissAltText = tour.dismissButtonText;\n } else {\n const warningMessage = \"[Deprecated] ProductTour: The 'dismissButtonText' options within the 'tours' prop now expects a string\";\n // eslint-disable-next-line no-console\n console.warn(warningMessage);\n }\n }\n\n // Replace checkpoint level dismissButtonText with dismissAltText\n if (Array.isArray(tour.checkpoints)) {\n updatedTour.checkpoints = tour.checkpoints.map((checkpoint) => {\n if (hasDismissButtonText(checkpoint)) {\n const { dismissButtonText, ...rest } = checkpoint;\n if (typeof dismissButtonText === 'string') {\n return { ...rest, dismissAltText: dismissButtonText };\n }\n }\n return checkpoint;\n });\n }\n return updatedTour;\n });\n\n // Return the transformed tours\n return tours;\n },\n },\n});\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,OAAOC,SAAS,MA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UACrD,CAAC,MAAM;YACL,MAAMY,cAAc,GAAG,wGAAwG;YAC/H;YACAC,OAAO,CAACC,IAAI,CAACF,cAAc,CAAC;UAC9B;QACF;;QAEA;QACA,IAAIN,KAAK,CAACC,OAAO,CAAC1E,IAAI,CAACE,WAAW,CAAC,EAAE;UACnC4E,WAAW,CAAC5E,WAAW,GAAGF,IAAI,CAACE,WAAW,CAAC2E,GAAG,CAAEzC,UAAU,IAAK;YAC7D,IAAI6B,oBAAoB,CAAC7B,UAAU,CAAC,EAAE;cACpC,MAAM;gBAAE+B,iBAAiB;gBAAE,GAAGe;cAAK,CAAC,GAAG9C,UAAU;cACjD,IAAI,OAAO+B,iBAAiB,KAAK,QAAQ,EAAE;gBACzC,OAAO;kBAAE,GAAGe,IAAI;kBAAEpE,cAAc,EAAEqD;gBAAkB,CAAC;cACvD;YACF;YACA,OAAO/B,UAAU;UACnB,CAAC,CAAC;QACJ;QACA,OAAO0C,WAAW;MACpB,CAAC,CAAC;;MAEF;MACA,OAAOlF,KAAK;IACd;EACF;AACF,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useEffect","useState","PropTypes","withDeprecatedProps","DeprTypes","Checkpoint","ProductTour","forwardRef","tours","ref","tourValue","find","tour","enabled","checkpoints","startingIndex","onEscape","onEnd","onAdvance","tourOnAdvance","onBack","tourOnBack","onDismiss","tourOnDismiss","advanceButtonText","tourAdvanceButtonText","dismissAltText","tourDismissAltText","endButtonText","tourEndButtonText","backButtonText","tourBackButtonText","currentCheckpointData","setCurrentCheckpointData","index","setIndex","isTourEnabled","setIsTourEnabled","prunedCheckpoints","setPrunedCheckpoints","title","body","placement","target","pruneCheckpoints","checkpointList","checkpointsWithRenderedTargets","filter","checkpoint","document","querySelector","length","handleEsc","event","key","global","addEventListener","removeEventListener","handleAdvance","handleBack","handleDismiss","handleEnd","checkpointIndex","createElement","totalCheckpoints","defaultProps","propTypes","arrayOf","shape","node","string","func","oneOf","isRequired","bool","number","tourId","hasDismissButtonText","obj","dismissButtonText","deprType","FORMAT","message","expect","propValue","Array","isArray","some","transform","map","updatedTour","warningMessage","console","warn","rest"],"sources":["../../src/ProductTour/index.jsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport withDeprecatedProps, { DeprTypes } from '../withDeprecatedProps';\n\nimport Checkpoint from './Checkpoint';\n\nconst ProductTour = React.forwardRef(({ tours }, ref) => {\n const tourValue = tours.find((tour) => tour.enabled);\n const {\n enabled,\n checkpoints = [],\n startingIndex,\n onEscape,\n onEnd,\n onAdvance: tourOnAdvance,\n onBack: tourOnBack,\n onDismiss: tourOnDismiss,\n advanceButtonText: tourAdvanceButtonText,\n dismissAltText: tourDismissAltText,\n endButtonText: tourEndButtonText,\n backButtonText: tourBackButtonText,\n } = tourValue || {};\n const [currentCheckpointData, setCurrentCheckpointData] = useState(null);\n const [index, setIndex] = useState(0);\n const [isTourEnabled, setIsTourEnabled] = useState(false);\n const [prunedCheckpoints, setPrunedCheckpoints] = useState([]);\n const {\n title,\n body,\n onAdvance,\n onBack,\n onDismiss,\n advanceButtonText,\n dismissAltText,\n endButtonText,\n backButtonText,\n placement,\n target,\n } = currentCheckpointData || {};\n\n /**\n * Takes a list of checkpoints and verifies that each target string provided is\n * an element in the DOM.\n */\n const pruneCheckpoints = (checkpointList) => {\n const checkpointsWithRenderedTargets = checkpointList.filter(\n (checkpoint) => !!document.querySelector(checkpoint.target),\n );\n setPrunedCheckpoints(checkpointsWithRenderedTargets);\n };\n\n useEffect(() => {\n if (enabled && checkpoints) {\n setIsTourEnabled(enabled);\n pruneCheckpoints(checkpoints);\n setIndex(startingIndex || 0);\n }\n }, [enabled, checkpoints, startingIndex]);\n\n useEffect(() => {\n if (isTourEnabled && prunedCheckpoints.length) {\n setCurrentCheckpointData(prunedCheckpoints[index]);\n }\n }, [index, isTourEnabled, prunedCheckpoints]);\n\n useEffect(() => {\n const handleEsc = (event) => {\n if (event.key === 'Escape') {\n setIsTourEnabled(false);\n if (onEscape) {\n onEscape();\n }\n }\n };\n global.addEventListener('keydown', handleEsc);\n\n return () => {\n global.removeEventListener('keydown', handleEsc);\n };\n }, [onEscape]);\n\n if (!tourValue || !currentCheckpointData || !isTourEnabled) {\n return null;\n }\n\n const handleAdvance = () => {\n setIndex(index + 1);\n if (onAdvance) {\n onAdvance();\n } else if (tourOnAdvance) {\n tourOnAdvance();\n }\n };\n\n const handleBack = () => {\n setIndex(index - 1);\n if (onBack) {\n onBack();\n } else if (tourOnBack) {\n tourOnBack();\n }\n };\n\n const handleDismiss = () => {\n setIndex(0);\n setIsTourEnabled(false);\n if (onDismiss) {\n onDismiss();\n } else if (tourOnDismiss) {\n tourOnDismiss();\n }\n setCurrentCheckpointData(null);\n };\n /**\n * Takes the final checkpoint array index value and looks for an existing onEnd callback.\n *\n * If an onEnd callback exist on checkpointIndex value and it is the final checkpoint\n * in the array, the onEnd callback will be called for the parent, and individual onEnd object.\n *\n * @param {Integer} checkpointIndex\n */\n const handleEnd = (checkpointIndex) => {\n setIndex(0);\n setIsTourEnabled(false);\n if (prunedCheckpoints[checkpointIndex].onEnd) {\n prunedCheckpoints[checkpointIndex].onEnd();\n } else if (onEnd) {\n onEnd(prunedCheckpoints[checkpointIndex]);\n }\n setCurrentCheckpointData(null);\n };\n return (\n <Checkpoint\n advanceButtonText={advanceButtonText || tourAdvanceButtonText}\n body={body}\n currentCheckpointData={currentCheckpointData}\n dismissAltText={dismissAltText || tourDismissAltText}\n endButtonText={endButtonText || tourEndButtonText}\n backButtonText={backButtonText || tourBackButtonText}\n index={index}\n onBack={handleBack}\n onAdvance={handleAdvance}\n onDismiss={handleDismiss}\n onEnd={handleEnd}\n placement={placement}\n target={target}\n title={title}\n totalCheckpoints={prunedCheckpoints.length}\n ref={ref}\n />\n );\n});\n\nProductTour.defaultProps = {\n tours: {\n advanceButtonText: '',\n backButtonText: '',\n checkpoints: {\n advanceButtonText: '',\n backButtonText: '',\n body: '',\n dismissAltText: '',\n endButtonText: '',\n onAdvance: () => {},\n onDismiss: () => {},\n onBack: () => {},\n placement: 'top',\n title: '',\n },\n dismissAltText: '',\n endButtonText: '',\n onBack: () => {},\n onDismiss: () => {},\n onEnd: () => {},\n onEscape: () => {},\n startingIndex: 0,\n },\n};\n\nProductTour.propTypes = {\n tours: PropTypes.arrayOf(PropTypes.shape({\n /** The text displayed on all buttons used to advance the tour. */\n advanceButtonText: PropTypes.node,\n /** The text displayed on all buttons used to go back in the tour */\n backButtonText: PropTypes.string,\n /** An array comprised of checkpoint objects supporting the following values: */\n checkpoints: PropTypes.arrayOf(PropTypes.shape({\n /** The text displayed on the button used to advance the tour for the given Checkpoint\n * (overrides the* `advanceButtonText` defined in the parent tour object). */\n advanceButtonText: PropTypes.node,\n /** The text displayed on the button used to go back in the tour for the given Checkpoint\n * (overrides the* `backButtonText` defined in the parent tour object). */\n backButtonText: PropTypes.string,\n /** The text displayed in the body of the Checkpoint */\n body: PropTypes.node,\n /** The text used in the alt for the icon used to dismiss the tour for the given Checkpoint */\n dismissAltText: PropTypes.string,\n /** The text displayed on the button used to end the tour for the given Checkpoint\n * (overrides the `endButtonText` defined in the parent tour object). */\n endButtonText: PropTypes.node,\n /** A function that runs when triggering the `onClick` event of the advance\n * button for the given Checkpoint. */\n onAdvance: PropTypes.func,\n /** A function that runs when triggering the `onClick` event of the dismiss\n * button for the given Checkpoint (overrides the `onDismiss` function defined in the parent tour object). */\n onDismiss: PropTypes.func,\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,\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 })),\n /** The text used in the alt for the icon used to dismiss the tour for the given Checkpoint */\n dismissAltText: PropTypes.string,\n /** Whether the tour is enabled. If there are multiple tours defined, only one should be enabled at a time. */\n enabled: PropTypes.bool.isRequired,\n /** The text displayed on the button used to end the tour. */\n endButtonText: PropTypes.node,\n /** A function that runs when triggering the `onBack` event of the back button. */\n onBack: PropTypes.func,\n /** A function that runs when triggering the `onClick` event of the dismiss button. */\n onDismiss: PropTypes.func,\n /** A function that runs when triggering the `onClick` event of the end button. */\n onEnd: PropTypes.func,\n /** A function that runs when pressing the Escape key. */\n onEscape: PropTypes.func,\n /** The index of the desired `Checkpoint` to render when the tour starts. */\n startingIndex: PropTypes.number,\n /** The ID of the tour */\n tourId: PropTypes.string.isRequired,\n })),\n};\n\n/**\n * Checks if the given object has a deprecated/legacy `dismissButtonText` property.\n * @param {Object} obj - The object to check\n * @returns {boolean} - True if the object has a deprecated/legacy `dismissButtonText` property, false otherwise\n */\nconst hasDismissButtonText = (obj) => {\n if ('dismissButtonText' in obj && !!obj.dismissButtonText) {\n return true;\n }\n return false;\n};\n\nexport default withDeprecatedProps(ProductTour, 'ProductTour', {\n tours: {\n deprType: DeprTypes.FORMAT,\n message: \"The dismissButtonText options in the 'tours' prop have been moved to 'dismissAltText'.\",\n /**\n * Determines whether the given prop value contains the deprecated/legacy `dismissButtonText` property.\n * @param {Object[]} propValue - The tours prop value to check\n * @returns {boolean} True if the prop value contains the deprecated/legacy `dismissButtonText`\n * property, false otherwise\n */\n expect: (propValue) => {\n if (!Array.isArray(propValue)) {\n return true;\n }\n return !propValue.some((tour) => {\n if (hasDismissButtonText(tour)) {\n return true;\n }\n return Array.isArray(tour.checkpoints)\n && tour.checkpoints.some(hasDismissButtonText);\n });\n },\n /**\n * Transforms the given prop value by updating the\n * deprecated/legacy `dismissButtonText` property to\n * `dismissAltText`, if the prop value is a string. Otherwise,\n * the original `dismissButtonText` property is ignored.\n * @param {Object[]} propValue - The tours prop value to transform\n * @returns {Object[]} The transformed prop value\n */\n transform: (propValue) => {\n const tours = propValue.map((tour) => {\n const updatedTour = { ...tour };\n\n // Replace tour level dismissButtonText with dismissAltText\n if (hasDismissButtonText(tour)) {\n if (typeof tour.dismissButtonText === 'string') {\n updatedTour.dismissAltText = tour.dismissButtonText;\n } else {\n const warningMessage = \"[Deprecated] ProductTour: The 'dismissButtonText' options within the 'tours' prop now expects a string\";\n // eslint-disable-next-line no-console\n console.warn(warningMessage);\n }\n }\n\n // Replace checkpoint level dismissButtonText with dismissAltText\n if (Array.isArray(tour.checkpoints)) {\n updatedTour.checkpoints = tour.checkpoints.map((checkpoint) => {\n if (hasDismissButtonText(checkpoint)) {\n const { dismissButtonText, ...rest } = checkpoint;\n if (typeof dismissButtonText === 'string') {\n return { ...rest, dismissAltText: dismissButtonText };\n }\n }\n return checkpoint;\n });\n }\n return updatedTour;\n });\n\n // Return the transformed tours\n return tours;\n },\n },\n});\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,mBAAmB,IAAIC,SAAS,QAAQ,wBAAwB;AAEvE,OAAOC,UAAU,MAAM,cAAc;AAErC,MAAMC,WAAW,gBAAGP,KAAK,CAACQ,UAAU,CAAC,CAAC;EAAEC;AAAM,CAAC,EAAEC,GAAG,KAAK;EACvD,MAAMC,SAAS,GAAGF,KAAK,CAACG,IAAI,CAAEC,IAAI,IAAKA,IAAI,CAACC,OAAO,CAAC;EACpD,MAAM;IACJA,OAAO;IACPC,WAAW,GAAG,EAAE;IAChBC,aAAa;IACbC,QAAQ;IACRC,KAAK;IACLC,SAAS,EAAEC,aAAa;IACxBC,MAAM,EAAEC,UAAU;IAClBC,SAAS,EAAEC,aAAa;IACxBC,iBAAiB,EAAEC,qBAAqB;IACxCC,cAAc,EAAEC,kBAAkB;IAClCC,aAAa,EAAEC,iBAAiB;IAChCC,cAAc,EAAEC;EAClB,CAAC,GAAGrB,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C,WAAW;MACpB,CAAC,CAAC;;MAEF;MACA,OAAOlF,KAAK;IACd;EACF;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -25,7 +25,6 @@ export const placeInfoAtZero = (
|
|
|
25
25
|
horizontalMargin += annotationOnly ? 0.0 : elementParams.width;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
// eslint-disable-next-line no-param-reassign
|
|
29
28
|
ref.current.style[direction === 'rtl' ? 'marginRight' : 'marginLeft'] = `${-horizontalMargin}px`;
|
|
30
29
|
return true;
|
|
31
30
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import Form, { CheckboxControl, RadioControl } from '../Form';
|
|
2
2
|
|
|
3
|
-
// eslint-disable-next-line import/prefer-default-export,consistent-return
|
|
4
3
|
export const getInputType = (component, type) => {
|
|
5
4
|
if (component === 'SelectableBox') {
|
|
6
5
|
switch (type) {
|
|
@@ -21,4 +20,5 @@ export const getInputType = (component, type) => {
|
|
|
21
20
|
return Form.RadioSet;
|
|
22
21
|
}
|
|
23
22
|
}
|
|
23
|
+
return null;
|
|
24
24
|
};
|
package/dist/Sticky/index.js
CHANGED
|
@@ -12,8 +12,6 @@ const Sticky = /*#__PURE__*/React.forwardRef(({
|
|
|
12
12
|
const [isSticky, setIsSticky] = useState(false);
|
|
13
13
|
const defaultRef = React.useRef();
|
|
14
14
|
const resolvedRef = ref || defaultRef;
|
|
15
|
-
|
|
16
|
-
// eslint-disable-next-line consistent-return
|
|
17
15
|
useLayoutEffect(() => {
|
|
18
16
|
if (resolvedRef.current) {
|
|
19
17
|
const stickyElement = resolvedRef.current;
|
|
@@ -34,6 +32,7 @@ const Sticky = /*#__PURE__*/React.forwardRef(({
|
|
|
34
32
|
observer.unobserve(stickyElement);
|
|
35
33
|
};
|
|
36
34
|
}
|
|
35
|
+
return undefined;
|
|
37
36
|
}, [position, resolvedRef]);
|
|
38
37
|
return /*#__PURE__*/React.createElement("div", {
|
|
39
38
|
className: classNames('pgn__sticky', `pgn__sticky-${position || 'top'}`, offset ? `pgn__sticky-offset--${offset}` : '', {
|
package/dist/Sticky/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useLayoutEffect","useState","PropTypes","classNames","POSITION_VARIANTS","Sticky","forwardRef","position","children","offset","className","rest","ref","isSticky","setIsSticky","defaultRef","useRef","resolvedRef","current","stickyElement","elementStyles","window","getComputedStyle","elementOffset","elementWithOffset","parseInt","observer","IntersectionObserver","entry","intersectionRatio","threshold","rootMargin","observe","unobserve","createElement","propTypes","node","isRequired","oneOf","oneOfType","number","string","defaultProps"
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useLayoutEffect","useState","PropTypes","classNames","POSITION_VARIANTS","Sticky","forwardRef","position","children","offset","className","rest","ref","isSticky","setIsSticky","defaultRef","useRef","resolvedRef","current","stickyElement","elementStyles","window","getComputedStyle","elementOffset","elementWithOffset","parseInt","observer","IntersectionObserver","entry","intersectionRatio","threshold","rootMargin","observe","unobserve","undefined","createElement","propTypes","node","isRequired","oneOf","oneOfType","number","string","defaultProps"],"sources":["../../src/Sticky/index.jsx"],"sourcesContent":["import React, { useLayoutEffect, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\n\nconst POSITION_VARIANTS = [\n 'top',\n 'bottom',\n];\n\nconst Sticky = React.forwardRef(({\n position,\n children,\n offset,\n className,\n ...rest\n}, ref) => {\n const [isSticky, setIsSticky] = useState(false);\n const defaultRef = React.useRef();\n const resolvedRef = ref || defaultRef;\n\n useLayoutEffect(() => {\n if (resolvedRef.current) {\n const stickyElement = resolvedRef.current;\n // getComputedStyle is used to get real top/bottom\n // values on the page for proper shadows display\n const elementStyles = window.getComputedStyle(stickyElement);\n const elementOffset = elementStyles[position || 'top'];\n // Margin calculations according to the offset.\n // 1 pixel above/bellow + offset pixels that determines\n // when callback function is called\n const elementWithOffset = 1 + (parseInt(elementOffset, 10) || 0);\n const observer = new IntersectionObserver(\n ([entry]) => setIsSticky(entry.intersectionRatio < 1),\n {\n threshold: [1],\n rootMargin: position === 'bottom'\n ? `0px 0px -${elementWithOffset}px 0px`\n : `-${elementWithOffset}px 0px 0px 0px`,\n },\n );\n observer.observe(stickyElement);\n\n return () => {\n observer.unobserve(stickyElement);\n };\n }\n return undefined;\n }, [position, resolvedRef]);\n\n return (\n <div\n className={classNames(\n 'pgn__sticky',\n `pgn__sticky-${position || 'top'}`,\n offset ? `pgn__sticky-offset--${offset}` : '',\n { 'pgn__sticky-shadow': isSticky },\n className,\n )}\n ref={resolvedRef}\n {...rest}\n >\n {children}\n </div>\n );\n});\n\nSticky.propTypes = {\n /** Specifies content of the component. */\n children: PropTypes.node.isRequired,\n /** Specifies position of the element. */\n position: PropTypes.oneOf(POSITION_VARIANTS),\n /**\n * Specifies offset from top/bottom depending on the `position` property.\n *\n * Valid values are based on `the spacing classes`:\n * `0, 0.5, ... 6`.\n */\n offset: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n /** Specifies an additional `className` to add to the base element. */\n className: PropTypes.string,\n};\n\nSticky.defaultProps = {\n position: 'top',\n offset: undefined,\n className: undefined,\n};\n\nexport default Sticky;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,eAAe,EAAEC,QAAQ,QAAQ,OAAO;AACxD,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AAEnC,MAAMC,iBAAiB,GAAG,CACxB,KAAK,EACL,QAAQ,CACT;AAED,MAAMC,MAAM,gBAAGN,KAAK,CAACO,UAAU,CAAC,CAAC;EAC/BC,QAAQ;EACRC,QAAQ;EACRC,MAAM;EACNC,SAAS;EACT,GAAGC;AACL,CAAC,EAAEC,GAAG,KAAK;EACT,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGb,QAAQ,CAAC,KAAK,CAAC;EAC/C,MAAMc,UAAU,GAAGhB,KAAK,CAACiB,MAAM,CAAC,CAAC;EACjC,MAAMC,WAAW,GAA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,CAACmC,IAAI,CAACC,UAAU;EACnC;EACA/B,QAAQ,EAAEL,SAAS,CAACqC,KAAK,CAACnC,iBAAiB,CAAC;EAC5C;AACF;AACA;AACA;AACA;AACA;EACEK,MAAM,EAAEP,SAAS,CAACsC,SAAS,CAAC,CAACtC,SAAS,CAACuC,MAAM,EAAEvC,SAAS,CAACwC,MAAM,CAAC,CAAC;EACjE;EACAhC,SAAS,EAAER,SAAS,CAACwC;AACvB,CAAC;AAEDrC,MAAM,CAACsC,YAAY,GAAG;EACpBpC,QAAQ,EAAE,KAAK;EACfE,MAAM,EAAEyB,SAAS;EACjBxB,SAAS,EAAEwB;AACb,CAAC;AAED,eAAe7B,MAAM","ignoreList":[]}
|
package/dist/asInput/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable react/no-unused-prop-types */
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import PropTypes from 'prop-types';
|
|
4
3
|
import classNames from 'classnames';
|
|
@@ -73,8 +72,6 @@ const asInput = (WrappedComponent, inputType = undefined, labelFirst = true) =>
|
|
|
73
72
|
dangerIconDescription
|
|
74
73
|
};
|
|
75
74
|
}
|
|
76
|
-
|
|
77
|
-
/* eslint-disable react/no-did-update-set-state */
|
|
78
75
|
componentDidUpdate(prevProps) {
|
|
79
76
|
const updatedState = {};
|
|
80
77
|
if (this.props.value !== prevProps.value) {
|
|
@@ -116,17 +113,13 @@ const asInput = (WrappedComponent, inputType = undefined, labelFirst = true) =>
|
|
|
116
113
|
this.props.onBlur(val, this.props.name);
|
|
117
114
|
}
|
|
118
115
|
getLabel() {
|
|
119
|
-
return (
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
'form-check-label': this.isGroupedInput()
|
|
127
|
-
})
|
|
128
|
-
}, this.props.label)
|
|
129
|
-
);
|
|
116
|
+
return /*#__PURE__*/React.createElement("label", {
|
|
117
|
+
id: `label-${this.state.id}`,
|
|
118
|
+
htmlFor: this.state.id,
|
|
119
|
+
className: classNames({
|
|
120
|
+
'form-check-label': this.isGroupedInput()
|
|
121
|
+
})
|
|
122
|
+
}, this.props.label);
|
|
130
123
|
}
|
|
131
124
|
getDescriptions() {
|
|
132
125
|
// possible future work: multiple feedback msgs?
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","PropTypes","classNames","newId","ValidationMessage","Variant","withDeprecatedProps","DeprTypes","getDisplayName","WrappedComponent","displayName","name","inputProps","label","oneOfType","string","element","isRequired","id","value","number","dangerIconDescription","description","disabled","bool","required","onChange","func","onKeyPress","onBlur","validator","isValid","validationMessage","className","themes","arrayOf","inline","inputGroupPrepend","inputGroupAppend","type","inputRef","shape","current","instanceOf","defaultProps","undefined","asInput","inputType","labelFirst","NewComponent","Component","constructor","props","handleChange","bind","handleBlur","handleKeyPress","renderInput","state","componentDidUpdate","prevProps","updatedState","Object","keys","length","setState","event","target","checked","val","getLabel","createElement","htmlFor","isGroupedInput","getDescriptions","errorId","descriptionId","desc","error","invalidMessage","variant","status","hasDangerTheme","DANGER","INFO","variantIconDescription","describedBy","key","trim","getAddons","addonElements","Array","isArray","map","addon","index","cloneElement","generateInputGroupAddonKey","prefix","indexOf","others","renderInputGroupAppend","renderInputGroupPrepend","render","propTypes","deprType","FORMAT","expect","transform","join","message","ariaLabel","MOVED","newName"],"sources":["../../src/asInput/index.jsx"],"sourcesContent":["/* eslint-disable react/no-unused-prop-types */\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\n\nimport newId from '../utils/newId';\nimport ValidationMessage from '../ValidationMessage/index';\nimport Variant from '../utils/constants';\nimport withDeprecatedProps, { DeprTypes } from '../withDeprecatedProps';\n\nexport const getDisplayName = WrappedComponent => WrappedComponent.displayName || WrappedComponent.name || 'Component';\n\nexport const inputProps = {\n label: PropTypes.oneOfType([PropTypes.string, PropTypes.element]).isRequired,\n name: PropTypes.string.isRequired,\n id: PropTypes.string,\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n dangerIconDescription: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n description: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.element,\n ]),\n disabled: PropTypes.bool,\n required: PropTypes.bool,\n onChange: PropTypes.func,\n onKeyPress: PropTypes.func,\n onBlur: PropTypes.func,\n validator: PropTypes.func,\n isValid: PropTypes.bool,\n validationMessage: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n className: PropTypes.string,\n themes: PropTypes.arrayOf(PropTypes.string),\n inline: PropTypes.bool,\n inputGroupPrepend: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element), PropTypes.element]),\n inputGroupAppend: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element), PropTypes.element]),\n type: PropTypes.string,\n inputRef: PropTypes.oneOfType([\n PropTypes.func,\n PropTypes.shape({ current: PropTypes.instanceOf(PropTypes.element) }),\n ]),\n};\n\nexport const defaultProps = {\n onChange: () => {},\n onBlur: () => {},\n onKeyPress: () => {},\n id: undefined,\n value: '',\n dangerIconDescription: '',\n description: undefined,\n disabled: false,\n required: false,\n validator: undefined,\n isValid: true,\n validationMessage: '',\n className: undefined,\n themes: [],\n inline: false,\n inputGroupPrepend: undefined,\n inputGroupAppend: undefined,\n type: undefined,\n inputRef: undefined,\n};\n\nconst asInput = (WrappedComponent, inputType = undefined, labelFirst = true) => {\n class NewComponent extends React.Component {\n constructor(props) {\n super(props);\n this.handleChange = this.handleChange.bind(this);\n this.handleBlur = this.handleBlur.bind(this);\n this.handleKeyPress = this.handleKeyPress.bind(this);\n this.renderInput = this.renderInput.bind(this);\n\n const id = this.props.id ? this.props.id : newId('asInput');\n const isValid = this.props.validator ? true : this.props.isValid;\n const validationMessage = this.props.validator ? '' : this.props.validationMessage;\n const dangerIconDescription = this.props.validator ? '' : this.props.dangerIconDescription;\n this.state = {\n id,\n value: this.props.value,\n isValid,\n validationMessage,\n dangerIconDescription,\n };\n }\n\n /* eslint-disable react/no-did-update-set-state */\n componentDidUpdate(prevProps) {\n const updatedState = {};\n if (this.props.value !== prevProps.value) {\n updatedState.value = this.props.value;\n }\n if (this.props.isValid !== prevProps.isValid && !this.props.validator) {\n updatedState.isValid = this.props.isValid;\n }\n if (this.props.validationMessage !== prevProps.validationMessage && !this.props.validator) {\n updatedState.validationMessage = this.props.validationMessage;\n }\n if (this.props.dangerIconDescription !== prevProps.dangerIconDescription\n && !this.props.validator) {\n updatedState.dangerIconDescription = this.props.dangerIconDescription;\n }\n // If validator goes away, revert to props\n if (this.props.validator !== prevProps.validator && !this.props.validator) {\n updatedState.isValid = this.props.isValid;\n updatedState.validationMessage = this.props.validationMessage;\n updatedState.dangerIconDescription = this.props.dangerIconDescription;\n }\n if (Object.keys(updatedState).length > 0) {\n this.setState(updatedState);\n }\n }\n\n handleChange(event) {\n this.setState({ value: event.target.value });\n\n this.props.onChange(\n event.target.type === 'checkbox' ? event.target.checked : event.target.value,\n this.props.name,\n );\n }\n\n handleKeyPress(event) {\n this.props.onKeyPress(event, this.props.name);\n }\n\n handleBlur(event) {\n const val = event.target.value;\n\n if (this.props.validator) {\n this.setState(this.props.validator(val));\n }\n this.props.onBlur(val, this.props.name);\n }\n\n getLabel() {\n return (\n // eslint-disable-next-line jsx-a11y/label-has-for\n <label\n id={`label-${this.state.id}`}\n htmlFor={this.state.id}\n className={classNames({\n 'form-check-label': this.isGroupedInput(),\n })}\n >\n {this.props.label}\n </label>\n );\n }\n\n getDescriptions() {\n // possible future work: multiple feedback msgs?\n const errorId = `error-${this.state.id}`;\n const descriptionId = `description-${this.state.id}`;\n const desc = {};\n\n // TODO: refactor this component to use Variants instead of the themes array.\n desc.error = (\n <ValidationMessage\n id={errorId}\n isValid={this.state.isValid}\n invalidMessage={this.state.validationMessage}\n variant={{\n status: this.hasDangerTheme() ? Variant.status.DANGER : Variant.status.INFO,\n }}\n variantIconDescription={this.state.dangerIconDescription}\n />\n );\n desc.describedBy = errorId;\n\n if (this.props.description) {\n desc.description = (\n <small className=\"form-text\" id={descriptionId} key=\"1\">\n {this.props.description}\n </small>\n );\n desc.describedBy = `${desc.describedBy} ${descriptionId}`.trim();\n }\n\n return desc;\n }\n\n getAddons({ addonElements, type }) {\n if (Array.isArray(addonElements)) {\n return addonElements.map((addon, index) => React.cloneElement(\n addon,\n { key: this.generateInputGroupAddonKey({ prefix: type, index }) },\n ));\n }\n return addonElements;\n }\n\n hasDangerTheme() {\n return this.props.themes.indexOf('danger') >= 0;\n }\n\n isGroupedInput() {\n switch (inputType) {\n case 'checkbox':\n return true;\n default:\n return false;\n }\n }\n\n generateInputGroupAddonKey({ prefix, index }) {\n return `${this.state.id}-${prefix}-${index}`;\n }\n\n renderInput(describedBy) {\n const {\n className,\n inputRef,\n type,\n isValid,\n // unused\n validator,\n themes,\n inline,\n inputGroupPrepend,\n inputGroupAppend,\n label,\n dangerIconDescription,\n description,\n validationMessage,\n ...others\n } = this.props;\n\n return (\n <WrappedComponent\n {...others}\n id={this.state.id}\n value={this.state.value}\n className={classNames(\n {\n 'form-control': !this.isGroupedInput(),\n 'form-check-input': this.isGroupedInput(),\n 'is-invalid': !this.state.isValid,\n 'is-invalid-nodanger': !this.hasDangerTheme(),\n },\n className,\n )}\n aria-describedby={describedBy}\n aria-invalid={!isValid}\n onChange={this.handleChange}\n onBlur={this.handleBlur}\n onKeyPress={this.handleKeyPress}\n type={type}\n inputRef={inputRef}\n />\n );\n }\n\n renderInputGroupAppend() {\n return (\n <div className=\"input-group-append\">\n {this.getAddons({ type: 'append', addonElements: this.props.inputGroupAppend })}\n </div>\n );\n }\n\n renderInputGroupPrepend() {\n return (\n <div className=\"input-group-prepend\">\n {this.getAddons({ type: 'prepend', addonElements: this.props.inputGroupPrepend })}\n </div>\n );\n }\n\n render() {\n const { description, error, describedBy } = this.getDescriptions();\n return (\n <div className={classNames({\n 'form-group': !this.isGroupedInput(),\n 'form-inline': !this.isGroupedInput() && this.props.inline,\n 'form-check': this.isGroupedInput(),\n })}\n >\n {labelFirst && this.getLabel()}\n {this.props.inputGroupPrepend || this.props.inputGroupAppend ? (\n <div className={classNames('input-group')} data-testid=\"input-group\">\n {this.renderInputGroupPrepend()}\n {this.renderInput(describedBy)}\n {this.renderInputGroupAppend()}\n </div>\n ) : this.renderInput(describedBy)}\n {!labelFirst && this.getLabel()}\n {error}\n {description}\n </div>\n );\n }\n }\n\n NewComponent.displayName = `asInput(${getDisplayName(WrappedComponent)})`;\n\n NewComponent.propTypes = inputProps;\n\n NewComponent.defaultProps = defaultProps;\n\n return withDeprecatedProps(NewComponent, 'asInput', {\n className: {\n deprType: DeprTypes.FORMAT,\n expect: value => typeof value === 'string',\n transform: value => (Array.isArray(value) ? value.join(' ') : value),\n message: 'It should be a string.',\n },\n ariaLabel: {\n deprType: DeprTypes.MOVED,\n newName: 'aria-label',\n },\n });\n};\n\nexport default asInput;\n"],"mappings":"AAAA;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AAEnC,OAAOC,KAAK,MAAM,gBAAgB;AAClC,OAAOC,iBAAiB,MAAM,4BAA4B;AAC1D,OAAOC,OAAO,MAAM,oBAAoB;AACxC,OAAOC,mBAAmB,IAAIC,SAAS,QAAQ,wBAAwB;AAEvE,OAAO,MAAMC,cAAc,GAAGC,gBAAgB,IAAIA,gBAAgB,CAACC,WAAW,IAAID,gBAAgB,CAACE,IAAI,IAAI,WAAW;AAEtH,OAAO,MAAMC,UAAU,GAAG;EACxBC,KAAK,EAAEZ,SAAS,CAACa,SAAS,CAAC,CAACb,SAAS,CAACc,MAAM,EAAEd,SAAS,CAACe,OAAO,CAAC,CAAC,CAACC,UAAU;EAC5EN,IAAI,EAAEV,SAAS,CAACc,MAAM,CAACE,UAAU;EACjCC,EAAE,EAAEjB,SAAS,CAACc,MAAM;EACpBI,KAAK,EAAElB,SAAS,CAACa,SAAS,CAAC,CAACb,SAAS,CAAC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C,YAAY,CAACuD,SAAS,GAAG5F,UAAU;EAEnCqC,YAAY,CAACL,YAAY,GAAGA,YAAY;EAExC,OAAOtC,mBAAmB,CAAC2C,YAAY,EAAE,SAAS,EAAE;IAClDhB,SAAS,EAAE;MACTwE,QAAQ,EAAElG,SAAS,CAACmG,MAAM;MAC1BC,MAAM,EAAExF,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ;MAC1CyF,SAAS,EAAEzF,KAAK,IAAKwE,KAAK,CAACC,OAAO,CAACzE,KAAK,CAAC,GAAGA,KAAK,CAAC0F,IAAI,CAAC,GAAG,CAAC,GAAG1F,KAAM;MACpE2F,OAAO,EAAE;IACX,CAAC;IACDC,SAAS,EAAE;MACTN,QAAQ,EAAElG,SAAS,CAACyG,KAAK;MACzBC,OAAO,EAAE;IACX;EACF,CAAC,CAAC;AACJ,CAAC;AAED,eAAenE,OAAO","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","PropTypes","classNames","newId","ValidationMessage","Variant","withDeprecatedProps","DeprTypes","getDisplayName","WrappedComponent","displayName","name","inputProps","label","oneOfType","string","element","isRequired","id","value","number","dangerIconDescription","description","disabled","bool","required","onChange","func","onKeyPress","onBlur","validator","isValid","validationMessage","className","themes","arrayOf","inline","inputGroupPrepend","inputGroupAppend","type","inputRef","shape","current","instanceOf","defaultProps","undefined","asInput","inputType","labelFirst","NewComponent","Component","constructor","props","handleChange","bind","handleBlur","handleKeyPress","renderInput","state","componentDidUpdate","prevProps","updatedState","Object","keys","length","setState","event","target","checked","val","getLabel","createElement","htmlFor","isGroupedInput","getDescriptions","errorId","descriptionId","desc","error","invalidMessage","variant","status","hasDangerTheme","DANGER","INFO","variantIconDescription","describedBy","key","trim","getAddons","addonElements","Array","isArray","map","addon","index","cloneElement","generateInputGroupAddonKey","prefix","indexOf","others","renderInputGroupAppend","renderInputGroupPrepend","render","propTypes","deprType","FORMAT","expect","transform","join","message","ariaLabel","MOVED","newName"],"sources":["../../src/asInput/index.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\n\nimport newId from '../utils/newId';\nimport ValidationMessage from '../ValidationMessage/index';\nimport Variant from '../utils/constants';\nimport withDeprecatedProps, { DeprTypes } from '../withDeprecatedProps';\n\nexport const getDisplayName = WrappedComponent => WrappedComponent.displayName || WrappedComponent.name || 'Component';\n\nexport const inputProps = {\n label: PropTypes.oneOfType([PropTypes.string, PropTypes.element]).isRequired,\n name: PropTypes.string.isRequired,\n id: PropTypes.string,\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n dangerIconDescription: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n description: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.element,\n ]),\n disabled: PropTypes.bool,\n required: PropTypes.bool,\n onChange: PropTypes.func,\n onKeyPress: PropTypes.func,\n onBlur: PropTypes.func,\n validator: PropTypes.func,\n isValid: PropTypes.bool,\n validationMessage: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n className: PropTypes.string,\n themes: PropTypes.arrayOf(PropTypes.string),\n inline: PropTypes.bool,\n inputGroupPrepend: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element), PropTypes.element]),\n inputGroupAppend: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element), PropTypes.element]),\n type: PropTypes.string,\n inputRef: PropTypes.oneOfType([\n PropTypes.func,\n PropTypes.shape({ current: PropTypes.instanceOf(PropTypes.element) }),\n ]),\n};\n\nexport const defaultProps = {\n onChange: () => {},\n onBlur: () => {},\n onKeyPress: () => {},\n id: undefined,\n value: '',\n dangerIconDescription: '',\n description: undefined,\n disabled: false,\n required: false,\n validator: undefined,\n isValid: true,\n validationMessage: '',\n className: undefined,\n themes: [],\n inline: false,\n inputGroupPrepend: undefined,\n inputGroupAppend: undefined,\n type: undefined,\n inputRef: undefined,\n};\n\nconst asInput = (WrappedComponent, inputType = undefined, labelFirst = true) => {\n class NewComponent extends React.Component {\n constructor(props) {\n super(props);\n this.handleChange = this.handleChange.bind(this);\n this.handleBlur = this.handleBlur.bind(this);\n this.handleKeyPress = this.handleKeyPress.bind(this);\n this.renderInput = this.renderInput.bind(this);\n\n const id = this.props.id ? this.props.id : newId('asInput');\n const isValid = this.props.validator ? true : this.props.isValid;\n const validationMessage = this.props.validator ? '' : this.props.validationMessage;\n const dangerIconDescription = this.props.validator ? '' : this.props.dangerIconDescription;\n this.state = {\n id,\n value: this.props.value,\n isValid,\n validationMessage,\n dangerIconDescription,\n };\n }\n\n componentDidUpdate(prevProps) {\n const updatedState = {};\n if (this.props.value !== prevProps.value) {\n updatedState.value = this.props.value;\n }\n if (this.props.isValid !== prevProps.isValid && !this.props.validator) {\n updatedState.isValid = this.props.isValid;\n }\n if (this.props.validationMessage !== prevProps.validationMessage && !this.props.validator) {\n updatedState.validationMessage = this.props.validationMessage;\n }\n if (this.props.dangerIconDescription !== prevProps.dangerIconDescription\n && !this.props.validator) {\n updatedState.dangerIconDescription = this.props.dangerIconDescription;\n }\n // If validator goes away, revert to props\n if (this.props.validator !== prevProps.validator && !this.props.validator) {\n updatedState.isValid = this.props.isValid;\n updatedState.validationMessage = this.props.validationMessage;\n updatedState.dangerIconDescription = this.props.dangerIconDescription;\n }\n if (Object.keys(updatedState).length > 0) {\n this.setState(updatedState);\n }\n }\n\n handleChange(event) {\n this.setState({ value: event.target.value });\n\n this.props.onChange(\n event.target.type === 'checkbox' ? event.target.checked : event.target.value,\n this.props.name,\n );\n }\n\n handleKeyPress(event) {\n this.props.onKeyPress(event, this.props.name);\n }\n\n handleBlur(event) {\n const val = event.target.value;\n\n if (this.props.validator) {\n this.setState(this.props.validator(val));\n }\n this.props.onBlur(val, this.props.name);\n }\n\n getLabel() {\n return (\n <label\n id={`label-${this.state.id}`}\n htmlFor={this.state.id}\n className={classNames({\n 'form-check-label': this.isGroupedInput(),\n })}\n >\n {this.props.label}\n </label>\n );\n }\n\n getDescriptions() {\n // possible future work: multiple feedback msgs?\n const errorId = `error-${this.state.id}`;\n const descriptionId = `description-${this.state.id}`;\n const desc = {};\n\n // TODO: refactor this component to use Variants instead of the themes array.\n desc.error = (\n <ValidationMessage\n id={errorId}\n isValid={this.state.isValid}\n invalidMessage={this.state.validationMessage}\n variant={{\n status: this.hasDangerTheme() ? Variant.status.DANGER : Variant.status.INFO,\n }}\n variantIconDescription={this.state.dangerIconDescription}\n />\n );\n desc.describedBy = errorId;\n\n if (this.props.description) {\n desc.description = (\n <small className=\"form-text\" id={descriptionId} key=\"1\">\n {this.props.description}\n </small>\n );\n desc.describedBy = `${desc.describedBy} ${descriptionId}`.trim();\n }\n\n return desc;\n }\n\n getAddons({ addonElements, type }) {\n if (Array.isArray(addonElements)) {\n return addonElements.map((addon, index) => React.cloneElement(\n addon,\n { key: this.generateInputGroupAddonKey({ prefix: type, index }) },\n ));\n }\n return addonElements;\n }\n\n hasDangerTheme() {\n return this.props.themes.indexOf('danger') >= 0;\n }\n\n isGroupedInput() {\n switch (inputType) {\n case 'checkbox':\n return true;\n default:\n return false;\n }\n }\n\n generateInputGroupAddonKey({ prefix, index }) {\n return `${this.state.id}-${prefix}-${index}`;\n }\n\n renderInput(describedBy) {\n const {\n className,\n inputRef,\n type,\n isValid,\n // unused\n validator,\n themes,\n inline,\n inputGroupPrepend,\n inputGroupAppend,\n label,\n dangerIconDescription,\n description,\n validationMessage,\n ...others\n } = this.props;\n\n return (\n <WrappedComponent\n {...others}\n id={this.state.id}\n value={this.state.value}\n className={classNames(\n {\n 'form-control': !this.isGroupedInput(),\n 'form-check-input': this.isGroupedInput(),\n 'is-invalid': !this.state.isValid,\n 'is-invalid-nodanger': !this.hasDangerTheme(),\n },\n className,\n )}\n aria-describedby={describedBy}\n aria-invalid={!isValid}\n onChange={this.handleChange}\n onBlur={this.handleBlur}\n onKeyPress={this.handleKeyPress}\n type={type}\n inputRef={inputRef}\n />\n );\n }\n\n renderInputGroupAppend() {\n return (\n <div className=\"input-group-append\">\n {this.getAddons({ type: 'append', addonElements: this.props.inputGroupAppend })}\n </div>\n );\n }\n\n renderInputGroupPrepend() {\n return (\n <div className=\"input-group-prepend\">\n {this.getAddons({ type: 'prepend', addonElements: this.props.inputGroupPrepend })}\n </div>\n );\n }\n\n render() {\n const { description, error, describedBy } = this.getDescriptions();\n return (\n <div className={classNames({\n 'form-group': !this.isGroupedInput(),\n 'form-inline': !this.isGroupedInput() && this.props.inline,\n 'form-check': this.isGroupedInput(),\n })}\n >\n {labelFirst && this.getLabel()}\n {this.props.inputGroupPrepend || this.props.inputGroupAppend ? (\n <div className={classNames('input-group')} data-testid=\"input-group\">\n {this.renderInputGroupPrepend()}\n {this.renderInput(describedBy)}\n {this.renderInputGroupAppend()}\n </div>\n ) : this.renderInput(describedBy)}\n {!labelFirst && this.getLabel()}\n {error}\n {description}\n </div>\n );\n }\n }\n\n NewComponent.displayName = `asInput(${getDisplayName(WrappedComponent)})`;\n\n NewComponent.propTypes = inputProps;\n\n NewComponent.defaultProps = defaultProps;\n\n return withDeprecatedProps(NewComponent, 'asInput', {\n className: {\n deprType: DeprTypes.FORMAT,\n expect: value => typeof value === 'string',\n transform: value => (Array.isArray(value) ? value.join(' ') : value),\n message: 'It should be a string.',\n },\n ariaLabel: {\n deprType: DeprTypes.MOVED,\n newName: 'aria-label',\n },\n });\n};\n\nexport default asInput;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AAEnC,OAAOC,KAAK,MAAM,gBAAgB;AAClC,OAAOC,iBAAiB,MAAM,4BAA4B;AAC1D,OAAOC,OAAO,MAAM,oBAAoB;AACxC,OAAOC,mBAAmB,IAAIC,SAAS,QAAQ,wBAAwB;AAEvE,OAAO,MAAMC,cAAc,GAAGC,gBAAgB,IAAIA,gBAAgB,CAACC,WAAW,IAAID,gBAAgB,CAACE,IAAI,IAAI,WAAW;AAEtH,OAAO,MAAMC,UAAU,GAAG;EACxBC,KAAK,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AC1B,CAAC,GACJ,IAAI,CAAC5C,WAAW,CAAC6B,WAAW,CAAC,EAChC,CAACtC,UAAU,IAAI,IAAI,CAACsB,QAAQ,CAAC,CAAC,EAC9BQ,KAAK,EACLxD,WACE,CAAC;IAEV;EACF;EAEA2B,YAAY,CAACvC,WAAW,GAAG,WAAWF,cAAc,CAACC,gBAAgB,CAAC,GAAG;EAEzEwC,YAAY,CAACuD,SAAS,GAAG5F,UAAU;EAEnCqC,YAAY,CAACL,YAAY,GAAGA,YAAY;EAExC,OAAOtC,mBAAmB,CAAC2C,YAAY,EAAE,SAAS,EAAE;IAClDhB,SAAS,EAAE;MACTwE,QAAQ,EAAElG,SAAS,CAACmG,MAAM;MAC1BC,MAAM,EAAExF,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ;MAC1CyF,SAAS,EAAEzF,KAAK,IAAKwE,KAAK,CAACC,OAAO,CAACzE,KAAK,CAAC,GAAGA,KAAK,CAAC0F,IAAI,CAAC,GAAG,CAAC,GAAG1F,KAAM;MACpE2F,OAAO,EAAE;IACX,CAAC;IACDC,SAAS,EAAE;MACTN,QAAQ,EAAElG,SAAS,CAACyG,KAAK;MACzBC,OAAO,EAAE;IACX;EACF,CAAC,CAAC;AACJ,CAAC;AAED,eAAenE,OAAO","ignoreList":[]}
|
package/dist/setupTest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupTest.js","names":["ResizeObserver","observe","unobserve","disconnect","window"],"sources":["../src/setupTest.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"setupTest.js","names":["ResizeObserver","observe","unobserve","disconnect","window"],"sources":["../src/setupTest.ts"],"sourcesContent":["import 'regenerator-runtime/runtime';\n\nimport '@testing-library/jest-dom';\n\nclass ResizeObserver {\n observe() {\n // do nothing\n }\n\n unobserve() {\n // do nothing\n }\n\n disconnect() {\n // do nothing\n }\n}\n\nwindow.ResizeObserver = ResizeObserver;\n"],"mappings":"AAAA,OAAO,6BAA6B;AAEpC,OAAO,2BAA2B;AAElC,MAAMA,cAAc,CAAC;EACnBC,OAAOA,CAAA,EAAG;IACR;EAAA;EAGFC,SAASA,CAAA,EAAG;IACV;EAAA;EAGFC,UAAUA,CAAA,EAAG;IACX;EAAA;AAEJ;AAEAC,MAAM,CAACJ,cAAc,GAAGA,cAAc","ignoreList":[]}
|
package/dist/utils/index.js
CHANGED
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["default","newId"],"sources":["../../src/utils/index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","newId"],"sources":["../../src/utils/index.ts"],"sourcesContent":["export { default as newId } from './newId';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,KAAK,QAAQ,SAAS","ignoreList":[]}
|
package/icons/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@babel/preset-react": "^7.12.10",
|
|
18
18
|
"@material-icons/svg": "^1.0.30",
|
|
19
19
|
"@svgr/cli": "^6.4.0",
|
|
20
|
-
"@svgr/babel-plugin-add-jsx-attribute": "^
|
|
20
|
+
"@svgr/babel-plugin-add-jsx-attribute": "^8.0.0",
|
|
21
21
|
"bootstrap-icons": "^1.11.3"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
package/lib/version.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
1
|
const chalk = require('chalk');
|
|
3
2
|
const { version } = require('../package.json');
|
|
4
3
|
|
|
5
4
|
function versionCommand() {
|
|
6
|
-
console.log(`Paragon CLI version: ${chalk.bold(version)}`);
|
|
5
|
+
console.log(`Paragon CLI version: ${chalk.bold(version)}`); /* eslint-disable-line no-console */
|
|
7
6
|
}
|
|
8
7
|
|
|
9
8
|
module.exports = versionCommand;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openedx/paragon",
|
|
3
|
-
"version": "23.14.
|
|
3
|
+
"version": "23.14.9",
|
|
4
4
|
"description": "Accessible, responsive UI component library based on Bootstrap.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"react-loading-skeleton": "^3.1.0",
|
|
98
98
|
"react-popper": "^2.2.5",
|
|
99
99
|
"react-proptype-conditional-require": "^1.0.4",
|
|
100
|
-
"react-responsive": "^
|
|
100
|
+
"react-responsive": "^10.0.0",
|
|
101
101
|
"react-table": "^7.7.0",
|
|
102
102
|
"react-transition-group": "^4.4.2",
|
|
103
103
|
"sass": "^1.58.3",
|
|
@@ -133,13 +133,13 @@
|
|
|
133
133
|
"@types/jest": "^29.5.10",
|
|
134
134
|
"@types/react": "^18",
|
|
135
135
|
"@types/react-dom": "^18",
|
|
136
|
-
"@types/react-responsive": "^
|
|
136
|
+
"@types/react-responsive": "^9.0.0",
|
|
137
137
|
"@types/react-table": "^7.7.19",
|
|
138
138
|
"@types/react-test-renderer": "^18.0.0",
|
|
139
139
|
"@types/uuid": "^9.0.0",
|
|
140
140
|
"@typescript-eslint/eslint-plugin": "^5.22.0",
|
|
141
141
|
"@typescript-eslint/parser": "^5.22.0",
|
|
142
|
-
"axios-mock-adapter": "^
|
|
142
|
+
"axios-mock-adapter": "^2.0.0",
|
|
143
143
|
"babel-jest": "^29.7.0",
|
|
144
144
|
"babel-loader": "^8.2.4",
|
|
145
145
|
"commander": "^9.3.0",
|
|
@@ -12,7 +12,6 @@ jest.mock('../../../OverflowScroll', () => ({
|
|
|
12
12
|
OverflowScroll: jest.fn(),
|
|
13
13
|
}));
|
|
14
14
|
|
|
15
|
-
// eslint-disable-next-line react/prop-types
|
|
16
15
|
OverflowScroll.mockImplementation(({ children }) => {
|
|
17
16
|
const overflowRef = { current: document.createElement('div') };
|
|
18
17
|
const contextValue = {
|
package/src/Chip/constants.ts
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
2
|
-
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
3
1
|
import React from 'react';
|
|
4
2
|
import { render, screen } from '@testing-library/react';
|
|
5
3
|
import userEvent from '@testing-library/user-event';
|
|
6
4
|
import { IntlProvider } from 'react-intl';
|
|
7
5
|
import ChipCarousel from '.';
|
|
6
|
+
import Chip from '../Chip';
|
|
8
7
|
|
|
9
|
-
const items =
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
];
|
|
8
|
+
const items = Array.from({ length: 4 }, (_, i) => (
|
|
9
|
+
<Chip onClick={jest.fn()}>
|
|
10
|
+
{`Item ${i + 1}`}
|
|
11
|
+
</Chip>
|
|
12
|
+
));
|
|
15
13
|
|
|
16
14
|
const ariaLabel = 'Test aria label';
|
|
17
15
|
function TestingChipCarousel(props) {
|
|
@@ -29,9 +27,9 @@ describe('<ChipCarousel />', () => {
|
|
|
29
27
|
const carousel = screen.getByTestId('chip-carousel');
|
|
30
28
|
expect(carousel).toBeTruthy();
|
|
31
29
|
|
|
32
|
-
const chipItems = screen.
|
|
33
|
-
expect(chipItems).toHaveLength(items.length
|
|
34
|
-
for (let i = 0; i < chipItems.length
|
|
30
|
+
const chipItems = screen.queryAllByRole('button');
|
|
31
|
+
expect(chipItems).toHaveLength(items.length);
|
|
32
|
+
for (let i = 0; i < chipItems.length; i++) {
|
|
35
33
|
expect(chipItems[i].textContent).toBe(items[i].props.children);
|
|
36
34
|
}
|
|
37
35
|
});
|
package/src/Container/index.tsx
CHANGED
|
@@ -51,7 +51,6 @@ function CollapsibleButtonGroup({
|
|
|
51
51
|
const cloneAction = (action, index) => React.cloneElement(
|
|
52
52
|
action.component,
|
|
53
53
|
{
|
|
54
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
55
54
|
key: `${action}${index}`,
|
|
56
55
|
as: Button, // for backwards compatibility this is needed
|
|
57
56
|
...action.args,
|
package/src/DataTable/README.md
CHANGED
|
@@ -423,17 +423,17 @@ See ``dataViewToggleOptions`` props documentation for all supported props.
|
|
|
423
423
|
Filter: CheckboxFilter,
|
|
424
424
|
filter: 'includesValue',
|
|
425
425
|
filterChoices: [{
|
|
426
|
-
name: '
|
|
426
|
+
name: 'Orange Tabby',
|
|
427
427
|
number: 1,
|
|
428
428
|
value: 'orange tabby',
|
|
429
429
|
},
|
|
430
430
|
{
|
|
431
|
-
name: '
|
|
431
|
+
name: 'Brown Tabby',
|
|
432
432
|
number: 1,
|
|
433
433
|
value: 'brown tabby',
|
|
434
434
|
},
|
|
435
435
|
{
|
|
436
|
-
name: '
|
|
436
|
+
name: 'Siamese',
|
|
437
437
|
number: 1,
|
|
438
438
|
value: 'siamese',
|
|
439
439
|
}],
|
|
@@ -503,17 +503,17 @@ See ``dataViewToggleOptions`` props documentation for all supported props.
|
|
|
503
503
|
Filter: CheckboxFilter,
|
|
504
504
|
filter: 'includesValue',
|
|
505
505
|
filterChoices: [{
|
|
506
|
-
name: '
|
|
506
|
+
name: 'Orange Tabby',
|
|
507
507
|
number: 1,
|
|
508
508
|
value: 'orange tabby',
|
|
509
509
|
},
|
|
510
510
|
{
|
|
511
|
-
name: '
|
|
511
|
+
name: 'Brown Tabby',
|
|
512
512
|
number: 1,
|
|
513
513
|
value: 'brown tabby',
|
|
514
514
|
},
|
|
515
515
|
{
|
|
516
|
-
name: '
|
|
516
|
+
name: 'Siamese',
|
|
517
517
|
number: 1,
|
|
518
518
|
value: 'siamese',
|
|
519
519
|
}]
|
|
@@ -1306,17 +1306,17 @@ For a more desktop friendly view, you can move filters into a sidebar by providi
|
|
|
1306
1306
|
Filter: CheckboxFilter,
|
|
1307
1307
|
filter: 'includesValue',
|
|
1308
1308
|
filterChoices: [{
|
|
1309
|
-
name: '
|
|
1309
|
+
name: 'Orange Tabby',
|
|
1310
1310
|
number: 2,
|
|
1311
1311
|
value: 'orange tabby',
|
|
1312
1312
|
},
|
|
1313
1313
|
{
|
|
1314
|
-
name: '
|
|
1314
|
+
name: 'Brown Tabby',
|
|
1315
1315
|
number: 2,
|
|
1316
1316
|
value: 'brown tabby',
|
|
1317
1317
|
},
|
|
1318
1318
|
{
|
|
1319
|
-
name: '
|
|
1319
|
+
name: 'Siamese',
|
|
1320
1320
|
number: 1,
|
|
1321
1321
|
value: 'siamese',
|
|
1322
1322
|
}]
|
|
@@ -1659,17 +1659,17 @@ After selecting the maximum possible number of rows, you can display an error me
|
|
|
1659
1659
|
filter: 'includesValue',
|
|
1660
1660
|
filterChoices: [
|
|
1661
1661
|
{
|
|
1662
|
-
name: '
|
|
1662
|
+
name: 'Russian white',
|
|
1663
1663
|
number: 1,
|
|
1664
1664
|
value: 'russian white',
|
|
1665
1665
|
},
|
|
1666
1666
|
{
|
|
1667
|
-
name: '
|
|
1667
|
+
name: 'Orange Tabby',
|
|
1668
1668
|
number: 2,
|
|
1669
1669
|
value: 'orange tabby',
|
|
1670
1670
|
},
|
|
1671
1671
|
{
|
|
1672
|
-
name: '
|
|
1672
|
+
name: 'Brown Tabby',
|
|
1673
1673
|
number: 3,
|
|
1674
1674
|
value: 'brown tabby',
|
|
1675
1675
|
},
|
|
@@ -31,7 +31,7 @@ function CheckboxFilter({
|
|
|
31
31
|
{filterChoices.map(({ name, number, value }) => (
|
|
32
32
|
<Form.Checkbox
|
|
33
33
|
key={`${headerBasedId}${name}`}
|
|
34
|
-
value={
|
|
34
|
+
value={value}
|
|
35
35
|
checked={checkedBoxes.includes(value)}
|
|
36
36
|
onChange={() => changeCheckbox(value)}
|
|
37
37
|
aria-label={name}
|
|
@@ -83,4 +83,35 @@ describe('<CheckboxFilter />', () => {
|
|
|
83
83
|
expect(checkbox).not.toBeChecked();
|
|
84
84
|
});
|
|
85
85
|
});
|
|
86
|
+
|
|
87
|
+
it('uses value for filtering when name and value differ', async () => {
|
|
88
|
+
const testChoice = { name: 'Test', value: 'test' };
|
|
89
|
+
const propsWithCaseDifference = {
|
|
90
|
+
column: {
|
|
91
|
+
...props.column,
|
|
92
|
+
filterChoices: [testChoice],
|
|
93
|
+
filterValue: [],
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const { rerender } = render(<CheckboxFilter {...propsWithCaseDifference} />);
|
|
98
|
+
|
|
99
|
+
const checkbox = screen.getByLabelText(testChoice.name);
|
|
100
|
+
|
|
101
|
+
await userEvent.click(checkbox);
|
|
102
|
+
|
|
103
|
+
expect(setFilterMock).toHaveBeenCalledWith([testChoice.value]);
|
|
104
|
+
|
|
105
|
+
rerender(<CheckboxFilter column={{
|
|
106
|
+
...propsWithCaseDifference.column,
|
|
107
|
+
filterValue: [testChoice.value],
|
|
108
|
+
}}
|
|
109
|
+
/>);
|
|
110
|
+
|
|
111
|
+
expect(checkbox).toBeChecked();
|
|
112
|
+
|
|
113
|
+
await userEvent.click(checkbox);
|
|
114
|
+
|
|
115
|
+
expect(setFilterMock).toHaveBeenCalledWith([]);
|
|
116
|
+
});
|
|
86
117
|
});
|