physical-quantity 1.1.21 → 1.1.24

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Physical Quantity Web Component
2
2
 
3
- `physical-quantity(PQE)` is a web component that allows you to create and manipulate physical quantities with different units. It provides an input for the value and a dropdown for the unit, automatically converting between units in the same category.
3
+ `physical-quantity(alias: uc-qty for quantity with built-in unit conversion)` is a web component that allows you to create and manipulate physical quantities with different units. It provides an input for the value and a dropdown for the unit, automatically converting between units in the same category.
4
4
 
5
5
  It is a new HTML element for expressing physical quantities, featuring self-contained unit conversion, a compact and clean UI, no redundant dual units, and seamless integration across all websites and platforms.
6
6
  ![Physical Quantity (Gif Animation)](https://firebasestorage.googleapis.com/v0/b/auto-calc-80237.appspot.com/o/PQE%2Fexamples%2FPhysicalQuantityElementDemo3-ezgif.com.gif?alt=media&token=b910c493-e990-490b-bf4d-015a4d4c10d2)
@@ -13,9 +13,7 @@ It is a new HTML element for expressing physical quantities, featuring self-cont
13
13
  - Easy to integrate into any web project.
14
14
 
15
15
  ## Demo: Physical Quantity element - No Unit Converter or Dual Units Needed
16
- [Live Demo on JS Fiddle](https://jsfiddle.net/hithere/tz8ym4fh/132/embedded/result)
17
-
18
- <iframe width="100%" height="300" src="https://jsfiddle.net/hithere/tz8ym4fh/132/embedded/result" allowfullscreen="true" frameborder="0"></iframe>
16
+ [Live Demo on JS Fiddle](https://jsfiddle.net/hithere/tz8ym4fh/134/embedded/result)
19
17
 
20
18
  [![Example 1 in UI](https://firebasestorage.googleapis.com/v0/b/auto-calc-80237.appspot.com/o/PQE%2Fexamples%2FPhysicalQuantityElementExample1.png?alt=media&token=2aa81849-9299-4ba5-9f62-79b8604b814f)](https://jsfiddle.net/hithere/tz8ym4fh/100/embedded/result)
21
19
 
@@ -39,9 +37,10 @@ Include the following script tag in your HTML file:
39
37
  ```
40
38
 
41
39
  ### Using the Component
42
- Add the `physical-quantity` tag to your HTML file:
40
+ Add the `physical-quantity` or `uc-qty` tag to your HTML file:
43
41
  ```html
44
42
  <physical-quantity value="25.4" unit="mm" decimal-places="4"></physical-quantity>
43
+ <uc-qty value="25.4" unit="mm" decimal-places="4"></uc-qty>
45
44
  ```
46
45
 
47
46
  ### Example - Linking the Code
@@ -57,6 +56,7 @@ Here's an example of how to use the component in an HTML file:
57
56
  </head>
58
57
  <body>
59
58
  <physical-quantity value="25.4" unit="mm"></physical-quantity>
59
+ <uc-qty value="25.4" unit="mm" decimal-places="4"></uc-qty>
60
60
 
61
61
  <script src="node_modules/physical-quantity/src/pq.es.js"></script>
62
62
  </body>
@@ -76,6 +76,8 @@ Here's an example of how to use the component in an HTML file:
76
76
  <body>
77
77
  <physical-quantity value="25.4" unit="mm"></physical-quantity>
78
78
  <physical-quantity value="1500" unit="psf" decimal-places=4></physical-quantity> <br>
79
+ <uc-qty value="2" unit="lbm" decimal-places="2"></uc-qty>
80
+
79
81
  </body>
80
82
  </html>
81
83
  ```
@@ -123,6 +125,8 @@ Currently, the component supports the following categories and units:
123
125
  - kg/L
124
126
  - g/cm³
125
127
  - g/mm³
128
+ - lbm/ft³
129
+ - lbm/in³
126
130
  - ... (more to update.)
127
131
 
128
132
  ## License
@@ -132,7 +136,8 @@ This project is licensed under the MIT License. See the LICENSE file for more de
132
136
  Contributions are welcome! Please contact the developer for any bugs, features, or improvements.
133
137
 
134
138
  ## Change Log
135
- - 20250602 v1.1.19: changed to umd for unpkg, and es for module.
139
+ - v1.1.21(20250603): added alias uc-qty.
140
+ - v1.1.19(20250602): changed to umd for unpkg, and es for module.
136
141
 
137
142
  ## Contact
138
143
  If you have any questions or feedback, feel free to contact me at don.wen@yahoo.com.
package/dist/pq.es.js CHANGED
@@ -1,182 +1,322 @@
1
- const o = 0.45359237, s = 25.4 / 1e3, a = 12 * s, l = 101325, n = 133.322387415;
1
+ function _0x4030(_0x4ab988, _0x3106b9) {
2
+ const _0x42fcce = _0x42fc();
3
+ return (
4
+ (_0x4030 = function (_0x4030be, _0x141d4c) {
5
+ _0x4030be = _0x4030be - 0x17c;
6
+ let _0x1e1738 = _0x42fcce[_0x4030be];
7
+ return _0x1e1738;
8
+ }),
9
+ _0x4030(_0x4ab988, _0x3106b9)
10
+ );
11
+ }
12
+ function _0x42fc() {
13
+ const _0x3b5091 = [
14
+ "ksi[kip/in²]",
15
+ "mouseout",
16
+ "shadowRoot",
17
+ "select",
18
+ "mbar",
19
+ "toPrecision",
20
+ "value",
21
+ "</option>",
22
+ "target",
23
+ "<option\x20value=\x22",
24
+ "selected",
25
+ "557380ZRhlCl",
26
+ "mm\x20HG",
27
+ "g/cm³",
28
+ "183JdCizK",
29
+ "toFixed",
30
+ "Length",
31
+ "replace",
32
+ "addEventListener",
33
+ "\x22\x20width=\x2212\x22\x20/>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</a>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20</div>\x20\x20\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20</div>\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20",
34
+ "observedAttributes",
35
+ "g/mm³",
36
+ "ksi",
37
+ "decimal-places",
38
+ "lbm/in³",
39
+ "kg/m³",
40
+ "mouseover",
41
+ "\x0a\x20\x20\x20\x20\x20\x20<style>\x0a\x20\x20\x20\x20\x20\x20\x20\x20:host\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20display:\x20inline-block;\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20.quantity\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20display:\x20flex;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20align-items:\x20center;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20position:\x20relative;\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20.value\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20margin-left:\x200.25em;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20margin-right:\x200.25em;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20cursor:\x20pointer;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20position:\x20relative;\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20.unit-container\x20select\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20position:\x20relative;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20display:\x20inline-flex;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20align-items:\x20center;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20color:\x20blue;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20background-color:\x20lightgray;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20border-radius:\x200.25em;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20border:\x20none;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20margin:\x200.25em;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20cursor:\x20pointer;\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20.tooltip\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20position:\x20absolute;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20bottom:\x2075%;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20left:\x2085%;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20transform:\x20translateX(-50%);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20background-color:\x20#f5f5f5;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20border:\x201px\x20solid\x20#ccc;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20padding:\x200;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20border-radius:\x204px;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20display:\x20none;\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20font-size:\x2012px;\x20\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20.tooltip\x20a\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20text-decoration:\x20none;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20color:\x20blue;\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20.tooltip\x20a:hover\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20text-decoration:\x20underline;\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20</style>\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20<div\x20class=\x22quantity\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20<span\x20class=\x22value\x22\x20style=\x22position:\x20relative;\x22>",
42
+ "lbm",
43
+ "handleArrowClick",
44
+ "5284eUjMtm",
45
+ "mm\x20W.C.",
46
+ ">\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20",
47
+ "attachShadow",
48
+ "kPa",
49
+ "psi",
50
+ "kg/L",
51
+ "formatValue",
52
+ "in\x20W.C.",
53
+ "in\x20HG",
54
+ "tagName",
55
+ "230592wqBsLI",
56
+ "display",
57
+ "getUnitCategory",
58
+ "https://firebasestorage.googleapis.com/v0/b/auto-calc-80237.appspot.com/o/shared%2Fassets%2Fimages%2Fe3d-logo2.png?alt=media&token=7064f466-6168-4b8a-b921-4e86115cb492",
59
+ "floor",
60
+ "unit",
61
+ "decimalPlaces",
62
+ "209620FqAmRz",
63
+ "map",
64
+ "innerHTML",
65
+ "click",
66
+ "closest",
67
+ "SELECT",
68
+ "none",
69
+ "unitConversion",
70
+ "render",
71
+ "pow",
72
+ "join",
73
+ "cm\x20HG",
74
+ ".tooltip",
75
+ "querySelectorAll",
76
+ "includes",
77
+ "toString",
78
+ "975366NMdCVH",
79
+ "1306074GsCYgw",
80
+ "handleUnitChange",
81
+ "</span>\x0a\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22unit-container\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<select>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20",
82
+ "1121552UdgHOa",
83
+ "bar",
84
+ "style",
85
+ "tooltipTimeout",
86
+ "define",
87
+ "units",
88
+ "psf",
89
+ "unitCategory",
90
+ "\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</select>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<a\x20class=\x22tooltip\x22\x20href=\x22https://v2.donwen.com/\x22\x20target=\x22_blank\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<img\x20src=\x22",
91
+ "change",
92
+ "e3dLogoUrl",
93
+ "GPa",
94
+ "isInteger",
95
+ ];
96
+ _0x42fc = function () {
97
+ return _0x3b5091;
98
+ };
99
+ return _0x42fc();
100
+ }
101
+ const _0x5a4856 = _0x4030;
102
+ (function (_0x5f14b2, _0x469583) {
103
+ const _0x34b91d = _0x4030,
104
+ _0x51d612 = _0x5f14b2();
105
+ while (!![]) {
106
+ try {
107
+ const _0x19a766 =
108
+ parseInt(_0x34b91d(0x1b1)) / 0x1 +
109
+ -parseInt(_0x34b91d(0x1aa)) / 0x2 +
110
+ (-parseInt(_0x34b91d(0x18f)) / 0x3) *
111
+ (parseInt(_0x34b91d(0x19f)) / 0x4) +
112
+ -parseInt(_0x34b91d(0x18c)) / 0x5 +
113
+ parseInt(_0x34b91d(0x1c1)) / 0x6 +
114
+ parseInt(_0x34b91d(0x1c2)) / 0x7 +
115
+ -parseInt(_0x34b91d(0x1c5)) / 0x8;
116
+ if (_0x19a766 === _0x469583) break;
117
+ else _0x51d612["push"](_0x51d612["shift"]());
118
+ } catch (_0x2738d4) {
119
+ _0x51d612["push"](_0x51d612["shift"]());
120
+ }
121
+ }
122
+ })(_0x42fc, 0x1b270);
123
+ const s = 0.45359237,
124
+ o = 25.4 / 0x3e8,
125
+ n = 0xc * o,
126
+ c = 0x18bcd,
127
+ a = 133.322387415;
2
128
  class r extends HTMLElement {
3
129
  constructor() {
4
- super(), this.attachShadow({ mode: "open" }), this.value = 0, this.unit = "mm", this.unitCategory = "Length", this.tooltipTimeout = null, this.decimalPlaces = 3, this.units = {
5
- Length: ["m", "km", "cm", "mm", "in", "ft"],
6
- Mass: ["g", "kg", "lbm"],
7
- Pressure: [
8
- "Pa",
9
- "kPa",
10
- "MPa",
11
- "GPa",
12
- "bar",
13
- "mbar",
14
- "atm",
15
- "mm HG",
16
- "cm HG",
17
- "in HG",
18
- "mm W.C.",
19
- "m W.C.",
20
- "in W.C.",
21
- "psf",
22
- "psi",
23
- "ksi",
24
- "ksi[kip/in²]"
25
- ],
26
- Density: ["kg/m³", "kg/L", "g/cm³", "g/mm³"]
27
- // Add other categories and units as needed
28
- }, this.unitConversion = {
29
- Length: {
30
- m: 1,
31
- km: 1e3,
32
- cm: 0.01,
33
- mm: 1e-3,
34
- in: s,
35
- ft: a
36
- // Add more conversion factors as needed
37
- },
38
- // Add other category conversion factors as needed
39
- Mass: {
40
- kg: 1,
41
- g: 1e-3,
42
- lbm: o
43
- // Add more conversion factors as needed
44
- },
45
- Pressure: {
46
- Pa: 1,
47
- kPa: 1e3,
48
- MPa: 1e6,
49
- GPa: 1e9,
50
- bar: 100 * 1e3,
51
- mbar: 100,
52
- atm: l,
53
- "mm HG": n,
54
- "cm HG": n * 10,
55
- "in HG": n * 25.4,
56
- "mm W.C.": 1 / 1e3 * 1e3 * 9.80665,
57
- "m W.C.": 1 * 1e3 * 9.80665,
58
- "in W.C.": s * 1e3 * 9.80665,
59
- psf: o * 9.80665 / Math.pow(a, 2),
60
- psi: o * 9.80665 / Math.pow(s, 2),
61
- ksi: o * 9.80665 / Math.pow(s, 2) * 1e3,
62
- "ksi[kip/in²]": o * 9.80665 / Math.pow(s, 2) * 1e3
63
- },
64
- Density: {
65
- "kg/m³": 1,
66
- "kg/L": 1e3,
67
- "g/cm³": 1 / 1e3 / Math.pow(0.01, 3),
68
- "g/mm³": 1 / 1e3 / Math.pow(1e-3, 3)
69
- }
70
- }, this.render();
130
+ const _0x304c29 = _0x4030;
131
+ super(),
132
+ this[_0x304c29(0x1a2)]({ mode: "open" }),
133
+ (this[_0x304c29(0x187)] = 0x0),
134
+ (this[_0x304c29(0x1af)] = "mm"),
135
+ (this[_0x304c29(0x1cc)] = _0x304c29(0x191)),
136
+ (this[_0x304c29(0x1c8)] = null),
137
+ (this["decimalPlaces"] = 0x3),
138
+ (this[_0x304c29(0x17e)] = _0x304c29(0x1ad)),
139
+ (this[_0x304c29(0x1ca)] = {
140
+ Length: ["m", "km", "cm", "mm", "in", "ft"],
141
+ Mass: ["g", "kg", _0x304c29(0x19d)],
142
+ Pressure: [
143
+ "Pa",
144
+ _0x304c29(0x1a3),
145
+ "MPa",
146
+ _0x304c29(0x17f),
147
+ _0x304c29(0x1c6),
148
+ _0x304c29(0x185),
149
+ "atm",
150
+ _0x304c29(0x18d),
151
+ _0x304c29(0x1bc),
152
+ _0x304c29(0x1a8),
153
+ _0x304c29(0x1a0),
154
+ "m\x20W.C.",
155
+ _0x304c29(0x1a7),
156
+ _0x304c29(0x1cb),
157
+ _0x304c29(0x1a4),
158
+ _0x304c29(0x197),
159
+ _0x304c29(0x181),
160
+ ],
161
+ Density: [
162
+ _0x304c29(0x19a),
163
+ _0x304c29(0x1a5),
164
+ _0x304c29(0x18e),
165
+ _0x304c29(0x196),
166
+ "lbm/ft³",
167
+ _0x304c29(0x199),
168
+ ],
169
+ }),
170
+ (this["unitConversion"] = {
171
+ Length: { m: 0x1, km: 0x3e8, cm: 0.01, mm: 0.001, in: o, ft: n },
172
+ Mass: { kg: 0x1, g: 0.001, lbm: s },
173
+ Pressure: {
174
+ Pa: 0x1,
175
+ kPa: 0x3e8,
176
+ MPa: 0xf4240,
177
+ GPa: 0x3b9aca00,
178
+ bar: 0x64 * 0x3e8,
179
+ mbar: 0x64,
180
+ atm: c,
181
+ "mm\x20HG": a,
182
+ "cm\x20HG": a * 0xa,
183
+ "in\x20HG": a * 25.4,
184
+ "mm\x20W.C.": (0x1 / 0x3e8) * 0x3e8 * 9.80665,
185
+ "m\x20W.C.": 0x1 * 0x3e8 * 9.80665,
186
+ "in\x20W.C.": o * 0x3e8 * 9.80665,
187
+ psf: (s * 9.80665) / Math["pow"](n, 0x2),
188
+ psi: (s * 9.80665) / Math[_0x304c29(0x1ba)](o, 0x2),
189
+ ksi: ((s * 9.80665) / Math[_0x304c29(0x1ba)](o, 0x2)) * 0x3e8,
190
+ "ksi[kip/in²]":
191
+ ((s * 9.80665) / Math[_0x304c29(0x1ba)](o, 0x2)) * 0x3e8,
192
+ },
193
+ Density: {
194
+ "kg/m³": 0x1,
195
+ "kg/L": 0x3e8,
196
+ "g/cm³": 0x1 / 0x3e8 / Math[_0x304c29(0x1ba)](0.01, 0x3),
197
+ "g/mm³": 0x1 / 0x3e8 / Math[_0x304c29(0x1ba)](0.001, 0x3),
198
+ "lbm/ft³": s / Math["pow"](n, 0x3),
199
+ "lbm/in³": s / Math[_0x304c29(0x1ba)](o, 0x3),
200
+ },
201
+ }),
202
+ this[_0x304c29(0x1b9)]();
71
203
  }
72
- static get observedAttributes() {
73
- return ["value", "unit", "decimal-places"];
204
+ static get [_0x5a4856(0x195)]() {
205
+ const _0x3d9867 = _0x5a4856;
206
+ return [_0x3d9867(0x187), _0x3d9867(0x1af), _0x3d9867(0x198)];
74
207
  }
75
- attributeChangedCallback(t, e, i) {
76
- t === "value" ? this.value = parseFloat(i) : t === "unit" ? (this.unit = i, this.unitCategory = this.getUnitCategory(i)) : t === "decimal-places" && (this.decimalPlaces = parseInt(i) || 3), this.render();
208
+ ["attributeChangedCallback"](_0x245af0, _0x5f24c0, _0x1757d5) {
209
+ const _0x44f36e = _0x5a4856;
210
+ _0x245af0 === _0x44f36e(0x187)
211
+ ? (this[_0x44f36e(0x187)] = parseFloat(_0x1757d5))
212
+ : _0x245af0 === _0x44f36e(0x1af)
213
+ ? ((this[_0x44f36e(0x1af)] = _0x1757d5),
214
+ (this[_0x44f36e(0x1cc)] = this[_0x44f36e(0x1ac)](_0x1757d5)))
215
+ : _0x245af0 === _0x44f36e(0x198) &&
216
+ (this[_0x44f36e(0x1b0)] = parseInt(_0x1757d5) || 0x3),
217
+ this[_0x44f36e(0x1b9)]();
77
218
  }
78
- getUnitCategory(t) {
79
- for (const e in this.units)
80
- if (this.units[e].includes(t))
81
- return e;
219
+ ["getUnitCategory"](_0x5e9d53) {
220
+ const _0x73ab41 = _0x5a4856;
221
+ for (const _0x5da375 in this[_0x73ab41(0x1ca)])
222
+ if (this[_0x73ab41(0x1ca)][_0x5da375][_0x73ab41(0x1bf)](_0x5e9d53))
223
+ return _0x5da375;
82
224
  return null;
83
225
  }
84
- connectedCallback() {
85
- this.shadowRoot.addEventListener("change", this.handleUnitChange.bind(this)), this.shadowRoot.addEventListener("mouseover", this.handleMouseOver.bind(this)), this.shadowRoot.addEventListener("mouseout", this.handleMouseOut.bind(this)), this.render();
226
+ ["connectedCallback"]() {
227
+ const _0x17c939 = _0x5a4856;
228
+ this["shadowRoot"][_0x17c939(0x193)](
229
+ "change",
230
+ this[_0x17c939(0x1c3)]["bind"](this)
231
+ ),
232
+ this[_0x17c939(0x1b9)]();
86
233
  }
87
- disconnectedCallback() {
88
- this.shadowRoot.removeEventListener("change", this.handleUnitChange.bind(this)), this.shadowRoot.removeEventListener("mouseover", this.handleMouseOver.bind(this)), this.shadowRoot.removeEventListener("mouseout", this.handleMouseOut.bind(this));
234
+ ["disconnectedCallback"]() {
235
+ const _0x575059 = _0x5a4856;
236
+ this[_0x575059(0x183)]["removeEventListener"](
237
+ _0x575059(0x17d),
238
+ this[_0x575059(0x1c3)]["bind"](this)
239
+ );
89
240
  }
90
- handleArrowClick(t) {
91
- if (t.target.closest(".unit-container")) {
92
- const e = this.shadowRoot.querySelector("select");
93
- e && (e.focus(), e.click());
241
+ [_0x5a4856(0x19e)](_0x4ec0ee) {
242
+ const _0x46e73e = _0x5a4856;
243
+ if (_0x4ec0ee["target"][_0x46e73e(0x1b5)](".unit-container")) {
244
+ const _0x56d313 = this[_0x46e73e(0x183)]["querySelector"](
245
+ _0x46e73e(0x184)
246
+ );
247
+ _0x56d313 && (_0x56d313["focus"](), _0x56d313[_0x46e73e(0x1b4)]());
94
248
  }
95
249
  }
96
- handleUnitChange(t) {
97
- if (t.target.tagName === "SELECT") {
98
- const e = t.target.value, i = this.unitConversion[this.unitCategory][this.unit] / this.unitConversion[this.unitCategory][e];
99
- this.value = this.value * i, this.unit = e, this.render();
250
+ ["handleUnitChange"](_0x36f3a3) {
251
+ const _0x5797c7 = _0x5a4856;
252
+ if (_0x36f3a3[_0x5797c7(0x189)][_0x5797c7(0x1a9)] === _0x5797c7(0x1b6)) {
253
+ const _0x3b712f = _0x36f3a3[_0x5797c7(0x189)][_0x5797c7(0x187)],
254
+ _0x576c36 =
255
+ this[_0x5797c7(0x1b8)][this[_0x5797c7(0x1cc)]][
256
+ this[_0x5797c7(0x1af)]
257
+ ] / this["unitConversion"][this["unitCategory"]][_0x3b712f];
258
+ (this[_0x5797c7(0x187)] = this[_0x5797c7(0x187)] * _0x576c36),
259
+ (this["unit"] = _0x3b712f),
260
+ this[_0x5797c7(0x1b9)]();
100
261
  }
101
262
  }
102
- handleMouseOver() {
103
- const t = this.shadowRoot.querySelector(".tooltip");
104
- t.style.display = "block", clearTimeout(this.tooltipTimeout);
105
- }
106
- handleMouseOut() {
107
- const t = this.shadowRoot.querySelector(".tooltip");
108
- this.tooltipTimeout = setTimeout(() => {
109
- t.style.display = "none";
110
- }, 1e3);
111
- }
112
- formatValue(t) {
113
- return Number.isInteger(t) ? t.toString() : Math.floor(t) !== 0 ? t.toFixed(this.decimalPlaces).replace(/0+$/, "").replace(/\.$/, "") : t.toPrecision(3);
263
+ [_0x5a4856(0x1a6)](_0xa85d74) {
264
+ const _0x2d56a1 = _0x5a4856;
265
+ return Number[_0x2d56a1(0x180)](_0xa85d74)
266
+ ? _0xa85d74[_0x2d56a1(0x1c0)]()
267
+ : Math[_0x2d56a1(0x1ae)](_0xa85d74) !== 0x0
268
+ ? _0xa85d74[_0x2d56a1(0x190)](this[_0x2d56a1(0x1b0)])
269
+ ["replace"](/0+$/, "")
270
+ [_0x2d56a1(0x192)](/\.$/, "")
271
+ : _0xa85d74[_0x2d56a1(0x186)](0x3);
114
272
  }
115
- render() {
116
- this.shadowRoot.innerHTML = `
117
- <style>
118
- :host {
119
- display: inline-block;
120
- }
121
- .quantity {
122
- display: flex;
123
- align-items: center;
124
- }
125
- .value {
126
- margin-left: 0.25em;
127
- margin-right: 0.25em;
128
- }
129
- .unit-container select {
130
- position: relative;
131
- display: inline-flex;
132
- align-items: center;
133
- color: blue;
134
- background-color: lightgray;
135
- border-radius: 0.25em;
136
- border: none;
137
- margin: 0.25em;
138
- cursor: pointer;
139
- }
140
-
141
- .tooltip {
142
- display: none; /* Set display to block for initial positioning */
143
- visibility: hidden; /* Initially hide the tooltip */
144
- opacity: 50; /* Start with zero opacity */
145
- transition: opacity 0.3s ease-in-out; /* Smooth transition */
146
- position: absolute;
147
- bottom: 100%;
148
- left: 50%;
149
- transform: translateX(-50%);
150
- background-color: black;
151
- color: red;
152
- padding: 5px;
153
- border-radius: 3px;
154
- font-size: 0.8em;
155
- white-space: nowrap;
156
- z-index: 10;
157
- }
158
-
159
- .tooltip a {
160
- color: cyan;
161
- }
162
-
163
- </style>
164
-
165
- <div class="quantity">
166
- <span class="value">${this.formatValue(this.value)}</span>
167
- <div class="unit-container">
168
- <select>
169
- ${this.units[this.unitCategory].map((t) => `<option value="${t}" ${t === this.unit ? "selected" : ""}>
170
- ${t}</option>`).join("")}
171
- </select>
172
- </div>
173
- </div>
174
- <div class="tooltip">
175
- Powered by <a href="https://v2.donwen.com" target="_blank">AutoCalcs</a>
176
- </div>
177
-
178
- `;
273
+ [_0x5a4856(0x1b9)]() {
274
+ const _0x38e8b1 = _0x5a4856;
275
+ this["shadowRoot"][_0x38e8b1(0x1b3)] =
276
+ _0x38e8b1(0x19c) +
277
+ this["formatValue"](this[_0x38e8b1(0x187)]) +
278
+ _0x38e8b1(0x1c4) +
279
+ this["units"][this["unitCategory"]]
280
+ [_0x38e8b1(0x1b2)](
281
+ (_0x440cab) =>
282
+ _0x38e8b1(0x18a) +
283
+ _0x440cab +
284
+ "\x22\x20" +
285
+ (_0x440cab === this[_0x38e8b1(0x1af)] ? _0x38e8b1(0x18b) : "") +
286
+ _0x38e8b1(0x1a1) +
287
+ _0x440cab +
288
+ _0x38e8b1(0x188)
289
+ )
290
+ [_0x38e8b1(0x1bb)]("") +
291
+ _0x38e8b1(0x17c) +
292
+ this["e3dLogoUrl"] +
293
+ _0x38e8b1(0x194);
294
+ const _0x5f4a70 =
295
+ this[_0x38e8b1(0x183)]["querySelector"](".unit-container"),
296
+ _0x1701b4 = this["shadowRoot"][_0x38e8b1(0x1be)](_0x38e8b1(0x1bd))[0x0];
297
+ _0x5f4a70["addEventListener"](_0x38e8b1(0x19b), () => {
298
+ const _0x393d26 = _0x38e8b1;
299
+ this[_0x393d26(0x1c8)] = setTimeout(() => {
300
+ const _0x1bde51 = _0x393d26;
301
+ _0x1701b4[_0x1bde51(0x1c7)][_0x1bde51(0x1ab)] = "block";
302
+ }, 0x3e8);
303
+ }),
304
+ _0x5f4a70[_0x38e8b1(0x193)](_0x38e8b1(0x182), () => {
305
+ const _0x63e53d = _0x38e8b1;
306
+ setTimeout(() => {
307
+ const _0x346b70 = _0x4030;
308
+ _0x1701b4[_0x346b70(0x1c7)][_0x346b70(0x1ab)] = _0x346b70(0x1b7);
309
+ }, 0x3e8),
310
+ clearTimeout(this[_0x63e53d(0x1c8)]);
311
+ }),
312
+ _0x1701b4[_0x38e8b1(0x193)]("mouseout", () => {
313
+ setTimeout(() => {
314
+ const _0x2980a5 = _0x4030;
315
+ _0x1701b4[_0x2980a5(0x1c7)][_0x2980a5(0x1ab)] = "none";
316
+ }, 0x3e8);
317
+ });
179
318
  }
180
319
  }
181
- customElements.define("physical-quantity", r);
182
- customElements.define("pqe", r);
320
+ customElements[_0x5a4856(0x1c9)]("physical-quantity", r);
321
+ class h extends r {}
322
+ customElements[_0x5a4856(0x1c9)]("uc-qty", h);
package/dist/pq.umd.js CHANGED
@@ -1,63 +1,352 @@
1
- (function(n){typeof define=="function"&&define.amd?define(n):n()})(function(){"use strict";const o=.45359237,i=25.4/1e3,r=12*i,h=101325,a=133.322387415;class l extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.value=0,this.unit="mm",this.unitCategory="Length",this.tooltipTimeout=null,this.decimalPlaces=3,this.units={Length:["m","km","cm","mm","in","ft"],Mass:["g","kg","lbm"],Pressure:["Pa","kPa","MPa","GPa","bar","mbar","atm","mm HG","cm HG","in HG","mm W.C.","m W.C.","in W.C.","psf","psi","ksi","ksi[kip/in²]"],Density:["kg/m³","kg/L","g/cm³","g/mm³"]},this.unitConversion={Length:{m:1,km:1e3,cm:.01,mm:.001,in:i,ft:r},Mass:{kg:1,g:.001,lbm:o},Pressure:{Pa:1,kPa:1e3,MPa:1e6,GPa:1e9,bar:100*1e3,mbar:100,atm:h,"mm HG":a,"cm HG":a*10,"in HG":a*25.4,"mm W.C.":1/1e3*1e3*9.80665,"m W.C.":1*1e3*9.80665,"in W.C.":i*1e3*9.80665,psf:o*9.80665/Math.pow(r,2),psi:o*9.80665/Math.pow(i,2),ksi:o*9.80665/Math.pow(i,2)*1e3,"ksi[kip/in²]":o*9.80665/Math.pow(i,2)*1e3},Density:{"kg/m³":1,"kg/L":1e3,"g/cm³":1/1e3/Math.pow(.01,3),"g/mm³":1/1e3/Math.pow(.001,3)}},this.render()}static get observedAttributes(){return["value","unit","decimal-places"]}attributeChangedCallback(t,e,s){t==="value"?this.value=parseFloat(s):t==="unit"?(this.unit=s,this.unitCategory=this.getUnitCategory(s)):t==="decimal-places"&&(this.decimalPlaces=parseInt(s)||3),this.render()}getUnitCategory(t){for(const e in this.units)if(this.units[e].includes(t))return e;return null}connectedCallback(){this.shadowRoot.addEventListener("change",this.handleUnitChange.bind(this)),this.shadowRoot.addEventListener("mouseover",this.handleMouseOver.bind(this)),this.shadowRoot.addEventListener("mouseout",this.handleMouseOut.bind(this)),this.render()}disconnectedCallback(){this.shadowRoot.removeEventListener("change",this.handleUnitChange.bind(this)),this.shadowRoot.removeEventListener("mouseover",this.handleMouseOver.bind(this)),this.shadowRoot.removeEventListener("mouseout",this.handleMouseOut.bind(this))}handleArrowClick(t){if(t.target.closest(".unit-container")){const e=this.shadowRoot.querySelector("select");e&&(e.focus(),e.click())}}handleUnitChange(t){if(t.target.tagName==="SELECT"){const e=t.target.value,s=this.unitConversion[this.unitCategory][this.unit]/this.unitConversion[this.unitCategory][e];this.value=this.value*s,this.unit=e,this.render()}}handleMouseOver(){const t=this.shadowRoot.querySelector(".tooltip");t.style.display="block",clearTimeout(this.tooltipTimeout)}handleMouseOut(){const t=this.shadowRoot.querySelector(".tooltip");this.tooltipTimeout=setTimeout(()=>{t.style.display="none"},1e3)}formatValue(t){return Number.isInteger(t)?t.toString():Math.floor(t)!==0?t.toFixed(this.decimalPlaces).replace(/0+$/,"").replace(/\.$/,""):t.toPrecision(3)}render(){this.shadowRoot.innerHTML=`
2
- <style>
3
- :host {
4
- display: inline-block;
1
+ function _0x42a0() {
2
+ const _0x132851 = [
3
+ "block",
4
+ "GPa",
5
+ "m\x20W.C.",
6
+ "</span>\x0a\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22unit-container\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<select>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20",
7
+ "unit",
8
+ "139010VJeOrf",
9
+ "decimal-places",
10
+ "ksi[kip/in²]",
11
+ "1256094ptqovg",
12
+ "atm",
13
+ "toString",
14
+ "render",
15
+ "SELECT",
16
+ "g/mm³",
17
+ "handleUnitChange",
18
+ "mouseover",
19
+ "bind",
20
+ "shadowRoot",
21
+ "240698EDrKED",
22
+ "floor",
23
+ "focus",
24
+ "attributeChangedCallback",
25
+ "\x0a\x20\x20\x20\x20\x20\x20<style>\x0a\x20\x20\x20\x20\x20\x20\x20\x20:host\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20display:\x20inline-block;\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20.quantity\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20display:\x20flex;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20align-items:\x20center;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20position:\x20relative;\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20.value\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20margin-left:\x200.25em;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20margin-right:\x200.25em;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20cursor:\x20pointer;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20position:\x20relative;\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20.unit-container\x20select\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20position:\x20relative;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20display:\x20inline-flex;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20align-items:\x20center;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20color:\x20blue;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20background-color:\x20lightgray;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20border-radius:\x200.25em;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20border:\x20none;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20margin:\x200.25em;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20cursor:\x20pointer;\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20.tooltip\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20position:\x20absolute;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20bottom:\x2075%;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20left:\x2085%;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20transform:\x20translateX(-50%);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20background-color:\x20#f5f5f5;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20border:\x201px\x20solid\x20#ccc;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20padding:\x200;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20border-radius:\x204px;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20display:\x20none;\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20font-size:\x2012px;\x20\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20.tooltip\x20a\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20text-decoration:\x20none;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20color:\x20blue;\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20.tooltip\x20a:hover\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20text-decoration:\x20underline;\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20</style>\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20<div\x20class=\x22quantity\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20<span\x20class=\x22value\x22\x20style=\x22position:\x20relative;\x22>",
26
+ "in\x20W.C.",
27
+ ".unit-container",
28
+ "selected",
29
+ "psf",
30
+ "ksi",
31
+ "none",
32
+ "units",
33
+ "removeEventListener",
34
+ "addEventListener",
35
+ "style",
36
+ "pow",
37
+ "mm\x20W.C.",
38
+ "644076ynGYJB",
39
+ "unitCategory",
40
+ "replace",
41
+ "909dUGDgf",
42
+ "includes",
43
+ "uc-qty",
44
+ "disconnectedCallback",
45
+ "select",
46
+ "e3dLogoUrl",
47
+ "unitConversion",
48
+ "https://firebasestorage.googleapis.com/v0/b/auto-calc-80237.appspot.com/o/shared%2Fassets%2Fimages%2Fe3d-logo2.png?alt=media&token=7064f466-6168-4b8a-b921-4e86115cb492",
49
+ "amd",
50
+ "display",
51
+ "7122294mKFOmu",
52
+ "querySelectorAll",
53
+ "closest",
54
+ "toFixed",
55
+ "toPrecision",
56
+ "kg/L",
57
+ "1vTxRWr",
58
+ "psi",
59
+ "<option\x20value=\x22",
60
+ "value",
61
+ "\x22\x20width=\x2212\x22\x20/>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</a>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20</div>\x20\x20\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20</div>\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20",
62
+ "\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</select>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<a\x20class=\x22tooltip\x22\x20href=\x22https://v2.donwen.com/\x22\x20target=\x22_blank\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<img\x20src=\x22",
63
+ "querySelector",
64
+ "kg/m³",
65
+ "Length",
66
+ "change",
67
+ "handleArrowClick",
68
+ "lbm",
69
+ "20saEnZO",
70
+ "lbm/ft³",
71
+ "formatValue",
72
+ "getUnitCategory",
73
+ "kPa",
74
+ "in\x20HG",
75
+ "mouseout",
76
+ "open",
77
+ "map",
78
+ "attachShadow",
79
+ "910245tOjNAl",
80
+ "lbm/in³",
81
+ "mm\x20HG",
82
+ "g/cm³",
83
+ "target",
84
+ "7001379ierJXm",
85
+ "56zEoxjk",
86
+ "tooltipTimeout",
87
+ "decimalPlaces",
88
+ "</option>",
89
+ "mbar",
90
+ ];
91
+ _0x42a0 = function () {
92
+ return _0x132851;
93
+ };
94
+ return _0x42a0();
95
+ }
96
+ function _0x3140(_0x4adaaa, _0x311d57) {
97
+ const _0x42a0f7 = _0x42a0();
98
+ return (
99
+ (_0x3140 = function (_0x314026, _0x2e0b21) {
100
+ _0x314026 = _0x314026 - 0x12c;
101
+ let _0x46f5f8 = _0x42a0f7[_0x314026];
102
+ return _0x46f5f8;
103
+ }),
104
+ _0x3140(_0x4adaaa, _0x311d57)
105
+ );
106
+ }
107
+ (function (_0x3558a9, _0x23e7f9) {
108
+ const _0x5b5928 = _0x3140,
109
+ _0x286df7 = _0x3558a9();
110
+ while (!![]) {
111
+ try {
112
+ const _0x48cf4a =
113
+ (parseInt(_0x5b5928(0x16e)) / 0x1) *
114
+ (-parseInt(_0x5b5928(0x14a)) / 0x2) +
115
+ -parseInt(_0x5b5928(0x15b)) / 0x3 +
116
+ (parseInt(_0x5b5928(0x17a)) / 0x4) *
117
+ (-parseInt(_0x5b5928(0x12d)) / 0x5) +
118
+ parseInt(_0x5b5928(0x168)) / 0x6 +
119
+ (-parseInt(_0x5b5928(0x140)) / 0x7) *
120
+ (parseInt(_0x5b5928(0x133)) / 0x8) +
121
+ (-parseInt(_0x5b5928(0x15e)) / 0x9) *
122
+ (-parseInt(_0x5b5928(0x13d)) / 0xa) +
123
+ parseInt(_0x5b5928(0x132)) / 0xb;
124
+ if (_0x48cf4a === _0x23e7f9) break;
125
+ else _0x286df7["push"](_0x286df7["shift"]());
126
+ } catch (_0x503e6f) {
127
+ _0x286df7["push"](_0x286df7["shift"]());
128
+ }
129
+ }
130
+ })(_0x42a0, 0xb148f),
131
+ (function (_0x35baa4) {
132
+ const _0x4a3fd5 = _0x3140;
133
+ typeof define == "function" && define[_0x4a3fd5(0x166)]
134
+ ? define(_0x35baa4)
135
+ : _0x35baa4();
136
+ })(function () {
137
+ "use strict";
138
+ const _0x1ccab9 = _0x3140;
139
+ const _0x4f7b31 = 0.45359237,
140
+ _0xf30773 = 25.4 / 0x3e8,
141
+ _0x46073f = 0xc * _0xf30773,
142
+ _0x579999 = 0x18bcd,
143
+ _0x380ffe = 133.322387415;
144
+ class _0x2cb387 extends HTMLElement {
145
+ constructor() {
146
+ const _0x2e4cee = _0x3140;
147
+ super(),
148
+ this[_0x2e4cee(0x12c)]({ mode: _0x2e4cee(0x181) }),
149
+ (this["value"] = 0x0),
150
+ (this["unit"] = "mm"),
151
+ (this[_0x2e4cee(0x15c)] = _0x2e4cee(0x176)),
152
+ (this["tooltipTimeout"] = null),
153
+ (this["decimalPlaces"] = 0x3),
154
+ (this["e3dLogoUrl"] = _0x2e4cee(0x165)),
155
+ (this[_0x2e4cee(0x155)] = {
156
+ Length: ["m", "km", "cm", "mm", "in", "ft"],
157
+ Mass: ["g", "kg", _0x2e4cee(0x179)],
158
+ Pressure: [
159
+ "Pa",
160
+ _0x2e4cee(0x17e),
161
+ "MPa",
162
+ _0x2e4cee(0x139),
163
+ "bar",
164
+ _0x2e4cee(0x137),
165
+ _0x2e4cee(0x141),
166
+ _0x2e4cee(0x12f),
167
+ "cm\x20HG",
168
+ _0x2e4cee(0x17f),
169
+ _0x2e4cee(0x15a),
170
+ _0x2e4cee(0x13a),
171
+ _0x2e4cee(0x14f),
172
+ _0x2e4cee(0x152),
173
+ _0x2e4cee(0x16f),
174
+ _0x2e4cee(0x153),
175
+ _0x2e4cee(0x13f),
176
+ ],
177
+ Density: [
178
+ _0x2e4cee(0x175),
179
+ _0x2e4cee(0x16d),
180
+ _0x2e4cee(0x130),
181
+ _0x2e4cee(0x145),
182
+ _0x2e4cee(0x17b),
183
+ _0x2e4cee(0x12e),
184
+ ],
185
+ }),
186
+ (this[_0x2e4cee(0x164)] = {
187
+ Length: {
188
+ m: 0x1,
189
+ km: 0x3e8,
190
+ cm: 0.01,
191
+ mm: 0.001,
192
+ in: _0xf30773,
193
+ ft: _0x46073f,
194
+ },
195
+ Mass: { kg: 0x1, g: 0.001, lbm: _0x4f7b31 },
196
+ Pressure: {
197
+ Pa: 0x1,
198
+ kPa: 0x3e8,
199
+ MPa: 0xf4240,
200
+ GPa: 0x3b9aca00,
201
+ bar: 0x64 * 0x3e8,
202
+ mbar: 0x64,
203
+ atm: _0x579999,
204
+ "mm\x20HG": _0x380ffe,
205
+ "cm\x20HG": _0x380ffe * 0xa,
206
+ "in\x20HG": _0x380ffe * 25.4,
207
+ "mm\x20W.C.": (0x1 / 0x3e8) * 0x3e8 * 9.80665,
208
+ "m\x20W.C.": 0x1 * 0x3e8 * 9.80665,
209
+ "in\x20W.C.": _0xf30773 * 0x3e8 * 9.80665,
210
+ psf:
211
+ (_0x4f7b31 * 9.80665) / Math[_0x2e4cee(0x159)](_0x46073f, 0x2),
212
+ psi:
213
+ (_0x4f7b31 * 9.80665) / Math[_0x2e4cee(0x159)](_0xf30773, 0x2),
214
+ ksi:
215
+ ((_0x4f7b31 * 9.80665) / Math["pow"](_0xf30773, 0x2)) * 0x3e8,
216
+ "ksi[kip/in²]":
217
+ ((_0x4f7b31 * 9.80665) /
218
+ Math[_0x2e4cee(0x159)](_0xf30773, 0x2)) *
219
+ 0x3e8,
220
+ },
221
+ Density: {
222
+ "kg/m³": 0x1,
223
+ "kg/L": 0x3e8,
224
+ "g/cm³": 0x1 / 0x3e8 / Math[_0x2e4cee(0x159)](0.01, 0x3),
225
+ "g/mm³": 0x1 / 0x3e8 / Math[_0x2e4cee(0x159)](0.001, 0x3),
226
+ "lbm/ft³": _0x4f7b31 / Math[_0x2e4cee(0x159)](_0x46073f, 0x3),
227
+ "lbm/in³": _0x4f7b31 / Math["pow"](_0xf30773, 0x3),
228
+ },
229
+ }),
230
+ this[_0x2e4cee(0x143)]();
231
+ }
232
+ static get ["observedAttributes"]() {
233
+ const _0x201eb8 = _0x3140;
234
+ return [_0x201eb8(0x171), _0x201eb8(0x13c), _0x201eb8(0x13e)];
235
+ }
236
+ [_0x1ccab9(0x14d)](_0x3af086, _0x26d93a, _0x5189cb) {
237
+ const _0xd7244f = _0x1ccab9;
238
+ _0x3af086 === _0xd7244f(0x171)
239
+ ? (this[_0xd7244f(0x171)] = parseFloat(_0x5189cb))
240
+ : _0x3af086 === "unit"
241
+ ? ((this[_0xd7244f(0x13c)] = _0x5189cb),
242
+ (this[_0xd7244f(0x15c)] = this[_0xd7244f(0x17d)](_0x5189cb)))
243
+ : _0x3af086 === "decimal-places" &&
244
+ (this[_0xd7244f(0x135)] = parseInt(_0x5189cb) || 0x3),
245
+ this[_0xd7244f(0x143)]();
246
+ }
247
+ [_0x1ccab9(0x17d)](_0x2c14ce) {
248
+ const _0x5bf016 = _0x1ccab9;
249
+ for (const _0x33307d in this[_0x5bf016(0x155)])
250
+ if (this[_0x5bf016(0x155)][_0x33307d][_0x5bf016(0x15f)](_0x2c14ce))
251
+ return _0x33307d;
252
+ return null;
253
+ }
254
+ ["connectedCallback"]() {
255
+ const _0xd1d3ca = _0x1ccab9;
256
+ this[_0xd1d3ca(0x149)][_0xd1d3ca(0x157)](
257
+ _0xd1d3ca(0x177),
258
+ this[_0xd1d3ca(0x146)][_0xd1d3ca(0x148)](this)
259
+ ),
260
+ this[_0xd1d3ca(0x143)]();
261
+ }
262
+ [_0x1ccab9(0x161)]() {
263
+ const _0x530172 = _0x1ccab9;
264
+ this["shadowRoot"][_0x530172(0x156)](
265
+ _0x530172(0x177),
266
+ this["handleUnitChange"][_0x530172(0x148)](this)
267
+ );
268
+ }
269
+ [_0x1ccab9(0x178)](_0x178b79) {
270
+ const _0x2950b5 = _0x1ccab9;
271
+ if (_0x178b79[_0x2950b5(0x131)][_0x2950b5(0x16a)](_0x2950b5(0x150))) {
272
+ const _0x41774b = this["shadowRoot"][_0x2950b5(0x174)](
273
+ _0x2950b5(0x162)
274
+ );
275
+ _0x41774b && (_0x41774b[_0x2950b5(0x14c)](), _0x41774b["click"]());
5
276
  }
6
- .quantity {
7
- display: flex;
8
- align-items: center;
277
+ }
278
+ [_0x1ccab9(0x146)](_0x5a3e6a) {
279
+ const _0x23b04e = _0x1ccab9;
280
+ if (_0x5a3e6a["target"]["tagName"] === _0x23b04e(0x144)) {
281
+ const _0x11be95 = _0x5a3e6a[_0x23b04e(0x131)][_0x23b04e(0x171)],
282
+ _0x663a9 =
283
+ this[_0x23b04e(0x164)][this[_0x23b04e(0x15c)]][
284
+ this[_0x23b04e(0x13c)]
285
+ ] / this[_0x23b04e(0x164)][this["unitCategory"]][_0x11be95];
286
+ (this["value"] = this[_0x23b04e(0x171)] * _0x663a9),
287
+ (this[_0x23b04e(0x13c)] = _0x11be95),
288
+ this[_0x23b04e(0x143)]();
9
289
  }
10
- .value {
11
- margin-left: 0.25em;
12
- margin-right: 0.25em;
13
- }
14
- .unit-container select {
15
- position: relative;
16
- display: inline-flex;
17
- align-items: center;
18
- color: blue;
19
- background-color: lightgray;
20
- border-radius: 0.25em;
21
- border: none;
22
- margin: 0.25em;
23
- cursor: pointer;
24
- }
25
-
26
- .tooltip {
27
- display: none; /* Set display to block for initial positioning */
28
- visibility: hidden; /* Initially hide the tooltip */
29
- opacity: 50; /* Start with zero opacity */
30
- transition: opacity 0.3s ease-in-out; /* Smooth transition */
31
- position: absolute;
32
- bottom: 100%;
33
- left: 50%;
34
- transform: translateX(-50%);
35
- background-color: black;
36
- color: red;
37
- padding: 5px;
38
- border-radius: 3px;
39
- font-size: 0.8em;
40
- white-space: nowrap;
41
- z-index: 10;
42
- }
43
-
44
- .tooltip a {
45
- color: cyan;
46
- }
47
-
48
- </style>
49
-
50
- <div class="quantity">
51
- <span class="value">${this.formatValue(this.value)}</span>
52
- <div class="unit-container">
53
- <select>
54
- ${this.units[this.unitCategory].map(t=>`<option value="${t}" ${t===this.unit?"selected":""}>
55
- ${t}</option>`).join("")}
56
- </select>
57
- </div>
58
- </div>
59
- <div class="tooltip">
60
- Powered by <a href="https://v2.donwen.com" target="_blank">AutoCalcs</a>
61
- </div>
62
-
63
- `}}customElements.define("physical-quantity",l),customElements.define("pqe",l)});
290
+ }
291
+ [_0x1ccab9(0x17c)](_0x51f3d2) {
292
+ const _0x1f30c0 = _0x1ccab9;
293
+ return Number["isInteger"](_0x51f3d2)
294
+ ? _0x51f3d2[_0x1f30c0(0x142)]()
295
+ : Math[_0x1f30c0(0x14b)](_0x51f3d2) !== 0x0
296
+ ? _0x51f3d2[_0x1f30c0(0x16b)](this[_0x1f30c0(0x135)])
297
+ ["replace"](/0+$/, "")
298
+ [_0x1f30c0(0x15d)](/\.$/, "")
299
+ : _0x51f3d2[_0x1f30c0(0x16c)](0x3);
300
+ }
301
+ [_0x1ccab9(0x143)]() {
302
+ const _0x40949f = _0x1ccab9;
303
+ this[_0x40949f(0x149)]["innerHTML"] =
304
+ _0x40949f(0x14e) +
305
+ this[_0x40949f(0x17c)](this[_0x40949f(0x171)]) +
306
+ _0x40949f(0x13b) +
307
+ this["units"][this[_0x40949f(0x15c)]]
308
+ [_0x40949f(0x182)](
309
+ (_0x24ef3b) =>
310
+ _0x40949f(0x170) +
311
+ _0x24ef3b +
312
+ "\x22\x20" +
313
+ (_0x24ef3b === this[_0x40949f(0x13c)] ? _0x40949f(0x151) : "") +
314
+ ">\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20" +
315
+ _0x24ef3b +
316
+ _0x40949f(0x136)
317
+ )
318
+ ["join"]("") +
319
+ _0x40949f(0x173) +
320
+ this[_0x40949f(0x163)] +
321
+ _0x40949f(0x172);
322
+ const _0x4f4daa = this[_0x40949f(0x149)]["querySelector"](
323
+ _0x40949f(0x150)
324
+ ),
325
+ _0x5175d5 = this[_0x40949f(0x149)][_0x40949f(0x169)](".tooltip")[0x0];
326
+ _0x4f4daa[_0x40949f(0x157)](_0x40949f(0x147), () => {
327
+ const _0x95d8da = _0x40949f;
328
+ this[_0x95d8da(0x134)] = setTimeout(() => {
329
+ const _0xa6822d = _0x95d8da;
330
+ _0x5175d5[_0xa6822d(0x158)][_0xa6822d(0x167)] = _0xa6822d(0x138);
331
+ }, 0x3e8);
332
+ }),
333
+ _0x4f4daa["addEventListener"](_0x40949f(0x180), () => {
334
+ const _0x583d0f = _0x40949f;
335
+ setTimeout(() => {
336
+ const _0x12a0e1 = _0x3140;
337
+ _0x5175d5[_0x12a0e1(0x158)][_0x12a0e1(0x167)] = "none";
338
+ }, 0x3e8),
339
+ clearTimeout(this[_0x583d0f(0x134)]);
340
+ }),
341
+ _0x5175d5[_0x40949f(0x157)](_0x40949f(0x180), () => {
342
+ setTimeout(() => {
343
+ const _0x442bf8 = _0x3140;
344
+ _0x5175d5[_0x442bf8(0x158)]["display"] = _0x442bf8(0x154);
345
+ }, 0x3e8);
346
+ });
347
+ }
348
+ }
349
+ customElements["define"]("physical-quantity", _0x2cb387);
350
+ class _0x2dfe31 extends _0x2cb387 {}
351
+ customElements["define"](_0x1ccab9(0x160), _0x2dfe31);
352
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "physical-quantity",
3
- "version": "1.1.21",
3
+ "version": "1.1.24",
4
4
  "description": "A web component to represent a physical quantity with unit conversion.",
5
5
  "main": "./pq.js",
6
6
  "module": "./pq.js",