@everymatrix/general-multi-select 0.0.1

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 (58) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/general-multi-select-c46368a0.js +208 -0
  3. package/dist/cjs/general-multi-select.cjs.entry.js +10 -0
  4. package/dist/cjs/general-multi-select.cjs.js +25 -0
  5. package/dist/cjs/index-5b495c2d.js +1262 -0
  6. package/dist/cjs/index.cjs.js +10 -0
  7. package/dist/cjs/loader.cjs.js +15 -0
  8. package/dist/collection/collection-manifest.json +12 -0
  9. package/dist/collection/components/general-multi-select/general-multi-select.css +144 -0
  10. package/dist/collection/components/general-multi-select/general-multi-select.js +319 -0
  11. package/dist/collection/components/general-multi-select/index.js +1 -0
  12. package/dist/collection/components/static/dropdown.svg +2 -0
  13. package/dist/collection/components/static/dropup.svg +1 -0
  14. package/dist/collection/index.js +1 -0
  15. package/dist/collection/utils/utils.js +3 -0
  16. package/dist/esm/app-globals-0f993ce5.js +3 -0
  17. package/dist/esm/general-multi-select-1ba05f04.js +206 -0
  18. package/dist/esm/general-multi-select.entry.js +2 -0
  19. package/dist/esm/general-multi-select.js +20 -0
  20. package/dist/esm/index-4b050939.js +1234 -0
  21. package/dist/esm/index.js +2 -0
  22. package/dist/esm/loader.js +11 -0
  23. package/dist/general-multi-select/app-globals-0f993ce5.js +1 -0
  24. package/dist/general-multi-select/general-multi-select-1ba05f04.js +1 -0
  25. package/dist/general-multi-select/general-multi-select.entry.js +1 -0
  26. package/dist/general-multi-select/general-multi-select.esm.js +1 -0
  27. package/dist/general-multi-select/index-4b050939.js +2 -0
  28. package/dist/general-multi-select/index.esm.js +1 -0
  29. package/dist/index.cjs.js +1 -0
  30. package/dist/index.js +1 -0
  31. package/dist/static/dropdown.svg +2 -0
  32. package/dist/static/dropup.svg +1 -0
  33. package/dist/stencil.config.dev.js +19 -0
  34. package/dist/stencil.config.js +19 -0
  35. package/dist/storybook/main.js +43 -0
  36. package/dist/storybook/preview.js +9 -0
  37. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/general-multi-select/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
  38. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/general-multi-select/.stencil/packages/stencil/general-multi-select/stencil.config.d.ts +2 -0
  39. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/general-multi-select/.stencil/packages/stencil/general-multi-select/stencil.config.dev.d.ts +2 -0
  40. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/general-multi-select/.stencil/packages/stencil/general-multi-select/storybook/main.d.ts +3 -0
  41. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/general-multi-select/.stencil/packages/stencil/general-multi-select/storybook/preview.d.ts +70 -0
  42. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/general-multi-select/.stencil/tools/plugins/index.d.ts +3 -0
  43. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/general-multi-select/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
  44. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/general-multi-select/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
  45. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/general-multi-select/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
  46. package/dist/types/components/general-multi-select/general-multi-select.d.ts +68 -0
  47. package/dist/types/components/general-multi-select/index.d.ts +1 -0
  48. package/dist/types/components.d.ts +105 -0
  49. package/dist/types/index.d.ts +1 -0
  50. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  51. package/dist/types/utils/utils.d.ts +1 -0
  52. package/loader/cdn.js +1 -0
  53. package/loader/index.cjs.js +1 -0
  54. package/loader/index.d.ts +24 -0
  55. package/loader/index.es2017.js +1 -0
  56. package/loader/index.js +2 -0
  57. package/loader/package.json +11 -0
  58. package/package.json +27 -0
@@ -0,0 +1,206 @@
1
+ import { r as registerInstance, c as createEvent, g as getAssetPath, h } from './index-4b050939.js';
2
+
3
+ /**
4
+ * @name setClientStyling
5
+ * @description Method used to create and append to the passed element of the widget a style element with the content received
6
+ * @param {HTMLElement} stylingContainer The reference element of the widget
7
+ * @param {string} clientStyling The style content
8
+ */
9
+ function setClientStyling(stylingContainer, clientStyling) {
10
+ if (stylingContainer) {
11
+ const sheet = document.createElement('style');
12
+ sheet.innerHTML = clientStyling;
13
+ stylingContainer.appendChild(sheet);
14
+ }
15
+ }
16
+
17
+ /**
18
+ * @name setClientStylingURL
19
+ * @description Method used to create and append to the passed element of the widget a style element with the content fetched from a given URL
20
+ * @param {HTMLElement} stylingContainer The reference element of the widget
21
+ * @param {string} clientStylingUrl The URL of the style content
22
+ */
23
+ function setClientStylingURL(stylingContainer, clientStylingUrl) {
24
+ const url = new URL(clientStylingUrl);
25
+
26
+ fetch(url.href)
27
+ .then((res) => res.text())
28
+ .then((data) => {
29
+ const cssFile = document.createElement('style');
30
+ cssFile.innerHTML = data;
31
+ if (stylingContainer) {
32
+ stylingContainer.appendChild(cssFile);
33
+ }
34
+ })
35
+ .catch((err) => {
36
+ console.error('There was an error while trying to load client styling from URL', err);
37
+ });
38
+ }
39
+
40
+ /**
41
+ * @name setStreamLibrary
42
+ * @description Method used to create and append to the passed element of the widget a style element with content fetched from the MessageBus
43
+ * @param {HTMLElement} stylingContainer The highest element of the widget
44
+ * @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
45
+ * @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
46
+ */
47
+ function setStreamStyling(stylingContainer, domain, subscription) {
48
+ if (window.emMessageBus) {
49
+ const sheet = document.createElement('style');
50
+
51
+ window.emMessageBus.subscribe(domain, (data) => {
52
+ sheet.innerHTML = data;
53
+ if (stylingContainer) {
54
+ stylingContainer.appendChild(sheet);
55
+ }
56
+ });
57
+ }
58
+ }
59
+
60
+ const generalMultiSelectCss = ".multi-select-container{position:relative;font-family:\"Inter\", sans-serif;margin-top:4px;width:100%}.flex-row{display:flex;flex-direction:row;align-items:center;flex-wrap:nowrap;padding:8px 12px;padding-right:4px;border-radius:4px;background:var(--emw-selector-color-background, #e8ebef);cursor:pointer}.control{flex:1;display:flex;align-items:center;flex-wrap:nowrap;overflow:hidden}.control:focus-within{border-color:var(--emw--color-primary, #fed275);box-shadow:0 0 0 2px var(--emw--button-box-shadow-color-secondary, rgba(0, 0, 0, 0.15))}.chip{display:inline-flex;align-items:center;background:var(--emw--color-gray-50, #f5f5f5);color:var(--emw--color-typography, #555);border-radius:4px;padding:2px 8px;margin-right:6px;font-size:0.875rem;line-height:1.2;justify-content:space-between;flex:0 1 auto;min-width:0}.chip-text{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.overflow-chip{background:var(--emw--color-gray-100, #e6e6e6);color:var(--emw--color-gray-300, #333);width:20px;text-align:center;display:block}.remove-btn{background:none;border:none;font-size:1rem;margin-left:6px;cursor:pointer;color:var(--emw--color-gray-150, #6f6f6f)}.remove-btn:hover{color:var(--emw--color-error, red)}.placeholder{color:var(--emw--color-gray-150, #6f6f6f);font-size:0.875rem;padding:3px 8px;line-height:1.2}.arrow{margin-left:auto;font-size:0.8rem;width:20px;color:var(--emw--color-gray-150, #6f6f6f)}.dropdown{position:absolute;top:calc(100% + 4px);left:0;width:100%;max-height:240px;overflow-y:auto;border:1px solid var(--emw--color-gray-100, #e6e6e6);border-radius:6px;background:var(--emw--color-background, #ffffff);box-shadow:0 4px 12px var(--emw--button-box-shadow-color-secondary, rgba(0, 0, 0, 0.15));z-index:10}.dropdown-item{padding:10px 14px;cursor:pointer;font-size:0.875rem;line-height:1.4;transition:background 0.2s}.dropdown-item:hover{background:var(--emw--color-gray-100, #f4f5f7)}.dropdown-item.selected{background:var(--emw--color-primary-variant, #bae7ff);color:var(--emw--color-primary, #0050b3);font-weight:500}.overflow-popover{position:absolute;top:var(--overflow-top, 0px);left:var(--overflow-left, 0px);max-width:200px;padding:12px;display:flex;flex-wrap:wrap;gap:6px;border:1px solid var(--emw--color-gray-100, #d0d5dd);border-radius:6px;background:var(--emw--color-background, #ffffff);box-shadow:0 4px 12px var(--emw--button-box-shadow-color-secondary, rgba(0, 0, 0, 0.15));z-index:20}";
61
+ const GeneralMultiSelectStyle0 = generalMultiSelectCss;
62
+
63
+ const GeneralMultiSelect = class {
64
+ constructor(hostRef) {
65
+ registerInstance(this, hostRef);
66
+ this.change = createEvent(this, "change", 7);
67
+ this.handleOutsideClick = (e) => {
68
+ // If click happens outside our component root, close both panels
69
+ const path = e.composedPath();
70
+ if (!path.includes(this.el)) {
71
+ this.dropdownOpen = false;
72
+ this.overflowOpen = false;
73
+ }
74
+ };
75
+ this.toggleDropdown = (e) => {
76
+ e.stopPropagation();
77
+ this.dropdownOpen = !this.dropdownOpen;
78
+ this.overflowOpen = false; // close overflow if open
79
+ };
80
+ this.isSelected = (value) => this.selectedValues.includes(value);
81
+ this.selectItem = (item) => {
82
+ if (!this.isSelected(item.value)) {
83
+ this.selectedValues = [...this.selectedValues, item.value];
84
+ this.change.emit(this.selectedValues);
85
+ }
86
+ };
87
+ this.toggleItem = (item) => {
88
+ if (this.isSelected(item.value)) {
89
+ this.removeItem(item.value);
90
+ }
91
+ else {
92
+ this.selectItem(item);
93
+ }
94
+ };
95
+ this.removeItem = (value, e) => {
96
+ e && e.stopPropagation();
97
+ this.selectedValues = this.selectedValues.filter((v) => v !== value);
98
+ this.change.emit(this.selectedValues);
99
+ };
100
+ this.downIcon = getAssetPath('../static/dropdown.svg');
101
+ this.upIcon = getAssetPath('../static/dropup.svg');
102
+ /** Touch-capable device? */
103
+ this.isTouch = 'ontouchstart' in window;
104
+ /** Open overflow popover */
105
+ this.openOverflow = () => {
106
+ if (!this.isTouch) {
107
+ // hover only on non-touch
108
+ this.computePopoverPosition();
109
+ this.overflowOpen = true;
110
+ }
111
+ };
112
+ /** Close overflow popover */
113
+ this.closeOverflow = () => {
114
+ if (!this.isTouch) {
115
+ this.overflowOpen = false;
116
+ }
117
+ };
118
+ this.toggleOverflow = (e) => {
119
+ e.stopPropagation();
120
+ this.computePopoverPosition();
121
+ this.overflowOpen = !this.overflowOpen;
122
+ };
123
+ this.mbSource = undefined;
124
+ this.clientStyling = undefined;
125
+ this.clientStylingUrl = undefined;
126
+ this.options = [];
127
+ this.maxVisibleChips = 2;
128
+ this.placeholder = '';
129
+ this.selectedValues = [];
130
+ this.dropdownOpen = false;
131
+ this.overflowOpen = false;
132
+ this.popoverStyle = { top: '0px', left: '0px' };
133
+ }
134
+ handleClientStylingChange(newValue, oldValue) {
135
+ if (newValue != oldValue) {
136
+ setClientStyling(this.stylingContainer, this.clientStyling);
137
+ }
138
+ }
139
+ handleClientStylingUrlChange(newValue, oldValue) {
140
+ if (newValue != oldValue) {
141
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
142
+ }
143
+ }
144
+ handleMbSourceChange(newValue, oldValue) {
145
+ if (newValue != oldValue) {
146
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
147
+ }
148
+ }
149
+ componentDidLoad() {
150
+ if (this.stylingContainer) {
151
+ if (this.mbSource)
152
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
153
+ if (this.clientStyling)
154
+ setClientStyling(this.stylingContainer, this.clientStyling);
155
+ if (this.clientStylingUrl)
156
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
157
+ }
158
+ }
159
+ async clear() {
160
+ this.selectedValues = [];
161
+ this.change.emit(this.selectedValues);
162
+ }
163
+ componentWillLoad() {
164
+ // Listen for clicks anywhere to close panels on outside click
165
+ document.addEventListener('click', this.handleOutsideClick);
166
+ }
167
+ disconnectedCallback() {
168
+ document.removeEventListener('click', this.handleOutsideClick);
169
+ this.stylingSubscription && this.stylingSubscription.unsubscribe();
170
+ }
171
+ get selectedOptions() {
172
+ return this.options.filter((o) => this.isSelected(o.value));
173
+ }
174
+ get visibleChips() {
175
+ return this.selectedOptions.slice(0, this.maxVisibleChips);
176
+ }
177
+ get hiddenChips() {
178
+ return this.selectedOptions.slice(this.maxVisibleChips);
179
+ }
180
+ computePopoverPosition() {
181
+ if (this.overflowChipEl && this.el) {
182
+ const { left: overflowChipElLeft } = this.overflowChipEl.getBoundingClientRect();
183
+ const { left: elLeft, height } = this.el.getBoundingClientRect();
184
+ this.popoverStyle = {
185
+ top: `${height - 10}px`,
186
+ left: `${overflowChipElLeft - elLeft}px`
187
+ };
188
+ }
189
+ }
190
+ render() {
191
+ var _a;
192
+ return (h("div", { key: '50b48397be3ede1907ab2c2abcd1cf2f43f69c13', class: "general-multi-select-container", ref: (el) => (this.stylingContainer = el) }, h("div", { key: '696a1bb1f221f8f5cf290fac040af10e2e5a115e', class: "multi-select-container", ref: (el) => (this.el = el) }, h("div", { key: '9ea92f01787b26d43054573a11896cf65065b073', class: "flex-row", onClick: this.toggleDropdown }, h("div", { key: 'f79720ca3ec383ee7f95b09483698ee18119c79a', class: "control" }, this.visibleChips.map((opt) => (h("span", { class: "chip" }, h("div", { class: "chip-text", title: opt.text }, opt.text), h("div", { class: "remove-btn", onClick: (e) => this.removeItem(opt.value, e) }, "\u00D7")))), this.hiddenChips.length > 0 && (h("span", { key: '25e9e527c33dd7a315dacb10cc51084fe69b9b7e', class: "chip overflow-chip", ref: (el) => (this.overflowChipEl = el), onMouseEnter: this.openOverflow, onMouseLeave: this.closeOverflow, onClick: this.toggleOverflow }, "\u2022\u2022\u2022")), this.selectedValues.length === 0 && h("span", { key: 'b061de660a55f7a0d41ce9aa650108d3f38a9dc0', class: "placeholder" }, this.placeholder)), h("div", { key: 'f83b6517e88b3976cdc18590f8f1233cb2515230', class: "arrow" }, h("img", { key: '1b61a49090237057b98e5ce8a4f7c1e3bfc9d4ba', class: "info-icon", src: this.dropdownOpen ? this.upIcon : this.downIcon, style: { width: '18px' } }))), this.dropdownOpen && (h("div", { key: 'e5b081007bcbdd251ce5ac235c1f19f17852c420', class: "dropdown" }, this.options.map((opt) => (h("div", { class: {
193
+ 'dropdown-item': true,
194
+ selected: this.isSelected(opt.value)
195
+ }, onClick: () => this.toggleItem(opt) }, opt.text))))), this.overflowOpen && !!((_a = this.hiddenChips) === null || _a === void 0 ? void 0 : _a.length) && (h("div", { key: 'f8e3289042c69c569bebcd0a40d90f31261c6c12', class: "overflow-popover", style: { top: this.popoverStyle.top, left: this.popoverStyle.left }, onMouseEnter: this.openOverflow, onMouseLeave: this.closeOverflow }, this.hiddenChips.map((opt) => (h("span", { class: "chip" }, h("span", { class: "chip-text", title: opt.text }, opt.text), h("span", { class: "remove-btn", onClick: (e) => this.removeItem(opt.value, e) }, "\u00D7")))))))));
196
+ }
197
+ static get assetsDirs() { return ["../static"]; }
198
+ static get watchers() { return {
199
+ "clientStyling": ["handleClientStylingChange"],
200
+ "clientStylingUrl": ["handleClientStylingUrlChange"],
201
+ "mbSource": ["handleMbSourceChange"]
202
+ }; }
203
+ };
204
+ GeneralMultiSelect.style = GeneralMultiSelectStyle0;
205
+
206
+ export { GeneralMultiSelect as G };
@@ -0,0 +1,2 @@
1
+ export { G as general_multi_select } from './general-multi-select-1ba05f04.js';
2
+ import './index-4b050939.js';
@@ -0,0 +1,20 @@
1
+ import { p as promiseResolve, b as bootstrapLazy } from './index-4b050939.js';
2
+ export { s as setNonce } from './index-4b050939.js';
3
+ import { g as globalScripts } from './app-globals-0f993ce5.js';
4
+
5
+ /*
6
+ Stencil Client Patch Browser v4.19.2 | MIT Licensed | https://stenciljs.com
7
+ */
8
+ var patchBrowser = () => {
9
+ const importMeta = import.meta.url;
10
+ const opts = {};
11
+ if (importMeta !== "") {
12
+ opts.resourcesUrl = new URL(".", importMeta).href;
13
+ }
14
+ return promiseResolve(opts);
15
+ };
16
+
17
+ patchBrowser().then(async (options) => {
18
+ await globalScripts();
19
+ return bootstrapLazy([["general-multi-select",[[1,"general-multi-select",{"mbSource":[513,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"options":[16],"maxVisibleChips":[2,"max-visible-chips"],"placeholder":[1],"selectedValues":[32],"dropdownOpen":[32],"overflowOpen":[32],"popoverStyle":[32],"clear":[64]},null,{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"]}]]]], options);
20
+ });