@uxf/localize 11.62.2 → 11.63.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/README.md CHANGED
@@ -27,14 +27,17 @@ import en from "@uxf/localize/locale/en"; // LocalizeConfig
27
27
  export const {
28
28
  LocalizeProvider,
29
29
  formatDateTime,
30
+ formatTime,
30
31
  formatMoney,
31
32
  formatNumber,
32
33
  formatPercentage,
33
34
  useFormatDateTime,
35
+ useFormatTime,
34
36
  useFormatMoney,
35
37
  useFormatNumber,
36
38
  useFormatPercentage,
37
39
  FormatDateTime,
40
+ FormatTime,
38
41
  FormatNumber,
39
42
  FormatMoney,
40
43
  FormatPercentage,
@@ -44,9 +47,9 @@ export const {
44
47
  ### Localize config examples
45
48
 
46
49
  ```ts
47
- import {DateTimes, LocalizeConfig} from "@uxf/localize";
50
+ import {DateTimes, Times, LocalizeConfig} from "@uxf/localize";
48
51
 
49
- const en: LocalizeConfig<DateTimes> = {
52
+ const en: LocalizeConfig<DateTimes, Times> = {
50
53
  number: {
51
54
  thousandsSeparator: ",",
52
55
  decimalSeparator: ".",
@@ -73,9 +76,13 @@ const en: LocalizeConfig<DateTimes> = {
73
76
  dateTimeMedium: "M/D/YYYY H:mm A",
74
77
  dateTimeLong: "MMMM D. YYYY H:mm:ss A",
75
78
  },
79
+ time: {
80
+ short: "h:mm A",
81
+ long: "h:mm:ss A",
82
+ },
76
83
  };
77
84
 
78
- const cs: LocalizeConfig<DateTimes> = {
85
+ const cs: LocalizeConfig<DateTimes, Times> = {
79
86
  number: {
80
87
  thousandsSeparator: "\xa0",
81
88
  decimalSeparator: ",",
@@ -102,6 +109,10 @@ const cs: LocalizeConfig<DateTimes> = {
102
109
  dateTimeMedium: "D. M. YYYY, H:mm",
103
110
  dateTimeLong: "D. MMMM YYYY, H:mm:ss",
104
111
  },
112
+ time: {
113
+ short: "H:mm",
114
+ long: "H:mm:ss",
115
+ }
105
116
  };
106
117
  ```
107
118
 
@@ -138,6 +149,18 @@ formatDateTime(new Date('2000-01-01'), "timeFull"); // 00:00:00
138
149
  <FormatDateTime value={new Date('2000-01-01')} format="dateShort"/>
139
150
  ```
140
151
 
152
+ ## Format time
153
+ ```tsx
154
+ const { useFormatTime, FormatTime } from "./localize";
155
+
156
+ const formatTime = useFormatTime();
157
+
158
+ formatTime("07:58:35", "short"); // 7:58
159
+ formatTime("07:58:35", "short"); // 7:58:35
160
+
161
+ <FormatTime value="07:58:35" format="short"/>
162
+ ```
163
+
141
164
  ## Format money
142
165
  ```tsx
143
166
  const { useFormatMoney, FormatMoney } from "./localize";
package/locale/cs.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { DateTimes, LocalizeConfig } from "../src/types";
2
- declare const locale: LocalizeConfig<DateTimes>;
1
+ import { DateTimes, LocalizeConfig, type Times } from "../src/types";
2
+ declare const locale: LocalizeConfig<DateTimes, Times>;
3
3
  export default locale;
package/locale/cs.js CHANGED
@@ -31,5 +31,9 @@ const locale = {
31
31
  dateTimeMedium: "D. M. YYYY, H:mm",
32
32
  dateTimeLong: "D. MMMM YYYY, H:mm:ss",
33
33
  },
34
+ time: {
35
+ short: "H:mm",
36
+ long: "H:mm:ss",
37
+ },
34
38
  };
35
39
  exports.default = locale;
package/locale/de.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { DateTimes, LocalizeConfig } from "../src/types";
2
- declare const locale: LocalizeConfig<DateTimes>;
1
+ import { DateTimes, LocalizeConfig, type Times } from "../src/types";
2
+ declare const locale: LocalizeConfig<DateTimes, Times>;
3
3
  export default locale;
package/locale/de.js CHANGED
@@ -21,5 +21,9 @@ const locale = {
21
21
  dateTimeMedium: "D. M. YYYY, H:mm",
22
22
  dateTimeLong: "D. MMMM YYYY, H:mm:ss",
23
23
  },
24
+ time: {
25
+ short: "H:mm",
26
+ long: "H:mm:ss",
27
+ },
24
28
  };
25
29
  exports.default = locale;
package/locale/en.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { DateTimes, LocalizeConfig } from "../src/types";
2
- declare const locale: LocalizeConfig<DateTimes>;
1
+ import { DateTimes, LocalizeConfig, type Times } from "../src/types";
2
+ declare const locale: LocalizeConfig<DateTimes, Times>;
3
3
  export default locale;
package/locale/en.js CHANGED
@@ -21,5 +21,9 @@ const locale = {
21
21
  dateTimeMedium: "M/D/YYYY h:mm A",
22
22
  dateTimeLong: "MMMM D. YYYY h:mm:ss A",
23
23
  },
24
+ time: {
25
+ short: "h:mm A",
26
+ long: "h:mm:ss A",
27
+ },
24
28
  };
25
29
  exports.default = locale;
package/locale/es.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { DateTimes, LocalizeConfig } from "../src/types";
2
- declare const locale: LocalizeConfig<DateTimes>;
1
+ import { DateTimes, LocalizeConfig, type Times } from "../src/types";
2
+ declare const locale: LocalizeConfig<DateTimes, Times>;
3
3
  export default locale;
package/locale/es.js CHANGED
@@ -21,5 +21,9 @@ const locale = {
21
21
  dateTimeMedium: "D MMM YYYY, H:mm",
22
22
  dateTimeLong: "D MMMM YYYY, H:mm:ss",
23
23
  },
24
+ time: {
25
+ short: "H:mm",
26
+ long: "H:mm:ss",
27
+ },
24
28
  };
25
29
  exports.default = locale;
package/locale/fr.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { DateTimes, LocalizeConfig } from "../src/types";
2
- declare const locale: LocalizeConfig<DateTimes>;
1
+ import { DateTimes, LocalizeConfig, type Times } from "../src/types";
2
+ declare const locale: LocalizeConfig<DateTimes, Times>;
3
3
  export default locale;
package/locale/fr.js CHANGED
@@ -27,5 +27,9 @@ const locale = {
27
27
  dateTimeMedium: "D MMM YYYY, HH:mm",
28
28
  dateTimeLong: "D MMMM YYYY, HH:mm:ss",
29
29
  },
30
+ time: {
31
+ short: "H:mm",
32
+ long: "H:mm:ss",
33
+ },
30
34
  };
31
35
  exports.default = locale;
package/locale/pl.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { DateTimes, LocalizeConfig } from "../src/types";
2
- declare const locale: LocalizeConfig<DateTimes>;
1
+ import { DateTimes, LocalizeConfig, type Times } from "../src/types";
2
+ declare const locale: LocalizeConfig<DateTimes, Times>;
3
3
  export default locale;
package/locale/pl.js CHANGED
@@ -21,5 +21,9 @@ const locale = {
21
21
  dateTimeMedium: "D.MM.YYYY, HH:mm",
22
22
  dateTimeLong: "D. MMMM YYYY, HH:mm:ss",
23
23
  },
24
+ time: {
25
+ short: "H:mm",
26
+ long: "H:mm:ss",
27
+ },
24
28
  };
25
29
  exports.default = locale;
package/locale/sk.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { DateTimes, LocalizeConfig } from "../src/types";
2
- declare const locale: LocalizeConfig<DateTimes>;
1
+ import { DateTimes, LocalizeConfig, type Times } from "../src/types";
2
+ declare const locale: LocalizeConfig<DateTimes, Times>;
3
3
  export default locale;
package/locale/sk.js CHANGED
@@ -27,5 +27,9 @@ const locale = {
27
27
  dateTimeMedium: "D. M. YYYY, H:mm",
28
28
  dateTimeLong: "D. MMMM YYYY, H:mm:ss",
29
29
  },
30
+ time: {
31
+ short: "H:mm",
32
+ long: "H:mm:ss",
33
+ },
30
34
  };
31
35
  exports.default = locale;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/localize",
3
- "version": "11.62.2",
3
+ "version": "11.63.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,2 +1,2 @@
1
1
  import { FormatDatetimeComponent, LocalizeConfigMap } from "../types";
2
- export declare function createFormatDatetimeComponent<DT extends string, Locales extends string>(localizeConfigs: LocalizeConfigMap<DT, Locales>): FormatDatetimeComponent<DT>;
2
+ export declare function createFormatDatetimeComponent<DT extends string, Locales extends string>(localizeConfigs: LocalizeConfigMap<DT, never, Locales>): FormatDatetimeComponent<DT>;
@@ -1,2 +1,2 @@
1
1
  import { FormatMoneyComponent, LocalizeConfigMap } from "../types";
2
- export declare function createFormatMoneyComponent<Locales extends string>(localizeConfigs: LocalizeConfigMap<never, Locales>): FormatMoneyComponent;
2
+ export declare function createFormatMoneyComponent<Locales extends string>(localizeConfigs: LocalizeConfigMap<never, never, Locales>): FormatMoneyComponent;
@@ -1,2 +1,2 @@
1
1
  import { FormatNumberComponent, LocalizeConfigMap } from "../types";
2
- export declare function createFormatNumberComponent<Locales extends string>(localizeConfigs: LocalizeConfigMap<never, Locales>): FormatNumberComponent;
2
+ export declare function createFormatNumberComponent<Locales extends string>(localizeConfigs: LocalizeConfigMap<never, never, Locales>): FormatNumberComponent;
@@ -1,2 +1,2 @@
1
1
  import { FormatPercentageComponent, LocalizeConfigMap } from "../types";
2
- export declare function createFormatPercentageComponent<Locales extends string>(localizeConfigs: LocalizeConfigMap<never, Locales>): FormatPercentageComponent;
2
+ export declare function createFormatPercentageComponent<Locales extends string>(localizeConfigs: LocalizeConfigMap<never, never, Locales>): FormatPercentageComponent;
@@ -0,0 +1,2 @@
1
+ import { type FormatTimeComponent, LocalizeConfigMap } from "../types";
2
+ export declare function createFormatTimeComponent<T extends string, Locales extends string>(localizeConfigs: LocalizeConfigMap<never, T, Locales>): FormatTimeComponent<T>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createFormatTimeComponent = createFormatTimeComponent;
7
+ const react_1 = __importDefault(require("react"));
8
+ const context_1 = require("../context/context");
9
+ const format_time_1 = require("../format-time/format-time");
10
+ function createFormatTimeComponent(localizeConfigs) {
11
+ const Component = (props) => {
12
+ const locale = (0, context_1._useLocalizeContext)();
13
+ return react_1.default.createElement(react_1.default.Fragment, null, (0, format_time_1.createFormatTime)(localizeConfigs)(locale, props.value, props.format));
14
+ };
15
+ return Component;
16
+ }
@@ -1,4 +1,4 @@
1
1
  import { LocalizeConfigMap } from "../types";
2
2
  export declare const _useLocalizeContext: () => string;
3
3
  export declare const _LocalizeProvider: import("react").Provider<string>;
4
- export declare const getLocaleConfigHook: <DateTimes extends string, Locales extends string>(allConfigurations: LocalizeConfigMap<DateTimes, Locales>) => () => LocalizeConfigMap<DateTimes, Locales>[Locales];
4
+ export declare const getLocaleConfigHook: <DateTimes extends string, Times extends string, Locales extends string>(allConfigurations: LocalizeConfigMap<DateTimes, Times, Locales>) => () => LocalizeConfigMap<DateTimes, Times, Locales>[Locales];
@@ -1,3 +1,3 @@
1
1
  import { FormatDatetimeFunction, LocalizeConfigMap } from "../types";
2
- export declare function createFormatDatetime<DT extends string, Locales extends string>(localizeConfigs: LocalizeConfigMap<DT, Locales>): FormatDatetimeFunction<DT, Locales>;
3
- export declare function createUseFormatDatetime<DT extends string, Locales extends string>(localizeConfigs: LocalizeConfigMap<DT, Locales>): () => (value: import("@uxf/core/date").DateValue, format: DT, timeZone?: import("../utils/time-zone").TimeZone | undefined) => string;
2
+ export declare function createFormatDatetime<DT extends string, Locales extends string>(localizeConfigs: LocalizeConfigMap<DT, never, Locales>): FormatDatetimeFunction<DT, Locales>;
3
+ export declare function createUseFormatDatetime<DT extends string, Locales extends string>(localizeConfigs: LocalizeConfigMap<DT, never, Locales>): () => (value: import("@uxf/core/date").DateValue, format: DT, timeZone?: import("../utils/time-zone").TimeZone | undefined) => string;
@@ -31,4 +31,9 @@ describe("datetime formatter", function () {
31
31
  expect(formatDatetimeWithLocales("en", date, "timeShort")).toBe("7:58 AM");
32
32
  expect(formatDatetimeWithLocales("en", date, "timeFull")).toBe("7:58:35 AM");
33
33
  });
34
+ it("format datetime with timezone", function () {
35
+ expect(formatDatetimeWithLocales("en", date, "dateTimeShort")).toBe("7/21/23 7:58 AM");
36
+ expect(formatDatetimeWithLocales("en", date, "dateTimeShort", "Europe/Prague")).toBe("7/21/23 7:58 AM");
37
+ expect(formatDatetimeWithLocales("en", date, "dateTimeShort", "America/New_York")).toBe("7/21/23 1:58 AM");
38
+ });
34
39
  });
@@ -1,3 +1,3 @@
1
1
  import { FormatMoneyFunction, LocalizeConfigMap } from "../types";
2
- export declare function createFormatMoney<Locales extends string>(localizeConfigs: LocalizeConfigMap<never, Locales>): FormatMoneyFunction<Locales>;
3
- export declare function createUseFormatMoney<Locales extends string>(localizeConfigs: LocalizeConfigMap<never, Locales>): () => (money: import("@uxf/core/money").Money, options?: import("../types").FormatMoneyOptions | undefined) => string;
2
+ export declare function createFormatMoney<Locales extends string>(localizeConfigs: LocalizeConfigMap<never, never, Locales>): FormatMoneyFunction<Locales>;
3
+ export declare function createUseFormatMoney<Locales extends string>(localizeConfigs: LocalizeConfigMap<never, never, Locales>): () => (money: import("@uxf/core/money").Money, options?: import("../types").FormatMoneyOptions | undefined) => string;
@@ -1,3 +1,3 @@
1
1
  import { FormatNumberFunction, LocalizeConfigMap } from "../types";
2
- export declare function createFormatNumber<Locales extends string>(localizeConfigs: LocalizeConfigMap<never, Locales>): FormatNumberFunction<Locales>;
3
- export declare function createUseFormatNumber<Locales extends string>(localizeConfigs: LocalizeConfigMap<never, Locales>): () => (value: number, options?: import("../types").FormatNumberOptions | undefined) => string;
2
+ export declare function createFormatNumber<Locales extends string>(localizeConfigs: LocalizeConfigMap<never, never, Locales>): FormatNumberFunction<Locales>;
3
+ export declare function createUseFormatNumber<Locales extends string>(localizeConfigs: LocalizeConfigMap<never, never, Locales>): () => (value: number, options?: import("../types").FormatNumberOptions | undefined) => string;
@@ -1,3 +1,3 @@
1
1
  import { FormatPercentageFunction, LocalizeConfigMap, RoundingType } from "../types";
2
- export declare function createFormatPercentage<Locales extends string>(localizeConfigs: LocalizeConfigMap<never, Locales>): FormatPercentageFunction<Locales>;
3
- export declare function createUseFormatPercentage<Locales extends string>(localizeConfigs: LocalizeConfigMap<never, Locales>): () => (value: number, roundingType?: RoundingType | null | undefined, options?: import("../types").FormatPercentageOptions | undefined) => string;
2
+ export declare function createFormatPercentage<Locales extends string>(localizeConfigs: LocalizeConfigMap<never, never, Locales>): FormatPercentageFunction<Locales>;
3
+ export declare function createUseFormatPercentage<Locales extends string>(localizeConfigs: LocalizeConfigMap<never, never, Locales>): () => (value: number, roundingType?: RoundingType | null | undefined, options?: import("../types").FormatPercentageOptions | undefined) => string;
@@ -0,0 +1,3 @@
1
+ import { type FormatTimeFunction, LocalizeConfigMap } from "../types";
2
+ export declare function createFormatTime<T extends string, Locales extends string>(localizeConfigs: LocalizeConfigMap<never, T, Locales>): FormatTimeFunction<T, Locales>;
3
+ export declare function createUseFormatTime<T extends string, Locales extends string>(localizeConfigs: LocalizeConfigMap<never, T, Locales>): () => (value: `${number}:${number}:${number}`, format: T) => string;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.createFormatTime = createFormatTime;
30
+ exports.createUseFormatTime = createUseFormatTime;
31
+ const dayjs_1 = __importStar(require("dayjs"));
32
+ const timezone_1 = __importDefault(require("dayjs/plugin/timezone"));
33
+ const utc_1 = __importDefault(require("dayjs/plugin/utc"));
34
+ const react_1 = require("react");
35
+ const context_1 = require("../context/context");
36
+ const curry_1 = require("../utils/curry");
37
+ (0, dayjs_1.extend)(utc_1.default);
38
+ (0, dayjs_1.extend)(timezone_1.default);
39
+ function createFormatTime(localizeConfigs) {
40
+ return (locale, value, format) => {
41
+ const localeTimes = localizeConfigs[locale].time;
42
+ const dateValue = `1970-01-01T${value}+00:00`;
43
+ return (0, dayjs_1.default)(dateValue, { utc: true }).format(localeTimes[format]);
44
+ };
45
+ }
46
+ function createUseFormatTime(localizeConfigs) {
47
+ return () => {
48
+ const locale = (0, context_1._useLocalizeContext)();
49
+ return (0, react_1.useMemo)(() => (0, curry_1._curry)(createFormatTime(localizeConfigs))(locale), [locale]);
50
+ };
51
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const cs_1 = __importDefault(require("../../locale/cs"));
7
+ const en_1 = __importDefault(require("../../locale/en"));
8
+ const format_time_1 = require("./format-time");
9
+ const time = "07:58:35";
10
+ describe("time formatter", function () {
11
+ const formatTimeWithLocales = (0, format_time_1.createFormatTime)({ cs: cs_1.default, en: en_1.default });
12
+ it("format time with 'cs' locale", function () {
13
+ expect(formatTimeWithLocales("cs", time, "short")).toBe("7:58");
14
+ expect(formatTimeWithLocales("cs", time, "long")).toBe("7:58:35");
15
+ });
16
+ it("format time with 'en' locale", function () {
17
+ expect(formatTimeWithLocales("en", time, "short")).toBe("7:58 AM");
18
+ expect(formatTimeWithLocales("en", time, "long")).toBe("7:58:35 AM");
19
+ });
20
+ });
package/src/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { CreateLocalizeReturn, DateTimes, LocalizeConfigMap } from "./types";
2
- export declare function createLocalize<DT extends string = DateTimes, Locales extends string = string>(config: LocalizeConfigMap<DT, Locales>): CreateLocalizeReturn<DT, Locales>;
1
+ import { CreateLocalizeReturn, DateTimes, LocalizeConfigMap, type Times } from "./types";
2
+ export declare function createLocalize<DT extends string = DateTimes, T extends string = Times, Locales extends string = string>(config: LocalizeConfigMap<DT, T, Locales>): CreateLocalizeReturn<DT, T, Locales>;
package/src/index.js CHANGED
@@ -5,23 +5,28 @@ const format_datetime_1 = require("./components/format-datetime");
5
5
  const format_money_1 = require("./components/format-money");
6
6
  const format_number_1 = require("./components/format-number");
7
7
  const format_percentage_1 = require("./components/format-percentage");
8
+ const format_time_1 = require("./components/format-time");
8
9
  const context_1 = require("./context/context");
9
10
  const format_datetime_2 = require("./format-datetime/format-datetime");
10
11
  const format_money_2 = require("./format-money/format-money");
11
12
  const format_number_2 = require("./format-number/format-number");
12
13
  const format_percentage_2 = require("./format-percentage/format-percentage");
14
+ const format_time_2 = require("./format-time/format-time");
13
15
  function createLocalize(config) {
14
16
  return {
15
17
  LocalizeProvider: context_1._LocalizeProvider,
18
+ formatTime: (0, format_time_2.createFormatTime)(config),
16
19
  formatDateTime: (0, format_datetime_2.createFormatDatetime)(config),
17
20
  formatNumber: (0, format_number_2.createFormatNumber)(config),
18
21
  formatPercentage: (0, format_percentage_2.createFormatPercentage)(config),
19
22
  formatMoney: (0, format_money_2.createFormatMoney)(config),
20
23
  FormatDateTime: (0, format_datetime_1.createFormatDatetimeComponent)(config),
24
+ FormatTime: (0, format_time_1.createFormatTimeComponent)(config),
21
25
  FormatNumber: (0, format_number_1.createFormatNumberComponent)(config),
22
26
  FormatPercentage: (0, format_percentage_1.createFormatPercentageComponent)(config),
23
27
  FormatMoney: (0, format_money_1.createFormatMoneyComponent)(config),
24
28
  useFormatDateTime: (0, format_datetime_2.createUseFormatDatetime)(config),
29
+ useFormatTime: (0, format_time_2.createUseFormatTime)(config),
25
30
  useFormatNumber: (0, format_number_2.createUseFormatNumber)(config),
26
31
  useFormatPercentage: (0, format_percentage_2.createUseFormatPercentage)(config),
27
32
  useFormatMoney: (0, format_money_2.createUseFormatMoney)(config),
package/src/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { DateValue } from "@uxf/core/date";
1
+ import { DateValue, type TimeString } from "@uxf/core/date";
2
2
  import { Currency as CoreCurrency, Money as CoreMoney } from "@uxf/core/money";
3
3
  import { FC, Provider } from "react";
4
4
  import { TimeZone as CoreTimeZone } from "./utils/time-zone";
@@ -47,7 +47,14 @@ export type FormatDatetimeComponent<DT extends string> = FC<{
47
47
  format: DT;
48
48
  timeZone?: TimeZone;
49
49
  }>;
50
- export type LocalizeConfig<DT extends string> = {
50
+ export type Times = "short" | "long";
51
+ export type FormatTimeFunction<T extends string, Locales extends string> = (locale: Locales, value: TimeString, format: T) => string;
52
+ export type UseFormatTimeFunction<T extends string> = () => (value: TimeString, format: T) => string;
53
+ export type FormatTimeComponent<T extends string> = FC<{
54
+ value: TimeString;
55
+ format: T;
56
+ }>;
57
+ export type LocalizeConfig<DT extends string, T extends string> = {
51
58
  number: {
52
59
  thousandsSeparator: string;
53
60
  decimalSeparator: string;
@@ -58,13 +65,14 @@ export type LocalizeConfig<DT extends string> = {
58
65
  decimalSeparator: string;
59
66
  };
60
67
  dateTime: Record<DT, string>;
68
+ time: Record<T, string>;
61
69
  };
62
- export type LocalizeConfigMap<DT extends string = DateTimes, Locales extends string = string> = Record<Locales, LocalizeConfig<DT>>;
70
+ export type LocalizeConfigMap<DT extends string = DateTimes, T extends string = Times, Locales extends string = string> = Record<Locales, LocalizeConfig<DT, T>>;
63
71
  export type LocalizeProviderType = Provider<string>;
64
- export type UseLocaleConfigType<DT extends string> = () => LocalizeConfig<DT>;
65
- export type CreateLocalizeReturn<DT extends string, Locales extends string> = {
72
+ export type UseLocaleConfigType<DT extends string, T extends string> = () => LocalizeConfig<DT, T>;
73
+ export type CreateLocalizeReturn<DT extends string, T extends string, Locales extends string> = {
66
74
  LocalizeProvider: LocalizeProviderType;
67
- useLocaleConfig: UseLocaleConfigType<DT>;
75
+ useLocaleConfig: UseLocaleConfigType<DT, T>;
68
76
  formatNumber: FormatNumberFunction<Locales>;
69
77
  useFormatNumber: UseFormatNumberFunction;
70
78
  FormatNumber: FormatNumberComponent;
@@ -77,5 +85,8 @@ export type CreateLocalizeReturn<DT extends string, Locales extends string> = {
77
85
  formatDateTime: FormatDatetimeFunction<DT, Locales>;
78
86
  useFormatDateTime: UseFormatDatetimeFunction<DT>;
79
87
  FormatDateTime: FormatDatetimeComponent<DT>;
88
+ formatTime: FormatTimeFunction<T, Locales>;
89
+ useFormatTime: UseFormatTimeFunction<T>;
90
+ FormatTime: FormatTimeComponent<T>;
80
91
  };
81
92
  export type TimeZone = CoreTimeZone;
@@ -1,3 +1,3 @@
1
1
  import currencyjs from "currency.js";
2
- import { DateTimes, LocalizeConfig } from "../types";
3
- export declare const _mapOptions: (options: LocalizeConfig<DateTimes>["number"]) => currencyjs.Options;
2
+ import { DateTimes, LocalizeConfig, type Times } from "../types";
3
+ export declare const _mapOptions: (options: LocalizeConfig<DateTimes, Times>["number"]) => currencyjs.Options;