@openedx/paragon 23.10.0 → 23.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,33 +1,36 @@
1
1
  import React from 'react';
2
2
  import { render, screen } from '@testing-library/react';
3
3
 
4
+ import { IntlProvider } from 'react-intl';
4
5
  import ModalDialog from '../ModalDialog';
5
6
 
6
7
  describe('ModalDialog', () => {
7
8
  it('renders a dialog with aria-label and content', () => {
8
9
  const onClose = jest.fn();
9
10
  render(
10
- <ModalDialog
11
- title="My dialog"
12
- isOpen
13
- onClose={onClose}
14
- size="md"
15
- variant="default"
16
- hasCloseButton
17
- isOverflowVisible={false}
18
- >
19
- <ModalDialog.Header>
20
- <ModalDialog.Title>The title</ModalDialog.Title>
21
- </ModalDialog.Header>
11
+ <IntlProvider locale="en" messages={{}}>
12
+ <ModalDialog
13
+ title="My dialog"
14
+ isOpen
15
+ onClose={onClose}
16
+ size="md"
17
+ variant="default"
18
+ hasCloseButton
19
+ isOverflowVisible={false}
20
+ >
21
+ <ModalDialog.Header>
22
+ <ModalDialog.Title>The title</ModalDialog.Title>
23
+ </ModalDialog.Header>
22
24
 
23
- <ModalDialog.Body>
24
- <p>The content</p>
25
- </ModalDialog.Body>
25
+ <ModalDialog.Body>
26
+ <p>The content</p>
27
+ </ModalDialog.Body>
26
28
 
27
- <ModalDialog.Footer>
28
- <ModalDialog.CloseButton>Cancel</ModalDialog.CloseButton>
29
- </ModalDialog.Footer>
30
- </ModalDialog>,
29
+ <ModalDialog.Footer>
30
+ <ModalDialog.CloseButton>Cancel</ModalDialog.CloseButton>
31
+ </ModalDialog.Footer>
32
+ </ModalDialog>
33
+ </IntlProvider>,
31
34
  );
32
35
 
33
36
  const dialogNode = screen.getByRole('dialog');
@@ -40,15 +43,17 @@ describe('ModalDialog', () => {
40
43
  it('is hidden by default', () => {
41
44
  const onClose = jest.fn();
42
45
  render(
43
- <ModalDialog
44
- title="My dialog"
45
- onClose={onClose}
46
- isOverflowVisible={false}
47
- >
48
- <ModalDialog.Header><ModalDialog.Title>The title</ModalDialog.Title></ModalDialog.Header>
49
- <ModalDialog.Body><p>The hidden content</p></ModalDialog.Body>
50
- <ModalDialog.Footer><ModalDialog.CloseButton>Cancel</ModalDialog.CloseButton></ModalDialog.Footer>
51
- </ModalDialog>,
46
+ <IntlProvider locale="en" messages={{}}>
47
+ <ModalDialog
48
+ title="My dialog"
49
+ onClose={onClose}
50
+ isOverflowVisible={false}
51
+ >
52
+ <ModalDialog.Header><ModalDialog.Title>The title</ModalDialog.Title></ModalDialog.Header>
53
+ <ModalDialog.Body><p>The hidden content</p></ModalDialog.Body>
54
+ <ModalDialog.Footer><ModalDialog.CloseButton>Cancel</ModalDialog.CloseButton></ModalDialog.Footer>
55
+ </ModalDialog>
56
+ </IntlProvider>,
52
57
  );
53
58
 
54
59
  expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
@@ -59,30 +64,32 @@ describe('ModalDialog with Hero', () => {
59
64
  it('renders a dialog with aria-label and hero with img', () => {
60
65
  const onClose = jest.fn();
61
66
  render(
62
- <ModalDialog
63
- title="My dialog"
64
- isOpen
65
- onClose={onClose}
66
- size="md"
67
- variant="default"
68
- hasCloseButton
69
- isOverflowVisible={false}
70
- >
71
- <ModalDialog.Hero>
72
- <ModalDialog.Hero.Background backgroundSrc="imageurl" />
73
- <ModalDialog.Hero.Content data-testid="modal-hero-content">
74
- <ModalDialog.Title>The title</ModalDialog.Title>
75
- </ModalDialog.Hero.Content>
76
- </ModalDialog.Hero>
67
+ <IntlProvider locale="en" messages={{}}>
68
+ <ModalDialog
69
+ title="My dialog"
70
+ isOpen
71
+ onClose={onClose}
72
+ size="md"
73
+ variant="default"
74
+ hasCloseButton
75
+ isOverflowVisible={false}
76
+ >
77
+ <ModalDialog.Hero>
78
+ <ModalDialog.Hero.Background backgroundSrc="imageurl" />
79
+ <ModalDialog.Hero.Content data-testid="modal-hero-content">
80
+ <ModalDialog.Title>The title</ModalDialog.Title>
81
+ </ModalDialog.Hero.Content>
82
+ </ModalDialog.Hero>
77
83
 
78
- <ModalDialog.Body>
79
- <p>The content</p>
80
- </ModalDialog.Body>
84
+ <ModalDialog.Body>
85
+ <p>The content</p>
86
+ </ModalDialog.Body>
81
87
 
82
- <ModalDialog.Footer>
83
- <ModalDialog.CloseButton>Cancel</ModalDialog.CloseButton>
84
- </ModalDialog.Footer>
85
- </ModalDialog>,
88
+ <ModalDialog.Footer>
89
+ <ModalDialog.CloseButton>Cancel</ModalDialog.CloseButton>
90
+ </ModalDialog.Footer>
91
+ </ModalDialog>
92
+ </IntlProvider>,
86
93
  );
87
94
  const dialogNode = screen.getByRole('dialog');
88
95
 
@@ -1,14 +1,12 @@
1
- // Keep this file in sync with the .d.ts file (manually). It's in the same order
2
- // and each line number is the same, to make it easier.
3
-
4
1
  // // // // // // // // // // // // // // // // // // // // // // // // // // //
5
2
  // Things that have types
6
3
  // // // // // // // // // // // // // // // // // // // // // // // // // // //
4
+ export { default as Alert, ALERT_CLOSE_LABEL_TEXT } from './Alert';
7
5
  export { default as Bubble } from './Bubble';
8
6
  export { default as Button, ButtonGroup, ButtonToolbar } from './Button';
9
7
  export { default as Chip, CHIP_PGN_CLASS } from './Chip';
10
8
  export { default as ChipCarousel } from './ChipCarousel';
11
- export { default as Container } from './Container';
9
+ export { default as Container, type ContainerSize } from './Container';
12
10
  export {
13
11
  default as Form,
14
12
  RadioControl,
@@ -35,29 +33,37 @@ export { default as Hyperlink } from './Hyperlink';
35
33
  export { default as Icon } from './Icon';
36
34
  export { default as IconButton, IconButtonWithTooltip } from './IconButton';
37
35
  export { default as ModalContext } from './Modal/ModalContext';
38
- export { default as ModalDialog, MODAL_DIALOG_CLOSE_LABEL } from './Modal/ModalDialog';
36
+ export { default as ModalDialog } from './Modal/ModalDialog';
39
37
  export { default as ModalLayer } from './Modal/ModalLayer';
40
38
  export { default as Overlay, OverlayTrigger } from './Overlay';
41
39
  export { default as Portal } from './Modal/Portal';
42
40
  export { default as Toast, TOAST_CLOSE_LABEL_TEXT, TOAST_DELAY } from './Toast';
43
41
  export { default as Tooltip } from './Tooltip';
44
- export { default as useWindowSize } from './hooks/useWindowSizeHook';
45
- export { default as useToggle } from './hooks/useToggleHook';
46
- export { default as useArrowKeyNavigation } from './hooks/useArrowKeyNavigationHook';
42
+ export { default as useWindowSize, type WindowSizeData } from './hooks/useWindowSizeHook';
43
+ export { default as useToggle, type Toggler, type ToggleHandlers } from './hooks/useToggleHook';
44
+ export { default as useArrowKeyNavigation, type ArrowKeyNavProps } from './hooks/useArrowKeyNavigationHook';
47
45
  export { default as useIndexOfLastVisibleChild } from './hooks/useIndexOfLastVisibleChildHook';
48
46
  export { default as useIsVisible } from './hooks/useIsVisibleHook';
47
+ export { default as breakpoints } from './utils/breakpoints';
49
48
 
50
49
  // // // // // // // // // // // // // // // // // // // // // // // // // // //
51
50
  // Things that don't have types
52
51
  // // // // // // // // // // // // // // // // // // // // // // // // // // //
52
+ // @ts-ignore: has yet to be converted to TypeScript
53
53
  export { default as asInput } from './asInput';
54
+ // @ts-ignore: has yet to be converted to TypeScript
54
55
  export { default as ActionRow } from './ActionRow';
55
- export { default as Alert, ALERT_CLOSE_LABEL_TEXT } from './Alert';
56
+ // @ts-ignore: has yet to be converted to TypeScript
56
57
  export { default as Annotation } from './Annotation';
58
+ // @ts-ignore: has yet to be converted to TypeScript
57
59
  export { default as Avatar } from './Avatar';
60
+ // @ts-ignore: has yet to be converted to TypeScript
58
61
  export { default as AvatarButton } from './AvatarButton';
62
+ // @ts-ignore: has yet to be converted to TypeScript
59
63
  export { default as Badge } from './Badge';
64
+ // @ts-ignore: has yet to be converted to TypeScript
60
65
  export { default as Breadcrumb } from './Breadcrumb';
66
+
61
67
  export {
62
68
  default as Card,
63
69
  CardColumns,
@@ -67,35 +73,58 @@ export {
67
73
  CardGrid,
68
74
  CardCarousel,
69
75
  CARD_VARIANTS,
76
+ // @ts-ignore: has yet to be converted to TypeScript
70
77
  } from './Card';
71
78
  export {
72
79
  default as Carousel, CarouselItem, CAROUSEL_NEXT_LABEL_TEXT, CAROUSEL_PREV_LABEL_TEXT,
80
+ // @ts-ignore: has yet to be converted to TypeScript
73
81
  } from './Carousel';
82
+ // @ts-ignore: has yet to be converted to TypeScript
74
83
  export { default as CloseButton } from './CloseButton';
84
+ // @ts-ignore: has yet to be converted to TypeScript
75
85
  export { default as Layout, Col, Row } from './Layout';
86
+ // @ts-ignore: has yet to be converted to TypeScript
76
87
  export { default as Collapse } from './Collapse';
88
+ // @ts-ignore: has yet to be converted to TypeScript
77
89
  export { default as Collapsible } from './Collapsible';
90
+ // @ts-ignore: has yet to be converted to TypeScript
78
91
  export { default as Scrollable } from './Scrollable';
79
92
  export {
80
93
  default as Dropdown,
81
94
  DropdownToggle,
82
95
  DropdownButton,
83
96
  SplitButton,
97
+ // @ts-ignore: has yet to be converted to TypeScript
84
98
  } from './Dropdown';
99
+ // @ts-ignore: has yet to be converted to TypeScript
85
100
  export { default as Fade } from './Fade';
101
+ // @ts-ignore: has yet to be converted to TypeScript
86
102
  export { default as IconButtonToggle } from './IconButtonToggle';
103
+ // @ts-ignore: has yet to be converted to TypeScript
87
104
  export { default as Image, Figure } from './Image';
105
+ // @ts-ignore: has yet to be converted to TypeScript
88
106
  export { default as MailtoLink, MAIL_TO_LINK_EXTERNAL_LINK_ALTERNATIVE_TEXT, MAIL_TO_LINK_EXTERNAL_LINK_TITLE } from './MailtoLink';
107
+ // @ts-ignore: has yet to be converted to TypeScript
89
108
  export { default as Media } from './Media';
109
+ // @ts-ignore: has yet to be converted to TypeScript
90
110
  export { default as Menu } from './Menu';
111
+ // @ts-ignore: has yet to be converted to TypeScript
91
112
  export { default as MenuItem } from './Menu/MenuItem';
113
+ // @ts-ignore: has yet to be converted to TypeScript
92
114
  export { default as SelectMenu, SELECT_MENU_DEFAULT_MESSAGE } from './Menu/SelectMenu';
115
+ // @ts-ignore: has yet to be converted to TypeScript
93
116
  export { default as ModalCloseButton } from './Modal/ModalCloseButton';
117
+ // @ts-ignore: has yet to be converted to TypeScript
94
118
  export { default as FullscreenModal, FULLSCREEN_MODAL_CLOSE_LABEL } from './Modal/FullscreenModal';
119
+ // @ts-ignore: has yet to be converted to TypeScript
95
120
  export { default as MarketingModal } from './Modal/MarketingModal';
121
+ // @ts-ignore: has yet to be converted to TypeScript
96
122
  export { default as StandardModal, STANDARD_MODAL_CLOSE_LABEL } from './Modal/StandardModal';
123
+ // @ts-ignore: has yet to be converted to TypeScript
97
124
  export { default as AlertModal } from './Modal/AlertModal';
125
+ // @ts-ignore: has yet to be converted to TypeScript
98
126
  export { default as ModalPopup } from './Modal/ModalPopup';
127
+ // @ts-ignore: has yet to be converted to TypeScript
99
128
  export { default as PopperElement } from './Modal/PopperElement';
100
129
 
101
130
  export {
@@ -103,8 +132,11 @@ export {
103
132
  NavDropdown,
104
133
  NavItem,
105
134
  NavLink,
135
+ // @ts-ignore: has yet to be converted to TypeScript
106
136
  } from './Nav';
137
+ // @ts-ignore: has yet to be converted to TypeScript
107
138
  export { default as Navbar, NavbarBrand, NAVBAR_LABEL } from './Navbar';
139
+ // @ts-ignore: has yet to be converted to TypeScript
108
140
  export { default as PageBanner, PAGE_BANNER_DISMISS_ALT_TEXT } from './PageBanner';
109
141
  export {
110
142
  default as Pagination,
@@ -115,10 +147,15 @@ export {
115
147
  PAGINATION_BUTTON_LABEL_CURRENT_PAGE,
116
148
  PAGINATION_BUTTON_LABEL_NEXT,
117
149
  PAGINATION_BUTTON_LABEL_PAGE,
150
+ // @ts-ignore: has yet to be converted to TypeScript
118
151
  } from './Pagination';
152
+ // @ts-ignore: has yet to be converted to TypeScript
119
153
  export { default as Popover, PopoverTitle, PopoverContent } from './Popover';
154
+ // @ts-ignore: has yet to be converted to TypeScript
120
155
  export { default as ProgressBar } from './ProgressBar';
156
+ // @ts-ignore: has yet to be converted to TypeScript
121
157
  export { default as ProductTour } from './ProductTour';
158
+ // @ts-ignore: has yet to be converted to TypeScript
122
159
  export { default as ResponsiveEmbed } from './ResponsiveEmbed';
123
160
  export {
124
161
  default as SearchField,
@@ -126,10 +163,15 @@ export {
126
163
  SEARCH_FIELD_SCREEN_READER_TEXT_CLEAR_BUTTON,
127
164
  SEARCH_FIELD_SCREEN_READER_TEXT_SUBMIT_BUTTON,
128
165
  SEARCH_FIELD_BUTTON_TEXT,
166
+ // @ts-ignore: has yet to be converted to TypeScript
129
167
  } from './SearchField';
168
+ // @ts-ignore: has yet to be converted to TypeScript
130
169
  export { default as Sheet } from './Sheet';
170
+ // @ts-ignore: has yet to be converted to TypeScript
131
171
  export { default as Spinner } from './Spinner';
172
+ // @ts-ignore: has yet to be converted to TypeScript
132
173
  export { default as Stepper } from './Stepper';
174
+ // @ts-ignore: has yet to be converted to TypeScript
133
175
  export { default as StatefulButton } from './StatefulButton';
134
176
  export {
135
177
  default as Tabs,
@@ -137,48 +179,80 @@ export {
137
179
  TabContainer,
138
180
  TabContent,
139
181
  TabPane,
182
+ // @ts-ignore: has yet to be converted to TypeScript
140
183
  } from './Tabs';
184
+ // @ts-ignore: has yet to be converted to TypeScript
141
185
  export { default as TransitionReplace } from './TransitionReplace';
186
+ // @ts-ignore: has yet to be converted to TypeScript
142
187
  export { default as ValidationMessage } from './ValidationMessage';
188
+ // @ts-ignore: has yet to be converted to TypeScript
143
189
  export { default as DataTable } from './DataTable';
190
+ // @ts-ignore: has yet to be converted to TypeScript
144
191
  export { default as TextFilter } from './DataTable/filters/TextFilter';
192
+ // @ts-ignore: has yet to be converted to TypeScript
145
193
  export { default as CheckboxFilter } from './DataTable/filters/CheckboxFilter';
194
+ // @ts-ignore: has yet to be converted to TypeScript
146
195
  export { default as DropdownFilter } from './DataTable/filters/DropdownFilter';
196
+ // @ts-ignore: has yet to be converted to TypeScript
147
197
  export { default as MultiSelectDropdownFilter } from './DataTable/filters/MultiSelectDropdownFilter';
198
+ // @ts-ignore: has yet to be converted to TypeScript
148
199
  export { default as TableHeaderCell } from './DataTable/TableHeaderCell';
200
+ // @ts-ignore: has yet to be converted to TypeScript
149
201
  export { default as TableCell } from './DataTable/TableCell';
202
+ // @ts-ignore: has yet to be converted to TypeScript
150
203
  export { default as TableFilters, TABLE_FILTERS_BUTTON_TEXT } from './DataTable/TableFilters';
204
+ // @ts-ignore: has yet to be converted to TypeScript
151
205
  export { default as TableHeader } from './DataTable/TableHeaderRow';
206
+ // @ts-ignore: has yet to be converted to TypeScript
152
207
  export { default as TableRow } from './DataTable/TableRow';
208
+ // @ts-ignore: has yet to be converted to TypeScript
153
209
  export { default as TablePagination } from './DataTable/TablePagination';
210
+ // @ts-ignore: has yet to be converted to TypeScript
154
211
  export { default as TablePaginationMinimal } from './DataTable/TablePaginationMinimal';
212
+ // @ts-ignore: has yet to be converted to TypeScript
155
213
  export { default as DataTableContext } from './DataTable/DataTableContext';
214
+ // @ts-ignore: has yet to be converted to TypeScript
156
215
  export { default as BulkActions } from './DataTable/BulkActions';
216
+ // @ts-ignore: has yet to be converted to TypeScript
157
217
  export { default as TableControlBar } from './DataTable/TableControlBar';
218
+ // @ts-ignore: has yet to be converted to TypeScript
158
219
  export { default as TableFooter } from './DataTable/TableFooter';
220
+ // @ts-ignore: has yet to be converted to TypeScript
159
221
  export { default as CardView } from './DataTable/CardView';
222
+ // @ts-ignore: has yet to be converted to TypeScript
160
223
  export { default as Skeleton, SkeletonTheme } from './Skeleton/index';
224
+ // @ts-ignore: has yet to be converted to TypeScript
161
225
  export { default as Stack } from './Stack';
226
+ // @ts-ignore: has yet to be converted to TypeScript
162
227
  export { default as ToggleButton, ToggleButtonGroup } from './ToggleButton';
228
+ // @ts-ignore: has yet to be converted to TypeScript
163
229
  export { default as Sticky } from './Sticky';
230
+ // @ts-ignore: has yet to be converted to TypeScript
164
231
  export { default as SelectableBox } from './SelectableBox';
165
- export { default as breakpoints } from './utils/breakpoints';
232
+ // @ts-ignore: has yet to be converted to TypeScript
166
233
  export { default as Variant } from './utils/constants';
167
234
  export {
168
235
  OverflowScrollContext,
169
236
  OverflowScroll,
170
237
  useOverflowScroll,
171
238
  useOverflowScrollItems,
239
+ // @ts-ignore: has yet to be converted to TypeScript
172
240
  } from './OverflowScroll';
241
+ // @ts-ignore: has yet to be converted to TypeScript
173
242
  export { default as Dropzone } from './Dropzone';
243
+ // @ts-ignore: has yet to be converted to TypeScript
174
244
  export { default as messages } from './i18n';
245
+ // @ts-ignore: has yet to be converted to TypeScript
175
246
  export { default as Truncate } from './Truncate';
247
+ // @ts-ignore: has yet to be converted to TypeScript
176
248
  export { default as ColorPicker } from './ColorPicker';
177
249
 
250
+ // // // // // // // // // // // // // // // // // // // // // // // // // // //
178
251
  // Pass through any needed whole third-party library functionality
179
252
  // useTable for example is needed to use the DataTable component seamlessly
180
253
  // rather than setting a peer dependency in this project, we opt to tightly
181
254
  // couple these dependencies by passing through needed functionality.
255
+ // // // // // // // // // // // // // // // // // // // // // // // // // // //
182
256
  export {
183
257
  default as MediaQuery,
184
258
  useMediaQuery,
@@ -0,0 +1,26 @@
1
+ interface BreakpointRange {
2
+ minWidth?: number;
3
+ maxWidth?: number;
4
+ }
5
+
6
+ interface Breakpoints {
7
+ extraSmall: BreakpointRange;
8
+ small: BreakpointRange;
9
+ medium: BreakpointRange;
10
+ large: BreakpointRange;
11
+ extraLarge: BreakpointRange;
12
+ extraExtraLarge: BreakpointRange;
13
+ }
14
+
15
+ export const Size: {
16
+ readonly xs: 'extraSmall';
17
+ readonly sm: 'small';
18
+ readonly md: 'medium';
19
+ readonly lg: 'large';
20
+ readonly xl: 'extraLarge';
21
+ readonly xxl: 'extraExtraLarge';
22
+ };
23
+
24
+ declare const breakpoints: Breakpoints;
25
+
26
+ export default breakpoints;
@@ -12,7 +12,7 @@
12
12
  "serif": {
13
13
  "source": "$font-family-sans-serif",
14
14
  "$value": ["-apple-system", "BlinkMacSystemFont", "Segoe UI", "Roboto", "Helvetica Neue", "Arial",
15
- "Noto Sans", "sans-serif", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"],
15
+ "Noto Sans", "sans-serif", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"],
16
16
  "$description": "Sans-serif font family."
17
17
  }
18
18
  },
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "monospace": {
25
25
  "source": "$font-family-monospace",
26
- "$value": ["SFMono-Regular", "Menlo", "Monaco", "Consolas", "Liberation Mono", "Courier New", "monospace"],
26
+ "$value": ["SFMono-Regular", "Menlo", "Monaco", "Consolas", "Liberation Mono", "Courier New", "monospace"],
27
27
  "$description": "Monospace font family."
28
28
  }
29
29
  },