input-element.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. import { LitElement, html } from 'lit-element';
  2. import { connect } from 'pwa-helpers/connect-mixin.js';
  3. import { store } from '../store.js';
  4. import '@polymer/paper-dialog/paper-dialog.js';
  5. import '@polymer/paper-icon-button/paper-icon-button.js';
  6. import './my-icons.js';
  7. class InputElement extends connect(store)(LitElement) {
  8. static get properties() {
  9. return {
  10. task: { type: String },
  11. text: { type: String}
  12. };
  13. }
  14. constructor() {
  15. super();
  16. this.task = '';
  17. this.text='';
  18. }
  19. render() {
  20. return html`
  21. <style media="screen">
  22. .input-layout {
  23. width: 100%;
  24. text-align: center;
  25. }
  26. .money{
  27. width: 10em;
  28. height: 4em;
  29. }
  30. .keyboard {
  31. display: inline-block;
  32. padding: 0.75em 1.5em;
  33. text-align: center;
  34. display: flex;
  35. }
  36. .item{
  37. width: 39em;
  38. }
  39. .number{
  40. width: 10em;
  41. }
  42. .key{
  43. height: 3em;
  44. width: 3em;
  45. margin: 0.4em 0;
  46. }
  47. #text{
  48. width: 20em;
  49. height: 2em;
  50. }
  51. #task{
  52. width: 20em;
  53. height: 2em;
  54. }
  55. #space {
  56. width: 15em;
  57. height: 3em;
  58. }
  59. #back {
  60. font-weight: bold;
  61. height: 3em;
  62. width: 6em;
  63. }
  64. #enter{
  65. width: 5em;
  66. height: 5em;
  67. }
  68. label{
  69. margin-left: 1em;
  70. }
  71. @media (max-width: 767px) {
  72. }
  73. </style>
  74. <div class="input-layout">
  75. <input type="text" id="text" autocomplete="off" placeholder="Car Plate Number" value="${this.text ||''}"
  76. @click="${() => this.showModal()}" readonly="readonly">
  77. <paper-icon-button class="money" icon="money"
  78. @click="${this.addToCarNo}">
  79. </paper-icon-button>
  80. </div>
  81. <paper-dialog id="actions">
  82. <div>
  83. <label>Car Plate Number</label>:
  84. <input type="text" id="task" autocomplete="off" value="${this.task || ''}"
  85. @change="${this.updateTask}" readonly="readonly">
  86. </div>
  87. <div class="keyboard">
  88. <div class="item">
  89. <button class="key" @click="${() => this.addToKey("Q")}">Q</button>
  90. <button class="key" @click="${() => this.addToKey("W")}">W</button>
  91. <button class="key" @click="${() => this.addToKey("E")}">E</button>
  92. <button class="key" @click="${() => this.addToKey("R")}">R</button>
  93. <button class="key" @click="${() => this.addToKey("T")}">T</button>
  94. <button class="key" @click="${() => this.addToKey("Y")}">Y</button>
  95. <button class="key" @click="${() => this.addToKey("U")}">U</button>
  96. <button class="key" @click="${() => this.addToKey("I")}">I</button>
  97. <button class="key" @click="${() => this.addToKey("O")}">O</button>
  98. <button class="key" @click="${() => this.addToKey("P")}">P</button>
  99. <button id="back" @click="${() => this.addToBack()}">&#8592;</button>
  100. <button class="key" @click="${() => this.addToKey("A")}">A</button>
  101. <button class="key" @click="${() => this.addToKey("S")}">S</button>
  102. <button class="key" @click="${() => this.addToKey("D")}">D</button>
  103. <button class="key" @click="${() => this.addToKey("F")}">F</button>
  104. <button class="key" @click="${() => this.addToKey("G")}">G</button>
  105. <button class="key" @click="${() => this.addToKey("H")}">H</button>
  106. <button class="key" @click="${() => this.addToKey("J")}">J</button>
  107. <button class="key" @click="${() => this.addToKey("K")}">K</button>
  108. <button class="key" @click="${() => this.addToKey("L")}">L</button>
  109. <button id="enter" @click="${() => this.addToEnter()}">Enter</button><br>
  110. <button class="key" @click="${() => this.addToKey("Z")}">Z</button>
  111. <button class="key" @click="${() => this.addToKey("X")}">X</button>
  112. <button class="key" @click="${() => this.addToKey("C")}">C</button>
  113. <button class="key" @click="${() => this.addToKey("V")}">V</button>
  114. <button class="key" @click="${() => this.addToKey("B")}">B</button>
  115. <button class="key" @click="${() => this.addToKey("N")}">N</button>
  116. <button class="key" @click="${() => this.addToKey("M")}">M</button>
  117. <button class="key" @click="${() => this.addToClear()}">clear</button><br>
  118. <button class="key" @click="${() => this.addToKey("/")}">/</button>
  119. <button class="key" @click="${() => this.addToKey("-")}">-</button>
  120. <button id="space" @click="${() => this.addToKey(" ")}"></button>
  121. <button class="key" @click="${() => this.closeModel()}">close</button>
  122. </div><div class="number">
  123. <button class="key" @click="${() => this.addToKey("7")}">7</button>
  124. <button class="key" @click="${() => this.addToKey("8")}">8</button>
  125. <button class="key" @click="${() => this.addToKey("9")}">9</button>
  126. <button class="key" @click="${() => this.addToKey("4")}">4</button>
  127. <button class="key" @click="${() => this.addToKey("5")}">5</button>
  128. <button class="key" @click="${() => this.addToKey("6")}">6</button>
  129. <button class="key" @click="${() => this.addToKey("1")}">1</button>
  130. <button class="key" @click="${() => this.addToKey("2")}">2</button>
  131. <button class="key" @click="${() => this.addToKey("3")}">3</button>
  132. <button class="key" @click="${() => this.addToKey("0")}">0</button>
  133. </div>
  134. </div>
  135. </paper-dialog>
  136. `
  137. }
  138. addToKey(value){
  139. console.log('choose value:::',value);
  140. this.task+=value;
  141. }
  142. addToEnter(){
  143. this.text=this.task;
  144. console.log('button enter>>>',this.text);
  145. this.shadowRoot.getElementById("actions").close();
  146. }
  147. addToBack(){
  148. this.task =this.shadowRoot.getElementById('task').value.replace(/.$/,'');
  149. }
  150. addToClear(){
  151. this.task = '';
  152. }
  153. showModal() {
  154. this.shadowRoot.getElementById("actions").open();
  155. }
  156. closeModel(){
  157. this.shadowRoot.getElementById("actions").close();
  158. }
  159. updateTask(e){
  160. this.task=e.target.value;
  161. }
  162. addToCarNo() {
  163. console.log('add car number:::', this.text);
  164. // store.dispatch(addTodo(this.task));
  165. this.text="";
  166. this.task="";
  167. }
  168. }
  169. customElements.define('input-element', InputElement);