@modernpoacher/gremlins 0.0.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.
- package/README.md +5 -0
- package/babel.config.cjs +106 -0
- package/package.json +139 -0
- package/src/components/common/disabled/index.cjs +17 -0
- package/src/components/common/disabled/index.jsx +9 -0
- package/src/components/common/readonly/index.cjs +17 -0
- package/src/components/common/readonly/index.jsx +9 -0
- package/src/components/common/required/index.cjs +17 -0
- package/src/components/common/required/index.jsx +9 -0
- package/src/components/common/text-content/index.cjs +17 -0
- package/src/components/common/text-content/index.jsx +24 -0
- package/src/components/field/index.cjs +16 -0
- package/src/components/field/index.jsx +146 -0
- package/src/components/group/index.cjs +17 -0
- package/src/components/group/index.jsx +55 -0
- package/src/gremlins/checkbox/field/index.cjs +17 -0
- package/src/gremlins/checkbox/field/index.jsx +62 -0
- package/src/gremlins/checkbox/index.cjs +17 -0
- package/src/gremlins/checkbox/index.jsx +84 -0
- package/src/gremlins/email/field/index.cjs +17 -0
- package/src/gremlins/email/field/index.jsx +58 -0
- package/src/gremlins/email/index.cjs +17 -0
- package/src/gremlins/email/index.jsx +65 -0
- package/src/gremlins/fieldset/group/index.cjs +17 -0
- package/src/gremlins/fieldset/group/index.jsx +20 -0
- package/src/gremlins/fieldset/index.cjs +17 -0
- package/src/gremlins/fieldset/index.jsx +40 -0
- package/src/gremlins/index.cjs +16 -0
- package/src/gremlins/index.jsx +226 -0
- package/src/gremlins/number/field/index.cjs +17 -0
- package/src/gremlins/number/field/index.jsx +67 -0
- package/src/gremlins/number/index.cjs +17 -0
- package/src/gremlins/number/index.jsx +74 -0
- package/src/gremlins/password/field/index.cjs +17 -0
- package/src/gremlins/password/field/index.jsx +58 -0
- package/src/gremlins/password/index.cjs +17 -0
- package/src/gremlins/password/index.jsx +65 -0
- package/src/gremlins/radio/field/index.cjs +17 -0
- package/src/gremlins/radio/field/index.jsx +79 -0
- package/src/gremlins/radio/index.cjs +17 -0
- package/src/gremlins/radio/index.jsx +95 -0
- package/src/gremlins/select/field/index.cjs +17 -0
- package/src/gremlins/select/field/index.jsx +71 -0
- package/src/gremlins/select/index.cjs +17 -0
- package/src/gremlins/select/index.jsx +81 -0
- package/src/gremlins/text/field/index.cjs +17 -0
- package/src/gremlins/text/field/index.jsx +58 -0
- package/src/gremlins/text/index.cjs +17 -0
- package/src/gremlins/text/index.jsx +65 -0
- package/src/gremlins/textarea/field/index.cjs +17 -0
- package/src/gremlins/textarea/field/index.jsx +57 -0
- package/src/gremlins/textarea/index.cjs +17 -0
- package/src/gremlins/textarea/index.jsx +65 -0
- package/src/index.cjs +29 -0
- package/src/index.d.cts +249 -0
- package/src/index.mjs +34 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CheckboxField component
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react'
|
|
5
|
+
import classnames from 'classnames'
|
|
6
|
+
|
|
7
|
+
import { CheckField } from '@modernpoacher/gremlins/components/field'
|
|
8
|
+
|
|
9
|
+
export default class CheckboxField extends CheckField {
|
|
10
|
+
getClassName () {
|
|
11
|
+
return classnames(super.getClassName(), 'checkbox')
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
render () {
|
|
15
|
+
const {
|
|
16
|
+
id,
|
|
17
|
+
name,
|
|
18
|
+
checked,
|
|
19
|
+
defaultChecked,
|
|
20
|
+
required,
|
|
21
|
+
disabled,
|
|
22
|
+
readOnly,
|
|
23
|
+
tabIndex,
|
|
24
|
+
accessKey,
|
|
25
|
+
fieldRef
|
|
26
|
+
} = this.props
|
|
27
|
+
|
|
28
|
+
const className = this.getClassName()
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<>
|
|
32
|
+
<input
|
|
33
|
+
id={id}
|
|
34
|
+
name={name}
|
|
35
|
+
checked={checked}
|
|
36
|
+
defaultChecked={defaultChecked}
|
|
37
|
+
required={required}
|
|
38
|
+
disabled={disabled}
|
|
39
|
+
readOnly={readOnly}
|
|
40
|
+
tabIndex={tabIndex}
|
|
41
|
+
accessKey={accessKey}
|
|
42
|
+
onClick={this.handleClick}
|
|
43
|
+
onChange={this.handleChange}
|
|
44
|
+
className={className}
|
|
45
|
+
type='checkbox'
|
|
46
|
+
ref={fieldRef}
|
|
47
|
+
/>
|
|
48
|
+
<label htmlFor={id}>
|
|
49
|
+
{String.fromCodePoint(8203)}
|
|
50
|
+
</label>
|
|
51
|
+
</>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
CheckboxField.propTypes = {
|
|
57
|
+
...CheckField.propTypes
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
CheckboxField.defaultProps = {
|
|
61
|
+
...CheckField.defaultProps
|
|
62
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require('@babel/register')({
|
|
2
|
+
ignore: [
|
|
3
|
+
/node_modules\/(?!@modernpoacher\/cogs|@modernpoacher\/gremlins|@modernpoacher\/sprockets)/
|
|
4
|
+
]
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
const debug = require('debug')
|
|
8
|
+
|
|
9
|
+
const log = debug('@modernpoacher/gremlins/gremlins/textbox')
|
|
10
|
+
|
|
11
|
+
log('`gremlins` is awake')
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
default: component
|
|
15
|
+
} = require('./index.jsx')
|
|
16
|
+
|
|
17
|
+
module.exports = component
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CheckboxGremlin component
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react'
|
|
5
|
+
import classnames from 'classnames'
|
|
6
|
+
|
|
7
|
+
import { CheckGremlin } from '@modernpoacher/gremlins/gremlins'
|
|
8
|
+
|
|
9
|
+
import Field from './field/index.jsx'
|
|
10
|
+
|
|
11
|
+
export default class CheckboxGremlin extends CheckGremlin {
|
|
12
|
+
getClassName () {
|
|
13
|
+
return classnames(super.getClassName(), 'checkbox')
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
handleClick = (value) => {
|
|
17
|
+
const {
|
|
18
|
+
onClick
|
|
19
|
+
} = this.props
|
|
20
|
+
|
|
21
|
+
onClick(value)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
handleChange = (value) => {
|
|
25
|
+
const {
|
|
26
|
+
onChange
|
|
27
|
+
} = this.props
|
|
28
|
+
|
|
29
|
+
onChange(value)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
renderField () {
|
|
33
|
+
const id = this.getId()
|
|
34
|
+
|
|
35
|
+
const {
|
|
36
|
+
name,
|
|
37
|
+
checked,
|
|
38
|
+
defaultChecked,
|
|
39
|
+
required,
|
|
40
|
+
disabled,
|
|
41
|
+
readOnly,
|
|
42
|
+
tabIndex,
|
|
43
|
+
accessKey,
|
|
44
|
+
placeholder,
|
|
45
|
+
fieldRef
|
|
46
|
+
} = this.props
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<Field
|
|
50
|
+
id={id}
|
|
51
|
+
name={name}
|
|
52
|
+
checked={checked}
|
|
53
|
+
defaultChecked={defaultChecked}
|
|
54
|
+
required={required}
|
|
55
|
+
disabled={disabled}
|
|
56
|
+
readOnly={readOnly}
|
|
57
|
+
tabIndex={tabIndex}
|
|
58
|
+
accessKey={accessKey}
|
|
59
|
+
placeholder={placeholder}
|
|
60
|
+
onClick={this.handleClick}
|
|
61
|
+
onChange={this.handleChange}
|
|
62
|
+
fieldRef={fieldRef}
|
|
63
|
+
/>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
render () {
|
|
68
|
+
const className = this.getClassName()
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<div className={className}>
|
|
72
|
+
{this.renderField()}
|
|
73
|
+
</div>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
CheckboxGremlin.propTypes = {
|
|
79
|
+
...CheckGremlin.propTypes
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
CheckboxGremlin.defaultProps = {
|
|
83
|
+
...CheckGremlin.defaultProps
|
|
84
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require('@babel/register')({
|
|
2
|
+
ignore: [
|
|
3
|
+
/node_modules\/(?!@modernpoacher\/cogs|@modernpoacher\/gremlins|@modernpoacher\/sprockets)/
|
|
4
|
+
]
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
const debug = require('debug')
|
|
8
|
+
|
|
9
|
+
const log = debug('@modernpoacher/gremlins/gremlins/email/field')
|
|
10
|
+
|
|
11
|
+
log('`gremlins` is awake')
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
default: component
|
|
15
|
+
} = require('./index.jsx')
|
|
16
|
+
|
|
17
|
+
module.exports = component
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EmailField component
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react'
|
|
5
|
+
import classnames from 'classnames'
|
|
6
|
+
|
|
7
|
+
import { ValueField } from '@modernpoacher/gremlins/components/field'
|
|
8
|
+
|
|
9
|
+
export default class EmailField extends ValueField {
|
|
10
|
+
getClassName () {
|
|
11
|
+
return classnames(super.getClassName(), 'email')
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
render () {
|
|
15
|
+
const {
|
|
16
|
+
id,
|
|
17
|
+
name,
|
|
18
|
+
value,
|
|
19
|
+
defaultValue,
|
|
20
|
+
required,
|
|
21
|
+
disabled,
|
|
22
|
+
readOnly,
|
|
23
|
+
tabIndex,
|
|
24
|
+
accessKey,
|
|
25
|
+
placeholder,
|
|
26
|
+
fieldRef
|
|
27
|
+
} = this.props
|
|
28
|
+
|
|
29
|
+
const className = this.getClassName()
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<input
|
|
33
|
+
id={id}
|
|
34
|
+
name={name}
|
|
35
|
+
value={value}
|
|
36
|
+
defaultValue={defaultValue}
|
|
37
|
+
required={required}
|
|
38
|
+
disabled={disabled}
|
|
39
|
+
readOnly={readOnly}
|
|
40
|
+
tabIndex={tabIndex}
|
|
41
|
+
accessKey={accessKey}
|
|
42
|
+
placeholder={placeholder}
|
|
43
|
+
onChange={this.handleChange}
|
|
44
|
+
className={className}
|
|
45
|
+
type='email'
|
|
46
|
+
ref={fieldRef}
|
|
47
|
+
/>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
EmailField.propTypes = {
|
|
53
|
+
...ValueField.propTypes
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
EmailField.defaultProps = {
|
|
57
|
+
...ValueField.defaultProps
|
|
58
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require('@babel/register')({
|
|
2
|
+
ignore: [
|
|
3
|
+
/node_modules\/(?!@modernpoacher\/cogs|@modernpoacher\/gremlins|@modernpoacher\/sprockets)/
|
|
4
|
+
]
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
const debug = require('debug')
|
|
8
|
+
|
|
9
|
+
const log = debug('@modernpoacher/gremlins/gremlins/email')
|
|
10
|
+
|
|
11
|
+
log('`gremlins` is awake')
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
default: component
|
|
15
|
+
} = require('./index.jsx')
|
|
16
|
+
|
|
17
|
+
module.exports = component
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EmailGremlin component
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react'
|
|
5
|
+
import classnames from 'classnames'
|
|
6
|
+
|
|
7
|
+
import { ValueGremlin } from '@modernpoacher/gremlins/gremlins'
|
|
8
|
+
|
|
9
|
+
import Field from './field/index.jsx'
|
|
10
|
+
|
|
11
|
+
export default class EmailGremlin extends ValueGremlin {
|
|
12
|
+
getClassName () {
|
|
13
|
+
return classnames(super.getClassName(), 'email')
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
handleChange = (value) => {
|
|
17
|
+
const {
|
|
18
|
+
onChange
|
|
19
|
+
} = this.props
|
|
20
|
+
|
|
21
|
+
onChange(value)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
renderField () {
|
|
25
|
+
const id = this.getId()
|
|
26
|
+
|
|
27
|
+
const {
|
|
28
|
+
name,
|
|
29
|
+
value,
|
|
30
|
+
defaultValue,
|
|
31
|
+
required,
|
|
32
|
+
disabled,
|
|
33
|
+
readOnly,
|
|
34
|
+
tabIndex,
|
|
35
|
+
accessKey,
|
|
36
|
+
placeholder,
|
|
37
|
+
fieldRef
|
|
38
|
+
} = this.props
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<Field
|
|
42
|
+
id={id}
|
|
43
|
+
name={name}
|
|
44
|
+
value={value}
|
|
45
|
+
defaultValue={defaultValue}
|
|
46
|
+
required={required}
|
|
47
|
+
disabled={disabled}
|
|
48
|
+
readOnly={readOnly}
|
|
49
|
+
tabIndex={tabIndex}
|
|
50
|
+
accessKey={accessKey}
|
|
51
|
+
placeholder={placeholder}
|
|
52
|
+
onChange={this.handleChange}
|
|
53
|
+
fieldRef={fieldRef}
|
|
54
|
+
/>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
EmailGremlin.propTypes = {
|
|
60
|
+
...ValueGremlin.propTypes
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
EmailGremlin.defaultProps = {
|
|
64
|
+
...ValueGremlin.defaultProps
|
|
65
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require('@babel/register')({
|
|
2
|
+
ignore: [
|
|
3
|
+
/node_modules\/(?!@modernpoacher\/cogs|@modernpoacher\/sprockets)/
|
|
4
|
+
]
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
const debug = require('debug')
|
|
8
|
+
|
|
9
|
+
const log = debug('@modernpoacher/gremlins/gremlins/fieldset/group')
|
|
10
|
+
|
|
11
|
+
log('`sprockets` is awake')
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
default: component
|
|
15
|
+
} = require('./index.jsx')
|
|
16
|
+
|
|
17
|
+
module.exports = component
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FieldsetGroup component
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import classnames from 'classnames'
|
|
6
|
+
import Group from '@modernpoacher/gremlins/components/group'
|
|
7
|
+
|
|
8
|
+
export default class FieldsetGroup extends Group {
|
|
9
|
+
getClassName () {
|
|
10
|
+
return classnames(super.getClassName(), 'fieldset')
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
FieldsetGroup.propTypes = {
|
|
15
|
+
...Group.propTypes
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
FieldsetGroup.defaultProps = {
|
|
19
|
+
...Group.defaultProps
|
|
20
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require('@babel/register')({
|
|
2
|
+
ignore: [
|
|
3
|
+
/node_modules\/(?!@modernpoacher\/cogs|@modernpoacher\/gremlins)/
|
|
4
|
+
]
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
const debug = require('debug')
|
|
8
|
+
|
|
9
|
+
const log = debug('@modernpoacher/gremlins/gremlins/fieldset')
|
|
10
|
+
|
|
11
|
+
log('`gremlins` is awake')
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
default: component
|
|
15
|
+
} = require('./index.jsx')
|
|
16
|
+
|
|
17
|
+
module.exports = component
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FieldsetGremlin component
|
|
3
|
+
*
|
|
4
|
+
* @typedef {import('@modernpoacher/gremlins/gremlins').GroupGremlinProps} GroupGremlinProps
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react'
|
|
8
|
+
|
|
9
|
+
import classnames from 'classnames'
|
|
10
|
+
|
|
11
|
+
import { GroupGremlin as Gremlin } from '@modernpoacher/gremlins/gremlins'
|
|
12
|
+
import Group from './group/index.jsx'
|
|
13
|
+
|
|
14
|
+
export default class FieldsetGremlin extends Gremlin {
|
|
15
|
+
getClassName () {
|
|
16
|
+
return classnames(super.getClassName(), 'fieldset')
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
renderGroup () {
|
|
20
|
+
const {
|
|
21
|
+
onChange,
|
|
22
|
+
children
|
|
23
|
+
} = this.props
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<Group
|
|
27
|
+
onChange={onChange}>
|
|
28
|
+
{children}
|
|
29
|
+
</Group>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
FieldsetGremlin.propTypes = {
|
|
35
|
+
...Gremlin.propTypes
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
FieldsetGremlin.defaultProps = {
|
|
39
|
+
...Gremlin.defaultProps
|
|
40
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require('@babel/register')({
|
|
2
|
+
ignore: [
|
|
3
|
+
/node_modules\/(?!@modernpoacher\/cogs|@modernpoacher\/gremlins|@modernpoacher\/sprockets)/
|
|
4
|
+
]
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
const debug = require('debug')
|
|
8
|
+
|
|
9
|
+
const log = debug('@modernpoacher/gremlins/gremlins')
|
|
10
|
+
|
|
11
|
+
log('`gremlins` is awake')
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Has default export, etc
|
|
15
|
+
*/
|
|
16
|
+
module.exports = require('./index.jsx')
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GroupGremlin component
|
|
3
|
+
*
|
|
4
|
+
* @typedef {import('@modernpoacher/gremlins/gremlins').GroupGremlinProps} GroupGremlinProps
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* FieldGremlin component
|
|
8
|
+
*
|
|
9
|
+
* @typedef {import('@modernpoacher/gremlins/gremlins').FieldGremlinProps} FieldGremlinProps
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import React, { Component } from 'react'
|
|
13
|
+
import PropTypes from 'prop-types'
|
|
14
|
+
import classnames from 'classnames'
|
|
15
|
+
|
|
16
|
+
import Field from '@modernpoacher/gremlins/components/field'
|
|
17
|
+
import Group from '@modernpoacher/gremlins/components/group'
|
|
18
|
+
|
|
19
|
+
function onChange () {
|
|
20
|
+
/* */
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function onClick () {
|
|
24
|
+
/* */
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class FieldGremlin extends Component {
|
|
28
|
+
getClassName () {
|
|
29
|
+
const {
|
|
30
|
+
required,
|
|
31
|
+
disabled,
|
|
32
|
+
readOnly
|
|
33
|
+
} = this.props
|
|
34
|
+
|
|
35
|
+
return classnames('gremlin', { required, disabled, readOnly })
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
getId () {
|
|
39
|
+
const {
|
|
40
|
+
id,
|
|
41
|
+
name
|
|
42
|
+
} = this.props
|
|
43
|
+
|
|
44
|
+
return id || name
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @param {FieldGremlinProps} props
|
|
49
|
+
* @returns {boolean}
|
|
50
|
+
*/
|
|
51
|
+
shouldComponentUpdate (props) {
|
|
52
|
+
return (
|
|
53
|
+
(props.name !== this.props.name) ||
|
|
54
|
+
(props.id !== this.props.id) ||
|
|
55
|
+
(props.required !== this.props.required) ||
|
|
56
|
+
(props.disabled !== this.props.disabled) ||
|
|
57
|
+
(props.readOnly !== this.props.readOnly) ||
|
|
58
|
+
(props.tabIndex !== this.props.tabIndex) ||
|
|
59
|
+
(props.accessKey !== this.props.accessKey) ||
|
|
60
|
+
(props.placeholder !== this.props.placeholder) ||
|
|
61
|
+
(props.onChange !== this.props.onChange)
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
renderField () {
|
|
66
|
+
const id = this.getId()
|
|
67
|
+
|
|
68
|
+
const {
|
|
69
|
+
name,
|
|
70
|
+
required,
|
|
71
|
+
disabled,
|
|
72
|
+
readOnly,
|
|
73
|
+
tabIndex,
|
|
74
|
+
accessKey,
|
|
75
|
+
placeholder,
|
|
76
|
+
onChange,
|
|
77
|
+
fieldRef
|
|
78
|
+
} = this.props
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<Field
|
|
82
|
+
id={id}
|
|
83
|
+
name={name}
|
|
84
|
+
required={required}
|
|
85
|
+
disabled={disabled}
|
|
86
|
+
readOnly={readOnly}
|
|
87
|
+
tabIndex={tabIndex}
|
|
88
|
+
accessKey={accessKey}
|
|
89
|
+
placeholder={placeholder}
|
|
90
|
+
onChange={onChange}
|
|
91
|
+
fieldRef={fieldRef}
|
|
92
|
+
/>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
render () {
|
|
97
|
+
const className = this.getClassName()
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<div className={className}>
|
|
101
|
+
{this.renderField()}
|
|
102
|
+
</div>
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
FieldGremlin.propTypes = {
|
|
108
|
+
id: PropTypes.string,
|
|
109
|
+
name: PropTypes.string.isRequired,
|
|
110
|
+
required: PropTypes.bool,
|
|
111
|
+
disabled: PropTypes.bool,
|
|
112
|
+
readOnly: PropTypes.bool,
|
|
113
|
+
placeholder: PropTypes.string,
|
|
114
|
+
onChange: PropTypes.func,
|
|
115
|
+
fieldRef: PropTypes.shape({
|
|
116
|
+
current: PropTypes.shape().isRequired
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
FieldGremlin.defaultProps = {
|
|
121
|
+
required: false,
|
|
122
|
+
disabled: false,
|
|
123
|
+
readOnly: false,
|
|
124
|
+
onChange
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export class ValueGremlin extends FieldGremlin {
|
|
128
|
+
shouldComponentUpdate (props) {
|
|
129
|
+
return (
|
|
130
|
+
super.shouldComponentUpdate(props) ||
|
|
131
|
+
(props.value !== this.props.value)
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
ValueGremlin.propTypes = {
|
|
137
|
+
...FieldGremlin.propTypes,
|
|
138
|
+
value: PropTypes.string,
|
|
139
|
+
defaultValue: PropTypes.string
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
ValueGremlin.defaultProps = {
|
|
143
|
+
...FieldGremlin.defaultProps
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export class CheckGremlin extends FieldGremlin {
|
|
147
|
+
shouldComponentUpdate (props) {
|
|
148
|
+
return (
|
|
149
|
+
super.shouldComponentUpdate(props) ||
|
|
150
|
+
(props.checked !== this.props.checked) ||
|
|
151
|
+
(props.onClick !== this.props.onClick)
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
CheckGremlin.propTypes = {
|
|
157
|
+
...FieldGremlin.propTypes,
|
|
158
|
+
checked: PropTypes.bool,
|
|
159
|
+
defaultChecked: PropTypes.bool,
|
|
160
|
+
onClick: PropTypes.func
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
CheckGremlin.defaultProps = {
|
|
164
|
+
...FieldGremlin.defaultProps,
|
|
165
|
+
onClick
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export class GroupGremlin extends Component {
|
|
169
|
+
getClassName () {
|
|
170
|
+
return 'gremlin'
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* @param {GroupGremlinProps} props
|
|
175
|
+
* @returns {boolean}
|
|
176
|
+
*/
|
|
177
|
+
shouldComponentUpdate (props) {
|
|
178
|
+
return (
|
|
179
|
+
(props.children !== this.props.children) ||
|
|
180
|
+
(props.onChange !== this.props.onChange)
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
renderGroup () {
|
|
185
|
+
const {
|
|
186
|
+
onChange,
|
|
187
|
+
groupRef,
|
|
188
|
+
children
|
|
189
|
+
} = this.props
|
|
190
|
+
|
|
191
|
+
return (
|
|
192
|
+
<Group
|
|
193
|
+
onChange={onChange}
|
|
194
|
+
groupRef={groupRef}>
|
|
195
|
+
{children}
|
|
196
|
+
</Group>
|
|
197
|
+
)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
render () {
|
|
201
|
+
const className = this.getClassName()
|
|
202
|
+
|
|
203
|
+
return (
|
|
204
|
+
<div className={className}>
|
|
205
|
+
{this.renderGroup()}
|
|
206
|
+
</div>
|
|
207
|
+
)
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
GroupGremlin.propTypes = {
|
|
212
|
+
onChange: PropTypes.func,
|
|
213
|
+
children: PropTypes.oneOfType([
|
|
214
|
+
PropTypes.node,
|
|
215
|
+
PropTypes.arrayOf(
|
|
216
|
+
PropTypes.node
|
|
217
|
+
)
|
|
218
|
+
]),
|
|
219
|
+
groupRef: PropTypes.shape({
|
|
220
|
+
current: PropTypes.shape().isRequired
|
|
221
|
+
})
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
GroupGremlin.defaultProps = {
|
|
225
|
+
onChange
|
|
226
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require('@babel/register')({
|
|
2
|
+
ignore: [
|
|
3
|
+
/node_modules\/(?!@modernpoacher\/cogs|@modernpoacher\/gremlins|@modernpoacher\/sprockets)/
|
|
4
|
+
]
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
const debug = require('debug')
|
|
8
|
+
|
|
9
|
+
const log = debug('@modernpoacher/gremlins/gremlins/number/field')
|
|
10
|
+
|
|
11
|
+
log('`gremlins` is awake')
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
default: component
|
|
15
|
+
} = require('./index.jsx')
|
|
16
|
+
|
|
17
|
+
module.exports = component
|