jsl-ui 9.28.7 → 10.0.0
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/docs/AutoSuggestComponent.md +17 -0
- package/docs/ButtonComponent.md +14 -0
- package/docs/CheckBoxComponent.md +12 -0
- package/docs/DateComponent.md +12 -0
- package/docs/DateRangeComponent.md +13 -0
- package/docs/DateTimeComponent.md +13 -0
- package/docs/DialogComponent.md +15 -0
- package/docs/ExpanderComponent.md +13 -0
- package/docs/FormComponent.md +15 -0
- package/docs/FormFieldComponent.md +15 -0
- package/docs/GridComponent.md +19 -0
- package/docs/InputComponent.md +15 -0
- package/docs/IntervalComponent.md +13 -0
- package/docs/LoadingComponent.md +12 -0
- package/docs/NavigationComponent.md +17 -0
- package/docs/Notification.md +14 -0
- package/docs/NotificationComponent.md +13 -0
- package/docs/NumberComponent.md +12 -0
- package/docs/OverlayComponent.md +12 -0
- package/docs/ProgressComponent.md +12 -0
- package/docs/README.md +24 -0
- package/docs/RibbonMenuComponent.md +14 -0
- package/docs/SelectComponent.md +15 -0
- package/docs/SplitterComponent.md +14 -0
- package/docs/StackPanelComponent.md +13 -0
- package/docs/TabsComponent.md +16 -0
- package/docs/TimeComponent.md +13 -0
- package/docs/TreeViewComponent.md +16 -0
- package/examples/showcase/checks-and-expanders.ts +163 -0
- package/examples/showcase/cultures.ts +39 -0
- package/examples/showcase/dates.ts +182 -0
- package/examples/showcase/dialogs.ts +184 -0
- package/examples/showcase/feedback-and-navigation.ts +174 -0
- package/examples/showcase/fields.ts +178 -0
- package/examples/showcase/fonts/Jost-Variable.ttf +0 -0
- package/examples/showcase/fonts/OFL-Jost.txt +93 -0
- package/examples/showcase/grids.ts +150 -0
- package/examples/showcase/index.html +60 -0
- package/examples/showcase/layout-and-navigation.ts +47 -0
- package/examples/showcase/nivona.css +98 -0
- package/examples/showcase/selects.ts +158 -0
- package/examples/showcase/showcase.css +231 -0
- package/examples/showcase/showcase.ts +214 -0
- package/examples/showcase/tabs.ts +161 -0
- package/examples/showcase/themes.css +83 -0
- package/examples/showcase/themes.ts +54 -0
- package/lib/components/IntervalComponent.d.ts +5 -0
- package/lib/components/IntervalComponent.js +29 -13
- package/lib/components/auto-suggest/AutoSuggestComponent.d.ts +11 -9
- package/lib/components/auto-suggest/AutoSuggestComponent.js +25 -38
- package/lib/components/button/ButtonComponent.d.ts +30 -1
- package/lib/components/button/ButtonComponent.js +85 -4
- package/lib/components/checkbox/CheckBoxComponent.d.ts +11 -1
- package/lib/components/checkbox/CheckBoxComponent.js +66 -56
- package/lib/components/checkbox/CheckBoxStyle.scss +72 -85
- package/lib/components/date/DateComponent.d.ts +10 -0
- package/lib/components/date/DateComponent.js +92 -44
- package/lib/components/date-range/DateRangeComponent.d.ts +14 -3
- package/lib/components/date-range/DateRangeComponent.js +96 -86
- package/lib/components/date-range/DateRangeStyle.scss +35 -11
- package/lib/components/date-time/DateTimeComponent.d.ts +8 -0
- package/lib/components/date-time/DateTimeComponent.js +64 -23
- package/lib/components/date-time/DateTimeStyle.scss +10 -7
- package/lib/components/dialog/DialogComponent.d.ts +21 -7
- package/lib/components/dialog/DialogComponent.js +179 -122
- package/lib/components/expander/ExpanderComponent.d.ts +15 -1
- package/lib/components/expander/ExpanderComponent.js +85 -64
- package/lib/components/expander/ExpanderStyle.scss +61 -47
- package/lib/components/form-field/FormFieldComponent.d.ts +45 -15
- package/lib/components/form-field/FormFieldComponent.js +249 -96
- package/lib/components/form-field/FormFieldStyle.scss +36 -87
- package/lib/components/form-field/create-control.d.ts +7 -0
- package/lib/components/form-field/create-control.js +48 -0
- package/lib/components/input/InputComponent.d.ts +18 -1
- package/lib/components/input/InputComponent.js +68 -93
- package/lib/components/loading/LoadingComponent.d.ts +9 -2
- package/lib/components/loading/LoadingComponent.js +13 -12
- package/lib/components/loading/LoadingStyle.css +19 -29
- package/lib/components/navigation/NavigationComponent.d.ts +34 -10
- package/lib/components/navigation/NavigationComponent.js +261 -33
- package/lib/components/navigation/NavigationStyle.scss +62 -226
- package/lib/components/notification/Notification.d.ts +37 -4
- package/lib/components/notification/Notification.js +160 -41
- package/lib/components/notification/Notification.scss +103 -19
- package/lib/components/number/NumberComponent.d.ts +16 -2
- package/lib/components/number/NumberComponent.js +54 -53
- package/lib/components/overlay/OverlayComponent.d.ts +13 -7
- package/lib/components/overlay/OverlayComponent.js +46 -114
- package/lib/components/overlay/overlay.css +18 -57
- package/lib/components/progress/ProgressComponent.d.ts +1 -0
- package/lib/components/progress/ProgressComponent.js +6 -6
- package/lib/components/progress/ProgressStyle.scss +5 -15
- package/lib/components/ribbon-menu/RibbonMenuComponent.js +2 -2
- package/lib/components/ribbon-menu/RibbonMenuStyle.scss +6 -76
- package/lib/components/select/SelectComponent.d.ts +33 -3
- package/lib/components/select/SelectComponent.js +312 -278
- package/lib/components/select/SelectDDAreaComponent.d.ts +13 -7
- package/lib/components/select/SelectDDAreaComponent.js +215 -256
- package/lib/components/select/SelectStyle.scss +204 -186
- package/lib/components/slider/nouislider.css +40 -54
- package/lib/components/stack-panel/SplitterComponent.d.ts +19 -3
- package/lib/components/stack-panel/SplitterComponent.js +94 -111
- package/lib/components/stack-panel/SplitterStyle.scss +9 -45
- package/lib/components/stack-panel/StackPanelComponent.js +3 -3
- package/lib/components/stack-panel/StackPanelStyle.scss +10 -52
- package/lib/components/tabs/TabsComponent.d.ts +17 -1
- package/lib/components/tabs/TabsComponent.js +247 -123
- package/lib/components/tabs/TabsStyle.scss +138 -75
- package/lib/components/time/TimeComponent.d.ts +5 -0
- package/lib/components/time/TimeComponent.js +61 -69
- package/lib/components/time/TimeComponent.scss +4 -4
- package/lib/components/tree-view/TreeViewComponent.d.ts +10 -4
- package/lib/components/tree-view/TreeViewComponent.js +65 -32
- package/lib/components/tree-view/TreeViewStyle.scss +12 -96
- package/lib/core/date.d.ts +2 -0
- package/lib/core/date.js +6 -0
- package/lib/core/jq.js +11 -8
- package/lib/grid/slick-default-theme.css +107 -31
- package/lib/grid/slick.creator.js +23 -5
- package/lib/grid/slick.formatters.js +4 -3
- package/lib/grid/slick.grid.css +38 -26
- package/lib/grid/slick.grid.d.ts +1 -0
- package/lib/grid/slick.grid.js +2 -3
- package/lib/grid.css +3413 -454
- package/lib/index.css +2500 -1031
- package/lib/index.css.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/interaction/moveable.d.ts +1 -0
- package/lib/interaction/moveable.js +8 -0
- package/lib/interaction/resizable.d.ts +1 -0
- package/lib/interaction/resizable.js +9 -0
- package/lib/ui/auto.suggest.css +31 -14
- package/lib/ui/auto.suggest.d.ts +1 -0
- package/lib/ui/auto.suggest.js +88 -18
- package/lib/ui/base.css +2 -48
- package/lib/ui/button.css +134 -0
- package/lib/ui/date-input.css +11 -0
- package/lib/ui/date.picker/css/tiny-date-picker.css +124 -325
- package/lib/ui/date.picker/date-picker-options.js +4 -3
- package/lib/ui/date.picker/lib/date-manip.js +9 -0
- package/lib/ui/date.picker/mode/base-mode.d.ts +2 -1
- package/lib/ui/date.picker/mode/base-mode.js +112 -22
- package/lib/ui/date.picker/mode/dropdown-mode.d.ts +2 -4
- package/lib/ui/date.picker/mode/dropdown-mode.js +29 -42
- package/lib/ui/date.picker/mode/index.d.ts +2 -1
- package/lib/ui/date.picker/mode/modal-mode.d.ts +2 -1
- package/lib/ui/date.picker/mode/modal-mode.js +4 -2
- package/lib/ui/date.picker/mode/permanent-mode.d.ts +2 -1
- package/lib/ui/date.picker/views/day-picker.js +24 -15
- package/lib/ui/date.picker/views/month-picker.js +1 -1
- package/lib/ui/date.picker/views/year-picker.js +3 -2
- package/lib/ui/date.picker.d.ts +2 -1
- package/lib/ui/dialog.css +144 -108
- package/lib/ui/dialog.d.ts +19 -1
- package/lib/ui/dialog.js +178 -60
- package/lib/ui/input.css +35 -0
- package/lib/ui/number.input.js +50 -37
- package/lib/ui/theme.css +28 -0
- package/package.json +12 -8
- package/lib/components/drop-down/DropDownComponent.d.ts +0 -27
- package/lib/components/drop-down/DropDownComponent.js +0 -60
- package/lib/components/expander/OldExpanderStyle.scss +0 -37
- package/lib/ui/drop.down.d.ts +0 -52
- package/lib/ui/drop.down.js +0 -2112
|
@@ -149,6 +149,14 @@ export class MoveableContainer {
|
|
|
149
149
|
this.container.addEventListener("mousedown", this.mouseDownContainer, false);
|
|
150
150
|
this.container.addEventListener("touchstart", this.mouseDownContainer, false);
|
|
151
151
|
}
|
|
152
|
+
destroy() {
|
|
153
|
+
this.container.removeEventListener("mousedown", this.mouseDownContainer);
|
|
154
|
+
this.container.removeEventListener("touchstart", this.mouseDownContainer);
|
|
155
|
+
window.removeEventListener("mousemove", this.mouseMove);
|
|
156
|
+
window.removeEventListener("mouseup", this.mouseUp);
|
|
157
|
+
window.removeEventListener("touchmove", this.mouseMove);
|
|
158
|
+
window.removeEventListener("touchend", this.mouseUp);
|
|
159
|
+
}
|
|
152
160
|
extractArg(evt, key) {
|
|
153
161
|
return evt[key] != null ? evt[key] : (evt.touches.length > 0 ? evt.touches : evt.changedTouches)[0][key];
|
|
154
162
|
}
|
|
@@ -98,6 +98,15 @@ export class ResizeContainer {
|
|
|
98
98
|
this.container.addEventListener("mousedown", this.mouseDownContainer, false);
|
|
99
99
|
this.container.addEventListener("touchstart", this.mouseDownContainer, false);
|
|
100
100
|
}
|
|
101
|
+
destroy() {
|
|
102
|
+
this.container.removeEventListener("mousedown", this.mouseDownContainer);
|
|
103
|
+
this.container.removeEventListener("touchstart", this.mouseDownContainer);
|
|
104
|
+
window.removeEventListener("mousemove", this.mouseMove);
|
|
105
|
+
window.removeEventListener("mouseup", this.mouseUp);
|
|
106
|
+
window.removeEventListener("touchmove", this.mouseMove);
|
|
107
|
+
window.removeEventListener("touchend", this.mouseUp);
|
|
108
|
+
this.container.classList.remove("resizable");
|
|
109
|
+
}
|
|
101
110
|
extractArg(evt, key) {
|
|
102
111
|
return evt[key] != null ? evt[key] : (evt.touches.length > 0 ? evt.touches : evt.changedTouches)[0][key];
|
|
103
112
|
}
|
package/lib/ui/auto.suggest.css
CHANGED
|
@@ -1,14 +1,31 @@
|
|
|
1
|
-
.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
@import "./theme.css";
|
|
2
|
+
|
|
3
|
+
.autocomplete-suggestions {
|
|
4
|
+
display: none;
|
|
5
|
+
position: absolute;
|
|
6
|
+
z-index: 2200;
|
|
7
|
+
max-height: min(16rem, calc(100dvh - 1rem));
|
|
8
|
+
overflow-y: auto;
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
padding: 4px;
|
|
11
|
+
border: 1px solid var(--jsl-color-border);
|
|
12
|
+
border-radius: .625rem;
|
|
13
|
+
background: var(--jsl-color-surface);
|
|
14
|
+
color: var(--jsl-color-text);
|
|
15
|
+
font: inherit;
|
|
16
|
+
font-size: .8125rem;
|
|
17
|
+
text-align: left;
|
|
18
|
+
box-shadow: 0 12px 32px rgba(0,0,0,.12), 0 2px 6px rgba(0,0,0,.06);
|
|
19
|
+
}
|
|
20
|
+
.autocomplete-suggestion {
|
|
21
|
+
position: relative;
|
|
22
|
+
padding: .5rem .625rem;
|
|
23
|
+
border-radius: .375rem;
|
|
24
|
+
line-height: 1.4;
|
|
25
|
+
white-space: nowrap;
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
text-overflow: ellipsis;
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
}
|
|
30
|
+
.autocomplete-suggestion b { color: inherit; font-weight: 600; }
|
|
31
|
+
.autocomplete-suggestion.selected, .autocomplete-suggestion:hover { background: var(--jsl-color-surface-selected); }
|
package/lib/ui/auto.suggest.d.ts
CHANGED
package/lib/ui/auto.suggest.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "./auto.suggest.css";
|
|
2
|
+
import { helper } from "../core/helper";
|
|
2
3
|
let autoComplete = (function () {
|
|
3
4
|
function autoComplete(options) {
|
|
4
5
|
// helpers
|
|
@@ -32,10 +33,12 @@ let autoComplete = (function () {
|
|
|
32
33
|
cache: false,
|
|
33
34
|
menuClass: '',
|
|
34
35
|
renderItem: function (item, search) {
|
|
36
|
+
var escape = value => String(value).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
|
35
37
|
// escape special characters
|
|
36
38
|
search = search.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
37
39
|
var re = new RegExp("(" + search.split(' ').join('|') + ")", "gi");
|
|
38
|
-
|
|
40
|
+
var highlighted = search ? String(item).split(re).map((part, index) => index % 2 ? '<b>' + escape(part) + '</b>' : escape(part)).join('') : escape(item);
|
|
41
|
+
return '<div class="autocomplete-suggestion" data-val="' + escape(item) + '">' + highlighted + '</div>';
|
|
39
42
|
},
|
|
40
43
|
onSelect: function (e, term, item) { }
|
|
41
44
|
};
|
|
@@ -48,23 +51,49 @@ let autoComplete = (function () {
|
|
|
48
51
|
let elems = typeof o.selector === 'object' ? [o.selector] : document.querySelectorAll(o.selector);
|
|
49
52
|
for (let i = 0; i < elems.length; i++) {
|
|
50
53
|
let that = elems[i];
|
|
54
|
+
that.destroyed = false;
|
|
51
55
|
// create suggestions container "sc"
|
|
52
56
|
that.sc = document.createElement('div');
|
|
53
57
|
that.sc.className = 'autocomplete-suggestions ' + o.menuClass;
|
|
58
|
+
that.sc.id = helper.newDomGuid();
|
|
59
|
+
that.sc.setAttribute('role', 'listbox');
|
|
60
|
+
that.originalAria = {};
|
|
61
|
+
['role', 'aria-autocomplete', 'aria-controls', 'aria-expanded', 'aria-activedescendant'].forEach(name => { that.originalAria[name] = that.getAttribute(name); });
|
|
62
|
+
that.setAttribute('role', 'combobox');
|
|
63
|
+
that.setAttribute('aria-autocomplete', 'list');
|
|
64
|
+
that.setAttribute('aria-controls', that.sc.id);
|
|
65
|
+
that.setAttribute('aria-expanded', 'false');
|
|
66
|
+
that.hideSuggestions = function () {
|
|
67
|
+
that.sc.style.display = 'none';
|
|
68
|
+
that.setAttribute('aria-expanded', 'false');
|
|
69
|
+
that.removeAttribute('aria-activedescendant');
|
|
70
|
+
};
|
|
71
|
+
that.syncAria = function () {
|
|
72
|
+
var selected = that.sc.querySelector('.autocomplete-suggestion.selected');
|
|
73
|
+
that.sc.querySelectorAll('.autocomplete-suggestion').forEach(item => item.setAttribute('aria-selected', String(item === selected)));
|
|
74
|
+
if (selected) {
|
|
75
|
+
that.setAttribute('aria-activedescendant', selected.id);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
that.removeAttribute('aria-activedescendant');
|
|
79
|
+
}
|
|
80
|
+
};
|
|
54
81
|
that.autocompleteAttr = that.getAttribute('autocomplete');
|
|
55
82
|
that.setAttribute('autocomplete', 'off');
|
|
56
83
|
that.cache = {};
|
|
57
84
|
that.last_val = '';
|
|
58
85
|
that.updateSC = function (resize, next) {
|
|
86
|
+
if (that.destroyed) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
59
89
|
var rect = that.getBoundingClientRect();
|
|
60
|
-
that.sc.style.left =
|
|
61
|
-
that.sc.style.top =
|
|
62
|
-
that.sc.style.width = Math.
|
|
90
|
+
that.sc.style.left = '0px';
|
|
91
|
+
that.sc.style.top = '0px';
|
|
92
|
+
that.sc.style.width = Math.min(rect.width, window.innerWidth - 16) + 'px';
|
|
63
93
|
if (!resize) {
|
|
64
94
|
that.sc.style.display = 'block';
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
95
|
+
that.setAttribute('aria-expanded', 'true');
|
|
96
|
+
that.sc.maxHeight = that.sc.clientHeight;
|
|
68
97
|
if (!that.sc.suggestionHeight) {
|
|
69
98
|
that.sc.suggestionHeight = that.sc.querySelector('.autocomplete-suggestion').offsetHeight;
|
|
70
99
|
}
|
|
@@ -83,13 +112,23 @@ let autoComplete = (function () {
|
|
|
83
112
|
}
|
|
84
113
|
}
|
|
85
114
|
}
|
|
115
|
+
var origin = that.sc.getBoundingClientRect();
|
|
116
|
+
var left = Math.max(8, Math.min(rect.left + o.offsetLeft, window.innerWidth - that.sc.offsetWidth - 8));
|
|
117
|
+
var top = rect.bottom + o.offsetTop + 5;
|
|
118
|
+
if (top + that.sc.offsetHeight > window.innerHeight && rect.top > that.sc.offsetHeight + 5) {
|
|
119
|
+
top = rect.top - that.sc.offsetHeight - 5;
|
|
120
|
+
}
|
|
121
|
+
that.sc.style.left = (left - origin.left) + 'px';
|
|
122
|
+
that.sc.style.top = (Math.max(8, top) - origin.top) + 'px';
|
|
123
|
+
that.syncAria();
|
|
86
124
|
};
|
|
87
125
|
addEvent(window, 'resize', that.updateSC);
|
|
88
|
-
|
|
126
|
+
window.addEventListener('scroll', that.updateSC, true);
|
|
127
|
+
(o.appendTo || that.closest('.jsl-dialog') || document.body).appendChild(that.sc);
|
|
89
128
|
live('autocomplete-suggestion', 'mouseleave', function (e) {
|
|
90
129
|
const sel = that.sc.querySelector('.autocomplete-suggestion.selected');
|
|
91
130
|
if (sel) {
|
|
92
|
-
setTimeout(function () { sel.className = sel.className.replace('selected', ''); }, 20);
|
|
131
|
+
setTimeout(function () { sel.className = sel.className.replace('selected', ''); that.syncAria(); }, 20);
|
|
93
132
|
}
|
|
94
133
|
}, that.sc);
|
|
95
134
|
live('autocomplete-suggestion', 'mouseover', function (e) {
|
|
@@ -98,14 +137,16 @@ let autoComplete = (function () {
|
|
|
98
137
|
sel.className = sel.className.replace('selected', '');
|
|
99
138
|
}
|
|
100
139
|
this.className += ' selected';
|
|
140
|
+
that.syncAria();
|
|
101
141
|
}, that.sc);
|
|
102
142
|
live('autocomplete-suggestion', 'mousedown', function (e) {
|
|
143
|
+
e.preventDefault();
|
|
103
144
|
// window.setTimeout(() => {
|
|
104
145
|
if (hasClass(this, 'autocomplete-suggestion')) { // else outside click
|
|
105
146
|
const v = this.getAttribute('data-val');
|
|
106
147
|
that.value = v;
|
|
107
148
|
o.onSelect(e, v, this);
|
|
108
|
-
that.
|
|
149
|
+
that.hideSuggestions();
|
|
109
150
|
}
|
|
110
151
|
// }, 1000);
|
|
111
152
|
}, that.sc);
|
|
@@ -114,16 +155,20 @@ let autoComplete = (function () {
|
|
|
114
155
|
//try { over_sb = document.querySelector('.autocomplete-suggestions:hover'); } catch (e) { over_sb = 0; }
|
|
115
156
|
//if (!over_sb) {
|
|
116
157
|
that.last_val = that.value;
|
|
117
|
-
that.
|
|
158
|
+
that.hideSuggestions();
|
|
118
159
|
//setTimeout(function() { that.sc.style.display = 'none'; }, 350); // hide suggestions on fast input
|
|
119
160
|
//} else if (that !== document.activeElement) { setTimeout(function() { that.focus(); }, 200); }
|
|
120
161
|
};
|
|
121
162
|
addEvent(that, 'blur', that.blurHandler);
|
|
122
163
|
that.inputHandler = function () {
|
|
123
|
-
|
|
164
|
+
var _a;
|
|
165
|
+
(_a = o.onChange) === null || _a === void 0 ? void 0 : _a.call(o, that.value);
|
|
124
166
|
};
|
|
125
167
|
addEvent(that, 'input', that.inputHandler);
|
|
126
168
|
var suggest = function (data) {
|
|
169
|
+
if (that.destroyed) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
127
172
|
var val = that.value;
|
|
128
173
|
that.cache[val] = data;
|
|
129
174
|
if (data.length && val.length >= o.minChars) {
|
|
@@ -132,16 +177,23 @@ let autoComplete = (function () {
|
|
|
132
177
|
s += o.renderItem(data[i], val);
|
|
133
178
|
}
|
|
134
179
|
that.sc.innerHTML = s;
|
|
180
|
+
that.sc.querySelectorAll('.autocomplete-suggestion').forEach((item, index) => {
|
|
181
|
+
item.id = that.sc.id + '-option-' + index;
|
|
182
|
+
item.setAttribute('role', 'option');
|
|
183
|
+
item.setAttribute('aria-selected', 'false');
|
|
184
|
+
});
|
|
135
185
|
that.updateSC(0);
|
|
136
186
|
}
|
|
137
187
|
else {
|
|
138
|
-
that.
|
|
188
|
+
that.hideSuggestions();
|
|
139
189
|
}
|
|
140
190
|
};
|
|
141
191
|
that.keydownHandler = function (e) {
|
|
142
192
|
var key = window.event ? e.keyCode : e.which;
|
|
143
193
|
// down (40), up (38)
|
|
144
194
|
if ((key === 40 || key === 38) && that.sc.innerHTML) {
|
|
195
|
+
e.preventDefault();
|
|
196
|
+
e.stopPropagation();
|
|
145
197
|
var next, sel = that.sc.querySelector('.autocomplete-suggestion.selected');
|
|
146
198
|
if (!sel) {
|
|
147
199
|
next = (key == 40) ? that.sc.querySelector('.autocomplete-suggestion') : that.sc.childNodes[that.sc.childNodes.length - 1]; // first : last
|
|
@@ -164,15 +216,21 @@ let autoComplete = (function () {
|
|
|
164
216
|
that.updateSC(0, next);
|
|
165
217
|
return false;
|
|
166
218
|
}
|
|
167
|
-
else if (key == 27) {
|
|
219
|
+
else if (key == 27 && that.sc.style.display !== 'none') {
|
|
220
|
+
e.preventDefault();
|
|
221
|
+
e.stopPropagation();
|
|
168
222
|
that.value = that.last_val;
|
|
169
|
-
that.
|
|
223
|
+
that.hideSuggestions();
|
|
170
224
|
}
|
|
171
225
|
else if (key == 13 || key == 9) {
|
|
172
226
|
var sel = that.sc.querySelector('.autocomplete-suggestion.selected');
|
|
173
227
|
if (sel && that.sc.style.display != 'none') {
|
|
228
|
+
if (key == 13) {
|
|
229
|
+
e.preventDefault();
|
|
230
|
+
e.stopPropagation();
|
|
231
|
+
}
|
|
174
232
|
o.onSelect(e, sel.getAttribute('data-val'), sel);
|
|
175
|
-
setTimeout(function () { that.
|
|
233
|
+
setTimeout(function () { that.hideSuggestions(); }, 20);
|
|
176
234
|
}
|
|
177
235
|
}
|
|
178
236
|
};
|
|
@@ -204,7 +262,7 @@ let autoComplete = (function () {
|
|
|
204
262
|
}
|
|
205
263
|
else {
|
|
206
264
|
that.last_val = val;
|
|
207
|
-
that.
|
|
265
|
+
that.hideSuggestions();
|
|
208
266
|
}
|
|
209
267
|
}
|
|
210
268
|
};
|
|
@@ -221,18 +279,30 @@ let autoComplete = (function () {
|
|
|
221
279
|
this.destroy = function () {
|
|
222
280
|
for (var i = 0; i < elems.length; i++) {
|
|
223
281
|
var that = elems[i];
|
|
282
|
+
that.destroyed = true;
|
|
283
|
+
clearTimeout(that.timer);
|
|
224
284
|
removeEvent(window, 'resize', that.updateSC);
|
|
285
|
+
window.removeEventListener('scroll', that.updateSC, true);
|
|
225
286
|
removeEvent(that, 'blur', that.blurHandler);
|
|
226
287
|
removeEvent(that, 'focus', that.focusHandler);
|
|
227
288
|
removeEvent(that, 'keydown', that.keydownHandler);
|
|
228
289
|
removeEvent(that, 'keyup', that.keyupHandler);
|
|
290
|
+
removeEvent(that, 'input', that.inputHandler);
|
|
291
|
+
Object.keys(that.originalAria).forEach(name => {
|
|
292
|
+
if (that.originalAria[name] == null) {
|
|
293
|
+
that.removeAttribute(name);
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
that.setAttribute(name, that.originalAria[name]);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
229
299
|
if (that.autocompleteAttr) {
|
|
230
300
|
that.setAttribute('autocomplete', that.autocompleteAttr);
|
|
231
301
|
}
|
|
232
302
|
else {
|
|
233
303
|
that.removeAttribute('autocomplete');
|
|
234
304
|
}
|
|
235
|
-
|
|
305
|
+
that.sc.remove();
|
|
236
306
|
that = null;
|
|
237
307
|
}
|
|
238
308
|
};
|
package/lib/ui/base.css
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@import "./button.css";
|
|
2
|
+
|
|
1
3
|
/* reset some browser inconsistencies */
|
|
2
4
|
|
|
3
5
|
html
|
|
@@ -87,54 +89,6 @@ html {
|
|
|
87
89
|
font-family: Tahoma;
|
|
88
90
|
} */
|
|
89
91
|
|
|
90
|
-
.jsl-button {
|
|
91
|
-
background-color: #3B99FF;
|
|
92
|
-
border: 1px solid #3B99FF;
|
|
93
|
-
vertical-align:middle;
|
|
94
|
-
color: white;
|
|
95
|
-
|
|
96
|
-
border-radius: .3rem;
|
|
97
|
-
/* color: white; */
|
|
98
|
-
cursor: pointer;
|
|
99
|
-
display: inline-block;
|
|
100
|
-
/* font-weight: 700; */
|
|
101
|
-
height: 2rem;
|
|
102
|
-
box-sizing: border-box;
|
|
103
|
-
letter-spacing: .1rem;
|
|
104
|
-
line-height: 2rem;
|
|
105
|
-
padding: 0rem 1.0rem;
|
|
106
|
-
text-align: center;
|
|
107
|
-
text-decoration: none;
|
|
108
|
-
white-space: nowrap;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
.jsl-button.jsl-button-outline {
|
|
112
|
-
background: white;
|
|
113
|
-
color: #444444;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
.jsl-button:active {
|
|
117
|
-
background-color: #3B99FF;
|
|
118
|
-
border-color:black;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.jsl-button:hover {
|
|
122
|
-
background-color: rgba(59, 154, 255, 0.5);
|
|
123
|
-
border-color: #C0C0C0;
|
|
124
|
-
color: black;
|
|
125
|
-
outline: 0;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
.jsl-button:focus {
|
|
129
|
-
outline: 0;
|
|
130
|
-
border-color: gray;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
.jsl-button[disabled] {
|
|
134
|
-
cursor: default;
|
|
135
|
-
opacity: .5;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
92
|
.right {
|
|
139
93
|
text-align: right;
|
|
140
94
|
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
@import "./theme.css";
|
|
2
|
+
|
|
3
|
+
/* Shared by ButtonComponent and vanilla buttons using .jsl-button.
|
|
4
|
+
Override --jsl-button-* variables on a container or individual button. */
|
|
5
|
+
.jsl-button {
|
|
6
|
+
--jsl-button-height: 2rem;
|
|
7
|
+
--jsl-button-padding: 0.875rem;
|
|
8
|
+
display: inline-flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
gap: 0.5rem;
|
|
12
|
+
position: relative;
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
height: var(--jsl-button-height);
|
|
15
|
+
padding: 0 var(--jsl-button-padding);
|
|
16
|
+
vertical-align: middle;
|
|
17
|
+
border: 1px solid transparent;
|
|
18
|
+
border-radius: var(--jsl-button-radius, 0.375rem);
|
|
19
|
+
background: var(--jsl-button-primary, var(--jsl-color-accent));
|
|
20
|
+
color: var(--jsl-button-on-primary, var(--jsl-color-on-accent));
|
|
21
|
+
font: inherit;
|
|
22
|
+
font-size: 0.875rem;
|
|
23
|
+
font-weight: 500;
|
|
24
|
+
line-height: 1.25;
|
|
25
|
+
letter-spacing: normal;
|
|
26
|
+
text-align: center;
|
|
27
|
+
text-decoration: none;
|
|
28
|
+
white-space: nowrap;
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.jsl-button:where(:hover) {
|
|
34
|
+
background: var(--jsl-button-primary-hover, var(--jsl-color-accent-hover));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.jsl-button:where(:active, .active, [aria-pressed="true"]) {
|
|
38
|
+
background: var(--jsl-button-primary-active, var(--jsl-color-accent-active));
|
|
39
|
+
box-shadow: inset 0 0 0 1px currentColor;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.jsl-button.jsl-button-outline {
|
|
43
|
+
border-color: var(--jsl-button-border, var(--jsl-color-border));
|
|
44
|
+
background: var(--jsl-button-surface, var(--jsl-color-surface));
|
|
45
|
+
color: var(--jsl-button-text, var(--jsl-color-text));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.jsl-button.jsl-button-ghost {
|
|
49
|
+
background: transparent;
|
|
50
|
+
color: var(--jsl-button-text, var(--jsl-color-text));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.jsl-button.jsl-button-outline:where(:hover),
|
|
54
|
+
.jsl-button.jsl-button-ghost:where(:hover) {
|
|
55
|
+
background: var(--jsl-button-hover-surface, var(--jsl-color-surface-hover));
|
|
56
|
+
border-color: var(--jsl-button-border, var(--jsl-color-border));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.jsl-button.jsl-button-outline:where(:active, .active, [aria-pressed="true"]),
|
|
60
|
+
.jsl-button.jsl-button-ghost:where(:active, .active, [aria-pressed="true"]) {
|
|
61
|
+
background: var(--jsl-button-selected-surface, var(--jsl-color-surface-selected));
|
|
62
|
+
border-color: var(--jsl-button-primary, var(--jsl-color-accent));
|
|
63
|
+
color: var(--jsl-button-selected-text, var(--jsl-color-text));
|
|
64
|
+
box-shadow: none;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.jsl-button:focus-visible {
|
|
68
|
+
outline: 2px solid var(--jsl-button-focus, var(--jsl-color-focus));
|
|
69
|
+
outline-offset: 3px;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.jsl-button.jsl-button-small {
|
|
73
|
+
--jsl-button-height: 1.75rem;
|
|
74
|
+
--jsl-button-padding: 0.625rem;
|
|
75
|
+
gap: 0.375rem;
|
|
76
|
+
font-size: 0.8125rem;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.jsl-button.jsl-button-large {
|
|
80
|
+
--jsl-button-height: 2.5rem;
|
|
81
|
+
--jsl-button-padding: 1rem;
|
|
82
|
+
font-size: 0.9375rem;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.jsl-button.jsl-button-icon-only {
|
|
86
|
+
width: var(--jsl-button-height);
|
|
87
|
+
padding: 0;
|
|
88
|
+
flex-shrink: 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.jsl-button-icon {
|
|
92
|
+
display: inline-flex;
|
|
93
|
+
align-items: center;
|
|
94
|
+
justify-content: center;
|
|
95
|
+
flex: 0 0 auto;
|
|
96
|
+
width: 1.125em;
|
|
97
|
+
height: 1.125em;
|
|
98
|
+
line-height: 1;
|
|
99
|
+
pointer-events: none;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.jsl-button-icon > img,
|
|
103
|
+
.jsl-button-icon > svg {
|
|
104
|
+
display: block;
|
|
105
|
+
width: 100%;
|
|
106
|
+
height: 100%;
|
|
107
|
+
object-fit: contain;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.jsl-button-label-hidden {
|
|
111
|
+
position: absolute;
|
|
112
|
+
width: 1px;
|
|
113
|
+
height: 1px;
|
|
114
|
+
padding: 0;
|
|
115
|
+
margin: -1px;
|
|
116
|
+
overflow: hidden;
|
|
117
|
+
clip-path: inset(50%);
|
|
118
|
+
white-space: nowrap;
|
|
119
|
+
border: 0;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.jsl-button:disabled,
|
|
123
|
+
.jsl-button.disabled {
|
|
124
|
+
background: var(--jsl-button-disabled-surface, var(--jsl-color-disabled-surface));
|
|
125
|
+
border-color: var(--jsl-button-disabled-border, var(--jsl-color-border-subtle));
|
|
126
|
+
color: var(--jsl-button-disabled-text, var(--jsl-color-disabled-text));
|
|
127
|
+
box-shadow: none;
|
|
128
|
+
cursor: not-allowed;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@media (prefers-reduced-motion: reduce) {
|
|
132
|
+
.jsl-button { transition: none; }
|
|
133
|
+
}
|
|
134
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
@import "./input.css";
|
|
2
|
+
|
|
3
|
+
.jsl-date-input { width: 11rem; font-variant-numeric: tabular-nums; }
|
|
4
|
+
.date-comp {
|
|
5
|
+
padding-right: 2.4rem;
|
|
6
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%2371717a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2.5' y='4' width='13' height='12' rx='2'/%3E%3Cpath d='M6 2v4M12 2v4M3 8h12'/%3E%3C/svg%3E");
|
|
7
|
+
background-position: right .7rem center;
|
|
8
|
+
background-repeat: no-repeat;
|
|
9
|
+
}
|
|
10
|
+
.jsl-date-input:disabled { opacity: .75; }
|
|
11
|
+
.jsl-date-input[aria-invalid="true"] { border-style: dashed; border-width: 2px; }
|