@busiverse/ui 0.2.4 → 0.2.5

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.
@@ -0,0 +1,101 @@
1
+ import {
2
+ cn
3
+ } from "./chunk-PYZVP4NI.js";
4
+
5
+ // src/i18n/format.ts
6
+ function formatCurrency(amount, region, options) {
7
+ return new Intl.NumberFormat(region.locale, { style: "currency", currency: region.currencyCode, ...options }).format(amount);
8
+ }
9
+ function formatNumber(value, locale = "en-NG", options) {
10
+ return new Intl.NumberFormat(locale, options).format(value);
11
+ }
12
+ function formatDate(value, region, options) {
13
+ return new Intl.DateTimeFormat(region.locale, { timeZone: region.timeZone, dateStyle: "medium", timeStyle: "short", ...options }).format(new Date(value));
14
+ }
15
+ function toRegionHeaders(region) {
16
+ return {
17
+ "Accept-Language": region.locale,
18
+ "X-Busiverse-Country": region.countryCode,
19
+ "X-Busiverse-Region": region.regionCode ?? region.countryCode,
20
+ "X-Busiverse-Currency": region.currencyCode,
21
+ "X-Busiverse-Timezone": region.timeZone
22
+ };
23
+ }
24
+
25
+ // src/pricing/regions.ts
26
+ var busiverseSupportedRegions = [
27
+ { label: "Nigeria", locale: "en-NG", countryCode: "NG", regionCode: "NG-LA", currencyCode: "NGN", timeZone: "Africa/Lagos", exchangeRateFromUsd: 1500, pricingNote: "NGN display estimate; Account will apply Mint/Location live rules." },
28
+ { label: "United States", locale: "en-US", countryCode: "US", regionCode: "US", currencyCode: "USD", timeZone: "America/New_York", exchangeRateFromUsd: 1 },
29
+ { label: "United Kingdom", locale: "en-GB", countryCode: "GB", regionCode: "GB", currencyCode: "GBP", timeZone: "Europe/London", exchangeRateFromUsd: 0.79 },
30
+ { label: "European Union", locale: "en-IE", countryCode: "IE", regionCode: "EU", currencyCode: "EUR", timeZone: "Europe/Dublin", exchangeRateFromUsd: 0.93 },
31
+ { label: "Ghana", locale: "en-GH", countryCode: "GH", regionCode: "GH", currencyCode: "GHS", timeZone: "Africa/Accra", exchangeRateFromUsd: 15 },
32
+ { label: "Kenya", locale: "en-KE", countryCode: "KE", regionCode: "KE", currencyCode: "KES", timeZone: "Africa/Nairobi", exchangeRateFromUsd: 130 },
33
+ { label: "South Africa", locale: "en-ZA", countryCode: "ZA", regionCode: "ZA", currencyCode: "ZAR", timeZone: "Africa/Johannesburg", exchangeRateFromUsd: 18 },
34
+ { label: "United Arab Emirates", locale: "en-AE", countryCode: "AE", regionCode: "AE", currencyCode: "AED", timeZone: "Asia/Dubai", exchangeRateFromUsd: 3.67 },
35
+ { label: "India", locale: "en-IN", countryCode: "IN", regionCode: "IN", currencyCode: "INR", timeZone: "Asia/Kolkata", exchangeRateFromUsd: 83 }
36
+ ];
37
+ function getSupportedRegion(countryCode) {
38
+ return busiverseSupportedRegions.find((region) => region.countryCode === countryCode) ?? busiverseSupportedRegions[0];
39
+ }
40
+
41
+ // src/i18n/BusiverseI18nProvider.tsx
42
+ import * as React from "react";
43
+ import { jsx } from "react/jsx-runtime";
44
+ var defaultRegion = {
45
+ locale: "en-NG",
46
+ countryCode: "NG",
47
+ regionCode: "NG-LA",
48
+ currencyCode: "NGN",
49
+ timeZone: "Africa/Lagos"
50
+ };
51
+ var I18nContext = React.createContext(null);
52
+ function BusiverseI18nProvider({ children, initialRegion, bundles = {} }) {
53
+ const [region, setRegion] = React.useState({ ...defaultRegion, ...initialRegion });
54
+ const t = React.useCallback((key, fallback, vars) => {
55
+ const value = bundles[region.locale]?.[key] ?? bundles[region.locale.split("-")[0]]?.[key] ?? fallback ?? key;
56
+ if (!vars) return value;
57
+ return Object.entries(vars).reduce((acc, [name, val]) => acc.replaceAll(`{${name}}`, String(val)), value);
58
+ }, [bundles, region.locale]);
59
+ return /* @__PURE__ */ jsx(I18nContext.Provider, { value: { region, bundles, setRegion, t }, children });
60
+ }
61
+ function useBusiverseI18n() {
62
+ const ctx = React.useContext(I18nContext);
63
+ if (!ctx) throw new Error("useBusiverseI18n must be used inside BusiverseI18nProvider");
64
+ return ctx;
65
+ }
66
+
67
+ // src/i18n/RegionSelector.tsx
68
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
69
+ function RegionSelector({ regions = busiverseSupportedRegions, label = "Pricing region", className }) {
70
+ const { region, setRegion } = useBusiverseI18n();
71
+ return /* @__PURE__ */ jsxs("label", { className: cn("busiverse-region-selector", className), children: [
72
+ /* @__PURE__ */ jsx2("span", { children: label }),
73
+ /* @__PURE__ */ jsx2(
74
+ "select",
75
+ {
76
+ value: region.countryCode,
77
+ onChange: (event) => {
78
+ const next = regions.find((item) => item.countryCode === event.target.value) ?? regions[0];
79
+ setRegion(next);
80
+ },
81
+ children: regions.map((item) => /* @__PURE__ */ jsxs("option", { value: item.countryCode, children: [
82
+ item.label,
83
+ " \xB7 ",
84
+ item.currencyCode
85
+ ] }, item.countryCode))
86
+ }
87
+ )
88
+ ] });
89
+ }
90
+
91
+ export {
92
+ formatCurrency,
93
+ formatNumber,
94
+ formatDate,
95
+ toRegionHeaders,
96
+ busiverseSupportedRegions,
97
+ getSupportedRegion,
98
+ BusiverseI18nProvider,
99
+ useBusiverseI18n,
100
+ RegionSelector
101
+ };
@@ -0,0 +1,12 @@
1
+ import {
2
+ CurrencyAmount,
3
+ ServicePricingExplorer,
4
+ UsageQuotaBar
5
+ } from "../../chunk-UU2CXC3N.js";
6
+ import "../../chunk-WDOMYE77.js";
7
+ import "../../chunk-PYZVP4NI.js";
8
+ export {
9
+ CurrencyAmount,
10
+ ServicePricingExplorer,
11
+ UsageQuotaBar
12
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"BusiverseBrandHead.d.ts","sourceRoot":"","sources":["../../../src/components/brand/BusiverseBrandHead.tsx"],"names":[],"mappings":"AAGA,MAAM,WAAW,uBAAuB;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AA6CD,wBAAgB,uBAAuB,CAAC,EACtC,KAAqB,EACrB,WAAiC,EACjC,QAAsB,EACtB,GAAG,EACH,KAAsC,EACtC,WAA2B,EAC3B,QAA8H,EAC9H,MAAgB,EAChB,UAAgC,EAChC,sBAAoC,EACpC,eAA6B,GAC9B,GAAE,uBAA4B,QAgC9B;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,QAkBhE"}
1
+ {"version":3,"file":"BusiverseBrandHead.d.ts","sourceRoot":"","sources":["../../../src/components/brand/BusiverseBrandHead.tsx"],"names":[],"mappings":"AAaA,MAAM,WAAW,uBAAuB;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AA6CD,wBAAgB,uBAAuB,CAAC,EACtC,KAAqB,EACrB,WAAiC,EACjC,QAAsB,EACtB,GAAG,EACH,KAA0B,EAC1B,WAA2B,EAC3B,QAA8H,EAC9H,MAAgB,EAChB,UAAgC,EAChC,sBAAoC,EACpC,eAA6B,GAC9B,GAAE,uBAA4B,QAgC9B;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,QAkBhE"}
@@ -0,0 +1,11 @@
1
+ import {
2
+ BusiverseBrandHead,
3
+ BusiverseLogo,
4
+ applyBusiverseBrandHead
5
+ } from "../../chunk-PTOKOI4Q.js";
6
+ import "../../chunk-PYZVP4NI.js";
7
+ export {
8
+ BusiverseBrandHead,
9
+ BusiverseLogo,
10
+ applyBusiverseBrandHead
11
+ };
@@ -0,0 +1,15 @@
1
+ import {
2
+ BusiverseGithubIcon,
3
+ BusiverseLinkedInIcon,
4
+ BusiverseMailIcon,
5
+ BusiverseSocialIcon,
6
+ BusiverseXIcon
7
+ } from "../../chunk-2TTXWTIT.js";
8
+ import "../../chunk-PYZVP4NI.js";
9
+ export {
10
+ BusiverseGithubIcon,
11
+ BusiverseLinkedInIcon,
12
+ BusiverseMailIcon,
13
+ BusiverseSocialIcon,
14
+ BusiverseXIcon
15
+ };
@@ -0,0 +1,20 @@
1
+ import "../chunk-NZ65VTKR.js";
2
+ import {
3
+ BusiverseI18nProvider,
4
+ RegionSelector,
5
+ formatCurrency,
6
+ formatDate,
7
+ formatNumber,
8
+ toRegionHeaders,
9
+ useBusiverseI18n
10
+ } from "../chunk-WDOMYE77.js";
11
+ import "../chunk-PYZVP4NI.js";
12
+ export {
13
+ BusiverseI18nProvider,
14
+ RegionSelector,
15
+ formatCurrency,
16
+ formatDate,
17
+ formatNumber,
18
+ toRegionHeaders,
19
+ useBusiverseI18n
20
+ };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export * from "./tokens";
2
- export * from "./assets/assets";
3
2
  export * from "./components";
4
3
  export * from "./registry/services";
5
4
  export * from "./pricing";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC"}