not-bulma 2.0.13 → 2.0.15

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.
@@ -1,6 +1,6 @@
1
- import Menu from "not-bulma/src/frame/components/navigation/menu.svelte.js";
1
+ import Menu from "./menu.svelte.js";
2
2
  import UINavbar from "../../../elements/navigation/ui.navbar.svelte";
3
- import UIAdapterSvelte from "not-bulma/src/frame/ui.adapter.svelte.js";
3
+ import UIAdapterSvelte from "../../ui.adapter.svelte.js";
4
4
 
5
5
  const TYPE = "top";
6
6
 
@@ -15,11 +15,10 @@ const TYPE = "top";
15
15
  * @prop {boolean} burgerControlsSidemenu
16
16
  * @prop {string} class
17
17
  * @prop {function} onclick
18
- *
18
+ *
19
19
  **/
20
20
 
21
21
  class notTopMenu extends Menu {
22
-
23
22
  static DEFAULT = {
24
23
  section: "any",
25
24
  sectionTitle: "Меню",
@@ -63,23 +62,22 @@ class notTopMenu extends Menu {
63
62
  onclick: this.getOptions()?.onclick,
64
63
  url: this.getCurrentUrl(),
65
64
  };
66
-
67
65
  }
68
66
 
69
67
  static render(app) {
70
68
  if (app) {
71
69
  this.setApp(app);
72
- }
70
+ }
73
71
  if (!this.menu) {
74
72
  this.prepareData();
75
73
  let props = this.initMenuProps();
76
74
  const target = document.querySelector(
77
75
  this.getOptions().targetSelector
78
- );
76
+ );
79
77
  if (!target) {
80
78
  return;
81
79
  }
82
- this.menu = new UIAdapterSvelte(UINavbar, target, props, true);
80
+ this.menu = new UIAdapterSvelte(UINavbar, target, props, true);
83
81
  this.interval = setInterval(
84
82
  this.updateMenuActiveItem.bind(this),
85
83
  notTopMenu.INTERVAL_UPDATE_ACTIVE_ITEM
@@ -87,24 +85,24 @@ class notTopMenu extends Menu {
87
85
  }
88
86
  }
89
87
 
90
- static updateMenuActiveItem() {
91
- this.menu.set('url', this.getCurrentUrl()) ;
88
+ static updateMenuActiveItem() {
89
+ this.menu.set("url", this.getCurrentUrl());
92
90
  }
93
91
 
94
92
  static toggle() {
95
- this.menu.set('active', !this.menu.get('active'));
93
+ this.menu.set("active", !this.menu.get("active"));
96
94
  }
97
95
 
98
- static hide() {
99
- this.menu.set('active', false);
96
+ static hide() {
97
+ this.menu.set("active", false);
100
98
  }
101
99
 
102
- static show() {
103
- this.menu.set('active', true);
100
+ static show() {
101
+ this.menu.set("active", true);
104
102
  }
105
103
 
106
104
  static setBurgerState(menuClosed) {
107
- this.menu.set('menuClosed', menuClosed);
105
+ this.menu.set("menuClosed", menuClosed);
108
106
  }
109
107
  }
110
108
 
@@ -1,11 +1,9 @@
1
1
  import EventEmitter from "wolfy87-eventemitter";
2
2
  import notPath from "not-path";
3
- import notCommon from "not-bulma/src/frame/common.js";
3
+ import notCommon from "../../common.js";
4
4
 
5
-
6
-
7
- import UITable from "not-bulma/src/frame/components/table/notTable.svelte";
8
- import UIAdapterSvelte from "not-bulma/src/frame/ui.adapter.svelte.js";
5
+ import UITable from "./notTable.svelte";
6
+ import UIAdapterSvelte from "../../ui.adapter.svelte.js";
9
7
 
10
8
  const CONST_ID_DUBLICATE_POSTFIX = "__dublicate__";
11
9
 
@@ -33,11 +31,9 @@ const DEFAULT_OPTIONS = {
33
31
  },
34
32
  };
35
33
 
36
- function defaultState(){
34
+ function defaultState() {
37
35
  return {
38
- pager:{
39
-
40
- },
36
+ pager: {},
41
37
  pagination: {
42
38
  items: {
43
39
  count: 0,
@@ -55,7 +51,7 @@ function defaultState(){
55
51
  };
56
52
  }
57
53
 
58
- function defaultStores(){
54
+ function defaultStores() {
59
55
  return {
60
56
  raw: [],
61
57
  filtered: [],
@@ -66,9 +62,7 @@ function defaultStores(){
66
62
  };
67
63
  }
68
64
 
69
-
70
65
  class notTable extends EventEmitter {
71
-
72
66
  #stores = defaultStores();
73
67
 
74
68
  #data = {
@@ -76,8 +70,8 @@ class notTable extends EventEmitter {
76
70
  filtered: [],
77
71
  refined: [],
78
72
  selected: {},
79
- working: {}
80
- };
73
+ working: {},
74
+ };
81
75
 
82
76
  #ui = {};
83
77
 
@@ -88,10 +82,9 @@ class notTable extends EventEmitter {
88
82
  ...DEFAULT_OPTIONS,
89
83
  ...(input.options ? input.options : {}),
90
84
  };
91
-
92
-
85
+
93
86
  if (notCommon.objHas(input, "data") && Array.isArray(input.data)) {
94
- this.setStoreContent('raw', input.data);
87
+ this.setStoreContent("raw", input.data);
95
88
  }
96
89
 
97
90
  this.setCombinedActionName(
@@ -127,27 +120,26 @@ class notTable extends EventEmitter {
127
120
  this.setSearch();
128
121
  }
129
122
 
130
- this.on('onStateUpdate', this.onStateUpdate.bind(this));
123
+ this.on("onStateUpdate", this.onStateUpdate.bind(this));
131
124
  this.render();
132
125
  this.updateData();
133
126
  return this;
134
127
  }
135
128
 
136
- setStoreContent(storeName, value){
129
+ setStoreContent(storeName, value) {
137
130
  this.#stores[storeName] = value;
138
131
  this.callStoreUpdateEvent(storeName, value);
139
132
  }
140
133
 
141
-
142
- updateStore(storeName, valueHandler){
134
+ updateStore(storeName, valueHandler) {
143
135
  this.#stores[storeName] = valueHandler(this.#stores[storeName]);
144
136
  this.callStoreUpdateEvent(storeName, this.#stores[storeName]);
145
137
  }
146
138
 
147
- callStoreUpdateEvent(storeName, value){
148
- const StoreName =notCommon.capitalizeFirstLetter(storeName);
139
+ callStoreUpdateEvent(storeName, value) {
140
+ const StoreName = notCommon.capitalizeFirstLetter(storeName);
149
141
  const EventHandlerName = `on${StoreName}Update`;
150
- if(this[EventHandlerName]){
142
+ if (this[EventHandlerName]) {
151
143
  this[EventHandlerName](value);
152
144
  }
153
145
  }
@@ -171,11 +163,11 @@ class notTable extends EventEmitter {
171
163
  onRefinedUpdate(val) {
172
164
  this.#data.refined = val;
173
165
  this.clearSelected();
174
- if (this.#ui && this.#ui.table){
175
- this.#ui.table.set('items', this.#data.refined);
166
+ if (this.#ui && this.#ui.table) {
167
+ this.#ui.table.set("items", this.#data.refined);
176
168
  }
177
169
  return val;
178
- }
170
+ }
179
171
 
180
172
  onSearchChange(line) {
181
173
  if (line.length > 3) {
@@ -235,10 +227,10 @@ class notTable extends EventEmitter {
235
227
  return this.getOptions("getItemId", DEFAULT_OPTIONS.getItemId)(item);
236
228
  }
237
229
 
238
- selectAll() {
230
+ selectAll() {
239
231
  this.#data.filtered.forEach((item) => {
240
232
  this.#ui.table.set(`selected.${this.getItemId(item)}`, true);
241
- });
233
+ });
242
234
  }
243
235
 
244
236
  selectNone() {
@@ -254,10 +246,10 @@ class notTable extends EventEmitter {
254
246
  this.options.targetEl,
255
247
  {
256
248
  id: this.id,
257
- filterUI: this.getOptions("filterUI", undefined),
249
+ filterUI: this.getOptions("filterUI", undefined),
258
250
  helpers: Object.assign({}, this.getHelpers()),
259
251
  fields: this.getOptions("fields"),
260
-
252
+
261
253
  actions: this.getActions(),
262
254
  links: this.getLinks(),
263
255
  search: "",
@@ -268,16 +260,15 @@ class notTable extends EventEmitter {
268
260
  idField: this.getOptions("idField"),
269
261
  getItemId: this.getOptions("getItemId"),
270
262
  filter: this.getFilter(),
271
-
263
+
272
264
  items: this.#stores.refined,
273
265
  selected: this.#stores.selected,
274
266
 
275
- state: this.#stores.state
276
-
267
+ state: this.#stores.state,
277
268
  }
278
- );
269
+ );
279
270
  }
280
-
271
+
281
272
  this.#ui.table.$on("onSearchChange", (e) => this.onSearchChange(e));
282
273
  this.#ui.table.$on("onSorterChange", (e) => this.onSorterChange(e));
283
274
  this.#ui.table.$on("onFilterChange", (e) => this.onFilterChange(e));
@@ -300,7 +291,7 @@ class notTable extends EventEmitter {
300
291
 
301
292
  setWorking(key, value) {
302
293
  notPath.set(key, this.#stores.working, this.getHelpers(), value);
303
- this.onWorkingUpdate(this.#stores.working);
294
+ this.onWorkingUpdate(this.#stores.working);
304
295
  return this;
305
296
  }
306
297
 
@@ -313,20 +304,20 @@ class notTable extends EventEmitter {
313
304
  }
314
305
  }
315
306
 
316
- onStateUpdate(){
317
- if(this.#ui.table){
318
- this.#ui.table.set(':state', this.#stores.state);
307
+ onStateUpdate() {
308
+ if (this.#ui.table) {
309
+ this.#ui.table.set(":state", this.#stores.state);
319
310
  }
320
311
  }
321
312
 
322
313
  setState(key, value) {
323
314
  notPath.set(key, this.#stores.state, this.getHelpers(), value);
324
- this.emit('onStateUpdate');
315
+ this.emit("onStateUpdate");
325
316
  return this;
326
317
  }
327
318
 
328
319
  getState(key, def) {
329
- let res = notPath.get(`:${key}`, this.#stores.state);
320
+ let res = notPath.get(`:${key}`, this.#stores.state);
330
321
  if (res === undefined) {
331
322
  return def;
332
323
  } else {
@@ -334,15 +325,20 @@ class notTable extends EventEmitter {
334
325
  }
335
326
  }
336
327
 
337
- updateState(updater){
328
+ updateState(updater) {
338
329
  this.#stores.state = updater(this.#stores.state);
339
- this.emit('onStateUpdate');
330
+ this.emit("onStateUpdate");
340
331
  return this;
341
332
  }
342
333
 
343
- updateStateProp(key, updater){
344
- notPath.set(key, this.#stores.state, this.getHelpers(), updater(notPath.get(key, this.#stores.state)));
345
- this.emit('onStateUpdate');
334
+ updateStateProp(key, updater) {
335
+ notPath.set(
336
+ key,
337
+ this.#stores.state,
338
+ this.getHelpers(),
339
+ updater(notPath.get(key, this.#stores.state))
340
+ );
341
+ this.emit("onStateUpdate");
346
342
  return this;
347
343
  }
348
344
 
@@ -407,7 +403,7 @@ class notTable extends EventEmitter {
407
403
  });
408
404
  }
409
405
 
410
- getPager() {
406
+ getPager() {
411
407
  return this.getState("pager");
412
408
  }
413
409
 
@@ -467,15 +463,15 @@ class notTable extends EventEmitter {
467
463
  }
468
464
 
469
465
  clearFilteredData() {
470
- this.setStoreContent('filtered', []);
466
+ this.setStoreContent("filtered", []);
471
467
  }
472
468
 
473
469
  clearRawData() {
474
- this.setStoreContent('raw', []);
470
+ this.setStoreContent("raw", []);
475
471
  }
476
472
 
477
473
  clearRefinedData() {
478
- this.setStoreContent('refined', []);
474
+ this.setStoreContent("refined", []);
479
475
  }
480
476
 
481
477
  invalidateData() {
@@ -617,10 +613,10 @@ class notTable extends EventEmitter {
617
613
 
618
614
  updatePagination(itemsCount) {
619
615
  this.log("update pagination", itemsCount);
620
- this.updateStateProp('pagination.pages.list', (listVal)=>{
616
+ this.updateStateProp("pagination.pages.list", (listVal) => {
621
617
  listVal.splice(0, listVal.length);
622
618
  return listVal;
623
- });
619
+ });
624
620
  let itemsFrom =
625
621
  (this.getPager().page - OPT_DEFAULT_PAGE_NUMBER) *
626
622
  this.getPager().size +
@@ -649,18 +645,18 @@ class notTable extends EventEmitter {
649
645
  });
650
646
  }
651
647
 
652
- this.log("update pagination", this.getState(':'));
653
- this.setState('count', itemsCount);
654
- this.setState('pagination.items.from', itemsFrom);
655
- this.setState('pagination.items.to',itemsTo);
656
- this.setState('pagination.pages.count',pagesCount);
657
- this.setState('pagination.pages.from',pagesFrom);
658
- this.setState('pagination.pages.to',pagesTo);
659
- this.setState('pagination.pages.current', this.getPager().page);
660
- this.updateStateProp('pagination.pages.list', (listVal)=>{
661
- listVal.splice(0, listVal.length, ...list );
648
+ this.log("update pagination", this.getState(":"));
649
+ this.setState("count", itemsCount);
650
+ this.setState("pagination.items.from", itemsFrom);
651
+ this.setState("pagination.items.to", itemsTo);
652
+ this.setState("pagination.pages.count", pagesCount);
653
+ this.setState("pagination.pages.from", pagesFrom);
654
+ this.setState("pagination.pages.to", pagesTo);
655
+ this.setState("pagination.pages.current", this.getPager().page);
656
+ this.updateStateProp("pagination.pages.list", (listVal) => {
657
+ listVal.splice(0, listVal.length, ...list);
662
658
  return listVal;
663
- });
659
+ });
664
660
  }
665
661
 
666
662
  updateData() {
@@ -678,7 +674,7 @@ class notTable extends EventEmitter {
678
674
  const full =
679
675
  notCommon.objHas(data, "status") &&
680
676
  notCommon.objHas(data, "result");
681
- this.updateStore('filtered', (val) => {
677
+ this.updateStore("filtered", (val) => {
682
678
  if (!this.getOptions("endless", false)) {
683
679
  val.splice(0);
684
680
  }
@@ -709,10 +705,10 @@ class notTable extends EventEmitter {
709
705
  } else {
710
706
  this.loadData()
711
707
  .then((data) => {
712
- this.updateStore('filtered', (val) => {
708
+ this.updateStore("filtered", (val) => {
713
709
  val.push(...data);
714
710
  return val;
715
- });
711
+ });
716
712
  })
717
713
  .then(this.getRowsCount.bind(this))
718
714
  .catch(this.error.bind(this))
@@ -741,7 +737,7 @@ class notTable extends EventEmitter {
741
737
  thatFilter.filterSearch !== null &&
742
738
  thatFilter.filterSearch.length > 0
743
739
  ) {
744
- this.updateStore('filtered', (val) => {
740
+ this.updateStore("filtered", (val) => {
745
741
  val.splice(
746
742
  0,
747
743
  val.length,
@@ -750,7 +746,7 @@ class notTable extends EventEmitter {
750
746
  return val;
751
747
  });
752
748
  } else {
753
- this.updateStore('filtered',(val) => {
749
+ this.updateStore("filtered", (val) => {
754
750
  val.splice(0, val.length, ...this.#data.raw);
755
751
  return val;
756
752
  });
@@ -758,7 +754,7 @@ class notTable extends EventEmitter {
758
754
  ////sorter
759
755
  let thatSorter = this.getSorter();
760
756
  if (typeof thatSorter !== "undefined" && thatSorter !== null) {
761
- this.updateStore('filtered', (val) => {
757
+ this.updateStore("filtered", (val) => {
762
758
  val.sort((item1, item2) => {
763
759
  let t1 = notPath.get(thatSorter.sortByField, item1, {}),
764
760
  t2 = notPath.get(thatSorter.sortByField, item2, {});
@@ -855,7 +851,7 @@ class notTable extends EventEmitter {
855
851
  });
856
852
  result.push(refined);
857
853
  });
858
- this.updateStore('refined',(val) => {
854
+ this.updateStore("refined", (val) => {
859
855
  val.splice(0, val.length, ...result);
860
856
  return val;
861
857
  });
@@ -1,17 +1,17 @@
1
- import UICommon from "not-bulma/src/elements/common.js";
1
+ import UICommon from "../../elements/common.js";
2
2
 
3
- import notBreadcrumbs from "not-bulma/src/frame/components/breadcrumbs/index.js";
3
+ import notBreadcrumbs from "../components/breadcrumbs/index.js";
4
4
 
5
5
  import UILoader from "../../elements/various/ui.loader.svelte";
6
6
  import UIAdapterSvelte from "../ui.adapter.svelte";
7
7
 
8
- import notController from "not-bulma/src/frame/controller.js";
9
- import notCommon from "not-bulma/src/frame/common.js";
8
+ import notController from "../controller.js";
9
+ import notCommon from "../common.js";
10
10
 
11
- import CRUDVariantsPreloader from "not-bulma/src/frame/crud/variants.preloader.js";
12
- import CRUDRouter from "not-bulma/src/frame/crud/router.js";
13
- import CRUDMessage from "not-bulma/src/frame/crud/message.js";
14
- import CRUDActions from "not-bulma/src/frame/crud/actions/index.js";
11
+ import CRUDVariantsPreloader from "./variants.preloader.js";
12
+ import CRUDRouter from "./router.js";
13
+ import CRUDMessage from "./message.js";
14
+ import CRUDActions from "./actions/index.js";
15
15
 
16
16
  const BREADCRUMBS = [];
17
17
  const TITLE_FIELDS_PRIORITY = ["title", "label", "id", "name"];
@@ -57,7 +57,6 @@ class notCRUD extends notController {
57
57
  },
58
58
  ];
59
59
  }
60
-
61
60
 
62
61
  constructor(
63
62
  app,
@@ -69,7 +68,7 @@ class notCRUD extends notController {
69
68
  }
70
69
  ) {
71
70
  super(app, `CRUD.${name}`);
72
-
71
+
73
72
  if (actions) {
74
73
  // @ts-ignore
75
74
  this.#actions = { ...this.#actions, ...actions };
@@ -80,7 +79,7 @@ class notCRUD extends notController {
80
79
  if (preloader) {
81
80
  this.#preloader = preloader;
82
81
  }
83
- this.ui = {};
82
+ this.ui = {};
84
83
  this.els = {};
85
84
  this.setOptions("names", {
86
85
  module: "",
@@ -226,8 +225,7 @@ class notCRUD extends notController {
226
225
 
227
226
  async preloadVariants(type = "list") {
228
227
  await this.#preloader.preload(this, type);
229
- this.emit('onVariantsPreloaded', {type});
230
-
228
+ this.emit("onVariantsPreloaded", { type });
231
229
  }
232
230
 
233
231
  getTitleFromLib(propName, id) {
@@ -400,7 +398,7 @@ class notCRUD extends notController {
400
398
  if (Object.hasOwn(this.ui, name)) {
401
399
  this.ui[name].$destroy && this.ui[name].$destroy();
402
400
  this.ui[name].destroy && this.ui[name].destroy();
403
- delete this.ui[name];
401
+ delete this.ui[name];
404
402
  }
405
403
  }
406
404
 
@@ -447,20 +445,24 @@ class notCRUD extends notController {
447
445
  }
448
446
 
449
447
  createLoaderUI() {
450
- return new UIAdapterSvelte(UILoader, this.getContainerInnerElement(), this.#loaderProps);
448
+ return new UIAdapterSvelte(
449
+ UILoader,
450
+ this.getContainerInnerElement(),
451
+ this.#loaderProps
452
+ );
451
453
  }
452
454
 
453
- setUIProp(uiName, propKey, propValue){
454
- if (this.ui && this.ui[uiName]){
455
+ setUIProp(uiName, propKey, propValue) {
456
+ if (this.ui && this.ui[uiName]) {
455
457
  this.ui[uiName].set(propKey, propValue);
456
458
  }
457
459
  }
458
460
 
459
- getActionProps(){
461
+ getActionProps() {
460
462
  return this.ui[this.getCurrentAction()].props;
461
463
  }
462
464
 
463
- setLoaderProp(key, val){
465
+ setLoaderProp(key, val) {
464
466
  this.getUI(LOADING_SCREEN_UI_NAME).set(key, val);
465
467
  }
466
468
  }