@financial-times/dotcom-ui-bootstrap 7.3.1 → 7.3.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.
- package/package.json +7 -3
- package/server.js +1 -0
- package/src/__test__/server/formatConfigJSON.spec.ts +16 -0
- package/src/__test__/server/getBootstrapJS.spec.ts +10 -0
- package/src/components/Bootstrap.tsx +30 -0
- package/src/index.ts +1 -0
- package/src/server/formatConfigJSON.ts +11 -0
- package/src/server/getBootstrapJS.ts +8 -0
- package/src/server/index.ts +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@financial-times/dotcom-ui-bootstrap",
|
|
3
|
-
"version": "7.3.
|
|
3
|
+
"version": "7.3.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "component.js",
|
|
6
6
|
"browser": "browser.js",
|
|
@@ -30,7 +30,11 @@
|
|
|
30
30
|
"react": "16.x || 17.x"
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
33
|
-
"dist/"
|
|
33
|
+
"dist/",
|
|
34
|
+
"src/",
|
|
35
|
+
"browser.js",
|
|
36
|
+
"component.js",
|
|
37
|
+
"server.js"
|
|
34
38
|
],
|
|
35
39
|
"repository": {
|
|
36
40
|
"type": "git",
|
|
@@ -45,4 +49,4 @@
|
|
|
45
49
|
"check-engine": "^1.10.1",
|
|
46
50
|
"react": "^16.8.6"
|
|
47
51
|
}
|
|
48
|
-
}
|
|
52
|
+
}
|
package/server.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/node/server/index')
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import subject from '../../server/formatConfigJSON'
|
|
2
|
+
|
|
3
|
+
describe('dotcom-ui-bootstrap/src/server/formatConfigJSON', () => {
|
|
4
|
+
it('returns a string', () => {
|
|
5
|
+
const result = subject([], [])
|
|
6
|
+
// NOTE: '' !== String('')
|
|
7
|
+
expect(typeof result === 'string').toBeTruthy()
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
it('returns a parseable JSON string', () => {
|
|
11
|
+
const result = JSON.parse(subject([], []))
|
|
12
|
+
|
|
13
|
+
expect(result.core).toBeInstanceOf(Array)
|
|
14
|
+
expect(result.enhanced).toBeInstanceOf(Array)
|
|
15
|
+
})
|
|
16
|
+
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import subject from '../../server/getBootstrapJS'
|
|
2
|
+
|
|
3
|
+
describe('dotcom-ui-bootstrap/src/server/formatConfigJSON', () => {
|
|
4
|
+
it('returns the JS snippet', () => {
|
|
5
|
+
const result = subject()
|
|
6
|
+
|
|
7
|
+
expect(typeof result === 'string').toBeTruthy()
|
|
8
|
+
expect(result).toMatch(/isEnhancedBrowser/)
|
|
9
|
+
})
|
|
10
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { formatConfigJSON, getBootstrapJS } from '../server'
|
|
3
|
+
|
|
4
|
+
type TBootstrapProps = {
|
|
5
|
+
trackErrors?: boolean
|
|
6
|
+
coreScripts?: string[]
|
|
7
|
+
enhancedScripts?: string[]
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function Bootstrap({ coreScripts, enhancedScripts, trackErrors }: TBootstrapProps) {
|
|
11
|
+
return (
|
|
12
|
+
<React.Fragment>
|
|
13
|
+
<script
|
|
14
|
+
type="application/json"
|
|
15
|
+
id="page-kit-bootstrap-config"
|
|
16
|
+
dangerouslySetInnerHTML={{ __html: formatConfigJSON(coreScripts, enhancedScripts, trackErrors) }}
|
|
17
|
+
/>
|
|
18
|
+
<script dangerouslySetInnerHTML={{ __html: getBootstrapJS() }} />
|
|
19
|
+
</React.Fragment>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
Bootstrap.defaultProps = {
|
|
24
|
+
trackErrors: true,
|
|
25
|
+
coreScripts: [],
|
|
26
|
+
enhancedScripts: []
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { Bootstrap }
|
|
30
|
+
export type { TBootstrapProps }
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components/Bootstrap'
|