not-bulma 1.0.40 → 1.0.43

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.40",
3
+ "version": "1.0.43",
4
4
  "description": "not-* family UI components on Bulma CSS Framework",
5
5
  "main": "src/index.js",
6
6
  "svelte": "src/index.js",
@@ -14,6 +14,7 @@ import UITelephone from "./ui.telephone.svelte";
14
14
  import UITextarea from "./ui.textarea.svelte";
15
15
  import UITextfield from "./ui.textfield.svelte";
16
16
  import UIRange from "./ui.range.svelte";
17
+ import UINumber from "./ui.number.svelte";
17
18
 
18
19
  export {
19
20
  UIAutocomplete,
@@ -32,4 +33,5 @@ export {
32
33
  UITextarea,
33
34
  UITextfield,
34
35
  UIRange,
36
+ UINumber,
35
37
  };
@@ -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
+ />
@@ -0,0 +1,102 @@
1
+ <script>
2
+ import UICommon from "../common.js";
3
+ import ErrorsList from "../various/ui.errors.list.svelte";
4
+ import { createEventDispatcher } from "svelte";
5
+ let dispatch = createEventDispatcher();
6
+
7
+ export let inputStarted = false;
8
+ export let value = 0;
9
+ export let placeholder = "0.0";
10
+ export let min = 0;
11
+ export let max = 100;
12
+ export let step = 1;
13
+ export let fieldname = "number";
14
+ export let icon = false;
15
+ export let required = true;
16
+ export let disabled = false;
17
+ export let readonly = false;
18
+ export let valid = true;
19
+ export let validated = false;
20
+ export let errors = false;
21
+ export let formErrors = false;
22
+ export let formLevelError = false;
23
+
24
+ $: iconClasses = (icon ? " has-icons-left " : "") + " has-icons-right ";
25
+ $: allErrors = [].concat(
26
+ errors ? errors : [],
27
+ formErrors ? formErrors : []
28
+ );
29
+ $: showErrors = !(validated && valid) && inputStarted;
30
+ $: invalid = valid === false || formLevelError;
31
+ $: validationClasses =
32
+ valid === true || !inputStarted
33
+ ? UICommon.CLASS_OK
34
+ : UICommon.CLASS_ERR;
35
+
36
+ function onBlur(/*ev*/) {
37
+ let data = {
38
+ field: fieldname,
39
+ value,
40
+ };
41
+ inputStarted = true;
42
+ dispatch("change", data);
43
+ return true;
44
+ }
45
+
46
+ function onInput(ev) {
47
+ let data = {
48
+ field: fieldname,
49
+ value: ev.currentTarget.value,
50
+ };
51
+ inputStarted = true;
52
+ dispatch("change", data);
53
+ return true;
54
+ }
55
+ </script>
56
+
57
+ <div class="control {iconClasses}">
58
+ {#if readonly}
59
+ <p>{value}</p>
60
+ {:else}
61
+ <input
62
+ id="form-field-textfield-{fieldname}"
63
+ class="input {validationClasses}"
64
+ type="number"
65
+ {min}
66
+ {max}
67
+ {step}
68
+ name={fieldname}
69
+ {invalid}
70
+ {disabled}
71
+ {required}
72
+ {readonly}
73
+ {placeholder}
74
+ bind:value
75
+ autocomplete={fieldname}
76
+ aria-controls="input-field-helper-{fieldname}"
77
+ on:change={onBlur}
78
+ on:input={onInput}
79
+ aria-describedby="input-field-helper-{fieldname}"
80
+ />
81
+ {#if icon}
82
+ <span class="icon is-small is-left"
83
+ ><i class="fas fa-{icon}" /></span
84
+ >
85
+ {/if}
86
+ {#if validated === true}
87
+ <span class="icon is-small is-right">
88
+ {#if valid === true}
89
+ <i class="fas fa-check" />
90
+ {:else if valid === false}
91
+ <i class="fas fa-exclamation-triangle" />
92
+ {/if}
93
+ </span>
94
+ {/if}
95
+ {/if}
96
+ </div>
97
+ <ErrorsList
98
+ bind:errors={allErrors}
99
+ bind:show={showErrors}
100
+ bind:classes={validationClasses}
101
+ id="input-field-helper-{fieldname}"
102
+ />
@@ -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;