shinkansen-cogs 1.7.302 → 1.8.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/babel.config.cjs +1 -0
- package/eslint.config.mjs +11 -56
- package/index.d.mts +214 -4
- package/package.json +5 -1
- package/src/cogs/checkbox/description/index.cjs +1 -1
- package/src/cogs/checkbox/description/index.jsx +0 -4
- package/src/cogs/checkbox/error-message/index.cjs +1 -1
- package/src/cogs/checkbox/error-message/index.jsx +0 -4
- package/src/cogs/checkbox/field/index.cjs +1 -1
- package/src/cogs/checkbox/field/index.d.mts +8 -2
- package/src/cogs/checkbox/field/index.jsx +11 -1
- package/src/cogs/checkbox/index.cjs +1 -1
- package/src/cogs/checkbox/index.d.mts +20 -2
- package/src/cogs/checkbox/index.jsx +41 -14
- package/src/cogs/checkbox/title/index.cjs +1 -1
- package/src/cogs/checkbox/title/index.d.mts +5 -1
- package/src/cogs/checkbox/title/index.jsx +8 -4
- package/src/cogs/email/description/index.cjs +1 -1
- package/src/cogs/email/description/index.jsx +0 -4
- package/src/cogs/email/error-message/index.cjs +1 -1
- package/src/cogs/email/error-message/index.jsx +0 -4
- package/src/cogs/email/field/index.cjs +1 -1
- package/src/cogs/email/field/index.d.mts +8 -2
- package/src/cogs/email/field/index.jsx +11 -5
- package/src/cogs/email/index.cjs +1 -1
- package/src/cogs/email/index.d.mts +13 -2
- package/src/cogs/email/index.jsx +17 -8
- package/src/cogs/email/title/index.cjs +1 -1
- package/src/cogs/email/title/index.d.mts +5 -1
- package/src/cogs/email/title/index.jsx +8 -4
- package/src/cogs/index.cjs +1 -0
- package/src/cogs/index.d.mts +31 -13
- package/src/cogs/index.jsx +43 -14
- package/src/cogs/number/description/index.cjs +1 -1
- package/src/cogs/number/description/index.jsx +0 -4
- package/src/cogs/number/error-message/index.cjs +1 -1
- package/src/cogs/number/error-message/index.jsx +0 -4
- package/src/cogs/number/field/index.cjs +1 -1
- package/src/cogs/number/field/index.d.mts +8 -2
- package/src/cogs/number/field/index.jsx +11 -1
- package/src/cogs/number/index.cjs +1 -1
- package/src/cogs/number/index.d.mts +13 -2
- package/src/cogs/number/index.jsx +17 -4
- package/src/cogs/number/title/index.cjs +1 -1
- package/src/cogs/number/title/index.d.mts +5 -1
- package/src/cogs/number/title/index.jsx +8 -4
- package/src/cogs/password/description/index.cjs +1 -1
- package/src/cogs/password/description/index.jsx +0 -4
- package/src/cogs/password/error-message/index.cjs +1 -1
- package/src/cogs/password/error-message/index.jsx +0 -4
- package/src/cogs/password/field/index.cjs +1 -1
- package/src/cogs/password/field/index.d.mts +8 -2
- package/src/cogs/password/field/index.jsx +11 -5
- package/src/cogs/password/index.cjs +1 -1
- package/src/cogs/password/index.d.mts +13 -2
- package/src/cogs/password/index.jsx +17 -8
- package/src/cogs/password/title/index.cjs +1 -1
- package/src/cogs/password/title/index.d.mts +5 -1
- package/src/cogs/password/title/index.jsx +8 -4
- package/src/cogs/radio/description/index.cjs +1 -1
- package/src/cogs/radio/description/index.jsx +0 -4
- package/src/cogs/radio/error-message/index.cjs +1 -1
- package/src/cogs/radio/error-message/index.jsx +0 -4
- package/src/cogs/radio/field/index.cjs +1 -1
- package/src/cogs/radio/field/index.d.mts +8 -2
- package/src/cogs/radio/field/index.jsx +11 -1
- package/src/cogs/radio/index.cjs +1 -1
- package/src/cogs/radio/index.d.mts +20 -2
- package/src/cogs/radio/index.jsx +41 -14
- package/src/cogs/radio/title/index.cjs +1 -1
- package/src/cogs/radio/title/index.d.mts +5 -1
- package/src/cogs/radio/title/index.jsx +8 -4
- package/src/cogs/select/description/index.cjs +1 -1
- package/src/cogs/select/description/index.jsx +0 -4
- package/src/cogs/select/error-message/index.cjs +1 -1
- package/src/cogs/select/error-message/index.jsx +0 -4
- package/src/cogs/select/field/index.cjs +1 -1
- package/src/cogs/select/field/index.d.mts +8 -2
- package/src/cogs/select/field/index.jsx +56 -15
- package/src/cogs/select/index.cjs +1 -1
- package/src/cogs/select/index.d.mts +13 -2
- package/src/cogs/select/index.jsx +39 -12
- package/src/cogs/select/title/index.cjs +1 -1
- package/src/cogs/select/title/index.d.mts +5 -1
- package/src/cogs/select/title/index.jsx +8 -4
- package/src/cogs/text/description/index.cjs +1 -1
- package/src/cogs/text/description/index.jsx +0 -4
- package/src/cogs/text/error-message/index.cjs +1 -1
- package/src/cogs/text/error-message/index.jsx +0 -4
- package/src/cogs/text/field/index.cjs +1 -1
- package/src/cogs/text/field/index.d.mts +8 -2
- package/src/cogs/text/field/index.jsx +11 -5
- package/src/cogs/text/index.cjs +1 -1
- package/src/cogs/text/index.d.mts +13 -2
- package/src/cogs/text/index.jsx +17 -8
- package/src/cogs/text/title/index.cjs +1 -1
- package/src/cogs/text/title/index.d.mts +5 -1
- package/src/cogs/text/title/index.jsx +8 -4
- package/src/cogs/textarea/description/index.cjs +1 -1
- package/src/cogs/textarea/description/index.jsx +0 -4
- package/src/cogs/textarea/error-message/index.cjs +1 -1
- package/src/cogs/textarea/error-message/index.jsx +0 -4
- package/src/cogs/textarea/field/index.cjs +1 -1
- package/src/cogs/textarea/field/index.d.mts +8 -2
- package/src/cogs/textarea/field/index.jsx +11 -5
- package/src/cogs/textarea/index.cjs +1 -1
- package/src/cogs/textarea/index.d.mts +13 -2
- package/src/cogs/textarea/index.jsx +17 -8
- package/src/cogs/textarea/title/index.cjs +1 -1
- package/src/cogs/textarea/title/index.d.mts +5 -1
- package/src/cogs/textarea/title/index.jsx +8 -4
- package/src/common/index.d.mts +10 -2
- package/src/components/common/disabled/index.cjs +1 -1
- package/src/components/common/disabled/index.jsx +7 -5
- package/src/components/common/readonly/index.cjs +1 -1
- package/src/components/common/readonly/index.jsx +7 -5
- package/src/components/common/required/index.cjs +1 -1
- package/src/components/common/required/index.jsx +7 -5
- package/src/components/common/text-content/index.cjs +1 -1
- package/src/components/common/text-content/index.d.mts +3 -4
- package/src/components/common/text-content/index.jsx +6 -5
- package/src/components/description/index.cjs +1 -1
- package/src/components/description/index.d.mts +10 -5
- package/src/components/description/index.jsx +12 -2
- package/src/components/error-message/index.cjs +1 -1
- package/src/components/error-message/index.d.mts +22 -3
- package/src/components/error-message/index.jsx +28 -11
- package/src/components/field/index.cjs +1 -1
- package/src/components/field/index.d.mts +29 -14
- package/src/components/field/index.jsx +57 -17
- package/src/components/title/index.cjs +1 -1
- package/src/components/title/index.d.mts +22 -10
- package/src/components/title/index.jsx +12 -2
- package/src/index.d.mts +3 -0
- package/src/transformers/error-message/index.d.mts +8 -0
- package/src/transformers/error-message/index.mjs +12 -4
|
@@ -2,8 +2,10 @@ import React from 'react'
|
|
|
2
2
|
|
|
3
3
|
const REQUIRED = String.fromCharCode(42)
|
|
4
4
|
|
|
5
|
-
export default ()
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
export default function Required () {
|
|
6
|
+
return (
|
|
7
|
+
<span className='is-required'>
|
|
8
|
+
{REQUIRED}
|
|
9
|
+
</span>
|
|
10
|
+
)
|
|
11
|
+
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
declare module '#cogs/components/common/text-content' {
|
|
2
2
|
import type React from 'react'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
textContent: string
|
|
6
|
-
}
|
|
4
|
+
type TextContentProps = CogsTypes.Components.Common.TextContent.TextContentProps
|
|
7
5
|
|
|
8
6
|
export default function TextContent (props: TextContentProps): React.JSX.Element | null
|
|
9
7
|
}
|
|
10
8
|
|
|
11
9
|
declare module 'shinkansen-cogs/components/common/text-content' {
|
|
10
|
+
export type TextContentProps = CogsTypes.Components.Common.TextContent.TextContentProps
|
|
11
|
+
|
|
12
12
|
export { default } from '#cogs/components/common/text-content'
|
|
13
|
-
export * from '#cogs/components/common/text-content'
|
|
14
13
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* TextContent
|
|
3
|
-
*
|
|
4
|
-
* @typedef {import('shinkansen-cogs/components/common/text-content').TextContentProps} TextContentProps
|
|
2
|
+
* @typedef {CogsTypes.Components.Common.TextContent.TextContentProps} TextContentProps
|
|
5
3
|
*/
|
|
6
4
|
|
|
5
|
+
/**
|
|
6
|
+
* TextContent component
|
|
7
|
+
*/
|
|
7
8
|
import React from 'react'
|
|
8
9
|
import PropTypes from 'prop-types'
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
12
|
+
* @param {TextContentProps} props
|
|
13
|
+
* @returns {React.JSX.Element | null}
|
|
13
14
|
*/
|
|
14
15
|
export default function TextContent ({ textContent }) {
|
|
15
16
|
if (textContent) {
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
declare module '#cogs/components/description' {
|
|
2
2
|
import React from 'react'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
type DescriptionProps = CogsTypes.Components.Description.DescriptionProps
|
|
5
|
+
|
|
6
|
+
export default class Description extends React.Component<DescriptionProps> {
|
|
7
|
+
static propTypes: object
|
|
8
|
+
|
|
9
|
+
getClassName (): string
|
|
7
10
|
|
|
8
|
-
|
|
11
|
+
shouldComponentUpdate (props: DescriptionProps): boolean
|
|
12
|
+
}
|
|
9
13
|
}
|
|
10
14
|
|
|
11
15
|
declare module 'shinkansen-cogs/components/description' {
|
|
16
|
+
export type DescriptionProps = CogsTypes.Components.Description.DescriptionProps
|
|
17
|
+
|
|
12
18
|
export { default } from '#cogs/components/description'
|
|
13
|
-
export * from '#cogs/components/description'
|
|
14
19
|
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {CogsTypes.Components.Description.DescriptionProps} DescriptionProps
|
|
3
|
+
*/
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* Description component
|
|
3
7
|
*/
|
|
@@ -11,14 +15,20 @@ export default class Description extends Component {
|
|
|
11
15
|
return 'description'
|
|
12
16
|
}
|
|
13
17
|
|
|
14
|
-
|
|
18
|
+
/**
|
|
19
|
+
* @param {DescriptionProps} props
|
|
20
|
+
* @returns {boolean}
|
|
21
|
+
*/
|
|
22
|
+
shouldComponentUpdate (props) {
|
|
15
23
|
return (
|
|
16
24
|
(props.description !== this.props.description)
|
|
17
25
|
)
|
|
18
26
|
}
|
|
19
27
|
|
|
20
28
|
render () {
|
|
21
|
-
const {
|
|
29
|
+
const {
|
|
30
|
+
description
|
|
31
|
+
} = this.props
|
|
22
32
|
|
|
23
33
|
if (description) {
|
|
24
34
|
return (
|
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
declare module '#cogs/components/error-message' {
|
|
2
2
|
import React from 'react'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type ErrorDefinitionType = CogsTypes.ErrorDefinitionType
|
|
5
|
+
type ErrorMessageProps = CogsTypes.Components.ErrorMessage.ErrorMessageProps
|
|
6
|
+
type ErrorMessageState = CogsTypes.Components.ErrorMessage.ErrorMessageState
|
|
5
7
|
|
|
6
|
-
export default class ErrorMessage extends React.Component<ErrorMessageProps> {
|
|
8
|
+
export default class ErrorMessage extends React.Component<ErrorMessageProps, ErrorMessageState> {
|
|
9
|
+
static propTypes: object
|
|
10
|
+
|
|
11
|
+
hasTextContent (): boolean
|
|
12
|
+
|
|
13
|
+
getTextContent (): string
|
|
14
|
+
|
|
15
|
+
getClassName (): string
|
|
16
|
+
|
|
17
|
+
static getDerivedStateFromProps (props: ErrorMessageProps, state: ErrorMessageState): ErrorMessageState
|
|
18
|
+
|
|
19
|
+
shouldComponentUpdate (props: ErrorMessageProps, state: ErrorMessageState): boolean
|
|
20
|
+
|
|
21
|
+
renderTextContent (): React.JSX.Element | null
|
|
22
|
+
}
|
|
7
23
|
}
|
|
8
24
|
|
|
9
25
|
declare module 'shinkansen-cogs/components/error-message' {
|
|
26
|
+
export type ErrorDefinitionType = CogsTypes.ErrorDefinitionType
|
|
27
|
+
export type ErrorMessageProps = CogsTypes.Components.ErrorMessage.ErrorMessageProps
|
|
28
|
+
export type ErrorMessageState = CogsTypes.Components.ErrorMessage.ErrorMessageState
|
|
29
|
+
|
|
10
30
|
export { default } from '#cogs/components/error-message'
|
|
11
|
-
export * from '#cogs/components/error-message'
|
|
12
31
|
}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {CogsTypes.ErrorDefinitionType} ErrorDefinitionType
|
|
3
|
+
* @typedef {CogsTypes.Components.ErrorMessage.ErrorMessageProps} ErrorMessageProps
|
|
4
|
+
* @typedef {CogsTypes.Components.ErrorMessage.ErrorMessageState} ErrorMessageState
|
|
5
|
+
*/
|
|
6
|
+
|
|
1
7
|
/**
|
|
2
8
|
* ErrorMessage component
|
|
3
9
|
*/
|
|
@@ -10,10 +16,15 @@ import transform from '#cogs/transformers/error-message'
|
|
|
10
16
|
import TextContent from '#cogs/components/common/text-content'
|
|
11
17
|
|
|
12
18
|
export default class ErrorMessage extends Component {
|
|
19
|
+
/**
|
|
20
|
+
* @type {ErrorMessageState}
|
|
21
|
+
*/
|
|
13
22
|
state = {}
|
|
14
23
|
|
|
15
24
|
hasTextContent () {
|
|
16
|
-
const {
|
|
25
|
+
const {
|
|
26
|
+
errorMessage
|
|
27
|
+
} = this.props
|
|
17
28
|
|
|
18
29
|
const {
|
|
19
30
|
text
|
|
@@ -23,7 +34,9 @@ export default class ErrorMessage extends Component {
|
|
|
23
34
|
}
|
|
24
35
|
|
|
25
36
|
getTextContent () {
|
|
26
|
-
const {
|
|
37
|
+
const {
|
|
38
|
+
errorMessage
|
|
39
|
+
} = this.props
|
|
27
40
|
|
|
28
41
|
const {
|
|
29
42
|
text
|
|
@@ -39,21 +52,21 @@ export default class ErrorMessage extends Component {
|
|
|
39
52
|
/**
|
|
40
53
|
* Merge latest `props` to `state`
|
|
41
54
|
*
|
|
42
|
-
* @param {
|
|
43
|
-
* @param {
|
|
44
|
-
* @returns {
|
|
55
|
+
* @param {ErrorMessageProps} props Latest props
|
|
56
|
+
* @param {ErrorMessageState} state Current state
|
|
57
|
+
* @returns {ErrorMessageState}
|
|
45
58
|
*/
|
|
46
59
|
static getDerivedStateFromProps ({ errorMessage }, { errorMessage: E }) {
|
|
47
60
|
return {
|
|
48
|
-
errorMessage: equal(
|
|
61
|
+
errorMessage: equal(errorMessage, E) ? E : errorMessage
|
|
49
62
|
}
|
|
50
63
|
}
|
|
51
64
|
|
|
52
65
|
/**
|
|
53
66
|
* Compare current and latest `state` for changes to `errorMessage`
|
|
54
67
|
*
|
|
55
|
-
* @param {
|
|
56
|
-
* @param {
|
|
68
|
+
* @param {ErrorMessageProps} props Latest props
|
|
69
|
+
* @param {ErrorMessageState} state Latest state
|
|
57
70
|
* @returns {boolean}
|
|
58
71
|
*/
|
|
59
72
|
shouldComponentUpdate (props, state) {
|
|
@@ -73,7 +86,9 @@ export default class ErrorMessage extends Component {
|
|
|
73
86
|
const textContent = this.getTextContent()
|
|
74
87
|
|
|
75
88
|
return (
|
|
76
|
-
<TextContent
|
|
89
|
+
<TextContent
|
|
90
|
+
textContent={textContent}
|
|
91
|
+
/>
|
|
77
92
|
)
|
|
78
93
|
}
|
|
79
94
|
|
|
@@ -81,7 +96,9 @@ export default class ErrorMessage extends Component {
|
|
|
81
96
|
}
|
|
82
97
|
|
|
83
98
|
render () {
|
|
84
|
-
const {
|
|
99
|
+
const {
|
|
100
|
+
errorMessage
|
|
101
|
+
} = this.props
|
|
85
102
|
|
|
86
103
|
if (errorMessage) {
|
|
87
104
|
return (
|
|
@@ -98,7 +115,7 @@ export default class ErrorMessage extends Component {
|
|
|
98
115
|
ErrorMessage.propTypes = {
|
|
99
116
|
errorMessage: PropTypes.shape({
|
|
100
117
|
type: PropTypes.string.isRequired,
|
|
101
|
-
params: PropTypes.shape().isRequired,
|
|
118
|
+
params: PropTypes.shape({}).isRequired,
|
|
102
119
|
uri: PropTypes.string.isRequired
|
|
103
120
|
})
|
|
104
121
|
}
|
|
@@ -1,23 +1,38 @@
|
|
|
1
1
|
declare module '#cogs/components/field' {
|
|
2
|
-
import React from 'react'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
fieldRef: object
|
|
2
|
+
import React, { type ChangeEvent, type MouseEvent } from 'react'
|
|
3
|
+
|
|
4
|
+
type FieldProps = CogsTypes.Components.Field.FieldProps
|
|
5
|
+
type ValueProps = CogsTypes.Components.Field.ValueProps
|
|
6
|
+
type CheckProps = CogsTypes.Components.Field.CheckProps
|
|
7
|
+
|
|
8
|
+
export default class Field<P extends FieldProps> extends React.Component<P> {
|
|
9
|
+
static propTypes: object
|
|
10
|
+
|
|
11
|
+
getClassName (): string
|
|
12
|
+
|
|
13
|
+
shouldComponentUpdate (props: FieldProps): boolean
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
export
|
|
16
|
+
export class ValueField<P extends ValueProps> extends Field<P> {
|
|
17
|
+
shouldComponentUpdate (props: ValueProps): boolean
|
|
18
|
+
|
|
19
|
+
handleChange (event: ChangeEvent<HTMLTextAreaElement> | ChangeEvent<HTMLInputElement>): void
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class CheckField<P extends CheckProps> extends Field<P> {
|
|
23
|
+
shouldComponentUpdate (props: CheckProps): boolean
|
|
24
|
+
|
|
25
|
+
handleChange (event: ChangeEvent<HTMLInputElement>): void
|
|
26
|
+
|
|
27
|
+
handleClick (event: MouseEvent<HTMLInputElement>): void
|
|
28
|
+
}
|
|
18
29
|
}
|
|
19
30
|
|
|
20
31
|
declare module 'shinkansen-cogs/components/field' {
|
|
32
|
+
export type FieldProps = CogsTypes.Components.Field.FieldProps
|
|
33
|
+
export type ValueProps = CogsTypes.Components.Field.ValueProps
|
|
34
|
+
export type CheckProps = CogsTypes.Components.Field.CheckProps
|
|
35
|
+
|
|
21
36
|
export { default } from '#cogs/components/field'
|
|
22
37
|
export * from '#cogs/components/field'
|
|
23
38
|
}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {CogsTypes.Components.Field.FieldProps} FieldProps
|
|
3
|
+
* @typedef {CogsTypes.Components.Field.ValueProps} ValueProps
|
|
4
|
+
* @typedef {CogsTypes.Components.Field.CheckProps} CheckProps
|
|
5
|
+
*/
|
|
6
|
+
|
|
1
7
|
/**
|
|
2
8
|
* Field component
|
|
3
9
|
*/
|
|
@@ -14,7 +20,11 @@ export default class Field extends Component {
|
|
|
14
20
|
return 'input'
|
|
15
21
|
}
|
|
16
22
|
|
|
17
|
-
|
|
23
|
+
/**
|
|
24
|
+
* @param {FieldProps} props
|
|
25
|
+
* @returns {boolean}
|
|
26
|
+
*/
|
|
27
|
+
shouldComponentUpdate (props) {
|
|
18
28
|
return (
|
|
19
29
|
(props.id !== this.props.id) ||
|
|
20
30
|
(props.required !== this.props.required) ||
|
|
@@ -66,7 +76,7 @@ Field.propTypes = {
|
|
|
66
76
|
placeholder: PropTypes.string,
|
|
67
77
|
onChange: PropTypes.func,
|
|
68
78
|
fieldRef: PropTypes.shape({
|
|
69
|
-
current: PropTypes.shape().isRequired
|
|
79
|
+
current: PropTypes.shape({}).isRequired
|
|
70
80
|
})
|
|
71
81
|
}
|
|
72
82
|
|
|
@@ -74,19 +84,27 @@ Field.propTypes = {
|
|
|
74
84
|
* ValueField component
|
|
75
85
|
*/
|
|
76
86
|
export class ValueField extends Field {
|
|
77
|
-
|
|
87
|
+
/**
|
|
88
|
+
* @param {ValueProps} props
|
|
89
|
+
* @returns {boolean}
|
|
90
|
+
*/
|
|
91
|
+
shouldComponentUpdate (props) {
|
|
78
92
|
return (
|
|
79
|
-
super.shouldComponentUpdate(props, state) ||
|
|
93
|
+
super.shouldComponentUpdate(props) || // }, state) ||
|
|
80
94
|
(props.value !== this.props.value)
|
|
81
95
|
)
|
|
82
96
|
}
|
|
83
97
|
|
|
98
|
+
/**
|
|
99
|
+
* @param {{ target: { value?: string } }} event
|
|
100
|
+
*/
|
|
84
101
|
handleChange = ({ target: { value } }) => {
|
|
85
102
|
const {
|
|
86
|
-
onChange = DEFAULT_HANDLE_CHANGE
|
|
103
|
+
onChange = DEFAULT_HANDLE_CHANGE,
|
|
104
|
+
name
|
|
87
105
|
} = this.props
|
|
88
106
|
|
|
89
|
-
onChange(value)
|
|
107
|
+
onChange(name, value)
|
|
90
108
|
}
|
|
91
109
|
}
|
|
92
110
|
|
|
@@ -100,34 +118,56 @@ ValueField.propTypes = {
|
|
|
100
118
|
* CheckField component
|
|
101
119
|
*/
|
|
102
120
|
export class CheckField extends Field {
|
|
103
|
-
|
|
121
|
+
/**
|
|
122
|
+
* @param {CheckProps} props
|
|
123
|
+
* @returns {boolean}
|
|
124
|
+
*/
|
|
125
|
+
shouldComponentUpdate (props) {
|
|
126
|
+
const {
|
|
127
|
+
value,
|
|
128
|
+
defaultChecked,
|
|
129
|
+
checked,
|
|
130
|
+
onClick,
|
|
131
|
+
...superProps
|
|
132
|
+
} = props
|
|
133
|
+
|
|
104
134
|
return (
|
|
105
|
-
super.shouldComponentUpdate(
|
|
106
|
-
(
|
|
107
|
-
(
|
|
108
|
-
(
|
|
135
|
+
super.shouldComponentUpdate(superProps) ||
|
|
136
|
+
(value !== this.props.value) ||
|
|
137
|
+
(checked !== this.props.checked) ||
|
|
138
|
+
(defaultChecked !== this.props.defaultChecked) ||
|
|
139
|
+
(onClick !== this.props.onClick)
|
|
109
140
|
)
|
|
110
141
|
}
|
|
111
142
|
|
|
112
|
-
|
|
143
|
+
/**
|
|
144
|
+
* @param {{ target: { value?: string, checked?: boolean } }} event
|
|
145
|
+
*/
|
|
146
|
+
handleChange = ({ target: { value, checked } }) => {
|
|
113
147
|
const {
|
|
114
|
-
|
|
148
|
+
onChange = DEFAULT_HANDLE_CHANGE,
|
|
149
|
+
name
|
|
115
150
|
} = this.props
|
|
116
151
|
|
|
117
|
-
|
|
152
|
+
onChange(name, value, checked)
|
|
118
153
|
}
|
|
119
154
|
|
|
120
|
-
|
|
155
|
+
/**
|
|
156
|
+
* @param {{ target: { value?: string, checked?: boolean } }} event
|
|
157
|
+
*/
|
|
158
|
+
handleClick = ({ target: { value, checked } }) => {
|
|
121
159
|
const {
|
|
122
|
-
|
|
160
|
+
onClick = DEFAULT_HANDLE_CLICK,
|
|
161
|
+
name
|
|
123
162
|
} = this.props
|
|
124
163
|
|
|
125
|
-
|
|
164
|
+
onClick(name, value, checked)
|
|
126
165
|
}
|
|
127
166
|
}
|
|
128
167
|
|
|
129
168
|
CheckField.propTypes = {
|
|
130
169
|
...Field.propTypes,
|
|
170
|
+
value: PropTypes.string,
|
|
131
171
|
checked: PropTypes.bool,
|
|
132
172
|
defaultChecked: PropTypes.bool,
|
|
133
173
|
onClick: PropTypes.func
|
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
declare module '#cogs/components/title' {
|
|
2
2
|
import React from 'react'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
type TitleProps = CogsTypes.Components.Title.TitleProps
|
|
5
|
+
|
|
6
|
+
export default class Title<P extends TitleProps> extends React.Component<P> {
|
|
7
|
+
static propTypes: object
|
|
8
|
+
|
|
9
|
+
isRequired (): boolean
|
|
10
|
+
|
|
11
|
+
isDisabled (): boolean
|
|
12
|
+
|
|
13
|
+
isReadOnly (): boolean
|
|
14
|
+
|
|
15
|
+
getClassName (): string
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
shouldComponentUpdate (props: TitleProps): boolean
|
|
18
|
+
|
|
19
|
+
renderIsRequired (): React.JSX.Element | null
|
|
20
|
+
|
|
21
|
+
renderIsDisabled (): React.JSX.Element | null
|
|
22
|
+
|
|
23
|
+
renderIsReadOnly (): React.JSX.Element | null
|
|
24
|
+
}
|
|
14
25
|
}
|
|
15
26
|
|
|
16
27
|
declare module 'shinkansen-cogs/components/title' {
|
|
28
|
+
export type TitleProps = CogsTypes.Components.Title.TitleProps
|
|
29
|
+
|
|
17
30
|
export { default } from '#cogs/components/title'
|
|
18
|
-
export * from '#cogs/components/title'
|
|
19
31
|
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {CogsTypes.Components.Title.TitleProps} TitleProps
|
|
3
|
+
*/
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* Title component
|
|
3
7
|
*/
|
|
@@ -38,7 +42,11 @@ export default class Title extends Component {
|
|
|
38
42
|
return 'title'
|
|
39
43
|
}
|
|
40
44
|
|
|
41
|
-
|
|
45
|
+
/**
|
|
46
|
+
* @param {TitleProps} props
|
|
47
|
+
* @returns {boolean}
|
|
48
|
+
*/
|
|
49
|
+
shouldComponentUpdate (props) {
|
|
42
50
|
return (
|
|
43
51
|
(props.id !== this.props.id) ||
|
|
44
52
|
(props.title !== this.props.title) ||
|
|
@@ -80,7 +88,9 @@ export default class Title extends Component {
|
|
|
80
88
|
}
|
|
81
89
|
|
|
82
90
|
render () {
|
|
83
|
-
const {
|
|
91
|
+
const {
|
|
92
|
+
title
|
|
93
|
+
} = this.props
|
|
84
94
|
|
|
85
95
|
if (title) {
|
|
86
96
|
const { id } = this.props
|
package/src/index.d.mts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
declare module '#cogs/transformers/error-message' {
|
|
2
2
|
export default function transform (error: CogsTypes.ErrorDefinitionType): CogsTypes.FieldErrorType
|
|
3
3
|
}
|
|
4
|
+
|
|
5
|
+
declare module 'shinkansen-cogs/transformers/error-message' {
|
|
6
|
+
export type ErrorDefinitionType = CogsTypes.ErrorDefinitionType
|
|
7
|
+
|
|
8
|
+
export type FieldErrorType = CogsTypes.FieldErrorType
|
|
9
|
+
|
|
10
|
+
export { default } from '#cogs/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
|
-
*
|
|
225
|
-
*
|
|
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
|
-
*
|
|
235
|
-
*
|
|
242
|
+
* @param {CogsTypes.ErrorDefinitionType} error
|
|
243
|
+
* @returns {CogsTypes.FieldErrorType}
|
|
236
244
|
*/
|
|
237
245
|
export default function transform (error) {
|
|
238
246
|
log('transform')
|