cellery 1.4.1 → 1.4.3

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/lib/cells.js CHANGED
@@ -13,6 +13,7 @@ class Cell {
13
13
  this.size = opts.size
14
14
  this.events = opts.events
15
15
  this.style = opts.style
16
+ this.class = opts.class
16
17
 
17
18
  this._eventsRegistered = false
18
19
  }
@@ -155,11 +156,27 @@ class Input extends Cell {
155
156
  }
156
157
  }
157
158
 
159
+ class Details extends Cell {
160
+ constructor(opts = {}) {
161
+ super(opts)
162
+ this.value = opts.value || this.children.filter((c) => typeof c === 'string').join('') || ''
163
+ }
164
+ }
165
+
166
+ class Summary extends Cell {
167
+ constructor(opts = {}) {
168
+ super(opts)
169
+ this.value = opts.value || this.children.filter((c) => typeof c === 'string').join('') || ''
170
+ }
171
+ }
172
+
158
173
  module.exports = {
159
174
  Cell,
160
175
  Container,
161
176
  Fragment,
162
177
  Text,
163
178
  Input,
179
+ Details,
180
+ Summary,
164
181
  Style
165
182
  }
package/lib/compat.js CHANGED
@@ -1,4 +1,4 @@
1
- const { Text, Input, Container, Fragment, Style } = require('./cells')
1
+ const { Text, Input, Container, Fragment, Style, Details, Summary } = require('./cells')
2
2
 
3
3
  module.exports = {
4
4
  '': Fragment,
@@ -14,5 +14,7 @@ module.exports = {
14
14
  span: Text,
15
15
  button: Container.Styled({ events: ['click'] }),
16
16
  p: Text.Styled({ paragraph: true }),
17
+ details: Details,
18
+ summary: Summary,
17
19
  style: Style
18
20
  }
package/lib/template.js CHANGED
@@ -1,17 +1,11 @@
1
- const { Cell, Container, Fragment, Text, Paragraph, Input, Style } = require('./cells')
1
+ const cells = require('./cells')
2
2
  const compat = require('./compat')
3
3
 
4
4
  const SENTINEL = '\x00'
5
5
 
6
6
  const registry = {
7
7
  ...compat,
8
- Cell,
9
- Container,
10
- Fragment,
11
- Text,
12
- Paragraph,
13
- Input,
14
- Style
8
+ ...cells
15
9
  }
16
10
 
17
11
  function register(cells) {
@@ -178,9 +172,12 @@ function build(node, slots) {
178
172
 
179
173
  let style = null
180
174
  const children = node.children
181
- .map((c) => build(c, slots))
175
+ .flatMap((c) => {
176
+ const built = build(c, slots)
177
+ return Array.isArray(built) ? built : [built]
178
+ })
182
179
  .filter((c) => {
183
- if (c instanceof Style) {
180
+ if (c instanceof cells.Style) {
184
181
  style = c
185
182
  return false
186
183
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cellery",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "description": "cellery",
5
5
  "exports": {
6
6
  "./package": "./package.json",