@instructure/ui-modal 8.53.3-snapshot-10 → 8.53.3-snapshot-13

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 (34) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/es/Modal/ModalBody/__new-tests__/ModalBody.test.js +101 -0
  3. package/es/Modal/ModalFooter/__new-tests__/ModalFooter.test.js +55 -0
  4. package/es/Modal/ModalHeader/__new-tests__/ModalHeader.test.js +91 -0
  5. package/es/Modal/__new-tests__/Modal.test.js +369 -0
  6. package/lib/Modal/ModalBody/__new-tests__/ModalBody.test.js +103 -0
  7. package/lib/Modal/ModalFooter/__new-tests__/ModalFooter.test.js +57 -0
  8. package/lib/Modal/ModalHeader/__new-tests__/ModalHeader.test.js +93 -0
  9. package/lib/Modal/__new-tests__/Modal.test.js +371 -0
  10. package/package.json +22 -21
  11. package/src/Modal/ModalBody/__new-tests__/ModalBody.test.tsx +117 -0
  12. package/src/Modal/ModalFooter/__new-tests__/ModalFooter.test.tsx +65 -0
  13. package/src/Modal/ModalHeader/__new-tests__/ModalHeader.test.tsx +107 -0
  14. package/src/Modal/__new-tests__/Modal.test.tsx +457 -0
  15. package/tsconfig.build.json +0 -2
  16. package/tsconfig.build.tsbuildinfo +1 -1
  17. package/types/Modal/ModalBody/__new-tests__/ModalBody.test.d.ts +2 -0
  18. package/types/Modal/ModalBody/__new-tests__/ModalBody.test.d.ts.map +1 -0
  19. package/types/Modal/ModalFooter/__new-tests__/ModalFooter.test.d.ts +2 -0
  20. package/types/Modal/ModalFooter/__new-tests__/ModalFooter.test.d.ts.map +1 -0
  21. package/types/Modal/ModalHeader/__new-tests__/ModalHeader.test.d.ts +2 -0
  22. package/types/Modal/ModalHeader/__new-tests__/ModalHeader.test.d.ts.map +1 -0
  23. package/types/Modal/__new-tests__/Modal.test.d.ts +2 -0
  24. package/types/Modal/__new-tests__/Modal.test.d.ts.map +1 -0
  25. package/es/Modal/ModalLocator.js +0 -46
  26. package/es/Modal/locator.js +0 -27
  27. package/lib/Modal/ModalLocator.js +0 -51
  28. package/lib/Modal/locator.js +0 -37
  29. package/src/Modal/ModalLocator.ts +0 -47
  30. package/src/Modal/locator.ts +0 -28
  31. package/types/Modal/ModalLocator.d.ts +0 -2656
  32. package/types/Modal/ModalLocator.d.ts.map +0 -1
  33. package/types/Modal/locator.d.ts +0 -4
  34. package/types/Modal/locator.d.ts.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-modal",
3
- "version": "8.53.3-snapshot-10",
3
+ "version": "8.53.3-snapshot-13",
4
4
  "description": "A component for displaying content in a dialog overlay",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -24,32 +24,33 @@
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
26
  "@babel/runtime": "^7.23.2",
27
- "@instructure/console": "8.53.3-snapshot-10",
28
- "@instructure/emotion": "8.53.3-snapshot-10",
29
- "@instructure/shared-types": "8.53.3-snapshot-10",
30
- "@instructure/ui-buttons": "8.53.3-snapshot-10",
31
- "@instructure/ui-dialog": "8.53.3-snapshot-10",
32
- "@instructure/ui-dom-utils": "8.53.3-snapshot-10",
33
- "@instructure/ui-motion": "8.53.3-snapshot-10",
34
- "@instructure/ui-overlays": "8.53.3-snapshot-10",
35
- "@instructure/ui-portal": "8.53.3-snapshot-10",
36
- "@instructure/ui-prop-types": "8.53.3-snapshot-10",
37
- "@instructure/ui-react-utils": "8.53.3-snapshot-10",
38
- "@instructure/ui-testable": "8.53.3-snapshot-10",
39
- "@instructure/ui-utils": "8.53.3-snapshot-10",
40
- "@instructure/ui-view": "8.53.3-snapshot-10",
27
+ "@instructure/console": "8.53.3-snapshot-13",
28
+ "@instructure/emotion": "8.53.3-snapshot-13",
29
+ "@instructure/shared-types": "8.53.3-snapshot-13",
30
+ "@instructure/ui-buttons": "8.53.3-snapshot-13",
31
+ "@instructure/ui-dialog": "8.53.3-snapshot-13",
32
+ "@instructure/ui-dom-utils": "8.53.3-snapshot-13",
33
+ "@instructure/ui-motion": "8.53.3-snapshot-13",
34
+ "@instructure/ui-overlays": "8.53.3-snapshot-13",
35
+ "@instructure/ui-portal": "8.53.3-snapshot-13",
36
+ "@instructure/ui-prop-types": "8.53.3-snapshot-13",
37
+ "@instructure/ui-react-utils": "8.53.3-snapshot-13",
38
+ "@instructure/ui-testable": "8.53.3-snapshot-13",
39
+ "@instructure/ui-utils": "8.53.3-snapshot-13",
40
+ "@instructure/ui-view": "8.53.3-snapshot-13",
41
41
  "prop-types": "^15.8.1"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "react": ">=16.8 <=18"
45
45
  },
46
46
  "devDependencies": {
47
- "@instructure/ui-babel-preset": "8.53.3-snapshot-10",
48
- "@instructure/ui-color-utils": "8.53.3-snapshot-10",
49
- "@instructure/ui-position": "8.53.3-snapshot-10",
50
- "@instructure/ui-test-locator": "8.53.3-snapshot-10",
51
- "@instructure/ui-test-utils": "8.53.3-snapshot-10",
52
- "@instructure/ui-themes": "8.53.3-snapshot-10"
47
+ "@instructure/ui-babel-preset": "8.53.3-snapshot-13",
48
+ "@instructure/ui-color-utils": "8.53.3-snapshot-13",
49
+ "@instructure/ui-position": "8.53.3-snapshot-13",
50
+ "@instructure/ui-themes": "8.53.3-snapshot-13",
51
+ "@testing-library/jest-dom": "^6.1.4",
52
+ "@testing-library/react": "^14.0.0",
53
+ "@testing-library/user-event": "^14.5.1"
53
54
  },
54
55
  "publishConfig": {
55
56
  "access": "public"
@@ -0,0 +1,117 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import React from 'react'
26
+
27
+ import { render } from '@testing-library/react'
28
+ import '@testing-library/jest-dom'
29
+
30
+ import { color2hex } from '@instructure/ui-color-utils'
31
+ import { canvas } from '@instructure/ui-themes'
32
+ import { View } from '@instructure/ui-view'
33
+ import type { ViewOwnProps } from '@instructure/ui-view'
34
+
35
+ import { ModalBody } from '../index'
36
+ import generateComponentTheme from '../theme'
37
+
38
+ const BODY_TEXT = 'Modal-body-text'
39
+
40
+ describe('<ModalBody />', () => {
41
+ it('should render', async () => {
42
+ const { findByText } = render(<ModalBody>{BODY_TEXT}</ModalBody>)
43
+ const modalBody = await findByText(BODY_TEXT)
44
+
45
+ expect(modalBody).toBeInTheDocument()
46
+ })
47
+
48
+ it('should set inverse styles', async () => {
49
+ const themeVariables = generateComponentTheme(canvas)
50
+ const { findByText } = render(
51
+ <ModalBody variant="inverse">{BODY_TEXT}</ModalBody>
52
+ )
53
+ const modalBody = await findByText(BODY_TEXT)
54
+ const modalBodyStyle = window.getComputedStyle(modalBody)
55
+ const bodyBackground = color2hex(
56
+ modalBodyStyle.getPropertyValue('background-color')
57
+ )
58
+
59
+ expect(modalBody).toBeInTheDocument()
60
+ expect(bodyBackground).toBe(themeVariables.inverseBackground)
61
+ })
62
+
63
+ it('should set the same width and height as the parent when overflow is set to fit', async () => {
64
+ const { findByText } = render(
65
+ <div style={{ width: '500px', height: '600px' }}>
66
+ <ModalBody overflow="fit">{BODY_TEXT}</ModalBody>
67
+ </div>
68
+ )
69
+ const modalBody = await findByText(BODY_TEXT)
70
+ const modalBodyStyle = window.getComputedStyle(modalBody)
71
+
72
+ expect(modalBodyStyle.width).toBe('100%')
73
+ expect(modalBodyStyle.height).toBe('100%')
74
+ })
75
+
76
+ describe('when passing down props to View', () => {
77
+ const allowedProps: Partial<ViewOwnProps> = {
78
+ padding: 'small',
79
+ elementRef: () => {},
80
+ as: 'section'
81
+ }
82
+
83
+ const allProps = View.allowedProps.filter((prop) => prop !== 'children')
84
+
85
+ allProps.forEach((prop) => {
86
+ if (prop in allowedProps) {
87
+ it(`should allow the '${prop}' prop`, () => {
88
+ const consoleErrorSpy = jest
89
+ .spyOn(console, 'error')
90
+ .mockImplementation(() => {})
91
+ const props = { [prop]: allowedProps[prop] }
92
+ render(<ModalBody {...props} />)
93
+
94
+ expect(consoleErrorSpy).not.toHaveBeenCalled()
95
+
96
+ consoleErrorSpy.mockRestore()
97
+ })
98
+ } else {
99
+ it(`should NOT allow the '${prop}' prop`, () => {
100
+ const expectedErrorMessage = `prop '${prop}' is not allowed.`
101
+ const consoleErrorSpy = jest
102
+ .spyOn(console, 'error')
103
+ .mockImplementation(() => {})
104
+
105
+ const props = { [prop]: 'NOT_ALLOWED_VALUE' }
106
+ render(<ModalBody {...props} />)
107
+
108
+ expect(consoleErrorSpy).toHaveBeenCalledWith(
109
+ expect.stringContaining(expectedErrorMessage),
110
+ expect.any(String)
111
+ )
112
+ consoleErrorSpy.mockRestore()
113
+ })
114
+ }
115
+ })
116
+ })
117
+ })
@@ -0,0 +1,65 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import React from 'react'
26
+
27
+ import { render } from '@testing-library/react'
28
+ import '@testing-library/jest-dom'
29
+
30
+ import { canvas } from '@instructure/ui-themes'
31
+ import { color2hex } from '@instructure/ui-color-utils'
32
+
33
+ import { ModalFooter } from '../index'
34
+ import generateComponentTheme from '../theme'
35
+
36
+ const FOOTER_TEXT = 'Modal-footer-text'
37
+
38
+ describe('<ModalFooter />', () => {
39
+ it('should render', async () => {
40
+ const { findByText } = render(<ModalFooter>{FOOTER_TEXT}</ModalFooter>)
41
+ const modalFooter = await findByText(FOOTER_TEXT)
42
+
43
+ expect(modalFooter).toBeInTheDocument()
44
+ })
45
+
46
+ it('should set inverse styles', async () => {
47
+ const themeVariables = generateComponentTheme(canvas)
48
+ const { findByText } = render(
49
+ <ModalFooter variant="inverse">{FOOTER_TEXT}</ModalFooter>
50
+ )
51
+ const modalFooter = await findByText(FOOTER_TEXT)
52
+
53
+ const modalFooterStyle = window.getComputedStyle(modalFooter)
54
+ const footerBackground = color2hex(
55
+ modalFooterStyle.getPropertyValue('background-color')
56
+ )
57
+ const footerBorderColor = color2hex(
58
+ modalFooterStyle.getPropertyValue('border-top-color')
59
+ )
60
+
61
+ expect(modalFooter).toBeInTheDocument()
62
+ expect(footerBackground).toBe(themeVariables.inverseBackground)
63
+ expect(footerBorderColor).toBe(themeVariables.inverseBorderColor)
64
+ })
65
+ })
@@ -0,0 +1,107 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import React from 'react'
26
+
27
+ import { render } from '@testing-library/react'
28
+ import '@testing-library/jest-dom'
29
+
30
+ import { canvas } from '@instructure/ui-themes'
31
+ import { color2hex } from '@instructure/ui-color-utils'
32
+
33
+ import { ModalHeader } from '../index'
34
+ import generateComponentTheme from '../theme'
35
+
36
+ const HEADER_TEXT = 'Modal-footer-text'
37
+
38
+ describe('<ModalHeader />', () => {
39
+ it('should render', async () => {
40
+ const { findByText } = render(<ModalHeader>{HEADER_TEXT}</ModalHeader>)
41
+ const modalHeader = await findByText(HEADER_TEXT)
42
+
43
+ expect(modalHeader).toBeInTheDocument()
44
+ })
45
+
46
+ it('should set inverse styles', async () => {
47
+ const themeVariables = generateComponentTheme(canvas)
48
+ const { findByText } = render(
49
+ <ModalHeader variant="inverse">{HEADER_TEXT}</ModalHeader>
50
+ )
51
+ const modalHeader = await findByText(HEADER_TEXT)
52
+
53
+ const modalHeaderStyle = window.getComputedStyle(modalHeader)
54
+ const headerBackground = color2hex(
55
+ modalHeaderStyle.getPropertyValue('background-color')
56
+ )
57
+ const headerBorderColor = color2hex(
58
+ modalHeaderStyle.getPropertyValue('border-bottom-color')
59
+ )
60
+
61
+ expect(modalHeader).toBeInTheDocument()
62
+ expect(headerBackground).toBe(themeVariables.inverseBackground)
63
+ expect(headerBorderColor).toBe(themeVariables.inverseBorderColor)
64
+ })
65
+
66
+ describe('spacing prop', () => {
67
+ it('should be correct by default', async () => {
68
+ const themeVariables = generateComponentTheme(canvas)
69
+ const { findByText } = render(<ModalHeader>{HEADER_TEXT}</ModalHeader>)
70
+ const modalHeader = await findByText(HEADER_TEXT)
71
+
72
+ const modalHeaderStyle = window.getComputedStyle(modalHeader)
73
+ const headerPadding = modalHeaderStyle.padding
74
+
75
+ expect(modalHeader).toBeInTheDocument()
76
+ expect(headerPadding).toBe(themeVariables.padding)
77
+ })
78
+
79
+ it('should correctly set default spacing', async () => {
80
+ const themeVariables = generateComponentTheme(canvas)
81
+ const { findByText } = render(
82
+ <ModalHeader spacing="default">{HEADER_TEXT}</ModalHeader>
83
+ )
84
+ const modalHeader = await findByText(HEADER_TEXT)
85
+
86
+ const modalHeaderStyle = window.getComputedStyle(modalHeader)
87
+ const headerPadding = modalHeaderStyle.padding
88
+
89
+ expect(modalHeader).toBeInTheDocument()
90
+ expect(headerPadding).toBe(themeVariables.padding)
91
+ })
92
+
93
+ it('should correctly set compact spacing', async () => {
94
+ const themeVariables = generateComponentTheme(canvas)
95
+ const { findByText } = render(
96
+ <ModalHeader spacing="compact">{HEADER_TEXT}</ModalHeader>
97
+ )
98
+ const modalHeader = await findByText(HEADER_TEXT)
99
+
100
+ const modalHeaderStyle = window.getComputedStyle(modalHeader)
101
+ const headerPadding = modalHeaderStyle.padding
102
+
103
+ expect(modalHeader).toBeInTheDocument()
104
+ expect(headerPadding).toBe(themeVariables.paddingCompact)
105
+ })
106
+ })
107
+ })