@modernpoacher/gremlins 0.0.241 → 0.0.243
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 +2 -46
- package/package.json +13 -30
- package/src/common/index.d.mts +9 -0
- package/src/components/common/disabled/index.cjs +1 -1
- package/src/components/common/disabled/index.d.mts +9 -0
- package/src/components/common/readonly/index.cjs +1 -1
- package/src/components/common/readonly/index.d.mts +9 -0
- package/src/components/common/required/index.cjs +1 -1
- package/src/components/common/required/index.d.mts +9 -0
- package/src/components/common/text-content/index.cjs +1 -1
- package/src/components/common/text-content/index.d.mts +14 -0
- package/src/components/common/text-content/index.jsx +1 -1
- package/src/components/field/index.cjs +1 -1
- package/src/components/field/index.d.mts +23 -0
- package/src/components/field/index.jsx +20 -13
- package/src/components/group/index.cjs +1 -1
- package/src/components/group/index.d.mts +16 -0
- package/src/components/group/index.jsx +2 -2
- package/src/gremlins/checkbox/field/index.cjs +1 -1
- package/src/gremlins/checkbox/field/index.d.mts +9 -0
- package/src/gremlins/checkbox/field/index.jsx +4 -8
- package/src/gremlins/checkbox/index.cjs +1 -1
- package/src/gremlins/checkbox/index.d.mts +9 -0
- package/src/gremlins/checkbox/index.jsx +20 -12
- package/src/gremlins/email/field/index.cjs +1 -1
- package/src/gremlins/email/field/index.d.mts +9 -0
- package/src/gremlins/email/field/index.jsx +1 -5
- package/src/gremlins/email/index.cjs +1 -1
- package/src/gremlins/email/index.d.mts +9 -0
- package/src/gremlins/email/index.jsx +6 -6
- package/src/gremlins/fieldset/group/index.cjs +1 -1
- package/src/gremlins/fieldset/group/index.d.mts +9 -0
- package/src/gremlins/fieldset/group/index.jsx +1 -5
- package/src/gremlins/fieldset/index.cjs +1 -1
- package/src/gremlins/fieldset/index.d.mts +9 -0
- package/src/gremlins/fieldset/index.jsx +2 -6
- package/src/gremlins/index.cjs +1 -1
- package/src/gremlins/index.d.mts +45 -0
- package/src/gremlins/index.jsx +7 -7
- package/src/gremlins/number/field/index.cjs +1 -1
- package/src/gremlins/number/field/index.d.mts +9 -0
- package/src/gremlins/number/field/index.jsx +1 -5
- package/src/gremlins/number/index.cjs +1 -1
- package/src/gremlins/number/index.d.mts +9 -0
- package/src/gremlins/number/index.jsx +6 -6
- package/src/gremlins/password/field/index.cjs +1 -1
- package/src/gremlins/password/field/index.d.mts +9 -0
- package/src/gremlins/password/field/index.jsx +1 -5
- package/src/gremlins/password/index.cjs +1 -1
- package/src/gremlins/password/index.d.mts +9 -0
- package/src/gremlins/password/index.jsx +6 -6
- package/src/gremlins/radio/field/index.cjs +1 -1
- package/src/gremlins/radio/field/index.d.mts +9 -0
- package/src/gremlins/radio/field/index.jsx +3 -19
- package/src/gremlins/radio/index.cjs +1 -1
- package/src/gremlins/radio/index.d.mts +9 -0
- package/src/gremlins/radio/index.jsx +14 -13
- package/src/gremlins/select/field/index.cjs +1 -1
- package/src/gremlins/select/field/index.d.mts +9 -0
- package/src/gremlins/select/field/index.jsx +9 -10
- package/src/gremlins/select/index.cjs +1 -1
- package/src/gremlins/select/index.d.mts +9 -0
- package/src/gremlins/select/index.jsx +8 -9
- package/src/gremlins/text/field/index.cjs +1 -1
- package/src/gremlins/text/field/index.d.mts +9 -0
- package/src/gremlins/text/field/index.jsx +1 -5
- package/src/gremlins/text/index.cjs +1 -1
- package/src/gremlins/text/index.d.mts +9 -0
- package/src/gremlins/text/index.jsx +6 -6
- package/src/gremlins/textarea/field/index.cjs +1 -1
- package/src/gremlins/textarea/field/index.d.mts +9 -0
- package/src/gremlins/textarea/field/index.jsx +1 -5
- package/src/gremlins/textarea/index.cjs +1 -1
- package/src/gremlins/textarea/index.d.mts +9 -0
- package/src/gremlins/textarea/index.jsx +6 -6
- package/src/index.cjs +1 -1
- package/src/index.d.mts +13 -208
package/babel.config.cjs
CHANGED
|
@@ -40,51 +40,7 @@ const presets = [
|
|
|
40
40
|
]
|
|
41
41
|
|
|
42
42
|
const plugins = [
|
|
43
|
-
'@babel/syntax-jsx'
|
|
44
|
-
[
|
|
45
|
-
'module-resolver', {
|
|
46
|
-
alias: {
|
|
47
|
-
/**
|
|
48
|
-
* Jest & Storybook
|
|
49
|
-
*/
|
|
50
|
-
'@modernpoacher/gremlins/common': './src/common/index.mjs',
|
|
51
|
-
'@modernpoacher/gremlins/gremlins/checkbox/field': './src/gremlins/checkbox/field/index.jsx',
|
|
52
|
-
'@modernpoacher/gremlins/gremlins/checkbox': './src/gremlins/checkbox/index.jsx',
|
|
53
|
-
'@modernpoacher/gremlins/gremlins/email/field': './src/gremlins/email/field/index.jsx',
|
|
54
|
-
'@modernpoacher/gremlins/gremlins/email': './src/gremlins/email/index.jsx',
|
|
55
|
-
'@modernpoacher/gremlins/gremlins/number/field': './src/gremlins/number/field/index.jsx',
|
|
56
|
-
'@modernpoacher/gremlins/gremlins/number': './src/gremlins/number/index.jsx',
|
|
57
|
-
'@modernpoacher/gremlins/gremlins/password/field': './src/gremlins/password/field/index.jsx',
|
|
58
|
-
'@modernpoacher/gremlins/gremlins/password': './src/gremlins/password/index.jsx',
|
|
59
|
-
'@modernpoacher/gremlins/gremlins/radio/field': './src/gremlins/radio/field/index.jsx',
|
|
60
|
-
'@modernpoacher/gremlins/gremlins/radio': './src/gremlins/radio/index.jsx',
|
|
61
|
-
'@modernpoacher/gremlins/gremlins/select/field': './src/gremlins/select/field/index.jsx',
|
|
62
|
-
'@modernpoacher/gremlins/gremlins/select': './src/gremlins/select/index.jsx',
|
|
63
|
-
'@modernpoacher/gremlins/gremlins/text/field': './src/gremlins/text/field/index.jsx',
|
|
64
|
-
'@modernpoacher/gremlins/gremlins/text': './src/gremlins/text/index.jsx',
|
|
65
|
-
'@modernpoacher/gremlins/gremlins/textarea/field': './src/gremlins/textarea/field/index.jsx',
|
|
66
|
-
'@modernpoacher/gremlins/gremlins/textarea': './src/gremlins/textarea/index.jsx',
|
|
67
|
-
'@modernpoacher/gremlins/gremlins/fieldset/group': './src/gremlins/fieldset/group/index.jsx',
|
|
68
|
-
'@modernpoacher/gremlins/gremlins/fieldset': './src/gremlins/fieldset/index.jsx',
|
|
69
|
-
'@modernpoacher/gremlins/gremlins': './src/gremlins/index.jsx',
|
|
70
|
-
'@modernpoacher/gremlins/components/common/disabled': './src/components/common/disabled/index.jsx',
|
|
71
|
-
'@modernpoacher/gremlins/components/common/readonly': './src/components/common/readonly/index.jsx',
|
|
72
|
-
'@modernpoacher/gremlins/components/common/required': './src/components/common/required/index.jsx',
|
|
73
|
-
'@modernpoacher/gremlins/components/common/text-content': './src/components/common/text-content/index.jsx',
|
|
74
|
-
'@modernpoacher/gremlins/components/field': './src/components/field/index.jsx',
|
|
75
|
-
'#stories/state/checkbox': './stories/state/checkbox/index.jsx',
|
|
76
|
-
'#stories/state/email': './stories/state/email/index.jsx',
|
|
77
|
-
'#stories/state/number': './stories/state/number/index.jsx',
|
|
78
|
-
'#stories/state/password': './stories/state/password/index.jsx',
|
|
79
|
-
'#stories/state/radio': './stories/state/radio/index.jsx',
|
|
80
|
-
'#stories/state/select': './stories/state/select/index.jsx',
|
|
81
|
-
'#stories/state/text': './stories/state/text/index.jsx',
|
|
82
|
-
'#stories/state/textarea': './stories/state/textarea/index.jsx',
|
|
83
|
-
'#stories/state': './stories/state/index.jsx',
|
|
84
|
-
'#stories': './stories'
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
]
|
|
43
|
+
'@babel/syntax-jsx'
|
|
88
44
|
]
|
|
89
45
|
|
|
90
46
|
module.exports = (api) => {
|
|
@@ -94,7 +50,7 @@ module.exports = (api) => {
|
|
|
94
50
|
presets,
|
|
95
51
|
plugins,
|
|
96
52
|
ignore: [
|
|
97
|
-
/node_modules\/(?!@modernpoacher\/cogs|@modernpoacher\/
|
|
53
|
+
/node_modules\/(?!@modernpoacher\/cogs|@modernpoacher\/sprockets|@modernpoacher\/gremlins)/
|
|
98
54
|
]
|
|
99
55
|
}
|
|
100
56
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modernpoacher/gremlins",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.243",
|
|
4
4
|
"description": "Gremlins",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Gremlins",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
],
|
|
9
9
|
"main": "./src/index.cjs",
|
|
10
10
|
"type": "module",
|
|
11
|
-
"types": "./src/index.d.
|
|
11
|
+
"types": "./src/index.d.mts",
|
|
12
12
|
"author": {
|
|
13
13
|
"name": "Jonathan Perry for Modern Poacher Limited",
|
|
14
14
|
"email": "modernpoacher@modernpoacher.com",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@babel/preset-env": "^7.26.0",
|
|
49
49
|
"@babel/preset-react": "^7.25.9",
|
|
50
50
|
"@babel/register": "^7.25.9",
|
|
51
|
-
"@modernpoacher/design-system": "1.1.
|
|
51
|
+
"@modernpoacher/design-system": "1.1.16",
|
|
52
52
|
"@storybook/addon-actions": "7.6.20",
|
|
53
53
|
"@storybook/addon-essentials": "7.6.20",
|
|
54
54
|
"@storybook/addon-links": "7.6.20",
|
|
@@ -58,14 +58,12 @@
|
|
|
58
58
|
"@typescript-eslint/eslint-plugin": "7.18.0",
|
|
59
59
|
"@typescript-eslint/parser": "7.18.0",
|
|
60
60
|
"autoprefixer": "^10.4.20",
|
|
61
|
-
"babel-plugin-module-resolver": "^5.0.2",
|
|
62
61
|
"clean-webpack-plugin": "^4.0.0",
|
|
63
62
|
"core-js": "^3.39.0",
|
|
64
63
|
"cross-env": "^7.0.3",
|
|
65
64
|
"eslint": "8.57.1",
|
|
66
65
|
"eslint-config-love": "47.0.0",
|
|
67
66
|
"eslint-config-standard": "^17.1.0",
|
|
68
|
-
"eslint-import-resolver-babel-module": "^5.3.2",
|
|
69
67
|
"eslint-plugin-react": "^7.37.2",
|
|
70
68
|
"husky": "^9.1.7",
|
|
71
69
|
"jest": "^29.7.0",
|
|
@@ -89,7 +87,14 @@
|
|
|
89
87
|
"webpack-cli": "^5.1.4"
|
|
90
88
|
},
|
|
91
89
|
"imports": {
|
|
92
|
-
"#build/paths": "./build/paths.mjs"
|
|
90
|
+
"#build/paths": "./build/paths.mjs",
|
|
91
|
+
"#gremlins/common": "./src/common/index.mjs",
|
|
92
|
+
"#gremlins/components/*": "./src/components/*/index.jsx",
|
|
93
|
+
"#gremlins/gremlins": "./src/gremlins/index.jsx",
|
|
94
|
+
"#gremlins/gremlins/*": "./src/gremlins/*/index.jsx",
|
|
95
|
+
"#stories/*": "./stories/*/index.stories.jsx",
|
|
96
|
+
"#stories/state": "./stories/state/index.jsx",
|
|
97
|
+
"#stories/state/*": "./stories/state/*/index.jsx"
|
|
93
98
|
},
|
|
94
99
|
"exports": {
|
|
95
100
|
".": {
|
|
@@ -97,30 +102,8 @@
|
|
|
97
102
|
"import": "./src/index.mjs"
|
|
98
103
|
},
|
|
99
104
|
"./common": "./src/common/index.mjs",
|
|
100
|
-
"./components
|
|
101
|
-
"./components/common/readonly": "./src/components/common/readonly/index.cjs",
|
|
102
|
-
"./components/common/required": "./src/components/common/required/index.cjs",
|
|
103
|
-
"./components/common/text-content": "./src/components/common/text-content/index.cjs",
|
|
104
|
-
"./components/field": "./src/components/field/index.cjs",
|
|
105
|
-
"./components/group": "./src/components/group/index.cjs",
|
|
105
|
+
"./components/*": "./src/components/*/index.cjs",
|
|
106
106
|
"./gremlins": "./src/gremlins/index.cjs",
|
|
107
|
-
"./gremlins
|
|
108
|
-
"./gremlins/checkbox/field": "./src/gremlins/checkbox/field/index.cjs",
|
|
109
|
-
"./gremlins/email": "./src/gremlins/email/index.cjs",
|
|
110
|
-
"./gremlins/email/field": "./src/gremlins/email/field/index.cjs",
|
|
111
|
-
"./gremlins/fieldset": "./src/gremlins/fieldset/index.cjs",
|
|
112
|
-
"./gremlins/fieldset/group": "./src/gremlins/fieldset/group/index.cjs",
|
|
113
|
-
"./gremlins/number": "./src/gremlins/number/index.cjs",
|
|
114
|
-
"./gremlins/number/field": "./src/gremlins/number/field/index.cjs",
|
|
115
|
-
"./gremlins/password": "./src/gremlins/password/index.cjs",
|
|
116
|
-
"./gremlins/password/field": "./src/gremlins/password/field/index.cjs",
|
|
117
|
-
"./gremlins/radio": "./src/gremlins/radio/index.cjs",
|
|
118
|
-
"./gremlins/radio/field": "./src/gremlins/radio/field/index.cjs",
|
|
119
|
-
"./gremlins/select": "./src/gremlins/select/index.cjs",
|
|
120
|
-
"./gremlins/select/field": "./src/gremlins/select/field/index.cjs",
|
|
121
|
-
"./gremlins/text": "./src/gremlins/text/index.cjs",
|
|
122
|
-
"./gremlins/text/field": "./src/gremlins/text/field/index.cjs",
|
|
123
|
-
"./gremlins/textarea": "./src/gremlins/textarea/index.cjs",
|
|
124
|
-
"./gremlins/textarea/field": "./src/gremlins/textarea/field/index.cjs"
|
|
107
|
+
"./gremlins/*": "./src/gremlins/*/index.cjs"
|
|
125
108
|
}
|
|
126
109
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare module '#gremlins/components/common/disabled' {
|
|
2
|
+
import type React from 'react'
|
|
3
|
+
|
|
4
|
+
export default function Disabled (): React.JSX.Element
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
declare module '@modernpoacher/gremlins/components/common/disabled' {
|
|
8
|
+
export { default } from '#gremlins/components/common/disabled'
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare module '#gremlins/components/common/readonly' {
|
|
2
|
+
import type React from 'react'
|
|
3
|
+
|
|
4
|
+
export default function ReadOnly (): React.JSX.Element
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
declare module '@modernpoacher/gremlins/components/common/readonly' {
|
|
8
|
+
export { default } from '#gremlins/components/common/readonly'
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare module '#gremlins/components/common/required' {
|
|
2
|
+
import type React from 'react'
|
|
3
|
+
|
|
4
|
+
export default function Required (): React.JSX.Element
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
declare module '@modernpoacher/gremlins/components/common/required' {
|
|
8
|
+
export { default } from '#gremlins/components/common/required'
|
|
9
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare module '#gremlins/components/common/text-content' {
|
|
2
|
+
import type React from 'react'
|
|
3
|
+
|
|
4
|
+
export interface TextContentProps {
|
|
5
|
+
textContent: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default function TextContent (props: TextContentProps): React.JSX.Element | null
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare module '@modernpoacher/gremlins/components/common/text-content' {
|
|
12
|
+
export { default } from '#gremlins/components/common/text-content'
|
|
13
|
+
export * from '#gremlins/components/common/text-content'
|
|
14
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
declare module '#gremlins/components/field' {
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
export interface FieldProps {
|
|
5
|
+
id: string
|
|
6
|
+
name: string
|
|
7
|
+
required: boolean
|
|
8
|
+
disabled: boolean
|
|
9
|
+
readOnly: boolean
|
|
10
|
+
tabIndex: number
|
|
11
|
+
accessKey: string
|
|
12
|
+
placeholder: string
|
|
13
|
+
onChange: GremlinsTypes.OnChangeType
|
|
14
|
+
fieldRef: object
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default class Field extends React.Component<FieldProps> {}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare module '@modernpoacher/gremlins/components/field' {
|
|
21
|
+
export { default } from '#gremlins/components/field'
|
|
22
|
+
export * from '#gremlins/components/field'
|
|
23
|
+
}
|
|
@@ -7,14 +7,14 @@ import PropTypes from 'prop-types'
|
|
|
7
7
|
import {
|
|
8
8
|
DEFAULT_HANDLE_CHANGE,
|
|
9
9
|
DEFAULT_HANDLE_CLICK
|
|
10
|
-
} from '
|
|
10
|
+
} from '#gremlins/common'
|
|
11
11
|
|
|
12
12
|
export default class Field extends Component {
|
|
13
13
|
getClassName () {
|
|
14
14
|
return 'input'
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
shouldComponentUpdate (props) {
|
|
17
|
+
shouldComponentUpdate (props, state) {
|
|
18
18
|
return (
|
|
19
19
|
(props.id !== this.props.id) ||
|
|
20
20
|
(props.required !== this.props.required) ||
|
|
@@ -81,15 +81,17 @@ Field.defaultProps = {
|
|
|
81
81
|
* ValueField component
|
|
82
82
|
*/
|
|
83
83
|
export class ValueField extends Field {
|
|
84
|
-
shouldComponentUpdate (props) {
|
|
84
|
+
shouldComponentUpdate (props, state) {
|
|
85
85
|
return (
|
|
86
|
-
super.shouldComponentUpdate(props) ||
|
|
86
|
+
super.shouldComponentUpdate(props, state) ||
|
|
87
87
|
(props.value !== this.props.value)
|
|
88
88
|
)
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
handleChange = ({ target: { value } }) => {
|
|
92
|
-
const {
|
|
92
|
+
const {
|
|
93
|
+
onChange = DEFAULT_HANDLE_CHANGE
|
|
94
|
+
} = this.props
|
|
93
95
|
|
|
94
96
|
onChange(value)
|
|
95
97
|
}
|
|
@@ -109,24 +111,29 @@ ValueField.defaultProps = {
|
|
|
109
111
|
* CheckField component
|
|
110
112
|
*/
|
|
111
113
|
export class CheckField extends Field {
|
|
112
|
-
shouldComponentUpdate (props) {
|
|
114
|
+
shouldComponentUpdate (props, state) {
|
|
113
115
|
return (
|
|
114
|
-
super.shouldComponentUpdate(props) ||
|
|
116
|
+
super.shouldComponentUpdate(props, state) ||
|
|
117
|
+
(props.value !== this.props.value) ||
|
|
115
118
|
(props.checked !== this.props.checked) ||
|
|
116
119
|
(props.onClick !== this.props.onClick)
|
|
117
120
|
)
|
|
118
121
|
}
|
|
119
122
|
|
|
120
|
-
handleClick = ({ target: { checked } }) => {
|
|
121
|
-
const {
|
|
123
|
+
handleClick = ({ target: { value, checked } }) => {
|
|
124
|
+
const {
|
|
125
|
+
onClick = DEFAULT_HANDLE_CLICK
|
|
126
|
+
} = this.props
|
|
122
127
|
|
|
123
|
-
onClick(checked)
|
|
128
|
+
onClick(value, checked)
|
|
124
129
|
}
|
|
125
130
|
|
|
126
|
-
handleChange = ({ target: { checked } }) => {
|
|
127
|
-
const {
|
|
131
|
+
handleChange = ({ target: { value, checked } }) => {
|
|
132
|
+
const {
|
|
133
|
+
onChange = DEFAULT_HANDLE_CHANGE
|
|
134
|
+
} = this.props
|
|
128
135
|
|
|
129
|
-
onChange(checked)
|
|
136
|
+
onChange(value, checked)
|
|
130
137
|
}
|
|
131
138
|
}
|
|
132
139
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare module '#gremlins/components/group' {
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
export interface GroupProps {
|
|
5
|
+
onChange: GremlinsTypes.OnChangeType
|
|
6
|
+
groupRef: object
|
|
7
|
+
children: React.JSX.Element | React.JSX.Element[]
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default class Group extends React.Component<GroupProps> {}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare module '@modernpoacher/gremlins/components/group' {
|
|
14
|
+
export { default } from '#gremlins/components/group'
|
|
15
|
+
export * from '#gremlins/components/group'
|
|
16
|
+
}
|
|
@@ -9,7 +9,7 @@ import PropTypes from 'prop-types'
|
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
11
|
DEFAULT_HANDLE_CHANGE
|
|
12
|
-
} from '
|
|
12
|
+
} from '#gremlins/common'
|
|
13
13
|
|
|
14
14
|
export default class Group extends Component {
|
|
15
15
|
getClassName () {
|
|
@@ -20,7 +20,7 @@ export default class Group extends Component {
|
|
|
20
20
|
* @param {GroupProps} props
|
|
21
21
|
* @returns {boolean}
|
|
22
22
|
*/
|
|
23
|
-
shouldComponentUpdate (props) {
|
|
23
|
+
shouldComponentUpdate (props, state) {
|
|
24
24
|
return (
|
|
25
25
|
(props.onChange !== this.props.onChange) ||
|
|
26
26
|
(props.children !== this.props.children)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare module '#gremlins/gremlins/checkbox/field' {
|
|
2
|
+
import Field from '#gremlins/components/field'
|
|
3
|
+
|
|
4
|
+
export default class CheckboxField extends Field {}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
declare module '@modernpoacher/gremlins/checkbox/field' {
|
|
8
|
+
export { default } from '#gremlins/gremlins/checkbox/field'
|
|
9
|
+
}
|
|
@@ -5,7 +5,7 @@ import React from 'react'
|
|
|
5
5
|
import PropTypes from 'prop-types'
|
|
6
6
|
import classnames from 'classnames'
|
|
7
7
|
|
|
8
|
-
import { CheckField } from '
|
|
8
|
+
import { CheckField } from '#gremlins/components/field'
|
|
9
9
|
|
|
10
10
|
export default class CheckboxField extends CheckField {
|
|
11
11
|
getClassName () {
|
|
@@ -41,8 +41,8 @@ export default class CheckboxField extends CheckField {
|
|
|
41
41
|
readOnly={readOnly}
|
|
42
42
|
tabIndex={tabIndex}
|
|
43
43
|
accessKey={accessKey}
|
|
44
|
-
onClick={this.handleClick}
|
|
45
44
|
onChange={this.handleChange}
|
|
45
|
+
onClick={this.handleClick}
|
|
46
46
|
className={className}
|
|
47
47
|
type='checkbox'
|
|
48
48
|
ref={fieldRef}
|
|
@@ -64,14 +64,14 @@ export default class CheckboxField extends CheckField {
|
|
|
64
64
|
defaultChecked={defaultChecked}
|
|
65
65
|
id={id}
|
|
66
66
|
name={name}
|
|
67
|
-
|
|
67
|
+
value={value}
|
|
68
68
|
required={required}
|
|
69
69
|
disabled={disabled}
|
|
70
70
|
readOnly={readOnly}
|
|
71
71
|
tabIndex={tabIndex}
|
|
72
72
|
accessKey={accessKey}
|
|
73
|
-
onClick={this.handleClick}
|
|
74
73
|
onChange={this.handleChange}
|
|
74
|
+
onClick={this.handleClick}
|
|
75
75
|
className={className}
|
|
76
76
|
type='checkbox'
|
|
77
77
|
ref={fieldRef}
|
|
@@ -88,7 +88,3 @@ CheckboxField.propTypes = {
|
|
|
88
88
|
...CheckField.propTypes,
|
|
89
89
|
value: PropTypes.string.isRequired
|
|
90
90
|
}
|
|
91
|
-
|
|
92
|
-
CheckboxField.defaultProps = {
|
|
93
|
-
...CheckField.defaultProps
|
|
94
|
-
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare module '#gremlins/gremlins/checkbox' {
|
|
2
|
+
import { FieldGremlin as Gremlin } from '#gremlins/gremlins'
|
|
3
|
+
|
|
4
|
+
export default class CheckboxGremlin extends Gremlin {}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
declare module '@modernpoacher/gremlins/gremlins/checkbox' {
|
|
8
|
+
export { default } from '#gremlins/gremlins/checkbox'
|
|
9
|
+
}
|
|
@@ -5,7 +5,12 @@ import React from 'react'
|
|
|
5
5
|
import PropTypes from 'prop-types'
|
|
6
6
|
import classnames from 'classnames'
|
|
7
7
|
|
|
8
|
-
import { CheckGremlin } from '
|
|
8
|
+
import { CheckGremlin } from '#gremlins/gremlins'
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
DEFAULT_HANDLE_CHANGE,
|
|
12
|
+
DEFAULT_HANDLE_CLICK
|
|
13
|
+
} from '#gremlins/common'
|
|
9
14
|
|
|
10
15
|
import Field from './field/index.jsx'
|
|
11
16
|
|
|
@@ -14,20 +19,27 @@ export default class CheckboxGremlin extends CheckGremlin {
|
|
|
14
19
|
return classnames(super.getClassName(), 'checkbox')
|
|
15
20
|
}
|
|
16
21
|
|
|
17
|
-
|
|
22
|
+
handleChange = (value, checked) => {
|
|
18
23
|
const {
|
|
19
|
-
|
|
24
|
+
onChange = DEFAULT_HANDLE_CHANGE
|
|
20
25
|
} = this.props
|
|
21
26
|
|
|
22
|
-
|
|
27
|
+
onChange(value, checked)
|
|
23
28
|
}
|
|
24
29
|
|
|
25
|
-
|
|
30
|
+
handleClick = (value, checked) => {
|
|
26
31
|
const {
|
|
27
|
-
|
|
32
|
+
onClick = DEFAULT_HANDLE_CLICK
|
|
28
33
|
} = this.props
|
|
29
34
|
|
|
30
|
-
|
|
35
|
+
onClick(value, checked)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
shouldComponentUpdate (props, state) {
|
|
39
|
+
return (
|
|
40
|
+
super.shouldComponentUpdate(props) ||
|
|
41
|
+
(props.value !== this.props.value)
|
|
42
|
+
)
|
|
31
43
|
}
|
|
32
44
|
|
|
33
45
|
renderField () {
|
|
@@ -60,8 +72,8 @@ export default class CheckboxGremlin extends CheckGremlin {
|
|
|
60
72
|
tabIndex={tabIndex}
|
|
61
73
|
accessKey={accessKey}
|
|
62
74
|
placeholder={placeholder}
|
|
63
|
-
onClick={this.handleClick}
|
|
64
75
|
onChange={this.handleChange}
|
|
76
|
+
onClick={this.handleClick}
|
|
65
77
|
fieldRef={fieldRef}
|
|
66
78
|
/>
|
|
67
79
|
)
|
|
@@ -82,7 +94,3 @@ CheckboxGremlin.propTypes = {
|
|
|
82
94
|
...CheckGremlin.propTypes,
|
|
83
95
|
value: PropTypes.string.isRequired
|
|
84
96
|
}
|
|
85
|
-
|
|
86
|
-
CheckboxGremlin.defaultProps = {
|
|
87
|
-
...CheckGremlin.defaultProps
|
|
88
|
-
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare module '#gremlins/gremlins/email/field' {
|
|
2
|
+
import Field from '#gremlins/components/field'
|
|
3
|
+
|
|
4
|
+
export default class EmailField extends Field {}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
declare module '@modernpoacher/gremlins/email/field' {
|
|
8
|
+
export { default } from '#gremlins/gremlins/email/field'
|
|
9
|
+
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import React from 'react'
|
|
5
5
|
import classnames from 'classnames'
|
|
6
6
|
|
|
7
|
-
import { ValueField } from '
|
|
7
|
+
import { ValueField } from '#gremlins/components/field'
|
|
8
8
|
|
|
9
9
|
export default class EmailField extends ValueField {
|
|
10
10
|
getClassName () {
|
|
@@ -52,7 +52,3 @@ export default class EmailField extends ValueField {
|
|
|
52
52
|
EmailField.propTypes = {
|
|
53
53
|
...ValueField.propTypes
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
EmailField.defaultProps = {
|
|
57
|
-
...ValueField.defaultProps
|
|
58
|
-
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare module '#gremlins/gremlins/email' {
|
|
2
|
+
import { FieldGremlin as Gremlin } from '#gremlins/gremlins'
|
|
3
|
+
|
|
4
|
+
export default class EmailGremlin extends Gremlin {}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
declare module '@modernpoacher/gremlins/gremlins/email' {
|
|
8
|
+
export { default } from '#gremlins/gremlins/email'
|
|
9
|
+
}
|
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
import React from 'react'
|
|
5
5
|
import classnames from 'classnames'
|
|
6
6
|
|
|
7
|
-
import { ValueGremlin } from '
|
|
7
|
+
import { ValueGremlin } from '#gremlins/gremlins'
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
DEFAULT_HANDLE_CHANGE
|
|
11
|
+
} from '#gremlins/common'
|
|
8
12
|
|
|
9
13
|
import Field from './field/index.jsx'
|
|
10
14
|
|
|
@@ -15,7 +19,7 @@ export default class EmailGremlin extends ValueGremlin {
|
|
|
15
19
|
|
|
16
20
|
handleChange = (value) => {
|
|
17
21
|
const {
|
|
18
|
-
onChange
|
|
22
|
+
onChange = DEFAULT_HANDLE_CHANGE
|
|
19
23
|
} = this.props
|
|
20
24
|
|
|
21
25
|
onChange(value)
|
|
@@ -59,7 +63,3 @@ export default class EmailGremlin extends ValueGremlin {
|
|
|
59
63
|
EmailGremlin.propTypes = {
|
|
60
64
|
...ValueGremlin.propTypes
|
|
61
65
|
}
|
|
62
|
-
|
|
63
|
-
EmailGremlin.defaultProps = {
|
|
64
|
-
...ValueGremlin.defaultProps
|
|
65
|
-
}
|