vueless 0.0.463 → 0.0.465

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.463",
3
+ "version": "0.0.465",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
@@ -5,7 +5,7 @@
5
5
  </template>
6
6
 
7
7
  <script setup>
8
- import { computed, onBeforeUnmount, watch, ref, onMounted, onUnmounted } from "vue";
8
+ import { computed, onBeforeUnmount, watch, ref, onMounted, onUnmounted, watchEffect } from "vue";
9
9
 
10
10
  import { getDefault } from "../utils/utilUI.js";
11
11
  import { isMobileApp } from "../utils/utilPlatform.js";
@@ -35,6 +35,14 @@ const props = defineProps({
35
35
  type: [String, Array],
36
36
  default: "",
37
37
  },
38
+
39
+ /**
40
+ * Loader state (shown / hidden).
41
+ */
42
+ loading: {
43
+ type: Boolean,
44
+ default: getDefault(defaultConfig, ULoaderProgress).loading,
45
+ },
38
46
  });
39
47
 
40
48
  const error = ref(false);
@@ -85,6 +93,17 @@ onUnmounted(() => {
85
93
  window.removeEventListener("loaderProgressOff", setLoaderOffHandler);
86
94
  });
87
95
 
96
+ watchEffect(() => {
97
+ if (props.loading) {
98
+ show.value = true;
99
+ start();
100
+
101
+ return;
102
+ }
103
+
104
+ done();
105
+ });
106
+
88
107
  function setLoaderOnHandler(event) {
89
108
  loaderProgressOn(event.detail.resource);
90
109
  }
@@ -113,7 +132,7 @@ function onChangeRequestsQueue() {
113
132
 
114
133
  if (isActiveRequests && !isStarted.value) {
115
134
  start();
116
- } else if (!isActiveRequests && isStarted.value && show.value) {
135
+ } else if (!isActiveRequests && isStarted.value && show.value && !props.loading) {
117
136
  done();
118
137
  }
119
138
  } else {
@@ -13,6 +13,7 @@ export default /*tw*/ {
13
13
  },
14
14
  defaults: {
15
15
  color: "brand",
16
+ loading: false,
16
17
  },
17
18
  safelist: (colors) => [{ pattern: `bg-(${colors})-600` }],
18
19
  };
@@ -12,12 +12,12 @@
12
12
  v-text="symbol + currencySpace"
13
13
  />
14
14
 
15
- <span v-if="sum" v-bind="mathSignAttrs" v-text="mathSign" />
15
+ <span v-if="value" v-bind="mathSignAttrs" v-text="mathSign" />
16
16
 
17
17
  <span v-bind="integerAttrs" v-text="preparedMoney.integer" />
18
18
 
19
19
  <span
20
- v-if="!integer"
20
+ v-if="maxFractionDigits > 0"
21
21
  v-bind="pennyAttrs"
22
22
  v-text="preparedMoney.decimalSeparator + preparedMoney.penny"
23
23
  />
@@ -52,7 +52,7 @@ const props = defineProps({
52
52
  /**
53
53
  * Money value.
54
54
  */
55
- sum: {
55
+ value: {
56
56
  type: Number,
57
57
  default: 0,
58
58
  },
@@ -110,11 +110,19 @@ const props = defineProps({
110
110
  },
111
111
 
112
112
  /**
113
- * Set the numeral decimal scale after the comma.
113
+ * Minimal number of signs after the decimal separator (fractional part of a number).
114
114
  */
115
- decimalScale: {
115
+ minFractionDigits: {
116
116
  type: Number,
117
- default: getDefault(defaultConfig, UMoney).decimalScale,
117
+ default: getDefault(defaultConfig, UMoney).minFractionDigits,
118
+ },
119
+
120
+ /**
121
+ * Maximal number of signs after the decimal separator (fractional part of a number).
122
+ */
123
+ maxFractionDigits: {
124
+ type: Number,
125
+ default: getDefault(defaultConfig, UMoney).maxFractionDigits,
118
126
  },
119
127
 
120
128
  /**
@@ -126,20 +134,20 @@ const props = defineProps({
126
134
  },
127
135
 
128
136
  /**
129
- * Money align.
130
- * @values right, left
137
+ * A symbol used to separate the thousand parts of a number.
131
138
  */
132
- align: {
139
+ thousandsSeparator: {
133
140
  type: String,
134
- default: getDefault(defaultConfig, UMoney).align,
141
+ default: getDefault(defaultConfig, UMoney).thousandsSeparator,
135
142
  },
136
143
 
137
144
  /**
138
- * Make money sum integer.
145
+ * Money align.
146
+ * @values right, left
139
147
  */
140
- integer: {
141
- type: Boolean,
142
- default: getDefault(defaultConfig, UMoney).integer,
148
+ align: {
149
+ type: String,
150
+ default: getDefault(defaultConfig, UMoney).align,
143
151
  },
144
152
 
145
153
  /**
@@ -200,6 +208,12 @@ const mathSign = computed(() => {
200
208
  });
201
209
 
202
210
  const preparedMoney = computed(() => {
203
- return separatedMoney(Math.abs(props.sum), props.decimalScale, props.decimalSeparator);
211
+ return separatedMoney(
212
+ Math.abs(props.value),
213
+ props.minFractionDigits,
214
+ props.maxFractionDigits,
215
+ props.decimalSeparator,
216
+ props.thousandsSeparator,
217
+ );
204
218
  });
205
219
  </script>
@@ -53,8 +53,10 @@ export default /*tw*/ {
53
53
  sign: "default",
54
54
  align: "left",
55
55
  symbolAlign: "right",
56
- decimalScale: 2,
56
+ minFractionDigits: 0,
57
+ maxFractionDigits: 2,
57
58
  decimalSeparator: ",",
59
+ thousandsSeparator: " ",
58
60
  planned: false,
59
61
  integer: false,
60
62
  symbolDivided: true,
@@ -16,7 +16,7 @@ export default {
16
16
  title: "Text & Content / Money",
17
17
  component: UMoney,
18
18
  args: {
19
- sum: 10,
19
+ value: 10,
20
20
  symbol: "$",
21
21
  sign: "positive",
22
22
  },
@@ -73,12 +73,12 @@ export const Default = DefaultTemplate.bind({});
73
73
  Default.args = {};
74
74
 
75
75
  export const OtherValues = DefaultTemplate.bind({});
76
- OtherValues.args = { sum: 10, symbol: "$", sign: "negative" };
76
+ OtherValues.args = { value: 10, symbol: "$", sign: "negative" };
77
77
 
78
78
  export const Colors = EnumVariantTemplate.bind({});
79
79
  Colors.args = {
80
80
  enum: "color",
81
- sum: 0,
81
+ value: 0,
82
82
  symbol: "$",
83
83
  sign: "default",
84
84
  };
@@ -95,11 +95,8 @@ SymbolAlign.args = { enum: "symbolAlign" };
95
95
  export const Planned = DefaultTemplate.bind({});
96
96
  Planned.args = { planned: true };
97
97
 
98
- export const Integer = DefaultTemplate.bind({});
99
- Integer.args = { integer: true };
100
-
101
- export const NumeralDecimalScale3 = DefaultTemplate.bind({});
102
- NumeralDecimalScale3.args = { numeralDecimalScale: 3 };
98
+ export const MinFractionDigits3 = DefaultTemplate.bind({});
99
+ MinFractionDigits3.args = { value: 25.67, minFractionDigits: 3, maxFractionDigits: 3 };
103
100
 
104
101
  export const Align = EnumVariantTemplate.bind({});
105
102
  Align.args = { enum: "align" };
@@ -8,21 +8,39 @@ export const ADD_SPACE_IN_MONEY_REG_EX = /(\d)(?=(\d{3})+(\D|$))/g;
8
8
  export const SINGLE_ZERO = "0";
9
9
  export const DOUBLE_ZERO = "00";
10
10
 
11
- export function separatedMoney(money, decimalPlaces = 2, decimalSeparator = ",") {
12
- const roundedMoney = money ? money.toFixed(decimalPlaces) : 0;
11
+ export function separatedMoney(
12
+ money,
13
+ minFractionDigits = 0,
14
+ maxFractionDigits = 2,
15
+ decimalSeparator = ",",
16
+ thousandsSeparator = " ",
17
+ ) {
18
+ const options = {
19
+ minimumFractionDigits: minFractionDigits,
20
+ maximumFractionDigits: maxFractionDigits,
21
+ };
13
22
 
14
- let [integer, penny] = String(roundedMoney).split(".");
23
+ const formattedMoney =
24
+ money !== undefined && money !== null ? Number(money).toLocaleString("en-US", options) : "0";
15
25
 
16
- integer = integer.replace(ADD_SPACE_IN_MONEY_REG_EX, "$1 ");
26
+ let [integer, penny = ""] = formattedMoney.split(".");
17
27
 
18
- if (!roundedMoney) {
28
+ integer = integer.replace(/,/g, thousandsSeparator);
29
+
30
+ if (!money && money !== 0) {
19
31
  integer = SINGLE_ZERO;
20
32
  penny = DOUBLE_ZERO;
21
33
  }
22
34
 
23
- if (decimalPlaces === 0) {
35
+ if (penny === "") {
36
+ decimalSeparator = "";
37
+ }
38
+
39
+ if (minFractionDigits === 0 && maxFractionDigits === 0) {
24
40
  decimalSeparator = "";
25
41
  penny = "";
42
+ } else if (penny.length < minFractionDigits) {
43
+ penny = penny.padEnd(minFractionDigits, "0");
26
44
  }
27
45
 
28
46
  return { integer, penny, decimalSeparator };
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.463",
4
+ "version": "0.0.465",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",
@@ -6303,6 +6303,15 @@
6303
6303
  "type": "string|array"
6304
6304
  },
6305
6305
  "default": "\"\""
6306
+ },
6307
+ {
6308
+ "name": "loading",
6309
+ "description": "Loader state (shown / hidden).",
6310
+ "value": {
6311
+ "kind": "expression",
6312
+ "type": "boolean"
6313
+ },
6314
+ "default": "false"
6306
6315
  }
6307
6316
  ],
6308
6317
  "source": {
@@ -6736,7 +6745,7 @@
6736
6745
  "description": "",
6737
6746
  "attributes": [
6738
6747
  {
6739
- "name": "sum",
6748
+ "name": "value",
6740
6749
  "description": "Money value.",
6741
6750
  "value": {
6742
6751
  "kind": "expression",
@@ -6799,8 +6808,17 @@
6799
6808
  "default": "default"
6800
6809
  },
6801
6810
  {
6802
- "name": "decimalScale",
6803
- "description": "Set the numeral decimal scale after the comma.",
6811
+ "name": "minFractionDigits",
6812
+ "description": "Minimal number of signs after the decimal separator (fractional part of a number).",
6813
+ "value": {
6814
+ "kind": "expression",
6815
+ "type": "number"
6816
+ },
6817
+ "default": "0"
6818
+ },
6819
+ {
6820
+ "name": "maxFractionDigits",
6821
+ "description": "Maximal number of signs after the decimal separator (fractional part of a number).",
6804
6822
  "value": {
6805
6823
  "kind": "expression",
6806
6824
  "type": "number"
@@ -6817,22 +6835,22 @@
6817
6835
  "default": ","
6818
6836
  },
6819
6837
  {
6820
- "name": "align",
6821
- "description": "Money align.",
6838
+ "name": "thousandsSeparator",
6839
+ "description": "A symbol used to separate the thousand parts of a number.",
6822
6840
  "value": {
6823
6841
  "kind": "expression",
6824
- "type": "'right' | 'left'"
6842
+ "type": "string"
6825
6843
  },
6826
- "default": "left"
6844
+ "default": " "
6827
6845
  },
6828
6846
  {
6829
- "name": "integer",
6830
- "description": "Make money sum integer.",
6847
+ "name": "align",
6848
+ "description": "Money align.",
6831
6849
  "value": {
6832
6850
  "kind": "expression",
6833
- "type": "boolean"
6851
+ "type": "'right' | 'left'"
6834
6852
  },
6835
- "default": "false"
6853
+ "default": "left"
6836
6854
  },
6837
6855
  {
6838
6856
  "name": "planned",