shinkansen-sprockets 1.1.244 → 1.1.246
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 +5 -5
- package/src/components/common/text-content/index.d.mts +1 -1
- package/src/components/common/text-content/index.jsx +9 -5
- package/src/components/common/visually-hidden-text/index.d.mts +9 -0
- package/src/components/common/visually-hidden-text/index.jsx +2 -6
- package/src/sprockets/check-answers/group/change-answer.jsx +31 -3
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "shinkansen-sprockets",
|
3
|
-
"version": "1.1.
|
3
|
+
"version": "1.1.246",
|
4
4
|
"description": "Shinkansen Sprockets",
|
5
5
|
"keywords": [
|
6
6
|
"Shinkansen",
|
@@ -58,7 +58,7 @@
|
|
58
58
|
"@babel/register": "^7.23.7",
|
59
59
|
"@modernpoacher/design-system": "1.0.134",
|
60
60
|
"@modernpoacher/hooks": "^1.0.466",
|
61
|
-
"@sequencemedia/gulp": "^1.1.
|
61
|
+
"@sequencemedia/gulp": "^1.1.165",
|
62
62
|
"@sequencemedia/gulp-clean-css": "^1.0.85",
|
63
63
|
"@sequencemedia/gulp-css-purge": "^1.1.83",
|
64
64
|
"@sequencemedia/gulp-debug": "^1.0.88",
|
@@ -70,9 +70,9 @@
|
|
70
70
|
"@storybook/addon-links": "^7.6.17",
|
71
71
|
"@storybook/react": "^7.6.17",
|
72
72
|
"@storybook/react-webpack5": "^7.6.17",
|
73
|
-
"@types/react": "^18.2.
|
74
|
-
"@typescript-eslint/eslint-plugin": "^7.0
|
75
|
-
"@typescript-eslint/parser": "^7.0
|
73
|
+
"@types/react": "^18.2.59",
|
74
|
+
"@typescript-eslint/eslint-plugin": "^7.1.0",
|
75
|
+
"@typescript-eslint/parser": "^7.1.0",
|
76
76
|
"autoprefixer": "^10.4.17",
|
77
77
|
"babel-plugin-module-resolver": "^5.0.0",
|
78
78
|
"core-js": "^3.36.0",
|
@@ -5,5 +5,5 @@ declare module 'shinkansen-sprockets/components/common/text-content' {
|
|
5
5
|
textContent: string
|
6
6
|
}
|
7
7
|
|
8
|
-
export default function TextContent (props: TextContentProps): React.JSX.Element
|
8
|
+
export default function TextContent (props: TextContentProps): React.JSX.Element | null
|
9
9
|
}
|
@@ -12,11 +12,15 @@ import PropTypes from 'prop-types'
|
|
12
12
|
* @returns {React.JSX.Element}
|
13
13
|
*/
|
14
14
|
export default function TextContent ({ textContent }) {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
if (textContent) {
|
16
|
+
return (
|
17
|
+
<span className='text-content'>
|
18
|
+
{textContent}
|
19
|
+
</span>
|
20
|
+
)
|
21
|
+
}
|
22
|
+
|
23
|
+
return null
|
20
24
|
}
|
21
25
|
|
22
26
|
TextContent.propTypes = {
|
@@ -0,0 +1,9 @@
|
|
1
|
+
declare module 'shinkansen-sprockets/components/common/visually-hidden-text' {
|
2
|
+
import type React from 'react'
|
3
|
+
|
4
|
+
export interface VisuallyHiddenTextProps {
|
5
|
+
visuallyHiddenText: string
|
6
|
+
}
|
7
|
+
|
8
|
+
export default function VisuallyHiddenText (props: VisuallyHiddenTextProps): React.JSX.Element | null
|
9
|
+
}
|
@@ -5,7 +5,7 @@ export default function VisuallyHiddenText ({ visuallyHiddenText }) {
|
|
5
5
|
if (visuallyHiddenText) {
|
6
6
|
return (
|
7
7
|
<span className='visually-hidden-text'>
|
8
|
-
{visuallyHiddenText
|
8
|
+
{visuallyHiddenText}
|
9
9
|
</span>
|
10
10
|
)
|
11
11
|
}
|
@@ -14,9 +14,5 @@ export default function VisuallyHiddenText ({ visuallyHiddenText }) {
|
|
14
14
|
}
|
15
15
|
|
16
16
|
VisuallyHiddenText.propTypes = {
|
17
|
-
visuallyHiddenText: PropTypes.string
|
18
|
-
}
|
19
|
-
|
20
|
-
VisuallyHiddenText.defaultProps = {
|
21
|
-
visuallyHiddenText: ''
|
17
|
+
visuallyHiddenText: PropTypes.string.isRequired
|
22
18
|
}
|
@@ -12,6 +12,36 @@ import VisuallyHiddenText from 'shinkansen-sprockets/components/common/visually-
|
|
12
12
|
|
13
13
|
const log = debug('shinkansen-sprockets/sprockets/check-answers/group/change-answer')
|
14
14
|
|
15
|
+
function TextContentWithVisuallyHiddenText ({ textContent, visuallyHiddenText }) {
|
16
|
+
return (
|
17
|
+
<>
|
18
|
+
<TextContent textContent={textContent} />
|
19
|
+
{String.fromCharCode(32)}
|
20
|
+
<VisuallyHiddenText visuallyHiddenText={visuallyHiddenText.toLowerCase()} />
|
21
|
+
</>
|
22
|
+
)
|
23
|
+
}
|
24
|
+
|
25
|
+
TextContentWithVisuallyHiddenText.propTypes = {
|
26
|
+
textContent: PropTypes.string.isRequired,
|
27
|
+
visuallyHiddenText: PropTypes.string.isRequired
|
28
|
+
}
|
29
|
+
|
30
|
+
function LinkText ({ textContent, visuallyHiddenText }) {
|
31
|
+
if (textContent) {
|
32
|
+
return (
|
33
|
+
visuallyHiddenText
|
34
|
+
? <TextContentWithVisuallyHiddenText textContent={textContent} visuallyHiddenText={visuallyHiddenText} />
|
35
|
+
: <TextContent textContent={textContent} />
|
36
|
+
)
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
LinkText.propTypes = {
|
41
|
+
textContent: PropTypes.string.isRequired,
|
42
|
+
visuallyHiddenText: PropTypes.string.isRequired
|
43
|
+
}
|
44
|
+
|
15
45
|
/**
|
16
46
|
* @param {SprocketsTypes.AnswerDefinitionType}
|
17
47
|
* @returns {React.JSX.Element}
|
@@ -22,9 +52,7 @@ export default function ChangeAnswer ({ changeAnswer: { href, text, visuallyHidd
|
|
22
52
|
return (
|
23
53
|
<dd className='change-answer'>
|
24
54
|
<Link to={href}>
|
25
|
-
<
|
26
|
-
{String.fromCharCode(32)}
|
27
|
-
<VisuallyHiddenText visuallyHiddenText={visuallyHiddenText} />
|
55
|
+
<LinkText textContent={text} visuallyHiddenText={visuallyHiddenText} />
|
28
56
|
</Link>
|
29
57
|
</dd>
|
30
58
|
)
|