vue2-excel-grid 1.3.1 → 1.4.0
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/package.json
CHANGED
|
@@ -917,6 +917,7 @@ import EgSelect from './EgSelect.vue'
|
|
|
917
917
|
import EgTreeSelect from './EgTreeSelect.vue'
|
|
918
918
|
import EgDatePicker from './EgDatePicker.vue'
|
|
919
919
|
import { parseDateValue, formatDate } from '../utils/dateUtils.js'
|
|
920
|
+
import { formatNumber as _formatNumber } from '../utils/numberFormat.js'
|
|
920
921
|
import { Mask, MaskInput } from '../utils/mask.js'
|
|
921
922
|
|
|
922
923
|
const SIZE_CONFIG = {
|
|
@@ -6116,6 +6117,15 @@ export default {
|
|
|
6116
6117
|
this.$refs.wrapper && this.$refs.wrapper.focus()
|
|
6117
6118
|
},
|
|
6118
6119
|
|
|
6120
|
+
// Public, ref-callable: formats a number with a custom thousands
|
|
6121
|
+
// separator (decimal point stays '.', no forced/padded decimals). Any
|
|
6122
|
+
// value that isn't a finite number — already-formatted text like
|
|
6123
|
+
// "6 000 000,00", arbitrary strings, etc. — is returned unchanged, so
|
|
6124
|
+
// hosts can call this on raw cell values without checking the type first.
|
|
6125
|
+
formatNumber(value, separator) {
|
|
6126
|
+
return _formatNumber(value, separator)
|
|
6127
|
+
},
|
|
6128
|
+
|
|
6119
6129
|
toggleLock() {
|
|
6120
6130
|
this.internalLocked = !this.internalLocked
|
|
6121
6131
|
this.$emit('update:locked', this.internalLocked)
|
|
@@ -6866,6 +6876,13 @@ export default {
|
|
|
6866
6876
|
}
|
|
6867
6877
|
.eg-cell-align-right { justify-content: flex-end; }
|
|
6868
6878
|
.eg-cell-align-center { justify-content: center; }
|
|
6879
|
+
/* .eg-cell-value is flex:1 (v1.1.126, to shrink/ellipsize correctly), so it
|
|
6880
|
+
always fills the cell's full width — .eg-cell-align-*'s justify-content
|
|
6881
|
+
above has no leftover space left to act on and never visibly moves it.
|
|
6882
|
+
Same root cause .eg-cell-action-wrap already works around below; apply the
|
|
6883
|
+
same fix here via text-align on the value span itself. */
|
|
6884
|
+
.eg-cell-align-right .eg-cell-value { text-align: right; }
|
|
6885
|
+
.eg-cell-align-center .eg-cell-value { text-align: center; }
|
|
6869
6886
|
.eg-cell--has-suffix.eg-cell-select::after { display: none; }
|
|
6870
6887
|
.eg-cell-select-trigger-wrap {
|
|
6871
6888
|
flex: 1;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Formats a JS number with a custom thousands separator, keeping the
|
|
2
|
+
// decimal point as '.' and showing only as many decimal digits as the
|
|
3
|
+
// number itself already has (no padding, no rounding). Any input that
|
|
4
|
+
// isn't a finite number — an already-formatted string like "6 000 000,00",
|
|
5
|
+
// arbitrary text, null, NaN, etc. — is returned unchanged, so callers can
|
|
6
|
+
// pass through mixed number/string cell values safely without pre-checking
|
|
7
|
+
// the type themselves.
|
|
8
|
+
export function formatNumber(value, separator) {
|
|
9
|
+
if (typeof value !== 'number' || !isFinite(value)) return value
|
|
10
|
+
const sep = separator == null ? '' : String(separator)
|
|
11
|
+
const sign = value < 0 ? '-' : ''
|
|
12
|
+
const [intPart, fracPart] = Math.abs(value).toString().split('.')
|
|
13
|
+
const grouped = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, sep)
|
|
14
|
+
return sign + grouped + (fracPart ? '.' + fracPart : '')
|
|
15
|
+
}
|