@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
package/README.md
ADDED
package/babel.config.cjs
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
const debug = require('debug')
|
|
2
|
+
|
|
3
|
+
const log = debug('@modernpoacher/gremlins')
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
env: {
|
|
7
|
+
NODE_ENV = 'development'
|
|
8
|
+
}
|
|
9
|
+
} = process
|
|
10
|
+
|
|
11
|
+
log('`gremlins` is awake')
|
|
12
|
+
|
|
13
|
+
function env () {
|
|
14
|
+
log({ NODE_ENV })
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
NODE_ENV === 'production'
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const presets = [
|
|
22
|
+
[
|
|
23
|
+
'@babel/env', {
|
|
24
|
+
targets: {
|
|
25
|
+
node: 'current',
|
|
26
|
+
browsers: [
|
|
27
|
+
'last 4 versions',
|
|
28
|
+
'safari >= 9',
|
|
29
|
+
'ios >= 8',
|
|
30
|
+
'ie >= 9',
|
|
31
|
+
'> 2%'
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
useBuiltIns: 'usage',
|
|
35
|
+
corejs: 3
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
'@babel/react'
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
const plugins = [
|
|
42
|
+
'@babel/syntax-jsx',
|
|
43
|
+
'@babel/proposal-export-default-from',
|
|
44
|
+
'@babel/proposal-export-namespace-from',
|
|
45
|
+
[
|
|
46
|
+
'@babel/proposal-class-properties',
|
|
47
|
+
{
|
|
48
|
+
loose: false
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
[
|
|
52
|
+
'module-resolver', {
|
|
53
|
+
alias: {
|
|
54
|
+
/**
|
|
55
|
+
* Storybook
|
|
56
|
+
*/
|
|
57
|
+
'@modernpoacher/gremlins/gremlins/checkbox/field': './src/gremlins/checkbox/field/index.jsx',
|
|
58
|
+
'@modernpoacher/gremlins/gremlins/checkbox': './src/gremlins/checkbox/index.jsx',
|
|
59
|
+
'@modernpoacher/gremlins/gremlins/email/field': './src/gremlins/email/field/index.jsx',
|
|
60
|
+
'@modernpoacher/gremlins/gremlins/email': './src/gremlins/email/index.jsx',
|
|
61
|
+
'@modernpoacher/gremlins/gremlins/number/field': './src/gremlins/number/field/index.jsx',
|
|
62
|
+
'@modernpoacher/gremlins/gremlins/number': './src/gremlins/number/index.jsx',
|
|
63
|
+
'@modernpoacher/gremlins/gremlins/password/field': './src/gremlins/password/field/index.jsx',
|
|
64
|
+
'@modernpoacher/gremlins/gremlins/password': './src/gremlins/password/index.jsx',
|
|
65
|
+
'@modernpoacher/gremlins/gremlins/radio/field': './src/gremlins/radio/field/index.jsx',
|
|
66
|
+
'@modernpoacher/gremlins/gremlins/radio': './src/gremlins/radio/index.jsx',
|
|
67
|
+
'@modernpoacher/gremlins/gremlins/select/field': './src/gremlins/select/field/index.jsx',
|
|
68
|
+
'@modernpoacher/gremlins/gremlins/select': './src/gremlins/select/index.jsx',
|
|
69
|
+
'@modernpoacher/gremlins/gremlins/text/field': './src/gremlins/text/field/index.jsx',
|
|
70
|
+
'@modernpoacher/gremlins/gremlins/text': './src/gremlins/text/index.jsx',
|
|
71
|
+
'@modernpoacher/gremlins/gremlins/textarea/field': './src/gremlins/textarea/field/index.jsx',
|
|
72
|
+
'@modernpoacher/gremlins/gremlins/textarea': './src/gremlins/textarea/index.jsx',
|
|
73
|
+
'@modernpoacher/gremlins/gremlins/fieldset/group': './src/gremlins/fieldset/group/index.jsx',
|
|
74
|
+
'@modernpoacher/gremlins/gremlins/fieldset': './src/gremlins/fieldset/index.jsx',
|
|
75
|
+
'@modernpoacher/gremlins/gremlins': './src/gremlins/index.jsx',
|
|
76
|
+
'@modernpoacher/gremlins/components/common/disabled': './src/components/common/disabled/index.jsx',
|
|
77
|
+
'@modernpoacher/gremlins/components/common/readonly': './src/components/common/readonly/index.jsx',
|
|
78
|
+
'@modernpoacher/gremlins/components/common/required': './src/components/common/required/index.jsx',
|
|
79
|
+
'@modernpoacher/gremlins/components/common/text-content': './src/components/common/text-content/index.jsx',
|
|
80
|
+
'@modernpoacher/gremlins/components/field': './src/components/field/index.jsx',
|
|
81
|
+
'#stories/state/checkbox': './stories/state/checkbox/index.jsx',
|
|
82
|
+
'#stories/state/email': './stories/state/email/index.jsx',
|
|
83
|
+
'#stories/state/number': './stories/state/number/index.jsx',
|
|
84
|
+
'#stories/state/password': './stories/state/password/index.jsx',
|
|
85
|
+
'#stories/state/radio': './stories/state/radio/index.jsx',
|
|
86
|
+
'#stories/state/select': './stories/state/select/index.jsx',
|
|
87
|
+
'#stories/state/text': './stories/state/text/index.jsx',
|
|
88
|
+
'#stories/state/textarea': './stories/state/textarea/index.jsx',
|
|
89
|
+
'#stories/state': './stories/state/index.jsx',
|
|
90
|
+
'#stories': './stories'
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
module.exports = (api) => {
|
|
97
|
+
if (api) api.cache.using(env)
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
presets,
|
|
101
|
+
plugins,
|
|
102
|
+
ignore: [
|
|
103
|
+
/node_modules\/(?!@modernpoacher\/cogs|@modernpoacher\/gremlins|@modernpoacher\/sprockets)/
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@modernpoacher/gremlins",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Gremlins",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Gremlins",
|
|
7
|
+
"React"
|
|
8
|
+
],
|
|
9
|
+
"main": "./src/index.cjs",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"author": {
|
|
12
|
+
"name": "Jonathan Perry for Modern Poacher Limited",
|
|
13
|
+
"email": "modernpoacher@modernpoacher.com",
|
|
14
|
+
"url": "https://modernpoacher.com"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=18.5.0"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git@github.com/modernpoacher/gremlins.git"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"prepublishOnly": "cross-env NODE_ENV=production npm run build",
|
|
26
|
+
"build": "cross-env DEBUG=@modernpoacher/gremlins npm run gulp -- build",
|
|
27
|
+
"build:watch": "cross-env DEBUG=@modernpoacher/gremlins npm run gulp -- build:watch",
|
|
28
|
+
"transform": "cross-env DEBUG=@modernpoacher/gremlins npm run gulp -- transform",
|
|
29
|
+
"transform:watch": "cross-env DEBUG=@modernpoacher/gremlins npm run gulp -- transform:watch",
|
|
30
|
+
"pregulp": "npm run nvm",
|
|
31
|
+
"gulp": "gulp --color",
|
|
32
|
+
"prelint": "npm run nvm",
|
|
33
|
+
"lint": "cross-env NODE_ENV=production eslint . .storybook --ext .mjs,.cjs,.jsx,.mts,.cts",
|
|
34
|
+
"lint:fix": "npm run lint -- --fix",
|
|
35
|
+
"pretest": "npm run nvm",
|
|
36
|
+
"test": "cross-env NODE_ENV=test jest",
|
|
37
|
+
"nvm": "bash nvm.sh",
|
|
38
|
+
"prestorybook": "npm run build && npm run transform",
|
|
39
|
+
"storybook": "storybook dev -p 6008",
|
|
40
|
+
"prepare": "husky install",
|
|
41
|
+
"build-storybook": "storybook build"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"classnames": "^2.3.2",
|
|
45
|
+
"debug": "^4.3.4"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@babel/core": "^7.22.11",
|
|
49
|
+
"@babel/eslint-parser": "^7.22.11",
|
|
50
|
+
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
51
|
+
"@babel/plugin-proposal-export-default-from": "^7.22.5",
|
|
52
|
+
"@babel/plugin-proposal-export-namespace-from": "^7.18.9",
|
|
53
|
+
"@babel/preset-env": "^7.22.14",
|
|
54
|
+
"@babel/preset-react": "^7.22.5",
|
|
55
|
+
"@babel/register": "^7.22.5",
|
|
56
|
+
"@modernpoacher/design-system": "1.0.71",
|
|
57
|
+
"@modernpoacher/hooks": "^1.0.432",
|
|
58
|
+
"@sequencemedia/gulp": "^1.1.63",
|
|
59
|
+
"@sequencemedia/gulp-clean-css": "^1.0.29",
|
|
60
|
+
"@sequencemedia/gulp-css-purge": "^1.1.22",
|
|
61
|
+
"@sequencemedia/gulp-debug": "^1.0.33",
|
|
62
|
+
"@sequencemedia/gulp-postcss": "^1.0.32",
|
|
63
|
+
"@sequencemedia/gulp-sass": "^1.0.28",
|
|
64
|
+
"@sequencemedia/gulp-sourcemaps": "^1.0.29",
|
|
65
|
+
"@storybook/addon-actions": "^7.4.0",
|
|
66
|
+
"@storybook/addon-essentials": "^7.4.0",
|
|
67
|
+
"@storybook/addon-links": "^7.4.0",
|
|
68
|
+
"@storybook/react": "^7.4.0",
|
|
69
|
+
"@storybook/react-webpack5": "^7.4.0",
|
|
70
|
+
"@types/react": "^18.2.21",
|
|
71
|
+
"@typescript-eslint/eslint-plugin": "5.61.0",
|
|
72
|
+
"@typescript-eslint/parser": "5.61.0",
|
|
73
|
+
"autoprefixer": "^10.4.15",
|
|
74
|
+
"babel-plugin-module-resolver": "^5.0.0",
|
|
75
|
+
"core-js": "^3.32.1",
|
|
76
|
+
"cross-env": "^7.0.3",
|
|
77
|
+
"cssnano": "^6.0.1",
|
|
78
|
+
"del": "^7.1.0",
|
|
79
|
+
"eslint": "^8.48.0",
|
|
80
|
+
"eslint-config-standard": "^17.1.0",
|
|
81
|
+
"eslint-config-standard-with-typescript": "35.0.0",
|
|
82
|
+
"eslint-import-resolver-babel-module": "^5.3.2",
|
|
83
|
+
"eslint-plugin-react": "^7.33.2",
|
|
84
|
+
"glob-all": "^3.3.1",
|
|
85
|
+
"husky": "^8.0.3",
|
|
86
|
+
"jest": "^29.6.4",
|
|
87
|
+
"postcss": "^8.4.29",
|
|
88
|
+
"postcss-easy-import": "^4.0.0",
|
|
89
|
+
"postcss-map": "^0.11.0",
|
|
90
|
+
"postcss-normalize": "^10.0.1",
|
|
91
|
+
"postcss-scss": "^4.0.7",
|
|
92
|
+
"prop-types": "^15.8.1",
|
|
93
|
+
"react": "^18.2.0",
|
|
94
|
+
"react-dom": "^18.2.0",
|
|
95
|
+
"react-test-renderer": "^18.2.0",
|
|
96
|
+
"regenerator-runtime": "^0.14.0",
|
|
97
|
+
"sass": "^1.66.1",
|
|
98
|
+
"storybook": "^7.4.0",
|
|
99
|
+
"vinyl-paths": "^5.0.0"
|
|
100
|
+
},
|
|
101
|
+
"imports": {
|
|
102
|
+
"#build/gulp/build/*": "./build/gulp/build/*.mjs",
|
|
103
|
+
"#build/gulp/build": "./build/gulp/build/index.mjs",
|
|
104
|
+
"#build/gulp/transform": "./build/gulp/transform/index.mjs",
|
|
105
|
+
"#build/gulp/*": "./build/gulp/*.mjs",
|
|
106
|
+
"#build/paths": "./build/paths.mjs"
|
|
107
|
+
},
|
|
108
|
+
"exports": {
|
|
109
|
+
".": {
|
|
110
|
+
"require": "./src/index.cjs",
|
|
111
|
+
"import": "./src/index.mjs"
|
|
112
|
+
},
|
|
113
|
+
"./gremlins/checkbox/field": "./src/gremlins/checkbox/field/index.cjs",
|
|
114
|
+
"./gremlins/checkbox": "./src/gremlins/checkbox/index.cjs",
|
|
115
|
+
"./gremlins/email/field": "./src/gremlins/email/field/index.cjs",
|
|
116
|
+
"./gremlins/email": "./src/gremlins/email/index.cjs",
|
|
117
|
+
"./gremlins/number/field": "./src/gremlins/number/field/index.cjs",
|
|
118
|
+
"./gremlins/number": "./src/gremlins/number/index.cjs",
|
|
119
|
+
"./gremlins/password/field": "./src/gremlins/password/field/index.cjs",
|
|
120
|
+
"./gremlins/password": "./src/gremlins/password/index.cjs",
|
|
121
|
+
"./gremlins/radio/field": "./src/gremlins/radio/field/index.cjs",
|
|
122
|
+
"./gremlins/radio": "./src/gremlins/radio/index.cjs",
|
|
123
|
+
"./gremlins/select/field": "./src/gremlins/select/field/index.cjs",
|
|
124
|
+
"./gremlins/select": "./src/gremlins/select/index.cjs",
|
|
125
|
+
"./gremlins/text/field": "./src/gremlins/text/field/index.cjs",
|
|
126
|
+
"./gremlins/text": "./src/gremlins/text/index.cjs",
|
|
127
|
+
"./gremlins/textarea/field": "./src/gremlins/textarea/field/index.cjs",
|
|
128
|
+
"./gremlins/textarea": "./src/gremlins/textarea/index.cjs",
|
|
129
|
+
"./gremlins/fieldset/group": "./src/gremlins/fieldset/group/index.cjs",
|
|
130
|
+
"./gremlins/fieldset": "./src/gremlins/fieldset/index.cjs",
|
|
131
|
+
"./gremlins": "./src/gremlins/index.cjs",
|
|
132
|
+
"./components/common/disabled": "./src/components/common/disabled/index.cjs",
|
|
133
|
+
"./components/common/readonly": "./src/components/common/readonly/index.cjs",
|
|
134
|
+
"./components/common/required": "./src/components/common/required/index.cjs",
|
|
135
|
+
"./components/common/text-content": "./src/components/common/text-content/index.cjs",
|
|
136
|
+
"./components/field": "./src/components/field/index.cjs",
|
|
137
|
+
"./components/group": "./src/components/group/index.cjs"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -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/components/common/disabled')
|
|
10
|
+
|
|
11
|
+
log('`gremlins` is awake')
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
default: component
|
|
15
|
+
} = require('./index.jsx')
|
|
16
|
+
|
|
17
|
+
module.exports = component
|
|
@@ -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/components/common/readonly')
|
|
10
|
+
|
|
11
|
+
log('`gremlins` is awake')
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
default: component
|
|
15
|
+
} = require('./index.jsx')
|
|
16
|
+
|
|
17
|
+
module.exports = component
|
|
@@ -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/components/common/readonly')
|
|
10
|
+
|
|
11
|
+
log('`gremlins` is awake')
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
default: component
|
|
15
|
+
} = require('./index.jsx')
|
|
16
|
+
|
|
17
|
+
module.exports = component
|
|
@@ -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/components/common/text-content')
|
|
10
|
+
|
|
11
|
+
log('`gremlins` is awake')
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
default: component
|
|
15
|
+
} = require('./index.jsx')
|
|
16
|
+
|
|
17
|
+
module.exports = component
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TextContent component
|
|
3
|
+
*
|
|
4
|
+
* @typedef {import('@modernpoacher/gremlins/components/common/text-content').TextContentProps} TextContentProps
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react'
|
|
8
|
+
import PropTypes from 'prop-types'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @param {TextContentProps}
|
|
12
|
+
* @returns {React.JSX.Element}
|
|
13
|
+
*/
|
|
14
|
+
const TextContent = ({ textContent }) => (
|
|
15
|
+
<span className='text-content'>
|
|
16
|
+
{textContent}
|
|
17
|
+
</span>
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
TextContent.propTypes = {
|
|
21
|
+
textContent: PropTypes.string.isRequired
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default TextContent
|
|
@@ -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/components/field')
|
|
10
|
+
|
|
11
|
+
log('`gremlins` is awake')
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Exports default, etc
|
|
15
|
+
*/
|
|
16
|
+
module.exports = require('./index.jsx')
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Field component
|
|
3
|
+
*/
|
|
4
|
+
import React, { Component } from 'react'
|
|
5
|
+
import PropTypes from 'prop-types'
|
|
6
|
+
|
|
7
|
+
function onChange () {
|
|
8
|
+
/* */
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function onClick () {
|
|
12
|
+
/* */
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default class Field extends Component {
|
|
16
|
+
getClassName () {
|
|
17
|
+
return 'input'
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
shouldComponentUpdate (props) {
|
|
21
|
+
return (
|
|
22
|
+
(props.id !== this.props.id) ||
|
|
23
|
+
(props.required !== this.props.required) ||
|
|
24
|
+
(props.disabled !== this.props.disabled) ||
|
|
25
|
+
(props.readOnly !== this.props.readOnly) ||
|
|
26
|
+
(props.tabIndex !== this.props.tabIndex) ||
|
|
27
|
+
(props.accessKey !== this.props.accessKey) ||
|
|
28
|
+
(props.placeholder !== this.props.placeholder) ||
|
|
29
|
+
(props.onChange !== this.props.onChange)
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
render () {
|
|
34
|
+
const {
|
|
35
|
+
id,
|
|
36
|
+
required,
|
|
37
|
+
disabled,
|
|
38
|
+
readOnly,
|
|
39
|
+
tabIndex,
|
|
40
|
+
accessKey,
|
|
41
|
+
placeholder,
|
|
42
|
+
fieldRef
|
|
43
|
+
} = this.props
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<input
|
|
47
|
+
id={id}
|
|
48
|
+
required={required}
|
|
49
|
+
disabled={disabled}
|
|
50
|
+
readOnly={readOnly}
|
|
51
|
+
tabIndex={tabIndex}
|
|
52
|
+
accessKey={accessKey}
|
|
53
|
+
placeholder={placeholder}
|
|
54
|
+
className={this.getClassName()}
|
|
55
|
+
ref={fieldRef}
|
|
56
|
+
/>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
Field.propTypes = {
|
|
62
|
+
id: PropTypes.string,
|
|
63
|
+
name: PropTypes.string.isRequired,
|
|
64
|
+
required: PropTypes.bool,
|
|
65
|
+
disabled: PropTypes.bool,
|
|
66
|
+
readOnly: PropTypes.bool,
|
|
67
|
+
tabIndex: PropTypes.number,
|
|
68
|
+
accessKey: PropTypes.string,
|
|
69
|
+
placeholder: PropTypes.string,
|
|
70
|
+
onChange: PropTypes.func,
|
|
71
|
+
fieldRef: PropTypes.shape({
|
|
72
|
+
current: PropTypes.shape().isRequired
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
Field.defaultProps = {
|
|
77
|
+
required: false,
|
|
78
|
+
disabled: false,
|
|
79
|
+
readOnly: false,
|
|
80
|
+
onChange
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* ValueField component
|
|
85
|
+
*/
|
|
86
|
+
export class ValueField extends Field {
|
|
87
|
+
shouldComponentUpdate (props) {
|
|
88
|
+
return (
|
|
89
|
+
super.shouldComponentUpdate(props) ||
|
|
90
|
+
(props.value !== this.props.value)
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
handleChange = ({ target: { value } }) => {
|
|
95
|
+
const { onChange } = this.props
|
|
96
|
+
|
|
97
|
+
onChange(value)
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
ValueField.propTypes = {
|
|
102
|
+
...Field.propTypes,
|
|
103
|
+
value: PropTypes.string,
|
|
104
|
+
defaultValue: PropTypes.string
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
ValueField.defaultProps = {
|
|
108
|
+
...Field.defaultProps
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* CheckField component
|
|
113
|
+
*/
|
|
114
|
+
export class CheckField extends Field {
|
|
115
|
+
shouldComponentUpdate (props) {
|
|
116
|
+
return (
|
|
117
|
+
super.shouldComponentUpdate(props) ||
|
|
118
|
+
(props.checked !== this.props.checked) ||
|
|
119
|
+
(props.onClick !== this.props.onClick)
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
handleClick = ({ target: { checked } }) => {
|
|
124
|
+
const { onClick } = this.props
|
|
125
|
+
|
|
126
|
+
onClick(checked)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
handleChange = ({ target: { checked } }) => {
|
|
130
|
+
const { onChange } = this.props
|
|
131
|
+
|
|
132
|
+
onChange(checked)
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
CheckField.propTypes = {
|
|
137
|
+
...Field.propTypes,
|
|
138
|
+
checked: PropTypes.bool,
|
|
139
|
+
defaultChecked: PropTypes.bool,
|
|
140
|
+
onClick: PropTypes.func
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
CheckField.defaultProps = {
|
|
144
|
+
...Field.defaultProps,
|
|
145
|
+
onClick
|
|
146
|
+
}
|
|
@@ -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/sprockets/components/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,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Group component
|
|
3
|
+
*
|
|
4
|
+
* @typedef {import('@modernpoacher/gremlins/components/group').GroupProps} GroupProps
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React, { Component } from 'react'
|
|
8
|
+
import PropTypes from 'prop-types'
|
|
9
|
+
|
|
10
|
+
export default class Group extends Component {
|
|
11
|
+
getClassName () {
|
|
12
|
+
return 'group'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {GroupProps} props
|
|
17
|
+
* @returns {boolean}
|
|
18
|
+
*/
|
|
19
|
+
shouldComponentUpdate (props) {
|
|
20
|
+
return (
|
|
21
|
+
(props.onChange !== this.props.onChange) ||
|
|
22
|
+
(props.children !== this.props.children)
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
render () {
|
|
27
|
+
const {
|
|
28
|
+
onChange,
|
|
29
|
+
groupRef,
|
|
30
|
+
children
|
|
31
|
+
} = this.props
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<fieldset
|
|
35
|
+
onChange={onChange}
|
|
36
|
+
className={this.getClassName()}
|
|
37
|
+
ref={groupRef}>
|
|
38
|
+
{children}
|
|
39
|
+
</fieldset>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
Group.propTypes = {
|
|
45
|
+
onChange: PropTypes.func,
|
|
46
|
+
children: PropTypes.oneOfType([
|
|
47
|
+
PropTypes.node,
|
|
48
|
+
PropTypes.arrayOf(
|
|
49
|
+
PropTypes.node
|
|
50
|
+
)
|
|
51
|
+
]),
|
|
52
|
+
groupRef: PropTypes.shape({
|
|
53
|
+
current: PropTypes.shape().isRequired
|
|
54
|
+
})
|
|
55
|
+
}
|
|
@@ -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/checkbox/field')
|
|
10
|
+
|
|
11
|
+
log('`gremlins` is awake')
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
default: component
|
|
15
|
+
} = require('./index.jsx')
|
|
16
|
+
|
|
17
|
+
module.exports = component
|