shinkansen-sprockets 1.0.60 → 1.0.63

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shinkansen-sprockets",
3
- "version": "1.0.60",
3
+ "version": "1.0.63",
4
4
  "description": "Shinkansen Sprockets",
5
5
  "keywords": [
6
6
  "Shinkansen",
@@ -12,7 +12,6 @@
12
12
  ],
13
13
  "main": "./src/index.cjs",
14
14
  "type": "module",
15
- "types": "./src/index.d.mts",
16
15
  "author": "Jonathan Perry for Modern Poacher Limited <modernpoacher@modernpoacher.com>",
17
16
  "license": "MIT",
18
17
  "engines": {
@@ -31,7 +30,7 @@
31
30
  "pregulp": "npm run nvm",
32
31
  "gulp": "gulp --color",
33
32
  "prelint": "npm run nvm",
34
- "lint": "cross-env NODE_ENV=production eslint . .storybook --ext .mjs --ext .cjs --ext .jsx --ext .mts",
33
+ "lint": "cross-env NODE_ENV=production eslint . .storybook --ext .mjs --ext .cjs --ext .jsx --ext .mts --ext .cts",
35
34
  "lint:fix": "npm run lint -- --fix",
36
35
  "pretest": "npm run nvm",
37
36
  "test": "cross-env NODE_ENV=test jest --collect-coverage false --verbose --run-in-band",
@@ -54,16 +53,16 @@
54
53
  "@babel/preset-env": "^7.21.5",
55
54
  "@babel/preset-react": "^7.18.6",
56
55
  "@babel/register": "^7.21.0",
57
- "@modernpoacher/design-system": "1.0.5",
58
- "@modernpoacher/hooks": "^1.0.396",
56
+ "@modernpoacher/design-system": "1.0.7",
57
+ "@modernpoacher/hooks": "^1.0.397",
59
58
  "@sequencemedia/gulp": "^1.0.7",
60
59
  "@storybook/addon-actions": "6.5.12",
61
60
  "@storybook/addon-essentials": "6.5.12",
62
61
  "@storybook/addon-links": "6.5.12",
63
62
  "@storybook/react": "6.5.12",
64
63
  "@types/react": "^18.2.6",
65
- "@typescript-eslint/eslint-plugin": "^5.59.2",
66
- "@typescript-eslint/parser": "^5.59.2",
64
+ "@typescript-eslint/eslint-plugin": "^5.59.5",
65
+ "@typescript-eslint/parser": "^5.59.5",
67
66
  "autoprefixer": "^10.4.14",
68
67
  "babel-plugin-module-resolver": "^5.0.0",
69
68
  "core-js": "^3.30.2",
@@ -1,6 +1,16 @@
1
+ /**
2
+ * TextContent component
3
+ *
4
+ * @typedef {import('shinkansen-sprockets/components/common/text-content').TextContentProps} TextContentProps
5
+ */
6
+
1
7
  import React from 'react'
2
8
  import PropTypes from 'prop-types'
3
9
 
10
+ /**
11
+ * @param {TextContentProps}
12
+ * @returns {React.JSX.Element}
13
+ */
4
14
  const TextContent = ({ textContent }) => (
5
15
  <span className='text-content'>
6
16
  {textContent}
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * FieldsetDescription component
3
3
  */
4
+
4
5
  import classnames from 'classnames'
5
6
  import Description from 'shinkansen-sprockets/components/description'
6
7
 
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Description component
3
3
  */
4
+
4
5
  import React, { Component } from 'react'
5
6
  import PropTypes from 'prop-types'
6
7
 
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * FieldsetErrorMessage component
3
3
  */
4
+
4
5
  import classnames from 'classnames'
5
6
  import ErrorMessage from 'shinkansen-sprockets/components/error-message'
6
7
 
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * ErrorMessage component
3
3
  */
4
+
4
5
  import React, { Component } from 'react'
5
6
  import PropTypes from 'prop-types'
6
7
 
@@ -4,8 +4,12 @@ import debug from 'debug'
4
4
 
5
5
  const log = debug('shinkansen-sprockets:components:group:check-answers')
6
6
 
7
- export default function SummaryTitle ({ answer: { title } }) {
8
- log('SummaryTitle')
7
+ /**
8
+ * @param {SprocketsTypes.AnswerDefinitionType}
9
+ * @returns {React.JSX.Element}
10
+ */
11
+ export default function AnswerTitle ({ answer: { title } }) {
12
+ log('AnswerTitle')
9
13
 
10
14
  return (
11
15
  <dt className='answer-title'>
@@ -14,7 +18,7 @@ export default function SummaryTitle ({ answer: { title } }) {
14
18
  )
15
19
  }
16
20
 
17
- SummaryTitle.propTypes = {
21
+ AnswerTitle.propTypes = {
18
22
  answer: PropTypes.shape({
19
23
  title: PropTypes.string.isRequired
20
24
  }).isRequired
@@ -4,6 +4,10 @@ import debug from 'debug'
4
4
 
5
5
  const log = debug('shinkansen-sprockets:components:group:check-answers')
6
6
 
7
+ /**
8
+ * @param {string | string[]}
9
+ * @returns {string | string[]}
10
+ */
7
11
  function getAnswerValue (value) {
8
12
  if (Array.isArray(value)) {
9
13
  const n = value.length - 1
@@ -23,8 +27,12 @@ function getAnswerValue (value) {
23
27
  return String(value)
24
28
  }
25
29
 
26
- export default function SummaryValue ({ answer: { value } }) {
27
- log('SummaryValue')
30
+ /**
31
+ * @param {SprocketsTypes.AnswerDefinitionType}
32
+ * @returns {React.JSX.Element}
33
+ */
34
+ export default function AnswerValue ({ answer: { value } }) {
35
+ log('AnswerValue')
28
36
 
29
37
  return (
30
38
  <dd className='answer-value'>
@@ -33,7 +41,7 @@ export default function SummaryValue ({ answer: { value } }) {
33
41
  )
34
42
  }
35
43
 
36
- SummaryValue.propTypes = {
44
+ AnswerValue.propTypes = {
37
45
  answer: PropTypes.shape({
38
46
  value: PropTypes.oneOfType([
39
47
  PropTypes.string,
@@ -12,6 +12,10 @@ import VisuallyHiddenText from './visually-hidden-text.cjs'
12
12
 
13
13
  const log = debug('shinkansen-sprockets:components:group:check-answers')
14
14
 
15
+ /**
16
+ * @param {SprocketsTypes.AnswerDefinitionType}
17
+ * @returns {React.JSX.Element}
18
+ */
15
19
  export default function ChangeAnswer ({ changeAnswer: { href, text, visuallyHiddenText } }) {
16
20
  log('ChangeAnswer')
17
21
 
@@ -1,6 +1,14 @@
1
1
  /**
2
2
  * CheckAnswersGroup component
3
+ *
4
+ * @typedef {import('shinkansen-sprockets/components/group').GroupProps} GroupProps
5
+ *
6
+ * Group state
7
+ *
8
+ * @typedef {Object} GroupState
9
+ * @property {{}} [checkAnswers]
3
10
  */
11
+
4
12
  import React from 'react'
5
13
  import PropTypes from 'prop-types'
6
14
 
@@ -37,6 +45,9 @@ function render ({ params: { answer, changeAnswer: { href, text, ...changeAnswer
37
45
  }
38
46
 
39
47
  export default class CheckAnswersGroup extends Group {
48
+ /**
49
+ * @type {GroupState}
50
+ */
40
51
  state = {}
41
52
 
42
53
  getClassName () {
@@ -46,8 +57,9 @@ export default class CheckAnswersGroup extends Group {
46
57
  /**
47
58
  * Compare latest 'props' with 'state' for changes to 'checkAnswers'
48
59
  *
49
- * @param {Object} props Latest props
50
- * @param {Object} state Current state
60
+ * @param {GroupProps} props Latest props
61
+ * @param {GroupState} state Current state
62
+ * @returns {{checkAnswers: {}}}
51
63
  */
52
64
  static getDerivedStateFromProps ({ checkAnswers }, { checkAnswers: C }) {
53
65
  return {
@@ -56,10 +68,11 @@ export default class CheckAnswersGroup extends Group {
56
68
  }
57
69
 
58
70
  /**
59
- * Compare latest 'props' with 'state' for changes to 'checkAnswers'
71
+ * Compare latest 'props' with 'state' for changes to 'checkAnswers'
60
72
  *
61
- * @param {Object} props Latest props
62
- * @param {Object} state Current state
73
+ * @param {GroupProps} props Latest props
74
+ * @param {GroupState} state Current state
75
+ * @returns {boolean}
63
76
  */
64
77
  shouldComponentUpdate (props, state) {
65
78
  const {
@@ -14,6 +14,8 @@ export default function VisuallyHiddenText ({ visuallyHiddenText }) {
14
14
  </span>
15
15
  )
16
16
  }
17
+
18
+ return null
17
19
  }
18
20
 
19
21
  VisuallyHiddenText.propTypes = {
@@ -1,6 +1,14 @@
1
1
  /**
2
2
  * ErrorSummaryGroup component
3
+ *
4
+ * @typedef {import('shinkansen-sprockets/components/group').GroupProps} GroupProps
5
+ *
6
+ * Group state
7
+ *
8
+ * @typedef {Object} GroupState
9
+ * @property {{}} [errorSummary]
3
10
  */
11
+
4
12
  import React from 'react'
5
13
  import PropTypes from 'prop-types'
6
14
 
@@ -39,6 +47,9 @@ function render (error, index) {
39
47
  }
40
48
 
41
49
  export default class ErrorSummaryGroup extends Group {
50
+ /**
51
+ * @type {GroupState}
52
+ */
42
53
  state = {}
43
54
 
44
55
  getClassName () {
@@ -46,10 +57,11 @@ export default class ErrorSummaryGroup extends Group {
46
57
  }
47
58
 
48
59
  /**
49
- * Compare latest 'props' with 'state' for changes to 'errorSummary'
60
+ * Compare latest 'props' with 'state' for changes to 'errorSummary'
50
61
  *
51
- * @param {Object} props Latest props
52
- * @param {Object} state Current state
62
+ * @param {GroupProps} props Latest props
63
+ * @param {GroupState} state Current state
64
+ * @returns {GroupState}
53
65
  */
54
66
  static getDerivedStateFromProps ({ errorSummary }, { errorSummary: E }) {
55
67
  return {
@@ -58,10 +70,11 @@ export default class ErrorSummaryGroup extends Group {
58
70
  }
59
71
 
60
72
  /**
61
- * Compare latest 'props' with 'state' for changes to 'errorSummary'
73
+ * Compare latest 'props' with 'state' for changes to 'errorSummary'
62
74
  *
63
- * @param {Object} props Latest props
64
- * @param {Object} state Current state
75
+ * @param {GroupProps} props Latest props
76
+ * @param {GroupState} state Current state
77
+ * @returns {boolean}
65
78
  */
66
79
  shouldComponentUpdate (props, state) {
67
80
  const {
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * FieldsetGroup component
3
3
  */
4
+
4
5
  import classnames from 'classnames'
5
6
  import Group from 'shinkansen-sprockets/components/group'
6
7
 
@@ -1,6 +1,9 @@
1
1
  /**
2
2
  * Group component
3
+ *
4
+ * @typedef {import('shinkansen-sprockets/components/group').GroupProps} GroupProps
3
5
  */
6
+
4
7
  import React, { Component } from 'react'
5
8
  import PropTypes from 'prop-types'
6
9
 
@@ -12,6 +15,10 @@ export default class Group extends Component {
12
15
  return 'group'
13
16
  }
14
17
 
18
+ /**
19
+ * @param {GroupProps} props
20
+ * @returns {boolean}
21
+ */
15
22
  shouldComponentUpdate (props) {
16
23
  return (
17
24
  (props.onChange !== this.props.onChange) ||
@@ -38,5 +45,10 @@ export default class Group extends Component {
38
45
 
39
46
  Group.propTypes = {
40
47
  onChange: PropTypes.func,
41
- children: PropTypes.any
48
+ children: PropTypes.oneOfType([
49
+ PropTypes.element,
50
+ PropTypes.arrayOf(
51
+ PropTypes.element
52
+ )
53
+ ])
42
54
  }
@@ -1,3 +1,9 @@
1
+ /**
2
+ * CheckAnswersSprocket component
3
+ *
4
+ * @typedef {import('shinkansen-sprockets/sprockets').SprocketProps} SprocketProps
5
+ */
6
+
1
7
  import React from 'react'
2
8
  import PropTypes from 'prop-types'
3
9
 
@@ -12,6 +18,10 @@ export default class CheckAnswersSprocket extends Sprocket {
12
18
  return classnames(super.getClassName(), 'check-answers')
13
19
  }
14
20
 
21
+ /**
22
+ * @param {SprocketProps} props
23
+ * @returns {boolean}
24
+ */
15
25
  shouldComponentUpdate (props) {
16
26
  return (
17
27
  super.shouldComponentUpdate(props) ||
@@ -1,6 +1,9 @@
1
1
  /**
2
2
  * ErrorSummarySprocket component
3
+ *
4
+ * @typedef {import('shinkansen-sprockets/sprockets').SprocketProps} SprocketProps
3
5
  */
6
+
4
7
  import React from 'react'
5
8
  import PropTypes from 'prop-types'
6
9
 
@@ -15,6 +18,10 @@ export default class ErrorSummarySprocket extends Sprocket {
15
18
  return classnames(super.getClassName(), 'error-summary')
16
19
  }
17
20
 
21
+ /**
22
+ * @param {SprocketProps} props
23
+ * @returns {boolean}
24
+ */
18
25
  shouldComponentUpdate (props) {
19
26
  return (
20
27
  super.shouldComponentUpdate(props) ||
@@ -1,6 +1,9 @@
1
1
  /**
2
2
  * FieldsetSprocket component
3
+ *
4
+ * @typedef {import('shinkansen-sprockets/sprockets').SprocketProps} SprocketProps
3
5
  */
6
+
4
7
  import React from 'react'
5
8
  import PropTypes from 'prop-types'
6
9
 
@@ -27,6 +30,10 @@ export default class FieldsetSprocket extends Sprocket {
27
30
  return classnames(super.getClassName(), { error: !!errorMessage }, 'fieldset')
28
31
  }
29
32
 
33
+ /**
34
+ * @param {SprocketProps} props
35
+ * @returns {boolean}
36
+ */
30
37
  shouldComponentUpdate (props) {
31
38
  return (
32
39
  super.shouldComponentUpdate(props) ||
@@ -1,6 +1,9 @@
1
1
  /**
2
2
  * Sprocket component
3
+ *
4
+ * @typedef {import('shinkansen-sprockets/sprockets').SprocketProps} SprocketProps
3
5
  */
6
+
4
7
  import React, { Component } from 'react'
5
8
  import PropTypes from 'prop-types'
6
9
 
@@ -22,6 +25,10 @@ export default class Sprocket extends Component {
22
25
  return 'sprocket'
23
26
  }
24
27
 
28
+ /**
29
+ * @param {SprocketProps} props
30
+ * @returns {boolean}
31
+ */
25
32
  shouldComponentUpdate (props) {
26
33
  return (
27
34
  (props.children !== this.props.children) ||
@@ -4,7 +4,11 @@ const log = debug('shinkansen-sprockets/transformers/check-answers')
4
4
 
5
5
  log('`shinkansen` is awake')
6
6
 
7
- export default function transform ({ changeAnswer: { text, href } }, components) {
7
+ /**
8
+ * @param {SprocketsTypes.AnswerDefinitionType}
9
+ * @returns {FieldChangeType}
10
+ */
11
+ export default function transform ({ changeAnswer: { text, href } }) {
8
12
  log('transform')
9
13
 
10
14
  return {
@@ -7,6 +7,12 @@ const log = debug('shinkansen-sprockets/transformers/common')
7
7
 
8
8
  log('`shinkansen` is awake')
9
9
 
10
+ /**
11
+ * @param {string} href
12
+ * @param {string} text
13
+ * @param {number} index
14
+ * @returns {string}
15
+ */
10
16
  export function getKey (href, text, index) {
11
17
  return (
12
18
  `${href}-${text}-${index}`
@@ -4,145 +4,145 @@ const log = debug('shinkansen-sprockets/transformers/error-message')
4
4
 
5
5
  log('`shinkansen` is awake')
6
6
 
7
- export function getErrorTextForMaxItems () { // (components = {}) {
7
+ export function getErrorTextForMaxItems () {
8
8
  log('getErrorTextForMaxItems')
9
9
 
10
10
  return 'Max items'
11
11
  }
12
12
 
13
- export function getErrorTextForMinItems () { // (components = {}) {
13
+ export function getErrorTextForMinItems () {
14
14
  log('getErrorTextForMinItems')
15
15
 
16
16
  return 'Min items'
17
17
  }
18
18
 
19
- export function getErrorTextForMaxLength () { // (components = {}) {
19
+ export function getErrorTextForMaxLength () {
20
20
  log('getErrorTextForMaxLength')
21
21
 
22
22
  return 'Max length'
23
23
  }
24
24
 
25
- export function getErrorTextForMinLength () { // (components = {}) {
25
+ export function getErrorTextForMinLength () {
26
26
  log('getErrorTextForMinLength')
27
27
 
28
28
  return 'Min length'
29
29
  }
30
30
 
31
- export function getErrorTextForMaxProperties () { // (components = {}) {
31
+ export function getErrorTextForMaxProperties () {
32
32
  log('getErrorTextForMaxProperties')
33
33
 
34
34
  return 'Max properties'
35
35
  }
36
36
 
37
- export function getErrorTextForMinProperties () { // (components = {}) {
37
+ export function getErrorTextForMinProperties () {
38
38
  log('getErrorTextForMinProperties')
39
39
 
40
40
  return 'Min properties'
41
41
  }
42
42
 
43
- export function getErrorTextForAdditionalItems () { // (components = {}) {
43
+ export function getErrorTextForAdditionalItems () {
44
44
  log('getErrorTextForAdditionalItems')
45
45
 
46
46
  return 'Additional items'
47
47
  }
48
48
 
49
- export function getErrorTextForMaximum () { // (components = {}) {
49
+ export function getErrorTextForMaximum () {
50
50
  log('getErrorTextForMaximum')
51
51
 
52
52
  return 'Maximum'
53
53
  }
54
54
 
55
- export function getErrorTextForMinimum () { // (components = {}) {
55
+ export function getErrorTextForMinimum () {
56
56
  log('getErrorTextForMinimum')
57
57
 
58
58
  return 'Minimum'
59
59
  }
60
60
 
61
- export function getErrorTextForFormat () { // (components = {}) {
61
+ export function getErrorTextForFormat () {
62
62
  log('getErrorTextForFormat')
63
63
 
64
64
  return 'Format'
65
65
  }
66
66
 
67
- export function getErrorTextForAdditionalProperties () { // (components = {}) {
67
+ export function getErrorTextForAdditionalProperties () {
68
68
  log('getErrorTextForAdditionalProperties')
69
69
 
70
70
  return 'Additional properties'
71
71
  }
72
72
 
73
- export function getErrorTextForDependencies () { // (components = {}) {
73
+ export function getErrorTextForDependencies () {
74
74
  log('getErrorTextForDependencies')
75
75
 
76
76
  return 'Dependencies'
77
77
  }
78
78
 
79
- export function getErrorTextForUniqeItems () { // (components = {}) {
79
+ export function getErrorTextForUniqeItems () {
80
80
  log('getErrorTextForUniqeItems')
81
81
 
82
82
  return 'Unique items'
83
83
  }
84
84
 
85
- export function getErrorTextForPropertyRequired () { // (components = {}) {
85
+ export function getErrorTextForPropertyRequired () {
86
86
  log('getErrorTextForPropertyRequired')
87
87
 
88
88
  return 'Property required'
89
89
  }
90
90
 
91
- export function getErrorTextForPropertyNames () { // (components = {}) {
91
+ export function getErrorTextForPropertyNames () {
92
92
  log('getErrorTextForPropertyNames')
93
93
 
94
94
  return 'Property names'
95
95
  }
96
96
 
97
- export function getErrorTextForPatternRequired () { // (components = {}) {
97
+ export function getErrorTextForPatternRequired () {
98
98
  log('getErrorTextForMultipleOf')
99
99
 
100
100
  return 'Pattern required'
101
101
  }
102
102
 
103
- export function getErrorTextForMultipleOf () { // (components = {}) {
103
+ export function getErrorTextForMultipleOf () {
104
104
  log('getErrorTextForMultipleOf')
105
105
 
106
106
  return 'Multiple of'
107
107
  }
108
108
 
109
- export function getErrorTextForPattern () { // (components = {}) {
109
+ export function getErrorTextForPattern () {
110
110
  log('getErrorTextForPattern')
111
111
 
112
112
  return 'Pattern'
113
113
  }
114
114
 
115
- export function getErrorTextForConst () { // (components = {}) {
115
+ export function getErrorTextForConst () {
116
116
  log('getErrorTextForConst')
117
117
 
118
118
  return 'Const'
119
119
  }
120
120
 
121
- export function getErrorTextForEnum () { // (components = {}) {
121
+ export function getErrorTextForEnum () {
122
122
  log('getErrorTextForEnum')
123
123
 
124
124
  return 'Enum'
125
125
  }
126
126
 
127
- export function getErrorTextFor$Ref () { // (components = {}) {
127
+ export function getErrorTextFor$Ref () {
128
128
  log('getErrorTextFor$Ref')
129
129
 
130
130
  return '$Ref'
131
131
  }
132
132
 
133
- export function getErrorTextForOneOf () { // (components = {}) {
133
+ export function getErrorTextForOneOf () {
134
134
  log('getErrorTextForOneOf')
135
135
 
136
136
  return 'One of'
137
137
  }
138
138
 
139
- export function getErrorTextForUnknown () { // (components = {}) {
139
+ export function getErrorTextForUnknown () {
140
140
  log('getErrorTextForUnknown')
141
141
 
142
142
  return 'Unknown'
143
143
  }
144
144
 
145
- export function getErrorTextForTypeInvalid ({ expectedType } = {}) { // , components = {}) {
145
+ export function getErrorTextForTypeInvalid ({ expectedType } = {}) {
146
146
  log('getErrorTextForTypeInvalid')
147
147
 
148
148
  switch (expectedType) {
@@ -163,74 +163,82 @@ export function getErrorTextForTypeInvalid ({ expectedType } = {}) { // , compon
163
163
  }
164
164
  }
165
165
 
166
- export function getErrorTextByType ({ type, params } = {}, components = {}) {
166
+ export function getErrorTextByType ({ type, params } = {}) {
167
167
  log('getErrorTextByType')
168
168
 
169
169
  switch (type) {
170
170
  case 'MAX_ITEMS':
171
- return getErrorTextForMaxItems(components)
171
+ return getErrorTextForMaxItems()
172
172
  case 'MIN_ITEMS':
173
- return getErrorTextForMinItems(components)
173
+ return getErrorTextForMinItems()
174
174
  case 'MAX_LENGTH':
175
- return getErrorTextForMaxLength(components)
175
+ return getErrorTextForMaxLength()
176
176
  case 'MIN_LENGTH':
177
- return getErrorTextForMinLength(components)
177
+ return getErrorTextForMinLength()
178
178
  case 'MAX_PROPERTIES':
179
- return getErrorTextForMaxProperties(components)
179
+ return getErrorTextForMaxProperties()
180
180
  case 'MIN_PROPERTIES':
181
- return getErrorTextForMinProperties(components)
181
+ return getErrorTextForMinProperties()
182
182
  case 'ADDITIONAL_ITEMS':
183
- return getErrorTextForAdditionalItems(components)
183
+ return getErrorTextForAdditionalItems()
184
184
  case 'MAXIMUM':
185
- return getErrorTextForMaximum(components)
185
+ return getErrorTextForMaximum()
186
186
  case 'MINIMUM':
187
- return getErrorTextForMinimum(components)
187
+ return getErrorTextForMinimum()
188
188
  case 'FORMAT':
189
- return getErrorTextForFormat(components)
189
+ return getErrorTextForFormat()
190
190
  case 'ADDITIONAL_PROPERTIES':
191
- return getErrorTextForAdditionalProperties(components)
191
+ return getErrorTextForAdditionalProperties()
192
192
  case 'DEPENDENCIES':
193
- return getErrorTextForDependencies(components)
193
+ return getErrorTextForDependencies()
194
194
  case 'UNIQUE_ITEMS':
195
- return getErrorTextForUniqeItems(components)
195
+ return getErrorTextForUniqeItems()
196
196
  case 'PROPERTY_REQUIRED':
197
- return getErrorTextForPropertyRequired(components)
197
+ return getErrorTextForPropertyRequired()
198
198
  case 'PROPERTY_NAMES':
199
- return getErrorTextForPropertyNames(components)
199
+ return getErrorTextForPropertyNames()
200
200
  case 'PATTERN_REQUIRED':
201
- return getErrorTextForPatternRequired(components)
201
+ return getErrorTextForPatternRequired()
202
202
  case 'TYPE_INVALID':
203
- return getErrorTextForTypeInvalid(params, components)
203
+ return getErrorTextForTypeInvalid(params)
204
204
  case 'MULTIPLE_OF':
205
- return getErrorTextForMultipleOf(components)
205
+ return getErrorTextForMultipleOf()
206
206
  case 'PATTERN':
207
- return getErrorTextForPattern(components)
207
+ return getErrorTextForPattern()
208
208
  case 'CONST':
209
- return getErrorTextForConst(components)
209
+ return getErrorTextForConst()
210
210
  case 'ENUM':
211
- return getErrorTextForEnum(components)
211
+ return getErrorTextForEnum()
212
212
  case '$REF':
213
- return getErrorTextFor$Ref(components)
213
+ return getErrorTextFor$Ref()
214
214
  case 'ONE_OF':
215
- return getErrorTextForOneOf(components)
215
+ return getErrorTextForOneOf()
216
216
  case 'UNKNOWN':
217
- return getErrorTextForUnknown(components)
217
+ return getErrorTextForUnknown()
218
218
  default:
219
219
  throw new Error('Incompatible with Shinkansen')
220
220
  }
221
221
  }
222
222
 
223
+ /**
224
+ * @param {SprocketsTypes.ErrorDefinitionType}
225
+ * @returns {string}
226
+ */
223
227
  export function getErrorHref ({ uri = '' } = {}) {
224
228
  log('getErrorHref')
225
229
 
226
230
  return '#'.concat(uri)
227
231
  }
228
232
 
229
- export default function transform (error, components) {
233
+ /**
234
+ * @param {SprocketsTypes.ErrorDefinitionType}
235
+ * @returns {SprocketsTypes.FieldErrorType}
236
+ */
237
+ export default function transform (error) { // , components) {
230
238
  log('transform')
231
239
 
232
240
  return {
233
- text: getErrorTextByType(error, components),
241
+ text: getErrorTextByType(error), // , components),
234
242
  href: getErrorHref(error)
235
243
  }
236
244
  }
@@ -4,145 +4,145 @@ const log = debug('shinkansen-sprockets/transformers/error-summary')
4
4
 
5
5
  log('`shinkansen` is awake')
6
6
 
7
- export function getErrorTextForMaxItems (components = {}) {
7
+ export function getErrorTextForMaxItems () {
8
8
  log('getErrorTextForMaxItems')
9
9
 
10
10
  return 'Max items'
11
11
  }
12
12
 
13
- export function getErrorTextForMinItems (components = {}) {
13
+ export function getErrorTextForMinItems () {
14
14
  log('getErrorTextForMinItems')
15
15
 
16
16
  return 'Min items'
17
17
  }
18
18
 
19
- export function getErrorTextForMaxLength (components = {}) {
19
+ export function getErrorTextForMaxLength () {
20
20
  log('getErrorTextForMaxLength')
21
21
 
22
22
  return 'Max length'
23
23
  }
24
24
 
25
- export function getErrorTextForMinLength (components = {}) {
25
+ export function getErrorTextForMinLength () {
26
26
  log('getErrorTextForMinLength')
27
27
 
28
28
  return 'Min length'
29
29
  }
30
30
 
31
- export function getErrorTextForMaxProperties (components = {}) {
31
+ export function getErrorTextForMaxProperties () {
32
32
  log('getErrorTextForMaxProperties')
33
33
 
34
34
  return 'Max properties'
35
35
  }
36
36
 
37
- export function getErrorTextForMinProperties (components = {}) {
37
+ export function getErrorTextForMinProperties () {
38
38
  log('getErrorTextForMinProperties')
39
39
 
40
40
  return 'Min properties'
41
41
  }
42
42
 
43
- export function getErrorTextForAdditionalItems (components = {}) {
43
+ export function getErrorTextForAdditionalItems () {
44
44
  log('getErrorTextForAdditionalItems')
45
45
 
46
46
  return 'Additional items'
47
47
  }
48
48
 
49
- export function getErrorTextForMaximum (components = {}) {
49
+ export function getErrorTextForMaximum () {
50
50
  log('getErrorTextForMaximum')
51
51
 
52
52
  return 'Maximum'
53
53
  }
54
54
 
55
- export function getErrorTextForMinimum (components = {}) {
55
+ export function getErrorTextForMinimum () {
56
56
  log('getErrorTextForMinimum')
57
57
 
58
58
  return 'Minimum'
59
59
  }
60
60
 
61
- export function getErrorTextForFormat (components = {}) {
61
+ export function getErrorTextForFormat () {
62
62
  log('getErrorTextForFormat')
63
63
 
64
64
  return 'Format'
65
65
  }
66
66
 
67
- export function getErrorTextForAdditionalProperties (components = {}) {
67
+ export function getErrorTextForAdditionalProperties () {
68
68
  log('getErrorTextForAdditionalProperties')
69
69
 
70
70
  return 'Additional properties'
71
71
  }
72
72
 
73
- export function getErrorTextForDependencies (components = {}) {
73
+ export function getErrorTextForDependencies () {
74
74
  log('getErrorTextForDependencies')
75
75
 
76
76
  return 'Dependencies'
77
77
  }
78
78
 
79
- export function getErrorTextForUniqeItems (components = {}) {
79
+ export function getErrorTextForUniqeItems () {
80
80
  log('getErrorTextForUniqeItems')
81
81
 
82
82
  return 'Unique items'
83
83
  }
84
84
 
85
- export function getErrorTextForPropertyRequired (components = {}) {
85
+ export function getErrorTextForPropertyRequired () {
86
86
  log('getErrorTextForPropertyRequired')
87
87
 
88
88
  return 'Property required'
89
89
  }
90
90
 
91
- export function getErrorTextForPropertyNames (components = {}) {
91
+ export function getErrorTextForPropertyNames () {
92
92
  log('getErrorTextForPropertyNames')
93
93
 
94
94
  return 'Property names'
95
95
  }
96
96
 
97
- export function getErrorTextForPatternRequired (components = {}) {
97
+ export function getErrorTextForPatternRequired () {
98
98
  log('getErrorTextForMultipleOf')
99
99
 
100
100
  return 'Pattern required'
101
101
  }
102
102
 
103
- export function getErrorTextForMultipleOf (components = {}) {
103
+ export function getErrorTextForMultipleOf () {
104
104
  log('getErrorTextForMultipleOf')
105
105
 
106
106
  return 'Multiple of'
107
107
  }
108
108
 
109
- export function getErrorTextForPattern (components = {}) {
109
+ export function getErrorTextForPattern () {
110
110
  log('getErrorTextForPattern')
111
111
 
112
112
  return 'Pattern'
113
113
  }
114
114
 
115
- export function getErrorTextForConst (components = {}) {
115
+ export function getErrorTextForConst () {
116
116
  log('getErrorTextForConst')
117
117
 
118
118
  return 'Const'
119
119
  }
120
120
 
121
- export function getErrorTextForEnum (components = {}) {
121
+ export function getErrorTextForEnum () {
122
122
  log('getErrorTextForEnum')
123
123
 
124
124
  return 'Enum'
125
125
  }
126
126
 
127
- export function getErrorTextFor$Ref (components = {}) {
127
+ export function getErrorTextFor$Ref () {
128
128
  log('getErrorTextFor$Ref')
129
129
 
130
130
  return '$Ref'
131
131
  }
132
132
 
133
- export function getErrorTextForOneOf (components = {}) {
133
+ export function getErrorTextForOneOf () {
134
134
  log('getErrorTextForOneOf')
135
135
 
136
136
  return 'One of'
137
137
  }
138
138
 
139
- export function getErrorTextForUnknown (components = {}) {
139
+ export function getErrorTextForUnknown () {
140
140
  log('getErrorTextForUnknown')
141
141
 
142
142
  return 'Unknown'
143
143
  }
144
144
 
145
- export function getErrorTextForTypeInvalid ({ expectedType } = {}, components = {}) {
145
+ export function getErrorTextForTypeInvalid ({ expectedType } = {}) {
146
146
  log('getErrorTextForTypeInvalid')
147
147
 
148
148
  switch (expectedType) {
@@ -163,74 +163,86 @@ export function getErrorTextForTypeInvalid ({ expectedType } = {}, components =
163
163
  }
164
164
  }
165
165
 
166
- export function getErrorTextByType ({ type, params } = {}, components = {}) {
166
+ /**
167
+ * @param {SprocketsTypes.ErrorDefinitionType}
168
+ * @returns {string}
169
+ */
170
+ export function getErrorTextByType ({ type, params } = {}) {
167
171
  log('getErrorTextByType')
168
172
 
169
173
  switch (type) {
170
174
  case 'MAX_ITEMS':
171
- return getErrorTextForMaxItems(components)
175
+ return getErrorTextForMaxItems()
172
176
  case 'MIN_ITEMS':
173
- return getErrorTextForMinItems(components)
177
+ return getErrorTextForMinItems()
174
178
  case 'MAX_LENGTH':
175
- return getErrorTextForMaxLength(components)
179
+ return getErrorTextForMaxLength()
176
180
  case 'MIN_LENGTH':
177
- return getErrorTextForMinLength(components)
181
+ return getErrorTextForMinLength()
178
182
  case 'MAX_PROPERTIES':
179
- return getErrorTextForMaxProperties(components)
183
+ return getErrorTextForMaxProperties()
180
184
  case 'MIN_PROPERTIES':
181
- return getErrorTextForMinProperties(components)
185
+ return getErrorTextForMinProperties()
182
186
  case 'ADDITIONAL_ITEMS':
183
- return getErrorTextForAdditionalItems(components)
187
+ return getErrorTextForAdditionalItems()
184
188
  case 'MAXIMUM':
185
- return getErrorTextForMaximum(components)
189
+ return getErrorTextForMaximum()
186
190
  case 'MINIMUM':
187
- return getErrorTextForMinimum(components)
191
+ return getErrorTextForMinimum()
188
192
  case 'FORMAT':
189
- return getErrorTextForFormat(components)
193
+ return getErrorTextForFormat()
190
194
  case 'ADDITIONAL_PROPERTIES':
191
- return getErrorTextForAdditionalProperties(components)
195
+ return getErrorTextForAdditionalProperties()
192
196
  case 'DEPENDENCIES':
193
- return getErrorTextForDependencies(components)
197
+ return getErrorTextForDependencies()
194
198
  case 'UNIQUE_ITEMS':
195
- return getErrorTextForUniqeItems(components)
199
+ return getErrorTextForUniqeItems()
196
200
  case 'PROPERTY_REQUIRED':
197
- return getErrorTextForPropertyRequired(components)
201
+ return getErrorTextForPropertyRequired()
198
202
  case 'PROPERTY_NAMES':
199
- return getErrorTextForPropertyNames(components)
203
+ return getErrorTextForPropertyNames()
200
204
  case 'PATTERN_REQUIRED':
201
- return getErrorTextForPatternRequired(components)
205
+ return getErrorTextForPatternRequired()
202
206
  case 'TYPE_INVALID':
203
- return getErrorTextForTypeInvalid(params, components)
207
+ return getErrorTextForTypeInvalid(params)
204
208
  case 'MULTIPLE_OF':
205
- return getErrorTextForMultipleOf(components)
209
+ return getErrorTextForMultipleOf()
206
210
  case 'PATTERN':
207
- return getErrorTextForPattern(components)
211
+ return getErrorTextForPattern()
208
212
  case 'CONST':
209
- return getErrorTextForConst(components)
213
+ return getErrorTextForConst()
210
214
  case 'ENUM':
211
- return getErrorTextForEnum(components)
215
+ return getErrorTextForEnum()
212
216
  case '$REF':
213
- return getErrorTextFor$Ref(components)
217
+ return getErrorTextFor$Ref()
214
218
  case 'ONE_OF':
215
- return getErrorTextForOneOf(components)
219
+ return getErrorTextForOneOf()
216
220
  case 'UNKNOWN':
217
- return getErrorTextForUnknown(components)
221
+ return getErrorTextForUnknown()
218
222
  default:
219
223
  throw new Error('Error incompatible with Zashiki')
220
224
  }
221
225
  }
222
226
 
227
+ /**
228
+ * @param {SprocketsTypes.ErrorDefinitionType}
229
+ * @returns {string}
230
+ */
223
231
  export function getErrorHref ({ uri = '' } = {}) {
224
232
  log('getErrorHref')
225
233
 
226
234
  return '#'.concat(uri)
227
235
  }
228
236
 
229
- export default function transform (error, components) {
237
+ /**
238
+ * @param {SprocketsTypes.ErrorDefinitionType}
239
+ * @returns {SprocketsTypes.FieldErrorType}
240
+ */
241
+ export default function transform (error) { // , components) {
230
242
  log('transform')
231
243
 
232
244
  return {
233
- text: getErrorTextByType(error, components),
245
+ text: getErrorTextByType(error), // , components),
234
246
  href: getErrorHref(error)
235
247
  }
236
248
  }
package/src/index.d.mts DELETED
@@ -1,7 +0,0 @@
1
- import React from 'react'
2
-
3
- declare module 'shinkansen-sprockets' {
4
- export const CheckAnswersSprocket: React.ComponentClass
5
- export const ErrorSummarySprocket: React.ComponentClass
6
- export const FieldsetSprocket: React.ComponentClass
7
- }
package/tsconfig.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "es2020",
4
- "target": "es2020",
5
- "moduleResolution": "node",
6
- "noEmit": true,
7
- "strict": true,
8
- "isolatedModules": true,
9
- "noImplicitAny": true,
10
- "allowSyntheticDefaultImports": true,
11
- "baseUrl": "./",
12
- "paths": {
13
- "shinkansen-sprockets/*": [
14
- "src/*"
15
- ]
16
- }
17
- },
18
- "include": [
19
- "src/*"
20
- ]
21
- }