@openedx/paragon 23.23.2 → 23.23.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 (123) hide show
  1. package/dist/Card/CardFooter.d.ts +19 -0
  2. package/dist/Card/CardFooter.js +5 -31
  3. package/dist/Card/CardFooter.js.map +1 -1
  4. package/dist/Card/CardSection.d.ts +19 -0
  5. package/dist/Card/CardSection.js +5 -31
  6. package/dist/Card/CardSection.js.map +1 -1
  7. package/dist/Card/CardStatus.d.ts +17 -0
  8. package/dist/Card/CardStatus.js +3 -25
  9. package/dist/Card/CardStatus.js.map +1 -1
  10. package/dist/Collapsible/CollapsibleAdvanced.d.ts +41 -0
  11. package/dist/Collapsible/CollapsibleAdvanced.js +8 -38
  12. package/dist/Collapsible/CollapsibleAdvanced.js.map +1 -1
  13. package/dist/Collapsible/CollapsibleBody.d.ts +11 -0
  14. package/dist/Collapsible/CollapsibleBody.js +6 -20
  15. package/dist/Collapsible/CollapsibleBody.js.map +1 -1
  16. package/dist/Collapsible/CollapsibleTrigger.d.ts +17 -0
  17. package/dist/Collapsible/CollapsibleTrigger.js +16 -33
  18. package/dist/Collapsible/CollapsibleTrigger.js.map +1 -1
  19. package/dist/Collapsible/CollapsibleVisible.d.ts +11 -0
  20. package/dist/Collapsible/CollapsibleVisible.js +6 -17
  21. package/dist/Collapsible/CollapsibleVisible.js.map +1 -1
  22. package/dist/Collapsible/index.d.ts +40 -0
  23. package/dist/Collapsible/index.js +23 -73
  24. package/dist/Collapsible/index.js.map +1 -1
  25. package/dist/DataTable/filters/DropdownFilter.d.ts +28 -0
  26. package/dist/DataTable/filters/DropdownFilter.js +0 -24
  27. package/dist/DataTable/filters/DropdownFilter.js.map +1 -1
  28. package/dist/Form/FormAutosuggestOption.d.ts +11 -0
  29. package/dist/Form/FormAutosuggestOption.js +1 -15
  30. package/dist/Form/FormAutosuggestOption.js.map +1 -1
  31. package/dist/Form/FormControlDecorator.d.ts +7 -0
  32. package/dist/Form/FormControlDecorator.js +1 -9
  33. package/dist/Form/FormControlDecorator.js.map +1 -1
  34. package/dist/Form/FormControlFloatingLabel.d.ts +6 -0
  35. package/dist/Form/FormControlFloatingLabel.js +0 -4
  36. package/dist/Form/FormControlFloatingLabel.js.map +1 -1
  37. package/dist/Form/index.d.ts +1 -1
  38. package/dist/Form/index.js +0 -1
  39. package/dist/Form/index.js.map +1 -1
  40. package/dist/Modal/ModalCloseButton.d.ts +15 -0
  41. package/dist/Modal/ModalCloseButton.js +11 -25
  42. package/dist/Modal/ModalCloseButton.js.map +1 -1
  43. package/dist/Modal/ModalDialog.d.ts +1 -1
  44. package/dist/Modal/ModalDialog.js +0 -1
  45. package/dist/Modal/ModalDialog.js.map +1 -1
  46. package/dist/ProductTour/CheckpointBody.d.ts +6 -0
  47. package/dist/ProductTour/CheckpointBody.js +3 -10
  48. package/dist/ProductTour/CheckpointBody.js.map +1 -1
  49. package/dist/ProductTour/CheckpointTitle.d.ts +6 -0
  50. package/dist/ProductTour/CheckpointTitle.js +3 -10
  51. package/dist/ProductTour/CheckpointTitle.js.map +1 -1
  52. package/dist/StatefulButton/index.d.ts +45 -0
  53. package/dist/StatefulButton/index.js +15 -61
  54. package/dist/StatefulButton/index.js.map +1 -1
  55. package/dist/Stepper/Stepper.d.ts +22 -0
  56. package/dist/Stepper/Stepper.js +1 -12
  57. package/dist/Stepper/Stepper.js.map +1 -1
  58. package/dist/Stepper/StepperActionRow.d.ts +19 -0
  59. package/dist/Stepper/StepperActionRow.js +10 -21
  60. package/dist/Stepper/StepperActionRow.js.map +1 -1
  61. package/dist/Stepper/StepperContext.d.ts +33 -0
  62. package/dist/Stepper/StepperContext.js +7 -10
  63. package/dist/Stepper/StepperContext.js.map +1 -1
  64. package/dist/Stepper/StepperHeader.d.ts +27 -0
  65. package/dist/Stepper/StepperHeader.js +17 -43
  66. package/dist/Stepper/StepperHeader.js.map +1 -1
  67. package/dist/Stepper/StepperHeaderStep.d.ts +16 -0
  68. package/dist/Stepper/StepperHeaderStep.js +2 -23
  69. package/dist/Stepper/StepperHeaderStep.js.map +1 -1
  70. package/dist/Stepper/StepperStep.d.ts +29 -0
  71. package/dist/Stepper/StepperStep.js +1 -36
  72. package/dist/Stepper/StepperStep.js.map +1 -1
  73. package/dist/Stepper/index.js +1 -0
  74. package/dist/Stepper/index.js.map +1 -0
  75. package/dist/TransitionReplace/index.d.ts +54 -0
  76. package/dist/TransitionReplace/index.js +9 -60
  77. package/dist/TransitionReplace/index.js.map +1 -1
  78. package/dist/index.d.ts +4 -4
  79. package/dist/index.js +4 -8
  80. package/dist/index.js.map +1 -1
  81. package/package.json +1 -1
  82. package/src/Card/{CardFooter.jsx → CardFooter.tsx} +25 -34
  83. package/src/Card/{CardSection.jsx → CardSection.tsx} +25 -34
  84. package/src/Card/{CardStatus.jsx → CardStatus.tsx} +21 -33
  85. package/src/Collapsible/{Collapsible.test.jsx → Collapsible.test.tsx} +88 -21
  86. package/src/Collapsible/{CollapsibleAdvanced.jsx → CollapsibleAdvanced.tsx} +42 -43
  87. package/src/Collapsible/{CollapsibleBody.jsx → CollapsibleBody.tsx} +13 -22
  88. package/src/Collapsible/{CollapsibleTrigger.jsx → CollapsibleTrigger.tsx} +29 -36
  89. package/src/Collapsible/{CollapsibleVisible.jsx → CollapsibleVisible.tsx} +14 -20
  90. package/src/Collapsible/__snapshots__/{Collapsible.test.jsx.snap → Collapsible.test.tsx.snap} +0 -1
  91. package/src/Collapsible/index.tsx +91 -0
  92. package/src/DataTable/filters/{DropdownFilter.jsx → DropdownFilter.tsx} +27 -28
  93. package/src/Form/{FormAutosuggestOption.jsx → FormAutosuggestOption.tsx} +12 -19
  94. package/src/Form/FormControlDecorator.tsx +16 -0
  95. package/src/Form/{FormControlFloatingLabel.jsx → FormControlFloatingLabel.tsx} +6 -7
  96. package/src/Form/index.tsx +0 -1
  97. package/src/Modal/ModalCloseButton.tsx +48 -0
  98. package/src/Modal/ModalDialog.tsx +0 -1
  99. package/src/Modal/tests/ModalDialog.test.tsx +1 -1
  100. package/src/ProductTour/{Checkpoint.test.jsx → Checkpoint.test.tsx} +11 -1
  101. package/src/ProductTour/CheckpointBody.tsx +21 -0
  102. package/src/ProductTour/CheckpointTitle.tsx +15 -0
  103. package/src/StatefulButton/{StatefulButtontest.test.jsx → StatefulButtontest.test.tsx} +4 -4
  104. package/src/StatefulButton/{index.jsx → index.tsx} +47 -57
  105. package/src/Stepper/{Stepper.jsx → Stepper.tsx} +18 -12
  106. package/src/Stepper/StepperActionRow.tsx +41 -0
  107. package/src/Stepper/{StepperContext.jsx → StepperContext.tsx} +41 -17
  108. package/src/Stepper/{StepperHeader.jsx → StepperHeader.tsx} +47 -44
  109. package/src/Stepper/{StepperHeaderStep.jsx → StepperHeaderStep.tsx} +18 -26
  110. package/src/Stepper/{StepperStep.jsx → StepperStep.tsx} +30 -39
  111. package/src/Stepper/index.ts +1 -0
  112. package/src/Stepper/tests/{Stepper.test.jsx → Stepper.test.tsx} +156 -14
  113. package/src/TransitionReplace/{TransitionReplace.test.jsx → TransitionReplace.test.tsx} +12 -10
  114. package/src/TransitionReplace/{index.jsx → index.tsx} +63 -72
  115. package/src/index.ts +4 -8
  116. package/src/Collapsible/index.jsx +0 -99
  117. package/src/Form/FormControlDecorator.jsx +0 -21
  118. package/src/Modal/ModalCloseButton.jsx +0 -45
  119. package/src/ProductTour/CheckpointBody.jsx +0 -24
  120. package/src/ProductTour/CheckpointTitle.jsx +0 -18
  121. package/src/Stepper/StepperActionRow.jsx +0 -40
  122. /package/{src/Stepper/index.js → dist/Stepper/index.d.ts} +0 -0
  123. /package/src/StatefulButton/__snapshots__/{StatefulButtontest.test.jsx.snap → StatefulButtontest.test.tsx.snap} +0 -0
@@ -1,10 +1,53 @@
1
1
  import React from 'react';
2
- import PropTypes from 'prop-types';
3
2
  import { CSSTransition, TransitionGroup } from 'react-transition-group';
4
3
  import classNames from 'classnames';
5
4
 
6
- class TransitionReplace extends React.Component {
7
- constructor(props) {
5
+ interface TransitionStyles {
6
+ entering?: React.CSSProperties;
7
+ entered?: React.CSSProperties;
8
+ exiting?: React.CSSProperties;
9
+ exited?: React.CSSProperties;
10
+ }
11
+
12
+ export interface TransitionReplaceProps {
13
+ /** The content that will be displayed with a transition when it changes. */
14
+ children?: React.ReactElement | null;
15
+ /** Duration of the element appearance transition. */
16
+ enterDuration?: number;
17
+ /** Duration of the element dismiss transition. */
18
+ exitDuration?: number;
19
+ /** Specifies class name to append to the base element. */
20
+ className?: string;
21
+ /** A `Transition` callback fired immediately after the `enter` or `appear` class is applied. */
22
+ onChildEnter?: (node: HTMLElement) => void;
23
+ /** A `Transition` callback fired immediately after the `enter-active` or `appear-active` class is applied. */
24
+ onChildEntering?: (node: HTMLElement) => void;
25
+ /**
26
+ * A `Transition` callback fired immediately after the `enter` or
27
+ * `appear` classes are removed and the done class is added to the DOM node.
28
+ */
29
+ onChildEntered?: (node: HTMLElement) => void;
30
+ /** A `Transition` callback fired immediately after the `exit` class is applied. */
31
+ onChildExit?: (node: HTMLElement) => void;
32
+ /** A `Transition` callback fired immediately after the `exit-active` is applied. */
33
+ onChildExiting?: (node: HTMLElement) => void;
34
+ /**
35
+ * A `Transition` callback fired immediately after the `exit` classes
36
+ * are removed and the exit-done class is added to the DOM node.
37
+ */
38
+ onChildExited?: (node: HTMLElement) => void;
39
+ /** An object that specifies transition styles. */
40
+ transitionStyles?: TransitionStyles;
41
+ /** Specifies class name to append to the `Transition`. */
42
+ transitionClassNames?: string;
43
+ }
44
+
45
+ interface TransitionReplaceState {
46
+ height: number | null;
47
+ }
48
+
49
+ class TransitionReplace extends React.Component<TransitionReplaceProps, TransitionReplaceState> {
50
+ constructor(props: TransitionReplaceProps) {
8
51
  super(props);
9
52
 
10
53
  this.state = { height: null };
@@ -31,47 +74,48 @@ class TransitionReplace extends React.Component {
31
74
  // 2. onChildEntering (set the height to match the new content)
32
75
  // 3. onChildExited (reset the height to null)
33
76
 
34
- onChildEnter(htmlNode) {
77
+ onChildEnter(htmlNode: HTMLElement) {
35
78
  if (this.props.onChildEnter) { this.props.onChildEnter(htmlNode); }
36
79
  }
37
80
 
38
- onChildEntering(htmlNode) {
81
+ onChildEntering(htmlNode: HTMLElement) {
39
82
  this.setState({ height: htmlNode.offsetHeight });
40
83
  if (this.props.onChildEntering) { this.props.onChildEntering(htmlNode); }
41
84
  }
42
85
 
43
- onChildEntered(htmlNode) {
86
+ onChildEntered(htmlNode: HTMLElement) {
44
87
  this.setState({ height: null });
45
88
  if (this.props.onChildEntered) { this.props.onChildEntered(htmlNode); }
46
89
  }
47
90
 
48
- onChildExit(htmlNode) {
91
+ onChildExit(htmlNode: HTMLElement) {
49
92
  this.setState({ height: htmlNode.offsetHeight });
50
93
  if (this.props.onChildExit) { this.props.onChildExit(htmlNode); }
51
94
  }
52
95
 
53
- onChildExiting(htmlNode) {
96
+ onChildExiting(htmlNode: HTMLElement) {
54
97
  if (this.props.onChildExiting) { this.props.onChildExiting(htmlNode); }
55
98
  }
56
99
 
57
- onChildExited(htmlNode) {
100
+ onChildExited(htmlNode: HTMLElement) {
58
101
  this.setState({ height: null });
59
102
  if (this.props.onChildExited) { this.props.onChildExited(htmlNode); }
60
103
  }
61
104
 
62
- renderChildTransition(child) {
105
+ renderChildTransition = (child: React.ReactElement) => {
63
106
  if (!child.key && process.env.NODE_ENV === 'development') {
64
107
  // eslint-disable-next-line no-console
65
108
  console.warn("TransitionReplace: A child is missing a 'key' prop. Keys are required for any child of this component.");
66
109
  }
110
+
67
111
  // Makes the exiting and entering children occupy the same space
68
112
  // SCSS handles the crossfade so it can be easily overridden
69
- const commonChildStyles = {
113
+ const commonChildStyles: React.CSSProperties = {
70
114
  // Prevent margin-collapsing which throws off height calculations
71
115
  padding: '.1px 0',
72
116
  };
73
117
 
74
- const transitionStyles = {
118
+ const transitionStyles: Record<string, React.CSSProperties> = {
75
119
  entering: {},
76
120
  entered: {},
77
121
  exiting: {
@@ -87,8 +131,8 @@ class TransitionReplace extends React.Component {
87
131
  return (
88
132
  <CSSTransition
89
133
  timeout={{
90
- enter: this.props.enterDuration,
91
- exit: this.props.exitDuration,
134
+ enter: this.props.enterDuration ?? 300,
135
+ exit: this.props.exitDuration ?? 300,
92
136
  }}
93
137
  unmountOnExit
94
138
  mountOnEnter
@@ -98,14 +142,14 @@ class TransitionReplace extends React.Component {
98
142
  onExit={this.onChildExit}
99
143
  onExiting={this.onChildExiting}
100
144
  onExited={this.onChildExited}
101
- classNames={this.props.transitionClassNames}
145
+ classNames={this.props.transitionClassNames ?? 'pgn__transition-replace'}
102
146
  >
103
147
  {state => (
104
148
  <div
105
149
  style={{
106
150
  ...commonChildStyles,
107
151
  ...transitionStyles[state],
108
- ...this.props.transitionStyles[state],
152
+ ...(this.props.transitionStyles?.[state as keyof TransitionStyles] || {}),
109
153
  }}
110
154
  >
111
155
  {child}
@@ -113,7 +157,7 @@ class TransitionReplace extends React.Component {
113
157
  )}
114
158
  </CSSTransition>
115
159
  );
116
- }
160
+ };
117
161
 
118
162
  render() {
119
163
  return (
@@ -124,65 +168,12 @@ class TransitionReplace extends React.Component {
124
168
  { 'overflow-hidden': this.state.height !== null },
125
169
  this.props.className,
126
170
  )}
127
- style={{ height: this.state.height }}
171
+ style={{ height: this.state.height ?? undefined }}
128
172
  >
129
- {React.Children.map(this.props.children, this.renderChildTransition, this)}
173
+ {React.Children.map(this.props.children, this.renderChildTransition)}
130
174
  </TransitionGroup>
131
175
  );
132
176
  }
133
177
  }
134
178
 
135
- TransitionReplace.propTypes = {
136
- /** Specifies an additional class for the base element */
137
- children: PropTypes.element,
138
- /** Duration of the element appearance transition. */
139
- enterDuration: PropTypes.number,
140
- /** Duration of the element dismiss transition. */
141
- exitDuration: PropTypes.number,
142
- /** Specifies class name to append to the base element. */
143
- className: PropTypes.string,
144
- /** A `Transition` callback fired immediately after the `enter` or `appear` class is applied. */
145
- onChildEnter: PropTypes.func,
146
- /** A `Transition` callback fired immediately after the `enter-active` or `appear-active` class is applied. */
147
- onChildEntering: PropTypes.func,
148
- /**
149
- * A `Transition` callback fired immediately after the `enter` or
150
- * `appear` classes are removed and the done class is added to the DOM node.
151
- */
152
- onChildEntered: PropTypes.func,
153
- /** A `Transition` callback fired immediately after the `exit` class is applied. */
154
- onChildExit: PropTypes.func,
155
- /** A `Transition` callback fired immediately after the `exit-active` is applied. */
156
- onChildExiting: PropTypes.func,
157
- /**
158
- * A `Transition` callback fired immediately after the `exit` classes
159
- * are removed and the exit-done class is added to the DOM node.
160
- */
161
- onChildExited: PropTypes.func,
162
- /** An object that specifies transition styles. */
163
- transitionStyles: PropTypes.shape({
164
- entering: PropTypes.shape({}),
165
- entered: PropTypes.shape({}),
166
- exiting: PropTypes.shape({}),
167
- exited: PropTypes.shape({}),
168
- }),
169
- /** Specifies class name to append to the `Transition`. */
170
- transitionClassNames: PropTypes.string,
171
- };
172
-
173
- TransitionReplace.defaultProps = {
174
- children: undefined,
175
- enterDuration: 300,
176
- exitDuration: 300,
177
- className: undefined,
178
- onChildEnter: undefined,
179
- onChildEntering: undefined,
180
- onChildEntered: undefined,
181
- onChildExit: undefined,
182
- onChildExiting: undefined,
183
- onChildExited: undefined,
184
- transitionStyles: {},
185
- transitionClassNames: 'pgn__transition-replace',
186
- };
187
-
188
179
  export default TransitionReplace;
package/src/index.ts CHANGED
@@ -12,7 +12,9 @@ export { default as Bubble } from './Bubble';
12
12
  export { default as Button, ButtonGroup, ButtonToolbar } from './Button';
13
13
  export { default as Chip, CHIP_PGN_CLASS } from './Chip';
14
14
  export { default as ChipCarousel } from './ChipCarousel';
15
+ export { default as CloseButton } from './CloseButton';
15
16
  export { default as Container, type ContainerSize } from './Container';
17
+ export { default as DropdownFilter } from './DataTable/filters/DropdownFilter';
16
18
  export {
17
19
  default as Form,
18
20
  RadioControl,
@@ -38,6 +40,7 @@ export {
38
40
  export { default as Hyperlink } from './Hyperlink';
39
41
  export { default as Icon } from './Icon';
40
42
  export { default as IconButton, IconButtonWithTooltip } from './IconButton';
43
+ export { default as ModalCloseButton } from './Modal/ModalCloseButton';
41
44
  export { default as ModalContext } from './Modal/ModalContext';
42
45
  export { default as ModalDialog } from './Modal/ModalDialog';
43
46
  export { default as ModalLayer } from './Modal/ModalLayer';
@@ -46,6 +49,7 @@ export { default as Portal } from './Modal/Portal';
46
49
  export { default as Scrollable } from './Scrollable';
47
50
  export { default as Spinner } from './Spinner';
48
51
  export { default as Stack } from './Stack';
52
+ export { default as StatefulButton } from './StatefulButton';
49
53
  export { default as Toast, TOAST_CLOSE_LABEL_TEXT, TOAST_DELAY } from './Toast';
50
54
  export { default as Tooltip } from './Tooltip';
51
55
  export { default as useWindowSize, type WindowSizeData } from './hooks/useWindowSizeHook';
@@ -77,8 +81,6 @@ export {
77
81
  // @ts-ignore: has yet to be converted to TypeScript
78
82
  } from './Carousel';
79
83
  // @ts-ignore: has yet to be converted to TypeScript
80
- export { default as CloseButton } from './CloseButton';
81
- // @ts-ignore: has yet to be converted to TypeScript
82
84
  export { default as Layout, Col, Row } from './Layout';
83
85
  // @ts-ignore: has yet to be converted to TypeScript
84
86
  export { default as Collapse } from './Collapse';
@@ -108,8 +110,6 @@ export { default as MenuItem } from './Menu/MenuItem';
108
110
  // @ts-ignore: has yet to be converted to TypeScript
109
111
  export { default as SelectMenu, SELECT_MENU_DEFAULT_MESSAGE } from './Menu/SelectMenu';
110
112
  // @ts-ignore: has yet to be converted to TypeScript
111
- export { default as ModalCloseButton } from './Modal/ModalCloseButton';
112
- // @ts-ignore: has yet to be converted to TypeScript
113
113
  export { default as FullscreenModal, FULLSCREEN_MODAL_CLOSE_LABEL } from './Modal/FullscreenModal';
114
114
  // @ts-ignore: has yet to be converted to TypeScript
115
115
  export { default as MarketingModal } from './Modal/MarketingModal';
@@ -164,8 +164,6 @@ export {
164
164
  export { default as Sheet } from './Sheet';
165
165
  // @ts-ignore: has yet to be converted to TypeScript
166
166
  export { default as Stepper } from './Stepper';
167
- // @ts-ignore: has yet to be converted to TypeScript
168
- export { default as StatefulButton } from './StatefulButton';
169
167
  export {
170
168
  default as Tabs,
171
169
  Tab,
@@ -185,8 +183,6 @@ export { default as TextFilter } from './DataTable/filters/TextFilter';
185
183
  // @ts-ignore: has yet to be converted to TypeScript
186
184
  export { default as CheckboxFilter } from './DataTable/filters/CheckboxFilter';
187
185
  // @ts-ignore: has yet to be converted to TypeScript
188
- export { default as DropdownFilter } from './DataTable/filters/DropdownFilter';
189
- // @ts-ignore: has yet to be converted to TypeScript
190
186
  export { default as MultiSelectDropdownFilter } from './DataTable/filters/MultiSelectDropdownFilter';
191
187
  // @ts-ignore: has yet to be converted to TypeScript
192
188
  export { default as TableHeaderCell } from './DataTable/TableHeaderCell';
@@ -1,99 +0,0 @@
1
- import React from 'react';
2
- import classNames from 'classnames';
3
- import PropTypes from 'prop-types';
4
-
5
- import { ExpandLess, ExpandMore } from '../../icons';
6
- import CollapsibleAdvanced, { CollapsibleContext } from './CollapsibleAdvanced';
7
- import CollapsibleBody from './CollapsibleBody';
8
- import CollapsibleTrigger from './CollapsibleTrigger';
9
- import CollapsibleVisible from './CollapsibleVisible';
10
- import Icon from '../Icon';
11
-
12
- const styleIcons = {
13
- basic: {
14
- iconWhenClosed: <Icon src={ExpandMore} />,
15
- iconWhenOpen: <Icon src={ExpandLess} />,
16
- },
17
- // card and card-lg use the defaults specified in defaultProps
18
- };
19
-
20
- const Collapsible = React.forwardRef((props, ref) => {
21
- const {
22
- children,
23
- className,
24
- title,
25
- styling,
26
- iconWhenClosed,
27
- iconWhenOpen,
28
- ...other
29
- } = props;
30
-
31
- const icons = { iconWhenClosed, iconWhenOpen, ...styleIcons[styling] };
32
- const titleElement = React.isValidElement(title) ? title : <span>{title}</span>;
33
-
34
- return (
35
- <Collapsible.Advanced
36
- {...other}
37
- className={classNames(className, `collapsible-${styling}`)}
38
- ref={ref}
39
- >
40
- <Collapsible.Trigger className="collapsible-trigger">
41
- {titleElement}
42
- <span className="collapsible-icon">
43
- <Collapsible.Visible whenClosed>{icons.iconWhenClosed}</Collapsible.Visible>
44
- <Collapsible.Visible whenOpen>{icons.iconWhenOpen}</Collapsible.Visible>
45
- </span>
46
- </Collapsible.Trigger>
47
-
48
- <Collapsible.Body className="collapsible-body">{children}</Collapsible.Body>
49
- </Collapsible.Advanced>
50
- );
51
- });
52
-
53
- Collapsible.propTypes = {
54
- /** Specifies contents of the component. */
55
- children: PropTypes.node.isRequired,
56
- /** Specifies class name to append to the base element. */
57
- className: PropTypes.string,
58
- /** Specifies whether the `Collapsible` should be initially open. */
59
- defaultOpen: PropTypes.bool,
60
- /** Specifies icon to show when `Collapsible` is closed. */
61
- iconWhenClosed: PropTypes.element,
62
- /** Specifies icon to show when `Collapsible` is open. */
63
- iconWhenOpen: PropTypes.element,
64
- /** Callback fired when `Collapsible` closes. */
65
- onClose: PropTypes.func,
66
- /** Callback fired when `Collapsible` opens. */
67
- onOpen: PropTypes.func,
68
- /** Callback fired when `Collapsible's` state is toggled. */
69
- onToggle: PropTypes.func,
70
- /** Specifies whether `Collapsible` is open. */
71
- open: PropTypes.bool,
72
- /** Specifies style variant. */
73
- styling: PropTypes.oneOf(['basic', 'card', 'card-lg']),
74
- /** Specifies title. */
75
- title: PropTypes.node.isRequired,
76
- /** Unmount the component (remove it from the DOM) when it is collapsed */
77
- unmountOnExit: PropTypes.bool,
78
- };
79
-
80
- Collapsible.defaultProps = {
81
- className: undefined,
82
- defaultOpen: false,
83
- iconWhenClosed: <Icon src={ExpandMore} />,
84
- iconWhenOpen: <Icon src={ExpandLess} />,
85
- onClose: undefined,
86
- onOpen: undefined,
87
- onToggle: undefined,
88
- open: undefined,
89
- styling: 'card',
90
- unmountOnExit: true,
91
- };
92
-
93
- Collapsible.Advanced = CollapsibleAdvanced;
94
- Collapsible.Body = CollapsibleBody;
95
- Collapsible.Trigger = CollapsibleTrigger;
96
- Collapsible.Visible = CollapsibleVisible;
97
- Collapsible.Context = CollapsibleContext;
98
-
99
- export default Collapsible;
@@ -1,21 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
-
4
- function FormControlDecorator({ children, location }) {
5
- return (
6
- <div className={`pgn__form-control-decorator pgn__form-control-decorator-${location}`}>
7
- {children}
8
- </div>
9
- );
10
- }
11
-
12
- FormControlDecorator.propTypes = {
13
- children: PropTypes.node.isRequired,
14
- location: PropTypes.oneOf(['leading', 'trailing']),
15
- };
16
-
17
- FormControlDecorator.defaultProps = {
18
- location: 'leading',
19
- };
20
-
21
- export default FormControlDecorator;
@@ -1,45 +0,0 @@
1
- import React, { useContext } from 'react';
2
- import PropTypes from 'prop-types';
3
- import classNames from 'classnames';
4
- import ModalContext from './ModalContext';
5
- import Button from '../Button';
6
-
7
- const ModalCloseButton = React.forwardRef(({ as, children, ...props }, ref) => {
8
- const { onClose } = useContext(ModalContext);
9
- const type = as;
10
- const componentProps = {
11
- ...props,
12
- className: classNames('pgn__modal-close-button', props.className),
13
- onClick: () => {
14
- onClose();
15
- if (props.onClick) {
16
- props.onClick();
17
- }
18
- },
19
- ref,
20
- };
21
-
22
- // Use the non-jsx syntax to create this element so we can more
23
- // finely control the component type (defaulted to Button via defaultProps)
24
- return React.createElement(type, componentProps, children);
25
- });
26
-
27
- ModalCloseButton.propTypes = {
28
- /** Specifies the base element */
29
- as: PropTypes.elementType,
30
- /** Specifies the content of the button */
31
- children: PropTypes.node,
32
- /** Specifies class name to append to the base element */
33
- className: PropTypes.string,
34
- /** Specifies the callback function when the close button is clicked */
35
- onClick: PropTypes.func,
36
- };
37
-
38
- ModalCloseButton.defaultProps = {
39
- as: Button,
40
- onClick: undefined,
41
- className: undefined,
42
- children: null,
43
- };
44
-
45
- export default ModalCloseButton;
@@ -1,24 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
-
4
- const CheckpointBody = React.forwardRef(({ children }, ref) => {
5
- if (!children) {
6
- return null;
7
- }
8
-
9
- return (
10
- <div className="pgn__checkpoint-body" ref={ref}>
11
- {children}
12
- </div>
13
- );
14
- });
15
-
16
- CheckpointBody.defaultProps = {
17
- children: null,
18
- };
19
-
20
- CheckpointBody.propTypes = {
21
- children: PropTypes.node,
22
- };
23
-
24
- export default CheckpointBody;
@@ -1,18 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
-
4
- const CheckpointTitle = React.forwardRef(({ children }, ref) => (
5
- <h2 id="pgn__checkpoint-title" ref={ref}>
6
- {children}
7
- </h2>
8
- ));
9
-
10
- CheckpointTitle.defaultProps = {
11
- children: null,
12
- };
13
-
14
- CheckpointTitle.propTypes = {
15
- children: PropTypes.node,
16
- };
17
-
18
- export default CheckpointTitle;
@@ -1,40 +0,0 @@
1
- import React, { useContext } from 'react';
2
- import PropTypes from 'prop-types';
3
- import { StepperContext } from './StepperContext';
4
- import ActionRow from '../ActionRow';
5
-
6
- function StepperActionRow({
7
- as,
8
- children,
9
- eventKey,
10
- ...props
11
- }) {
12
- const { activeKey } = useContext(StepperContext);
13
- const isActive = activeKey === eventKey;
14
-
15
- if (!isActive) {
16
- return null;
17
- }
18
-
19
- return React.createElement(as, props, children);
20
- }
21
-
22
- StepperActionRow.propTypes = {
23
- /** Specifies the content of the `ActionRow`. */
24
- children: PropTypes.node.isRequired,
25
- /**
26
- * An identifier of the `ActionRow`. When `activeKey` on the
27
- * `Stepper` equals to the `eventKey`, the `ActionRow` will be displayed.
28
- */
29
- eventKey: PropTypes.string.isRequired,
30
- /** Specifies the base element */
31
- as: PropTypes.elementType,
32
- };
33
-
34
- StepperActionRow.defaultProps = {
35
- as: ActionRow,
36
- };
37
-
38
- StepperActionRow.Spacer = ActionRow.Spacer;
39
-
40
- export default StepperActionRow;