shinkansen-cogs 1.5.62 → 1.5.65
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/package.json +6 -7
- package/src/components/common/text-content/index.jsx +10 -0
- package/src/transformers/error-message/index.mjs +59 -51
- package/jsconfig.json +0 -11
- package/src/index.d.mts +0 -12
- package/tsconfig.json +0 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shinkansen-cogs",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.65",
|
|
4
4
|
"description": "Shinkansen Cogs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Shinkansen",
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
],
|
|
13
13
|
"main": "./src/index.cjs",
|
|
14
14
|
"type": "module",
|
|
15
|
-
"types": "./src/index.d.mts",
|
|
16
15
|
"author": "Jonathan Perry for Modern Poacher Limited <modernpoacher@modernpoacher.com>",
|
|
17
16
|
"license": "MIT",
|
|
18
17
|
"engines": {
|
|
@@ -31,7 +30,7 @@
|
|
|
31
30
|
"pregulp": "npm run nvm",
|
|
32
31
|
"gulp": "gulp --color",
|
|
33
32
|
"prelint": "npm run nvm",
|
|
34
|
-
"lint": "cross-env NODE_ENV=production eslint . .storybook --ext .mjs --ext .cjs --ext .jsx --ext .mts",
|
|
33
|
+
"lint": "cross-env NODE_ENV=production eslint . .storybook --ext .mjs --ext .cjs --ext .jsx --ext .mts --ext .cts",
|
|
35
34
|
"lint:fix": "npm run lint -- --fix",
|
|
36
35
|
"pretest": "npm run nvm",
|
|
37
36
|
"test": "cross-env NODE_ENV=test jest --collect-coverage false --verbose --run-in-band",
|
|
@@ -54,16 +53,16 @@
|
|
|
54
53
|
"@babel/preset-env": "^7.21.5",
|
|
55
54
|
"@babel/preset-react": "^7.18.6",
|
|
56
55
|
"@babel/register": "^7.21.0",
|
|
57
|
-
"@modernpoacher/design-system": "1.0.
|
|
58
|
-
"@modernpoacher/hooks": "^1.0.
|
|
56
|
+
"@modernpoacher/design-system": "1.0.7",
|
|
57
|
+
"@modernpoacher/hooks": "^1.0.397",
|
|
59
58
|
"@sequencemedia/gulp": "^1.0.7",
|
|
60
59
|
"@storybook/addon-actions": "6.5.12",
|
|
61
60
|
"@storybook/addon-essentials": "6.5.12",
|
|
62
61
|
"@storybook/addon-links": "6.5.12",
|
|
63
62
|
"@storybook/react": "6.5.12",
|
|
64
63
|
"@types/react": "^18.2.6",
|
|
65
|
-
"@typescript-eslint/eslint-plugin": "^5.59.
|
|
66
|
-
"@typescript-eslint/parser": "^5.59.
|
|
64
|
+
"@typescript-eslint/eslint-plugin": "^5.59.5",
|
|
65
|
+
"@typescript-eslint/parser": "^5.59.5",
|
|
67
66
|
"autoprefixer": "^10.4.14",
|
|
68
67
|
"babel-plugin-module-resolver": "^5.0.0",
|
|
69
68
|
"core-js": "^3.30.2",
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TextContent component
|
|
3
|
+
*
|
|
4
|
+
* @typedef {import('shinkansen-cogs/components/common/text-content').TextContentProps} TextContentProps
|
|
5
|
+
*/
|
|
6
|
+
|
|
1
7
|
import React from 'react'
|
|
2
8
|
import PropTypes from 'prop-types'
|
|
3
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @param {TextContentProps}
|
|
12
|
+
* @returns {React.JSX.Element}
|
|
13
|
+
*/
|
|
4
14
|
const TextContent = ({ textContent }) => (
|
|
5
15
|
<span className='text-content'>
|
|
6
16
|
{textContent}
|
|
@@ -4,145 +4,145 @@ const log = debug('shinkansen-cogs/transformers/error-message')
|
|
|
4
4
|
|
|
5
5
|
log('`shinkansen` is awake')
|
|
6
6
|
|
|
7
|
-
export function getErrorTextForMaxItems () {
|
|
7
|
+
export function getErrorTextForMaxItems () {
|
|
8
8
|
log('getErrorTextForMaxItems')
|
|
9
9
|
|
|
10
10
|
return 'Max items'
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export function getErrorTextForMinItems () {
|
|
13
|
+
export function getErrorTextForMinItems () {
|
|
14
14
|
log('getErrorTextForMinItems')
|
|
15
15
|
|
|
16
16
|
return 'Min items'
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export function getErrorTextForMaxLength () {
|
|
19
|
+
export function getErrorTextForMaxLength () {
|
|
20
20
|
log('getErrorTextForMaxLength')
|
|
21
21
|
|
|
22
22
|
return 'Max length'
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export function getErrorTextForMinLength () {
|
|
25
|
+
export function getErrorTextForMinLength () {
|
|
26
26
|
log('getErrorTextForMinLength')
|
|
27
27
|
|
|
28
28
|
return 'Min length'
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export function getErrorTextForMaxProperties () {
|
|
31
|
+
export function getErrorTextForMaxProperties () {
|
|
32
32
|
log('getErrorTextForMaxProperties')
|
|
33
33
|
|
|
34
34
|
return 'Max properties'
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export function getErrorTextForMinProperties () {
|
|
37
|
+
export function getErrorTextForMinProperties () {
|
|
38
38
|
log('getErrorTextForMinProperties')
|
|
39
39
|
|
|
40
40
|
return 'Min properties'
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export function getErrorTextForAdditionalItems () {
|
|
43
|
+
export function getErrorTextForAdditionalItems () {
|
|
44
44
|
log('getErrorTextForAdditionalItems')
|
|
45
45
|
|
|
46
46
|
return 'Additional items'
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export function getErrorTextForMaximum () {
|
|
49
|
+
export function getErrorTextForMaximum () {
|
|
50
50
|
log('getErrorTextForMaximum')
|
|
51
51
|
|
|
52
52
|
return 'Maximum'
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
export function getErrorTextForMinimum () {
|
|
55
|
+
export function getErrorTextForMinimum () {
|
|
56
56
|
log('getErrorTextForMinimum')
|
|
57
57
|
|
|
58
58
|
return 'Minimum'
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
export function getErrorTextForFormat () {
|
|
61
|
+
export function getErrorTextForFormat () {
|
|
62
62
|
log('getErrorTextForFormat')
|
|
63
63
|
|
|
64
64
|
return 'Format'
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
export function getErrorTextForAdditionalProperties () {
|
|
67
|
+
export function getErrorTextForAdditionalProperties () {
|
|
68
68
|
log('getErrorTextForAdditionalProperties')
|
|
69
69
|
|
|
70
70
|
return 'Additional properties'
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
export function getErrorTextForDependencies () {
|
|
73
|
+
export function getErrorTextForDependencies () {
|
|
74
74
|
log('getErrorTextForDependencies')
|
|
75
75
|
|
|
76
76
|
return 'Dependencies'
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
export function getErrorTextForUniqeItems () {
|
|
79
|
+
export function getErrorTextForUniqeItems () {
|
|
80
80
|
log('getErrorTextForUniqeItems')
|
|
81
81
|
|
|
82
82
|
return 'Unique items'
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
export function getErrorTextForPropertyRequired () {
|
|
85
|
+
export function getErrorTextForPropertyRequired () {
|
|
86
86
|
log('getErrorTextForPropertyRequired')
|
|
87
87
|
|
|
88
88
|
return 'Property required'
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
export function getErrorTextForPropertyNames () {
|
|
91
|
+
export function getErrorTextForPropertyNames () {
|
|
92
92
|
log('getErrorTextForPropertyNames')
|
|
93
93
|
|
|
94
94
|
return 'Property names'
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
export function getErrorTextForPatternRequired () {
|
|
97
|
+
export function getErrorTextForPatternRequired () {
|
|
98
98
|
log('getErrorTextForMultipleOf')
|
|
99
99
|
|
|
100
100
|
return 'Pattern required'
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
export function getErrorTextForMultipleOf () {
|
|
103
|
+
export function getErrorTextForMultipleOf () {
|
|
104
104
|
log('getErrorTextForMultipleOf')
|
|
105
105
|
|
|
106
106
|
return 'Multiple of'
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
export function getErrorTextForPattern () {
|
|
109
|
+
export function getErrorTextForPattern () {
|
|
110
110
|
log('getErrorTextForPattern')
|
|
111
111
|
|
|
112
112
|
return 'Pattern'
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
export function getErrorTextForConst () {
|
|
115
|
+
export function getErrorTextForConst () {
|
|
116
116
|
log('getErrorTextForConst')
|
|
117
117
|
|
|
118
118
|
return 'Const'
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
export function getErrorTextForEnum () {
|
|
121
|
+
export function getErrorTextForEnum () {
|
|
122
122
|
log('getErrorTextForEnum')
|
|
123
123
|
|
|
124
124
|
return 'Enum'
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
export function getErrorTextFor$Ref () {
|
|
127
|
+
export function getErrorTextFor$Ref () {
|
|
128
128
|
log('getErrorTextFor$Ref')
|
|
129
129
|
|
|
130
130
|
return '$Ref'
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
export function getErrorTextForOneOf () {
|
|
133
|
+
export function getErrorTextForOneOf () {
|
|
134
134
|
log('getErrorTextForOneOf')
|
|
135
135
|
|
|
136
136
|
return 'One of'
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
export function getErrorTextForUnknown () {
|
|
139
|
+
export function getErrorTextForUnknown () {
|
|
140
140
|
log('getErrorTextForUnknown')
|
|
141
141
|
|
|
142
142
|
return 'Unknown'
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
export function getErrorTextForTypeInvalid ({ expectedType } = {}) {
|
|
145
|
+
export function getErrorTextForTypeInvalid ({ expectedType } = {}) {
|
|
146
146
|
log('getErrorTextForTypeInvalid')
|
|
147
147
|
|
|
148
148
|
switch (expectedType) {
|
|
@@ -163,74 +163,82 @@ export function getErrorTextForTypeInvalid ({ expectedType } = {}) { // , compon
|
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
export function getErrorTextByType ({ type, params } = {}
|
|
166
|
+
export function getErrorTextByType ({ type, params } = {}) {
|
|
167
167
|
log('getErrorTextByType')
|
|
168
168
|
|
|
169
169
|
switch (type) {
|
|
170
170
|
case 'MAX_ITEMS':
|
|
171
|
-
return getErrorTextForMaxItems(
|
|
171
|
+
return getErrorTextForMaxItems()
|
|
172
172
|
case 'MIN_ITEMS':
|
|
173
|
-
return getErrorTextForMinItems(
|
|
173
|
+
return getErrorTextForMinItems()
|
|
174
174
|
case 'MAX_LENGTH':
|
|
175
|
-
return getErrorTextForMaxLength(
|
|
175
|
+
return getErrorTextForMaxLength()
|
|
176
176
|
case 'MIN_LENGTH':
|
|
177
|
-
return getErrorTextForMinLength(
|
|
177
|
+
return getErrorTextForMinLength()
|
|
178
178
|
case 'MAX_PROPERTIES':
|
|
179
|
-
return getErrorTextForMaxProperties(
|
|
179
|
+
return getErrorTextForMaxProperties()
|
|
180
180
|
case 'MIN_PROPERTIES':
|
|
181
|
-
return getErrorTextForMinProperties(
|
|
181
|
+
return getErrorTextForMinProperties()
|
|
182
182
|
case 'ADDITIONAL_ITEMS':
|
|
183
|
-
return getErrorTextForAdditionalItems(
|
|
183
|
+
return getErrorTextForAdditionalItems()
|
|
184
184
|
case 'MAXIMUM':
|
|
185
|
-
return getErrorTextForMaximum(
|
|
185
|
+
return getErrorTextForMaximum()
|
|
186
186
|
case 'MINIMUM':
|
|
187
|
-
return getErrorTextForMinimum(
|
|
187
|
+
return getErrorTextForMinimum()
|
|
188
188
|
case 'FORMAT':
|
|
189
|
-
return getErrorTextForFormat(
|
|
189
|
+
return getErrorTextForFormat()
|
|
190
190
|
case 'ADDITIONAL_PROPERTIES':
|
|
191
|
-
return getErrorTextForAdditionalProperties(
|
|
191
|
+
return getErrorTextForAdditionalProperties()
|
|
192
192
|
case 'DEPENDENCIES':
|
|
193
|
-
return getErrorTextForDependencies(
|
|
193
|
+
return getErrorTextForDependencies()
|
|
194
194
|
case 'UNIQUE_ITEMS':
|
|
195
|
-
return getErrorTextForUniqeItems(
|
|
195
|
+
return getErrorTextForUniqeItems()
|
|
196
196
|
case 'PROPERTY_REQUIRED':
|
|
197
|
-
return getErrorTextForPropertyRequired(
|
|
197
|
+
return getErrorTextForPropertyRequired()
|
|
198
198
|
case 'PROPERTY_NAMES':
|
|
199
|
-
return getErrorTextForPropertyNames(
|
|
199
|
+
return getErrorTextForPropertyNames()
|
|
200
200
|
case 'PATTERN_REQUIRED':
|
|
201
|
-
return getErrorTextForPatternRequired(
|
|
201
|
+
return getErrorTextForPatternRequired()
|
|
202
202
|
case 'TYPE_INVALID':
|
|
203
|
-
return getErrorTextForTypeInvalid(params
|
|
203
|
+
return getErrorTextForTypeInvalid(params)
|
|
204
204
|
case 'MULTIPLE_OF':
|
|
205
|
-
return getErrorTextForMultipleOf(
|
|
205
|
+
return getErrorTextForMultipleOf()
|
|
206
206
|
case 'PATTERN':
|
|
207
|
-
return getErrorTextForPattern(
|
|
207
|
+
return getErrorTextForPattern()
|
|
208
208
|
case 'CONST':
|
|
209
|
-
return getErrorTextForConst(
|
|
209
|
+
return getErrorTextForConst()
|
|
210
210
|
case 'ENUM':
|
|
211
|
-
return getErrorTextForEnum(
|
|
211
|
+
return getErrorTextForEnum()
|
|
212
212
|
case '$REF':
|
|
213
|
-
return getErrorTextFor$Ref(
|
|
213
|
+
return getErrorTextFor$Ref()
|
|
214
214
|
case 'ONE_OF':
|
|
215
|
-
return getErrorTextForOneOf(
|
|
215
|
+
return getErrorTextForOneOf()
|
|
216
216
|
case 'UNKNOWN':
|
|
217
|
-
return getErrorTextForUnknown(
|
|
217
|
+
return getErrorTextForUnknown()
|
|
218
218
|
default:
|
|
219
219
|
throw new Error('Incompatible with Shinkansen')
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
+
/**
|
|
224
|
+
* @param {CogsTypes.ErrorDefinitionType}
|
|
225
|
+
* @returns {string}
|
|
226
|
+
*/
|
|
223
227
|
export function getErrorHref ({ uri = '' } = {}) {
|
|
224
228
|
log('getErrorHref')
|
|
225
229
|
|
|
226
230
|
return '#'.concat(uri)
|
|
227
231
|
}
|
|
228
232
|
|
|
229
|
-
|
|
233
|
+
/**
|
|
234
|
+
* @param {CogsTypes.ErrorDefinitionType}
|
|
235
|
+
* @returns {CogsTypes.FieldErrorType}
|
|
236
|
+
*/
|
|
237
|
+
export default function transform (error) {
|
|
230
238
|
log('transform')
|
|
231
239
|
|
|
232
240
|
return {
|
|
233
|
-
text: getErrorTextByType(error
|
|
241
|
+
text: getErrorTextByType(error),
|
|
234
242
|
href: getErrorHref(error)
|
|
235
243
|
}
|
|
236
244
|
}
|
package/jsconfig.json
DELETED
package/src/index.d.mts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
3
|
-
declare module 'shinkansen-cogs' {
|
|
4
|
-
export const CheckboxCog: React.ComponentClass
|
|
5
|
-
export const EmailCog: React.ComponentClass
|
|
6
|
-
export const NumberCog: React.ComponentClass
|
|
7
|
-
export const PasswordCog: React.ComponentClass
|
|
8
|
-
export const RadioCog: React.ComponentClass
|
|
9
|
-
export const SelectCog: React.ComponentClass
|
|
10
|
-
export const TextCog: React.ComponentClass
|
|
11
|
-
export const TextareaCog: React.ComponentClass
|
|
12
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"module": "es2020",
|
|
4
|
-
"target": "es2020",
|
|
5
|
-
"moduleResolution": "node",
|
|
6
|
-
"noEmit": true,
|
|
7
|
-
"strict": true,
|
|
8
|
-
"isolatedModules": true,
|
|
9
|
-
"noImplicitAny": true,
|
|
10
|
-
"allowSyntheticDefaultImports": true,
|
|
11
|
-
"baseUrl": "./",
|
|
12
|
-
"paths": {
|
|
13
|
-
"shinkansen-cogs/*": [
|
|
14
|
-
"src/*"
|
|
15
|
-
]
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
"include": [
|
|
19
|
-
"src/*"
|
|
20
|
-
]
|
|
21
|
-
}
|