@modernpoacher/gremlins 0.0.176 → 0.0.178
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/package.json +9 -8
- package/src/common/index.mjs +7 -0
- package/src/components/field/index.jsx +12 -15
- package/src/components/group/index.jsx +5 -1
- package/src/gremlins/checkbox/field/index.jsx +3 -3
- package/src/gremlins/checkbox/index.jsx +3 -3
- package/src/gremlins/email/field/index.jsx +3 -3
- package/src/gremlins/email/index.jsx +3 -3
- package/src/gremlins/fieldset/index.jsx +6 -1
- package/src/gremlins/index.jsx +84 -19
- package/src/gremlins/number/field/index.jsx +3 -3
- package/src/gremlins/number/index.jsx +3 -3
- package/src/gremlins/password/field/index.jsx +3 -3
- package/src/gremlins/password/index.jsx +3 -3
- package/src/gremlins/radio/field/index.jsx +3 -3
- package/src/gremlins/radio/index.jsx +3 -3
- package/src/gremlins/select/field/index.jsx +3 -3
- package/src/gremlins/select/index.jsx +3 -3
- package/src/gremlins/text/field/index.jsx +3 -3
- package/src/gremlins/text/index.jsx +3 -3
- package/src/gremlins/textarea/field/index.jsx +3 -3
- package/src/gremlins/textarea/index.jsx +3 -3
package/babel.config.cjs
CHANGED
|
@@ -47,6 +47,7 @@ const plugins = [
|
|
|
47
47
|
/**
|
|
48
48
|
* Storybook
|
|
49
49
|
*/
|
|
50
|
+
'@modernpoacher/gremlins/common': './src/common/index.mjs',
|
|
50
51
|
'@modernpoacher/gremlins/gremlins/checkbox/field': './src/gremlins/checkbox/field/index.jsx',
|
|
51
52
|
'@modernpoacher/gremlins/gremlins/checkbox': './src/gremlins/checkbox/index.jsx',
|
|
52
53
|
'@modernpoacher/gremlins/gremlins/email/field': './src/gremlins/email/field/index.jsx',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modernpoacher/gremlins",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.178",
|
|
4
4
|
"description": "Gremlins",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Gremlins",
|
|
@@ -52,11 +52,11 @@
|
|
|
52
52
|
"@babel/register": "^7.24.6",
|
|
53
53
|
"@modernpoacher/design-system": "1.0.117",
|
|
54
54
|
"@modernpoacher/hooks": "^1.0.479",
|
|
55
|
-
"@storybook/addon-actions": "
|
|
56
|
-
"@storybook/addon-essentials": "
|
|
57
|
-
"@storybook/addon-links": "
|
|
58
|
-
"@storybook/react": "
|
|
59
|
-
"@storybook/react-webpack5": "
|
|
55
|
+
"@storybook/addon-actions": "7.6.20",
|
|
56
|
+
"@storybook/addon-essentials": "7.6.20",
|
|
57
|
+
"@storybook/addon-links": "7.6.20",
|
|
58
|
+
"@storybook/react": "7.6.20",
|
|
59
|
+
"@storybook/react-webpack5": "7.6.20",
|
|
60
60
|
"@types/react": "^18.3.3",
|
|
61
61
|
"@typescript-eslint/eslint-plugin": "^7.14.1",
|
|
62
62
|
"@typescript-eslint/parser": "^7.14.1",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"husky": "^9.0.11",
|
|
73
73
|
"jest": "^29.7.0",
|
|
74
74
|
"mini-css-extract-plugin": "^2.9.0",
|
|
75
|
-
"postcss": "^8.4.
|
|
75
|
+
"postcss": "^8.4.39",
|
|
76
76
|
"postcss-import": "^16.1.0",
|
|
77
77
|
"postcss-loader": "^8.1.1",
|
|
78
78
|
"postcss-map": "^0.11.0",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"remove-files-webpack-plugin": "^1.5.0",
|
|
84
84
|
"sass": "^1.77.6",
|
|
85
85
|
"sass-loader": "^14.2.1",
|
|
86
|
-
"storybook": "
|
|
86
|
+
"storybook": "7.6.20",
|
|
87
87
|
"webpack": "^5.92.1",
|
|
88
88
|
"webpack-cli": "^5.1.4"
|
|
89
89
|
},
|
|
@@ -95,6 +95,7 @@
|
|
|
95
95
|
"require": "./src/index.cjs",
|
|
96
96
|
"import": "./src/index.mjs"
|
|
97
97
|
},
|
|
98
|
+
"./common": "./src/common/index.mjs",
|
|
98
99
|
"./components/common/disabled": "./src/components/common/disabled/index.cjs",
|
|
99
100
|
"./components/common/readonly": "./src/components/common/readonly/index.cjs",
|
|
100
101
|
"./components/common/required": "./src/components/common/required/index.cjs",
|
|
@@ -4,13 +4,10 @@
|
|
|
4
4
|
import React, { Component } from 'react'
|
|
5
5
|
import PropTypes from 'prop-types'
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
function onClick () {
|
|
12
|
-
/* */
|
|
13
|
-
}
|
|
7
|
+
import {
|
|
8
|
+
DEFAULT_HANDLE_CHANGE,
|
|
9
|
+
DEFAULT_HANDLE_CLICK
|
|
10
|
+
} from '@modernpoacher/gremlins/common'
|
|
14
11
|
|
|
15
12
|
export default class Field extends Component {
|
|
16
13
|
getClassName () {
|
|
@@ -33,9 +30,9 @@ export default class Field extends Component {
|
|
|
33
30
|
render () {
|
|
34
31
|
const {
|
|
35
32
|
id,
|
|
36
|
-
required,
|
|
37
|
-
disabled,
|
|
38
|
-
readOnly,
|
|
33
|
+
required = false,
|
|
34
|
+
disabled = false,
|
|
35
|
+
readOnly = false,
|
|
39
36
|
tabIndex,
|
|
40
37
|
accessKey,
|
|
41
38
|
placeholder,
|
|
@@ -77,7 +74,7 @@ Field.defaultProps = {
|
|
|
77
74
|
required: false,
|
|
78
75
|
disabled: false,
|
|
79
76
|
readOnly: false,
|
|
80
|
-
onChange
|
|
77
|
+
onChange: DEFAULT_HANDLE_CHANGE
|
|
81
78
|
}
|
|
82
79
|
|
|
83
80
|
/**
|
|
@@ -92,7 +89,7 @@ export class ValueField extends Field {
|
|
|
92
89
|
}
|
|
93
90
|
|
|
94
91
|
handleChange = ({ target: { value } }) => {
|
|
95
|
-
const { onChange } = this.props
|
|
92
|
+
const { onChange = DEFAULT_HANDLE_CHANGE } = this.props
|
|
96
93
|
|
|
97
94
|
onChange(value)
|
|
98
95
|
}
|
|
@@ -121,13 +118,13 @@ export class CheckField extends Field {
|
|
|
121
118
|
}
|
|
122
119
|
|
|
123
120
|
handleClick = ({ target: { checked } }) => {
|
|
124
|
-
const { onClick } = this.props
|
|
121
|
+
const { onClick = DEFAULT_HANDLE_CLICK } = this.props
|
|
125
122
|
|
|
126
123
|
onClick(checked)
|
|
127
124
|
}
|
|
128
125
|
|
|
129
126
|
handleChange = ({ target: { checked } }) => {
|
|
130
|
-
const { onChange } = this.props
|
|
127
|
+
const { onChange = DEFAULT_HANDLE_CHANGE } = this.props
|
|
131
128
|
|
|
132
129
|
onChange(checked)
|
|
133
130
|
}
|
|
@@ -142,5 +139,5 @@ CheckField.propTypes = {
|
|
|
142
139
|
|
|
143
140
|
CheckField.defaultProps = {
|
|
144
141
|
...Field.defaultProps,
|
|
145
|
-
onClick
|
|
142
|
+
onClick: DEFAULT_HANDLE_CLICK
|
|
146
143
|
}
|
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
import React, { Component } from 'react'
|
|
8
8
|
import PropTypes from 'prop-types'
|
|
9
9
|
|
|
10
|
+
import {
|
|
11
|
+
DEFAULT_HANDLE_CHANGE
|
|
12
|
+
} from '@modernpoacher/gremlins/common'
|
|
13
|
+
|
|
10
14
|
export default class Group extends Component {
|
|
11
15
|
getClassName () {
|
|
12
16
|
return 'group'
|
|
@@ -25,7 +29,7 @@ export default class Group extends Component {
|
|
|
25
29
|
|
|
26
30
|
render () {
|
|
27
31
|
const {
|
|
28
|
-
onChange,
|
|
32
|
+
onChange = DEFAULT_HANDLE_CHANGE,
|
|
29
33
|
groupRef,
|
|
30
34
|
children
|
|
31
35
|
} = this.props
|
|
@@ -9,6 +9,11 @@ import React from 'react'
|
|
|
9
9
|
import classnames from 'classnames'
|
|
10
10
|
|
|
11
11
|
import { GroupGremlin as Gremlin } from '@modernpoacher/gremlins/gremlins'
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
DEFAULT_HANDLE_CHANGE
|
|
15
|
+
} from '@modernpoacher/gremlins/common'
|
|
16
|
+
|
|
12
17
|
import Group from './group/index.jsx'
|
|
13
18
|
|
|
14
19
|
export default class FieldsetGremlin extends Gremlin {
|
|
@@ -18,7 +23,7 @@ export default class FieldsetGremlin extends Gremlin {
|
|
|
18
23
|
|
|
19
24
|
renderGroup () {
|
|
20
25
|
const {
|
|
21
|
-
onChange,
|
|
26
|
+
onChange = DEFAULT_HANDLE_CHANGE,
|
|
22
27
|
children
|
|
23
28
|
} = this.props
|
|
24
29
|
|
package/src/gremlins/index.jsx
CHANGED
|
@@ -13,23 +13,24 @@ import React, { Component } from 'react'
|
|
|
13
13
|
import PropTypes from 'prop-types'
|
|
14
14
|
import classnames from 'classnames'
|
|
15
15
|
|
|
16
|
-
import
|
|
17
|
-
|
|
16
|
+
import {
|
|
17
|
+
DEFAULT_HANDLE_CHANGE,
|
|
18
|
+
DEFAULT_HANDLE_CLICK
|
|
19
|
+
} from '@modernpoacher/gremlins/common'
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
import Field, {
|
|
22
|
+
ValueField,
|
|
23
|
+
CheckField
|
|
24
|
+
} from '@modernpoacher/gremlins/components/field'
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
/* */
|
|
25
|
-
}
|
|
26
|
+
import Group from '@modernpoacher/gremlins/components/group'
|
|
26
27
|
|
|
27
28
|
export class FieldGremlin extends Component {
|
|
28
29
|
getClassName () {
|
|
29
30
|
const {
|
|
30
|
-
required,
|
|
31
|
-
disabled,
|
|
32
|
-
readOnly
|
|
31
|
+
required = false,
|
|
32
|
+
disabled = false,
|
|
33
|
+
readOnly = false
|
|
33
34
|
} = this.props
|
|
34
35
|
|
|
35
36
|
return classnames('gremlin', { required, disabled, readOnly })
|
|
@@ -67,13 +68,13 @@ export class FieldGremlin extends Component {
|
|
|
67
68
|
|
|
68
69
|
const {
|
|
69
70
|
name,
|
|
70
|
-
required,
|
|
71
|
-
disabled,
|
|
72
|
-
readOnly,
|
|
71
|
+
required = false,
|
|
72
|
+
disabled = false,
|
|
73
|
+
readOnly = false,
|
|
73
74
|
tabIndex,
|
|
74
75
|
accessKey,
|
|
75
76
|
placeholder,
|
|
76
|
-
onChange,
|
|
77
|
+
onChange = DEFAULT_HANDLE_CHANGE,
|
|
77
78
|
fieldRef
|
|
78
79
|
} = this.props
|
|
79
80
|
|
|
@@ -121,7 +122,7 @@ FieldGremlin.defaultProps = {
|
|
|
121
122
|
required: false,
|
|
122
123
|
disabled: false,
|
|
123
124
|
readOnly: false,
|
|
124
|
-
onChange
|
|
125
|
+
onChange: DEFAULT_HANDLE_CHANGE
|
|
125
126
|
}
|
|
126
127
|
|
|
127
128
|
export class ValueGremlin extends FieldGremlin {
|
|
@@ -131,6 +132,37 @@ export class ValueGremlin extends FieldGremlin {
|
|
|
131
132
|
(props.value !== this.props.value)
|
|
132
133
|
)
|
|
133
134
|
}
|
|
135
|
+
|
|
136
|
+
renderField () {
|
|
137
|
+
const id = this.getId()
|
|
138
|
+
|
|
139
|
+
const {
|
|
140
|
+
name,
|
|
141
|
+
required = false,
|
|
142
|
+
disabled = false,
|
|
143
|
+
readOnly = false,
|
|
144
|
+
tabIndex,
|
|
145
|
+
accessKey,
|
|
146
|
+
placeholder,
|
|
147
|
+
onChange = DEFAULT_HANDLE_CHANGE,
|
|
148
|
+
fieldRef
|
|
149
|
+
} = this.props
|
|
150
|
+
|
|
151
|
+
return (
|
|
152
|
+
<ValueField
|
|
153
|
+
id={id}
|
|
154
|
+
name={name}
|
|
155
|
+
required={required}
|
|
156
|
+
disabled={disabled}
|
|
157
|
+
readOnly={readOnly}
|
|
158
|
+
tabIndex={tabIndex}
|
|
159
|
+
accessKey={accessKey}
|
|
160
|
+
placeholder={placeholder}
|
|
161
|
+
onChange={onChange}
|
|
162
|
+
fieldRef={fieldRef}
|
|
163
|
+
/>
|
|
164
|
+
)
|
|
165
|
+
}
|
|
134
166
|
}
|
|
135
167
|
|
|
136
168
|
ValueGremlin.propTypes = {
|
|
@@ -151,6 +183,39 @@ export class CheckGremlin extends FieldGremlin {
|
|
|
151
183
|
(props.onClick !== this.props.onClick)
|
|
152
184
|
)
|
|
153
185
|
}
|
|
186
|
+
|
|
187
|
+
renderField () {
|
|
188
|
+
const id = this.getId()
|
|
189
|
+
|
|
190
|
+
const {
|
|
191
|
+
name,
|
|
192
|
+
required = false,
|
|
193
|
+
disabled = false,
|
|
194
|
+
readOnly = false,
|
|
195
|
+
tabIndex,
|
|
196
|
+
accessKey,
|
|
197
|
+
placeholder,
|
|
198
|
+
onChange = DEFAULT_HANDLE_CHANGE,
|
|
199
|
+
onClick = DEFAULT_HANDLE_CLICK,
|
|
200
|
+
fieldRef
|
|
201
|
+
} = this.props
|
|
202
|
+
|
|
203
|
+
return (
|
|
204
|
+
<CheckField
|
|
205
|
+
id={id}
|
|
206
|
+
name={name}
|
|
207
|
+
required={required}
|
|
208
|
+
disabled={disabled}
|
|
209
|
+
readOnly={readOnly}
|
|
210
|
+
tabIndex={tabIndex}
|
|
211
|
+
accessKey={accessKey}
|
|
212
|
+
placeholder={placeholder}
|
|
213
|
+
onChange={onChange}
|
|
214
|
+
onClick={onClick}
|
|
215
|
+
fieldRef={fieldRef}
|
|
216
|
+
/>
|
|
217
|
+
)
|
|
218
|
+
}
|
|
154
219
|
}
|
|
155
220
|
|
|
156
221
|
CheckGremlin.propTypes = {
|
|
@@ -162,7 +227,7 @@ CheckGremlin.propTypes = {
|
|
|
162
227
|
|
|
163
228
|
CheckGremlin.defaultProps = {
|
|
164
229
|
...FieldGremlin.defaultProps,
|
|
165
|
-
onClick
|
|
230
|
+
onClick: DEFAULT_HANDLE_CLICK
|
|
166
231
|
}
|
|
167
232
|
|
|
168
233
|
export class GroupGremlin extends Component {
|
|
@@ -183,7 +248,7 @@ export class GroupGremlin extends Component {
|
|
|
183
248
|
|
|
184
249
|
renderGroup () {
|
|
185
250
|
const {
|
|
186
|
-
onChange,
|
|
251
|
+
onChange = DEFAULT_HANDLE_CHANGE,
|
|
187
252
|
groupRef,
|
|
188
253
|
children
|
|
189
254
|
} = this.props
|
|
@@ -222,5 +287,5 @@ GroupGremlin.propTypes = {
|
|
|
222
287
|
}
|
|
223
288
|
|
|
224
289
|
GroupGremlin.defaultProps = {
|
|
225
|
-
onChange
|
|
290
|
+
onChange: DEFAULT_HANDLE_CHANGE
|
|
226
291
|
}
|