physical-quantity 1.1.6 → 1.1.8

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
@@ -66,6 +66,7 @@ Here's an example of how to use the component in an HTML file:
66
66
  </head>
67
67
  <body>
68
68
  <physical-quantity value="25.4" unit="mm"></physical-quantity>
69
+ <physical-quantity value="1500" unit="psf" decimal-places=4></physical-quantity> <br>
69
70
  </body>
70
71
  </html>
71
72
  ```
@@ -73,8 +74,9 @@ Here's an example of how to use the component in an HTML file:
73
74
  ### Attributes
74
75
  The physical-quantity component supports the following attributes:
75
76
 
76
- value: The initial value of the physical quantity. It can be any number.
77
- unit: The initial unit of the physical quantity. It must be a valid unit within the supported unit category (e.g., mm, cm, m, in, ft for length).
77
+ - value: The initial value of the physical quantity. It can be any number.
78
+ - unit: The initial unit of the physical quantity. It must be a valid unit within the supported unit category (e.g., mm, cm, m, in, ft for length).
79
+ - decimal-places: web author can specify the decimal-places depending on the magnitude of the quantity. Default to be 3.
78
80
 
79
81
  ### Supported Units
80
82
  Currently, the component supports the following categories and units:
@@ -88,6 +90,24 @@ Currently, the component supports the following categories and units:
88
90
  - kg (kilogram)
89
91
  - g (gram)
90
92
  - lbm (pound mass)
93
+ - Pressure/Stress:
94
+ - Pa
95
+ - kPa
96
+ - MPa
97
+ - GPa
98
+ - bar
99
+ - mbar,
100
+ - atm,
101
+ - mm HG,
102
+ - cm HG,
103
+ - in HG,
104
+ - mm W.C.,
105
+ - m W.C.,
106
+ - in W.C.,
107
+ - psf,
108
+ - psi,
109
+ - ksi,
110
+ - ksi[kip/in²,
91
111
  - ... (more to update.)
92
112
 
93
113
  ## License
package/dist/pq.min.js CHANGED
@@ -1,7 +1,8 @@
1
- class PhysicalQuantity extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.value=0,this.unit="mm",this.unitCategory="length",this.decimalPlaces=3,// Default decimal places
2
- this.units={length:["m","cm","mm","in","ft"],mass:["g","kg","lbm"]},this.unitConversion={length:{m:1,cm:.01,mm:.001,in:.0254,ft:12*.0254},
1
+ const GRAVITY_SI=9.80665,POUNDMASS_KG=.45359237,INCH_METER=.0254,FOOT_METER=12*INCH_METER,ATM_PA=101325,TORR_ATM=1/760,MMHG_PA=133.322387415;// 1 mmHG = 133.322387415 Pa
2
+ class PhysicalQuantity extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.value=0,this.unit="mm",this.unitCategory="Length",this.decimalPlaces=3,// Default decimal places
3
+ this.units={Length:["m","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²]"]},this.unitConversion={Length:{m:1,cm:.01,mm:.001,in:INCH_METER,ft:FOOT_METER},
3
4
  // Add other category conversion factors as needed
4
- mass:{kg:1,g:.001,lbm:.454}},
5
+ Mass:{kg:1,g:.001,lbm:POUNDMASS_KG},Pressure:{Pa:1,kPa:1e3,MPa:1e6,GPa:1e9,bar:1e5,mbar:100,atm:ATM_PA,"mm HG":MMHG_PA,"cm HG":10*MMHG_PA,"in HG":25.4*MMHG_PA,"mm W.C.":+GRAVITY_SI,"m W.C.":1e3*GRAVITY_SI,"in W.C.":1e3*INCH_METER*GRAVITY_SI,psf:POUNDMASS_KG*GRAVITY_SI/Math.pow(FOOT_METER,2),psi:POUNDMASS_KG*GRAVITY_SI/Math.pow(INCH_METER,2),ksi:POUNDMASS_KG*GRAVITY_SI/Math.pow(INCH_METER,2)*1e3,"ksi[kip/in²]":POUNDMASS_KG*GRAVITY_SI/Math.pow(INCH_METER,2)*1e3}},
5
6
  // this.handleUnitChange = this.handleUnitChange; // Bind the method to the instance
6
7
  // this.handleMouseOver = this.handleMouseOver; // Bind the method to the instance
7
8
  // this.handleMouseOut = this.handleMouseOut;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "physical-quantity",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
4
4
  "description": "A web component to represent a physical quantity with unit conversion.",
5
5
  "main": "./dist/pq.min.js",
6
6
  "files": [