simplyview 2.0.2 → 2.0.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.
@@ -639,8 +639,8 @@ properties for a given parent, keep seperate index for this?
639
639
  handleEvents: function() {
640
640
  global.addEventListener('popstate', function() {
641
641
  if (route.match(getPath(document.location.pathname + document.location.hash)) === false) {
642
- route.match(getPath(document.location.pathname));
643
- }
642
+ route.match(getPath(document.location.pathname));
643
+ }
644
644
  });
645
645
  global.document.addEventListener('click', linkHandler);
646
646
  },
@@ -665,22 +665,24 @@ properties for a given parent, keep seperate index for this?
665
665
 
666
666
  var matches;
667
667
  if (!path) {
668
- if (route.match(document.location.pathname+document.location.hash)) {
669
- return true;
670
- } else {
671
- return route.match(document.location.pathname);
672
- }
668
+ if (route.match(document.location.pathname+document.location.hash)) {
669
+ return true;
670
+ } else {
671
+ return route.match(document.location.pathname);
672
+ }
673
673
  }
674
674
  path = getPath(path);
675
675
  for ( var i=0; i<routeInfo.length; i++) {
676
- if (path && path[path.length-1]!='/') {
677
- matches = routeInfo[i].match.exec(path+'/');
678
- if (matches) {
679
- path+='/';
680
- history.replaceState({}, '', getUrl(path));
676
+ matches = routeInfo[i].match.exec(path);
677
+ if (!matches || !matches.length) {
678
+ if (path && path[path.length-1]!='/') {
679
+ matches = routeInfo[i].match.exec(path+'/');
680
+ if (matches) {
681
+ path+='/';
682
+ history.replaceState({}, '', getUrl(path));
683
+ }
681
684
  }
682
685
  }
683
- matches = routeInfo[i].match.exec(path);
684
686
  if (matches && matches.length) {
685
687
  var params = {};
686
688
  routeInfo[i].params.forEach(function(key, i) {
@@ -697,9 +699,9 @@ properties for a given parent, keep seperate index for this?
697
699
  args.result = routeInfo[i].action.call(route, params);
698
700
  runListeners('finish', args);
699
701
  return args.result;
700
- }
702
+ }
701
703
  }
702
- return false;
704
+ return false;
703
705
  },
704
706
  goto: function(path) {
705
707
  history.pushState({},'',getUrl(path));
@@ -734,7 +736,7 @@ properties for a given parent, keep seperate index for this?
734
736
  listeners[action][route] = listeners[action][route].filter(function(listener) {
735
737
  return listener != callback;
736
738
  });
737
- },
739
+ },
738
740
  init: function(params) {
739
741
  if (params.root) {
740
742
  options.root = params.root;
@@ -1125,8 +1127,25 @@ properties for a given parent, keep seperate index for this?
1125
1127
  if (e.target.closest('[data-simply-keyboard]')) {
1126
1128
  selectedKeyboard = e.target.closest('[data-simply-keyboard]').dataset.simplyKeyboard;
1127
1129
  }
1128
- if (keys[selectedKeyboard] && keys[selectedKeyboard][e.code]) {
1129
- keys[selectedKeyboard][e.code].call(app,e);
1130
+ let key = '';
1131
+ if (e.ctrlKey && e.keyCode!=17) {
1132
+ key+='Control+';
1133
+ }
1134
+ if (e.metaKey && e.keyCode!=224) {
1135
+ key+='Meta+';
1136
+ }
1137
+ if (e.altKey && e.keyCode!=18) {
1138
+ key+='Alt+';
1139
+ }
1140
+ if (e.shiftKey && e.keyCode!=16) {
1141
+ key+='Shift+';
1142
+ }
1143
+ key+=e.key;
1144
+
1145
+ if (keys[selectedKeyboard] && keys[selectedKeyboard][key]) {
1146
+ let keyboard = keys[selectedKeyboard]
1147
+ keyboard.app = app;
1148
+ keyboard[key].call(keyboard,e);
1130
1149
  }
1131
1150
  });
1132
1151
 
@@ -1775,7 +1794,7 @@ properties for a given parent, keep seperate index for this?
1775
1794
  'use strict';
1776
1795
 
1777
1796
  var api = {
1778
- /**
1797
+ /**
1779
1798
  * Returns a Proxy object that translates property access to a URL in the api
1780
1799
  * and method calls to a fetch on that URL.
1781
1800
  * @param options: a list of options for fetch(),
@@ -1897,27 +1916,27 @@ properties for a given parent, keep seperate index for this?
1897
1916
  */
1898
1917
  getResult: function(response, options) {
1899
1918
  if (response.ok) {
1900
- switch(options.responseFormat) {
1901
- case 'text':
1902
- return response.text();
1903
- break;
1904
- case 'formData':
1905
- return response.formData();
1906
- break;
1907
- case 'blob':
1908
- return response.blob();
1909
- break;
1910
- case 'arrayBuffer':
1911
- return response.arrayBuffer();
1912
- break;
1913
- case 'unbuffered':
1914
- return response.body;
1915
- break;
1916
- case 'json':
1917
- default:
1918
- return response.json();
1919
- break;
1920
- }
1919
+ switch(options.responseFormat) {
1920
+ case 'text':
1921
+ return response.text();
1922
+ break;
1923
+ case 'formData':
1924
+ return response.formData();
1925
+ break;
1926
+ case 'blob':
1927
+ return response.blob();
1928
+ break;
1929
+ case 'arrayBuffer':
1930
+ return response.arrayBuffer();
1931
+ break;
1932
+ case 'unbuffered':
1933
+ return response.body;
1934
+ break;
1935
+ case 'json':
1936
+ default:
1937
+ return response.json();
1938
+ break;
1939
+ }
1921
1940
  } else {
1922
1941
  throw {
1923
1942
  status: response.status,
@@ -1925,23 +1944,22 @@ properties for a given parent, keep seperate index for this?
1925
1944
  response: response
1926
1945
  }
1927
1946
  }
1928
- },
1929
-
1930
- logError: function(error, options) {
1947
+ },
1948
+ logError: function(error, options) {
1931
1949
  console.error(error.status, error.message);
1932
- }
1950
+ }
1933
1951
  }
1934
1952
 
1935
1953
  var defaultOptions = {
1936
- path: '',
1937
- responseFormat: 'json',
1938
- paramsFormat: 'search',
1939
- verbs: ['get','post'],
1940
- handlers: {
1941
- fetch: api.fetch,
1942
- result: api.getResult,
1943
- error: api.logError
1944
- }
1954
+ path: '',
1955
+ responseFormat: 'json',
1956
+ paramsFormat: 'search',
1957
+ verbs: ['get','post'],
1958
+ handlers: {
1959
+ fetch: api.fetch,
1960
+ result: api.getResult,
1961
+ error: api.logError
1962
+ }
1945
1963
  };
1946
1964
 
1947
1965
  function cd(path, name) {
@@ -1952,20 +1970,20 @@ properties for a given parent, keep seperate index for this?
1952
1970
  return path+encodeURIComponent(name);
1953
1971
  }
1954
1972
 
1955
- function fetchChain(prop, params) {
1956
- var options = this;
1957
- return this.handlers.fetch
1958
- .call(this, prop, params, options)
1959
- .then(function(res) {
1960
- return options.handlers.result.call(options, res, options);
1961
- })
1962
- .catch(function(error) {
1963
- return options.handlers.error.call(options, error, options);
1964
- });
1965
- }
1973
+ function fetchChain(prop, params) {
1974
+ var options = this;
1975
+ return this.handlers.fetch
1976
+ .call(this, prop, params, options)
1977
+ .then(function(res) {
1978
+ return options.handlers.result.call(options, res, options);
1979
+ })
1980
+ .catch(function(error) {
1981
+ return options.handlers.error.call(options, error, options);
1982
+ });
1983
+ }
1966
1984
 
1967
1985
  function getApiHandler(options) {
1968
- options.handlers = Object.assign({}, defaultOptions.handlers, options.handlers);
1986
+ options.handlers = Object.assign({}, defaultOptions.handlers, options.handlers);
1969
1987
  options = Object.assign({}, defaultOptions, options);
1970
1988
 
1971
1989
  return {
package/js/simply.api.js CHANGED
@@ -2,7 +2,7 @@
2
2
  'use strict';
3
3
 
4
4
  var api = {
5
- /**
5
+ /**
6
6
  * Returns a Proxy object that translates property access to a URL in the api
7
7
  * and method calls to a fetch on that URL.
8
8
  * @param options: a list of options for fetch(),
@@ -124,27 +124,27 @@
124
124
  */
125
125
  getResult: function(response, options) {
126
126
  if (response.ok) {
127
- switch(options.responseFormat) {
128
- case 'text':
129
- return response.text();
130
- break;
131
- case 'formData':
132
- return response.formData();
133
- break;
134
- case 'blob':
135
- return response.blob();
136
- break;
137
- case 'arrayBuffer':
138
- return response.arrayBuffer();
139
- break;
140
- case 'unbuffered':
141
- return response.body;
142
- break;
143
- case 'json':
144
- default:
145
- return response.json();
146
- break;
147
- }
127
+ switch(options.responseFormat) {
128
+ case 'text':
129
+ return response.text();
130
+ break;
131
+ case 'formData':
132
+ return response.formData();
133
+ break;
134
+ case 'blob':
135
+ return response.blob();
136
+ break;
137
+ case 'arrayBuffer':
138
+ return response.arrayBuffer();
139
+ break;
140
+ case 'unbuffered':
141
+ return response.body;
142
+ break;
143
+ case 'json':
144
+ default:
145
+ return response.json();
146
+ break;
147
+ }
148
148
  } else {
149
149
  throw {
150
150
  status: response.status,
@@ -152,23 +152,22 @@
152
152
  response: response
153
153
  }
154
154
  }
155
- },
156
-
157
- logError: function(error, options) {
155
+ },
156
+ logError: function(error, options) {
158
157
  console.error(error.status, error.message);
159
- }
158
+ }
160
159
  }
161
160
 
162
161
  var defaultOptions = {
163
- path: '',
164
- responseFormat: 'json',
165
- paramsFormat: 'search',
166
- verbs: ['get','post'],
167
- handlers: {
168
- fetch: api.fetch,
169
- result: api.getResult,
170
- error: api.logError
171
- }
162
+ path: '',
163
+ responseFormat: 'json',
164
+ paramsFormat: 'search',
165
+ verbs: ['get','post'],
166
+ handlers: {
167
+ fetch: api.fetch,
168
+ result: api.getResult,
169
+ error: api.logError
170
+ }
172
171
  };
173
172
 
174
173
  function cd(path, name) {
@@ -179,20 +178,20 @@
179
178
  return path+encodeURIComponent(name);
180
179
  }
181
180
 
182
- function fetchChain(prop, params) {
183
- var options = this;
184
- return this.handlers.fetch
185
- .call(this, prop, params, options)
186
- .then(function(res) {
187
- return options.handlers.result.call(options, res, options);
188
- })
189
- .catch(function(error) {
190
- return options.handlers.error.call(options, error, options);
191
- });
192
- }
181
+ function fetchChain(prop, params) {
182
+ var options = this;
183
+ return this.handlers.fetch
184
+ .call(this, prop, params, options)
185
+ .then(function(res) {
186
+ return options.handlers.result.call(options, res, options);
187
+ })
188
+ .catch(function(error) {
189
+ return options.handlers.error.call(options, error, options);
190
+ });
191
+ }
193
192
 
194
193
  function getApiHandler(options) {
195
- options.handlers = Object.assign({}, defaultOptions.handlers, options.handlers);
194
+ options.handlers = Object.assign({}, defaultOptions.handlers, options.handlers);
196
195
  options = Object.assign({}, defaultOptions, options);
197
196
 
198
197
  return {
@@ -25,8 +25,25 @@
25
25
  if (e.target.closest('[data-simply-keyboard]')) {
26
26
  selectedKeyboard = e.target.closest('[data-simply-keyboard]').dataset.simplyKeyboard;
27
27
  }
28
- if (keys[selectedKeyboard] && keys[selectedKeyboard][e.code]) {
29
- keys[selectedKeyboard][e.code].call(app,e);
28
+ let key = '';
29
+ if (e.ctrlKey && e.keyCode!=17) {
30
+ key+='Control+';
31
+ }
32
+ if (e.metaKey && e.keyCode!=224) {
33
+ key+='Meta+';
34
+ }
35
+ if (e.altKey && e.keyCode!=18) {
36
+ key+='Alt+';
37
+ }
38
+ if (e.shiftKey && e.keyCode!=16) {
39
+ key+='Shift+';
40
+ }
41
+ key+=e.key;
42
+
43
+ if (keys[selectedKeyboard] && keys[selectedKeyboard][key]) {
44
+ let keyboard = keys[selectedKeyboard]
45
+ keyboard.app = app;
46
+ keyboard[key].call(keyboard,e);
30
47
  }
31
48
  });
32
49
 
@@ -118,8 +118,8 @@
118
118
  handleEvents: function() {
119
119
  global.addEventListener('popstate', function() {
120
120
  if (route.match(getPath(document.location.pathname + document.location.hash)) === false) {
121
- route.match(getPath(document.location.pathname));
122
- }
121
+ route.match(getPath(document.location.pathname));
122
+ }
123
123
  });
124
124
  global.document.addEventListener('click', linkHandler);
125
125
  },
@@ -144,22 +144,24 @@
144
144
 
145
145
  var matches;
146
146
  if (!path) {
147
- if (route.match(document.location.pathname+document.location.hash)) {
148
- return true;
149
- } else {
150
- return route.match(document.location.pathname);
151
- }
147
+ if (route.match(document.location.pathname+document.location.hash)) {
148
+ return true;
149
+ } else {
150
+ return route.match(document.location.pathname);
151
+ }
152
152
  }
153
153
  path = getPath(path);
154
154
  for ( var i=0; i<routeInfo.length; i++) {
155
- if (path && path[path.length-1]!='/') {
156
- matches = routeInfo[i].match.exec(path+'/');
157
- if (matches) {
158
- path+='/';
159
- history.replaceState({}, '', getUrl(path));
155
+ matches = routeInfo[i].match.exec(path);
156
+ if (!matches || !matches.length) {
157
+ if (path && path[path.length-1]!='/') {
158
+ matches = routeInfo[i].match.exec(path+'/');
159
+ if (matches) {
160
+ path+='/';
161
+ history.replaceState({}, '', getUrl(path));
162
+ }
160
163
  }
161
164
  }
162
- matches = routeInfo[i].match.exec(path);
163
165
  if (matches && matches.length) {
164
166
  var params = {};
165
167
  routeInfo[i].params.forEach(function(key, i) {
@@ -176,9 +178,9 @@
176
178
  args.result = routeInfo[i].action.call(route, params);
177
179
  runListeners('finish', args);
178
180
  return args.result;
179
- }
181
+ }
180
182
  }
181
- return false;
183
+ return false;
182
184
  },
183
185
  goto: function(path) {
184
186
  history.pushState({},'',getUrl(path));
@@ -213,7 +215,7 @@
213
215
  listeners[action][route] = listeners[action][route].filter(function(listener) {
214
216
  return listener != callback;
215
217
  });
216
- },
218
+ },
217
219
  init: function(params) {
218
220
  if (params.root) {
219
221
  options.root = params.root;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simplyview",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "Library to rapidly build UI components, using declarative tools",
5
5
  "main": "dist/simply.everything.js",
6
6
  "directories": {
@@ -1,107 +0,0 @@
1
- <!doctype html>
2
- <meta charset="utf-8">
3
- <pre id="output"></pre>
4
- <script src="../dist/simply.everything.js"></script>
5
- <script src="../js/simply.api.js"></script>
6
- <h1>Github repo browser</h1>
7
- <form data-simply-command="showRepo">
8
- <label>Owner
9
- <input type="text" name="owner">
10
- </label>
11
- <label>Repository
12
- <input type="text" name="repo">
13
- </label>
14
- <label>Application token
15
- <input type="text" name="token">
16
- </label>
17
- <button type="submit">OK</button>
18
- </form>
19
- <main>
20
- <h2 data-simply-field="repo.name"></h2>
21
- <div data-simply-field="repo.description"></div>
22
- <ul data-simply-list="repo.files.entries">
23
- <template>
24
- <li><span data-simply-field="name"></span></li>
25
- </template>
26
- </ul>
27
- </main>
28
- <script>
29
- simply.bind = false;
30
- document.addEventListener('simply-content-loaded', function() {
31
- editor.pageData.repo = {
32
- name: "foo",
33
- files: {
34
- entries: [
35
- {
36
- name: 'barf'
37
- }
38
- ]
39
- }
40
- };
41
- return;
42
- });
43
-
44
-
45
- var githubURL = 'https://api.github.com/graphql';
46
- var githubToken = 'af948d67c63a2f9f940e0b0be7a2d5ff3446327f';
47
- var github = {
48
- repository: simply.api.graphqlQuery(
49
- githubURL,
50
- `query($owner:String!, $repo:String!) {
51
- repository(name:$repo, owner:$owner) {
52
- id
53
- name
54
- description
55
- files: object(expression: "master:") {
56
- ... on Tree {
57
- entries {
58
- oid
59
- name
60
- type
61
- }
62
- }
63
-
64
- }
65
- }
66
- }`,
67
- {
68
- headers: { Authorization: 'bearer '+githubToken },
69
- responseResult: 'data.repository',
70
- responseErrors: 'errors'
71
- }
72
- )
73
- };
74
- /*
75
- github.repository({
76
- login: 'poef',
77
- repo: 'arc-web'
78
- }).then(function(data) {
79
- document.getElementById('output').innerText = JSON.stringify(data,
80
- null, 4);
81
- });
82
-
83
- async function foo() {
84
- var foo = await github.repository({ login: 'poef', repo: 'arc-web'});
85
- console.log(foo);
86
- };
87
- foo();
88
- */
89
- var githubBrowser = simply.app({
90
- commands: {
91
- 'showRepo': function(form, values) {
92
- if (values.token) {
93
- githubToken = values.token;
94
- }
95
- github.repository({
96
- owner: values.owner,
97
- repo: values.repo
98
- })
99
- .then(function(data) {
100
- githubBrowser.view.repo = data.data.repository;
101
- });
102
- }
103
- }
104
- })
105
-
106
- </script>
107
- <script src="//cdn.simplyedit.io/1/simply-edit.js"></script>
@@ -1,51 +0,0 @@
1
- <!doctype html>
2
- <ul data-simply-list="vakleergebieden">
3
- <template>
4
- <li><span data-simply-field="title"></span></li>
5
- </template>
6
- </ul>
7
- <script src="//cdn.simplyedit.io/1/simply-edit.js" data-storage="none"></script>
8
- <script src="../dist/simply.everything.js"></script>
9
- <script>
10
- var baseURL = '//localhost:3000/';
11
-
12
- var app = simply.app({
13
- routes: {
14
- '/:*': function() {
15
- api.Vakleergebied().then(result => {
16
- app.view.vakleergebieden = result.data.allVakleergebied;
17
- });
18
- }
19
- },
20
- view: {
21
- vakleergebieden: []
22
- }
23
- });
24
-
25
- var api = simply.api.proxy({
26
- baseURL: baseURL
27
- });
28
-
29
- api.Vakleergebied = simply.api.graphqlQuery(baseURL,
30
- 'Vakleergebied',
31
- `fragment NiveauShort on Niveau {
32
- id
33
- title
34
- prefix
35
- }
36
- query Vakleergebied($page:Int,$perPage:Int) {
37
- allVakleergebied(page:$page,perPage:$perPage,sortField:"title") {
38
- id
39
- prefix
40
- title
41
- prefix
42
- Niveau {
43
- ...NiveauShort
44
- }
45
- }
46
- _allVakleergebiedMeta {
47
- count
48
- }
49
- }`);
50
-
51
- </script>
@@ -1,35 +0,0 @@
1
- <!doctype html>
2
- <script src="//cdn.simplyedit.io/1/simply-edit.js" data-storage="none"></script>
3
- <script src="../dist/simply.everything.js"></script>
4
- <script>
5
- var baseURL = '//localhost:3000/';
6
-
7
- var api = simply.api.proxy({
8
- baseURL: baseURL
9
- });
10
-
11
- api.Vakleergebied = simply.api.graphqlQuery(baseURL,
12
- 'Vakleergebied',
13
- `fragment NiveauShort on Niveau {
14
- id
15
- title
16
- prefix
17
- }
18
- query Vakleergebied($page:Int,$perPage:Int) {
19
- allVakleergebied(page:$page,perPage:$perPage,sortField:"title") {
20
- id
21
- prefix
22
- title
23
- prefix
24
- Niveau {
25
- ...NiveauShort
26
- }
27
- }
28
- _allVakleergebiedMeta {
29
- count
30
- }
31
- }`);
32
-
33
- api.Vakleergebied()
34
- .then(result => console.log(result));
35
- </script>
@@ -1,41 +0,0 @@
1
- <h1>Examples</h1>
2
- <h2>Keyboard</h2>
3
- <link rel="stylesheet" href="examples.css">
4
-
5
- <div id="myApp">
6
- <input type="text" data-simply-field="counter">
7
- <button data-simply-command="add1">+</button>
8
- <button data-simply-command="sub1">-</button>
9
- <div>Counter is now: <span data-simply-field="counter"></span></div>
10
- </div>
11
-
12
- <script src="../dist/simply.everything.js"></script>
13
- <script src="//cdn.simplyedit.io/1/simply-edit.js"></script>
14
- <script>
15
- var myApp = simply.app({
16
- container: document.getElementById('myApp'),
17
- keyboard: {
18
- default: {
19
- ArrowDown: function(e) {
20
- this.view.counter--;
21
- e.preventDefault();
22
- },
23
- ArrowUp: function(e) {
24
- this.view.counter++;
25
- e.preventDefault();
26
- }
27
- }
28
- },
29
- commands: {
30
- add1: function(el, value) {
31
- this.app.view.counter++;
32
- },
33
- sub1: function(el, value) {
34
- this.app.view.counter--;
35
- }
36
- },
37
- view: {
38
- counter: 1
39
- }
40
- });
41
- </script>
package/make~ DELETED
@@ -1,17 +0,0 @@
1
- #!/bin/bash
2
- rm dist/simply.everything.js
3
- cat js/simply.observe.js \
4
- js/simply.render.js \
5
- js/simply.path.js \
6
- js/simply.route.js \
7
- js/simply.activate.js \
8
- js/simply.collect.js \
9
- js/simply.command.js \
10
- js/simply.action.js \
11
- js/simply.resize.js \
12
- js/simply.include.js \
13
- js/simply.view.js \
14
- js/simply.viewmodel.js \
15
- js/simply.api.js \
16
- js/simply.app.js > dist/simply.everything.js
17
- cp js/simply.include.next.js dist/
package/package.json~ DELETED
@@ -1,31 +0,0 @@
1
- {
2
- "name": "simplyview",
3
- "version": "2.0.1",
4
- "description": "Library to rapidly build UI components, using declarative tools",
5
- "main": "dist/simply.everything.js",
6
- "directories": {
7
- "example": "examples"
8
- },
9
- "scripts": {
10
- "test": "jest"
11
- },
12
- "repository": {
13
- "type": "git",
14
- "url": "git+https://github.com/simplyedit/simplyview.git"
15
- },
16
- "keywords": [
17
- "UI",
18
- "components",
19
- "declarative",
20
- "reactive"
21
- ],
22
- "author": "auke@muze.nl",
23
- "license": "MIT",
24
- "bugs": {
25
- "url": "https://github.com/simplyedit/simplyview/issues"
26
- },
27
- "homepage": "https://github.com/simplyedit/simplyview#readme",
28
- "devDependencies": {
29
- "jest": "^24.9.0"
30
- }
31
- }