not-bulma 1.0.42 → 1.0.44

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.42",
3
+ "version": "1.0.44",
4
4
  "description": "not-* family UI components on Bulma CSS Framework",
5
5
  "main": "src/index.js",
6
6
  "svelte": "src/index.js",
@@ -170,4 +170,4 @@
170
170
  ]
171
171
  }
172
172
  }
173
- }
173
+ }
@@ -1,82 +1,100 @@
1
1
  <script>
2
+ import UICommon from "../common.js";
3
+ import ErrorsList from "../various/ui.errors.list.svelte";
2
4
 
3
- import UICommon from '../common.js';
4
- import ErrorsList from '../various/ui.errors.list.svelte';
5
+ import { createEventDispatcher } from "svelte";
6
+ let dispatch = createEventDispatcher();
5
7
 
6
- import {createEventDispatcher} from 'svelte';
7
- let dispatch = createEventDispatcher();
8
+ export let inputStarted = false;
8
9
 
9
- export let inputStarted = false;
10
+ export let value = new Date();
11
+ export let placeholder = "Date and time of event";
12
+ export let fieldname = "datetime";
13
+ export let icon = false;
14
+ export let required = true;
15
+ export let readonly = false;
16
+ export let valid = true;
17
+ export let validated = false;
18
+ export let errors = false;
19
+ export let formErrors = false;
20
+ export let formLevelError = false;
10
21
 
11
- export let value = '';
12
- export let placeholder = 'Date and time of event';
13
- export let fieldname = 'datetime';
14
- export let icon = false;
15
- export let required = true;
16
- export let readonly = false;
17
- export let valid = true;
18
- export let validated = false;
19
- export let errors = false;
20
- export let formErrors = false;
21
- export let formLevelError = false;
22
+ $: iconClasses = (icon ? " has-icons-left " : "") + " has-icons-right ";
23
+ $: allErrors = [].concat(
24
+ errors ? errors : [],
25
+ formErrors ? formErrors : []
26
+ );
27
+ $: invalid = valid === false || formLevelError;
28
+ $: showErrors = !(validated && valid) && inputStarted;
29
+ $: validationClasses =
30
+ valid === true || !inputStarted
31
+ ? UICommon.CLASS_OK
32
+ : UICommon.CLASS_ERR;
22
33
 
23
- $: iconClasses = (icon? ' has-icons-left ':'') + ' has-icons-right ';
24
- $: allErrors = [].concat(errors?errors:[], formErrors?formErrors:[]);
25
- $: invalid = ((valid===false) || (formLevelError));
26
- $: showErrors = (!(validated && valid) && (inputStarted));
27
- $: validationClasses = (valid===true || !inputStarted)?UICommon.CLASS_OK:UICommon.CLASS_ERR;
28
-
29
- function onBlur(ev){
30
- let data = {
31
- field: fieldname,
32
- value: ev.currentTarget.value
33
- };
34
- inputStarted = true;
35
- dispatch('change', data);
36
- return true;
37
- }
38
-
39
- function onInput(ev){
40
- let data = {
41
- field: fieldname,
42
- value: ev.currentTarget.value
43
- };
44
- inputStarted = true;
45
- dispatch('change', data);
46
- return true;
47
- }
34
+ function onBlur(ev) {
35
+ let data = {
36
+ field: fieldname,
37
+ value: ev.currentTarget.value,
38
+ };
39
+ inputStarted = true;
40
+ dispatch("change", data);
41
+ return true;
42
+ }
48
43
 
44
+ function onInput(ev) {
45
+ let data = {
46
+ field: fieldname,
47
+ value: ev.currentTarget.value,
48
+ };
49
+ inputStarted = true;
50
+ dispatch("change", data);
51
+ return true;
52
+ }
49
53
  </script>
50
54
 
51
- <div class="control {iconClasses}">
52
- {#if readonly }
53
- <p><time datetime="{value}">{UICommon.tryFormatLocaleDateTime(value)}</time></p>
55
+ <div class="control {iconClasses}">
56
+ {#if readonly}
57
+ <p>
58
+ <time datetime={value}
59
+ >{UICommon.tryFormatLocaleDateTime(value)}</time
60
+ >
61
+ </p>
54
62
  {:else}
55
- <input class="input {validationClasses}"
56
- id="form-field-date-{fieldname}"
57
- type="date" name="{fieldname}"
58
- invalid="{invalid}" required={required}
59
- placeholder="{placeholder}" bind:value={value} {readonly}
60
- autocomplete="{fieldname}" aria-controls="input-field-helper-{fieldname}"
61
- on:change={onBlur} on:input={onInput}
62
- aria-describedby="input-field-helper-{fieldname}" />
63
- {#if icon }
64
- <span class="icon is-small is-left"><i class="fas fa-{icon}"></i></span>
65
- {/if}
66
- {#if validated === true }
67
- <span class="icon is-small is-right">
68
- {#if valid === true }
69
- <i class="fas fa-check"></i>
70
- {:else if (valid === false) }
71
- <i class="fas fa-exclamation-triangle"></i>
72
- {/if}
73
- </span>
74
- {/if}
63
+ <input
64
+ class="input {validationClasses}"
65
+ id="form-field-date-{fieldname}"
66
+ type="date"
67
+ name={fieldname}
68
+ {invalid}
69
+ {required}
70
+ {placeholder}
71
+ bind:value
72
+ {readonly}
73
+ autocomplete={fieldname}
74
+ aria-controls="input-field-helper-{fieldname}"
75
+ on:change={onBlur}
76
+ on:input={onInput}
77
+ aria-describedby="input-field-helper-{fieldname}"
78
+ />
79
+ {#if icon}
80
+ <span class="icon is-small is-left"
81
+ ><i class="fas fa-{icon}" /></span
82
+ >
83
+ {/if}
84
+ {#if validated === true}
85
+ <span class="icon is-small is-right">
86
+ {#if valid === true}
87
+ <i class="fas fa-check" />
88
+ {:else if valid === false}
89
+ <i class="fas fa-exclamation-triangle" />
90
+ {/if}
91
+ </span>
92
+ {/if}
75
93
  {/if}
76
- </div>
77
- <ErrorsList
94
+ </div>
95
+ <ErrorsList
78
96
  bind:errors={allErrors}
79
97
  bind:show={showErrors}
80
98
  bind:classes={validationClasses}
81
99
  id="input-field-helper-{fieldname}"
82
- />
100
+ />
@@ -8,8 +8,8 @@
8
8
  export let value = 0;
9
9
  export let placeholder = "0.0";
10
10
  export let min = 0;
11
- export let max = 0;
12
- export let step = 0;
11
+ export let max = 100;
12
+ export let step = 1;
13
13
  export let fieldname = "number";
14
14
  export let icon = false;
15
15
  export let required = true;
@@ -1,185 +1,189 @@
1
- import Menu from '../menu.js';
2
- import UISideMenu from './ui.side.menu.svelte';
1
+ import Menu from "../menu.js";
2
+ import UISideMenu from "./ui.side.menu.svelte";
3
3
 
4
- const TYPE = 'side';
4
+ const TYPE = "side";
5
5
 
6
6
  class notSideMenu extends Menu {
7
- static nav;
8
- static main;
9
- static aside;
10
-
11
- static DEFAULT = {
12
- section: 'any',
13
- sectionTitle: 'Меню',
14
- priority: 0,
15
- open: false
16
- };
17
-
18
- static options = {
19
- type: TYPE,
20
- items: [],
21
- sections: [],
22
- targetSelector: `#${TYPE}-menu`,
23
- toggleSelector: `.${TYPE}-menu-toggle`,
24
- root: '/',
25
- open: false,
26
- navigate: (urls) => {
27
- this.hide();
28
- if (!(this.isDirectNavigation()) && this.app) {
29
- let func = this.app.getWorking('router');
30
- if (func) {
31
- return func.navigate(urls.short);
7
+ static nav;
8
+ static main;
9
+ static aside;
10
+
11
+ static DEFAULT = {
12
+ section: "any",
13
+ sectionTitle: "Меню",
14
+ priority: 0,
15
+ open: false,
16
+ };
17
+
18
+ static options = {
19
+ type: TYPE,
20
+ items: [],
21
+ sections: [],
22
+ targetSelector: `#${TYPE}-menu`,
23
+ toggleSelector: `.${TYPE}-menu-toggle`,
24
+ root: "/",
25
+ open: false,
26
+ navigate: (urls) => {
27
+ this.hide();
28
+ if (!this.isDirectNavigation() && this.app) {
29
+ let func = this.app.getWorking("router");
30
+ if (func) {
31
+ return func.navigate(urls.short);
32
+ }
33
+ }
34
+ document.location.assign(urls.full);
35
+ },
36
+ };
37
+
38
+ static render(app) {
39
+ if (app) {
40
+ this.setApp(app);
41
+ }
42
+ this.prepareData();
43
+ if (!this.menu) {
44
+ this.createUI();
32
45
  }
33
- }
34
- document.location.assign(urls.full);
35
46
  }
36
- };
37
47
 
38
- static render(app) {
39
- if (app) {
40
- this.setApp(app);
48
+ static update() {
49
+ if (this.menu) {
50
+ this.menu.$destroy();
51
+ this.createUI();
52
+ }
41
53
  }
42
- this.prepareData();
43
- if (!this.menu) {
44
- this.createUI();
54
+
55
+ static createUI() {
56
+ let target = document.querySelector(this.getOptions().targetSelector);
57
+ if (!target) {
58
+ return;
59
+ }
60
+ this.menu = new UISideMenu({
61
+ target,
62
+ props: {
63
+ items: this.items,
64
+ sections: this.sections,
65
+ root: this.getOptions().root,
66
+ navigate: this.getOptions().navigate,
67
+ },
68
+ });
69
+ this.initSizeResponse();
70
+ this.interval = setInterval(this.updateMenuActiveItem.bind(this), 200);
71
+ this.bindToggle();
45
72
  }
46
- }
47
73
 
48
- static update(){
49
- if (this.menu) {
50
- this.menu.$destroy();
51
- this.createUI();
74
+ static itemIsActive(itemURL) {
75
+ return (this.location + "/").indexOf(itemURL + "/") > -1;
52
76
  }
53
- }
54
-
55
- static createUI(){
56
- let target = document.querySelector(this.getOptions().targetSelector);
57
- if(!target){return;}
58
- this.menu = new UISideMenu({
59
- target,
60
- props: {
61
- items: this.items,
62
- sections: this.sections,
63
- root: this.getOptions().root,
64
- navigate: this.getOptions().navigate
65
- }
66
- });
67
- this.initSizeResponse();
68
- this.interval = setInterval(this.updateMenuActiveItem.bind(this), 200);
69
- this.bindToggle();
70
- }
71
-
72
- static itemIsActive(itemURL) {
73
- return ((this.location + '/').indexOf(itemURL + '/') > -1);
74
- }
75
-
76
- static updateMenu() {
77
- Array.from(document.querySelectorAll(this.getOptions().targetSelector + ' a')).forEach((item) => {
78
- if (this.itemIsActive(item.getAttribute('href'))) {
79
- item.classList.add('is-active');
80
- } else {
81
- item.classList.remove('is-active');
82
- }
83
- });
84
- }
85
-
86
- static updateMenuActiveItem() {
87
- let url = window.location.toString(),
88
- lastLocation = this.location;
89
- if (lastLocation) {
90
- if (url !== lastLocation) {
91
- this.location = url;
92
- this.updateMenu();
93
- }
94
- } else {
95
- this.location = url;
96
- this.updateMenu();
77
+
78
+ static updateMenu() {
79
+ Array.from(
80
+ document.querySelectorAll(this.getOptions().targetSelector + " a")
81
+ ).forEach((item) => {
82
+ if (this.itemIsActive(item.getAttribute("href"))) {
83
+ item.classList.add("is-active");
84
+ } else {
85
+ item.classList.remove("is-active");
86
+ }
87
+ });
97
88
  }
98
- }
99
-
100
- static initSizeResponse() {
101
- this.nav = document.querySelector('nav.navbar');
102
- this.aside = document.querySelector('aside');
103
- this.main = document.querySelector('main');
104
- this.resizeAsideAndMain(this.aside, this.main, this.nav);
105
- this.resizeMain(this.main, this.aside);
106
- window.addEventListener('resize', this.resizeMain.bind(this));
107
- if(this.getOptions().open){
108
- this.show();
109
- }else{
110
- this.hide();
89
+
90
+ static updateMenuActiveItem() {
91
+ let url = window.location.toString(),
92
+ lastLocation = this.location;
93
+ if (lastLocation) {
94
+ if (url !== lastLocation) {
95
+ this.location = url;
96
+ this.updateMenu();
97
+ }
98
+ } else {
99
+ this.location = url;
100
+ this.updateMenu();
101
+ }
111
102
  }
112
- }
113
-
114
- static resizeMain() {
115
- if(this.isTouch()){
116
- if(this.aside.classList.contains('is-active')){
117
- this.main.style.display = 'none';
118
- }else{
119
- this.main.style.display = 'block';
120
- this.main.style.marginLeft = '0px';
121
- }
122
- }else{
123
- let rect = this.aside.getBoundingClientRect();
124
- this.main.style.display = 'block';
125
- if (this.main.style.height === '0px') {
126
- this.main.style.height = 'auto';
127
- }
128
- this.main.style.marginLeft = (rect.width + rect.left) + 'px';
103
+
104
+ static initSizeResponse() {
105
+ this.nav = document.querySelector("nav.navbar");
106
+ this.aside = document.querySelector("aside");
107
+ this.main = document.querySelector("main");
108
+ this.resizeAsideAndMain(this.aside, this.main, this.nav);
109
+ this.resizeMain(this.main, this.aside);
110
+ window.addEventListener("resize", this.resizeMain.bind(this));
111
+ if (this.getOptions().open) {
112
+ this.show();
113
+ } else {
114
+ this.hide();
115
+ }
116
+ }
117
+
118
+ static resizeMain() {
119
+ if (this.isTouch()) {
120
+ if (this.aside.classList.contains("is-active")) {
121
+ this.main.style.display = "none";
122
+ } else {
123
+ this.main.style.display = "block";
124
+ this.main.style.marginLeft = "0px";
125
+ }
126
+ } else {
127
+ let rect = this.aside.getBoundingClientRect();
128
+ this.main.style.display = "block";
129
+ if (this.main.style.height === "0px") {
130
+ this.main.style.height = "auto";
131
+ }
132
+ this.main.style.marginLeft = rect.width + rect.left + "px";
133
+ }
129
134
  }
130
- }
131
135
 
132
- static resizeAside() {
133
- if (this.aside.style.display !== 'none') {
134
- let rect = this.nav.getBoundingClientRect();
135
- this.aside.style.height = (window.innerHeight - rect.height) + 'px';
136
- this.aside.style.marginTop = (rect.height) + 'px';
136
+ static resizeAside() {
137
+ if (this.aside.style.display !== "none") {
138
+ let rect = this.nav.getBoundingClientRect();
139
+ this.aside.style.height = window.innerHeight - rect.height + "px";
140
+ this.aside.style.marginTop = rect.height + "px";
141
+ }
137
142
  }
138
- }
139
-
140
- static resizeAsideAndMain() {
141
- let rect = this.nav.getBoundingClientRect();
142
- this.aside.style.height = (window.innerHeight - rect.height) + 'px';
143
- //this.aside.style.paddingTop = (rect.height) + 'px';
144
- this.main.style.marginTop = (rect.height) + 'px';
145
- }
146
-
147
- static bindToggle() {
148
- let els = document.querySelectorAll(this.getOptions().toggleSelector);
149
- Array.from(els).forEach((el) => {
150
- el.removeEventListener('click', this.toggle.bind(this));
151
- el.addEventListener('click', this.toggle.bind(this));
152
- });
153
- }
154
-
155
- static toggle(e) {
156
- e && e.preventDefault();
157
- this.aside.classList.toggle('is-active');
158
- this.resizeMain();
159
- return false;
160
- }
161
-
162
- static hide(e) {
163
- e && e.preventDefault();
164
- this.aside.classList.remove('is-active');
165
- this.resizeMain();
166
- return false;
167
- }
168
-
169
- static show(e) {
170
- e && e.preventDefault();
171
- this.classList.add('is-active');
172
- this.resizeMain();
173
- return false;
174
- }
175
-
176
- static isOpen(){
177
- if(this.aside){
178
- return this.aside.classList.contains('is-active');
179
- }else{
180
- return true;
143
+
144
+ static resizeAsideAndMain() {
145
+ let rect = this.nav.getBoundingClientRect();
146
+ this.aside.style.height = window.innerHeight - rect.height + "px";
147
+ //this.aside.style.paddingTop = (rect.height) + 'px';
148
+ //this.main.style.marginTop = (rect.height) + 'px';
149
+ }
150
+
151
+ static bindToggle() {
152
+ let els = document.querySelectorAll(this.getOptions().toggleSelector);
153
+ Array.from(els).forEach((el) => {
154
+ el.removeEventListener("click", this.toggle.bind(this));
155
+ el.addEventListener("click", this.toggle.bind(this));
156
+ });
157
+ }
158
+
159
+ static toggle(e) {
160
+ e && e.preventDefault();
161
+ this.aside.classList.toggle("is-active");
162
+ this.resizeMain();
163
+ return false;
164
+ }
165
+
166
+ static hide(e) {
167
+ e && e.preventDefault();
168
+ this.aside.classList.remove("is-active");
169
+ this.resizeMain();
170
+ return false;
171
+ }
172
+
173
+ static show(e) {
174
+ e && e.preventDefault();
175
+ this.classList.add("is-active");
176
+ this.resizeMain();
177
+ return false;
178
+ }
179
+
180
+ static isOpen() {
181
+ if (this.aside) {
182
+ return this.aside.classList.contains("is-active");
183
+ } else {
184
+ return true;
185
+ }
181
186
  }
182
- }
183
187
  }
184
188
 
185
189
  export default notSideMenu;
@@ -3,67 +3,71 @@
3
3
  /*
4
4
  Common functions
5
5
  */
6
- import notCommon from './common.js';
6
+ import notCommon from "./common.js";
7
7
 
8
8
  /*
9
9
  framework wide parser for data access
10
10
  */
11
- import notPath from 'not-path';
11
+ import notPath from "not-path";
12
12
 
13
+ import notRouter from "./router.js";
13
14
 
14
- import notRouter from './router.js';
15
-
16
- import * as notAPI from './api';
15
+ import * as notAPI from "./api";
16
+ import * as notStores from "./stores";
17
17
  /*
18
18
  basic event handlers and core data modifiers
19
19
  */
20
- import notBase from './base.js';
20
+ import notBase from "./base.js";
21
21
 
22
- import {COMPONENTS, FIELDS, VARIANTS} from './LIB.js';
22
+ import { COMPONENTS, FIELDS, VARIANTS } from "./LIB.js";
23
23
  /*
24
24
  application main infrastructure setter
25
25
  */
26
- import notApp from './app.js';
26
+ import notApp from "./app.js";
27
27
  /*
28
28
  user controllers
29
29
  */
30
- import notController from './controller.js';
31
- import notRecord from './record.js'; // wrapper for data with server live interactions
32
- import notInterface from './interface.js'; // wrapper for data with server live interactions
30
+ import notController from "./controller.js";
31
+ import notRecord from "./record.js"; // wrapper for data with server live interactions
32
+ import notInterface from "./interface.js"; // wrapper for data with server live interactions
33
33
 
34
34
  import {
35
- notTable,
36
- UIForm,
37
- notForm,
38
- notFormSet,
39
- notFormUtils,
40
- notBreadcrumbs,
41
- notTopMenu,
42
- notSideMenu
43
- } from './components';
35
+ notTable,
36
+ UIForm,
37
+ notForm,
38
+ notFormSet,
39
+ notFormUtils,
40
+ notBreadcrumbs,
41
+ notTopMenu,
42
+ notSideMenu,
43
+ } from "./components";
44
44
 
45
- import notCRUD from './crud/controller.crud.js';
45
+ import notCRUD from "./crud/controller.crud.js";
46
46
 
47
47
  const ncCRUD = notCRUD; //legacy alias
48
48
 
49
49
  export {
50
- notCommon,
51
- notPath,
52
- notController,
53
- notBase,
54
- notRouter,
55
- notRecord,
56
- notInterface,
57
- notApp,
58
- notAPI,
59
- notCRUD, ncCRUD,
60
- COMPONENTS, FIELDS, VARIANTS,
61
- notTable,
62
- UIForm,
63
- notForm,
64
- notFormSet,
65
- notFormUtils,
66
- notBreadcrumbs,
67
- notTopMenu,
68
- notSideMenu
50
+ notCommon,
51
+ notPath,
52
+ notController,
53
+ notBase,
54
+ notRouter,
55
+ notRecord,
56
+ notInterface,
57
+ notApp,
58
+ notAPI,
59
+ notStores,
60
+ notCRUD,
61
+ ncCRUD,
62
+ COMPONENTS,
63
+ FIELDS,
64
+ VARIANTS,
65
+ notTable,
66
+ UIForm,
67
+ notForm,
68
+ notFormSet,
69
+ notFormUtils,
70
+ notBreadcrumbs,
71
+ notTopMenu,
72
+ notSideMenu,
69
73
  };
@@ -0,0 +1,56 @@
1
+ import { writable } from "svelte/store";
2
+
3
+ const ALL = {};
4
+
5
+ function exist(key) {
6
+ return Object.hasOwn(ALL, key);
7
+ }
8
+
9
+ function get(key) {
10
+ if (exist(key)) {
11
+ return ALL[key];
12
+ } else {
13
+ return false;
14
+ }
15
+ }
16
+
17
+ function create(
18
+ key,
19
+ props = {
20
+ raw: [],
21
+ filtered: [],
22
+ selected: {},
23
+ }
24
+ ) {
25
+ if (!exist(key)) {
26
+ if (Object.keys(props).length > 0) {
27
+ ALL[key] = {};
28
+ Object.keys(props).forEach((name) => {
29
+ ALL[key][name] = writable(props[name]);
30
+ });
31
+ } else {
32
+ throw new Error("store's props wasn't specified");
33
+ }
34
+ }
35
+ return ALL[key];
36
+ }
37
+
38
+ /**
39
+ * Creates object that is fake Store
40
+ * Some time this is useful when you need to initialize local var,
41
+ * before you could get actual Stores from central storage by its ID
42
+ * @params {mixed} val data of type that is actual storage will contain
43
+ * @returns {Object}
44
+ */
45
+
46
+ function fake(val) {
47
+ return {
48
+ subscribe(f) {
49
+ f(val);
50
+ return () => {};
51
+ },
52
+ set() {},
53
+ };
54
+ }
55
+
56
+ export { create, get, fake };