@nectary/components 0.34.0 → 0.36.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 +35 -10
- package/accordion/types.d.ts +3 -2
- package/accordion-item/index.js +8 -4
- package/action-menu/index.js +7 -8
- package/action-menu/types.d.ts +3 -3
- package/action-menu-option/index.js +23 -3
- package/action-menu-option/types.d.ts +2 -0
- package/alert/index.d.ts +4 -0
- package/alert/index.js +17 -32
- package/alert/types.d.ts +1 -7
- package/alert/utils.d.ts +3 -0
- package/alert/utils.js +6 -1
- package/avatar/index.js +1 -1
- package/button/index.js +69 -5
- package/button/types.d.ts +6 -0
- package/checkbox/index.js +64 -6
- package/checkbox/types.d.ts +8 -2
- package/date-picker/index.js +37 -12
- package/date-picker/types.d.ts +4 -2
- package/dialog/index.js +5 -6
- package/dialog/types.d.ts +3 -3
- package/dropdown/index.js +44 -28
- package/dropdown/types.d.ts +6 -4
- package/dropdown-checkbox-option/index.js +1 -1
- package/dropdown-checkbox-option/types.d.ts +0 -2
- package/dropdown-radio-option/index.js +1 -1
- package/dropdown-radio-option/types.d.ts +0 -2
- package/dropdown-text-option/index.js +1 -1
- package/dropdown-text-option/types.d.ts +0 -2
- package/horizontal-stepper/types.d.ts +4 -0
- package/horizontal-stepper-item/index.js +1 -1
- package/horizontal-stepper-item/types.d.ts +9 -0
- package/icon-button/index.js +75 -5
- package/icon-button/types.d.ts +6 -0
- package/icons/create-icon-class.js +1 -1
- package/icons-branded/create-icon-class.js +3 -7
- package/icons-branded/types.d.ts +3 -0
- package/icons-channel/create-icon-class.js +3 -7
- package/icons-channel/types.d.ts +3 -0
- package/inline-alert/index.d.ts +17 -0
- package/inline-alert/index.js +154 -0
- package/inline-alert/types.d.ts +15 -0
- package/inline-alert/utils.d.ts +5 -0
- package/inline-alert/utils.js +6 -0
- package/input/index.d.ts +0 -1
- package/input/index.js +58 -5
- package/input/types.d.ts +8 -2
- package/link/index.js +81 -3
- package/link/types.d.ts +9 -0
- package/package.json +1 -1
- package/pagination/index.js +24 -8
- package/pagination/types.d.ts +3 -1
- package/popover/index.js +5 -6
- package/popover/types.d.ts +4 -3
- package/radio/index.js +36 -8
- package/radio/types.d.ts +3 -1
- package/radio-option/index.js +1 -1
- package/search/types.d.ts +0 -1
- package/segment-collapse/index.js +28 -12
- package/segment-collapse/types.d.ts +3 -1
- package/segmented-control/index.js +28 -23
- package/segmented-control/types.d.ts +3 -2
- package/segmented-control-option/index.js +59 -13
- package/segmented-control-option/types.d.ts +4 -0
- package/segmented-icon-control/index.js +27 -16
- package/segmented-icon-control/types.d.ts +5 -2
- package/segmented-icon-control-option/index.js +54 -12
- package/segmented-icon-control-option/types.d.ts +4 -0
- package/select/index.js +68 -9
- package/select/types.d.ts +8 -2
- package/tabs/index.js +32 -8
- package/tabs/types.d.ts +3 -2
- package/tabs-option/index.js +2 -2
- package/text/index.js +1 -1
- package/textarea/index.js +58 -4
- package/textarea/types.d.ts +7 -2
- package/tile-control/index.d.ts +11 -0
- package/tile-control/index.js +181 -0
- package/tile-control/types.d.ts +38 -0
- package/tile-control/types.js +1 -0
- package/tile-control-option/index.d.ts +11 -0
- package/tile-control-option/index.js +161 -0
- package/tile-control-option/types.d.ts +37 -0
- package/time-picker/index.js +18 -4
- package/time-picker/types.d.ts +4 -2
- package/toggle/index.js +63 -5
- package/toggle/types.d.ts +3 -1
- package/vertical-stepper/index.d.ts +13 -0
- package/vertical-stepper/index.js +95 -0
- package/vertical-stepper/types.d.ts +13 -0
- package/vertical-stepper/types.js +1 -0
- package/vertical-stepper-item/index.d.ts +13 -0
- package/vertical-stepper-item/index.js +100 -0
- package/vertical-stepper-item/types.d.ts +24 -0
- package/vertical-stepper-item/types.js +1 -0
- package/vertical-stepper-item/utils.d.ts +2 -0
- package/vertical-stepper-item/utils.js +1 -0
- package/alert-button/index.d.ts +0 -11
- package/alert-button/index.js +0 -59
- package/alert-button/types.d.ts +0 -8
- package/alert-close/index.d.ts +0 -12
- package/alert-close/index.js +0 -38
- package/alert-close/types.d.ts +0 -3
- /package/{alert-button → inline-alert}/types.js +0 -0
- /package/{alert-close → tile-control-option}/types.js +0 -0
package/select/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
2
|
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
3
|
|
|
4
|
-
var _$button, _$buttonContent, _$label, _$optionalText, _$additionalText, _$invalidText, _$dropdown, _$optionSlot, _$sh, _createElement, _updateButtonContent, _onValueChange, _getOptionWithValue, _onLabelClick, _onDropdownClick, _onDropdownClose;
|
|
4
|
+
var _$button, _$buttonContent, _$label, _$optionalText, _$additionalText, _$invalidText, _$dropdown, _$optionSlot, _$sh, _createElement, _updateButtonContent, _onValueChange, _getOptionWithValue, _onLabelClick, _onDropdownClick, _onDropdownClose, _onButtonFocus, _onButtonBlur, _onChangeReactHandler, _onFocusReactHandler, _onBlurReactHandler;
|
|
5
5
|
|
|
6
6
|
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
7
7
|
|
|
@@ -12,11 +12,11 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
|
|
|
12
12
|
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
13
13
|
|
|
14
14
|
import '../dropdown';
|
|
15
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateIntegerAttribute } from '../utils';
|
|
16
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-color-icon:var(--sinch-color-stormy-500)}#wrapper{position:relative}sinch-dropdown{display:block}#button{all:initial;display:flex;align-items:center;gap:8px;border:1px solid var(--sinch-color-stormy-200);border-radius:var(--sinch-shape-radius-s);box-sizing:border-box;width:100%;height:48px;padding:8px 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100);cursor:pointer}#button:focus{border-color:var(--sinch-color-stormy-600)}#dropdown-icon{fill:var(--sinch-color-stormy-500)}#button>*{pointer-events:none}#button[data-unselected]{color:var(--sinch-color-text-muted)}#button:disabled{border-color:var(--sinch-color-snow-500);color:var(--sinch-color-stormy-100);cursor:initial}#button:disabled #dropdown-icon{fill:var(--sinch-color-stormy-100)}:host([invalidtext]:not([invalidtext=""])) #button:not(:disabled){border-color:var(--sinch-color-text-invalid)}#content{flex:1;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}#bottom,#top{display:flex;align-items:baseline}#top{height:24px;margin-bottom:2px}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-font-title-s);color:var(--sinch-color-text-default)}#optional{flex:1;text-align:right;font:var(--sinch-font-small-text);color:var(--sinch-color-text-muted)}#additional{flex:1;text-align:right;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-muted);line-height:20px;margin-top:2px}#additional:empty{display:none}#invalid{font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-invalid);line-height:20px;margin-top:2px}#invalid:empty{display:none}::slotted(sinch-help-tooltip){align-self:center;margin:0 8px}:host([disabled]:not([disabled=false])) :is(#label,#additional,#optional,#invalid){color:var(--sinch-color-stormy-100)}:host([disabled]:not([disabled=false])){--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><div id="top"><label id="label" for="button"></label><slot name="tooltip"></slot><span id="optional"></span></div><sinch-dropdown id="dropdown" modal orientation="bottom"><button slot="target" id="button"><span id="content"></span
|
|
15
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateIntegerAttribute } from '../utils';
|
|
16
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-color-icon:var(--sinch-color-stormy-500)}#wrapper{position:relative}sinch-dropdown{display:block}#button{all:initial;display:flex;align-items:center;gap:8px;border:1px solid var(--sinch-color-stormy-200);border-radius:var(--sinch-shape-radius-s);box-sizing:border-box;width:100%;height:48px;padding:8px 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100);cursor:pointer}#button:focus{border-color:var(--sinch-color-stormy-600)}#dropdown-icon{fill:var(--sinch-color-stormy-500)}#button>*{pointer-events:none}#button[data-unselected]{color:var(--sinch-color-text-muted)}#button:disabled{border-color:var(--sinch-color-snow-500);color:var(--sinch-color-stormy-100);cursor:initial}#button:disabled #dropdown-icon{fill:var(--sinch-color-stormy-100)}:host([invalidtext]:not([invalidtext=""])) #button:not(:disabled){border-color:var(--sinch-color-text-invalid)}#content{flex:1;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}#bottom,#top{display:flex;align-items:baseline}#top{height:24px;margin-bottom:2px}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-font-title-s);color:var(--sinch-color-text-default)}#optional{flex:1;text-align:right;font:var(--sinch-font-small-text);color:var(--sinch-color-text-muted)}#additional{flex:1;text-align:right;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-muted);line-height:20px;margin-top:2px}#additional:empty{display:none}#invalid{font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-invalid);line-height:20px;margin-top:2px}#invalid:empty{display:none}::slotted(sinch-help-tooltip){align-self:center;margin:0 8px}:host([disabled]:not([disabled=false])) :is(#label,#additional,#optional,#invalid){color:var(--sinch-color-stormy-100)}:host([disabled]:not([disabled=false])){--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><div id="top"><label id="label" for="button"></label><slot name="tooltip"></slot><span id="optional"></span></div><sinch-dropdown id="dropdown" modal orientation="bottom"><button slot="target" id="button"><span id="content"></span><svg id="dropdown-icon" width="12" height="8" aria-hidden="true"><path d="M1.41.59 6 5.17 10.59.59 12 2 6 8 0 2 1.41.59Z"/></svg></button><slot name="option" slot="option"></slot></sinch-dropdown><div id="bottom"><span id="invalid"></span><span id="additional"></span></div></div>';
|
|
17
17
|
const template = document.createElement('template');
|
|
18
18
|
template.innerHTML = templateHTML;
|
|
19
|
-
defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _$dropdown = new WeakMap(), _$optionSlot = new WeakMap(), _$sh = new WeakMap(), _createElement = new WeakSet(), _updateButtonContent = new WeakSet(), _onValueChange = new WeakMap(), _getOptionWithValue = new WeakSet(), _onLabelClick = new WeakMap(), _onDropdownClick = new WeakMap(), _onDropdownClose = new WeakMap(), class extends NectaryElement {
|
|
19
|
+
defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _$dropdown = new WeakMap(), _$optionSlot = new WeakMap(), _$sh = new WeakMap(), _createElement = new WeakSet(), _updateButtonContent = new WeakSet(), _onValueChange = new WeakMap(), _getOptionWithValue = new WeakSet(), _onLabelClick = new WeakMap(), _onDropdownClick = new WeakMap(), _onDropdownClose = new WeakMap(), _onButtonFocus = new WeakMap(), _onButtonBlur = new WeakMap(), _onChangeReactHandler = new WeakMap(), _onFocusReactHandler = new WeakMap(), _onBlurReactHandler = new WeakMap(), class extends NectaryElement {
|
|
20
20
|
constructor() {
|
|
21
21
|
super();
|
|
22
22
|
|
|
@@ -74,11 +74,15 @@ defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent =
|
|
|
74
74
|
_classPrivateFieldInitSpec(this, _onValueChange, {
|
|
75
75
|
writable: true,
|
|
76
76
|
value: e => {
|
|
77
|
+
const detail = e.detail;
|
|
77
78
|
_classPrivateFieldGet(this, _$dropdown).open = false;
|
|
78
79
|
this.dispatchEvent(new CustomEvent('change', {
|
|
79
|
-
detail
|
|
80
|
+
detail,
|
|
80
81
|
bubbles: true
|
|
81
82
|
}));
|
|
83
|
+
this.dispatchEvent(new CustomEvent('-change', {
|
|
84
|
+
detail
|
|
85
|
+
}));
|
|
82
86
|
}
|
|
83
87
|
});
|
|
84
88
|
|
|
@@ -103,6 +107,41 @@ defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent =
|
|
|
103
107
|
}
|
|
104
108
|
});
|
|
105
109
|
|
|
110
|
+
_classPrivateFieldInitSpec(this, _onButtonFocus, {
|
|
111
|
+
writable: true,
|
|
112
|
+
value: () => {
|
|
113
|
+
this.dispatchEvent(new CustomEvent('-focus'));
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
_classPrivateFieldInitSpec(this, _onButtonBlur, {
|
|
118
|
+
writable: true,
|
|
119
|
+
value: () => {
|
|
120
|
+
this.dispatchEvent(new CustomEvent('-blur'));
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
_classPrivateFieldInitSpec(this, _onChangeReactHandler, {
|
|
125
|
+
writable: true,
|
|
126
|
+
value: e => {
|
|
127
|
+
getReactEventHandler(this, 'on-change')?.(e);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
_classPrivateFieldInitSpec(this, _onFocusReactHandler, {
|
|
132
|
+
writable: true,
|
|
133
|
+
value: () => {
|
|
134
|
+
getReactEventHandler(this, 'on-focus')?.();
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
_classPrivateFieldInitSpec(this, _onBlurReactHandler, {
|
|
139
|
+
writable: true,
|
|
140
|
+
value: () => {
|
|
141
|
+
getReactEventHandler(this, 'on-blur')?.();
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
|
|
106
145
|
const shadowRoot = this.attachShadow();
|
|
107
146
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
108
147
|
|
|
@@ -129,23 +168,39 @@ defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent =
|
|
|
129
168
|
this.setAttribute('role', 'listbox');
|
|
130
169
|
this.setAttribute('aria-haspopup', 'listbox');
|
|
131
170
|
|
|
132
|
-
_classPrivateFieldGet(this, _$dropdown).addEventListener('change', _classPrivateFieldGet(this, _onValueChange));
|
|
171
|
+
_classPrivateFieldGet(this, _$dropdown).addEventListener('-change', _classPrivateFieldGet(this, _onValueChange));
|
|
133
172
|
|
|
134
|
-
_classPrivateFieldGet(this, _$dropdown).addEventListener('close', _classPrivateFieldGet(this, _onDropdownClose));
|
|
173
|
+
_classPrivateFieldGet(this, _$dropdown).addEventListener('-close', _classPrivateFieldGet(this, _onDropdownClose));
|
|
135
174
|
|
|
136
175
|
_classPrivateFieldGet(this, _$button).addEventListener('click', _classPrivateFieldGet(this, _onDropdownClick));
|
|
137
176
|
|
|
177
|
+
_classPrivateFieldGet(this, _$button).addEventListener('focus', _classPrivateFieldGet(this, _onButtonFocus));
|
|
178
|
+
|
|
179
|
+
_classPrivateFieldGet(this, _$button).addEventListener('blur', _classPrivateFieldGet(this, _onButtonBlur));
|
|
180
|
+
|
|
138
181
|
_classPrivateFieldGet(this, _$label).addEventListener('click', _classPrivateFieldGet(this, _onLabelClick));
|
|
182
|
+
|
|
183
|
+
this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
184
|
+
this.addEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
|
|
185
|
+
this.addEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
|
|
139
186
|
}
|
|
140
187
|
|
|
141
188
|
disconnectedCallback() {
|
|
142
|
-
_classPrivateFieldGet(this, _$dropdown).removeEventListener('change', _classPrivateFieldGet(this, _onValueChange));
|
|
189
|
+
_classPrivateFieldGet(this, _$dropdown).removeEventListener('-change', _classPrivateFieldGet(this, _onValueChange));
|
|
143
190
|
|
|
144
|
-
_classPrivateFieldGet(this, _$dropdown).removeEventListener('close', _classPrivateFieldGet(this, _onDropdownClose));
|
|
191
|
+
_classPrivateFieldGet(this, _$dropdown).removeEventListener('-close', _classPrivateFieldGet(this, _onDropdownClose));
|
|
145
192
|
|
|
146
193
|
_classPrivateFieldGet(this, _$button).removeEventListener('click', _classPrivateFieldGet(this, _onDropdownClick));
|
|
147
194
|
|
|
195
|
+
_classPrivateFieldGet(this, _$button).removeEventListener('focus', _classPrivateFieldGet(this, _onButtonFocus));
|
|
196
|
+
|
|
197
|
+
_classPrivateFieldGet(this, _$button).removeEventListener('blur', _classPrivateFieldGet(this, _onButtonBlur));
|
|
198
|
+
|
|
148
199
|
_classPrivateFieldGet(this, _$label).removeEventListener('click', _classPrivateFieldGet(this, _onLabelClick));
|
|
200
|
+
|
|
201
|
+
this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
202
|
+
this.removeEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
|
|
203
|
+
this.removeEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
|
|
149
204
|
}
|
|
150
205
|
|
|
151
206
|
static get observedAttributes() {
|
|
@@ -225,6 +280,10 @@ defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent =
|
|
|
225
280
|
}
|
|
226
281
|
|
|
227
282
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
283
|
+
if (newVal === oldVal) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
|
|
228
287
|
switch (name) {
|
|
229
288
|
case 'value':
|
|
230
289
|
{
|
package/select/types.d.ts
CHANGED
|
@@ -19,7 +19,9 @@ export declare type TSinchSelectElement = HTMLElement & {
|
|
|
19
19
|
maxVisibleItems: number | null;
|
|
20
20
|
readonly dropdownRect: TRect;
|
|
21
21
|
/** Change value event */
|
|
22
|
-
addEventListener(type: 'change', listener: (e: CustomEvent<string>) => void): void;
|
|
22
|
+
addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
|
|
23
|
+
addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
|
|
24
|
+
addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
|
|
23
25
|
/** Value that matches one of the options `value` */
|
|
24
26
|
setAttribute(name: 'value', value: string): void;
|
|
25
27
|
/** Label */
|
|
@@ -57,5 +59,9 @@ export declare type TSinchSelectReact = TSinchElementReact<TSinchSelectElement>
|
|
|
57
59
|
/** Number of visible at the same time options in the list */
|
|
58
60
|
maxVisibleItems?: number;
|
|
59
61
|
/** Change value handler */
|
|
60
|
-
onChange
|
|
62
|
+
onChange?: (e: SyntheticEvent<TSinchSelectElement, CustomEvent<string>>) => void;
|
|
63
|
+
/** Change value handler */
|
|
64
|
+
'on-change'?: (e: CustomEvent<string>) => void;
|
|
65
|
+
'on-focus'?: (e: CustomEvent<void>) => void;
|
|
66
|
+
'on-blur'?: (e: CustomEvent<void>) => void;
|
|
61
67
|
};
|
package/tabs/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
2
1
|
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
3
|
|
|
4
|
-
var _$slot, _onOptionKeyDown, _onSlotChange, _onOptionChange, _onValueChange, _dispatchChangeEvent, _getFirstOption, _getLastOption, _getNextOption, _getPrevOption, _getEnabledRadioElements;
|
|
4
|
+
var _$slot, _onOptionKeyDown, _onSlotChange, _onOptionChange, _onValueChange, _dispatchChangeEvent, _getFirstOption, _getLastOption, _getNextOption, _getPrevOption, _getEnabledRadioElements, _onChangeReactHandler;
|
|
5
5
|
|
|
6
6
|
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
7
7
|
|
|
@@ -11,7 +11,7 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
|
|
|
11
11
|
|
|
12
12
|
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
13
13
|
|
|
14
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
14
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
15
15
|
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:row;height:44px;width:100%;box-sizing:border-box}</style><div id="wrapper"><slot></slot></div>';
|
|
16
16
|
|
|
17
17
|
const findSelectedOption = elements => {
|
|
@@ -20,7 +20,7 @@ const findSelectedOption = elements => {
|
|
|
20
20
|
|
|
21
21
|
const template = document.createElement('template');
|
|
22
22
|
template.innerHTML = templateHTML;
|
|
23
|
-
defineCustomElement('sinch-tabs', (_$slot = new WeakMap(), _onOptionKeyDown = new WeakMap(), _onSlotChange = new WeakMap(), _onOptionChange = new WeakMap(), _onValueChange = new WeakSet(), _dispatchChangeEvent = new WeakSet(), _getFirstOption = new WeakSet(), _getLastOption = new WeakSet(), _getNextOption = new WeakSet(), _getPrevOption = new WeakSet(), _getEnabledRadioElements = new WeakSet(), class extends NectaryElement {
|
|
23
|
+
defineCustomElement('sinch-tabs', (_$slot = new WeakMap(), _onOptionKeyDown = new WeakMap(), _onSlotChange = new WeakMap(), _onOptionChange = new WeakMap(), _onValueChange = new WeakSet(), _dispatchChangeEvent = new WeakSet(), _getFirstOption = new WeakSet(), _getLastOption = new WeakSet(), _getNextOption = new WeakSet(), _getPrevOption = new WeakSet(), _getEnabledRadioElements = new WeakSet(), _onChangeReactHandler = new WeakMap(), class extends NectaryElement {
|
|
24
24
|
constructor() {
|
|
25
25
|
super();
|
|
26
26
|
|
|
@@ -98,18 +98,39 @@ defineCustomElement('sinch-tabs', (_$slot = new WeakMap(), _onOptionKeyDown = ne
|
|
|
98
98
|
}
|
|
99
99
|
});
|
|
100
100
|
|
|
101
|
+
_classPrivateFieldInitSpec(this, _onChangeReactHandler, {
|
|
102
|
+
writable: true,
|
|
103
|
+
value: e => {
|
|
104
|
+
getReactEventHandler(this, 'on-change')?.(e);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
101
108
|
const shadowRoot = this.attachShadow();
|
|
102
109
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
103
|
-
shadowRoot.addEventListener('keydown', _classPrivateFieldGet(this, _onOptionKeyDown));
|
|
104
|
-
shadowRoot.addEventListener('change', _classPrivateFieldGet(this, _onOptionChange));
|
|
105
110
|
|
|
106
111
|
_classPrivateFieldSet(this, _$slot, shadowRoot.querySelector('slot'));
|
|
107
|
-
|
|
108
|
-
_classPrivateFieldGet(this, _$slot).addEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
|
|
109
112
|
}
|
|
110
113
|
|
|
111
114
|
connectedCallback() {
|
|
112
115
|
this.setAttribute('role', 'tablist');
|
|
116
|
+
|
|
117
|
+
_classPrivateFieldGet(this, _$slot).addEventListener('keydown', _classPrivateFieldGet(this, _onOptionKeyDown));
|
|
118
|
+
|
|
119
|
+
_classPrivateFieldGet(this, _$slot).addEventListener('option-change', _classPrivateFieldGet(this, _onOptionChange));
|
|
120
|
+
|
|
121
|
+
_classPrivateFieldGet(this, _$slot).addEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
|
|
122
|
+
|
|
123
|
+
this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
disconnectedCallback() {
|
|
127
|
+
_classPrivateFieldGet(this, _$slot).removeEventListener('keydown', _classPrivateFieldGet(this, _onOptionKeyDown));
|
|
128
|
+
|
|
129
|
+
_classPrivateFieldGet(this, _$slot).removeEventListener('option-change', _classPrivateFieldGet(this, _onOptionChange));
|
|
130
|
+
|
|
131
|
+
_classPrivateFieldGet(this, _$slot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
|
|
132
|
+
|
|
133
|
+
this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
113
134
|
}
|
|
114
135
|
|
|
115
136
|
static get observedAttributes() {
|
|
@@ -153,6 +174,9 @@ function _dispatchChangeEvent2(value) {
|
|
|
153
174
|
detail: value,
|
|
154
175
|
bubbles: true
|
|
155
176
|
}));
|
|
177
|
+
this.dispatchEvent(new CustomEvent('-change', {
|
|
178
|
+
detail: value
|
|
179
|
+
}));
|
|
156
180
|
}
|
|
157
181
|
|
|
158
182
|
function _getFirstOption2() {
|
package/tabs/types.d.ts
CHANGED
|
@@ -2,11 +2,12 @@ import type { TSinchElementReact } from '../types';
|
|
|
2
2
|
import type { SyntheticEvent } from 'react';
|
|
3
3
|
export declare type TSinchTabsElement = HTMLElement & {
|
|
4
4
|
value: string;
|
|
5
|
-
addEventListener(type: 'change', listener: (e: CustomEvent<string>) => void): void;
|
|
5
|
+
addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
|
|
6
6
|
setAttribute(name: 'value', value: string): void;
|
|
7
7
|
};
|
|
8
8
|
export declare type TSinchTabsReact = TSinchElementReact<TSinchTabsElement> & {
|
|
9
9
|
value: string;
|
|
10
10
|
'aria-label': string;
|
|
11
|
-
onChange
|
|
11
|
+
onChange?: (event: SyntheticEvent<TSinchTabsElement, CustomEvent<string>>) => void;
|
|
12
|
+
'on-change'?: (e: CustomEvent<string>) => void;
|
|
12
13
|
};
|
package/tabs-option/index.js
CHANGED
|
@@ -8,7 +8,7 @@ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedec
|
|
|
8
8
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
9
9
|
|
|
10
10
|
import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
11
|
-
const templateHTML = '<style>:host{display:block;outline:0}:host()>*{pointer-events:none}#wrapper{display:flex;flex-direction:row;align-items:center;gap:12px;position:relative;width:100%;height:42px;padding:8px 20px;box-sizing:border-box;box-shadow:0 1px 0 0 var(--sinch-color-stormy-100);color:var(--sinch-color-stormy-500);background-color:var(--sinch-color-snow-100);--sinch-color-icon:var(--sinch-color-stormy-500);--sinch-size-icon:16px}#content{font:var(--sinch-font-title-s);flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host([checked]:not([checked=false])) #wrapper{box-shadow:0 2px 0 0 var(--sinch-color-stormy-500)}#button{all:initial;position:absolute;left:0;top:0;box-sizing:border-box;width:100%;height:100%;cursor:pointer}#button:disabled{cursor:unset}:host([disabled]:not([disabled=false])) #wrapper{color:var(--sinch-color-stormy-100);--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><slot name="icon"></slot><label for="input" id="content"></label
|
|
11
|
+
const templateHTML = '<style>:host{display:block;outline:0}:host()>*{pointer-events:none}#wrapper{display:flex;flex-direction:row;align-items:center;gap:12px;position:relative;width:100%;height:42px;padding:8px 20px;box-sizing:border-box;box-shadow:0 1px 0 0 var(--sinch-color-stormy-100);color:var(--sinch-color-stormy-500);background-color:var(--sinch-color-snow-100);--sinch-color-icon:var(--sinch-color-stormy-500);--sinch-size-icon:16px}#content{font:var(--sinch-font-title-s);flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host([checked]:not([checked=false])) #wrapper{box-shadow:0 2px 0 0 var(--sinch-color-stormy-500)}#button{all:initial;position:absolute;left:0;top:0;box-sizing:border-box;width:100%;height:100%;cursor:pointer}#button:disabled{cursor:unset}:host([disabled]:not([disabled=false])) #wrapper{color:var(--sinch-color-stormy-100);--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><slot name="icon"></slot><label for="input" id="content"></label><button id="button" type="radio"/></div>';
|
|
12
12
|
const template = document.createElement('template');
|
|
13
13
|
template.innerHTML = templateHTML;
|
|
14
14
|
defineCustomElement('sinch-tabs-option', (_$button = new WeakMap(), _$label = new WeakMap(), _onClick = new WeakMap(), class extends NectaryElement {
|
|
@@ -29,7 +29,7 @@ defineCustomElement('sinch-tabs-option', (_$button = new WeakMap(), _$label = ne
|
|
|
29
29
|
writable: true,
|
|
30
30
|
value: e => {
|
|
31
31
|
e.stopPropagation();
|
|
32
|
-
this.dispatchEvent(new CustomEvent('change', {
|
|
32
|
+
this.dispatchEvent(new CustomEvent('option-change', {
|
|
33
33
|
bubbles: true,
|
|
34
34
|
detail: this.value
|
|
35
35
|
}));
|
package/text/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '../icons/cancel';
|
|
2
2
|
import { defineCustomElement, getBooleanAttribute, updateBooleanAttribute, NectaryElement, getLiteralAttribute, updateLiteralAttribute, isAttrTrue } from '../utils';
|
|
3
|
-
const templateHTML = '<style>:host{display:block;font:var(--sinch-font-text-m)}:host([inline]:not([inline=false])){display:inline}:host([
|
|
3
|
+
const templateHTML = '<style>:host{display:block;font:var(--sinch-font-text-m)}:host([inline]:not([inline=false])){display:inline}:host([type="s"]){font:var(--sinch-font-text-s)}:host([type=xs]){font:var(--sinch-font-text-xs)}:host([type=xxs]){font:var(--sinch-font-text-xxs)}:host([emphasized]:not([emphasized=false])){font-weight:var(--sinch-font-weight-emphasized)}</style><slot></slot>';
|
|
4
4
|
import { assertType, typeValues } from './utils';
|
|
5
5
|
const template = document.createElement('template');
|
|
6
6
|
template.innerHTML = templateHTML;
|
package/textarea/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
2
|
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
3
|
|
|
4
|
-
var _$input, _$label, _$optionalText, _$additionalText, _$invalidText, _cursorPos, _isPendingDk, _onCompositionStart, _onSelectionChange, _onInput;
|
|
4
|
+
var _$input, _$label, _$optionalText, _$additionalText, _$invalidText, _cursorPos, _isPendingDk, _onCompositionStart, _onSelectionChange, _onInput, _onInputFocus, _onInputBlur, _onChangeReactHandler, _onFocusReactHandler, _onBlurReactHandler;
|
|
5
5
|
|
|
6
6
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
7
7
|
|
|
8
8
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
9
9
|
|
|
10
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
11
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-color-icon:var(--sinch-color-stormy-500)}#wrapper{width:100%;box-sizing:border-box}#input{all:initial;border:1px solid var(--sinch-color-stormy-200);box-sizing:border-box;border-radius:var(--sinch-shape-radius-s);width:100%;padding:8px 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto);background-color:var(--sinch-color-snow-100);resize:none}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted)}#input:disabled{border-color:var(--sinch-color-snow-500);color:var(--sinch-color-stormy-100)}#input:disabled::placeholder{color:var(--sinch-color-snow-500)}#input:focus{border-color:var(--sinch-color-stormy-600)}:host([resizable]:not([resizable=false])) #input{resize:vertical}:host([invalidtext]:not([invalidtext=""])) #input:not(:disabled){border-color:var(--sinch-color-text-invalid)}#bottom,#top{display:flex;align-items:baseline}#top{height:24px;margin-bottom:2px}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-font-title-s);color:var(--sinch-color-text-default)}#optional{flex:1;text-align:right;font:var(--sinch-font-small-text);color:var(--sinch-color-text-muted)}#additional{flex:1;text-align:right;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-muted);line-height:20px;margin-top:2px}#additional:empty{display:none}#invalid{font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-invalid);line-height:20px;margin-top:2px}#invalid:empty{display:none}::slotted(sinch-help-tooltip){align-self:center;margin:0 8px}:host([disabled]:not([disabled=false])) :is(#label,#additional,#optional,#invalid){color:var(--sinch-color-stormy-100)}:host([disabled]:not([disabled=false])){--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><div id="top"><label id="label" for="input"></label><slot name="tooltip"></slot><span id="optional"></span></div><textarea id="input"></textarea><div id="bottom"><span id="invalid"></span
|
|
10
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
11
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-color-icon:var(--sinch-color-stormy-500)}#wrapper{width:100%;box-sizing:border-box}#input{all:initial;display:block;border:1px solid var(--sinch-color-stormy-200);box-sizing:border-box;border-radius:var(--sinch-shape-radius-s);width:100%;padding:8px 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto);background-color:var(--sinch-color-snow-100);resize:none}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted)}#input:disabled{border-color:var(--sinch-color-snow-500);color:var(--sinch-color-stormy-100)}#input:disabled::placeholder{color:var(--sinch-color-snow-500)}#input:focus{border-color:var(--sinch-color-stormy-600)}:host([resizable]:not([resizable=false])) #input{resize:vertical}:host([invalidtext]:not([invalidtext=""])) #input:not(:disabled){border-color:var(--sinch-color-text-invalid)}#bottom,#top{display:flex;align-items:baseline}#top{height:24px;margin-bottom:2px}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-font-title-s);color:var(--sinch-color-text-default)}#optional{flex:1;text-align:right;font:var(--sinch-font-small-text);color:var(--sinch-color-text-muted)}#additional{flex:1;text-align:right;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-muted);line-height:20px;margin-top:2px}#additional:empty{display:none}#invalid{font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-invalid);line-height:20px;margin-top:2px}#invalid:empty{display:none}::slotted(sinch-help-tooltip){align-self:center;margin:0 8px}:host([disabled]:not([disabled=false])) :is(#label,#additional,#optional,#invalid){color:var(--sinch-color-stormy-100)}:host([disabled]:not([disabled=false])){--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><div id="top"><label id="label" for="input"></label><slot name="tooltip"></slot><span id="optional"></span></div><textarea id="input"></textarea><div id="bottom"><span id="invalid"></span><span id="additional"></span></div></div>';
|
|
12
12
|
const template = document.createElement('template');
|
|
13
13
|
template.innerHTML = templateHTML;
|
|
14
|
-
defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _cursorPos = new WeakMap(), _isPendingDk = new WeakMap(), _onCompositionStart = new WeakMap(), _onSelectionChange = new WeakMap(), _onInput = new WeakMap(), class extends NectaryElement {
|
|
14
|
+
defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _cursorPos = new WeakMap(), _isPendingDk = new WeakMap(), _onCompositionStart = new WeakMap(), _onSelectionChange = new WeakMap(), _onInput = new WeakMap(), _onInputFocus = new WeakMap(), _onInputBlur = new WeakMap(), _onChangeReactHandler = new WeakMap(), _onFocusReactHandler = new WeakMap(), _onBlurReactHandler = new WeakMap(), class extends NectaryElement {
|
|
15
15
|
constructor() {
|
|
16
16
|
super();
|
|
17
17
|
|
|
@@ -96,10 +96,48 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
|
|
|
96
96
|
detail: nextValue,
|
|
97
97
|
bubbles: true
|
|
98
98
|
}));
|
|
99
|
+
this.dispatchEvent(new CustomEvent('-change', {
|
|
100
|
+
detail: nextValue
|
|
101
|
+
}));
|
|
99
102
|
}
|
|
100
103
|
}
|
|
101
104
|
});
|
|
102
105
|
|
|
106
|
+
_classPrivateFieldInitSpec(this, _onInputFocus, {
|
|
107
|
+
writable: true,
|
|
108
|
+
value: () => {
|
|
109
|
+
this.dispatchEvent(new CustomEvent('-focus'));
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
_classPrivateFieldInitSpec(this, _onInputBlur, {
|
|
114
|
+
writable: true,
|
|
115
|
+
value: () => {
|
|
116
|
+
this.dispatchEvent(new CustomEvent('-blur'));
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
_classPrivateFieldInitSpec(this, _onChangeReactHandler, {
|
|
121
|
+
writable: true,
|
|
122
|
+
value: e => {
|
|
123
|
+
getReactEventHandler(this, 'on-change')?.(e);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
_classPrivateFieldInitSpec(this, _onFocusReactHandler, {
|
|
128
|
+
writable: true,
|
|
129
|
+
value: () => {
|
|
130
|
+
getReactEventHandler(this, 'on-focus')?.();
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
_classPrivateFieldInitSpec(this, _onBlurReactHandler, {
|
|
135
|
+
writable: true,
|
|
136
|
+
value: () => {
|
|
137
|
+
getReactEventHandler(this, 'on-blur')?.();
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
|
|
103
141
|
const shadowRoot = this.attachShadow();
|
|
104
142
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
105
143
|
|
|
@@ -125,6 +163,14 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
|
|
|
125
163
|
_classPrivateFieldGet(this, _$input).addEventListener('mousedown', _classPrivateFieldGet(this, _onSelectionChange));
|
|
126
164
|
|
|
127
165
|
_classPrivateFieldGet(this, _$input).addEventListener('keydown', _classPrivateFieldGet(this, _onSelectionChange));
|
|
166
|
+
|
|
167
|
+
_classPrivateFieldGet(this, _$input).addEventListener('focus', _classPrivateFieldGet(this, _onInputFocus));
|
|
168
|
+
|
|
169
|
+
_classPrivateFieldGet(this, _$input).addEventListener('blur', _classPrivateFieldGet(this, _onInputBlur));
|
|
170
|
+
|
|
171
|
+
this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
172
|
+
this.addEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
|
|
173
|
+
this.addEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
|
|
128
174
|
}
|
|
129
175
|
|
|
130
176
|
disconnectedCallback() {
|
|
@@ -135,6 +181,14 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
|
|
|
135
181
|
_classPrivateFieldGet(this, _$input).removeEventListener('mousedown', _classPrivateFieldGet(this, _onSelectionChange));
|
|
136
182
|
|
|
137
183
|
_classPrivateFieldGet(this, _$input).removeEventListener('keydown', _classPrivateFieldGet(this, _onSelectionChange));
|
|
184
|
+
|
|
185
|
+
_classPrivateFieldGet(this, _$input).removeEventListener('focus', _classPrivateFieldGet(this, _onInputFocus));
|
|
186
|
+
|
|
187
|
+
_classPrivateFieldGet(this, _$input).removeEventListener('blur', _classPrivateFieldGet(this, _onInputBlur));
|
|
188
|
+
|
|
189
|
+
this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
190
|
+
this.removeEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
|
|
191
|
+
this.removeEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
|
|
138
192
|
}
|
|
139
193
|
|
|
140
194
|
static get observedAttributes() {
|
package/textarea/types.d.ts
CHANGED
|
@@ -13,7 +13,9 @@ export declare type TSinchTextareaElement = HTMLElement & {
|
|
|
13
13
|
selectionDirection: HTMLTextAreaElement['selectionDirection'];
|
|
14
14
|
rows: HTMLTextAreaElement['rows'];
|
|
15
15
|
resizable: boolean;
|
|
16
|
-
addEventListener(type: 'change', listener: (e: CustomEvent<string>) => void): void;
|
|
16
|
+
addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
|
|
17
|
+
addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
|
|
18
|
+
addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
|
|
17
19
|
setAttribute(name: 'value', value: string): void;
|
|
18
20
|
setAttribute(name: 'label', value: string): void;
|
|
19
21
|
setAttribute(name: 'placeholder', value: string): void;
|
|
@@ -35,5 +37,8 @@ export declare type TSinchTextareaReact = TSinchElementReact<TSinchTextareaEleme
|
|
|
35
37
|
'aria-label': string;
|
|
36
38
|
rows?: number;
|
|
37
39
|
resizable?: boolean;
|
|
38
|
-
onChange
|
|
40
|
+
onChange?: (e: SyntheticEvent<TSinchTextareaElement, CustomEvent<string>>) => void;
|
|
41
|
+
'on-change'?: (e: CustomEvent<string>) => void;
|
|
42
|
+
'on-focus'?: (e: CustomEvent<void>) => void;
|
|
43
|
+
'on-blur'?: (e: CustomEvent<void>) => void;
|
|
39
44
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TSinchTileControlElement, TSinchTileControlReact } from './types';
|
|
2
|
+
declare global {
|
|
3
|
+
namespace JSX {
|
|
4
|
+
interface IntrinsicElements {
|
|
5
|
+
'sinch-tile-control': TSinchTileControlReact;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
interface HTMLElementTagNameMap {
|
|
9
|
+
'sinch-tile-control': TSinchTileControlElement;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
+
|
|
4
|
+
var _$slot, _onSlotChange, _onOptionChange, _onValueChange, _onSmallChange, _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
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getCsvSet, getFirstCsvValue, getIntegerAttribute, getReactEventHandler, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv, updateIntegerAttribute } from '../utils';
|
|
15
|
+
const templateHTML = '<style>:host{display:block;outline:0;--sinch-grid-num-columns:1}#wrapper{display:grid;grid-template-columns:repeat(var(--sinch-grid-num-columns),auto);gap:16px;width:fit-content}:host([small]:not([small=false])) #wrapper{gap:8px}:host([cols="2"]){--sinch-grid-num-columns:2}:host([cols="3"]){--sinch-grid-num-columns:3}:host([cols="4"]){--sinch-grid-num-columns:4}:host([cols="5"]){--sinch-grid-num-columns:5}:host([cols="6"]){--sinch-grid-num-columns:6}:host([cols="7"]){--sinch-grid-num-columns:7}:host([cols="8"]){--sinch-grid-num-columns:8}</style><div id="wrapper"><slot></slot></div>';
|
|
16
|
+
const template = document.createElement('template');
|
|
17
|
+
template.innerHTML = templateHTML;
|
|
18
|
+
defineCustomElement('sinch-tile-control', (_$slot = new WeakMap(), _onSlotChange = new WeakMap(), _onOptionChange = new WeakMap(), _onValueChange = new WeakSet(), _onSmallChange = new WeakSet(), _onChangeReactHandler = new WeakMap(), class extends NectaryElement {
|
|
19
|
+
constructor() {
|
|
20
|
+
super();
|
|
21
|
+
|
|
22
|
+
_classPrivateMethodInitSpec(this, _onSmallChange);
|
|
23
|
+
|
|
24
|
+
_classPrivateMethodInitSpec(this, _onValueChange);
|
|
25
|
+
|
|
26
|
+
_classPrivateFieldInitSpec(this, _$slot, {
|
|
27
|
+
writable: true,
|
|
28
|
+
value: void 0
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
_classPrivateFieldInitSpec(this, _onSlotChange, {
|
|
32
|
+
writable: true,
|
|
33
|
+
value: () => {
|
|
34
|
+
_classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, this.value);
|
|
35
|
+
|
|
36
|
+
_classPrivateMethodGet(this, _onSmallChange, _onSmallChange2).call(this);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
_classPrivateFieldInitSpec(this, _onOptionChange, {
|
|
41
|
+
writable: true,
|
|
42
|
+
value: e => {
|
|
43
|
+
e.stopPropagation();
|
|
44
|
+
const $elem = e.target;
|
|
45
|
+
const value = e.detail;
|
|
46
|
+
const detail = this.multiple ? updateCsv(this.value, value, !getBooleanAttribute($elem, 'data-checked')) : value;
|
|
47
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
48
|
+
detail,
|
|
49
|
+
bubbles: true
|
|
50
|
+
}));
|
|
51
|
+
this.dispatchEvent(new CustomEvent('-change', {
|
|
52
|
+
detail
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
_classPrivateFieldInitSpec(this, _onChangeReactHandler, {
|
|
58
|
+
writable: true,
|
|
59
|
+
value: e => {
|
|
60
|
+
getReactEventHandler(this, 'on-change')?.(e);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const shadowRoot = this.attachShadow();
|
|
65
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
66
|
+
|
|
67
|
+
_classPrivateFieldSet(this, _$slot, shadowRoot.querySelector('slot'));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
connectedCallback() {
|
|
71
|
+
this.setAttribute('role', 'tablist');
|
|
72
|
+
|
|
73
|
+
_classPrivateFieldGet(this, _$slot).addEventListener('option-change', _classPrivateFieldGet(this, _onOptionChange));
|
|
74
|
+
|
|
75
|
+
_classPrivateFieldGet(this, _$slot).addEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
|
|
76
|
+
|
|
77
|
+
this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
disconnectedCallback() {
|
|
81
|
+
_classPrivateFieldGet(this, _$slot).removeEventListener('option-change', _classPrivateFieldGet(this, _onOptionChange));
|
|
82
|
+
|
|
83
|
+
_classPrivateFieldGet(this, _$slot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
|
|
84
|
+
|
|
85
|
+
this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
static get observedAttributes() {
|
|
89
|
+
return ['value', 'small', 'multiple'];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
get nodeName() {
|
|
93
|
+
return 'select';
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
set value(value) {
|
|
97
|
+
updateAttribute(this, 'value', value);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
get value() {
|
|
101
|
+
return getAttribute(this, 'value', '');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
set small(isSmall) {
|
|
105
|
+
updateBooleanAttribute(this, 'small', isSmall);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
get small() {
|
|
109
|
+
return getBooleanAttribute(this, 'small');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
set multiple(isMultiple) {
|
|
113
|
+
updateBooleanAttribute(this, 'multiple', isMultiple);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
get multiple() {
|
|
117
|
+
return getBooleanAttribute(this, 'multiple');
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
set cols(value) {
|
|
121
|
+
updateIntegerAttribute(this, 'cols', value);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
get cols() {
|
|
125
|
+
return getIntegerAttribute(this, 'cols', 1);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
129
|
+
if (oldVal === newVal) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
switch (name) {
|
|
134
|
+
case 'value':
|
|
135
|
+
{
|
|
136
|
+
_classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, newVal ?? '');
|
|
137
|
+
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
case 'small':
|
|
142
|
+
{
|
|
143
|
+
_classPrivateMethodGet(this, _onSmallChange, _onSmallChange2).call(this);
|
|
144
|
+
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
case 'multiple':
|
|
149
|
+
{
|
|
150
|
+
_classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, this.value);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
}));
|
|
156
|
+
|
|
157
|
+
function _onValueChange2(csv) {
|
|
158
|
+
if (this.multiple) {
|
|
159
|
+
const values = getCsvSet(csv);
|
|
160
|
+
|
|
161
|
+
for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements()) {
|
|
162
|
+
const isChecked = !getBooleanAttribute($option, 'disabled') && values.has(getAttribute($option, 'value', ''));
|
|
163
|
+
updateBooleanAttribute($option, 'data-checked', isChecked);
|
|
164
|
+
}
|
|
165
|
+
} else {
|
|
166
|
+
const value = getFirstCsvValue(csv);
|
|
167
|
+
|
|
168
|
+
for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements()) {
|
|
169
|
+
const isChecked = !getBooleanAttribute($option, 'disabled') && value === getAttribute($option, 'value', '');
|
|
170
|
+
updateBooleanAttribute($option, 'data-checked', isChecked);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function _onSmallChange2() {
|
|
176
|
+
const isSmall = this.small;
|
|
177
|
+
|
|
178
|
+
for (const $opt of _classPrivateFieldGet(this, _$slot).assignedElements()) {
|
|
179
|
+
updateBooleanAttribute($opt, 'data-small', isSmall);
|
|
180
|
+
}
|
|
181
|
+
}
|