@nectary/components 0.39.0 → 0.41.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 (142) hide show
  1. package/accordion/index.js +47 -84
  2. package/accordion-item/index.js +30 -53
  3. package/action-menu/index.d.ts +0 -1
  4. package/action-menu/index.js +177 -223
  5. package/action-menu/types.d.ts +8 -18
  6. package/action-menu-option/index.d.ts +1 -0
  7. package/action-menu-option/index.js +52 -62
  8. package/action-menu-option/types.d.ts +9 -0
  9. package/action-menu-option/utils.d.ts +2 -0
  10. package/action-menu-option/utils.js +3 -0
  11. package/alert/index.js +6 -20
  12. package/avatar/index.js +12 -31
  13. package/avatar-badge/index.js +8 -22
  14. package/avatar-status/index.js +1 -1
  15. package/button/index.js +46 -92
  16. package/button/types.d.ts +1 -1
  17. package/card/index.js +21 -59
  18. package/chat-avatar/index.js +8 -22
  19. package/chat-block/index.js +29 -69
  20. package/chat-bubble/index.js +6 -20
  21. package/checkbox/index.js +59 -107
  22. package/chip/index.d.ts +13 -0
  23. package/chip/index.js +140 -0
  24. package/chip/types.d.ts +37 -0
  25. package/color-menu/index.d.ts +14 -0
  26. package/color-menu/index.js +450 -0
  27. package/color-menu/types.d.ts +36 -0
  28. package/color-menu/utils.d.ts +1 -0
  29. package/color-menu/utils.js +15 -0
  30. package/color-swatch/index.d.ts +13 -0
  31. package/color-swatch/index.js +60 -0
  32. package/color-swatch/types.d.ts +11 -0
  33. package/colors.json +61 -49
  34. package/date-picker/index.js +162 -293
  35. package/dialog/index.js +70 -142
  36. package/field/index.js +44 -65
  37. package/file-drop/index.js +123 -200
  38. package/file-picker/index.d.ts +0 -1
  39. package/file-picker/index.js +55 -108
  40. package/file-status/index.js +15 -39
  41. package/help-tooltip/index.js +11 -28
  42. package/horizontal-stepper/index.js +33 -59
  43. package/horizontal-stepper-item/index.js +13 -37
  44. package/icon-button/index.d.ts +1 -0
  45. package/icon-button/index.js +51 -85
  46. package/icon-button/types.d.ts +16 -2
  47. package/icons-channel/notify/index.d.ts +11 -0
  48. package/icons-channel/notify/index.js +4 -0
  49. package/illustrations/create-illustration-class.js +1 -1
  50. package/inline-alert/index.js +29 -81
  51. package/input/index.js +117 -222
  52. package/link/index.js +51 -97
  53. package/list-item/index.js +1 -1
  54. package/package.json +12 -14
  55. package/pagination/index.js +113 -163
  56. package/pop/index.d.ts +11 -0
  57. package/pop/index.js +391 -0
  58. package/pop/types.d.ts +35 -0
  59. package/pop/utils.d.ts +7 -0
  60. package/pop/utils.js +18 -0
  61. package/popover/index.d.ts +1 -0
  62. package/popover/index.js +105 -314
  63. package/popover/types.d.ts +8 -1
  64. package/popover/utils.d.ts +5 -0
  65. package/popover/utils.js +17 -1
  66. package/progress/index.js +9 -28
  67. package/radio/index.js +103 -169
  68. package/radio-option/index.js +28 -48
  69. package/segment/index.js +49 -130
  70. package/segment-collapse/index.js +28 -49
  71. package/segmented-control/index.js +36 -73
  72. package/segmented-control-option/index.js +45 -87
  73. package/segmented-icon-control/index.js +47 -84
  74. package/segmented-icon-control-option/index.js +42 -79
  75. package/select-button/index.d.ts +13 -0
  76. package/select-button/index.js +158 -0
  77. package/select-button/types.d.ts +43 -0
  78. package/select-menu/index.d.ts +11 -0
  79. package/select-menu/index.js +345 -0
  80. package/select-menu/types.d.ts +29 -0
  81. package/{dropdown-text-option → select-menu-option}/index.d.ts +5 -7
  82. package/select-menu-option/index.js +76 -0
  83. package/{select-option → select-menu-option}/types.d.ts +8 -9
  84. package/stop-events/index.js +7 -20
  85. package/table-head-cell/index.js +7 -21
  86. package/tabs/index.js +103 -165
  87. package/tabs-option/index.js +24 -44
  88. package/tag/index.d.ts +0 -1
  89. package/tag/index.js +35 -38
  90. package/tag/types.d.ts +12 -7
  91. package/textarea/index.js +96 -167
  92. package/theme.css +146 -49
  93. package/tile-control/index.js +55 -96
  94. package/tile-control-option/index.js +45 -87
  95. package/time-picker/index.js +216 -368
  96. package/title/index.js +6 -20
  97. package/toast/index.js +32 -70
  98. package/toast-manager/index.js +141 -217
  99. package/toggle/index.js +59 -107
  100. package/tooltip/index.d.ts +2 -0
  101. package/tooltip/index.js +160 -17
  102. package/tooltip/types.d.ts +13 -0
  103. package/tooltip/utils.d.ts +5 -0
  104. package/tooltip/utils.js +25 -1
  105. package/utils/animation.d.ts +17 -0
  106. package/utils/animation.js +142 -0
  107. package/utils/colors.d.ts +5 -0
  108. package/utils/colors.js +5 -0
  109. package/utils/context.d.ts +15 -0
  110. package/utils/context.js +57 -0
  111. package/{utils.d.ts → utils/index.d.ts} +15 -11
  112. package/{utils.js → utils/index.js} +104 -48
  113. package/vertical-stepper/index.js +29 -50
  114. package/vertical-stepper-item/index.js +13 -37
  115. package/dropdown/index.d.ts +0 -12
  116. package/dropdown/index.js +0 -415
  117. package/dropdown/types.d.ts +0 -32
  118. package/dropdown-checkbox-option/index.d.ts +0 -11
  119. package/dropdown-checkbox-option/index.js +0 -88
  120. package/dropdown-checkbox-option/types.d.ts +0 -15
  121. package/dropdown-radio-option/index.d.ts +0 -11
  122. package/dropdown-radio-option/index.js +0 -88
  123. package/dropdown-radio-option/types.d.ts +0 -15
  124. package/dropdown-text-option/index.js +0 -104
  125. package/dropdown-text-option/types.d.ts +0 -16
  126. package/select/index.d.ts +0 -13
  127. package/select/index.js +0 -316
  128. package/select/types.d.ts +0 -53
  129. package/select-option/index.d.ts +0 -11
  130. package/select-option/index.js +0 -8
  131. package/tag/utils.d.ts +0 -5
  132. package/tag/utils.js +0 -6
  133. package/tag-close/index.d.ts +0 -12
  134. package/tag-close/index.js +0 -42
  135. package/tag-close/types.d.ts +0 -5
  136. /package/{dropdown-checkbox-option → chip}/types.js +0 -0
  137. /package/{dropdown-radio-option → color-menu}/types.js +0 -0
  138. /package/{dropdown-text-option → color-swatch}/types.js +0 -0
  139. /package/{dropdown → pop}/types.js +0 -0
  140. /package/{select-option → select-button}/types.js +0 -0
  141. /package/{tag-close → select-menu}/types.js +0 -0
  142. /package/{select → select-menu-option}/types.js +0 -0
@@ -0,0 +1,5 @@
1
+ export declare const NO_COLOR: "";
2
+ export declare const lightColorNames: string;
3
+ export declare const darkColorNames: string;
4
+ export declare const vibrantColorNames: string;
5
+ export declare const skinToneColorNames: string;
@@ -0,0 +1,5 @@
1
+ export const NO_COLOR = '';
2
+ export const lightColorNames = ['light-violet', 'light-blue', 'light-green', 'light-yellow', 'light-orange', 'light-pink', 'light-brown', 'light-gray'].join(',');
3
+ export const darkColorNames = ['dark-violet', 'dark-blue', 'dark-green', 'dark-yellow', 'dark-orange', 'dark-pink', 'dark-brown', 'dark-gray'].join(',');
4
+ export const vibrantColorNames = ['violet', 'blue', 'green', 'yellow', 'orange', 'pink', 'brown', 'gray'].join(',');
5
+ export const skinToneColorNames = ['skin-tone-0', 'skin-tone-10', 'skin-tone-20', 'skin-tone-30', 'skin-tone-40', 'skin-tone-50'].join(',');
@@ -0,0 +1,15 @@
1
+ export declare type TContextName = 'visibility' | 'keydown';
2
+ export declare type TContextKeyboard = {
3
+ code: string;
4
+ preventDefault: () => void;
5
+ };
6
+ export declare type TContextVisibility = boolean;
7
+ export declare class Context {
8
+ #private;
9
+ constructor($element: Element, name: TContextName);
10
+ get elements(): Iterable<Element>;
11
+ subscribe(): void;
12
+ unsubscribe(): void;
13
+ }
14
+ export declare const dispatchContextConnectEvent: (el: Element, name: TContextName) => void;
15
+ export declare const dispatchContextDisconnectEvent: (el: Element, name: TContextName) => void;
@@ -0,0 +1,57 @@
1
+ export class Context {
2
+ #$root;
3
+ #listeners = new Set();
4
+ #name;
5
+ #isSubscribed = false;
6
+
7
+ constructor($element, name) {
8
+ this.#$root = $element;
9
+ this.#name = name;
10
+ }
11
+
12
+ get elements() {
13
+ return this.#listeners;
14
+ }
15
+
16
+ subscribe() {
17
+ if (this.#isSubscribed) {
18
+ return;
19
+ }
20
+
21
+ this.#$root.addEventListener(`-context-connect-${this.#name}`, this.#onConnect);
22
+ this.#$root.addEventListener(`-context-disconnect-${this.#name}`, this.#onDisconnect);
23
+ this.#isSubscribed = true;
24
+ }
25
+
26
+ unsubscribe() {
27
+ this.#listeners.clear();
28
+ this.#$root.removeEventListener(`-context-connect-${this.#name}`, this.#onConnect);
29
+ this.#$root.removeEventListener(`-context-disconnect-${this.#name}`, this.#onDisconnect);
30
+ this.#isSubscribed = false;
31
+ }
32
+
33
+ #onConnect = e => {
34
+ e.stopPropagation();
35
+ this.#listeners.add(e.detail);
36
+ };
37
+ #onDisconnect = e => {
38
+ e.stopPropagation();
39
+ this.#listeners.delete(e.detail);
40
+ };
41
+ }
42
+ export const dispatchContextConnectEvent = (el, name) => {
43
+ requestAnimationFrame(() => {
44
+ el.dispatchEvent(new CustomEvent(`-context-connect-${name}`, {
45
+ bubbles: true,
46
+ composed: true,
47
+ detail: el
48
+ }));
49
+ });
50
+ };
51
+ export const dispatchContextDisconnectEvent = (el, name) => {
52
+ el.dispatchEvent(new CustomEvent(`-context-disconnect-${name}`, {
53
+ bubbles: true,
54
+ composed: true,
55
+ detail: el
56
+ }));
57
+ };
@@ -1,4 +1,4 @@
1
- import type { TRect } from './types';
1
+ import type { TRect } from '../types';
2
2
  export declare const defineCustomElement: (name: string, constructor: CustomElementConstructor) => void;
3
3
  export declare const setNectaryRegistry: (registry: CustomElementRegistry) => void;
4
4
  declare global {
@@ -8,7 +8,8 @@ declare global {
8
8
  }
9
9
  export declare class NectaryElement extends HTMLElement {
10
10
  attachShadow(options?: Partial<ShadowRootInit>): ShadowRoot;
11
- __version: string;
11
+ version: string;
12
+ get focusable(): boolean;
12
13
  }
13
14
  export declare const getReactEventHandler: ($element: HTMLElement, handlerName: string) => ((arg?: any) => void) | null;
14
15
  export declare const updateExplicitBooleanAttribute: ($element: Element, attrName: string, attrValue: boolean | null | undefined) => void;
@@ -16,8 +17,7 @@ export declare const isAttrTrue: (attrValue: string | null) => boolean;
16
17
  export declare const getBooleanAttribute: ($element: Element, attrName: string) => boolean;
17
18
  export declare const updateBooleanAttribute: ($element: Element, attrName: string, attrValue: boolean | null | undefined) => void;
18
19
  export declare const updateAttribute: ($element: Element, attrName: string, attrValue: string | number | boolean | null | undefined) => void;
19
- export declare function getAttribute($element: Element, attrName: string): string | undefined;
20
- export declare function getAttribute($element: Element, attrName: string, defaultValue: null): string | null;
20
+ export declare function getAttribute($element: Element, attrName: string): string | null;
21
21
  export declare function getAttribute($element: Element, attrName: string, defaultValue: string): string;
22
22
  export declare const isLiteralValue: <T extends readonly string[]>(literals: T, value: string | null | undefined) => value is T[number];
23
23
  export declare const updateLiteralAttribute: <T extends readonly string[]>($element: Element, literals: T, attrName: string, attrValue: string | null | undefined) => void;
@@ -25,15 +25,16 @@ export declare function getLiteralAttribute<T extends readonly string[]>($elemen
25
25
  export declare function getLiteralAttribute<T extends readonly string[]>($element: Element, literals: T, attrName: string, defaultValue: null): T[number] | null;
26
26
  export declare function getLiteralAttribute<T extends readonly string[]>($element: Element, literals: T, attrName: string, defaultValue: T[number]): T[number];
27
27
  export declare const clampNumber: (value: number, min: number, max: number) => number;
28
- declare type TRange = {
28
+ declare type IntegerOptions = {
29
29
  min?: number;
30
30
  max?: number;
31
+ defaultValue?: number | null;
32
+ itemSizeMultiplier?: number;
33
+ itemSpaceBetween?: number;
31
34
  };
32
- export declare const attrValueToInteger: (value: string | null, range?: TRange) => number | null;
33
- export declare const attrValueToPixels: (value: string | null, options?: TRange & {
34
- multiplier?: number;
35
- }) => string;
36
- export declare const updateIntegerAttribute: ($element: Element, attrName: string, attrValue: string | number | null | undefined, range?: TRange) => void;
35
+ export declare const attrValueToInteger: (value: string | null, options?: IntegerOptions) => number | null;
36
+ export declare const attrValueToPixels: (value: string | null, options?: IntegerOptions) => string;
37
+ export declare const updateIntegerAttribute: ($element: Element, attrName: string, attrValue: string | number | null | undefined, options?: IntegerOptions) => void;
37
38
  export declare function getIntegerAttribute($element: Element, attrName: string): number | undefined;
38
39
  export declare function getIntegerAttribute($element: Element, attrName: string, defaultValue: null): number | null;
39
40
  export declare function getIntegerAttribute($element: Element, attrName: string, defaultValue: number): number;
@@ -47,6 +48,9 @@ export declare const throttleAnimationFrame: (cb: (...args: any[]) => void) => {
47
48
  fn: (...args: any[]) => void;
48
49
  cancel: () => void;
49
50
  };
50
- export declare const getFirstSlotElement: (root: HTMLSlotElement) => HTMLElement | null;
51
+ export declare const getFirstSlotElement: (root: HTMLSlotElement, isDeep?: boolean) => HTMLElement | null;
52
+ export declare const getFirstFocusableElement: (root: Element) => NectaryElement | null;
51
53
  export declare const cloneNode: (el: Element, deep: boolean) => Element;
54
+ export declare const isElementFocused: ($el: Element | null) => boolean;
55
+ export declare const rectOverlap: (targetRect: TRect, contentRect: TRect) => boolean;
52
56
  export {};
@@ -1,5 +1,4 @@
1
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
- import pkg from './package.json';
1
+ import pkg from '../package.json';
3
2
  const nectaryDefinitions = new Map();
4
3
  let nectaryRegistry = null;
5
4
  export const defineCustomElement = (name, constructor) => {
@@ -29,12 +28,6 @@ export const setNectaryRegistry = registry => {
29
28
  nectaryDefinitions.clear();
30
29
  };
31
30
  export class NectaryElement extends HTMLElement {
32
- constructor() {
33
- super(...arguments);
34
-
35
- _defineProperty(this, '__version', pkg.version);
36
- }
37
-
38
31
  attachShadow(options) {
39
32
  return super.attachShadow({
40
33
  mode: 'closed',
@@ -44,6 +37,12 @@ export class NectaryElement extends HTMLElement {
44
37
  });
45
38
  }
46
39
 
40
+ version = pkg.version;
41
+
42
+ get focusable() {
43
+ return false;
44
+ }
45
+
47
46
  }
48
47
  export const getReactEventHandler = ($element, handlerName) => {
49
48
  for (const key in $element) {
@@ -81,7 +80,8 @@ export const updateAttribute = ($element, attrName, attrValue) => {
81
80
  $element.removeAttribute(attrName);
82
81
  }
83
82
  };
84
- export function getAttribute($element, attrName, defaultValue) {
83
+ export function getAttribute($element, attrName) {
84
+ let defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
85
85
  return $element.getAttribute(attrName) ?? defaultValue;
86
86
  }
87
87
  export const isLiteralValue = (literals, value) => {
@@ -110,59 +110,79 @@ export function getLiteralAttribute($element, literals, attrName, defaultValue)
110
110
  export const clampNumber = (value, min, max) => {
111
111
  return Math.min(max, Math.max(min, value));
112
112
  };
113
+ const DEFAULT_INTEGER_OPTIONS = {
114
+ itemSizeMultiplier: 1,
115
+ itemSpaceBetween: 0,
116
+ defaultValue: null
117
+ };
113
118
 
114
- const applyRange = (value, range) => {
119
+ const applyRange = (value, _ref) => {
120
+ let {
121
+ min,
122
+ max
123
+ } = _ref;
115
124
  let result = value;
116
125
 
117
- if (typeof range.min === 'number') {
118
- result = Math.max(range.min, result);
126
+ if (min != null) {
127
+ result = Math.max(min, result);
119
128
  }
120
129
 
121
- if (typeof range.max === 'number') {
122
- result = Math.min(range.max, result);
130
+ if (max != null) {
131
+ result = Math.min(max, result);
123
132
  }
124
133
 
125
134
  return result;
126
135
  };
127
136
 
128
137
  export const attrValueToInteger = function (value) {
129
- let range = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
138
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_INTEGER_OPTIONS;
139
+ const {
140
+ defaultValue = null,
141
+ itemSizeMultiplier = 1,
142
+ itemSpaceBetween = 0
143
+ } = options;
144
+ let intValue = defaultValue;
130
145
 
131
- if (value === null) {
132
- return null;
133
- }
146
+ if (value !== null) {
147
+ const int = parseInt(value);
134
148
 
135
- const int = parseInt(value);
149
+ if (Number.isInteger(int)) {
150
+ intValue = applyRange(int, options);
151
+ }
152
+ }
136
153
 
137
- if (!Number.isInteger(int)) {
138
- return null;
154
+ if (intValue !== null) {
155
+ return intValue * itemSizeMultiplier + Math.max(intValue - 1, 0) * itemSpaceBetween;
139
156
  }
140
157
 
141
- return applyRange(int, range);
158
+ return null;
142
159
  };
143
160
  export const attrValueToPixels = function (value) {
144
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
145
- const int = attrValueToInteger(value, {
146
- min: options.min ?? 0,
147
- max: options.max
148
- });
149
- return int === null ? 'unset' : `${int * (options.multiplier ?? 1)}px`;
161
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_INTEGER_OPTIONS;
162
+ const int = attrValueToInteger(value, options);
163
+ return int === null ? 'unset' : `${int}px`;
150
164
  };
151
165
  export const updateIntegerAttribute = function ($element, attrName, attrValue) {
152
- let range = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
153
-
154
- if (attrValue == null) {
155
- $element.removeAttribute(attrName);
156
- return;
166
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_INTEGER_OPTIONS;
167
+ const {
168
+ defaultValue = null,
169
+ itemSizeMultiplier: multiplier = 1
170
+ } = options;
171
+ let intValue = null;
172
+
173
+ if (typeof attrValue === 'string') {
174
+ intValue = attrValueToInteger(attrValue, options);
175
+ } else if (typeof attrValue === 'number') {
176
+ intValue = applyRange(attrValue, options) * multiplier;
177
+ } else {
178
+ intValue = defaultValue;
157
179
  }
158
180
 
159
- const intValue = typeof attrValue === 'string' ? attrValueToInteger(attrValue, range) : applyRange(attrValue, range);
160
-
161
181
  if (intValue === null) {
162
- return;
182
+ $element.removeAttribute(attrName);
183
+ } else {
184
+ $element.setAttribute(attrName, intValue.toFixed(0));
163
185
  }
164
-
165
- $element.setAttribute(attrName, intValue.toFixed(0));
166
186
  };
167
187
  export function getIntegerAttribute($element, attrName, defaultValue) {
168
188
  return attrValueToInteger($element.getAttribute(attrName)) ?? defaultValue;
@@ -245,22 +265,52 @@ const throttle = (delayFn, cancelFn) => cb => {
245
265
  };
246
266
 
247
267
  export const throttleAnimationFrame = throttle(global.requestAnimationFrame, global.cancelAnimationFrame);
248
- export const getFirstSlotElement = root => {
249
- let slot = root;
250
268
 
251
- while (true) {
252
- const el = slot.assignedElements()[0];
269
+ const isSlotElement = el => {
270
+ return el.tagName === 'SLOT';
271
+ };
253
272
 
254
- if (el == null) {
255
- return null;
256
- }
273
+ export const getFirstSlotElement = function (root) {
274
+ let isDeep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
275
+ const el = root.assignedElements()[0];
276
+
277
+ if (el == null) {
278
+ return null;
279
+ }
280
+
281
+ if (isDeep && isSlotElement(el)) {
282
+ return getFirstSlotElement(el, isDeep);
283
+ }
284
+
285
+ return el;
286
+ };
287
+
288
+ const getChildren = root => {
289
+ if (isSlotElement(root)) {
290
+ return root.assignedElements();
291
+ }
292
+
293
+ return Array.from(root.children);
294
+ };
257
295
 
258
- if (el.tagName !== 'SLOT') {
259
- return el;
296
+ const isFocusable = el => {
297
+ return el.focusable === true;
298
+ };
299
+
300
+ export const getFirstFocusableElement = root => {
301
+ for (const child of getChildren(root)) {
302
+ if (isFocusable(child)) {
303
+ return child;
260
304
  }
261
305
 
262
- slot = el;
306
+ const resultEl = getFirstFocusableElement(child);
307
+
308
+ if (resultEl !== null) {
309
+ return resultEl;
310
+ }
263
311
  }
312
+
313
+ return null;
264
314
  };
265
315
  export const cloneNode = (el, deep) => {
266
316
  const root = el.getRootNode();
@@ -283,4 +333,10 @@ export const cloneNode = (el, deep) => {
283
333
  }
284
334
 
285
335
  return el.cloneNode(deep);
336
+ };
337
+ export const isElementFocused = $el => {
338
+ return $el !== null && $el === $el.getRootNode().activeElement;
339
+ };
340
+ export const rectOverlap = (targetRect, contentRect) => {
341
+ return targetRect.x < contentRect.x + contentRect.width && targetRect.x + targetRect.width > contentRect.x && targetRect.y < contentRect.y + contentRect.height && targetRect.y + targetRect.height > contentRect.y;
286
342
  };
@@ -1,68 +1,27 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$itemsSlot, _updateItems;
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/check';
11
2
  import '../icons/error-outline';
12
3
  import { clampNumber, defineCustomElement, getAttribute, getIntegerAttribute, NectaryElement, updateAttribute } from '../utils';
13
4
  const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative;display:flex;flex-direction:column;width:100%}#progress{position:absolute;height:1px;background-color:var(--sinch-color-snow-700);left:72px;right:72px;top:16px;transform:translateY(-50%)}#bar{position:absolute;height:1px;background-color:var(--sinch-color-stormy-400);left:0;top:0}</style><div id="wrapper"><slot></slot></div>';
14
5
  const template = document.createElement('template');
15
6
  template.innerHTML = templateHTML;
16
- defineCustomElement('sinch-vertical-stepper', (_$itemsSlot = new WeakMap(), _updateItems = new WeakMap(), class extends NectaryElement {
7
+ defineCustomElement('sinch-vertical-stepper', class extends NectaryElement {
8
+ #$itemsSlot;
9
+
17
10
  constructor() {
18
11
  super();
19
-
20
- _classPrivateFieldInitSpec(this, _$itemsSlot, {
21
- writable: true,
22
- value: void 0
23
- });
24
-
25
- _classPrivateFieldInitSpec(this, _updateItems, {
26
- writable: true,
27
- value: () => {
28
- const $items = _classPrivateFieldGet(this, _$itemsSlot).assignedElements();
29
-
30
- const activeIndex = clampNumber(getIntegerAttribute(this, 'index', 0), 0, $items.length + 1);
31
-
32
- for (let i = 0; i < $items.length; i++) {
33
- const $el = $items[i];
34
- const itemIndex = i + 1;
35
- $el.setAttribute('data-index', String(itemIndex));
36
-
37
- if (itemIndex === activeIndex) {
38
- $el.setAttribute('data-progress', 'active');
39
- } else if (itemIndex < activeIndex) {
40
- $el.setAttribute('data-progress', 'done');
41
- } else {
42
- $el.removeAttribute('data-progress');
43
- }
44
- }
45
-
46
- this.setAttribute('aria-valuemax', String($items.length));
47
- this.setAttribute('aria-valuenow', String(clampNumber(activeIndex, 0, $items.length)));
48
- }
49
- });
50
-
51
12
  const shadowRoot = this.attachShadow();
52
13
  shadowRoot.appendChild(template.content.cloneNode(true));
53
-
54
- _classPrivateFieldSet(this, _$itemsSlot, shadowRoot.querySelector('slot'));
14
+ this.#$itemsSlot = shadowRoot.querySelector('slot');
55
15
  }
56
16
 
57
17
  connectedCallback() {
58
18
  this.setAttribute('role', 'progressbar');
59
19
  this.setAttribute('aria-valuemin', '0');
60
-
61
- _classPrivateFieldGet(this, _$itemsSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _updateItems));
20
+ this.#$itemsSlot.addEventListener('slotchange', this.#updateItems);
62
21
  }
63
22
 
64
23
  disconnectedCallback() {
65
- _classPrivateFieldGet(this, _$itemsSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _updateItems));
24
+ this.#$itemsSlot.removeEventListener('slotchange', this.#updateItems);
66
25
  }
67
26
 
68
27
  static get observedAttributes() {
@@ -77,8 +36,7 @@ defineCustomElement('sinch-vertical-stepper', (_$itemsSlot = new WeakMap(), _upd
77
36
  switch (name) {
78
37
  case 'index':
79
38
  {
80
- _classPrivateFieldGet(this, _updateItems).call(this);
81
-
39
+ this.#updateItems();
82
40
  break;
83
41
  }
84
42
  }
@@ -92,4 +50,25 @@ defineCustomElement('sinch-vertical-stepper', (_$itemsSlot = new WeakMap(), _upd
92
50
  return getAttribute(this, 'index', '1');
93
51
  }
94
52
 
95
- }));
53
+ #updateItems = () => {
54
+ const $items = this.#$itemsSlot.assignedElements();
55
+ const activeIndex = clampNumber(getIntegerAttribute(this, 'index', 0), 0, $items.length + 1);
56
+
57
+ for (let i = 0; i < $items.length; i++) {
58
+ const $el = $items[i];
59
+ const itemIndex = i + 1;
60
+ $el.setAttribute('data-index', String(itemIndex));
61
+
62
+ if (itemIndex === activeIndex) {
63
+ $el.setAttribute('data-progress', 'active');
64
+ } else if (itemIndex < activeIndex) {
65
+ $el.setAttribute('data-progress', 'done');
66
+ } else {
67
+ $el.removeAttribute('data-progress');
68
+ }
69
+ }
70
+
71
+ this.setAttribute('aria-valuemax', String($items.length));
72
+ this.setAttribute('aria-valuenow', String(clampNumber(activeIndex, 0, $items.length)));
73
+ };
74
+ });
@@ -1,46 +1,22 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$label, _$description, _$circleText;
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/check';
11
2
  import '../icons/exclamation';
12
3
  import { defineCustomElement, getAttribute, getLiteralAttribute, NectaryElement, updateAttribute, updateLiteralAttribute } from '../utils';
13
- const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:column;position:relative;width:100%;min-height:68px}#circle-wrapper{display:flex;flex-direction:row;align-items:flex-start;gap:8px;min-width:0}#circle{display:flex;align-items:center;justify-content:center;width:32px;height:32px;background-color:var(--sinch-color-snow-700);font:var(--sinch-font-title-s);line-height:32px;text-align:center;color:var(--sinch-color-stormy-500);border:1px solid transparent;border-radius:50%;box-sizing:border-box;--sinch-icon-size:20px}#label-wrapper{margin-top:4px;min-width:0;flex:1}#label{font:var(--sinch-font-title-s);color:var(--sinch-color-stormy-500);overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#description{font:var(--sinch-font-text-xs);color:var(--sinch-color-stormy-300);overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#icon-error,#icon-success{display:none}#content{display:none;padding:16px 0 16px 40px}#progress{position:absolute;width:1px;left:16px;top:32px;bottom:0;background-color:var(--sinch-color-snow-700);transform:translateX(-50%)}#bar{position:absolute;width:1px;height:0;background-color:var(--sinch-color-stormy-400);left:0;top:0}:host(:last-of-type) #progress{display:none}:host([data-progress=active]) #content{display:block}:host([data-progress=active]) #circle{color:var(--sinch-color-snow-100);background-color:var(--sinch-color-stormy-400)}:host([data-progress=done]) #circle{border-color:var(--sinch-color-stormy-400)}:host([data-progress=done]:not([status])) #icon-success{display:block}:host([data-progress=done][status=error]) #circle{background-color:var(--sinch-color-error-200);border-color:var(--sinch-color-stormy-400)}:host([data-progress=done][status=error]) #icon-error{display:block}:host([data-progress=done]:not([status=skip])) #circle-text{display:none}:host([data-progress=done]) #bar{height:100%}</style><div id="wrapper"><div id="progress"><div id="bar"></div></div><div id="circle-wrapper"><div id="circle" aria-hidden="true"><sinch-icon-check id="icon-success"></sinch-icon-check><sinch-icon-exclamation id="icon-error"></sinch-icon-exclamation><span id="circle-text"></span></div><div id="label-wrapper"><div id="label"></div><div id="description"></div></div></div><div id="content"><slot></slot></div></div>';
4
+ const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:column;position:relative;width:100%;min-height:68px}#circle-wrapper{display:flex;flex-direction:row;align-items:flex-start;gap:8px;min-width:0}#circle{display:flex;align-items:center;justify-content:center;width:32px;height:32px;background-color:var(--sinch-color-snow-700);font:var(--sinch-font-title-s);line-height:32px;text-align:center;color:var(--sinch-color-stormy-500);border:1px solid transparent;border-radius:50%;box-sizing:border-box;--sinch-size-icon:20px}#label-wrapper{margin-top:4px;min-width:0;flex:1}#label{font:var(--sinch-font-title-s);color:var(--sinch-color-stormy-500);overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#description{font:var(--sinch-font-text-xs);color:var(--sinch-color-stormy-300);overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#icon-error,#icon-success{display:none}#content{display:none;padding:16px 0 16px 40px}#progress{position:absolute;width:1px;left:16px;top:32px;bottom:0;background-color:var(--sinch-color-snow-700);transform:translateX(-50%)}#bar{position:absolute;width:1px;height:0;background-color:var(--sinch-color-stormy-400);left:0;top:0}:host(:last-of-type) #progress{display:none}:host([data-progress=active]) #content{display:block}:host([data-progress=active]) #circle{color:var(--sinch-color-snow-100);background-color:var(--sinch-color-stormy-400)}:host([data-progress=done]) #circle{border-color:var(--sinch-color-stormy-400)}:host([data-progress=done]:not([status])) #icon-success{display:block}:host([data-progress=done][status=error]) #circle{background-color:var(--sinch-color-error-200);border-color:var(--sinch-color-stormy-400)}:host([data-progress=done][status=error]) #icon-error{display:block}:host([data-progress=done]:not([status=skip])) #circle-text{display:none}:host([data-progress=done]) #bar{height:100%}</style><div id="wrapper"><div id="progress"><div id="bar"></div></div><div id="circle-wrapper"><div id="circle" aria-hidden="true"><sinch-icon-check id="icon-success"></sinch-icon-check><sinch-icon-exclamation id="icon-error"></sinch-icon-exclamation><span id="circle-text"></span></div><div id="label-wrapper"><div id="label"></div><div id="description"></div></div></div><div id="content"><slot></slot></div></div>';
14
5
  import { statusValues } from './utils';
15
6
  const template = document.createElement('template');
16
7
  template.innerHTML = templateHTML;
17
- defineCustomElement('sinch-vertical-stepper-item', (_$label = new WeakMap(), _$description = new WeakMap(), _$circleText = new WeakMap(), class extends NectaryElement {
8
+ defineCustomElement('sinch-vertical-stepper-item', class extends NectaryElement {
9
+ #$label;
10
+ #$description;
11
+ #$circleText;
12
+
18
13
  constructor() {
19
14
  super();
20
-
21
- _classPrivateFieldInitSpec(this, _$label, {
22
- writable: true,
23
- value: void 0
24
- });
25
-
26
- _classPrivateFieldInitSpec(this, _$description, {
27
- writable: true,
28
- value: void 0
29
- });
30
-
31
- _classPrivateFieldInitSpec(this, _$circleText, {
32
- writable: true,
33
- value: void 0
34
- });
35
-
36
15
  const shadowRoot = this.attachShadow();
37
16
  shadowRoot.appendChild(template.content.cloneNode(true));
38
-
39
- _classPrivateFieldSet(this, _$label, shadowRoot.querySelector('#label'));
40
-
41
- _classPrivateFieldSet(this, _$description, shadowRoot.querySelector('#description'));
42
-
43
- _classPrivateFieldSet(this, _$circleText, shadowRoot.querySelector('#circle-text'));
17
+ this.#$label = shadowRoot.querySelector('#label');
18
+ this.#$description = shadowRoot.querySelector('#description');
19
+ this.#$circleText = shadowRoot.querySelector('#circle-text');
44
20
  }
45
21
 
46
22
  connectedCallback() {}
@@ -55,19 +31,19 @@ defineCustomElement('sinch-vertical-stepper-item', (_$label = new WeakMap(), _$d
55
31
  switch (name) {
56
32
  case 'label':
57
33
  {
58
- _classPrivateFieldGet(this, _$label).textContent = newVal;
34
+ this.#$label.textContent = newVal;
59
35
  break;
60
36
  }
61
37
 
62
38
  case 'description':
63
39
  {
64
- _classPrivateFieldGet(this, _$description).textContent = newVal;
40
+ this.#$description.textContent = newVal;
65
41
  break;
66
42
  }
67
43
 
68
44
  case 'data-index':
69
45
  {
70
- _classPrivateFieldGet(this, _$circleText).textContent = newVal;
46
+ this.#$circleText.textContent = newVal;
71
47
  break;
72
48
  }
73
49
  }
@@ -97,4 +73,4 @@ defineCustomElement('sinch-vertical-stepper-item', (_$label = new WeakMap(), _$d
97
73
  updateLiteralAttribute(this, statusValues, 'status', value);
98
74
  }
99
75
 
100
- }));
76
+ });
@@ -1,12 +0,0 @@
1
- import '../popover';
2
- import type { TSinchDropdownElement, TSinchDropdownReact } from './types';
3
- declare global {
4
- namespace JSX {
5
- interface IntrinsicElements {
6
- 'sinch-dropdown': TSinchDropdownReact;
7
- }
8
- }
9
- interface HTMLElementTagNameMap {
10
- 'sinch-dropdown': TSinchDropdownElement;
11
- }
12
- }