@openedx/paragon 23.0.0-alpha.1 → 23.0.0-alpha.3

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.
Files changed (124) hide show
  1. package/README.md +31 -22
  2. package/dist/Button/index.d.ts +35 -0
  3. package/dist/Button/index.js +37 -15
  4. package/dist/Button/index.js.map +1 -1
  5. package/dist/Button/index.scss +0 -2
  6. package/dist/Chip/ChipIcon.d.ts +13 -8
  7. package/dist/Chip/ChipIcon.js +0 -2
  8. package/dist/Chip/ChipIcon.js.map +1 -1
  9. package/dist/Chip/constants.d.ts +4 -0
  10. package/dist/Chip/constants.js +3 -2
  11. package/dist/Chip/constants.js.map +1 -0
  12. package/dist/Chip/index.d.ts +4 -3
  13. package/dist/Chip/index.js +2 -4
  14. package/dist/Chip/index.js.map +1 -1
  15. package/dist/Chip/index.scss +6 -5
  16. package/dist/Chip/mixins.scss +4 -4
  17. package/dist/ChipCarousel/index.js +0 -2
  18. package/dist/ChipCarousel/index.js.map +1 -1
  19. package/dist/Collapsible/index.scss +3 -3
  20. package/dist/Hyperlink/index.d.ts +24 -0
  21. package/dist/Hyperlink/index.js +20 -32
  22. package/dist/Hyperlink/index.js.map +1 -1
  23. package/dist/Icon/index.d.ts +4 -2
  24. package/dist/Icon/index.js +1 -1
  25. package/dist/Icon/index.js.map +1 -1
  26. package/dist/IconButton/index.d.ts +342 -0
  27. package/dist/IconButton/index.js +18 -26
  28. package/dist/IconButton/index.js.map +1 -1
  29. package/dist/Modal/ModalPopup.js +7 -1
  30. package/dist/Modal/ModalPopup.js.map +1 -1
  31. package/dist/Modal/_ModalDialog.scss +4 -0
  32. package/dist/Overlay/index.d.ts +128 -0
  33. package/dist/Overlay/index.js +8 -2
  34. package/dist/Overlay/index.js.map +1 -1
  35. package/dist/Stepper/index.scss +3 -2
  36. package/dist/Tabs/index.scss +9 -6
  37. package/dist/Tooltip/index.d.ts +7 -0
  38. package/dist/Tooltip/index.js.map +1 -1
  39. package/dist/core.css +22 -30
  40. package/dist/core.css.map +1 -1
  41. package/dist/core.min.css +1 -1
  42. package/dist/index.d.ts +5 -5
  43. package/dist/index.js +7 -7
  44. package/dist/light.css +11 -11
  45. package/dist/light.css.map +1 -1
  46. package/dist/light.min.css +1 -1
  47. package/dist/setupTest.d.ts +2 -0
  48. package/dist/setupTest.js.map +1 -0
  49. package/dist/utils/types/bootstrap.d.ts +39 -0
  50. package/dist/utils/types/bootstrap.js +2 -0
  51. package/dist/utils/types/bootstrap.js.map +1 -0
  52. package/lib/build-tokens.js +18 -4
  53. package/package.json +6 -5
  54. package/src/Button/{Button.test.jsx → Button.test.tsx} +14 -2
  55. package/src/Button/__snapshots__/{Button.test.jsx.snap → Button.test.tsx.snap} +19 -2
  56. package/src/Button/index.scss +0 -2
  57. package/src/Button/{index.jsx → index.tsx} +58 -16
  58. package/src/Chip/{Chip.test.jsx → Chip.test.tsx} +5 -7
  59. package/src/Chip/ChipIcon.tsx +8 -8
  60. package/src/Chip/{constants.js → constants.ts} +1 -1
  61. package/src/Chip/index.scss +6 -5
  62. package/src/Chip/index.tsx +6 -8
  63. package/src/Chip/mixins.scss +4 -4
  64. package/src/ChipCarousel/index.tsx +0 -2
  65. package/src/Collapsible/index.scss +3 -3
  66. package/src/Hyperlink/{Hyperlink.test.jsx → Hyperlink.test.tsx} +21 -10
  67. package/src/Hyperlink/{index.jsx → index.tsx} +41 -37
  68. package/src/Icon/index.d.ts +4 -2
  69. package/src/Icon/index.jsx +1 -1
  70. package/src/IconButton/{IconButton.test.jsx → IconButton.test.tsx} +24 -3
  71. package/src/IconButton/__snapshots__/IconButton.test.tsx.snap +90 -0
  72. package/src/IconButton/{index.jsx → index.tsx} +66 -26
  73. package/src/Modal/ModalPopup.jsx +9 -1
  74. package/src/Modal/_ModalDialog.scss +4 -0
  75. package/src/Modal/tests/ModalPopupNoMock.test.jsx +29 -0
  76. package/src/Overlay/{index.jsx → index.tsx} +13 -8
  77. package/src/Stepper/index.scss +3 -2
  78. package/src/Tabs/index.scss +9 -6
  79. package/src/Tooltip/{index.jsx → index.tsx} +9 -3
  80. package/src/index.d.ts +5 -5
  81. package/src/index.js +7 -7
  82. package/src/{setupTest.js → setupTest.ts} +1 -0
  83. package/src/utils/types/bootstrap.test.tsx +86 -0
  84. package/src/utils/types/bootstrap.ts +43 -0
  85. package/styles/css/core/variables.css +11 -22
  86. package/styles/css/themes/light/variables.css +11 -11
  87. package/styles/scss/core/_variables.scss +4 -5
  88. package/styles/scss/core/core.scss +1 -1
  89. package/tokens/README.md +1 -2
  90. package/tokens/src/core/alias/size.json +3 -3
  91. package/tokens/src/core/components/Breadcrumb.json +0 -14
  92. package/tokens/src/core/components/Card.json +6 -1
  93. package/tokens/src/core/components/Chip.json +4 -6
  94. package/tokens/src/core/components/ColorPicker.json +2 -2
  95. package/tokens/src/core/components/DataTable.json +1 -1
  96. package/tokens/src/core/components/Form/size.json +3 -7
  97. package/tokens/src/core/components/Nav.json +0 -3
  98. package/tokens/src/core/components/Pagination.json +0 -4
  99. package/tokens/src/core/components/ProductTour.json +0 -5
  100. package/tokens/src/core/global/display.json +2 -1
  101. package/tokens/src/core/global/spacing.json +7 -5
  102. package/tokens/src/themes/light/alias/color.json +2 -2
  103. package/tokens/src/themes/light/components/Alert.json +0 -9
  104. package/tokens/src/themes/light/components/Annotation.json +11 -11
  105. package/tokens/src/themes/light/components/Avatar.json +1 -1
  106. package/tokens/src/themes/light/components/Breadcrumb.json +0 -1
  107. package/tokens/src/themes/light/components/Card.json +2 -6
  108. package/tokens/src/themes/light/components/DataTable.json +1 -1
  109. package/tokens/src/themes/light/components/Form/color.json +4 -4
  110. package/tokens/src/themes/light/components/Form/elevation.json +1 -1
  111. package/tokens/src/themes/light/components/Form/other.json +3 -3
  112. package/tokens/src/themes/light/components/general/input.json +1 -1
  113. package/tokens/src/themes/light/components/general/link.json +1 -1
  114. package/tokens/src/themes/light/components/general/list.json +1 -1
  115. package/tokens/src/themes/light/components/general/text.json +7 -1
  116. package/tokens/src/themes/light/global/color.json +2 -2
  117. package/tokens/style-dictionary.js +6 -0
  118. package/src/IconButton/__snapshots__/IconButton.test.jsx.snap +0 -20
  119. /package/src/Button/{ButtonGroup.test.jsx → ButtonGroup.test.tsx} +0 -0
  120. /package/src/Button/{ButtonToolbar.test.jsx → ButtonToolbar.test.tsx} +0 -0
  121. /package/src/Button/__snapshots__/{ButtonGroup.test.jsx.snap → ButtonGroup.test.tsx.snap} +0 -0
  122. /package/src/Button/__snapshots__/{ButtonToolbar.test.jsx.snap → ButtonToolbar.test.tsx.snap} +0 -0
  123. /package/src/Chip/__snapshots__/{Chip.test.jsx.snap → Chip.test.tsx.snap} +0 -0
  124. /package/src/Tooltip/{Tooltip.test.jsx → Tooltip.test.tsx} +0 -0
package/README.md CHANGED
@@ -39,29 +39,39 @@ In your React project:
39
39
  import { ComponentName } from '@openedx/paragon';
40
40
  ```
41
41
 
42
- #### SCSS Foundation
42
+ #### CSS Foundation
43
43
 
44
- Usage for Open edX and others:
44
+ **Usage with no theme:**
45
45
 
46
- **index.scss**
46
+ The Paragon CSS Foundation offers a collection of fundamental styles, encompassing padding, typography, and sizing.
47
+ When applied, these styles contribute to the creation of a straightforward and neat appearance for your application.
48
+
49
+ To integrate these foundational styles into your project, include the following import:
47
50
 
48
51
  ```
49
- // ... Any custom SCSS variables should be defined here
50
- @import '~@openedx/paragon/styles/scss/core/core.scss';
52
+ @use "@openedx/paragon/dist/core.min.css";
51
53
  ```
52
54
 
53
- Usage on with `@edx/brand`:
55
+ **Usage with a theme:**
56
+
57
+ In addition to the basic styles, you can provide a theme layer that includes styles for colors, shadows, backgrounds
58
+ and transparency of elements. This allows you to visually represent a specific theme in your application.
54
59
 
55
- **index.scss**
60
+ To apply these theme-specific styles, include the following import:
56
61
 
57
62
  ```
58
- @import '~@edx/brand/paragon/fonts.scss';
59
- @import '~@edx/brand/paragon/variables.scss';
60
- @import '~@openedx/paragon/styles/scss/core/core.scss';
61
- @import '~@edx/brand/paragon/overrides.scss';
63
+ @use "@openedx/paragon/dist/core.min.css";
64
+ @use "@my-brand/light.min.css";
62
65
  ```
63
66
 
64
- Note that including fonts will affect performance. In some applications may choose not to load the custom font to keep it highly performant.
67
+ **CDN links:**
68
+
69
+ Alternative style integration is available when using CDN links:
70
+
71
+ ```
72
+ @import url("https://cdn.jsdelivr.net/npm/@my-brand/core.min.css");
73
+ @import url("https://cdn.jsdelivr.net/npm/@my-brand/light.min.css");
74
+ ```
65
75
 
66
76
  ## Paragon CLI
67
77
 
@@ -69,7 +79,8 @@ The Paragon CLI (Command Line Interface) is a tool that provides various utility
69
79
 
70
80
  ### Available Commands
71
81
 
72
- - `paragon install-theme [theme]`: Installs the specific [brand package](https://github.com/openedx/brand-openedx).
82
+ - `paragon install-theme`: Install a [brand package](https://github.com/openedx/brand-openedx).
83
+ - `paragon migrate-to-openedx-scope`: Migrate from "@edx/paragon" to "@openedx/paragon".
73
84
  - `paragon build-tokens`: Build Paragon's design tokens.
74
85
  - `paragon replace-variables`: Replace SCSS variables usages or definitions to CSS variables and vice versa in `.scss` files.
75
86
  - `paragon build-scss`: Compile Paragon's core and themes SCSS into CSS.
@@ -161,7 +172,7 @@ module.exports = {
161
172
  };
162
173
  ```
163
174
 
164
- Then, when importing Paragon's core SCSS in your MFE the import needs to begin with a tilde `~` so that path to your local Paragon repository gets resolved correctly: `@import "~@openedx/paragon/styles/scss/core";`
175
+ Then, when importing Paragon's core SCSS in your MFE the import needs to begin with a tilde `~` so that path to your local Paragon repository gets resolved correctly: `@import "~@openedx/paragon/styles/scss/core/core.scss";`
165
176
 
166
177
  #### Internationalization
167
178
 
@@ -274,8 +285,7 @@ This will create a directory in `/src/` that will contain templates for all nece
274
285
  MyComponent
275
286
  ├── index.jsx
276
287
  ├── README.md
277
- ├── MyComponent.scss
278
- ├── _variables.scss
288
+ ├── index.scss
279
289
  └── MyComponent.test.jsx
280
290
  ```
281
291
 
@@ -314,11 +324,10 @@ export default MyComponent;
314
324
  ##### 4. (Optional) Add styles to your component.
315
325
 
316
326
  If your component requires additional styling (which most likely is the case), edit created SCSS style sheet in your
317
- component's directory `/src/MyComponent/MyComponent.scss` which by default contains an empty class for your component.
327
+ component's directory `/src/MyComponent/index.scss` which by default contains an empty class for your component.
318
328
 
319
- If you wish to use SASS variables (which is the preferred way of styling the components since values can be
320
- easily overridden and customized by the consumers of Paragon), add them in `/src/MyComponent/_variables.scss` (this file should contain all variables specific to your component).
321
- This way the variables will also get automatically picked up by documentation site and displayed on your component's page.
329
+ If you wish to use CSS variables (which is the preferred way of styling the components since values can be
330
+ easily overridden and customized by the consumers of Paragon), you can do so by utilizing [design tokens](/tokens).
322
331
 
323
332
  **Please note that you need to follow [Paragon's CSS styling conventions](docs/decisions/0012-css-styling-conventions).**
324
333
 
@@ -502,9 +511,9 @@ Paragon uses [style-dictionary](https://github.com/amzn/style-dictionary) to bui
502
511
  6. Consuming applications would inject the `core.css` and `light.css` theme files into their applications via a mechanism similar to https://github.com/openedx/frontend-platform/pull/440 (ideally pulling from a public CDN for NPM packages, but falling back to locally installed copies, if needed).
503
512
 
504
513
  #### Compiling CSS from design tokens for `@edx/brand` theme authors (in `@edx/brand` repos)
505
- 1. **`npm install`.** Install dependencies, including `@edx/paragon`.
514
+ 1. **`npm install`.** Install dependencies, including `@openedx/paragon`.
506
515
  2. Create tokens that will override Paragon's default tokens (matching same JSON schema).
507
- 3. **`npm run build-scss`.** This `@edx/brand` repo will have a new NPM script that utilizes a new CLI exported by `@edx/paragon` which exposes the `build-tokens.js` script (or possibly another if we end up needing one for the brand packages to run specifically, TBD) for `@edx/brand` consumers.
516
+ 3. **`npm run build-scss`.** This `@edx/brand` repo will have a new NPM script that utilizes a new CLI exported by `@openedx/paragon` which exposes the `build-tokens.js` script (or possibly another if we end up needing one for the brand packages to run specifically, TBD) for `@edx/brand` consumers.
508
517
  - The intent of running this command is to effectively deep merge the tokens defined in Paragon's default tokens with the override tokens defined by `@edx/brand`, generating its own `core.css` and `light.css` output files (exact output files still a TBD) containing CSS variable overrides based on the token overrides.
509
518
  5. Ensure any changes to the generated `core.css` and `light.css` files are committed & released to NPM (which also "releases" them on versioned public CDNs for NPM packages).
510
519
  - _Note: It is a bit unclear still in the above linked implementation POC for `@edx/frontend-platform` how it would integrate with `@edx/brand` in this way. Open to suggestions/feedback/ideas here._
@@ -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 };
@@ -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; }
@@ -19,21 +20,24 @@ var Button = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
19
20
  var children = _ref.children,
20
21
  iconAfter = _ref.iconAfter,
21
22
  iconBefore = _ref.iconBefore,
23
+ size = _ref.size,
22
24
  props = _objectWithoutProperties(_ref, _excluded);
23
- return /*#__PURE__*/React.createElement(BaseButton, _extends({}, props, {
25
+ return /*#__PURE__*/React.createElement(BaseButton, _extends({
26
+ size: size // Bootstrap's <Button> types do not allow 'md' or 'inline', but we do.
27
+ }, props, {
24
28
  className: classNames(props.className),
25
29
  ref: ref
26
30
  }), iconBefore && /*#__PURE__*/React.createElement(Icon, {
27
31
  className: "btn-icon-before",
28
- size: props.size,
32
+ size: size,
29
33
  src: iconBefore
30
34
  }), children, iconAfter && /*#__PURE__*/React.createElement(Icon, {
31
35
  className: "btn-icon-after",
32
- size: props.size,
36
+ size: size,
33
37
  src: iconAfter
34
38
  }));
35
39
  });
36
- Button.propTypes = _objectSpread(_objectSpread({}, Button.propTypes), {}, {
40
+ Button.propTypes = {
37
41
  /** Specifies class name to apply to the button */
38
42
  className: PropTypes.string,
39
43
  /** Disables the Button, preventing mouse events, even if the underlying component is an `<a>` element */
@@ -59,11 +63,14 @@ Button.propTypes = _objectSpread(_objectSpread({}, Button.propTypes), {}, {
59
63
  variant: PropTypes.string,
60
64
  /** An icon component to render.
61
65
  * Example import of a Paragon icon component: `import { Check } from '@openedx/paragon/icons';` */
62
- iconBefore: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]),
66
+ iconBefore: PropTypes.elementType,
63
67
  /** An icon component to render.
64
68
  * Example import of a Paragon icon component: `import { Check } from '@openedx/paragon/icons';` */
65
- iconAfter: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node])
66
- });
69
+ iconAfter: PropTypes.elementType
70
+ // The 'as' type casting above is required for TypeScript checking, because the 'PropTypes.elementType' type normally
71
+ // allows strings as a value (for use cases like 'div') but we don't support that for <Icon />/iconBefore/iconAfter.
72
+ // The React TypeScript type definitions are more specific (React.ComponentType vs React.ElementType).
73
+ };
67
74
  Button.defaultProps = _objectSpread(_objectSpread({}, Button.defaultProps), {}, {
68
75
  children: undefined,
69
76
  className: undefined,
@@ -71,19 +78,29 @@ Button.defaultProps = _objectSpread(_objectSpread({}, Button.defaultProps), {},
71
78
  iconAfter: undefined,
72
79
  disabled: false
73
80
  });
74
- function ButtonGroup(props) {
75
- return /*#__PURE__*/React.createElement(BaseButtonGroup, props);
76
- }
77
- function ButtonToolbar(props) {
78
- return /*#__PURE__*/React.createElement(BaseButtonToolbar, props);
79
- }
81
+
82
+ // We could just re-export 'ButtonGroup' and 'ButtonToolbar', but we currently
83
+ // override them to add propTypes validation at runtime, since most Paragon
84
+ // consumers aren't using TypeScript yet. We also force ButtonGroup's 'size'
85
+ // prop to accept our custom values of 'md' and 'inline' which are used in
86
+ // Paragon but not used in the base Bootstrap classes.
87
+
88
+ var ButtonGroup = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
89
+ var size = _ref2.size,
90
+ props = _objectWithoutProperties(_ref2, _excluded2);
91
+ return /*#__PURE__*/React.createElement(BaseButtonGroup, _extends({
92
+ size: size
93
+ }, props, {
94
+ ref: ref
95
+ }));
96
+ });
80
97
  ButtonGroup.propTypes = {
81
98
  /** Specifies element type for this component. */
82
99
  as: PropTypes.elementType,
83
100
  /** An ARIA role describing the button group. */
84
101
  role: PropTypes.string,
85
102
  /** Specifies the size for all Buttons in the group. */
86
- size: PropTypes.oneOf(['sm', 'md', 'lg']),
103
+ size: PropTypes.oneOf(['sm', 'md', 'lg', 'inline']),
87
104
  /** Display as a button toggle group. */
88
105
  toggle: PropTypes.bool,
89
106
  /** Specifies if the set of Buttons should appear vertically stacked. */
@@ -99,6 +116,11 @@ ButtonGroup.defaultProps = {
99
116
  bsPrefix: 'btn-group',
100
117
  size: 'md'
101
118
  };
119
+ var ButtonToolbar = /*#__PURE__*/React.forwardRef(function (props, ref) {
120
+ return /*#__PURE__*/React.createElement(BaseButtonToolbar, _extends({}, props, {
121
+ ref: ref
122
+ }));
123
+ });
102
124
  ButtonToolbar.propTypes = {
103
125
  /** An ARIA role describing the button group. */
104
126
  role: PropTypes.string,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["React","PropTypes","classNames","BaseButton","BaseButtonGroup","BaseButtonToolbar","Icon","Button","forwardRef","_ref","ref","children","iconAfter","iconBefore","props","_objectWithoutProperties","_excluded","createElement","_extends","className","size","src","propTypes","_objectSpread","string","disabled","bool","node","isRequired","onClick","func","onKeyDown","type","variant","oneOfType","elementType","defaultProps","undefined","ButtonGroup","ButtonToolbar","as","role","oneOf","toggle","vertical","bsPrefix"],"sources":["../../src/Button/index.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport BaseButton from 'react-bootstrap/Button';\nimport BaseButtonGroup from 'react-bootstrap/ButtonGroup';\nimport BaseButtonToolbar from 'react-bootstrap/ButtonToolbar';\n\nimport Icon from '../Icon';\n\nconst Button = React.forwardRef(({\n children,\n iconAfter,\n iconBefore,\n ...props\n}, ref) => (\n <BaseButton\n {...props}\n className={classNames(props.className)}\n ref={ref}\n >\n {iconBefore && <Icon className=\"btn-icon-before\" size={props.size} src={iconBefore} />}\n {children}\n {iconAfter && <Icon className=\"btn-icon-after\" size={props.size} src={iconAfter} />}\n </BaseButton>\n));\n\nButton.propTypes = {\n ...Button.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.oneOfType([PropTypes.elementType, PropTypes.node]),\n /** An icon component to render.\n * Example import of a Paragon icon component: `import { Check } from '@openedx/paragon/icons';` */\n iconAfter: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]),\n};\n\nButton.defaultProps = {\n ...Button.defaultProps,\n children: undefined,\n className: undefined,\n iconBefore: undefined,\n iconAfter: undefined,\n disabled: false,\n};\n\nfunction ButtonGroup(props) {\n return <BaseButtonGroup {...props} />;\n}\nfunction ButtonToolbar(props) {\n return <BaseButtonToolbar {...props} />;\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']),\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\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,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,UAAU,MAAM,wBAAwB;AAC/C,OAAOC,eAAe,MAAM,6BAA6B;AACzD,OAAOC,iBAAiB,MAAM,+BAA+B;AAE7D,OAAOC,IAAI,MAAM,SAAS;AAE1B,IAAMC,MAAM,gBAAGP,KAAK,CAACQ,UAAU,CAAC,UAAAC,IAAA,EAK7BC,GAAG;EAAA,IAJJC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IACRC,SAAS,GAAAH,IAAA,CAATG,SAAS;IACTC,UAAU,GAAAJ,IAAA,CAAVI,UAAU;IACPC,KAAK,GAAAC,wBAAA,CAAAN,IAAA,EAAAO,SAAA;EAAA,oBAERhB,KAAA,CAAAiB,aAAA,CAACd,UAAU,EAAAe,QAAA,KACLJ,KAAK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names":["React","PropTypes","classNames","BaseButton","BaseButtonGroup","BaseButtonToolbar","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","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\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\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;AAG1F,OAAOC,IAAI,MAAM,SAAS;AAwB1B,IAAMC,MAAkB,gBAAGP,KAAK,CAAC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IAAI,EAAE;AACR,CAAC;AAED,IAAMgC,aAA6D,gBACjE9C,KAAK,CAACQ,UAAU,CAAwC,UAACO,KAAK,EAAEL,GAAG;EAAA,oBACjEV,KAAA,CAAAkB,aAAA,CAACb,iBAAiB,EAAAc,QAAA,KAAKJ,KAAK;IAAEL,GAAG,EAAEA;EAAI,EAAE,CAAC;AAAA,CAC3C,CACF;AAEDoC,aAAa,CAACxB,SAAS,GAAG;EACxB;EACAmB,IAAI,EAAExC,SAAS,CAACsB,MAAM;EACtB;EACAsB,QAAQ,EAAE5C,SAAS,CAACsB;AACtB,CAAC;AAEDuB,aAAa,CAACZ,YAAY,GAAG;EAC3BO,IAAI,EAAE,SAAS;EACfI,QAAQ,EAAE;AACZ,CAAC;AAED,eAAetC,MAAM;AACrB,SAAS8B,WAAW,EAAES,aAAa","ignoreList":[]}
@@ -91,8 +91,6 @@
91
91
  opacity: var(--pgn-other-btn-disabled-opacity);
92
92
  }
93
93
 
94
- // Button Icon Sizes
95
-
96
94
  .btn-icon-before {
97
95
  margin-inline-end: .5rem;
98
96
  margin-left: -.25em;
@@ -1,14 +1,19 @@
1
1
  import React, { KeyboardEventHandler, MouseEventHandler } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- export interface ChipIconProps {
3
+ import { STYLE_VARIANTS } from './constants';
4
+ export type ChipIconProps = {
4
5
  className: string;
5
- src: React.ReactElement | Function;
6
- onClick?: KeyboardEventHandler & MouseEventHandler;
7
- alt?: string;
8
- variant: string;
6
+ src: React.ComponentType;
7
+ variant: typeof STYLE_VARIANTS[keyof typeof STYLE_VARIANTS];
9
8
  disabled?: boolean;
10
- }
11
- declare function ChipIcon({ className, src, onClick, alt, variant, disabled, }: ChipIconProps): JSX.Element;
9
+ } & ({
10
+ onClick: KeyboardEventHandler<HTMLButtonElement> & MouseEventHandler<HTMLButtonElement>;
11
+ alt: string;
12
+ } | {
13
+ onClick?: undefined;
14
+ alt?: undefined;
15
+ });
16
+ declare function ChipIcon({ className, src, onClick, alt, variant, disabled, }: ChipIconProps): React.JSX.Element;
12
17
  declare namespace ChipIcon {
13
18
  var propTypes: {
14
19
  className: PropTypes.Validator<string>;
@@ -21,7 +26,7 @@ declare namespace ChipIcon {
21
26
  var defaultProps: {
22
27
  onClick: undefined;
23
28
  alt: undefined;
24
- variant: any;
29
+ variant: "light";
25
30
  disabled: boolean;
26
31
  };
27
32
  }
@@ -1,9 +1,7 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import Icon from '../Icon';
4
- // @ts-ignore
5
4
  import IconButton from '../IconButton';
6
- // @ts-ignore
7
5
  import { STYLE_VARIANTS } from './constants';
8
6
  function ChipIcon(_ref) {
9
7
  var className = _ref.className,
@@ -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.ReactElement | Function,\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,GAAG,GAAAJ,IAAA,CAAHI,GAAG;IAAEC,OAAO,GAAAL,IAAA,CAAPK,OAAO;IAAEC,QAAQ,GAAAN,IAAA,CAARM,QAAQ;EAE/C,IAAIH,OAAO,EAAE;IACX,oBACET,KAAA,CAAAa,aAAA,CAACV,UAAU;MACTI,SAAS,EAAEA,SAAU;MACrBC,GAAG,EAAEA,GAAI;MACTC,OAAO,EAAEA,OAAQ;MACjBK,MAAM,EAAEZ,IAAK;MACbQ,GAAG,EAAEA,GAAI;MACTK,YAAY,EAAEJ,OAAO,KAAKP,cAAc,CAACY,IAAK;MAC9CC,QAAQ,EAAEL,QAAQ,GAAG,CAAC,CAAC,GAAG;IAAE,CAC7B,CAAC;EAEN;EAEA,oBAAOZ,KAAA,CAAAa,aAAA,CAACX,IAAI;IAACM,GAAG,EAAEA,GAAI;IAACD,SAAS,EAAEA,SAAU;IAACW,IAAI,EAAC;EAAI,CAAE,CAAC;AAC3D;AAEAb,QAAQ,CAACc,SAAS,GAAG;EACnBZ,SAAS,EAAEN,SAAS,CAACmB,MAAM,CAACC,UAAU;EACtCb,GAAG,EAAEP,SAAS,CAACqB,SAAS,CAAC,CAACrB,SAAS,CAACsB,OAAO,EAAEtB,SAAS,CAACuB,IAAI,CAAC,CAAC,CAACH,UAAU;EACxEZ,OAAO,EAAER,SAAS,CAACuB,IAAI;EACvBd,GAAG,EAAET,SAAS,CAACmB,MAAM;EACrBT,OAAO,EAAEV,SAAS,CAACmB,MAAM;EACzBR,QAAQ,EAAEX,SAAS,CAACwB;AACtB,CAAC;AAEDpB,QAAQ,CAACqB,YAAY,GAAG;EACtBjB,OAAO,EAAEkB,SAAS;EAClBjB,GAAG,EAAEiB,SAAS;EACdhB,OAAO,EAAEP,cAAc,CAACwB,KAAK;EAC7BhB,QAAQ,EAAE;AACZ,CAAC;AAED,eAAeP,QAAQ","ignoreList":[]}
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';\nimport IconButton from '../IconButton';\nimport { STYLE_VARIANTS } from './constants';\n\nexport type ChipIconProps = {\n className: string,\n src: React.ComponentType,\n variant: typeof STYLE_VARIANTS[keyof typeof STYLE_VARIANTS],\n disabled?: boolean,\n} & (\n // Either _both_ onClick and alt are provided, or neither is:\n | { onClick: KeyboardEventHandler<HTMLButtonElement> & MouseEventHandler<HTMLButtonElement>, alt: string }\n | { onClick?: undefined, alt?: undefined }\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,OAAOC,UAAU,MAAM,eAAe;AACtC,SAASC,cAAc,QAAQ,aAAa;AAa5C,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,GAAG,GAAAJ,IAAA,CAAHI,GAAG;IAAEC,OAAO,GAAAL,IAAA,CAAPK,OAAO;IAAEC,QAAQ,GAAAN,IAAA,CAARM,QAAQ;EAE/C,IAAIH,OAAO,EAAE;IACX,oBACET,KAAA,CAAAa,aAAA,CAACV,UAAU;MACTI,SAAS,EAAEA,SAAU;MACrBC,GAAG,EAAEA,GAAI;MACTC,OAAO,EAAEA,OAAQ;MACjBK,MAAM,EAAEZ,IAAK;MACbQ,GAAG,EAAEA,GAAI;MACTK,YAAY,EAAEJ,OAAO,KAAKP,cAAc,CAACY,IAAK;MAC9CC,QAAQ,EAAEL,QAAQ,GAAG,CAAC,CAAC,GAAG;IAAE,CAC7B,CAAC;EAEN;EAEA,oBAAOZ,KAAA,CAAAa,aAAA,CAACX,IAAI;IAACM,GAAG,EAAEA,GAAI;IAACD,SAAS,EAAEA,SAAU;IAACW,IAAI,EAAC;EAAI,CAAE,CAAC;AAC3D;AAEAb,QAAQ,CAACc,SAAS,GAAG;EACnBZ,SAAS,EAAEN,SAAS,CAACmB,MAAM,CAACC,UAAU;EACtCb,GAAG,EAAEP,SAAS,CAACqB,SAAS,CAAC,CAACrB,SAAS,CAACsB,OAAO,EAAEtB,SAAS,CAACuB,IAAI,CAAC,CAAC,CAACH,UAAU;EACxEZ,OAAO,EAAER,SAAS,CAACuB,IAAI;EACvBd,GAAG,EAAET,SAAS,CAACmB,MAAM;EACrBT,OAAO,EAAEV,SAAS,CAACmB,MAAM;EACzBR,QAAQ,EAAEX,SAAS,CAACwB;AACtB,CAAC;AAEDpB,QAAQ,CAACqB,YAAY,GAAG;EACtBjB,OAAO,EAAEkB,SAAS;EAClBjB,GAAG,EAAEiB,SAAS;EACdhB,OAAO,EAAEP,cAAc,CAACwB,KAAK;EAC7BhB,QAAQ,EAAE;AACZ,CAAC;AAED,eAAeP,QAAQ","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ export declare const STYLE_VARIANTS: {
2
+ readonly DARK: "dark";
3
+ readonly LIGHT: "light";
4
+ };
@@ -1,5 +1,6 @@
1
1
  // eslint-disable-next-line import/prefer-default-export
2
- export const STYLE_VARIANTS = {
2
+ export var STYLE_VARIANTS = {
3
3
  DARK: 'dark',
4
- LIGHT: 'light',
4
+ LIGHT: 'light'
5
5
  };
6
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","names":["STYLE_VARIANTS","DARK","LIGHT"],"sources":["../../src/Chip/constants.ts"],"sourcesContent":["// eslint-disable-next-line import/prefer-default-export\nexport const STYLE_VARIANTS = {\n DARK: 'dark',\n LIGHT: 'light',\n} as const;\n"],"mappings":"AAAA;AACA,OAAO,IAAMA,cAAc,GAAG;EAC5BC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE;AACT,CAAU","ignoreList":[]}
@@ -1,13 +1,14 @@
1
1
  import React, { KeyboardEventHandler, MouseEventHandler } from 'react';
2
+ import { STYLE_VARIANTS } from './constants';
2
3
  export declare const CHIP_PGN_CLASS = "pgn__chip";
3
4
  export interface IChip {
4
5
  children: React.ReactNode;
5
6
  onClick?: KeyboardEventHandler & MouseEventHandler;
6
7
  className?: string;
7
- variant?: string;
8
- iconBefore?: React.ReactElement | Function;
8
+ variant?: typeof STYLE_VARIANTS[keyof typeof STYLE_VARIANTS];
9
+ iconBefore?: React.ComponentType;
9
10
  iconBeforeAlt?: string;
10
- iconAfter?: React.ReactElement | Function;
11
+ iconAfter?: React.ComponentType;
11
12
  iconAfterAlt?: string;
12
13
  onIconBeforeClick?: KeyboardEventHandler & MouseEventHandler;
13
14
  onIconAfterClick?: KeyboardEventHandler & MouseEventHandler;
@@ -7,9 +7,7 @@ import PropTypes from 'prop-types';
7
7
  import classNames from 'classnames';
8
8
  // @ts-ignore
9
9
  import { requiredWhen } from '../utils/propTypes';
10
- // @ts-ignore
11
10
  import { STYLE_VARIANTS } from './constants';
12
- // @ts-ignore
13
11
  import ChipIcon from './ChipIcon';
14
12
  export var CHIP_PGN_CLASS = 'pgn__chip';
15
13
  var Chip = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
@@ -79,7 +77,7 @@ Chip.propTypes = {
79
77
  *
80
78
  * `import { Check } from '@openedx/paragon/icons';`
81
79
  */
82
- iconBefore: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
80
+ iconBefore: PropTypes.elementType,
83
81
  /** Specifies icon alt text. */
84
82
  iconBeforeAlt: requiredWhen(PropTypes.string, ['iconBefore', 'onIconBeforeClick']),
85
83
  /** A click handler for the `Chip` icon before. */
@@ -90,7 +88,7 @@ Chip.propTypes = {
90
88
  *
91
89
  * `import { Check } from '@openedx/paragon/icons';`
92
90
  */
93
- iconAfter: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
91
+ iconAfter: PropTypes.elementType,
94
92
  /** Specifies icon alt text. */
95
93
  iconAfterAlt: requiredWhen(PropTypes.string, ['iconAfter', 'onIconAfterClick']),
96
94
  /** A click handler for the `Chip` icon after. */
@@ -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","oneOfType","element","defaultProps","undefined","LIGHT"],"sources":["../../src/Chip/index.tsx"],"sourcesContent":["import React, { ForwardedRef, KeyboardEventHandler, MouseEventHandler } from 'react';\nimport PropTypes 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.ReactElement | Function,\n iconBeforeAlt?: string,\n iconAfter?: React.ReactElement | Function,\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.oneOfType([PropTypes.element, PropTypes.func]),\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.oneOfType([PropTypes.element, PropTypes.func]),\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,MAAM,YAAY;AAClC,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,EAAAgB,SAAA;EAER,IAAMC,mBAAmB,GAAG,CAAC,EAAER,iBAAiB,IAAIC,gBAAgB,CA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AAS;EAC5B9B,gBAAgB,EAAE8B,SAAS;EAC3B5B,UAAU,EAAE,KAAK;EACjBJ,YAAY,EAAEgC,SAAS;EACvBlC,aAAa,EAAEkC;AACjB,CAAC;AAED,eAAe1C,IAAI","ignoreList":[]}
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';\nimport { STYLE_VARIANTS } from './constants';\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?: typeof STYLE_VARIANTS[keyof typeof STYLE_VARIANTS],\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,SAASC,cAAc,QAAQ,aAAa;AAC5C,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,C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AgB,EAAE6B,SAAS;EAC3B3B,UAAU,EAAE,KAAK;EACjBJ,YAAY,EAAE+B,SAAS;EACvBjC,aAAa,EAAEiC;AACjB,CAAC;AAED,eAAezC,IAAI","ignoreList":[]}
@@ -93,11 +93,12 @@
93
93
  background-color: var(--pgn-color-chip-bg-dark);
94
94
 
95
95
  &.selected {
96
- @include chip-outline(var(--pgn-color-chip-outline-dark),
97
- calc(var(--pgn-spacing-chip-outline-selected-distance-dark) * -1),
98
- calc(var(--pgn-size-chip-border-radius) + var(--pgn-spacing-chip-outline-width)),
99
- var(--pgn-spacing-chip-outline-selected-distance-dark)
100
- );
96
+ @include chip-outline(
97
+ var(--pgn-color-chip-outline-dark),
98
+ calc(var(--pgn-spacing-chip-outline-selected-distance-dark) * -1),
99
+ calc(var(--pgn-size-chip-border-radius) + var(--pgn-spacing-chip-outline-width)),
100
+ var(--pgn-spacing-chip-outline-selected-distance-dark)
101
+ );
101
102
 
102
103
  &:focus {
103
104
  border: 1px solid var(--pgn-color-chip-border-focus-selected-dark);
@@ -1,8 +1,8 @@
1
1
  @mixin chip-outline(
2
2
  $outline-color: var(--pgn-color-white),
3
3
  $distance-to-border: 0,
4
- $border-radius: 50%,
5
- $border-width-value: .125rem
4
+ $outline-border-radius: 50%,
5
+ $outline-border-width: .125rem
6
6
  ) {
7
7
  &::before {
8
8
  content: "";
@@ -11,8 +11,8 @@
11
11
  right: $distance-to-border;
12
12
  bottom: $distance-to-border;
13
13
  left: $distance-to-border;
14
- border: solid $border-width-value $outline-color;
15
- border-radius: var(--pgn-size-border-radius-base);
14
+ border: solid $outline-border-width $outline-color;
15
+ border-radius: $outline-border-radius;
16
16
  }
17
17
  }
18
18
 
@@ -14,9 +14,7 @@ import { useIntl } from 'react-intl';
14
14
  import classNames from 'classnames';
15
15
  // @ts-ignore
16
16
  import { OverflowScroll, OverflowScrollContext } from '../OverflowScroll';
17
- // @ts-ignore
18
17
  import IconButton from '../IconButton';
19
- // @ts-ignore
20
18
  import Icon from '../Icon';
21
19
  // @ts-ignore
22
20
  import { ArrowForward, ArrowBack } from '../../icons';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["React","PropTypes","useIntl","classNames","OverflowScroll","OverflowScrollContext","IconButton","Icon","ArrowForward","ArrowBack","messages","Chip","ChipCarousel","forwardRef","_ref","ref","className","items","ariaLabel","disableOpacityMasks","onScrollPrevious","onScrollNext","_ref$canScrollHorizon","canScrollHorizontal","_ref$offset","offset","_ref$offsetType","offsetType","gap","props","_objectWithoutProperties","_excluded","intl","createElement","_extends","concat","hasInteractiveChildren","disableScroll","Consumer","_ref2","setOverflowRef","isScrolledToStart","isScrolledToEnd","scrollToPrevious","scrollToNext","Fragment","size","src","iconAs","alt","formatMessage","onClick","Items","map","item","id","_ref3","children","_objectSpread","key","propTypes","string","isRequired","arrayOf","element","bool","func","oneOfType","number","oneOf","defaultProps","undefined"],"sources":["../../src/ChipCarousel/index.tsx"],"sourcesContent":["import React, { ForwardedRef } from 'react';\nimport PropTypes from 'prop-types';\nimport { useIntl } from 'react-intl';\nimport classNames from 'classnames';\n// @ts-ignore\nimport { OverflowScroll, OverflowScrollContext } from '../OverflowScroll';\n// @ts-ignore\nimport IconButton from '../IconButton';\n// @ts-ignore\nimport Icon from '../Icon';\n// @ts-ignore\nimport { ArrowForward, ArrowBack } from '../../icons';\n// @ts-ignore\nimport messages from './messages';\nimport Chip from '../Chip';\n\nexport interface OverflowScrollContextProps {\n setOverflowRef: () => void,\n isScrolledToStart: boolean,\n isScrolledToEnd: boolean,\n scrollToPrevious: () => void,\n scrollToNext: () => void,\n}\n\nexport interface ChipCarouselProps {\n className?: string;\n items: Array<React.ReactElement>;\n ariaLabel: string;\n disableOpacityMasks?: boolean;\n onScrollPrevious?: () => void;\n onScrollNext?: () => void;\n canScrollHorizontal?: boolean;\n offset?: number | string;\n offsetType?: 'percentage' | 'fixed';\n gap?: number;\n}\n\nconst ChipCarousel = React.forwardRef(({\n className,\n items,\n ariaLabel,\n disableOpacityMasks,\n onScrollPrevious,\n onScrollNext,\n canScrollHorizontal = false,\n offset = 120,\n offsetType = 'fixed',\n gap,\n ...props\n}: ChipCarouselProps, ref: ForwardedRef<HTMLDivElement>) => {\n const intl = useIntl();\n\n return (\n <div\n className={classNames('pgn__chip-carousel', className, gap ? `pgn__chip-carousel-gap__${gap}` : '')}\n {...props}\n ref={ref}\n >\n <OverflowScroll\n ariaLabel={ariaLabel}\n hasInteractiveChildren\n disableScroll={!canScrollHorizontal}\n disableOpacityMasks={disableOpacityMasks}\n onScrollPrevious={onScrollPrevious}\n onScrollNext={onScrollNext}\n offset={offset}\n offsetType={offsetType}\n >\n <OverflowScrollContext.Consumer>\n {({\n setOverflowRef,\n isScrolledToStart,\n isScrolledToEnd,\n scrollToPrevious,\n scrollToNext,\n }: OverflowScrollContextProps) => (\n <>\n <>\n {!isScrolledToStart && (\n <IconButton\n size=\"sm\"\n className=\"pgn__chip-carousel__left-control\"\n src={ArrowBack}\n iconAs={Icon}\n alt={intl.formatMessage(messages.scrollToPrevious)}\n onClick={scrollToPrevious}\n />\n )}\n {!isScrolledToEnd && (\n <IconButton\n size=\"sm\"\n className=\"pgn__chip-carousel__right-control\"\n src={ArrowForward}\n iconAs={Icon}\n alt={intl.formatMessage(messages.scrollToNext)}\n onClick={scrollToNext}\n />\n )}\n </>\n <div ref={setOverflowRef} className=\"d-flex\">\n <OverflowScroll.Items>\n {items?.map((item, id) => {\n const { children } = item?.props || {};\n if (!children) {\n return null;\n }\n // eslint-disable-next-line react/no-array-index-key\n return React.createElement(Chip, { ...item.props, key: id });\n })}\n </OverflowScroll.Items>\n </div>\n </>\n )}\n </OverflowScrollContext.Consumer>\n </OverflowScroll>\n </div>\n );\n});\n\nChipCarousel.propTypes = {\n /** Text describing the ChipCarousel for screen readers. */\n ariaLabel: PropTypes.string.isRequired,\n /** Specifies class name for the ChipCarousel. */\n className: PropTypes.string,\n /** Specifies array of `Chip` elements to be rendered inside the carousel. */\n // @ts-ignore\n items: PropTypes.arrayOf(PropTypes.element).isRequired,\n /** Whether the default opacity masks should be shown at the start/end, if applicable. */\n disableOpacityMasks: PropTypes.bool,\n /** Callback function for when the user scrolls to the previous element. */\n onScrollPrevious: PropTypes.func,\n /** Callback function for when the user scrolls to the next element. */\n onScrollNext: PropTypes.func,\n /** Whether users can scroll within the overflow container. */\n canScrollHorizontal: PropTypes.bool,\n /** A value specifying the distance the scroll should move. */\n offset: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n /** Type of offset value (percentage or fixed). */\n offsetType: PropTypes.oneOf(['percentage', 'fixed']),\n /**\n * Specifies inner space between children blocks.\n *\n * Valid values are based on `the spacing classes`:\n * `0, 0.5, ... 6`.\n */\n gap: PropTypes.number,\n};\n\nChipCarousel.defaultProps = {\n className: undefined,\n disableOpacityMasks: undefined,\n onScrollPrevious: undefined,\n onScrollNext: undefined,\n canScrollHorizontal: false,\n offset: 120,\n offsetType: 'fixed',\n gap: 3,\n};\n\nexport default ChipCarousel;\n"],"mappings":";;;;;;;;;;AAAA,OAAOA,KAAK,MAAwB,OAAO;AAC3C,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,OAAO,QAAQ,YAAY;AACpC,OAAOC,UAAU,MAAM,YAAY;AACnC;AACA,SAASC,cAAc,EAAEC,qBAAqB,QAAQ,mBAAmB;AACzE;AACA,OAAOC,UAAU,MAAM,eAAe;AACtC;AACA,OAAOC,IAAI,MAAM,SAAS;AAC1B;AACA,SAASC,YAAY,EAAEC,SAAS,QAAQ,aAAa;AACrD;AACA,OAAOC,QAAQ,MAAM,YAAY;AACjC,OAAOC,IAAI,MAAM,SAAS;AAuB1B,IAAMC,YAAY,gBAAGZ,KAAK,CAACa,UAAU,CAAC,UAAAC,IAAA,EAYhBC,GAAiC,EAAK;EAAA,IAX1DC,SAAS,GAAAF,IAAA,CAATE,SAAS;IACTC,KAAK,GAAAH,IAAA,CAALG,KAAK;IACLC,SAAS,GAAAJ,IAAA,CAATI,SAAS;IACTC,mBAAmB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":3,"file":"index.js","names":["React","PropTypes","useIntl","classNames","OverflowScroll","OverflowScrollContext","IconButton","Icon","ArrowForward","ArrowBack","messages","Chip","ChipCarousel","forwardRef","_ref","ref","className","items","ariaLabel","disableOpacityMasks","onScrollPrevious","onScrollNext","_ref$canScrollHorizon","canScrollHorizontal","_ref$offset","offset","_ref$offsetType","offsetType","gap","props","_objectWithoutProperties","_excluded","intl","createElement","_extends","concat","hasInteractiveChildren","disableScroll","Consumer","_ref2","setOverflowRef","isScrolledToStart","isScrolledToEnd","scrollToPrevious","scrollToNext","Fragment","size","src","iconAs","alt","formatMessage","onClick","Items","map","item","id","_ref3","children","_objectSpread","key","propTypes","string","isRequired","arrayOf","element","bool","func","oneOfType","number","oneOf","defaultProps","undefined"],"sources":["../../src/ChipCarousel/index.tsx"],"sourcesContent":["import React, { ForwardedRef } from 'react';\nimport PropTypes from 'prop-types';\nimport { useIntl } from 'react-intl';\nimport classNames from 'classnames';\n// @ts-ignore\nimport { OverflowScroll, OverflowScrollContext } from '../OverflowScroll';\nimport IconButton from '../IconButton';\nimport Icon from '../Icon';\n// @ts-ignore\nimport { ArrowForward, ArrowBack } from '../../icons';\n// @ts-ignore\nimport messages from './messages';\nimport Chip from '../Chip';\n\nexport interface OverflowScrollContextProps {\n setOverflowRef: () => void,\n isScrolledToStart: boolean,\n isScrolledToEnd: boolean,\n scrollToPrevious: () => void,\n scrollToNext: () => void,\n}\n\nexport interface ChipCarouselProps {\n className?: string;\n items: Array<React.ReactElement>;\n ariaLabel: string;\n disableOpacityMasks?: boolean;\n onScrollPrevious?: () => void;\n onScrollNext?: () => void;\n canScrollHorizontal?: boolean;\n offset?: number | string;\n offsetType?: 'percentage' | 'fixed';\n gap?: number;\n}\n\nconst ChipCarousel = React.forwardRef(({\n className,\n items,\n ariaLabel,\n disableOpacityMasks,\n onScrollPrevious,\n onScrollNext,\n canScrollHorizontal = false,\n offset = 120,\n offsetType = 'fixed',\n gap,\n ...props\n}: ChipCarouselProps, ref: ForwardedRef<HTMLDivElement>) => {\n const intl = useIntl();\n\n return (\n <div\n className={classNames('pgn__chip-carousel', className, gap ? `pgn__chip-carousel-gap__${gap}` : '')}\n {...props}\n ref={ref}\n >\n <OverflowScroll\n ariaLabel={ariaLabel}\n hasInteractiveChildren\n disableScroll={!canScrollHorizontal}\n disableOpacityMasks={disableOpacityMasks}\n onScrollPrevious={onScrollPrevious}\n onScrollNext={onScrollNext}\n offset={offset}\n offsetType={offsetType}\n >\n <OverflowScrollContext.Consumer>\n {({\n setOverflowRef,\n isScrolledToStart,\n isScrolledToEnd,\n scrollToPrevious,\n scrollToNext,\n }: OverflowScrollContextProps) => (\n <>\n <>\n {!isScrolledToStart && (\n <IconButton\n size=\"sm\"\n className=\"pgn__chip-carousel__left-control\"\n src={ArrowBack}\n iconAs={Icon}\n alt={intl.formatMessage(messages.scrollToPrevious)}\n onClick={scrollToPrevious}\n />\n )}\n {!isScrolledToEnd && (\n <IconButton\n size=\"sm\"\n className=\"pgn__chip-carousel__right-control\"\n src={ArrowForward}\n iconAs={Icon}\n alt={intl.formatMessage(messages.scrollToNext)}\n onClick={scrollToNext}\n />\n )}\n </>\n <div ref={setOverflowRef} className=\"d-flex\">\n <OverflowScroll.Items>\n {items?.map((item, id) => {\n const { children } = item?.props || {};\n if (!children) {\n return null;\n }\n // eslint-disable-next-line react/no-array-index-key\n return React.createElement(Chip, { ...item.props, key: id });\n })}\n </OverflowScroll.Items>\n </div>\n </>\n )}\n </OverflowScrollContext.Consumer>\n </OverflowScroll>\n </div>\n );\n});\n\nChipCarousel.propTypes = {\n /** Text describing the ChipCarousel for screen readers. */\n ariaLabel: PropTypes.string.isRequired,\n /** Specifies class name for the ChipCarousel. */\n className: PropTypes.string,\n /** Specifies array of `Chip` elements to be rendered inside the carousel. */\n // @ts-ignore\n items: PropTypes.arrayOf(PropTypes.element).isRequired,\n /** Whether the default opacity masks should be shown at the start/end, if applicable. */\n disableOpacityMasks: PropTypes.bool,\n /** Callback function for when the user scrolls to the previous element. */\n onScrollPrevious: PropTypes.func,\n /** Callback function for when the user scrolls to the next element. */\n onScrollNext: PropTypes.func,\n /** Whether users can scroll within the overflow container. */\n canScrollHorizontal: PropTypes.bool,\n /** A value specifying the distance the scroll should move. */\n offset: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n /** Type of offset value (percentage or fixed). */\n offsetType: PropTypes.oneOf(['percentage', 'fixed']),\n /**\n * Specifies inner space between children blocks.\n *\n * Valid values are based on `the spacing classes`:\n * `0, 0.5, ... 6`.\n */\n gap: PropTypes.number,\n};\n\nChipCarousel.defaultProps = {\n className: undefined,\n disableOpacityMasks: undefined,\n onScrollPrevious: undefined,\n onScrollNext: undefined,\n canScrollHorizontal: false,\n offset: 120,\n offsetType: 'fixed',\n gap: 3,\n};\n\nexport default ChipCarousel;\n"],"mappings":";;;;;;;;;;AAAA,OAAOA,KAAK,MAAwB,OAAO;AAC3C,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,OAAO,QAAQ,YAAY;AACpC,OAAOC,UAAU,MAAM,YAAY;AACnC;AACA,SAASC,cAAc,EAAEC,qBAAqB,QAAQ,mBAAmB;AACzE,OAAOC,UAAU,MAAM,eAAe;AACtC,OAAOC,IAAI,MAAM,SAAS;AAC1B;AACA,SAASC,YAAY,EAAEC,SAAS,QAAQ,aAAa;AACrD;AACA,OAAOC,QAAQ,MAAM,YAAY;AACjC,OAAOC,IAAI,MAAM,SAAS;AAuB1B,IAAMC,YAAY,gBAAGZ,KAAK,CAACa,UAAU,CAAC,UAAAC,IAAA,EAYhBC,GAAiC,EAAK;EAAA,IAX1DC,SAAS,GAAAF,IAAA,CAATE,SAAS;IACTC,KAAK,GAAAH,IAAA,CAALG,KAAK;IACLC,SAAS,GAAAJ,IAAA,CAATI,SAAS;IACTC,mBAAmB,GAAAL,IAAA,CAAnBK,mBAAmB;IACnBC,gBAAgB,GAAAN,IAAA,CAAhBM,gBAAgB;IAChBC,YAAY,GAAAP,IAAA,CAAZO,YAAY;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C;IAC9D,CAAC,CACmB,CACnB,CACL,CAAC;EAAA,CAEyB,CAClB,CACb,CAAC;AAEV,CAAC,CAAC;AAEF3C,YAAY,CAACgD,SAAS,GAAG;EACvB;EACA1C,SAAS,EAAEjB,SAAS,CAAC4D,MAAM,CAACC,UAAU;EACtC;EACA9C,SAAS,EAAEf,SAAS,CAAC4D,MAAM;EAC3B;EACA;EACA5C,KAAK,EAAEhB,SAAS,CAAC8D,OAAO,CAAC9D,SAAS,CAAC+D,OAAO,CAAC,CAACF,UAAU;EACtD;EACA3C,mBAAmB,EAAElB,SAAS,CAACgE,IAAI;EACnC;EACA7C,gBAAgB,EAAEnB,SAAS,CAACiE,IAAI;EAChC;EACA7C,YAAY,EAAEpB,SAAS,CAACiE,IAAI;EAC5B;EACA3C,mBAAmB,EAAEtB,SAAS,CAACgE,IAAI;EACnC;EACAxC,MAAM,EAAExB,SAAS,CAACkE,SAAS,CAAC,CAAClE,SAAS,CAACmE,MAAM,EAAEnE,SAAS,CAAC4D,MAAM,CAAC,CAAC;EACjE;EACAlC,UAAU,EAAE1B,SAAS,CAACoE,KAAK,CAAC,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;EACpD;AACF;AACA;AACA;AACA;AACA;EACEzC,GAAG,EAAE3B,SAAS,CAACmE;AACjB,CAAC;AAEDxD,YAAY,CAAC0D,YAAY,GAAG;EAC1BtD,SAAS,EAAEuD,SAAS;EACpBpD,mBAAmB,EAAEoD,SAAS;EAC9BnD,gBAAgB,EAAEmD,SAAS;EAC3BlD,YAAY,EAAEkD,SAAS;EACvBhD,mBAAmB,EAAE,KAAK;EAC1BE,MAAM,EAAE,GAAG;EACXE,UAAU,EAAE,OAAO;EACnBC,GAAG,EAAE;AACP,CAAC;AAED,eAAehB,YAAY","ignoreList":[]}
@@ -6,7 +6,7 @@
6
6
 
7
7
  .collapsible-trigger {
8
8
  padding: var(--pgn-spacing-collapsible-card-spacer-y-base) var(--pgn-spacing-collapsible-card-spacer-x-base);
9
- border-radius: calc(var(--pgn-size-card-border-radius-base) - var(--pgn-size-card-border-width));
9
+ border-radius: var(--pgn-size-card-border-radius-inner);
10
10
  border-bottom: var(--pgn-size-card-border-width) solid transparent;
11
11
  transition: border-color 100ms ease 150ms;
12
12
  cursor: pointer;
@@ -22,8 +22,8 @@
22
22
 
23
23
  &[aria-expanded="true"] {
24
24
  border-radius:
25
- calc(var(--pgn-size-card-border-radius-base) - var(--pgn-size-card-border-width))
26
- calc(var(--pgn-size-card-border-radius-base) - var(--pgn-size-card-border-width)) 0 0;
25
+ var(--pgn-size-card-border-radius-inner)
26
+ var(--pgn-size-card-border-radius-inner) 0 0;
27
27
  border-color: var(--pgn-color-card-border-base);
28
28
  transition: none;
29
29
  text-align: start;