shinkansen-cogs 1.8.20 → 1.9.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/eslint.config.mjs +16 -3
- package/index.d.mts +116 -104
- package/package.json +38 -7
- package/src/cogs/checkbox/description/index.cjs +5 -2
- package/src/cogs/checkbox/description/index.jsx +1 -1
- package/src/cogs/checkbox/error-message/index.cjs +5 -2
- package/src/cogs/checkbox/error-message/index.jsx +1 -1
- package/src/cogs/checkbox/field/index.cjs +5 -2
- package/src/cogs/checkbox/field/index.jsx +1 -1
- package/src/cogs/checkbox/index.cjs +5 -2
- package/src/cogs/checkbox/index.d.mts +1 -1
- package/src/cogs/checkbox/index.jsx +13 -10
- package/src/cogs/checkbox/title/index.cjs +5 -2
- package/src/cogs/checkbox/title/index.jsx +2 -2
- package/src/cogs/email/description/index.cjs +5 -2
- package/src/cogs/email/description/index.jsx +1 -1
- package/src/cogs/email/error-message/index.cjs +5 -2
- package/src/cogs/email/error-message/index.jsx +1 -1
- package/src/cogs/email/field/index.cjs +5 -2
- package/src/cogs/email/field/index.jsx +1 -1
- package/src/cogs/email/index.cjs +5 -2
- package/src/cogs/email/index.d.mts +1 -1
- package/src/cogs/email/index.jsx +12 -8
- package/src/cogs/email/title/index.cjs +5 -2
- package/src/cogs/email/title/index.jsx +2 -2
- package/src/cogs/index.cjs +7 -5
- package/src/cogs/index.d.cts +0 -1
- package/src/cogs/index.d.mts +4 -23
- package/src/cogs/index.jsx +22 -169
- package/src/cogs/number/description/index.cjs +5 -2
- package/src/cogs/number/description/index.jsx +1 -1
- package/src/cogs/number/error-message/index.cjs +5 -2
- package/src/cogs/number/error-message/index.jsx +1 -1
- package/src/cogs/number/field/index.cjs +5 -2
- package/src/cogs/number/field/index.jsx +1 -1
- package/src/cogs/number/index.cjs +5 -2
- package/src/cogs/number/index.d.mts +1 -1
- package/src/cogs/number/index.jsx +12 -8
- package/src/cogs/number/title/index.cjs +5 -2
- package/src/cogs/number/title/index.jsx +2 -2
- package/src/cogs/password/description/index.cjs +5 -2
- package/src/cogs/password/description/index.jsx +1 -1
- package/src/cogs/password/error-message/index.cjs +5 -2
- package/src/cogs/password/error-message/index.jsx +1 -1
- package/src/cogs/password/field/index.cjs +5 -2
- package/src/cogs/password/field/index.jsx +1 -1
- package/src/cogs/password/index.cjs +5 -2
- package/src/cogs/password/index.d.mts +1 -1
- package/src/cogs/password/index.jsx +12 -8
- package/src/cogs/password/title/index.cjs +5 -2
- package/src/cogs/password/title/index.jsx +2 -2
- package/src/cogs/radio/description/index.cjs +5 -2
- package/src/cogs/radio/description/index.jsx +1 -1
- package/src/cogs/radio/error-message/index.cjs +5 -2
- package/src/cogs/radio/error-message/index.jsx +1 -1
- package/src/cogs/radio/field/index.cjs +5 -2
- package/src/cogs/radio/field/index.jsx +1 -1
- package/src/cogs/radio/index.cjs +5 -2
- package/src/cogs/radio/index.d.mts +1 -1
- package/src/cogs/radio/index.jsx +13 -10
- package/src/cogs/radio/title/index.cjs +5 -2
- package/src/cogs/radio/title/index.jsx +2 -2
- package/src/cogs/select/description/index.cjs +5 -2
- package/src/cogs/select/description/index.jsx +1 -1
- package/src/cogs/select/error-message/index.cjs +5 -2
- package/src/cogs/select/error-message/index.jsx +1 -1
- package/src/cogs/select/field/index.cjs +5 -2
- package/src/cogs/select/field/index.jsx +9 -5
- package/src/cogs/select/index.cjs +5 -2
- package/src/cogs/select/index.d.mts +1 -1
- package/src/cogs/select/index.jsx +12 -8
- package/src/cogs/select/title/index.cjs +5 -2
- package/src/cogs/select/title/index.jsx +2 -2
- package/src/cogs/text/description/index.cjs +5 -2
- package/src/cogs/text/description/index.jsx +1 -1
- package/src/cogs/text/error-message/index.cjs +5 -2
- package/src/cogs/text/error-message/index.jsx +1 -1
- package/src/cogs/text/field/index.cjs +5 -2
- package/src/cogs/text/field/index.jsx +1 -1
- package/src/cogs/text/index.cjs +5 -2
- package/src/cogs/text/index.d.mts +1 -1
- package/src/cogs/text/index.jsx +12 -8
- package/src/cogs/text/title/index.cjs +5 -2
- package/src/cogs/text/title/index.jsx +2 -2
- package/src/cogs/textarea/description/index.cjs +5 -2
- package/src/cogs/textarea/description/index.jsx +1 -1
- package/src/cogs/textarea/error-message/index.cjs +5 -2
- package/src/cogs/textarea/error-message/index.jsx +1 -1
- package/src/cogs/textarea/field/index.cjs +5 -2
- package/src/cogs/textarea/field/index.jsx +1 -1
- package/src/cogs/textarea/index.cjs +5 -2
- package/src/cogs/textarea/index.d.mts +1 -1
- package/src/cogs/textarea/index.jsx +12 -8
- package/src/cogs/textarea/title/index.cjs +5 -2
- package/src/cogs/textarea/title/index.jsx +2 -2
- package/src/common/index.d.mts +1 -7
- package/src/common/index.mjs +1 -5
- package/src/components/common/disabled/index.cjs +5 -2
- package/src/components/common/readonly/index.cjs +5 -2
- package/src/components/common/required/index.cjs +5 -2
- package/src/components/common/text-content/index.cjs +5 -2
- package/src/components/common/text-content/index.jsx +1 -1
- package/src/components/description/index.cjs +5 -2
- package/src/components/description/index.d.mts +1 -1
- package/src/components/description/index.jsx +2 -44
- package/src/components/error-message/index.cjs +5 -2
- package/src/components/error-message/index.d.mts +2 -21
- package/src/components/error-message/index.jsx +2 -118
- package/src/components/field/index.cjs +9 -3
- package/src/components/field/index.d.cts +0 -1
- package/src/components/field/index.d.mts +3 -11
- package/src/components/field/index.jsx +18 -75
- package/src/components/index.cjs +25 -5
- package/src/components/index.d.cts +4 -4
- package/src/components/index.d.mts +4 -4
- package/src/components/index.mjs +4 -4
- package/src/components/title/index.cjs +2 -2
- package/src/components/title/index.d.mts +2 -23
- package/src/components/title/index.jsx +2 -118
- package/src/super/cogs/index.cjs +20 -0
- package/src/super/cogs/index.d.cts +2 -0
- package/src/super/cogs/index.d.mts +28 -0
- package/src/super/cogs/index.jsx +179 -0
- package/src/super/components/description/index.cjs +20 -0
- package/src/super/components/description/index.d.cts +2 -0
- package/src/super/components/description/index.d.mts +18 -0
- package/src/super/components/description/index.jsx +47 -0
- package/src/super/components/error-message/index.cjs +20 -0
- package/src/super/components/error-message/index.d.cts +2 -0
- package/src/super/components/error-message/index.d.mts +28 -0
- package/src/super/components/error-message/index.jsx +121 -0
- package/src/super/components/field/index.cjs +20 -0
- package/src/super/components/field/index.d.cts +2 -0
- package/src/super/components/field/index.d.mts +18 -0
- package/src/super/components/field/index.jsx +74 -0
- package/src/super/components/index.cjs +32 -0
- package/src/super/components/index.d.cts +4 -0
- package/src/super/components/index.d.mts +4 -0
- package/src/super/components/index.mjs +10 -0
- package/src/super/components/title/index.cjs +20 -0
- package/src/super/components/title/index.d.cts +2 -0
- package/src/super/components/title/index.d.mts +30 -0
- package/src/super/components/title/index.jsx +121 -0
|
@@ -11,7 +11,10 @@ const log = debug('shinkansen-cogs/cogs/textarea/field')
|
|
|
11
11
|
log('`shinkansen` is awake')
|
|
12
12
|
|
|
13
13
|
const {
|
|
14
|
-
default:
|
|
14
|
+
default: Field // @ts-expect-error
|
|
15
15
|
} = require('./index.jsx')
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Exports only default
|
|
19
|
+
*/
|
|
20
|
+
module.exports = Field
|
|
@@ -11,7 +11,10 @@ const log = debug('shinkansen-cogs/cogs/textarea')
|
|
|
11
11
|
log('`shinkansen` is awake')
|
|
12
12
|
|
|
13
13
|
const {
|
|
14
|
-
default:
|
|
14
|
+
default: Textarea // @ts-expect-error
|
|
15
15
|
} = require('./index.jsx')
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Exports only default
|
|
19
|
+
*/
|
|
20
|
+
module.exports = Textarea
|
|
@@ -3,7 +3,7 @@ declare module '#cogs/cogs/textarea' {
|
|
|
3
3
|
ValueCog
|
|
4
4
|
} from '#cogs/cogs'
|
|
5
5
|
|
|
6
|
-
export type TextareaProps = CogsTypes.Cogs.
|
|
6
|
+
export type TextareaProps = CogsTypes.Cogs.Textarea.TextareaProps
|
|
7
7
|
|
|
8
8
|
export default class TextareaCog<P extends TextareaProps> extends ValueCog<P> {
|
|
9
9
|
handleChange (
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {CogsTypes.
|
|
3
|
-
* @typedef {CogsTypes.Cogs.
|
|
2
|
+
* @typedef {CogsTypes.OnEventType} OnEventType
|
|
3
|
+
* @typedef {CogsTypes.Cogs.ValueProps} ValueProps
|
|
4
|
+
* @typedef {CogsTypes.Cogs.Textarea.TextareaProps} TextareaProps
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* TextareaCog component
|
|
8
9
|
*/
|
|
9
10
|
import React from 'react'
|
|
10
11
|
import classnames from 'classnames'
|
|
@@ -13,15 +14,18 @@ import {
|
|
|
13
14
|
ValueCog
|
|
14
15
|
} from '#cogs/cogs'
|
|
15
16
|
|
|
16
|
-
import {
|
|
17
|
-
DEFAULT_HANDLE_CHANGE
|
|
18
|
-
} from '#cogs/common'
|
|
19
|
-
|
|
20
17
|
import Title from '#cogs/cogs/textarea/title'
|
|
21
18
|
import Description from '#cogs/cogs/textarea/description'
|
|
22
19
|
import ErrorMessage from '#cogs/cogs/textarea/error-message'
|
|
23
20
|
import Field from '#cogs/cogs/textarea/field'
|
|
24
21
|
|
|
22
|
+
/**
|
|
23
|
+
* @type {OnEventType}
|
|
24
|
+
*/
|
|
25
|
+
function DEFAULT_HANDLE_EVENT () {
|
|
26
|
+
//
|
|
27
|
+
}
|
|
28
|
+
|
|
25
29
|
/**
|
|
26
30
|
* @extends {ValueCog<ValueProps & TextareaProps>}
|
|
27
31
|
*/
|
|
@@ -36,7 +40,7 @@ export default class TextareaCog extends ValueCog {
|
|
|
36
40
|
*/
|
|
37
41
|
handleChange = (name, value) => {
|
|
38
42
|
const {
|
|
39
|
-
onChange =
|
|
43
|
+
onChange = DEFAULT_HANDLE_EVENT
|
|
40
44
|
} = this.props
|
|
41
45
|
|
|
42
46
|
onChange(name, value)
|
|
@@ -11,7 +11,10 @@ const log = debug('shinkansen-cogs/cogs/textarea/title')
|
|
|
11
11
|
log('`shinkansen` is awake')
|
|
12
12
|
|
|
13
13
|
const {
|
|
14
|
-
default:
|
|
14
|
+
default: Title // @ts-expect-error
|
|
15
15
|
} = require('./index.jsx')
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Exports only default
|
|
19
|
+
*/
|
|
20
|
+
module.exports = Title
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {CogsTypes.Components.Title.TitleProps} TitleProps
|
|
2
|
+
* @typedef {CogsTypes.Super.Components.Title.TitleProps} TitleProps
|
|
3
3
|
* @typedef {CogsTypes.Components.Title.Textarea.TextareaProps} TextareaProps
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* TextareaTitle component
|
|
8
8
|
*/
|
|
9
9
|
import classnames from 'classnames'
|
|
10
10
|
import Title from '#cogs/components/title'
|
package/src/common/index.d.mts
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
export function
|
|
2
|
-
name: string,
|
|
3
|
-
value?: string | string[],
|
|
4
|
-
checked?: boolean
|
|
5
|
-
): void
|
|
6
|
-
|
|
7
|
-
export function DEFAULT_HANDLE_CLICK (
|
|
1
|
+
export function DEFAULT_HANDLE_EVENT (
|
|
8
2
|
name: string,
|
|
9
3
|
value?: string | string[],
|
|
10
4
|
checked?: boolean
|
package/src/common/index.mjs
CHANGED
|
@@ -11,7 +11,10 @@ const log = debug('shinkansen-cogs/components/common/disabled')
|
|
|
11
11
|
log('`shinkansen` is awake')
|
|
12
12
|
|
|
13
13
|
const {
|
|
14
|
-
default:
|
|
14
|
+
default: Disabled // @ts-expect-error
|
|
15
15
|
} = require('./index.jsx')
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Exports only default
|
|
19
|
+
*/
|
|
20
|
+
module.exports = Disabled
|
|
@@ -11,7 +11,10 @@ const log = debug('shinkansen-cogs/components/common/readonly')
|
|
|
11
11
|
log('`shinkansen` is awake')
|
|
12
12
|
|
|
13
13
|
const {
|
|
14
|
-
default:
|
|
14
|
+
default: ReadOnly // @ts-expect-error
|
|
15
15
|
} = require('./index.jsx')
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Exports only default
|
|
19
|
+
*/
|
|
20
|
+
module.exports = ReadOnly
|
|
@@ -11,7 +11,10 @@ const log = debug('shinkansen-cogs/components/common/readonly')
|
|
|
11
11
|
log('`shinkansen` is awake')
|
|
12
12
|
|
|
13
13
|
const {
|
|
14
|
-
default:
|
|
14
|
+
default: Required // @ts-expect-error
|
|
15
15
|
} = require('./index.jsx')
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Exports only default
|
|
19
|
+
*/
|
|
20
|
+
module.exports = Required
|
|
@@ -11,7 +11,10 @@ const log = debug('shinkansen-cogs/components/common/text-content')
|
|
|
11
11
|
log('`shinkansen` is awake')
|
|
12
12
|
|
|
13
13
|
const {
|
|
14
|
-
default:
|
|
14
|
+
default: TextComponent // @ts-expect-error
|
|
15
15
|
} = require('./index.jsx')
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Exports only default
|
|
19
|
+
*/
|
|
20
|
+
module.exports = TextComponent
|
|
@@ -11,7 +11,10 @@ const log = debug('shinkansen-cogs/components/description')
|
|
|
11
11
|
log('`shinkansen` is awake')
|
|
12
12
|
|
|
13
13
|
const {
|
|
14
|
-
default:
|
|
14
|
+
default: Description // @ts-expect-error
|
|
15
15
|
} = require('./index.jsx')
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Exports only default
|
|
19
|
+
*/
|
|
20
|
+
module.exports = Description
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare module '#cogs/components/description' {
|
|
2
2
|
import React from 'react'
|
|
3
3
|
|
|
4
|
-
export type DescriptionProps = CogsTypes.Components.Description.DescriptionProps
|
|
4
|
+
export type DescriptionProps = CogsTypes.Super.Components.Description.DescriptionProps
|
|
5
5
|
|
|
6
6
|
export default class Description extends React.Component<DescriptionProps> {
|
|
7
7
|
static propTypes: object
|
|
@@ -1,47 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Description component
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
* Description component
|
|
7
|
-
*/
|
|
8
|
-
import React, { Component } from 'react'
|
|
9
|
-
import PropTypes from 'prop-types'
|
|
10
|
-
|
|
11
|
-
import TextContent from '#cogs/components/common/text-content'
|
|
12
|
-
|
|
13
|
-
export default class Description extends Component {
|
|
14
|
-
getClassName () {
|
|
15
|
-
return 'description'
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @param {DescriptionProps} props
|
|
20
|
-
* @returns {boolean}
|
|
21
|
-
*/
|
|
22
|
-
shouldComponentUpdate (props) {
|
|
23
|
-
return (
|
|
24
|
-
(props.description !== this.props.description)
|
|
25
|
-
)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
render () {
|
|
29
|
-
const {
|
|
30
|
-
description
|
|
31
|
-
} = this.props
|
|
32
|
-
|
|
33
|
-
if (description) {
|
|
34
|
-
return (
|
|
35
|
-
<span className={this.getClassName()}>
|
|
36
|
-
<TextContent textContent={description} />
|
|
37
|
-
</span>
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return null
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
Description.propTypes = {
|
|
46
|
-
description: PropTypes.string
|
|
47
|
-
}
|
|
5
|
+
export { default } from '#cogs/super/components/description'
|
|
@@ -11,7 +11,10 @@ const log = debug('shinkansen-cogs/components/error-message')
|
|
|
11
11
|
log('`shinkansen` is awake')
|
|
12
12
|
|
|
13
13
|
const {
|
|
14
|
-
default:
|
|
14
|
+
default: ErrorMessage // @ts-expect-error
|
|
15
15
|
} = require('./index.jsx')
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Exports only default
|
|
19
|
+
*/
|
|
20
|
+
module.exports = ErrorMessage
|
|
@@ -1,25 +1,6 @@
|
|
|
1
1
|
declare module '#cogs/components/error-message' {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export type ErrorDefinitionType = CogsTypes.ErrorDefinitionType
|
|
5
|
-
export type ErrorMessageProps = CogsTypes.Components.ErrorMessage.ErrorMessageProps
|
|
6
|
-
export type ErrorMessageState = CogsTypes.Components.ErrorMessage.ErrorMessageState
|
|
7
|
-
|
|
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
|
-
}
|
|
2
|
+
export { default } from '#cogs/super/components/error-message'
|
|
3
|
+
export * from '#cogs/super/components/error-message'
|
|
23
4
|
}
|
|
24
5
|
|
|
25
6
|
declare module 'shinkansen-cogs/components/error-message' {
|
|
@@ -1,121 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @typedef {CogsTypes.Components.ErrorMessage.ErrorMessageProps} ErrorMessageProps
|
|
4
|
-
* @typedef {CogsTypes.Components.ErrorMessage.ErrorMessageState} ErrorMessageState
|
|
2
|
+
* ErrorMessage component
|
|
5
3
|
*/
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
* ErrorMessage component
|
|
9
|
-
*/
|
|
10
|
-
import React, { Component } from 'react'
|
|
11
|
-
import PropTypes from 'prop-types'
|
|
12
|
-
import equal from 'fast-deep-equal'
|
|
13
|
-
|
|
14
|
-
import transform from '#cogs/transformers/error-message'
|
|
15
|
-
|
|
16
|
-
import TextContent from '#cogs/components/common/text-content'
|
|
17
|
-
|
|
18
|
-
export default class ErrorMessage extends Component {
|
|
19
|
-
/**
|
|
20
|
-
* @type {ErrorMessageState}
|
|
21
|
-
*/
|
|
22
|
-
state = {}
|
|
23
|
-
|
|
24
|
-
hasTextContent () {
|
|
25
|
-
const {
|
|
26
|
-
errorMessage
|
|
27
|
-
} = this.props
|
|
28
|
-
|
|
29
|
-
const {
|
|
30
|
-
text
|
|
31
|
-
} = transform(errorMessage)
|
|
32
|
-
|
|
33
|
-
return !!text
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
getTextContent () {
|
|
37
|
-
const {
|
|
38
|
-
errorMessage
|
|
39
|
-
} = this.props
|
|
40
|
-
|
|
41
|
-
const {
|
|
42
|
-
text
|
|
43
|
-
} = transform(errorMessage)
|
|
44
|
-
|
|
45
|
-
return text
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
getClassName () {
|
|
49
|
-
return 'error-message'
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Merge latest `props` to `state`
|
|
54
|
-
*
|
|
55
|
-
* @param {ErrorMessageProps} props Latest props
|
|
56
|
-
* @param {ErrorMessageState} state Current state
|
|
57
|
-
* @returns {ErrorMessageState}
|
|
58
|
-
*/
|
|
59
|
-
static getDerivedStateFromProps ({ errorMessage }, { errorMessage: E }) {
|
|
60
|
-
return {
|
|
61
|
-
errorMessage: equal(errorMessage, E) ? E : errorMessage
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Compare current and latest `state` for changes to `errorMessage`
|
|
67
|
-
*
|
|
68
|
-
* @param {ErrorMessageProps} props Latest props
|
|
69
|
-
* @param {ErrorMessageState} state Latest state
|
|
70
|
-
* @returns {boolean}
|
|
71
|
-
*/
|
|
72
|
-
shouldComponentUpdate (props, state) {
|
|
73
|
-
const {
|
|
74
|
-
errorMessage: e
|
|
75
|
-
} = state
|
|
76
|
-
|
|
77
|
-
const {
|
|
78
|
-
errorMessage: E
|
|
79
|
-
} = this.state
|
|
80
|
-
|
|
81
|
-
return !equal(E, e)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
renderTextContent () {
|
|
85
|
-
if (this.hasTextContent()) {
|
|
86
|
-
const textContent = this.getTextContent()
|
|
87
|
-
|
|
88
|
-
return (
|
|
89
|
-
<TextContent
|
|
90
|
-
textContent={textContent}
|
|
91
|
-
/>
|
|
92
|
-
)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return null
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
render () {
|
|
99
|
-
const {
|
|
100
|
-
errorMessage
|
|
101
|
-
} = this.props
|
|
102
|
-
|
|
103
|
-
if (errorMessage) {
|
|
104
|
-
return (
|
|
105
|
-
<span className={this.getClassName()}>
|
|
106
|
-
{this.renderTextContent()}
|
|
107
|
-
</span>
|
|
108
|
-
)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return null
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
ErrorMessage.propTypes = {
|
|
116
|
-
errorMessage: PropTypes.shape({
|
|
117
|
-
type: PropTypes.string.isRequired,
|
|
118
|
-
params: PropTypes.shape({}).isRequired,
|
|
119
|
-
uri: PropTypes.string.isRequired
|
|
120
|
-
})
|
|
121
|
-
}
|
|
5
|
+
export { default } from '#cogs/super/components/error-message'
|
|
@@ -10,7 +10,13 @@ const log = debug('shinkansen-cogs/components/field')
|
|
|
10
10
|
|
|
11
11
|
log('`shinkansen` is awake')
|
|
12
12
|
|
|
13
|
+
const {
|
|
14
|
+
ValueField,
|
|
15
|
+
CheckField // @ts-expect-error
|
|
16
|
+
} = require('./index.jsx')
|
|
17
|
+
|
|
13
18
|
/**
|
|
14
|
-
* Exports
|
|
15
|
-
*/
|
|
16
|
-
module.exports =
|
|
19
|
+
* Exports ValueField and CheckField
|
|
20
|
+
*/
|
|
21
|
+
module.exports.ValueField = ValueField
|
|
22
|
+
module.exports.CheckField = CheckField
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
declare module '#cogs/components/field' {
|
|
2
|
-
import
|
|
2
|
+
import type { ChangeEvent, MouseEvent } from 'react'
|
|
3
|
+
|
|
4
|
+
import Field from '#cogs/super/components/field'
|
|
3
5
|
|
|
4
|
-
export type FieldProps = CogsTypes.Components.Field.FieldProps
|
|
5
6
|
export type ValueProps = CogsTypes.Components.Field.ValueProps
|
|
6
7
|
export type CheckProps = CogsTypes.Components.Field.CheckProps
|
|
7
8
|
|
|
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
|
|
14
|
-
}
|
|
15
|
-
|
|
16
9
|
export class ValueField<P extends ValueProps> extends Field<P> {
|
|
17
10
|
shouldComponentUpdate (props: ValueProps): boolean
|
|
18
11
|
|
|
@@ -29,6 +22,5 @@ declare module '#cogs/components/field' {
|
|
|
29
22
|
}
|
|
30
23
|
|
|
31
24
|
declare module 'shinkansen-cogs/components/field' {
|
|
32
|
-
export { default } from '#cogs/components/field'
|
|
33
25
|
export * from '#cogs/components/field'
|
|
34
26
|
}
|
|
@@ -1,87 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {CogsTypes.
|
|
2
|
+
* @typedef {CogsTypes.OnEventType} OnEventType
|
|
3
|
+
* @typedef {CogsTypes.Super.Components.Field.FieldProps} FieldProps
|
|
3
4
|
* @typedef {CogsTypes.Components.Field.ValueProps} ValueProps
|
|
4
5
|
* @typedef {CogsTypes.Components.Field.CheckProps} CheckProps
|
|
5
6
|
*/
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
+
* Field component
|
|
9
10
|
*/
|
|
10
|
-
import React, { Component } from 'react'
|
|
11
11
|
import PropTypes from 'prop-types'
|
|
12
12
|
|
|
13
|
-
import
|
|
14
|
-
DEFAULT_HANDLE_CHANGE,
|
|
15
|
-
DEFAULT_HANDLE_CLICK
|
|
16
|
-
} from '#cogs/common'
|
|
13
|
+
import Field from '#cogs/super/components/field'
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @param {FieldProps} props
|
|
25
|
-
* @returns {boolean}
|
|
26
|
-
*/
|
|
27
|
-
shouldComponentUpdate (props) {
|
|
28
|
-
return (
|
|
29
|
-
(props.id !== this.props.id) ||
|
|
30
|
-
(props.required !== this.props.required) ||
|
|
31
|
-
(props.disabled !== this.props.disabled) ||
|
|
32
|
-
(props.readOnly !== this.props.readOnly) ||
|
|
33
|
-
(props.tabIndex !== this.props.tabIndex) ||
|
|
34
|
-
(props.accessKey !== this.props.accessKey) ||
|
|
35
|
-
(props.placeholder !== this.props.placeholder) ||
|
|
36
|
-
(props.onChange !== this.props.onChange)
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
render () {
|
|
41
|
-
const {
|
|
42
|
-
id,
|
|
43
|
-
required = false,
|
|
44
|
-
disabled = false,
|
|
45
|
-
readOnly = false,
|
|
46
|
-
tabIndex,
|
|
47
|
-
accessKey,
|
|
48
|
-
placeholder,
|
|
49
|
-
fieldRef
|
|
50
|
-
} = this.props
|
|
51
|
-
|
|
52
|
-
return (
|
|
53
|
-
<input
|
|
54
|
-
id={id}
|
|
55
|
-
required={required}
|
|
56
|
-
disabled={disabled}
|
|
57
|
-
readOnly={readOnly}
|
|
58
|
-
tabIndex={tabIndex}
|
|
59
|
-
accessKey={accessKey}
|
|
60
|
-
placeholder={placeholder}
|
|
61
|
-
className={this.getClassName()}
|
|
62
|
-
ref={fieldRef}
|
|
63
|
-
/>
|
|
64
|
-
)
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
Field.propTypes = {
|
|
69
|
-
id: PropTypes.string,
|
|
70
|
-
name: PropTypes.string.isRequired,
|
|
71
|
-
required: PropTypes.bool,
|
|
72
|
-
disabled: PropTypes.bool,
|
|
73
|
-
readOnly: PropTypes.bool,
|
|
74
|
-
tabIndex: PropTypes.number,
|
|
75
|
-
accessKey: PropTypes.string,
|
|
76
|
-
placeholder: PropTypes.string,
|
|
77
|
-
onChange: PropTypes.func,
|
|
78
|
-
fieldRef: PropTypes.shape({
|
|
79
|
-
current: PropTypes.shape({}).isRequired
|
|
80
|
-
})
|
|
15
|
+
/**
|
|
16
|
+
* @type {OnEventType}
|
|
17
|
+
*/
|
|
18
|
+
function DEFAULT_HANDLE_EVENT () {
|
|
19
|
+
//
|
|
81
20
|
}
|
|
82
21
|
|
|
83
22
|
/**
|
|
84
|
-
*
|
|
23
|
+
* ValueField component
|
|
24
|
+
*
|
|
25
|
+
* @extends {Field<FieldProps & ValueProps>}
|
|
85
26
|
*/
|
|
86
27
|
export class ValueField extends Field {
|
|
87
28
|
/**
|
|
@@ -100,7 +41,7 @@ export class ValueField extends Field {
|
|
|
100
41
|
*/
|
|
101
42
|
handleChange = ({ target: { value } }) => {
|
|
102
43
|
const {
|
|
103
|
-
onChange =
|
|
44
|
+
onChange = DEFAULT_HANDLE_EVENT,
|
|
104
45
|
name
|
|
105
46
|
} = this.props
|
|
106
47
|
|
|
@@ -115,7 +56,9 @@ ValueField.propTypes = {
|
|
|
115
56
|
}
|
|
116
57
|
|
|
117
58
|
/**
|
|
118
|
-
*
|
|
59
|
+
* CheckField component
|
|
60
|
+
*
|
|
61
|
+
* @extends {Field<FieldProps & CheckProps>}
|
|
119
62
|
*/
|
|
120
63
|
export class CheckField extends Field {
|
|
121
64
|
/**
|
|
@@ -145,7 +88,7 @@ export class CheckField extends Field {
|
|
|
145
88
|
*/
|
|
146
89
|
handleChange = ({ target: { value, checked } }) => {
|
|
147
90
|
const {
|
|
148
|
-
onChange =
|
|
91
|
+
onChange = DEFAULT_HANDLE_EVENT,
|
|
149
92
|
name
|
|
150
93
|
} = this.props
|
|
151
94
|
|
|
@@ -157,7 +100,7 @@ export class CheckField extends Field {
|
|
|
157
100
|
*/
|
|
158
101
|
handleClick = ({ target: { value, checked } }) => {
|
|
159
102
|
const {
|
|
160
|
-
onClick =
|
|
103
|
+
onClick = DEFAULT_HANDLE_EVENT,
|
|
161
104
|
name
|
|
162
105
|
} = this.props
|
|
163
106
|
|
package/src/components/index.cjs
CHANGED
|
@@ -6,11 +6,31 @@ require('@babel/register')({
|
|
|
6
6
|
|
|
7
7
|
const debug = require('debug')
|
|
8
8
|
|
|
9
|
-
const log = debug('shinkansen-
|
|
9
|
+
const log = debug('shinkansen-cogs/components')
|
|
10
10
|
|
|
11
11
|
log('`shinkansen` is awake')
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const {
|
|
14
|
+
default: Description // @ts-expect-error
|
|
15
|
+
} = require('./description/index.jsx')
|
|
16
|
+
|
|
17
|
+
const {
|
|
18
|
+
default: ErrorMessage // @ts-expect-error
|
|
19
|
+
} = require('./error-message/index.jsx')
|
|
20
|
+
|
|
21
|
+
const {
|
|
22
|
+
ValueField,
|
|
23
|
+
CheckField // @ts-expect-error
|
|
24
|
+
} = require('./field/index.jsx')
|
|
25
|
+
|
|
26
|
+
const {
|
|
27
|
+
default: Title // @ts-expect-error
|
|
28
|
+
} = require('./title/index.jsx')
|
|
29
|
+
|
|
30
|
+
module.exports.Description = Description // require('./description/index.cjs')
|
|
31
|
+
module.exports.ErrorMessage = ErrorMessage // require('./error-message/index.cjs')
|
|
32
|
+
module.exports.Field = {
|
|
33
|
+
ValueField,
|
|
34
|
+
CheckField
|
|
35
|
+
} // require('./field/index.cjs')
|
|
36
|
+
module.exports.Title = Title // require('./title/index.cjs')
|