@nectary/components 0.38.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/types.d.ts +1 -0
- 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.d.ts +2 -0
- package/card/index.js +24 -87
- 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 +196 -287
- package/date-picker/types.d.ts +25 -1
- package/dialog/index.d.ts +1 -0
- package/dialog/index.js +72 -143
- 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 +30 -82
- 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/pagination/types.d.ts +1 -0
- package/popover/index.js +224 -294
- package/progress/index.js +9 -28
- package/radio/index.js +103 -169
- package/radio/types.d.ts +1 -0
- package/radio-option/index.js +24 -48
- package/segment/index.js +50 -131
- package/segment-collapse/index.js +24 -49
- package/segment-collapse/types.d.ts +1 -0
- package/segmented-control/index.js +36 -73
- package/segmented-control/types.d.ts +1 -0
- package/segmented-control-option/index.js +41 -87
- package/segmented-icon-control/index.js +47 -84
- package/segmented-icon-control/types.d.ts +1 -0
- 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/{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/types.d.ts +1 -0
- package/tabs-option/index.js +20 -44
- package/tag/index.d.ts +1 -1
- package/tag/index.js +42 -36
- 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 +224 -368
- package/time-picker/types.d.ts +5 -1
- package/title/index.js +6 -20
- package/toast/index.d.ts +17 -0
- package/toast/index.js +115 -0
- package/toast/types.d.ts +28 -0
- package/toast/utils.d.ts +5 -0
- package/toast/utils.js +6 -0
- package/toast-manager/index.d.ts +17 -0
- package/toast-manager/index.js +195 -0
- package/toast-manager/types.d.ts +7 -0
- package/toggle/index.js +55 -108
- package/toggle/types.d.ts +1 -0
- 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} +18 -9
- package/{utils.js → utils/index.js} +118 -39
- package/vertical-stepper/index.js +29 -50
- package/vertical-stepper-item/index.js +13 -37
- package/card-button/index.d.ts +0 -11
- package/card-button/index.js +0 -77
- package/card-button/types.d.ts +0 -12
- package/card-link/index.d.ts +0 -12
- package/card-link/index.js +0 -115
- package/card-link/types.d.ts +0 -14
- package/dropdown/index.d.ts +0 -12
- package/dropdown/index.js +0 -415
- package/dropdown/types.d.ts +0 -30
- package/dropdown-text-option/index.js +0 -104
- package/dropdown-text-option/types.d.ts +0 -16
- package/search/index.d.ts +0 -14
- package/search/index.js +0 -523
- package/search/types.d.ts +0 -25
- package/search-option/index.d.ts +0 -11
- package/search-option/index.js +0 -55
- package/search-option/types.d.ts +0 -9
- 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 -2
- package/tag/utils.js +0 -1
- package/tag-close/index.d.ts +0 -12
- package/tag-close/index.js +0 -38
- package/tag-close/types.d.ts +0 -3
- package/tag-close/types.js +0 -1
- /package/{card-button → chip}/types.js +0 -0
- /package/{card-link → color-menu}/types.js +0 -0
- /package/{dropdown-text-option → color-swatch}/types.js +0 -0
- /package/{dropdown → select-button}/types.js +0 -0
- /package/{search → select-menu}/types.js +0 -0
- /package/{search-option → select-menu-option}/types.js +0 -0
- /package/{select → toast}/types.js +0 -0
- /package/{select-option → toast-manager}/types.js +0 -0
package/link/index.js
CHANGED
|
@@ -1,110 +1,38 @@
|
|
|
1
|
-
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
-
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
-
|
|
4
|
-
var _$anchor, _$text, _onAnchorClick, _onAnchorFocus, _onAnchorBlur, _onFocusReactHandler, _onBlurReactHandler, _onClickReactHandler;
|
|
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/open-in-new';
|
|
11
2
|
import '../icons/arrow-forward';
|
|
12
3
|
import { defineCustomElement, getBooleanAttribute, getAttribute, updateBooleanAttribute, updateAttribute, NectaryElement, isAttrTrue, getReactEventHandler } from '../utils';
|
|
13
4
|
const templateHTML = '<style>:host{display:inline}a{font:var(--sinch-font-text-m);font-size:inherit;line-height:inherit;color:var(--sinch-color-tropical-500);border-radius:.5em;--sinch-size-icon:1em;--sinch-color-icon:var(--sinch-color-tropical-500)}a:hover{color:var(--sinch-color-tropical-600);--sinch-color-icon:var(--sinch-color-tropical-600)}a:focus-visible{outline:2px solid var(--sinch-color-aqua-400);outline-offset:2px}@supports not selector(:focus-visible){a:focus{outline:2px solid var(--sinch-color-aqua-400);outline-offset:2px}}#external-icon{display:none;margin-right:.2em;vertical-align:-.2em}#standalone-icon{display:none}:host([external]:not([external=false])) #external-icon{display:inline-block}:host([standalone]:not([standalone=false])){display:block}:host([standalone]:not([standalone=false])) a{display:block;font:var(--sinch-font-text-m);font-weight:var(--sinch-font-weight-emphasized);text-decoration:none;border-radius:var(--sinch-shape-radius-m);width:fit-content;--sinch-size-icon:24px}:host([standalone]:not([standalone=false])) #external-icon{margin-right:8px;vertical-align:-7px}:host([standalone]:not([standalone=false]):is([external=false],:not([external]))) #standalone-icon{display:inline-block;vertical-align:-7px;margin-left:8px}:host([disabled]:not([disabled=false])) a{color:var(--sinch-color-tropical-200);pointer-events:none;cursor:initial;--sinch-color-icon:var(--sinch-color-tropical-200)}</style><a referrerpolicy="no-referer" aria-hidden="true"><sinch-icon-open-in-new id="external-icon"></sinch-icon-open-in-new><span id="content"></span><sinch-icon-arrow-forward id="standalone-icon"></sinch-icon-arrow-forward></a>';
|
|
14
5
|
const template = document.createElement('template');
|
|
15
6
|
template.innerHTML = templateHTML;
|
|
16
|
-
defineCustomElement('sinch-link',
|
|
7
|
+
defineCustomElement('sinch-link', class extends NectaryElement {
|
|
8
|
+
#$anchor;
|
|
9
|
+
#$text;
|
|
10
|
+
|
|
17
11
|
constructor() {
|
|
18
12
|
super();
|
|
19
|
-
|
|
20
|
-
_classPrivateFieldInitSpec(this, _$anchor, {
|
|
21
|
-
writable: true,
|
|
22
|
-
value: void 0
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
_classPrivateFieldInitSpec(this, _$text, {
|
|
26
|
-
writable: true,
|
|
27
|
-
value: void 0
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
_classPrivateFieldInitSpec(this, _onAnchorClick, {
|
|
31
|
-
writable: true,
|
|
32
|
-
value: e => {
|
|
33
|
-
if (this.preventDefault) {
|
|
34
|
-
e.preventDefault();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
this.dispatchEvent(new CustomEvent('-click'));
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
_classPrivateFieldInitSpec(this, _onAnchorFocus, {
|
|
42
|
-
writable: true,
|
|
43
|
-
value: () => {
|
|
44
|
-
this.dispatchEvent(new CustomEvent('-focus'));
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
_classPrivateFieldInitSpec(this, _onAnchorBlur, {
|
|
49
|
-
writable: true,
|
|
50
|
-
value: () => {
|
|
51
|
-
this.dispatchEvent(new CustomEvent('-blur'));
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
_classPrivateFieldInitSpec(this, _onFocusReactHandler, {
|
|
56
|
-
writable: true,
|
|
57
|
-
value: () => {
|
|
58
|
-
getReactEventHandler(this, 'on-focus')?.();
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
_classPrivateFieldInitSpec(this, _onBlurReactHandler, {
|
|
63
|
-
writable: true,
|
|
64
|
-
value: () => {
|
|
65
|
-
getReactEventHandler(this, 'on-blur')?.();
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
_classPrivateFieldInitSpec(this, _onClickReactHandler, {
|
|
70
|
-
writable: true,
|
|
71
|
-
value: e => {
|
|
72
|
-
getReactEventHandler(this, 'on-click')?.(e);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
|
|
76
13
|
const shadowRoot = this.attachShadow();
|
|
77
14
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
_classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#content'));
|
|
15
|
+
this.#$anchor = shadowRoot.querySelector('a');
|
|
16
|
+
this.#$text = shadowRoot.querySelector('#content');
|
|
82
17
|
}
|
|
83
18
|
|
|
84
19
|
connectedCallback() {
|
|
85
20
|
this.setAttribute('role', 'link');
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
this.addEventListener('-click', _classPrivateFieldGet(this, _onClickReactHandler));
|
|
94
|
-
this.addEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
|
|
95
|
-
this.addEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
|
|
21
|
+
this.#$anchor.addEventListener('click', this.#onAnchorClick);
|
|
22
|
+
this.#$anchor.addEventListener('focus', this.#onAnchorFocus);
|
|
23
|
+
this.#$anchor.addEventListener('blur', this.#onAnchorBlur);
|
|
24
|
+
this.addEventListener('-click', this.#onClickReactHandler);
|
|
25
|
+
this.addEventListener('-focus', this.#onFocusReactHandler);
|
|
26
|
+
this.addEventListener('-blur', this.#onBlurReactHandler);
|
|
96
27
|
}
|
|
97
28
|
|
|
98
29
|
disconnectedCallback() {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
this.removeEventListener('-click', _classPrivateFieldGet(this, _onClickReactHandler));
|
|
106
|
-
this.removeEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
|
|
107
|
-
this.removeEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
|
|
30
|
+
this.#$anchor.removeEventListener('click', this.#onAnchorClick);
|
|
31
|
+
this.#$anchor.removeEventListener('focus', this.#onAnchorFocus);
|
|
32
|
+
this.#$anchor.removeEventListener('blur', this.#onAnchorBlur);
|
|
33
|
+
this.removeEventListener('-click', this.#onClickReactHandler);
|
|
34
|
+
this.removeEventListener('-focus', this.#onFocusReactHandler);
|
|
35
|
+
this.removeEventListener('-blur', this.#onBlurReactHandler);
|
|
108
36
|
}
|
|
109
37
|
|
|
110
38
|
get text() {
|
|
@@ -167,30 +95,52 @@ defineCustomElement('sinch-link', (_$anchor = new WeakMap(), _$text = new WeakMa
|
|
|
167
95
|
switch (name) {
|
|
168
96
|
case 'text':
|
|
169
97
|
{
|
|
170
|
-
|
|
98
|
+
this.#$text.textContent = newVal;
|
|
171
99
|
break;
|
|
172
100
|
}
|
|
173
101
|
|
|
174
102
|
case 'href':
|
|
175
103
|
{
|
|
176
|
-
updateAttribute(
|
|
104
|
+
updateAttribute(this.#$anchor, 'href', newVal);
|
|
177
105
|
break;
|
|
178
106
|
}
|
|
179
107
|
|
|
180
108
|
case 'external':
|
|
181
109
|
{
|
|
182
|
-
updateAttribute(
|
|
110
|
+
updateAttribute(this.#$anchor, 'target', isAttrTrue(newVal) ? '_blank' : null);
|
|
183
111
|
break;
|
|
184
112
|
}
|
|
185
113
|
}
|
|
186
114
|
}
|
|
187
115
|
|
|
188
116
|
focus() {
|
|
189
|
-
|
|
117
|
+
this.#$anchor.focus();
|
|
190
118
|
}
|
|
191
119
|
|
|
192
120
|
blur() {
|
|
193
|
-
|
|
121
|
+
this.#$anchor.blur();
|
|
194
122
|
}
|
|
195
123
|
|
|
196
|
-
|
|
124
|
+
#onAnchorClick = e => {
|
|
125
|
+
if (this.preventDefault) {
|
|
126
|
+
e.preventDefault();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
this.dispatchEvent(new CustomEvent('-click'));
|
|
130
|
+
};
|
|
131
|
+
#onAnchorFocus = () => {
|
|
132
|
+
this.dispatchEvent(new CustomEvent('-focus'));
|
|
133
|
+
};
|
|
134
|
+
#onAnchorBlur = () => {
|
|
135
|
+
this.dispatchEvent(new CustomEvent('-blur'));
|
|
136
|
+
};
|
|
137
|
+
#onFocusReactHandler = () => {
|
|
138
|
+
getReactEventHandler(this, 'on-focus')?.();
|
|
139
|
+
};
|
|
140
|
+
#onBlurReactHandler = () => {
|
|
141
|
+
getReactEventHandler(this, 'on-blur')?.();
|
|
142
|
+
};
|
|
143
|
+
#onClickReactHandler = e => {
|
|
144
|
+
getReactEventHandler(this, 'on-click')?.(e);
|
|
145
|
+
};
|
|
146
|
+
});
|
package/list-item/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '../icons/keyboard-arrow-down';
|
|
2
2
|
import { defineCustomElement, NectaryElement } from '../utils';
|
|
3
|
-
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{width:100%;height:100%;box-sizing:border-box;overflow:hidden;padding:8px 0;border-bottom:1px solid var(--sinch-color-snow-
|
|
3
|
+
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{width:100%;height:100%;box-sizing:border-box;overflow:hidden;padding:8px 0;border-bottom:1px solid var(--sinch-color-snow-500)}:host(:last-child)>#wrapper{border-bottom:none}:host(:hover)>#wrapper{background-color:var(--sinch-color-snow-400)}</style><div id="wrapper"><slot name="content"></slot></div>';
|
|
4
4
|
const template = document.createElement('template');
|
|
5
5
|
template.innerHTML = templateHTML;
|
|
6
6
|
defineCustomElement('sinch-list-item', class extends NectaryElement {
|
package/package.json
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nectary/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.40.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"theme.css",
|
|
6
6
|
"**/*/*.js",
|
|
7
7
|
"**/*/*.d.ts",
|
|
8
|
-
"utils.js",
|
|
9
|
-
"utils.d.ts",
|
|
10
8
|
"types.d.ts",
|
|
11
9
|
"colors.json"
|
|
12
10
|
],
|
|
@@ -14,19 +12,19 @@
|
|
|
14
12
|
"build": "NODE_ENV=production babel . --extensions '.ts' --out-dir . && tsc --declaration --emitDeclarationOnly"
|
|
15
13
|
},
|
|
16
14
|
"dependencies": {
|
|
17
|
-
"@babel/runtime": "^7.
|
|
15
|
+
"@babel/runtime": "^7.19.0",
|
|
18
16
|
"dialog-polyfill": "^0.5.6"
|
|
19
17
|
},
|
|
20
18
|
"devDependencies": {
|
|
21
|
-
"@babel/cli": "^7.
|
|
22
|
-
"@babel/core": "^7.
|
|
23
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
24
|
-
"@babel/preset-env": "^7.
|
|
25
|
-
"@babel/preset-typescript": "^7.
|
|
26
|
-
"@types/node": "^17.0.
|
|
27
|
-
"@types/react": "^17.0.
|
|
28
|
-
"babel-plugin-html-inline-minifier": "workspace
|
|
29
|
-
"babel-plugin-transform-inline-environment-variables": "^0.4.
|
|
30
|
-
"typescript": "^4.4
|
|
19
|
+
"@babel/cli": "^7.19.3",
|
|
20
|
+
"@babel/core": "^7.19.3",
|
|
21
|
+
"@babel/plugin-transform-runtime": "^7.19.1",
|
|
22
|
+
"@babel/preset-env": "^7.19.3",
|
|
23
|
+
"@babel/preset-typescript": "^7.18.6",
|
|
24
|
+
"@types/node": "^17.0.45",
|
|
25
|
+
"@types/react": "^17.0.50",
|
|
26
|
+
"babel-plugin-html-inline-minifier": "workspace:^0.0.0",
|
|
27
|
+
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
|
|
28
|
+
"typescript": "^4.8.4"
|
|
31
29
|
}
|
|
32
30
|
}
|
package/pagination/index.js
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
-
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
-
|
|
4
|
-
var _$left, _$right, _$buttons, _$wrapper, _onValueChange, _onButtonClick, _clamp, _dispatchChangeEvent, _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 '../icons/keyboard-arrow-left';
|
|
15
2
|
import '../icons/keyboard-arrow-right';
|
|
16
3
|
import { defineCustomElement, updateAttribute, getIntegerAttribute, setClass, NectaryElement, getRect, getReactEventHandler } from '../utils';
|
|
@@ -23,106 +10,31 @@ const DOTS_LEFT_INDEX = 1;
|
|
|
23
10
|
const DOTS_RIGHT_INDEX = LAST_BTN_INDEX - 1;
|
|
24
11
|
const template = document.createElement('template');
|
|
25
12
|
template.innerHTML = templateHTML;
|
|
26
|
-
defineCustomElement('sinch-pagination',
|
|
13
|
+
defineCustomElement('sinch-pagination', class extends NectaryElement {
|
|
14
|
+
#$left;
|
|
15
|
+
#$right;
|
|
16
|
+
#$buttons;
|
|
17
|
+
#$wrapper;
|
|
18
|
+
|
|
27
19
|
constructor() {
|
|
28
20
|
super();
|
|
29
|
-
|
|
30
|
-
_classPrivateMethodInitSpec(this, _dispatchChangeEvent);
|
|
31
|
-
|
|
32
|
-
_classPrivateMethodInitSpec(this, _clamp);
|
|
33
|
-
|
|
34
|
-
_classPrivateMethodInitSpec(this, _onValueChange);
|
|
35
|
-
|
|
36
|
-
_classPrivateFieldInitSpec(this, _$left, {
|
|
37
|
-
writable: true,
|
|
38
|
-
value: void 0
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
_classPrivateFieldInitSpec(this, _$right, {
|
|
42
|
-
writable: true,
|
|
43
|
-
value: void 0
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
_classPrivateFieldInitSpec(this, _$buttons, {
|
|
47
|
-
writable: true,
|
|
48
|
-
value: void 0
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
_classPrivateFieldInitSpec(this, _$wrapper, {
|
|
52
|
-
writable: true,
|
|
53
|
-
value: void 0
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
_classPrivateFieldInitSpec(this, _onButtonClick, {
|
|
57
|
-
writable: true,
|
|
58
|
-
value: e => {
|
|
59
|
-
e.stopPropagation();
|
|
60
|
-
const value = getIntegerAttribute(this, 'value', 0) - 1;
|
|
61
|
-
const max = Math.max(0, getIntegerAttribute(this, 'max', 0));
|
|
62
|
-
|
|
63
|
-
if (e.target === _classPrivateFieldGet(this, _$left)) {
|
|
64
|
-
return _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, value - 1);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (e.target === _classPrivateFieldGet(this, _$right)) {
|
|
68
|
-
return _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, value + 1);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const btnIndex = Array.prototype.indexOf.call(_classPrivateFieldGet(this, _$wrapper).children, e.target) - 1;
|
|
72
|
-
|
|
73
|
-
if (btnIndex >= 0 && btnIndex < _classPrivateFieldGet(this, _$buttons).length) {
|
|
74
|
-
if (btnIndex === FIRST_BTN_INDEX) {
|
|
75
|
-
return _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, 0);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (btnIndex === _classPrivateFieldGet(this, _$buttons).length - 1) {
|
|
79
|
-
return _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, max - 1);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (btnIndex === DOTS_LEFT_INDEX && max > NUM_BUTTONS && value > MIDDLE_BTN_INDEX) {
|
|
83
|
-
return _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, Math.floor(value / 2));
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (btnIndex === DOTS_RIGHT_INDEX && max > NUM_BUTTONS && value <= max - DOTS_RIGHT_INDEX) {
|
|
87
|
-
return _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, Math.floor((max - value) / 2 + value));
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, btnIndex + Math.min(Math.max(0, value - MIDDLE_BTN_INDEX), Math.max(0, max - NUM_BUTTONS)));
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
_classPrivateFieldInitSpec(this, _onChangeReactHandler, {
|
|
96
|
-
writable: true,
|
|
97
|
-
value: e => {
|
|
98
|
-
getReactEventHandler(this, 'on-change')?.(e);
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
|
|
102
21
|
const shadowRoot = this.attachShadow();
|
|
103
22
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
_classPrivateFieldSet(this, _$buttons, shadowRoot.querySelectorAll('.page'));
|
|
110
|
-
|
|
111
|
-
_classPrivateFieldSet(this, _$wrapper, shadowRoot.querySelector('#wrapper'));
|
|
23
|
+
this.#$left = shadowRoot.querySelector('#left');
|
|
24
|
+
this.#$right = shadowRoot.querySelector('#right');
|
|
25
|
+
this.#$buttons = shadowRoot.querySelectorAll('.page');
|
|
26
|
+
this.#$wrapper = shadowRoot.querySelector('#wrapper');
|
|
112
27
|
}
|
|
113
28
|
|
|
114
29
|
connectedCallback() {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
30
|
+
this.#onValueChange();
|
|
31
|
+
this.#$wrapper.addEventListener('click', this.#onButtonClick);
|
|
32
|
+
this.addEventListener('-change', this.#onChangeReactHandler);
|
|
120
33
|
}
|
|
121
34
|
|
|
122
35
|
disconnectedCallback() {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
36
|
+
this.#$wrapper.removeEventListener('click', this.#onButtonClick);
|
|
37
|
+
this.removeEventListener('-change', this.#onChangeReactHandler);
|
|
126
38
|
}
|
|
127
39
|
|
|
128
40
|
static get observedAttributes() {
|
|
@@ -133,15 +45,13 @@ defineCustomElement('sinch-pagination', (_$left = new WeakMap(), _$right = new W
|
|
|
133
45
|
switch (name) {
|
|
134
46
|
case 'value':
|
|
135
47
|
{
|
|
136
|
-
|
|
137
|
-
|
|
48
|
+
this.#onValueChange();
|
|
138
49
|
break;
|
|
139
50
|
}
|
|
140
51
|
|
|
141
52
|
case 'max':
|
|
142
53
|
{
|
|
143
|
-
|
|
144
|
-
|
|
54
|
+
this.#onValueChange();
|
|
145
55
|
break;
|
|
146
56
|
}
|
|
147
57
|
}
|
|
@@ -167,80 +77,116 @@ defineCustomElement('sinch-pagination', (_$left = new WeakMap(), _$right = new W
|
|
|
167
77
|
return getIntegerAttribute(this, 'value', 0);
|
|
168
78
|
}
|
|
169
79
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
80
|
+
#onValueChange() {
|
|
81
|
+
const value = getIntegerAttribute(this, 'value', 0) - 1;
|
|
82
|
+
const max = Math.max(0, getIntegerAttribute(this, 'max', 0));
|
|
83
|
+
const valueOffset = Math.min(Math.max(0, value - MIDDLE_BTN_INDEX), Math.max(0, max - NUM_BUTTONS));
|
|
173
84
|
|
|
174
|
-
|
|
175
|
-
|
|
85
|
+
for (let i = 0; i < this.#$buttons.length; i++) {
|
|
86
|
+
const $b = this.#$buttons[i];
|
|
176
87
|
|
|
177
|
-
|
|
88
|
+
if (value < 3) {
|
|
89
|
+
setClass($b, 'active', value === i);
|
|
90
|
+
} else if (value >= max - MIDDLE_BTN_INDEX) {
|
|
91
|
+
setClass($b, 'active', i + valueOffset === value);
|
|
92
|
+
} else {
|
|
93
|
+
setClass($b, 'active', i === MIDDLE_BTN_INDEX);
|
|
94
|
+
}
|
|
178
95
|
|
|
179
|
-
|
|
180
|
-
|
|
96
|
+
if (max > NUM_BUTTONS) {
|
|
97
|
+
setClass($b, 'dots', i === DOTS_LEFT_INDEX && value > MIDDLE_BTN_INDEX || i === DOTS_RIGHT_INDEX && value <= max - DOTS_RIGHT_INDEX);
|
|
98
|
+
}
|
|
181
99
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
100
|
+
setClass($b, 'hidden', i >= max);
|
|
101
|
+
const btnText = $b.firstElementChild;
|
|
185
102
|
|
|
186
|
-
|
|
187
|
-
|
|
103
|
+
if (btnText != null) {
|
|
104
|
+
btnText.textContent = i === FIRST_BTN_INDEX ? '1' : i === LAST_BTN_INDEX ? String(max) : String(i + 1 + valueOffset);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const isValueBad = value < 0 || value >= max;
|
|
109
|
+
this.#$left.disabled = isValueBad || value === 0;
|
|
110
|
+
this.#$right.disabled = isValueBad || value === max - 1;
|
|
188
111
|
}
|
|
189
112
|
|
|
190
|
-
|
|
191
|
-
|
|
113
|
+
#onButtonClick = e => {
|
|
114
|
+
e.stopPropagation();
|
|
115
|
+
const value = getIntegerAttribute(this, 'value', 0) - 1;
|
|
116
|
+
const max = Math.max(0, getIntegerAttribute(this, 'max', 0));
|
|
192
117
|
|
|
193
|
-
|
|
194
|
-
|
|
118
|
+
if (e.target === this.#$left) {
|
|
119
|
+
return this.#dispatchChangeEvent(value - 1);
|
|
120
|
+
}
|
|
195
121
|
|
|
196
|
-
|
|
122
|
+
if (e.target === this.#$right) {
|
|
123
|
+
return this.#dispatchChangeEvent(value + 1);
|
|
124
|
+
}
|
|
197
125
|
|
|
198
|
-
|
|
199
|
-
const value = getIntegerAttribute(this, 'value', 0) - 1;
|
|
200
|
-
const max = Math.max(0, getIntegerAttribute(this, 'max', 0));
|
|
201
|
-
const valueOffset = Math.min(Math.max(0, value - MIDDLE_BTN_INDEX), Math.max(0, max - NUM_BUTTONS));
|
|
126
|
+
const btnIndex = Array.prototype.indexOf.call(this.#$wrapper.children, e.target) - 1;
|
|
202
127
|
|
|
203
|
-
|
|
204
|
-
|
|
128
|
+
if (btnIndex >= 0 && btnIndex < this.#$buttons.length) {
|
|
129
|
+
if (btnIndex === FIRST_BTN_INDEX) {
|
|
130
|
+
return this.#dispatchChangeEvent(0);
|
|
131
|
+
}
|
|
205
132
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
setClass($b, 'active', i + valueOffset === value);
|
|
210
|
-
} else {
|
|
211
|
-
setClass($b, 'active', i === MIDDLE_BTN_INDEX);
|
|
212
|
-
}
|
|
133
|
+
if (btnIndex === this.#$buttons.length - 1) {
|
|
134
|
+
return this.#dispatchChangeEvent(max - 1);
|
|
135
|
+
}
|
|
213
136
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
137
|
+
if (btnIndex === DOTS_LEFT_INDEX && max > NUM_BUTTONS && value > MIDDLE_BTN_INDEX) {
|
|
138
|
+
return this.#dispatchChangeEvent(Math.floor(value / 2));
|
|
139
|
+
}
|
|
217
140
|
|
|
218
|
-
|
|
219
|
-
|
|
141
|
+
if (btnIndex === DOTS_RIGHT_INDEX && max > NUM_BUTTONS && value <= max - DOTS_RIGHT_INDEX) {
|
|
142
|
+
return this.#dispatchChangeEvent(Math.floor((max - value) / 2 + value));
|
|
143
|
+
}
|
|
220
144
|
|
|
221
|
-
|
|
222
|
-
btnText.textContent = i === FIRST_BTN_INDEX ? '1' : i === LAST_BTN_INDEX ? String(max) : String(i + 1 + valueOffset);
|
|
145
|
+
return this.#dispatchChangeEvent(btnIndex + Math.min(Math.max(0, value - MIDDLE_BTN_INDEX), Math.max(0, max - NUM_BUTTONS)));
|
|
223
146
|
}
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
#clamp(value) {
|
|
150
|
+
const max = getIntegerAttribute(this, 'max', 0);
|
|
151
|
+
return Math.max(0, Math.min(max - 1, value)) + 1;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
#dispatchChangeEvent(value) {
|
|
155
|
+
const detail = this.#clamp(value);
|
|
156
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
157
|
+
detail,
|
|
158
|
+
bubbles: true
|
|
159
|
+
}));
|
|
160
|
+
this.dispatchEvent(new CustomEvent('-change', {
|
|
161
|
+
detail
|
|
162
|
+
}));
|
|
224
163
|
}
|
|
225
164
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}
|
|
165
|
+
#onChangeReactHandler = e => {
|
|
166
|
+
getReactEventHandler(this, 'on-change')?.(e);
|
|
167
|
+
};
|
|
230
168
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
169
|
+
focus() {
|
|
170
|
+
this.#$left.focus();
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
blur() {
|
|
174
|
+
this.#$left.blur();
|
|
175
|
+
this.#$right.blur();
|
|
176
|
+
this.#$buttons.forEach($b => $b.blur());
|
|
177
|
+
}
|
|
235
178
|
|
|
236
|
-
|
|
237
|
-
|
|
179
|
+
get prevButtonRect() {
|
|
180
|
+
return getRect(this.#$left);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
get nextButtonRect() {
|
|
184
|
+
return getRect(this.#$right);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
nthButtonRect(index) {
|
|
188
|
+
const btn = this.#$buttons[index];
|
|
189
|
+
return btn == null ? null : getRect(btn);
|
|
190
|
+
}
|
|
238
191
|
|
|
239
|
-
|
|
240
|
-
detail,
|
|
241
|
-
bubbles: true
|
|
242
|
-
}));
|
|
243
|
-
this.dispatchEvent(new CustomEvent('-change', {
|
|
244
|
-
detail
|
|
245
|
-
}));
|
|
246
|
-
}
|
|
192
|
+
});
|
package/pagination/types.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare type TSinchPaginationElement = HTMLElement & {
|
|
|
14
14
|
export declare type TSinchPaginationReact = TSinchElementReact<TSinchPaginationElement> & {
|
|
15
15
|
value: number;
|
|
16
16
|
max: number;
|
|
17
|
+
/** @deprecated */
|
|
17
18
|
onChange?: (event: SyntheticEvent<TSinchPaginationElement, CustomEvent<number>>) => void;
|
|
18
19
|
'on-change': (e: CustomEvent<number>) => void;
|
|
19
20
|
};
|