shinkansen-cogs 1.5.63 → 1.5.66
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/index.d.cts +388 -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.66",
|
|
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}
|
package/src/index.d.cts
ADDED
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
declare namespace CogsTypes {
|
|
2
|
+
export type OnChangeType = () => void
|
|
3
|
+
|
|
4
|
+
export type AnswerDefinitionType = {
|
|
5
|
+
answer: {
|
|
6
|
+
title: string
|
|
7
|
+
value: string | string[]
|
|
8
|
+
}
|
|
9
|
+
changeAnswer: {
|
|
10
|
+
text: string
|
|
11
|
+
href: string
|
|
12
|
+
visuallyHiddenText?: string
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type ErrorDefinitionType = {
|
|
17
|
+
type: string,
|
|
18
|
+
uri: string,
|
|
19
|
+
params: {
|
|
20
|
+
expectedType: string
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type ComponentsType = {}
|
|
25
|
+
|
|
26
|
+
export type FieldChangeType = {
|
|
27
|
+
text: string,
|
|
28
|
+
href: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type FieldErrorType = {
|
|
32
|
+
text: string,
|
|
33
|
+
href: string
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare module 'shinkansen-cogs/cogs' {
|
|
38
|
+
import React from 'react'
|
|
39
|
+
|
|
40
|
+
export type CogProps = {
|
|
41
|
+
id: string,
|
|
42
|
+
name: string,
|
|
43
|
+
title: string,
|
|
44
|
+
description: string,
|
|
45
|
+
errorMessage: CogsTypes.ErrorDefinitionType,
|
|
46
|
+
required: boolean,
|
|
47
|
+
disabled: boolean,
|
|
48
|
+
readOnly: boolean,
|
|
49
|
+
placeholder: string,
|
|
50
|
+
onChange: CogsTypes.OnChangeType
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default class Cog extends React.Component<CogProps> {}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
declare module 'shinkansen-cogs/cogs/checkbox' {
|
|
57
|
+
import Cog from 'shinkansen-cogs/cogs'
|
|
58
|
+
|
|
59
|
+
export default class CheckboxCog extends Cog {}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
declare module 'shinkansen-cogs/cogs/email' {
|
|
63
|
+
import Cog from 'shinkansen-cogs/cogs'
|
|
64
|
+
|
|
65
|
+
export default class EmailCog extends Cog {}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
declare module 'shinkansen-cogs/cogs/number' {
|
|
69
|
+
import Cog from 'shinkansen-cogs/cogs'
|
|
70
|
+
|
|
71
|
+
export default class NumberCog extends Cog {}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
declare module 'shinkansen-cogs/cogs/password' {
|
|
75
|
+
import Cog from 'shinkansen-cogs/cogs'
|
|
76
|
+
|
|
77
|
+
export default class PasswordCog extends Cog {}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
declare module 'shinkansen-cogs/cogs/radio' {
|
|
81
|
+
import Cog from 'shinkansen-cogs/cogs'
|
|
82
|
+
|
|
83
|
+
export default class RadioCog extends Cog {}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
declare module 'shinkansen-cogs/cogs/select' {
|
|
87
|
+
import Cog from 'shinkansen-cogs/cogs'
|
|
88
|
+
|
|
89
|
+
export default class SelectCog extends Cog {}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
declare module 'shinkansen-cogs/cogs/text' {
|
|
93
|
+
import Cog from 'shinkansen-cogs/cogs'
|
|
94
|
+
|
|
95
|
+
export default class TextCog extends Cog {}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
declare module 'shinkansen-cogs/cogs/textarea' {
|
|
99
|
+
import Cog from 'shinkansen-cogs/cogs'
|
|
100
|
+
|
|
101
|
+
export default class TextareaCog extends Cog {}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
declare module 'shinkansen-cogs/components/common/disabled' {
|
|
105
|
+
import React from 'react'
|
|
106
|
+
|
|
107
|
+
export default function Disabled(): React.JSX.Element
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
declare module 'shinkansen-cogs/components/common/readonly' {
|
|
111
|
+
import React from 'react'
|
|
112
|
+
|
|
113
|
+
export default function ReadOnly(): React.JSX.Element
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
declare module 'shinkansen-cogs/components/common/required' {
|
|
117
|
+
import React from 'react'
|
|
118
|
+
|
|
119
|
+
export default function Required(): React.JSX.Element
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
declare module 'shinkansen-cogs/components/common/text-content' {
|
|
123
|
+
import React from 'react'
|
|
124
|
+
|
|
125
|
+
export type TextContentProps = {
|
|
126
|
+
textContent: string
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export default function TextContent(props: TextContentProps): React.JSX.Element
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
declare module 'shinkansen-cogs/components/description' {
|
|
133
|
+
import React from 'react'
|
|
134
|
+
|
|
135
|
+
export type DescriptionProps = {
|
|
136
|
+
description: string
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export default class Description extends React.Component<DescriptionProps> {}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
declare module 'shinkansen-cogs/components/description/checkbox' {
|
|
143
|
+
import Description from 'shinkansen-cogs/components/description'
|
|
144
|
+
|
|
145
|
+
export default class CheckboxDescription extends Description {}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
declare module 'shinkansen-cogs/components/description/email' {
|
|
149
|
+
import Description from 'shinkansen-cogs/components/description'
|
|
150
|
+
|
|
151
|
+
export default class EmailDescription extends Description {}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
declare module 'shinkansen-cogs/components/description/number' {
|
|
155
|
+
import Description from 'shinkansen-cogs/components/description'
|
|
156
|
+
|
|
157
|
+
export default class NumberDescription extends Description {}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
declare module 'shinkansen-cogs/components/description/password' {
|
|
161
|
+
import Description from 'shinkansen-cogs/components/description'
|
|
162
|
+
|
|
163
|
+
export default class PasswordDescription extends Description {}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
declare module 'shinkansen-cogs/components/description/radio' {
|
|
167
|
+
import Description from 'shinkansen-cogs/components/description'
|
|
168
|
+
|
|
169
|
+
export default class RadioDescription extends Description {}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
declare module 'shinkansen-cogs/components/description/select' {
|
|
173
|
+
import Description from 'shinkansen-cogs/components/description'
|
|
174
|
+
|
|
175
|
+
export default class SelectDescription extends Description {}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
declare module 'shinkansen-cogs/components/description/text' {
|
|
179
|
+
import Description from 'shinkansen-cogs/components/description'
|
|
180
|
+
|
|
181
|
+
export default class TextDescription extends Description {}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
declare module 'shinkansen-cogs/components/description/textarea' {
|
|
185
|
+
import Description from 'shinkansen-cogs/components/description'
|
|
186
|
+
|
|
187
|
+
export default class TextareaDescription extends Description {}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
declare module 'shinkansen-cogs/components/error-message' {
|
|
191
|
+
import React from 'react'
|
|
192
|
+
|
|
193
|
+
export type ErrorMessageProps = CogsTypes.ErrorDefinitionType
|
|
194
|
+
|
|
195
|
+
export default class ErrorMessage extends React.Component<ErrorMessageProps> {}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
declare module 'shinkansen-cogs/components/error-message/checkbox' {
|
|
199
|
+
import ErrorMessage from 'shinkansen-cogs/components/error-message'
|
|
200
|
+
|
|
201
|
+
export default class CheckboxErrorMessage extends ErrorMessage {}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
declare module 'shinkansen-cogs/components/error-message/email' {
|
|
205
|
+
import ErrorMessage from 'shinkansen-cogs/components/error-message'
|
|
206
|
+
|
|
207
|
+
export default class EmailErrorMessage extends ErrorMessage {}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
declare module 'shinkansen-cogs/components/error-message/number' {
|
|
211
|
+
import ErrorMessage from 'shinkansen-cogs/components/error-message'
|
|
212
|
+
|
|
213
|
+
export default class NumberErrorMessage extends ErrorMessage {}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
declare module 'shinkansen-cogs/components/error-message/password' {
|
|
217
|
+
import ErrorMessage from 'shinkansen-cogs/components/error-message'
|
|
218
|
+
|
|
219
|
+
export default class PasswordErrorMessage extends ErrorMessage {}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
declare module 'shinkansen-cogs/components/error-message/radio' {
|
|
223
|
+
import ErrorMessage from 'shinkansen-cogs/components/error-message'
|
|
224
|
+
|
|
225
|
+
export default class RadioErrorMessage extends ErrorMessage {}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
declare module 'shinkansen-cogs/components/error-message/select' {
|
|
229
|
+
import ErrorMessage from 'shinkansen-cogs/components/error-message'
|
|
230
|
+
|
|
231
|
+
export default class SelectErrorMessage extends ErrorMessage {}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
declare module 'shinkansen-cogs/components/error-message/text' {
|
|
235
|
+
import ErrorMessage from 'shinkansen-cogs/components/error-message'
|
|
236
|
+
|
|
237
|
+
export default class TextErrorMessage extends ErrorMessage {}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
declare module 'shinkansen-cogs/components/error-message/textarea' {
|
|
241
|
+
import ErrorMessage from 'shinkansen-cogs/components/error-message'
|
|
242
|
+
|
|
243
|
+
export default class TextareaErrorMessage extends ErrorMessage {}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
declare module 'shinkansen-cogs/components/field' {
|
|
247
|
+
import React from 'react'
|
|
248
|
+
|
|
249
|
+
export type FieldProps = {
|
|
250
|
+
id: string,
|
|
251
|
+
name: string,
|
|
252
|
+
required: boolean,
|
|
253
|
+
disabled: boolean,
|
|
254
|
+
readOnly: boolean,
|
|
255
|
+
tabIndex: number,
|
|
256
|
+
accessKey: string,
|
|
257
|
+
placeholder: string,
|
|
258
|
+
onChange: CogsTypes.OnChangeType
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export default class Field extends React.Component<FieldProps> {}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
declare module 'shinkansen-cogs/components/field/checkbox' {
|
|
265
|
+
import Field from 'shinkansen-cogs/components/field'
|
|
266
|
+
|
|
267
|
+
export default class CheckboxField extends Field {}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
declare module 'shinkansen-cogs/components/field/email' {
|
|
271
|
+
import Field from 'shinkansen-cogs/components/field'
|
|
272
|
+
|
|
273
|
+
export default class EmailField extends Field {}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
declare module 'shinkansen-cogs/components/field/number' {
|
|
277
|
+
import Field from 'shinkansen-cogs/components/field'
|
|
278
|
+
|
|
279
|
+
export default class NumberField extends Field {}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
declare module 'shinkansen-cogs/components/field/password' {
|
|
283
|
+
import Field from 'shinkansen-cogs/components/field'
|
|
284
|
+
|
|
285
|
+
export default class PasswordField extends Field {}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
declare module 'shinkansen-cogs/components/field/radio' {
|
|
289
|
+
import Field from 'shinkansen-cogs/components/field'
|
|
290
|
+
|
|
291
|
+
export default class RadioField extends Field {}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
declare module 'shinkansen-cogs/components/field/select' {
|
|
295
|
+
import Field from 'shinkansen-cogs/components/field'
|
|
296
|
+
|
|
297
|
+
export default class SelectField extends Field {}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
declare module 'shinkansen-cogs/components/field/text' {
|
|
301
|
+
import Field from 'shinkansen-cogs/components/field'
|
|
302
|
+
|
|
303
|
+
export default class TextField extends Field {}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
declare module 'shinkansen-cogs/components/field/textarea' {
|
|
307
|
+
import Field from 'shinkansen-cogs/components/field'
|
|
308
|
+
|
|
309
|
+
export default class TextareaField extends Field {}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
declare module 'shinkansen-cogs/components/title' {
|
|
313
|
+
import React from 'react'
|
|
314
|
+
|
|
315
|
+
export type TitleProps = {
|
|
316
|
+
id: string,
|
|
317
|
+
title: string,
|
|
318
|
+
required: boolean,
|
|
319
|
+
disabled: boolean,
|
|
320
|
+
readOnly: boolean,
|
|
321
|
+
children: React.JSX.Element | React.JSX.Element[]
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
export default class Title extends React.Component<TitleProps> {}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
declare module 'shinkansen-cogs/components/title/checkbox' {
|
|
328
|
+
import Title from 'shinkansen-cogs/components/title'
|
|
329
|
+
|
|
330
|
+
export default class CheckboxTitle extends Title {}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
declare module 'shinkansen-cogs/components/title/email' {
|
|
334
|
+
import Title from 'shinkansen-cogs/components/title'
|
|
335
|
+
|
|
336
|
+
export default class EmailTitle extends Title {}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
declare module 'shinkansen-cogs/components/title/number' {
|
|
340
|
+
import Title from 'shinkansen-cogs/components/title'
|
|
341
|
+
|
|
342
|
+
export default class NumberTitle extends Title {}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
declare module 'shinkansen-cogs/components/title/password' {
|
|
346
|
+
import Title from 'shinkansen-cogs/components/title'
|
|
347
|
+
|
|
348
|
+
export default class PasswordTitle extends Title {}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
declare module 'shinkansen-cogs/components/title/radio' {
|
|
352
|
+
import Title from 'shinkansen-cogs/components/title'
|
|
353
|
+
|
|
354
|
+
export default class RadioTitle extends Title {}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
declare module 'shinkansen-cogs/components/title/select' {
|
|
358
|
+
import Title from 'shinkansen-cogs/components/title'
|
|
359
|
+
|
|
360
|
+
export default class SelectTitle extends Title {}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
declare module 'shinkansen-cogs/components/title/text' {
|
|
364
|
+
import Title from 'shinkansen-cogs/components/title'
|
|
365
|
+
|
|
366
|
+
export default class TextTitle extends Title {}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
declare module 'shinkansen-cogs/components/title/textarea' {
|
|
370
|
+
import Title from 'shinkansen-cogs/components/title'
|
|
371
|
+
|
|
372
|
+
export default class TextareaTitle extends Title {}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
declare module 'shinkansen-cogs/transformers/error-message' {
|
|
376
|
+
export default function transform (error: CogsTypes.ErrorDefinitionType): CogsTypes.FieldErrorType
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
declare module 'shinkansen-cogs' {
|
|
380
|
+
export { default as CheckboxCog } from 'shinkansen-cogs/cogs/checkbox'
|
|
381
|
+
export { default as EmailCog } from 'shinkansen-cogs/cogs/email'
|
|
382
|
+
export { default as NumberCog } from 'shinkansen-cogs/cogs/number'
|
|
383
|
+
export { default as PasswordCog } from 'shinkansen-cogs/cogs/password'
|
|
384
|
+
export { default as RadioCog } from 'shinkansen-cogs/cogs/radio'
|
|
385
|
+
export { default as SelectCog } from 'shinkansen-cogs/cogs/select'
|
|
386
|
+
export { default as TextCog } from 'shinkansen-cogs/cogs/text'
|
|
387
|
+
export { default as TextareaCog } from 'shinkansen-cogs/cogs/textarea'
|
|
388
|
+
}
|
|
@@ -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
|
-
}
|