not-bulma 1.2.58 → 1.2.60

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.2.58",
3
+ "version": "1.2.60",
4
4
  "description": "not-* family UI components on Bulma CSS Framework",
5
5
  "main": "src/index.js",
6
6
  "svelte": "src/index.js",
@@ -18,6 +18,7 @@ import UIRangeLogarithmic from "./ui.range.logarithmic.svelte";
18
18
  import UISelectFromModel from "./ui.select.from.model.svelte";
19
19
  import UISelect from "./ui.select.svelte";
20
20
  import UISwitch from "./ui.switch.svelte";
21
+ import UISwitchList from "./ui.switch.list.svelte";
21
22
  import UITagSelect from "./ui.tag.select.svelte";
22
23
  import UITelephone from "./ui.telephone.svelte";
23
24
  import UITextarea from "./ui.textarea.svelte";
@@ -44,6 +45,7 @@ export {
44
45
  UISelectFromModel,
45
46
  UISelect,
46
47
  UISwitch,
48
+ UISwitchList,
47
49
  UITagSelect,
48
50
  UITelephone,
49
51
  UITextarea,
@@ -0,0 +1,125 @@
1
+ <script>
2
+ import { LOCALE } from "../../locale";
3
+ import "bulma-switch";
4
+ import UICommon from "../common.js";
5
+ import ErrorsList from "../various/ui.errors.list.svelte";
6
+ import UIBooleans from "../various/ui.booleans.svelte";
7
+ import { createEventDispatcher } from "svelte";
8
+ let dispatch = createEventDispatcher();
9
+
10
+ export let inputStarted = false;
11
+ export let value = [];
12
+ export let variants = [];
13
+ export let label = "";
14
+ export let hideLabel = false;
15
+ export let placeholder = "input some text here, please";
16
+ export let fieldname = "textfield";
17
+ export let icon = false;
18
+ export let required = true;
19
+ export let readonly = false;
20
+ export let multiple = true;
21
+ export let disabled = false;
22
+ export let valid = true;
23
+ export let styling = " is-rounded is-success ";
24
+ export let validated = false;
25
+ export let errors = false;
26
+ export let formErrors = false;
27
+ export let formLevelError = false;
28
+
29
+ $: iconClasses = (icon ? " has-icons-left " : "") + " has-icons-right ";
30
+ $: allErrors = [].concat(
31
+ errors ? errors : [],
32
+ formErrors ? formErrors : []
33
+ );
34
+ $: showErrors = !(validated && valid) && inputStarted;
35
+ $: invalid = valid === false || formLevelError;
36
+ $: validationClasses =
37
+ valid === true || !inputStarted
38
+ ? UICommon.CLASS_OK
39
+ : UICommon.CLASS_ERR;
40
+
41
+ function addId(varId) {
42
+ if (!value.includes(varId)) {
43
+ value.push(varId);
44
+ value = value;
45
+ }
46
+ }
47
+
48
+ function remId(varId) {
49
+ if (value.includes(varId)) {
50
+ value.splice(value.indexOf(varId), 1);
51
+ value = value;
52
+ }
53
+ }
54
+
55
+ function onBlur(ev) {
56
+ console.log("switch list element blur", ev);
57
+ const varId = ev.target.id.split("-variant-").at(-1);
58
+ console.log(varId);
59
+ ev.target.checked ? addId(varId) : remId(varId);
60
+ let data = {
61
+ field: fieldname,
62
+ value,
63
+ };
64
+ inputStarted = true;
65
+ dispatch("change", data);
66
+ return true;
67
+ }
68
+
69
+ function onInput(ev) {
70
+ console.log("switch list element input", ev);
71
+ const varId = ev.target.id.split("-variant-").at(-1);
72
+ console.log(varId);
73
+ ev.target.checked ? addId(varId) : remId(varId);
74
+ let data = {
75
+ field: fieldname,
76
+ value,
77
+ };
78
+ inputStarted = true;
79
+ dispatch("change", data);
80
+ return true;
81
+ }
82
+ </script>
83
+
84
+ <div class="control">
85
+ {#if readonly}
86
+ {#if value}
87
+ {variants
88
+ .filter((variant) => value.includes(variant.id))
89
+ .map((variant) => variant.title)
90
+ .join(", ")}
91
+ {/if}
92
+ {:else}
93
+ {#each variants as variant (variant.id)}
94
+ <div class="switch-list-item">
95
+ <input
96
+ type="checkbox"
97
+ class="switch {styling}"
98
+ id="form-field-switch-{fieldname}-variant-{variant.id}"
99
+ checked={value.includes(variant.id)}
100
+ name={fieldname}
101
+ {disabled}
102
+ {required}
103
+ {readonly}
104
+ {invalid}
105
+ on:blur={onBlur}
106
+ on:input={onInput}
107
+ aria-controls="input-field-helper-{fieldname}-variant-{variant.id}"
108
+ aria-describedby="input-field-helper-{fieldname}-variant-{variant.id}"
109
+ />
110
+ <label
111
+ class="label"
112
+ for="form-field-switch-{fieldname}-variant-{variant.id}"
113
+ >
114
+ {$LOCALE[variant.title]}
115
+ </label>
116
+ </div>
117
+ {/each}
118
+ {/if}
119
+ </div>
120
+ <ErrorsList
121
+ bind:errors={allErrors}
122
+ bind:show={showErrors}
123
+ bind:classes={validationClasses}
124
+ id="input-field-helper-{fieldname}"
125
+ />
@@ -19,6 +19,7 @@
19
19
  export let subtitle = "";
20
20
  export let classes = "";
21
21
  export let overlayClasses = "";
22
+ export let buttonsClasses = "";
22
23
 
23
24
  export let WAITING_TEXT = "Обработка";
24
25
  </script>
@@ -38,6 +39,7 @@
38
39
 
39
40
  {#if buttonsPosition === "top"}
40
41
  <UIButtonsRow
42
+ classes={buttonsClasses}
41
43
  left={closeButton ? [closeButton] : []}
42
44
  right={applyButton ? [applyButton] : []}
43
45
  ></UIButtonsRow>
@@ -47,6 +49,7 @@
47
49
 
48
50
  {#if buttonsPosition === "bottom"}
49
51
  <UIButtonsRow
52
+ classes={buttonsClasses || "is-footer"}
50
53
  left={closeButton ? [closeButton] : []}
51
54
  right={applyButton ? [applyButton] : []}
52
55
  ></UIButtonsRow>
@@ -1,7 +1,12 @@
1
- .form-container{
2
- position:relative;
1
+ .form-container {
2
+ position: relative;
3
3
  }
4
4
 
5
- .edit-form-error.notification.is-danger span:not(:first-child)::before{
6
- content: ', '
5
+ .edit-form-error.notification.is-danger span:not(:first-child)::before {
6
+ content: ", ";
7
+ }
8
+
9
+ .switch-list-item {
10
+ display: inline-block;
11
+ margin-right: 4rem;
7
12
  }
@@ -19,3 +19,17 @@
19
19
  .is-no-flex-wrap {
20
20
  flex-wrap: nowrap !important;
21
21
  }
22
+
23
+ .is-footer {
24
+ position: absolute;
25
+ bottom: 0px;
26
+ transform: translateY(-50%);
27
+ width: 100%;
28
+ }
29
+
30
+ .is-fullscreen {
31
+ height: 100%;
32
+ width: 100%;
33
+ margin: 0px;
34
+ border: none;
35
+ }
@@ -1,17 +1,16 @@
1
1
  .not-overlay {
2
- position: fixed!important;
3
- top: 0px;
4
- left: 0px;
5
- width: 100vw;
6
- height: 100vh;
7
- margin: 0px;
8
- display: block;
9
- opacity: 1;
10
- overflow: hidden;
2
+ position: fixed !important;
3
+ top: 0px;
4
+ left: 0px;
5
+ width: 100vw;
6
+ height: 100vh;
7
+ margin: 0px;
8
+ display: block;
9
+ opacity: 1;
10
+ overflow: hidden;
11
11
  }
12
12
 
13
-
14
13
  .stop-scrolling {
15
- height: 100%;
16
- overflow: hidden;
14
+ height: 100%;
15
+ overflow: hidden;
17
16
  }