@everymatrix/helper-filters 0.1.0 → 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-d16cebbc.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;
@@ -900,9 +892,6 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
900
892
  .map(([propName, m]) => {
901
893
  const attrName = m[1] || propName;
902
894
  attrNameToPropName.set(attrName, propName);
903
- if (m[0] & 512 /* ReflectAttr */) {
904
- cmpMeta.$attrsToReflect$.push([propName, attrName]);
905
- }
906
895
  return attrName;
907
896
  });
908
897
  }
@@ -1063,9 +1052,6 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1063
1052
  {
1064
1053
  cmpMeta.$listeners$ = compactMeta[3];
1065
1054
  }
1066
- {
1067
- cmpMeta.$attrsToReflect$ = [];
1068
- }
1069
1055
  const tagName = cmpMeta.$tagName$;
1070
1056
  const HostElement = class extends HTMLElement {
1071
1057
  // StencilLazyHost
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-d16cebbc.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
  }
@@ -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() {
@@ -98,9 +99,7 @@ export class HelperFilters {
98
99
  h("div", { class: "FilterModalBody" },
99
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) }),
100
101
  h("p", null, translate('filterOrDate', this.language)),
101
- h("div", { class: "FilterCalendarWrapper" },
102
- h("vaadin-date-picker", { value: this.filterData.filterFromCalendar, onChange: (event) => this.handleFilterFrom(event), placeholder: translate('filterFromCalendar', this.language), class: "VaadinDatePicker" }),
103
- h("vaadin-date-picker", { value: this.filterData.filterToCalendar, onChange: (event) => this.handleFilterTo(event), placeholder: translate('filterToCalendar', this.language), class: "VaadinDatePicker" }))),
102
+ h("div", { class: "FilterCalendarWrapper" })),
104
103
  h("div", { class: "FilterModalFooter" },
105
104
  h("button", { class: "FilterModalButton", onClick: () => this.filterSearch() }, translate('filterModalButton', this.language))))));
106
105
  }