@everymatrix/helper-filters 0.1.2 → 0.1.3

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.
@@ -0,0 +1,137 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-0c5bb1ff.js');
6
+ require('@everymatrix/helper-modal');
7
+
8
+ const DEFAULT_LANGUAGE = 'en';
9
+ const SUPPORTED_LANGUAGES = ['ro', 'en'];
10
+ const TRANSLATIONS = {
11
+ en: {
12
+ filterOpen: 'Filter',
13
+ filterClear: 'Clear',
14
+ filterModalTicketTitle: 'Ticket Results',
15
+ filterModalDrawTitle: 'Draws Results History',
16
+ filterTicketPlaceholder: 'Search for a ticket ID',
17
+ filterDrawPlaceholder: 'Search for a draw ID',
18
+ filterDateRangePlaceholder: 'Date Range',
19
+ filterModalButton: 'Search',
20
+ filterFromCalendar: 'From',
21
+ filterToCalendar: 'To',
22
+ filterOrDate: 'or search by date'
23
+ },
24
+ ro: {
25
+ filterOpen: 'Filtrare',
26
+ filterClear: 'Stergere',
27
+ filterModalTicketTitle: 'Rezultatele biletelor',
28
+ filterModalDrawTitle: 'Rezultatele draw-urilor',
29
+ filterTicketPlaceholder: 'Cauta ID bilet',
30
+ filterDrawPlaceholder: 'Cauta ID draw',
31
+ filterDateRangePlaceholder: 'Perioada',
32
+ filterModalButton: 'Cauta',
33
+ filterOrDate: 'sau cauta dupa data'
34
+ },
35
+ };
36
+ const translate = (key, customLang) => {
37
+ const lang = customLang;
38
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
39
+ };
40
+
41
+ const helperFiltersCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}.FilterButtonsWrapper{display:flex;justify-content:flex-end;gap:5px}.FilterButtonsWrapper .FilterOpen{cursor:pointer;border-radius:4px;padding:8px 15px;width:max-content;border:1px solid #00958f;background:#00958f;color:#FFF;font-size:12px;transition:all 0.2s linear;text-align:center;letter-spacing:0}.FilterButtonsWrapper .FilterOpen:hover{background:#00958f;color:#FFF}.FilterButtonsWrapper .FilterClear{cursor:pointer;border-radius:4px;padding:8px 15px;width:max-content;border:1px solid #00958f;background:#FFF;color:#000;font-size:12px;transition:all 0.2s linear;text-align:center;letter-spacing:0}.FilterButtonsWrapper .FilterClear:hover{background:#00958f;color:#FFF}.FilterModalHeader,.FilterModalBody,.FilterModalFooter{display:flex;flex-direction:column;gap:5px;align-items:center;margin:20px 0}.FilterModalHeader .FilterModalTitle,.FilterModalBody .FilterModalTitle,.FilterModalFooter .FilterModalTitle{margin:0;padding:0;font-weight:700;font-size:16px;color:#009993;text-transform:uppercase}.FilterModalHeader .FilterModalSearch,.FilterModalBody .FilterModalSearch,.FilterModalFooter .FilterModalSearch{border-radius:4px;background:#e8ebef;color:#263445;width:100%;height:26px;max-width:280px;padding:5px;font-size:15px;border:none;outline:#009993}.FilterModalHeader .FilterCalendarWrapper,.FilterModalBody .FilterCalendarWrapper,.FilterModalFooter .FilterCalendarWrapper{display:flex;gap:5px}.FilterModalHeader .FilterCalendarWrapper .VaadinDatePicker,.FilterModalBody .FilterCalendarWrapper .VaadinDatePicker,.FilterModalFooter .FilterCalendarWrapper .VaadinDatePicker{width:50%;max-width:143px}.FilterModalHeader .FilterModalButton,.FilterModalBody .FilterModalButton,.FilterModalFooter .FilterModalButton{cursor:pointer;border-radius:4px;padding:8px 60px;width:max-content;margin:5px;border:1px solid #00958f;background:#00958f;color:#FFF;font-size:12px;transition:all 0.2s linear;text-transform:uppercase;text-align:center;letter-spacing:0}.FilterModalHeader .FilterModalButton:hover,.FilterModalBody .FilterModalButton:hover,.FilterModalFooter .FilterModalButton:hover{background:#00958f;color:#FFF}.FilterModalHeader p,.FilterModalBody p,.FilterModalFooter p{margin:5px 0}";
42
+
43
+ const HelperFilters = class {
44
+ constructor(hostRef) {
45
+ index.registerInstance(this, hostRef);
46
+ this.filterDraw = index.createEvent(this, "filterDraw", 7);
47
+ this.filterSelection = index.createEvent(this, "filterSelection", 7);
48
+ this.filterSelectionReset = index.createEvent(this, "filterSelectionReset", 7);
49
+ /**
50
+ * Check if show the filter option by id
51
+ */
52
+ this.showFilterId = true;
53
+ /**
54
+ * Choose if filter by draw ID or ticket ID. By default is draw ID.
55
+ */
56
+ this.activateTicketSearch = false;
57
+ /**
58
+ * Game ID
59
+ */
60
+ this.gameId = '';
61
+ /**
62
+ * Player ID
63
+ */
64
+ this.playerId = '';
65
+ /**
66
+ * Session ID
67
+ */
68
+ this.session = '';
69
+ /**
70
+ * Instead of customEvents the widget triggers postMessages
71
+ */
72
+ this.postMessage = false;
73
+ /**
74
+ * Language
75
+ */
76
+ this.language = 'en';
77
+ this.showFilterModal = false;
78
+ this.showClearButton = false;
79
+ this.filterData = {};
80
+ this.filterDataReset = { ticketDrawId: '', filterFromCalendar: '', filterToCalendar: '' };
81
+ }
82
+ // reset field values each time the filter modal opens
83
+ componentDidRender() {
84
+ this.filterData.ticketDrawId = null;
85
+ this.filterData.filterFromCalendar = null;
86
+ this.filterData.filterToCalendar = null;
87
+ // @TODO: to way binding?
88
+ if (document.getElementById('#FilterById'))
89
+ document.getElementById('#FilterById').value = '';
90
+ }
91
+ filterSelectionHandler(event) {
92
+ if (this.postMessage)
93
+ window.postMessage({ type: 'filterSelection', event }, window.location.href);
94
+ if (this.filterData.ticketDrawId)
95
+ this.filterDraw.emit(event);
96
+ if (this.filterData.filterFromCalendar || this.filterData.filterToCalendar)
97
+ this.filterSelection.emit(event);
98
+ }
99
+ filterSelectionResetHandler(event) {
100
+ if (this.postMessage)
101
+ window.postMessage({ type: 'filterSelectionReset', event }, window.location.href);
102
+ this.filterSelectionReset.emit(event);
103
+ }
104
+ modalCloseEvent() {
105
+ this.showFilterModal = false;
106
+ }
107
+ // Toggle filter modal
108
+ toggleFilterModal() {
109
+ this.showFilterModal = true;
110
+ }
111
+ // Filter search
112
+ filterSearch() {
113
+ this.modalCloseEvent();
114
+ this.showClearButton = true;
115
+ this.filterSelectionHandler(this.filterData);
116
+ }
117
+ resetSearch() {
118
+ this.showClearButton = false;
119
+ this.filterSelectionResetHandler(this.filterDataReset);
120
+ this.filterData = {};
121
+ }
122
+ handleTicketDrawId(event) {
123
+ this.filterData.ticketDrawId = event.target.value;
124
+ }
125
+ handleFilterFrom(event) {
126
+ this.filterData.filterFromCalendar = new Date(event.target.value).toISOString();
127
+ }
128
+ handleFilterTo(event) {
129
+ this.filterData.filterToCalendar = new Date(event.target.value).toISOString();
130
+ }
131
+ render() {
132
+ return (index.h("div", { class: "HelperFilters" }, index.h("div", { class: "FilterButtonsWrapper" }, index.h("button", { class: "FilterOpen", onClick: () => this.toggleFilterModal() }, translate('filterOpen', this.language)), this.showClearButton ? index.h("button", { class: "FilterClear", onClick: () => this.resetSearch() }, translate('filterClear', this.language)) : null), index.h("helper-modal", { "title-modal": "Filter Modal", visible: this.showFilterModal }, index.h("div", { class: "FilterModalHeader" }, index.h("h3", { class: "FilterModalTitle" }, this.activateTicketSearch ? translate('filterModalTicketTitle', this.language) : translate('filterModalDrawTitle', this.language))), index.h("div", { class: "FilterModalBody" }, index.h("input", { id: "FilterById", type: "text", value: this.filterData.ticketDrawId, onInput: (event) => this.handleTicketDrawId(event), class: "FilterModalSearch", placeholder: this.activateTicketSearch ? translate('filterTicketPlaceholder', this.language) : translate('filterDrawPlaceholder', this.language) }), index.h("p", null, translate('filterOrDate', this.language)), index.h("div", { class: "FilterCalendarWrapper" })), index.h("div", { class: "FilterModalFooter" }, index.h("button", { class: "FilterModalButton", onClick: () => this.filterSearch() }, translate('filterModalButton', this.language))))));
133
+ }
134
+ };
135
+ HelperFilters.style = helperFiltersCss;
136
+
137
+ exports.helper_filters = HelperFilters;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const index = require('./index-979fa60b.js');
3
+ const index = require('./index-0c5bb1ff.js');
4
4
 
5
5
  /*
6
6
  Stencil Client Patch Browser v2.15.2 | MIT Licensed | https://stenciljs.com
@@ -15,5 +15,5 @@ const patchBrowser = () => {
15
15
  };
16
16
 
17
17
  patchBrowser().then(options => {
18
- return index.bootstrapLazy([["helper-filters_2.cjs",[[1,"helper-filters",{"showFilterId":[4,"show-filter-id"],"activateTicketSearch":[4,"activate-ticket-search"],"gameId":[1,"game-id"],"playerId":[1,"player-id"],"session":[1],"postMessage":[4,"post-message"],"language":[1],"showFilterModal":[32],"showClearButton":[32],"filterData":[32],"filterDataReset":[32]},[[0,"modalCloseEvent","modalCloseEvent"]]],[1,"helper-modal",{"titleModal":[1,"title-modal"],"visible":[1540]}]]]], options);
18
+ return index.bootstrapLazy([["helper-filters.cjs",[[1,"helper-filters",{"showFilterId":[4,"show-filter-id"],"activateTicketSearch":[4,"activate-ticket-search"],"gameId":[1,"game-id"],"playerId":[1,"player-id"],"session":[1],"postMessage":[4,"post-message"],"language":[1],"showFilterModal":[32],"showClearButton":[32],"filterData":[32],"filterDataReset":[32]},[[0,"modalCloseEvent","modalCloseEvent"]]]]]], options);
19
19
  });
@@ -502,14 +502,11 @@ const patch = (oldVNode, newVNode) => {
502
502
  const elm = (newVNode.$elm$ = oldVNode.$elm$);
503
503
  const oldChildren = oldVNode.$children$;
504
504
  const newChildren = newVNode.$children$;
505
- const tag = newVNode.$tag$;
506
505
  const text = newVNode.$text$;
507
506
  if (text === null) {
508
507
  // element node
509
508
  {
510
- if (tag === 'slot')
511
- ;
512
- else {
509
+ {
513
510
  // either this is the first render of an element OR it's an update
514
511
  // AND we already know it's possible it could have changed
515
512
  // this updates the element's css classes, attrs, props, listeners, etc.
@@ -542,14 +539,9 @@ const patch = (oldVNode, newVNode) => {
542
539
  };
543
540
  const renderVdom = (hostRef, renderFnResults) => {
544
541
  const hostElm = hostRef.$hostElement$;
545
- const cmpMeta = hostRef.$cmpMeta$;
546
542
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
547
543
  const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
548
544
  hostTagName = hostElm.tagName;
549
- if (cmpMeta.$attrsToReflect$) {
550
- rootVnode.$attrs$ = rootVnode.$attrs$ || {};
551
- cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
552
- }
553
545
  rootVnode.$tag$ = null;
554
546
  rootVnode.$flags$ |= 4 /* isHost */;
555
547
  hostRef.$vnode$ = rootVnode;
@@ -686,7 +678,11 @@ const postUpdateComponent = (hostRef) => {
686
678
  const tagName = hostRef.$cmpMeta$.$tagName$;
687
679
  const elm = hostRef.$hostElement$;
688
680
  const endPostUpdate = createTime('postUpdate', tagName);
681
+ const instance = hostRef.$lazyInstance$ ;
689
682
  const ancestorComponent = hostRef.$ancestorComponent$;
683
+ {
684
+ safeCall(instance, 'componentDidRender');
685
+ }
690
686
  if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
691
687
  hostRef.$flags$ |= 64 /* hasLoadedComponent */;
692
688
  {
@@ -896,9 +892,6 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
896
892
  .map(([propName, m]) => {
897
893
  const attrName = m[1] || propName;
898
894
  attrNameToPropName.set(attrName, propName);
899
- if (m[0] & 512 /* ReflectAttr */) {
900
- cmpMeta.$attrsToReflect$.push([propName, attrName]);
901
- }
902
895
  return attrName;
903
896
  });
904
897
  }
@@ -1059,9 +1052,6 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1059
1052
  {
1060
1053
  cmpMeta.$listeners$ = compactMeta[3];
1061
1054
  }
1062
- {
1063
- cmpMeta.$attrsToReflect$ = [];
1064
- }
1065
1055
  const tagName = cmpMeta.$tagName$;
1066
1056
  const HostElement = class extends HTMLElement {
1067
1057
  // StencilLazyHost
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-979fa60b.js');
5
+ const index = require('./index-0c5bb1ff.js');
6
6
 
7
7
  /*
8
8
  Stencil Client Patch Esm v2.15.2 | MIT Licensed | https://stenciljs.com
@@ -14,7 +14,7 @@ const patchEsm = () => {
14
14
  const defineCustomElements = (win, options) => {
15
15
  if (typeof window === 'undefined') return Promise.resolve();
16
16
  return patchEsm().then(() => {
17
- return index.bootstrapLazy([["helper-filters_2.cjs",[[1,"helper-filters",{"showFilterId":[4,"show-filter-id"],"activateTicketSearch":[4,"activate-ticket-search"],"gameId":[1,"game-id"],"playerId":[1,"player-id"],"session":[1],"postMessage":[4,"post-message"],"language":[1],"showFilterModal":[32],"showClearButton":[32],"filterData":[32],"filterDataReset":[32]},[[0,"modalCloseEvent","modalCloseEvent"]]],[1,"helper-modal",{"titleModal":[1,"title-modal"],"visible":[1540]}]]]], options);
17
+ return index.bootstrapLazy([["helper-filters.cjs",[[1,"helper-filters",{"showFilterId":[4,"show-filter-id"],"activateTicketSearch":[4,"activate-ticket-search"],"gameId":[1,"game-id"],"playerId":[1,"player-id"],"session":[1],"postMessage":[4,"post-message"],"language":[1],"showFilterModal":[32],"showClearButton":[32],"filterData":[32],"filterDataReset":[32]},[[0,"modalCloseEvent","modalCloseEvent"]]]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -7,13 +7,6 @@
7
7
  "version": "2.15.2",
8
8
  "typescriptVersion": "4.5.4"
9
9
  },
10
- "collections": [
11
- {
12
- "name": "@everymatrix/helper-modal",
13
- "tags": [
14
- "helper-modal"
15
- ]
16
- }
17
- ],
10
+ "collections": [],
18
11
  "bundles": []
19
12
  }
@@ -111,4 +111,9 @@
111
111
  .FilterModalFooter .FilterModalButton:hover {
112
112
  background: #00958f;
113
113
  color: #FFF;
114
+ }
115
+ .FilterModalHeader p,
116
+ .FilterModalBody p,
117
+ .FilterModalFooter p {
118
+ margin: 5px 0;
114
119
  }
@@ -1,6 +1,7 @@
1
1
  import { Component, h, State, Prop, Event, Listen } from '@stencil/core';
2
2
  import { translate } from '../../utils/locale.utils';
3
- import '@vaadin/date-picker';
3
+ // import '@vaadin/date-picker';
4
+ // import '@vaadin/vaadin-date-picker/vaadin-date-picker.js';
4
5
  import '@everymatrix/helper-modal';
5
6
  export class HelperFilters {
6
7
  constructor() {
@@ -35,23 +36,30 @@ export class HelperFilters {
35
36
  this.showFilterModal = false;
36
37
  this.showClearButton = false;
37
38
  this.filterData = {};
38
- this.filterDataReset = { drawTicketId: '', filterFromCalendar: '', filterToCalendar: '' };
39
+ this.filterDataReset = { ticketDrawId: '', filterFromCalendar: '', filterToCalendar: '' };
40
+ }
41
+ // reset field values each time the filter modal opens
42
+ componentDidRender() {
43
+ this.filterData.ticketDrawId = null;
44
+ this.filterData.filterFromCalendar = null;
45
+ this.filterData.filterToCalendar = null;
46
+ // @TODO: to way binding?
47
+ if (document.getElementById('#FilterById'))
48
+ document.getElementById('#FilterById').value = '';
39
49
  }
40
50
  filterSelectionHandler(event) {
41
- if (this.postMessage) {
51
+ if (this.postMessage)
42
52
  window.postMessage({ type: 'filterSelection', event }, window.location.href);
43
- }
44
- else {
53
+ if (this.filterData.ticketDrawId)
54
+ this.filterDraw.emit(event);
55
+ if (this.filterData.filterFromCalendar || this.filterData.filterToCalendar)
45
56
  this.filterSelection.emit(event);
46
- }
57
+ ;
47
58
  }
48
59
  filterSelectionResetHandler(event) {
49
- if (this.postMessage) {
60
+ if (this.postMessage)
50
61
  window.postMessage({ type: 'filterSelectionReset', event }, window.location.href);
51
- }
52
- else {
53
- this.filterSelectionReset.emit(event);
54
- }
62
+ this.filterSelectionReset.emit(event);
55
63
  }
56
64
  modalCloseEvent() {
57
65
  this.showFilterModal = false;
@@ -69,9 +77,10 @@ export class HelperFilters {
69
77
  resetSearch() {
70
78
  this.showClearButton = false;
71
79
  this.filterSelectionResetHandler(this.filterDataReset);
80
+ this.filterData = {};
72
81
  }
73
- handleDrawTicketId(event) {
74
- this.filterData.drawTicketId = event.target.value;
82
+ handleTicketDrawId(event) {
83
+ this.filterData.ticketDrawId = event.target.value;
75
84
  }
76
85
  handleFilterFrom(event) {
77
86
  this.filterData.filterFromCalendar = new Date(event.target.value).toISOString();
@@ -88,10 +97,9 @@ export class HelperFilters {
88
97
  h("div", { class: "FilterModalHeader" },
89
98
  h("h3", { class: "FilterModalTitle" }, this.activateTicketSearch ? translate('filterModalTicketTitle', this.language) : translate('filterModalDrawTitle', this.language))),
90
99
  h("div", { class: "FilterModalBody" },
91
- h("input", { type: "text", value: this.filterData.drawTicketId, onInput: (event) => this.handleDrawTicketId(event), class: "FilterModalSearch", placeholder: this.activateTicketSearch ? translate('filterTicketPlaceholder', this.language) : translate('filterDrawPlaceholder', this.language) }),
92
- h("div", { class: "FilterCalendarWrapper" },
93
- h("vaadin-date-picker", { value: this.filterData.filterFromCalendar, onChange: (event) => this.handleFilterFrom(event), placeholder: translate('filterFromCalendar', this.language), class: "VaadinDatePicker" }),
94
- h("vaadin-date-picker", { value: this.filterData.filterToCalendar, onChange: (event) => this.handleFilterTo(event), placeholder: translate('filterToCalendar', this.language), class: "VaadinDatePicker" }))),
100
+ h("input", { id: "FilterById", type: "text", value: this.filterData.ticketDrawId, onInput: (event) => this.handleTicketDrawId(event), class: "FilterModalSearch", placeholder: this.activateTicketSearch ? translate('filterTicketPlaceholder', this.language) : translate('filterDrawPlaceholder', this.language) }),
101
+ h("p", null, translate('filterOrDate', this.language)),
102
+ h("div", { class: "FilterCalendarWrapper" })),
95
103
  h("div", { class: "FilterModalFooter" },
96
104
  h("button", { class: "FilterModalButton", onClick: () => this.filterSearch() }, translate('filterModalButton', this.language))))));
97
105
  }
@@ -238,6 +246,25 @@ export class HelperFilters {
238
246
  "filterDataReset": {}
239
247
  }; }
240
248
  static get events() { return [{
249
+ "method": "filterDraw",
250
+ "name": "filterDraw",
251
+ "bubbles": true,
252
+ "cancelable": true,
253
+ "composed": true,
254
+ "docs": {
255
+ "tags": [],
256
+ "text": ""
257
+ },
258
+ "complexType": {
259
+ "original": "HelperFilters",
260
+ "resolved": "HelperFilters",
261
+ "references": {
262
+ "HelperFilters": {
263
+ "location": "global"
264
+ }
265
+ }
266
+ }
267
+ }, {
241
268
  "method": "filterSelection",
242
269
  "name": "filterSelection",
243
270
  "bubbles": true,
@@ -11,7 +11,8 @@ const TRANSLATIONS = {
11
11
  filterDateRangePlaceholder: 'Date Range',
12
12
  filterModalButton: 'Search',
13
13
  filterFromCalendar: 'From',
14
- filterToCalendar: 'To'
14
+ filterToCalendar: 'To',
15
+ filterOrDate: 'or search by date'
15
16
  },
16
17
  ro: {
17
18
  filterOpen: 'Filtrare',
@@ -21,7 +22,8 @@ const TRANSLATIONS = {
21
22
  filterTicketPlaceholder: 'Cauta ID bilet',
22
23
  filterDrawPlaceholder: 'Cauta ID draw',
23
24
  filterDateRangePlaceholder: 'Perioada',
24
- filterModalButton: 'Cauta'
25
+ filterModalButton: 'Cauta',
26
+ filterOrDate: 'sau cauta dupa data'
25
27
  },
26
28
  };
27
29
  export const translate = (key, customLang) => {