@openedx/paragon 23.14.8 → 23.15.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/Card/CardBody.d.ts +9 -0
- package/dist/Card/CardBody.js +0 -11
- package/dist/Card/CardBody.js.map +1 -1
- package/dist/Card/CardContext.d.ts +17 -0
- package/dist/Card/CardContext.js +8 -21
- package/dist/Card/CardContext.js.map +1 -1
- package/dist/Card/CardDivider.d.ts +7 -0
- package/dist/Card/CardDivider.js +2 -10
- package/dist/Card/CardDivider.js.map +1 -1
- package/dist/Card/CardFallbackDefaultImage.d.ts +1 -0
- package/dist/Card/CardFallbackDefaultImage.js +1 -0
- package/dist/Card/CardFallbackDefaultImage.js.map +1 -0
- package/dist/Card/CardGrid.d.ts +22 -0
- package/dist/Card/CardGrid.js +6 -31
- package/dist/Card/CardGrid.js.map +1 -1
- 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/DataTableContext.d.ts +3 -0
- package/dist/DataTable/DataTableContext.js.map +1 -1
- package/dist/DataTable/TableCell.d.ts +14 -0
- package/dist/DataTable/TableCell.js +0 -12
- package/dist/DataTable/TableCell.js.map +1 -1
- package/dist/DataTable/TableHeaderCell.d.ts +26 -0
- package/dist/DataTable/TableHeaderCell.js +4 -32
- package/dist/DataTable/TableHeaderCell.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/Menu/MenuItem.d.ts +17 -0
- package/dist/Menu/MenuItem.js +5 -27
- package/dist/Menu/MenuItem.js.map +1 -1
- package/dist/Menu/index.d.ts +16 -0
- package/dist/Menu/index.js +4 -24
- package/dist/Menu/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.d.ts +1 -0
- package/dist/OverflowScroll/data/constants.js +1 -2
- package/dist/OverflowScroll/data/constants.js.map +1 -0
- package/dist/PageBanner/index.d.ts +27 -0
- package/dist/PageBanner/index.js +5 -28
- package/dist/PageBanner/index.js.map +1 -1
- 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/Sheet/SheetContainer.js +30 -8
- package/dist/Sheet/SheetContainer.js.map +1 -1
- package/dist/Sheet/index.js +15 -5
- package/dist/Sheet/index.js.map +1 -1
- package/dist/Stack/index.d.ts +20 -0
- package/dist/Stack/index.js +3 -28
- package/dist/Stack/index.js.map +1 -1
- package/dist/Sticky/index.js +1 -2
- package/dist/Sticky/index.js.map +1 -1
- package/dist/Tabs/Tab.d.ts +19 -0
- package/dist/Tabs/Tab.js +0 -23
- package/dist/Tabs/Tab.js.map +1 -1
- package/dist/asInput/index.js +7 -14
- package/dist/asInput/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -2
- package/dist/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/lib/version.js +1 -2
- package/package.json +3 -3
- package/src/Card/CardBody.tsx +19 -0
- package/src/Card/CardCarousel/tests/CardCarousel.test.jsx +0 -1
- package/src/Card/{CardContext.jsx → CardContext.tsx} +24 -25
- package/src/Card/CardDivider.tsx +13 -0
- package/src/Card/{CardGrid.jsx → CardGrid.tsx} +28 -35
- 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/{TableCell.jsx → TableCell.tsx} +13 -15
- package/src/DataTable/{TableHeaderCell.jsx → TableHeaderCell.tsx} +32 -33
- 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/Menu/MenuItem.tsx +49 -0
- package/src/Menu/{index.jsx → index.tsx} +18 -27
- 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 → constants.ts} +0 -2
- package/src/PageBanner/{index.jsx → index.tsx} +27 -29
- 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/Sheet/Sheet.test.jsx +63 -3
- package/src/Sheet/SheetContainer.jsx +34 -7
- package/src/Sheet/SheetContainer.test.jsx +34 -1
- package/src/Sheet/__snapshots__/Sheet.test.jsx.snap +15 -6
- package/src/Sheet/index.jsx +12 -2
- package/src/Stack/{index.jsx → index.tsx} +22 -35
- package/src/Sticky/index.jsx +1 -1
- package/src/Tabs/{Tab.jsx → Tab.tsx} +10 -18
- 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/index.ts +1 -2
- package/src/setupTest.ts +0 -1
- package/src/utils/index.ts +0 -1
- package/src/Card/CardBody.jsx +0 -23
- package/src/Card/CardDivider.jsx +0 -18
- package/src/Menu/MenuItem.jsx +0 -57
- /package/src/Card/{CardFallbackDefaultImage.js → CardFallbackDefaultImage.ts} +0 -0
- /package/src/DataTable/{DataTableContext.jsx → DataTableContext.tsx} +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export declare const PAGE_BANNER_DISMISS_ALT_TEXT = "Dismiss";
|
|
3
|
+
export declare const VARIANTS: {
|
|
4
|
+
readonly light: "light";
|
|
5
|
+
readonly dark: "dark";
|
|
6
|
+
readonly warning: "warning";
|
|
7
|
+
readonly accentA: "accentA";
|
|
8
|
+
readonly accentB: "accentB";
|
|
9
|
+
};
|
|
10
|
+
interface PageBannerProps {
|
|
11
|
+
/** An element rendered inside the `Page Banner`. */
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
/** Boolean used to control whether `Page Banner` is dismissible. */
|
|
14
|
+
dismissible: boolean;
|
|
15
|
+
/** An element to be set as the dismiss button's alt text (preferably a translated string). */
|
|
16
|
+
dismissAltText: string;
|
|
17
|
+
/** A function to be called on dismiss of the `Page Banner`. */
|
|
18
|
+
onDismiss: () => void;
|
|
19
|
+
/** Boolean used to control whether the Page Banner shows. */
|
|
20
|
+
show: boolean;
|
|
21
|
+
/** A string designating which color variant of the `Page Banner` to display.
|
|
22
|
+
* The full list of variants can be seen [here.](https://github.com/openedx/paragon/blob/release-23.x/src/PageBanner/index.tsx)
|
|
23
|
+
*/
|
|
24
|
+
variant: keyof typeof VARIANTS;
|
|
25
|
+
}
|
|
26
|
+
declare function PageBanner({ children, dismissible, dismissAltText, onDismiss, show, variant, ...rest }: PageBannerProps): import("react/jsx-runtime").JSX.Element | null;
|
|
27
|
+
export default PageBanner;
|
package/dist/PageBanner/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
2
|
import classNames from 'classnames';
|
|
4
3
|
import { Close } from '../../icons';
|
|
5
4
|
import Icon from '../Icon';
|
|
@@ -14,11 +13,11 @@ export const VARIANTS = {
|
|
|
14
13
|
};
|
|
15
14
|
function PageBanner({
|
|
16
15
|
children,
|
|
17
|
-
dismissible,
|
|
18
|
-
dismissAltText,
|
|
19
|
-
onDismiss,
|
|
20
|
-
show,
|
|
21
|
-
variant,
|
|
16
|
+
dismissible = false,
|
|
17
|
+
dismissAltText = PAGE_BANNER_DISMISS_ALT_TEXT,
|
|
18
|
+
onDismiss = () => {},
|
|
19
|
+
show = true,
|
|
20
|
+
variant = VARIANTS.accentA,
|
|
22
21
|
...rest
|
|
23
22
|
}) {
|
|
24
23
|
if (!show) {
|
|
@@ -44,27 +43,5 @@ function PageBanner({
|
|
|
44
43
|
variant: variant === 'dark' ? 'dark' : 'black'
|
|
45
44
|
})));
|
|
46
45
|
}
|
|
47
|
-
PageBanner.propTypes = {
|
|
48
|
-
/** An element rendered inside the `Page Banner`. */
|
|
49
|
-
children: PropTypes.node,
|
|
50
|
-
/** Boolean used to control whether `Page Banner` is dismissible. */
|
|
51
|
-
dismissible: PropTypes.bool,
|
|
52
|
-
/** An element to be set as the dismiss button's alt text (preferably a translated string). */
|
|
53
|
-
dismissAltText: PropTypes.node,
|
|
54
|
-
/** A function to be called on dismiss of the `Page Banner`. */
|
|
55
|
-
onDismiss: PropTypes.func,
|
|
56
|
-
/** Boolean used to control whether the Page Banner shows. */
|
|
57
|
-
show: PropTypes.bool,
|
|
58
|
-
/** A string designating which color variant of the `Page Banner` to display */
|
|
59
|
-
variant: PropTypes.oneOf([VARIANTS.light, VARIANTS.dark, VARIANTS.warning, VARIANTS.accentA, VARIANTS.accentB])
|
|
60
|
-
};
|
|
61
|
-
PageBanner.defaultProps = {
|
|
62
|
-
children: undefined,
|
|
63
|
-
dismissible: false,
|
|
64
|
-
dismissAltText: PAGE_BANNER_DISMISS_ALT_TEXT,
|
|
65
|
-
onDismiss: () => {},
|
|
66
|
-
show: true,
|
|
67
|
-
variant: VARIANTS.accentA
|
|
68
|
-
};
|
|
69
46
|
export default PageBanner;
|
|
70
47
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","classNames","Close","Icon","IconButton","PAGE_BANNER_DISMISS_ALT_TEXT","VARIANTS","light","dark","warning","accentA","accentB","PageBanner","children","dismissible","dismissAltText","onDismiss","show","variant","rest","createElement","className","role","onClick","iconAs","alt","src","size","invertColors"],"sources":["../../src/PageBanner/index.tsx"],"sourcesContent":["import React, { ReactNode } from 'react';\nimport classNames from 'classnames';\nimport { Close } from '../../icons';\nimport Icon from '../Icon';\nimport IconButton from '../IconButton';\n\nexport const PAGE_BANNER_DISMISS_ALT_TEXT = 'Dismiss';\n\nexport const VARIANTS = {\n light: 'light',\n dark: 'dark',\n warning: 'warning',\n accentA: 'accentA',\n accentB: 'accentB',\n} as const;\n\ninterface PageBannerProps {\n /** An element rendered inside the `Page Banner`. */\n children: ReactNode;\n /** Boolean used to control whether `Page Banner` is dismissible. */\n dismissible: boolean;\n /** An element to be set as the dismiss button's alt text (preferably a translated string). */\n dismissAltText: string;\n /** A function to be called on dismiss of the `Page Banner`. */\n onDismiss: () => void;\n /** Boolean used to control whether the Page Banner shows. */\n show: boolean;\n /** A string designating which color variant of the `Page Banner` to display.\n * The full list of variants can be seen [here.](https://github.com/openedx/paragon/blob/release-23.x/src/PageBanner/index.tsx)\n */\n variant: keyof typeof VARIANTS;\n}\n\nfunction PageBanner({\n children,\n dismissible = false,\n dismissAltText = PAGE_BANNER_DISMISS_ALT_TEXT,\n onDismiss = () => {},\n show = true,\n variant = VARIANTS.accentA,\n ...rest\n}: PageBannerProps) {\n if (!show) {\n return null;\n }\n return (\n <div\n className={classNames(\n 'pgn__pageBanner-component',\n `pgn__pageBanner__${variant}`,\n )}\n role=\"alert\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n {...rest}\n >\n <div className=\"pgn__pageBanner-content\">\n { children }\n </div>\n {dismissible && (\n <span className=\"pgn__pageBanner-dismissButtonContainer\">\n <IconButton\n onClick={onDismiss}\n iconAs={Icon}\n alt={dismissAltText}\n src={Close}\n size=\"inline\"\n invertColors={variant === 'dark'}\n variant={variant === 'dark' ? 'dark' : 'black'}\n />\n </span>\n )}\n </div>\n );\n}\n\nexport default PageBanner;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAqB,OAAO;AACxC,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,KAAK,QAAQ,aAAa;AACnC,OAAOC,IAAI,MAAM,SAAS;AAC1B,OAAOC,UAAU,MAAM,eAAe;AAEtC,OAAO,MAAMC,4BAA4B,GAAG,SAAS;AAErD,OAAO,MAAMC,QAAQ,GAAG;EACtBC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,MAAM;EACZC,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE;AACX,CAAU;AAmBV,SAASC,UAAUA,CAAC;EAClBC,QAAQ;EACRC,WAAW,GAAG,KAAK;EACnBC,cAAc,GAAGV,4BAA4B;EAC7CW,SAAS,GAAGA,CAAA,KAAM,CAAC,CAAC;EACpBC,IAAI,GAAG,IAAI;EACXC,OAAO,GAAGZ,QAAQ,CAACI,OAAO;EAC1B,GAAGS;AACY,CAAC,EAAE;EAClB,IAAI,CAACF,IAAI,EAAE;IACT,OAAO,IAAI;EACb;EACA,oBACEjB,KAAA,CAAAoB,aAAA;IACEC,SAAS,EAAEpB,UAAU,CACnB,2BAA2B,EAC3B,oBAAoBiB,OAAO,EAC7B,CAAE;IACFI,IAAI,EAAC,OAAO;IACZ,aAAU,QAAQ;IAClB,eAAY,MAAM;IAAA,GACdH;EAAI,gBAERnB,KAAA,CAAAoB,aAAA;IAAKC,SAAS,EAAC;EAAyB,GACpCR,QACC,CAAC,EACLC,WAAW,iBACVd,KAAA,CAAAoB,aAAA;IAAMC,SAAS,EAAC;EAAwC,gBACtDrB,KAAA,CAAAoB,aAAA,CAAChB,UAAU;IACTmB,OAAO,EAAEP,SAAU;IACnBQ,MAAM,EAAErB,IAAK;IACbsB,GAAG,EAAEV,cAAe;IACpBW,GAAG,EAAExB,KAAM;IACXyB,IAAI,EAAC,QAAQ;IACbC,YAAY,EAAEV,OAAO,KAAK,MAAO;IACjCA,OAAO,EAAEA,OAAO,KAAK,MAAM,GAAG,MAAM,GAAG;EAAQ,CAChD,CACG,CAEL,CAAC;AAEV;AAEA,eAAeN,UAAU","ignoreList":[]}
|
|
@@ -101,16 +101,14 @@ const ProductTour = /*#__PURE__*/React.forwardRef(({
|
|
|
101
101
|
}
|
|
102
102
|
setCurrentCheckpointData(null);
|
|
103
103
|
};
|
|
104
|
-
/* eslint-disable */
|
|
105
104
|
/**
|
|
106
105
|
* Takes the final checkpoint array index value and looks for an existing onEnd callback.
|
|
107
|
-
*
|
|
108
|
-
* If an onEnd callback exist on checkpointIndex value and it is the final checkpoint
|
|
109
|
-
* in the array, the onEnd callback will be called for the parent, and individual onEnd object.
|
|
110
|
-
*
|
|
111
|
-
* @param {Integer} checkpointIndex
|
|
106
|
+
*
|
|
107
|
+
* If an onEnd callback exist on checkpointIndex value and it is the final checkpoint
|
|
108
|
+
* in the array, the onEnd callback will be called for the parent, and individual onEnd object.
|
|
109
|
+
*
|
|
110
|
+
* @param {Integer} checkpointIndex
|
|
112
111
|
*/
|
|
113
|
-
/* eslint-enable */
|
|
114
112
|
const handleEnd = checkpointIndex => {
|
|
115
113
|
setIndex(0);
|
|
116
114
|
setIsTourEnabled(false);
|
|
@@ -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,Q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AAChE,cAAc,GAAGd,IAAI,CAACmE,iBAAiB;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;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UAAU;UACnB,CAAC,CAAC;QACJ;QACA,OAAO0C,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
|
};
|
|
@@ -1,22 +1,39 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import ReactDOM from 'react-dom';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
+
import classNames from 'classnames';
|
|
4
5
|
class SheetContainer extends React.Component {
|
|
5
6
|
constructor(props) {
|
|
6
7
|
super(props);
|
|
7
8
|
this.sheetRootName = 'sheet-root';
|
|
9
|
+
this.updateRootElement();
|
|
10
|
+
}
|
|
11
|
+
componentDidUpdate(prevProps) {
|
|
12
|
+
if (prevProps.className !== this.props.className) {
|
|
13
|
+
this.updateRootElement();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
updateRootElement = () => {
|
|
17
|
+
const {
|
|
18
|
+
className
|
|
19
|
+
} = this.props;
|
|
20
|
+
|
|
21
|
+
/* istanbul ignore next */
|
|
8
22
|
if (typeof document === 'undefined') {
|
|
9
23
|
this.rootElement = null;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
let rootElement = document.getElementById(this.sheetRootName);
|
|
27
|
+
if (!rootElement) {
|
|
28
|
+
rootElement = document.createElement('div');
|
|
14
29
|
rootElement.setAttribute('id', this.sheetRootName);
|
|
15
|
-
rootElement.setAttribute('class', 'sheet-container');
|
|
16
30
|
rootElement.setAttribute('data-testid', 'sheet-container');
|
|
17
|
-
|
|
31
|
+
document.body.appendChild(rootElement);
|
|
18
32
|
}
|
|
19
|
-
|
|
33
|
+
const classes = classNames('sheet-container', className);
|
|
34
|
+
rootElement.setAttribute('class', classes);
|
|
35
|
+
this.rootElement = rootElement;
|
|
36
|
+
};
|
|
20
37
|
render() {
|
|
21
38
|
if (this.rootElement) {
|
|
22
39
|
return /*#__PURE__*/ReactDOM.createPortal(this.props.children, this.rootElement);
|
|
@@ -25,7 +42,12 @@ class SheetContainer extends React.Component {
|
|
|
25
42
|
}
|
|
26
43
|
}
|
|
27
44
|
SheetContainer.propTypes = {
|
|
28
|
-
children: PropTypes.node.isRequired
|
|
45
|
+
children: PropTypes.node.isRequired,
|
|
46
|
+
/** Additional CSS classes to apply to the sheet container */
|
|
47
|
+
className: PropTypes.string
|
|
48
|
+
};
|
|
49
|
+
SheetContainer.defaultProps = {
|
|
50
|
+
className: undefined
|
|
29
51
|
};
|
|
30
52
|
export default SheetContainer;
|
|
31
53
|
//# sourceMappingURL=SheetContainer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SheetContainer.js","names":["React","ReactDOM","PropTypes","SheetContainer","Component","constructor","props","sheetRootName","document","rootElement","getElementById","createElement","setAttribute","body","appendChild","render","createPortal","children","propTypes","node","isRequired"],"sources":["../../src/Sheet/SheetContainer.jsx"],"sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport PropTypes from 'prop-types';\n\nclass SheetContainer extends React.Component {\n constructor(props) {\n super(props);\n this.sheetRootName = 'sheet-root';\n if (
|
|
1
|
+
{"version":3,"file":"SheetContainer.js","names":["React","ReactDOM","PropTypes","classNames","SheetContainer","Component","constructor","props","sheetRootName","updateRootElement","componentDidUpdate","prevProps","className","document","rootElement","getElementById","createElement","setAttribute","body","appendChild","classes","render","createPortal","children","propTypes","node","isRequired","string","defaultProps","undefined"],"sources":["../../src/Sheet/SheetContainer.jsx"],"sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\n\nclass SheetContainer extends React.Component {\n constructor(props) {\n super(props);\n this.sheetRootName = 'sheet-root';\n this.updateRootElement();\n }\n\n componentDidUpdate(prevProps) {\n if (prevProps.className !== this.props.className) {\n this.updateRootElement();\n }\n }\n\n updateRootElement = () => {\n const { className } = this.props;\n\n /* istanbul ignore next */\n if (typeof document === 'undefined') {\n this.rootElement = null;\n return;\n }\n\n let rootElement = document.getElementById(this.sheetRootName);\n\n if (!rootElement) {\n rootElement = document.createElement('div');\n rootElement.setAttribute('id', this.sheetRootName);\n rootElement.setAttribute('data-testid', 'sheet-container');\n document.body.appendChild(rootElement);\n }\n\n const classes = classNames('sheet-container', className);\n rootElement.setAttribute('class', classes);\n\n this.rootElement = rootElement;\n };\n\n render() {\n if (this.rootElement) {\n return ReactDOM.createPortal(\n this.props.children,\n this.rootElement,\n );\n }\n return null;\n }\n}\n\nSheetContainer.propTypes = {\n children: PropTypes.node.isRequired,\n /** Additional CSS classes to apply to the sheet container */\n className: PropTypes.string,\n};\n\nSheetContainer.defaultProps = {\n className: undefined,\n};\n\nexport default SheetContainer;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,QAAQ,MAAM,WAAW;AAChC,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AAEnC,MAAMC,cAAc,SAASJ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AI;EACb;AACF;AAEAV,cAAc,CAACoB,SAAS,GAAG;EACzBD,QAAQ,EAAErB,SAAS,CAACuB,IAAI,CAACC,UAAU;EACnC;EACAd,SAAS,EAAEV,SAAS,CAACyB;AACvB,CAAC;AAEDvB,cAAc,CAACwB,YAAY,GAAG;EAC5BhB,SAAS,EAAEiB;AACb,CAAC;AAED,eAAezB,cAAc","ignoreList":[]}
|
package/dist/Sheet/index.js
CHANGED
|
@@ -23,10 +23,11 @@ class Sheet extends React.Component {
|
|
|
23
23
|
const {
|
|
24
24
|
children,
|
|
25
25
|
position,
|
|
26
|
-
variant
|
|
26
|
+
variant,
|
|
27
|
+
className
|
|
27
28
|
} = this.props;
|
|
28
29
|
return /*#__PURE__*/React.createElement("div", {
|
|
29
|
-
className: classNames('pgn__sheet-component', `pgn__sheet__${variant}`, position),
|
|
30
|
+
className: classNames('pgn__sheet-component', `pgn__sheet__${variant}`, position, className),
|
|
30
31
|
role: "alert",
|
|
31
32
|
"aria-live": "polite",
|
|
32
33
|
"aria-atomic": "true"
|
|
@@ -38,12 +39,15 @@ class Sheet extends React.Component {
|
|
|
38
39
|
const {
|
|
39
40
|
blocking,
|
|
40
41
|
show,
|
|
41
|
-
onClose
|
|
42
|
+
onClose,
|
|
43
|
+
containerClassName
|
|
42
44
|
} = this.props;
|
|
43
45
|
if (!show) {
|
|
44
46
|
return null;
|
|
45
47
|
}
|
|
46
|
-
return /*#__PURE__*/React.createElement(SheetContainer,
|
|
48
|
+
return /*#__PURE__*/React.createElement(SheetContainer, {
|
|
49
|
+
className: classNames(containerClassName)
|
|
50
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
47
51
|
className: classNames('pgn__sheet-skrim', {
|
|
48
52
|
hidden: !blocking
|
|
49
53
|
}),
|
|
@@ -60,6 +64,10 @@ Sheet.propTypes = {
|
|
|
60
64
|
blocking: PropTypes.bool,
|
|
61
65
|
/** an element rendered inside the sheet */
|
|
62
66
|
children: PropTypes.node,
|
|
67
|
+
/** A class that is appended to the sheet container element. */
|
|
68
|
+
containerClassName: PropTypes.string,
|
|
69
|
+
/** A class that is appended to the sheet element. */
|
|
70
|
+
className: PropTypes.string,
|
|
63
71
|
/** a string designating the sheet's position on the window */
|
|
64
72
|
position: PropTypes.oneOf([POSITIONS.left, POSITIONS.right, POSITIONS.top, POSITIONS.bottom]),
|
|
65
73
|
/** Boolean used to control whether the Sheet shows. */
|
|
@@ -75,7 +83,9 @@ Sheet.defaultProps = {
|
|
|
75
83
|
position: POSITIONS.bottom,
|
|
76
84
|
show: true,
|
|
77
85
|
onClose: () => {},
|
|
78
|
-
variant: VARIANTS.light
|
|
86
|
+
variant: VARIANTS.light,
|
|
87
|
+
containerClassName: undefined,
|
|
88
|
+
className: undefined
|
|
79
89
|
};
|
|
80
90
|
export default Sheet;
|
|
81
91
|
//# sourceMappingURL=index.js.map
|
package/dist/Sheet/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","PropTypes","classNames","FocusOn","SheetContainer","POSITIONS","left","right","top","bottom","VARIANTS","light","dark","Sheet","Component","constructor","props","wrapperRef","createRef","renderSheet","bind","children","position","variant","
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","PropTypes","classNames","FocusOn","SheetContainer","POSITIONS","left","right","top","bottom","VARIANTS","light","dark","Sheet","Component","constructor","props","wrapperRef","createRef","renderSheet","bind","children","position","variant","className","createElement","role","render","blocking","show","onClose","containerClassName","hidden","onClickOutside","onEscapeKey","shards","propTypes","bool","node","string","oneOf","func","defaultProps","undefined"],"sources":["../../src/Sheet/index.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { FocusOn } from 'react-focus-on';\n\nimport SheetContainer from './SheetContainer';\n\nexport const POSITIONS = {\n left: 'left',\n right: 'right',\n top: 'top',\n bottom: 'bottom',\n};\n\nexport const VARIANTS = {\n light: 'light',\n dark: 'dark',\n};\n\nclass Sheet extends React.Component {\n constructor(props) {\n super(props);\n\n this.wrapperRef = React.createRef();\n this.renderSheet = this.renderSheet.bind(this);\n }\n\n renderSheet() {\n const {\n children, position, variant, className,\n } = this.props;\n return (\n <div\n className={classNames(\n 'pgn__sheet-component',\n `pgn__sheet__${variant}`,\n position,\n className,\n )}\n role=\"alert\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n >\n <div className=\"pgn__sheet-content\">\n { children }\n </div>\n </div>\n );\n }\n\n render() {\n const {\n blocking,\n show,\n onClose,\n containerClassName,\n } = this.props;\n if (!show) {\n return null;\n }\n return (\n <SheetContainer className={classNames(containerClassName)}>\n <div\n className={classNames(\n 'pgn__sheet-skrim',\n { hidden: !blocking },\n )}\n role=\"presentation\"\n />\n <FocusOn\n onClickOutside={blocking ? () => {} : onClose}\n onEscapeKey={blocking ? () => {} : onClose}\n shards={[this.wrapperRef]}\n >\n {this.renderSheet()}\n </FocusOn>\n </SheetContainer>\n );\n }\n}\n\nSheet.propTypes = {\n /** specifies whether the sheet provides a click-blocking scrim */\n blocking: PropTypes.bool,\n /** an element rendered inside the sheet */\n children: PropTypes.node,\n /** A class that is appended to the sheet container element. */\n containerClassName: PropTypes.string,\n /** A class that is appended to the sheet element. */\n className: PropTypes.string,\n /** a string designating the sheet's position on the window */\n position: PropTypes.oneOf([\n POSITIONS.left,\n POSITIONS.right,\n POSITIONS.top,\n POSITIONS.bottom,\n ]),\n /** Boolean used to control whether the Sheet shows. */\n show: PropTypes.bool,\n /** Specifies function that controls `show` value. */\n onClose: PropTypes.func,\n /** a string designating which version of the sheet to show (light vs dark) */\n variant: PropTypes.oneOf([VARIANTS.light, VARIANTS.dark]),\n};\n\nSheet.defaultProps = {\n blocking: false,\n children: undefined,\n position: POSITIONS.bottom,\n show: true,\n onClose: () => {},\n variant: VARIANTS.light,\n containerClassName: undefined,\n className: undefined,\n};\n\nexport default Sheet;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AA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,CAAA,KAAM,CAAC,CAAC;EACjBP,OAAO,EAAEb,QAAQ,CAACC,KAAK;EACvBoB,kBAAkB,EAAEY,SAAS;EAC7BnB,SAAS,EAAEmB;AACb,CAAC;AAED,eAAe9B,KAAK","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface StackProps {
|
|
3
|
+
/** Specifies the content of the `Stack`. */
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
/** Specifies direction of the children blocks (column/row). */
|
|
6
|
+
direction?: 'horizontal' | 'vertical';
|
|
7
|
+
/**
|
|
8
|
+
* Specifies inner space between children blocks.
|
|
9
|
+
*
|
|
10
|
+
* Valid values are based on `the spacing classes`:
|
|
11
|
+
* `0, 0.5, ... 6`.
|
|
12
|
+
*/
|
|
13
|
+
gap?: number;
|
|
14
|
+
/** Specifies the order of the children. */
|
|
15
|
+
reversed?: boolean;
|
|
16
|
+
/** Specifies an additional `className` to add to the base element. */
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
declare const Stack: React.ForwardRefExoticComponent<StackProps & React.RefAttributes<HTMLDivElement>>;
|
|
20
|
+
export default Stack;
|
package/dist/Stack/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
2
|
import classNames from 'classnames';
|
|
4
|
-
const DIRECTION_VARIANTS = ['horizontal', 'vertical'];
|
|
5
3
|
const Stack = /*#__PURE__*/forwardRef(({
|
|
6
|
-
direction,
|
|
7
|
-
gap,
|
|
8
|
-
reversed,
|
|
4
|
+
direction = 'vertical',
|
|
5
|
+
gap = 0,
|
|
6
|
+
reversed = false,
|
|
9
7
|
children,
|
|
10
8
|
className,
|
|
11
9
|
...rest
|
|
@@ -14,28 +12,5 @@ const Stack = /*#__PURE__*/forwardRef(({
|
|
|
14
12
|
className: classNames(direction === 'horizontal' ? 'pgn__hstack' : 'pgn__vstack', gap ? `pgn__stack-gap--${gap}` : '', reversed ? 'pgn__stack-reversed' : '', className),
|
|
15
13
|
...rest
|
|
16
14
|
}, children));
|
|
17
|
-
Stack.propTypes = {
|
|
18
|
-
/** Specifies the content of the `Stack`. */
|
|
19
|
-
children: PropTypes.node.isRequired,
|
|
20
|
-
/** Specifies direction of the children blocks (column/row). */
|
|
21
|
-
direction: PropTypes.oneOf(DIRECTION_VARIANTS),
|
|
22
|
-
/**
|
|
23
|
-
* Specifies inner space between children blocks.
|
|
24
|
-
*
|
|
25
|
-
* Valid values are based on `the spacing classes`:
|
|
26
|
-
* `0, 0.5, ... 6`.
|
|
27
|
-
*/
|
|
28
|
-
gap: PropTypes.number,
|
|
29
|
-
/** Specifies the order of the children. */
|
|
30
|
-
reversed: PropTypes.bool,
|
|
31
|
-
/** Specifies an additional `className` to add to the base element. */
|
|
32
|
-
className: PropTypes.string
|
|
33
|
-
};
|
|
34
|
-
Stack.defaultProps = {
|
|
35
|
-
direction: 'vertical',
|
|
36
|
-
gap: 0,
|
|
37
|
-
className: undefined,
|
|
38
|
-
reversed: false
|
|
39
|
-
};
|
|
40
15
|
export default Stack;
|
|
41
16
|
//# sourceMappingURL=index.js.map
|
package/dist/Stack/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","forwardRef","
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","forwardRef","classNames","Stack","direction","gap","reversed","children","className","rest","ref","createElement"],"sources":["../../src/Stack/index.tsx"],"sourcesContent":["import React, { forwardRef, ForwardedRef } from 'react';\nimport classNames from 'classnames';\n\ninterface StackProps {\n /** Specifies the content of the `Stack`. */\n children: React.ReactNode;\n /** Specifies direction of the children blocks (column/row). */\n direction?: 'horizontal' | 'vertical';\n /**\n * Specifies inner space between children blocks.\n *\n * Valid values are based on `the spacing classes`:\n * `0, 0.5, ... 6`.\n */\n gap?: number;\n /** Specifies the order of the children. */\n reversed?: boolean;\n /** Specifies an additional `className` to add to the base element. */\n className?: string;\n}\n\nconst Stack = forwardRef(({\n direction = 'vertical',\n gap = 0,\n reversed = false,\n children,\n className,\n ...rest\n}: StackProps, ref: ForwardedRef<HTMLDivElement>) => (\n <div\n ref={ref}\n className={classNames(\n direction === 'horizontal' ? 'pgn__hstack' : 'pgn__vstack',\n gap ? `pgn__stack-gap--${gap}` : '',\n reversed ? 'pgn__stack-reversed' : '',\n className,\n )}\n {...rest}\n >\n {children}\n </div>\n));\n\nexport default Stack;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAsB,OAAO;AACvD,OAAOC,UAAU,MAAM,YAAY;AAoBnC,MAAMC,KAAK,gBAAGF,UAAU,CAAC,CAAC;EACxBG,SAAS,GAAG,UAAU;EACtBC,GAAG,GAAG,CAAC;EACPC,QAAQ,GAAG,KAAK;EAChBC,QAAQ;EACRC,SAAS;EACT,GAAGC;AACO,CAAC,EAAEC,GAAiC,kBAC9CV,KAAA,CAAAW,aAAA;EACED,GAAG,EAAEA,GAAI;EACTF,SAAS,EAAEN,UAAU,CACnBE,SAAS,KAAK,YAAY,GAAG,aAAa,GAAG,aAAa,EAC1DC,GAAG,GAAG,mBAAmBA,GAAG,EAAE,GAAG,EAAE,EACnCC,QAAQ,GAAG,qBAAqB,GAAG,EAAE,EACrCE,SACF,CAAE;EAAA,GACEC;AAAI,GAEPF,QACE,CACN,CAAC;AAEF,eAAeJ,KAAK","ignoreList":[]}
|
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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AG,EAAE,EAC7C;MAAE,oBAAoB,EAAEI;IAAS,CAAC,EAClCH,SACF,CAAE;IACFE,GAAG,EAAEK,WAAY;IAAA,GACbN;EAAI,GAEPH,QACE,CAAC;AAEV,CAAC,CAAC;AAEFH,MAAM,CAAC+B,SAAS,GAAG;EACjB;EACA5B,QAAQ,EAAEN,SAAS,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":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface TabProps {
|
|
3
|
+
/** Specifies the `Tab` navigation title. */
|
|
4
|
+
title: React.ReactNode;
|
|
5
|
+
/** Specifies notification bubble content. It appears on the top right of the `Tab`. */
|
|
6
|
+
notification?: React.ReactNode;
|
|
7
|
+
/** Specifies whether `Tab` is disabled. */
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* A unique identifier for the Component, the `eventKey` makes it distinguishable
|
|
11
|
+
* from others in a set. Similar to React's `key` prop, in that it only needs to be
|
|
12
|
+
* unique amongst the Components siblings, not globally.
|
|
13
|
+
*/
|
|
14
|
+
eventKey?: string | number;
|
|
15
|
+
/** Specifies class name to append to the base element. */
|
|
16
|
+
tabClassName?: string;
|
|
17
|
+
}
|
|
18
|
+
declare function Tab(props: TabProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export default Tab;
|
package/dist/Tabs/Tab.js
CHANGED
|
@@ -1,32 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
2
|
import BaseTab from 'react-bootstrap/Tab';
|
|
4
3
|
function Tab(props) {
|
|
5
4
|
return /*#__PURE__*/React.createElement(BaseTab, {
|
|
6
5
|
...props
|
|
7
6
|
});
|
|
8
7
|
}
|
|
9
|
-
Tab.propTypes = {
|
|
10
|
-
/** Specifies the `Tab` navigation title. */
|
|
11
|
-
title: PropTypes.node.isRequired,
|
|
12
|
-
/** Specifies notification bubble content. It appears on the top right of the `Tab`. */
|
|
13
|
-
notification: PropTypes.node,
|
|
14
|
-
/** Specifies whether `Tab` is disabled. */
|
|
15
|
-
disabled: PropTypes.bool,
|
|
16
|
-
/**
|
|
17
|
-
* A unique identifier for the Component, the `eventKey` makes it distinguishable
|
|
18
|
-
* from others in a set. Similar to React's `key` prop, in that it only needs to be
|
|
19
|
-
* unique amongst the Components siblings, not globally.
|
|
20
|
-
*/
|
|
21
|
-
eventKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
22
|
-
/** Specifies class name to append to the base element. */
|
|
23
|
-
tabClassName: PropTypes.string
|
|
24
|
-
};
|
|
25
|
-
Tab.defaultProps = {
|
|
26
|
-
notification: undefined,
|
|
27
|
-
disabled: undefined,
|
|
28
|
-
eventKey: undefined,
|
|
29
|
-
tabClassName: undefined
|
|
30
|
-
};
|
|
31
8
|
export default Tab;
|
|
32
9
|
//# sourceMappingURL=Tab.js.map
|
package/dist/Tabs/Tab.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tab.js","names":["React","
|
|
1
|
+
{"version":3,"file":"Tab.js","names":["React","BaseTab","Tab","props","createElement"],"sources":["../../src/Tabs/Tab.tsx"],"sourcesContent":["import React from 'react';\nimport BaseTab from 'react-bootstrap/Tab';\n\ninterface TabProps {\n /** Specifies the `Tab` navigation title. */\n title: React.ReactNode;\n /** Specifies notification bubble content. It appears on the top right of the `Tab`. */\n notification?: React.ReactNode;\n /** Specifies whether `Tab` is disabled. */\n disabled?: boolean;\n /**\n * A unique identifier for the Component, the `eventKey` makes it distinguishable\n * from others in a set. Similar to React's `key` prop, in that it only needs to be\n * unique amongst the Components siblings, not globally.\n */\n eventKey?: string | number;\n /** Specifies class name to append to the base element. */\n tabClassName?: string;\n}\n\nfunction Tab(props: TabProps) {\n return <BaseTab {...props} />;\n}\n\nexport default Tab;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,OAAO,MAAM,qBAAqB;AAmBzC,SAASC,GAAGA,CAACC,KAAe,EAAE;EAC5B,oBAAOH,KAAA,CAAAI,aAAA,CAACH,OAAO;IAAA,GAAKE;EAAK,CAAG,CAAC;AAC/B;AAEA,eAAeD,GAAG","ignoreList":[]}
|