@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,5 @@
1
+ 'use strict';
2
+
3
+ const globalScripts = () => {};
4
+
5
+ exports.globalScripts = globalScripts;
@@ -0,0 +1,208 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-5b495c2d.js');
4
+
5
+ /**
6
+ * @name setClientStyling
7
+ * @description Method used to create and append to the passed element of the widget a style element with the content received
8
+ * @param {HTMLElement} stylingContainer The reference element of the widget
9
+ * @param {string} clientStyling The style content
10
+ */
11
+ function setClientStyling(stylingContainer, clientStyling) {
12
+ if (stylingContainer) {
13
+ const sheet = document.createElement('style');
14
+ sheet.innerHTML = clientStyling;
15
+ stylingContainer.appendChild(sheet);
16
+ }
17
+ }
18
+
19
+ /**
20
+ * @name setClientStylingURL
21
+ * @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
22
+ * @param {HTMLElement} stylingContainer The reference element of the widget
23
+ * @param {string} clientStylingUrl The URL of the style content
24
+ */
25
+ function setClientStylingURL(stylingContainer, clientStylingUrl) {
26
+ const url = new URL(clientStylingUrl);
27
+
28
+ fetch(url.href)
29
+ .then((res) => res.text())
30
+ .then((data) => {
31
+ const cssFile = document.createElement('style');
32
+ cssFile.innerHTML = data;
33
+ if (stylingContainer) {
34
+ stylingContainer.appendChild(cssFile);
35
+ }
36
+ })
37
+ .catch((err) => {
38
+ console.error('There was an error while trying to load client styling from URL', err);
39
+ });
40
+ }
41
+
42
+ /**
43
+ * @name setStreamLibrary
44
+ * @description Method used to create and append to the passed element of the widget a style element with content fetched from the MessageBus
45
+ * @param {HTMLElement} stylingContainer The highest element of the widget
46
+ * @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
47
+ * @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
48
+ */
49
+ function setStreamStyling(stylingContainer, domain, subscription) {
50
+ if (window.emMessageBus) {
51
+ const sheet = document.createElement('style');
52
+
53
+ window.emMessageBus.subscribe(domain, (data) => {
54
+ sheet.innerHTML = data;
55
+ if (stylingContainer) {
56
+ stylingContainer.appendChild(sheet);
57
+ }
58
+ });
59
+ }
60
+ }
61
+
62
+ 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}";
63
+ const GeneralMultiSelectStyle0 = generalMultiSelectCss;
64
+
65
+ const GeneralMultiSelect = class {
66
+ constructor(hostRef) {
67
+ index.registerInstance(this, hostRef);
68
+ this.change = index.createEvent(this, "change", 7);
69
+ this.handleOutsideClick = (e) => {
70
+ // If click happens outside our component root, close both panels
71
+ const path = e.composedPath();
72
+ if (!path.includes(this.el)) {
73
+ this.dropdownOpen = false;
74
+ this.overflowOpen = false;
75
+ }
76
+ };
77
+ this.toggleDropdown = (e) => {
78
+ e.stopPropagation();
79
+ this.dropdownOpen = !this.dropdownOpen;
80
+ this.overflowOpen = false; // close overflow if open
81
+ };
82
+ this.isSelected = (value) => this.selectedValues.includes(value);
83
+ this.selectItem = (item) => {
84
+ if (!this.isSelected(item.value)) {
85
+ this.selectedValues = [...this.selectedValues, item.value];
86
+ this.change.emit(this.selectedValues);
87
+ }
88
+ };
89
+ this.toggleItem = (item) => {
90
+ if (this.isSelected(item.value)) {
91
+ this.removeItem(item.value);
92
+ }
93
+ else {
94
+ this.selectItem(item);
95
+ }
96
+ };
97
+ this.removeItem = (value, e) => {
98
+ e && e.stopPropagation();
99
+ this.selectedValues = this.selectedValues.filter((v) => v !== value);
100
+ this.change.emit(this.selectedValues);
101
+ };
102
+ this.downIcon = index.getAssetPath('../static/dropdown.svg');
103
+ this.upIcon = index.getAssetPath('../static/dropup.svg');
104
+ /** Touch-capable device? */
105
+ this.isTouch = 'ontouchstart' in window;
106
+ /** Open overflow popover */
107
+ this.openOverflow = () => {
108
+ if (!this.isTouch) {
109
+ // hover only on non-touch
110
+ this.computePopoverPosition();
111
+ this.overflowOpen = true;
112
+ }
113
+ };
114
+ /** Close overflow popover */
115
+ this.closeOverflow = () => {
116
+ if (!this.isTouch) {
117
+ this.overflowOpen = false;
118
+ }
119
+ };
120
+ this.toggleOverflow = (e) => {
121
+ e.stopPropagation();
122
+ this.computePopoverPosition();
123
+ this.overflowOpen = !this.overflowOpen;
124
+ };
125
+ this.mbSource = undefined;
126
+ this.clientStyling = undefined;
127
+ this.clientStylingUrl = undefined;
128
+ this.options = [];
129
+ this.maxVisibleChips = 2;
130
+ this.placeholder = '';
131
+ this.selectedValues = [];
132
+ this.dropdownOpen = false;
133
+ this.overflowOpen = false;
134
+ this.popoverStyle = { top: '0px', left: '0px' };
135
+ }
136
+ handleClientStylingChange(newValue, oldValue) {
137
+ if (newValue != oldValue) {
138
+ setClientStyling(this.stylingContainer, this.clientStyling);
139
+ }
140
+ }
141
+ handleClientStylingUrlChange(newValue, oldValue) {
142
+ if (newValue != oldValue) {
143
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
144
+ }
145
+ }
146
+ handleMbSourceChange(newValue, oldValue) {
147
+ if (newValue != oldValue) {
148
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
149
+ }
150
+ }
151
+ componentDidLoad() {
152
+ if (this.stylingContainer) {
153
+ if (this.mbSource)
154
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
155
+ if (this.clientStyling)
156
+ setClientStyling(this.stylingContainer, this.clientStyling);
157
+ if (this.clientStylingUrl)
158
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
159
+ }
160
+ }
161
+ async clear() {
162
+ this.selectedValues = [];
163
+ this.change.emit(this.selectedValues);
164
+ }
165
+ componentWillLoad() {
166
+ // Listen for clicks anywhere to close panels on outside click
167
+ document.addEventListener('click', this.handleOutsideClick);
168
+ }
169
+ disconnectedCallback() {
170
+ document.removeEventListener('click', this.handleOutsideClick);
171
+ this.stylingSubscription && this.stylingSubscription.unsubscribe();
172
+ }
173
+ get selectedOptions() {
174
+ return this.options.filter((o) => this.isSelected(o.value));
175
+ }
176
+ get visibleChips() {
177
+ return this.selectedOptions.slice(0, this.maxVisibleChips);
178
+ }
179
+ get hiddenChips() {
180
+ return this.selectedOptions.slice(this.maxVisibleChips);
181
+ }
182
+ computePopoverPosition() {
183
+ if (this.overflowChipEl && this.el) {
184
+ const { left: overflowChipElLeft } = this.overflowChipEl.getBoundingClientRect();
185
+ const { left: elLeft, height } = this.el.getBoundingClientRect();
186
+ this.popoverStyle = {
187
+ top: `${height - 10}px`,
188
+ left: `${overflowChipElLeft - elLeft}px`
189
+ };
190
+ }
191
+ }
192
+ render() {
193
+ var _a;
194
+ return (index.h("div", { key: '50b48397be3ede1907ab2c2abcd1cf2f43f69c13', class: "general-multi-select-container", ref: (el) => (this.stylingContainer = el) }, index.h("div", { key: '696a1bb1f221f8f5cf290fac040af10e2e5a115e', class: "multi-select-container", ref: (el) => (this.el = el) }, index.h("div", { key: '9ea92f01787b26d43054573a11896cf65065b073', class: "flex-row", onClick: this.toggleDropdown }, index.h("div", { key: 'f79720ca3ec383ee7f95b09483698ee18119c79a', class: "control" }, this.visibleChips.map((opt) => (index.h("span", { class: "chip" }, index.h("div", { class: "chip-text", title: opt.text }, opt.text), index.h("div", { class: "remove-btn", onClick: (e) => this.removeItem(opt.value, e) }, "\u00D7")))), this.hiddenChips.length > 0 && (index.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 && index.h("span", { key: 'b061de660a55f7a0d41ce9aa650108d3f38a9dc0', class: "placeholder" }, this.placeholder)), index.h("div", { key: 'f83b6517e88b3976cdc18590f8f1233cb2515230', class: "arrow" }, index.h("img", { key: '1b61a49090237057b98e5ce8a4f7c1e3bfc9d4ba', class: "info-icon", src: this.dropdownOpen ? this.upIcon : this.downIcon, style: { width: '18px' } }))), this.dropdownOpen && (index.h("div", { key: 'e5b081007bcbdd251ce5ac235c1f19f17852c420', class: "dropdown" }, this.options.map((opt) => (index.h("div", { class: {
195
+ 'dropdown-item': true,
196
+ selected: this.isSelected(opt.value)
197
+ }, onClick: () => this.toggleItem(opt) }, opt.text))))), this.overflowOpen && !!((_a = this.hiddenChips) === null || _a === void 0 ? void 0 : _a.length) && (index.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) => (index.h("span", { class: "chip" }, index.h("span", { class: "chip-text", title: opt.text }, opt.text), index.h("span", { class: "remove-btn", onClick: (e) => this.removeItem(opt.value, e) }, "\u00D7")))))))));
198
+ }
199
+ static get assetsDirs() { return ["../static"]; }
200
+ static get watchers() { return {
201
+ "clientStyling": ["handleClientStylingChange"],
202
+ "clientStylingUrl": ["handleClientStylingUrlChange"],
203
+ "mbSource": ["handleMbSourceChange"]
204
+ }; }
205
+ };
206
+ GeneralMultiSelect.style = GeneralMultiSelectStyle0;
207
+
208
+ exports.GeneralMultiSelect = GeneralMultiSelect;
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const generalMultiSelect = require('./general-multi-select-c46368a0.js');
6
+ require('./index-5b495c2d.js');
7
+
8
+
9
+
10
+ exports.general_multi_select = generalMultiSelect.GeneralMultiSelect;
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-5b495c2d.js');
6
+ const appGlobals = require('./app-globals-3a1e7e63.js');
7
+
8
+ /*
9
+ Stencil Client Patch Browser v4.19.2 | MIT Licensed | https://stenciljs.com
10
+ */
11
+ var patchBrowser = () => {
12
+ const importMeta = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('general-multi-select.cjs.js', document.baseURI).href));
13
+ const opts = {};
14
+ if (importMeta !== "") {
15
+ opts.resourcesUrl = new URL(".", importMeta).href;
16
+ }
17
+ return index.promiseResolve(opts);
18
+ };
19
+
20
+ patchBrowser().then(async (options) => {
21
+ await appGlobals.globalScripts();
22
+ return index.bootstrapLazy([["general-multi-select.cjs",[[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);
23
+ });
24
+
25
+ exports.setNonce = index.setNonce;