@nectary/components 0.39.0 → 0.40.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/accordion/index.js +47 -84
- package/accordion-item/index.js +26 -53
- package/action-menu/index.d.ts +0 -1
- package/action-menu/index.js +179 -223
- package/action-menu/types.d.ts +8 -18
- package/action-menu-option/index.d.ts +1 -0
- package/action-menu-option/index.js +51 -62
- package/action-menu-option/types.d.ts +9 -0
- package/action-menu-option/utils.d.ts +2 -0
- package/action-menu-option/utils.js +3 -0
- package/alert/index.js +6 -20
- package/avatar/index.js +12 -31
- package/avatar-badge/index.js +8 -22
- package/avatar-status/index.js +1 -1
- package/button/index.js +42 -92
- package/card/index.js +21 -59
- package/chat-avatar/index.js +8 -22
- package/chat-block/index.js +29 -69
- package/chat-bubble/index.js +6 -20
- package/checkbox/index.js +55 -107
- package/chip/index.d.ts +13 -0
- package/chip/index.js +137 -0
- package/chip/types.d.ts +38 -0
- package/color-menu/index.d.ts +13 -0
- package/color-menu/index.js +464 -0
- package/color-menu/types.d.ts +37 -0
- package/color-swatch/index.d.ts +13 -0
- package/color-swatch/index.js +59 -0
- package/color-swatch/types.d.ts +12 -0
- package/colors.json +57 -49
- package/date-picker/index.js +161 -292
- package/dialog/index.js +70 -142
- package/dropdown-checkbox-option/index.js +6 -20
- package/dropdown-radio-option/index.js +6 -20
- package/field/index.js +25 -63
- package/file-drop/index.js +123 -200
- package/file-picker/index.d.ts +0 -1
- package/file-picker/index.js +55 -108
- package/file-status/index.js +15 -39
- package/help-tooltip/index.js +1 -1
- package/horizontal-stepper/index.js +33 -59
- package/horizontal-stepper-item/index.js +13 -37
- package/icon-button/index.js +39 -84
- package/icons-channel/notify/index.d.ts +11 -0
- package/icons-channel/notify/index.js +4 -0
- package/illustrations/create-illustration-class.js +1 -1
- package/inline-alert/index.js +29 -81
- package/input/index.js +113 -222
- package/link/index.js +46 -96
- package/list-item/index.js +1 -1
- package/package.json +12 -14
- package/pagination/index.js +109 -163
- package/popover/index.js +224 -294
- package/progress/index.js +9 -28
- package/radio/index.js +103 -169
- package/radio-option/index.js +24 -48
- package/segment/index.js +49 -130
- package/segment-collapse/index.js +24 -49
- package/segmented-control/index.js +36 -73
- package/segmented-control-option/index.js +41 -87
- package/segmented-icon-control/index.js +47 -84
- package/segmented-icon-control-option/index.js +38 -79
- package/select-button/index.d.ts +13 -0
- package/select-button/index.js +153 -0
- package/select-button/types.d.ts +43 -0
- package/select-menu/index.d.ts +11 -0
- package/select-menu/index.js +346 -0
- package/select-menu/types.d.ts +29 -0
- package/select-menu/types.js +1 -0
- package/{dropdown-text-option → select-menu-option}/index.d.ts +5 -7
- package/select-menu-option/index.js +76 -0
- package/{select-option → select-menu-option}/types.d.ts +8 -9
- package/stop-events/index.js +7 -20
- package/table-head-cell/index.js +7 -21
- package/tabs/index.js +103 -165
- package/tabs-option/index.js +20 -44
- package/tag/index.d.ts +0 -1
- package/tag/index.js +37 -38
- package/tag/types.d.ts +13 -7
- package/textarea/index.js +92 -167
- package/theme.css +80 -49
- package/tile-control/index.js +55 -96
- package/tile-control-option/index.js +40 -86
- package/time-picker/index.js +216 -368
- package/title/index.js +6 -20
- package/toast/index.js +32 -70
- package/toast-manager/index.js +141 -217
- package/toggle/index.js +54 -106
- package/types.d.ts +7 -0
- package/utils/colors.d.ts +10 -0
- package/utils/colors.js +121 -0
- package/{utils.d.ts → utils/index.d.ts} +17 -9
- package/{utils.js → utils/index.js} +96 -39
- package/vertical-stepper/index.js +29 -50
- package/vertical-stepper-item/index.js +13 -37
- package/dropdown/index.d.ts +0 -12
- package/dropdown/index.js +0 -415
- package/dropdown/types.d.ts +0 -32
- package/dropdown-text-option/index.js +0 -104
- package/dropdown-text-option/types.d.ts +0 -16
- package/select/index.d.ts +0 -13
- package/select/index.js +0 -316
- package/select/types.d.ts +0 -53
- package/select-option/index.d.ts +0 -11
- package/select-option/index.js +0 -8
- package/tag/utils.d.ts +0 -5
- package/tag/utils.js +0 -6
- package/tag-close/index.d.ts +0 -12
- package/tag-close/index.js +0 -42
- package/tag-close/types.d.ts +0 -5
- /package/{dropdown-text-option → chip}/types.js +0 -0
- /package/{dropdown → color-menu}/types.js +0 -0
- /package/{select-option → color-swatch}/types.js +0 -0
- /package/{select → select-button}/types.js +0 -0
- /package/{tag-close → select-menu-option}/types.js +0 -0
package/accordion/index.js
CHANGED
|
@@ -1,66 +1,15 @@
|
|
|
1
|
-
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
-
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
-
|
|
4
|
-
var _$slot, _onSlotChange, _onOptionChange, _onValueChange, _onChangeReactHandler;
|
|
5
|
-
|
|
6
|
-
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
7
|
-
|
|
8
|
-
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
9
|
-
|
|
10
|
-
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
11
|
-
|
|
12
|
-
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
13
|
-
|
|
14
1
|
import { defineCustomElement, getAttribute, getBooleanAttribute, getCsvSet, getFirstCsvValue, getReactEventHandler, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv } from '../utils';
|
|
15
2
|
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;box-sizing:border-box;width:100%;height:100%}::slotted(sinch-accordion-item){flex-shrink:1}</style><div id="wrapper"><slot></slot></div>';
|
|
16
3
|
const template = document.createElement('template');
|
|
17
4
|
template.innerHTML = templateHTML;
|
|
18
|
-
defineCustomElement('sinch-accordion',
|
|
5
|
+
defineCustomElement('sinch-accordion', class extends NectaryElement {
|
|
6
|
+
#$slot;
|
|
7
|
+
|
|
19
8
|
constructor() {
|
|
20
9
|
super();
|
|
21
|
-
|
|
22
|
-
_classPrivateMethodInitSpec(this, _onValueChange);
|
|
23
|
-
|
|
24
|
-
_classPrivateFieldInitSpec(this, _$slot, {
|
|
25
|
-
writable: true,
|
|
26
|
-
value: void 0
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
_classPrivateFieldInitSpec(this, _onSlotChange, {
|
|
30
|
-
writable: true,
|
|
31
|
-
value: () => {
|
|
32
|
-
_classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, this.value);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
_classPrivateFieldInitSpec(this, _onOptionChange, {
|
|
37
|
-
writable: true,
|
|
38
|
-
value: e => {
|
|
39
|
-
e.stopPropagation();
|
|
40
|
-
const $elem = e.target;
|
|
41
|
-
const value = e.detail;
|
|
42
|
-
const result = this.multiple ? updateCsv(this.value, value, !getBooleanAttribute($elem, 'data-checked')) : getBooleanAttribute($elem, 'data-checked') ? '' : value;
|
|
43
|
-
this.dispatchEvent(new CustomEvent('change', {
|
|
44
|
-
detail: result,
|
|
45
|
-
bubbles: true
|
|
46
|
-
}));
|
|
47
|
-
this.dispatchEvent(new CustomEvent('-change', {
|
|
48
|
-
detail: result
|
|
49
|
-
}));
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
_classPrivateFieldInitSpec(this, _onChangeReactHandler, {
|
|
54
|
-
writable: true,
|
|
55
|
-
value: e => {
|
|
56
|
-
getReactEventHandler(this, 'on-change')?.(e);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
10
|
const shadowRoot = this.attachShadow();
|
|
61
11
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
62
|
-
|
|
63
|
-
_classPrivateFieldSet(this, _$slot, shadowRoot.querySelector('slot'));
|
|
12
|
+
this.#$slot = shadowRoot.querySelector('slot');
|
|
64
13
|
}
|
|
65
14
|
|
|
66
15
|
static get observedAttributes() {
|
|
@@ -69,20 +18,15 @@ defineCustomElement('sinch-accordion', (_$slot = new WeakMap(), _onSlotChange =
|
|
|
69
18
|
|
|
70
19
|
connectedCallback() {
|
|
71
20
|
this.setAttribute('aria-label', 'accordion');
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
_classPrivateFieldGet(this, _$slot).addEventListener('option-change', _classPrivateFieldGet(this, _onOptionChange));
|
|
76
|
-
|
|
77
|
-
this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
21
|
+
this.#$slot.addEventListener('slotchange', this.#onSlotChange);
|
|
22
|
+
this.#$slot.addEventListener('option-change', this.#onOptionChange);
|
|
23
|
+
this.addEventListener('-change', this.#onChangeReactHandler);
|
|
78
24
|
}
|
|
79
25
|
|
|
80
26
|
disconnectedCallback() {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
27
|
+
this.#$slot.removeEventListener('slotchange', this.#onSlotChange);
|
|
28
|
+
this.#$slot.removeEventListener('option-change', this.#onOptionChange);
|
|
29
|
+
this.removeEventListener('-change', this.#onChangeReactHandler);
|
|
86
30
|
}
|
|
87
31
|
|
|
88
32
|
get nodeName() {
|
|
@@ -113,29 +57,48 @@ defineCustomElement('sinch-accordion', (_$slot = new WeakMap(), _onSlotChange =
|
|
|
113
57
|
switch (name) {
|
|
114
58
|
case 'value':
|
|
115
59
|
{
|
|
116
|
-
|
|
117
|
-
|
|
60
|
+
this.#onValueChange(newVal ?? '');
|
|
118
61
|
break;
|
|
119
62
|
}
|
|
120
63
|
}
|
|
121
64
|
}
|
|
122
65
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
66
|
+
#onSlotChange = () => {
|
|
67
|
+
this.#onValueChange(this.value);
|
|
68
|
+
};
|
|
69
|
+
#onOptionChange = e => {
|
|
70
|
+
e.stopPropagation();
|
|
71
|
+
const $elem = e.target;
|
|
72
|
+
const value = e.detail;
|
|
73
|
+
const result = this.multiple ? updateCsv(this.value, value, !getBooleanAttribute($elem, 'data-checked')) : getBooleanAttribute($elem, 'data-checked') ? '' : value;
|
|
74
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
75
|
+
detail: result,
|
|
76
|
+
bubbles: true
|
|
77
|
+
}));
|
|
78
|
+
this.dispatchEvent(new CustomEvent('-change', {
|
|
79
|
+
detail: result
|
|
80
|
+
}));
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
#onValueChange(csv) {
|
|
84
|
+
if (this.multiple) {
|
|
85
|
+
const values = getCsvSet(csv);
|
|
86
|
+
|
|
87
|
+
for (const $option of this.#$slot.assignedElements()) {
|
|
88
|
+
const isChecked = !getBooleanAttribute($option, 'disabled') && values.has(getAttribute($option, 'value', ''));
|
|
89
|
+
updateBooleanAttribute($option, 'data-checked', isChecked);
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
const value = getFirstCsvValue(csv);
|
|
135
93
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
94
|
+
for (const $option of this.#$slot.assignedElements()) {
|
|
95
|
+
const isChecked = !getBooleanAttribute($option, 'disabled') && value === getAttribute($option, 'value', '');
|
|
96
|
+
updateBooleanAttribute($option, 'data-checked', isChecked);
|
|
97
|
+
}
|
|
139
98
|
}
|
|
140
99
|
}
|
|
141
|
-
|
|
100
|
+
|
|
101
|
+
#onChangeReactHandler = e => {
|
|
102
|
+
getReactEventHandler(this, 'on-change')?.(e);
|
|
103
|
+
};
|
|
104
|
+
});
|
package/accordion-item/index.js
CHANGED
|
@@ -1,64 +1,29 @@
|
|
|
1
|
-
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
-
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
-
|
|
4
|
-
var _$button, _$buttonContent, _$optionalText, _onButtonClick;
|
|
5
|
-
|
|
6
|
-
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
7
|
-
|
|
8
|
-
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
9
|
-
|
|
10
1
|
import '../icons/keyboard-arrow-down';
|
|
11
2
|
import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateLiteralAttribute } from '../utils';
|
|
12
3
|
const templateHTML = '<style>:host{display:block;outline:0;min-height:48px}#wrapper{display:flex;flex-direction:column;position:relative;width:100%;height:100%;box-sizing:border-box;overflow:hidden;border-bottom:1px solid var(--sinch-color-stormy-200);--sinch-size-icon:16px}#button{all:initial;cursor:pointer;display:flex;align-items:center;gap:8px;box-sizing:border-box;width:100%;height:48px;padding:12px 8px;font:var(--sinch-font-title-s);color:var(--sinch-color-text-default);fill:var(--sinch-color-stormy-500)}#button>*{pointer-events:none}#button:disabled{cursor:initial;color:var(--sinch-color-stormy-100);fill:var(--sinch-color-stormy-100)}#button::before{width:8px;height:8px;border-radius:50%;margin-left:2px;margin-right:8px}:host([status=success]) #button::before{content:"";background-color:var(--sinch-color-success-500)}:host([status=warn]) #button::before{content:"";background-color:var(--sinch-color-warning-500)}:host([status=error]) #button::before{content:"";background-color:var(--sinch-color-error-500)}:host([status=info]) #button::before{content:"";background-color:var(--sinch-color-informative-500)}#title{flex:1;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}#content{display:none;overflow-y:auto;flex-shrink:1;min-height:0;padding:0 8px 18px;font:var(--sinch-font-body);color:var(--sinch-color-text-default)}#dropdown-icon{--sinch-size-icon:24px}#button[aria-expanded=true]>#dropdown-icon{transform:rotate(180deg)}#button[aria-expanded=true]+#content{display:block}#optional{font:var(--sinch-font-small-text);color:var(--sinch-color-stormy-300)}</style><div id="wrapper"><button id="button" aria-controls="content" aria-expanded="false"><slot name="icon"></slot><span id="title"></span><span id="optional"></span><sinch-icon-keyboard-arrow-down id="dropdown-icon"></sinch-icon-keyboard-arrow-down></button><div id="content" role="region" aria-labelledby="button"><slot name="content"></slot></div></div>';
|
|
13
4
|
import { statusValues } from './utils';
|
|
14
5
|
const template = document.createElement('template');
|
|
15
6
|
template.innerHTML = templateHTML;
|
|
16
|
-
defineCustomElement('sinch-accordion-item',
|
|
7
|
+
defineCustomElement('sinch-accordion-item', class extends NectaryElement {
|
|
8
|
+
#$button;
|
|
9
|
+
#$buttonContent;
|
|
10
|
+
#$optionalText;
|
|
11
|
+
|
|
17
12
|
constructor() {
|
|
18
13
|
super();
|
|
19
|
-
|
|
20
|
-
_classPrivateFieldInitSpec(this, _$button, {
|
|
21
|
-
writable: true,
|
|
22
|
-
value: void 0
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
_classPrivateFieldInitSpec(this, _$buttonContent, {
|
|
26
|
-
writable: true,
|
|
27
|
-
value: void 0
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
_classPrivateFieldInitSpec(this, _$optionalText, {
|
|
31
|
-
writable: true,
|
|
32
|
-
value: void 0
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
_classPrivateFieldInitSpec(this, _onButtonClick, {
|
|
36
|
-
writable: true,
|
|
37
|
-
value: e => {
|
|
38
|
-
e.stopPropagation();
|
|
39
|
-
this.dispatchEvent(new CustomEvent('option-change', {
|
|
40
|
-
bubbles: true,
|
|
41
|
-
detail: this.value
|
|
42
|
-
}));
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
14
|
const shadowRoot = this.attachShadow();
|
|
47
15
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
_classPrivateFieldSet(this, _$buttonContent, shadowRoot.querySelector('#title'));
|
|
52
|
-
|
|
53
|
-
_classPrivateFieldSet(this, _$optionalText, shadowRoot.querySelector('#optional'));
|
|
16
|
+
this.#$button = shadowRoot.querySelector('#button');
|
|
17
|
+
this.#$buttonContent = shadowRoot.querySelector('#title');
|
|
18
|
+
this.#$optionalText = shadowRoot.querySelector('#optional');
|
|
54
19
|
}
|
|
55
20
|
|
|
56
21
|
connectedCallback() {
|
|
57
|
-
|
|
22
|
+
this.#$button.addEventListener('click', this.#onButtonClick);
|
|
58
23
|
}
|
|
59
24
|
|
|
60
25
|
disconnectedCallback() {
|
|
61
|
-
|
|
26
|
+
this.#$button.removeEventListener('click', this.#onButtonClick);
|
|
62
27
|
}
|
|
63
28
|
|
|
64
29
|
static get observedAttributes() {
|
|
@@ -102,7 +67,7 @@ defineCustomElement('sinch-accordion-item', (_$button = new WeakMap(), _$buttonC
|
|
|
102
67
|
}
|
|
103
68
|
|
|
104
69
|
get optionalText() {
|
|
105
|
-
return getAttribute(this, 'optionaltext'
|
|
70
|
+
return getAttribute(this, 'optionaltext');
|
|
106
71
|
}
|
|
107
72
|
|
|
108
73
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
@@ -113,36 +78,44 @@ defineCustomElement('sinch-accordion-item', (_$button = new WeakMap(), _$buttonC
|
|
|
113
78
|
switch (name) {
|
|
114
79
|
case 'label':
|
|
115
80
|
{
|
|
116
|
-
|
|
81
|
+
this.#$buttonContent.textContent = newVal;
|
|
117
82
|
break;
|
|
118
83
|
}
|
|
119
84
|
|
|
120
85
|
case 'disabled':
|
|
121
86
|
{
|
|
122
|
-
|
|
87
|
+
this.#$button.disabled = isAttrTrue(newVal);
|
|
123
88
|
break;
|
|
124
89
|
}
|
|
125
90
|
|
|
126
91
|
case 'data-checked':
|
|
127
92
|
{
|
|
128
|
-
updateExplicitBooleanAttribute(
|
|
93
|
+
updateExplicitBooleanAttribute(this.#$button, 'aria-expanded', isAttrTrue(newVal));
|
|
129
94
|
break;
|
|
130
95
|
}
|
|
131
96
|
|
|
132
97
|
case 'optionaltext':
|
|
133
98
|
{
|
|
134
|
-
|
|
99
|
+
this.#$optionalText.textContent = newVal;
|
|
135
100
|
break;
|
|
136
101
|
}
|
|
137
102
|
}
|
|
138
103
|
}
|
|
139
104
|
|
|
105
|
+
#onButtonClick = e => {
|
|
106
|
+
e.stopPropagation();
|
|
107
|
+
this.dispatchEvent(new CustomEvent('option-change', {
|
|
108
|
+
bubbles: true,
|
|
109
|
+
detail: this.value
|
|
110
|
+
}));
|
|
111
|
+
};
|
|
112
|
+
|
|
140
113
|
focus() {
|
|
141
|
-
|
|
114
|
+
this.#$button.focus();
|
|
142
115
|
}
|
|
143
116
|
|
|
144
117
|
blur() {
|
|
145
|
-
|
|
118
|
+
this.#$button.blur();
|
|
146
119
|
}
|
|
147
120
|
|
|
148
|
-
})
|
|
121
|
+
});
|
package/action-menu/index.d.ts
CHANGED