@heigin/ui 0.0.0-stage → 0.1.1

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.
Files changed (124) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/LICENSE +15 -0
  3. package/README.md +28 -2
  4. package/dist/base.css +44 -0
  5. package/dist/components/crm/activity-timeline.d.ts +23 -0
  6. package/dist/components/crm/activity-timeline.js +41 -0
  7. package/dist/components/crm/approval-card.d.ts +33 -0
  8. package/dist/components/crm/approval-card.js +101 -0
  9. package/dist/components/crm/channel-mark.d.ts +10 -0
  10. package/dist/components/crm/channel-mark.js +57 -0
  11. package/dist/components/crm/conversation-list-item.d.ts +23 -0
  12. package/dist/components/crm/conversation-list-item.js +62 -0
  13. package/dist/components/crm/crm.module.js +161 -0
  14. package/dist/components/crm/deal-stage.d.ts +13 -0
  15. package/dist/components/crm/deal-stage.js +27 -0
  16. package/dist/components/crm/detail-list.d.ts +17 -0
  17. package/dist/components/crm/detail-list.js +35 -0
  18. package/dist/components/crm/filter-chip.d.ts +16 -0
  19. package/dist/components/crm/filter-chip.js +45 -0
  20. package/dist/components/crm/filter-toolbar.d.ts +16 -0
  21. package/dist/components/crm/filter-toolbar.js +42 -0
  22. package/dist/components/crm/metric-card.d.ts +30 -0
  23. package/dist/components/crm/metric-card.js +61 -0
  24. package/dist/components/crm/money-value.d.ts +9 -0
  25. package/dist/components/crm/money-value.js +27 -0
  26. package/dist/components/crm/page-header.d.ts +11 -0
  27. package/dist/components/crm/page-header.js +28 -0
  28. package/dist/components/crm/record-header.d.ts +22 -0
  29. package/dist/components/crm/record-header.js +53 -0
  30. package/dist/components/crm/sidebar-nav.d.ts +33 -0
  31. package/dist/components/crm/sidebar-nav.js +53 -0
  32. package/dist/components/crm/sla-clock.d.ts +11 -0
  33. package/dist/components/crm/sla-clock.js +41 -0
  34. package/dist/components/crm/status-badge.d.ts +94 -0
  35. package/dist/components/crm/status-badge.js +106 -0
  36. package/dist/components/crm/task-row.d.ts +18 -0
  37. package/dist/components/crm/task-row.js +52 -0
  38. package/dist/components/crm/trust-rung-badge.d.ts +14 -0
  39. package/dist/components/crm/trust-rung-badge.js +35 -0
  40. package/dist/components/ui/alert-dialog.d.ts +22 -0
  41. package/dist/components/ui/alert-dialog.js +87 -0
  42. package/dist/components/ui/avatar.d.ts +13 -0
  43. package/dist/components/ui/avatar.js +38 -0
  44. package/dist/components/ui/avatar.module.js +17 -0
  45. package/dist/components/ui/badge.d.ts +12 -0
  46. package/dist/components/ui/badge.js +28 -0
  47. package/dist/components/ui/badge.module.js +25 -0
  48. package/dist/components/ui/button.d.ts +19 -0
  49. package/dist/components/ui/button.js +39 -0
  50. package/dist/components/ui/button.module.js +27 -0
  51. package/dist/components/ui/card.d.ts +19 -0
  52. package/dist/components/ui/card.js +35 -0
  53. package/dist/components/ui/card.module.js +23 -0
  54. package/dist/components/ui/checkbox.d.ts +11 -0
  55. package/dist/components/ui/checkbox.js +47 -0
  56. package/dist/components/ui/choice.module.js +28 -0
  57. package/dist/components/ui/dialog.d.ts +32 -0
  58. package/dist/components/ui/dialog.js +67 -0
  59. package/dist/components/ui/dialog.module.js +39 -0
  60. package/dist/components/ui/drawer.d.ts +20 -0
  61. package/dist/components/ui/drawer.js +44 -0
  62. package/dist/components/ui/dropdown-menu.d.ts +38 -0
  63. package/dist/components/ui/dropdown-menu.js +66 -0
  64. package/dist/components/ui/empty-state.d.ts +12 -0
  65. package/dist/components/ui/empty-state.js +33 -0
  66. package/dist/components/ui/empty-state.module.js +19 -0
  67. package/dist/components/ui/field.d.ts +38 -0
  68. package/dist/components/ui/field.js +77 -0
  69. package/dist/components/ui/field.module.js +17 -0
  70. package/dist/components/ui/icon-button.d.ts +9 -0
  71. package/dist/components/ui/icon-button.js +21 -0
  72. package/dist/components/ui/input.d.ts +8 -0
  73. package/dist/components/ui/input.js +23 -0
  74. package/dist/components/ui/input.module.js +25 -0
  75. package/dist/components/ui/kbd.d.ts +3 -0
  76. package/dist/components/ui/kbd.js +34 -0
  77. package/dist/components/ui/native-select.d.ts +10 -0
  78. package/dist/components/ui/native-select.js +26 -0
  79. package/dist/components/ui/pagination.d.ts +12 -0
  80. package/dist/components/ui/pagination.js +54 -0
  81. package/dist/components/ui/popover.d.ts +17 -0
  82. package/dist/components/ui/popover.js +41 -0
  83. package/dist/components/ui/popup.module.js +39 -0
  84. package/dist/components/ui/radio-group.d.ts +18 -0
  85. package/dist/components/ui/radio-group.js +50 -0
  86. package/dist/components/ui/search-input.d.ts +15 -0
  87. package/dist/components/ui/search-input.js +64 -0
  88. package/dist/components/ui/select.d.ts +27 -0
  89. package/dist/components/ui/select.js +71 -0
  90. package/dist/components/ui/skeleton.d.ts +12 -0
  91. package/dist/components/ui/skeleton.js +23 -0
  92. package/dist/components/ui/skeleton.module.js +15 -0
  93. package/dist/components/ui/spinner.d.ts +8 -0
  94. package/dist/components/ui/spinner.js +19 -0
  95. package/dist/components/ui/spinner.module.js +13 -0
  96. package/dist/components/ui/switch.d.ts +10 -0
  97. package/dist/components/ui/switch.js +35 -0
  98. package/dist/components/ui/table.d.ts +52 -0
  99. package/dist/components/ui/table.js +143 -0
  100. package/dist/components/ui/table.module.js +42 -0
  101. package/dist/components/ui/tabs.d.ts +25 -0
  102. package/dist/components/ui/tabs.js +47 -0
  103. package/dist/components/ui/tabs.module.js +21 -0
  104. package/dist/components/ui/textarea.d.ts +6 -0
  105. package/dist/components/ui/textarea.js +23 -0
  106. package/dist/components/ui/toast.d.ts +30 -0
  107. package/dist/components/ui/toast.js +81 -0
  108. package/dist/components/ui/toast.module.js +21 -0
  109. package/dist/components/ui/tooltip.d.ts +18 -0
  110. package/dist/components/ui/tooltip.js +30 -0
  111. package/dist/components/ui/visually-hidden.d.ts +3 -0
  112. package/dist/components/ui/visually-hidden.js +26 -0
  113. package/dist/index.d.ts +48 -0
  114. package/dist/index.js +50 -0
  115. package/dist/lib/cn.d.ts +2 -0
  116. package/dist/lib/cn.js +7 -0
  117. package/dist/lib/format.d.ts +6 -0
  118. package/dist/lib/format.js +33 -0
  119. package/dist/styles.css +2317 -0
  120. package/dist/tailwind.css +82 -0
  121. package/dist/tokens.css +131 -0
  122. package/dist/tokens.d.ts +339 -0
  123. package/dist/tokens.js +791 -0
  124. package/package.json +54 -4
@@ -0,0 +1,81 @@
1
+ "use client";
2
+ "use client";
3
+ import { cn } from "../../lib/cn.js";
4
+ import toast_module_default from "./toast.module.js";
5
+ import * as React from "react";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ import { CircleCheck, CircleX, Info, TriangleAlert, X } from "lucide-react";
8
+ import { Toast } from "@base-ui/react/toast";
9
+ //#region src/components/ui/toast.tsx
10
+ var toneIcon = {
11
+ neutral: null,
12
+ success: CircleCheck,
13
+ warning: TriangleAlert,
14
+ danger: CircleX,
15
+ info: Info
16
+ };
17
+ /**
18
+ * Returns `toast(options)` and `dismiss(id?)`. Must be used inside `ToastProvider`.
19
+ * Danger toasts are announced assertively; others politely.
20
+ */
21
+ function useToast() {
22
+ const manager = Toast.useToastManager();
23
+ return {
24
+ toast: React.useCallback(({ title, description, tone = "neutral", timeout = 5e3, action }) => manager.add({
25
+ title,
26
+ description,
27
+ type: tone,
28
+ timeout,
29
+ priority: tone === "danger" ? "high" : "low",
30
+ actionProps: action ? {
31
+ children: action.label,
32
+ onClick: action.onClick
33
+ } : void 0
34
+ }), [manager]),
35
+ dismiss: manager.close
36
+ };
37
+ }
38
+ function ToastList({ closeLabel }) {
39
+ const { toasts } = Toast.useToastManager();
40
+ return toasts.map((t) => {
41
+ const tone = t.type ?? "neutral";
42
+ const Icon = toneIcon[tone] ?? null;
43
+ return /* @__PURE__ */ jsxs(Toast.Root, {
44
+ toast: t,
45
+ className: cn(toast_module_default.toast),
46
+ "data-tone": tone,
47
+ children: [
48
+ Icon && /* @__PURE__ */ jsx("span", {
49
+ className: toast_module_default.icon,
50
+ "aria-hidden": "true",
51
+ children: /* @__PURE__ */ jsx(Icon, { strokeWidth: 1.6 })
52
+ }),
53
+ /* @__PURE__ */ jsxs("div", {
54
+ className: toast_module_default.content,
55
+ children: [/* @__PURE__ */ jsx(Toast.Title, { className: toast_module_default.title }), /* @__PURE__ */ jsx(Toast.Description, { className: toast_module_default.description })]
56
+ }),
57
+ t.actionProps && /* @__PURE__ */ jsx(Toast.Action, { className: toast_module_default.action }),
58
+ /* @__PURE__ */ jsx(Toast.Close, {
59
+ className: toast_module_default.close,
60
+ "aria-label": closeLabel,
61
+ children: /* @__PURE__ */ jsx(X, {
62
+ strokeWidth: 1.6,
63
+ "aria-hidden": "true"
64
+ })
65
+ })
66
+ ]
67
+ }, t.id);
68
+ });
69
+ }
70
+ /** Mount once near the app root. Renders the toast viewport (bottom-right; bottom-centre on mobile). */
71
+ function ToastProvider({ children, limit = 3, closeLabel = "Dismiss notification" }) {
72
+ return /* @__PURE__ */ jsxs(Toast.Provider, {
73
+ limit,
74
+ children: [children, /* @__PURE__ */ jsx(Toast.Portal, { children: /* @__PURE__ */ jsx(Toast.Viewport, {
75
+ className: toast_module_default.viewport,
76
+ children: /* @__PURE__ */ jsx(ToastList, { closeLabel })
77
+ }) })]
78
+ });
79
+ }
80
+ //#endregion
81
+ export { ToastProvider, useToast };
@@ -0,0 +1,21 @@
1
+ //#region src/components/ui/toast.module.css
2
+ var viewport = "hg-toast-module_viewport_roFpT";
3
+ var toast = "hg-toast-module_toast_-dJxM";
4
+ var icon = "hg-toast-module_icon_-CH-S";
5
+ var content = "hg-toast-module_content_wplKO";
6
+ var title = "hg-toast-module_title_NwvAf";
7
+ var description = "hg-toast-module_description_QUica";
8
+ var action = "hg-toast-module_action_cH0cn";
9
+ var close = "hg-toast-module_close_qxk1P";
10
+ var toast_module_default = {
11
+ viewport,
12
+ toast,
13
+ icon,
14
+ content,
15
+ title,
16
+ description,
17
+ action,
18
+ close
19
+ };
20
+ //#endregion
21
+ export { action, close, content, toast_module_default as default, description, icon, title, toast, viewport };
@@ -0,0 +1,18 @@
1
+ import * as React from "react";
2
+ export interface TooltipProps {
3
+ /** Tooltip text. Keep it short; never put essential or interactive content in a tooltip. */
4
+ content: React.ReactNode;
5
+ /** The trigger. Must be a single focusable element that accepts a ref (e.g. Button, IconButton). */
6
+ children: React.ReactElement;
7
+ side?: "top" | "bottom" | "left" | "right";
8
+ /** Delay before showing, in ms. */
9
+ delay?: number;
10
+ className?: string;
11
+ }
12
+ /**
13
+ * Supplementary label shown on hover and keyboard focus. Escape dismisses it.
14
+ * Wrap the app (or a region) in `TooltipProvider` to share delays between adjacent tooltips.
15
+ */
16
+ export declare function Tooltip({ content, children, side, delay, className }: TooltipProps): React.JSX.Element;
17
+ /** Optional provider that lets adjacent tooltips open instantly after the first one. */
18
+ export declare const TooltipProvider: React.FC<import("@base-ui/react").TooltipProviderProps>;
@@ -0,0 +1,30 @@
1
+ "use client";
2
+ "use client";
3
+ import { cn } from "../../lib/cn.js";
4
+ import popup_module_default from "./popup.module.js";
5
+ import "react";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ import { Tooltip } from "@base-ui/react/tooltip";
8
+ //#region src/components/ui/tooltip.tsx
9
+ /**
10
+ * Supplementary label shown on hover and keyboard focus. Escape dismisses it.
11
+ * Wrap the app (or a region) in `TooltipProvider` to share delays between adjacent tooltips.
12
+ */
13
+ function Tooltip$1({ content, children, side = "top", delay = 400, className }) {
14
+ return /* @__PURE__ */ jsxs(Tooltip.Root, { children: [/* @__PURE__ */ jsx(Tooltip.Trigger, {
15
+ delay,
16
+ render: children
17
+ }), /* @__PURE__ */ jsx(Tooltip.Portal, { children: /* @__PURE__ */ jsx(Tooltip.Positioner, {
18
+ className: popup_module_default.tooltipPositioner,
19
+ side,
20
+ sideOffset: 6,
21
+ children: /* @__PURE__ */ jsx(Tooltip.Popup, {
22
+ className: cn(popup_module_default.tooltip, className),
23
+ children: content
24
+ })
25
+ }) })] });
26
+ }
27
+ /** Optional provider that lets adjacent tooltips open instantly after the first one. */
28
+ var TooltipProvider = Tooltip.Provider;
29
+ //#endregion
30
+ export { Tooltip$1 as Tooltip, TooltipProvider };
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ /** Hides content visually while keeping it available to screen readers. */
3
+ export declare function VisuallyHidden({ style, ...props }: React.HTMLAttributes<HTMLSpanElement>): React.JSX.Element;
@@ -0,0 +1,26 @@
1
+ import "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+ //#region src/components/ui/visually-hidden.tsx
4
+ var hiddenStyle = {
5
+ position: "absolute",
6
+ width: 1,
7
+ height: 1,
8
+ padding: 0,
9
+ margin: -1,
10
+ overflow: "hidden",
11
+ clip: "rect(0, 0, 0, 0)",
12
+ whiteSpace: "nowrap",
13
+ border: 0
14
+ };
15
+ /** Hides content visually while keeping it available to screen readers. */
16
+ function VisuallyHidden({ style, ...props }) {
17
+ return /* @__PURE__ */ jsx("span", {
18
+ style: {
19
+ ...hiddenStyle,
20
+ ...style
21
+ },
22
+ ...props
23
+ });
24
+ }
25
+ //#endregion
26
+ export { VisuallyHidden };
@@ -0,0 +1,48 @@
1
+ export { cn } from "./lib/cn.js";
2
+ export * from "./components/ui/button.js";
3
+ export * from "./components/ui/icon-button.js";
4
+ export * from "./components/ui/field.js";
5
+ export * from "./components/ui/input.js";
6
+ export * from "./components/ui/textarea.js";
7
+ export * from "./components/ui/search-input.js";
8
+ export * from "./components/ui/select.js";
9
+ export * from "./components/ui/native-select.js";
10
+ export * from "./components/ui/checkbox.js";
11
+ export * from "./components/ui/radio-group.js";
12
+ export * from "./components/ui/switch.js";
13
+ export * from "./components/ui/tabs.js";
14
+ export * from "./components/ui/dropdown-menu.js";
15
+ export * from "./components/ui/pagination.js";
16
+ export * from "./components/ui/avatar.js";
17
+ export * from "./components/ui/badge.js";
18
+ export * from "./components/ui/card.js";
19
+ export * from "./components/ui/empty-state.js";
20
+ export * from "./components/ui/kbd.js";
21
+ export * from "./components/ui/skeleton.js";
22
+ export * from "./components/ui/spinner.js";
23
+ export * from "./components/ui/table.js";
24
+ export * from "./components/ui/visually-hidden.js";
25
+ export * from "./components/ui/alert-dialog.js";
26
+ export * from "./components/ui/dialog.js";
27
+ export * from "./components/ui/drawer.js";
28
+ export * from "./components/ui/popover.js";
29
+ export * from "./components/ui/toast.js";
30
+ export * from "./components/ui/tooltip.js";
31
+ export * from "./lib/format.js";
32
+ export * from "./components/crm/activity-timeline.js";
33
+ export * from "./components/crm/approval-card.js";
34
+ export * from "./components/crm/channel-mark.js";
35
+ export * from "./components/crm/conversation-list-item.js";
36
+ export * from "./components/crm/deal-stage.js";
37
+ export * from "./components/crm/detail-list.js";
38
+ export * from "./components/crm/filter-chip.js";
39
+ export * from "./components/crm/filter-toolbar.js";
40
+ export * from "./components/crm/metric-card.js";
41
+ export * from "./components/crm/money-value.js";
42
+ export * from "./components/crm/page-header.js";
43
+ export * from "./components/crm/record-header.js";
44
+ export * from "./components/crm/sidebar-nav.js";
45
+ export * from "./components/crm/sla-clock.js";
46
+ export * from "./components/crm/status-badge.js";
47
+ export * from "./components/crm/task-row.js";
48
+ export * from "./components/crm/trust-rung-badge.js";
package/dist/index.js ADDED
@@ -0,0 +1,50 @@
1
+ /* empty css */
2
+ import { cn } from "./lib/cn.js";
3
+ import { Spinner } from "./components/ui/spinner.js";
4
+ import { Button } from "./components/ui/button.js";
5
+ import { IconButton } from "./components/ui/icon-button.js";
6
+ import { Field, useField, useFieldControlProps } from "./components/ui/field.js";
7
+ import { Input } from "./components/ui/input.js";
8
+ import { Textarea } from "./components/ui/textarea.js";
9
+ import { SearchInput } from "./components/ui/search-input.js";
10
+ import { Select } from "./components/ui/select.js";
11
+ import { NativeSelect } from "./components/ui/native-select.js";
12
+ import { Checkbox } from "./components/ui/checkbox.js";
13
+ import { RadioGroup } from "./components/ui/radio-group.js";
14
+ import { Switch } from "./components/ui/switch.js";
15
+ import { Tab, Tabs, TabsList, TabsPanel } from "./components/ui/tabs.js";
16
+ import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from "./components/ui/dropdown-menu.js";
17
+ import { Pagination } from "./components/ui/pagination.js";
18
+ import { Avatar, getInitials } from "./components/ui/avatar.js";
19
+ import { Badge } from "./components/ui/badge.js";
20
+ import { Card, CardHeader } from "./components/ui/card.js";
21
+ import { EmptyState } from "./components/ui/empty-state.js";
22
+ import { Kbd } from "./components/ui/kbd.js";
23
+ import { Skeleton } from "./components/ui/skeleton.js";
24
+ import { Table } from "./components/ui/table.js";
25
+ import { VisuallyHidden } from "./components/ui/visually-hidden.js";
26
+ import { AlertDialog } from "./components/ui/alert-dialog.js";
27
+ import { Dialog, DialogClose, DialogContent, DialogHeader, DialogTrigger } from "./components/ui/dialog.js";
28
+ import { Drawer, DrawerClose, DrawerContent, DrawerTrigger } from "./components/ui/drawer.js";
29
+ import { Popover, PopoverClose, PopoverContent, PopoverTrigger } from "./components/ui/popover.js";
30
+ import { ToastProvider, useToast } from "./components/ui/toast.js";
31
+ import { Tooltip, TooltipProvider } from "./components/ui/tooltip.js";
32
+ import { formatINR, formatINRCompact, formatNumber } from "./lib/format.js";
33
+ import { ActivityItem, ActivityTimeline } from "./components/crm/activity-timeline.js";
34
+ import { TRUST_RUNGS, TrustRungBadge } from "./components/crm/trust-rung-badge.js";
35
+ import { ApprovalCard } from "./components/crm/approval-card.js";
36
+ import { ChannelMark } from "./components/crm/channel-mark.js";
37
+ import { ConversationListItem } from "./components/crm/conversation-list-item.js";
38
+ import { DealStage } from "./components/crm/deal-stage.js";
39
+ import { DetailList } from "./components/crm/detail-list.js";
40
+ import { FilterChip } from "./components/crm/filter-chip.js";
41
+ import { FilterToolbar } from "./components/crm/filter-toolbar.js";
42
+ import { MetricCard, MetricGroup } from "./components/crm/metric-card.js";
43
+ import { MoneyValue } from "./components/crm/money-value.js";
44
+ import { PageHeader } from "./components/crm/page-header.js";
45
+ import { RecordHeader } from "./components/crm/record-header.js";
46
+ import { SidebarNav } from "./components/crm/sidebar-nav.js";
47
+ import { SLAClock } from "./components/crm/sla-clock.js";
48
+ import { STATUS_REGISTRY, StatusBadge } from "./components/crm/status-badge.js";
49
+ import { TaskRow } from "./components/crm/task-row.js";
50
+ export { ActivityItem, ActivityTimeline, AlertDialog, ApprovalCard, Avatar, Badge, Button, Card, CardHeader, ChannelMark, Checkbox, ConversationListItem, DealStage, DetailList, Dialog, DialogClose, DialogContent, DialogHeader, DialogTrigger, Drawer, DrawerClose, DrawerContent, DrawerTrigger, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, EmptyState, Field, FilterChip, FilterToolbar, IconButton, Input, Kbd, MetricCard, MetricGroup, MoneyValue, NativeSelect, PageHeader, Pagination, Popover, PopoverClose, PopoverContent, PopoverTrigger, RadioGroup, RecordHeader, SLAClock, STATUS_REGISTRY, SearchInput, Select, SidebarNav, Skeleton, Spinner, StatusBadge, Switch, TRUST_RUNGS, Tab, Table, Tabs, TabsList, TabsPanel, TaskRow, Textarea, ToastProvider, Tooltip, TooltipProvider, TrustRungBadge, VisuallyHidden, cn, formatINR, formatINRCompact, formatNumber, getInitials, useField, useFieldControlProps, useToast };
@@ -0,0 +1,2 @@
1
+ /** Joins class names, skipping falsy values. Dependency-free stand-in for clsx. */
2
+ export declare function cn(...parts: Array<string | false | null | undefined>): string;
package/dist/lib/cn.js ADDED
@@ -0,0 +1,7 @@
1
+ //#region src/lib/cn.ts
2
+ /** Joins class names, skipping falsy values. Dependency-free stand-in for clsx. */
3
+ function cn(...parts) {
4
+ return parts.filter(Boolean).join(" ");
5
+ }
6
+ //#endregion
7
+ export { cn };
@@ -0,0 +1,6 @@
1
+ /** ₹8,49,600 (Indian digit grouping). Pass `withPaise` for ₹8,49,600.00. */
2
+ export declare function formatINR(amount: number, withPaise?: boolean): string;
3
+ /** Compact lakh/crore form used in summaries, matching production: ₹8.5L, ₹2.31Cr, ₹64K. */
4
+ export declare function formatINRCompact(amount: number): string;
5
+ /** 1,34,200 */
6
+ export declare function formatNumber(n: number): string;
@@ -0,0 +1,33 @@
1
+ //#region src/lib/format.ts
2
+ var inr0 = new Intl.NumberFormat("en-IN", {
3
+ style: "currency",
4
+ currency: "INR",
5
+ maximumFractionDigits: 0
6
+ });
7
+ var inr2 = new Intl.NumberFormat("en-IN", {
8
+ style: "currency",
9
+ currency: "INR",
10
+ minimumFractionDigits: 2,
11
+ maximumFractionDigits: 2
12
+ });
13
+ var num = new Intl.NumberFormat("en-IN");
14
+ /** ₹8,49,600 (Indian digit grouping). Pass `withPaise` for ₹8,49,600.00. */
15
+ function formatINR(amount, withPaise = false) {
16
+ return (withPaise ? inr2 : inr0).format(amount);
17
+ }
18
+ /** Compact lakh/crore form used in summaries, matching production: ₹8.5L, ₹2.31Cr, ₹64K. */
19
+ function formatINRCompact(amount) {
20
+ const sign = amount < 0 ? "-" : "";
21
+ const abs = Math.abs(amount);
22
+ const trim = (n, digits) => n.toFixed(digits).replace(/\.?0+$/, "");
23
+ if (abs >= 1e7) return `${sign}₹${trim(abs / 1e7, 2)}Cr`;
24
+ if (abs >= 1e5) return `${sign}₹${trim(abs / 1e5, 1)}L`;
25
+ if (abs >= 1e3) return `${sign}₹${trim(abs / 1e3, 1)}K`;
26
+ return `${sign}₹${num.format(abs)}`;
27
+ }
28
+ /** 1,34,200 */
29
+ function formatNumber(n) {
30
+ return num.format(n);
31
+ }
32
+ //#endregion
33
+ export { formatINR, formatINRCompact, formatNumber };