@openedx/paragon 22.5.0 → 22.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Button/index.d.ts +35 -0
- package/dist/Button/index.js +38 -15
- package/dist/Button/index.js.map +1 -1
- package/dist/Chip/ChipIcon.d.ts +2 -2
- package/dist/Chip/ChipIcon.js.map +1 -1
- package/dist/Chip/index.d.ts +2 -2
- package/dist/Chip/index.js +2 -2
- package/dist/Chip/index.js.map +1 -1
- package/dist/Hyperlink/index.d.ts +1 -1
- package/dist/Icon/index.d.ts +4 -2
- package/dist/Icon/index.js +1 -1
- package/dist/Icon/index.js.map +1 -1
- package/dist/Modal/_ModalDialog.scss +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/paragon.css +1 -1
- package/dist/utils/types/bootstrap.d.ts +39 -0
- package/dist/utils/types/bootstrap.js +2 -0
- package/dist/utils/types/bootstrap.js.map +1 -0
- package/package.json +3 -3
- package/src/Button/{Button.test.jsx → Button.test.tsx} +14 -2
- package/src/Button/__snapshots__/{Button.test.jsx.snap → Button.test.tsx.snap} +19 -2
- package/src/Button/{index.jsx → index.tsx} +59 -16
- package/src/Chip/ChipIcon.tsx +1 -1
- package/src/Chip/index.tsx +5 -5
- package/src/Icon/index.d.ts +4 -2
- package/src/Icon/index.jsx +1 -1
- package/src/Modal/_ModalDialog.scss +4 -0
- package/src/index.d.ts +1 -1
- package/src/index.js +3 -3
- package/src/utils/types/bootstrap.test.tsx +86 -0
- package/src/utils/types/bootstrap.ts +43 -0
- /package/src/Button/{ButtonGroup.test.jsx → ButtonGroup.test.tsx} +0 -0
- /package/src/Button/{ButtonToolbar.test.jsx → ButtonToolbar.test.tsx} +0 -0
- /package/src/Button/__snapshots__/{ButtonGroup.test.jsx.snap → ButtonGroup.test.tsx.snap} +0 -0
- /package/src/Button/__snapshots__/{ButtonToolbar.test.jsx.snap → ButtonToolbar.test.tsx.snap} +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type ButtonProps as BaseButtonProps } from 'react-bootstrap/Button';
|
|
3
|
+
import { type ButtonGroupProps as BaseButtonGroupProps } from 'react-bootstrap/ButtonGroup';
|
|
4
|
+
import { type ButtonToolbarProps } from 'react-bootstrap/ButtonToolbar';
|
|
5
|
+
import type { ComponentWithAsProp } from '../utils/types/bootstrap';
|
|
6
|
+
interface ButtonProps extends Omit<BaseButtonProps, 'size'> {
|
|
7
|
+
/**
|
|
8
|
+
* An icon component to render. Example:
|
|
9
|
+
* ```
|
|
10
|
+
* import { Close } from '@openedx/paragon/icons';
|
|
11
|
+
* <Button iconBefore={Close}>Close</Button>
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
iconBefore?: React.ComponentType;
|
|
15
|
+
/**
|
|
16
|
+
* An icon component to render. Example:
|
|
17
|
+
* ```
|
|
18
|
+
* import { Close } from '@openedx/paragon/icons';
|
|
19
|
+
* <Button iconAfter={Close}>Close</Button>
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
iconAfter?: React.ComponentType;
|
|
23
|
+
size?: 'sm' | 'md' | 'lg' | 'inline';
|
|
24
|
+
}
|
|
25
|
+
type ButtonType = ComponentWithAsProp<'button', ButtonProps> & {
|
|
26
|
+
Deprecated?: any;
|
|
27
|
+
};
|
|
28
|
+
declare const Button: ButtonType;
|
|
29
|
+
interface ButtonGroupProps extends Omit<BaseButtonGroupProps, 'size'> {
|
|
30
|
+
size?: 'sm' | 'md' | 'lg' | 'inline';
|
|
31
|
+
}
|
|
32
|
+
declare const ButtonGroup: ComponentWithAsProp<'div', ButtonGroupProps>;
|
|
33
|
+
declare const ButtonToolbar: ComponentWithAsProp<'div', ButtonToolbarProps>;
|
|
34
|
+
export default Button;
|
|
35
|
+
export { ButtonGroup, ButtonToolbar };
|
package/dist/Button/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _excluded = ["children", "iconAfter", "iconBefore"]
|
|
2
|
+
var _excluded = ["children", "iconAfter", "iconBefore", "size"],
|
|
3
|
+
_excluded2 = ["size"];
|
|
3
4
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
5
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
6
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -14,27 +15,31 @@ import classNames from 'classnames';
|
|
|
14
15
|
import BaseButton from 'react-bootstrap/Button';
|
|
15
16
|
import BaseButtonGroup from 'react-bootstrap/ButtonGroup';
|
|
16
17
|
import BaseButtonToolbar from 'react-bootstrap/ButtonToolbar';
|
|
18
|
+
// @ts-ignore - we're not going to bother adding types for the deprecated button
|
|
17
19
|
import ButtonDeprecated from './deprecated';
|
|
18
20
|
import Icon from '../Icon';
|
|
19
21
|
var Button = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
20
22
|
var children = _ref.children,
|
|
21
23
|
iconAfter = _ref.iconAfter,
|
|
22
24
|
iconBefore = _ref.iconBefore,
|
|
25
|
+
size = _ref.size,
|
|
23
26
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
24
|
-
return /*#__PURE__*/React.createElement(BaseButton, _extends({
|
|
27
|
+
return /*#__PURE__*/React.createElement(BaseButton, _extends({
|
|
28
|
+
size: size // Bootstrap's <Button> types do not allow 'md' or 'inline', but we do.
|
|
29
|
+
}, props, {
|
|
25
30
|
className: classNames(props.className),
|
|
26
31
|
ref: ref
|
|
27
32
|
}), iconBefore && /*#__PURE__*/React.createElement(Icon, {
|
|
28
33
|
className: "btn-icon-before",
|
|
29
|
-
size:
|
|
34
|
+
size: size,
|
|
30
35
|
src: iconBefore
|
|
31
36
|
}), children, iconAfter && /*#__PURE__*/React.createElement(Icon, {
|
|
32
37
|
className: "btn-icon-after",
|
|
33
|
-
size:
|
|
38
|
+
size: size,
|
|
34
39
|
src: iconAfter
|
|
35
40
|
}));
|
|
36
41
|
});
|
|
37
|
-
Button.propTypes =
|
|
42
|
+
Button.propTypes = {
|
|
38
43
|
/** Specifies class name to apply to the button */
|
|
39
44
|
className: PropTypes.string,
|
|
40
45
|
/** Disables the Button, preventing mouse events, even if the underlying component is an `<a>` element */
|
|
@@ -60,11 +65,14 @@ Button.propTypes = _objectSpread(_objectSpread({}, Button.propTypes), {}, {
|
|
|
60
65
|
variant: PropTypes.string,
|
|
61
66
|
/** An icon component to render.
|
|
62
67
|
* Example import of a Paragon icon component: `import { Check } from '@openedx/paragon/icons';` */
|
|
63
|
-
iconBefore: PropTypes.
|
|
68
|
+
iconBefore: PropTypes.elementType,
|
|
64
69
|
/** An icon component to render.
|
|
65
70
|
* Example import of a Paragon icon component: `import { Check } from '@openedx/paragon/icons';` */
|
|
66
|
-
iconAfter: PropTypes.
|
|
67
|
-
|
|
71
|
+
iconAfter: PropTypes.elementType
|
|
72
|
+
// The 'as' type casting above is required for TypeScript checking, because the 'PropTypes.elementType' type normally
|
|
73
|
+
// allows strings as a value (for use cases like 'div') but we don't support that for <Icon />/iconBefore/iconAfter.
|
|
74
|
+
// The React TypeScript type definitions are more specific (React.ComponentType vs React.ElementType).
|
|
75
|
+
};
|
|
68
76
|
Button.defaultProps = _objectSpread(_objectSpread({}, Button.defaultProps), {}, {
|
|
69
77
|
children: undefined,
|
|
70
78
|
className: undefined,
|
|
@@ -73,19 +81,29 @@ Button.defaultProps = _objectSpread(_objectSpread({}, Button.defaultProps), {},
|
|
|
73
81
|
disabled: false
|
|
74
82
|
});
|
|
75
83
|
Button.Deprecated = ButtonDeprecated;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
|
|
85
|
+
// We could just re-export 'ButtonGroup' and 'ButtonToolbar', but we currently
|
|
86
|
+
// override them to add propTypes validation at runtime, since most Paragon
|
|
87
|
+
// consumers aren't using TypeScript yet. We also force ButtonGroup's 'size'
|
|
88
|
+
// prop to accept our custom values of 'md' and 'inline' which are used in
|
|
89
|
+
// Paragon but not used in the base Bootstrap classes.
|
|
90
|
+
|
|
91
|
+
var ButtonGroup = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
92
|
+
var size = _ref2.size,
|
|
93
|
+
props = _objectWithoutProperties(_ref2, _excluded2);
|
|
94
|
+
return /*#__PURE__*/React.createElement(BaseButtonGroup, _extends({
|
|
95
|
+
size: size
|
|
96
|
+
}, props, {
|
|
97
|
+
ref: ref
|
|
98
|
+
}));
|
|
99
|
+
});
|
|
82
100
|
ButtonGroup.propTypes = {
|
|
83
101
|
/** Specifies element type for this component. */
|
|
84
102
|
as: PropTypes.elementType,
|
|
85
103
|
/** An ARIA role describing the button group. */
|
|
86
104
|
role: PropTypes.string,
|
|
87
105
|
/** Specifies the size for all Buttons in the group. */
|
|
88
|
-
size: PropTypes.oneOf(['sm', 'md', 'lg']),
|
|
106
|
+
size: PropTypes.oneOf(['sm', 'md', 'lg', 'inline']),
|
|
89
107
|
/** Display as a button toggle group. */
|
|
90
108
|
toggle: PropTypes.bool,
|
|
91
109
|
/** Specifies if the set of Buttons should appear vertically stacked. */
|
|
@@ -101,6 +119,11 @@ ButtonGroup.defaultProps = {
|
|
|
101
119
|
bsPrefix: 'btn-group',
|
|
102
120
|
size: 'md'
|
|
103
121
|
};
|
|
122
|
+
var ButtonToolbar = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
123
|
+
return /*#__PURE__*/React.createElement(BaseButtonToolbar, _extends({}, props, {
|
|
124
|
+
ref: ref
|
|
125
|
+
}));
|
|
126
|
+
});
|
|
104
127
|
ButtonToolbar.propTypes = {
|
|
105
128
|
/** An ARIA role describing the button group. */
|
|
106
129
|
role: PropTypes.string,
|
package/dist/Button/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","PropTypes","classNames","BaseButton","BaseButtonGroup","BaseButtonToolbar","ButtonDeprecated","Icon","Button","forwardRef","_ref","ref","children","iconAfter","iconBefore","props","_objectWithoutProperties","_excluded","createElement","_extends","className","
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","PropTypes","classNames","BaseButton","BaseButtonGroup","BaseButtonToolbar","ButtonDeprecated","Icon","Button","forwardRef","_ref","ref","children","iconAfter","iconBefore","size","props","_objectWithoutProperties","_excluded","createElement","_extends","className","src","propTypes","string","disabled","bool","node","isRequired","onClick","func","onKeyDown","type","variant","elementType","defaultProps","_objectSpread","undefined","Deprecated","ButtonGroup","_ref2","_excluded2","as","role","oneOf","toggle","vertical","bsPrefix","ButtonToolbar"],"sources":["../../src/Button/index.tsx"],"sourcesContent":["import React from 'react';\nimport PropTypes, { type Requireable } from 'prop-types';\nimport classNames from 'classnames';\nimport BaseButton, { type ButtonProps as BaseButtonProps } from 'react-bootstrap/Button';\nimport BaseButtonGroup, { type ButtonGroupProps as BaseButtonGroupProps } from 'react-bootstrap/ButtonGroup';\nimport BaseButtonToolbar, { type ButtonToolbarProps } from 'react-bootstrap/ButtonToolbar';\nimport type { ComponentWithAsProp } from '../utils/types/bootstrap';\n// @ts-ignore - we're not going to bother adding types for the deprecated button\nimport ButtonDeprecated from './deprecated';\n\nimport Icon from '../Icon';\n\ninterface ButtonProps extends Omit<BaseButtonProps, 'size'> {\n /**\n * An icon component to render. Example:\n * ```\n * import { Close } from '@openedx/paragon/icons';\n * <Button iconBefore={Close}>Close</Button>\n * ```\n */\n iconBefore?: React.ComponentType;\n /**\n * An icon component to render. Example:\n * ```\n * import { Close } from '@openedx/paragon/icons';\n * <Button iconAfter={Close}>Close</Button>\n * ```\n */\n iconAfter?: React.ComponentType;\n size?: 'sm' | 'md' | 'lg' | 'inline';\n}\n\ntype ButtonType = ComponentWithAsProp<'button', ButtonProps> & { Deprecated?: any };\n\nconst Button: ButtonType = React.forwardRef<HTMLButtonElement, ButtonProps>(({\n children,\n iconAfter,\n iconBefore,\n size,\n ...props\n}, ref) => (\n <BaseButton\n size={size as 'sm' | 'lg' | undefined} // Bootstrap's <Button> types do not allow 'md' or 'inline', but we do.\n {...props}\n className={classNames(props.className)}\n ref={ref}\n >\n {iconBefore && <Icon className=\"btn-icon-before\" size={size} src={iconBefore} />}\n {children}\n {iconAfter && <Icon className=\"btn-icon-after\" size={size} src={iconAfter} />}\n </BaseButton>\n));\n\nButton.propTypes = {\n /** Specifies class name to apply to the button */\n className: PropTypes.string,\n /** Disables the Button, preventing mouse events, even if the underlying component is an `<a>` element */\n disabled: PropTypes.bool,\n /** Specifies the text that is displayed within the button. */\n children: PropTypes.node.isRequired,\n /** A function that would specify what the button should do when the `onClick` event is triggered.\n * For example, the button could launch a `Modal`. The default is an empty function. */\n onClick: PropTypes.func,\n /** A function that would specify what the button should do when the `onKeyDown` event is triggered.\n * For example, this could handle using the `Escape` key to trigger the button's action.\n * The default is an empty function. */\n onKeyDown: PropTypes.func,\n /** Used to set the `type` attribute on the `button` tag. The default type is `button`. */\n type: PropTypes.string,\n /** Specifies variant to use.\n * Can be on of the base variants: `primary`, `secondary`, `success`, `danger`, `warning`, `info`, `dark`,\n * `light`, `link`\n *\n * as well as one of the customized variants (= base variant prefixed with `inverse-`, `outline-`\n * or `inverse-outline-`)\n * */\n variant: PropTypes.string,\n /** An icon component to render.\n * Example import of a Paragon icon component: `import { Check } from '@openedx/paragon/icons';` */\n iconBefore: PropTypes.elementType as Requireable<React.ComponentType>,\n /** An icon component to render.\n * Example import of a Paragon icon component: `import { Check } from '@openedx/paragon/icons';` */\n iconAfter: PropTypes.elementType as Requireable<React.ComponentType>,\n // The 'as' type casting above is required for TypeScript checking, because the 'PropTypes.elementType' type normally\n // allows strings as a value (for use cases like 'div') but we don't support that for <Icon />/iconBefore/iconAfter.\n // The React TypeScript type definitions are more specific (React.ComponentType vs React.ElementType).\n};\n\nButton.defaultProps = {\n ...Button.defaultProps,\n children: undefined,\n className: undefined,\n iconBefore: undefined,\n iconAfter: undefined,\n disabled: false,\n};\n\nButton.Deprecated = ButtonDeprecated;\n\n// We could just re-export 'ButtonGroup' and 'ButtonToolbar', but we currently\n// override them to add propTypes validation at runtime, since most Paragon\n// consumers aren't using TypeScript yet. We also force ButtonGroup's 'size'\n// prop to accept our custom values of 'md' and 'inline' which are used in\n// Paragon but not used in the base Bootstrap classes.\n\ninterface ButtonGroupProps extends Omit<BaseButtonGroupProps, 'size'> {\n size?: 'sm' | 'md' | 'lg' | 'inline';\n}\n\nconst ButtonGroup: ComponentWithAsProp<'div', ButtonGroupProps> = (\n React.forwardRef<HTMLButtonElement, ButtonGroupProps>(({ size, ...props }, ref) => (\n <BaseButtonGroup size={size as 'sm' | 'lg'} {...props} ref={ref} />\n ))\n);\n\nButtonGroup.propTypes = {\n /** Specifies element type for this component. */\n as: PropTypes.elementType,\n /** An ARIA role describing the button group. */\n role: PropTypes.string,\n /** Specifies the size for all Buttons in the group. */\n size: PropTypes.oneOf(['sm', 'md', 'lg', 'inline']),\n /** Display as a button toggle group. */\n toggle: PropTypes.bool,\n /** Specifies if the set of Buttons should appear vertically stacked. */\n vertical: PropTypes.bool,\n /** Overrides underlying component base CSS class name */\n bsPrefix: PropTypes.string,\n};\n\nButtonGroup.defaultProps = {\n as: 'div',\n role: 'group',\n toggle: false,\n vertical: false,\n bsPrefix: 'btn-group',\n size: 'md',\n};\n\nconst ButtonToolbar: ComponentWithAsProp<'div', ButtonToolbarProps> = (\n React.forwardRef<HTMLButtonElement, ButtonToolbarProps>((props, ref) => (\n <BaseButtonToolbar {...props} ref={ref} />\n ))\n);\n\nButtonToolbar.propTypes = {\n /** An ARIA role describing the button group. */\n role: PropTypes.string,\n /** Overrides underlying component base CSS class name */\n bsPrefix: PropTypes.string,\n};\n\nButtonToolbar.defaultProps = {\n role: 'toolbar',\n bsPrefix: 'btn-toolbar',\n};\n\nexport default Button;\nexport { ButtonGroup, ButtonToolbar };\n"],"mappings":";;;;;;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAA4B,YAAY;AACxD,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,UAAU,MAA+C,wBAAwB;AACxF,OAAOC,eAAe,MAAyD,6BAA6B;AAC5G,OAAOC,iBAAiB,MAAmC,+BAA+B;AAE1F;AACA,OAAOC,gBAAgB,MAAM,cAAc;AAE3C,OAAOC,IAAI,MAAM,SAAS;AAwB1B,IAAMC,MAAkB,gBAAGR,KAAK,CAACS,UAAU,CAAiC,UAAAC,IAAA,EAMzEC,GAAG;EAAA,IALJC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IACRC,SAAS,GAAAH,IAAA,CAATG,SAAS;IACTC,UAAU,GAAAJ,IAAA,CAAVI,UAAU;IACVC,IAAI,GAAAL,IAAA,CAAJK,IAAI;IACDC,KAAK,GAAAC,wBAAA,CAAAP,IAAA,EAAAQ,SAAA;EAAA,oBAERlB,KAAA,CAAAmB,aAAA,CAAChB,UAAU,EAAAiB,QAAA;IACTL,IAAI,EAAEA,IAAgC,CAAC;EAAA,GACnCC,KAAK;IACTK,SAAS,EAAEnB,UAAU,CAACc,KAAK,CAACK,SAA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C;AAEDwB,aAAa,CAACb,YAAY,GAAG;EAC3BQ,IAAI,EAAE,SAAS;EACfI,QAAQ,EAAE;AACZ,CAAC;AAED,eAAevC,MAAM;AACrB,SAAS+B,WAAW,EAAES,aAAa","ignoreList":[]}
|
package/dist/Chip/ChipIcon.d.ts
CHANGED
|
@@ -2,13 +2,13 @@ import React, { KeyboardEventHandler, MouseEventHandler } from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
export interface ChipIconProps {
|
|
4
4
|
className: string;
|
|
5
|
-
src: React.
|
|
5
|
+
src: React.ComponentType;
|
|
6
6
|
onClick?: KeyboardEventHandler & MouseEventHandler;
|
|
7
7
|
alt?: string;
|
|
8
8
|
variant: string;
|
|
9
9
|
disabled?: boolean;
|
|
10
10
|
}
|
|
11
|
-
declare function ChipIcon({ className, src, onClick, alt, variant, disabled, }: ChipIconProps): JSX.Element;
|
|
11
|
+
declare function ChipIcon({ className, src, onClick, alt, variant, disabled, }: ChipIconProps): React.JSX.Element;
|
|
12
12
|
declare namespace ChipIcon {
|
|
13
13
|
var propTypes: {
|
|
14
14
|
className: PropTypes.Validator<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChipIcon.js","names":["React","PropTypes","Icon","IconButton","STYLE_VARIANTS","ChipIcon","_ref","className","src","onClick","alt","variant","disabled","createElement","iconAs","invertColors","DARK","tabIndex","size","propTypes","string","isRequired","oneOfType","element","func","bool","defaultProps","undefined","LIGHT"],"sources":["../../src/Chip/ChipIcon.tsx"],"sourcesContent":["import React, { KeyboardEventHandler, MouseEventHandler } from 'react';\nimport PropTypes from 'prop-types';\nimport Icon from '../Icon';\n// @ts-ignore\nimport IconButton from '../IconButton';\n// @ts-ignore\nimport { STYLE_VARIANTS } from './constants';\n\nexport interface ChipIconProps {\n className: string,\n src: React.
|
|
1
|
+
{"version":3,"file":"ChipIcon.js","names":["React","PropTypes","Icon","IconButton","STYLE_VARIANTS","ChipIcon","_ref","className","src","onClick","alt","variant","disabled","createElement","iconAs","invertColors","DARK","tabIndex","size","propTypes","string","isRequired","oneOfType","element","func","bool","defaultProps","undefined","LIGHT"],"sources":["../../src/Chip/ChipIcon.tsx"],"sourcesContent":["import React, { KeyboardEventHandler, MouseEventHandler } from 'react';\nimport PropTypes from 'prop-types';\nimport Icon from '../Icon';\n// @ts-ignore\nimport IconButton from '../IconButton';\n// @ts-ignore\nimport { STYLE_VARIANTS } from './constants';\n\nexport interface ChipIconProps {\n className: string,\n src: React.ComponentType,\n onClick?: KeyboardEventHandler & MouseEventHandler,\n alt?: string,\n variant: string,\n disabled?: boolean,\n}\n\nfunction ChipIcon({\n className, src, onClick, alt, variant, disabled,\n}: ChipIconProps) {\n if (onClick) {\n return (\n <IconButton\n className={className}\n src={src}\n onClick={onClick}\n iconAs={Icon}\n alt={alt}\n invertColors={variant === STYLE_VARIANTS.DARK}\n tabIndex={disabled ? -1 : 0}\n />\n );\n }\n\n return <Icon src={src} className={className} size=\"sm\" />;\n}\n\nChipIcon.propTypes = {\n className: PropTypes.string.isRequired,\n src: PropTypes.oneOfType([PropTypes.element, PropTypes.func]).isRequired,\n onClick: PropTypes.func,\n alt: PropTypes.string,\n variant: PropTypes.string,\n disabled: PropTypes.bool,\n};\n\nChipIcon.defaultProps = {\n onClick: undefined,\n alt: undefined,\n variant: STYLE_VARIANTS.LIGHT,\n disabled: false,\n};\n\nexport default ChipIcon;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAmD,OAAO;AACtE,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,IAAI,MAAM,SAAS;AAC1B;AACA,OAAOC,UAAU,MAAM,eAAe;AACtC;AACA,SAASC,cAAc,QAAQ,aAAa;AAW5C,SAASC,QAAQA,CAAAC,IAAA,EAEC;EAAA,IADhBC,SAAS,GAAAD,IAAA,CAATC,SAAS;IAAEC,GAAG,GAAAF,IAAA,CAAHE,GAAG;IAAEC,OAAO,GAAAH,IAAA,CAAPG,OAAO;IAAEC,GA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onClick?: KeyboardEventHandler & MouseEventHandler;
|
|
6
6
|
className?: string;
|
|
7
7
|
variant?: string;
|
|
8
|
-
iconBefore?: React.
|
|
8
|
+
iconBefore?: React.ComponentType;
|
|
9
9
|
iconBeforeAlt?: string;
|
|
10
|
-
iconAfter?: React.
|
|
10
|
+
iconAfter?: React.ComponentType;
|
|
11
11
|
iconAfterAlt?: string;
|
|
12
12
|
onIconBeforeClick?: KeyboardEventHandler & MouseEventHandler;
|
|
13
13
|
onIconAfterClick?: KeyboardEventHandler & MouseEventHandler;
|
package/dist/Chip/index.js
CHANGED
|
@@ -79,7 +79,7 @@ Chip.propTypes = {
|
|
|
79
79
|
*
|
|
80
80
|
* `import { Check } from '@openedx/paragon/icons';`
|
|
81
81
|
*/
|
|
82
|
-
iconBefore: PropTypes.
|
|
82
|
+
iconBefore: PropTypes.elementType,
|
|
83
83
|
/** Specifies icon alt text. */
|
|
84
84
|
iconBeforeAlt: requiredWhen(PropTypes.string, ['iconBefore', 'onIconBeforeClick']),
|
|
85
85
|
/** A click handler for the `Chip` icon before. */
|
|
@@ -90,7 +90,7 @@ Chip.propTypes = {
|
|
|
90
90
|
*
|
|
91
91
|
* `import { Check } from '@openedx/paragon/icons';`
|
|
92
92
|
*/
|
|
93
|
-
iconAfter: PropTypes.
|
|
93
|
+
iconAfter: PropTypes.elementType,
|
|
94
94
|
/** Specifies icon alt text. */
|
|
95
95
|
iconAfterAlt: requiredWhen(PropTypes.string, ['iconAfter', 'onIconAfterClick']),
|
|
96
96
|
/** A click handler for the `Chip` icon after. */
|
package/dist/Chip/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","PropTypes","classNames","requiredWhen","STYLE_VARIANTS","ChipIcon","CHIP_PGN_CLASS","Chip","forwardRef","_ref","ref","children","className","variant","iconBefore","iconBeforeAlt","iconAfter","iconAfterAlt","onIconBeforeClick","onIconAfterClick","disabled","isSelected","onClick","props","_objectWithoutProperties","_excluded","hasInteractiveIcons","isChipInteractive","interactionProps","onKeyPress","tabIndex","role","createElement","_extends","concat","selected","interactive","src","alt","propTypes","node","isRequired","string","oneOf","bool","func","
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","PropTypes","classNames","requiredWhen","STYLE_VARIANTS","ChipIcon","CHIP_PGN_CLASS","Chip","forwardRef","_ref","ref","children","className","variant","iconBefore","iconBeforeAlt","iconAfter","iconAfterAlt","onIconBeforeClick","onIconAfterClick","disabled","isSelected","onClick","props","_objectWithoutProperties","_excluded","hasInteractiveIcons","isChipInteractive","interactionProps","onKeyPress","tabIndex","role","createElement","_extends","concat","selected","interactive","src","alt","propTypes","node","isRequired","string","oneOf","bool","func","elementType","defaultProps","undefined","LIGHT"],"sources":["../../src/Chip/index.tsx"],"sourcesContent":["import React, { ForwardedRef, KeyboardEventHandler, MouseEventHandler } from 'react';\nimport PropTypes, { type Requireable } from 'prop-types';\nimport classNames from 'classnames';\n// @ts-ignore\nimport { requiredWhen } from '../utils/propTypes';\n// @ts-ignore\nimport { STYLE_VARIANTS } from './constants';\n// @ts-ignore\nimport ChipIcon from './ChipIcon';\n\nexport const CHIP_PGN_CLASS = 'pgn__chip';\n\nexport interface IChip {\n children: React.ReactNode,\n onClick?: KeyboardEventHandler & MouseEventHandler,\n className?: string,\n variant?: string,\n iconBefore?: React.ComponentType,\n iconBeforeAlt?: string,\n iconAfter?: React.ComponentType,\n iconAfterAlt?: string,\n onIconBeforeClick?: KeyboardEventHandler & MouseEventHandler,\n onIconAfterClick?: KeyboardEventHandler & MouseEventHandler,\n disabled?: boolean,\n isSelected?: boolean,\n}\n\nconst Chip = React.forwardRef(({\n children,\n className,\n variant,\n iconBefore,\n iconBeforeAlt,\n iconAfter,\n iconAfterAlt,\n onIconBeforeClick,\n onIconAfterClick,\n disabled,\n isSelected,\n onClick,\n ...props\n}: IChip, ref: ForwardedRef<HTMLDivElement>) => {\n const hasInteractiveIcons = !!(onIconBeforeClick || onIconAfterClick);\n const isChipInteractive = !hasInteractiveIcons && !!onClick;\n\n const interactionProps = isChipInteractive ? {\n onClick,\n onKeyPress: onClick,\n tabIndex: 0,\n role: 'button',\n } : {};\n\n return (\n <div\n className={classNames(\n CHIP_PGN_CLASS,\n `pgn__chip-${variant}`,\n className,\n { disabled, selected: isSelected, interactive: isChipInteractive },\n )}\n ref={ref}\n {...interactionProps}\n {...props}\n >\n {iconBefore && (\n <ChipIcon\n className={`${CHIP_PGN_CLASS}__icon-before`}\n src={iconBefore}\n onClick={onIconBeforeClick}\n alt={iconBeforeAlt}\n variant={variant}\n disabled={disabled}\n />\n )}\n <div\n className={classNames(`${CHIP_PGN_CLASS}__label`, {\n 'p-before': iconBefore,\n 'p-after': iconAfter,\n })}\n >\n {children}\n </div>\n {iconAfter && (\n <ChipIcon\n className={`${CHIP_PGN_CLASS}__icon-after`}\n src={iconAfter}\n onClick={onIconAfterClick}\n alt={iconAfterAlt}\n variant={variant}\n disabled={disabled}\n />\n )}\n </div>\n );\n});\n\nChip.propTypes = {\n /** Specifies the content of the `Chip`. */\n children: PropTypes.node.isRequired,\n /** Specifies an additional `className` to add to the base element. */\n className: PropTypes.string,\n /** The `Chip` style variant to use. */\n variant: PropTypes.oneOf(['light', 'dark']),\n /** Disables the `Chip`. */\n disabled: PropTypes.bool,\n /** Click handler for the whole Chip, has effect only when Chip does not have any interactive icons. */\n onClick: PropTypes.func,\n /**\n * An icon component to render before the content.\n * Example import of a Paragon icon component:\n *\n * `import { Check } from '@openedx/paragon/icons';`\n */\n iconBefore: PropTypes.elementType as Requireable<React.ComponentType>,\n /** Specifies icon alt text. */\n iconBeforeAlt: requiredWhen(PropTypes.string, ['iconBefore', 'onIconBeforeClick']),\n /** A click handler for the `Chip` icon before. */\n onIconBeforeClick: PropTypes.func,\n /**\n * An icon component to render before after the content.\n * Example import of a Paragon icon component:\n *\n * `import { Check } from '@openedx/paragon/icons';`\n */\n iconAfter: PropTypes.elementType as Requireable<React.ComponentType>,\n /** Specifies icon alt text. */\n iconAfterAlt: requiredWhen(PropTypes.string, ['iconAfter', 'onIconAfterClick']),\n /** A click handler for the `Chip` icon after. */\n onIconAfterClick: PropTypes.func,\n /** Indicates if `Chip` has been selected. */\n isSelected: PropTypes.bool,\n};\n\nChip.defaultProps = {\n className: undefined,\n variant: STYLE_VARIANTS.LIGHT,\n disabled: false,\n onClick: undefined,\n iconBefore: undefined,\n iconAfter: undefined,\n onIconBeforeClick: undefined,\n onIconAfterClick: undefined,\n isSelected: false,\n iconAfterAlt: undefined,\n iconBeforeAlt: undefined,\n};\n\nexport default Chip;\n"],"mappings":";;;;AAAA,OAAOA,KAAK,MAAiE,OAAO;AACpF,OAAOC,SAAS,MAA4B,YAAY;AACxD,OAAOC,UAAU,MAAM,YAAY;AACnC;AACA,SAASC,YAAY,QAAQ,oBAAoB;AACjD;AACA,SAASC,cAAc,QAAQ,aAAa;AAC5C;AACA,OAAOC,QAAQ,MAAM,YAAY;AAEjC,OAAO,IAAMC,cAAc,GAAG,WAAW;AAiBzC,IAAMC,IAAI,gBAAGP,KAAK,CAACQ,UAAU,CAAC,UAAAC,IAAA,EAcpBC,GAAiC,EAAK;EAAA,IAb9CC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IACRC,SAAS,GAAAH,IAAA,CAATG,SAAS;IACTC,OAAO,GAAAJ,IAAA,CAAPI,OAAO;IACPC,UAAU,GAAAL,IAAA,CAAVK,UAAU;IACVC,aAAa,GAAAN,IAAA,CAAbM,aAAa;IACbC,SAAS,GAAAP,IAAA,CAATO,SAAS;IACTC,YAAY,GAAAR,IAAA,CAAZQ,YAAY;IACZC,iBAAiB,GAAAT,IAAA,CAAjBS,iBAAiB;IACjBC,gBAAgB,GAAAV,IAAA,CAAhBU,gBAAgB;IAChBC,QAAQ,GAAAX,IAAA,CAARW,QAAQ;IACRC,UAAU,GAAAZ,IAAA,CAAVY,UAAU;IACVC,OAAO,GAAAb,IAAA,CAAPa,OAAO;IACJC,KAAK,GAAAC,wBAAA,CAAAf,IAAA,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J,YAAY,EAAE+B,SAAS;EACvBjC,aAAa,EAAEiC;AACjB,CAAC;AAED,eAAezC,IAAI","ignoreList":[]}
|
|
@@ -20,5 +20,5 @@ interface Props extends Omit<React.ComponentPropsWithRef<'a'>, 'href' | 'target'
|
|
|
20
20
|
showLaunchIcon?: boolean;
|
|
21
21
|
target?: '_blank' | '_self';
|
|
22
22
|
}
|
|
23
|
-
declare const Hyperlink: React.ForwardRefExoticComponent<
|
|
23
|
+
declare const Hyperlink: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
|
|
24
24
|
export default Hyperlink;
|
package/dist/Icon/index.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
export interface IconProps extends React.ComponentPropsWithoutRef<'span'> {
|
|
4
|
-
|
|
4
|
+
// Note: React.ComponentType is what we want here. React.ElementType would allow some element type strings like "div",
|
|
5
|
+
// but we only want to allow components like 'Add' (a specific icon component function/class)
|
|
6
|
+
src?: React.ComponentType;
|
|
5
7
|
svgAttrs?: {
|
|
6
8
|
'aria-label'?: string;
|
|
7
9
|
'aria-labelledby'?: string;
|
|
8
10
|
};
|
|
9
11
|
id?: string | null;
|
|
10
|
-
size?: 'xs' | 'sm' | 'md' | 'lg';
|
|
12
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'inline';
|
|
11
13
|
className?: string | string[];
|
|
12
14
|
hidden?: boolean;
|
|
13
15
|
screenReaderText?: React.ReactNode;
|
package/dist/Icon/index.js
CHANGED
|
@@ -61,7 +61,7 @@ Icon.propTypes = {
|
|
|
61
61
|
* An icon component to render.
|
|
62
62
|
* Example import of a Paragon icon component: `import { Check } from '@openedx/paragon/icons';`
|
|
63
63
|
*/
|
|
64
|
-
src: PropTypes.
|
|
64
|
+
src: PropTypes.elementType,
|
|
65
65
|
/** HTML element attributes to pass through to the underlying svg element */
|
|
66
66
|
svgAttrs: PropTypes.shape({
|
|
67
67
|
'aria-label': PropTypes.string,
|
package/dist/Icon/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","PropTypes","classNames","newId","withDeprecatedProps","DeprTypes","Icon","_ref","Component","src","id","className","hidden","screenReaderText","svgAttrs","size","attrs","_objectWithoutProperties","_excluded","hasAriaLabel","mergedSvgProps","_objectSpread","undefined","createElement","_extends","_defineProperty","concat","role","focusable","Fragment","propTypes","
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","PropTypes","classNames","newId","withDeprecatedProps","DeprTypes","Icon","_ref","Component","src","id","className","hidden","screenReaderText","svgAttrs","size","attrs","_objectWithoutProperties","_excluded","hasAriaLabel","mergedSvgProps","_objectSpread","undefined","createElement","_extends","_defineProperty","concat","role","focusable","Fragment","propTypes","elementType","shape","string","oneOf","bool","oneOfType","element","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 '@openedx/paragon/icons';`\n */\n src: 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;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eAAelB,mBAAmB,CAACE,IAAI,EAAE,MAAM,EAAE;EAC/CK,SAAS,EAAE;IACT4B,QAAQ,EAAElC,SAAS,CAACmC,MAAM;IAC1BC,MAAM,EAAE,SAAAA,OAAAC,KAAK;MAAA,OAAI,OAAOA,KAAK,KAAK,QAAQ;IAAA;IAC1CC,SAAS,EAAE,SAAAA,UAAAD,KAAK;MAAA,OAAKE,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,GAAGA,KAAK,CAACI,IAAI,CAAC,GAAG,CAAC,GAAGJ,KAAK;IAAA,CAAC;IACpEK,OAAO,EAAE;EACX;AACF,CAAC,CAAC","ignoreList":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// Things that have types
|
|
6
6
|
// // // // // // // // // // // // // // // // // // // // // // // // // // //
|
|
7
7
|
export { default as Bubble } from './Bubble';
|
|
8
|
+
export { default as Button, ButtonGroup, ButtonToolbar } from './Button';
|
|
8
9
|
export { default as Chip, CHIP_PGN_CLASS } from './Chip';
|
|
9
10
|
export { default as ChipCarousel } from './ChipCarousel';
|
|
10
11
|
export { default as Hyperlink, HYPER_LINK_EXTERNAL_LINK_ALT_TEXT, HYPER_LINK_EXTERNAL_LINK_TITLE } from './Hyperlink';
|
|
@@ -21,7 +22,6 @@ export const Avatar: any; // from './Avatar';
|
|
|
21
22
|
export const AvatarButton: any; // from './AvatarButton';
|
|
22
23
|
export const Badge: any; // from './Badge';
|
|
23
24
|
export const Breadcrumb: any; // from './Breadcrumb';
|
|
24
|
-
export const Button: any, ButtonGroup: any, ButtonToolbar: any; // from './Button';
|
|
25
25
|
export const
|
|
26
26
|
Card: any,
|
|
27
27
|
CardColumns: any,
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
//
|
|
2
|
-
// and each line number is the same
|
|
1
|
+
// Keep this file in sync with the .d.ts file (manually). It's in the same order
|
|
2
|
+
// and each line number is the same, to make it easier.
|
|
3
3
|
|
|
4
4
|
// // // // // // // // // // // // // // // // // // // // // // // // // // //
|
|
5
5
|
// Things that have types
|
|
6
6
|
// // // // // // // // // // // // // // // // // // // // // // // // // // //
|
|
7
7
|
export { default as Bubble } from './Bubble';
|
|
8
|
+
export { default as Button, ButtonGroup, ButtonToolbar } from './Button';
|
|
8
9
|
export { default as Chip, CHIP_PGN_CLASS } from './Chip';
|
|
9
10
|
export { default as ChipCarousel } from './ChipCarousel';
|
|
10
11
|
export { default as Hyperlink, HYPER_LINK_EXTERNAL_LINK_ALT_TEXT, HYPER_LINK_EXTERNAL_LINK_TITLE } from './Hyperlink';
|
|
@@ -21,7 +22,6 @@ export { default as Avatar } from './Avatar';
|
|
|
21
22
|
export { default as AvatarButton } from './AvatarButton';
|
|
22
23
|
export { default as Badge } from './Badge';
|
|
23
24
|
export { default as Breadcrumb } from './Breadcrumb';
|
|
24
|
-
export { default as Button, ButtonGroup, ButtonToolbar } from './Button';
|
|
25
25
|
export {
|
|
26
26
|
default as Card,
|
|
27
27
|
CardColumns,
|