@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.
Files changed (148) hide show
  1. package/accordion/index.js +47 -84
  2. package/accordion/types.d.ts +1 -0
  3. package/accordion-item/index.js +26 -53
  4. package/action-menu/index.d.ts +0 -1
  5. package/action-menu/index.js +179 -223
  6. package/action-menu/types.d.ts +8 -18
  7. package/action-menu-option/index.d.ts +1 -0
  8. package/action-menu-option/index.js +51 -62
  9. package/action-menu-option/types.d.ts +9 -0
  10. package/action-menu-option/utils.d.ts +2 -0
  11. package/action-menu-option/utils.js +3 -0
  12. package/alert/index.js +6 -20
  13. package/avatar/index.js +12 -31
  14. package/avatar-badge/index.js +8 -22
  15. package/avatar-status/index.js +1 -1
  16. package/button/index.js +42 -92
  17. package/card/index.d.ts +2 -0
  18. package/card/index.js +24 -87
  19. package/chat-avatar/index.js +8 -22
  20. package/chat-block/index.js +29 -69
  21. package/chat-bubble/index.js +6 -20
  22. package/checkbox/index.js +55 -107
  23. package/chip/index.d.ts +13 -0
  24. package/chip/index.js +137 -0
  25. package/chip/types.d.ts +38 -0
  26. package/color-menu/index.d.ts +13 -0
  27. package/color-menu/index.js +464 -0
  28. package/color-menu/types.d.ts +37 -0
  29. package/color-swatch/index.d.ts +13 -0
  30. package/color-swatch/index.js +59 -0
  31. package/color-swatch/types.d.ts +12 -0
  32. package/colors.json +57 -49
  33. package/date-picker/index.js +196 -287
  34. package/date-picker/types.d.ts +25 -1
  35. package/dialog/index.d.ts +1 -0
  36. package/dialog/index.js +72 -143
  37. package/dropdown-checkbox-option/index.js +6 -20
  38. package/dropdown-radio-option/index.js +6 -20
  39. package/field/index.js +25 -63
  40. package/file-drop/index.js +123 -200
  41. package/file-picker/index.d.ts +0 -1
  42. package/file-picker/index.js +55 -108
  43. package/file-status/index.js +15 -39
  44. package/help-tooltip/index.js +1 -1
  45. package/horizontal-stepper/index.js +33 -59
  46. package/horizontal-stepper-item/index.js +13 -37
  47. package/icon-button/index.js +39 -84
  48. package/icons-channel/notify/index.d.ts +11 -0
  49. package/icons-channel/notify/index.js +4 -0
  50. package/illustrations/create-illustration-class.js +1 -1
  51. package/inline-alert/index.js +30 -82
  52. package/input/index.js +113 -222
  53. package/link/index.js +46 -96
  54. package/list-item/index.js +1 -1
  55. package/package.json +12 -14
  56. package/pagination/index.js +109 -163
  57. package/pagination/types.d.ts +1 -0
  58. package/popover/index.js +224 -294
  59. package/progress/index.js +9 -28
  60. package/radio/index.js +103 -169
  61. package/radio/types.d.ts +1 -0
  62. package/radio-option/index.js +24 -48
  63. package/segment/index.js +50 -131
  64. package/segment-collapse/index.js +24 -49
  65. package/segment-collapse/types.d.ts +1 -0
  66. package/segmented-control/index.js +36 -73
  67. package/segmented-control/types.d.ts +1 -0
  68. package/segmented-control-option/index.js +41 -87
  69. package/segmented-icon-control/index.js +47 -84
  70. package/segmented-icon-control/types.d.ts +1 -0
  71. package/segmented-icon-control-option/index.js +38 -79
  72. package/select-button/index.d.ts +13 -0
  73. package/select-button/index.js +153 -0
  74. package/select-button/types.d.ts +43 -0
  75. package/select-menu/index.d.ts +11 -0
  76. package/select-menu/index.js +346 -0
  77. package/select-menu/types.d.ts +29 -0
  78. package/{dropdown-text-option → select-menu-option}/index.d.ts +5 -7
  79. package/select-menu-option/index.js +76 -0
  80. package/{select-option → select-menu-option}/types.d.ts +8 -9
  81. package/stop-events/index.js +7 -20
  82. package/table-head-cell/index.js +7 -21
  83. package/tabs/index.js +103 -165
  84. package/tabs/types.d.ts +1 -0
  85. package/tabs-option/index.js +20 -44
  86. package/tag/index.d.ts +1 -1
  87. package/tag/index.js +42 -36
  88. package/tag/types.d.ts +13 -7
  89. package/textarea/index.js +92 -167
  90. package/theme.css +80 -49
  91. package/tile-control/index.js +55 -96
  92. package/tile-control-option/index.js +40 -86
  93. package/time-picker/index.js +224 -368
  94. package/time-picker/types.d.ts +5 -1
  95. package/title/index.js +6 -20
  96. package/toast/index.d.ts +17 -0
  97. package/toast/index.js +115 -0
  98. package/toast/types.d.ts +28 -0
  99. package/toast/utils.d.ts +5 -0
  100. package/toast/utils.js +6 -0
  101. package/toast-manager/index.d.ts +17 -0
  102. package/toast-manager/index.js +195 -0
  103. package/toast-manager/types.d.ts +7 -0
  104. package/toggle/index.js +55 -108
  105. package/toggle/types.d.ts +1 -0
  106. package/types.d.ts +7 -0
  107. package/utils/colors.d.ts +10 -0
  108. package/utils/colors.js +121 -0
  109. package/{utils.d.ts → utils/index.d.ts} +18 -9
  110. package/{utils.js → utils/index.js} +118 -39
  111. package/vertical-stepper/index.js +29 -50
  112. package/vertical-stepper-item/index.js +13 -37
  113. package/card-button/index.d.ts +0 -11
  114. package/card-button/index.js +0 -77
  115. package/card-button/types.d.ts +0 -12
  116. package/card-link/index.d.ts +0 -12
  117. package/card-link/index.js +0 -115
  118. package/card-link/types.d.ts +0 -14
  119. package/dropdown/index.d.ts +0 -12
  120. package/dropdown/index.js +0 -415
  121. package/dropdown/types.d.ts +0 -30
  122. package/dropdown-text-option/index.js +0 -104
  123. package/dropdown-text-option/types.d.ts +0 -16
  124. package/search/index.d.ts +0 -14
  125. package/search/index.js +0 -523
  126. package/search/types.d.ts +0 -25
  127. package/search-option/index.d.ts +0 -11
  128. package/search-option/index.js +0 -55
  129. package/search-option/types.d.ts +0 -9
  130. package/select/index.d.ts +0 -13
  131. package/select/index.js +0 -316
  132. package/select/types.d.ts +0 -53
  133. package/select-option/index.d.ts +0 -11
  134. package/select-option/index.js +0 -8
  135. package/tag/utils.d.ts +0 -2
  136. package/tag/utils.js +0 -1
  137. package/tag-close/index.d.ts +0 -12
  138. package/tag-close/index.js +0 -38
  139. package/tag-close/types.d.ts +0 -3
  140. package/tag-close/types.js +0 -1
  141. /package/{card-button → chip}/types.js +0 -0
  142. /package/{card-link → color-menu}/types.js +0 -0
  143. /package/{dropdown-text-option → color-swatch}/types.js +0 -0
  144. /package/{dropdown → select-button}/types.js +0 -0
  145. /package/{search → select-menu}/types.js +0 -0
  146. /package/{search-option → select-menu-option}/types.js +0 -0
  147. /package/{select → toast}/types.js +0 -0
  148. /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', (_$anchor = new WeakMap(), _$text = new WeakMap(), _onAnchorClick = new WeakMap(), _onAnchorFocus = new WeakMap(), _onAnchorBlur = new WeakMap(), _onFocusReactHandler = new WeakMap(), _onBlurReactHandler = new WeakMap(), _onClickReactHandler = new WeakMap(), class extends NectaryElement {
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
- _classPrivateFieldSet(this, _$anchor, shadowRoot.querySelector('a'));
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
- _classPrivateFieldGet(this, _$anchor).addEventListener('click', _classPrivateFieldGet(this, _onAnchorClick));
88
-
89
- _classPrivateFieldGet(this, _$anchor).addEventListener('focus', _classPrivateFieldGet(this, _onAnchorFocus));
90
-
91
- _classPrivateFieldGet(this, _$anchor).addEventListener('blur', _classPrivateFieldGet(this, _onAnchorBlur));
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
- _classPrivateFieldGet(this, _$anchor).removeEventListener('click', _classPrivateFieldGet(this, _onAnchorClick));
100
-
101
- _classPrivateFieldGet(this, _$anchor).removeEventListener('focus', _classPrivateFieldGet(this, _onAnchorFocus));
102
-
103
- _classPrivateFieldGet(this, _$anchor).removeEventListener('blur', _classPrivateFieldGet(this, _onAnchorBlur));
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
- _classPrivateFieldGet(this, _$text).textContent = newVal;
98
+ this.#$text.textContent = newVal;
171
99
  break;
172
100
  }
173
101
 
174
102
  case 'href':
175
103
  {
176
- updateAttribute(_classPrivateFieldGet(this, _$anchor), 'href', newVal);
104
+ updateAttribute(this.#$anchor, 'href', newVal);
177
105
  break;
178
106
  }
179
107
 
180
108
  case 'external':
181
109
  {
182
- updateAttribute(_classPrivateFieldGet(this, _$anchor), 'target', isAttrTrue(newVal) ? '_blank' : null);
110
+ updateAttribute(this.#$anchor, 'target', isAttrTrue(newVal) ? '_blank' : null);
183
111
  break;
184
112
  }
185
113
  }
186
114
  }
187
115
 
188
116
  focus() {
189
- _classPrivateFieldGet(this, _$anchor).focus();
117
+ this.#$anchor.focus();
190
118
  }
191
119
 
192
120
  blur() {
193
- _classPrivateFieldGet(this, _$anchor).blur();
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
+ });
@@ -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-600)}:host(:last-child)>#wrapper{border-bottom:none}:host(:hover)>#wrapper{background-color:var(--sinch-color-snow-500)}</style><div id="wrapper"><slot name="content"></slot></div>';
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.38.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.17.0",
15
+ "@babel/runtime": "^7.19.0",
18
16
  "dialog-polyfill": "^0.5.6"
19
17
  },
20
18
  "devDependencies": {
21
- "@babel/cli": "^7.17.0",
22
- "@babel/core": "^7.17.0",
23
- "@babel/plugin-transform-runtime": "^7.17.0",
24
- "@babel/preset-env": "^7.16.0",
25
- "@babel/preset-typescript": "^7.16.0",
26
- "@types/node": "^17.0.14",
27
- "@types/react": "^17.0.0",
28
- "babel-plugin-html-inline-minifier": "workspace:babel-plugin-html-inline-minifier@*",
29
- "babel-plugin-transform-inline-environment-variables": "^0.4.3",
30
- "typescript": "^4.4.2"
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
  }
@@ -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', (_$left = new WeakMap(), _$right = new WeakMap(), _$buttons = new WeakMap(), _$wrapper = new WeakMap(), _onValueChange = new WeakSet(), _onButtonClick = new WeakMap(), _clamp = new WeakSet(), _dispatchChangeEvent = new WeakSet(), _onChangeReactHandler = new WeakMap(), class extends NectaryElement {
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
- _classPrivateFieldSet(this, _$left, shadowRoot.querySelector('#left'));
106
-
107
- _classPrivateFieldSet(this, _$right, shadowRoot.querySelector('#right'));
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
- _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this);
116
-
117
- _classPrivateFieldGet(this, _$wrapper).addEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
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
- _classPrivateFieldGet(this, _$wrapper).removeEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
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
- _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this);
137
-
48
+ this.#onValueChange();
138
49
  break;
139
50
  }
140
51
 
141
52
  case 'max':
142
53
  {
143
- _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this);
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
- focus() {
171
- _classPrivateFieldGet(this, _$left).focus();
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
- blur() {
175
- _classPrivateFieldGet(this, _$left).blur();
85
+ for (let i = 0; i < this.#$buttons.length; i++) {
86
+ const $b = this.#$buttons[i];
176
87
 
177
- _classPrivateFieldGet(this, _$right).blur();
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
- _classPrivateFieldGet(this, _$buttons).forEach($b => $b.blur());
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
- get prevButtonRect() {
183
- return getRect(_classPrivateFieldGet(this, _$left));
184
- }
100
+ setClass($b, 'hidden', i >= max);
101
+ const btnText = $b.firstElementChild;
185
102
 
186
- get nextButtonRect() {
187
- return getRect(_classPrivateFieldGet(this, _$right));
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
- nthButtonRect(index) {
191
- const btn = _classPrivateFieldGet(this, _$buttons)[index];
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
- return btn == null ? null : getRect(btn);
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
- function _onValueChange2() {
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
- for (let i = 0; i < _classPrivateFieldGet(this, _$buttons).length; i++) {
204
- const $b = _classPrivateFieldGet(this, _$buttons)[i];
128
+ if (btnIndex >= 0 && btnIndex < this.#$buttons.length) {
129
+ if (btnIndex === FIRST_BTN_INDEX) {
130
+ return this.#dispatchChangeEvent(0);
131
+ }
205
132
 
206
- if (value < 3) {
207
- setClass($b, 'active', value === i);
208
- } else if (value >= max - MIDDLE_BTN_INDEX) {
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
- if (max > NUM_BUTTONS) {
215
- setClass($b, 'dots', i === DOTS_LEFT_INDEX && value > MIDDLE_BTN_INDEX || i === DOTS_RIGHT_INDEX && value <= max - DOTS_RIGHT_INDEX);
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
- setClass($b, 'hidden', i >= max);
219
- const btnText = $b.firstElementChild;
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
- if (btnText != null) {
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
- const isValueBad = value < 0 || value >= max;
227
- _classPrivateFieldGet(this, _$left).disabled = isValueBad || value === 0;
228
- _classPrivateFieldGet(this, _$right).disabled = isValueBad || value === max - 1;
229
- }
165
+ #onChangeReactHandler = e => {
166
+ getReactEventHandler(this, 'on-change')?.(e);
167
+ };
230
168
 
231
- function _clamp2(value) {
232
- const max = getIntegerAttribute(this, 'max', 0);
233
- return Math.max(0, Math.min(max - 1, value)) + 1;
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
- function _dispatchChangeEvent2(value) {
237
- const detail = _classPrivateMethodGet(this, _clamp, _clamp2).call(this, value);
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
- this.dispatchEvent(new CustomEvent('change', {
240
- detail,
241
- bubbles: true
242
- }));
243
- this.dispatchEvent(new CustomEvent('-change', {
244
- detail
245
- }));
246
- }
192
+ });
@@ -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
  };