@operato/input 1.13.9 → 1.13.12

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ### [1.13.12](https://github.com/hatiolab/operato/compare/v1.13.11...v1.13.12) (2024-01-24)
7
+
8
+
9
+ ### :bug: Bug Fix
10
+
11
+ * fix typo ([5e71d20](https://github.com/hatiolab/operato/commit/5e71d20af7f30c57249cfbdfdeb9e88c48ef738e))
12
+ * ox-input-data 자동 타입 식별 기능 ([0763ddb](https://github.com/hatiolab/operato/commit/0763ddb2b0b9334c357d4b16df530ee3c8b883f3))
13
+
14
+
15
+
16
+ ### [1.13.11](https://github.com/hatiolab/operato/compare/v1.13.10...v1.13.11) (2024-01-18)
17
+
18
+
19
+ ### :bug: Bug Fix
20
+
21
+ * add composable property for ox-input-mass-fraction ([046f7d6](https://github.com/hatiolab/operato/commit/046f7d64a8280b6ad762cda0c88f58fa1fd644d8))
22
+
23
+
24
+
6
25
  ### [1.13.9](https://github.com/hatiolab/operato/compare/v1.13.8...v1.13.9) (2024-01-17)
7
26
 
8
27
  **Note:** Version bump only for package @operato/input
@@ -2,7 +2,6 @@
2
2
  * @license Copyright © HatioLab Inc. All rights reserved.
3
3
  */
4
4
  import './ox-input-code';
5
- import { PropertyValues } from 'lit';
6
5
  import { OxFormField } from './ox-form-field.js';
7
6
  /**
8
7
  WEB Component for code-mirror based data editor.
@@ -16,9 +15,8 @@ export declare class OxInputData extends OxFormField {
16
15
  static styles: import("lit").CSSResult[];
17
16
  render(): import("lit").TemplateResult<1>;
18
17
  firstUpdated(): void;
19
- udpated(changes: PropertyValues<this>): void;
20
18
  _setDataType(type: string | undefined | null): void;
21
19
  _clearData(): void;
22
20
  _getData(data: any): any;
23
- _onAfterValueChange(): void;
21
+ _onAfterValueChange(): Promise<void>;
24
22
  }
@@ -5,6 +5,7 @@ import { __decorate } from "tslib";
5
5
  import './ox-input-code';
6
6
  import { css, html } from 'lit';
7
7
  import { customElement } from 'lit/decorators.js';
8
+ import { live } from 'lit/directives/live.js';
8
9
  import { OxFormField } from './ox-form-field.js';
9
10
  /**
10
11
  WEB Component for code-mirror based data editor.
@@ -43,34 +44,42 @@ let OxInputData = class OxInputData extends OxFormField {
43
44
  `
44
45
  ]; }
45
46
  render() {
47
+ const valueType = typeof this.value;
46
48
  return html `
47
49
  <div datatype>
48
50
  <input
51
+ id="string"
49
52
  type="radio"
50
53
  name="data-type"
51
54
  data-value="string"
52
- .checked=${typeof this.value == 'string'}
55
+ .checked=${live(valueType == 'string')}
53
56
  @click=${() => this._setDataType('string')}
54
57
  ?disabled=${this.disabled}
55
- />string
58
+ />
59
+ <label for="string">string</label>
56
60
 
57
61
  <input
62
+ id="number"
58
63
  type="radio"
59
64
  name="data-type"
60
65
  data-value="number"
61
- .checked=${typeof this.value == 'number'}
66
+ .checked=${live(valueType == 'number')}
62
67
  @click=${() => this._setDataType('number')}
63
68
  ?disabled=${this.disabled}
64
- />number
69
+ />
70
+ <label for="number">number</label>
65
71
 
66
72
  <input
73
+ id="object"
67
74
  type="radio"
68
75
  name="data-type"
69
76
  data-value="object"
70
- .checked=${typeof this.value == 'object'}
77
+ .checked=${live(valueType == 'object')}
71
78
  @click=${() => this._setDataType('object')}
72
79
  ?disabled=${this.disabled}
73
- />object
80
+ />
81
+ <label for="object">object</label>
82
+
74
83
  <mwc-icon @click=${() => this._clearData()} title="delete">delete_forever</mwc-icon>
75
84
  </div>
76
85
 
@@ -89,18 +98,13 @@ let OxInputData = class OxInputData extends OxFormField {
89
98
  this._setDataType(type);
90
99
  });
91
100
  }
92
- udpated(changes) {
93
- if (changes.has('value')) {
94
- this.value = this._getData(this.value);
95
- }
96
- }
97
101
  _setDataType(type) {
98
102
  if (typeof this.value !== type) {
99
103
  var value = this.value;
100
104
  try {
101
105
  switch (type) {
102
106
  case 'string':
103
- this.value = String(value || '');
107
+ this.value = this._getData(value);
104
108
  break;
105
109
  case 'number':
106
110
  if (!isNaN(value)) {
@@ -116,6 +120,7 @@ let OxInputData = class OxInputData extends OxFormField {
116
120
  console.log(e);
117
121
  }
118
122
  }
123
+ this.requestUpdate();
119
124
  this._onAfterValueChange();
120
125
  }
121
126
  _clearData() {
@@ -125,7 +130,7 @@ let OxInputData = class OxInputData extends OxFormField {
125
130
  _getData(data) {
126
131
  return typeof data !== 'object' ? data || '' : JSON.stringify(data, null, 1);
127
132
  }
128
- _onAfterValueChange() {
133
+ async _onAfterValueChange() {
129
134
  this.dispatchEvent(new CustomEvent('change', {
130
135
  bubbles: true,
131
136
  composed: true
@@ -1 +1 @@
1
- {"version":3,"file":"ox-input-data.js","sourceRoot":"","sources":["../../src/ox-input-data.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,iBAAiB,CAAA;AAExB,OAAO,EAAE,GAAG,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAGhD;;;;;;;EAOE;AAEK,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,WAAW;aACnC,WAAM,GAAG;QACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;KAwBF;KACF,AA1BY,CA0BZ;IAED,MAAM;QACJ,OAAO,IAAI,CAAA;;;;;;qBAMM,OAAO,IAAI,CAAC,KAAK,IAAI,QAAQ;mBAC/B,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC;sBAC9B,IAAI,CAAC,QAAQ;;;;;;;qBAOd,OAAO,IAAI,CAAC,KAAK,IAAI,QAAQ;mBAC/B,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC;sBAC9B,IAAI,CAAC,QAA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MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAA;wBAChC,MAAK;oBACP,KAAK,QAAQ;wBACX,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;4BAClB,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;wBAC5B,CAAC;wBACD,MAAK;oBACP,KAAK,QAAQ;wBACX,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,GAAG,KAAK,GAAG,GAAG,CAAC,CAAA;wBACpC,MAAK;gBACT,CAAC;YACH,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;YAChB,CAAC;QACH,CAAC;QAED,IAAI,CAAC,mBAAmB,EAAE,CAAA;IAC5B,CAAC;IAED,UAAU;QACR,IAAI,CAAC,KAAK,GAAG,SAAS,CAAA;QACtB,IAAI,CAAC,mBAAmB,EAAE,CAAA;IAC5B,CAAC;IAED,QAAQ,CAAC,IAAS;QAChB,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAC9E,CAAC;IAED,mBAAmB;QACjB,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,QAAQ,EAAE;YACxB,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;SACf,CAAC,CACH,CAAA;IACH,CAAC;;AA/HU,WAAW;IADvB,aAAa,CAAC,eAAe,CAAC;GAClB,WAAW,CAgIvB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport './ox-input-code'\n\nimport { css, html, PropertyValues } from 'lit'\nimport { customElement } from 'lit/decorators.js'\n\nimport { OxFormField } from './ox-form-field.js'\nimport { OxInputCode } from './ox-input-code.js'\n\n/**\nWEB Component for code-mirror based data editor.\n\nExample:\n\n <ox-input-data value=${text}>\n </ox-input-data>\n*/\n@customElement('ox-input-data')\nexport class OxInputData extends OxFormField {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n position: relative;\n }\n\n div[datatype] {\n display: flex;\n align-items: center;\n padding: 2px;\n background-color: rgba(0, 0, 0, 0.08);\n font-size: small;\n }\n\n div[datatype] mwc-icon {\n margin-left: auto;\n }\n\n ox-input-code {\n flex: 1;\n max-width: 260px;\n overflow: auto;\n }\n `\n ]\n\n render() {\n return html`\n <div datatype>\n <input\n type=\"radio\"\n name=\"data-type\"\n data-value=\"string\"\n .checked=${typeof this.value == 'string'}\n @click=${() => this._setDataType('string')}\n ?disabled=${this.disabled}\n />string\n\n <input\n type=\"radio\"\n name=\"data-type\"\n data-value=\"number\"\n .checked=${typeof this.value == 'number'}\n @click=${() => this._setDataType('number')}\n ?disabled=${this.disabled}\n />number\n\n <input\n type=\"radio\"\n name=\"data-type\"\n data-value=\"object\"\n .checked=${typeof this.value == 'object'}\n @click=${() => this._setDataType('object')}\n ?disabled=${this.disabled}\n />object\n <mwc-icon @click=${() => this._clearData()} title=\"delete\">delete_forever</mwc-icon>\n </div>\n\n <ox-input-code .value=${this._getData(this.value)} language=\"javascript\" editor ?disabled=${this.disabled}>\n </ox-input-code>\n `\n }\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', e => {\n e.stopPropagation()\n const target = e.target as OxInputCode\n if (target.hasAttribute('editor')) {\n this.value = target.value\n }\n\n const type = this.renderRoot.querySelector('input[name=data-type]:checked')?.getAttribute('data-value')\n this._setDataType(type)\n })\n }\n\n udpated(changes: PropertyValues<this>) {\n if (changes.has('value')) {\n this.value = this._getData(this.value)\n }\n }\n\n _setDataType(type: string | undefined | null) {\n if (typeof this.value !== type) {\n var value = this.value\n\n try {\n switch (type) {\n case 'string':\n this.value = String(value || '')\n break\n case 'number':\n if (!isNaN(value)) {\n this.value = Number(value)\n }\n break\n case 'object':\n this.value = eval('(' + value + ')')\n break\n }\n } catch (e) {\n console.log(e)\n }\n }\n\n this._onAfterValueChange()\n }\n\n _clearData() {\n this.value = undefined\n this._onAfterValueChange()\n }\n\n _getData(data: any) {\n return typeof data !== 'object' ? data || '' : JSON.stringify(data, null, 1)\n }\n\n _onAfterValueChange() {\n this.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true\n })\n )\n }\n}\n"]}
1
+ {"version":3,"file":"ox-input-data.js","sourceRoot":"","sources":["../../src/ox-input-data.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,iBAAiB,CAAA;AAExB,OAAO,EAAE,GAAG,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAS,MAAM,mBAAmB,CAAA;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAGhD;;;;;;;EAOE;AAEK,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,WAAW;aACnC,WAAM,GAAG;QACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;KAwBF;KACF,AA1BY,CA0BZ;IAED,MAAM;QACJ,MAAM,SAAS,GAAG,OAAO,IAAI,CAAC,KAAK,CAAA;QAEnC,OAAO,IAAI,CAAA;;;;;;;qBAOM,IAAI,CAAC,SAAS,IAAI,QAAQ,CAAC;mBAC7B,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC;sBAC9B,IAAI,CAAC,QAAQ;;;;;;;;;qBASd,IAAI,CAAC,SAAS,IAAI,QAAQ,CAAC;mBAC7B,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC;sBAC9B,IAAI,CAAC,QAAQ;;;;;;;;;qBASd,IAAI,CAAC,SAAS,IAAI,QAAQ,CAAC;mBAC7B,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC;sB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AAC,CAAA;wBACpC,MAAK;gBACT,CAAC;YACH,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;YAChB,CAAC;QACH,CAAC;QAED,IAAI,CAAC,aAAa,EAAE,CAAA;QACpB,IAAI,CAAC,mBAAmB,EAAE,CAAA;IAC5B,CAAC;IAED,UAAU;QACR,IAAI,CAAC,KAAK,GAAG,SAAS,CAAA;QACtB,IAAI,CAAC,mBAAmB,EAAE,CAAA;IAC5B,CAAC;IAED,QAAQ,CAAC,IAAS;QAChB,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAC9E,CAAC;IAED,KAAK,CAAC,mBAAmB;QACvB,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,QAAQ,EAAE;YACxB,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;SACf,CAAC,CACH,CAAA;IACH,CAAC;;AAnIU,WAAW;IADvB,aAAa,CAAC,eAAe,CAAC;GAClB,WAAW,CAoIvB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport './ox-input-code'\n\nimport { css, html, PropertyValues } from 'lit'\nimport { customElement, state } from 'lit/decorators.js'\nimport { live } from 'lit/directives/live.js'\n\nimport { OxFormField } from './ox-form-field.js'\nimport { OxInputCode } from './ox-input-code.js'\n\n/**\nWEB Component for code-mirror based data editor.\n\nExample:\n\n <ox-input-data value=${text}>\n </ox-input-data>\n*/\n@customElement('ox-input-data')\nexport class OxInputData extends OxFormField {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n position: relative;\n }\n\n div[datatype] {\n display: flex;\n align-items: center;\n padding: 2px;\n background-color: rgba(0, 0, 0, 0.08);\n font-size: small;\n }\n\n div[datatype] mwc-icon {\n margin-left: auto;\n }\n\n ox-input-code {\n flex: 1;\n max-width: 260px;\n overflow: auto;\n }\n `\n ]\n\n render() {\n const valueType = typeof this.value\n\n return html`\n <div datatype>\n <input\n id=\"string\"\n type=\"radio\"\n name=\"data-type\"\n data-value=\"string\"\n .checked=${live(valueType == 'string')}\n @click=${() => this._setDataType('string')}\n ?disabled=${this.disabled}\n />\n <label for=\"string\">string</label>\n\n <input\n id=\"number\"\n type=\"radio\"\n name=\"data-type\"\n data-value=\"number\"\n .checked=${live(valueType == 'number')}\n @click=${() => this._setDataType('number')}\n ?disabled=${this.disabled}\n />\n <label for=\"number\">number</label>\n\n <input\n id=\"object\"\n type=\"radio\"\n name=\"data-type\"\n data-value=\"object\"\n .checked=${live(valueType == 'object')}\n @click=${() => this._setDataType('object')}\n ?disabled=${this.disabled}\n />\n <label for=\"object\">object</label>\n\n <mwc-icon @click=${() => this._clearData()} title=\"delete\">delete_forever</mwc-icon>\n </div>\n\n <ox-input-code .value=${this._getData(this.value)} language=\"javascript\" editor ?disabled=${this.disabled}>\n </ox-input-code>\n `\n }\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', e => {\n e.stopPropagation()\n const target = e.target as OxInputCode\n if (target.hasAttribute('editor')) {\n this.value = target.value\n }\n\n const type = this.renderRoot.querySelector('input[name=data-type]:checked')?.getAttribute('data-value')\n this._setDataType(type)\n })\n }\n\n _setDataType(type: string | undefined | null) {\n if (typeof this.value !== type) {\n var value = this.value\n\n try {\n switch (type) {\n case 'string':\n this.value = this._getData(value)\n break\n case 'number':\n if (!isNaN(value)) {\n this.value = Number(value)\n }\n break\n case 'object':\n this.value = eval('(' + value + ')')\n break\n }\n } catch (e) {\n console.log(e)\n }\n }\n\n this.requestUpdate()\n this._onAfterValueChange()\n }\n\n _clearData() {\n this.value = undefined\n this._onAfterValueChange()\n }\n\n _getData(data: any) {\n return typeof data !== 'object' ? data || '' : JSON.stringify(data, null, 1)\n }\n\n async _onAfterValueChange() {\n this.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true\n })\n )\n }\n}\n"]}
@@ -28,6 +28,7 @@ export declare class OxInputMassFraction extends OxFormField {
28
28
  static styles: import("lit").CSSResult[];
29
29
  defaultValue: MassFraction;
30
30
  value: MassFraction;
31
+ composable: boolean;
31
32
  records: NodeListOf<HTMLElement>;
32
33
  private options;
33
34
  private changingNow;
@@ -25,6 +25,7 @@ let OxInputMassFraction = class OxInputMassFraction extends OxFormField {
25
25
  super(...arguments);
26
26
  this.defaultValue = {};
27
27
  this.value = {};
28
+ this.composable = false;
28
29
  this.options = FLUIDS.map(fluid => html `<div option value=${fluid}>${fluid}</div>`);
29
30
  this.changingNow = false;
30
31
  }
@@ -123,6 +124,10 @@ let OxInputMassFraction = class OxInputMassFraction extends OxFormField {
123
124
  display: block;
124
125
  text-align: center;
125
126
  }
127
+
128
+ [right-end] {
129
+ margin-left: auto;
130
+ }
126
131
  `
127
132
  ]; }
128
133
  firstUpdated() {
@@ -148,14 +153,18 @@ let OxInputMassFraction = class OxInputMassFraction extends OxFormField {
148
153
  list="value-template"
149
154
  ?disabled=${this.disabled}
150
155
  />
151
- <button
152
- class="record-action"
153
- @click=${(e) => this._delete(e)}
154
- tabindex="-1"
155
- ?disabled=${this.disabled}
156
- >
157
- <mwc-icon>remove</mwc-icon>
158
- </button>
156
+ ${this.composable
157
+ ? html `
158
+ <button
159
+ class="record-action"
160
+ @click=${(e) => this._delete(e)}
161
+ tabindex="-1"
162
+ ?disabled=${this.disabled}
163
+ >
164
+ <mwc-icon>remove</mwc-icon>
165
+ </button>
166
+ `
167
+ : nothing}
159
168
  <button
160
169
  class="record-action"
161
170
  @click=${(e) => this._up(e)}
@@ -181,36 +190,41 @@ let OxInputMassFraction = class OxInputMassFraction extends OxFormField {
181
190
  ? nothing
182
191
  : html `
183
192
  <div data-record-new>
184
- <ox-select
185
- data-key
186
- placeholder="Fluid"
187
- .value=${live('')}
188
- @change=${(e) => {
189
- e.stopPropagation();
190
- }}
191
- >
192
- <ox-popup-list with-search> ${this.options} </ox-popup-list>
193
- </ox-select>
193
+ ${this.composable
194
+ ? html `
195
+ <ox-select
196
+ data-key
197
+ placeholder="Fluid"
198
+ .value=${live('')}
199
+ @change=${(e) => {
200
+ e.stopPropagation();
201
+ }}
202
+ >
203
+ <ox-popup-list with-search> ${this.options} </ox-popup-list>
204
+ </ox-select>
194
205
 
195
- <input
196
- type="number"
197
- data-value
198
- placeholder="proportion"
199
- min="0"
200
- max="1"
201
- step="0.01"
202
- value=""
203
- list="value-template"
204
- />
205
- <button class="record-action" @click=${(e) => this._add()} tabindex="-1">
206
- <mwc-icon>add</mwc-icon>
207
- </button>
206
+ <input
207
+ type="number"
208
+ data-value
209
+ placeholder="proportion"
210
+ min="0"
211
+ max="1"
212
+ step="0.01"
213
+ value=""
214
+ list="value-template"
215
+ />
216
+ <button class="record-action" @click=${(e) => this._add()} tabindex="-1">
217
+ <mwc-icon>add</mwc-icon>
218
+ </button>
219
+ `
220
+ : nothing}
208
221
  <button
209
222
  title="fill with the values suggested"
210
223
  @click=${() => {
211
224
  this.value = { ...this.defaultValue };
212
225
  this.dispatchChangeEvent();
213
226
  }}
227
+ right-end
214
228
  >
215
229
  <mwc-icon>settings_suggest</mwc-icon>
216
230
  </button>
@@ -346,6 +360,9 @@ __decorate([
346
360
  __decorate([
347
361
  property({ type: Object })
348
362
  ], OxInputMassFraction.prototype, "value", void 0);
363
+ __decorate([
364
+ property({ type: Boolean, attribute: true })
365
+ ], OxInputMassFraction.prototype, "composable", void 0);
349
366
  __decorate([
350
367
  queryAll('[data-record]')
351
368
  ], OxInputMassFraction.prototype, "records", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"ox-input-mass-fraction.js","sourceRoot":"","sources":["../../src/ox-input-mass-fraction.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,oBAAoB,CAAA;AAC3B,OAAO,iCAAiC,CAAA;AACxC,OAAO,gBAAgB,CAAA;AAEvB,OAAO,EAAE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AAK,CAAA;YAC1E,MAAM,KAAK,GAAI,MAAM,CAAC,aAAa,CAAC,cAAc,CAAsB,CAAC,KAAK,CAAA;YAE9E,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;YAC7B,OAAO,GAAG,CAAA;QACZ,CAAC,EAAE,EAAkB,CAAC,CAAA;QAEtB,IAAI,CAAC,mBAAmB,EAAE,CAAA;IAC5B,CAAC;IAED,mBAAmB;QACjB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IACtG,CAAC;;AA3Q2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAAgC;AAC/B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAyB;AAEzB;IAA1B,QAAQ,CAAC,eAAe,CAAC;oDAAkC;AAtGjD,mBAAmB;IAD/B,aAAa,CAAC,wBAAwB,CAAC;GAC3B,mBAAmB,CA+W/B","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport '@material/mwc-icon'\nimport '@operato/popup/ox-popup-list.js'\nimport './ox-select.js'\n\nimport { css, html, nothing } from 'lit'\nimport { customElement, property, queryAll } from 'lit/decorators.js'\nimport { live } from 'lit/directives/live.js'\n\nimport { ScrollbarStyles } from '@operato/styles'\n\nimport { OxFormField } from './ox-form-field'\n\nconst FLUIDS = ['CH4', 'C2H6', 'C3H8', 'C4H10', 'CO2', 'H2O', 'H2S', 'N2', 'N2O', 'NO2', 'O2']\n\ntype ArrayElement<ArrayType extends readonly unknown[]> = ArrayType extends readonly (infer ElementType)[]\n ? ElementType\n : never\n\ntype FLUID = ArrayElement<typeof FLUIDS>\n\ntype MassFraction = { [key: FLUID]: number }\ntype ArrayedMassFraction = { key: FLUID; value: number }[]\n\n/**\n input component for mass-fraction map\n \n Example:\n \n <ox-input-mass-fraction \n value=${map}\n </ox-input-mass-fraction>\n */\n@customElement('ox-input-mass-fraction')\nexport class OxInputMassFraction extends OxFormField {\n static styles = [\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n }\n\n [records] {\n flex: 1;\n\n overflow: overlay;\n }\n\n [records] > div {\n display: flex;\n flex-flow: row nowrap;\n gap: var(--mass-fraction-gap, 3px);\n margin-bottom: var(--margin-narrow);\n }\n\n [data-record-new] {\n display: flex;\n flex-flow: row nowrap;\n gap: var(--mass-fraction-gap, 3px);\n margin: var(--margin-narrow) 0;\n }\n\n button {\n display: inherit;\n align-self: center;\n border: var(--button-border);\n border-radius: var(--border-radius);\n background-color: var(--button-background-color);\n padding: var(--mass-fraction-button-padding-vertical, 3px) var(--mass-fraction-button-padding-horizontal, 3px);\n color: var(--button-color);\n cursor: pointer;\n }\n button mwc-icon {\n font-size: var(--fontsize-default);\n }\n button:focus,\n button:hover,\n button:active {\n border: var(--button-active-border);\n background-color: var(--button-background-focus-color);\n color: var(--theme-white-color);\n }\n\n input,\n ox-select {\n border: 0;\n border-bottom: var(--border-dark-color);\n font: var(--input-font);\n color: var(--primary-text-color);\n min-width: 50px;\n }\n\n input {\n padding: var(--input-padding);\n }\n\n ox-select {\n padding: 0;\n }\n\n [data-key] {\n flex: 2;\n }\n\n [data-value] {\n flex: 1;\n }\n\n input:focus {\n outline: none;\n border-bottom: 1px solid var(--primary-color);\n }\n\n button.hidden {\n opacity: 0;\n cursor: default;\n }\n\n ox-popup-list {\n max-height: 300px;\n overflow: auto;\n left: 0;\n }\n\n [records] > [nofraction] {\n display: block;\n text-align: center;\n }\n `\n ]\n\n @property({ type: Object }) defaultValue: MassFraction = {}\n @property({ type: Object }) value: MassFraction = {}\n\n @queryAll('[data-record]') records!: NodeListOf<HTMLElement>\n\n private options = FLUIDS.map(fluid => html`<div option value=${fluid}>${fluid}</div>`)\n private changingNow: boolean = false\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', this._onChange.bind(this))\n }\n\n render() {\n const value = !this.value || typeof this.value !== 'object' ? {} : this.value\n const arrayed = this._toArray(value)\n\n return html`\n <div records>\n ${arrayed.length\n ? arrayed.map(\n (item, idx) => html`\n <div data-record>\n <input type=\"text\" data-key .value=${item.key} disabled />\n <input\n type=\"number\"\n data-value\n placeholder=\"fraction\"\n min=\"0\"\n max=\"1\"\n step=\"0.01\"\n .value=${String(item.value)}\n list=\"value-template\"\n ?disabled=${this.disabled}\n />\n <button\n class=\"record-action\"\n @click=${(e: MouseEvent) => this._delete(e)}\n tabindex=\"-1\"\n ?disabled=${this.disabled}\n >\n <mwc-icon>remove</mwc-icon>\n </button>\n <button\n class=\"record-action\"\n @click=${(e: MouseEvent) => this._up(e)}\n tabindex=\"-1\"\n ?disabled=${this.disabled || idx === 0}\n >\n <mwc-icon>arrow_upward</mwc-icon>\n </button>\n <button\n class=\"record-action\"\n @click=${(e: MouseEvent) => this._down(e)}\n tabindex=\"-1\"\n ?disabled=${this.disabled || idx === arrayed.length - 1}\n >\n <mwc-icon>arrow_downward</mwc-icon>\n </button>\n </div>\n `\n )\n : html`<div nofraction>No Fractions</div>`}\n </div>\n\n ${this.disabled\n ? nothing\n : html`\n <div data-record-new>\n <ox-select\n data-key\n placeholder=\"Fluid\"\n .value=${live('')}\n @change=${(e: Event) => {\n e.stopPropagation()\n }}\n >\n <ox-popup-list with-search> ${this.options} </ox-popup-list>\n </ox-select>\n\n <input\n type=\"number\"\n data-value\n placeholder=\"proportion\"\n min=\"0\"\n max=\"1\"\n step=\"0.01\"\n value=\"\"\n list=\"value-template\"\n />\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._add()} tabindex=\"-1\">\n <mwc-icon>add</mwc-icon>\n </button>\n <button\n title=\"fill with the values suggested\"\n @click=${() => {\n this.value = { ...this.defaultValue }\n this.dispatchChangeEvent()\n }}\n >\n <mwc-icon>settings_suggest</mwc-icon>\n </button>\n <button\n title=\"normalize fraction\"\n @click=${() => {\n this._normalize()\n }}\n >\n <mwc-icon>repartition</mwc-icon>\n </button>\n </div>\n `}\n `\n }\n\n _onChange(e: Event) {\n if (this.changingNow) {\n return\n }\n\n this.changingNow = true\n\n const input = e.target as HTMLInputElement\n\n const record = (e.target as Element).closest('[data-record],[data-record-new]') as HTMLElement\n\n if (record.hasAttribute('data-record')) {\n this._build()\n } else if (record.hasAttribute('data-record-new') && input.hasAttribute('data-value')) {\n this._add()\n }\n\n this.changingNow = false\n }\n\n _normalize() {\n const fraction: MassFraction = this.value || {}\n const sum = Object.values(fraction).reduce((a, b) => a + b, 0)\n this.value = Object.keys(fraction).reduce((newvalue, key) => {\n newvalue[key] = fraction[key] / sum\n return newvalue\n }, {} as MassFraction)\n\n this.dispatchChangeEvent()\n }\n\n _build(includeNewRecord?: boolean) {\n if (includeNewRecord) {\n var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]') as NodeListOf<HTMLElement>\n } else {\n var records = this.renderRoot.querySelectorAll('[data-record]') as NodeListOf<HTMLElement>\n }\n\n var newmap: MassFraction = {}\n\n for (var i = 0; i < records.length; i++) {\n var record = records[i]\n\n const key = (record.querySelector('[data-key]') as HTMLInputElement).value\n const inputs = record.querySelectorAll(\n '[data-value]:not([style*=\"display: none\"])'\n ) as NodeListOf<HTMLInputElement>\n\n if (!inputs || inputs.length == 0) {\n continue\n }\n\n var input = inputs[inputs.length - 1]\n\n var value = input.value\n\n if (key) {\n newmap[key] = Number(value) || 0\n }\n }\n\n this.value = newmap\n\n this.dispatchChangeEvent()\n }\n\n /* map아이템들을 template(dom-repeat)용 배열로 변환하는 함수 */\n _toArray(map: MassFraction) {\n var array: ArrayedMassFraction = []\n\n for (var key in map) {\n array.push({\n key: key,\n value: map[key]\n })\n }\n\n return array\n }\n\n _add() {\n this._build(true)\n\n const inputs = this.renderRoot.querySelectorAll(\n '[data-record-new] input:not([style*=\"display: none\"])'\n ) as NodeListOf<HTMLInputElement & { value: any }>\n\n for (var i = 0; i < inputs.length; i++) {\n let input = inputs[i]\n\n if (input.type == 'checkbox') input.checked = false\n else input.value = ''\n }\n\n inputs[0].focus()\n }\n\n _delete(e: MouseEvent) {\n const record = (e.target as Element).closest('[data-record]') as HTMLElement\n\n ;(record!.querySelector('[data-key]') as HTMLInputElement)!.value = ''\n\n this._build()\n }\n\n _up(e: MouseEvent) {\n const record = (e.target as Element).closest('[data-record]') as HTMLElement\n const array = Array.from(this.records)\n const index = array.indexOf(record) - 1\n\n if (index < 0) {\n return\n }\n\n const deleted = array.splice(index, 1)\n array.splice(index + 1, 0, ...deleted)\n\n this.value = array.reduce((sum, record) => {\n const key = (record.querySelector('[data-key]') as HTMLInputElement).value\n const value = (record.querySelector('[data-value]') as HTMLInputElement).value\n\n sum[key] = Number(value) || 0\n return sum\n }, {} as MassFraction)\n\n this.dispatchChangeEvent()\n }\n\n _down(e: MouseEvent) {\n const record = (e.target as Element).closest('[data-record]') as HTMLElement\n const array = Array.from(this.records)\n const index = array.indexOf(record)\n\n if (index > array.length) {\n return\n }\n\n array.splice(index, 1)\n array.splice(index + 1, 0, record)\n\n this.value = array.reduce((sum, record) => {\n const key = (record.querySelector('[data-key]') as HTMLInputElement).value\n const value = (record.querySelector('[data-value]') as HTMLInputElement).value\n\n sum[key] = Number(value) || 0\n return sum\n }, {} as MassFraction)\n\n this.dispatchChangeEvent()\n }\n\n dispatchChangeEvent() {\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n}\n"]}
1
+ {"version":3,"file":"ox-input-mass-fraction.js","sourceRoot":"","sources":["../../src/ox-input-mass-fraction.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,oBAAoB,CAAA;AAC3B,OAAO,iCAAiC,CAAA;AACxC,OAAO,gBAAgB,CAAA;AAEvB,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAA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C,CAAA;QAElC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;YACxC,MAAM,GAAG,GAAI,MAAM,CAAC,aAAa,CAAC,YAAY,CAAsB,CAAC,KAAK,CAAA;YAC1E,MAAM,KAAK,GAAI,MAAM,CAAC,aAAa,CAAC,cAAc,CAAsB,CAAC,KAAK,CAAA;YAE9E,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;YAC7B,OAAO,GAAG,CAAA;QACZ,CAAC,EAAE,EAAkB,CAAC,CAAA;QAEtB,IAAI,CAAC,mBAAmB,EAAE,CAAA;IAC5B,CAAC;IAED,mBAAmB;QACjB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IACtG,CAAC;;AArR2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAAgC;AAC/B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAyB;AACN;IAA7C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;uDAA4B;AAE9C;IAA1B,QAAQ,CAAC,eAAe,CAAC;oDAAkC;AA3GjD,mBAAmB;IAD/B,aAAa,CAAC,wBAAwB,CAAC;GAC3B,mBAAmB,CA6X/B","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport '@material/mwc-icon'\nimport '@operato/popup/ox-popup-list.js'\nimport './ox-select.js'\n\nimport { css, html, nothing } from 'lit'\nimport { customElement, property, queryAll } from 'lit/decorators.js'\nimport { live } from 'lit/directives/live.js'\n\nimport { ScrollbarStyles } from '@operato/styles'\n\nimport { OxFormField } from './ox-form-field'\n\nconst FLUIDS = ['CH4', 'C2H6', 'C3H8', 'C4H10', 'CO2', 'H2O', 'H2S', 'N2', 'N2O', 'NO2', 'O2']\n\ntype ArrayElement<ArrayType extends readonly unknown[]> = ArrayType extends readonly (infer ElementType)[]\n ? ElementType\n : never\n\ntype FLUID = ArrayElement<typeof FLUIDS>\n\ntype MassFraction = { [key: FLUID]: number }\ntype ArrayedMassFraction = { key: FLUID; value: number }[]\n\n/**\n input component for mass-fraction map\n \n Example:\n \n <ox-input-mass-fraction \n value=${map}\n </ox-input-mass-fraction>\n */\n@customElement('ox-input-mass-fraction')\nexport class OxInputMassFraction extends OxFormField {\n static styles = [\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n }\n\n [records] {\n flex: 1;\n\n overflow: overlay;\n }\n\n [records] > div {\n display: flex;\n flex-flow: row nowrap;\n gap: var(--mass-fraction-gap, 3px);\n margin-bottom: var(--margin-narrow);\n }\n\n [data-record-new] {\n display: flex;\n flex-flow: row nowrap;\n gap: var(--mass-fraction-gap, 3px);\n margin: var(--margin-narrow) 0;\n }\n\n button {\n display: inherit;\n align-self: center;\n border: var(--button-border);\n border-radius: var(--border-radius);\n background-color: var(--button-background-color);\n padding: var(--mass-fraction-button-padding-vertical, 3px) var(--mass-fraction-button-padding-horizontal, 3px);\n color: var(--button-color);\n cursor: pointer;\n }\n button mwc-icon {\n font-size: var(--fontsize-default);\n }\n button:focus,\n button:hover,\n button:active {\n border: var(--button-active-border);\n background-color: var(--button-background-focus-color);\n color: var(--theme-white-color);\n }\n\n input,\n ox-select {\n border: 0;\n border-bottom: var(--border-dark-color);\n font: var(--input-font);\n color: var(--primary-text-color);\n min-width: 50px;\n }\n\n input {\n padding: var(--input-padding);\n }\n\n ox-select {\n padding: 0;\n }\n\n [data-key] {\n flex: 2;\n }\n\n [data-value] {\n flex: 1;\n }\n\n input:focus {\n outline: none;\n border-bottom: 1px solid var(--primary-color);\n }\n\n button.hidden {\n opacity: 0;\n cursor: default;\n }\n\n ox-popup-list {\n max-height: 300px;\n overflow: auto;\n left: 0;\n }\n\n [records] > [nofraction] {\n display: block;\n text-align: center;\n }\n\n [right-end] {\n margin-left: auto;\n }\n `\n ]\n\n @property({ type: Object }) defaultValue: MassFraction = {}\n @property({ type: Object }) value: MassFraction = {}\n @property({ type: Boolean, attribute: true }) composable: boolean = false\n\n @queryAll('[data-record]') records!: NodeListOf<HTMLElement>\n\n private options = FLUIDS.map(fluid => html`<div option value=${fluid}>${fluid}</div>`)\n private changingNow: boolean = false\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', this._onChange.bind(this))\n }\n\n render() {\n const value = !this.value || typeof this.value !== 'object' ? {} : this.value\n const arrayed = this._toArray(value)\n\n return html`\n <div records>\n ${arrayed.length\n ? arrayed.map(\n (item, idx) => html`\n <div data-record>\n <input type=\"text\" data-key .value=${item.key} disabled />\n <input\n type=\"number\"\n data-value\n placeholder=\"fraction\"\n min=\"0\"\n max=\"1\"\n step=\"0.01\"\n .value=${String(item.value)}\n list=\"value-template\"\n ?disabled=${this.disabled}\n />\n ${this.composable\n ? html`\n <button\n class=\"record-action\"\n @click=${(e: MouseEvent) => this._delete(e)}\n tabindex=\"-1\"\n ?disabled=${this.disabled}\n >\n <mwc-icon>remove</mwc-icon>\n </button>\n `\n : nothing}\n <button\n class=\"record-action\"\n @click=${(e: MouseEvent) => this._up(e)}\n tabindex=\"-1\"\n ?disabled=${this.disabled || idx === 0}\n >\n <mwc-icon>arrow_upward</mwc-icon>\n </button>\n <button\n class=\"record-action\"\n @click=${(e: MouseEvent) => this._down(e)}\n tabindex=\"-1\"\n ?disabled=${this.disabled || idx === arrayed.length - 1}\n >\n <mwc-icon>arrow_downward</mwc-icon>\n </button>\n </div>\n `\n )\n : html`<div nofraction>No Fractions</div>`}\n </div>\n\n ${this.disabled\n ? nothing\n : html`\n <div data-record-new>\n ${this.composable\n ? html`\n <ox-select\n data-key\n placeholder=\"Fluid\"\n .value=${live('')}\n @change=${(e: Event) => {\n e.stopPropagation()\n }}\n >\n <ox-popup-list with-search> ${this.options} </ox-popup-list>\n </ox-select>\n\n <input\n type=\"number\"\n data-value\n placeholder=\"proportion\"\n min=\"0\"\n max=\"1\"\n step=\"0.01\"\n value=\"\"\n list=\"value-template\"\n />\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._add()} tabindex=\"-1\">\n <mwc-icon>add</mwc-icon>\n </button>\n `\n : nothing}\n <button\n title=\"fill with the values suggested\"\n @click=${() => {\n this.value = { ...this.defaultValue }\n this.dispatchChangeEvent()\n }}\n right-end\n >\n <mwc-icon>settings_suggest</mwc-icon>\n </button>\n <button\n title=\"normalize fraction\"\n @click=${() => {\n this._normalize()\n }}\n >\n <mwc-icon>repartition</mwc-icon>\n </button>\n </div>\n `}\n `\n }\n\n _onChange(e: Event) {\n if (this.changingNow) {\n return\n }\n\n this.changingNow = true\n\n const input = e.target as HTMLInputElement\n\n const record = (e.target as Element).closest('[data-record],[data-record-new]') as HTMLElement\n\n if (record.hasAttribute('data-record')) {\n this._build()\n } else if (record.hasAttribute('data-record-new') && input.hasAttribute('data-value')) {\n this._add()\n }\n\n this.changingNow = false\n }\n\n _normalize() {\n const fraction: MassFraction = this.value || {}\n const sum = Object.values(fraction).reduce((a, b) => a + b, 0)\n this.value = Object.keys(fraction).reduce((newvalue, key) => {\n newvalue[key] = fraction[key] / sum\n return newvalue\n }, {} as MassFraction)\n\n this.dispatchChangeEvent()\n }\n\n _build(includeNewRecord?: boolean) {\n if (includeNewRecord) {\n var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]') as NodeListOf<HTMLElement>\n } else {\n var records = this.renderRoot.querySelectorAll('[data-record]') as NodeListOf<HTMLElement>\n }\n\n var newmap: MassFraction = {}\n\n for (var i = 0; i < records.length; i++) {\n var record = records[i]\n\n const key = (record.querySelector('[data-key]') as HTMLInputElement).value\n const inputs = record.querySelectorAll(\n '[data-value]:not([style*=\"display: none\"])'\n ) as NodeListOf<HTMLInputElement>\n\n if (!inputs || inputs.length == 0) {\n continue\n }\n\n var input = inputs[inputs.length - 1]\n\n var value = input.value\n\n if (key) {\n newmap[key] = Number(value) || 0\n }\n }\n\n this.value = newmap\n\n this.dispatchChangeEvent()\n }\n\n /* map아이템들을 template(dom-repeat)용 배열로 변환하는 함수 */\n _toArray(map: MassFraction) {\n var array: ArrayedMassFraction = []\n\n for (var key in map) {\n array.push({\n key: key,\n value: map[key]\n })\n }\n\n return array\n }\n\n _add() {\n this._build(true)\n\n const inputs = this.renderRoot.querySelectorAll(\n '[data-record-new] input:not([style*=\"display: none\"])'\n ) as NodeListOf<HTMLInputElement & { value: any }>\n\n for (var i = 0; i < inputs.length; i++) {\n let input = inputs[i]\n\n if (input.type == 'checkbox') input.checked = false\n else input.value = ''\n }\n\n inputs[0].focus()\n }\n\n _delete(e: MouseEvent) {\n const record = (e.target as Element).closest('[data-record]') as HTMLElement\n\n ;(record!.querySelector('[data-key]') as HTMLInputElement)!.value = ''\n\n this._build()\n }\n\n _up(e: MouseEvent) {\n const record = (e.target as Element).closest('[data-record]') as HTMLElement\n const array = Array.from(this.records)\n const index = array.indexOf(record) - 1\n\n if (index < 0) {\n return\n }\n\n const deleted = array.splice(index, 1)\n array.splice(index + 1, 0, ...deleted)\n\n this.value = array.reduce((sum, record) => {\n const key = (record.querySelector('[data-key]') as HTMLInputElement).value\n const value = (record.querySelector('[data-value]') as HTMLInputElement).value\n\n sum[key] = Number(value) || 0\n return sum\n }, {} as MassFraction)\n\n this.dispatchChangeEvent()\n }\n\n _down(e: MouseEvent) {\n const record = (e.target as Element).closest('[data-record]') as HTMLElement\n const array = Array.from(this.records)\n const index = array.indexOf(record)\n\n if (index > array.length) {\n return\n }\n\n array.splice(index, 1)\n array.splice(index + 1, 0, record)\n\n this.value = array.reduce((sum, record) => {\n const key = (record.querySelector('[data-key]') as HTMLInputElement).value\n const value = (record.querySelector('[data-value]') as HTMLInputElement).value\n\n sum[key] = Number(value) || 0\n return sum\n }, {} as MassFraction)\n\n this.dispatchChangeEvent()\n }\n\n dispatchChangeEvent() {\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n}\n"]}
@@ -0,0 +1,33 @@
1
+ import '../src/ox-input-data.js';
2
+ import { TemplateResult } from 'lit';
3
+ declare const _default: {
4
+ title: string;
5
+ component: string;
6
+ argTypes: {
7
+ value: {
8
+ control: string;
9
+ };
10
+ name: {
11
+ control: string;
12
+ };
13
+ language: {
14
+ control: string;
15
+ options: string[];
16
+ };
17
+ disabled: {
18
+ control: string;
19
+ };
20
+ };
21
+ };
22
+ export default _default;
23
+ interface Story<T> {
24
+ (args: T): TemplateResult;
25
+ args?: Partial<T>;
26
+ argTypes?: Record<string, unknown>;
27
+ }
28
+ interface ArgTypes {
29
+ name?: string;
30
+ value?: string | number | object;
31
+ disabled?: boolean;
32
+ }
33
+ export declare const Regular: Story<ArgTypes>;
@@ -0,0 +1,40 @@
1
+ import '../src/ox-input-data.js';
2
+ import { html } from 'lit';
3
+ export default {
4
+ title: 'ox-input-data',
5
+ component: 'ox-input-data',
6
+ argTypes: {
7
+ value: { control: 'text' },
8
+ name: { control: 'text' },
9
+ language: { control: 'select', options: ['javascript', 'sql', 'json'] },
10
+ disabled: { control: 'boolean' }
11
+ }
12
+ };
13
+ const Template = ({ name = 'code', value = '', disabled }) => html `
14
+ <link href="/themes/app-theme.css" rel="stylesheet" />
15
+ <link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet" />
16
+ <style>
17
+ body {
18
+ }
19
+ ox-input-data {
20
+ height: 300px;
21
+ }
22
+ </style>
23
+
24
+ <ox-input-data
25
+ @change=${(e) => {
26
+ const value = e.target.value;
27
+ console.log('value : ', value, typeof value);
28
+ }}
29
+ name=${name}
30
+ .value=${value}
31
+ ?disabled=${disabled}
32
+ >
33
+ </ox-input-data>
34
+ `;
35
+ export const Regular = Template.bind({});
36
+ Regular.args = {
37
+ name: 'data',
38
+ value: ''
39
+ };
40
+ //# sourceMappingURL=ox-input-data.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ox-input-data.stories.js","sourceRoot":"","sources":["../../stories/ox-input-data.stories.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA;AAEhC,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAE1C,eAAe;IACb,KAAK,EAAE,eAAe;IACtB,SAAS,EAAE,eAAe;IAC1B,QAAQ,EAAE;QACR,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;QAC1B,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;QACzB,QAAQ,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,YAAY,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE;QACvE,QAAQ,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;KACjC;CACF,CAAA;AAcD,MAAM,QAAQ,GAAoB,CAAC,EAAE,IAAI,GAAG,MAAM,EAAE,KAAK,GAAG,EAAE,EAAE,QAAQ,EAAY,EAAE,EAAE,CAAC,IAAI,CAAA;;;;;;;;;;;;cAY/E,CAAC,CAAQ,EAAE,EAAE;IACrB,MAAM,KAAK,GAAI,CAAC,CAAC,MAA2B,CAAC,KAAK,CAAA;IAClD,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,OAAO,KAAK,CAAC,CAAA;AAC9C,CAAC;WACM,IAAI;aACF,KAAK;gBACF,QAAQ;;;CAGvB,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACxC,OAAO,CAAC,IAAI,GAAG;IACb,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,EAAE;CACV,CAAA","sourcesContent":["import '../src/ox-input-data.js'\n\nimport { html, TemplateResult } from 'lit'\n\nexport default {\n title: 'ox-input-data',\n component: 'ox-input-data',\n argTypes: {\n value: { control: 'text' },\n name: { control: 'text' },\n language: { control: 'select', options: ['javascript', 'sql', 'json'] },\n disabled: { control: 'boolean' }\n }\n}\n\ninterface Story<T> {\n (args: T): TemplateResult\n args?: Partial<T>\n argTypes?: Record<string, unknown>\n}\n\ninterface ArgTypes {\n name?: string\n value?: string | number | object\n disabled?: boolean\n}\n\nconst Template: Story<ArgTypes> = ({ name = 'code', value = '', disabled }: ArgTypes) => html`\n <link href=\"/themes/app-theme.css\" rel=\"stylesheet\" />\n <link href=\"https://fonts.googleapis.com/css?family=Material+Icons&display=block\" rel=\"stylesheet\" />\n <style>\n body {\n }\n ox-input-data {\n height: 300px;\n }\n </style>\n\n <ox-input-data\n @change=${(e: Event) => {\n const value = (e.target as HTMLInputElement).value\n console.log('value : ', value, typeof value)\n }}\n name=${name}\n .value=${value}\n ?disabled=${disabled}\n >\n </ox-input-data>\n`\n\nexport const Regular = Template.bind({})\nRegular.args = {\n name: 'data',\n value: ''\n}\n"]}
@@ -13,6 +13,9 @@ declare const _default: {
13
13
  defaultValue: {
14
14
  control: string;
15
15
  };
16
+ composable: {
17
+ control: string;
18
+ };
16
19
  disabled: {
17
20
  control: string;
18
21
  };
@@ -28,6 +31,7 @@ interface ArgTypes {
28
31
  name?: string;
29
32
  value?: object;
30
33
  defaultValue?: object;
34
+ composable?: boolean;
31
35
  disabled?: boolean;
32
36
  }
33
37
  export declare const Regular: Story<ArgTypes>;
@@ -7,10 +7,11 @@ export default {
7
7
  name: { control: 'text' },
8
8
  value: { control: 'object' },
9
9
  defaultValue: { control: 'object' },
10
+ composable: { control: 'boolean' },
10
11
  disabled: { control: 'boolean' }
11
12
  }
12
13
  };
13
- const Template = ({ name = 'mass-fraction', value = {}, defaultValue = {}, disabled }) => html `
14
+ const Template = ({ name = 'mass-fraction', value = {}, defaultValue = {}, composable = true, disabled }) => html `
14
15
  <link href="/themes/app-theme.css" rel="stylesheet" />
15
16
  <link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet" />
16
17
  <style>
@@ -25,6 +26,7 @@ const Template = ({ name = 'mass-fraction', value = {}, defaultValue = {}, disab
25
26
  name=${name}
26
27
  .value=${value}
27
28
  .defaultValue=${defaultValue}
29
+ ?composable=${composable}
28
30
  ?disabled=${disabled}
29
31
  >
30
32
  </ox-input-mass-fraction>
@@ -32,7 +34,12 @@ const Template = ({ name = 'mass-fraction', value = {}, defaultValue = {}, disab
32
34
  export const Regular = Template.bind({});
33
35
  Regular.args = {
34
36
  name: 'mass-fraction',
35
- value: {},
37
+ value: {
38
+ H2O: 0.8,
39
+ N2O: 0.1,
40
+ CO2: 0.1
41
+ },
42
+ composable: true,
36
43
  defaultValue: {
37
44
  H2O: 0.8,
38
45
  N2O: 0.1,
@@ -1 +1 @@
1
- {"version":3,"file":"ox-input-mass-fraction.stories.js","sourceRoot":"","sources":["../../stories/ox-input-mass-fraction.stories.ts"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,CAAA;AAEzC,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAE1C,eAAe;IACb,KAAK,EAAE,wBAAwB;IAC/B,SAAS,EAAE,wBAAwB;IACnC,QAAQ,EAAE;QACR,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;QACzB,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;QAC5B,YAAY,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;QACnC,QAAQ,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;KACjC;CACF,CAAA;AAeD,MAAM,QAAQ,GAAoB,CAAC,EACjC,IAAI,GAAG,eAAe,EACtB,KAAK,GAAG,EAAE,EACV,YAAY,GAAG,EAAE,EACjB,QAAQ,EACC,EAAE,EAAE,CAAC,IAAI,CAAA;;;;;;;;;cASN,CAAC,CAAQ,EAAE,EAAE;IACrB,OAAO,CAAC,GAAG,CAAE,CAAC,CAAC,MAA2B,CAAC,KAAK,CAAC,CAAA;AACnD,CAAC;WACM,IAAI;aACF,KAAK;oBACE,YAAY;gBAChB,QAAQ;;;CAGvB,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACxC,OAAO,CAAC,IAAI,GAAG;IACb,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE,EAAE;IACT,YAAY,EAAE;QACZ,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG;KACT;CACF,CAAA","sourcesContent":["import '../src/ox-input-mass-fraction.js'\n\nimport { html, TemplateResult } from 'lit'\n\nexport default {\n title: 'ox-input-mass-fraction',\n component: 'ox-input-mass-fraction',\n argTypes: {\n name: { control: 'text' },\n value: { control: 'object' },\n defaultValue: { control: 'object' },\n disabled: { control: 'boolean' }\n }\n}\n\ninterface Story<T> {\n (args: T): TemplateResult\n args?: Partial<T>\n argTypes?: Record<string, unknown>\n}\n\ninterface ArgTypes {\n name?: string\n value?: object\n defaultValue?: object\n disabled?: boolean\n}\n\nconst Template: Story<ArgTypes> = ({\n name = 'mass-fraction',\n value = {},\n defaultValue = {},\n disabled\n}: ArgTypes) => html`\n <link href=\"/themes/app-theme.css\" rel=\"stylesheet\" />\n <link href=\"https://fonts.googleapis.com/css?family=Material+Icons&display=block\" rel=\"stylesheet\" />\n <style>\n body {\n }\n </style>\n\n <ox-input-mass-fraction\n @change=${(e: Event) => {\n console.log((e.target as HTMLInputElement).value)\n }}\n name=${name}\n .value=${value}\n .defaultValue=${defaultValue}\n ?disabled=${disabled}\n >\n </ox-input-mass-fraction>\n`\n\nexport const Regular = Template.bind({})\nRegular.args = {\n name: 'mass-fraction',\n value: {},\n defaultValue: {\n H2O: 0.8,\n N2O: 0.1,\n CO2: 0.1\n }\n}\n"]}
1
+ {"version":3,"file":"ox-input-mass-fraction.stories.js","sourceRoot":"","sources":["../../stories/ox-input-mass-fraction.stories.ts"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,CAAA;AAEzC,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAE1C,eAAe;IACb,KAAK,EAAE,wBAAwB;IAC/B,SAAS,EAAE,wBAAwB;IACnC,QAAQ,EAAE;QACR,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;QACzB,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;QAC5B,YAAY,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;QACnC,UAAU,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;QAClC,QAAQ,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;KACjC;CACF,CAAA;AAgBD,MAAM,QAAQ,GAAoB,CAAC,EACjC,IAAI,GAAG,eAAe,EACtB,KAAK,GAAG,EAAE,EACV,YAAY,GAAG,EAAE,EACjB,UAAU,GAAG,IAAI,EACjB,QAAQ,EACC,EAAE,EAAE,CAAC,IAAI,CAAA;;;;;;;;;cASN,CAAC,CAAQ,EAAE,EAAE;IACrB,OAAO,CAAC,GAAG,CAAE,CAAC,CAAC,MAA2B,CAAC,KAAK,CAAC,CAAA;AACnD,CAAC;WACM,IAAI;aACF,KAAK;oBACE,YAAY;kBACd,UAAU;gBACZ,QAAQ;;;CAGvB,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACxC,OAAO,CAAC,IAAI,GAAG;IACb,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE;QACL,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG;KACT;IACD,UAAU,EAAE,IAAI;IAChB,YAAY,EAAE;QACZ,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG;KACT;CACF,CAAA","sourcesContent":["import '../src/ox-input-mass-fraction.js'\n\nimport { html, TemplateResult } from 'lit'\n\nexport default {\n title: 'ox-input-mass-fraction',\n component: 'ox-input-mass-fraction',\n argTypes: {\n name: { control: 'text' },\n value: { control: 'object' },\n defaultValue: { control: 'object' },\n composable: { control: 'boolean' },\n disabled: { control: 'boolean' }\n }\n}\n\ninterface Story<T> {\n (args: T): TemplateResult\n args?: Partial<T>\n argTypes?: Record<string, unknown>\n}\n\ninterface ArgTypes {\n name?: string\n value?: object\n defaultValue?: object\n composable?: boolean\n disabled?: boolean\n}\n\nconst Template: Story<ArgTypes> = ({\n name = 'mass-fraction',\n value = {},\n defaultValue = {},\n composable = true,\n disabled\n}: ArgTypes) => html`\n <link href=\"/themes/app-theme.css\" rel=\"stylesheet\" />\n <link href=\"https://fonts.googleapis.com/css?family=Material+Icons&display=block\" rel=\"stylesheet\" />\n <style>\n body {\n }\n </style>\n\n <ox-input-mass-fraction\n @change=${(e: Event) => {\n console.log((e.target as HTMLInputElement).value)\n }}\n name=${name}\n .value=${value}\n .defaultValue=${defaultValue}\n ?composable=${composable}\n ?disabled=${disabled}\n >\n </ox-input-mass-fraction>\n`\n\nexport const Regular = Template.bind({})\nRegular.args = {\n name: 'mass-fraction',\n value: {\n H2O: 0.8,\n N2O: 0.1,\n CO2: 0.1\n },\n composable: true,\n defaultValue: {\n H2O: 0.8,\n N2O: 0.1,\n CO2: 0.1\n }\n}\n"]}