@almighty-shogun/utils 1.5.0 → 1.7.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/dist/containsRoutePrefix.js +1 -1
- package/dist/formatCurrency.d.ts.map +1 -1
- package/dist/formatCurrency.js +3 -1
- package/dist/formatDate.d.ts +1 -1
- package/dist/formatDate.d.ts.map +1 -1
- package/dist/formatDate.js +5 -1
- package/dist/formatDateTime.d.ts +1 -1
- package/dist/formatDateTime.d.ts.map +1 -1
- package/dist/formatDateTime.js +8 -2
- package/dist/formatFullDate.d.ts.map +1 -1
- package/dist/formatFullDate.js +5 -1
- package/dist/formatHour.d.ts +1 -1
- package/dist/formatHour.d.ts.map +1 -1
- package/dist/formatHour.js +6 -2
- package/dist/formatMonth.d.ts +1 -1
- package/dist/formatMonth.d.ts.map +1 -1
- package/dist/formatMonth.js +5 -1
- package/dist/formatNumber.d.ts.map +1 -1
- package/dist/formatNumber.js +3 -1
- package/dist/formatPercentage.d.ts.map +1 -1
- package/dist/formatPercentage.js +3 -1
- package/dist/formatTime.d.ts +1 -1
- package/dist/formatTime.d.ts.map +1 -1
- package/dist/formatTime.js +6 -2
- package/dist/formatWeekday.d.ts +1 -1
- package/dist/formatWeekday.d.ts.map +1 -1
- package/dist/formatWeekday.js +5 -1
- package/dist/hasCurrentRoute.js +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/initApplication.d.ts +8 -0
- package/dist/initApplication.d.ts.map +1 -0
- package/dist/initApplication.js +9 -0
- package/dist/internal/getCorrectDateTime.d.ts +3 -0
- package/dist/internal/getCorrectDateTime.d.ts.map +1 -0
- package/dist/internal/getCorrectDateTime.js +4 -0
- package/dist/internal/getCorrectLocale.d.ts +2 -0
- package/dist/internal/getCorrectLocale.d.ts.map +1 -0
- package/dist/internal/getCorrectLocale.js +3 -0
- package/dist/internal/getCurrentRouteName.d.ts.map +1 -0
- package/dist/isBeforeNow.d.ts +3 -0
- package/dist/isBeforeNow.d.ts.map +1 -0
- package/dist/isBeforeNow.js +6 -0
- package/dist/isCurrentRoute.js +1 -1
- package/dist/useDarkTheme.d.ts +2 -0
- package/dist/useDarkTheme.d.ts.map +1 -0
- package/dist/useDarkTheme.js +3 -0
- package/package.json +2 -2
- package/src/containsRoutePrefix.ts +1 -1
- package/src/formatCurrency.ts +5 -1
- package/src/formatDate.ts +7 -2
- package/src/formatDateTime.ts +10 -3
- package/src/formatFullDate.ts +6 -1
- package/src/formatHour.ts +7 -2
- package/src/formatMonth.ts +7 -2
- package/src/formatNumber.ts +5 -1
- package/src/formatPercentage.ts +5 -1
- package/src/formatTime.ts +7 -2
- package/src/formatWeekday.ts +7 -2
- package/src/hasCurrentRoute.ts +1 -1
- package/src/index.ts +4 -2
- package/src/initApplication.ts +18 -0
- package/src/internal/getCorrectDateTime.ts +5 -0
- package/src/internal/getCorrectLocale.ts +3 -0
- package/src/isBeforeNow.ts +8 -0
- package/src/isCurrentRoute.ts +1 -1
- package/src/useDarkTheme.ts +3 -0
- package/dist/getCurrentRouteName.d.ts.map +0 -1
- /package/dist/{getCurrentRouteName.d.ts → internal/getCurrentRouteName.d.ts} +0 -0
- /package/dist/{getCurrentRouteName.js → internal/getCurrentRouteName.js} +0 -0
- /package/src/{getCurrentRouteName.ts → internal/getCurrentRouteName.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatCurrency.d.ts","sourceRoot":"","sources":["../src/formatCurrency.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatCurrency.d.ts","sourceRoot":"","sources":["../src/formatCurrency.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,WAAW,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAUlF"}
|
package/dist/formatCurrency.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import getCorrectLocale from './internal/getCorrectLocale';
|
|
1
2
|
export default function (value, currency, locale) {
|
|
2
|
-
|
|
3
|
+
const localization = getCorrectLocale(locale);
|
|
4
|
+
return new Intl.NumberFormat(localization, {
|
|
3
5
|
style: "currency",
|
|
4
6
|
currency: currency ?? "EUR",
|
|
5
7
|
currencyDisplay: "symbol",
|
package/dist/formatDate.d.ts
CHANGED
package/dist/formatDate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatDate.d.ts","sourceRoot":"","sources":["../src/formatDate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"formatDate.d.ts","sourceRoot":"","sources":["../src/formatDate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAIhC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAS5E"}
|
package/dist/formatDate.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import getCorrectLocale from './internal/getCorrectLocale';
|
|
2
|
+
import getCorrectDateTime from './internal/getCorrectDateTime';
|
|
1
3
|
export default function (date, locale) {
|
|
2
|
-
|
|
4
|
+
const localization = getCorrectLocale(locale);
|
|
5
|
+
const dateTime = getCorrectDateTime(date);
|
|
6
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
3
7
|
year: "numeric",
|
|
4
8
|
month: "long",
|
|
5
9
|
day: "numeric"
|
package/dist/formatDateTime.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatDateTime.d.ts","sourceRoot":"","sources":["../src/formatDateTime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"formatDateTime.d.ts","sourceRoot":"","sources":["../src/formatDateTime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAIhC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAW5E"}
|
package/dist/formatDateTime.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import getCorrectLocale from './internal/getCorrectLocale';
|
|
2
|
+
import getCorrectDateTime from './internal/getCorrectDateTime';
|
|
1
3
|
export default function (date, locale) {
|
|
2
|
-
|
|
4
|
+
const localization = getCorrectLocale(locale);
|
|
5
|
+
const dateTime = getCorrectDateTime(date);
|
|
6
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
3
7
|
day: "numeric",
|
|
4
8
|
weekday: "long",
|
|
5
|
-
month: "long"
|
|
9
|
+
month: "long",
|
|
10
|
+
hour: "2-digit",
|
|
11
|
+
minute: "2-digit"
|
|
6
12
|
});
|
|
7
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatFullDate.d.ts","sourceRoot":"","sources":["../src/formatFullDate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"formatFullDate.d.ts","sourceRoot":"","sources":["../src/formatFullDate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAIhC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAShE"}
|
package/dist/formatFullDate.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import getCorrectLocale from './internal/getCorrectLocale';
|
|
2
|
+
import getCorrectDateTime from './internal/getCorrectDateTime';
|
|
1
3
|
export default function (date, locale) {
|
|
2
|
-
|
|
4
|
+
const localization = getCorrectLocale(locale);
|
|
5
|
+
const dateTime = getCorrectDateTime(date);
|
|
6
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
3
7
|
day: "numeric",
|
|
4
8
|
weekday: "long",
|
|
5
9
|
month: "long"
|
package/dist/formatHour.d.ts
CHANGED
package/dist/formatHour.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatHour.d.ts","sourceRoot":"","sources":["../src/formatHour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"formatHour.d.ts","sourceRoot":"","sources":["../src/formatHour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAIhC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAO5E"}
|
package/dist/formatHour.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import getCorrectLocale from './internal/getCorrectLocale';
|
|
2
|
+
import getCorrectDateTime from './internal/getCorrectDateTime';
|
|
3
|
+
export default function (date, locale) {
|
|
4
|
+
const dateTime = getCorrectDateTime(date);
|
|
5
|
+
const localization = getCorrectLocale(locale);
|
|
6
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
3
7
|
hour: "2-digit"
|
|
4
8
|
});
|
|
5
9
|
}
|
package/dist/formatMonth.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatMonth.d.ts","sourceRoot":"","sources":["../src/formatMonth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"formatMonth.d.ts","sourceRoot":"","sources":["../src/formatMonth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAIhC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,EAAE,MAAM,GAAE,OAAc,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAOpG"}
|
package/dist/formatMonth.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import getCorrectLocale from './internal/getCorrectLocale';
|
|
2
|
+
import getCorrectDateTime from './internal/getCorrectDateTime';
|
|
1
3
|
export default function (date, isLong = true, locale) {
|
|
2
|
-
|
|
4
|
+
const localization = getCorrectLocale(locale);
|
|
5
|
+
const dateTime = getCorrectDateTime(date);
|
|
6
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
3
7
|
month: isLong ? "long" : "short",
|
|
4
8
|
});
|
|
5
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatNumber.d.ts","sourceRoot":"","sources":["../src/formatNumber.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatNumber.d.ts","sourceRoot":"","sources":["../src/formatNumber.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,WAAW,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAU,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAOrF"}
|
package/dist/formatNumber.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import getCorrectLocale from './internal/getCorrectLocale';
|
|
1
2
|
export default function (value, decimals = 2, locale) {
|
|
2
|
-
|
|
3
|
+
const localization = getCorrectLocale(locale);
|
|
4
|
+
return new Intl.NumberFormat(localization, {
|
|
3
5
|
maximumFractionDigits: decimals,
|
|
4
6
|
minimumFractionDigits: decimals
|
|
5
7
|
}).format(value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatPercentage.d.ts","sourceRoot":"","sources":["../src/formatPercentage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatPercentage.d.ts","sourceRoot":"","sources":["../src/formatPercentage.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,WAAW,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAQ/D"}
|
package/dist/formatPercentage.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import getCorrectLocale from './internal/getCorrectLocale';
|
|
1
2
|
export default function (value, locale) {
|
|
2
|
-
|
|
3
|
+
const localization = getCorrectLocale(locale);
|
|
4
|
+
return new Intl.NumberFormat(localization, {
|
|
3
5
|
style: "percent",
|
|
4
6
|
maximumFractionDigits: 1,
|
|
5
7
|
minimumFractionDigits: 0
|
package/dist/formatTime.d.ts
CHANGED
package/dist/formatTime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatTime.d.ts","sourceRoot":"","sources":["../src/formatTime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"formatTime.d.ts","sourceRoot":"","sources":["../src/formatTime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAIhC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAQ5E"}
|
package/dist/formatTime.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import getCorrectLocale from './internal/getCorrectLocale';
|
|
2
|
+
import getCorrectDateTime from './internal/getCorrectDateTime';
|
|
3
|
+
export default function (date, locale) {
|
|
4
|
+
const localization = getCorrectLocale(locale);
|
|
5
|
+
const dateTime = getCorrectDateTime(date);
|
|
6
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
3
7
|
hour: "2-digit",
|
|
4
8
|
minute: "2-digit"
|
|
5
9
|
});
|
package/dist/formatWeekday.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatWeekday.d.ts","sourceRoot":"","sources":["../src/formatWeekday.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"formatWeekday.d.ts","sourceRoot":"","sources":["../src/formatWeekday.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAIhC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,EAAE,MAAM,GAAE,OAAc,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAOpG"}
|
package/dist/formatWeekday.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import getCorrectLocale from './internal/getCorrectLocale';
|
|
2
|
+
import getCorrectDateTime from './internal/getCorrectDateTime';
|
|
1
3
|
export default function (date, isLong = true, locale) {
|
|
2
|
-
|
|
4
|
+
const localization = getCorrectLocale(locale);
|
|
5
|
+
const dateTime = getCorrectDateTime(date);
|
|
6
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
3
7
|
weekday: isLong ? "long" : "short",
|
|
4
8
|
});
|
|
5
9
|
}
|
package/dist/hasCurrentRoute.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -16,9 +16,11 @@ export { default as formatNumber } from './formatNumber';
|
|
|
16
16
|
export { default as formatPercentage } from './formatPercentage';
|
|
17
17
|
export { default as formatTime } from './formatTime';
|
|
18
18
|
export { default as formatWeekday } from './formatWeekday';
|
|
19
|
-
export { default as getCurrentRouteName } from './getCurrentRouteName';
|
|
20
19
|
export { default as getWeather } from './getWeather';
|
|
21
20
|
export { default as hasCurrentRoute } from './hasCurrentRoute';
|
|
22
|
-
export { default as
|
|
21
|
+
export { default as initApplication } from './initApplication';
|
|
22
|
+
export { default as isBeforeNow } from './isBeforeNow';
|
|
23
23
|
export { default as isCurrentRoute } from './isCurrentRoute';
|
|
24
|
+
export { default as scrollToTop } from './scrollToTop';
|
|
25
|
+
export { default as useDarkTheme } from './useDarkTheme';
|
|
24
26
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAElE,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAClE,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC1E,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAChE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,OAAO,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAElE,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAClE,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC1E,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAChE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAC9D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAC9D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -15,8 +15,10 @@ export { default as formatNumber } from './formatNumber';
|
|
|
15
15
|
export { default as formatPercentage } from './formatPercentage';
|
|
16
16
|
export { default as formatTime } from './formatTime';
|
|
17
17
|
export { default as formatWeekday } from './formatWeekday';
|
|
18
|
-
export { default as getCurrentRouteName } from './getCurrentRouteName';
|
|
19
18
|
export { default as getWeather } from './getWeather';
|
|
20
19
|
export { default as hasCurrentRoute } from './hasCurrentRoute';
|
|
21
|
-
export { default as
|
|
20
|
+
export { default as initApplication } from './initApplication';
|
|
21
|
+
export { default as isBeforeNow } from './isBeforeNow';
|
|
22
22
|
export { default as isCurrentRoute } from './isCurrentRoute';
|
|
23
|
+
export { default as scrollToTop } from './scrollToTop';
|
|
24
|
+
export { default as useDarkTheme } from './useDarkTheme';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initApplication.d.ts","sourceRoot":"","sources":["../src/initApplication.ts"],"names":[],"mappings":"AAGA,KAAK,iBAAiB,GAAG;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAA;AAED,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAQxD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import disableZoom from './disableZoom';
|
|
2
|
+
import useDarkTheme from './useDarkTheme';
|
|
3
|
+
export default function (config) {
|
|
4
|
+
document.documentElement.setAttribute("lang", config.locale ?? "en");
|
|
5
|
+
useDarkTheme(config.isDarkTheme ?? false);
|
|
6
|
+
if (config.isZoomDisabled) {
|
|
7
|
+
disableZoom();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCorrectDateTime.d.ts","sourceRoot":"","sources":["../../src/internal/getCorrectDateTime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,GAAG,QAAQ,CAE7D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCorrectLocale.d.ts","sourceRoot":"","sources":["../../src/internal/getCorrectLocale.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,WAAW,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAEhD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCurrentRouteName.d.ts","sourceRoot":"","sources":["../../src/internal/getCurrentRouteName.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,cAAc,MAAM,CAIjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isBeforeNow.d.ts","sourceRoot":"","sources":["../src/isBeforeNow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAGhC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,GAAG,OAAO,CAI5D"}
|
package/dist/isCurrentRoute.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDarkTheme.d.ts","sourceRoot":"","sources":["../src/useDarkTheme.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,OAAO,GAAG,IAAI,CAE9C"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@almighty-shogun/utils",
|
|
3
3
|
"description": "A small package that contains common utilities used in all my projects.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.7.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {
|
|
@@ -38,6 +38,6 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@types/luxon": "^3.7.1",
|
|
40
40
|
"luxon": "^3.7.2",
|
|
41
|
-
"vue-router": "^4.6.
|
|
41
|
+
"vue-router": "^4.6.4"
|
|
42
42
|
}
|
|
43
43
|
}
|
package/src/formatCurrency.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import getCorrectLocale from './internal/getCorrectLocale'
|
|
2
|
+
|
|
1
3
|
export default function (value: number, currency?: string, locale?: string): string {
|
|
2
|
-
|
|
4
|
+
const localization = getCorrectLocale(locale);
|
|
5
|
+
|
|
6
|
+
return new Intl.NumberFormat(localization, {
|
|
3
7
|
style: "currency",
|
|
4
8
|
currency: currency ?? "EUR",
|
|
5
9
|
currencyDisplay: "symbol",
|
package/src/formatDate.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { DateTime } from 'luxon'
|
|
2
|
+
import getCorrectLocale from './internal/getCorrectLocale'
|
|
3
|
+
import getCorrectDateTime from './internal/getCorrectDateTime'
|
|
2
4
|
|
|
3
|
-
export default function (date: DateTime, locale?: string): string {
|
|
4
|
-
|
|
5
|
+
export default function (date: DateTime|string|null, locale?: string): string {
|
|
6
|
+
const localization = getCorrectLocale(locale);
|
|
7
|
+
const dateTime = getCorrectDateTime(date);
|
|
8
|
+
|
|
9
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
5
10
|
year: "numeric",
|
|
6
11
|
month: "long",
|
|
7
12
|
day: "numeric"
|
package/src/formatDateTime.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { DateTime } from 'luxon'
|
|
2
|
+
import getCorrectLocale from './internal/getCorrectLocale'
|
|
3
|
+
import getCorrectDateTime from './internal/getCorrectDateTime'
|
|
2
4
|
|
|
3
|
-
export default function (date: DateTime, locale?: string): string {
|
|
4
|
-
|
|
5
|
+
export default function (date: DateTime|string|null, locale?: string): string {
|
|
6
|
+
const localization = getCorrectLocale(locale);
|
|
7
|
+
const dateTime = getCorrectDateTime(date);
|
|
8
|
+
|
|
9
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
5
10
|
day: "numeric",
|
|
6
11
|
weekday: "long",
|
|
7
|
-
month: "long"
|
|
12
|
+
month: "long",
|
|
13
|
+
hour: "2-digit",
|
|
14
|
+
minute: "2-digit"
|
|
8
15
|
});
|
|
9
16
|
}
|
package/src/formatFullDate.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { DateTime } from 'luxon'
|
|
2
|
+
import getCorrectLocale from './internal/getCorrectLocale'
|
|
3
|
+
import getCorrectDateTime from './internal/getCorrectDateTime'
|
|
2
4
|
|
|
3
5
|
export default function (date: DateTime, locale?: string): string {
|
|
4
|
-
|
|
6
|
+
const localization = getCorrectLocale(locale);
|
|
7
|
+
const dateTime = getCorrectDateTime(date);
|
|
8
|
+
|
|
9
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
5
10
|
day: "numeric",
|
|
6
11
|
weekday: "long",
|
|
7
12
|
month: "long"
|
package/src/formatHour.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { DateTime } from 'luxon'
|
|
2
|
+
import getCorrectLocale from './internal/getCorrectLocale'
|
|
3
|
+
import getCorrectDateTime from './internal/getCorrectDateTime'
|
|
2
4
|
|
|
3
|
-
export default function (date: DateTime): string {
|
|
4
|
-
|
|
5
|
+
export default function (date: DateTime|string|null, locale?: string): string {
|
|
6
|
+
const dateTime = getCorrectDateTime(date);
|
|
7
|
+
const localization = getCorrectLocale(locale);
|
|
8
|
+
|
|
9
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
5
10
|
hour: "2-digit"
|
|
6
11
|
});
|
|
7
12
|
}
|
package/src/formatMonth.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { DateTime } from 'luxon'
|
|
2
|
+
import getCorrectLocale from './internal/getCorrectLocale'
|
|
3
|
+
import getCorrectDateTime from './internal/getCorrectDateTime'
|
|
2
4
|
|
|
3
|
-
export default function (date: DateTime, isLong: boolean = true, locale?: string): string {
|
|
4
|
-
|
|
5
|
+
export default function (date: DateTime|string|null, isLong: boolean = true, locale?: string): string {
|
|
6
|
+
const localization = getCorrectLocale(locale);
|
|
7
|
+
const dateTime = getCorrectDateTime(date);
|
|
8
|
+
|
|
9
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
5
10
|
month: isLong ? "long" : "short",
|
|
6
11
|
});
|
|
7
12
|
}
|
package/src/formatNumber.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import getCorrectLocale from './internal/getCorrectLocale'
|
|
2
|
+
|
|
1
3
|
export default function (value: number, decimals: number = 2, locale?: string): string {
|
|
2
|
-
|
|
4
|
+
const localization = getCorrectLocale(locale);
|
|
5
|
+
|
|
6
|
+
return new Intl.NumberFormat(localization, {
|
|
3
7
|
maximumFractionDigits: decimals,
|
|
4
8
|
minimumFractionDigits: decimals
|
|
5
9
|
}).format(value);
|
package/src/formatPercentage.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import getCorrectLocale from './internal/getCorrectLocale'
|
|
2
|
+
|
|
1
3
|
export default function (value: number, locale?: string): string {
|
|
2
|
-
|
|
4
|
+
const localization = getCorrectLocale(locale);
|
|
5
|
+
|
|
6
|
+
return new Intl.NumberFormat(localization, {
|
|
3
7
|
style: "percent",
|
|
4
8
|
maximumFractionDigits: 1,
|
|
5
9
|
minimumFractionDigits: 0
|
package/src/formatTime.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { DateTime } from 'luxon'
|
|
2
|
+
import getCorrectLocale from './internal/getCorrectLocale'
|
|
3
|
+
import getCorrectDateTime from './internal/getCorrectDateTime'
|
|
2
4
|
|
|
3
|
-
export default function (date: DateTime): string {
|
|
4
|
-
|
|
5
|
+
export default function (date: DateTime|string|null, locale?: string): string {
|
|
6
|
+
const localization = getCorrectLocale(locale);
|
|
7
|
+
const dateTime = getCorrectDateTime(date);
|
|
8
|
+
|
|
9
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
5
10
|
hour: "2-digit",
|
|
6
11
|
minute: "2-digit"
|
|
7
12
|
});
|
package/src/formatWeekday.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { DateTime } from 'luxon'
|
|
2
|
+
import getCorrectLocale from './internal/getCorrectLocale'
|
|
3
|
+
import getCorrectDateTime from './internal/getCorrectDateTime'
|
|
2
4
|
|
|
3
|
-
export default function (date: DateTime, isLong: boolean = true, locale?: string): string {
|
|
4
|
-
|
|
5
|
+
export default function (date: DateTime|string|null, isLong: boolean = true, locale?: string): string {
|
|
6
|
+
const localization = getCorrectLocale(locale);
|
|
7
|
+
const dateTime = getCorrectDateTime(date);
|
|
8
|
+
|
|
9
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
5
10
|
weekday: isLong ? "long" : "short",
|
|
6
11
|
});
|
|
7
12
|
}
|
package/src/hasCurrentRoute.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -17,8 +17,10 @@ export { default as formatNumber } from './formatNumber'
|
|
|
17
17
|
export { default as formatPercentage } from './formatPercentage'
|
|
18
18
|
export { default as formatTime } from './formatTime'
|
|
19
19
|
export { default as formatWeekday } from './formatWeekday'
|
|
20
|
-
export { default as getCurrentRouteName } from './getCurrentRouteName'
|
|
21
20
|
export { default as getWeather } from './getWeather'
|
|
22
21
|
export { default as hasCurrentRoute } from './hasCurrentRoute'
|
|
23
|
-
export { default as
|
|
22
|
+
export { default as initApplication } from './initApplication'
|
|
23
|
+
export { default as isBeforeNow } from './isBeforeNow'
|
|
24
24
|
export { default as isCurrentRoute } from './isCurrentRoute'
|
|
25
|
+
export { default as scrollToTop } from './scrollToTop'
|
|
26
|
+
export { default as useDarkTheme } from './useDarkTheme'
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import disableZoom from './disableZoom'
|
|
2
|
+
import useDarkTheme from './useDarkTheme'
|
|
3
|
+
|
|
4
|
+
type ApplicationConfig = {
|
|
5
|
+
locale?: string;
|
|
6
|
+
isDarkTheme?: boolean;
|
|
7
|
+
isZoomDisabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default function (config: ApplicationConfig): void {
|
|
11
|
+
document.documentElement.setAttribute("lang", config.locale ?? "en");
|
|
12
|
+
|
|
13
|
+
useDarkTheme(config.isDarkTheme ?? false);
|
|
14
|
+
|
|
15
|
+
if (config.isZoomDisabled) {
|
|
16
|
+
disableZoom();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DateTime } from 'luxon'
|
|
2
|
+
import getCorrectDateTime from './internal/getCorrectDateTime'
|
|
3
|
+
|
|
4
|
+
export default function (date: DateTime|string|null): boolean {
|
|
5
|
+
const dateTime = getCorrectDateTime(date);
|
|
6
|
+
|
|
7
|
+
return dateTime.toMillis() < DateTime.now().toMillis();
|
|
8
|
+
}
|
package/src/isCurrentRoute.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getCurrentRouteName.d.ts","sourceRoot":"","sources":["../src/getCurrentRouteName.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,cAAc,MAAM,CAIjC"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|