@modernpoacher/sprockets 0.0.5 → 0.0.6

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/babel.config.cjs CHANGED
@@ -71,9 +71,6 @@ const plugins = [
71
71
  '@modernpoacher/sprockets/sprockets/fieldset/group': './src/sprockets/fieldset/group/index.jsx',
72
72
  '@modernpoacher/sprockets/sprockets/fieldset/title': './src/sprockets/fieldset/title/index.jsx',
73
73
  '@modernpoacher/sprockets/sprockets/fieldset': './src/sprockets/fieldset/index.jsx',
74
- '@modernpoacher/sprockets/sprockets/table/group': './src/sprockets/table/group/index.jsx',
75
- '@modernpoacher/sprockets/sprockets/table/title': './src/sprockets/table/title/index.jsx',
76
- '@modernpoacher/sprockets/sprockets/table': './src/sprockets/table/index.jsx',
77
74
  '@modernpoacher/sprockets/sprockets': './src/sprockets/index.jsx',
78
75
  '@modernpoacher/sprockets/components/common/text-content': './src/components/common/text-content/index.jsx',
79
76
  '@modernpoacher/sprockets/components/description': './src/components/description/index.jsx',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modernpoacher/sprockets",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "Sprockets",
5
5
  "keywords": [
6
6
  "Sprockets",
@@ -112,21 +112,21 @@
112
112
  "require": "./src/index.cjs",
113
113
  "import": "./src/index.mjs"
114
114
  },
115
- "./sprockets/check-answers/group/*": "./src/components/group/check-answers/*.cjs",
116
- "./sprockets/check-answers/group": "./src/components/group/check-answers/index.cjs",
117
- "./sprockets/check-answers/title": "./src/components/title/check-answers/index.cjs",
115
+ "./sprockets/check-answers/group/*": "./src/sprockets/check-answers/group/*.cjs",
116
+ "./sprockets/check-answers/group": "./src/sprockets/check-answers/group/index.cjs",
117
+ "./sprockets/check-answers/title": "./src/sprockets/check-answers/title/index.cjs",
118
118
  "./sprockets/check-answers": "./src/sprockets/check-answers/index.cjs",
119
- "./sprockets/error-summary/group/*": "./src/components/group/error-summary/*.cjs",
120
- "./sprockets/error-summary/group": "./src/components/group/error-summary/index.cjs",
121
- "./sprockets/error-summary/title": "./src/components/title/error-summary/index.cjs",
119
+ "./sprockets/error-summary/group/*": "./src/sprockets/error-summary/group/*.cjs",
120
+ "./sprockets/error-summary/group": "./src/sprockets/error-summary/group/index.cjs",
121
+ "./sprockets/error-summary/title": "./src/sprockets/error-summary/title/index.cjs",
122
122
  "./sprockets/error-summary": "./src/sprockets/error-summary/index.cjs",
123
- "./sprockets/fieldset/description": "./src/components/description/fieldset/index.cjs",
124
- "./sprockets/fieldset/error-message": "./src/components/error-message/fieldset/index.cjs",
125
- "./sprockets/fieldset/group": "./src/components/group/fieldset/index.cjs",
126
- "./sprockets/fieldset/title": "./src/components/title/fieldset/index.cjs",
123
+ "./sprockets/fieldset/description": "./src/sprockets/fieldset/description/index.cjs",
124
+ "./sprockets/fieldset/error-message": "./src/sprockets/fieldset/error-message/index.cjs",
125
+ "./sprockets/fieldset/group": "./src/sprockets/fieldset/group/index.cjs",
126
+ "./sprockets/fieldset/title": "./src/sprockets/fieldset/title/index.cjs",
127
127
  "./sprockets/fieldset": "./src/sprockets/fieldset/index.cjs",
128
- "./sprockets/table/group": "./src/components/group/table/index.cjs",
129
- "./sprockets/table/title": "./src/components/table/table/index.cjs",
128
+ "./sprockets/table/group": "./src/sprockets/group/table/index.cjs",
129
+ "./sprockets/table/title": "./src/sprockets/table/table/index.cjs",
130
130
  "./sprockets/table": "./src/sprockets/table/index.cjs",
131
131
  "./sprockets": "./src/sprockets/index.cjs",
132
132
  "./components/common/text-content": "./src/components/common/text-content/index.cjs",
package/tsconfig.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "NodeNext",
4
+ "target": "ESNext",
5
+ "moduleResolution": "NodeNext",
6
+ "noEmit": true,
7
+ "strict": true,
8
+ "isolatedModules": true,
9
+ "baseUrl": "."
10
+ }
11
+ }
@@ -1,17 +0,0 @@
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/sprockets/table/group')
10
-
11
- log('`sprockets` is awake')
12
-
13
- const {
14
- default: component
15
- } = require('./index.jsx')
16
-
17
- module.exports = component
@@ -1,163 +0,0 @@
1
- /**
2
- * TableGroup component
3
- *
4
- * @typedef {import('@modernpoacher/sprockets/components/group').GroupProps} GroupProps
5
- *
6
- * Group state
7
- *
8
- * @typedef {Object} GroupState
9
- * @property {{}} [children]
10
- */
11
-
12
- import React, { isValidElement } from 'react'
13
- import PropTypes from 'prop-types'
14
-
15
- import classnames from 'classnames'
16
-
17
- import Group from '@modernpoacher/sprockets/components/group'
18
- import Title from '@modernpoacher/sprockets/sprockets/table/title'
19
-
20
- function getText ({ text }) {
21
- return text
22
- }
23
-
24
- export default class TableGroup extends Group {
25
- /**
26
- * @type {GroupState}
27
- */
28
- state = {}
29
-
30
- getClassName () {
31
- return classnames(super.getClassName(), 'table')
32
- }
33
-
34
- /**
35
- * Compare latest 'props' with 'state' for changes to 'children'
36
- *
37
- * @param {GroupProps} props Latest props
38
- * @param {GroupState} state Current state
39
- * @returns {{children: {}}}
40
- */
41
- static getDerivedStateFromProps ({ children: c }, { children: C }) {
42
- return {
43
- children: (c !== C) ? c : C
44
- }
45
- }
46
-
47
- /**
48
- * Compare latest 'props' with 'state' for changes to 'children'
49
- *
50
- * @param {GroupProps} props Latest props
51
- * @param {GroupState} state Current state
52
- * @returns {boolean}
53
- */
54
- shouldComponentUpdate (props, state) {
55
- const {
56
- head: h,
57
- body: b
58
- } = state
59
-
60
- const {
61
- head: H,
62
- body: B
63
- } = this.state
64
-
65
- return (h !== H) || (b !== B)
66
- }
67
-
68
- render () {
69
- const {
70
- groupRef,
71
- title,
72
- head,
73
- body
74
- } = this.props
75
-
76
- if (head.length || body.length) {
77
- return (
78
- <table
79
- className={this.getClassName()}
80
- ref={groupRef}>
81
- <Title
82
- title={title}
83
- />
84
- {head.length && (
85
- <thead>
86
- <tr>
87
- {head.map(({ text }, i) => (
88
- <th key={i}>
89
- {text}
90
- </th>
91
- ))}
92
- </tr>
93
- </thead>
94
- )}
95
- {body.length && (
96
- <tbody>
97
- {body.map((row, i) => (
98
- <tr key={i}>
99
- {row.map((item, i) => {
100
- if (i) {
101
- if (isValidElement(item)) {
102
- return (
103
- <td key={i}>
104
- {item}
105
- </td>
106
- )
107
- }
108
-
109
- return (
110
- <td key={i}>
111
- {getText(item)}
112
- </td>
113
- )
114
- }
115
-
116
- if (isValidElement(item)) {
117
- return (
118
- <th key={i}>
119
- {item}
120
- </th>
121
- )
122
- }
123
-
124
- return (
125
- <th key={i}>
126
- {getText(item)}
127
- </th>
128
- )
129
- })}
130
- </tr>
131
- ))}
132
- </tbody>
133
- )}
134
- </table>
135
- )
136
- }
137
-
138
- return null
139
- }
140
- }
141
-
142
- TableGroup.propTypes = {
143
- title: PropTypes.string,
144
- head: PropTypes.arrayOf(
145
- PropTypes.shape({
146
- text: PropTypes.string.isRequired
147
- })
148
- ),
149
- body: PropTypes.arrayOf(
150
- PropTypes.arrayOf(
151
- PropTypes.shape({
152
- text: PropTypes.string.isRequired
153
- })
154
- )
155
- ),
156
- groupRef: PropTypes.shape({
157
- current: PropTypes.shape().isRequired
158
- })
159
- }
160
-
161
- TableGroup.defaultProps = {
162
- ...Group.defaultProps
163
- }
@@ -1,17 +0,0 @@
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/sprockets/table')
10
-
11
- log('`sprockets` is awake')
12
-
13
- const {
14
- default: component
15
- } = require('./index.jsx')
16
-
17
- module.exports = component
@@ -1,91 +0,0 @@
1
- /**
2
- * TableSprocket component
3
- *
4
- * @typedef {import('@modernpoacher/sprockets/sprockets').SprocketProps} SprocketProps
5
- */
6
-
7
- import React from 'react'
8
- import PropTypes from 'prop-types'
9
-
10
- import classnames from 'classnames'
11
-
12
- import Sprocket from '@modernpoacher/sprockets/sprockets'
13
- import Group from './group/index.jsx'
14
-
15
- export default class TableSprocket extends Sprocket {
16
- getClassName () {
17
- return classnames(super.getClassName(), 'table')
18
- }
19
-
20
- /**
21
- * @param {SprocketProps} props
22
- * @returns {boolean}
23
- */
24
- shouldComponentUpdate (props) {
25
- return (
26
- (props.title !== this.props.title) ||
27
- (props.head !== this.props.head) ||
28
- (props.body !== this.props.body)
29
- )
30
- }
31
-
32
- renderGroup () {
33
- const {
34
- groupRef,
35
- title,
36
- head,
37
- body
38
- } = this.props
39
-
40
- return (
41
- <Group
42
- groupRef={groupRef}
43
- title={title}
44
- head={head}
45
- body={body}
46
- />
47
- )
48
- }
49
-
50
- render () {
51
- const {
52
- head,
53
- body
54
- } = this.props
55
-
56
- if (head.length || body.length) {
57
- return (
58
- <div className={this.getClassName()}>
59
- {this.renderGroup()}
60
- </div>
61
- )
62
- }
63
-
64
- return null
65
- }
66
- }
67
-
68
- TableSprocket.propTypes = {
69
- title: PropTypes.string,
70
- head: PropTypes.arrayOf(
71
- PropTypes.shape({
72
- text: PropTypes.string.isRequired
73
- })
74
- ),
75
- body: PropTypes.arrayOf(
76
- PropTypes.arrayOf(
77
- PropTypes.shape({
78
- text: PropTypes.string.isRequired
79
- })
80
- )
81
- ),
82
- groupRef: PropTypes.shape({
83
- current: PropTypes.shape().isRequired
84
- })
85
- }
86
-
87
- TableSprocket.defaultProps = {
88
- ...Sprocket.defaultProps,
89
- head: [],
90
- body: []
91
- }
@@ -1,17 +0,0 @@
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/sprockets/table/title')
10
-
11
- log('`sprockets` is awake')
12
-
13
- const {
14
- default: component
15
- } = require('./index.jsx')
16
-
17
- module.exports = component
@@ -1,33 +0,0 @@
1
- /**
2
- * TableTitle component
3
- */
4
-
5
- import React from 'react'
6
- import classnames from 'classnames'
7
- import Title from '@modernpoacher/sprockets/components/title'
8
-
9
- export default class TableTitle extends Title {
10
- getClassName () {
11
- return classnames(super.getClassName(), 'table')
12
- }
13
-
14
- render () {
15
- if (this.hasTextContent()) {
16
- return (
17
- <caption className={this.getClassName()}>
18
- {this.renderTextContent()}
19
- </caption>
20
- )
21
- }
22
-
23
- return null
24
- }
25
- }
26
-
27
- TableTitle.propTypes = {
28
- ...Title.propTypes
29
- }
30
-
31
- TableTitle.defaultProps = {
32
- ...Title.defaultProps
33
- }