@craftzbay/ui 0.11.2 → 0.11.4
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-lib/_virtual/_rolldown/runtime.js +11 -0
- package/dist-lib/components/ui/Accordion.js +42 -67
- package/dist-lib/components/ui/Accordion.js.map +1 -1
- package/dist-lib/components/ui/Alert.js +71 -77
- package/dist-lib/components/ui/Alert.js.map +1 -1
- package/dist-lib/components/ui/Avatar.js +67 -92
- package/dist-lib/components/ui/Avatar.js.map +1 -1
- package/dist-lib/components/ui/Badge.js +119 -74
- package/dist-lib/components/ui/Badge.js.map +1 -1
- package/dist-lib/components/ui/Breadcrumbs.js +62 -50
- package/dist-lib/components/ui/Breadcrumbs.js.map +1 -1
- package/dist-lib/components/ui/Button.js +129 -127
- package/dist-lib/components/ui/Button.js.map +1 -1
- package/dist-lib/components/ui/Calendar.d.ts +1 -1
- package/dist-lib/components/ui/Calendar.js +99 -136
- package/dist-lib/components/ui/Calendar.js.map +1 -1
- package/dist-lib/components/ui/Card.js +88 -94
- package/dist-lib/components/ui/Card.js.map +1 -1
- package/dist-lib/components/ui/Carousel.js +125 -170
- package/dist-lib/components/ui/Carousel.js.map +1 -1
- package/dist-lib/components/ui/Chart.d.ts +3 -3
- package/dist-lib/components/ui/Chart.js +435 -464
- package/dist-lib/components/ui/Chart.js.map +1 -1
- package/dist-lib/components/ui/Checkbox.js +60 -69
- package/dist-lib/components/ui/Checkbox.js.map +1 -1
- package/dist-lib/components/ui/Combobox.js +179 -192
- package/dist-lib/components/ui/Combobox.js.map +1 -1
- package/dist-lib/components/ui/CommandPalette.d.ts +2 -2
- package/dist-lib/components/ui/CommandPalette.js +106 -167
- package/dist-lib/components/ui/CommandPalette.js.map +1 -1
- package/dist-lib/components/ui/ContextMenu.d.ts +1 -1
- package/dist-lib/components/ui/ContextMenu.js +89 -154
- package/dist-lib/components/ui/ContextMenu.js.map +1 -1
- package/dist-lib/components/ui/DataGrid.d.ts +1 -1
- package/dist-lib/components/ui/DataGrid.js +99 -96
- package/dist-lib/components/ui/DataGrid.js.map +1 -1
- package/dist-lib/components/ui/DatePicker.js +151 -188
- package/dist-lib/components/ui/DatePicker.js.map +1 -1
- package/dist-lib/components/ui/DesignSystemProvider.d.ts +1 -1
- package/dist-lib/components/ui/DesignSystemProvider.js +120 -130
- package/dist-lib/components/ui/DesignSystemProvider.js.map +1 -1
- package/dist-lib/components/ui/Dialog.d.ts +3 -3
- package/dist-lib/components/ui/Dialog.js +108 -156
- package/dist-lib/components/ui/Dialog.js.map +1 -1
- package/dist-lib/components/ui/Drawer.d.ts +3 -3
- package/dist-lib/components/ui/Drawer.js +90 -124
- package/dist-lib/components/ui/Drawer.js.map +1 -1
- package/dist-lib/components/ui/DropdownMenu.d.ts +1 -1
- package/dist-lib/components/ui/DropdownMenu.js +92 -158
- package/dist-lib/components/ui/DropdownMenu.js.map +1 -1
- package/dist-lib/components/ui/EmptyState.js +31 -44
- package/dist-lib/components/ui/EmptyState.js.map +1 -1
- package/dist-lib/components/ui/ErrorState.js +57 -67
- package/dist-lib/components/ui/ErrorState.js.map +1 -1
- package/dist-lib/components/ui/FileUpload.js +113 -107
- package/dist-lib/components/ui/FileUpload.js.map +1 -1
- package/dist-lib/components/ui/Form.d.ts +6 -4
- package/dist-lib/components/ui/Form.js +117 -122
- package/dist-lib/components/ui/Form.js.map +1 -1
- package/dist-lib/components/ui/Icon.d.ts +1 -1
- package/dist-lib/components/ui/Icon.js +30 -29
- package/dist-lib/components/ui/Icon.js.map +1 -1
- package/dist-lib/components/ui/IconButton.js +61 -61
- package/dist-lib/components/ui/IconButton.js.map +1 -1
- package/dist-lib/components/ui/Input.js +133 -156
- package/dist-lib/components/ui/Input.js.map +1 -1
- package/dist-lib/components/ui/Kbd.js +14 -21
- package/dist-lib/components/ui/Kbd.js.map +1 -1
- package/dist-lib/components/ui/MultiSelect.js +176 -208
- package/dist-lib/components/ui/MultiSelect.js.map +1 -1
- package/dist-lib/components/ui/Pagination.js +152 -149
- package/dist-lib/components/ui/Pagination.js.map +1 -1
- package/dist-lib/components/ui/Popover.js +18 -33
- package/dist-lib/components/ui/Popover.js.map +1 -1
- package/dist-lib/components/ui/Progress.js +77 -99
- package/dist-lib/components/ui/Progress.js.map +1 -1
- package/dist-lib/components/ui/RadioGroup.js +51 -80
- package/dist-lib/components/ui/RadioGroup.js.map +1 -1
- package/dist-lib/components/ui/RelativeTime.js +22 -29
- package/dist-lib/components/ui/RelativeTime.js.map +1 -1
- package/dist-lib/components/ui/ScrollArea.js +39 -58
- package/dist-lib/components/ui/ScrollArea.js.map +1 -1
- package/dist-lib/components/ui/Select.js +108 -131
- package/dist-lib/components/ui/Select.js.map +1 -1
- package/dist-lib/components/ui/Separator.js +18 -24
- package/dist-lib/components/ui/Separator.js.map +1 -1
- package/dist-lib/components/ui/Sheet.d.ts +2 -2
- package/dist-lib/components/ui/Sheet.js +77 -129
- package/dist-lib/components/ui/Sheet.js.map +1 -1
- package/dist-lib/components/ui/Sidebar.d.ts +1 -1
- package/dist-lib/components/ui/Sidebar.js +168 -207
- package/dist-lib/components/ui/Sidebar.js.map +1 -1
- package/dist-lib/components/ui/Skeleton.js +17 -27
- package/dist-lib/components/ui/Skeleton.js.map +1 -1
- package/dist-lib/components/ui/Slider.js +45 -62
- package/dist-lib/components/ui/Slider.js.map +1 -1
- package/dist-lib/components/ui/Snackbar.js +75 -55
- package/dist-lib/components/ui/Snackbar.js.map +1 -1
- package/dist-lib/components/ui/Spinner.js +45 -52
- package/dist-lib/components/ui/Spinner.js.map +1 -1
- package/dist-lib/components/ui/Stepper.js +56 -108
- package/dist-lib/components/ui/Stepper.js.map +1 -1
- package/dist-lib/components/ui/Switch.js +46 -79
- package/dist-lib/components/ui/Switch.js.map +1 -1
- package/dist-lib/components/ui/Table.js +108 -169
- package/dist-lib/components/ui/Table.js.map +1 -1
- package/dist-lib/components/ui/Tabs.js +57 -88
- package/dist-lib/components/ui/Tabs.js.map +1 -1
- package/dist-lib/components/ui/TagInput.js +76 -109
- package/dist-lib/components/ui/TagInput.js.map +1 -1
- package/dist-lib/components/ui/Textarea.js +74 -86
- package/dist-lib/components/ui/Textarea.js.map +1 -1
- package/dist-lib/components/ui/Timeline.d.ts +3 -3
- package/dist-lib/components/ui/Timeline.js +61 -49
- package/dist-lib/components/ui/Timeline.js.map +1 -1
- package/dist-lib/components/ui/Toast.d.ts +1 -1
- package/dist-lib/components/ui/Toast.js +136 -150
- package/dist-lib/components/ui/Toast.js.map +1 -1
- package/dist-lib/components/ui/Tooltip.d.ts +2 -2
- package/dist-lib/components/ui/Tooltip.js +35 -56
- package/dist-lib/components/ui/Tooltip.js.map +1 -1
- package/dist-lib/components/ui/TopNav.js +46 -66
- package/dist-lib/components/ui/TopNav.js.map +1 -1
- package/dist-lib/components/ui/Tree.js +134 -168
- package/dist-lib/components/ui/Tree.js.map +1 -1
- package/dist-lib/hooks/use-debounce.js +27 -33
- package/dist-lib/hooks/use-debounce.js.map +1 -1
- package/dist-lib/hooks/use-delayed-loading.js +19 -18
- package/dist-lib/hooks/use-delayed-loading.js.map +1 -1
- package/dist-lib/hooks/use-field-ids.js +14 -16
- package/dist-lib/hooks/use-field-ids.js.map +1 -1
- package/dist-lib/hooks/use-media-query.js +15 -19
- package/dist-lib/hooks/use-media-query.js.map +1 -1
- package/dist-lib/hooks/use-modifier-key.js +20 -15
- package/dist-lib/hooks/use-modifier-key.js.map +1 -1
- package/dist-lib/hooks/use-strings.js +10 -10
- package/dist-lib/hooks/use-strings.js.map +1 -1
- package/dist-lib/hooks/use-toast.js +73 -62
- package/dist-lib/hooks/use-toast.js.map +1 -1
- package/dist-lib/icon.js +2 -6
- package/dist-lib/icons/index.js +166 -163
- package/dist-lib/icons/index.js.map +1 -1
- package/dist-lib/illustrations/index.d.ts +7 -7
- package/dist-lib/illustrations/index.js +255 -106
- package/dist-lib/illustrations/index.js.map +1 -1
- package/dist-lib/index.js +69 -291
- package/dist-lib/lib/cva.js +2 -0
- package/dist-lib/lib/format.js +71 -87
- package/dist-lib/lib/format.js.map +1 -1
- package/dist-lib/lib/return-focus.js +11 -11
- package/dist-lib/lib/return-focus.js.map +1 -1
- package/dist-lib/lib/strings.js +167 -135
- package/dist-lib/lib/strings.js.map +1 -1
- package/dist-lib/lib/strings.mn.js +150 -113
- package/dist-lib/lib/strings.mn.js.map +1 -1
- package/dist-lib/lib/utils.js +9 -9
- package/dist-lib/lib/utils.js.map +1 -1
- package/dist-lib/styles.css +3 -1
- package/dist-lib/theme.css +18 -5
- package/package.json +50 -50
- package/dist-lib/__tests__/helpers/color.d.ts +0 -9
- package/dist-lib/__tests__/helpers/theme.d.ts +0 -18
- package/dist-lib/icon.js.map +0 -1
- package/dist-lib/index.js.map +0 -1
package/dist-lib/index.js
CHANGED
|
@@ -1,291 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import { defaultStrings as
|
|
5
|
-
import { mnStrings as
|
|
6
|
-
import { formatDate as
|
|
7
|
-
import { useMediaQuery as
|
|
8
|
-
import { TOAST_DURATIONS as
|
|
9
|
-
import { useFieldIds as
|
|
10
|
-
import { isApplePlatform as
|
|
11
|
-
import { useDelayedLoading as
|
|
12
|
-
import { useDebounce as
|
|
13
|
-
import { useStrings as
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import { Accordion as
|
|
17
|
-
import { Alert as
|
|
18
|
-
import { Avatar as
|
|
19
|
-
import { Badge as
|
|
20
|
-
import { Breadcrumbs as
|
|
21
|
-
import { Button as
|
|
22
|
-
import { Card as
|
|
23
|
-
import { Checkbox as
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
import {
|
|
56
|
-
import {
|
|
57
|
-
import {
|
|
58
|
-
import {
|
|
59
|
-
import {
|
|
60
|
-
import { Carousel as
|
|
61
|
-
import { AreaChart as
|
|
62
|
-
import { RelativeTime as
|
|
63
|
-
import { Drawer as
|
|
64
|
-
import { FileUpload as
|
|
65
|
-
import { Snackbar as
|
|
66
|
-
import { TagInput as
|
|
67
|
-
import { Timeline as
|
|
68
|
-
import { Tree as
|
|
69
|
-
|
|
70
|
-
export {
|
|
71
|
-
O as Accordion,
|
|
72
|
-
E as AccordionContent,
|
|
73
|
-
U as AccordionItem,
|
|
74
|
-
_ as AccordionTrigger,
|
|
75
|
-
V as Alert,
|
|
76
|
-
Bt as AreaChart,
|
|
77
|
-
$ as Avatar,
|
|
78
|
-
j as AvatarGroup,
|
|
79
|
-
z as Badge,
|
|
80
|
-
Ht as BarChart,
|
|
81
|
-
W as Breadcrumbs,
|
|
82
|
-
Y as Button,
|
|
83
|
-
Ft as Calendar,
|
|
84
|
-
ee as Card,
|
|
85
|
-
oe as CardContent,
|
|
86
|
-
re as CardDescription,
|
|
87
|
-
te as CardFooter,
|
|
88
|
-
ae as CardHeader,
|
|
89
|
-
ne as CardTitle,
|
|
90
|
-
At as Carousel,
|
|
91
|
-
Lt as CarouselContent,
|
|
92
|
-
Rt as CarouselItem,
|
|
93
|
-
kt as CarouselNext,
|
|
94
|
-
Gt as CarouselPrevious,
|
|
95
|
-
pe as Checkbox,
|
|
96
|
-
le as Combobox,
|
|
97
|
-
ue as Command,
|
|
98
|
-
de as CommandDialog,
|
|
99
|
-
fe as CommandEmpty,
|
|
100
|
-
se as CommandGroup,
|
|
101
|
-
Ce as CommandInput,
|
|
102
|
-
Te as CommandItem,
|
|
103
|
-
Se as CommandList,
|
|
104
|
-
ce as CommandSeparator,
|
|
105
|
-
De as CommandShortcut,
|
|
106
|
-
je as ConfirmationDialog,
|
|
107
|
-
Me as ContextMenu,
|
|
108
|
-
we as ContextMenuCheckboxItem,
|
|
109
|
-
Pe as ContextMenuContent,
|
|
110
|
-
he as ContextMenuGroup,
|
|
111
|
-
Ie as ContextMenuItem,
|
|
112
|
-
Fe as ContextMenuLabel,
|
|
113
|
-
ve as ContextMenuPortal,
|
|
114
|
-
Ae as ContextMenuRadioGroup,
|
|
115
|
-
Le as ContextMenuRadioItem,
|
|
116
|
-
Re as ContextMenuSeparator,
|
|
117
|
-
ke as ContextMenuShortcut,
|
|
118
|
-
Ge as ContextMenuSub,
|
|
119
|
-
ye as ContextMenuSubContent,
|
|
120
|
-
Be as ContextMenuSubTrigger,
|
|
121
|
-
He as ContextMenuTrigger,
|
|
122
|
-
Nt as DEFAULT_CHART_COLORS,
|
|
123
|
-
Oe as DataGrid,
|
|
124
|
-
Ue as DatePicker,
|
|
125
|
-
_e as DateRangePicker,
|
|
126
|
-
Ve as DesignSystemProvider,
|
|
127
|
-
qe as Dialog,
|
|
128
|
-
ze as DialogClose,
|
|
129
|
-
Je as DialogContent,
|
|
130
|
-
We as DialogDescription,
|
|
131
|
-
Xe as DialogFooter,
|
|
132
|
-
Ye as DialogHeader,
|
|
133
|
-
Ze as DialogOverlay,
|
|
134
|
-
eo as DialogPortal,
|
|
135
|
-
oo as DialogTitle,
|
|
136
|
-
ro as DialogTrigger,
|
|
137
|
-
$t as Drawer,
|
|
138
|
-
jt as DrawerClose,
|
|
139
|
-
qt as DrawerContent,
|
|
140
|
-
zt as DrawerDescription,
|
|
141
|
-
Jt as DrawerFooter,
|
|
142
|
-
Wt as DrawerHeader,
|
|
143
|
-
Xt as DrawerOverlay,
|
|
144
|
-
Yt as DrawerPortal,
|
|
145
|
-
Zt as DrawerTitle,
|
|
146
|
-
ea as DrawerTrigger,
|
|
147
|
-
ao as DropdownMenu,
|
|
148
|
-
no as DropdownMenuCheckboxItem,
|
|
149
|
-
mo as DropdownMenuContent,
|
|
150
|
-
po as DropdownMenuGroup,
|
|
151
|
-
io as DropdownMenuItem,
|
|
152
|
-
lo as DropdownMenuLabel,
|
|
153
|
-
xo as DropdownMenuPortal,
|
|
154
|
-
uo as DropdownMenuRadioGroup,
|
|
155
|
-
fo as DropdownMenuRadioItem,
|
|
156
|
-
so as DropdownMenuSeparator,
|
|
157
|
-
Co as DropdownMenuShortcut,
|
|
158
|
-
To as DropdownMenuSub,
|
|
159
|
-
So as DropdownMenuSubContent,
|
|
160
|
-
co as DropdownMenuSubTrigger,
|
|
161
|
-
Do as DropdownMenuTrigger,
|
|
162
|
-
bo as EmptyState,
|
|
163
|
-
wo as ErrorState,
|
|
164
|
-
ra as FileUpload,
|
|
165
|
-
ho as Form,
|
|
166
|
-
Io as FormControl,
|
|
167
|
-
Fo as FormDescription,
|
|
168
|
-
vo as FormError,
|
|
169
|
-
Ao as FormField,
|
|
170
|
-
Lo as FormItem,
|
|
171
|
-
Ro as FormLabel,
|
|
172
|
-
yo as IconButton,
|
|
173
|
-
o as Icons,
|
|
174
|
-
r as Illustrations,
|
|
175
|
-
Ho as Input,
|
|
176
|
-
Oo as Kbd,
|
|
177
|
-
Ot as LineChart,
|
|
178
|
-
Uo as MultiSelect,
|
|
179
|
-
Ko as Pagination,
|
|
180
|
-
jo as Popover,
|
|
181
|
-
qo as PopoverAnchor,
|
|
182
|
-
zo as PopoverClose,
|
|
183
|
-
Jo as PopoverContent,
|
|
184
|
-
Wo as PopoverTrigger,
|
|
185
|
-
Yo as Progress,
|
|
186
|
-
Zo as ProgressCircle,
|
|
187
|
-
or as RadioGroup,
|
|
188
|
-
rr as RadioItem,
|
|
189
|
-
Vt as RelativeTime,
|
|
190
|
-
ar as ScrollArea,
|
|
191
|
-
nr as ScrollBar,
|
|
192
|
-
pr as Select,
|
|
193
|
-
ir as SelectContent,
|
|
194
|
-
lr as SelectGroup,
|
|
195
|
-
xr as SelectItem,
|
|
196
|
-
ur as SelectLabel,
|
|
197
|
-
dr as SelectScrollDownButton,
|
|
198
|
-
fr as SelectScrollUpButton,
|
|
199
|
-
sr as SelectSeparator,
|
|
200
|
-
Cr as SelectTrigger,
|
|
201
|
-
Tr as SelectValue,
|
|
202
|
-
cr as Separator,
|
|
203
|
-
gr as Sheet,
|
|
204
|
-
br as SheetClose,
|
|
205
|
-
Mr as SheetContent,
|
|
206
|
-
wr as SheetDescription,
|
|
207
|
-
Pr as SheetFooter,
|
|
208
|
-
hr as SheetHeader,
|
|
209
|
-
Ir as SheetPortal,
|
|
210
|
-
Fr as SheetTitle,
|
|
211
|
-
vr as SheetTrigger,
|
|
212
|
-
Lr as Sidebar,
|
|
213
|
-
Rr as SidebarGroup,
|
|
214
|
-
kr as SidebarItem,
|
|
215
|
-
Gr as SidebarSection,
|
|
216
|
-
Hr as Skeleton,
|
|
217
|
-
Or as Slider,
|
|
218
|
-
aa as Snackbar,
|
|
219
|
-
Ur as Spinner,
|
|
220
|
-
Kr as Stepper,
|
|
221
|
-
Qr as Switch,
|
|
222
|
-
M as TOAST_DURATIONS,
|
|
223
|
-
jr as Table,
|
|
224
|
-
qr as TableBody,
|
|
225
|
-
zr as TableCaption,
|
|
226
|
-
Jr as TableCell,
|
|
227
|
-
Wr as TableFooter,
|
|
228
|
-
Xr as TableHead,
|
|
229
|
-
Yr as TableHeader,
|
|
230
|
-
Zr as TableRow,
|
|
231
|
-
et as TableSortHeader,
|
|
232
|
-
rt as Tabs,
|
|
233
|
-
tt as TabsContent,
|
|
234
|
-
at as TabsList,
|
|
235
|
-
nt as TabsTrigger,
|
|
236
|
-
ma as TagInput,
|
|
237
|
-
pt as Textarea,
|
|
238
|
-
ia as Timeline,
|
|
239
|
-
la as TimelineDescription,
|
|
240
|
-
xa as TimelineItem,
|
|
241
|
-
ua as TimelineTime,
|
|
242
|
-
da as TimelineTitle,
|
|
243
|
-
lt as Toast,
|
|
244
|
-
xt as ToastAction,
|
|
245
|
-
ut as ToastClose,
|
|
246
|
-
dt as ToastDescription,
|
|
247
|
-
ft as ToastProvider,
|
|
248
|
-
st as ToastTitle,
|
|
249
|
-
Ct as ToastViewport,
|
|
250
|
-
Tt as Toaster,
|
|
251
|
-
ct as Tooltip,
|
|
252
|
-
Dt as TooltipContent,
|
|
253
|
-
gt as TooltipProvider,
|
|
254
|
-
bt as TooltipRoot,
|
|
255
|
-
Mt as TooltipTrigger,
|
|
256
|
-
Pt as TopNav,
|
|
257
|
-
ht as TopNavLink,
|
|
258
|
-
sa as Tree,
|
|
259
|
-
Et as abbreviateNumber,
|
|
260
|
-
Qe as brandPresets,
|
|
261
|
-
n as cn,
|
|
262
|
-
Ta as cva,
|
|
263
|
-
Ut as defaultChartLabels,
|
|
264
|
-
Vo as defaultPaginationLabels,
|
|
265
|
-
p as defaultStrings,
|
|
266
|
-
d as formatDate,
|
|
267
|
-
f as formatMNT,
|
|
268
|
-
s as formatNumber,
|
|
269
|
-
C as formatPhone,
|
|
270
|
-
i as formatString,
|
|
271
|
-
T as getDateTimeFormat,
|
|
272
|
-
v as isApplePlatform,
|
|
273
|
-
x as mnStrings,
|
|
274
|
-
_t as niceTicks,
|
|
275
|
-
Qo as paginationLabelsFromStrings,
|
|
276
|
-
S as parsePhoneMN,
|
|
277
|
-
w as toast,
|
|
278
|
-
ge as useCommandPaletteShortcut,
|
|
279
|
-
G as useDebounce,
|
|
280
|
-
y as useDebouncedCallback,
|
|
281
|
-
R as useDelayedLoading,
|
|
282
|
-
I as useFieldIds,
|
|
283
|
-
ko as useFormField,
|
|
284
|
-
D as useMediaQuery,
|
|
285
|
-
A as useModifierKey,
|
|
286
|
-
g as usePrefersReducedMotion,
|
|
287
|
-
yr as useSidebar,
|
|
288
|
-
H as useStrings,
|
|
289
|
-
P as useToast
|
|
290
|
-
};
|
|
291
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
/* empty css */
|
|
2
|
+
import { cn as e } from "./lib/utils.js";
|
|
3
|
+
import { cva as t } from "./lib/cva.js";
|
|
4
|
+
import { defaultStrings as n, formatString as r } from "./lib/strings.js";
|
|
5
|
+
import { mnStrings as i } from "./lib/strings.mn.js";
|
|
6
|
+
import { formatDate as a, formatMNT as o, formatNumber as s, formatPhone as c, getDateTimeFormat as l, parsePhoneMN as u } from "./lib/format.js";
|
|
7
|
+
import { useMediaQuery as d, usePrefersReducedMotion as f } from "./hooks/use-media-query.js";
|
|
8
|
+
import { TOAST_DURATIONS as p, toast as m, useToast as h } from "./hooks/use-toast.js";
|
|
9
|
+
import { useFieldIds as g } from "./hooks/use-field-ids.js";
|
|
10
|
+
import { isApplePlatform as _, useModifierKey as v } from "./hooks/use-modifier-key.js";
|
|
11
|
+
import { useDelayedLoading as y } from "./hooks/use-delayed-loading.js";
|
|
12
|
+
import { useDebounce as b, useDebouncedCallback as x } from "./hooks/use-debounce.js";
|
|
13
|
+
import { useStrings as S } from "./hooks/use-strings.js";
|
|
14
|
+
import { icons_exports as C } from "./icons/index.js";
|
|
15
|
+
import { illustrations_exports as w } from "./illustrations/index.js";
|
|
16
|
+
import { Accordion as T, AccordionContent as E, AccordionItem as D, AccordionTrigger as O } from "./components/ui/Accordion.js";
|
|
17
|
+
import { Alert as k } from "./components/ui/Alert.js";
|
|
18
|
+
import { Avatar as A, AvatarGroup as j } from "./components/ui/Avatar.js";
|
|
19
|
+
import { Badge as M } from "./components/ui/Badge.js";
|
|
20
|
+
import { Breadcrumbs as N } from "./components/ui/Breadcrumbs.js";
|
|
21
|
+
import { Button as P } from "./components/ui/Button.js";
|
|
22
|
+
import { Card as F, CardContent as I, CardDescription as L, CardFooter as R, CardHeader as z, CardTitle as B } from "./components/ui/Card.js";
|
|
23
|
+
import { Checkbox as V } from "./components/ui/Checkbox.js";
|
|
24
|
+
import { IconButton as H } from "./components/ui/IconButton.js";
|
|
25
|
+
import { Combobox as U } from "./components/ui/Combobox.js";
|
|
26
|
+
import { Command as W, CommandDialog as G, CommandEmpty as K, CommandGroup as q, CommandInput as J, CommandItem as Y, CommandList as X, CommandSeparator as Z, CommandShortcut as Q, useCommandPaletteShortcut as $ } from "./components/ui/CommandPalette.js";
|
|
27
|
+
import { ContextMenu as ee, ContextMenuCheckboxItem as te, ContextMenuContent as ne, ContextMenuGroup as re, ContextMenuItem as ie, ContextMenuLabel as ae, ContextMenuPortal as oe, ContextMenuRadioGroup as se, ContextMenuRadioItem as ce, ContextMenuSeparator as le, ContextMenuShortcut as ue, ContextMenuSub as de, ContextMenuSubContent as fe, ContextMenuSubTrigger as pe, ContextMenuTrigger as me } from "./components/ui/ContextMenu.js";
|
|
28
|
+
import { DropdownMenu as he, DropdownMenuCheckboxItem as ge, DropdownMenuContent as _e, DropdownMenuGroup as ve, DropdownMenuItem as ye, DropdownMenuLabel as be, DropdownMenuPortal as xe, DropdownMenuRadioGroup as Se, DropdownMenuRadioItem as Ce, DropdownMenuSeparator as we, DropdownMenuShortcut as Te, DropdownMenuSub as Ee, DropdownMenuSubContent as De, DropdownMenuSubTrigger as Oe, DropdownMenuTrigger as ke } from "./components/ui/DropdownMenu.js";
|
|
29
|
+
import { Input as Ae } from "./components/ui/Input.js";
|
|
30
|
+
import { Table as je, TableBody as Me, TableCaption as Ne, TableCell as Pe, TableFooter as Fe, TableHead as Ie, TableHeader as Le, TableRow as Re, TableSortHeader as ze } from "./components/ui/Table.js";
|
|
31
|
+
import { Skeleton as Be } from "./components/ui/Skeleton.js";
|
|
32
|
+
import { DataGrid as Ve } from "./components/ui/DataGrid.js";
|
|
33
|
+
import { Select as He, SelectContent as Ue, SelectGroup as We, SelectItem as Ge, SelectLabel as Ke, SelectScrollDownButton as qe, SelectScrollUpButton as Je, SelectSeparator as Ye, SelectTrigger as Xe, SelectValue as Ze } from "./components/ui/Select.js";
|
|
34
|
+
import { Calendar as Qe } from "./components/ui/Calendar.js";
|
|
35
|
+
import { DatePicker as $e, DateRangePicker as et } from "./components/ui/DatePicker.js";
|
|
36
|
+
import { DesignSystemProvider as tt, brandPresets as nt } from "./components/ui/DesignSystemProvider.js";
|
|
37
|
+
import { ConfirmationDialog as rt, Dialog as it, DialogClose as at, DialogContent as ot, DialogDescription as st, DialogFooter as ct, DialogHeader as lt, DialogOverlay as ut, DialogPortal as dt, DialogTitle as ft, DialogTrigger as pt } from "./components/ui/Dialog.js";
|
|
38
|
+
import { EmptyState as mt } from "./components/ui/EmptyState.js";
|
|
39
|
+
import { ErrorState as ht } from "./components/ui/ErrorState.js";
|
|
40
|
+
import { Form as gt, FormControl as _t, FormDescription as vt, FormError as yt, FormField as bt, FormItem as xt, FormLabel as St, useFormField as Ct } from "./components/ui/Form.js";
|
|
41
|
+
import { Kbd as wt } from "./components/ui/Kbd.js";
|
|
42
|
+
import { MultiSelect as Tt } from "./components/ui/MultiSelect.js";
|
|
43
|
+
import { Pagination as Et, defaultPaginationLabels as Dt, paginationLabelsFromStrings as Ot } from "./components/ui/Pagination.js";
|
|
44
|
+
import { Popover as kt, PopoverAnchor as At, PopoverClose as jt, PopoverContent as Mt, PopoverTrigger as Nt } from "./components/ui/Popover.js";
|
|
45
|
+
import { Progress as Pt, ProgressCircle as Ft } from "./components/ui/Progress.js";
|
|
46
|
+
import { RadioGroup as It, RadioItem as Lt } from "./components/ui/RadioGroup.js";
|
|
47
|
+
import { ScrollArea as Rt, ScrollBar as zt } from "./components/ui/ScrollArea.js";
|
|
48
|
+
import { Separator as Bt } from "./components/ui/Separator.js";
|
|
49
|
+
import { Sheet as Vt, SheetClose as Ht, SheetContent as Ut, SheetDescription as Wt, SheetFooter as Gt, SheetHeader as Kt, SheetPortal as qt, SheetTitle as Jt, SheetTrigger as Yt } from "./components/ui/Sheet.js";
|
|
50
|
+
import { Tooltip as Xt, TooltipContent as Zt, TooltipProvider as Qt, TooltipRoot as $t, TooltipTrigger as en } from "./components/ui/Tooltip.js";
|
|
51
|
+
import { Sidebar as tn, SidebarGroup as nn, SidebarItem as rn, SidebarSection as an, useSidebar as on } from "./components/ui/Sidebar.js";
|
|
52
|
+
import { Slider as sn } from "./components/ui/Slider.js";
|
|
53
|
+
import { Spinner as cn } from "./components/ui/Spinner.js";
|
|
54
|
+
import { Stepper as ln } from "./components/ui/Stepper.js";
|
|
55
|
+
import { Switch as un } from "./components/ui/Switch.js";
|
|
56
|
+
import { Tabs as dn, TabsContent as fn, TabsList as pn, TabsTrigger as mn } from "./components/ui/Tabs.js";
|
|
57
|
+
import { Textarea as hn } from "./components/ui/Textarea.js";
|
|
58
|
+
import { Toast as gn, ToastAction as _n, ToastClose as vn, ToastDescription as yn, ToastProvider as bn, ToastTitle as xn, ToastViewport as Sn, Toaster as Cn } from "./components/ui/Toast.js";
|
|
59
|
+
import { TopNav as wn, TopNavLink as Tn } from "./components/ui/TopNav.js";
|
|
60
|
+
import { Carousel as En, CarouselContent as Dn, CarouselItem as On, CarouselNext as kn, CarouselPrevious as An } from "./components/ui/Carousel.js";
|
|
61
|
+
import { AreaChart as jn, BarChart as Mn, DEFAULT_CHART_COLORS as Nn, LineChart as Pn, abbreviateNumber as Fn, defaultChartLabels as In, niceTicks as Ln } from "./components/ui/Chart.js";
|
|
62
|
+
import { RelativeTime as Rn } from "./components/ui/RelativeTime.js";
|
|
63
|
+
import { Drawer as zn, DrawerClose as Bn, DrawerContent as Vn, DrawerDescription as Hn, DrawerFooter as Un, DrawerHeader as Wn, DrawerOverlay as Gn, DrawerPortal as Kn, DrawerTitle as qn, DrawerTrigger as Jn } from "./components/ui/Drawer.js";
|
|
64
|
+
import { FileUpload as Yn } from "./components/ui/FileUpload.js";
|
|
65
|
+
import { Snackbar as Xn } from "./components/ui/Snackbar.js";
|
|
66
|
+
import { TagInput as Zn } from "./components/ui/TagInput.js";
|
|
67
|
+
import { Timeline as Qn, TimelineDescription as $n, TimelineItem as er, TimelineTime as tr, TimelineTitle as nr } from "./components/ui/Timeline.js";
|
|
68
|
+
import { Tree as rr } from "./components/ui/Tree.js";
|
|
69
|
+
export { T as Accordion, E as AccordionContent, D as AccordionItem, O as AccordionTrigger, k as Alert, jn as AreaChart, A as Avatar, j as AvatarGroup, M as Badge, Mn as BarChart, N as Breadcrumbs, P as Button, Qe as Calendar, F as Card, I as CardContent, L as CardDescription, R as CardFooter, z as CardHeader, B as CardTitle, En as Carousel, Dn as CarouselContent, On as CarouselItem, kn as CarouselNext, An as CarouselPrevious, V as Checkbox, U as Combobox, W as Command, G as CommandDialog, K as CommandEmpty, q as CommandGroup, J as CommandInput, Y as CommandItem, X as CommandList, Z as CommandSeparator, Q as CommandShortcut, rt as ConfirmationDialog, ee as ContextMenu, te as ContextMenuCheckboxItem, ne as ContextMenuContent, re as ContextMenuGroup, ie as ContextMenuItem, ae as ContextMenuLabel, oe as ContextMenuPortal, se as ContextMenuRadioGroup, ce as ContextMenuRadioItem, le as ContextMenuSeparator, ue as ContextMenuShortcut, de as ContextMenuSub, fe as ContextMenuSubContent, pe as ContextMenuSubTrigger, me as ContextMenuTrigger, Nn as DEFAULT_CHART_COLORS, Ve as DataGrid, $e as DatePicker, et as DateRangePicker, tt as DesignSystemProvider, it as Dialog, at as DialogClose, ot as DialogContent, st as DialogDescription, ct as DialogFooter, lt as DialogHeader, ut as DialogOverlay, dt as DialogPortal, ft as DialogTitle, pt as DialogTrigger, zn as Drawer, Bn as DrawerClose, Vn as DrawerContent, Hn as DrawerDescription, Un as DrawerFooter, Wn as DrawerHeader, Gn as DrawerOverlay, Kn as DrawerPortal, qn as DrawerTitle, Jn as DrawerTrigger, he as DropdownMenu, ge as DropdownMenuCheckboxItem, _e as DropdownMenuContent, ve as DropdownMenuGroup, ye as DropdownMenuItem, be as DropdownMenuLabel, xe as DropdownMenuPortal, Se as DropdownMenuRadioGroup, Ce as DropdownMenuRadioItem, we as DropdownMenuSeparator, Te as DropdownMenuShortcut, Ee as DropdownMenuSub, De as DropdownMenuSubContent, Oe as DropdownMenuSubTrigger, ke as DropdownMenuTrigger, mt as EmptyState, ht as ErrorState, Yn as FileUpload, gt as Form, _t as FormControl, vt as FormDescription, yt as FormError, bt as FormField, xt as FormItem, St as FormLabel, H as IconButton, C as Icons, w as Illustrations, Ae as Input, wt as Kbd, Pn as LineChart, Tt as MultiSelect, Et as Pagination, kt as Popover, At as PopoverAnchor, jt as PopoverClose, Mt as PopoverContent, Nt as PopoverTrigger, Pt as Progress, Ft as ProgressCircle, It as RadioGroup, Lt as RadioItem, Rn as RelativeTime, Rt as ScrollArea, zt as ScrollBar, He as Select, Ue as SelectContent, We as SelectGroup, Ge as SelectItem, Ke as SelectLabel, qe as SelectScrollDownButton, Je as SelectScrollUpButton, Ye as SelectSeparator, Xe as SelectTrigger, Ze as SelectValue, Bt as Separator, Vt as Sheet, Ht as SheetClose, Ut as SheetContent, Wt as SheetDescription, Gt as SheetFooter, Kt as SheetHeader, qt as SheetPortal, Jt as SheetTitle, Yt as SheetTrigger, tn as Sidebar, nn as SidebarGroup, rn as SidebarItem, an as SidebarSection, Be as Skeleton, sn as Slider, Xn as Snackbar, cn as Spinner, ln as Stepper, un as Switch, p as TOAST_DURATIONS, je as Table, Me as TableBody, Ne as TableCaption, Pe as TableCell, Fe as TableFooter, Ie as TableHead, Le as TableHeader, Re as TableRow, ze as TableSortHeader, dn as Tabs, fn as TabsContent, pn as TabsList, mn as TabsTrigger, Zn as TagInput, hn as Textarea, Qn as Timeline, $n as TimelineDescription, er as TimelineItem, tr as TimelineTime, nr as TimelineTitle, gn as Toast, _n as ToastAction, vn as ToastClose, yn as ToastDescription, bn as ToastProvider, xn as ToastTitle, Sn as ToastViewport, Cn as Toaster, Xt as Tooltip, Zt as TooltipContent, Qt as TooltipProvider, $t as TooltipRoot, en as TooltipTrigger, wn as TopNav, Tn as TopNavLink, rr as Tree, Fn as abbreviateNumber, nt as brandPresets, e as cn, t as cva, In as defaultChartLabels, Dt as defaultPaginationLabels, n as defaultStrings, a as formatDate, o as formatMNT, s as formatNumber, c as formatPhone, r as formatString, l as getDateTimeFormat, _ as isApplePlatform, i as mnStrings, Ln as niceTicks, Ot as paginationLabelsFromStrings, u as parsePhoneMN, m as toast, $ as useCommandPaletteShortcut, b as useDebounce, x as useDebouncedCallback, y as useDelayedLoading, g as useFieldIds, Ct as useFormField, d as useMediaQuery, v as useModifierKey, f as usePrefersReducedMotion, on as useSidebar, S as useStrings, h as useToast };
|
package/dist-lib/lib/format.js
CHANGED
|
@@ -1,95 +1,79 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
//#region src/lib/format.ts
|
|
3
|
+
var e = (e, t = 2) => String(e).padStart(t, "0"), t = /* @__PURE__ */ new Map();
|
|
4
|
+
function n(e) {
|
|
5
|
+
let n = t.get(e);
|
|
6
|
+
return n || (n = new Intl.DateTimeFormat("en-US", {
|
|
7
|
+
timeZone: e,
|
|
8
|
+
hourCycle: "h23",
|
|
9
|
+
year: "numeric",
|
|
10
|
+
month: "2-digit",
|
|
11
|
+
day: "2-digit",
|
|
12
|
+
hour: "2-digit",
|
|
13
|
+
minute: "2-digit",
|
|
14
|
+
second: "2-digit"
|
|
15
|
+
}), t.set(e, n)), n;
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return i;
|
|
17
|
+
function r(e, t) {
|
|
18
|
+
let r = n(t), i = {};
|
|
19
|
+
for (let t of r.formatToParts(e)) t.type !== "literal" && (i[t.type] = Number(t.value));
|
|
20
|
+
return i;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
case "M":
|
|
41
|
-
return String(e.month);
|
|
42
|
-
case "d":
|
|
43
|
-
return String(e.day);
|
|
44
|
-
case "H":
|
|
45
|
-
return String(c);
|
|
46
|
-
default:
|
|
47
|
-
return a;
|
|
48
|
-
}
|
|
49
|
-
});
|
|
22
|
+
function i(t, { tz: n = "Asia/Ulaanbaatar", pattern: i = "yyyy-MM-dd HH:mm" } = {}) {
|
|
23
|
+
let a = t instanceof Date ? t : new Date(t);
|
|
24
|
+
if (Number.isNaN(a.getTime())) return "";
|
|
25
|
+
let o = r(a, n), s = o.hour === 24 ? 0 : o.hour;
|
|
26
|
+
return i.replace(/yyyy|MM|dd|HH|mm|ss|M|d|H/g, (t) => {
|
|
27
|
+
switch (t) {
|
|
28
|
+
case "yyyy": return String(o.year);
|
|
29
|
+
case "MM": return e(o.month);
|
|
30
|
+
case "dd": return e(o.day);
|
|
31
|
+
case "HH": return e(s);
|
|
32
|
+
case "mm": return e(o.minute);
|
|
33
|
+
case "ss": return e(o.second);
|
|
34
|
+
case "M": return String(o.month);
|
|
35
|
+
case "d": return String(o.day);
|
|
36
|
+
case "H": return String(s);
|
|
37
|
+
default: return t;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
50
40
|
}
|
|
51
|
-
function
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const c = Math.abs(t).toFixed(r);
|
|
59
|
-
let [a, s = ""] = c.split(".");
|
|
60
|
-
s = s.replace(/0+$/, "");
|
|
61
|
-
const d = t < 0 && Number(c) !== 0 ? "-" : "";
|
|
62
|
-
for (; s.length < n; ) s += "0";
|
|
63
|
-
return a = a.replace(/\B(?=(\d{3})+(?!\d))/g, i), `${d}${a}${s ? e + s : ""}`;
|
|
41
|
+
function a(e, { maximumFractionDigits: t = 2, minimumFractionDigits: n = 0, group: r = ",", decimal: i = "." } = {}) {
|
|
42
|
+
if (!Number.isFinite(e)) return "";
|
|
43
|
+
let a = Math.abs(e).toFixed(t), [o, s = ""] = a.split(".");
|
|
44
|
+
s = s.replace(/0+$/, "");
|
|
45
|
+
let c = e < 0 && Number(a) !== 0 ? "-" : "";
|
|
46
|
+
for (; s.length < n;) s += "0";
|
|
47
|
+
return o = o.replace(/\B(?=(\d{3})+(?!\d))/g, r), `${c}${o}${s ? i + s : ""}`;
|
|
64
48
|
}
|
|
65
|
-
function
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
49
|
+
function o(e, { compact: t, ...n } = {}) {
|
|
50
|
+
if (t && Number.isFinite(e) && Math.abs(e) >= 1e3) {
|
|
51
|
+
let t = [
|
|
52
|
+
[1e9, "B"],
|
|
53
|
+
[1e6, "M"],
|
|
54
|
+
[1e3, "K"]
|
|
55
|
+
], r = t.findIndex(([t]) => Math.abs(e) >= t);
|
|
56
|
+
r > 0 && Math.abs(e / t[r][0]).toFixed(1) === "1000.0" && --r;
|
|
57
|
+
let [i, o] = t[r];
|
|
58
|
+
return `${a(e / i, {
|
|
59
|
+
...n,
|
|
60
|
+
maximumFractionDigits: 1
|
|
61
|
+
})}${o}₮`;
|
|
62
|
+
}
|
|
63
|
+
return `${a(e, {
|
|
64
|
+
...n,
|
|
65
|
+
maximumFractionDigits: 0
|
|
66
|
+
})}₮`;
|
|
78
67
|
}
|
|
79
|
-
function
|
|
80
|
-
|
|
81
|
-
|
|
68
|
+
function s(e) {
|
|
69
|
+
let t = e.replace(/[\s\-().]/g, ""), n = /^(?:\+?976)?(\d{8})$/.exec(t);
|
|
70
|
+
return n ? `+976 ${n[1].slice(0, 4)} ${n[1].slice(4)}` : e;
|
|
82
71
|
}
|
|
83
|
-
function
|
|
84
|
-
|
|
85
|
-
|
|
72
|
+
function c(e) {
|
|
73
|
+
let t = e.replace(/[\s\-().]/g, ""), n = /^(?:\+?976)?(\d{8})$/.exec(t);
|
|
74
|
+
return n ? `+976${n[1]}` : null;
|
|
86
75
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
h as formatPhone,
|
|
92
|
-
f as getDateTimeFormat,
|
|
93
|
-
M as parsePhoneMN
|
|
94
|
-
};
|
|
95
|
-
//# sourceMappingURL=format.js.map
|
|
76
|
+
//#endregion
|
|
77
|
+
export { i as formatDate, o as formatMNT, a as formatNumber, s as formatPhone, n as getDateTimeFormat, c as parsePhoneMN };
|
|
78
|
+
|
|
79
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sources":["../../src/lib/format.ts"],"sourcesContent":["'use client';\n\n/**\n * Dependency-free locale helpers. Defaults target Mongolia (Asia/Ulaanbaatar,\n * `₮` suffix, `,` thousands) but every option is overridable.\n */\n\nexport interface FormatDateOptions {\n /** IANA zone. Default `Asia/Ulaanbaatar`. */\n tz?: string;\n /**\n * Tokens: `yyyy` `MM` `dd` `HH` `mm` `ss`, plus `M`/`d`/`H` (unpadded).\n * Default `yyyy-MM-dd HH:mm`.\n */\n pattern?: string;\n}\n\nconst pad = (n: number, w = 2) => String(n).padStart(w, '0');\n\n/** Intl.DateTimeFormat construction is expensive (~ms); cache per zone. */\nconst dtfCache = new Map<string, Intl.DateTimeFormat>();\n\nexport function getDateTimeFormat(tz: string): Intl.DateTimeFormat {\n let dtf = dtfCache.get(tz);\n if (!dtf) {\n dtf = new Intl.DateTimeFormat('en-US', {\n timeZone: tz,\n hourCycle: 'h23',\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n });\n dtfCache.set(tz, dtf);\n }\n return dtf;\n}\n\nfunction parts(d: Date, tz: string) {\n const dtf = getDateTimeFormat(tz);\n const out: Record<string, number> = {};\n for (const p of dtf.formatToParts(d)) {\n if (p.type !== 'literal') out[p.type] = Number(p.value);\n }\n return out;\n}\n\n/**\n * Format a date in a fixed time zone with a small token pattern.\n *\n * @example\n * formatDate(new Date('2026-08-20T02:05:00Z')) // \"2026-08-20 10:05\"\n * formatDate(d, { pattern: 'dd.MM.yyyy', tz: 'UTC' }) // \"20.08.2026\"\n */\nexport function formatDate(\n date: Date | number | string,\n { tz = 'Asia/Ulaanbaatar', pattern = 'yyyy-MM-dd HH:mm' }: FormatDateOptions = {},\n): string {\n const d = date instanceof Date ? date : new Date(date);\n if (Number.isNaN(d.getTime())) return '';\n const p = parts(d, tz);\n const hour = p.hour === 24 ? 0 : p.hour;\n return pattern.replace(/yyyy|MM|dd|HH|mm|ss|M|d|H/g, (t) => {\n switch (t) {\n case 'yyyy':\n return String(p.year);\n case 'MM':\n return pad(p.month);\n case 'dd':\n return pad(p.day);\n case 'HH':\n return pad(hour);\n case 'mm':\n return pad(p.minute);\n case 'ss':\n return pad(p.second);\n case 'M':\n return String(p.month);\n case 'd':\n return String(p.day);\n case 'H':\n return String(hour);\n default:\n return t;\n }\n });\n}\n\nexport interface FormatNumberOptions {\n /** Max fraction digits. Default 2. */\n maximumFractionDigits?: number;\n /** Min fraction digits. Default 0. */\n minimumFractionDigits?: number;\n /** Thousands separator. Default `,`. */\n group?: string;\n /** Decimal separator. Default `.`. */\n decimal?: string;\n}\n\n/**\n * Group thousands with a fixed separator (locale-independent, so SSR and\n * client always agree).\n *\n * @example formatNumber(1250000) // \"1,250,000\"\n */\nexport function formatNumber(\n n: number,\n {\n maximumFractionDigits = 2,\n minimumFractionDigits = 0,\n group = ',',\n decimal = '.',\n }: FormatNumberOptions = {},\n): string {\n if (!Number.isFinite(n)) return '';\n const fixed = Math.abs(n).toFixed(maximumFractionDigits);\n let [int, frac = ''] = fixed.split('.');\n frac = frac.replace(/0+$/, '');\n // Normalise -0 and values that round to zero (e.g. -0.001) → \"0\", not \"-0\".\n const sign = n < 0 && Number(fixed) !== 0 ? '-' : '';\n while (frac.length < minimumFractionDigits) frac += '0';\n int = int.replace(/\\B(?=(\\d{3})+(?!\\d))/g, group);\n return `${sign}${int}${frac ? decimal + frac : ''}`;\n}\n\nexport interface FormatMNTOptions extends Omit<FormatNumberOptions, 'maximumFractionDigits'> {\n /** Abbreviate ≥1,000 as `K` / `M` / `B` with one decimal: `12.4M₮`, `850K₮`. */\n compact?: boolean;\n}\n\n/**\n * Mongolian tögrög: grouped integer + `₮` suffix, no space.\n *\n * @example formatMNT(1250000) // \"1,250,000₮\"\n * @example formatMNT(12400000, { compact: true }) // \"12.4M₮\"\n * @example formatMNT(850000, { compact: true }) // \"850K₮\"\n */\nexport function formatMNT(n: number, { compact, ...options }: FormatMNTOptions = {}) {\n if (compact && Number.isFinite(n) && Math.abs(n) >= 1000) {\n const units: Array<[number, string]> = [\n [1e9, 'B'],\n [1e6, 'M'],\n [1e3, 'K'],\n ];\n let idx = units.findIndex(([d]) => Math.abs(n) >= d);\n // 999,999 → \"1000.0K\" after rounding; promote to the next unit instead.\n if (idx > 0 && Math.abs(n / units[idx][0]).toFixed(1) === '1000.0') idx -= 1;\n const [div, unit] = units[idx];\n return `${formatNumber(n / div, { ...options, maximumFractionDigits: 1 })}${unit}₮`;\n }\n return `${formatNumber(n, { ...options, maximumFractionDigits: 0 })}₮`;\n}\n\n/**\n * Display form for Mongolian phone numbers. Accepts `XXXXXXXX`, `+976XXXXXXXX`,\n * `976XXXXXXXX`, or already-spaced input; anything else is returned unchanged.\n *\n * @example formatPhone('99112233') // \"+976 9911 2233\"\n * @example formatPhone('+97699112233') // \"+976 9911 2233\"\n * @example formatPhone('+1 555 0100') // \"+1 555 0100\" (non-MN, untouched)\n */\nexport function formatPhone(input: string): string {\n const digits = input.replace(/[\\s\\-().]/g, '');\n const m = /^(?:\\+?976)?(\\d{8})$/.exec(digits);\n if (!m) return input;\n return `+976 ${m[1].slice(0, 4)} ${m[1].slice(4)}`;\n}\n\n/**\n * Normalise a Mongolian phone number to E.164 (`+976XXXXXXXX`) for storage.\n * Returns `null` when the input is not an 8-digit MN number.\n */\nexport function parsePhoneMN(input: string): string | null {\n const digits = input.replace(/[\\s\\-().]/g, '');\n const m = /^(?:\\+?976)?(\\d{8})$/.exec(digits);\n return m ? `+976${m[1]}` : null;\n}\n"],"
|
|
1
|
+
{"version":3,"file":"format.js","names":[],"sources":["../../src/lib/format.ts"],"sourcesContent":["'use client';\n\n/**\n * Dependency-free locale helpers. Defaults target Mongolia (Asia/Ulaanbaatar,\n * `₮` suffix, `,` thousands) but every option is overridable.\n */\n\nexport interface FormatDateOptions {\n /** IANA zone. Default `Asia/Ulaanbaatar`. */\n tz?: string;\n /**\n * Tokens: `yyyy` `MM` `dd` `HH` `mm` `ss`, plus `M`/`d`/`H` (unpadded).\n * Default `yyyy-MM-dd HH:mm`.\n */\n pattern?: string;\n}\n\nconst pad = (n: number, w = 2) => String(n).padStart(w, '0');\n\n/** Intl.DateTimeFormat construction is expensive (~ms); cache per zone. */\nconst dtfCache = new Map<string, Intl.DateTimeFormat>();\n\nexport function getDateTimeFormat(tz: string): Intl.DateTimeFormat {\n let dtf = dtfCache.get(tz);\n if (!dtf) {\n dtf = new Intl.DateTimeFormat('en-US', {\n timeZone: tz,\n hourCycle: 'h23',\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n });\n dtfCache.set(tz, dtf);\n }\n return dtf;\n}\n\nfunction parts(d: Date, tz: string) {\n const dtf = getDateTimeFormat(tz);\n const out: Record<string, number> = {};\n for (const p of dtf.formatToParts(d)) {\n if (p.type !== 'literal') out[p.type] = Number(p.value);\n }\n return out;\n}\n\n/**\n * Format a date in a fixed time zone with a small token pattern.\n *\n * @example\n * formatDate(new Date('2026-08-20T02:05:00Z')) // \"2026-08-20 10:05\"\n * formatDate(d, { pattern: 'dd.MM.yyyy', tz: 'UTC' }) // \"20.08.2026\"\n */\nexport function formatDate(\n date: Date | number | string,\n { tz = 'Asia/Ulaanbaatar', pattern = 'yyyy-MM-dd HH:mm' }: FormatDateOptions = {},\n): string {\n const d = date instanceof Date ? date : new Date(date);\n if (Number.isNaN(d.getTime())) return '';\n const p = parts(d, tz);\n const hour = p.hour === 24 ? 0 : p.hour;\n return pattern.replace(/yyyy|MM|dd|HH|mm|ss|M|d|H/g, (t) => {\n switch (t) {\n case 'yyyy':\n return String(p.year);\n case 'MM':\n return pad(p.month);\n case 'dd':\n return pad(p.day);\n case 'HH':\n return pad(hour);\n case 'mm':\n return pad(p.minute);\n case 'ss':\n return pad(p.second);\n case 'M':\n return String(p.month);\n case 'd':\n return String(p.day);\n case 'H':\n return String(hour);\n default:\n return t;\n }\n });\n}\n\nexport interface FormatNumberOptions {\n /** Max fraction digits. Default 2. */\n maximumFractionDigits?: number;\n /** Min fraction digits. Default 0. */\n minimumFractionDigits?: number;\n /** Thousands separator. Default `,`. */\n group?: string;\n /** Decimal separator. Default `.`. */\n decimal?: string;\n}\n\n/**\n * Group thousands with a fixed separator (locale-independent, so SSR and\n * client always agree).\n *\n * @example formatNumber(1250000) // \"1,250,000\"\n */\nexport function formatNumber(\n n: number,\n {\n maximumFractionDigits = 2,\n minimumFractionDigits = 0,\n group = ',',\n decimal = '.',\n }: FormatNumberOptions = {},\n): string {\n if (!Number.isFinite(n)) return '';\n const fixed = Math.abs(n).toFixed(maximumFractionDigits);\n let [int, frac = ''] = fixed.split('.');\n frac = frac.replace(/0+$/, '');\n // Normalise -0 and values that round to zero (e.g. -0.001) → \"0\", not \"-0\".\n const sign = n < 0 && Number(fixed) !== 0 ? '-' : '';\n while (frac.length < minimumFractionDigits) frac += '0';\n int = int.replace(/\\B(?=(\\d{3})+(?!\\d))/g, group);\n return `${sign}${int}${frac ? decimal + frac : ''}`;\n}\n\nexport interface FormatMNTOptions extends Omit<FormatNumberOptions, 'maximumFractionDigits'> {\n /** Abbreviate ≥1,000 as `K` / `M` / `B` with one decimal: `12.4M₮`, `850K₮`. */\n compact?: boolean;\n}\n\n/**\n * Mongolian tögrög: grouped integer + `₮` suffix, no space.\n *\n * @example formatMNT(1250000) // \"1,250,000₮\"\n * @example formatMNT(12400000, { compact: true }) // \"12.4M₮\"\n * @example formatMNT(850000, { compact: true }) // \"850K₮\"\n */\nexport function formatMNT(n: number, { compact, ...options }: FormatMNTOptions = {}) {\n if (compact && Number.isFinite(n) && Math.abs(n) >= 1000) {\n const units: Array<[number, string]> = [\n [1e9, 'B'],\n [1e6, 'M'],\n [1e3, 'K'],\n ];\n let idx = units.findIndex(([d]) => Math.abs(n) >= d);\n // 999,999 → \"1000.0K\" after rounding; promote to the next unit instead.\n if (idx > 0 && Math.abs(n / units[idx][0]).toFixed(1) === '1000.0') idx -= 1;\n const [div, unit] = units[idx];\n return `${formatNumber(n / div, { ...options, maximumFractionDigits: 1 })}${unit}₮`;\n }\n return `${formatNumber(n, { ...options, maximumFractionDigits: 0 })}₮`;\n}\n\n/**\n * Display form for Mongolian phone numbers. Accepts `XXXXXXXX`, `+976XXXXXXXX`,\n * `976XXXXXXXX`, or already-spaced input; anything else is returned unchanged.\n *\n * @example formatPhone('99112233') // \"+976 9911 2233\"\n * @example formatPhone('+97699112233') // \"+976 9911 2233\"\n * @example formatPhone('+1 555 0100') // \"+1 555 0100\" (non-MN, untouched)\n */\nexport function formatPhone(input: string): string {\n const digits = input.replace(/[\\s\\-().]/g, '');\n const m = /^(?:\\+?976)?(\\d{8})$/.exec(digits);\n if (!m) return input;\n return `+976 ${m[1].slice(0, 4)} ${m[1].slice(4)}`;\n}\n\n/**\n * Normalise a Mongolian phone number to E.164 (`+976XXXXXXXX`) for storage.\n * Returns `null` when the input is not an 8-digit MN number.\n */\nexport function parsePhoneMN(input: string): string | null {\n const digits = input.replace(/[\\s\\-().]/g, '');\n const m = /^(?:\\+?976)?(\\d{8})$/.exec(digits);\n return m ? `+976${m[1]}` : null;\n}\n"],"mappings":"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"}
|