shinkansen-sprockets 1.1.463 → 1.2.1

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 (72) hide show
  1. package/babel.config.cjs +1 -0
  2. package/eslint.config.mjs +11 -56
  3. package/index.d.mts +122 -13
  4. package/package.json +9 -4
  5. package/src/common/index.d.mts +1 -3
  6. package/src/common/index.mjs +1 -7
  7. package/src/components/common/text-content/index.cjs +1 -1
  8. package/src/components/common/text-content/index.d.mts +3 -4
  9. package/src/components/common/text-content/index.jsx +7 -6
  10. package/src/components/common/visually-hidden-text/index.cjs +1 -1
  11. package/src/components/common/visually-hidden-text/index.d.mts +3 -4
  12. package/src/components/common/visually-hidden-text/index.jsx +7 -6
  13. package/src/components/description/index.cjs +1 -1
  14. package/src/components/description/index.d.mts +10 -5
  15. package/src/components/description/index.jsx +12 -3
  16. package/src/components/error-message/index.cjs +1 -1
  17. package/src/components/error-message/index.d.mts +20 -5
  18. package/src/components/error-message/index.jsx +30 -15
  19. package/src/components/group/index.cjs +1 -1
  20. package/src/components/group/index.d.mts +12 -7
  21. package/src/components/group/index.jsx +8 -15
  22. package/src/components/title/index.cjs +1 -1
  23. package/src/components/title/index.d.mts +16 -5
  24. package/src/components/title/index.jsx +18 -4
  25. package/src/index.d.mts +8 -0
  26. package/src/sprockets/check-answers/group/answer-title.cjs +1 -0
  27. package/src/sprockets/check-answers/group/answer-title.jsx +2 -2
  28. package/src/sprockets/check-answers/group/answer-value.cjs +1 -0
  29. package/src/sprockets/check-answers/group/answer-value.jsx +29 -12
  30. package/src/sprockets/check-answers/group/change-answer.cjs +1 -0
  31. package/src/sprockets/check-answers/group/change-answer.jsx +17 -7
  32. package/src/sprockets/check-answers/group/index.cjs +1 -1
  33. package/src/sprockets/check-answers/group/index.d.mts +7 -1
  34. package/src/sprockets/check-answers/group/index.jsx +43 -28
  35. package/src/sprockets/check-answers/index.cjs +1 -1
  36. package/src/sprockets/check-answers/index.d.mts +5 -1
  37. package/src/sprockets/check-answers/index.jsx +25 -9
  38. package/src/sprockets/check-answers/title/index.cjs +1 -1
  39. package/src/sprockets/check-answers/title/index.d.mts +5 -1
  40. package/src/sprockets/check-answers/title/index.jsx +8 -5
  41. package/src/sprockets/error-summary/group/index.cjs +1 -1
  42. package/src/sprockets/error-summary/group/index.d.mts +7 -1
  43. package/src/sprockets/error-summary/group/index.jsx +31 -23
  44. package/src/sprockets/error-summary/index.cjs +1 -1
  45. package/src/sprockets/error-summary/index.d.mts +5 -1
  46. package/src/sprockets/error-summary/index.jsx +19 -9
  47. package/src/sprockets/error-summary/title/index.cjs +1 -1
  48. package/src/sprockets/error-summary/title/index.d.mts +5 -1
  49. package/src/sprockets/error-summary/title/index.jsx +8 -5
  50. package/src/sprockets/fieldset/description/index.cjs +1 -1
  51. package/src/sprockets/fieldset/description/index.jsx +0 -5
  52. package/src/sprockets/fieldset/error-message/index.cjs +1 -1
  53. package/src/sprockets/fieldset/error-message/index.jsx +0 -5
  54. package/src/sprockets/fieldset/group/index.cjs +1 -1
  55. package/src/sprockets/fieldset/group/index.d.mts +7 -1
  56. package/src/sprockets/fieldset/group/index.jsx +10 -5
  57. package/src/sprockets/fieldset/index.cjs +1 -1
  58. package/src/sprockets/fieldset/index.d.mts +11 -1
  59. package/src/sprockets/fieldset/index.jsx +22 -17
  60. package/src/sprockets/fieldset/title/index.cjs +1 -1
  61. package/src/sprockets/fieldset/title/index.d.mts +5 -1
  62. package/src/sprockets/fieldset/title/index.jsx +8 -4
  63. package/src/sprockets/index.cjs +1 -4
  64. package/src/sprockets/index.d.mts +14 -8
  65. package/src/sprockets/index.jsx +9 -16
  66. package/src/transformers/check-answers/index.d.mts +8 -0
  67. package/src/transformers/check-answers/index.mjs +2 -2
  68. package/src/transformers/common/index.mjs +4 -4
  69. package/src/transformers/error-message/index.d.mts +8 -0
  70. package/src/transformers/error-message/index.mjs +12 -4
  71. package/src/transformers/error-summary/index.d.mts +8 -0
  72. package/src/transformers/error-summary/index.mjs +10 -6
@@ -10,11 +10,8 @@ const log = debug('shinkansen-sprockets/sprockets')
10
10
 
11
11
  log('`shinkansen` is awake')
12
12
 
13
- /**
14
- * Has only default export
15
- */
16
13
  const {
17
- default: component
14
+ default: component // @ts-ignore
18
15
  } = require('./index.jsx')
19
16
 
20
17
  module.exports = component
@@ -1,17 +1,23 @@
1
1
  declare module '#sprockets/sprockets' {
2
2
  import React from 'react'
3
3
 
4
- export interface SprocketProps {
5
- title: string
6
- onChange: SprocketsTypes.OnChangeType
7
- groupRef: object
8
- children: React.JSX.Element | React.JSX.Element[]
9
- }
4
+ type SprocketProps = SprocketsTypes.Sprockets.Sprocket.SprocketProps
5
+
6
+ export default class Sprocket<P extends SprocketProps> extends React.Component<P> {
7
+ static propTypes: object
8
+
9
+ getClassName (): string
10
+
11
+ shouldComponentUpdate (props: SprocketProps): boolean
10
12
 
11
- export default class Sprocket extends React.Component<SprocketProps> {}
13
+ renderTitle (): React.JSX.Element | null
14
+
15
+ renderGroup (): React.JSX.Element | null
16
+ }
12
17
  }
13
18
 
14
19
  declare module 'shinkansen-sprockets/sprockets' {
20
+ export type SprocketProps = SprocketsTypes.Sprockets.Sprocket.SprocketProps
21
+
15
22
  export { default } from '#sprockets/sprockets'
16
- export * from '#sprockets/sprockets'
17
23
  }
@@ -1,16 +1,13 @@
1
1
  /**
2
- * Sprocket component
3
- *
4
- * @typedef {import('shinkansen-sprockets/sprockets').SprocketProps} SprocketProps
2
+ * @typedef {SprocketsTypes.Sprockets.Sprocket.SprocketProps} SprocketProps
5
3
  */
6
4
 
5
+ /**
6
+ * Sprocket component
7
+ */
7
8
  import React, { Component } from 'react'
8
9
  import PropTypes from 'prop-types'
9
10
 
10
- import {
11
- DEFAULT_HANDLE_CHANGE
12
- } from '#sprockets/common'
13
-
14
11
  import Title from '#sprockets/components/title'
15
12
  import Group from '#sprockets/components/group'
16
13
 
@@ -20,14 +17,13 @@ export default class Sprocket extends Component {
20
17
  }
21
18
 
22
19
  /**
23
- * @param {SprocketProps} props
24
- * @returns {boolean}
20
+ * @param {SprocketProps} props
21
+ * @returns {boolean}
25
22
  */
26
- shouldComponentUpdate (props, state) {
23
+ shouldComponentUpdate (props) {
27
24
  return (
28
25
  (props.children !== this.props.children) ||
29
- (props.title !== this.props.title) ||
30
- (props.onChange !== this.props.onChange)
26
+ (props.title !== this.props.title)
31
27
  )
32
28
  }
33
29
 
@@ -45,14 +41,12 @@ export default class Sprocket extends Component {
45
41
 
46
42
  renderGroup () {
47
43
  const {
48
- onChange = DEFAULT_HANDLE_CHANGE,
49
44
  groupRef,
50
45
  children
51
46
  } = this.props
52
47
 
53
48
  return (
54
49
  <Group
55
- onChange={onChange}
56
50
  groupRef={groupRef}>
57
51
  {this.renderTitle()}
58
52
  {children}
@@ -73,7 +67,6 @@ export default class Sprocket extends Component {
73
67
 
74
68
  Sprocket.propTypes = {
75
69
  title: PropTypes.string,
76
- onChange: PropTypes.func,
77
70
  children: PropTypes.oneOfType([
78
71
  PropTypes.node,
79
72
  PropTypes.arrayOf(
@@ -81,6 +74,6 @@ Sprocket.propTypes = {
81
74
  )
82
75
  ]),
83
76
  groupRef: PropTypes.shape({
84
- current: PropTypes.shape().isRequired
77
+ current: PropTypes.shape({}).isRequired
85
78
  })
86
79
  }
@@ -1,3 +1,11 @@
1
1
  declare module '#sprockets/transformers/check-answers' {
2
2
  export default function transform (answer: SprocketsTypes.AnswerDefinitionType): SprocketsTypes.FieldChangeType
3
3
  }
4
+
5
+ declare module 'shinkansen-sprockets/transformers/check-answers' {
6
+ export type AnswerDefinitionType = SprocketsTypes.AnswerDefinitionType
7
+
8
+ export type FieldChangeType = SprocketsTypes.FieldChangeType
9
+
10
+ export { default } from '#sprockets/transformers/check-answers'
11
+ }
@@ -5,8 +5,8 @@ const log = debug('shinkansen-sprockets/transformers/check-answers')
5
5
  log('`shinkansen` is awake')
6
6
 
7
7
  /**
8
- * @param {SprocketsTypes.AnswerDefinitionType}
9
- * @returns {FieldChangeType}
8
+ * @param {SprocketsTypes.AnswerDefinitionType}
9
+ * @returns {FieldChangeType}
10
10
  */
11
11
  export default function transform ({ changeAnswer: { text, href } }) {
12
12
  log('transform')
@@ -8,10 +8,10 @@ const log = debug('shinkansen-sprockets/transformers/common')
8
8
  log('`shinkansen` is awake')
9
9
 
10
10
  /**
11
- * @param {string} href
12
- * @param {string} text
13
- * @param {number} index
14
- * @returns {string}
11
+ * @param {string} href
12
+ * @param {string} text
13
+ * @param {number} index
14
+ * @returns {string}
15
15
  */
16
16
  export function getKey (href, text, index) {
17
17
  return (
@@ -1,3 +1,11 @@
1
1
  declare module '#sprockets/transformers/error-message' {
2
2
  export default function transform (error: SprocketsTypes.ErrorDefinitionType): SprocketsTypes.FieldErrorType
3
3
  }
4
+
5
+ declare module 'shinkansen-sprockets/transformers/error-message' {
6
+ export type ErrorDefinitionType = SprocketsTypes.ErrorDefinitionType
7
+
8
+ export type FieldErrorType = SprocketsTypes.FieldErrorType
9
+
10
+ export { default } from '#sprockets/transformers/error-message'
11
+ }
@@ -142,6 +142,10 @@ export function getErrorTextForUnknown () {
142
142
  return 'Unknown'
143
143
  }
144
144
 
145
+ /**
146
+ * @param {{ expectedType?: string }} params
147
+ * @returns {string}
148
+ */
145
149
  export function getErrorTextForTypeInvalid ({ expectedType } = {}) {
146
150
  log('getErrorTextForTypeInvalid')
147
151
 
@@ -163,6 +167,10 @@ export function getErrorTextForTypeInvalid ({ expectedType } = {}) {
163
167
  }
164
168
  }
165
169
 
170
+ /**
171
+ * @param {{ type?: string, params?: Record<PropertyKey, unknown> }} params
172
+ * @returns {string}
173
+ */
166
174
  export function getErrorTextByType ({ type, params } = {}) {
167
175
  log('getErrorTextByType')
168
176
 
@@ -221,8 +229,8 @@ export function getErrorTextByType ({ type, params } = {}) {
221
229
  }
222
230
 
223
231
  /**
224
- * @param {SprocketsTypes.ErrorDefinitionType}
225
- * @returns {string}
232
+ * @param {{ uri?: string }} [params]
233
+ * @returns {string}
226
234
  */
227
235
  export function getErrorHref ({ uri = '' } = {}) {
228
236
  log('getErrorHref')
@@ -231,8 +239,8 @@ export function getErrorHref ({ uri = '' } = {}) {
231
239
  }
232
240
 
233
241
  /**
234
- * @param {SprocketsTypes.ErrorDefinitionType}
235
- * @returns {SprocketsTypes.FieldErrorType}
242
+ * @param {SprocketsTypes.ErrorDefinitionType} error
243
+ * @returns {SprocketsTypes.FieldErrorType}
236
244
  */
237
245
  export default function transform (error) { // , components) {
238
246
  log('transform')
@@ -1,3 +1,11 @@
1
1
  declare module '#sprockets/transformers/error-summary' {
2
2
  export default function transform (error: SprocketsTypes.ErrorDefinitionType): SprocketsTypes.FieldErrorType
3
3
  }
4
+
5
+ declare module 'shinkansen-sprockets/transformers/error-summary' {
6
+ export type ErrorDefinitionType = SprocketsTypes.ErrorDefinitionType
7
+
8
+ export type FieldErrorType = SprocketsTypes.FieldErrorType
9
+
10
+ export { default } from '#sprockets/transformers/error-summary'
11
+ }
@@ -142,6 +142,10 @@ export function getErrorTextForUnknown () {
142
142
  return 'Unknown'
143
143
  }
144
144
 
145
+ /**
146
+ * @param {{ expectedType?: string }} params
147
+ * @returns {string}
148
+ */
145
149
  export function getErrorTextForTypeInvalid ({ expectedType } = {}) {
146
150
  log('getErrorTextForTypeInvalid')
147
151
 
@@ -164,8 +168,8 @@ export function getErrorTextForTypeInvalid ({ expectedType } = {}) {
164
168
  }
165
169
 
166
170
  /**
167
- * @param {SprocketsTypes.ErrorDefinitionType}
168
- * @returns {string}
171
+ * @param {{ type?: string, params?: Record<PropertyKey, unknown> }} params
172
+ * @returns {string}
169
173
  */
170
174
  export function getErrorTextByType ({ type, params } = {}) {
171
175
  log('getErrorTextByType')
@@ -225,8 +229,8 @@ export function getErrorTextByType ({ type, params } = {}) {
225
229
  }
226
230
 
227
231
  /**
228
- * @param {SprocketsTypes.ErrorDefinitionType}
229
- * @returns {string}
232
+ * @param {{ uri?: string }} [params]
233
+ * @returns {string}
230
234
  */
231
235
  export function getErrorHref ({ uri = '' } = {}) {
232
236
  log('getErrorHref')
@@ -235,8 +239,8 @@ export function getErrorHref ({ uri = '' } = {}) {
235
239
  }
236
240
 
237
241
  /**
238
- * @param {SprocketsTypes.ErrorDefinitionType}
239
- * @returns {SprocketsTypes.FieldErrorType}
242
+ * @param {SprocketsTypes.ErrorDefinitionType} error
243
+ * @returns {SprocketsTypes.FieldErrorType}
240
244
  */
241
245
  export default function transform (error) { // , components) {
242
246
  log('transform')