sygnal 2.1.1 → 2.4.0

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/.babelrc CHANGED
@@ -1,3 +1,6 @@
1
1
  {
2
- "presets": ["@babel/preset-env"]
2
+ "presets": [["@babel/preset-env", {
3
+ "modules": false
4
+ }]],
5
+ "sourceMaps": true
3
6
  }
package/README.md CHANGED
@@ -114,11 +114,11 @@ Alternatively, you can use any other bundler of your choice (Webpack, Babel, Rol
114
114
  ...,
115
115
  esbuild: {
116
116
  // add the import for Sygnal's JSX and Fragment handler to the top of each .jsx and .tsx page automatically
117
- jsxInject: `import { jsx, Fragment } from 'sygnal/jsx'`
117
+ jsxInject: `import { jsx, Fragment } from 'sygnal/jsx'`,
118
118
  // tell the transpiler to use Sygnal's 'jsx' funtion to render JSX elements
119
119
  jsxFactory: `jsx`,
120
120
  // tell the transpiler to use Sygnal's 'Fragment' funtion to render JSX fragments (<>...</>)
121
- jsxFragment: 'Fragment',
121
+ jsxFragment: 'Fragment'
122
122
  },
123
123
  }
124
124
  ```
@@ -1,16 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = collection;
7
-
8
- var _isolate = _interopRequireDefault(require("@cycle/isolate"));
9
-
10
- var _state = require("@cycle/state");
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
-
14
3
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
4
 
16
5
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
@@ -25,11 +14,23 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
25
14
 
26
15
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
27
16
 
28
- function collection(component, stateLense) {
29
- var combineList = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ['DOM'];
30
- var globalList = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ['EVENTS'];
31
- var stateSourceName = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'STATE';
17
+ import isolate from '@cycle/isolate';
18
+ import { makeCollection } from '@cycle/state';
19
+ export default function collection(component, stateLense) {
20
+ var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
21
+ var _opts$combineList = opts.combineList,
22
+ combineList = _opts$combineList === void 0 ? ['DOM'] : _opts$combineList,
23
+ _opts$globalList = opts.globalList,
24
+ globalList = _opts$globalList === void 0 ? ['EVENTS'] : _opts$globalList,
25
+ _opts$stateSourceName = opts.stateSourceName,
26
+ stateSourceName = _opts$stateSourceName === void 0 ? 'STATE' : _opts$stateSourceName,
27
+ _opts$domSourceName = opts.domSourceName,
28
+ domSourceName = _opts$domSourceName === void 0 ? 'DOM' : _opts$domSourceName,
29
+ _opts$container = opts.container,
30
+ container = _opts$container === void 0 ? 'div' : _opts$container,
31
+ containerClass = opts.containerClass;
32
32
  return function (sources) {
33
+ var key = Date.now();
33
34
  var collectionOpts = {
34
35
  item: component,
35
36
  itemKey: function itemKey(state, ind) {
@@ -46,7 +47,28 @@ function collection(component, stateLense) {
46
47
  stream = _ref2[1];
47
48
 
48
49
  if (combineList.includes(name)) {
49
- acc[name] = instances.pickCombine(name);
50
+ var combined = instances.pickCombine(name);
51
+
52
+ if (name === domSourceName && container) {
53
+ acc.DOM = combined.map(function (children) {
54
+ var data = containerClass ? {
55
+ props: {
56
+ className: containerClass
57
+ }
58
+ } : {};
59
+ return {
60
+ sel: container,
61
+ data: data,
62
+ children: children,
63
+ key: key,
64
+ text: undefined,
65
+ elm: undefined
66
+ };
67
+ });
68
+ } else {
69
+ console.warn('Collections without wrapping containers will fail in unpredictable ways when used inside JSX fragments');
70
+ acc[name] = combined;
71
+ }
50
72
  } else {
51
73
  acc[name] = instances.pickMerge(name);
52
74
  }
@@ -77,7 +99,6 @@ function collection(component, stateLense) {
77
99
  * @return {Object} collection of component sinks
78
100
  */
79
101
 
80
-
81
102
  function makeIsolatedCollection(collectionOpts, isolateOpts, sources) {
82
- return (0, _isolate["default"])((0, _state.makeCollection)(collectionOpts), isolateOpts)(sources);
103
+ return isolate(makeCollection(collectionOpts), isolateOpts)(sources);
83
104
  }