vueless 0.0.776 → 0.0.778
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 +1 -1
- package/ui.data-table/UTable.vue +40 -8
- package/ui.data-table/storybook/stories.ts +7 -1
- package/ui.data-table/types.ts +2 -0
- package/ui.form-input-money/UInputMoney.vue +10 -4
- package/ui.form-input-money/constants.ts +2 -0
- package/ui.form-input-money/useFormatCurrency.ts +14 -6
- package/ui.form-input-money/utilFormat.ts +3 -3
package/package.json
CHANGED
package/ui.data-table/UTable.vue
CHANGED
|
@@ -19,7 +19,7 @@ import ULoaderProgress from "../ui.loader-progress/ULoaderProgress.vue";
|
|
|
19
19
|
import UTableRow from "./UTableRow.vue";
|
|
20
20
|
|
|
21
21
|
import useUI from "../composables/useUI.ts";
|
|
22
|
-
import { getDefaults, cx } from "../utils/ui.ts";
|
|
22
|
+
import { getDefaults, cx, getMergedConfig } from "../utils/ui.ts";
|
|
23
23
|
import { hasSlotContent } from "../utils/helper.ts";
|
|
24
24
|
import { useLocale } from "../composables/useLocale.ts";
|
|
25
25
|
import { PX_IN_REM } from "../constants.js";
|
|
@@ -37,8 +37,17 @@ import {
|
|
|
37
37
|
|
|
38
38
|
import { COMPONENT_NAME } from "./constants.ts";
|
|
39
39
|
|
|
40
|
-
import type { Cell, Row, RowId, UTableProps, UTableRowAttrs, Config } from "./types.ts";
|
|
41
40
|
import type { Ref, ComputedRef } from "vue";
|
|
41
|
+
import type { Config as UDividerConfig } from "../ui.container-divider/types.ts";
|
|
42
|
+
import type {
|
|
43
|
+
Cell,
|
|
44
|
+
Row,
|
|
45
|
+
RowId,
|
|
46
|
+
UTableProps,
|
|
47
|
+
UTableRowAttrs,
|
|
48
|
+
Config,
|
|
49
|
+
DateDivider,
|
|
50
|
+
} from "./types.ts";
|
|
42
51
|
|
|
43
52
|
defineOptions({ inheritAttrs: false });
|
|
44
53
|
|
|
@@ -256,10 +265,21 @@ function onWindowResize() {
|
|
|
256
265
|
setFooterCellWidth();
|
|
257
266
|
}
|
|
258
267
|
|
|
259
|
-
function
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
268
|
+
function getDateDividerData(rowDate: string | Date) {
|
|
269
|
+
let dividerItem = {} as DateDivider;
|
|
270
|
+
|
|
271
|
+
if (Array.isArray(props.dateDivider)) {
|
|
272
|
+
const dividerItemData = props.dateDivider.find((dateItem) => dateItem.date === rowDate);
|
|
273
|
+
|
|
274
|
+
if (dividerItemData) {
|
|
275
|
+
dividerItem = dividerItemData;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
return {
|
|
280
|
+
label: dividerItem?.label || String(rowDate),
|
|
281
|
+
config: dividerItem?.config,
|
|
282
|
+
};
|
|
263
283
|
}
|
|
264
284
|
|
|
265
285
|
function setFooterCellWidth(zero?: null) {
|
|
@@ -684,8 +704,14 @@ const {
|
|
|
684
704
|
<td v-bind="bodyCellDateDividerAttrs" :colspan="colsCount">
|
|
685
705
|
<UDivider
|
|
686
706
|
size="xs"
|
|
687
|
-
:label="
|
|
707
|
+
:label="getDateDividerData(row.rowDate).label"
|
|
688
708
|
v-bind="bodyDateDividerAttrs"
|
|
709
|
+
:config="
|
|
710
|
+
getMergedConfig({
|
|
711
|
+
defaultConfig: bodyDateDividerAttrs.config,
|
|
712
|
+
globalConfig: getDateDividerData(row.rowDate).config,
|
|
713
|
+
}) as UDividerConfig
|
|
714
|
+
"
|
|
689
715
|
/>
|
|
690
716
|
</td>
|
|
691
717
|
</tr>
|
|
@@ -697,8 +723,14 @@ const {
|
|
|
697
723
|
<td v-bind="bodyCellDateDividerAttrs" :colspan="colsCount">
|
|
698
724
|
<UDivider
|
|
699
725
|
size="xs"
|
|
700
|
-
:label="
|
|
726
|
+
:label="getDateDividerData(row.rowDate).label"
|
|
701
727
|
v-bind="bodySelectedDateDividerAttrs"
|
|
728
|
+
:config="
|
|
729
|
+
getMergedConfig({
|
|
730
|
+
defaultConfig: bodyDateDividerAttrs.config,
|
|
731
|
+
globalConfig: getDateDividerData(row.rowDate).config,
|
|
732
|
+
}) as UDividerConfig
|
|
733
|
+
"
|
|
702
734
|
/>
|
|
703
735
|
</td>
|
|
704
736
|
</tr>
|
|
@@ -334,7 +334,13 @@ DateDividerCustomLabel.args = {
|
|
|
334
334
|
rows: Array(10)
|
|
335
335
|
.fill({})
|
|
336
336
|
.map(() => getDateDividerRow()),
|
|
337
|
-
dateDivider: [
|
|
337
|
+
dateDivider: [
|
|
338
|
+
{
|
|
339
|
+
date: new Date().toString(),
|
|
340
|
+
label: "Custom label for specific date",
|
|
341
|
+
config: { label: "!text-orange-400", divider: "!border-orange-300" },
|
|
342
|
+
},
|
|
343
|
+
],
|
|
338
344
|
};
|
|
339
345
|
|
|
340
346
|
export const SlotDefault = DefaultTemplate.bind({});
|
package/ui.data-table/types.ts
CHANGED
|
@@ -2,6 +2,7 @@ import defaultConfig from "./config.ts";
|
|
|
2
2
|
|
|
3
3
|
import type { Ref } from "vue";
|
|
4
4
|
import type { ComponentConfig, UnknownObject } from "../types.ts";
|
|
5
|
+
import type { Config as UDividerConfig } from "../ui.container-divider/types.ts";
|
|
5
6
|
|
|
6
7
|
export type Config = typeof defaultConfig;
|
|
7
8
|
|
|
@@ -23,6 +24,7 @@ export interface RowData {
|
|
|
23
24
|
export interface DateDivider {
|
|
24
25
|
date: Date | string;
|
|
25
26
|
label?: string;
|
|
27
|
+
config?: ComponentConfig<UDividerConfig>;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
export interface Row {
|
|
@@ -8,7 +8,7 @@ import UInput from "../ui.form-input/UInput.vue";
|
|
|
8
8
|
|
|
9
9
|
import defaultConfig from "./config.ts";
|
|
10
10
|
import useFormatCurrency from "./useFormatCurrency.ts";
|
|
11
|
-
import { COMPONENT_NAME } from "./constants.ts";
|
|
11
|
+
import { COMPONENT_NAME, RAW_DECIMAL_MARK } from "./constants.ts";
|
|
12
12
|
|
|
13
13
|
import type { Props, Config } from "./types.ts";
|
|
14
14
|
|
|
@@ -52,9 +52,15 @@ const input = computed(() => {
|
|
|
52
52
|
return moneyInputRef.value?.inputRef || null;
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
-
const stringLocalValue = computed(() =>
|
|
56
|
-
Object.is(localValue.value, -0)
|
|
57
|
-
|
|
55
|
+
const stringLocalValue = computed(() => {
|
|
56
|
+
if (Object.is(localValue.value, -0)) return "-0";
|
|
57
|
+
|
|
58
|
+
const fraction = String(rawValue.value).split(RAW_DECIMAL_MARK).at(1) || "";
|
|
59
|
+
|
|
60
|
+
return props.valueType === "number" && !Number.isNaN(parseFloat(String(localValue.value)))
|
|
61
|
+
? parseFloat(String(localValue.value)).toFixed(fraction.length)
|
|
62
|
+
: String(localValue.value);
|
|
63
|
+
});
|
|
58
64
|
|
|
59
65
|
watch(
|
|
60
66
|
() => props.modelValue,
|
|
@@ -2,10 +2,11 @@ import { onMounted, nextTick, ref, onBeforeUnmount, toValue, watch, computed, re
|
|
|
2
2
|
|
|
3
3
|
import { getRawValue, getFormattedValue } from "./utilFormat.ts";
|
|
4
4
|
|
|
5
|
+
import { RAW_DECIMAL_MARK } from "./constants.ts";
|
|
6
|
+
|
|
5
7
|
import type { FormatOptions } from "./types.ts";
|
|
6
8
|
|
|
7
9
|
const digitSet = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"];
|
|
8
|
-
const rawDecimalMark = ".";
|
|
9
10
|
const comma = ",";
|
|
10
11
|
const minus = "-";
|
|
11
12
|
|
|
@@ -83,7 +84,7 @@ export default function useFormatCurrency(
|
|
|
83
84
|
|
|
84
85
|
const endsWithDecimal = formattedValue.value.endsWith(options.value.decimalSeparator);
|
|
85
86
|
|
|
86
|
-
if ((event.key === comma || event.key ===
|
|
87
|
+
if ((event.key === comma || event.key === RAW_DECIMAL_MARK) && endsWithDecimal) {
|
|
87
88
|
event.preventDefault();
|
|
88
89
|
|
|
89
90
|
return;
|
|
@@ -120,7 +121,7 @@ export default function useFormatCurrency(
|
|
|
120
121
|
}
|
|
121
122
|
|
|
122
123
|
// Replace dot with decimal separator
|
|
123
|
-
if (eventData ===
|
|
124
|
+
if (eventData === RAW_DECIMAL_MARK || eventData === comma) {
|
|
124
125
|
value = [
|
|
125
126
|
...prevValue.value.slice(0, prevCursorPosition),
|
|
126
127
|
options.value.decimalSeparator,
|
|
@@ -145,7 +146,6 @@ export default function useFormatCurrency(
|
|
|
145
146
|
!options.value.minFractionDigits
|
|
146
147
|
) {
|
|
147
148
|
formattedValue.value = value;
|
|
148
|
-
|
|
149
149
|
rawValue.value = newRawValue;
|
|
150
150
|
|
|
151
151
|
return;
|
|
@@ -156,7 +156,7 @@ export default function useFormatCurrency(
|
|
|
156
156
|
const isDoubleMinus = isMinus && prevValue.value.startsWith(minus);
|
|
157
157
|
const isMinusWithin = newRawValue.includes(minus) && !newRawValue.startsWith(minus);
|
|
158
158
|
|
|
159
|
-
const isReservedSymbol = eventData !==
|
|
159
|
+
const isReservedSymbol = eventData !== RAW_DECIMAL_MARK && eventData !== comma;
|
|
160
160
|
|
|
161
161
|
if (
|
|
162
162
|
(!isNumericValue && isReservedSymbol && !isMinus && eventData.length === 1) ||
|
|
@@ -172,7 +172,15 @@ export default function useFormatCurrency(
|
|
|
172
172
|
return;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
const
|
|
175
|
+
const currentFraction = (newRawValue.split(RAW_DECIMAL_MARK).at(1) || "").slice(
|
|
176
|
+
0,
|
|
177
|
+
options.value.maxFractionDigits,
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
const newFormattedValue = getFormattedValue(newRawValue, {
|
|
181
|
+
...options.value,
|
|
182
|
+
minFractionDigits: currentFraction.length,
|
|
183
|
+
});
|
|
176
184
|
|
|
177
185
|
if (Number.isNaN(newFormattedValue) || newFormattedValue.includes("NaN")) {
|
|
178
186
|
inputElement.value = prevValue.value;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RAW_DECIMAL_MARK } from "./constants.ts";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import type { FormatOptions } from "./types.ts";
|
|
4
4
|
|
|
5
5
|
export function getRawValue(
|
|
6
6
|
value: string,
|
|
@@ -12,7 +12,7 @@ export function getRawValue(
|
|
|
12
12
|
|
|
13
13
|
const rawValueWithPrefix = value
|
|
14
14
|
.replaceAll(thousandsSeparator, "")
|
|
15
|
-
.replace(decimalSeparator,
|
|
15
|
+
.replace(decimalSeparator, RAW_DECIMAL_MARK);
|
|
16
16
|
|
|
17
17
|
return rawValueWithPrefix.replace(prefix, "") as Intl.StringNumericLiteral;
|
|
18
18
|
}
|