not-bulma 1.0.63 → 1.0.65

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "not-bulma",
3
- "version": "1.0.63",
3
+ "version": "1.0.65",
4
4
  "description": "not-* family UI components on Bulma CSS Framework",
5
5
  "main": "src/index.js",
6
6
  "svelte": "src/index.js",
package/src/frame/app.js CHANGED
@@ -1,208 +1,230 @@
1
- import notCommon from './common.js';
2
- import notRecord from './record.js';
3
- import notBase from './base.js';
4
- import notRouter from './router.js';
1
+ import notCommon from "./common.js";
2
+ import notRecord from "./record.js";
3
+ import notBase from "./base.js";
4
+ import notRouter from "./router.js";
5
5
 
6
- const OPT_CONTROLLER_PREFIX = 'nc',
7
- OPT_RECORD_PREFIX = 'nr',
8
- DEFAULT_WS_CLIENT_NAME = 'main';
6
+ const OPT_CONTROLLER_PREFIX = "nc",
7
+ OPT_RECORD_PREFIX = "nr",
8
+ DEFAULT_WS_CLIENT_NAME = "main";
9
9
 
10
10
  export default class notApp extends notBase {
11
- static DEFAULT_WS_CLIENT_NAME = DEFAULT_WS_CLIENT_NAME;
12
- constructor(options) {
13
- super({
14
- working: {
15
- name: options.name,
16
- interfaces: {},
17
- controllers: Object.prototype.hasOwnProperty.call(options, 'controllers') ? options.controllers : {},
18
- initController: null,
19
- currentController: null,
20
- uis: {},
21
- wsc: {},
22
- wss: {},
23
- services: {}
24
- },
25
- options
26
- });
27
- this.log('start app');
28
- notCommon.register('app', this);
29
- this.initManifest();
30
- return this;
31
- }
32
-
33
- initManifest() {
34
- notCommon.getJSON(this.getOptions('manifestURL'), {})
35
- .then(this.setInterfaceManifest.bind(this))
36
- .catch(notCommon.report.bind(this));
37
- }
38
-
39
- initRouter() {
40
- this.setWorking('router', notRouter);
41
- this.getWorking('router').setRoot(this.getOptions('router.root'));
42
- notRouter.reRouteExisted();
43
- }
44
-
45
- execRouter() {
46
- var routieInput = {};
47
- for (let t = 0; t < this.getOptions('router.manifest').length; t++) {
48
- let routeBlock = this.getOptions('router.manifest')[t],
49
- paths = routeBlock.paths,
50
- schemes = routeBlock.schemes,
51
- controller = routeBlock.controller;
52
- for (let i = 0; i < paths.length; i++) {
53
- let pathScheme = (schemes && Array.isArray(schemes) && schemes.length > i) ? schemes[i] : false;
54
- routieInput[paths[i]] = this.bindController(controller, pathScheme);
55
- }
56
- }
57
- this.getWorking('router').addList(routieInput).listen(); //.navigate(this.getOptions('router.index'));
58
- }
59
-
60
- setInterfaceManifest(manifest) {
61
- this.setOptions('interfaceManifest', manifest);
62
- this.initRouter();
63
- this.update();
64
- }
65
-
66
- getInterfaceManifest(modelName) {
67
- if (modelName) {
68
- return this.getOptions('interfaceManifest')[modelName];
69
- } else {
70
- return this.getOptions('interfaceManifest');
71
- }
72
- }
73
-
74
- update() {
75
- //нужно инициализировать
76
- //модели полученными интерфейсами
77
- this.updateInterfaces();
78
- //иницилицировать и запустить контроллер инициализации
79
- this.initController();
80
- this.startApp();
81
- }
82
-
83
- startApp() {
84
- this.initServices();
85
- //создать контроллеры
86
- //роутер и привязать к нему контроллеры
87
- this.execRouter();
88
- this.emit('afterStarted', this);
89
- }
90
-
91
- bindController(controllerName, controllerPathScheme) {
92
- let app = this;
93
- return function() {
94
- new controllerName(app, arguments, controllerPathScheme);
95
- };
96
- }
97
-
98
- initController() {
99
- if (typeof(this.getOptions('initController')) !== 'undefined') {
100
- let initController = this.getOptions('initController');
101
- this.setWorking('initController', new initController(this));
102
- }
103
- }
104
-
105
- getCurrentController() {
106
- return this.getWorking('currentController');
107
- }
108
-
109
- setCurrentController(ctrl) {
110
- let oldCtrl = this.getCurrentController();
111
- if (oldCtrl && oldCtrl.destroy) {
112
- oldCtrl.destroy();
113
- }
114
- this.setWorking('currentController', ctrl);
115
- return this;
116
- }
117
-
118
- updateInterfaces() {
119
- this.clearInterfaces();
120
- let manifests = this.getOptions('interfaceManifest');
121
- if (manifests) {
122
- for (let name in manifests) {
123
- let recordManifest = manifests[name],
124
- recordMethods = this.getOptions(['models', name].join('.'), {});
125
- recordManifest.methods = recordMethods;
126
- this.getWorking('interfaces')[name] = (recordData) => new notRecord(recordManifest, recordData);
127
- window['nr' + notCommon.capitalizeFirstLetter(name)] = this.getWorking('interfaces')[name];
128
- }
129
- }
130
- }
131
-
132
- getRecordName(name) {
133
- return OPT_RECORD_PREFIX + notCommon.capitalizeFirstLetter(name);
134
- }
135
-
136
- getControllerName(name) {
137
- return OPT_CONTROLLER_PREFIX + notCommon.capitalizeFirstLetter(name);
138
- }
139
-
140
- getInterfaces() {
141
- return this.getWorking('interfaces');
142
- }
143
-
144
- clearInterfaces() {
145
- this.setWorking('interfaces', {});
146
- return this;
147
- }
148
-
149
- setWSClient(name = DEFAULT_WS_CLIENT_NAME, wsc) {
150
- return this.setWorking(`wsc.${name}`, wsc);
151
- }
152
-
153
- getWSClient(name = DEFAULT_WS_CLIENT_NAME) {
154
- return this.getWorking(`wsc.${name}`);
155
- }
156
-
157
- getInterface(name) {
158
- return this.getInterfaces()[name];
159
- }
160
-
161
- getModel(name, data = {}) {
162
- return this.getInterface(name)(data);
163
- }
164
-
165
- setService(name, val) {
166
- return this.setWorking(`services.${name}`, val);
167
- }
168
-
169
- getService(name) {
170
- return this.getWorking(`services.${name}`);
171
- }
172
-
173
- initServices() {
174
- if (this.getOptions('services')) {
175
- for (let servName in this.getOptions('services')) {
176
- try {
177
- let serv = this.getOptions(`services.${servName}`);
178
- const servType = notCommon.detectType(serv);
179
- switch (servType) {
180
- case 'function':
181
- case 'class':
182
- this.setService(servName, new serv(this));
183
- break;
184
- default:
185
- this.setService(servName, serv);
186
- }
187
- } catch (e) {
188
- this.error(`Service (${servName}) init error`, e);
11
+ static DEFAULT_WS_CLIENT_NAME = DEFAULT_WS_CLIENT_NAME;
12
+ constructor(options) {
13
+ super({
14
+ working: {
15
+ name: options.name,
16
+ interfaces: {},
17
+ controllers: Object.prototype.hasOwnProperty.call(
18
+ options,
19
+ "controllers"
20
+ )
21
+ ? options.controllers
22
+ : {},
23
+ initController: null,
24
+ currentController: null,
25
+ uis: {},
26
+ wsc: {},
27
+ wss: {},
28
+ services: {},
29
+ },
30
+ options,
31
+ });
32
+ this.log("start app");
33
+ notCommon.register("app", this);
34
+ this.initManifest();
35
+ return this;
36
+ }
37
+
38
+ initManifest() {
39
+ notCommon
40
+ .getJSON(this.getOptions("manifestURL"), {})
41
+ .then(this.setInterfaceManifest.bind(this))
42
+ .catch(notCommon.report.bind(this));
43
+ }
44
+
45
+ initRouter() {
46
+ this.setWorking("router", notRouter);
47
+ this.getWorking("router").setRoot(this.getOptions("router.root"));
48
+ notRouter.reRouteExisted();
49
+ }
50
+
51
+ execRouter() {
52
+ var routieInput = {};
53
+ for (let t = 0; t < this.getOptions("router.manifest").length; t++) {
54
+ let routeBlock = this.getOptions("router.manifest")[t],
55
+ paths = routeBlock.paths,
56
+ schemes = routeBlock.schemes,
57
+ controller = routeBlock.controller;
58
+ for (let i = 0; i < paths.length; i++) {
59
+ let pathScheme =
60
+ schemes && Array.isArray(schemes) && schemes.length > i
61
+ ? schemes[i]
62
+ : false;
63
+ routieInput[paths[i]] = this.bindController(
64
+ controller,
65
+ pathScheme
66
+ );
67
+ }
189
68
  }
190
- }
69
+ this.getWorking("router").addList(routieInput).listen(); //.navigate(this.getOptions('router.index'));
191
70
  }
192
- }
193
71
 
194
- getConfigReaderForModule(moduleName = '') {
195
- const modConfPath = ['modules', moduleName].join('.');
196
- return {
197
- get: (subPath, fallback) => {
198
- if (subPath && typeof subPath == 'string' && subPath.length) {
199
- return this.getOptions([modConfPath, subPath].join('.'), fallback);
72
+ setInterfaceManifest(manifest) {
73
+ this.setOptions("interfaceManifest", manifest);
74
+ this.initRouter();
75
+ this.update();
76
+ }
77
+
78
+ getInterfaceManifest(modelName) {
79
+ if (modelName) {
80
+ return this.getOptions("interfaceManifest")[modelName];
200
81
  } else {
201
- return this.getOptions(modConfPath, fallback);
82
+ return this.getOptions("interfaceManifest");
83
+ }
84
+ }
85
+
86
+ update() {
87
+ //нужно инициализировать
88
+ //модели полученными интерфейсами
89
+ this.updateInterfaces();
90
+ //иницилицировать и запустить контроллер инициализации
91
+ this.initController();
92
+ this.startApp();
93
+ }
94
+
95
+ startApp() {
96
+ this.initServices();
97
+ //создать контроллеры
98
+ //роутер и привязать к нему контроллеры
99
+ this.execRouter();
100
+ this.emit("afterStarted", this);
101
+ }
102
+
103
+ bindController(controllerName, controllerPathScheme) {
104
+ let app = this;
105
+ return function () {
106
+ new controllerName(app, arguments, controllerPathScheme);
107
+ };
108
+ }
109
+
110
+ initController() {
111
+ if (typeof this.getOptions("initController") !== "undefined") {
112
+ let initController = this.getOptions("initController");
113
+ this.setWorking("initController", new initController(this));
202
114
  }
203
- }
204
- };
205
- }
115
+ }
206
116
 
117
+ getCurrentController() {
118
+ return this.getWorking("currentController");
119
+ }
207
120
 
121
+ setCurrentController(ctrl) {
122
+ let oldCtrl = this.getCurrentController();
123
+ if (oldCtrl && oldCtrl.destroy) {
124
+ oldCtrl.destroy();
125
+ }
126
+ this.setWorking("currentController", ctrl);
127
+ return this;
128
+ }
129
+
130
+ updateInterfaces() {
131
+ this.clearInterfaces();
132
+ let manifests = this.getOptions("interfaceManifest");
133
+ if (manifests) {
134
+ for (let name in manifests) {
135
+ let recordManifest = manifests[name],
136
+ recordMethods = this.getOptions(
137
+ ["models", name].join("."),
138
+ {}
139
+ );
140
+ recordManifest.methods = recordMethods;
141
+ this.getWorking("interfaces")[name] = (recordData) =>
142
+ new notRecord(recordManifest, recordData);
143
+ window["nr" + notCommon.capitalizeFirstLetter(name)] =
144
+ this.getWorking("interfaces")[name];
145
+ }
146
+ }
147
+ }
148
+
149
+ getRecordName(name) {
150
+ return OPT_RECORD_PREFIX + notCommon.capitalizeFirstLetter(name);
151
+ }
152
+
153
+ getControllerName(name) {
154
+ return OPT_CONTROLLER_PREFIX + notCommon.capitalizeFirstLetter(name);
155
+ }
156
+
157
+ getInterfaces() {
158
+ return this.getWorking("interfaces");
159
+ }
160
+
161
+ clearInterfaces() {
162
+ this.setWorking("interfaces", {});
163
+ return this;
164
+ }
165
+
166
+ setWSClient(name = DEFAULT_WS_CLIENT_NAME, wsc) {
167
+ return this.setWorking(`wsc.${name}`, wsc);
168
+ }
169
+
170
+ getWSClient(name = DEFAULT_WS_CLIENT_NAME) {
171
+ return this.getWorking(`wsc.${name}`);
172
+ }
173
+
174
+ getInterface(name) {
175
+ return this.getInterfaces()[name];
176
+ }
177
+
178
+ getModel(name, data = {}) {
179
+ return this.getInterface(name)(data);
180
+ }
181
+
182
+ setService(name, val) {
183
+ return this.setWorking(`services.${name}`, val);
184
+ }
185
+
186
+ getService(name) {
187
+ return this.getWorking(`services.${name}`);
188
+ }
189
+
190
+ initServices() {
191
+ if (this.getOptions("services")) {
192
+ for (let servName in this.getOptions("services")) {
193
+ try {
194
+ let serv = this.getOptions(`services.${servName}`);
195
+ const servType = notCommon.detectType(serv);
196
+ switch (servType) {
197
+ case "function":
198
+ case "class":
199
+ this.setService(servName, new serv(this));
200
+ break;
201
+ default:
202
+ this.setService(servName, serv);
203
+ }
204
+ } catch (e) {
205
+ this.error(`Service (${servName}) init error`, e);
206
+ }
207
+ }
208
+ }
209
+ }
210
+
211
+ getConfigReaderForModule(moduleName = "") {
212
+ const modConfPath = ["modules", moduleName].join(".");
213
+ return {
214
+ get: (subPath, fallback) => {
215
+ if (subPath && typeof subPath == "string" && subPath.length) {
216
+ return this.getOptions(
217
+ [modConfPath, subPath].join("."),
218
+ fallback
219
+ );
220
+ } else {
221
+ return this.getOptions(modConfPath, fallback);
222
+ }
223
+ },
224
+ };
225
+ }
226
+
227
+ moduleConfig(moduleName = "") {
228
+ return this.getConfigReaderForModule(moduleName);
229
+ }
208
230
  }
@@ -26,6 +26,7 @@ class notSideMenu extends Menu {
26
26
  navigate: (urls) => {
27
27
  if (this.isTouch()) {
28
28
  this.hide();
29
+ this.app.emit("top-navbar-burger:update", { closed: true });
29
30
  }
30
31
  if (!this.isDirectNavigation() && this.app) {
31
32
  let func = this.app.getWorking("router");
@@ -163,34 +164,40 @@ class notSideMenu extends Menu {
163
164
 
164
165
  static toggle(e) {
165
166
  e && e.preventDefault();
166
- if (this.isTouch()) {
167
- this.aside.classList.toggle("is-active");
168
- } else {
169
- this.aside.classList.toggle("is-closed");
167
+ if (this.aside) {
168
+ if (this.isTouch()) {
169
+ this.aside.classList.toggle("is-active");
170
+ } else {
171
+ this.aside.classList.toggle("is-closed");
172
+ }
173
+ this.resizeMain();
170
174
  }
171
- this.resizeMain();
172
175
  return false;
173
176
  }
174
177
 
175
178
  static hide(e) {
176
179
  e && e.preventDefault();
177
- if (this.isTouch()) {
178
- this.aside.classList.remove("is-active");
179
- } else {
180
- this.aside.classList.add("is-closed");
180
+ if (this.aside) {
181
+ if (this.isTouch()) {
182
+ this.aside.classList.remove("is-active");
183
+ } else {
184
+ this.aside.classList.add("is-closed");
185
+ }
186
+ this.resizeMain();
181
187
  }
182
- this.resizeMain();
183
188
  return false;
184
189
  }
185
190
 
186
191
  static show(e) {
187
192
  e && e.preventDefault();
188
- if (this.isTouch()) {
189
- this.aside.classList.add("is-active");
190
- } else {
191
- this.aside.classList.remove("is-closed");
193
+ if (this.aside) {
194
+ if (this.isTouch()) {
195
+ this.aside.classList.add("is-active");
196
+ } else {
197
+ this.aside.classList.remove("is-closed");
198
+ }
199
+ this.resizeMain();
192
200
  }
193
- this.resizeMain();
194
201
  return false;
195
202
  }
196
203
 
@@ -1,15 +1,17 @@
1
1
  <script>
2
- import UIIcon from '../../../../elements/icon/ui.icon.svelte';
3
- export let url = '/';
4
- export let title = '';
5
- export let icon = {
6
- src: 'https://via.placeholder.com/56x28',
7
- width: 28,
8
- height: 56
9
- };
2
+ import UIIcon from "../../../../elements/icon/ui.icon.svelte";
3
+ export let url = "/";
4
+ export let title = "";
5
+ export let icon = {
6
+ src: "https://via.placeholder.com/56x28",
7
+ width: 28,
8
+ height: 56,
9
+ };
10
10
  </script>
11
11
 
12
-
13
- <a class="navbar-item" href="{url}">
14
- <UIIcon {...icon}></UIIcon>{title?` ${title}`:''}
12
+ <a class="navbar-item" href={url}>
13
+ <UIIcon {...icon} />
14
+ {#if title}
15
+ {@html `<span class="navbar-item-brand-title">${title}</span>`}
16
+ {/if}
15
17
  </a>
@@ -1,46 +1,52 @@
1
1
  <script>
2
- const COMPONENT_NAME = 'top-navbar-burger';
2
+ const COMPONENT_NAME = "top-navbar-burger";
3
3
 
4
- import {
5
- createEventDispatcher,
6
- onMount
7
- } from 'svelte';
8
- const dispatch = createEventDispatcher();
4
+ import { createEventDispatcher, onMount } from "svelte";
9
5
 
10
- import notCommon from '../../../common';
6
+ const dispatch = createEventDispatcher();
11
7
 
12
- export let events = {};
13
- export let register = notCommon.registerWidgetEvents.bind(notCommon);
8
+ import notCommon from "../../../common";
14
9
 
15
- export let closed = true;
10
+ export let events = {};
11
+ export let register = notCommon.registerWidgetEvents.bind(notCommon);
16
12
 
17
- function toggle(e) {
18
- e.preventDefault();
19
- closed = !closed;
20
- dispatch('toggle', {
21
- closed
22
- });
23
- return false;
24
- }
25
-
26
- function getStandartUpdateEventName() {
27
- return COMPONENT_NAME + ':update';
28
- }
13
+ export let closed = true;
29
14
 
30
- export let onUpdate = (data) => {
31
- closed = data.closed;
32
- };
15
+ function toggle(e) {
16
+ e.preventDefault();
17
+ closed = !closed;
18
+ dispatch("toggle", {
19
+ closed,
20
+ });
21
+ return false;
22
+ }
33
23
 
34
- onMount(() => {
35
- if (!Object.prototype.hasOwnProperty.call(events, getStandartUpdateEventName())) {
36
- events[getStandartUpdateEventName()] = onUpdate;
24
+ function getStandartUpdateEventName() {
25
+ return COMPONENT_NAME + ":update";
37
26
  }
38
- register(events);
39
- });
27
+
28
+ export let onUpdate = (data) => {
29
+ closed = data.closed;
30
+ };
31
+
32
+ onMount(() => {
33
+ if (!Object.hasOwn(events, getStandartUpdateEventName())) {
34
+ events[getStandartUpdateEventName()] = onUpdate;
35
+ }
36
+ register(events);
37
+ });
40
38
  </script>
41
39
 
42
- <a href on:click={toggle} role="button" class="navbar-burger {closed?'':'is-active'}" aria-label="menu" aria-expanded="false" data-target="navbar">
43
- <span aria-hidden="true"></span>
44
- <span aria-hidden="true"></span>
45
- <span aria-hidden="true"></span>
40
+ <a
41
+ href
42
+ on:click={toggle}
43
+ role="button"
44
+ class="navbar-burger {closed ? '' : 'is-active'}"
45
+ aria-label="menu"
46
+ aria-expanded="false"
47
+ data-target="navbar"
48
+ >
49
+ <span aria-hidden="true" />
50
+ <span aria-hidden="true" />
51
+ <span aria-hidden="true" />
46
52
  </a>
@@ -81,3 +81,6 @@ a:not(.is-active) > span.is-no-link:hover{
81
81
  .menu-list li ul, .menu-list li ul li ul{
82
82
  margin-right: 0em!important;
83
83
  }
84
+ .navbar-item-brand-title{
85
+ margin-left: 1rem;
86
+ }