shinkansen-cogs 1.5.63 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shinkansen-cogs",
3
- "version": "1.5.63",
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.6",
58
- "@modernpoacher/hooks": "^1.0.396",
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.2",
66
- "@typescript-eslint/parser": "^5.59.2",
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 () { // (components = {}) {
7
+ export function getErrorTextForMaxItems () {
8
8
  log('getErrorTextForMaxItems')
9
9
 
10
10
  return 'Max items'
11
11
  }
12
12
 
13
- export function getErrorTextForMinItems () { // (components = {}) {
13
+ export function getErrorTextForMinItems () {
14
14
  log('getErrorTextForMinItems')
15
15
 
16
16
  return 'Min items'
17
17
  }
18
18
 
19
- export function getErrorTextForMaxLength () { // (components = {}) {
19
+ export function getErrorTextForMaxLength () {
20
20
  log('getErrorTextForMaxLength')
21
21
 
22
22
  return 'Max length'
23
23
  }
24
24
 
25
- export function getErrorTextForMinLength () { // (components = {}) {
25
+ export function getErrorTextForMinLength () {
26
26
  log('getErrorTextForMinLength')
27
27
 
28
28
  return 'Min length'
29
29
  }
30
30
 
31
- export function getErrorTextForMaxProperties () { // (components = {}) {
31
+ export function getErrorTextForMaxProperties () {
32
32
  log('getErrorTextForMaxProperties')
33
33
 
34
34
  return 'Max properties'
35
35
  }
36
36
 
37
- export function getErrorTextForMinProperties () { // (components = {}) {
37
+ export function getErrorTextForMinProperties () {
38
38
  log('getErrorTextForMinProperties')
39
39
 
40
40
  return 'Min properties'
41
41
  }
42
42
 
43
- export function getErrorTextForAdditionalItems () { // (components = {}) {
43
+ export function getErrorTextForAdditionalItems () {
44
44
  log('getErrorTextForAdditionalItems')
45
45
 
46
46
  return 'Additional items'
47
47
  }
48
48
 
49
- export function getErrorTextForMaximum () { // (components = {}) {
49
+ export function getErrorTextForMaximum () {
50
50
  log('getErrorTextForMaximum')
51
51
 
52
52
  return 'Maximum'
53
53
  }
54
54
 
55
- export function getErrorTextForMinimum () { // (components = {}) {
55
+ export function getErrorTextForMinimum () {
56
56
  log('getErrorTextForMinimum')
57
57
 
58
58
  return 'Minimum'
59
59
  }
60
60
 
61
- export function getErrorTextForFormat () { // (components = {}) {
61
+ export function getErrorTextForFormat () {
62
62
  log('getErrorTextForFormat')
63
63
 
64
64
  return 'Format'
65
65
  }
66
66
 
67
- export function getErrorTextForAdditionalProperties () { // (components = {}) {
67
+ export function getErrorTextForAdditionalProperties () {
68
68
  log('getErrorTextForAdditionalProperties')
69
69
 
70
70
  return 'Additional properties'
71
71
  }
72
72
 
73
- export function getErrorTextForDependencies () { // (components = {}) {
73
+ export function getErrorTextForDependencies () {
74
74
  log('getErrorTextForDependencies')
75
75
 
76
76
  return 'Dependencies'
77
77
  }
78
78
 
79
- export function getErrorTextForUniqeItems () { // (components = {}) {
79
+ export function getErrorTextForUniqeItems () {
80
80
  log('getErrorTextForUniqeItems')
81
81
 
82
82
  return 'Unique items'
83
83
  }
84
84
 
85
- export function getErrorTextForPropertyRequired () { // (components = {}) {
85
+ export function getErrorTextForPropertyRequired () {
86
86
  log('getErrorTextForPropertyRequired')
87
87
 
88
88
  return 'Property required'
89
89
  }
90
90
 
91
- export function getErrorTextForPropertyNames () { // (components = {}) {
91
+ export function getErrorTextForPropertyNames () {
92
92
  log('getErrorTextForPropertyNames')
93
93
 
94
94
  return 'Property names'
95
95
  }
96
96
 
97
- export function getErrorTextForPatternRequired () { // (components = {}) {
97
+ export function getErrorTextForPatternRequired () {
98
98
  log('getErrorTextForMultipleOf')
99
99
 
100
100
  return 'Pattern required'
101
101
  }
102
102
 
103
- export function getErrorTextForMultipleOf () { // (components = {}) {
103
+ export function getErrorTextForMultipleOf () {
104
104
  log('getErrorTextForMultipleOf')
105
105
 
106
106
  return 'Multiple of'
107
107
  }
108
108
 
109
- export function getErrorTextForPattern () { // (components = {}) {
109
+ export function getErrorTextForPattern () {
110
110
  log('getErrorTextForPattern')
111
111
 
112
112
  return 'Pattern'
113
113
  }
114
114
 
115
- export function getErrorTextForConst () { // (components = {}) {
115
+ export function getErrorTextForConst () {
116
116
  log('getErrorTextForConst')
117
117
 
118
118
  return 'Const'
119
119
  }
120
120
 
121
- export function getErrorTextForEnum () { // (components = {}) {
121
+ export function getErrorTextForEnum () {
122
122
  log('getErrorTextForEnum')
123
123
 
124
124
  return 'Enum'
125
125
  }
126
126
 
127
- export function getErrorTextFor$Ref () { // (components = {}) {
127
+ export function getErrorTextFor$Ref () {
128
128
  log('getErrorTextFor$Ref')
129
129
 
130
130
  return '$Ref'
131
131
  }
132
132
 
133
- export function getErrorTextForOneOf () { // (components = {}) {
133
+ export function getErrorTextForOneOf () {
134
134
  log('getErrorTextForOneOf')
135
135
 
136
136
  return 'One of'
137
137
  }
138
138
 
139
- export function getErrorTextForUnknown () { // (components = {}) {
139
+ export function getErrorTextForUnknown () {
140
140
  log('getErrorTextForUnknown')
141
141
 
142
142
  return 'Unknown'
143
143
  }
144
144
 
145
- export function getErrorTextForTypeInvalid ({ expectedType } = {}) { // , components = {}) {
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 } = {}, components = {}) {
166
+ export function getErrorTextByType ({ type, params } = {}) {
167
167
  log('getErrorTextByType')
168
168
 
169
169
  switch (type) {
170
170
  case 'MAX_ITEMS':
171
- return getErrorTextForMaxItems(components)
171
+ return getErrorTextForMaxItems()
172
172
  case 'MIN_ITEMS':
173
- return getErrorTextForMinItems(components)
173
+ return getErrorTextForMinItems()
174
174
  case 'MAX_LENGTH':
175
- return getErrorTextForMaxLength(components)
175
+ return getErrorTextForMaxLength()
176
176
  case 'MIN_LENGTH':
177
- return getErrorTextForMinLength(components)
177
+ return getErrorTextForMinLength()
178
178
  case 'MAX_PROPERTIES':
179
- return getErrorTextForMaxProperties(components)
179
+ return getErrorTextForMaxProperties()
180
180
  case 'MIN_PROPERTIES':
181
- return getErrorTextForMinProperties(components)
181
+ return getErrorTextForMinProperties()
182
182
  case 'ADDITIONAL_ITEMS':
183
- return getErrorTextForAdditionalItems(components)
183
+ return getErrorTextForAdditionalItems()
184
184
  case 'MAXIMUM':
185
- return getErrorTextForMaximum(components)
185
+ return getErrorTextForMaximum()
186
186
  case 'MINIMUM':
187
- return getErrorTextForMinimum(components)
187
+ return getErrorTextForMinimum()
188
188
  case 'FORMAT':
189
- return getErrorTextForFormat(components)
189
+ return getErrorTextForFormat()
190
190
  case 'ADDITIONAL_PROPERTIES':
191
- return getErrorTextForAdditionalProperties(components)
191
+ return getErrorTextForAdditionalProperties()
192
192
  case 'DEPENDENCIES':
193
- return getErrorTextForDependencies(components)
193
+ return getErrorTextForDependencies()
194
194
  case 'UNIQUE_ITEMS':
195
- return getErrorTextForUniqeItems(components)
195
+ return getErrorTextForUniqeItems()
196
196
  case 'PROPERTY_REQUIRED':
197
- return getErrorTextForPropertyRequired(components)
197
+ return getErrorTextForPropertyRequired()
198
198
  case 'PROPERTY_NAMES':
199
- return getErrorTextForPropertyNames(components)
199
+ return getErrorTextForPropertyNames()
200
200
  case 'PATTERN_REQUIRED':
201
- return getErrorTextForPatternRequired(components)
201
+ return getErrorTextForPatternRequired()
202
202
  case 'TYPE_INVALID':
203
- return getErrorTextForTypeInvalid(params, components)
203
+ return getErrorTextForTypeInvalid(params)
204
204
  case 'MULTIPLE_OF':
205
- return getErrorTextForMultipleOf(components)
205
+ return getErrorTextForMultipleOf()
206
206
  case 'PATTERN':
207
- return getErrorTextForPattern(components)
207
+ return getErrorTextForPattern()
208
208
  case 'CONST':
209
- return getErrorTextForConst(components)
209
+ return getErrorTextForConst()
210
210
  case 'ENUM':
211
- return getErrorTextForEnum(components)
211
+ return getErrorTextForEnum()
212
212
  case '$REF':
213
- return getErrorTextFor$Ref(components)
213
+ return getErrorTextFor$Ref()
214
214
  case 'ONE_OF':
215
- return getErrorTextForOneOf(components)
215
+ return getErrorTextForOneOf()
216
216
  case 'UNKNOWN':
217
- return getErrorTextForUnknown(components)
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
- export default function transform (error, components) {
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, components),
241
+ text: getErrorTextByType(error),
234
242
  href: getErrorHref(error)
235
243
  }
236
244
  }
package/jsconfig.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "baseUrl": "./",
4
- "paths": {
5
- "shinkansen-cogs/*": [
6
- "src/*",
7
- "stories/*"
8
- ]
9
- }
10
- }
11
- }
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
- }