@modernpoacher/sprockets 0.0.5
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/README.md +11 -0
- package/babel.config.cjs +99 -0
- package/jsconfig.json +11 -0
- package/package.json +138 -0
- package/src/components/common/text-content/index.cjs +17 -0
- package/src/components/common/text-content/index.jsx +24 -0
- package/src/components/description/index.cjs +17 -0
- package/src/components/description/index.jsx +38 -0
- package/src/components/error-message/index.cjs +17 -0
- package/src/components/error-message/index.jsx +42 -0
- package/src/components/group/index.cjs +17 -0
- package/src/components/group/index.jsx +55 -0
- package/src/components/title/index.cjs +17 -0
- package/src/components/title/index.jsx +59 -0
- package/src/index.cjs +19 -0
- package/src/index.d.cts +172 -0
- package/src/index.mjs +19 -0
- package/src/sprockets/check-answers/group/answer-item.cjs +13 -0
- package/src/sprockets/check-answers/group/answer-item.jsx +37 -0
- package/src/sprockets/check-answers/group/answer-title.cjs +13 -0
- package/src/sprockets/check-answers/group/answer-title.jsx +23 -0
- package/src/sprockets/check-answers/group/answer-value.cjs +13 -0
- package/src/sprockets/check-answers/group/answer-value.jsx +51 -0
- package/src/sprockets/check-answers/group/change-answer.cjs +13 -0
- package/src/sprockets/check-answers/group/change-answer.jsx +37 -0
- package/src/sprockets/check-answers/group/index.cjs +17 -0
- package/src/sprockets/check-answers/group/index.jsx +93 -0
- package/src/sprockets/check-answers/group/visually-hidden-text.cjs +13 -0
- package/src/sprockets/check-answers/group/visually-hidden-text.jsx +27 -0
- package/src/sprockets/check-answers/index.cjs +17 -0
- package/src/sprockets/check-answers/index.jsx +86 -0
- package/src/sprockets/check-answers/title/index.cjs +17 -0
- package/src/sprockets/check-answers/title/index.jsx +33 -0
- package/src/sprockets/error-summary/group/error-item.cjs +13 -0
- package/src/sprockets/error-summary/group/error-item.jsx +22 -0
- package/src/sprockets/error-summary/group/index.cjs +17 -0
- package/src/sprockets/error-summary/group/index.jsx +93 -0
- package/src/sprockets/error-summary/index.cjs +17 -0
- package/src/sprockets/error-summary/index.jsx +88 -0
- package/src/sprockets/error-summary/title/index.cjs +17 -0
- package/src/sprockets/error-summary/title/index.jsx +33 -0
- package/src/sprockets/fieldset/description/index.cjs +17 -0
- package/src/sprockets/fieldset/description/index.jsx +20 -0
- package/src/sprockets/fieldset/error-message/index.cjs +17 -0
- package/src/sprockets/fieldset/error-message/index.jsx +20 -0
- package/src/sprockets/fieldset/group/index.cjs +17 -0
- package/src/sprockets/fieldset/group/index.jsx +20 -0
- package/src/sprockets/fieldset/index.cjs +17 -0
- package/src/sprockets/fieldset/index.jsx +105 -0
- package/src/sprockets/fieldset/title/index.cjs +17 -0
- package/src/sprockets/fieldset/title/index.jsx +19 -0
- package/src/sprockets/index.cjs +20 -0
- package/src/sprockets/index.jsx +90 -0
- package/src/sprockets/table/group/index.cjs +17 -0
- package/src/sprockets/table/group/index.jsx +163 -0
- package/src/sprockets/table/index.cjs +17 -0
- package/src/sprockets/table/index.jsx +91 -0
- package/src/sprockets/table/title/index.cjs +17 -0
- package/src/sprockets/table/title/index.jsx +33 -0
package/README.md
ADDED
package/babel.config.cjs
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
const debug = require('debug')
|
|
2
|
+
|
|
3
|
+
const log = debug('@modernpoacher/sprockets')
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
env: {
|
|
7
|
+
NODE_ENV = 'development'
|
|
8
|
+
}
|
|
9
|
+
} = process
|
|
10
|
+
|
|
11
|
+
log('`sprockets` is awake')
|
|
12
|
+
|
|
13
|
+
function env () {
|
|
14
|
+
log({ NODE_ENV })
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
NODE_ENV === 'production'
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const presets = [
|
|
22
|
+
[
|
|
23
|
+
'@babel/env', {
|
|
24
|
+
targets: {
|
|
25
|
+
node: 'current',
|
|
26
|
+
browsers: [
|
|
27
|
+
'last 4 versions',
|
|
28
|
+
'safari >= 9',
|
|
29
|
+
'ios >= 8',
|
|
30
|
+
'ie >= 9',
|
|
31
|
+
'> 2%'
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
useBuiltIns: 'usage',
|
|
35
|
+
corejs: 3
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
'@babel/react'
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
const plugins = [
|
|
42
|
+
'@babel/syntax-jsx',
|
|
43
|
+
'@babel/proposal-export-default-from',
|
|
44
|
+
'@babel/proposal-export-namespace-from',
|
|
45
|
+
[
|
|
46
|
+
'@babel/proposal-class-properties',
|
|
47
|
+
{
|
|
48
|
+
loose: false
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
[
|
|
52
|
+
'module-resolver', {
|
|
53
|
+
alias: {
|
|
54
|
+
/**
|
|
55
|
+
* Storybook
|
|
56
|
+
*/
|
|
57
|
+
'@modernpoacher/sprockets/sprockets/check-answers/group/answer-item': './src/sprockets/check-answers/group/answer-item.jsx',
|
|
58
|
+
'@modernpoacher/sprockets/sprockets/check-answers/group/answer-title': './src/sprockets/check-answers/group/answer-title.jsx',
|
|
59
|
+
'@modernpoacher/sprockets/sprockets/check-answers/group/answer-value': './src/sprockets/check-answers/group/answer-value.jsx',
|
|
60
|
+
'@modernpoacher/sprockets/sprockets/check-answers/group/change-answer': './src/sprockets/check-answers/group/change-answer.jsx',
|
|
61
|
+
'@modernpoacher/sprockets/sprockets/check-answers/group/visually-hidden-text': './src/sprockets/check-answers/group/visually-hidden-text.jsx',
|
|
62
|
+
'@modernpoacher/sprockets/sprockets/check-answers/group': './src/sprockets/check-answers/group/index.jsx',
|
|
63
|
+
'@modernpoacher/sprockets/sprockets/check-answers/title': './src/sprockets/check-answers/title/index.jsx',
|
|
64
|
+
'@modernpoacher/sprockets/sprockets/check-answers': './src/sprockets/check-answers/index.jsx',
|
|
65
|
+
'@modernpoacher/sprockets/sprockets/error-summary/group/error-item': './src/sprockets/error-summary/group/error-item.jsx',
|
|
66
|
+
'@modernpoacher/sprockets/sprockets/error-summary/group': './src/sprockets/error-summary/group/index.jsx',
|
|
67
|
+
'@modernpoacher/sprockets/sprockets/error-summary/title': './src/sprockets/error-summary/title/index.jsx',
|
|
68
|
+
'@modernpoacher/sprockets/sprockets/error-summary': './src/sprockets/error-summary/index.jsx',
|
|
69
|
+
'@modernpoacher/sprockets/sprockets/fieldset/description': './src/sprockets/fieldset/description/index.jsx',
|
|
70
|
+
'@modernpoacher/sprockets/sprockets/fieldset/error-message': './src/sprockets/fieldset/error-message/index.jsx',
|
|
71
|
+
'@modernpoacher/sprockets/sprockets/fieldset/group': './src/sprockets/fieldset/group/index.jsx',
|
|
72
|
+
'@modernpoacher/sprockets/sprockets/fieldset/title': './src/sprockets/fieldset/title/index.jsx',
|
|
73
|
+
'@modernpoacher/sprockets/sprockets/fieldset': './src/sprockets/fieldset/index.jsx',
|
|
74
|
+
'@modernpoacher/sprockets/sprockets/table/group': './src/sprockets/table/group/index.jsx',
|
|
75
|
+
'@modernpoacher/sprockets/sprockets/table/title': './src/sprockets/table/title/index.jsx',
|
|
76
|
+
'@modernpoacher/sprockets/sprockets/table': './src/sprockets/table/index.jsx',
|
|
77
|
+
'@modernpoacher/sprockets/sprockets': './src/sprockets/index.jsx',
|
|
78
|
+
'@modernpoacher/sprockets/components/common/text-content': './src/components/common/text-content/index.jsx',
|
|
79
|
+
'@modernpoacher/sprockets/components/description': './src/components/description/index.jsx',
|
|
80
|
+
'@modernpoacher/sprockets/components/error-message': './src/components/error-message/index.jsx',
|
|
81
|
+
'@modernpoacher/sprockets/components/title': './src/components/title/index.jsx',
|
|
82
|
+
'@modernpoacher/sprockets/components/group': './src/components/group/index.jsx',
|
|
83
|
+
'#stories': './stories'
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
]
|
|
88
|
+
|
|
89
|
+
module.exports = (api) => {
|
|
90
|
+
if (api) api.cache.using(env)
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
presets,
|
|
94
|
+
plugins,
|
|
95
|
+
ignore: [
|
|
96
|
+
/node_modules\/(?!@modernpoacher\/cogs|@modernpoacher\/sprockets)/
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
}
|
package/jsconfig.json
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@modernpoacher/sprockets",
|
|
3
|
+
"version": "0.0.5",
|
|
4
|
+
"description": "Sprockets",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Sprockets",
|
|
7
|
+
"React"
|
|
8
|
+
],
|
|
9
|
+
"main": "./src/index.cjs",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"author": {
|
|
12
|
+
"name": "Jonathan Perry for Modern Poacher Limited",
|
|
13
|
+
"email": "modernpoacher@modernpoacher.com",
|
|
14
|
+
"url": "https://modernpoacher.com"
|
|
15
|
+
},
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=18.5.0"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git@github.com/modernpoacher/sprockets.git"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"prepublishOnly": "cross-env NODE_ENV=production npm run build",
|
|
26
|
+
"build": "cross-env DEBUG=@modernpoacher/sprockets npm run gulp -- build",
|
|
27
|
+
"build:watch": "cross-env DEBUG=@modernpoacher/sprockets npm run gulp -- build:watch",
|
|
28
|
+
"transform": "cross-env DEBUG=@modernpoacher/sprockets npm run gulp -- transform",
|
|
29
|
+
"transform:watch": "cross-env DEBUG=@modernpoacher/sprockets npm run gulp -- transform:watch",
|
|
30
|
+
"pregulp": "npm run nvm",
|
|
31
|
+
"gulp": "gulp --color",
|
|
32
|
+
"prelint": "npm run nvm",
|
|
33
|
+
"lint": "cross-env NODE_ENV=production eslint . .storybook --ext .mjs,.cjs,.jsx,.mts,.cts",
|
|
34
|
+
"lint:fix": "npm run lint -- --fix",
|
|
35
|
+
"pretest": "npm run nvm",
|
|
36
|
+
"test": "cross-env NODE_ENV=test jest --collect-coverage false --run-in-band",
|
|
37
|
+
"nvm": "bash nvm.sh",
|
|
38
|
+
"prestorybook": "npm run build && npm run transform",
|
|
39
|
+
"storybook": "storybook dev -p 6007",
|
|
40
|
+
"prepare": "husky install",
|
|
41
|
+
"build-storybook": "storybook build"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"classnames": "^2.3.2",
|
|
45
|
+
"debug": "^4.3.4"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@babel/core": "^7.22.11",
|
|
49
|
+
"@babel/eslint-parser": "^7.22.11",
|
|
50
|
+
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
51
|
+
"@babel/plugin-proposal-export-default-from": "^7.22.5",
|
|
52
|
+
"@babel/plugin-proposal-export-namespace-from": "^7.18.9",
|
|
53
|
+
"@babel/preset-env": "^7.22.14",
|
|
54
|
+
"@babel/preset-react": "^7.22.5",
|
|
55
|
+
"@babel/register": "^7.22.5",
|
|
56
|
+
"@modernpoacher/design-system": "1.0.71",
|
|
57
|
+
"@modernpoacher/hooks": "^1.0.432",
|
|
58
|
+
"@sequencemedia/gulp": "^1.1.63",
|
|
59
|
+
"@sequencemedia/gulp-clean-css": "^1.0.29",
|
|
60
|
+
"@sequencemedia/gulp-css-purge": "^1.1.22",
|
|
61
|
+
"@sequencemedia/gulp-debug": "^1.0.33",
|
|
62
|
+
"@sequencemedia/gulp-postcss": "^1.0.32",
|
|
63
|
+
"@sequencemedia/gulp-sass": "^1.0.28",
|
|
64
|
+
"@sequencemedia/gulp-sourcemaps": "^1.0.29",
|
|
65
|
+
"@storybook/addon-actions": "^7.4.0",
|
|
66
|
+
"@storybook/addon-essentials": "^7.4.0",
|
|
67
|
+
"@storybook/addon-links": "^7.4.0",
|
|
68
|
+
"@storybook/react": "^7.4.0",
|
|
69
|
+
"@storybook/react-webpack5": "^7.4.0",
|
|
70
|
+
"@types/react": "^18.2.21",
|
|
71
|
+
"@typescript-eslint/eslint-plugin": "5.61.0",
|
|
72
|
+
"@typescript-eslint/parser": "5.61.0",
|
|
73
|
+
"autoprefixer": "^10.4.15",
|
|
74
|
+
"babel-plugin-module-resolver": "^5.0.0",
|
|
75
|
+
"core-js": "^3.32.1",
|
|
76
|
+
"cross-env": "^7.0.3",
|
|
77
|
+
"cssnano": "^6.0.1",
|
|
78
|
+
"del": "^7.1.0",
|
|
79
|
+
"eslint": "^8.48.0",
|
|
80
|
+
"eslint-config-standard": "^17.1.0",
|
|
81
|
+
"eslint-config-standard-with-typescript": "35.0.0",
|
|
82
|
+
"eslint-import-resolver-babel-module": "^5.3.2",
|
|
83
|
+
"eslint-plugin-react": "^7.33.2",
|
|
84
|
+
"glob-all": "^3.3.1",
|
|
85
|
+
"husky": "^8.0.3",
|
|
86
|
+
"jest": "^29.6.4",
|
|
87
|
+
"postcss": "^8.4.29",
|
|
88
|
+
"postcss-easy-import": "^4.0.0",
|
|
89
|
+
"postcss-map": "^0.11.0",
|
|
90
|
+
"postcss-normalize": "^10.0.1",
|
|
91
|
+
"postcss-scss": "^4.0.7",
|
|
92
|
+
"prop-types": "^15.8.1",
|
|
93
|
+
"react": "^18.2.0",
|
|
94
|
+
"react-dom": "^18.2.0",
|
|
95
|
+
"react-router": "^6.15.0",
|
|
96
|
+
"react-router-dom": "^6.15.0",
|
|
97
|
+
"react-test-renderer": "^18.2.0",
|
|
98
|
+
"regenerator-runtime": "^0.14.0",
|
|
99
|
+
"sass": "^1.66.1",
|
|
100
|
+
"storybook": "^7.4.0",
|
|
101
|
+
"vinyl-paths": "^5.0.0"
|
|
102
|
+
},
|
|
103
|
+
"imports": {
|
|
104
|
+
"#build/gulp/build/*": "./build/gulp/build/*.mjs",
|
|
105
|
+
"#build/gulp/build": "./build/gulp/build/index.mjs",
|
|
106
|
+
"#build/gulp/*": "./build/gulp/*.mjs",
|
|
107
|
+
"#build/gulp/transform": "./build/gulp/transform/index.mjs",
|
|
108
|
+
"#build/paths": "./build/paths.mjs"
|
|
109
|
+
},
|
|
110
|
+
"exports": {
|
|
111
|
+
".": {
|
|
112
|
+
"require": "./src/index.cjs",
|
|
113
|
+
"import": "./src/index.mjs"
|
|
114
|
+
},
|
|
115
|
+
"./sprockets/check-answers/group/*": "./src/components/group/check-answers/*.cjs",
|
|
116
|
+
"./sprockets/check-answers/group": "./src/components/group/check-answers/index.cjs",
|
|
117
|
+
"./sprockets/check-answers/title": "./src/components/title/check-answers/index.cjs",
|
|
118
|
+
"./sprockets/check-answers": "./src/sprockets/check-answers/index.cjs",
|
|
119
|
+
"./sprockets/error-summary/group/*": "./src/components/group/error-summary/*.cjs",
|
|
120
|
+
"./sprockets/error-summary/group": "./src/components/group/error-summary/index.cjs",
|
|
121
|
+
"./sprockets/error-summary/title": "./src/components/title/error-summary/index.cjs",
|
|
122
|
+
"./sprockets/error-summary": "./src/sprockets/error-summary/index.cjs",
|
|
123
|
+
"./sprockets/fieldset/description": "./src/components/description/fieldset/index.cjs",
|
|
124
|
+
"./sprockets/fieldset/error-message": "./src/components/error-message/fieldset/index.cjs",
|
|
125
|
+
"./sprockets/fieldset/group": "./src/components/group/fieldset/index.cjs",
|
|
126
|
+
"./sprockets/fieldset/title": "./src/components/title/fieldset/index.cjs",
|
|
127
|
+
"./sprockets/fieldset": "./src/sprockets/fieldset/index.cjs",
|
|
128
|
+
"./sprockets/table/group": "./src/components/group/table/index.cjs",
|
|
129
|
+
"./sprockets/table/title": "./src/components/table/table/index.cjs",
|
|
130
|
+
"./sprockets/table": "./src/sprockets/table/index.cjs",
|
|
131
|
+
"./sprockets": "./src/sprockets/index.cjs",
|
|
132
|
+
"./components/common/text-content": "./src/components/common/text-content/index.cjs",
|
|
133
|
+
"./components/description": "./src/components/description/index.cjs",
|
|
134
|
+
"./components/error-message": "./src/components/error-message/index.cjs",
|
|
135
|
+
"./components/group": "./src/components/group/index.cjs",
|
|
136
|
+
"./components/title": "./src/components/title/index.cjs"
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require('@babel/register')({
|
|
2
|
+
ignore: [
|
|
3
|
+
/node_modules\/(?!@modernpoacher\/cogs|@modernpoacher\/sprockets)/
|
|
4
|
+
]
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
const debug = require('debug')
|
|
8
|
+
|
|
9
|
+
const log = debug('@modernpoacher/sprockets/sprockets/common/text-content')
|
|
10
|
+
|
|
11
|
+
log('`sprockets` is awake')
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
default: component
|
|
15
|
+
} = require('./index.jsx')
|
|
16
|
+
|
|
17
|
+
module.exports = component
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TextContent component
|
|
3
|
+
*
|
|
4
|
+
* @typedef {import('@modernpoacher/sprockets/components/common/text-content').TextContentProps} TextContentProps
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react'
|
|
8
|
+
import PropTypes from 'prop-types'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @param {TextContentProps}
|
|
12
|
+
* @returns {React.JSX.Element}
|
|
13
|
+
*/
|
|
14
|
+
const TextContent = ({ textContent }) => (
|
|
15
|
+
<span className='text-content'>
|
|
16
|
+
{textContent}
|
|
17
|
+
</span>
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
TextContent.propTypes = {
|
|
21
|
+
textContent: PropTypes.string.isRequired
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default TextContent
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require('@babel/register')({
|
|
2
|
+
ignore: [
|
|
3
|
+
/node_modules\/(?!@modernpoacher\/cogs|@modernpoacher\/sprockets)/
|
|
4
|
+
]
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
const debug = require('debug')
|
|
8
|
+
|
|
9
|
+
const log = debug('@modernpoacher/sprockets/components/description')
|
|
10
|
+
|
|
11
|
+
log('`sprockets` is awake')
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
default: component
|
|
15
|
+
} = require('./index.jsx')
|
|
16
|
+
|
|
17
|
+
module.exports = component
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Description component
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import React, { Component } from 'react'
|
|
6
|
+
import PropTypes from 'prop-types'
|
|
7
|
+
|
|
8
|
+
import TextContent from '@modernpoacher/sprockets/components/common/text-content'
|
|
9
|
+
|
|
10
|
+
export default class Description extends Component {
|
|
11
|
+
getClassName () {
|
|
12
|
+
return 'description'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
shouldComponentUpdate (props) {
|
|
16
|
+
return (
|
|
17
|
+
(props.description !== this.props.description)
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
render () {
|
|
22
|
+
const { description } = this.props
|
|
23
|
+
|
|
24
|
+
if (description) {
|
|
25
|
+
return (
|
|
26
|
+
<span className={this.getClassName()}>
|
|
27
|
+
<TextContent textContent={description} />
|
|
28
|
+
</span>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return null
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
Description.propTypes = {
|
|
37
|
+
description: PropTypes.string
|
|
38
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require('@babel/register')({
|
|
2
|
+
ignore: [
|
|
3
|
+
/node_modules\/(?!@modernpoacher\/cogs|@modernpoacher\/sprockets)/
|
|
4
|
+
]
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
const debug = require('debug')
|
|
8
|
+
|
|
9
|
+
const log = debug('@modernpoacher/sprockets/components/error-message')
|
|
10
|
+
|
|
11
|
+
log('`sprockets` is awake')
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
default: component
|
|
15
|
+
} = require('./index.jsx')
|
|
16
|
+
|
|
17
|
+
module.exports = component
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ErrorMessage component
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import React, { Component } from 'react'
|
|
6
|
+
import PropTypes from 'prop-types'
|
|
7
|
+
|
|
8
|
+
import TextContent from '@modernpoacher/sprockets/components/common/text-content'
|
|
9
|
+
|
|
10
|
+
export default class ErrorMessage extends Component {
|
|
11
|
+
getClassName () {
|
|
12
|
+
return 'error-message'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Compare current and latest `props` for changes to `errorMessage`
|
|
17
|
+
*
|
|
18
|
+
* @param {{errorMessage?: string}} props Latest props
|
|
19
|
+
* @returns {boolean}
|
|
20
|
+
*/
|
|
21
|
+
shouldComponentUpdate (props) {
|
|
22
|
+
return (props.errorMessage !== this.props.errorMessage)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
render () {
|
|
26
|
+
const { errorMessage } = this.props
|
|
27
|
+
|
|
28
|
+
if (errorMessage) {
|
|
29
|
+
return (
|
|
30
|
+
<span className={this.getClassName()}>
|
|
31
|
+
<TextContent textContent={errorMessage} />
|
|
32
|
+
</span>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return null
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
ErrorMessage.propTypes = {
|
|
41
|
+
errorMessage: PropTypes.string
|
|
42
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require('@babel/register')({
|
|
2
|
+
ignore: [
|
|
3
|
+
/node_modules\/(?!@modernpoacher\/cogs|@modernpoacher\/sprockets)/
|
|
4
|
+
]
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
const debug = require('debug')
|
|
8
|
+
|
|
9
|
+
const log = debug('@modernpoacher/sprockets/components/group')
|
|
10
|
+
|
|
11
|
+
log('`sprockets` is awake')
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
default: component
|
|
15
|
+
} = require('./index.jsx')
|
|
16
|
+
|
|
17
|
+
module.exports = component
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Group component
|
|
3
|
+
*
|
|
4
|
+
* @typedef {import('@modernpoacher/sprockets/components/group').GroupProps} GroupProps
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React, { Component } from 'react'
|
|
8
|
+
import PropTypes from 'prop-types'
|
|
9
|
+
|
|
10
|
+
export default class Group extends Component {
|
|
11
|
+
getClassName () {
|
|
12
|
+
return 'group'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {GroupProps} props
|
|
17
|
+
* @returns {boolean}
|
|
18
|
+
*/
|
|
19
|
+
shouldComponentUpdate (props) {
|
|
20
|
+
return (
|
|
21
|
+
(props.onChange !== this.props.onChange) ||
|
|
22
|
+
(props.children !== this.props.children)
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
render () {
|
|
27
|
+
const {
|
|
28
|
+
onChange,
|
|
29
|
+
groupRef,
|
|
30
|
+
children
|
|
31
|
+
} = this.props
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<fieldset
|
|
35
|
+
onChange={onChange}
|
|
36
|
+
className={this.getClassName()}
|
|
37
|
+
ref={groupRef}>
|
|
38
|
+
{children}
|
|
39
|
+
</fieldset>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
Group.propTypes = {
|
|
45
|
+
onChange: PropTypes.func,
|
|
46
|
+
children: PropTypes.oneOfType([
|
|
47
|
+
PropTypes.node,
|
|
48
|
+
PropTypes.arrayOf(
|
|
49
|
+
PropTypes.node
|
|
50
|
+
)
|
|
51
|
+
]),
|
|
52
|
+
groupRef: PropTypes.shape({
|
|
53
|
+
current: PropTypes.shape().isRequired
|
|
54
|
+
})
|
|
55
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require('@babel/register')({
|
|
2
|
+
ignore: [
|
|
3
|
+
/node_modules\/(?!@modernpoacher\/cogs|@modernpoacher\/sprockets)/
|
|
4
|
+
]
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
const debug = require('debug')
|
|
8
|
+
|
|
9
|
+
const log = debug('@modernpoacher/sprockets/components/title')
|
|
10
|
+
|
|
11
|
+
log('`sprockets` is awake')
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
default: component
|
|
15
|
+
} = require('./index.jsx')
|
|
16
|
+
|
|
17
|
+
module.exports = component
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Title component
|
|
3
|
+
*/
|
|
4
|
+
import React, { Component } from 'react'
|
|
5
|
+
import PropTypes from 'prop-types'
|
|
6
|
+
|
|
7
|
+
import TextContent from '@modernpoacher/sprockets/components/common/text-content'
|
|
8
|
+
|
|
9
|
+
export default class Title extends Component {
|
|
10
|
+
hasTextContent () {
|
|
11
|
+
const { title } = this.props
|
|
12
|
+
|
|
13
|
+
return !!title
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
getTextContent () {
|
|
17
|
+
const { title } = this.props
|
|
18
|
+
|
|
19
|
+
return title
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getClassName () {
|
|
23
|
+
return 'title'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
shouldComponentUpdate (props) {
|
|
27
|
+
return (
|
|
28
|
+
(props.title !== this.props.title)
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
renderTextContent () {
|
|
33
|
+
if (this.hasTextContent()) {
|
|
34
|
+
const textContent = this.getTextContent()
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<TextContent textContent={textContent} />
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return null
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
render () {
|
|
45
|
+
if (this.hasTextContent()) {
|
|
46
|
+
return (
|
|
47
|
+
<legend className={this.getClassName()}>
|
|
48
|
+
{this.renderTextContent()}
|
|
49
|
+
</legend>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return null
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
Title.propTypes = {
|
|
58
|
+
title: PropTypes.string
|
|
59
|
+
}
|
package/src/index.cjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require('@babel/register')({
|
|
2
|
+
ignore: [
|
|
3
|
+
/node_modules\/(?!@modernpoacher\/cogs|@modernpoacher\/sprockets)/
|
|
4
|
+
]
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
const debug = require('debug')
|
|
8
|
+
|
|
9
|
+
const log = debug('@modernpoacher/sprockets')
|
|
10
|
+
|
|
11
|
+
log('`sprockets` is awake')
|
|
12
|
+
|
|
13
|
+
const CheckAnswersSprocket = require('./sprockets/check-answers/index.cjs')
|
|
14
|
+
const ErrorSummarySprocket = require('./sprockets/error-summary/index.cjs')
|
|
15
|
+
const FieldsetSprocket = require('./sprockets/fieldset/index.cjs')
|
|
16
|
+
|
|
17
|
+
module.exports.CheckAnswersSprocket = CheckAnswersSprocket
|
|
18
|
+
module.exports.ErrorSummarySprocket = ErrorSummarySprocket
|
|
19
|
+
module.exports.FieldsetSprocket = FieldsetSprocket
|