@nectary/components 1.2.1 → 1.2.2
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/colors.json +3 -3
- package/package.json +1 -1
- package/select-menu/index.js +44 -49
- package/theme/color-swatch.css +6 -0
- package/theme/colors.js +3 -3
- package/theme/palette.css +3 -3
- package/utils/dom.d.ts +1 -0
- package/utils/dom.js +3 -0
package/colors.json
CHANGED
|
@@ -73,9 +73,9 @@
|
|
|
73
73
|
"colorCeltic700": "#003B7E",
|
|
74
74
|
"colorCeltic400": "#2071CE",
|
|
75
75
|
"colorCeltic200": "#D5E5F8",
|
|
76
|
-
"colorJasper700": "#
|
|
77
|
-
"colorJasper400": "#
|
|
78
|
-
"colorJasper200": "#
|
|
76
|
+
"colorJasper700": "#B71C1C",
|
|
77
|
+
"colorJasper400": "#F44336",
|
|
78
|
+
"colorJasper200": "#FFCDD2",
|
|
79
79
|
"colorPumpkin700": "#9C2E00",
|
|
80
80
|
"colorPumpkin400": "#F35B1C",
|
|
81
81
|
"colorPumpkin200": "#FFE8D6",
|
package/package.json
CHANGED
package/select-menu/index.js
CHANGED
|
@@ -2,10 +2,10 @@ import '../input';
|
|
|
2
2
|
import '../icon-button';
|
|
3
3
|
import '../icon';
|
|
4
4
|
import '../text';
|
|
5
|
-
import { attrValueToPixels, defineCustomElement, getAttribute, getBooleanAttribute, unpackCsv, getFirstCsvValue, getIntegerAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv, updateExplicitBooleanAttribute, updateIntegerAttribute, debounceTimeout, setClass, subscribeContext, getCssVar } from '../utils';
|
|
5
|
+
import { attrValueToPixels, defineCustomElement, getAttribute, getBooleanAttribute, unpackCsv, getFirstCsvValue, getIntegerAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv, updateExplicitBooleanAttribute, updateIntegerAttribute, debounceTimeout, setClass, subscribeContext, getCssVar, hasClass } from '../utils';
|
|
6
6
|
const templateHTML = '<style>:host{display:block;outline:0}#listbox{overflow-y:auto}#search{display:none;margin:10px}#search.active{display:block}#not-found{display:none;width:100%;height:30px;align-items:center;justify-content:center;margin-bottom:10px;color:var(--sinch-color-text-muted);pointer-events:none;user-select:none}#not-found.active{display:flex}::slotted(.hidden){display:none}</style><sinch-input id="search" size="s" placeholder="Search"><sinch-icon id="icon-search" slot="icon"></sinch-icon></sinch-input><div id="not-found"><sinch-text type="m">No results</sinch-text></div><div id="listbox" role="presentation"><slot></slot></div>';
|
|
7
7
|
const ITEM_HEIGHT = 40;
|
|
8
|
-
const NUM_ITEMS_SEARCH =
|
|
8
|
+
const NUM_ITEMS_SEARCH = 7;
|
|
9
9
|
const template = document.createElement('template');
|
|
10
10
|
template.innerHTML = templateHTML;
|
|
11
11
|
defineCustomElement('sinch-select-menu', class extends NectaryElement {
|
|
@@ -29,35 +29,23 @@ defineCustomElement('sinch-select-menu', class extends NectaryElement {
|
|
|
29
29
|
}
|
|
30
30
|
connectedCallback() {
|
|
31
31
|
this.#controller = new AbortController();
|
|
32
|
-
const {
|
|
33
|
-
signal
|
|
34
|
-
}
|
|
32
|
+
const options = {
|
|
33
|
+
signal: this.#controller.signal
|
|
34
|
+
};
|
|
35
35
|
this.setAttribute('role', 'listbox');
|
|
36
36
|
this.setAttribute('tabindex', '0');
|
|
37
|
-
this.addEventListener('keydown', this.#onListboxKeyDown,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
this.addEventListener('
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.#$
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
this
|
|
47
|
-
signal
|
|
48
|
-
});
|
|
49
|
-
this.#$search.addEventListener('-change', this.#onSearchChange, {
|
|
50
|
-
signal
|
|
51
|
-
});
|
|
52
|
-
this.#$optionSlot.addEventListener('slotchange', this.#onOptionSlotChange, {
|
|
53
|
-
signal
|
|
54
|
-
});
|
|
55
|
-
this.addEventListener('-change', this.#onChangeReactHandler, {
|
|
56
|
-
signal
|
|
57
|
-
});
|
|
58
|
-
subscribeContext(this, 'keydown', this.#onContextKeyDown, signal);
|
|
59
|
-
subscribeContext(this, 'visibility', this.#onContextVisibility, signal);
|
|
37
|
+
this.addEventListener('keydown', this.#onListboxKeyDown, options);
|
|
38
|
+
this.addEventListener('focus', this.#onFocus, options);
|
|
39
|
+
this.addEventListener('blur', this.#onListboxBlur, options);
|
|
40
|
+
this.#$listbox.addEventListener('mousedown', this.#onListboxMousedown, options);
|
|
41
|
+
this.#$listbox.addEventListener('click', this.#onListboxClick, options);
|
|
42
|
+
this.#$search.addEventListener('-change', this.#onSearchChange, options);
|
|
43
|
+
this.#$optionSlot.addEventListener('slotchange', this.#onOptionSlotChange, options);
|
|
44
|
+
this.addEventListener('-change', this.#onChangeReactHandler, options);
|
|
45
|
+
subscribeContext(this, 'keydown', this.#onContextKeyDown, this.#controller.signal);
|
|
46
|
+
subscribeContext(this, 'visibility', this.#onContextVisibility, this.#controller.signal);
|
|
60
47
|
updateAttribute(this.#$iconSearch, 'name', getCssVar(this, '--sinch-select-menu-icon-search'));
|
|
48
|
+
this.#onOptionSlotChange();
|
|
61
49
|
}
|
|
62
50
|
disconnectedCallback() {
|
|
63
51
|
this.#controller.abort();
|
|
@@ -66,24 +54,6 @@ defineCustomElement('sinch-select-menu', class extends NectaryElement {
|
|
|
66
54
|
static get observedAttributes() {
|
|
67
55
|
return ['value', 'rows', 'multiple'];
|
|
68
56
|
}
|
|
69
|
-
set value(value) {
|
|
70
|
-
updateAttribute(this, 'value', value);
|
|
71
|
-
}
|
|
72
|
-
get value() {
|
|
73
|
-
return getAttribute(this, 'value', '');
|
|
74
|
-
}
|
|
75
|
-
set rows(value) {
|
|
76
|
-
updateIntegerAttribute(this, 'rows', value);
|
|
77
|
-
}
|
|
78
|
-
get rows() {
|
|
79
|
-
return getIntegerAttribute(this, 'rows', null);
|
|
80
|
-
}
|
|
81
|
-
set multiple(isMultiple) {
|
|
82
|
-
updateBooleanAttribute(this, 'multiple', isMultiple);
|
|
83
|
-
}
|
|
84
|
-
get multiple() {
|
|
85
|
-
return getBooleanAttribute(this, 'multiple');
|
|
86
|
-
}
|
|
87
57
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
88
58
|
if (oldVal === newVal) {
|
|
89
59
|
return;
|
|
@@ -110,6 +80,33 @@ defineCustomElement('sinch-select-menu', class extends NectaryElement {
|
|
|
110
80
|
}
|
|
111
81
|
}
|
|
112
82
|
}
|
|
83
|
+
set value(value) {
|
|
84
|
+
updateAttribute(this, 'value', value);
|
|
85
|
+
}
|
|
86
|
+
get value() {
|
|
87
|
+
return getAttribute(this, 'value', '');
|
|
88
|
+
}
|
|
89
|
+
set rows(value) {
|
|
90
|
+
updateIntegerAttribute(this, 'rows', value);
|
|
91
|
+
}
|
|
92
|
+
get rows() {
|
|
93
|
+
return getIntegerAttribute(this, 'rows', null);
|
|
94
|
+
}
|
|
95
|
+
set multiple(isMultiple) {
|
|
96
|
+
updateBooleanAttribute(this, 'multiple', isMultiple);
|
|
97
|
+
}
|
|
98
|
+
get multiple() {
|
|
99
|
+
return getBooleanAttribute(this, 'multiple');
|
|
100
|
+
}
|
|
101
|
+
get focusable() {
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
#onFocus = () => {
|
|
105
|
+
const isSearchActive = hasClass(this.#$search, 'active');
|
|
106
|
+
if (isSearchActive) {
|
|
107
|
+
this.#$search.focus();
|
|
108
|
+
}
|
|
109
|
+
};
|
|
113
110
|
#onListboxMousedown = e => {
|
|
114
111
|
const $elem = e.target;
|
|
115
112
|
if (!getBooleanAttribute($elem, 'disabled')) {
|
|
@@ -147,6 +144,7 @@ defineCustomElement('sinch-select-menu', class extends NectaryElement {
|
|
|
147
144
|
#onContextVisibility = e => {
|
|
148
145
|
if (e.detail) {
|
|
149
146
|
this.#selectOption(this.#findCheckedOption());
|
|
147
|
+
this.#onFocus();
|
|
150
148
|
} else {
|
|
151
149
|
this.#selectOption(null);
|
|
152
150
|
}
|
|
@@ -306,7 +304,4 @@ defineCustomElement('sinch-select-menu', class extends NectaryElement {
|
|
|
306
304
|
#onChangeReactHandler = e => {
|
|
307
305
|
getReactEventHandler(this, 'on-change')?.(e);
|
|
308
306
|
};
|
|
309
|
-
get focusable() {
|
|
310
|
-
return true;
|
|
311
|
-
}
|
|
312
307
|
});
|
package/theme/color-swatch.css
CHANGED
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
--sinch-color-swatch-color-light-violet-fg: var(--sinch-color-violet-700);
|
|
19
19
|
--sinch-color-swatch-color-light-yellow-bg: var(--sinch-color-bolt-200);
|
|
20
20
|
--sinch-color-swatch-color-light-yellow-fg: var(--sinch-color-bolt-700);
|
|
21
|
+
--sinch-color-swatch-color-light-red-bg: var(--sinch-color-jasper-200);
|
|
22
|
+
--sinch-color-swatch-color-light-red-fg: var(--sinch-color-jasper-700);
|
|
21
23
|
--sinch-color-swatch-color-dark-blue-bg: var(--sinch-color-night-700);
|
|
22
24
|
--sinch-color-swatch-color-dark-blue-fg: var(--sinch-color-night-200);
|
|
23
25
|
--sinch-color-swatch-color-dark-brown-bg: var(--sinch-color-mud-700);
|
|
@@ -34,6 +36,8 @@
|
|
|
34
36
|
--sinch-color-swatch-color-dark-violet-fg: var(--sinch-color-violet-200);
|
|
35
37
|
--sinch-color-swatch-color-dark-yellow-bg: var(--sinch-color-bolt-700);
|
|
36
38
|
--sinch-color-swatch-color-dark-yellow-fg: var(--sinch-color-bolt-200);
|
|
39
|
+
--sinch-color-swatch-color-dark-red-bg: var(--sinch-color-jasper-700);
|
|
40
|
+
--sinch-color-swatch-color-dark-red-fg: var(--sinch-color-jasper-200);
|
|
37
41
|
--sinch-color-swatch-color-blue-bg: var(--sinch-color-night-400);
|
|
38
42
|
--sinch-color-swatch-color-blue-fg: var(--sinch-color-snow-100);
|
|
39
43
|
--sinch-color-swatch-color-brown-bg: var(--sinch-color-mud-400);
|
|
@@ -50,6 +54,8 @@
|
|
|
50
54
|
--sinch-color-swatch-color-violet-fg: var(--sinch-color-stormy-500);
|
|
51
55
|
--sinch-color-swatch-color-yellow-bg: var(--sinch-color-bolt-400);
|
|
52
56
|
--sinch-color-swatch-color-yellow-fg: var(--sinch-color-stormy-500);
|
|
57
|
+
--sinch-color-swatch-color-red-bg: var(--sinch-color-jasper-400);
|
|
58
|
+
--sinch-color-swatch-color-red-fg: var(--sinch-color-stormy-500);
|
|
53
59
|
--sinch-color-swatch-color-skin-tone-0-bg: var(--sinch-color-skin-tone-0);
|
|
54
60
|
--sinch-color-swatch-color-skin-tone-0-fg: var(--sinch-color-stormy-500);
|
|
55
61
|
--sinch-color-swatch-color-skin-tone-10-bg: var(--sinch-color-skin-tone-10);
|
package/theme/colors.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const lightColorNames = ['light-violet', 'light-blue', 'light-green', 'light-yellow', 'light-orange', 'light-pink', 'light-brown', 'light-gray'].join(',');
|
|
2
|
-
export const darkColorNames = ['dark-violet', 'dark-blue', 'dark-green', 'dark-yellow', 'dark-orange', 'dark-pink', 'dark-brown', 'dark-gray'].join(',');
|
|
3
|
-
export const vibrantColorNames = ['violet', 'blue', 'green', 'yellow', 'orange', 'pink', 'brown', 'gray'].join(',');
|
|
1
|
+
export const lightColorNames = ['light-violet', 'light-blue', 'light-green', 'light-yellow', 'light-orange', 'light-red', 'light-pink', 'light-brown', 'light-gray'].join(',');
|
|
2
|
+
export const darkColorNames = ['dark-violet', 'dark-blue', 'dark-green', 'dark-yellow', 'dark-orange', 'dark-red', 'dark-pink', 'dark-brown', 'dark-gray'].join(',');
|
|
3
|
+
export const vibrantColorNames = ['violet', 'blue', 'green', 'yellow', 'orange', 'red', 'pink', 'brown', 'gray'].join(',');
|
|
4
4
|
export const skinToneColorNames = ['skin-tone-0', 'skin-tone-10', 'skin-tone-20', 'skin-tone-30', 'skin-tone-40', 'skin-tone-50'].join(',');
|
package/theme/palette.css
CHANGED
|
@@ -74,9 +74,9 @@
|
|
|
74
74
|
--sinch-color-celtic-700: #003B7E;
|
|
75
75
|
--sinch-color-celtic-400: #2071CE;
|
|
76
76
|
--sinch-color-celtic-200: #D5E5F8;
|
|
77
|
-
--sinch-color-jasper-700: #
|
|
78
|
-
--sinch-color-jasper-400: #
|
|
79
|
-
--sinch-color-jasper-200: #
|
|
77
|
+
--sinch-color-jasper-700: #B71C1C;
|
|
78
|
+
--sinch-color-jasper-400: #F44336;
|
|
79
|
+
--sinch-color-jasper-200: #FFCDD2;
|
|
80
80
|
--sinch-color-pumpkin-700: #9C2E00;
|
|
81
81
|
--sinch-color-pumpkin-400: #F35B1C;
|
|
82
82
|
--sinch-color-pumpkin-200: #FFE8D6;
|
package/utils/dom.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export declare function getIntegerAttribute($element: Element, attrName: string)
|
|
|
25
25
|
export declare function getIntegerAttribute($element: Element, attrName: string, defaultValue: null): number | null;
|
|
26
26
|
export declare function getIntegerAttribute($element: Element, attrName: string, defaultValue: number): number;
|
|
27
27
|
export declare const setClass: (elem: Element, name: string, isSet: boolean) => void;
|
|
28
|
+
export declare const hasClass: (elem: Element, name: string) => boolean;
|
|
28
29
|
export declare const getCssVar: (element: Element, variableName: string) => string | null;
|
|
29
30
|
export declare const getCssVars: (element: Element, variableNames: string[]) => (string | null)[];
|
|
30
31
|
export declare const cloneNode: (el: Element, deep: boolean) => Element;
|
package/utils/dom.js
CHANGED
|
@@ -122,6 +122,9 @@ export function getIntegerAttribute($element, attrName, defaultValue) {
|
|
|
122
122
|
export const setClass = (elem, name, isSet) => {
|
|
123
123
|
isSet ? elem.classList.add(name) : elem.classList.remove(name);
|
|
124
124
|
};
|
|
125
|
+
export const hasClass = (elem, name) => {
|
|
126
|
+
return elem.classList.contains(name);
|
|
127
|
+
};
|
|
125
128
|
export const getCssVar = (element, variableName) => {
|
|
126
129
|
const result = getComputedStyle(element).getPropertyValue(variableName).trim();
|
|
127
130
|
return result === '' ? null : result;
|