@nectary/components 0.39.0 → 0.40.0

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