@getflip/swirl-components 0.85.1 → 0.87.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 (152) hide show
  1. package/components.json +712 -145
  2. package/dist/cjs/index-506fe4ea.js +32 -8
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/swirl-app-layout_7.cjs.entry.js +8 -3
  5. package/dist/cjs/swirl-autocomplete.cjs.entry.js +99 -15
  6. package/dist/cjs/swirl-button.cjs.entry.js +1 -1
  7. package/dist/cjs/swirl-components.cjs.js +1 -1
  8. package/dist/cjs/swirl-emoji-clap.cjs.entry.js +23 -0
  9. package/dist/cjs/swirl-emoji-happy.cjs.entry.js +23 -0
  10. package/dist/cjs/swirl-emoji-idea.cjs.entry.js +23 -0
  11. package/dist/cjs/swirl-emoji-love.cjs.entry.js +23 -0
  12. package/dist/cjs/swirl-emoji-sad.cjs.entry.js +23 -0
  13. package/dist/cjs/swirl-emoji-thumbs-up.cjs.entry.js +23 -0
  14. package/dist/cjs/swirl-emoji.cjs.entry.js +23 -0
  15. package/dist/cjs/swirl-form-control.cjs.entry.js +1 -1
  16. package/dist/cjs/swirl-icon.cjs.entry.js +3 -3
  17. package/dist/cjs/{swirl-option-list.cjs.entry.js → swirl-option-list_2.cjs.entry.js} +29 -0
  18. package/dist/cjs/swirl-select.cjs.entry.js +2 -2
  19. package/dist/cjs/swirl-tab-bar.cjs.entry.js +2 -2
  20. package/dist/cjs/swirl-tab.cjs.entry.js +1 -0
  21. package/dist/cjs/swirl-tabs.cjs.entry.js +1 -0
  22. package/dist/cjs/swirl-text-input.cjs.entry.js +1 -1
  23. package/dist/collection/assets/pdfjs/pdf.worker.min.js +0 -22
  24. package/dist/collection/collection-manifest.json +7 -0
  25. package/dist/collection/components/swirl-autocomplete/swirl-autocomplete.css +15 -0
  26. package/dist/collection/components/swirl-autocomplete/swirl-autocomplete.js +155 -26
  27. package/dist/collection/components/swirl-autocomplete/swirl-autocomplete.spec.js +12 -14
  28. package/dist/collection/components/swirl-autocomplete/swirl-autocomplete.stories.js +15 -7
  29. package/dist/collection/components/swirl-button/swirl-button.css +5 -5
  30. package/dist/collection/components/swirl-emoji/emojis/swirl-emoji-clap.js +70 -0
  31. package/dist/collection/components/swirl-emoji/emojis/swirl-emoji-happy.js +70 -0
  32. package/dist/collection/components/swirl-emoji/emojis/swirl-emoji-idea.js +70 -0
  33. package/dist/collection/components/swirl-emoji/emojis/swirl-emoji-love.js +70 -0
  34. package/dist/collection/components/swirl-emoji/emojis/swirl-emoji-sad.js +70 -0
  35. package/dist/collection/components/swirl-emoji/emojis/swirl-emoji-thumbs-up.js +70 -0
  36. package/dist/collection/components/swirl-emoji/swirl-emoji.css +3 -0
  37. package/dist/collection/components/swirl-emoji/swirl-emoji.js +86 -0
  38. package/dist/collection/components/swirl-emoji/swirl-emoji.spec.js +17 -0
  39. package/dist/collection/components/swirl-emoji/swirl-emoji.stories.js +28 -0
  40. package/dist/collection/components/swirl-emoji/swirl-emoji.types.js +1 -0
  41. package/dist/collection/components/swirl-form-control/swirl-form-control.css +19 -0
  42. package/dist/collection/components/swirl-icon/swirl-icon.js +1 -1
  43. package/dist/collection/components/swirl-option-list/swirl-option-list.js +5 -0
  44. package/dist/collection/components/swirl-resource-list-item/swirl-resource-list-item.css +44 -10
  45. package/dist/collection/components/swirl-resource-list-item/swirl-resource-list-item.js +25 -2
  46. package/dist/collection/components/swirl-resource-list-item/swirl-resource-list-item.stories.js +15 -4
  47. package/dist/collection/components/swirl-select/swirl-select.css +2 -1
  48. package/dist/collection/components/swirl-select/swirl-select.js +1 -1
  49. package/dist/collection/components/swirl-tab/swirl-tab.js +18 -0
  50. package/dist/collection/components/swirl-tab/swirl-tab.stories.js +1 -0
  51. package/dist/collection/components/swirl-tab-bar/swirl-tab-bar.css +7 -2
  52. package/dist/collection/components/swirl-tab-bar/swirl-tab-bar.js +1 -1
  53. package/dist/collection/components/swirl-tab-bar/swirl-tab-bar.stories.js +2 -0
  54. package/dist/collection/components/swirl-tabs/swirl-tabs.js +1 -0
  55. package/dist/collection/components/swirl-tabs/swirl-tabs.stories.js +2 -2
  56. package/dist/collection/components/swirl-text-input/swirl-text-input.css +8 -0
  57. package/dist/collection/components/swirl-text-input/swirl-text-input.stories.js +1 -0
  58. package/dist/components/assets/pdfjs/pdf.worker.min.js +0 -22
  59. package/dist/components/swirl-autocomplete.js +142 -38
  60. package/dist/components/swirl-button2.js +1 -1
  61. package/dist/components/swirl-emoji-clap.d.ts +11 -0
  62. package/dist/components/swirl-emoji-clap.js +41 -0
  63. package/dist/components/swirl-emoji-happy.d.ts +11 -0
  64. package/dist/components/swirl-emoji-happy.js +41 -0
  65. package/dist/components/swirl-emoji-idea.d.ts +11 -0
  66. package/dist/components/swirl-emoji-idea.js +41 -0
  67. package/dist/components/swirl-emoji-love.d.ts +11 -0
  68. package/dist/components/swirl-emoji-love.js +41 -0
  69. package/dist/components/swirl-emoji-sad.d.ts +11 -0
  70. package/dist/components/swirl-emoji-sad.js +41 -0
  71. package/dist/components/swirl-emoji-thumbs-up.d.ts +11 -0
  72. package/dist/components/swirl-emoji-thumbs-up.js +41 -0
  73. package/dist/components/swirl-emoji.d.ts +11 -0
  74. package/dist/components/swirl-emoji.js +42 -0
  75. package/dist/components/swirl-form-control.js +1 -1
  76. package/dist/components/swirl-icon.js +3 -3
  77. package/dist/components/swirl-option-list2.js +5 -0
  78. package/dist/components/swirl-resource-list-item2.js +9 -3
  79. package/dist/components/swirl-select.js +2 -2
  80. package/dist/components/swirl-tab-bar2.js +2 -2
  81. package/dist/components/swirl-tab.js +2 -0
  82. package/dist/components/swirl-tabs.js +1 -0
  83. package/dist/components/swirl-text-input2.js +1 -1
  84. package/dist/esm/index-99d0060d.js +32 -8
  85. package/dist/esm/loader.js +1 -1
  86. package/dist/esm/swirl-app-layout_7.entry.js +8 -3
  87. package/dist/esm/swirl-autocomplete.entry.js +99 -15
  88. package/dist/esm/swirl-button.entry.js +1 -1
  89. package/dist/esm/swirl-components.js +1 -1
  90. package/dist/esm/swirl-emoji-clap.entry.js +19 -0
  91. package/dist/esm/swirl-emoji-happy.entry.js +19 -0
  92. package/dist/esm/swirl-emoji-idea.entry.js +19 -0
  93. package/dist/esm/swirl-emoji-love.entry.js +19 -0
  94. package/dist/esm/swirl-emoji-sad.entry.js +19 -0
  95. package/dist/esm/swirl-emoji-thumbs-up.entry.js +19 -0
  96. package/dist/esm/swirl-emoji.entry.js +19 -0
  97. package/dist/esm/swirl-form-control.entry.js +1 -1
  98. package/dist/esm/swirl-icon.entry.js +3 -3
  99. package/dist/esm/{swirl-option-list.entry.js → swirl-option-list_2.entry.js} +29 -1
  100. package/dist/esm/swirl-select.entry.js +2 -2
  101. package/dist/esm/swirl-tab-bar.entry.js +2 -2
  102. package/dist/esm/swirl-tab.entry.js +1 -0
  103. package/dist/esm/swirl-tabs.entry.js +1 -0
  104. package/dist/esm/swirl-text-input.entry.js +1 -1
  105. package/dist/swirl-components/p-01a47a2e.entry.js +1 -0
  106. package/dist/swirl-components/{p-902fc533.entry.js → p-0f979ef7.entry.js} +1 -1
  107. package/dist/swirl-components/p-2d16eca4.entry.js +1 -0
  108. package/dist/swirl-components/p-377f7d35.entry.js +1 -0
  109. package/dist/swirl-components/p-3a430e14.entry.js +1 -0
  110. package/dist/swirl-components/p-66551e51.entry.js +1 -0
  111. package/dist/swirl-components/p-7dafac36.entry.js +1 -0
  112. package/dist/swirl-components/p-8153cd85.entry.js +1 -0
  113. package/dist/swirl-components/p-a298fdf9.entry.js +1 -0
  114. package/dist/swirl-components/p-b5be788e.entry.js +1 -0
  115. package/dist/swirl-components/p-bf258885.entry.js +1 -0
  116. package/dist/swirl-components/{p-a3e6a921.entry.js → p-c8870a5b.entry.js} +1 -1
  117. package/dist/swirl-components/p-cfbfb7be.entry.js +1 -0
  118. package/dist/swirl-components/p-e1daecf5.entry.js +1 -0
  119. package/dist/swirl-components/p-e9b2ed15.entry.js +1 -0
  120. package/dist/swirl-components/{p-ce1cd2e1.entry.js → p-e9e6bea8.entry.js} +1 -1
  121. package/dist/swirl-components/p-eb3c6b4d.entry.js +1 -0
  122. package/dist/swirl-components/swirl-components.css +1 -1
  123. package/dist/swirl-components/swirl-components.esm.js +1 -1
  124. package/dist/types/components/swirl-autocomplete/swirl-autocomplete.d.ts +11 -4
  125. package/dist/types/components/swirl-autocomplete/swirl-autocomplete.stories.d.ts +7 -0
  126. package/dist/types/components/swirl-emoji/emojis/swirl-emoji-clap.d.ts +6 -0
  127. package/dist/types/components/swirl-emoji/emojis/swirl-emoji-happy.d.ts +6 -0
  128. package/dist/types/components/swirl-emoji/emojis/swirl-emoji-idea.d.ts +6 -0
  129. package/dist/types/components/swirl-emoji/emojis/swirl-emoji-love.d.ts +6 -0
  130. package/dist/types/components/swirl-emoji/emojis/swirl-emoji-sad.d.ts +6 -0
  131. package/dist/types/components/swirl-emoji/emojis/swirl-emoji-thumbs-up.d.ts +6 -0
  132. package/dist/types/components/swirl-emoji/swirl-emoji.d.ts +7 -0
  133. package/dist/types/components/swirl-emoji/swirl-emoji.stories.d.ts +20 -0
  134. package/dist/types/components/swirl-emoji/swirl-emoji.types.d.ts +1 -0
  135. package/dist/types/components/swirl-icon/swirl-icon.d.ts +1 -1
  136. package/dist/types/components/swirl-resource-list-item/swirl-resource-list-item.d.ts +2 -0
  137. package/dist/types/components/swirl-tab/swirl-tab.d.ts +1 -0
  138. package/dist/types/components/swirl-tab-bar/swirl-tab-bar.d.ts +1 -0
  139. package/dist/types/components.d.ts +138 -7
  140. package/dist/types/index.d.ts +1 -0
  141. package/package.json +2 -2
  142. package/vscode-data.json +139 -4
  143. package/dist/cjs/swirl-tag.cjs.entry.js +0 -30
  144. package/dist/esm/swirl-tag.entry.js +0 -26
  145. package/dist/swirl-components/p-06012b5a.entry.js +0 -1
  146. package/dist/swirl-components/p-18a16156.entry.js +0 -1
  147. package/dist/swirl-components/p-6f178b75.entry.js +0 -1
  148. package/dist/swirl-components/p-7521afa2.entry.js +0 -1
  149. package/dist/swirl-components/p-9c5e2b99.entry.js +0 -1
  150. package/dist/swirl-components/p-b86c0a97.entry.js +0 -1
  151. package/dist/swirl-components/p-c3d23855.entry.js +0 -1
  152. package/dist/swirl-components/p-f299ab14.entry.js +0 -1
@@ -60,6 +60,13 @@
60
60
  "./components/swirl-date-input/swirl-date-input.js",
61
61
  "./components/swirl-date-picker/swirl-date-picker.js",
62
62
  "./components/swirl-description-list/swirl-description-list.js",
63
+ "./components/swirl-emoji/emojis/swirl-emoji-clap.js",
64
+ "./components/swirl-emoji/swirl-emoji.js",
65
+ "./components/swirl-emoji/emojis/swirl-emoji-happy.js",
66
+ "./components/swirl-emoji/emojis/swirl-emoji-idea.js",
67
+ "./components/swirl-emoji/emojis/swirl-emoji-love.js",
68
+ "./components/swirl-emoji/emojis/swirl-emoji-sad.js",
69
+ "./components/swirl-emoji/emojis/swirl-emoji-thumbs-up.js",
63
70
  "./components/swirl-empty-state/swirl-empty-state.js",
64
71
  "./components/swirl-file-uploader/swirl-file-uploader.js",
65
72
  "./components/swirl-file-viewer/swirl-file-viewer.js",
@@ -18,6 +18,7 @@
18
18
  padding-bottom: var(--s-space-8);
19
19
  border-radius: var(--s-border-radius-sm);
20
20
  background-color: var(--s-surface-overlay-default);
21
+ animation: autocomplete-enter 0.1s;
21
22
  box-shadow: var(--s-shadow-level-1);
22
23
  }
23
24
 
@@ -31,3 +32,17 @@
31
32
  justify-content: center;
32
33
  align-items: center;
33
34
  }
35
+
36
+ .autocomplete__multi-select-tags {
37
+ margin-bottom: var(--s-space-4);
38
+ margin-top: var(--swirl-autocomplete-tags-margin-top);
39
+ }
40
+
41
+ @keyframes autocomplete-enter {
42
+ from {
43
+ opacity: 0;
44
+ }
45
+ to {
46
+ opacity: 1;
47
+ }
48
+ }
@@ -4,19 +4,57 @@ import classnames from "classnames";
4
4
  import { debounce } from "../../utils";
5
5
  export class SwirlAutocomplete {
6
6
  constructor() {
7
- this.onChange = debounce(async (event) => {
8
- this.value = event.detail;
9
- this.valueChange.emit(this.value);
10
- this.updateSuggestions();
7
+ this.onChange = (event) => {
8
+ event.stopPropagation();
9
+ this.updateTerm(event);
10
+ };
11
+ this.updateTerm = debounce(async (event) => {
12
+ this.updateSuggestions(event.detail);
11
13
  this.open();
14
+ if (this.multiSelect) {
15
+ return;
16
+ }
17
+ if (!Boolean(event.detail) || event.detail === "") {
18
+ this.value = undefined;
19
+ this.valueChange.emit(this.value);
20
+ }
12
21
  }, 250, false);
13
- this.onSelect = (event) => {
14
- if (Boolean(event.detail[0])) {
15
- this.value = event.detail[0];
22
+ this.onSelect = async (event) => {
23
+ event.stopPropagation();
24
+ if (this.multiSelect) {
25
+ const selectedItemIds = event.detail;
26
+ const unselectedItemIds = this.suggestions
27
+ .filter((suggestion) => !selectedItemIds.includes(suggestion.id))
28
+ .map((suggestion) => suggestion.id);
29
+ this.value = [
30
+ ...this.value.filter((item) => !unselectedItemIds.includes(item.id)),
31
+ ...this.suggestions.filter((suggestion) => selectedItemIds.includes(suggestion.id) &&
32
+ !this.value.some((item) => item.id === suggestion.id)),
33
+ ];
16
34
  this.valueChange.emit(this.value);
35
+ this.inputEl.querySelector("input")?.focus();
36
+ await this.updateSuggestions(this.inputEl.querySelector("input").value);
37
+ }
38
+ else {
39
+ if (Boolean(event.detail[0])) {
40
+ const itemId = event.detail[0];
41
+ const suggestion = this.suggestions.find((suggestion) => suggestion.id === itemId);
42
+ if (!Boolean(suggestion)) {
43
+ return;
44
+ }
45
+ this.value = suggestion;
46
+ this.valueChange.emit(this.value);
47
+ this.inputEl.querySelector("input")?.focus();
48
+ this.close();
49
+ }
17
50
  }
18
- this.inputEl.querySelector("input")?.focus();
19
- this.close();
51
+ };
52
+ this.onRemoveValue = (value) => {
53
+ if (!Array.isArray(this.value)) {
54
+ return;
55
+ }
56
+ this.value = this.value.filter((item) => item.id !== value);
57
+ this.valueChange.emit(this.value);
20
58
  };
21
59
  this.onFocusOut = (event) => {
22
60
  const relatedTarget = event.relatedTarget;
@@ -31,6 +69,7 @@ export class SwirlAutocomplete {
31
69
  this.onKeyDown = (event) => {
32
70
  if (event.code === "Escape") {
33
71
  event.preventDefault();
72
+ event.stopPropagation();
34
73
  this.inputEl.querySelector("input").focus();
35
74
  this.close();
36
75
  }
@@ -51,6 +90,8 @@ export class SwirlAutocomplete {
51
90
  this.maxLength = undefined;
52
91
  this.menuLabel = "Suggestions";
53
92
  this.mode = undefined;
93
+ this.multiSelect = undefined;
94
+ this.placeholder = undefined;
54
95
  this.required = undefined;
55
96
  this.spellCheck = undefined;
56
97
  this.swirlAriaDescribedby = undefined;
@@ -63,6 +104,7 @@ export class SwirlAutocomplete {
63
104
  componentWillLoad() {
64
105
  const index = document.querySelectorAll("swirl-datepicker").length;
65
106
  this.id = `autocomplete-${index}`;
107
+ this.handleInitialValue();
66
108
  }
67
109
  onWindowClick(event) {
68
110
  const target = event.target;
@@ -70,6 +112,9 @@ export class SwirlAutocomplete {
70
112
  this.close();
71
113
  }
72
114
  }
115
+ watchMultiSelect() {
116
+ this.handleInitialValue();
117
+ }
73
118
  async close() {
74
119
  if (!this.active) {
75
120
  return;
@@ -77,6 +122,16 @@ export class SwirlAutocomplete {
77
122
  if (this.disableAutoUpdate) {
78
123
  this.disableAutoUpdate();
79
124
  }
125
+ const inputEl = this.inputEl.querySelector("input");
126
+ if (Boolean(inputEl)) {
127
+ if (this.multiSelect) {
128
+ inputEl.value = "";
129
+ }
130
+ else {
131
+ inputEl.value =
132
+ this.value?.label || "";
133
+ }
134
+ }
80
135
  this.active = false;
81
136
  }
82
137
  async open() {
@@ -89,8 +144,9 @@ export class SwirlAutocomplete {
89
144
  if (this.disableAutoUpdate) {
90
145
  this.disableAutoUpdate();
91
146
  }
92
- this.disableAutoUpdate = autoUpdate(this.inputEl, this.listboxContainerEl, this.reposition.bind(this));
147
+ this.disableAutoUpdate = autoUpdate(this.inputEl, this.listboxContainerEl, this.reposition.bind(this), { animationFrame: true });
93
148
  this.listboxContainerEl.scrollTop = 0;
149
+ this.updateSuggestions(this.inputEl.querySelector("input").value);
94
150
  });
95
151
  }
96
152
  async reposition() {
@@ -103,22 +159,47 @@ export class SwirlAutocomplete {
103
159
  strategy: "fixed",
104
160
  });
105
161
  }
106
- async updateSuggestions() {
162
+ async updateSuggestions(term) {
107
163
  this.loading = true;
108
164
  this.suggestions = [];
109
- this.suggestions = await this.generateSuggestions(this.value);
165
+ this.suggestions = await this.generateSuggestions(term);
110
166
  this.loading = false;
111
167
  }
168
+ handleInitialValue() {
169
+ if (this.multiSelect && !Array.isArray(this.value)) {
170
+ this.value = [];
171
+ }
172
+ if (!this.multiSelect && Array.isArray(this.value)) {
173
+ this.value = undefined;
174
+ }
175
+ }
112
176
  render() {
113
177
  const suggestionsMenuId = `${this.id}-suggestions`;
178
+ const clearable = this.clearable && !this.multiSelect;
179
+ const optionListValue = this.multiSelect
180
+ ? this.value.map((item) => item.id)
181
+ : Boolean(this.value)
182
+ ? [this.value.id]
183
+ : [];
184
+ const valueLabel = this.multiSelect
185
+ ? undefined
186
+ : this.value?.label || "";
114
187
  const className = classnames("autocomplete", {
115
188
  "autocomplete--inactive": !this.active,
116
189
  });
117
- return (h(Host, null, h("div", { class: className, onFocusout: this.onFocusOut, onKeyDown: this.onKeyDown }, h("swirl-text-input", { autoSelect: this.autoSelect, class: "autocomplete__input", clearable: this.clearable, clearButtonLabel: this.clearButtonLabel, disabled: this.disabled, disableDynamicWidth: true, id: this.id, inline: this.inline, invalid: this.invalid, onInputFocus: this.onFocus, onKeyDown: this.onInputKeyDown, onValueChange: this.onChange, maxLength: this.maxLength, mode: this.mode, ref: (el) => (this.inputEl = el), required: this.required, spellCheck: this.spellCheck, swirlAriaAutocomplete: "list", swirlAriaControls: suggestionsMenuId, swirlAriaDescribedby: this.swirlAriaDescribedby, swirlAriaExpanded: String(this.active), swirlRole: "combobox", value: this.value }), h("div", { class: "autocomplete__listbox-container", ref: (el) => (this.listboxContainerEl = el), style: {
190
+ return (h(Host, null, h("div", { class: className, onFocusout: this.onFocusOut, onKeyDown: this.onKeyDown }, this.multiSelect &&
191
+ Array.isArray(this.value) &&
192
+ this.value.length > 0 && (h("div", { class: "autocomplete__multi-select-tags" }, h("swirl-stack", { orientation: "horizontal", spacing: "8", wrap: true }, this.value.map((item) => {
193
+ return (h("swirl-tag", { key: item.id, label: item.label,
194
+ // eslint-disable-next-line react/jsx-no-bind
195
+ onRemove: () => this.onRemoveValue(item.id), removable: !this.disabled }));
196
+ })))), h("swirl-text-input", { autoSelect: this.autoSelect, class: "autocomplete__input", clearable: clearable, clearButtonLabel: this.clearButtonLabel, disabled: this.disabled, disableDynamicWidth: true, id: this.id, inline: this.inline, invalid: this.invalid, onInputFocus: this.onFocus, onKeyDown: this.onInputKeyDown, onValueChange: this.onChange, maxLength: this.maxLength, mode: this.mode, placeholder: this.placeholder, ref: (el) => (this.inputEl = el), required: this.required, spellCheck: this.spellCheck, swirlAriaAutocomplete: "list", swirlAriaControls: suggestionsMenuId, swirlAriaDescribedby: this.swirlAriaDescribedby, swirlAriaExpanded: String(this.active), swirlRole: "combobox", value: valueLabel }), h("div", { class: "autocomplete__listbox-container", ref: (el) => (this.listboxContainerEl = el), style: {
118
197
  top: Boolean(this.position) ? `${this.position?.y}px` : "",
119
198
  left: Boolean(this.position) ? `${this.position?.x}px` : "",
120
199
  width: `${this.inputEl?.getBoundingClientRect().width + 32}px`,
121
- } }, this.loading && (h("div", { class: "autocomplete__spinner" }, h("swirl-spinner", null))), this.suggestions.length > 0 && (h("swirl-option-list", { label: this.menuLabel, onValueChange: this.onSelect, optionListId: suggestionsMenuId, ref: (el) => (this.listboxEl = el), value: [this.value] }, this.suggestions.map((suggestion) => (h("swirl-option-list-item", { selected: this.value === suggestion.label, key: suggestion.id, disabled: suggestion.disabled, label: suggestion.label, value: suggestion.label })))))))));
200
+ } }, this.loading && (h("div", { class: "autocomplete__spinner" }, h("swirl-spinner", null))), this.suggestions.length > 0 && (h("swirl-option-list", { allowDeselect: this.multiSelect === true, label: this.menuLabel, multiSelect: this.multiSelect, onValueChange: this.onSelect, optionListId: suggestionsMenuId, ref: (el) => (this.listboxEl = el), value: optionListValue }, this.suggestions.map((suggestion) => (h("swirl-option-list-item", { selected: Array.isArray(this.value)
201
+ ? this.value.some((item) => item.id === suggestion.id)
202
+ : this.value?.id === suggestion.id, key: suggestion.id, disabled: suggestion.disabled, label: suggestion.label, value: suggestion.id })))))))));
122
203
  }
123
204
  static get is() { return "swirl-autocomplete"; }
124
205
  static get encapsulation() { return "scoped"; }
@@ -208,8 +289,8 @@ export class SwirlAutocomplete {
208
289
  "type": "unknown",
209
290
  "mutable": true,
210
291
  "complexType": {
211
- "original": "(\n currentValue: string\n ) => Promise<SwirlAutocompleteSuggestion[]>",
212
- "resolved": "(currentValue: string) => Promise<SwirlAutocompleteSuggestion[]>",
292
+ "original": "(\n term: string\n ) => Promise<SwirlAutocompleteSuggestion[]>",
293
+ "resolved": "(term: string) => Promise<SwirlAutocompleteSuggestion[]>",
213
294
  "references": {
214
295
  "Promise": {
215
296
  "location": "global"
@@ -319,6 +400,40 @@ export class SwirlAutocomplete {
319
400
  "attribute": "mode",
320
401
  "reflect": false
321
402
  },
403
+ "multiSelect": {
404
+ "type": "boolean",
405
+ "mutable": false,
406
+ "complexType": {
407
+ "original": "boolean",
408
+ "resolved": "boolean",
409
+ "references": {}
410
+ },
411
+ "required": false,
412
+ "optional": true,
413
+ "docs": {
414
+ "tags": [],
415
+ "text": ""
416
+ },
417
+ "attribute": "multi-select",
418
+ "reflect": false
419
+ },
420
+ "placeholder": {
421
+ "type": "string",
422
+ "mutable": false,
423
+ "complexType": {
424
+ "original": "string",
425
+ "resolved": "string",
426
+ "references": {}
427
+ },
428
+ "required": false,
429
+ "optional": true,
430
+ "docs": {
431
+ "tags": [],
432
+ "text": ""
433
+ },
434
+ "attribute": "placeholder",
435
+ "reflect": false
436
+ },
322
437
  "required": {
323
438
  "type": "boolean",
324
439
  "mutable": false,
@@ -371,21 +486,24 @@ export class SwirlAutocomplete {
371
486
  "reflect": false
372
487
  },
373
488
  "value": {
374
- "type": "string",
489
+ "type": "unknown",
375
490
  "mutable": true,
376
491
  "complexType": {
377
- "original": "string",
378
- "resolved": "string",
379
- "references": {}
492
+ "original": "SwirlAutocompleteValue",
493
+ "resolved": "SwirlAutocompleteSuggestion[] | { disabled?: boolean; id: string; label: string; }",
494
+ "references": {
495
+ "SwirlAutocompleteValue": {
496
+ "location": "local",
497
+ "path": "/home/runner/work/swirl/swirl/packages/swirl-components/src/components/swirl-autocomplete/swirl-autocomplete.tsx"
498
+ }
499
+ }
380
500
  },
381
501
  "required": false,
382
502
  "optional": true,
383
503
  "docs": {
384
504
  "tags": [],
385
505
  "text": ""
386
- },
387
- "attribute": "value",
388
- "reflect": true
506
+ }
389
507
  }
390
508
  };
391
509
  }
@@ -409,13 +527,24 @@ export class SwirlAutocomplete {
409
527
  "text": ""
410
528
  },
411
529
  "complexType": {
412
- "original": "string",
413
- "resolved": "string",
414
- "references": {}
530
+ "original": "SwirlAutocompleteValue",
531
+ "resolved": "SwirlAutocompleteSuggestion[] | { disabled?: boolean; id: string; label: string; }",
532
+ "references": {
533
+ "SwirlAutocompleteValue": {
534
+ "location": "local",
535
+ "path": "/home/runner/work/swirl/swirl/packages/swirl-components/src/components/swirl-autocomplete/swirl-autocomplete.tsx"
536
+ }
537
+ }
415
538
  }
416
539
  }];
417
540
  }
418
541
  static get elementRef() { return "el"; }
542
+ static get watchers() {
543
+ return [{
544
+ "propName": "multiSelect",
545
+ "methodName": "watchMultiSelect"
546
+ }];
547
+ }
419
548
  static get listeners() {
420
549
  return [{
421
550
  "name": "click",
@@ -38,12 +38,12 @@ describe("swirl-autocomplete", () => {
38
38
  expect(page.root).toEqualHtml(`
39
39
  <swirl-autocomplete>
40
40
  <div class="autocomplete">
41
- <swirl-text-input class="autocomplete__input" clearable="" clearbuttonlabel="Clear input" disabledynamicwidth="" swirlariaautocomplete="list" swirlariacontrols="autocomplete-0-suggestions" swirlariaexpanded="true" swirlrole="combobox" id="autocomplete-0"></swirl-text-input>
41
+ <swirl-text-input class="autocomplete__input" clearable="" clearbuttonlabel="Clear input" disabledynamicwidth="" swirlariaautocomplete="list" swirlariacontrols="autocomplete-0-suggestions" swirlariaexpanded="true" swirlrole="combobox" id="autocomplete-0" value=""></swirl-text-input>
42
42
  <div class="autocomplete__listbox-container" style="width: 32px;">
43
43
  <swirl-option-list label="Suggestions" optionlistid="autocomplete-0-suggestions">
44
- <swirl-option-list-item label="Item #1" value="Item #1"></swirl-option-list-item>
45
- <swirl-option-list-item disabled="" label="Item #2" value="Item #2"></swirl-option-list-item>
46
- <swirl-option-list-item label="Item #3" value="Item #3"></swirl-option-list-item>
44
+ <swirl-option-list-item label="Item #1" value="1"></swirl-option-list-item>
45
+ <swirl-option-list-item disabled="" label="Item #2" value="2"></swirl-option-list-item>
46
+ <swirl-option-list-item label="Item #3" value="3"></swirl-option-list-item>
47
47
  </swirl-option-list>
48
48
  </div>
49
49
  </div>
@@ -61,12 +61,12 @@ describe("swirl-autocomplete", () => {
61
61
  input.dispatchEvent(new CustomEvent("valueChange", { detail: "#3" }));
62
62
  await page.waitForChanges();
63
63
  expect(page.root).toEqualHtml(`
64
- <swirl-autocomplete value="#3">
64
+ <swirl-autocomplete>
65
65
  <div class="autocomplete">
66
- <swirl-text-input class="autocomplete__input" clearable="" clearbuttonlabel="Clear input" disabledynamicwidth="" swirlariaautocomplete="list" swirlariacontrols="autocomplete-0-suggestions" swirlariaexpanded="true" swirlrole="combobox" id="autocomplete-0" value="#3"></swirl-text-input>
66
+ <swirl-text-input class="autocomplete__input" clearable="" clearbuttonlabel="Clear input" disabledynamicwidth="" swirlariaautocomplete="list" swirlariacontrols="autocomplete-0-suggestions" swirlariaexpanded="true" swirlrole="combobox" id="autocomplete-0" value=""></swirl-text-input>
67
67
  <div class="autocomplete__listbox-container" style="width: 32px;">
68
68
  <swirl-option-list label="Suggestions" optionlistid="autocomplete-0-suggestions">
69
- <swirl-option-list-item label="Item #3" value="Item #3"></swirl-option-list-item>
69
+ <swirl-option-list-item label="Item #3" value="3"></swirl-option-list-item>
70
70
  </swirl-option-list>
71
71
  </div>
72
72
  </div>
@@ -84,15 +84,15 @@ describe("swirl-autocomplete", () => {
84
84
  input.dispatchEvent(new CustomEvent("valueChange", { detail: "#3" }));
85
85
  await page.waitForChanges();
86
86
  const listbox = page.root.querySelector("swirl-option-list");
87
- listbox.dispatchEvent(new CustomEvent("valueChange", { detail: ["Item #3"] }));
87
+ listbox.dispatchEvent(new CustomEvent("valueChange", { detail: ["3"] }));
88
88
  await page.waitForChanges();
89
89
  expect(page.root).toEqualHtml(`
90
- <swirl-autocomplete value="Item #3">
90
+ <swirl-autocomplete>
91
91
  <div class="autocomplete autocomplete--inactive">
92
92
  <swirl-text-input class="autocomplete__input" clearable="" clearbuttonlabel="Clear input" disabledynamicwidth="" swirlariaautocomplete="list" swirlariacontrols="autocomplete-0-suggestions" swirlariaexpanded="false" swirlrole="combobox" id="autocomplete-0" value="Item #3"></swirl-text-input>
93
93
  <div class="autocomplete__listbox-container" style="width: 32px;">
94
94
  <swirl-option-list label="Suggestions" optionlistid="autocomplete-0-suggestions">
95
- <swirl-option-list-item label="Item #3" selected="" value="Item #3"></swirl-option-list-item>
95
+ <swirl-option-list-item label="Item #3" selected="" value="3"></swirl-option-list-item>
96
96
  </swirl-option-list>
97
97
  </div>
98
98
  </div>
@@ -112,9 +112,7 @@ describe("swirl-autocomplete", () => {
112
112
  input.dispatchEvent(new CustomEvent("valueChange", { detail: "#3" }));
113
113
  await page.waitForChanges();
114
114
  const listbox = page.root.querySelector("swirl-option-list");
115
- listbox.dispatchEvent(new CustomEvent("valueChange", { detail: ["Item #3"] }));
116
- expect(spy.mock.calls[0][0].detail).toBe("#3");
117
- input.dispatchEvent(new CustomEvent("valueChange", { detail: "#3" }));
118
- expect(spy.mock.calls[1][0].detail).toBe("Item #3");
115
+ listbox.dispatchEvent(new CustomEvent("valueChange", { detail: ["3"] }));
116
+ expect(spy.mock.calls[0][0].detail).toEqual({ id: "3", label: "Item #3" });
119
117
  });
120
118
  });
@@ -3,6 +3,13 @@ import Docs from "./swirl-autocomplete.mdx";
3
3
  export default {
4
4
  component: "swirl-autocomplete",
5
5
  tags: ["autodocs"],
6
+ argTypes: {
7
+ value: {
8
+ control: {
9
+ type: "object",
10
+ },
11
+ },
12
+ },
6
13
  parameters: {
7
14
  docs: {
8
15
  page: Docs,
@@ -16,16 +23,16 @@ export default {
16
23
 
17
24
  const suggestions = [
18
25
  {
19
- id: "1",
26
+ id: "item-1",
20
27
  label: "Item #1",
21
28
  },
22
29
  {
23
30
  disabled: true,
24
- id: "2",
31
+ id: "item-2",
25
32
  label: "Item #2",
26
33
  },
27
34
  {
28
- id: "3",
35
+ id: "item-3",
29
36
  label: "Item #3",
30
37
  },
31
38
  ];
@@ -49,20 +56,21 @@ export default {
49
56
  const Template = (args) => {
50
57
  const formControl = document.createElement("swirl-form-control");
51
58
  const element = generateStoryElement("swirl-autocomplete", args);
59
+ formControl.setAttribute("disabled", args.disabled ? "true" : "false");
52
60
  formControl.label = "Autocomplete";
53
61
  const suggestions = [
54
62
  {
55
- id: "1",
63
+ id: "item-1",
56
64
  label: "Item #1",
57
65
  },
58
66
  {
59
67
  disabled: true,
60
- id: "2",
68
+ id: "item-2",
61
69
  label: "Item #2",
62
70
  },
63
71
  {
64
- id: "3",
65
- label: "Item #3",
72
+ id: "item-3",
73
+ label: "Item #3 with a longer label",
66
74
  },
67
75
  ];
68
76
  element.generateSuggestions = async (value) => {
@@ -39,7 +39,7 @@
39
39
 
40
40
  .button:disabled {
41
41
  color: var(--s-text-disabled);
42
- background-color: var(--swirl-ghost-button-background-default);
42
+ background-color: var(--swirl-ghost-button-background-disabled);
43
43
  cursor: default;
44
44
  }
45
45
 
@@ -100,19 +100,19 @@
100
100
 
101
101
  .button--variant-flat {
102
102
  color: var(--s-text-default);
103
- background-color: var(--s-action-neutral-default);
103
+ background-color: var(--swirl-flat-button-background-default);
104
104
  }
105
105
 
106
106
  .button--variant-flat:hover {
107
- background-color: var(--s-action-neutral-hovered);
107
+ background-color: var(--swirl-flat-button-background-hovered);
108
108
  }
109
109
 
110
110
  .button--variant-flat:active {
111
- background-color: var(--s-action-neutral-pressed);
111
+ background-color: var(--swirl-flat-button-background-pressed);
112
112
  }
113
113
 
114
114
  .button--variant-flat:disabled {
115
- background-color: var(--s-action-neutral-disabled);
115
+ background-color: var(--swirl-flat-button-background-disabled);
116
116
  }
117
117
 
118
118
  .button--variant-flat.button--intent-primary:not(:disabled) {
@@ -0,0 +1,70 @@
1
+ // DO NOT EDIT. THIS FILE GETS GENERATED VIA "yarn generate".
2
+ import { Fragment, h } from "@stencil/core";
3
+ import classnames from "classnames";
4
+ export class SwirlEmojiClap {
5
+ constructor() {
6
+ this.label = "";
7
+ this.size = 24;
8
+ }
9
+ render() {
10
+ const className = classnames("emoji", `emoji--size-${this.size}`);
11
+ return (h(Fragment, null, this.size === 16 && (h("img", { alt: this.label, class: className, height: "16", src: "/emojis/Clap16.png", width: "16" })), this.size === 20 && (h("img", { alt: this.label, class: className, height: "20", src: "/emojis/Clap20.png", width: "20" })), this.size === 24 && (h("img", { alt: this.label, class: className, height: "24", src: "/emojis/Clap24.png", width: "24" })), this.size === 32 && (h("img", { alt: this.label, class: className, height: "32", src: "/emojis/Clap32.png", width: "32" }))));
12
+ }
13
+ static get is() { return "swirl-emoji-clap"; }
14
+ static get encapsulation() { return "shadow"; }
15
+ static get originalStyleUrls() {
16
+ return {
17
+ "$": ["../swirl-emoji.css"]
18
+ };
19
+ }
20
+ static get styleUrls() {
21
+ return {
22
+ "$": ["../swirl-emoji.css"]
23
+ };
24
+ }
25
+ static get properties() {
26
+ return {
27
+ "label": {
28
+ "type": "string",
29
+ "mutable": false,
30
+ "complexType": {
31
+ "original": "string",
32
+ "resolved": "string",
33
+ "references": {}
34
+ },
35
+ "required": false,
36
+ "optional": true,
37
+ "docs": {
38
+ "tags": [],
39
+ "text": ""
40
+ },
41
+ "attribute": "label",
42
+ "reflect": false,
43
+ "defaultValue": "\"\""
44
+ },
45
+ "size": {
46
+ "type": "number",
47
+ "mutable": false,
48
+ "complexType": {
49
+ "original": "SwirlEmojiSize",
50
+ "resolved": "16 | 20 | 24 | 32",
51
+ "references": {
52
+ "SwirlEmojiSize": {
53
+ "location": "import",
54
+ "path": "../swirl-emoji.types"
55
+ }
56
+ }
57
+ },
58
+ "required": false,
59
+ "optional": true,
60
+ "docs": {
61
+ "tags": [],
62
+ "text": ""
63
+ },
64
+ "attribute": "size",
65
+ "reflect": false,
66
+ "defaultValue": "24"
67
+ }
68
+ };
69
+ }
70
+ }
@@ -0,0 +1,70 @@
1
+ // DO NOT EDIT. THIS FILE GETS GENERATED VIA "yarn generate".
2
+ import { Fragment, h } from "@stencil/core";
3
+ import classnames from "classnames";
4
+ export class SwirlEmojiHappy {
5
+ constructor() {
6
+ this.label = "";
7
+ this.size = 24;
8
+ }
9
+ render() {
10
+ const className = classnames("emoji", `emoji--size-${this.size}`);
11
+ return (h(Fragment, null, this.size === 16 && (h("img", { alt: this.label, class: className, height: "16", src: "/emojis/Happy16.png", width: "16" })), this.size === 20 && (h("img", { alt: this.label, class: className, height: "20", src: "/emojis/Happy20.png", width: "20" })), this.size === 24 && (h("img", { alt: this.label, class: className, height: "24", src: "/emojis/Happy24.png", width: "24" })), this.size === 32 && (h("img", { alt: this.label, class: className, height: "32", src: "/emojis/Happy32.png", width: "32" }))));
12
+ }
13
+ static get is() { return "swirl-emoji-happy"; }
14
+ static get encapsulation() { return "shadow"; }
15
+ static get originalStyleUrls() {
16
+ return {
17
+ "$": ["../swirl-emoji.css"]
18
+ };
19
+ }
20
+ static get styleUrls() {
21
+ return {
22
+ "$": ["../swirl-emoji.css"]
23
+ };
24
+ }
25
+ static get properties() {
26
+ return {
27
+ "label": {
28
+ "type": "string",
29
+ "mutable": false,
30
+ "complexType": {
31
+ "original": "string",
32
+ "resolved": "string",
33
+ "references": {}
34
+ },
35
+ "required": false,
36
+ "optional": true,
37
+ "docs": {
38
+ "tags": [],
39
+ "text": ""
40
+ },
41
+ "attribute": "label",
42
+ "reflect": false,
43
+ "defaultValue": "\"\""
44
+ },
45
+ "size": {
46
+ "type": "number",
47
+ "mutable": false,
48
+ "complexType": {
49
+ "original": "SwirlEmojiSize",
50
+ "resolved": "16 | 20 | 24 | 32",
51
+ "references": {
52
+ "SwirlEmojiSize": {
53
+ "location": "import",
54
+ "path": "../swirl-emoji.types"
55
+ }
56
+ }
57
+ },
58
+ "required": false,
59
+ "optional": true,
60
+ "docs": {
61
+ "tags": [],
62
+ "text": ""
63
+ },
64
+ "attribute": "size",
65
+ "reflect": false,
66
+ "defaultValue": "24"
67
+ }
68
+ };
69
+ }
70
+ }