cellery 1.4.0 → 1.4.2

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/index.d.ts CHANGED
@@ -121,7 +121,6 @@ declare module 'cellery' {
121
121
  _render(): this
122
122
  render(opts?: Record<string, any>): void
123
123
  destroy(): void
124
- register(cellery: Cellery): void // lunte-disable-line
125
124
  }
126
125
 
127
126
  export interface ContainerOptions extends CellOptions {
package/lib/cellery.js CHANGED
@@ -8,7 +8,6 @@ class Cellery extends Iambus {
8
8
  this.adapter = adapter
9
9
 
10
10
  Cell.cellery = this
11
- this.app.register(this)
12
11
  }
13
12
 
14
13
  // TODO: pipe compat...
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
  }
@@ -67,26 +68,11 @@ class Cell {
67
68
  destroy: true
68
69
  })
69
70
  }
70
-
71
- // @deprecated
72
- register(cellery) {}
73
71
  }
74
72
 
75
73
  class Style {
76
74
  constructor(opts = {}) {
77
75
  this.content = parse(opts.children?.join('\n'))
78
-
79
- // setup data-cellery-cell for namespaced matching
80
- const cellNames = new Set(Object.keys(opts.cells))
81
-
82
- walk(this.content, {
83
- visit: 'TypeSelector',
84
- enter(node) {
85
- if (cellNames.has(node.name)) {
86
- node.name = `[data-cellery-cell="${node.name}"]`
87
- }
88
- }
89
- })
90
76
  }
91
77
 
92
78
  findPropertyOfCell(name, property) {
@@ -113,14 +99,11 @@ class Style {
113
99
  return value
114
100
  }
115
101
 
116
- addScope(target, parent) {
102
+ addScope(parent) {
117
103
  walk(this.content, {
118
104
  visit: 'Rule',
119
105
  enter(rule) {
120
106
  rule.prelude.children.forEach((selector) => {
121
- const str = generate(selector)
122
- if (!str.startsWith(target)) return
123
-
124
107
  selector.children.prependData({ type: 'Combinator', name: ' ' })
125
108
  selector.children.prependData({ type: 'IdSelector', name: parent })
126
109
  })
@@ -173,11 +156,27 @@ class Input extends Cell {
173
156
  }
174
157
  }
175
158
 
159
+ class Detail 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
+
176
173
  module.exports = {
177
174
  Cell,
178
175
  Container,
179
176
  Fragment,
180
177
  Text,
181
178
  Input,
179
+ Detail,
180
+ Summary,
182
181
  Style
183
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, Detail, Summary } = require('./cells')
2
2
 
3
3
  module.exports = {
4
4
  '': Fragment,
@@ -12,7 +12,9 @@ module.exports = {
12
12
  input: Input.Styled({ multiline: false }),
13
13
  textbox: Input.Styled({ multiline: true }),
14
14
  span: Text,
15
- button: Text.Styled({ events: ['click'] }),
15
+ button: Container.Styled({ events: ['click'] }),
16
16
  p: Text.Styled({ paragraph: true }),
17
+ detail: Detail,
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.0",
3
+ "version": "1.4.2",
4
4
  "description": "cellery",
5
5
  "exports": {
6
6
  "./package": "./package.json",