@operato/input 1.1.18 → 1.1.23

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,24 @@
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.1.23](https://github.com/hatiolab/operato/compare/v1.1.22...v1.1.23) (2022-12-04)
7
+
8
+
9
+ ### :bug: Bug Fix
10
+
11
+ * add ox-input-mass-fraction ([6d52d4d](https://github.com/hatiolab/operato/commit/6d52d4d456bf4b405964b5b46f79e97cba6ba64e))
12
+
13
+
14
+
15
+ ### [1.1.21](https://github.com/hatiolab/operato/compare/v1.1.20...v1.1.21) (2022-12-01)
16
+
17
+
18
+ ### :bug: Bug Fix
19
+
20
+ * hashtags style ([d2d5d22](https://github.com/hatiolab/operato/commit/d2d5d22d67bf8118d15f7df0f3662573ba57d9aa))
21
+
22
+
23
+
6
24
  ### [1.1.18](https://github.com/hatiolab/operato/compare/v1.1.17...v1.1.18) (2022-11-27)
7
25
 
8
26
 
@@ -18,6 +18,11 @@ let OxInputHashtags = class OxInputHashtags extends OxFormField {
18
18
  #editor {
19
19
  display: block;
20
20
  box-sizing: border-box;
21
+ --hashtag-padding : 2px 4px;
22
+ --hashtag-background : rgba(var(--primary-color-rgb),.15);
23
+ --hashtag-background-hover : rgba(var(--primary-color-rgb),1);
24
+ --hashtag-closer-padding:0 2px 0 4px;
25
+ --hashtag-input-padding : 2px;
21
26
  }
22
27
 
23
28
  .tags {
@@ -25,26 +30,41 @@ let OxInputHashtags = class OxInputHashtags extends OxFormField {
25
30
  }
26
31
 
27
32
  .tag {
28
- border-radius: 5px;
29
- background-color: cyan;
30
- color: #3e3e3e;
33
+ border-radius: var(--border-radius);
34
+ background-color: var(--hashtag-background);
35
+ padding:var(--hashtag-padding);
36
+ font: var(--input-font);
37
+ color: var(--primary-text-color);
38
+ cursor:pointer;
31
39
  }
32
40
 
41
+ .tag:hover {
42
+ background-color: var(--hashtag-background-hover);
43
+ color: var(--theme-white-color) !important;
44
+ }
45
+
33
46
  .closer {
34
- color: red;
47
+ opacity:.3;
48
+ padding:var(--hashtag-closer-padding);
49
+ text-transform:uppercase;
50
+ color: var(--primary-text-color);
51
+ }
52
+ .tag:hover .closer{
53
+ opacity:.9;
54
+ color: var(--theme-white-color);
35
55
  }
36
56
 
37
57
  .input {
38
58
  display: inline-block;
59
+ color: var(--primary-text-color);
39
60
  }
40
61
 
41
62
  .input::before {
42
63
  display: inline;
43
64
  position: relative;
65
+ opacity:.5;
44
66
  top: -1px;
45
67
  content: '#';
46
- color: #3e3e3e;
47
- margin-right: 2px;
48
68
  vertical-align: middle;
49
69
  }
50
70
 
@@ -52,20 +72,22 @@ let OxInputHashtags = class OxInputHashtags extends OxFormField {
52
72
  vertical-align: middle;
53
73
  -webkit-appearance: none;
54
74
  -webkit-text-size-adjust: none;
55
- padding: 0;
75
+ padding: var(--hashtag-input-padding);
56
76
  border: 0;
77
+ border-bottom: var(--border-dark-color);
57
78
  outline: none;
58
- color: #3e3e3e;
79
+ font-weight:bold;
59
80
  }
60
81
 
61
82
  input:focus {
62
83
  outline: none;
63
- opacity: 1;
84
+ border-bottom: 1px solid var(--primary-color);
64
85
  }
65
86
 
66
87
  .error {
67
- padding: 0 5px;
68
- color: #ea2136;
88
+ margin:var(--margin-narrow);
89
+ color: var(--status-danger-color);
90
+ font: var(--input-font);
69
91
  text-align: left;
70
92
  }
71
93
  `; }
@@ -1 +1 @@
1
- {"version":3,"file":"ox-input-hashtags.js","sourceRoot":"","sources":["../../src/ox-input-hashtags.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,EAAE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AED,aAAa,CAAC,GAAW;QACvB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;QACzB,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAA;QAC5B,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAClF,CAAC;;AAxF0B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;8CAAqB;AACnB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oDAA4B;AACvC;IAAf,KAAK,CAAC,OAAO,CAAC;8CAAyB;AAE/B;IAAR,KAAK,EAAE;+CAAuB;AA7DpB,eAAe;IAF3B,SAAS,EAAE;IACX,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CAkJ3B;SAlJY,eAAe","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { css, html } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport { when } from 'lit/directives/when.js'\nimport { repeat } from 'lit/directives/repeat.js'\nimport { localized, msg } from '@lit/localize'\n\nimport { OxFormField } from './ox-form-field.js'\n\n@localized()\n@customElement('ox-input-hashtags')\nexport class OxInputHashtags extends OxFormField {\n static styles = css`\n #editor {\n display: block;\n box-sizing: border-box;\n }\n\n .tags {\n display: inline-block;\n }\n\n .tag {\n border-radius: 5px;\n background-color: cyan;\n color: #3e3e3e;\n }\n\n .closer {\n color: red;\n }\n\n .input {\n display: inline-block;\n }\n\n .input::before {\n display: inline;\n position: relative;\n top: -1px;\n content: '#';\n color: #3e3e3e;\n margin-right: 2px;\n vertical-align: middle;\n }\n\n input {\n vertical-align: middle;\n -webkit-appearance: none;\n -webkit-text-size-adjust: none;\n padding: 0;\n border: 0;\n outline: none;\n color: #3e3e3e;\n }\n\n input:focus {\n outline: none;\n opacity: 1;\n }\n\n .error {\n padding: 0 5px;\n color: #ea2136;\n text-align: left;\n }\n `\n\n @property({ type: Array }) value: string[] = []\n @property({ type: String }) placeholder: string = 'tag'\n @query('input') input!: HTMLInputElement\n\n @state() errors?: string | null\n\n render() {\n return html`\n <div id=\"editor\" @click=${this.setHashtags}>\n <div class=\"tags\">\n ${repeat(\n this.value,\n tag => tag,\n (tag, index) =>\n html`\n <span class=\"tag\">#${tag} <span @click=${() => this.removeHashtag(index)} class=\"closer\">x</span></span>\n `\n )}\n </div>\n\n <div class=\"input\">\n <input type=\"text\" @keyup=${this.onInputKeyup} placeholder=\"태그입력\" />\n </div>\n </div>\n\n ${when(this.errors, () => html`<p class=\"error\">${this.errors}</p>`)}\n `\n }\n\n private onInputKeyup(e: KeyboardEvent) {\n e.stopPropagation()\n\n const tag = this.input.value.trim()\n\n switch (e.key) {\n case 'Enter':\n case 'Spacebar':\n this.addHashtag(tag)\n break\n default:\n this.errors = this.validate(tag)\n }\n }\n\n async setHashtags() {\n this.input.focus()\n }\n\n initErrors() {\n this.errors = null\n }\n\n validate(newtag: string) {\n if (this.value.some(tag => tag === newtag)) {\n return msg('tag duplicated')\n }\n\n const regex = /[~!@#$%^&*()+|<>?:{},.=\"':;/-]/\n if (regex.test(newtag)) {\n return msg('special characters not allowed')\n }\n }\n\n async addHashtag(tag: string) {\n if (!tag) {\n this.initErrors()\n this.input.focus()\n return\n }\n\n this.errors = this.validate(tag)\n if (this.errors) {\n this.input.focus()\n return\n }\n\n this.value = [...this.value, tag]\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n\n this.errors = null\n this.input.value = ''\n this.input.focus()\n }\n\n removeHashtag(idx: number) {\n this.value.splice(idx, 1)\n this.value = [...this.value]\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n }\n}\n"]}
1
+ {"version":3,"file":"ox-input-hashtags.js","sourceRoot":"","sources":["../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,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;QAEhF,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;QAClB,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAA;QACrB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;IAED,aAAa,CAAC,GAAW;QACvB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;QACzB,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAA;QAC5B,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAClF,CAAC;;AAxF0B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;8CAAqB;AACnB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oDAA4B;AACvC;IAAf,KAAK,CAAC,OAAO,CAAC;8CAAyB;AAE/B;IAAR,KAAK,EAAE;+CAAuB;AAnFpB,eAAe;IAF3B,SAAS,EAAE;IACX,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CAwK3B;SAxKY,eAAe","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { css, html } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport { when } from 'lit/directives/when.js'\nimport { repeat } from 'lit/directives/repeat.js'\nimport { localized, msg } from '@lit/localize'\n\nimport { OxFormField } from './ox-form-field.js'\n\n@localized()\n@customElement('ox-input-hashtags')\nexport class OxInputHashtags extends OxFormField {\n static styles = css`\n #editor {\n display: block;\n box-sizing: border-box;\n --hashtag-padding : 2px 4px;\n --hashtag-background : rgba(var(--primary-color-rgb),.15);\n --hashtag-background-hover : rgba(var(--primary-color-rgb),1);\n --hashtag-closer-padding:0 2px 0 4px;\n --hashtag-input-padding : 2px;\n }\n\n .tags {\n display: inline-block;\n }\n\n .tag {\n border-radius: var(--border-radius);\n background-color: var(--hashtag-background);\n padding:var(--hashtag-padding);\n font: var(--input-font);\n color: var(--primary-text-color);\n cursor:pointer;\n }\n\n .tag:hover {\n background-color: var(--hashtag-background-hover);\n color: var(--theme-white-color) !important;\n }\n \n .closer {\n opacity:.3;\n padding:var(--hashtag-closer-padding);\n text-transform:uppercase;\n color: var(--primary-text-color);\n }\n .tag:hover .closer{\n opacity:.9;\n color: var(--theme-white-color);\n }\n\n .input {\n display: inline-block;\n color: var(--primary-text-color);\n }\n\n .input::before {\n display: inline;\n position: relative;\n opacity:.5;\n top: -1px;\n content: '#';\n vertical-align: middle;\n }\n\n input {\n vertical-align: middle;\n -webkit-appearance: none;\n -webkit-text-size-adjust: none;\n padding: var(--hashtag-input-padding);\n border: 0;\n border-bottom: var(--border-dark-color);\n outline: none;\n font-weight:bold;\n }\n\n input:focus {\n outline: none;\n border-bottom: 1px solid var(--primary-color);\n }\n\n .error {\n margin:var(--margin-narrow);\n color: var(--status-danger-color);\n font: var(--input-font);\n text-align: left;\n }\n `\n\n @property({ type: Array }) value: string[] = []\n @property({ type: String }) placeholder: string = 'tag'\n @query('input') input!: HTMLInputElement\n\n @state() errors?: string | null\n\n render() {\n return html`\n <div id=\"editor\" @click=${this.setHashtags}>\n <div class=\"tags\">\n ${repeat(\n this.value,\n tag => tag,\n (tag, index) =>\n html`\n <span class=\"tag\">#${tag} <span @click=${() => this.removeHashtag(index)} class=\"closer\">x</span></span>\n `\n )}\n </div>\n\n <div class=\"input\">\n <input type=\"text\" @keyup=${this.onInputKeyup} placeholder=\"태그입력\" />\n </div>\n </div>\n\n ${when(this.errors, () => html`<p class=\"error\">${this.errors}</p>`)}\n `\n }\n\n private onInputKeyup(e: KeyboardEvent) {\n e.stopPropagation()\n\n const tag = this.input.value.trim()\n\n switch (e.key) {\n case 'Enter':\n case 'Spacebar':\n this.addHashtag(tag)\n break\n default:\n this.errors = this.validate(tag)\n }\n }\n\n async setHashtags() {\n this.input.focus()\n }\n\n initErrors() {\n this.errors = null\n }\n\n validate(newtag: string) {\n if (this.value.some(tag => tag === newtag)) {\n return msg('tag duplicated')\n }\n\n const regex = /[~!@#$%^&*()+|<>?:{},.=\"':;/-]/\n if (regex.test(newtag)) {\n return msg('special characters not allowed')\n }\n }\n\n async addHashtag(tag: string) {\n if (!tag) {\n this.initErrors()\n this.input.focus()\n return\n }\n\n this.errors = this.validate(tag)\n if (this.errors) {\n this.input.focus()\n return\n }\n\n this.value = [...this.value, tag]\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n\n this.errors = null\n this.input.value = ''\n this.input.focus()\n }\n\n removeHashtag(idx: number) {\n this.value.splice(idx, 1)\n this.value = [...this.value]\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n }\n}\n"]}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import '@material/mwc-icon';
5
+ import '@operato/popup/ox-popup-list.js';
6
+ import { OxFormField } from './ox-form-field';
7
+ import './ox-select.js';
8
+ declare const FLUIDS: string[];
9
+ type ArrayElement<ArrayType extends readonly unknown[]> = ArrayType extends readonly (infer ElementType)[] ? ElementType : never;
10
+ type FLUID = ArrayElement<typeof FLUIDS>;
11
+ type MassFraction = {
12
+ [key: FLUID]: number;
13
+ };
14
+ type ArrayedMassFraction = {
15
+ key: FLUID;
16
+ value: number;
17
+ }[];
18
+ /**
19
+ input component for mass-fraction map
20
+
21
+ Example:
22
+
23
+ <ox-input-mass-fraction
24
+ value=${map}
25
+ </ox-input-mass-fraction>
26
+ */
27
+ export declare class OxInputMassFraction extends OxFormField {
28
+ static styles: import("lit").CSSResult[];
29
+ defaultValue: MassFraction;
30
+ value: MassFraction;
31
+ private options;
32
+ private changingNow;
33
+ firstUpdated(): void;
34
+ render(): import("lit-html").TemplateResult<1>;
35
+ _onChange(e: Event): void;
36
+ _normalize(): void;
37
+ _build(includeNewRecord?: boolean): void;
38
+ _toArray(map: MassFraction): ArrayedMassFraction;
39
+ _add(): void;
40
+ _delete(e: MouseEvent): void;
41
+ records: NodeListOf<HTMLElement>;
42
+ _up(e: MouseEvent): void;
43
+ _down(e: MouseEvent): void;
44
+ dispatchChangeEvent(): void;
45
+ }
46
+ export {};
@@ -0,0 +1,434 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import { __decorate } from "tslib";
5
+ import '@material/mwc-icon';
6
+ import '@operato/popup/ox-popup-list.js';
7
+ import { ScrollbarStyles } from '@operato/styles';
8
+ import { css, html } from 'lit';
9
+ import { customElement, property, queryAll } from 'lit/decorators.js';
10
+ import { live } from 'lit/directives/live.js';
11
+ import { OxFormField } from './ox-form-field';
12
+ import './ox-select.js';
13
+ const FLUIDS = [
14
+ '1-Butene',
15
+ 'Acetone',
16
+ 'Air',
17
+ 'Ammonia',
18
+ 'Argon',
19
+ 'Benzene',
20
+ 'CO2',
21
+ 'CarbonMonoxide',
22
+ 'CarbonylSulfide',
23
+ 'CycloHexane',
24
+ 'CycloPropane',
25
+ 'Cyclopentane',
26
+ 'D4',
27
+ 'D5',
28
+ 'D6',
29
+ 'Deuterium',
30
+ 'Dichloroethane',
31
+ 'DiethylEther',
32
+ 'DimethylCarbonate',
33
+ 'DimethylEther',
34
+ 'Ethane',
35
+ 'Ethanol',
36
+ 'EthylBenzene',
37
+ 'Ethylene',
38
+ 'EthyleneOxide',
39
+ 'Fluorine',
40
+ 'HFE143m',
41
+ 'HeavyWater',
42
+ 'Helium',
43
+ 'Hydrogen',
44
+ 'HydrogenChloride',
45
+ 'HydrogenSulfide',
46
+ 'IsoButane',
47
+ 'IsoButene',
48
+ 'Isohexane',
49
+ 'Isopentane',
50
+ 'Krypton',
51
+ 'MD2M',
52
+ 'MD3M',
53
+ 'MD4M',
54
+ 'MDM',
55
+ 'MM',
56
+ 'Methane',
57
+ 'Methanol',
58
+ 'MethylLinoleate',
59
+ 'MethylLinolenate',
60
+ 'MethylOleate',
61
+ 'MethylPalmitate',
62
+ 'MethylStearate',
63
+ 'Neon',
64
+ 'Neopentane',
65
+ 'Nitrogen',
66
+ 'NitrousOxide',
67
+ 'Novec649',
68
+ 'OrthoDeuterium',
69
+ 'OrthoHydrogen',
70
+ 'Oxygen',
71
+ 'ParaDeuterium',
72
+ 'ParaHydrogen',
73
+ 'Propylene',
74
+ 'Propyne',
75
+ 'R11',
76
+ 'R113',
77
+ 'R114',
78
+ 'R115',
79
+ 'R116',
80
+ 'R12',
81
+ 'R123',
82
+ 'R1233zd(E)',
83
+ 'R1234yf',
84
+ 'R1234ze(E)',
85
+ 'R1234ze(Z)',
86
+ 'R124',
87
+ 'R1243zf',
88
+ 'R125',
89
+ 'R13',
90
+ 'R134a',
91
+ 'R13I1',
92
+ 'R14',
93
+ 'R141b',
94
+ 'R142b',
95
+ 'R143a',
96
+ 'R152A',
97
+ 'R161',
98
+ 'R21',
99
+ 'R218',
100
+ 'R22',
101
+ 'R227EA',
102
+ 'R23',
103
+ 'R236EA',
104
+ 'R236FA',
105
+ 'R245ca',
106
+ 'R245fa',
107
+ 'R32',
108
+ 'R365MFC',
109
+ 'R40',
110
+ 'R404A',
111
+ 'R407C',
112
+ 'R41',
113
+ 'R410A',
114
+ 'R507A',
115
+ 'RC318',
116
+ 'SES36',
117
+ 'SulfurDioxide',
118
+ 'SulfurHexafluorid',
119
+ 'Toluene',
120
+ 'Water',
121
+ 'Xenon',
122
+ 'cis-2-Butene',
123
+ 'm-Xylene',
124
+ 'n-Butane',
125
+ 'n-Decane',
126
+ 'n-Dodecane',
127
+ 'n-Heptane',
128
+ 'n-Hexane',
129
+ 'n-Nonane',
130
+ 'n-Octane',
131
+ 'n-Pentane',
132
+ 'n-Propane',
133
+ 'n-Undecane',
134
+ 'o-Xylene',
135
+ 'p-Xylene',
136
+ 'trans-2-Butene'
137
+ ];
138
+ /**
139
+ input component for mass-fraction map
140
+
141
+ Example:
142
+
143
+ <ox-input-mass-fraction
144
+ value=${map}
145
+ </ox-input-mass-fraction>
146
+ */
147
+ let OxInputMassFraction = class OxInputMassFraction extends OxFormField {
148
+ constructor() {
149
+ super(...arguments);
150
+ this.defaultValue = {};
151
+ this.value = {};
152
+ this.options = FLUIDS.map(fluid => html `<div option value=${fluid}>${fluid}</div>`);
153
+ this.changingNow = false;
154
+ }
155
+ static { this.styles = [
156
+ ScrollbarStyles,
157
+ css `
158
+ :host {
159
+ display: flex;
160
+ flex-direction: column;
161
+ justify-content: space-between;
162
+ }
163
+
164
+ :host > div {
165
+ display: flex;
166
+ flex-flow: row nowrap;
167
+ gap: var(--mass-fraction-gap, 4px);
168
+ margin-bottom: var(--margin-narrow);
169
+ }
170
+
171
+ button {
172
+ border: var(--button-border);
173
+ border-radius: var(--border-radius);
174
+ background-color: var(--button-background-color);
175
+ padding: var(--mass-fraction-button-padding-vertical, 2px) var(--mass-fraction-button-padding-horizontal, 4px);
176
+ color: var(--button-color);
177
+ cursor: pointer;
178
+ }
179
+ button mwc-icon {
180
+ font-size: var(--fontsize-default);
181
+ }
182
+ button:focus,
183
+ button:hover,
184
+ button:active {
185
+ border: var(--button-activ-border);
186
+ background-color: var(--button-background-focus-color);
187
+ color: var(--theme-white-color);
188
+ }
189
+
190
+ input,
191
+ ox-select {
192
+ border: 0;
193
+ border-bottom: var(--border-dark-color);
194
+ padding: var(--input-padding);
195
+ font: var(--input-font);
196
+ color: var(--primary-text-color);
197
+ min-width: 50px;
198
+ }
199
+
200
+ [data-key] {
201
+ flex: 2;
202
+ }
203
+
204
+ [data-value] {
205
+ flex: 1;
206
+ }
207
+
208
+ input:focus {
209
+ outline: none;
210
+ border-bottom: 1px solid var(--primary-color);
211
+ }
212
+
213
+ button.hidden {
214
+ opacity: 0;
215
+ cursor: default;
216
+ }
217
+
218
+ ox-popup-list {
219
+ max-height: 300px;
220
+ overflow: auto;
221
+ left: 0;
222
+ }
223
+ `
224
+ ]; }
225
+ firstUpdated() {
226
+ this.renderRoot.addEventListener('change', this._onChange.bind(this));
227
+ }
228
+ render() {
229
+ const value = !this.value || typeof this.value !== 'object' ? {} : this.value;
230
+ const arrayed = this._toArray(value);
231
+ return html `
232
+ ${arrayed.map((item, idx) => html `
233
+ <div data-record>
234
+ <input type="text" data-key .value=${item.key} disabled />
235
+ <input
236
+ type="number"
237
+ data-value
238
+ placeholder="fraction"
239
+ min="0"
240
+ max="1"
241
+ step="0.01"
242
+ .value=${String(item.value)}
243
+ list="value-template"
244
+ />
245
+ <button class="record-action" @click=${(e) => this._delete(e)} tabindex="-1">
246
+ <mwc-icon>remove</mwc-icon>
247
+ </button>
248
+ <button class="record-action" @click=${(e) => this._up(e)} tabindex="-1" ?disabled=${idx === 0}>
249
+ <mwc-icon>arrow_upward</mwc-icon>
250
+ </button>
251
+ <button
252
+ class="record-action"
253
+ @click=${(e) => this._down(e)}
254
+ tabindex="-1"
255
+ ?disabled=${idx === arrayed.length - 1}
256
+ >
257
+ <mwc-icon>arrow_downward</mwc-icon>
258
+ </button>
259
+ </div>
260
+ `)}
261
+
262
+ <div data-record-new>
263
+ <ox-select
264
+ data-key
265
+ placeholder="fluid"
266
+ .value=${live('')}
267
+ @change=${(e) => {
268
+ e.stopPropagation();
269
+ }}
270
+ >
271
+ <ox-popup-list with-search> ${this.options} </ox-popup-list>
272
+ </ox-select>
273
+
274
+ <input
275
+ type="number"
276
+ data-value
277
+ placeholder="proportion"
278
+ min="0"
279
+ max="1"
280
+ step="0.01"
281
+ value=""
282
+ list="value-template"
283
+ />
284
+ <button class="record-action" @click=${(e) => this._add()} tabindex="-1">
285
+ <mwc-icon>add</mwc-icon>
286
+ </button>
287
+ <button
288
+ title="fill with the values suggested"
289
+ @click=${() => {
290
+ this.value = { ...this.defaultValue };
291
+ this.dispatchChangeEvent();
292
+ }}
293
+ >
294
+ <mwc-icon>settings_suggest</mwc-icon>
295
+ </button>
296
+ <button
297
+ title="normalize fraction"
298
+ @click=${() => {
299
+ this._normalize();
300
+ }}
301
+ >
302
+ <mwc-icon>repartition</mwc-icon>
303
+ </button>
304
+ </div>
305
+ `;
306
+ }
307
+ _onChange(e) {
308
+ if (this.changingNow) {
309
+ return;
310
+ }
311
+ this.changingNow = true;
312
+ const input = e.target;
313
+ const record = e.target.closest('[data-record],[data-record-new]');
314
+ if (record.hasAttribute('data-record')) {
315
+ this._build();
316
+ }
317
+ else if (record.hasAttribute('data-record-new') && input.hasAttribute('data-value')) {
318
+ this._add();
319
+ }
320
+ this.changingNow = false;
321
+ }
322
+ _normalize() {
323
+ const fraction = this.value || {};
324
+ const sum = Object.values(fraction).reduce((a, b) => a + b, 0);
325
+ this.value = Object.keys(fraction).reduce((newvalue, key) => {
326
+ newvalue[key] = fraction[key] / sum;
327
+ return newvalue;
328
+ }, {});
329
+ this.dispatchChangeEvent();
330
+ }
331
+ _build(includeNewRecord) {
332
+ if (includeNewRecord) {
333
+ var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]');
334
+ }
335
+ else {
336
+ var records = this.renderRoot.querySelectorAll('[data-record]');
337
+ }
338
+ var newmap = {};
339
+ for (var i = 0; i < records.length; i++) {
340
+ var record = records[i];
341
+ const key = record.querySelector('[data-key]').value;
342
+ const inputs = record.querySelectorAll('[data-value]:not([style*="display: none"])');
343
+ if (!inputs || inputs.length == 0) {
344
+ continue;
345
+ }
346
+ var input = inputs[inputs.length - 1];
347
+ var value = input.value;
348
+ if (key) {
349
+ newmap[key] = Number(value) || 0;
350
+ }
351
+ }
352
+ this.value = newmap;
353
+ this.dispatchChangeEvent();
354
+ }
355
+ /* map아이템들을 template(dom-repeat)용 배열로 변환하는 함수 */
356
+ _toArray(map) {
357
+ var array = [];
358
+ for (var key in map) {
359
+ array.push({
360
+ key: key,
361
+ value: map[key]
362
+ });
363
+ }
364
+ return array;
365
+ }
366
+ _add() {
367
+ this._build(true);
368
+ const inputs = this.renderRoot.querySelectorAll('[data-record-new] input:not([style*="display: none"])');
369
+ for (var i = 0; i < inputs.length; i++) {
370
+ let input = inputs[i];
371
+ if (input.type == 'checkbox')
372
+ input.checked = false;
373
+ else
374
+ input.value = '';
375
+ }
376
+ inputs[0].focus();
377
+ }
378
+ _delete(e) {
379
+ const record = e.target.closest('[data-record]');
380
+ record.querySelector('[data-key]').value = '';
381
+ this._build();
382
+ }
383
+ _up(e) {
384
+ const record = e.target.closest('[data-record]');
385
+ const array = Array.from(this.records);
386
+ const index = array.indexOf(record) - 1;
387
+ if (index < 0) {
388
+ return;
389
+ }
390
+ const deleted = array.splice(index, 1);
391
+ array.splice(index + 1, 0, ...deleted);
392
+ this.value = array.reduce((sum, record) => {
393
+ const key = record.querySelector('[data-key]').value;
394
+ const value = record.querySelector('[data-value]').value;
395
+ sum[key] = Number(value) || 0;
396
+ return sum;
397
+ }, {});
398
+ this.dispatchChangeEvent();
399
+ }
400
+ _down(e) {
401
+ const record = e.target.closest('[data-record]');
402
+ const array = Array.from(this.records);
403
+ const index = array.indexOf(record);
404
+ if (index > array.length) {
405
+ return;
406
+ }
407
+ array.splice(index, 1);
408
+ array.splice(index + 1, 0, record);
409
+ this.value = array.reduce((sum, record) => {
410
+ const key = record.querySelector('[data-key]').value;
411
+ const value = record.querySelector('[data-value]').value;
412
+ sum[key] = Number(value) || 0;
413
+ return sum;
414
+ }, {});
415
+ this.dispatchChangeEvent();
416
+ }
417
+ dispatchChangeEvent() {
418
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }));
419
+ }
420
+ };
421
+ __decorate([
422
+ property({ type: Object })
423
+ ], OxInputMassFraction.prototype, "defaultValue", void 0);
424
+ __decorate([
425
+ property({ type: Object })
426
+ ], OxInputMassFraction.prototype, "value", void 0);
427
+ __decorate([
428
+ queryAll('[data-record]')
429
+ ], OxInputMassFraction.prototype, "records", void 0);
430
+ OxInputMassFraction = __decorate([
431
+ customElement('ox-input-mass-fraction')
432
+ ], OxInputMassFraction);
433
+ export { OxInputMassFraction };
434
+ //# sourceMappingURL=ox-input-mass-fraction.js.map
@@ -0,0 +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,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,gBAAgB,CAAA;AAEvB,MAAM,MAAM,GAAG;IACb,UAAU;IACV,SAAS;IACT,KAAK;IACL,SAAS;IACT,OAAO;IACP,SAAS;IACT,KAAK;IACL,gBAAgB;IAChB,iBAAiB;IACjB,aAAa;IACb,cAAc;IACd,cAAc;IACd,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,WAAW;IACX,gBAAgB;IAChB,cAAc;IACd,mBAAmB;IACnB,eAAe;IACf,QAAQ;IACR,SAAS;IACT,cAAc;IACd,UAAU;IACV,eAAe;IACf,UAAU;IACV,SAAS;IACT,YAAY;IACZ,QAAQ;IACR,UAAU;IACV,kBAAkB;IAClB,iBAAiB;IACjB,WAAW;IACX,WAAW;IACX,WAAW;IACX,YAAY;IACZ,SAAS;IACT,MAAM;IACN,MAAM;IACN,MAAM;IACN,KAAK;IACL,IAAI;IACJ,SAAS;IACT,UAAU;IACV,iBAAiB;IACjB,kBAAkB;IAClB,cAAc;IACd,iBAAiB;IACjB,gBAAgB;IAChB,MAAM;IACN,YAAY;IACZ,UAAU;IACV,cAAc;IAC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M,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;;AAxP2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAAgC;AAC/B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAyB;AAqMzB;IAA1B,QAAQ,CAAC,eAAe,CAAC;oDAAkC;AA9QjD,mBAAmB;IAD/B,aAAa,CAAC,wBAAwB,CAAC;GAC3B,mBAAmB,CAiU/B;SAjUY,mBAAmB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport '@material/mwc-icon'\nimport '@operato/popup/ox-popup-list.js'\nimport { ScrollbarStyles } from '@operato/styles'\n\nimport { css, html } from 'lit'\nimport { customElement, property, queryAll } from 'lit/decorators.js'\nimport { live } from 'lit/directives/live.js'\n\nimport { OxFormField } from './ox-form-field'\nimport './ox-select.js'\n\nconst FLUIDS = [\n '1-Butene',\n 'Acetone',\n 'Air',\n 'Ammonia',\n 'Argon',\n 'Benzene',\n 'CO2',\n 'CarbonMonoxide',\n 'CarbonylSulfide',\n 'CycloHexane',\n 'CycloPropane',\n 'Cyclopentane',\n 'D4',\n 'D5',\n 'D6',\n 'Deuterium',\n 'Dichloroethane',\n 'DiethylEther',\n 'DimethylCarbonate',\n 'DimethylEther',\n 'Ethane',\n 'Ethanol',\n 'EthylBenzene',\n 'Ethylene',\n 'EthyleneOxide',\n 'Fluorine',\n 'HFE143m',\n 'HeavyWater',\n 'Helium',\n 'Hydrogen',\n 'HydrogenChloride',\n 'HydrogenSulfide',\n 'IsoButane',\n 'IsoButene',\n 'Isohexane',\n 'Isopentane',\n 'Krypton',\n 'MD2M',\n 'MD3M',\n 'MD4M',\n 'MDM',\n 'MM',\n 'Methane',\n 'Methanol',\n 'MethylLinoleate',\n 'MethylLinolenate',\n 'MethylOleate',\n 'MethylPalmitate',\n 'MethylStearate',\n 'Neon',\n 'Neopentane',\n 'Nitrogen',\n 'NitrousOxide',\n 'Novec649',\n 'OrthoDeuterium',\n 'OrthoHydrogen',\n 'Oxygen',\n 'ParaDeuterium',\n 'ParaHydrogen',\n 'Propylene',\n 'Propyne',\n 'R11',\n 'R113',\n 'R114',\n 'R115',\n 'R116',\n 'R12',\n 'R123',\n 'R1233zd(E)',\n 'R1234yf',\n 'R1234ze(E)',\n 'R1234ze(Z)',\n 'R124',\n 'R1243zf',\n 'R125',\n 'R13',\n 'R134a',\n 'R13I1',\n 'R14',\n 'R141b',\n 'R142b',\n 'R143a',\n 'R152A',\n 'R161',\n 'R21',\n 'R218',\n 'R22',\n 'R227EA',\n 'R23',\n 'R236EA',\n 'R236FA',\n 'R245ca',\n 'R245fa',\n 'R32',\n 'R365MFC',\n 'R40',\n 'R404A',\n 'R407C',\n 'R41',\n 'R410A',\n 'R507A',\n 'RC318',\n 'SES36',\n 'SulfurDioxide',\n 'SulfurHexafluorid',\n 'Toluene',\n 'Water',\n 'Xenon',\n 'cis-2-Butene',\n 'm-Xylene',\n 'n-Butane',\n 'n-Decane',\n 'n-Dodecane',\n 'n-Heptane',\n 'n-Hexane',\n 'n-Nonane',\n 'n-Octane',\n 'n-Pentane',\n 'n-Propane',\n 'n-Undecane',\n 'o-Xylene',\n 'p-Xylene',\n 'trans-2-Butene'\n]\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 :host > div {\n display: flex;\n flex-flow: row nowrap;\n gap: var(--mass-fraction-gap, 4px);\n margin-bottom: var(--margin-narrow);\n }\n\n button {\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, 2px) var(--mass-fraction-button-padding-horizontal, 4px);\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-activ-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 padding: var(--input-padding);\n font: var(--input-font);\n color: var(--primary-text-color);\n min-width: 50px;\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 ]\n\n @property({ type: Object }) defaultValue: MassFraction = {}\n @property({ type: Object }) value: MassFraction = {}\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 ${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 />\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._delete(e)} tabindex=\"-1\">\n <mwc-icon>remove</mwc-icon>\n </button>\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._up(e)} tabindex=\"-1\" ?disabled=${idx === 0}>\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=${idx === arrayed.length - 1}\n >\n <mwc-icon>arrow_downward</mwc-icon>\n </button>\n </div>\n `\n )}\n\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 _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 @queryAll('[data-record]') records!: NodeListOf<HTMLElement>\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"]}