@openedx/paragon 22.0.0-alpha.23 → 22.0.0-alpha.25
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/bin/paragon-scripts.js +1 -1
- package/dist/Button/index.js +2 -2
- package/dist/Button/index.js.map +1 -1
- package/dist/Button/index.scss +3 -3
- package/dist/ColorPicker/index.js +48 -18
- package/dist/ColorPicker/index.js.map +1 -1
- package/dist/Container/index.js +6 -2
- package/dist/Container/index.js.map +1 -1
- package/dist/DataTable/index.js +2 -1
- package/dist/DataTable/index.js.map +1 -1
- package/dist/DataTable/selection/BaseSelectionStatus.js +3 -2
- package/dist/DataTable/selection/BaseSelectionStatus.js.map +1 -1
- package/dist/Dropdown/index.js.map +1 -1
- package/dist/Dropzone/index.js +2 -3
- package/dist/Dropzone/index.js.map +1 -1
- package/dist/Form/FormAutosuggest.js +9 -4
- package/dist/Form/FormAutosuggest.js.map +1 -1
- package/dist/Form/FormSwitch.js +3 -0
- package/dist/Form/FormSwitch.js.map +1 -1
- package/dist/Hyperlink/index.js +7 -6
- package/dist/Hyperlink/index.js.map +1 -1
- package/dist/Icon/index.js +18 -11
- package/dist/Icon/index.js.map +1 -1
- package/dist/IconButton/index.js +1 -1
- package/dist/IconButton/index.js.map +1 -1
- package/dist/Layout/index.js.map +1 -1
- package/dist/Menu/MenuItem.js +2 -2
- package/dist/Menu/MenuItem.js.map +1 -1
- package/dist/Modal/ModalDialog.js +3 -0
- package/dist/Modal/ModalDialog.js.map +1 -1
- package/dist/Popover/index.js +8 -8
- package/dist/Popover/index.js.map +1 -1
- package/dist/ProductTour/Checkpoint.js +10 -8
- package/dist/ProductTour/Checkpoint.js.map +1 -1
- package/dist/ProductTour/messages.js +16 -0
- package/dist/SearchField/SearchFieldAdvanced.js +12 -7
- package/dist/SearchField/SearchFieldAdvanced.js.map +1 -1
- package/dist/SearchField/SearchFieldLabel.js +3 -3
- package/dist/SearchField/SearchFieldLabel.js.map +1 -1
- package/dist/SearchField/index.js +0 -1
- package/dist/SearchField/index.js.map +1 -1
- package/dist/Tabs/index.js +13 -13
- package/dist/Tabs/index.js.map +1 -1
- package/dist/core.css +8 -6
- package/dist/core.css.map +1 -1
- package/dist/core.min.css +1 -1
- package/dist/hooks/useIndexOfLastVisibleChild.js +33 -38
- package/dist/hooks/useIndexOfLastVisibleChild.js.map +1 -1
- package/dist/i18n/messages/ar.json +2 -1
- package/dist/i18n/messages/ca.json +2 -1
- package/dist/i18n/messages/es_419.json +2 -1
- package/dist/i18n/messages/es_AR.json +2 -1
- package/dist/i18n/messages/es_ES.json +2 -1
- package/dist/i18n/messages/fr.json +2 -1
- package/dist/i18n/messages/he.json +2 -1
- package/dist/i18n/messages/id.json +2 -1
- package/dist/i18n/messages/it_IT.json +2 -1
- package/dist/i18n/messages/ko_KR.json +2 -1
- package/dist/i18n/messages/pl.json +2 -1
- package/dist/i18n/messages/pt_BR.json +2 -1
- package/dist/i18n/messages/pt_PT.json +2 -1
- package/dist/i18n/messages/ru.json +2 -1
- package/dist/i18n/messages/th.json +2 -1
- package/dist/i18n/messages/tr_TR.json +2 -1
- package/dist/i18n/messages/uk.json +2 -1
- package/dist/i18n/messages/zh_CN.json +2 -1
- package/dist/light.css +11 -11
- package/dist/light.css.map +1 -1
- package/dist/light.min.css +1 -1
- package/icons/es5/RightSidebarFilled.js +15 -0
- package/icons/es5/RightSidebarOutlined.js +15 -0
- package/icons/es5/index.js +2 -0
- package/icons/jsx/RightSidebarFilled.jsx +19 -0
- package/icons/jsx/RightSidebarOutlined.jsx +19 -0
- package/icons/jsx/index.jsx +2 -0
- package/icons/svg/right_sidebar_filled.svg +3 -0
- package/icons/svg/right_sidebar_outlined.svg +3 -0
- package/lib/utils.js +23 -2
- package/package.json +3 -3
- package/src/Button/README.md +94 -68
- package/src/Button/index.jsx +2 -2
- package/src/Button/index.scss +3 -3
- package/src/ColorPicker/ColorPicker.test.jsx +24 -2
- package/src/ColorPicker/index.jsx +56 -16
- package/src/Container/index.jsx +4 -0
- package/src/DataTable/README.md +3 -3
- package/src/DataTable/index.jsx +2 -1
- package/src/DataTable/selection/BaseSelectionStatus.jsx +2 -2
- package/src/DataTable/tablefilters.mdx +3 -3
- package/src/DataTable/tests/DataTable.test.jsx +31 -0
- package/src/Dropdown/index.jsx +4 -0
- package/src/Dropzone/index.jsx +2 -3
- package/src/Form/FormAutosuggest.jsx +11 -5
- package/src/Form/FormSwitch.jsx +3 -0
- package/src/Form/form-autosuggest.mdx +80 -72
- package/src/Form/tests/FormAutosuggest.test.jsx +21 -0
- package/src/Hyperlink/index.jsx +7 -6
- package/src/Icon/index.jsx +18 -11
- package/src/IconButton/index.jsx +1 -1
- package/src/Layout/index.jsx +1 -4
- package/src/Menu/MenuItem.jsx +2 -2
- package/src/Modal/ModalDialog.jsx +3 -0
- package/src/Overlay/README.md +1 -1
- package/src/Popover/README.md +0 -1
- package/src/Popover/index.jsx +11 -11
- package/src/ProductTour/Checkpoint.jsx +9 -6
- package/src/ProductTour/messages.js +16 -0
- package/src/SearchField/SearchFieldAdvanced.jsx +12 -7
- package/src/SearchField/SearchFieldLabel.jsx +3 -3
- package/src/SearchField/index.jsx +0 -1
- package/src/SelectableBox/tests/SelectableBoxSet.test.jsx +1 -1
- package/src/Tabs/index.jsx +19 -13
- package/src/hooks/tests/useIndexOfLastVisibleChild.test.jsx +3 -3
- package/src/hooks/useIndexOfLastVisibleChild.jsx +36 -38
- package/src/hooks/useIndexOfLastVisibleChild.mdx +3 -3
- package/src/i18n/messages/ar.json +2 -1
- package/src/i18n/messages/ca.json +2 -1
- package/src/i18n/messages/es_419.json +2 -1
- package/src/i18n/messages/es_AR.json +2 -1
- package/src/i18n/messages/es_ES.json +2 -1
- package/src/i18n/messages/fr.json +2 -1
- package/src/i18n/messages/he.json +2 -1
- package/src/i18n/messages/id.json +2 -1
- package/src/i18n/messages/it_IT.json +2 -1
- package/src/i18n/messages/ko_KR.json +2 -1
- package/src/i18n/messages/pl.json +2 -1
- package/src/i18n/messages/pt_BR.json +2 -1
- package/src/i18n/messages/pt_PT.json +2 -1
- package/src/i18n/messages/ru.json +2 -1
- package/src/i18n/messages/th.json +2 -1
- package/src/i18n/messages/tr_TR.json +2 -1
- package/src/i18n/messages/uk.json +2 -1
- package/src/i18n/messages/zh_CN.json +2 -1
- package/styles/css/core/variables.css +5 -3
- package/styles/css/themes/light/variables.css +11 -11
- package/tokens/src/core/components/Button/core.json +8 -4
- package/tokens/src/themes/light/alias/color.json +10 -10
package/dist/Dropzone/index.js
CHANGED
|
@@ -177,8 +177,7 @@ function Dropzone(_ref) {
|
|
|
177
177
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
178
178
|
"data-testid": "dropzone-container"
|
|
179
179
|
}, getRootProps({
|
|
180
|
-
className: classNames('pgn__dropzone', {
|
|
181
|
-
className,
|
|
180
|
+
className: classNames('pgn__dropzone', className, {
|
|
182
181
|
'pgn__dropzone-validation-error': isMultipleDragged || errors.length > 0 || isDragReject,
|
|
183
182
|
'pgn__dropzone-active': isDragActive && !isDragReject
|
|
184
183
|
})
|
|
@@ -262,7 +261,7 @@ Dropzone.propTypes = {
|
|
|
262
261
|
*/
|
|
263
262
|
validator: PropTypes.func,
|
|
264
263
|
/** A component to display initial state of the `Dropzone`. */
|
|
265
|
-
inputComponent: PropTypes.oneOfType([PropTypes.
|
|
264
|
+
inputComponent: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node])
|
|
266
265
|
};
|
|
267
266
|
export default Dropzone;
|
|
268
267
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useState","PropTypes","classNames","useDropzone","ErrorCode","fromEvent","useIntl","DragError","GenericError","UploadProgress","DefaultContent","messages","getTypesString","isMultipleTypes","formatBytes","Dropzone","_ref","className","accept","minSize","maxSize","validator","errorMessages","progressVariant","inputComponent","onProcessUpload","onUploadProgress","onUploadCancel","props","_objectWithoutProperties","_excluded","isMultipleDragged","setIsMultipleDragged","errors","setErrors","progress","setProgress","fileName","setFileName","undefined","controller","setController","intl","uploadError","uploadErrorMsg","invalidSizeLess","invalidSizeLessMsg","invalidSizeMore","invalidSizeMoreMsg","invalidType","invalidTypeMsg","multipleDragged","multipleDraggedMsg","onDragEnter","e","files","length","onDragLeave","onDropRejected","map","error","code","FileTooLarge","formatMessage","size","FileTooSmall","FileInvalidType","count","typeString","unexpectedValidationError","handleProgressUpload","progressEvent","percentValue","Math","round","loaded","total","handleUploadError","processUpload","fileData","newController","AbortController","requestConfig","signal","handleError","onDropAccepted","file","customValidationError","formData","FormData","append","name","handleUploadCancel","abort","getRootProps","getInputProps","isDragActive","isDragReject","multiple","maxFiles","disabled","renderContent","createElement","message","Fragment","errorMsgs","variant","percent","onCancel","_extends","defaultProps","Infinity","propTypes","string","objectOf","arrayOf","number","func","isRequired","shape","oneOfType","element","oneOf","node"],"sources":["../../src/Dropzone/index.jsx"],"sourcesContent":["import React, { useState } from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { useDropzone, ErrorCode } from 'react-dropzone';\nimport { fromEvent } from 'file-selector';\nimport { useIntl } from 'react-intl';\n\nimport DragError from './DragError';\nimport GenericError from './GenericError';\nimport UploadProgress from './UploadProgress';\nimport DefaultContent from './DefaultContent';\nimport messages from './messages';\nimport { getTypesString, isMultipleTypes, formatBytes } from './utils';\n\nfunction Dropzone({\n className, accept, minSize, maxSize, validator,\n errorMessages, progressVariant, inputComponent,\n onProcessUpload, onUploadProgress, onUploadCancel,\n ...props\n}) {\n const [isMultipleDragged, setIsMultipleDragged] = useState(false);\n const [errors, setErrors] = useState([]);\n const [progress, setProgress] = useState(0);\n const [fileName, setFileName] = useState(undefined);\n const [controller, setController] = useState(undefined);\n const intl = useIntl();\n\n const {\n uploadError: uploadErrorMsg,\n invalidSizeLess: invalidSizeLessMsg,\n invalidSizeMore: invalidSizeMoreMsg,\n invalidType: invalidTypeMsg,\n multipleDragged: multipleDraggedMsg,\n } = errorMessages;\n\n const onDragEnter = async (e) => {\n if (errors) {\n setErrors([]);\n }\n const files = await fromEvent(e);\n if (files && files.length > 1) {\n setIsMultipleDragged(true);\n }\n };\n\n const onDragLeave = () => {\n if (isMultipleDragged) {\n setIsMultipleDragged(false);\n }\n };\n\n const onDropRejected = (files) => {\n if (!isMultipleDragged) {\n setErrors(files[0].errors.map(error => {\n switch (error.code) {\n case ErrorCode.FileTooLarge:\n return invalidSizeMoreMsg || intl.formatMessage(messages.invalidSizeMore, { size: formatBytes(maxSize) });\n case ErrorCode.FileTooSmall:\n return invalidSizeLessMsg || intl.formatMessage(messages.invalidSizeLess, { size: formatBytes(minSize) });\n case ErrorCode.FileInvalidType:\n return invalidTypeMsg || intl.formatMessage(\n messages.invalidType,\n { count: isMultipleTypes(accept) ? 2 : 1, typeString: getTypesString(accept) },\n );\n default:\n return intl.formatMessage(messages.unexpectedValidationError);\n }\n }));\n } else {\n setIsMultipleDragged(false);\n }\n };\n\n const handleProgressUpload = (progressEvent) => {\n const percentValue = Math.round((progressEvent.loaded * 100) / progressEvent.total);\n setProgress(percentValue);\n onUploadProgress(percentValue, progressEvent);\n };\n\n const handleUploadError = (error) => {\n // check if request has been canceled before treating the exception as an upload error\n if (error.code !== 'ERR_CANCELED') {\n setProgress(0);\n setErrors([uploadErrorMsg || intl.formatMessage(messages.uploadError)]);\n }\n };\n\n const processUpload = (fileData) => {\n const newController = new AbortController();\n setController(newController);\n\n const requestConfig = {\n onUploadProgress: handleProgressUpload,\n signal: newController.signal,\n };\n\n onProcessUpload({\n fileData,\n requestConfig,\n handleError: handleUploadError,\n });\n };\n\n const onDropAccepted = async (files) => {\n const file = files[0];\n if (validator) {\n const customValidationError = await validator(file);\n if (customValidationError) {\n setErrors([customValidationError]);\n return;\n }\n }\n\n if (errors) {\n setErrors([]);\n }\n\n const formData = new FormData();\n formData.append('file', file);\n setFileName(file.name);\n\n processUpload(formData);\n };\n\n const handleUploadCancel = () => {\n controller.abort();\n setProgress(0);\n onUploadCancel();\n };\n\n const {\n getRootProps,\n getInputProps,\n isDragActive,\n isDragReject,\n } = useDropzone({\n multiple: false,\n maxFiles: 1,\n maxSize,\n minSize,\n onDragLeave,\n onDragEnter,\n onDropRejected,\n onDropAccepted,\n accept,\n disabled: progress && progress !== 100,\n });\n\n const renderContent = () => {\n if (isMultipleDragged) {\n return <DragError message={multipleDraggedMsg || intl.formatMessage(messages.multipleDragged)} />;\n }\n\n if (errors.length > 0) {\n return (\n <>\n <GenericError errorMsgs={errors} />\n {inputComponent || <DefaultContent minSize={minSize} maxSize={maxSize} accept={accept} />}\n </>\n );\n }\n\n if (progress && progress !== 100) {\n return (\n <UploadProgress\n variant={progressVariant}\n percent={progress}\n name={fileName}\n onCancel={handleUploadCancel}\n />\n );\n }\n\n return inputComponent || <DefaultContent minSize={minSize} maxSize={maxSize} accept={accept} />;\n };\n\n return (\n <div\n data-testid=\"dropzone-container\"\n {...getRootProps({\n className: classNames('pgn__dropzone', {\n className,\n 'pgn__dropzone-validation-error': isMultipleDragged || errors.length > 0 || isDragReject,\n 'pgn__dropzone-active': isDragActive && !isDragReject,\n }),\n })}\n {...props}\n >\n <input {...getInputProps()} />\n <div className=\"d-flex flex-column justify-content-around align-items-center w-100\">\n {renderContent()}\n </div>\n </div>\n );\n}\n\nDropzone.defaultProps = {\n className: undefined,\n accept: undefined,\n maxSize: Infinity,\n minSize: 0,\n onUploadProgress: () => {},\n onUploadCancel: () => {},\n errorMessages: {\n invalidType: undefined,\n invalidSizeLess: undefined,\n invalidSizeMore: undefined,\n multipleDragged: undefined,\n uploadError: undefined,\n },\n progressVariant: 'spinner',\n validator: undefined,\n inputComponent: undefined,\n};\n\nDropzone.propTypes = {\n /** Specifies class name to append to the base element. */\n className: PropTypes.string,\n /**\n * Set accepted file types.\n * This should be an object with the keys set to the\n * [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types)\n * and the values to an array of file extensions.\n */\n accept: PropTypes.objectOf(PropTypes.arrayOf(PropTypes.string)),\n /** Maximum file size (in bytes). */\n maxSize: PropTypes.number,\n /** Minimum file size (in bytes). */\n minSize: PropTypes.number,\n /**\n * A callback fired each time an upload progress event happens,\n * receives (percentageUploaded, progressEvent) as arguments.\n */\n onUploadProgress: PropTypes.func,\n /** A callback fired upon successful upload, receives Response object as a single argument. */\n onUploadCancel: PropTypes.func,\n /**\n * A function responsible for uploading the file.\n * Receives following object as its only argument\n * {\n * @param {object} fileData - Metadata about the uploaded file.\n * @param {object} requestConfig - Config to pass to `axios` call.\n * @param {function} handleError - Function to communicate to `Dropzone` that file upload resulted in failure,\n * expects `Error` object to be passed as its only argument.\n * }\n */\n onProcessUpload: PropTypes.func.isRequired,\n /**\n * An object containing error messages, following are supported:\n * 1) invalidType - A message to display when file of invalid type is dropped into `Dropzone`.\n * Defaults to 'The file type must be {filType} file / one of {fileTypes} files.'.\n * 2) invalidSizeLess - A message to display when file of size less than minSize value is dropped into `Dropzone`.\n * Defaults to 'File must be larger than {minSize}.'.\n * 3) invalidSizeMore - A message to display when file of size greater than maxSize value is dropped into `Dropzone`.\n * Defaults to 'File must be less than {maxSize}.'.\n * 4) multipleDragged - A message to display when multiple files are dragged over `Dropzone`.\n * 5) uploadError - A message to display in case upload results in an error\n */\n errorMessages: PropTypes.shape({\n invalidType: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n invalidSizeLess: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n invalidSizeMore: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n multipleDragged: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n uploadError: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n }),\n /** Specifies how the upload progress should be displayed, component shows either spinner or a progress bar. */\n progressVariant: PropTypes.oneOf(['spinner', 'bar']),\n /**\n * Custom validation function, receives `File` object as its only argument.\n * Note that this function will be invoked as a last validation step before beginning an upload process.\n */\n validator: PropTypes.func,\n /** A component to display initial state of the `Drop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OAAO,CAAC,CAAC;IAC3E1E,eAAe,EAAE9C,SAAS,CAACuH,SAAS,CAAC,CAACvH,SAAS,CAACgH,MAAM,EAAEhH,SAAS,CAACwH,OAAO,CAAC,CAAC;IAC3EtE,eAAe,EAAElD,SAAS,CAACuH,SAAS,CAAC,CAACvH,SAAS,CAACgH,MAAM,EAAEhH,SAAS,CAACwH,OAAO,CAAC,CAAC;IAC3E9E,WAAW,EAAE1C,SAAS,CAACuH,SAAS,CAAC,CAACvH,SAAS,CAACgH,MAAM,EAAEhH,SAAS,CAACwH,OAAO,CAAC;EACxE,CAAC,CAAC;EACF;EACAlG,eAAe,EAAEtB,SAAS,CAACyH,KAAK,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;EACpD;AACF;AACA;AACA;EACErG,SAAS,EAAEpB,SAAS,CAACoH,IAAI;EACzB;EACA7F,cAAc,EAAEvB,SAAS,CAACuH,SAAS,CAAC,CAACvH,SAAS,CAACoH,IAAI,EAAEpH,SAAS,CAAC0H,IAAI,CAAC;AACtE,CAAC;AAED,eAAe5G,QAAQ"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useState","PropTypes","classNames","useDropzone","ErrorCode","fromEvent","useIntl","DragError","GenericError","UploadProgress","DefaultContent","messages","getTypesString","isMultipleTypes","formatBytes","Dropzone","_ref","className","accept","minSize","maxSize","validator","errorMessages","progressVariant","inputComponent","onProcessUpload","onUploadProgress","onUploadCancel","props","_objectWithoutProperties","_excluded","isMultipleDragged","setIsMultipleDragged","errors","setErrors","progress","setProgress","fileName","setFileName","undefined","controller","setController","intl","uploadError","uploadErrorMsg","invalidSizeLess","invalidSizeLessMsg","invalidSizeMore","invalidSizeMoreMsg","invalidType","invalidTypeMsg","multipleDragged","multipleDraggedMsg","onDragEnter","e","files","length","onDragLeave","onDropRejected","map","error","code","FileTooLarge","formatMessage","size","FileTooSmall","FileInvalidType","count","typeString","unexpectedValidationError","handleProgressUpload","progressEvent","percentValue","Math","round","loaded","total","handleUploadError","processUpload","fileData","newController","AbortController","requestConfig","signal","handleError","onDropAccepted","file","customValidationError","formData","FormData","append","name","handleUploadCancel","abort","getRootProps","getInputProps","isDragActive","isDragReject","multiple","maxFiles","disabled","renderContent","createElement","message","Fragment","errorMsgs","variant","percent","onCancel","_extends","defaultProps","Infinity","propTypes","string","objectOf","arrayOf","number","func","isRequired","shape","oneOfType","element","oneOf","elementType","node"],"sources":["../../src/Dropzone/index.jsx"],"sourcesContent":["import React, { useState } from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { useDropzone, ErrorCode } from 'react-dropzone';\nimport { fromEvent } from 'file-selector';\nimport { useIntl } from 'react-intl';\n\nimport DragError from './DragError';\nimport GenericError from './GenericError';\nimport UploadProgress from './UploadProgress';\nimport DefaultContent from './DefaultContent';\nimport messages from './messages';\nimport { getTypesString, isMultipleTypes, formatBytes } from './utils';\n\nfunction Dropzone({\n className, accept, minSize, maxSize, validator,\n errorMessages, progressVariant, inputComponent,\n onProcessUpload, onUploadProgress, onUploadCancel,\n ...props\n}) {\n const [isMultipleDragged, setIsMultipleDragged] = useState(false);\n const [errors, setErrors] = useState([]);\n const [progress, setProgress] = useState(0);\n const [fileName, setFileName] = useState(undefined);\n const [controller, setController] = useState(undefined);\n const intl = useIntl();\n\n const {\n uploadError: uploadErrorMsg,\n invalidSizeLess: invalidSizeLessMsg,\n invalidSizeMore: invalidSizeMoreMsg,\n invalidType: invalidTypeMsg,\n multipleDragged: multipleDraggedMsg,\n } = errorMessages;\n\n const onDragEnter = async (e) => {\n if (errors) {\n setErrors([]);\n }\n const files = await fromEvent(e);\n if (files && files.length > 1) {\n setIsMultipleDragged(true);\n }\n };\n\n const onDragLeave = () => {\n if (isMultipleDragged) {\n setIsMultipleDragged(false);\n }\n };\n\n const onDropRejected = (files) => {\n if (!isMultipleDragged) {\n setErrors(files[0].errors.map(error => {\n switch (error.code) {\n case ErrorCode.FileTooLarge:\n return invalidSizeMoreMsg || intl.formatMessage(messages.invalidSizeMore, { size: formatBytes(maxSize) });\n case ErrorCode.FileTooSmall:\n return invalidSizeLessMsg || intl.formatMessage(messages.invalidSizeLess, { size: formatBytes(minSize) });\n case ErrorCode.FileInvalidType:\n return invalidTypeMsg || intl.formatMessage(\n messages.invalidType,\n { count: isMultipleTypes(accept) ? 2 : 1, typeString: getTypesString(accept) },\n );\n default:\n return intl.formatMessage(messages.unexpectedValidationError);\n }\n }));\n } else {\n setIsMultipleDragged(false);\n }\n };\n\n const handleProgressUpload = (progressEvent) => {\n const percentValue = Math.round((progressEvent.loaded * 100) / progressEvent.total);\n setProgress(percentValue);\n onUploadProgress(percentValue, progressEvent);\n };\n\n const handleUploadError = (error) => {\n // check if request has been canceled before treating the exception as an upload error\n if (error.code !== 'ERR_CANCELED') {\n setProgress(0);\n setErrors([uploadErrorMsg || intl.formatMessage(messages.uploadError)]);\n }\n };\n\n const processUpload = (fileData) => {\n const newController = new AbortController();\n setController(newController);\n\n const requestConfig = {\n onUploadProgress: handleProgressUpload,\n signal: newController.signal,\n };\n\n onProcessUpload({\n fileData,\n requestConfig,\n handleError: handleUploadError,\n });\n };\n\n const onDropAccepted = async (files) => {\n const file = files[0];\n if (validator) {\n const customValidationError = await validator(file);\n if (customValidationError) {\n setErrors([customValidationError]);\n return;\n }\n }\n\n if (errors) {\n setErrors([]);\n }\n\n const formData = new FormData();\n formData.append('file', file);\n setFileName(file.name);\n\n processUpload(formData);\n };\n\n const handleUploadCancel = () => {\n controller.abort();\n setProgress(0);\n onUploadCancel();\n };\n\n const {\n getRootProps,\n getInputProps,\n isDragActive,\n isDragReject,\n } = useDropzone({\n multiple: false,\n maxFiles: 1,\n maxSize,\n minSize,\n onDragLeave,\n onDragEnter,\n onDropRejected,\n onDropAccepted,\n accept,\n disabled: progress && progress !== 100,\n });\n\n const renderContent = () => {\n if (isMultipleDragged) {\n return <DragError message={multipleDraggedMsg || intl.formatMessage(messages.multipleDragged)} />;\n }\n\n if (errors.length > 0) {\n return (\n <>\n <GenericError errorMsgs={errors} />\n {inputComponent || <DefaultContent minSize={minSize} maxSize={maxSize} accept={accept} />}\n </>\n );\n }\n\n if (progress && progress !== 100) {\n return (\n <UploadProgress\n variant={progressVariant}\n percent={progress}\n name={fileName}\n onCancel={handleUploadCancel}\n />\n );\n }\n\n return inputComponent || <DefaultContent minSize={minSize} maxSize={maxSize} accept={accept} />;\n };\n\n return (\n <div\n data-testid=\"dropzone-container\"\n {...getRootProps({\n className: classNames('pgn__dropzone', className, {\n 'pgn__dropzone-validation-error': isMultipleDragged || errors.length > 0 || isDragReject,\n 'pgn__dropzone-active': isDragActive && !isDragReject,\n }),\n })}\n {...props}\n >\n <input {...getInputProps()} />\n <div className=\"d-flex flex-column justify-content-around align-items-center w-100\">\n {renderContent()}\n </div>\n </div>\n );\n}\n\nDropzone.defaultProps = {\n className: undefined,\n accept: undefined,\n maxSize: Infinity,\n minSize: 0,\n onUploadProgress: () => {},\n onUploadCancel: () => {},\n errorMessages: {\n invalidType: undefined,\n invalidSizeLess: undefined,\n invalidSizeMore: undefined,\n multipleDragged: undefined,\n uploadError: undefined,\n },\n progressVariant: 'spinner',\n validator: undefined,\n inputComponent: undefined,\n};\n\nDropzone.propTypes = {\n /** Specifies class name to append to the base element. */\n className: PropTypes.string,\n /**\n * Set accepted file types.\n * This should be an object with the keys set to the\n * [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types)\n * and the values to an array of file extensions.\n */\n accept: PropTypes.objectOf(PropTypes.arrayOf(PropTypes.string)),\n /** Maximum file size (in bytes). */\n maxSize: PropTypes.number,\n /** Minimum file size (in bytes). */\n minSize: PropTypes.number,\n /**\n * A callback fired each time an upload progress event happens,\n * receives (percentageUploaded, progressEvent) as arguments.\n */\n onUploadProgress: PropTypes.func,\n /** A callback fired upon successful upload, receives Response object as a single argument. */\n onUploadCancel: PropTypes.func,\n /**\n * A function responsible for uploading the file.\n * Receives following object as its only argument\n * {\n * @param {object} fileData - Metadata about the uploaded file.\n * @param {object} requestConfig - Config to pass to `axios` call.\n * @param {function} handleError - Function to communicate to `Dropzone` that file upload resulted in failure,\n * expects `Error` object to be passed as its only argument.\n * }\n */\n onProcessUpload: PropTypes.func.isRequired,\n /**\n * An object containing error messages, following are supported:\n * 1) invalidType - A message to display when file of invalid type is dropped into `Dropzone`.\n * Defaults to 'The file type must be {filType} file / one of {fileTypes} files.'.\n * 2) invalidSizeLess - A message to display when file of size less than minSize value is dropped into `Dropzone`.\n * Defaults to 'File must be larger than {minSize}.'.\n * 3) invalidSizeMore - A message to display when file of size greater than maxSize value is dropped into `Dropzone`.\n * Defaults to 'File must be less than {maxSize}.'.\n * 4) multipleDragged - A message to display when multiple files are dragged over `Dropzone`.\n * 5) uploadError - A message to display in case upload results in an error\n */\n errorMessages: PropTypes.shape({\n invalidType: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n invalidSizeLess: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n invalidSizeMore: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n multipleDragged: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n uploadError: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n }),\n /** Specifies how the upload progress should be displayed, component shows either spinner or a progress bar. */\n progressVariant: PropTypes.oneOf(['spinner', 'bar']),\n /**\n * Custom validation function, receives `File` object as its only argument.\n * Note that this function will be invoked as a last validation step before beginning an upload process.\n */\n validator: PropTypes.func,\n /** A component to display initial state of the `Dropzone`. */\n inputComponent: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]),\n};\n\nexport default Dropzone;\n"],"mappings":";;;;AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,WAAW,EAAEC,SAAS,QAAQ,gBAAgB;AACvD,SAASC,SAAS,QAAQ,eAAe;AACzC,SAASC,OAAO,QAAQ,YAAY;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,SAAS,CAACgH,MAAM,EAAEhH,SAAS,CAACwH,OAAO,CAAC;EACxE,CAAC,CAAC;EACF;EACAlG,eAAe,EAAEtB,SAAS,CAACyH,KAAK,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;EACpD;AACF;AACA;AACA;EACErG,SAAS,EAAEpB,SAAS,CAACoH,IAAI;EACzB;EACA7F,cAAc,EAAEvB,SAAS,CAACuH,SAAS,CAAC,CAACvH,SAAS,CAAC0H,WAAW,EAAE1H,SAAS,CAAC2H,IAAI,CAAC;AAC7E,CAAC;AAED,eAAe7G,QAAQ"}
|
|
@@ -14,7 +14,7 @@ import { v4 as uuidv4 } from 'uuid';
|
|
|
14
14
|
import { useIntl } from 'react-intl';
|
|
15
15
|
import { KeyboardArrowUp, KeyboardArrowDown } from '../../icons';
|
|
16
16
|
import Icon from '../Icon';
|
|
17
|
-
import
|
|
17
|
+
import { FormGroupContextProvider, useFormGroupContext } from './FormGroupContext';
|
|
18
18
|
import FormControl from './FormControl';
|
|
19
19
|
import FormControlFeedback from './FormControlFeedback';
|
|
20
20
|
import IconButton from '../IconButton';
|
|
@@ -198,6 +198,10 @@ function FormAutosuggest(_ref) {
|
|
|
198
198
|
}
|
|
199
199
|
setDisplayValue(e.target.value);
|
|
200
200
|
};
|
|
201
|
+
const {
|
|
202
|
+
getControlProps
|
|
203
|
+
} = useFormGroupContext();
|
|
204
|
+
const controlProps = getControlProps(props);
|
|
201
205
|
return /*#__PURE__*/React.createElement("div", {
|
|
202
206
|
className: "pgn__form-autosuggest__wrapper",
|
|
203
207
|
ref: parentRef
|
|
@@ -205,7 +209,8 @@ function FormAutosuggest(_ref) {
|
|
|
205
209
|
"aria-live": "assertive",
|
|
206
210
|
className: "sr-only",
|
|
207
211
|
"data-testid": "autosuggest-screen-reader-options-count"
|
|
208
|
-
}, `${state.dropDownItems.length} options found`), /*#__PURE__*/React.createElement(
|
|
212
|
+
}, `${state.dropDownItems.length} options found`), /*#__PURE__*/React.createElement(FormGroupContextProvider, {
|
|
213
|
+
controlId: controlProps.id,
|
|
209
214
|
isInvalid: !!state.errorMessage
|
|
210
215
|
}, /*#__PURE__*/React.createElement(FormControl, _extends({
|
|
211
216
|
ref: formControlRef,
|
|
@@ -221,11 +226,11 @@ function FormAutosuggest(_ref) {
|
|
|
221
226
|
onClick: handleClick,
|
|
222
227
|
trailingElement: iconToggle,
|
|
223
228
|
"data-testid": "autosuggest-textbox-input"
|
|
224
|
-
},
|
|
229
|
+
}, controlProps)), helpMessage && !state.errorMessage && /*#__PURE__*/React.createElement(FormControlFeedback, {
|
|
225
230
|
type: "default"
|
|
226
231
|
}, helpMessage), state.errorMessage && /*#__PURE__*/React.createElement(FormControlFeedback, {
|
|
227
232
|
type: "invalid",
|
|
228
|
-
"feedback-for":
|
|
233
|
+
"feedback-for": controlProps.name
|
|
229
234
|
}, errorMessageText)), /*#__PURE__*/React.createElement("ul", {
|
|
230
235
|
id: "pgn__form-autosuggest__dropdown-box",
|
|
231
236
|
className: "pgn__form-autosuggest__dropdown",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormAutosuggest.js","names":["React","useEffect","useState","useRef","PropTypes","v4","uuidv4","useIntl","KeyboardArrowUp","KeyboardArrowDown","Icon","FormGroup","FormControl","FormControlFeedback","IconButton","Spinner","useArrowKeyNavigation","messages","FormAutosuggest","_ref","children","arrowKeyNavigationSelector","ignoredArrowKeysNames","screenReaderText","value","isLoading","errorMessageText","onChange","onSelected","helpMessage","props","_objectWithoutProperties","_excluded","intl","formControlRef","parentRef","selectors","ignoredKeys","isMenuClosed","setIsMenuClosed","isActive","setIsActive","state","setState","displayValue","errorMessage","dropDownItems","activeMenuItemId","setActiveMenuItemId","handleMenuItemFocus","menuItemId","handleItemClick","e","onClick","clickedValue","currentTarget","getAttribute","prevState","_objectSpread","getItems","strToFind","arguments","length","undefined","childrenOpt","Children","map","child","_child$props","rest","_excluded2","cloneElement","id","onFocus","filter","opt","toLowerCase","includes","handleExpand","newState","iconToggle","createElement","className","tabindex","src","iconAs","size","variant","alt","formatMessage","iconButtonOpened","iconButtonClosed","leaveControl","handleDocumentClick","current","contains","target","keyDownHandler","key","preventDefault","focus","document","addEventListener","removeEventListener","setDisplayValue","itemValue","optValue","forEach","push","normalized","find","o","handleClick","handleOnChange","findStr","filteredItems","ref","isInvalid","_extends","toString","role","autoComplete","trailingElement","type","name","animation","defaultProps","floatingLabel","placeholder","readOnly","propTypes","string","arrayOf","bool","func","node"],"sources":["../../src/Form/FormAutosuggest.jsx"],"sourcesContent":["import React, {\n useEffect, useState, useRef,\n} from 'react';\nimport PropTypes from 'prop-types';\nimport { v4 as uuidv4 } from 'uuid';\nimport { useIntl } from 'react-intl';\nimport { KeyboardArrowUp, KeyboardArrowDown } from '../../icons';\nimport Icon from '../Icon';\nimport FormGroup from './FormGroup';\nimport FormControl from './FormControl';\nimport FormControlFeedback from './FormControlFeedback';\nimport IconButton from '../IconButton';\nimport Spinner from '../Spinner';\nimport useArrowKeyNavigation from '../hooks/useArrowKeyNavigation';\nimport messages from './messages';\n\nfunction FormAutosuggest({\n children,\n arrowKeyNavigationSelector,\n ignoredArrowKeysNames,\n screenReaderText,\n value,\n isLoading,\n errorMessageText,\n onChange,\n onSelected,\n helpMessage,\n ...props\n}) {\n const intl = useIntl();\n const formControlRef = useRef();\n const parentRef = useArrowKeyNavigation({\n selectors: arrowKeyNavigationSelector,\n ignoredKeys: ignoredArrowKeysNames,\n });\n const [isMenuClosed, setIsMenuClosed] = useState(true);\n const [isActive, setIsActive] = useState(false);\n const [state, setState] = useState({\n displayValue: value || '',\n errorMessage: '',\n dropDownItems: [],\n });\n const [activeMenuItemId, setActiveMenuItemId] = useState(null);\n\n const handleMenuItemFocus = (menuItemId) => {\n setActiveMenuItemId(menuItemId);\n };\n\n const handleItemClick = (e, onClick) => {\n const clickedValue = e.currentTarget.getAttribute('data-value');\n\n if (onSelected && clickedValue !== value) {\n onSelected(clickedValue);\n }\n\n setState(prevState => ({\n ...prevState,\n dropDownItems: [],\n displayValue: clickedValue,\n }));\n\n setIsMenuClosed(true);\n\n if (onClick) {\n onClick(e);\n }\n };\n\n function getItems(strToFind = '') {\n let childrenOpt = React.Children.map(children, (child) => {\n // eslint-disable-next-line no-shadow\n const { children, onClick, ...rest } = child.props;\n const menuItemId = uuidv4();\n\n return React.cloneElement(child, {\n ...rest,\n children,\n 'data-value': children,\n onClick: (e) => handleItemClick(e, onClick),\n id: menuItemId,\n onFocus: () => handleMenuItemFocus(menuItemId),\n });\n });\n\n if (strToFind.length > 0) {\n childrenOpt = childrenOpt\n .filter((opt) => (opt.props.children.toLowerCase().includes(strToFind.toLowerCase())));\n }\n\n return childrenOpt;\n }\n\n const handleExpand = () => {\n setIsMenuClosed(!isMenuClosed);\n\n const newState = {\n dropDownItems: [],\n };\n\n if (isMenuClosed) {\n setIsActive(true);\n newState.dropDownItems = getItems(state.displayValue);\n newState.errorMessage = '';\n }\n\n setState(prevState => ({\n ...prevState,\n ...newState,\n }));\n };\n\n const iconToggle = (\n <IconButton\n className=\"pgn__form-autosuggest__icon-button\"\n data-testid=\"autosuggest-iconbutton\"\n tabindex=\"-1\"\n src={isMenuClosed ? KeyboardArrowDown : KeyboardArrowUp}\n iconAs={Icon}\n size=\"sm\"\n variant=\"secondary\"\n alt={isMenuClosed\n ? intl.formatMessage(messages.iconButtonOpened)\n : intl.formatMessage(messages.iconButtonClosed)}\n onClick={(e) => handleExpand(e, isMenuClosed)}\n />\n );\n\n const leaveControl = () => {\n setIsActive(false);\n\n setState(prevState => ({\n ...prevState,\n dropDownItems: [],\n errorMessage: !state.displayValue ? errorMessageText : '',\n }));\n\n setIsMenuClosed(true);\n };\n\n const handleDocumentClick = (e) => {\n if (parentRef.current && !parentRef.current.contains(e.target) && isActive) {\n leaveControl();\n }\n };\n\n const keyDownHandler = e => {\n if (e.key === 'Escape' && isActive) {\n e.preventDefault();\n\n if (formControlRef) {\n formControlRef.current.focus();\n }\n\n setState(prevState => ({\n ...prevState,\n dropDownItems: [],\n }));\n\n setIsMenuClosed(true);\n }\n if (e.key === 'Tab' && isActive) {\n leaveControl();\n }\n };\n\n useEffect(() => {\n document.addEventListener('keydown', keyDownHandler);\n document.addEventListener('click', handleDocumentClick, true);\n\n return () => {\n document.removeEventListener('click', handleDocumentClick, true);\n document.removeEventListener('keydown', keyDownHandler);\n };\n });\n\n useEffect(() => {\n if (value || value === '') {\n setState(prevState => ({\n ...prevState,\n displayValue: value,\n }));\n }\n }, [value]);\n\n const setDisplayValue = (itemValue) => {\n const optValue = [];\n\n children.forEach(opt => {\n optValue.push(opt.props.children);\n });\n\n const normalized = itemValue.toLowerCase();\n const opt = optValue.find((o) => o.toLowerCase() === normalized);\n\n setState(prevState => ({\n ...prevState,\n displayValue: opt || itemValue,\n }));\n };\n\n const handleClick = (e) => {\n setIsActive(true);\n const dropDownItems = getItems(e.target.value);\n\n if (dropDownItems.length > 1) {\n setState(prevState => ({\n ...prevState,\n dropDownItems,\n errorMessage: '',\n }));\n\n setIsMenuClosed(false);\n }\n };\n\n const handleOnChange = (e) => {\n const findStr = e.target.value;\n\n if (onChange) { onChange(findStr); }\n\n if (findStr.length) {\n const filteredItems = getItems(findStr);\n setState(prevState => ({\n ...prevState,\n dropDownItems: filteredItems,\n errorMessage: '',\n }));\n\n setIsMenuClosed(false);\n } else {\n setState(prevState => ({\n ...prevState,\n dropDownItems: [],\n }));\n\n setIsMenuClosed(true);\n }\n\n setDisplayValue(e.target.value);\n };\n\n return (\n <div className=\"pgn__form-autosuggest__wrapper\" ref={parentRef}>\n <div aria-live=\"assertive\" className=\"sr-only\" data-testid=\"autosuggest-screen-reader-options-count\">\n {`${state.dropDownItems.length} options found`}\n </div>\n <FormGroup isInvalid={!!state.errorMessage}>\n <FormControl\n ref={formControlRef}\n aria-expanded={(state.dropDownItems.length > 0).toString()}\n aria-owns=\"pgn__form-autosuggest__dropdown-box\"\n role=\"combobox\"\n aria-autocomplete=\"list\"\n autoComplete=\"off\"\n value={state.displayValue}\n aria-invalid={state.errorMessage}\n aria-activedescendant={activeMenuItemId}\n onChange={handleOnChange}\n onClick={handleClick}\n trailingElement={iconToggle}\n data-testid=\"autosuggest-textbox-input\"\n {...props}\n />\n\n {helpMessage && !state.errorMessage && (\n <FormControlFeedback type=\"default\">\n {helpMessage}\n </FormControlFeedback>\n )}\n\n {state.errorMessage && (\n <FormControlFeedback type=\"invalid\" feedback-for={props.name}>\n {errorMessageText}\n </FormControlFeedback>\n )}\n </FormGroup>\n\n <ul\n id=\"pgn__form-autosuggest__dropdown-box\"\n className=\"pgn__form-autosuggest__dropdown\"\n role=\"listbox\"\n >\n {isLoading ? (\n <div className=\"pgn__form-autosuggest__dropdown-loading\">\n <Spinner\n animation=\"border\"\n variant=\"dark\"\n screenReaderText={screenReaderText}\n data-testid=\"autosuggest-loading-spinner\"\n />\n </div>\n ) : state.dropDownItems.length > 0 && state.dropDownItems}\n </ul>\n </div>\n );\n}\n\nFormAutosuggest.defaultProps = {\n arrowKeyNavigationSelector: 'a:not(:disabled),li:not(:disabled, .btn-icon),input:not(:disabled)',\n ignoredArrowKeysNames: ['ArrowRight', 'ArrowLeft'],\n isLoading: false,\n className: null,\n floatingLabel: null,\n onChange: null,\n onSelected: null,\n helpMessage: '',\n placeholder: '',\n value: null,\n errorMessageText: null,\n readOnly: false,\n children: null,\n name: 'form-autosuggest',\n screenReaderText: 'loading',\n};\n\nFormAutosuggest.propTypes = {\n /**\n * Specifies the CSS selector string that indicates to which elements\n * the user can navigate using the arrow keys\n */\n arrowKeyNavigationSelector: PropTypes.string,\n /** Specifies ignored hook keys. */\n ignoredArrowKeysNames: PropTypes.arrayOf(PropTypes.string),\n /** Specifies loading state. */\n isLoading: PropTypes.bool,\n /** Specifies class name to append to the base element. */\n className: PropTypes.string,\n /** Specifies floating label to display for the input component. */\n floatingLabel: PropTypes.string,\n /** Specifies onChange event handler. */\n onChange: PropTypes.func,\n /** Specifies help information for the user. */\n helpMessage: PropTypes.string,\n /** Specifies the placeholder text for the input. */\n placeholder: PropTypes.string,\n /** Specifies values for the input. */\n value: PropTypes.string,\n /** Informs user has errors. */\n errorMessageText: PropTypes.string,\n /** Specifies the name of the base input element. */\n name: PropTypes.string,\n /** Selected list item is read-only. */\n readOnly: PropTypes.bool,\n /** Specifies the content of the `FormAutosuggest`. */\n children: PropTypes.node,\n /** Specifies the screen reader text */\n screenReaderText: PropTypes.string,\n /** Function that receives the selected value. */\n onSelected: PropTypes.func,\n};\n\nexport default FormAutosuggest;\n"],"mappings":";;;;;;;;;;AAAA,OAAOA,KAAK,IACVC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,QACtB,OAAO;AACd,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,EAAE,IAAIC,MAAM,QAAQ,MAAM;AACnC,SAASC,OAAO,QAAQ,YAAY;AACpC,SAASC,eAAe,EAAEC,iBAAiB,QAAQ,aAAa;AAChE,OAAOC,IAAI,MAAM,SAAS;AAC1B,OAAOC,SAAS,MAAM,aAAa;AACnC,OAAOC,WAAW,MAAM,eAAe;AACvC,OAAOC,mBAAmB,MAAM,uBAAuB;AACvD,OAAOC,UAAU,MAAM,eAAe;AACtC,OAAOC,OAAO,MAAM,YAAY;AAChC,OAAOC,qBAAqB,MAAM,gCAAgC;AAClE,OAAOC,QAAQ,MAAM,YAAY;AAEjC,SAASC,eAAeA,CAAAC,IAAA,EAYrB;EAAA,IAZsB;MACvBC,QAAQ;MACRC,0BAA0B;MAC1BC,qBAAqB;MACrBC,gBAAgB;MAChBC,KAAK;MACLC,SAAS;MACTC,gBAAgB;MAChBC,QAAQ;MACRC,UAAU;MACVC;IAEF,CAAC,GAAAV,IAAA;IADIW,KAAK,GAAAC,wBAAA,CAAAZ,IAAA,EAAAa,SAAA;EAER,MAAMC,IAAI,GAAG1B,OAAO,CAAC,CAAC;EACtB,MAAM2B,cAAc,GAAG/B,MAAM,CAAC,CAAC;EAC/B,MAAMgC,SAAS,GAAGnB,qBAAqB,CAAC;IACtCoB,SAA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SAAS,CAAC+H,MAAM;EACvB;EACAzG,gBAAgB,EAAEtB,SAAS,CAAC+H,MAAM;EAClC;EACAP,IAAI,EAAExH,SAAS,CAAC+H,MAAM;EACtB;EACAF,QAAQ,EAAE7H,SAAS,CAACiI,IAAI;EACxB;EACAjH,QAAQ,EAAEhB,SAAS,CAACmI,IAAI;EACxB;EACAhH,gBAAgB,EAAEnB,SAAS,CAAC+H,MAAM;EAClC;EACAvG,UAAU,EAAExB,SAAS,CAACkI;AACxB,CAAC;AAED,eAAepH,eAAe"}
|
|
1
|
+
{"version":3,"file":"FormAutosuggest.js","names":["React","useEffect","useState","useRef","PropTypes","v4","uuidv4","useIntl","KeyboardArrowUp","KeyboardArrowDown","Icon","FormGroupContextProvider","useFormGroupContext","FormControl","FormControlFeedback","IconButton","Spinner","useArrowKeyNavigation","messages","FormAutosuggest","_ref","children","arrowKeyNavigationSelector","ignoredArrowKeysNames","screenReaderText","value","isLoading","errorMessageText","onChange","onSelected","helpMessage","props","_objectWithoutProperties","_excluded","intl","formControlRef","parentRef","selectors","ignoredKeys","isMenuClosed","setIsMenuClosed","isActive","setIsActive","state","setState","displayValue","errorMessage","dropDownItems","activeMenuItemId","setActiveMenuItemId","handleMenuItemFocus","menuItemId","handleItemClick","e","onClick","clickedValue","currentTarget","getAttribute","prevState","_objectSpread","getItems","strToFind","arguments","length","undefined","childrenOpt","Children","map","child","_child$props","rest","_excluded2","cloneElement","id","onFocus","filter","opt","toLowerCase","includes","handleExpand","newState","iconToggle","createElement","className","tabindex","src","iconAs","size","variant","alt","formatMessage","iconButtonOpened","iconButtonClosed","leaveControl","handleDocumentClick","current","contains","target","keyDownHandler","key","preventDefault","focus","document","addEventListener","removeEventListener","setDisplayValue","itemValue","optValue","forEach","push","normalized","find","o","handleClick","handleOnChange","findStr","filteredItems","getControlProps","controlProps","ref","controlId","isInvalid","_extends","toString","role","autoComplete","trailingElement","type","name","animation","defaultProps","floatingLabel","placeholder","readOnly","propTypes","string","arrayOf","bool","func","node"],"sources":["../../src/Form/FormAutosuggest.jsx"],"sourcesContent":["import React, {\n useEffect, useState, useRef,\n} from 'react';\nimport PropTypes from 'prop-types';\nimport { v4 as uuidv4 } from 'uuid';\nimport { useIntl } from 'react-intl';\nimport { KeyboardArrowUp, KeyboardArrowDown } from '../../icons';\nimport Icon from '../Icon';\nimport { FormGroupContextProvider, useFormGroupContext } from './FormGroupContext';\nimport FormControl from './FormControl';\nimport FormControlFeedback from './FormControlFeedback';\nimport IconButton from '../IconButton';\nimport Spinner from '../Spinner';\nimport useArrowKeyNavigation from '../hooks/useArrowKeyNavigation';\nimport messages from './messages';\n\nfunction FormAutosuggest({\n children,\n arrowKeyNavigationSelector,\n ignoredArrowKeysNames,\n screenReaderText,\n value,\n isLoading,\n errorMessageText,\n onChange,\n onSelected,\n helpMessage,\n ...props\n}) {\n const intl = useIntl();\n const formControlRef = useRef();\n const parentRef = useArrowKeyNavigation({\n selectors: arrowKeyNavigationSelector,\n ignoredKeys: ignoredArrowKeysNames,\n });\n const [isMenuClosed, setIsMenuClosed] = useState(true);\n const [isActive, setIsActive] = useState(false);\n const [state, setState] = useState({\n displayValue: value || '',\n errorMessage: '',\n dropDownItems: [],\n });\n const [activeMenuItemId, setActiveMenuItemId] = useState(null);\n\n const handleMenuItemFocus = (menuItemId) => {\n setActiveMenuItemId(menuItemId);\n };\n\n const handleItemClick = (e, onClick) => {\n const clickedValue = e.currentTarget.getAttribute('data-value');\n\n if (onSelected && clickedValue !== value) {\n onSelected(clickedValue);\n }\n\n setState(prevState => ({\n ...prevState,\n dropDownItems: [],\n displayValue: clickedValue,\n }));\n\n setIsMenuClosed(true);\n\n if (onClick) {\n onClick(e);\n }\n };\n\n function getItems(strToFind = '') {\n let childrenOpt = React.Children.map(children, (child) => {\n // eslint-disable-next-line no-shadow\n const { children, onClick, ...rest } = child.props;\n const menuItemId = uuidv4();\n\n return React.cloneElement(child, {\n ...rest,\n children,\n 'data-value': children,\n onClick: (e) => handleItemClick(e, onClick),\n id: menuItemId,\n onFocus: () => handleMenuItemFocus(menuItemId),\n });\n });\n\n if (strToFind.length > 0) {\n childrenOpt = childrenOpt\n .filter((opt) => (opt.props.children.toLowerCase().includes(strToFind.toLowerCase())));\n }\n\n return childrenOpt;\n }\n\n const handleExpand = () => {\n setIsMenuClosed(!isMenuClosed);\n\n const newState = {\n dropDownItems: [],\n };\n\n if (isMenuClosed) {\n setIsActive(true);\n newState.dropDownItems = getItems(state.displayValue);\n newState.errorMessage = '';\n }\n\n setState(prevState => ({\n ...prevState,\n ...newState,\n }));\n };\n\n const iconToggle = (\n <IconButton\n className=\"pgn__form-autosuggest__icon-button\"\n data-testid=\"autosuggest-iconbutton\"\n tabindex=\"-1\"\n src={isMenuClosed ? KeyboardArrowDown : KeyboardArrowUp}\n iconAs={Icon}\n size=\"sm\"\n variant=\"secondary\"\n alt={isMenuClosed\n ? intl.formatMessage(messages.iconButtonOpened)\n : intl.formatMessage(messages.iconButtonClosed)}\n onClick={(e) => handleExpand(e, isMenuClosed)}\n />\n );\n\n const leaveControl = () => {\n setIsActive(false);\n\n setState(prevState => ({\n ...prevState,\n dropDownItems: [],\n errorMessage: !state.displayValue ? errorMessageText : '',\n }));\n\n setIsMenuClosed(true);\n };\n\n const handleDocumentClick = (e) => {\n if (parentRef.current && !parentRef.current.contains(e.target) && isActive) {\n leaveControl();\n }\n };\n\n const keyDownHandler = e => {\n if (e.key === 'Escape' && isActive) {\n e.preventDefault();\n\n if (formControlRef) {\n formControlRef.current.focus();\n }\n\n setState(prevState => ({\n ...prevState,\n dropDownItems: [],\n }));\n\n setIsMenuClosed(true);\n }\n if (e.key === 'Tab' && isActive) {\n leaveControl();\n }\n };\n\n useEffect(() => {\n document.addEventListener('keydown', keyDownHandler);\n document.addEventListener('click', handleDocumentClick, true);\n\n return () => {\n document.removeEventListener('click', handleDocumentClick, true);\n document.removeEventListener('keydown', keyDownHandler);\n };\n });\n\n useEffect(() => {\n if (value || value === '') {\n setState(prevState => ({\n ...prevState,\n displayValue: value,\n }));\n }\n }, [value]);\n\n const setDisplayValue = (itemValue) => {\n const optValue = [];\n\n children.forEach(opt => {\n optValue.push(opt.props.children);\n });\n\n const normalized = itemValue.toLowerCase();\n const opt = optValue.find((o) => o.toLowerCase() === normalized);\n\n setState(prevState => ({\n ...prevState,\n displayValue: opt || itemValue,\n }));\n };\n\n const handleClick = (e) => {\n setIsActive(true);\n const dropDownItems = getItems(e.target.value);\n\n if (dropDownItems.length > 1) {\n setState(prevState => ({\n ...prevState,\n dropDownItems,\n errorMessage: '',\n }));\n\n setIsMenuClosed(false);\n }\n };\n\n const handleOnChange = (e) => {\n const findStr = e.target.value;\n\n if (onChange) { onChange(findStr); }\n\n if (findStr.length) {\n const filteredItems = getItems(findStr);\n setState(prevState => ({\n ...prevState,\n dropDownItems: filteredItems,\n errorMessage: '',\n }));\n\n setIsMenuClosed(false);\n } else {\n setState(prevState => ({\n ...prevState,\n dropDownItems: [],\n }));\n\n setIsMenuClosed(true);\n }\n\n setDisplayValue(e.target.value);\n };\n\n const { getControlProps } = useFormGroupContext();\n const controlProps = getControlProps(props);\n\n return (\n <div className=\"pgn__form-autosuggest__wrapper\" ref={parentRef}>\n <div aria-live=\"assertive\" className=\"sr-only\" data-testid=\"autosuggest-screen-reader-options-count\">\n {`${state.dropDownItems.length} options found`}\n </div>\n <FormGroupContextProvider\n controlId={controlProps.id}\n isInvalid={!!state.errorMessage}\n >\n <FormControl\n ref={formControlRef}\n aria-expanded={(state.dropDownItems.length > 0).toString()}\n aria-owns=\"pgn__form-autosuggest__dropdown-box\"\n role=\"combobox\"\n aria-autocomplete=\"list\"\n autoComplete=\"off\"\n value={state.displayValue}\n aria-invalid={state.errorMessage}\n aria-activedescendant={activeMenuItemId}\n onChange={handleOnChange}\n onClick={handleClick}\n trailingElement={iconToggle}\n data-testid=\"autosuggest-textbox-input\"\n {...controlProps}\n />\n\n {helpMessage && !state.errorMessage && (\n <FormControlFeedback type=\"default\">\n {helpMessage}\n </FormControlFeedback>\n )}\n\n {state.errorMessage && (\n <FormControlFeedback type=\"invalid\" feedback-for={controlProps.name}>\n {errorMessageText}\n </FormControlFeedback>\n )}\n </FormGroupContextProvider>\n\n <ul\n id=\"pgn__form-autosuggest__dropdown-box\"\n className=\"pgn__form-autosuggest__dropdown\"\n role=\"listbox\"\n >\n {isLoading ? (\n <div className=\"pgn__form-autosuggest__dropdown-loading\">\n <Spinner\n animation=\"border\"\n variant=\"dark\"\n screenReaderText={screenReaderText}\n data-testid=\"autosuggest-loading-spinner\"\n />\n </div>\n ) : state.dropDownItems.length > 0 && state.dropDownItems}\n </ul>\n </div>\n );\n}\n\nFormAutosuggest.defaultProps = {\n arrowKeyNavigationSelector: 'a:not(:disabled),li:not(:disabled, .btn-icon),input:not(:disabled)',\n ignoredArrowKeysNames: ['ArrowRight', 'ArrowLeft'],\n isLoading: false,\n className: null,\n floatingLabel: null,\n onChange: null,\n onSelected: null,\n helpMessage: '',\n placeholder: '',\n value: null,\n errorMessageText: null,\n readOnly: false,\n children: null,\n name: 'form-autosuggest',\n screenReaderText: 'loading',\n};\n\nFormAutosuggest.propTypes = {\n /**\n * Specifies the CSS selector string that indicates to which elements\n * the user can navigate using the arrow keys\n */\n arrowKeyNavigationSelector: PropTypes.string,\n /** Specifies ignored hook keys. */\n ignoredArrowKeysNames: PropTypes.arrayOf(PropTypes.string),\n /** Specifies loading state. */\n isLoading: PropTypes.bool,\n /** Specifies class name to append to the base element. */\n className: PropTypes.string,\n /** Specifies floating label to display for the input component. */\n floatingLabel: PropTypes.string,\n /** Specifies onChange event handler. */\n onChange: PropTypes.func,\n /** Specifies help information for the user. */\n helpMessage: PropTypes.string,\n /** Specifies the placeholder text for the input. */\n placeholder: PropTypes.string,\n /** Specifies values for the input. */\n value: PropTypes.string,\n /** Informs user has errors. */\n errorMessageText: PropTypes.string,\n /** Specifies the name of the base input element. */\n name: PropTypes.string,\n /** Selected list item is read-only. */\n readOnly: PropTypes.bool,\n /** Specifies the content of the `FormAutosuggest`. */\n children: PropTypes.node,\n /** Specifies the screen reader text */\n screenReaderText: PropTypes.string,\n /** Function that receives the selected value. */\n onSelected: PropTypes.func,\n};\n\nexport default FormAutosuggest;\n"],"mappings":";;;;;;;;;;AAAA,OAAOA,KAAK,IACVC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,QACtB,OAAO;AACd,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,EAAE,IAAIC,MAAM,QAAQ,MAAM;AACnC,SAASC,OAAO,QAAQ,YAAY;AACpC,SAASC,eAAe,EAAEC,iBAAiB,QAAQ,aAAa;AAChE,OAAOC,IAAI,MAAM,SAAS;AAC1B,SAASC,wBAAwB,EAAEC,mBAAmB,QAAQ,oBAAoB;AAClF,OAAOC,WAAW,MAAM,eAAe;AACvC,OAAOC,mBAAmB,MAAM,uBAAuB;AACvD,OAAOC,UAAU,MAAM,eAAe;AACtC,OAAOC,OAAO,MAAM,YAAY;AAChC,OAAOC,qBAAqB,MAAM,gCAAgC;AAClE,OAAOC,QAAQ,MAAM,YAAY;AAEjC,SAASC,eAAeA,CAAAC,IAAA,EAYrB;EAAA,IAZsB;MACvBC,QAAQ;MACRC,0BAA0B;MAC1BC,qBAAqB;MACrBC,gBAAgB;MAChBC,KAAK;MACLC,SAAS;MACTC,gBAAgB;MAChBC,QAAQ;MACRC,UAAU;MACVC;IAEF,CAAC,GAAAV,IAAA;IADIW,KAAK,GAAAC,wBAAA,CAAAZ,IAAA,EAAAa,SAAA;EAER,MAAMC,IAAI,GAAG3B,OAAO,CAAC,CAAC;EACtB,MAAM4B,cAAc,GAAGhC,MAAM,CAAC,CAAC;EAC/B,MAAMiC,SAAS,GAAGnB,qBAAqB,CAAC;IACtCoB,SAAS,EAAEf,0BAA0B;IACrCgB,WAAW,EAAEf;EACf,CAAC,CAAC;EACF,MAAM,CAACgB,YAAY,EAAEC,eAAe,CAAC,GAAGtC,QAAQ,CAAC,IAAI,CAAC;EACtD,MAAM,CAACuC,QAAQ,EAAEC,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AM;EACvB;EACA5G,gBAAgB,EAAEvB,SAAS,CAACmI,MAAM;EAClC;EACAP,IAAI,EAAE5H,SAAS,CAACmI,MAAM;EACtB;EACAF,QAAQ,EAAEjI,SAAS,CAACqI,IAAI;EACxB;EACApH,QAAQ,EAAEjB,SAAS,CAACuI,IAAI;EACxB;EACAnH,gBAAgB,EAAEpB,SAAS,CAACmI,MAAM;EAClC;EACA1G,UAAU,EAAEzB,SAAS,CAACsI;AACxB,CAAC;AAED,eAAevH,eAAe"}
|
package/dist/Form/FormSwitch.js
CHANGED
|
@@ -77,8 +77,11 @@ FormSwitch.propTypes = {
|
|
|
77
77
|
children: PropTypes.node.isRequired,
|
|
78
78
|
/** Specifies class name to append to the base element. */
|
|
79
79
|
className: PropTypes.string,
|
|
80
|
+
/** Specifies class name to append to the label element. */
|
|
80
81
|
labelClassName: PropTypes.string,
|
|
82
|
+
/** Specifies helper text to display below the switch. */
|
|
81
83
|
helperText: PropTypes.node,
|
|
84
|
+
/** Determines whether the label should float to the left when the switch is active. */
|
|
82
85
|
floatLabelLeft: PropTypes.bool
|
|
83
86
|
};
|
|
84
87
|
FormSwitch.defaultProps = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormSwitch.js","names":["React","PropTypes","classNames","FormCheckbox","useFormGroupContext","SwitchControl","forwardRef","_ref","ref","isIndeterminate","props","_objectWithoutProperties","_excluded","defaultRef","useRef","resolvedRef","getControlProps","checkboxProps","_objectSpread","className","useEffect","current","indeterminate","createElement","_extends","type","propTypes","bool","string","defaultProps","undefined","FormSwitch","_ref2","children","helperText","_excluded2","role","controlAs","isValid","isInvalid","description","node","isRequired","labelClassName","floatLabelLeft"],"sources":["../../src/Form/FormSwitch.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport FormCheckbox from './FormCheckbox';\nimport { useFormGroupContext } from './FormGroupContext';\n\nconst SwitchControl = React.forwardRef(\n ({ isIndeterminate, ...props }, ref) => {\n const defaultRef = React.useRef();\n const resolvedRef = ref || defaultRef;\n const { getControlProps } = useFormGroupContext();\n const checkboxProps = getControlProps({\n ...props,\n className: classNames(\n 'pgn__form-switch-input',\n props.className,\n ),\n });\n\n React.useEffect(() => {\n // this if(resolvedRef.current) prevents console errors in testing\n if (resolvedRef.current) {\n resolvedRef.current.indeterminate = isIndeterminate;\n }\n }, [resolvedRef, isIndeterminate]);\n\n return (\n <input\n type=\"checkbox\"\n {...checkboxProps}\n ref={resolvedRef}\n />\n );\n },\n);\n\nSwitchControl.propTypes = {\n /** Specifies whether input should be rendered in indeterminate state. */\n isIndeterminate: PropTypes.bool,\n /** Specifies class name to append to the base element. */\n className: PropTypes.string,\n};\n\nSwitchControl.defaultProps = {\n isIndeterminate: false,\n className: undefined,\n};\n\nconst FormSwitch = React.forwardRef(({\n children,\n className,\n helperText,\n ...props\n}, ref) => (\n <div className=\"d-inline-flex flex-column\">\n <FormCheckbox\n className={classNames('pgn__form-switch', className)}\n {...props}\n role=\"switch\"\n ref={ref}\n controlAs={SwitchControl}\n // ignore the following props for form switch\n isValid={null}\n isInvalid={null}\n description={null}\n >\n {children}\n </FormCheckbox>\n {helperText && (\n <div className=\"pgn__form-switch-helper-text\">\n {helperText}\n </div>\n )}\n </div>\n));\n\nFormSwitch.propTypes = {\n /** Specifies contents of the component. */\n children: PropTypes.node.isRequired,\n /** Specifies class name to append to the base element. */\n className: PropTypes.string,\n labelClassName: PropTypes.string,\n helperText: PropTypes.node,\n floatLabelLeft: PropTypes.bool,\n};\n\nFormSwitch.defaultProps = {\n className: undefined,\n labelClassName: undefined,\n helperText: undefined,\n floatLabelLeft: false,\n};\n\nexport { SwitchControl };\nexport default FormSwitch;\n"],"mappings":";;;;;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,YAAY,MAAM,gBAAgB;AACzC,SAASC,mBAAmB,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ADItB,KAAK,GAAAC,wBAAA,CAAAqB,KAAA,EAAAG,UAAA;EAAA,oBAERnC,KAAA,CAAAuB,aAAA;IAAKJ,SAAS,EAAC;EAA2B,gBACxCnB,KAAA,CAAAuB,aAAA,CAACpB,YAAY,EAAAqB,QAAA;IACXL,SAAS,EAAEjB,UAAU,CAAC,kBAAkB,EAAEiB,SAAS;EAAE,GACjDT,KAAK;IACT0B,IAAI,EAAC,QAAQ;IACb5B,GAAG,EAAEA,GAAI;IACT6B,SAAS,EAAEhC;IACX;IAAA;IACAiC,OAAO,EAAE,IAAK;IACdC,SAAS,EAAE,IAAK;IAChBC,WAAW,EAAE;EAAK,IAEjBP,QACW,CAAC,EACdC,UAAU,iBACTlC,KAAA,CAAAuB,aAAA;IAAKJ,SAAS,EAAC;EAA8B,GAC1Ce,UACE,CAEJ,CAAC;AAAA,CACP,CAAC;AAEFH,UAAU,CAACL,SAAS,GAAG;EACrB;EACAO,QAAQ,EAAEhC,SAAS,CAACwC,IAAI,CAACC,UAAU;EACnC;EACAvB,SAAS,EAAElB,SAAS,CAAC2B,MAAM;
|
|
1
|
+
{"version":3,"file":"FormSwitch.js","names":["React","PropTypes","classNames","FormCheckbox","useFormGroupContext","SwitchControl","forwardRef","_ref","ref","isIndeterminate","props","_objectWithoutProperties","_excluded","defaultRef","useRef","resolvedRef","getControlProps","checkboxProps","_objectSpread","className","useEffect","current","indeterminate","createElement","_extends","type","propTypes","bool","string","defaultProps","undefined","FormSwitch","_ref2","children","helperText","_excluded2","role","controlAs","isValid","isInvalid","description","node","isRequired","labelClassName","floatLabelLeft"],"sources":["../../src/Form/FormSwitch.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport FormCheckbox from './FormCheckbox';\nimport { useFormGroupContext } from './FormGroupContext';\n\nconst SwitchControl = React.forwardRef(\n ({ isIndeterminate, ...props }, ref) => {\n const defaultRef = React.useRef();\n const resolvedRef = ref || defaultRef;\n const { getControlProps } = useFormGroupContext();\n const checkboxProps = getControlProps({\n ...props,\n className: classNames(\n 'pgn__form-switch-input',\n props.className,\n ),\n });\n\n React.useEffect(() => {\n // this if(resolvedRef.current) prevents console errors in testing\n if (resolvedRef.current) {\n resolvedRef.current.indeterminate = isIndeterminate;\n }\n }, [resolvedRef, isIndeterminate]);\n\n return (\n <input\n type=\"checkbox\"\n {...checkboxProps}\n ref={resolvedRef}\n />\n );\n },\n);\n\nSwitchControl.propTypes = {\n /** Specifies whether input should be rendered in indeterminate state. */\n isIndeterminate: PropTypes.bool,\n /** Specifies class name to append to the base element. */\n className: PropTypes.string,\n};\n\nSwitchControl.defaultProps = {\n isIndeterminate: false,\n className: undefined,\n};\n\nconst FormSwitch = React.forwardRef(({\n children,\n className,\n helperText,\n ...props\n}, ref) => (\n <div className=\"d-inline-flex flex-column\">\n <FormCheckbox\n className={classNames('pgn__form-switch', className)}\n {...props}\n role=\"switch\"\n ref={ref}\n controlAs={SwitchControl}\n // ignore the following props for form switch\n isValid={null}\n isInvalid={null}\n description={null}\n >\n {children}\n </FormCheckbox>\n {helperText && (\n <div className=\"pgn__form-switch-helper-text\">\n {helperText}\n </div>\n )}\n </div>\n));\n\nFormSwitch.propTypes = {\n /** Specifies contents of the component. */\n children: PropTypes.node.isRequired,\n /** Specifies class name to append to the base element. */\n className: PropTypes.string,\n /** Specifies class name to append to the label element. */\n labelClassName: PropTypes.string,\n /** Specifies helper text to display below the switch. */\n helperText: PropTypes.node,\n /** Determines whether the label should float to the left when the switch is active. */\n floatLabelLeft: PropTypes.bool,\n};\n\nFormSwitch.defaultProps = {\n className: undefined,\n labelClassName: undefined,\n helperText: undefined,\n floatLabelLeft: false,\n};\n\nexport { SwitchControl };\nexport default FormSwitch;\n"],"mappings":";;;;;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,YAAY,MAAM,gBAAgB;AACzC,S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AAAF,KAAA;IADItB,KAAK,GAAAC,wBAAA,CAAAqB,KAAA,EAAAG,UAAA;EAAA,oBAERnC,KAAA,CAAAuB,aAAA;IAAKJ,SAAS,EAAC;EAA2B,gBACxCnB,KAAA,CAAAuB,aAAA,CAACpB,YAAY,EAAAqB,QAAA;IACXL,SAAS,EAAEjB,UAAU,CAAC,kBAAkB,EAAEiB,SAAS;EAAE,GACjDT,KAAK;IACT0B,IAAI,EAAC,QAAQ;IACb5B,GAAG,EAAEA,GAAI;IACT6B,SAAS,EAAEhC;IACX;IAAA;IACAiC,OAAO,EAAE,IAAK;IACdC,SAAS,EAAE,IAAK;IAChBC,WAAW,EAAE;EAAK,IAEjBP,QACW,CAAC,EACdC,UAAU,iBACTlC,KAAA,CAAAuB,aAAA;IAAKJ,SAAS,EAAC;EAA8B,GAC1Ce,UACE,CAEJ,CAAC;AAAA,CACP,CAAC;AAEFH,UAAU,CAACL,SAAS,GAAG;EACrB;EACAO,QAAQ,EAAEhC,SAAS,CAACwC,IAAI,CAACC,UAAU;EACnC;EACAvB,SAAS,EAAElB,SAAS,CAAC2B,MAAM;EAC3B;EACAe,cAAc,EAAE1C,SAAS,CAAC2B,MAAM;EAChC;EACAM,UAAU,EAAEjC,SAAS,CAACwC,IAAI;EAC1B;EACAG,cAAc,EAAE3C,SAAS,CAAC0B;AAC5B,CAAC;AAEDI,UAAU,CAACF,YAAY,GAAG;EACxBV,SAAS,EAAEW,SAAS;EACpBa,cAAc,EAAEb,SAAS;EACzBI,UAAU,EAAEJ,SAAS;EACrBc,cAAc,EAAE;AAClB,CAAC;AAED,SAASvC,aAAa;AACtB,eAAe0B,UAAU"}
|
package/dist/Hyperlink/index.js
CHANGED
|
@@ -88,22 +88,23 @@ Hyperlink.propTypes = {
|
|
|
88
88
|
children: PropTypes.node.isRequired,
|
|
89
89
|
/** Custom class names for the hyperlink */
|
|
90
90
|
className: PropTypes.string,
|
|
91
|
-
/** specifies where the link should open. The default behavior is `_self`, which means that the URL will be
|
|
92
|
-
|
|
91
|
+
/** specifies where the link should open. The default behavior is `_self`, which means that the URL will be
|
|
92
|
+
* loaded into the same browsing context as the current one.
|
|
93
|
+
* If the target is `_blank` (opening a new window) `rel='noopener'` will be added to the anchor tag to prevent
|
|
94
|
+
* any potential [reverse tabnabbing attack](https://www.owasp.org/index.php/Reverse_Tabnabbing).
|
|
95
|
+
*/
|
|
93
96
|
target: PropTypes.string,
|
|
94
97
|
/** specifies the callback function when the link is clicked */
|
|
95
98
|
onClick: PropTypes.func,
|
|
96
|
-
// eslint-disable-next-line max-len
|
|
97
99
|
/** specifies the text for links with a `_blank` target (which loads the URL in a new browsing context). */
|
|
98
100
|
externalLinkAlternativeText: isRequiredIf(PropTypes.string, props => props.target === '_blank'),
|
|
99
|
-
// eslint-disable-next-line max-len
|
|
100
101
|
/** specifies the title for links with a `_blank` target (which loads the URL in a new browsing context). */
|
|
101
102
|
externalLinkTitle: isRequiredIf(PropTypes.string, props => props.target === '_blank'),
|
|
102
103
|
/** type of hyperlink */
|
|
103
104
|
variant: PropTypes.oneOf(['default', 'muted', 'brand']),
|
|
104
|
-
/** specify the link style. By default it will be underlined. */
|
|
105
|
+
/** specify the link style. By default, it will be underlined. */
|
|
105
106
|
isInline: PropTypes.bool,
|
|
106
|
-
/** specify if we need to show launch Icon. By default it will be visible. */
|
|
107
|
+
/** specify if we need to show launch Icon. By default, it will be visible. */
|
|
107
108
|
showLaunchIcon: PropTypes.bool
|
|
108
109
|
};
|
|
109
110
|
export default withDeprecatedProps(Hyperlink, 'Hyperlink', {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","PropTypes","classNames","isRequiredIf","Launch","Icon","withDeprecatedProps","DeprTypes","HYPER_LINK_EXTERNAL_LINK_ALT_TEXT","HYPER_LINK_EXTERNAL_LINK_TITLE","Hyperlink","forwardRef","props","ref","className","destination","children","target","onClick","externalLinkAlternativeText","externalLinkTitle","variant","isInline","showLaunchIcon","attrs","_objectWithoutProperties","_excluded","externalLinkIcon","generateRel","rel","includes","createElement","title","src","screenReaderText","style","height","width","_extends","href","defaultProps","undefined","propTypes","string","isRequired","node","func","oneOf","bool","content","deprType","MOVED","newName"],"sources":["../../src/Hyperlink/index.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport isRequiredIf from 'react-proptype-conditional-require';\nimport { Launch } from '../../icons';\nimport Icon from '../Icon';\n\nimport withDeprecatedProps, { DeprTypes } from '../withDeprecatedProps';\n\nexport const HYPER_LINK_EXTERNAL_LINK_ALT_TEXT = 'in a new tab';\nexport const HYPER_LINK_EXTERNAL_LINK_TITLE = 'Opens in a new tab';\n\nconst Hyperlink = React.forwardRef((props, ref) => {\n const {\n className,\n destination,\n children,\n target,\n onClick,\n externalLinkAlternativeText,\n externalLinkTitle,\n variant,\n isInline,\n showLaunchIcon,\n ...attrs\n } = props;\n let externalLinkIcon;\n\n if (target === '_blank') {\n const generateRel = () => {\n let { rel } = attrs;\n if (!rel) {\n return 'noopener noreferrer';\n }\n if (!rel.includes('noopener')) {\n rel += ' noopener';\n }\n if (!rel.includes('noreferrer')) {\n rel += ' noreferrer';\n }\n return rel;\n };\n\n // Add this rel attribute to prevent Reverse Tabnabbing\n attrs.rel = generateRel();\n if (showLaunchIcon) {\n externalLinkIcon = (\n <span\n className=\"pgn__hyperlink__external-icon\"\n title={externalLinkTitle}\n >\n <Icon\n src={Launch}\n screenReaderText={externalLinkAlternativeText}\n style={{ height: '1em', width: '1em' }}\n data-testid=\"hyperlink-icon\"\n />\n </span>\n );\n }\n }\n\n return (\n <a\n ref={ref}\n className={classNames(\n 'pgn__hyperlink',\n `${variant}-link`,\n {\n 'standalone-link': !isInline,\n 'inline-link': isInline,\n },\n className,\n )}\n href={destination}\n target={target}\n onClick={onClick}\n {...attrs}\n >\n {children}\n {externalLinkIcon}\n </a>\n );\n});\n\nHyperlink.defaultProps = {\n className: undefined,\n target: '_self',\n onClick: () => {},\n externalLinkAlternativeText: HYPER_LINK_EXTERNAL_LINK_ALT_TEXT,\n externalLinkTitle: HYPER_LINK_EXTERNAL_LINK_TITLE,\n variant: 'default',\n isInline: false,\n showLaunchIcon: true,\n};\n\nHyperlink.propTypes = {\n /** specifies the URL */\n destination: PropTypes.string.isRequired,\n /** Content of the hyperlink */\n children: PropTypes.node.isRequired,\n /** Custom class names for the hyperlink */\n className: PropTypes.string,\n /** specifies where the link should open. The default behavior is `_self`, which means that the URL will be loaded into the same browsing context as the current one
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","PropTypes","classNames","isRequiredIf","Launch","Icon","withDeprecatedProps","DeprTypes","HYPER_LINK_EXTERNAL_LINK_ALT_TEXT","HYPER_LINK_EXTERNAL_LINK_TITLE","Hyperlink","forwardRef","props","ref","className","destination","children","target","onClick","externalLinkAlternativeText","externalLinkTitle","variant","isInline","showLaunchIcon","attrs","_objectWithoutProperties","_excluded","externalLinkIcon","generateRel","rel","includes","createElement","title","src","screenReaderText","style","height","width","_extends","href","defaultProps","undefined","propTypes","string","isRequired","node","func","oneOf","bool","content","deprType","MOVED","newName"],"sources":["../../src/Hyperlink/index.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport isRequiredIf from 'react-proptype-conditional-require';\nimport { Launch } from '../../icons';\nimport Icon from '../Icon';\n\nimport withDeprecatedProps, { DeprTypes } from '../withDeprecatedProps';\n\nexport const HYPER_LINK_EXTERNAL_LINK_ALT_TEXT = 'in a new tab';\nexport const HYPER_LINK_EXTERNAL_LINK_TITLE = 'Opens in a new tab';\n\nconst Hyperlink = React.forwardRef((props, ref) => {\n const {\n className,\n destination,\n children,\n target,\n onClick,\n externalLinkAlternativeText,\n externalLinkTitle,\n variant,\n isInline,\n showLaunchIcon,\n ...attrs\n } = props;\n let externalLinkIcon;\n\n if (target === '_blank') {\n const generateRel = () => {\n let { rel } = attrs;\n if (!rel) {\n return 'noopener noreferrer';\n }\n if (!rel.includes('noopener')) {\n rel += ' noopener';\n }\n if (!rel.includes('noreferrer')) {\n rel += ' noreferrer';\n }\n return rel;\n };\n\n // Add this rel attribute to prevent Reverse Tabnabbing\n attrs.rel = generateRel();\n if (showLaunchIcon) {\n externalLinkIcon = (\n <span\n className=\"pgn__hyperlink__external-icon\"\n title={externalLinkTitle}\n >\n <Icon\n src={Launch}\n screenReaderText={externalLinkAlternativeText}\n style={{ height: '1em', width: '1em' }}\n data-testid=\"hyperlink-icon\"\n />\n </span>\n );\n }\n }\n\n return (\n <a\n ref={ref}\n className={classNames(\n 'pgn__hyperlink',\n `${variant}-link`,\n {\n 'standalone-link': !isInline,\n 'inline-link': isInline,\n },\n className,\n )}\n href={destination}\n target={target}\n onClick={onClick}\n {...attrs}\n >\n {children}\n {externalLinkIcon}\n </a>\n );\n});\n\nHyperlink.defaultProps = {\n className: undefined,\n target: '_self',\n onClick: () => {},\n externalLinkAlternativeText: HYPER_LINK_EXTERNAL_LINK_ALT_TEXT,\n externalLinkTitle: HYPER_LINK_EXTERNAL_LINK_TITLE,\n variant: 'default',\n isInline: false,\n showLaunchIcon: true,\n};\n\nHyperlink.propTypes = {\n /** specifies the URL */\n destination: PropTypes.string.isRequired,\n /** Content of the hyperlink */\n children: PropTypes.node.isRequired,\n /** Custom class names for the hyperlink */\n className: PropTypes.string,\n /** specifies where the link should open. The default behavior is `_self`, which means that the URL will be\n * loaded into the same browsing context as the current one.\n * If the target is `_blank` (opening a new window) `rel='noopener'` will be added to the anchor tag to prevent\n * any potential [reverse tabnabbing attack](https://www.owasp.org/index.php/Reverse_Tabnabbing).\n */\n target: PropTypes.string,\n /** specifies the callback function when the link is clicked */\n onClick: PropTypes.func,\n /** specifies the text for links with a `_blank` target (which loads the URL in a new browsing context). */\n externalLinkAlternativeText: isRequiredIf(\n PropTypes.string,\n props => props.target === '_blank',\n ),\n /** specifies the title for links with a `_blank` target (which loads the URL in a new browsing context). */\n externalLinkTitle: isRequiredIf(\n PropTypes.string,\n props => props.target === '_blank',\n ),\n /** type of hyperlink */\n variant: PropTypes.oneOf(['default', 'muted', 'brand']),\n /** specify the link style. By default, it will be underlined. */\n isInline: PropTypes.bool,\n /** specify if we need to show launch Icon. By default, it will be visible. */\n showLaunchIcon: PropTypes.bool,\n};\n\nexport default withDeprecatedProps(Hyperlink, 'Hyperlink', {\n /** specifies the text or element that a URL should be associated with */\n content: {\n deprType: DeprTypes.MOVED,\n newName: 'children',\n },\n});\n"],"mappings":";;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,YAAY,MAAM,oCAAoC;AAC7D,SAASC,MAAM,QAAQ,aAAa;AACpC,OAAOC,IAAI,MAAM,SAAS;AAE1B,OAAOC,mBAAmB,IAAIC,SAAS,QAAQ,wBAAwB;AAEvE,OAAO,MAAMC,iCAAiC,GAAG,cAAc;AAC/D,OAAO,MAAMC,8BAA8B,GAAG,oBAAoB;AAElE,MAAMC,SAAS,gBAAGV,KAAK,CAACW,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EACjD,MAAM;MACJC,SAAS;MACTC,WAAW;MACXC,QAAQ;MACRC,MAAM;MACNC,OAAO;MACPC,2BAA2B;MAC3BC,iBAAiB;MACjBC,OAAO;MACPC,QAAQ;MACRC;IAEF,CAAC,GAAGX,KAAK;IADJY,KAAK,GAAAC,wBAAA,CACNb,KAAK,EAAAc,SAAA;EACT,IAAIC,gBAAgB;EAEpB,IAAIV,MAAM,KAAK,QAAQ,EAAE;IACvB,MAAMW,WAAW,GAAGA,CAAA,KAAM;MACxB,IAAI;QAAEC;MAAI,CAAC,GAAGL,KAAK;MACnB,IAAI,CAACK,GAAG,EAAE;QACR,OAAO,qBAAqB;MAC9B;MACA,IAAI,CAACA,GAAG,CAACC,QAAQ,CAAC,UAAU,CAAC,EAAE;QAC7BD,GAAG,IAAI,WAAW;MACpB;MACA,IAAI,CAACA,GAAG,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,MAAM,CAACC,UAAU;EACxC;EACA5B,QAAQ,EAAEf,SAAS,CAAC4C,IAAI,CAACD,UAAU;EACnC;EACA9B,SAAS,EAAEb,SAAS,CAAC0C,MAAM;EAC3B;AACF;AACA;AACA;AACA;EACE1B,MAAM,EAAEhB,SAAS,CAAC0C,MAAM;EACxB;EACAzB,OAAO,EAAEjB,SAAS,CAAC6C,IAAI;EACvB;EACA3B,2BAA2B,EAAEhB,YAAY,CACvCF,SAAS,CAAC0C,MAAM,EAChB/B,KAAK,IAAIA,KAAK,CAACK,MAAM,KAAK,QAC5B,CAAC;EACD;EACAG,iBAAiB,EAAEjB,YAAY,CAC7BF,SAAS,CAAC0C,MAAM,EAChB/B,KAAK,IAAIA,KAAK,CAACK,MAAM,KAAK,QAC5B,CAAC;EACD;EACAI,OAAO,EAAEpB,SAAS,CAAC8C,KAAK,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;EACvD;EACAzB,QAAQ,EAAErB,SAAS,CAAC+C,IAAI;EACxB;EACAzB,cAAc,EAAEtB,SAAS,CAAC+C;AAC5B,CAAC;AAED,eAAe1C,mBAAmB,CAACI,SAAS,EAAE,WAAW,EAAE;EACzD;EACAuC,OAAO,EAAE;IACPC,QAAQ,EAAE3C,SAAS,CAAC4C,KAAK;IACzBC,OAAO,EAAE;EACX;AACF,CAAC,CAAC"}
|
package/dist/Icon/index.js
CHANGED
|
@@ -60,28 +60,35 @@ function Icon(_ref) {
|
|
|
60
60
|
}, screenReaderText));
|
|
61
61
|
}
|
|
62
62
|
Icon.propTypes = {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
/**
|
|
64
|
+
* An icon component to render.
|
|
65
|
+
* Example import of a Paragon icon component: `import { Check } from '@edx/paragon/icons';`
|
|
66
|
+
*/
|
|
67
|
+
src: PropTypes.oneOfType([PropTypes.element, PropTypes.elementType]),
|
|
66
68
|
/** HTML element attributes to pass through to the underlying svg element */
|
|
67
69
|
svgAttrs: PropTypes.shape({
|
|
68
70
|
'aria-label': PropTypes.string,
|
|
69
71
|
'aria-labelledby': PropTypes.string
|
|
70
72
|
}),
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
/**
|
|
74
|
+
* the `id` property of the Icon element, by default this value is generated
|
|
75
|
+
* with the `newId` function with the `prefix` of `Icon`.
|
|
76
|
+
*/
|
|
73
77
|
id: PropTypes.string,
|
|
74
|
-
// eslint-disable-next-line max-len
|
|
75
78
|
/** The size of the icon. */
|
|
76
79
|
size: PropTypes.oneOf(['xs', 'sm', 'md', 'lg']),
|
|
77
|
-
// eslint-disable-next-line max-len
|
|
78
80
|
/** A class name that will define what the Icon looks like. */
|
|
79
81
|
className: PropTypes.string,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
/**
|
|
83
|
+
* a boolean that determines the value of `aria-hidden` attribute on the Icon span,
|
|
84
|
+
* this value is `true` by default.
|
|
85
|
+
*/
|
|
82
86
|
hidden: PropTypes.bool,
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
/**
|
|
88
|
+
* a string or an element that will be used on a secondary span leveraging the `sr-only` style
|
|
89
|
+
* for screenreader only text, this value is `undefined` by default. This value is recommended for use unless
|
|
90
|
+
* the Icon is being used in a way that is purely decorative or provides no additional context for screen
|
|
91
|
+
* reader users. This field should be thought of the same way an `alt` attribute would be used for `image` tags.
|
|
85
92
|
*/
|
|
86
93
|
screenReaderText: PropTypes.oneOfType([PropTypes.string, PropTypes.element])
|
|
87
94
|
};
|
package/dist/Icon/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","PropTypes","classNames","newId","withDeprecatedProps","DeprTypes","Icon","_ref","src","Component","id","className","hidden","screenReaderText","svgAttrs","size","attrs","_objectWithoutProperties","_excluded","hasAriaLabel","mergedSvgProps","_objectSpread","undefined","createElement","_extends","role","focusable","Fragment","propTypes","oneOfType","element","
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","PropTypes","classNames","newId","withDeprecatedProps","DeprTypes","Icon","_ref","src","Component","id","className","hidden","screenReaderText","svgAttrs","size","attrs","_objectWithoutProperties","_excluded","hasAriaLabel","mergedSvgProps","_objectSpread","undefined","createElement","_extends","role","focusable","Fragment","propTypes","oneOfType","element","elementType","shape","string","oneOf","bool","defaultProps","deprType","FORMAT","expect","value","transform","Array","isArray","join","message"],"sources":["../../src/Icon/index.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\n\nimport newId from '../utils/newId';\nimport withDeprecatedProps, { DeprTypes } from '../withDeprecatedProps';\n\n/**\n * An svg with an \"img\" role must satisfy the following a11y requirements\n * - It needs a text alternative in the form of aria-label, aria-labelledby, or screen-reader only text.\n * - If no label is desired, aria-label will be set to an empty string and aria-hidden to \"true\".\n * - focusable is set to false on the svg in all cases as a workaround for an ie11 bug\n */\n\nfunction Icon({\n src: Component,\n id,\n className,\n hidden,\n screenReaderText,\n svgAttrs,\n size,\n ...attrs\n}) {\n if (Component) {\n // If no aria label is specified, hide this icon from screenreaders\n const hasAriaLabel = svgAttrs['aria-label'] || svgAttrs['aria-labelledby'];\n\n const mergedSvgProps = { ...svgAttrs };\n\n if (!hasAriaLabel) {\n mergedSvgProps['aria-label'] = undefined;\n mergedSvgProps['aria-hidden'] = true;\n }\n\n return (\n <span\n className={classNames('pgn__icon', { [`pgn__icon__${size}`]: !!size }, className)}\n id={id}\n {...attrs}\n >\n <Component\n role=\"img\"\n focusable={false}\n {...mergedSvgProps}\n />\n {screenReaderText && (\n <span className=\"sr-only\">\n {screenReaderText}\n </span>\n )}\n </span>\n );\n }\n\n return (\n <>\n <span\n id={id || newId('Icon')}\n className={className}\n aria-hidden={hidden}\n />\n {screenReaderText && (\n <span className=\"sr-only\">\n {screenReaderText}\n </span>\n )}\n </>\n );\n}\n\nIcon.propTypes = {\n /**\n * An icon component to render.\n * Example import of a Paragon icon component: `import { Check } from '@edx/paragon/icons';`\n */\n src: PropTypes.oneOfType([PropTypes.element, PropTypes.elementType]),\n /** HTML element attributes to pass through to the underlying svg element */\n svgAttrs: PropTypes.shape({\n 'aria-label': PropTypes.string,\n 'aria-labelledby': PropTypes.string,\n }),\n /**\n * the `id` property of the Icon element, by default this value is generated\n * with the `newId` function with the `prefix` of `Icon`.\n */\n id: PropTypes.string,\n /** The size of the icon. */\n size: PropTypes.oneOf(['xs', 'sm', 'md', 'lg']),\n /** A class name that will define what the Icon looks like. */\n className: PropTypes.string,\n /**\n * a boolean that determines the value of `aria-hidden` attribute on the Icon span,\n * this value is `true` by default.\n */\n hidden: PropTypes.bool,\n /**\n * a string or an element that will be used on a secondary span leveraging the `sr-only` style\n * for screenreader only text, this value is `undefined` by default. This value is recommended for use unless\n * the Icon is being used in a way that is purely decorative or provides no additional context for screen\n * reader users. This field should be thought of the same way an `alt` attribute would be used for `image` tags.\n */\n screenReaderText: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n};\n\nIcon.defaultProps = {\n src: null,\n svgAttrs: {},\n id: undefined,\n hidden: true,\n screenReaderText: undefined,\n size: undefined,\n className: undefined,\n};\n\nexport default withDeprecatedProps(Icon, 'Icon', {\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});\n"],"mappings":";;;;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AAEnC,OAAOC,KAAK,MAAM,gBAAgB;AAClC,OAAOC,mBAAmB,IAAIC,SAAS,QAAQ,wBAAwB;;AAEvE;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASC,IAAIA,CAAAC,IAAA,EASV;EAAA,IATW;MACZC,GAAG,EAAEC,SAAS;MACdC,EAAE;MACFC,SAAS;MACTC,MAAM;MACNC,gBAAgB;MAChBC,QAAQ;MACRC;IAEF,CAAC,GAAAR,IAAA;IAD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.propTypes = {
|
|
|
63
63
|
/** An icon component to render. Example import of a Paragon icon component:
|
|
64
64
|
* `import { Check } from '@edx/paragon/dist/icon';`
|
|
65
65
|
* */
|
|
66
|
-
src: PropTypes.oneOfType([PropTypes.element, PropTypes.
|
|
66
|
+
src: PropTypes.oneOfType([PropTypes.element, PropTypes.elementType]),
|
|
67
67
|
/** Alt text for your icon. For best practice, avoid using alt text to describe
|
|
68
68
|
* the image in the `IconButton`. Instead, we recommend describing the function
|
|
69
69
|
* of the button. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","PropTypes","classNames","Icon","OverlayTrigger","Tooltip","IconButton","forwardRef","_ref","ref","className","alt","invertColors","icon","src","iconClassNames","onClick","size","variant","iconAs","isActive","attrs","_objectWithoutProperties","_excluded","invert","activeStyle","IconComponent","createElement","_extends","type","defaultProps","undefined","propTypes","string","elementType","oneOfType","element","
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","PropTypes","classNames","Icon","OverlayTrigger","Tooltip","IconButton","forwardRef","_ref","ref","className","alt","invertColors","icon","src","iconClassNames","onClick","size","variant","iconAs","isActive","attrs","_objectWithoutProperties","_excluded","invert","activeStyle","IconComponent","createElement","_extends","type","defaultProps","undefined","propTypes","string","elementType","oneOfType","element","isRequired","bool","shape","prefix","iconName","array","func","oneOf","IconButtonWithTooltip","_ref2","tooltipPlacement","tooltipContent","props","_excluded2","placement","overlay","id","node"],"sources":["../../src/IconButton/index.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\n\nimport Icon from '../Icon';\nimport { OverlayTrigger } from '../Overlay';\nimport Tooltip from '../Tooltip';\n\nconst IconButton = React.forwardRef(({\n className,\n alt,\n invertColors,\n icon,\n src,\n iconClassNames,\n onClick,\n size,\n variant,\n iconAs,\n isActive,\n ...attrs\n}, ref) => {\n const invert = invertColors ? 'inverse-' : '';\n const activeStyle = isActive ? `${variant}-` : '';\n const IconComponent = iconAs;\n\n return (\n <button\n aria-label={alt}\n className={classNames(\n 'btn-icon',\n `btn-icon-${invert}${variant}`,\n `btn-icon-${size}`,\n {\n [`btn-icon-${invert}${activeStyle}active`]: isActive,\n },\n className,\n )}\n onClick={onClick}\n type=\"button\"\n ref={ref}\n {...attrs}\n >\n <span className=\"btn-icon__icon-container\">\n <IconComponent\n className={classNames('btn-icon__icon', iconClassNames)}\n icon={icon}\n src={src}\n />\n </span>\n </button>\n );\n});\n\nIconButton.defaultProps = {\n iconAs: Icon,\n src: null,\n icon: undefined,\n iconClassNames: undefined,\n className: undefined,\n invertColors: false,\n variant: 'primary',\n size: 'md',\n onClick: () => {},\n isActive: false,\n};\n\nIconButton.propTypes = {\n /** A custom class name. */\n className: PropTypes.string,\n /** Component that renders the icon, currently defaults to `Icon` */\n iconAs: PropTypes.elementType,\n /** An icon component to render. Example import of a Paragon icon component:\n * `import { Check } from '@edx/paragon/dist/icon';`\n * */\n src: PropTypes.oneOfType([PropTypes.element, PropTypes.elementType]),\n /** Alt text for your icon. For best practice, avoid using alt text to describe\n * the image in the `IconButton`. Instead, we recommend describing the function\n * of the button. */\n alt: PropTypes.string.isRequired,\n /** Changes icon styles for dark background */\n invertColors: PropTypes.bool,\n /** Accepts a [Paragon icon](https://paragon-openedx.netlify.app/foundations/icons) */\n icon: PropTypes.shape({\n prefix: PropTypes.string,\n iconName: PropTypes.string,\n // eslint-disable-next-line react/forbid-prop-types\n icon: PropTypes.array,\n }),\n /** Extra class names that will be added to the icon */\n iconClassNames: PropTypes.string,\n /** Click handler for the button */\n onClick: PropTypes.func,\n /** Type of button (uses Bootstrap options) */\n variant: PropTypes.oneOf(['primary', 'secondary', 'success', 'warning', 'danger', 'light', 'dark', 'black', 'brand']),\n /** size of button to render */\n size: PropTypes.oneOf(['sm', 'md', 'inline']),\n /** whether to show the `IconButton` in an active state, whose styling is distinct from default state */\n isActive: PropTypes.bool,\n};\n\n/**\n *\n * @param { object } args Arguments\n * @param { string } args.tooltipPlacement choose from https://popper.js.org/docs/v2/constructors/#options\n * @param { React.Component } args.tooltipContent any content to pass to tooltip content area\n * @returns { IconButton } a button wrapped in overlaytrigger\n */\nfunction IconButtonWithTooltip({\n tooltipPlacement, tooltipContent, variant, invertColors, ...props\n}) {\n const invert = invertColors ? 'inverse-' : '';\n return (\n <OverlayTrigger\n placement={tooltipPlacement}\n overlay={(\n <Tooltip\n id={`iconbutton-tooltip-${tooltipPlacement}`}\n variant={invert ? 'light' : ''}\n >\n {tooltipContent}\n </Tooltip>\n )}\n >\n <IconButton variant={variant} invertColors={invertColors} {...props} />\n </OverlayTrigger>\n );\n}\n\nIconButtonWithTooltip.defaultProps = {\n tooltipPlacement: 'top',\n variant: 'primary',\n invertColors: false,\n};\n\nIconButtonWithTooltip.propTypes = {\n /** tooltip placement can be top, left, right etc, per https://popper.js.org/docs/v2/constructors/#options */\n tooltipPlacement: PropTypes.string,\n /** any valid JSX or text to be rendered as tooltip contents */\n tooltipContent: PropTypes.node.isRequired,\n /** Type of button (uses Bootstrap options) */\n variant: PropTypes.oneOf(['primary', 'secondary', 'success', 'warning', 'danger', 'light', 'dark', 'black', 'brand']),\n /** Changes icon styles for dark background */\n invertColors: PropTypes.bool,\n};\n\nIconButton.IconButtonWithTooltip = IconButtonWithTooltip;\n\nexport default IconButton;\nexport { IconButtonWithTooltip };\n"],"mappings":";;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AAEnC,OAAOC,IAAI,MAAM,SAAS;AAC1B,SAASC,cAAc,QAAQ,YAAY;AAC3C,OAAOC,OAAO,MAAM,YAAY;AAEhC,MAAMC,UAAU,gBAAGN,KAAK,CAACO,UAAU,CAAC,CAAAC,IAAA,EAajCC,GAAG,KAAK;EAAA,IAb0B;MACnCC,SAAS;MACTC,GAAG;MACHC,YAAY;MACZC,IAAI;MACJC,GAAG;MACHC,cAAc;MACdC,OAAO;MACPC,IAAI;M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AC7C,oBACEZ,KAAA,CAAA2B,aAAA,CAACvB,cAAc;IACb+C,SAAS,EAAEJ,gBAAiB;IAC5BK,OAAO,eACLpD,KAAA,CAAA2B,aAAA,CAACtB,OAAO;MACNgD,EAAE,EAAG,sBAAqBN,gBAAiB,EAAE;MAC7C7B,OAAO,EAAEM,MAAM,GAAG,OAAO,GAAG;IAAG,GAE9BwB,cACM;EACT,gBAEFhD,KAAA,CAAA2B,aAAA,CAACrB,UAAU,EAAAsB,QAAA;IAACV,OAAO,EAAEA,OAAQ;IAACN,YAAY,EAAEA;EAAa,GAAKqC,KAAK,CAAG,CACxD,CAAC;AAErB;AAEAJ,qBAAqB,CAACf,YAAY,GAAG;EACnCiB,gBAAgB,EAAE,KAAK;EACvB7B,OAAO,EAAE,SAAS;EAClBN,YAAY,EAAE;AAChB,CAAC;AAEDiC,qBAAqB,CAACb,SAAS,GAAG;EAChC;EACAe,gBAAgB,EAAE9C,SAAS,CAACgC,MAAM;EAClC;EACAe,cAAc,EAAE/C,SAAS,CAACqD,IAAI,CAACjB,UAAU;EACzC;EACAnB,OAAO,EAAEjB,SAAS,CAAC2C,KAAK,CAAC,CAAC,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;EACrH;EACAhC,YAAY,EAAEX,SAAS,CAACqC;AAC1B,CAAC;AAEDhC,UAAU,CAACuC,qBAAqB,GAAGA,qBAAqB;AAExD,eAAevC,UAAU;AACzB,SAASuC,qBAAqB"}
|
package/dist/Layout/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","Col","Row","PropTypes","COL_VALUES","SIZES","LayoutElement","forwardRef","props","ref","createElement","_extends","Layout","_ref","children","_objectWithoutProperties","_excluded","childrenLength","length","isValidDimensions","dataList","validLength","errors","layout","Children","map","child","index","newProps","_objectSpread","forEach","size","sizeProps","span","offset","undefined","Object","keys","breakpoint","console","error","defaultProps","xs","sm","md","lg","xl","propTypes","node","isRequired","arrayOf","shape","oneOf","sizeDefaultProps","Element"],"sources":["../../src/Layout/index.jsx"],"sourcesContent":["import React from 'react';\nimport Col from 'react-bootstrap/Col';\nimport Row from 'react-bootstrap/Row';\nimport PropTypes from 'prop-types';\n\nconst COL_VALUES = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 'auto'];\nconst SIZES = ['xs', 'sm', 'md', 'lg', 'xl'];\n\nconst LayoutElement = React.forwardRef((props, ref) => <div ref={ref} {...props} />);\n\nconst Layout = React.forwardRef(({ children, ...props }, ref) => {\n const childrenLength = children.length;\n\n const isValidDimensions = (dataList, validLength) => !dataList || dataList.length === validLength;\n const errors = {};\n\n const layout = React.Children.map(children, (child, index) => {\n const newProps = { ...child.props };\n SIZES.forEach(size => {\n const sizeProps = props[size];\n const { span = 0, offset = 0 } = (sizeProps && sizeProps[index]) || {};\n if (errors[size] === undefined) {\n errors[size] = false;\n if (!isValidDimensions(sizeProps, childrenLength)) {\n errors[size] = `${size} prop accepts array which length must be equal to the number of children.`;\n }\n }\n newProps[size] = { span, offset };\n });\n newProps.ref = child.ref;\n return React.createElement(Col, newProps, child.props.children);\n });\n\n Object.keys(errors).forEach(breakpoint => {\n if (errors[breakpoint]) {\n // eslint-disable-next-line no-console\n console.error(errors[breakpoint]);\n }\n });\n\n return (\n <Row ref={ref}>\n {layout}\n </Row>\n );\n});\n\nLayout.defaultProps = {\n xs: undefined,\n sm: undefined,\n md: undefined,\n lg: undefined,\n xl: undefined,\n};\n\nLayout.propTypes = {\n children: PropTypes.node.isRequired,\n xs: PropTypes.arrayOf(PropTypes.shape({\n span: PropTypes.oneOf(COL_VALUES).isRequired,\n offset: PropTypes.oneOf(COL_VALUES),\n })),\n sm: PropTypes.arrayOf(PropTypes.shape({\n span: PropTypes.oneOf(COL_VALUES).isRequired,\n offset: PropTypes.oneOf(COL_VALUES),\n })),\n md: PropTypes.arrayOf(PropTypes.shape({\n span: PropTypes.oneOf(COL_VALUES).isRequired,\n offset: PropTypes.oneOf(COL_VALUES),\n })),\n lg: PropTypes.arrayOf(PropTypes.shape({\n span: PropTypes.oneOf(COL_VALUES).isRequired,\n offset: PropTypes.oneOf(COL_VALUES),\n })),\n xl: PropTypes.arrayOf(PropTypes.shape({\n span: PropTypes.oneOf(COL_VALUES).isRequired,\n offset: PropTypes.oneOf(COL_VALUES),\n })),\n};\n\nconst sizeDefaultProps = { span: [], offset: [] };\n\nSIZES.forEach(size => {\n // eslint-disable-next-line react/default-props-match-prop-types\n Layout.defaultProps[size] = sizeDefaultProps;\n});\n\nexport {
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","Col","Row","PropTypes","COL_VALUES","SIZES","LayoutElement","forwardRef","props","ref","createElement","_extends","Layout","_ref","children","_objectWithoutProperties","_excluded","childrenLength","length","isValidDimensions","dataList","validLength","errors","layout","Children","map","child","index","newProps","_objectSpread","forEach","size","sizeProps","span","offset","undefined","Object","keys","breakpoint","console","error","defaultProps","xs","sm","md","lg","xl","propTypes","node","isRequired","arrayOf","shape","oneOf","sizeDefaultProps","Element"],"sources":["../../src/Layout/index.jsx"],"sourcesContent":["import React from 'react';\nimport Col from 'react-bootstrap/Col';\nimport Row from 'react-bootstrap/Row';\nimport PropTypes from 'prop-types';\n\nconst COL_VALUES = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 'auto'];\nconst SIZES = ['xs', 'sm', 'md', 'lg', 'xl'];\n\nconst LayoutElement = React.forwardRef((props, ref) => <div ref={ref} {...props} />);\n\nconst Layout = React.forwardRef(({ children, ...props }, ref) => {\n const childrenLength = children.length;\n\n const isValidDimensions = (dataList, validLength) => !dataList || dataList.length === validLength;\n const errors = {};\n\n const layout = React.Children.map(children, (child, index) => {\n const newProps = { ...child.props };\n SIZES.forEach(size => {\n const sizeProps = props[size];\n const { span = 0, offset = 0 } = (sizeProps && sizeProps[index]) || {};\n if (errors[size] === undefined) {\n errors[size] = false;\n if (!isValidDimensions(sizeProps, childrenLength)) {\n errors[size] = `${size} prop accepts array which length must be equal to the number of children.`;\n }\n }\n newProps[size] = { span, offset };\n });\n newProps.ref = child.ref;\n return React.createElement(Col, newProps, child.props.children);\n });\n\n Object.keys(errors).forEach(breakpoint => {\n if (errors[breakpoint]) {\n // eslint-disable-next-line no-console\n console.error(errors[breakpoint]);\n }\n });\n\n return (\n <Row ref={ref}>\n {layout}\n </Row>\n );\n});\n\nLayout.defaultProps = {\n xs: undefined,\n sm: undefined,\n md: undefined,\n lg: undefined,\n xl: undefined,\n};\n\nLayout.propTypes = {\n children: PropTypes.node.isRequired,\n xs: PropTypes.arrayOf(PropTypes.shape({\n span: PropTypes.oneOf(COL_VALUES).isRequired,\n offset: PropTypes.oneOf(COL_VALUES),\n })),\n sm: PropTypes.arrayOf(PropTypes.shape({\n span: PropTypes.oneOf(COL_VALUES).isRequired,\n offset: PropTypes.oneOf(COL_VALUES),\n })),\n md: PropTypes.arrayOf(PropTypes.shape({\n span: PropTypes.oneOf(COL_VALUES).isRequired,\n offset: PropTypes.oneOf(COL_VALUES),\n })),\n lg: PropTypes.arrayOf(PropTypes.shape({\n span: PropTypes.oneOf(COL_VALUES).isRequired,\n offset: PropTypes.oneOf(COL_VALUES),\n })),\n xl: PropTypes.arrayOf(PropTypes.shape({\n span: PropTypes.oneOf(COL_VALUES).isRequired,\n offset: PropTypes.oneOf(COL_VALUES),\n })),\n};\n\nconst sizeDefaultProps = { span: [], offset: [] };\n\nSIZES.forEach(size => {\n // eslint-disable-next-line react/default-props-match-prop-types\n Layout.defaultProps[size] = sizeDefaultProps;\n});\n\nexport { Col, Row };\nLayout.Element = LayoutElement;\nexport default Layout;\n"],"mappings":";;;;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,GAAG,MAAM,qBAAqB;AACrC,OAAOC,GAAG,MAAM,qBAAqB;AACrC,OAAOC,SAAS,MAAM,YAAY;AAElC,M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AAC9C,CAAC,CAAC;AAEF,SAASpD,GAAG,EAAEC,GAAG;AACjBU,MAAM,CAAC0C,OAAO,GAAGhD,aAAa;AAC9B,eAAeM,MAAM"}
|
package/dist/Menu/MenuItem.js
CHANGED
|
@@ -44,9 +44,9 @@ MenuItem.propTypes = {
|
|
|
44
44
|
/** Specifies the base element */
|
|
45
45
|
as: PropTypes.elementType,
|
|
46
46
|
/** Specifies the jsx before the content of the ``MenuItem`` */
|
|
47
|
-
iconBefore: PropTypes.oneOfType([PropTypes.element, PropTypes.
|
|
47
|
+
iconBefore: PropTypes.oneOfType([PropTypes.element, PropTypes.elementType]),
|
|
48
48
|
/** Specifies the jsx after the content of the ``MenuItem`` */
|
|
49
|
-
iconAfter: PropTypes.oneOfType([PropTypes.element, PropTypes.
|
|
49
|
+
iconAfter: PropTypes.oneOfType([PropTypes.element, PropTypes.elementType])
|
|
50
50
|
};
|
|
51
51
|
MenuItem.defaultProps = {
|
|
52
52
|
defaultSelected: false,
|