@symbo.ls/sync 2.11.437 → 2.11.438

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/DefaultSyncApp.js CHANGED
@@ -1,8 +1,9 @@
1
1
  'use strict'
2
2
 
3
+ import { SyncComponent } from './index'
3
4
  import { Inspect } from './Inspect'
4
5
  import { Notifications } from './Notifications'
5
6
 
6
7
  export const DefaultSyncApp = {
7
- extend: [Inspect, Notifications]
8
+ extend: [SyncComponent, Inspect, Notifications]
8
9
  }
package/Inspect.js CHANGED
@@ -4,6 +4,55 @@ import * as smblsUI from '@symbo.ls/uikit'
4
4
  import { isObject, isString, isArray } from '@domql/utils'
5
5
  import { send } from '@symbo.ls/socket/client'
6
6
 
7
+ function returnStringExtend (extend) {
8
+ return isString(extend) ? extend : isArray(extend) ? extend.find(extItem => isString(extItem)) : ''
9
+ }
10
+
11
+ function getComponentKey (el) {
12
+ if (!el) return
13
+ const __componentKey = el.__ref.__componentKey
14
+ const extendStr = el.extend && returnStringExtend(el.extend)
15
+ const parentChildExtendStr = el.parent && el.parent.childExtend && returnStringExtend(el.parent.childExtend)
16
+ return (__componentKey || extendStr || parentChildExtendStr || '').split('_')[0].split('.')[0].split('+')[0]
17
+ }
18
+
19
+ function findComponent (el) {
20
+ if (!el || !el.__ref) return
21
+ const { components, pages, editor } = el.context
22
+ const componentKey = getComponentKey(el)
23
+ if (editor && editor.onInitInspect) {
24
+ const initInspectReturns = editor.onInitInspect(componentKey, el, el.state)
25
+ if (!initInspectReturns) return findComponent(el.parent)
26
+ }
27
+ if (componentKey && (components[componentKey] || pages[componentKey])) {
28
+ return el
29
+ }
30
+ return findComponent(el.parent)
31
+ }
32
+
33
+ export const inspectOnKey = (app, ctx) => {
34
+ const windowOpts = ctx.window || window
35
+ windowOpts.onkeydown = (ev) => {
36
+ if (ev.altKey && ev.shiftKey) {
37
+ app.state.update({ debugging: true, preventSelect: true }, {
38
+ preventUpdate: true,
39
+ preventContentUpdate: true,
40
+ preventRecursive: true
41
+ })
42
+ }
43
+ }
44
+ windowOpts.onkeyup = (ev) => {
45
+ if (app.state.preventSelect && (!ev.altKey || !ev.shiftKey)) {
46
+ app.state.replace({ debugging: false, preventSelect: false }, {
47
+ preventUpdate: true,
48
+ preventContentUpdate: true,
49
+ preventRecursive: true
50
+ })
51
+ app.focus.state.update({ area: false })
52
+ }
53
+ }
54
+ }
55
+
7
56
  export const Inspect = {
8
57
  props: {
9
58
  '.preventSelect': { userSelect: 'none' },
@@ -145,52 +194,3 @@ export const Inspect = {
145
194
  }
146
195
  }
147
196
  }
148
-
149
- function returnStringExtend (extend) {
150
- return isString(extend) ? extend : isArray(extend) ? extend.find(extItem => isString(extItem)) : ''
151
- }
152
-
153
- function getComponentKey (el) {
154
- if (!el) return
155
- const __componentKey = el.__ref.__componentKey
156
- const extendStr = el.extend && returnStringExtend(el.extend)
157
- const parentChildExtendStr = el.parent && el.parent.childExtend && returnStringExtend(el.parent.childExtend)
158
- return (__componentKey || extendStr || parentChildExtendStr || '').split('_')[0].split('.')[0].split('+')[0]
159
- }
160
-
161
- function findComponent (el) {
162
- if (!el || !el.__ref) return
163
- const { components, pages, editor } = el.context
164
- const componentKey = getComponentKey(el)
165
- if (editor && editor.onInitInspect) {
166
- const initInspectReturns = editor.onInitInspect(componentKey, el, el.state)
167
- if (!initInspectReturns) return findComponent(el.parent)
168
- }
169
- if (componentKey && (components[componentKey] || pages[componentKey])) {
170
- return el
171
- }
172
- return findComponent(el.parent)
173
- }
174
-
175
- export const inspectOnKey = (app, ctx) => {
176
- const windowOpts = ctx.window || window
177
- windowOpts.onkeydown = (ev) => {
178
- if (ev.altKey && ev.shiftKey) {
179
- app.state.update({ debugging: true, preventSelect: true }, {
180
- preventUpdate: true,
181
- preventContentUpdate: true,
182
- preventRecursive: true
183
- })
184
- }
185
- }
186
- windowOpts.onkeyup = (ev) => {
187
- if (app.state.preventSelect && (!ev.altKey || !ev.shiftKey)) {
188
- app.state.replace({ debugging: false, preventSelect: false }, {
189
- preventUpdate: true,
190
- preventContentUpdate: true,
191
- preventRecursive: true
192
- })
193
- app.focus.state.update({ area: false })
194
- }
195
- }
196
- }
package/Notifications.js CHANGED
@@ -80,41 +80,43 @@ export const connectedToSymbols = (clients, element, state) => {
80
80
  }
81
81
  }
82
82
 
83
- const Notifications = {
84
- props: {
85
- position: 'fixed',
86
- left: 'A2',
87
- bottom: 'Z2',
88
- zIndex: '999'
83
+ export const Notifications = {
84
+ state: {
85
+ notifications: []
89
86
  },
90
- childExtend: {
91
- extend: 'Notification',
92
- props: ({ state }) => ({
93
- animation: 'fadeInUp',
94
- animationDuration: 'C',
95
- background: NOTIF_COLORS[state.type || 'success'],
96
- icon: null,
97
- Flex: {
98
- Title: {
99
- text: state.title
87
+
88
+ Notifications: {
89
+ props: {
90
+ position: 'fixed',
91
+ left: 'A2',
92
+ bottom: 'Z2',
93
+ zIndex: '999'
94
+ },
95
+ childExtend: {
96
+ extend: 'Notification',
97
+ props: ({ state }) => ({
98
+ animationDuration: 'C',
99
+ background: NOTIF_COLORS[state.type || 'success'],
100
+ icon: null,
101
+ Flex: {
102
+ Title: {
103
+ text: '{{ title }}'
104
+ },
105
+ P: {
106
+ text: '{{ title }}'
107
+ }
100
108
  },
101
- P: {
102
- text: state.message
109
+ onRender: (e, el, s) => {
110
+ el.setProps({ animation: 'fadeInUp' })
111
+ },
112
+ onClick: (e, el, s) => {
113
+ delete s.notifications[el.key]
114
+ el.setProps({ animation: 'fadeOutDown' })
115
+ if (s.onClose) s.onClose(e, el, s)
103
116
  }
104
- },
105
- onClick: (e, el, s) => {
106
- delete s.notifications[el.key]
107
- el.setProps({ animation: 'fadeOutDown' })
108
- }
109
- })
110
- },
111
- $stateCollection: ({ state }) => state.notifications
112
- }
113
-
114
- export const Sync = {
115
- notifications: Notifications,
116
-
117
- state: {
118
- notifications: []
117
+ }),
118
+ IconText: null
119
+ },
120
+ $stateCollection: ({ state }) => state.notifications
119
121
  }
120
122
  }
package/index.js CHANGED
@@ -70,3 +70,9 @@ export const connectToSocket = (el, s, ctx) => {
70
70
  onChange: onChange(el, s, ctx)
71
71
  })
72
72
  }
73
+
74
+ export const SyncComponent = {
75
+ on: {
76
+ complete: connectToSocket
77
+ }
78
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/sync",
3
- "version": "2.11.437",
3
+ "version": "2.11.438",
4
4
  "main": "index.js",
5
5
  "module": "index.js",
6
6
  "gitHead": "d1b6122e6d2aaca97f342e5e9ebb181797b85e23",