@modernpoacher/sprockets 0.0.288 → 1.0.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.
- package/.prettierignore +4 -0
- package/babel.config.cjs +6 -2
- package/eslint.config.mjs +33 -71
- package/index.d.mts +156 -6
- package/jest.after-each.mjs +10 -0
- package/jest.before-each.mjs +10 -0
- package/jest.config.mjs +11 -1
- package/package.json +93 -35
- package/src/js/components/common/text-content/index.cjs +20 -0
- package/src/js/components/common/text-content/index.d.cts +2 -0
- package/src/{components → js/components}/common/text-content/index.d.mts +1 -3
- package/src/{components → js/components}/common/text-content/index.jsx +7 -6
- package/src/{components → js/components}/common/visually-hidden-text/index.cjs +5 -2
- package/src/js/components/common/visually-hidden-text/index.d.cts +2 -0
- package/src/{components → js/components}/common/visually-hidden-text/index.d.mts +1 -3
- package/src/{components → js/components}/common/visually-hidden-text/index.jsx +7 -6
- package/src/{components → js/components}/description/index.cjs +5 -2
- package/src/js/components/description/index.d.cts +2 -0
- package/src/{components → js/components}/description/index.d.mts +2 -7
- package/src/js/components/description/index.jsx +5 -0
- package/src/{components → js/components}/error-message/index.cjs +5 -2
- package/src/js/components/error-message/index.d.cts +2 -0
- package/src/{components → js/components}/error-message/index.d.mts +2 -7
- package/src/js/components/error-message/index.jsx +5 -0
- package/src/{components → js/components}/group/index.cjs +5 -2
- package/src/js/components/group/index.d.cts +2 -0
- package/src/js/components/group/index.d.mts +9 -0
- package/src/js/components/group/index.jsx +5 -0
- package/src/js/components/index.cjs +32 -0
- package/src/js/components/index.d.cts +4 -0
- package/src/js/components/index.d.mts +4 -0
- package/src/js/components/index.mjs +10 -0
- package/src/{components → js/components}/title/index.cjs +5 -2
- package/src/js/components/title/index.d.cts +2 -0
- package/src/{components → js/components}/title/index.d.mts +2 -7
- package/src/js/components/title/index.jsx +5 -0
- package/src/js/index.d.cts +34 -0
- package/src/js/index.d.mts +34 -0
- package/src/js/sprockets/check-answers/group/answer-item.d.cts +1 -0
- package/src/js/sprockets/check-answers/group/answer-item.d.mts +11 -0
- package/src/{sprockets → js/sprockets}/check-answers/group/answer-item.jsx +9 -0
- package/src/{sprockets → js/sprockets}/check-answers/group/answer-title.cjs +1 -0
- package/src/js/sprockets/check-answers/group/answer-title.d.cts +1 -0
- package/src/js/sprockets/check-answers/group/answer-title.d.mts +9 -0
- package/src/{sprockets → js/sprockets}/check-answers/group/answer-title.jsx +2 -2
- package/src/{sprockets → js/sprockets}/check-answers/group/answer-value.cjs +1 -0
- package/src/js/sprockets/check-answers/group/answer-value.d.cts +1 -0
- package/src/js/sprockets/check-answers/group/answer-value.d.mts +9 -0
- package/src/js/sprockets/check-answers/group/answer-value.jsx +63 -0
- package/src/{sprockets → js/sprockets}/check-answers/group/change-answer.cjs +1 -0
- package/src/js/sprockets/check-answers/group/change-answer.d.cts +1 -0
- package/src/js/sprockets/check-answers/group/change-answer.d.mts +9 -0
- package/src/{sprockets → js/sprockets}/check-answers/group/change-answer.jsx +20 -12
- package/src/{sprockets → js/sprockets}/check-answers/group/index.cjs +5 -2
- package/src/js/sprockets/check-answers/group/index.d.cts +2 -0
- package/src/js/sprockets/check-answers/group/index.d.mts +13 -0
- package/src/js/sprockets/check-answers/group/index.jsx +134 -0
- package/src/{sprockets → js/sprockets}/check-answers/index.cjs +5 -2
- package/src/js/sprockets/check-answers/index.d.cts +2 -0
- package/src/js/sprockets/check-answers/index.d.mts +12 -0
- package/src/{sprockets → js/sprockets}/check-answers/index.jsx +25 -12
- package/src/{sprockets → js/sprockets}/check-answers/title/index.cjs +5 -2
- package/src/js/sprockets/check-answers/title/index.d.cts +2 -0
- package/src/js/sprockets/check-answers/title/index.d.mts +12 -0
- package/src/js/sprockets/check-answers/title/index.jsx +37 -0
- package/src/{sprockets → js/sprockets}/error-summary/group/index.cjs +5 -2
- package/src/js/sprockets/error-summary/group/index.d.cts +2 -0
- package/src/js/sprockets/error-summary/group/index.d.mts +13 -0
- package/src/js/sprockets/error-summary/group/index.jsx +124 -0
- package/src/{sprockets → js/sprockets}/error-summary/index.cjs +5 -2
- package/src/js/sprockets/error-summary/index.d.cts +2 -0
- package/src/js/sprockets/error-summary/index.d.mts +12 -0
- package/src/{sprockets → js/sprockets}/error-summary/index.jsx +26 -13
- package/src/{sprockets → js/sprockets}/error-summary/title/index.cjs +5 -2
- package/src/js/sprockets/error-summary/title/index.d.cts +2 -0
- package/src/js/sprockets/error-summary/title/index.d.mts +12 -0
- package/src/js/sprockets/error-summary/title/index.jsx +37 -0
- package/src/{sprockets → js/sprockets}/fieldset/description/index.cjs +5 -2
- package/src/js/sprockets/fieldset/description/index.d.cts +1 -0
- package/src/{sprockets → js/sprockets}/fieldset/description/index.jsx +2 -7
- package/src/{sprockets → js/sprockets}/fieldset/error-message/index.cjs +5 -2
- package/src/js/sprockets/fieldset/error-message/index.d.cts +1 -0
- package/src/{sprockets → js/sprockets}/fieldset/error-message/index.d.mts +1 -1
- package/src/{sprockets → js/sprockets}/fieldset/error-message/index.jsx +2 -7
- package/src/{sprockets → js/sprockets}/fieldset/group/index.cjs +5 -2
- package/src/js/sprockets/fieldset/group/index.d.cts +2 -0
- package/src/js/sprockets/fieldset/group/index.d.mts +13 -0
- package/src/js/sprockets/fieldset/group/index.jsx +21 -0
- package/src/{sprockets → js/sprockets}/fieldset/index.cjs +5 -2
- package/src/js/sprockets/fieldset/index.d.cts +2 -0
- package/src/js/sprockets/fieldset/index.d.mts +18 -0
- package/src/{sprockets → js/sprockets}/fieldset/index.jsx +26 -26
- package/src/{sprockets → js/sprockets}/fieldset/title/index.cjs +5 -2
- package/src/js/sprockets/fieldset/title/index.d.cts +2 -0
- package/src/js/sprockets/fieldset/title/index.d.mts +12 -0
- package/src/js/sprockets/fieldset/title/index.jsx +20 -0
- package/src/{sprockets → js/sprockets}/index.cjs +5 -5
- package/src/js/sprockets/index.d.cts +2 -0
- package/src/js/sprockets/index.d.mts +9 -0
- package/src/js/sprockets/index.jsx +5 -0
- package/src/js/super/components/description/index.cjs +20 -0
- package/src/js/super/components/description/index.d.cts +2 -0
- package/src/js/super/components/description/index.d.mts +18 -0
- package/src/{components → js/super/components}/description/index.jsx +15 -3
- package/src/js/super/components/error-message/index.cjs +20 -0
- package/src/js/super/components/error-message/index.d.cts +2 -0
- package/src/js/super/components/error-message/index.d.mts +27 -0
- package/src/{components → js/super/components}/error-message/index.jsx +8 -6
- package/src/js/super/components/group/index.cjs +20 -0
- package/src/js/super/components/group/index.d.cts +2 -0
- package/src/js/super/components/group/index.d.mts +19 -0
- package/src/js/super/components/group/index.jsx +59 -0
- package/src/js/super/components/index.cjs +32 -0
- package/src/js/super/components/index.d.cts +4 -0
- package/src/js/super/components/index.d.mts +4 -0
- package/src/js/super/components/index.mjs +10 -0
- package/src/js/super/components/title/index.cjs +20 -0
- package/src/js/super/components/title/index.d.cts +2 -0
- package/src/js/super/components/title/index.d.mts +20 -0
- package/src/js/super/components/title/index.jsx +62 -0
- package/src/{components/common/text-content → js/super/sprockets}/index.cjs +6 -3
- package/src/js/super/sprockets/index.d.cts +2 -0
- package/src/js/super/sprockets/index.d.mts +22 -0
- package/src/{sprockets → js/super/sprockets}/index.jsx +11 -18
- package/src/js/transformers/common/index.d.mts +1 -0
- package/src/{transformers → js/transformers}/common/index.mjs +5 -5
- package/src/js/transformers/index.d.mts +1 -0
- package/src/js/transformers/index.mjs +1 -0
- package/src/sass/.stylelintrc +14 -0
- package/src/sass/_sprockets.scss +77 -0
- package/src/sass/sprockets/_check-answers.scss +54 -0
- package/src/sass/sprockets/_error-summary.scss +57 -0
- package/src/sass/sprockets/_error.scss +47 -0
- package/jsconfig.json +0 -5
- package/src/common/index.d.mts +0 -9
- package/src/common/index.mjs +0 -7
- package/src/components/group/index.d.mts +0 -16
- package/src/components/group/index.jsx +0 -59
- package/src/components/title/index.jsx +0 -59
- package/src/index.d.mts +0 -9
- package/src/sprockets/check-answers/group/answer-value.jsx +0 -46
- package/src/sprockets/check-answers/group/index.d.mts +0 -9
- package/src/sprockets/check-answers/group/index.jsx +0 -125
- package/src/sprockets/check-answers/index.d.mts +0 -9
- package/src/sprockets/check-answers/title/index.d.mts +0 -9
- package/src/sprockets/check-answers/title/index.jsx +0 -29
- package/src/sprockets/error-summary/group/error-item.cjs +0 -13
- package/src/sprockets/error-summary/group/error-item.jsx +0 -22
- package/src/sprockets/error-summary/group/index.d.mts +0 -9
- package/src/sprockets/error-summary/group/index.jsx +0 -115
- package/src/sprockets/error-summary/index.d.mts +0 -9
- package/src/sprockets/error-summary/title/index.d.mts +0 -9
- package/src/sprockets/error-summary/title/index.jsx +0 -29
- package/src/sprockets/fieldset/group/index.d.mts +0 -9
- package/src/sprockets/fieldset/group/index.jsx +0 -16
- package/src/sprockets/fieldset/index.d.mts +0 -9
- package/src/sprockets/fieldset/title/index.d.mts +0 -9
- package/src/sprockets/fieldset/title/index.jsx +0 -15
- package/src/sprockets/index.d.mts +0 -17
- package/src/transformers/common/index.d.mts +0 -7
- package/tsconfig.json +0 -18
- /package/src/{index.cjs → js/index.cjs} +0 -0
- /package/src/{index.mjs → js/index.mjs} +0 -0
- /package/src/{sprockets → js/sprockets}/check-answers/group/answer-item.cjs +0 -0
- /package/src/{sprockets → js/sprockets}/fieldset/description/index.d.mts +0 -0
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Title component
|
|
3
|
-
*/
|
|
4
|
-
import React, { Component } from 'react'
|
|
5
|
-
import PropTypes from 'prop-types'
|
|
6
|
-
|
|
7
|
-
import TextContent from '#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, state) {
|
|
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.d.mts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare module '#sprockets' {
|
|
2
|
-
export { default as CheckAnswersSprocket } from '#sprockets/sprockets/check-answers'
|
|
3
|
-
export { default as ErrorSummarySprocket } from '#sprockets/sprockets/error-summary'
|
|
4
|
-
export { default as FieldsetSprocket } from '#sprockets/sprockets/fieldset'
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
declare module '@modernpoacher/sprockets' {
|
|
8
|
-
export * from '#sprockets'
|
|
9
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import PropTypes from 'prop-types'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @param {string | string[]}
|
|
6
|
-
* @returns {string | string[]}
|
|
7
|
-
*/
|
|
8
|
-
function getAnswerValue (value) {
|
|
9
|
-
if (Array.isArray(value)) {
|
|
10
|
-
const n = value.length - 1
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
value
|
|
14
|
-
.reduce((a, v, i) => {
|
|
15
|
-
const s = String(v)
|
|
16
|
-
|
|
17
|
-
return (i !== n)
|
|
18
|
-
? a.concat(s).concat(<br key={i} />)
|
|
19
|
-
: a.concat(s)
|
|
20
|
-
}, [])
|
|
21
|
-
)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return String(value)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @param {SprocketsTypes.AnswerDefinitionType}
|
|
29
|
-
* @returns {React.JSX.Element}
|
|
30
|
-
*/
|
|
31
|
-
export default function AnswerValue ({ value }) {
|
|
32
|
-
return (
|
|
33
|
-
<dd className='answer-value'>
|
|
34
|
-
{getAnswerValue(value)}
|
|
35
|
-
</dd>
|
|
36
|
-
)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
AnswerValue.propTypes = {
|
|
40
|
-
value: PropTypes.oneOfType([
|
|
41
|
-
PropTypes.string,
|
|
42
|
-
PropTypes.arrayOf(
|
|
43
|
-
PropTypes.string
|
|
44
|
-
)
|
|
45
|
-
]).isRequired
|
|
46
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare module '#sprockets/sprockets/check-answers/group' {
|
|
2
|
-
import Group from '#sprockets/components/group'
|
|
3
|
-
|
|
4
|
-
export default class CheckAnswersGroup extends Group {}
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
declare module '@modernpoacher/sprockets/sprockets/check-answers/group' {
|
|
8
|
-
export { default } from '#sprockets/sprockets/check-answers/group'
|
|
9
|
-
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CheckAnswersGroup component
|
|
3
|
-
*
|
|
4
|
-
* @typedef {import('@modernpoacher/sprockets/components/group').GroupProps} GroupProps
|
|
5
|
-
*
|
|
6
|
-
* Group state
|
|
7
|
-
*
|
|
8
|
-
* @typedef {Object} GroupState
|
|
9
|
-
* @property {{}} [checkAnswers]
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import React from 'react'
|
|
13
|
-
import PropTypes from 'prop-types'
|
|
14
|
-
|
|
15
|
-
import debug from 'debug'
|
|
16
|
-
|
|
17
|
-
import equal from 'fast-deep-equal'
|
|
18
|
-
import classnames from 'classnames'
|
|
19
|
-
|
|
20
|
-
import Group from '#sprockets/components/group'
|
|
21
|
-
|
|
22
|
-
import {
|
|
23
|
-
getKey
|
|
24
|
-
} from '#sprockets/transformers/common'
|
|
25
|
-
|
|
26
|
-
import AnswerTitle from './answer-title.jsx'
|
|
27
|
-
import AnswerValue from './answer-value.jsx'
|
|
28
|
-
import ChangeAnswer from './change-answer.jsx'
|
|
29
|
-
|
|
30
|
-
const DEFAULT_CHECK_ANSWERS = []
|
|
31
|
-
|
|
32
|
-
const log = debug('@modernpoacher/sprockets/components/group/check-answers')
|
|
33
|
-
|
|
34
|
-
/* eslint-disable-next-line react/prop-types */
|
|
35
|
-
function render ({ answer: { title, value }, changeAnswer: { href, text, ...changeAnswer } }, index) {
|
|
36
|
-
log('render')
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<div key={getKey(href, text, index)} className='answer'>
|
|
40
|
-
<AnswerTitle
|
|
41
|
-
title={title}
|
|
42
|
-
/>
|
|
43
|
-
|
|
44
|
-
<AnswerValue
|
|
45
|
-
value={value}
|
|
46
|
-
/>
|
|
47
|
-
|
|
48
|
-
<ChangeAnswer
|
|
49
|
-
changeAnswer={{ ...changeAnswer, href, text }}
|
|
50
|
-
/>
|
|
51
|
-
</div>
|
|
52
|
-
)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export default class CheckAnswersGroup extends Group {
|
|
56
|
-
/**
|
|
57
|
-
* @type {GroupState}
|
|
58
|
-
*/
|
|
59
|
-
state = {
|
|
60
|
-
checkAnswers: DEFAULT_CHECK_ANSWERS
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
getClassName () {
|
|
64
|
-
return classnames(super.getClassName(), 'check-answers')
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Compare latest 'props' with 'state' for changes to 'checkAnswers'
|
|
69
|
-
*
|
|
70
|
-
* @param {GroupProps} props Latest props
|
|
71
|
-
* @param {GroupState} state Current state
|
|
72
|
-
* @returns {{checkAnswers: {}}}
|
|
73
|
-
*/
|
|
74
|
-
static getDerivedStateFromProps ({ checkAnswers }, { checkAnswers: C }) {
|
|
75
|
-
return {
|
|
76
|
-
checkAnswers: equal(checkAnswers, C) ? C : checkAnswers
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Compare latest 'props' with 'state' for changes to 'checkAnswers'
|
|
82
|
-
*
|
|
83
|
-
* @param {GroupProps} props Latest props
|
|
84
|
-
* @param {GroupState} state Current state
|
|
85
|
-
* @returns {boolean}
|
|
86
|
-
*/
|
|
87
|
-
shouldComponentUpdate (props, state) {
|
|
88
|
-
const {
|
|
89
|
-
checkAnswers: c = DEFAULT_CHECK_ANSWERS
|
|
90
|
-
} = state
|
|
91
|
-
|
|
92
|
-
const {
|
|
93
|
-
checkAnswers: C = DEFAULT_CHECK_ANSWERS
|
|
94
|
-
} = this.state
|
|
95
|
-
|
|
96
|
-
return (c !== C)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
render () {
|
|
100
|
-
const {
|
|
101
|
-
checkAnswers = DEFAULT_CHECK_ANSWERS
|
|
102
|
-
} = this.props
|
|
103
|
-
|
|
104
|
-
if (checkAnswers.length) {
|
|
105
|
-
const {
|
|
106
|
-
groupRef
|
|
107
|
-
} = this.props
|
|
108
|
-
|
|
109
|
-
return (
|
|
110
|
-
<dl
|
|
111
|
-
className={this.getClassName()}
|
|
112
|
-
ref={groupRef}>
|
|
113
|
-
{checkAnswers.map(render)}
|
|
114
|
-
</dl>
|
|
115
|
-
)
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return null
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
CheckAnswersGroup.propTypes = {
|
|
123
|
-
...Group.propTypes,
|
|
124
|
-
checkAnswers: PropTypes.arrayOf(PropTypes.shape({}))
|
|
125
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare module '#sprockets/sprockets/check-answers' {
|
|
2
|
-
import Sprocket from '#sprockets/sprockets'
|
|
3
|
-
|
|
4
|
-
export default class ErrorSummarySprocket extends Sprocket {}
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
declare module '@modernpoacher/sprockets/sprockets/check-answers' {
|
|
8
|
-
export { default } from '#sprockets/sprockets/check-answers'
|
|
9
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare module '#sprockets/sprockets/check-answers/title' {
|
|
2
|
-
import Title from '#sprockets/components/title'
|
|
3
|
-
|
|
4
|
-
export default class CheckAnswersTitle extends Title {}
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
declare module '@modernpoacher/sprockets/sprockets/check-answers/title' {
|
|
8
|
-
export { default } from '#sprockets/sprockets/check-answers/title'
|
|
9
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CheckAnswersTitle component
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import React from 'react'
|
|
6
|
-
import classnames from 'classnames'
|
|
7
|
-
import Title from '#sprockets/components/title'
|
|
8
|
-
|
|
9
|
-
export default class CheckAnswersTitle extends Title {
|
|
10
|
-
getClassName () {
|
|
11
|
-
return classnames(super.getClassName(), 'check-answers')
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
render () {
|
|
15
|
-
if (this.hasTextContent()) {
|
|
16
|
-
return (
|
|
17
|
-
<h2 className={this.getClassName()}>
|
|
18
|
-
{this.renderTextContent()}
|
|
19
|
-
</h2>
|
|
20
|
-
)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return null
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
CheckAnswersTitle.propTypes = {
|
|
28
|
-
...Title.propTypes
|
|
29
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
require('@babel/register')({
|
|
2
|
-
ignore: [
|
|
3
|
-
/node_modules\/(?!@modernpoacher\/cogs|@modernpoacher\/sprockets|@modernpoacher\/gremlins)/
|
|
4
|
-
]
|
|
5
|
-
})
|
|
6
|
-
|
|
7
|
-
const debug = require('debug')
|
|
8
|
-
|
|
9
|
-
const log = debug('@modernpoacher/sprockets/sprockets/error-summary/group/error-item')
|
|
10
|
-
|
|
11
|
-
log('`sprockets` is awake')
|
|
12
|
-
|
|
13
|
-
module.exports = require('./error-item.jsx')
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import PropTypes from 'prop-types'
|
|
3
|
-
|
|
4
|
-
import TextContent from '#sprockets/components/common/text-content'
|
|
5
|
-
|
|
6
|
-
export default function ErrorItem ({
|
|
7
|
-
href,
|
|
8
|
-
text
|
|
9
|
-
}) {
|
|
10
|
-
return (
|
|
11
|
-
<li className='error'>
|
|
12
|
-
<a href={href}>
|
|
13
|
-
<TextContent textContent={text} />
|
|
14
|
-
</a>
|
|
15
|
-
</li>
|
|
16
|
-
)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
ErrorItem.propTypes = {
|
|
20
|
-
href: PropTypes.string.isRequired,
|
|
21
|
-
text: PropTypes.string.isRequired
|
|
22
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare module '#sprockets/sprockets/error-summary/group' {
|
|
2
|
-
import Group from '#sprockets/components/group'
|
|
3
|
-
|
|
4
|
-
export default class ErrorSummaryGroup extends Group {}
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
declare module '@modernpoacher/sprockets/sprockets/error-summary/group' {
|
|
8
|
-
export { default } from '#sprockets/sprockets/error-summary/group'
|
|
9
|
-
}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ErrorSummaryGroup component
|
|
3
|
-
*
|
|
4
|
-
* @typedef {import('@modernpoacher/sprockets/components/group').GroupProps} GroupProps
|
|
5
|
-
*
|
|
6
|
-
* Group state
|
|
7
|
-
*
|
|
8
|
-
* @typedef {Object} GroupState
|
|
9
|
-
* @property {{}} [errorSummary]
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import React from 'react'
|
|
13
|
-
import PropTypes from 'prop-types'
|
|
14
|
-
|
|
15
|
-
import debug from 'debug'
|
|
16
|
-
|
|
17
|
-
import equal from 'fast-deep-equal'
|
|
18
|
-
import classnames from 'classnames'
|
|
19
|
-
|
|
20
|
-
import Group from '#sprockets/components/group'
|
|
21
|
-
|
|
22
|
-
import {
|
|
23
|
-
getKey
|
|
24
|
-
} from '#sprockets/transformers/common'
|
|
25
|
-
|
|
26
|
-
import TextContent from '#sprockets/components/common/text-content'
|
|
27
|
-
|
|
28
|
-
const DEFAULT_ERROR_SUMMARY = []
|
|
29
|
-
|
|
30
|
-
const log = debug('@modernpoacher/sprockets/sprockets/error-summary/group')
|
|
31
|
-
|
|
32
|
-
/* eslint-disable-next-line react/prop-types */
|
|
33
|
-
function render ({ href, text }, index) {
|
|
34
|
-
log('render')
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<li key={getKey(href, text, index)} className='error'>
|
|
38
|
-
<a href={href}>
|
|
39
|
-
<TextContent textContent={text} />
|
|
40
|
-
</a>
|
|
41
|
-
</li>
|
|
42
|
-
)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export default class ErrorSummaryGroup extends Group {
|
|
46
|
-
/**
|
|
47
|
-
* @type {GroupState}
|
|
48
|
-
*/
|
|
49
|
-
state = {
|
|
50
|
-
errorSummary: DEFAULT_ERROR_SUMMARY
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
getClassName () {
|
|
54
|
-
return classnames(super.getClassName(), 'error-summary')
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Compare latest 'props' with 'state' for changes to 'errorSummary'
|
|
59
|
-
*
|
|
60
|
-
* @param {GroupProps} props Latest props
|
|
61
|
-
* @param {GroupState} state Current state
|
|
62
|
-
* @returns {GroupState}
|
|
63
|
-
*/
|
|
64
|
-
static getDerivedStateFromProps ({ errorSummary }, { errorSummary: E }) {
|
|
65
|
-
return {
|
|
66
|
-
errorSummary: equal(errorSummary, E) ? E : errorSummary
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Compare latest 'props' with 'state' for changes to 'errorSummary'
|
|
72
|
-
*
|
|
73
|
-
* @param {GroupProps} props Latest props
|
|
74
|
-
* @param {GroupState} state Current state
|
|
75
|
-
* @returns {boolean}
|
|
76
|
-
*/
|
|
77
|
-
shouldComponentUpdate (props, state) {
|
|
78
|
-
const {
|
|
79
|
-
errorSummary: e = DEFAULT_ERROR_SUMMARY
|
|
80
|
-
} = state
|
|
81
|
-
|
|
82
|
-
const {
|
|
83
|
-
errorSummary: E = DEFAULT_ERROR_SUMMARY
|
|
84
|
-
} = this.state
|
|
85
|
-
|
|
86
|
-
return (e !== E)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
render () {
|
|
90
|
-
const {
|
|
91
|
-
errorSummary = DEFAULT_ERROR_SUMMARY
|
|
92
|
-
} = this.props
|
|
93
|
-
|
|
94
|
-
if (errorSummary.length) {
|
|
95
|
-
const {
|
|
96
|
-
groupRef
|
|
97
|
-
} = this.props
|
|
98
|
-
|
|
99
|
-
return (
|
|
100
|
-
<ul
|
|
101
|
-
className={this.getClassName()}
|
|
102
|
-
ref={groupRef}>
|
|
103
|
-
{errorSummary.map(render)}
|
|
104
|
-
</ul>
|
|
105
|
-
)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return null
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
ErrorSummaryGroup.propTypes = {
|
|
113
|
-
...Group.propTypes,
|
|
114
|
-
errorSummary: PropTypes.arrayOf(PropTypes.shape())
|
|
115
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare module '#sprockets/sprockets/error-summary' {
|
|
2
|
-
import Sprocket from '#sprockets/sprockets'
|
|
3
|
-
|
|
4
|
-
export default class CheckAnswersSprocket extends Sprocket {}
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
declare module '@modernpoacher/sprockets/sprockets/error-summary' {
|
|
8
|
-
export { default } from '#sprockets/sprockets/error-summary'
|
|
9
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare module '#sprockets/sprockets/error-summary/title' {
|
|
2
|
-
import Title from '#sprockets/components/title'
|
|
3
|
-
|
|
4
|
-
export default class ErrorSummaryTitle extends Title {}
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
declare module '@modernpoacher/sprockets/sprockets/error-summary/title' {
|
|
8
|
-
export { default } from '#sprockets/sprockets/error-summary/title'
|
|
9
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ErrorSummaryTitle component
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import React from 'react'
|
|
6
|
-
import classnames from 'classnames'
|
|
7
|
-
import Title from '#sprockets/components/title'
|
|
8
|
-
|
|
9
|
-
export default class ErrorSummaryTitle extends Title {
|
|
10
|
-
getClassName () {
|
|
11
|
-
return classnames(super.getClassName(), 'error-summary')
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
render () {
|
|
15
|
-
if (this.hasTextContent()) {
|
|
16
|
-
return (
|
|
17
|
-
<h2 className={this.getClassName()}>
|
|
18
|
-
{this.renderTextContent()}
|
|
19
|
-
</h2>
|
|
20
|
-
)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return null
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
ErrorSummaryTitle.propTypes = {
|
|
28
|
-
...Title.propTypes
|
|
29
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare module '#sprockets/sprockets/fieldset/group' {
|
|
2
|
-
import Group from '#sprockets/components/group'
|
|
3
|
-
|
|
4
|
-
export default class FieldsetGroup extends Group {}
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
declare module '@modernpoacher/sprockets/sprockets/fieldset/group' {
|
|
8
|
-
export { default } from '#sprockets/sprockets/fieldset/group'
|
|
9
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* FieldsetGroup component
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import classnames from 'classnames'
|
|
6
|
-
import Group from '#sprockets/components/group'
|
|
7
|
-
|
|
8
|
-
export default class FieldsetGroup extends Group {
|
|
9
|
-
getClassName () {
|
|
10
|
-
return classnames(super.getClassName(), 'fieldset')
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
FieldsetGroup.propTypes = {
|
|
15
|
-
...Group.propTypes
|
|
16
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare module '#sprockets/sprockets/fieldset' {
|
|
2
|
-
import Sprocket from '#sprockets/sprockets'
|
|
3
|
-
|
|
4
|
-
export default class FieldsetSprocket extends Sprocket {}
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
declare module '@modernpoacher/sprockets/sprockets/fieldset' {
|
|
8
|
-
export { default } from '#sprockets/sprockets/fieldset'
|
|
9
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare module '#sprockets/sprockets/fieldset/title' {
|
|
2
|
-
import Title from '#sprockets/components/title'
|
|
3
|
-
|
|
4
|
-
export default class FieldsetTitle extends Title {}
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
declare module '@modernpoacher/sprockets/sprockets/fieldset/title' {
|
|
8
|
-
export { default } from '#sprockets/sprockets/fieldset/title'
|
|
9
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* FieldsetTitle component
|
|
3
|
-
*/
|
|
4
|
-
import classnames from 'classnames'
|
|
5
|
-
import Title from '#sprockets/components/title'
|
|
6
|
-
|
|
7
|
-
export default class FieldsetTitle extends Title {
|
|
8
|
-
getClassName () {
|
|
9
|
-
return classnames(super.getClassName(), 'fieldset')
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
FieldsetTitle.propTypes = {
|
|
14
|
-
...Title.propTypes
|
|
15
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
declare module '#sprockets/sprockets' {
|
|
2
|
-
import React from 'react'
|
|
3
|
-
|
|
4
|
-
export interface SprocketProps {
|
|
5
|
-
title: string
|
|
6
|
-
onChange: SprocketsTypes.onEventType
|
|
7
|
-
groupRef: object
|
|
8
|
-
children: React.JSX.Element | React.JSX.Element[]
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export default class Sprocket extends React.Component<SprocketProps> {}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
declare module '@modernpoacher/sprockets/sprockets' {
|
|
15
|
-
export { default } from '#sprockets/sprockets'
|
|
16
|
-
export * from '#sprockets/sprockets'
|
|
17
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"module": "ESNext",
|
|
4
|
-
"target": "ESNext",
|
|
5
|
-
"allowJs": true,
|
|
6
|
-
"checkJs": false,
|
|
7
|
-
"noEmit": true,
|
|
8
|
-
"strict": true,
|
|
9
|
-
"allowSyntheticDefaultImports": true,
|
|
10
|
-
"isolatedModules": true,
|
|
11
|
-
"baseUrl": "."
|
|
12
|
-
},
|
|
13
|
-
"include": [
|
|
14
|
-
".",
|
|
15
|
-
"src/**/*",
|
|
16
|
-
"stories/**/*"
|
|
17
|
-
]
|
|
18
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|