@symbo.ls/atoms 2.11.475 → 2.11.477

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 (3) hide show
  1. package/Collection.js +26 -26
  2. package/Hgroup.js +91 -0
  3. package/package.json +2 -2
package/Collection.js CHANGED
@@ -1,46 +1,45 @@
1
1
  'use strict'
2
2
 
3
3
  import { isState, getChildStateInKey } from '@domql/state'
4
- import { isString, isNot, isArray, isObject, isObjectLike, exec, deepClone, addAdditionalExtend } from '@domql/utils'
4
+ import { isString, isNumber, isNot, isArray, isObject, isObjectLike, exec, deepClone, addAdditionalExtend } from '@domql/utils'
5
5
 
6
6
  export const Collection = {
7
7
  define: {
8
8
  $collection: (param, el, state) => {
9
9
  const { __ref: ref } = el
10
- const { children, childrenAs, childExtends } = (el.props || {})
11
- const childrenExec = children && exec(children, el, state)
12
-
13
- if (isArray(childrenExec)) {
14
- param = deepClone(childrenExec)
15
- if (childrenAs) param = param.map(v => ({ extend: childExtends, [childrenAs]: v }))
16
- } else if (isObject(childrenExec)) {
17
- if (childrenExec.$$typeof) return el.call('renderReact', childrenExec, el)
18
- param = deepClone(childrenExec)
19
- param = Object.keys(param).map(v => {
20
- const val = param[v]
21
- return addAdditionalExtend(v, val)
22
- })
23
- el.removeContent()
24
- el.content = {
25
- extend: childExtends,
26
- props: {
27
- childProps: el.props && el.props.childProps
10
+ const { children: childrenProps, childrenAs, childExtends } = (el.props || {})
11
+ const children = childrenProps && exec(childrenProps, el, state)
12
+
13
+ if (children) {
14
+ if (isObject(children)) {
15
+ if (children.$$typeof) return el.call('renderReact', children, el)
16
+ param = deepClone(children)
17
+ param = Object.keys(param).map(v => {
18
+ const val = param[v]
19
+ return addAdditionalExtend(v, val)
20
+ })
21
+ } else if (isArray(children)) {
22
+ param = deepClone(children)
23
+ if (childrenAs) {
24
+ param = param.map(v => ({
25
+ extend: childExtends,
26
+ [childrenAs]: v
27
+ }))
28
28
  }
29
+ } else if (isString(children) || isNumber(children)) {
30
+ el.removeContent()
31
+ el.content = { text: param }
32
+ return
29
33
  }
30
- return
31
- } else if (childrenExec) {
32
- el.removeContent()
33
- el.content = { text: param }
34
- return
35
34
  }
36
35
 
37
36
  if (!param) return
37
+
38
38
  const filterReact = param.filter(v => !v.$$typeof)
39
39
  if (filterReact.length !== param.length) {
40
40
  const extractedReactComponents = param.filter(v => v.$$typeof)
41
41
  el.call('renderReact', extractedReactComponents, el)
42
- }
43
- param = filterReact
42
+ } param = filterReact
44
43
 
45
44
  if (isString(param)) {
46
45
  if (param === 'state') param = state.parse()
@@ -67,6 +66,7 @@ export const Collection = {
67
66
  const obj = {
68
67
  tag: 'fragment',
69
68
  props: {
69
+ ignoreChildProps: true,
70
70
  childProps: el.props && el.props.childProps
71
71
  }
72
72
  }
package/Hgroup.js ADDED
@@ -0,0 +1,91 @@
1
+ 'use strict'
2
+
3
+ export const Hgroup = {
4
+ extend: 'Flex',
5
+ tag: 'hgroup',
6
+
7
+ props: {
8
+ flow: 'y',
9
+ gap: 'Y2',
10
+
11
+ Title: {
12
+ fontWeight: '700',
13
+ alignItems: 'center'
14
+ },
15
+
16
+ Paragraph: {
17
+ margin: '0',
18
+ color: 'caption',
19
+ '> p': { margin: '0' }
20
+ },
21
+
22
+ H: {
23
+ color: 'title',
24
+ tag: 'h3',
25
+ lineHeight: '1em',
26
+ margin: '0'
27
+ },
28
+ P: {
29
+ margin: '0',
30
+ color: 'paragraph'
31
+ }
32
+ },
33
+
34
+ H: {},
35
+ P: {},
36
+
37
+ Title: {
38
+ extend: 'Flex',
39
+ if: ({ parent }) => parent.props.title,
40
+ props: ({ parent }) => ({
41
+ text: parent.props.title,
42
+ lineHeight: '1em'
43
+ })
44
+ },
45
+
46
+ Paragraph: {
47
+ extend: 'Flex',
48
+ if: ({ parent }) => parent.props.paragraph,
49
+ props: ({ parent }) => ({
50
+ text: parent.props.paragraph,
51
+ margin: '0'
52
+ })
53
+ }
54
+ }
55
+
56
+ export const HgroupRows = {
57
+ extend: 'Hgroup',
58
+
59
+ Title: {
60
+ extend: 'Flex',
61
+ props: { color: 'title', align: 'center space-between' }
62
+ },
63
+
64
+ Paragraph: {
65
+ extend: 'Flex',
66
+ props: { color: 'paragraph', align: 'center space-between' }
67
+ }
68
+ }
69
+
70
+ export const HgroupButton = {
71
+ extend: 'HgroupRows',
72
+
73
+ Title: {
74
+ props: { justifyContent: 'space-between' },
75
+
76
+ Span: {},
77
+ Button: {
78
+ props: {
79
+ background: 'transparent',
80
+ color: 'currentColor',
81
+ padding: '0',
82
+ Icon: {
83
+ name: 'x',
84
+ fontSize: 'C'
85
+ }
86
+ }
87
+ }
88
+ },
89
+
90
+ Paragraph: {}
91
+ }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@symbo.ls/atoms",
3
- "version": "2.11.475",
3
+ "version": "2.11.477",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
- "gitHead": "d2198b5f44d161e2cf0dd8a9d88a5301192bcb02",
6
+ "gitHead": "47546f8e3e61900fb07e92c3faf7abf2bce919ae",
7
7
  "dependencies": {
8
8
  "@domql/state": "^2.5.0",
9
9
  "@domql/utils": "^2.5.0",