shinkansen-cogs 1.7.302 → 1.8.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.
Files changed (136) hide show
  1. package/babel.config.cjs +1 -0
  2. package/eslint.config.mjs +11 -56
  3. package/index.d.mts +214 -4
  4. package/package.json +8 -4
  5. package/src/cogs/checkbox/description/index.cjs +1 -1
  6. package/src/cogs/checkbox/description/index.jsx +0 -4
  7. package/src/cogs/checkbox/error-message/index.cjs +1 -1
  8. package/src/cogs/checkbox/error-message/index.jsx +0 -4
  9. package/src/cogs/checkbox/field/index.cjs +1 -1
  10. package/src/cogs/checkbox/field/index.d.mts +8 -2
  11. package/src/cogs/checkbox/field/index.jsx +11 -1
  12. package/src/cogs/checkbox/index.cjs +1 -1
  13. package/src/cogs/checkbox/index.d.mts +20 -2
  14. package/src/cogs/checkbox/index.jsx +41 -14
  15. package/src/cogs/checkbox/title/index.cjs +1 -1
  16. package/src/cogs/checkbox/title/index.d.mts +5 -1
  17. package/src/cogs/checkbox/title/index.jsx +8 -4
  18. package/src/cogs/email/description/index.cjs +1 -1
  19. package/src/cogs/email/description/index.jsx +0 -4
  20. package/src/cogs/email/error-message/index.cjs +1 -1
  21. package/src/cogs/email/error-message/index.jsx +0 -4
  22. package/src/cogs/email/field/index.cjs +1 -1
  23. package/src/cogs/email/field/index.d.mts +8 -2
  24. package/src/cogs/email/field/index.jsx +11 -5
  25. package/src/cogs/email/index.cjs +1 -1
  26. package/src/cogs/email/index.d.mts +13 -2
  27. package/src/cogs/email/index.jsx +17 -8
  28. package/src/cogs/email/title/index.cjs +1 -1
  29. package/src/cogs/email/title/index.d.mts +5 -1
  30. package/src/cogs/email/title/index.jsx +8 -4
  31. package/src/cogs/index.cjs +1 -0
  32. package/src/cogs/index.d.mts +31 -13
  33. package/src/cogs/index.jsx +43 -14
  34. package/src/cogs/number/description/index.cjs +1 -1
  35. package/src/cogs/number/description/index.jsx +0 -4
  36. package/src/cogs/number/error-message/index.cjs +1 -1
  37. package/src/cogs/number/error-message/index.jsx +0 -4
  38. package/src/cogs/number/field/index.cjs +1 -1
  39. package/src/cogs/number/field/index.d.mts +8 -2
  40. package/src/cogs/number/field/index.jsx +11 -1
  41. package/src/cogs/number/index.cjs +1 -1
  42. package/src/cogs/number/index.d.mts +13 -2
  43. package/src/cogs/number/index.jsx +17 -4
  44. package/src/cogs/number/title/index.cjs +1 -1
  45. package/src/cogs/number/title/index.d.mts +5 -1
  46. package/src/cogs/number/title/index.jsx +8 -4
  47. package/src/cogs/password/description/index.cjs +1 -1
  48. package/src/cogs/password/description/index.jsx +0 -4
  49. package/src/cogs/password/error-message/index.cjs +1 -1
  50. package/src/cogs/password/error-message/index.jsx +0 -4
  51. package/src/cogs/password/field/index.cjs +1 -1
  52. package/src/cogs/password/field/index.d.mts +8 -2
  53. package/src/cogs/password/field/index.jsx +11 -5
  54. package/src/cogs/password/index.cjs +1 -1
  55. package/src/cogs/password/index.d.mts +13 -2
  56. package/src/cogs/password/index.jsx +17 -8
  57. package/src/cogs/password/title/index.cjs +1 -1
  58. package/src/cogs/password/title/index.d.mts +5 -1
  59. package/src/cogs/password/title/index.jsx +8 -4
  60. package/src/cogs/radio/description/index.cjs +1 -1
  61. package/src/cogs/radio/description/index.jsx +0 -4
  62. package/src/cogs/radio/error-message/index.cjs +1 -1
  63. package/src/cogs/radio/error-message/index.jsx +0 -4
  64. package/src/cogs/radio/field/index.cjs +1 -1
  65. package/src/cogs/radio/field/index.d.mts +8 -2
  66. package/src/cogs/radio/field/index.jsx +11 -1
  67. package/src/cogs/radio/index.cjs +1 -1
  68. package/src/cogs/radio/index.d.mts +20 -2
  69. package/src/cogs/radio/index.jsx +41 -14
  70. package/src/cogs/radio/title/index.cjs +1 -1
  71. package/src/cogs/radio/title/index.d.mts +5 -1
  72. package/src/cogs/radio/title/index.jsx +8 -4
  73. package/src/cogs/select/description/index.cjs +1 -1
  74. package/src/cogs/select/description/index.jsx +0 -4
  75. package/src/cogs/select/error-message/index.cjs +1 -1
  76. package/src/cogs/select/error-message/index.jsx +0 -4
  77. package/src/cogs/select/field/index.cjs +1 -1
  78. package/src/cogs/select/field/index.d.mts +8 -2
  79. package/src/cogs/select/field/index.jsx +56 -15
  80. package/src/cogs/select/index.cjs +1 -1
  81. package/src/cogs/select/index.d.mts +13 -2
  82. package/src/cogs/select/index.jsx +39 -12
  83. package/src/cogs/select/title/index.cjs +1 -1
  84. package/src/cogs/select/title/index.d.mts +5 -1
  85. package/src/cogs/select/title/index.jsx +8 -4
  86. package/src/cogs/text/description/index.cjs +1 -1
  87. package/src/cogs/text/description/index.jsx +0 -4
  88. package/src/cogs/text/error-message/index.cjs +1 -1
  89. package/src/cogs/text/error-message/index.jsx +0 -4
  90. package/src/cogs/text/field/index.cjs +1 -1
  91. package/src/cogs/text/field/index.d.mts +8 -2
  92. package/src/cogs/text/field/index.jsx +11 -5
  93. package/src/cogs/text/index.cjs +1 -1
  94. package/src/cogs/text/index.d.mts +13 -2
  95. package/src/cogs/text/index.jsx +17 -8
  96. package/src/cogs/text/title/index.cjs +1 -1
  97. package/src/cogs/text/title/index.d.mts +5 -1
  98. package/src/cogs/text/title/index.jsx +8 -4
  99. package/src/cogs/textarea/description/index.cjs +1 -1
  100. package/src/cogs/textarea/description/index.jsx +0 -4
  101. package/src/cogs/textarea/error-message/index.cjs +1 -1
  102. package/src/cogs/textarea/error-message/index.jsx +0 -4
  103. package/src/cogs/textarea/field/index.cjs +1 -1
  104. package/src/cogs/textarea/field/index.d.mts +8 -2
  105. package/src/cogs/textarea/field/index.jsx +11 -5
  106. package/src/cogs/textarea/index.cjs +1 -1
  107. package/src/cogs/textarea/index.d.mts +13 -2
  108. package/src/cogs/textarea/index.jsx +17 -8
  109. package/src/cogs/textarea/title/index.cjs +1 -1
  110. package/src/cogs/textarea/title/index.d.mts +5 -1
  111. package/src/cogs/textarea/title/index.jsx +8 -4
  112. package/src/common/index.d.mts +10 -2
  113. package/src/components/common/disabled/index.cjs +1 -1
  114. package/src/components/common/disabled/index.jsx +7 -5
  115. package/src/components/common/readonly/index.cjs +1 -1
  116. package/src/components/common/readonly/index.jsx +7 -5
  117. package/src/components/common/required/index.cjs +1 -1
  118. package/src/components/common/required/index.jsx +7 -5
  119. package/src/components/common/text-content/index.cjs +1 -1
  120. package/src/components/common/text-content/index.d.mts +3 -4
  121. package/src/components/common/text-content/index.jsx +6 -5
  122. package/src/components/description/index.cjs +1 -1
  123. package/src/components/description/index.d.mts +10 -5
  124. package/src/components/description/index.jsx +12 -2
  125. package/src/components/error-message/index.cjs +1 -1
  126. package/src/components/error-message/index.d.mts +22 -3
  127. package/src/components/error-message/index.jsx +28 -11
  128. package/src/components/field/index.cjs +1 -1
  129. package/src/components/field/index.d.mts +29 -14
  130. package/src/components/field/index.jsx +57 -17
  131. package/src/components/title/index.cjs +1 -1
  132. package/src/components/title/index.d.mts +22 -10
  133. package/src/components/title/index.jsx +12 -2
  134. package/src/index.d.mts +3 -0
  135. package/src/transformers/error-message/index.d.mts +8 -0
  136. package/src/transformers/error-message/index.mjs +12 -4
package/babel.config.cjs CHANGED
@@ -43,6 +43,7 @@ const plugins = [
43
43
  '@babel/syntax-jsx'
44
44
  ]
45
45
 
46
+ // @ts-ignore
46
47
  module.exports = (api) => {
47
48
  if (api) api.cache.using(env)
48
49
 
package/eslint.config.mjs CHANGED
@@ -1,5 +1,7 @@
1
1
  import globals from 'globals'
2
+ // @ts-ignore
2
3
  import standard from '@sequencemedia/eslint-config-standard/configs/recommended/merge'
4
+ // @ts-ignore
3
5
  import typescript from '@sequencemedia/eslint-config-typescript/configs/recommended/merge'
4
6
  import babelParser from '@babel/eslint-parser'
5
7
  import typescriptParser from '@typescript-eslint/parser'
@@ -58,12 +60,11 @@ export default [
58
60
  ]
59
61
  },
60
62
  /**
61
- * React config for all `jsx` and `tsx` files
63
+ * React config for all `jsx` and `jsx` files
62
64
  */
63
65
  {
64
66
  ...reactPlugin.configs.flat.recommended,
65
67
  settings: {
66
- ...reactPlugin.configs.flat.recommended.settings,
67
68
  ...reactSettings
68
69
  }
69
70
  },
@@ -100,15 +101,15 @@ export default [
100
101
  }
101
102
  }),
102
103
  /**
103
- * Standard config for all `jsx` and `tsx` files
104
+ * Standard config for all `jsx`
104
105
  */
105
106
  standard({
106
107
  files: [
107
- 'src/**/*.tsx',
108
+ 'src/**/*.jsx',
108
109
  'stories/**/*.jsx'
109
110
  ],
110
111
  ignores: [
111
- 'src/**/__tests__/**/*.tsx',
112
+ 'src/**/__tests__/**/*.jsx',
112
113
  'stories/**/__tests__/**/*.jsx'
113
114
  ],
114
115
  languageOptions: {
@@ -137,7 +138,7 @@ export default [
137
138
  }),
138
139
  standard({
139
140
  files: [
140
- 'src/**/__tests__/**/*.tsx',
141
+ 'src/**/__tests__/**/*.jsx',
141
142
  'stories/**/__tests__/**/*.jsx'
142
143
  ],
143
144
  languageOptions: {
@@ -175,78 +176,32 @@ export default [
175
176
  ignores: [
176
177
  'src'
177
178
  ],
178
- languageOptions: {
179
- globals: {
180
- ...globals.node,
181
- CogsTypes: 'readonly'
182
- }
183
- }
184
- }),
185
- typescript({
186
- files: [
187
- 'src/**/*.{mts,cts}'
188
- ],
189
- languageOptions: {
190
- globals: {
191
- ...globals.browser
192
- }
193
- }
194
- }),
195
- /**
196
- * TypeScript config for only `tsx` files
197
- */
198
- typescript({
199
- files: [
200
- 'src/**/*.tsx'
201
- ],
202
- ignores: [
203
- 'src/**/__tests__/**/*.tsx'
204
- ],
205
179
  languageOptions: {
206
180
  parser: typescriptParser,
207
181
  parserOptions: {
208
- ...reactParserOptions,
209
182
  projectService: true,
210
183
  project: 'tsconfig.json'
211
184
  },
212
185
  globals: {
213
- ...globals.browser
186
+ ...globals.node,
187
+ CogsTypes: 'readonly'
214
188
  }
215
- },
216
- plugins: {
217
- ...reactPlugins
218
- },
219
- rules: {
220
- ...reactRules
221
- },
222
- settings: {
223
- ...reactSettings
224
189
  }
225
190
  }),
226
191
  typescript({
227
192
  files: [
228
- 'src/**/__tests__/**/*.tsx'
193
+ 'src/**/*.{mts,cts}'
229
194
  ],
230
195
  languageOptions: {
231
196
  parser: typescriptParser,
232
197
  parserOptions: {
233
- ...reactParserOptions,
234
198
  projectService: true,
235
199
  project: 'tsconfig.json'
236
200
  },
237
201
  globals: {
238
202
  ...globals.browser,
239
- ...globals.jest
203
+ CogsTypes: 'readonly'
240
204
  }
241
- },
242
- plugins: {
243
- ...reactPlugins
244
- },
245
- rules: {
246
- ...reactRules
247
- },
248
- settings: {
249
- ...reactSettings
250
205
  }
251
206
  })
252
207
  ]
package/index.d.mts CHANGED
@@ -1,19 +1,229 @@
1
+ import type React from 'react'
2
+
1
3
  declare global {
2
4
  namespace CogsTypes {
3
- export type OnChangeType = () => void
5
+ export type OnChangeType = (
6
+ name: string,
7
+ value?: string | string[],
8
+ checked?: boolean
9
+ ) => void
10
+
11
+ export type OnClickType = (
12
+ name: string,
13
+ value?: string | string[],
14
+ checked?: boolean
15
+ ) => void
4
16
 
5
17
  export interface ErrorDefinitionType {
6
18
  type: string
7
19
  uri: string
8
- params: {
9
- expectedType: string
10
- }
20
+ params: Record<PropertyKey, unknown> | Record<PropertyKey, never>
11
21
  }
12
22
 
13
23
  export interface FieldErrorType {
14
24
  text: string
15
25
  href: string
16
26
  }
27
+
28
+ export namespace Components {
29
+ export namespace Common {
30
+ export namespace TextContent {
31
+ export interface TextContentProps {
32
+ textContent?: string
33
+ }
34
+ }
35
+ }
36
+
37
+ export namespace Description {
38
+ export interface DescriptionProps {
39
+ description?: string
40
+ }
41
+ }
42
+
43
+ export namespace ErrorMessage {
44
+ export interface ErrorMessageProps {
45
+ errorMessage?: ErrorDefinitionType
46
+ }
47
+
48
+ export interface ErrorMessageState {
49
+ errorMessage?: ErrorDefinitionType
50
+ }
51
+ }
52
+
53
+ export namespace Field {
54
+ export interface FieldProps extends React.PropsWithChildren {
55
+ id?: string
56
+ name: string
57
+ required?: boolean
58
+ disabled?: boolean
59
+ readOnly?: boolean
60
+ tabIndex?: number
61
+ accessKey?: string
62
+ placeholder?: string
63
+ onChange?: OnChangeType
64
+ fieldRef?: React.RefObject<any> // eslint-disable-line @typescript-eslint/no-explicit-any -- Simplicity
65
+ }
66
+
67
+ export interface ValueProps extends FieldProps {
68
+ value?: string,
69
+ defaultValue?: string
70
+ }
71
+
72
+ export interface CheckProps extends FieldProps {
73
+ value?: string,
74
+ checked?: boolean,
75
+ defaultChecked?: boolean,
76
+ onClick: OnClickType
77
+ }
78
+
79
+ export namespace Checkbox {
80
+ export type CheckboxProps = CheckProps
81
+ }
82
+
83
+ export namespace Email {
84
+ export type EmailProps = ValueProps
85
+ }
86
+
87
+ export namespace Number {
88
+ export type NumberProps = ValueProps
89
+ }
90
+
91
+ export namespace Password {
92
+ export type PasswordProps = ValueProps
93
+ }
94
+
95
+ export namespace Radio {
96
+ export type RadioProps = CheckProps
97
+ }
98
+
99
+ export namespace Select {
100
+ export interface SelectProps extends ValueProps, React.PropsWithChildren {
101
+ multiple?: boolean
102
+ }
103
+ }
104
+
105
+ export namespace Text {
106
+ export type TextProps = ValueProps
107
+ }
108
+
109
+ export namespace Textarea {
110
+ export type TextareaProps = ValueProps
111
+ }
112
+ }
113
+
114
+ export namespace Title {
115
+ export interface TitleProps extends React.PropsWithChildren {
116
+ id: string
117
+ title?: string
118
+ required?: boolean
119
+ disabled?: boolean
120
+ readOnly?: boolean
121
+ }
122
+
123
+ export namespace Checkbox {
124
+ export type CheckboxProps = TitleProps
125
+ }
126
+
127
+ export namespace Email {
128
+ export type EmailProps = TitleProps
129
+ }
130
+
131
+ export namespace Number {
132
+ export type NumberProps = TitleProps
133
+ }
134
+
135
+ export namespace Password {
136
+ export type PasswordProps = TitleProps
137
+ }
138
+
139
+ export namespace Radio {
140
+ export type RadioProps = TitleProps
141
+ }
142
+
143
+ export namespace Select {
144
+ export type SelectProps = TitleProps
145
+ }
146
+
147
+ export namespace Text {
148
+ export type TextProps = TitleProps
149
+ }
150
+
151
+ export namespace Textarea {
152
+ export type TextareaProps = TitleProps
153
+ }
154
+ }
155
+ }
156
+
157
+ export namespace Cogs {
158
+ export namespace Cog {
159
+ export interface CogProps {
160
+ id?: string
161
+ name: string
162
+ title?: string
163
+ description?: string
164
+ errorMessage?: ErrorDefinitionType
165
+ required?: boolean
166
+ disabled?: boolean
167
+ readOnly?: boolean
168
+ tabIndex?: number,
169
+ accessKey?: string,
170
+ placeholder?: string
171
+ onChange?: OnChangeType
172
+ fieldRef?: React.RefObject<any> // eslint-disable-line @typescript-eslint/no-explicit-any -- Simplicity
173
+ }
174
+
175
+ export interface ValueProps extends CogProps {
176
+ value?: string,
177
+ defaultValue?: string
178
+ }
179
+
180
+ export interface CheckProps extends CogProps {
181
+ value?: string,
182
+ checked?: boolean,
183
+ defaultChecked?: boolean,
184
+ onClick: OnClickType
185
+ }
186
+
187
+ export namespace Checkbox {
188
+ export type CheckboxProps = CheckProps
189
+ }
190
+
191
+ export namespace Email {
192
+ export type EmailProps = ValueProps
193
+ }
194
+
195
+ export namespace Number {
196
+ export interface NumberProps extends Omit<Omit<ValueProps, 'value'>, 'defaultValue'> {
197
+ value?: string | number
198
+ defaultValue?: string | number
199
+ }
200
+ }
201
+
202
+ export namespace Password {
203
+ export type PasswordProps = ValueProps
204
+ }
205
+
206
+ export namespace Radio {
207
+ export type RadioProps = CheckProps
208
+ }
209
+
210
+ export namespace Select {
211
+ export interface SelectProps extends Omit<Omit<ValueProps, 'value'>, 'defaultValue'>, React.PropsWithChildren {
212
+ multiple?: boolean
213
+ value?: string | string[]
214
+ defaultValue?: string | string[]
215
+ }
216
+ }
217
+
218
+ export namespace Text {
219
+ export type TextProps = ValueProps
220
+ }
221
+
222
+ export namespace Textarea {
223
+ export type TextareaProps = ValueProps
224
+ }
225
+ }
226
+ }
17
227
  }
18
228
  }
19
229
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shinkansen-cogs",
3
- "version": "1.7.302",
3
+ "version": "1.8.1",
4
4
  "description": "Shinkansen Cogs",
5
5
  "keywords": [
6
6
  "Shinkansen",
@@ -54,14 +54,18 @@
54
54
  "@babel/preset-react": "^7.26.3",
55
55
  "@babel/register": "^7.25.9",
56
56
  "@modernpoacher/design-system": "1.1.27",
57
- "@sequencemedia/eslint-config-standard": "^0.2.25",
58
- "@sequencemedia/eslint-config-typescript": "^0.1.36",
57
+ "@sequencemedia/eslint-config-standard": "^0.2.26",
58
+ "@sequencemedia/eslint-config-typescript": "^0.1.37",
59
59
  "@storybook/addon-actions": "7.6.20",
60
60
  "@storybook/addon-essentials": "7.6.20",
61
61
  "@storybook/addon-links": "7.6.20",
62
62
  "@storybook/react": "7.6.20",
63
63
  "@storybook/react-webpack5": "7.6.20",
64
+ "@types/babel__register": "^7.17.3",
65
+ "@types/debug": "^4.1.12",
66
+ "@types/jest": "^29.5.14",
64
67
  "@types/react": "18.3.13",
68
+ "@types/react-test-renderer": "^19.0.0",
65
69
  "@typescript-eslint/eslint-plugin": "^8.24.1",
66
70
  "@typescript-eslint/parser": "^8.24.1",
67
71
  "autoprefixer": "^10.4.20",
@@ -77,7 +81,7 @@
77
81
  "jest": "^29.7.0",
78
82
  "mini-css-extract-plugin": "^2.9.2",
79
83
  "perfectionist": "^2.4.0",
80
- "postcss": "^8.5.2",
84
+ "postcss": "^8.5.3",
81
85
  "postcss-discard-comments": "^7.0.3",
82
86
  "postcss-discard-empty": "^7.0.0",
83
87
  "postcss-import": "^16.1.0",
@@ -11,7 +11,7 @@ const log = debug('shinkansen-cogs/cogs/checkbox/description')
11
11
  log('`shinkansen` is awake')
12
12
 
13
13
  const {
14
- default: component
14
+ default: component // @ts-ignore
15
15
  } = require('./index.jsx')
16
16
 
17
17
  module.exports = component
@@ -9,7 +9,3 @@ export default class CheckboxDescription extends Description {
9
9
  return classnames(super.getClassName(), 'checkbox')
10
10
  }
11
11
  }
12
-
13
- CheckboxDescription.propTypes = {
14
- ...Description.propTypes
15
- }
@@ -11,7 +11,7 @@ const log = debug('shinkansen-cogs/cogs/checkbox/error-message')
11
11
  log('`shinkansen` is awake')
12
12
 
13
13
  const {
14
- default: component
14
+ default: component // @ts-ignore
15
15
  } = require('./index.jsx')
16
16
 
17
17
  module.exports = component
@@ -9,7 +9,3 @@ export default class CheckboxErrorMessage extends ErrorMessage {
9
9
  return classnames(super.getClassName(), 'checkbox')
10
10
  }
11
11
  }
12
-
13
- CheckboxErrorMessage.propTypes = {
14
- ...ErrorMessage.propTypes
15
- }
@@ -11,7 +11,7 @@ const log = debug('shinkansen-cogs/cogs/checkbox/field')
11
11
  log('`shinkansen` is awake')
12
12
 
13
13
  const {
14
- default: component
14
+ default: component // @ts-ignore
15
15
  } = require('./index.jsx')
16
16
 
17
17
  module.exports = component
@@ -1,9 +1,15 @@
1
1
  declare module '#cogs/cogs/checkbox/field' {
2
- import Field from '#cogs/components/field'
2
+ import {
3
+ CheckField
4
+ } from '#cogs/components/field'
3
5
 
4
- export default class CheckboxField extends Field {}
6
+ type CheckboxProps = CogsTypes.Components.Field.Checkbox.CheckboxProps
7
+
8
+ export default class CheckboxField<P extends CheckboxProps> extends CheckField<P> {}
5
9
  }
6
10
 
7
11
  declare module 'shinkansen-cogs/cogs/checkbox/field' {
12
+ export type CheckboxProps = CogsTypes.Components.Field.Checkbox.CheckboxProps
13
+
8
14
  export { default } from '#cogs/cogs/checkbox/field'
9
15
  }
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @typedef {CogsTypes.Components.Field.CheckProps} CheckProps
3
+ * @typedef {CogsTypes.Components.Field.Checkbox.CheckboxProps} CheckboxProps
4
+ */
5
+
1
6
  /**
2
7
  * CheckboxField component
3
8
  */
@@ -5,8 +10,13 @@ import React from 'react'
5
10
  import PropTypes from 'prop-types'
6
11
  import classnames from 'classnames'
7
12
 
8
- import { CheckField } from '#cogs/components/field'
13
+ import {
14
+ CheckField
15
+ } from '#cogs/components/field'
9
16
 
17
+ /**
18
+ * @extends {CheckField<CheckProps & CheckboxProps>}
19
+ */
10
20
  export default class CheckboxField extends CheckField {
11
21
  getClassName () {
12
22
  return classnames(super.getClassName(), 'checkbox')
@@ -11,7 +11,7 @@ const log = debug('shinkansen-cogs/cogs/checkbox')
11
11
  log('`shinkansen` is awake')
12
12
 
13
13
  const {
14
- default: component
14
+ default: component // @ts-ignore
15
15
  } = require('./index.jsx')
16
16
 
17
17
  module.exports = component
@@ -1,9 +1,27 @@
1
1
  declare module '#cogs/cogs/checkbox' {
2
- import Cog from '#cogs/cogs'
2
+ import {
3
+ CheckCog
4
+ } from '#cogs/cogs'
3
5
 
4
- export default class CheckboxCog extends Cog {}
6
+ type CheckboxProps = CogsTypes.Cogs.Cog.Checkbox.CheckboxProps
7
+
8
+ export default class CheckboxCog<P extends CheckboxProps> extends CheckCog<P> {
9
+ handleChange (
10
+ name: string,
11
+ value?: string | string[],
12
+ checked?: boolean
13
+ ): void
14
+
15
+ handleClick (
16
+ name: string,
17
+ value?: string | string[],
18
+ checked?: boolean
19
+ ): void
20
+ }
5
21
  }
6
22
 
7
23
  declare module 'shinkansen-cogs/cogs/checkbox' {
24
+ export type CheckboxProps = CogsTypes.Cogs.Cog.Checkbox.CheckboxProps
25
+
8
26
  export { default } from '#cogs/cogs/checkbox'
9
27
  }
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @typedef {CogsTypes.Cogs.Cog.CheckProps} CheckProps
3
+ * @typedef {CogsTypes.Cogs.Cog.Checkbox.CheckboxProps} CheckboxProps
4
+ */
5
+
1
6
  /**
2
7
  * CheckboxCog component
3
8
  */
@@ -5,7 +10,9 @@ import React from 'react'
5
10
  import PropTypes from 'prop-types'
6
11
  import classnames from 'classnames'
7
12
 
8
- import { CheckCog } from '#cogs/cogs'
13
+ import {
14
+ CheckCog
15
+ } from '#cogs/cogs'
9
16
 
10
17
  import {
11
18
  DEFAULT_HANDLE_CHANGE,
@@ -17,36 +24,56 @@ import Description from './description/index.jsx'
17
24
  import ErrorMessage from './error-message/index.jsx'
18
25
  import Field from './field/index.jsx'
19
26
 
27
+ /**
28
+ * @extends {CheckCog<CheckProps & CheckboxProps>}
29
+ */
20
30
  export default class CheckboxCog extends CheckCog {
21
31
  getClassName () {
22
32
  return classnames(super.getClassName(), 'checkbox')
23
33
  }
24
34
 
25
- handleChange = (value, checked) => {
35
+ /**
36
+ * @param {CheckProps} props
37
+ * @returns {boolean}
38
+ */
39
+ shouldComponentUpdate (props) {
26
40
  const {
27
- onChange = DEFAULT_HANDLE_CHANGE,
28
- name
41
+ value,
42
+ ...superProps
43
+ } = props
44
+
45
+ return (
46
+ super.shouldComponentUpdate(superProps) ||
47
+ (value !== this.props.value)
48
+ )
49
+ }
50
+
51
+ /**
52
+ * @param {string} name
53
+ * @param {string | string[]} [value]
54
+ * @param {boolean} [checked]
55
+ */
56
+ handleChange = (name, value, checked) => {
57
+ const {
58
+ onChange = DEFAULT_HANDLE_CHANGE
29
59
  } = this.props
30
60
 
31
61
  onChange(name, value, checked)
32
62
  }
33
63
 
34
- handleClick = (value, checked) => {
64
+ /**
65
+ * @param {string} name
66
+ * @param {string | string[]} [value]
67
+ * @param {boolean} [checked]
68
+ */
69
+ handleClick = (name, value, checked) => {
35
70
  const {
36
- onClick = DEFAULT_HANDLE_CLICK,
37
- name
71
+ onClick = DEFAULT_HANDLE_CLICK
38
72
  } = this.props
39
73
 
40
74
  onClick(name, value, checked)
41
75
  }
42
76
 
43
- shouldComponentUpdate (props, state) {
44
- return (
45
- super.shouldComponentUpdate(props) ||
46
- (props.value !== this.props.value)
47
- )
48
- }
49
-
50
77
  renderTitle () {
51
78
  const id = this.getId()
52
79
 
@@ -11,7 +11,7 @@ const log = debug('shinkansen-cogs/cogs/checkbox/title')
11
11
  log('`shinkansen` is awake')
12
12
 
13
13
  const {
14
- default: component
14
+ default: component // @ts-ignore
15
15
  } = require('./index.jsx')
16
16
 
17
17
  module.exports = component
@@ -1,9 +1,13 @@
1
1
  declare module '#cogs/cogs/checkbox/title' {
2
2
  import Title from '#cogs/components/title'
3
3
 
4
- export default class CheckboxTitle extends Title {}
4
+ type CheckboxProps = CogsTypes.Components.Title.Checkbox.CheckboxProps
5
+
6
+ export default class CheckboxTitle<P extends CheckboxProps> extends Title<P> {}
5
7
  }
6
8
 
7
9
  declare module 'shinkansen-cogs/cogs/checkbox/title' {
10
+ export type CheckboxProps = CogsTypes.Components.Title.Checkbox.CheckboxProps
11
+
8
12
  export { default } from '#cogs/cogs/checkbox/title'
9
13
  }
@@ -1,15 +1,19 @@
1
+ /**
2
+ * @typedef {CogsTypes.Components.Title.TitleProps} TitleProps
3
+ * @typedef {CogsTypes.Components.Title.Checkbox.CheckboxProps} CheckboxProps
4
+ */
5
+
1
6
  /**
2
7
  * CheckboxTitle component
3
8
  */
4
9
  import classnames from 'classnames'
5
10
  import Title from '#cogs/components/title'
6
11
 
12
+ /**
13
+ * @extends {Title<TitleProps & CheckboxProps>}
14
+ */
7
15
  export default class CheckboxTitle extends Title {
8
16
  getClassName () {
9
17
  return classnames(super.getClassName(), 'checkbox')
10
18
  }
11
19
  }
12
-
13
- CheckboxTitle.propTypes = {
14
- ...Title.propTypes
15
- }
@@ -11,7 +11,7 @@ const log = debug('shinkansen-cogs/cogs/email/description')
11
11
  log('`shinkansen` is awake')
12
12
 
13
13
  const {
14
- default: component
14
+ default: component // @ts-ignore
15
15
  } = require('./index.jsx')
16
16
 
17
17
  module.exports = component