@hoardodile/ui 0.1.6 → 0.1.8

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 (273) hide show
  1. package/dist/chunk-2BVZEYNW.js +97 -0
  2. package/dist/chunk-2BVZEYNW.js.map +1 -0
  3. package/dist/chunk-2DTR6CD5.js +47 -0
  4. package/dist/chunk-2DTR6CD5.js.map +1 -0
  5. package/dist/chunk-2HWSCY4T.js +20 -0
  6. package/dist/chunk-2HWSCY4T.js.map +1 -0
  7. package/dist/chunk-363CCKQ7.js +75 -0
  8. package/dist/chunk-363CCKQ7.js.map +1 -0
  9. package/dist/chunk-3ZQJWBVB.js +30 -0
  10. package/dist/chunk-3ZQJWBVB.js.map +1 -0
  11. package/dist/chunk-4D36OO5W.js +277 -0
  12. package/dist/chunk-4D36OO5W.js.map +1 -0
  13. package/dist/chunk-4UITFLIN.js +31 -0
  14. package/dist/chunk-4UITFLIN.js.map +1 -0
  15. package/dist/chunk-6HAIUXNZ.js +11 -0
  16. package/dist/chunk-6HAIUXNZ.js.map +1 -0
  17. package/dist/chunk-7JMMFY67.js +62 -0
  18. package/dist/chunk-7JMMFY67.js.map +1 -0
  19. package/dist/chunk-7MWWHI6T.js +1149 -0
  20. package/dist/chunk-7MWWHI6T.js.map +1 -0
  21. package/dist/chunk-AEHTAUAQ.js +65 -0
  22. package/dist/chunk-AEHTAUAQ.js.map +1 -0
  23. package/dist/chunk-ASRGQ5BD.js +130 -0
  24. package/dist/chunk-ASRGQ5BD.js.map +1 -0
  25. package/dist/chunk-BFGOE5AI.js +187 -0
  26. package/dist/chunk-BFGOE5AI.js.map +1 -0
  27. package/dist/chunk-BRT25IDQ.js +46 -0
  28. package/dist/chunk-BRT25IDQ.js.map +1 -0
  29. package/dist/chunk-BU5DQOPM.js +29 -0
  30. package/dist/chunk-BU5DQOPM.js.map +1 -0
  31. package/dist/chunk-BWASOT5X.js +266 -0
  32. package/dist/chunk-BWASOT5X.js.map +1 -0
  33. package/dist/chunk-F32V4Z7Q.js +26 -0
  34. package/dist/chunk-F32V4Z7Q.js.map +1 -0
  35. package/dist/chunk-F7RHDRRJ.js +24 -0
  36. package/dist/chunk-F7RHDRRJ.js.map +1 -0
  37. package/dist/chunk-FH5RNCFR.js +21 -0
  38. package/dist/chunk-FH5RNCFR.js.map +1 -0
  39. package/dist/chunk-GKSX5ULZ.js +513 -0
  40. package/dist/chunk-GKSX5ULZ.js.map +1 -0
  41. package/dist/chunk-JPFDNRCA.js +26 -0
  42. package/dist/chunk-JPFDNRCA.js.map +1 -0
  43. package/dist/chunk-KNPRUZ4H.js +13 -0
  44. package/dist/chunk-KNPRUZ4H.js.map +1 -0
  45. package/dist/chunk-KOFWEPPB.js +254 -0
  46. package/dist/chunk-KOFWEPPB.js.map +1 -0
  47. package/dist/chunk-M5OJN54O.js +10 -0
  48. package/dist/chunk-M5OJN54O.js.map +1 -0
  49. package/dist/chunk-OEVALKQ5.js +51 -0
  50. package/dist/chunk-OEVALKQ5.js.map +1 -0
  51. package/dist/chunk-OW5FWLPH.js +33 -0
  52. package/dist/chunk-OW5FWLPH.js.map +1 -0
  53. package/dist/chunk-POX7TXBH.js +41 -0
  54. package/dist/chunk-POX7TXBH.js.map +1 -0
  55. package/dist/chunk-PWJBHUM2.js +58 -0
  56. package/dist/chunk-PWJBHUM2.js.map +1 -0
  57. package/dist/chunk-QGMDWGJT.js +23 -0
  58. package/dist/chunk-QGMDWGJT.js.map +1 -0
  59. package/dist/chunk-QGTQQNUL.js +36 -0
  60. package/dist/chunk-QGTQQNUL.js.map +1 -0
  61. package/dist/chunk-SAY52ZKI.js +152 -0
  62. package/dist/chunk-SAY52ZKI.js.map +1 -0
  63. package/dist/chunk-SKDPGSRL.js +166 -0
  64. package/dist/chunk-SKDPGSRL.js.map +1 -0
  65. package/dist/chunk-T56ARCUK.js +38 -0
  66. package/dist/chunk-T56ARCUK.js.map +1 -0
  67. package/dist/chunk-TDDHQZ62.js +227 -0
  68. package/dist/chunk-TDDHQZ62.js.map +1 -0
  69. package/dist/chunk-TMQ5OMBK.js +29 -0
  70. package/dist/chunk-TMQ5OMBK.js.map +1 -0
  71. package/dist/chunk-UEVND7AS.js +23 -0
  72. package/dist/chunk-UEVND7AS.js.map +1 -0
  73. package/dist/chunk-UPWHCG4S.js +40 -0
  74. package/dist/chunk-UPWHCG4S.js.map +1 -0
  75. package/dist/chunk-VWUNF7VX.js +3 -0
  76. package/dist/chunk-VWUNF7VX.js.map +1 -0
  77. package/dist/chunk-WI6O7GZK.js +45 -0
  78. package/dist/chunk-WI6O7GZK.js.map +1 -0
  79. package/dist/chunk-WVEK3WCX.js +21 -0
  80. package/dist/chunk-WVEK3WCX.js.map +1 -0
  81. package/dist/chunk-XBPQEZES.js +48 -0
  82. package/dist/chunk-XBPQEZES.js.map +1 -0
  83. package/dist/chunk-ZYAGKKR7.js +142 -0
  84. package/dist/chunk-ZYAGKKR7.js.map +1 -0
  85. package/dist/components/alert.js +2 -21
  86. package/dist/components/alert.js.map +1 -1
  87. package/dist/components/app-dialog.js +10 -654
  88. package/dist/components/app-dialog.js.map +1 -1
  89. package/dist/components/badge.js +2 -23
  90. package/dist/components/badge.js.map +1 -1
  91. package/dist/components/breadcrumb.js +5 -501
  92. package/dist/components/breadcrumb.js.map +1 -1
  93. package/dist/components/button.js +3 -76
  94. package/dist/components/button.js.map +1 -1
  95. package/dist/components/caption-bar.js +7 -518
  96. package/dist/components/caption-bar.js.map +1 -1
  97. package/dist/components/checkbox.js +4 -74
  98. package/dist/components/checkbox.js.map +1 -1
  99. package/dist/components/chip-button.js +4 -85
  100. package/dist/components/chip-button.js.map +1 -1
  101. package/dist/components/close-confirm-dialog.js +12 -662
  102. package/dist/components/close-confirm-dialog.js.map +1 -1
  103. package/dist/components/color-picker.js +7 -530
  104. package/dist/components/color-picker.js.map +1 -1
  105. package/dist/components/combobox.js +15 -934
  106. package/dist/components/combobox.js.map +1 -1
  107. package/dist/components/confirm-by-typing-dialog.js +12 -669
  108. package/dist/components/confirm-by-typing-dialog.js.map +1 -1
  109. package/dist/components/confirm-dialog.js +11 -637
  110. package/dist/components/confirm-dialog.js.map +1 -1
  111. package/dist/components/count-badge.js +2 -21
  112. package/dist/components/count-badge.js.map +1 -1
  113. package/dist/components/dialog.js +8 -569
  114. package/dist/components/dialog.js.map +1 -1
  115. package/dist/components/dropdown-menu.js +9 -1004
  116. package/dist/components/dropdown-menu.js.map +1 -1
  117. package/dist/components/dropdown-select.js +9 -880
  118. package/dist/components/dropdown-select.js.map +1 -1
  119. package/dist/components/empty.js +2 -21
  120. package/dist/components/empty.js.map +1 -1
  121. package/dist/components/filter-rail.js +7 -145
  122. package/dist/components/filter-rail.js.map +1 -1
  123. package/dist/components/fixed-action-bar.js +2 -21
  124. package/dist/components/fixed-action-bar.js.map +1 -1
  125. package/dist/components/font-picker.js +11 -586
  126. package/dist/components/font-picker.js.map +1 -1
  127. package/dist/components/form.js +9 -66
  128. package/dist/components/form.js.map +1 -1
  129. package/dist/components/icon-tile.js +3 -43
  130. package/dist/components/icon-tile.js.map +1 -1
  131. package/dist/components/icon-toggle.js +3 -43
  132. package/dist/components/icon-toggle.js.map +1 -1
  133. package/dist/components/icon.js +3 -47
  134. package/dist/components/icon.js.map +1 -1
  135. package/dist/components/image-crop-panel.js +19 -772
  136. package/dist/components/image-crop-panel.js.map +1 -1
  137. package/dist/components/image-cropper.js +1 -164
  138. package/dist/components/image-cropper.js.map +1 -1
  139. package/dist/components/input-group.js +6 -268
  140. package/dist/components/input-group.js.map +1 -1
  141. package/dist/components/input.js +3 -58
  142. package/dist/components/input.js.map +1 -1
  143. package/dist/components/label.js +3 -38
  144. package/dist/components/label.js.map +1 -1
  145. package/dist/components/list-empty-row.js +2 -21
  146. package/dist/components/list-empty-row.js.map +1 -1
  147. package/dist/components/management-empty.js +2 -21
  148. package/dist/components/management-empty.js.map +1 -1
  149. package/dist/components/management-skeleton.js +4 -59
  150. package/dist/components/management-skeleton.js.map +1 -1
  151. package/dist/components/meta-chip.js +2 -21
  152. package/dist/components/meta-chip.js.map +1 -1
  153. package/dist/components/mobile-drawer.js +7 -268
  154. package/dist/components/mobile-drawer.js.map +1 -1
  155. package/dist/components/page-header.js +3 -42
  156. package/dist/components/page-header.js.map +1 -1
  157. package/dist/components/page-scaffold.js +5 -76
  158. package/dist/components/page-scaffold.js.map +1 -1
  159. package/dist/components/pagination-bar.js +13 -614
  160. package/dist/components/pagination-bar.js.map +1 -1
  161. package/dist/components/pagination.js +6 -681
  162. package/dist/components/pagination.js.map +1 -1
  163. package/dist/components/panel-toolbar.js +11 -713
  164. package/dist/components/panel-toolbar.js.map +1 -1
  165. package/dist/components/pill-tabs.js +2 -21
  166. package/dist/components/pill-tabs.js.map +1 -1
  167. package/dist/components/plugin-download-consent.js +13 -663
  168. package/dist/components/plugin-download-consent.js.map +1 -1
  169. package/dist/components/popover.js +5 -242
  170. package/dist/components/popover.js.map +1 -1
  171. package/dist/components/preview-card.js +2 -21
  172. package/dist/components/preview-card.js.map +1 -1
  173. package/dist/components/progress.js +2 -20
  174. package/dist/components/progress.js.map +1 -1
  175. package/dist/components/radio-group.js +2 -21
  176. package/dist/components/radio-group.js.map +1 -1
  177. package/dist/components/scroll-area.js +2 -21
  178. package/dist/components/scroll-area.js.map +1 -1
  179. package/dist/components/search-field.js +6 -587
  180. package/dist/components/search-field.js.map +1 -1
  181. package/dist/components/secondary-stat.js +3 -40
  182. package/dist/components/secondary-stat.js.map +1 -1
  183. package/dist/components/section-header.js +3 -43
  184. package/dist/components/section-header.js.map +1 -1
  185. package/dist/components/section-label.js +3 -44
  186. package/dist/components/section-label.js.map +1 -1
  187. package/dist/components/section-tabs.js +2 -21
  188. package/dist/components/section-tabs.js.map +1 -1
  189. package/dist/components/separator.js +3 -47
  190. package/dist/components/separator.js.map +1 -1
  191. package/dist/components/sheet.js +8 -467
  192. package/dist/components/sheet.js.map +1 -1
  193. package/dist/components/sidebar.js +24 -1044
  194. package/dist/components/sidebar.js.map +1 -1
  195. package/dist/components/skeleton.js +3 -39
  196. package/dist/components/skeleton.js.map +1 -1
  197. package/dist/components/slider.js +2 -21
  198. package/dist/components/slider.js.map +1 -1
  199. package/dist/components/sortable-chip-list.js +2 -21
  200. package/dist/components/sortable-chip-list.js.map +1 -1
  201. package/dist/components/special-tag-surface.js +3 -531
  202. package/dist/components/special-tag-surface.js.map +1 -1
  203. package/dist/components/spinner.js +3 -63
  204. package/dist/components/spinner.js.map +1 -1
  205. package/dist/components/surface.js +3 -49
  206. package/dist/components/surface.js.map +1 -1
  207. package/dist/components/switch.js +3 -51
  208. package/dist/components/switch.js.map +1 -1
  209. package/dist/components/table.js +2 -20
  210. package/dist/components/table.js.map +1 -1
  211. package/dist/components/tag-chip.js +6 -617
  212. package/dist/components/tag-chip.js.map +1 -1
  213. package/dist/components/textarea.js +3 -56
  214. package/dist/components/textarea.js.map +1 -1
  215. package/dist/components/toast.js +8 -806
  216. package/dist/components/toast.js.map +1 -1
  217. package/dist/components/toggle.js +2 -20
  218. package/dist/components/toggle.js.map +1 -1
  219. package/dist/components/tooltip.js +3 -80
  220. package/dist/components/tooltip.js.map +1 -1
  221. package/dist/hooks/use-dialog-footer-actions.js +1 -9
  222. package/dist/hooks/use-dialog-footer-actions.js.map +1 -1
  223. package/dist/hooks/use-form-field.js +1 -34
  224. package/dist/hooks/use-form-field.js.map +1 -1
  225. package/dist/hooks/use-mobile.js +2 -27
  226. package/dist/hooks/use-mobile.js.map +1 -1
  227. package/dist/hooks/useMobileBackToClose.js +3 -232
  228. package/dist/hooks/useMobileBackToClose.js.map +1 -1
  229. package/dist/icons/actions.js +4 -521
  230. package/dist/icons/actions.js.map +1 -1
  231. package/dist/icons/icon-style.js +1 -49
  232. package/dist/icons/icon-style.js.map +1 -1
  233. package/dist/icons/marks.js +1 -46
  234. package/dist/icons/marks.js.map +1 -1
  235. package/dist/icons/registry.d.ts +2 -1
  236. package/dist/icons/registry.js +2 -1186
  237. package/dist/icons/registry.js.map +1 -1
  238. package/dist/index.js +10 -651
  239. package/dist/index.js.map +1 -1
  240. package/dist/lib/colors.js +1 -63
  241. package/dist/lib/colors.js.map +1 -1
  242. package/dist/lib/merge-config.js +1 -18
  243. package/dist/lib/merge-config.js.map +1 -1
  244. package/dist/lib/pagination.js +1 -24
  245. package/dist/lib/pagination.js.map +1 -1
  246. package/dist/lib/tag-surface.js +5 -613
  247. package/dist/lib/tag-surface.js.map +1 -1
  248. package/dist/lib/utils.js +2 -24
  249. package/dist/lib/utils.js.map +1 -1
  250. package/dist/res-card-template/format.d.ts +21 -0
  251. package/dist/res-card-template/format.js +3 -0
  252. package/dist/res-card-template/format.js.map +1 -0
  253. package/dist/res-card-template/icon.d.ts +38 -0
  254. package/dist/res-card-template/icon.js +3 -0
  255. package/dist/res-card-template/icon.js.map +1 -0
  256. package/dist/res-card-template/index.d.ts +4 -0
  257. package/dist/res-card-template/index.js +5 -0
  258. package/dist/res-card-template/index.js.map +1 -0
  259. package/dist/res-card-template/template.d.ts +48 -0
  260. package/dist/res-card-template/template.js +5 -0
  261. package/dist/res-card-template/template.js.map +1 -0
  262. package/dist/viewport.js +1 -11
  263. package/dist/viewport.js.map +1 -1
  264. package/package.json +9 -2
  265. package/src/components/image-crop-panel.dist.test.tsx +54 -0
  266. package/src/icons/registry.ts +8 -0
  267. package/src/res-card-template/format.test.ts +45 -0
  268. package/src/res-card-template/format.ts +36 -0
  269. package/src/res-card-template/icon.test.ts +100 -0
  270. package/src/res-card-template/icon.ts +86 -0
  271. package/src/res-card-template/index.ts +22 -0
  272. package/src/res-card-template/template.test.ts +457 -0
  273. package/src/res-card-template/template.ts +429 -0
@@ -1,668 +1,18 @@
1
- import * as React from 'react';
2
- import { createContext, useState, useEffect, useRef, useMemo } from 'react';
3
- import { Dialog as Dialog$1 } from '@base-ui/react/dialog';
1
+ import { Checkbox } from '../chunk-3ZQJWBVB.js';
2
+ import { AppDialog } from '../chunk-2BVZEYNW.js';
3
+ import '../chunk-6HAIUXNZ.js';
4
+ import '../chunk-KOFWEPPB.js';
5
+ import '../chunk-TDDHQZ62.js';
6
+ import '../chunk-QGMDWGJT.js';
7
+ import '../chunk-XBPQEZES.js';
8
+ import '../chunk-KNPRUZ4H.js';
9
+ import { Button } from '../chunk-PWJBHUM2.js';
10
+ import '../chunk-M5OJN54O.js';
11
+ import '../chunk-2HWSCY4T.js';
12
+ import { useState, useEffect } from 'react';
4
13
  import { useTranslation } from 'react-i18next';
5
- import { clsx } from 'clsx';
6
- import { extendTailwindMerge } from 'tailwind-merge';
7
- import { Button as Button$1 } from '@base-ui/react/button';
8
- import { cva } from 'class-variance-authority';
9
14
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
10
- import 'react-use';
11
- import { Checkbox as Checkbox$1 } from '@base-ui/react/checkbox';
12
15
 
13
- // src/components/dialog.tsx
14
- var mergeTheme = {
15
- text: ["tiny", "ui", "doc", "doc-title", "doc-heading", "quote"],
16
- spacing: ["chip", "control", "nav", "sidebar", "panel"],
17
- tracking: ["label"],
18
- shadow: ["card", "dialog"],
19
- container: ["reading", "medium", "content"],
20
- font: ["doc", "heading"],
21
- ease: ["standard"],
22
- animate: ["skel", "pop"]
23
- };
24
- var twMerge = extendTailwindMerge({
25
- extend: { theme: mergeTheme }
26
- });
27
-
28
- // src/lib/utils.ts
29
- function cn(...inputs) {
30
- return twMerge(clsx(inputs));
31
- }
32
- var buttonVariants = cva(
33
- "group/button inline-flex shrink-0 items-center justify-center rounded-lg text-ui font-medium whitespace-nowrap outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
34
- {
35
- variants: {
36
- variant: {
37
- default: "bg-primary px-4! text-primary-foreground hover:bg-primary/80",
38
- outline: "border-border bg-background shadow-xs hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
39
- secondary: "bg-secondary text-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-foreground",
40
- ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
41
- destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
42
- danger: "bg-[color-mix(in_oklab,var(--destructive),black_12%)] text-white hover:bg-[color-mix(in_oklab,var(--destructive),black_4%)] focus-visible:border-destructive/40 focus-visible:ring-destructive/20 disabled:bg-destructive/10 disabled:text-muted-foreground dark:focus-visible:ring-destructive/40",
43
- link: "text-primary underline-offset-4 hover:underline"
44
- },
45
- size: {
46
- default: "h-control gap-2 px-3 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
47
- xs: "h-6 gap-2 rounded-[min(var(--radius-md),8px)] px-2 text-xs in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
48
- sm: "h-chip gap-2 rounded-[min(var(--radius-md),10px)] px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5",
49
- lg: "h-10 gap-2 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
50
- icon: "size-9",
51
- "icon-xs": "size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3",
52
- "icon-sm": "size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md",
53
- "icon-lg": "size-10"
54
- }
55
- },
56
- defaultVariants: {
57
- variant: "default",
58
- size: "default"
59
- }
60
- }
61
- );
62
- function Button({
63
- active,
64
- className,
65
- variant = "default",
66
- size = "default",
67
- ...props
68
- }) {
69
- return /* @__PURE__ */ jsx(
70
- Button$1,
71
- {
72
- "data-slot": "button",
73
- className: cn(
74
- buttonVariants({ variant, size, className }),
75
- active && "bg-accent text-accent-foreground hover:bg-accent"
76
- ),
77
- ...props
78
- }
79
- );
80
- }
81
-
82
- // src/viewport.ts
83
- var MOBILE_BREAKPOINT_PX = 768;
84
- var MOBILE_QUERY = `(max-width: ${MOBILE_BREAKPOINT_PX - 1}px)`;
85
- function isBelowMd() {
86
- if (typeof window === "undefined") return false;
87
- return window.matchMedia(MOBILE_QUERY).matches;
88
- }
89
- var HISTORY_KEY = "__appMobileOverlay";
90
- var overlayStack = [];
91
- var popListenerInstalled = false;
92
- var historyPatched = false;
93
- var nextOverlayId = 0;
94
- var suppressPopCount = 0;
95
- var seenSyntheticIds = /* @__PURE__ */ new Set();
96
- function patchHistory() {
97
- if (historyPatched) return;
98
- if (typeof window === "undefined") return;
99
- historyPatched = true;
100
- const origPush = window.history.pushState.bind(window.history);
101
- window.history.pushState = (data, unused, url) => {
102
- const state = data;
103
- if (state !== null && typeof state === "object" && HISTORY_KEY in state) {
104
- origPush(data, unused, url);
105
- return;
106
- }
107
- if (overlayStack.length > 0) {
108
- closeAllOverlays();
109
- }
110
- origPush(data, unused, url);
111
- };
112
- }
113
- function closeAllOverlays() {
114
- while (overlayStack.length > 0) {
115
- const entry = overlayStack.pop();
116
- if (entry?.close !== void 0) {
117
- const fn = entry.close;
118
- entry.close = void 0;
119
- fn();
120
- }
121
- }
122
- }
123
- function ensurePopListener() {
124
- if (popListenerInstalled) return;
125
- if (typeof window === "undefined") return;
126
- popListenerInstalled = true;
127
- window.addEventListener(
128
- "popstate",
129
- (e) => {
130
- if (suppressPopCount > 0) return;
131
- const state = e.state;
132
- if (state !== null && typeof state === "object" && HISTORY_KEY in state) {
133
- const id = state[HISTORY_KEY];
134
- if (typeof id === "number" && overlayStack.some((entry) => entry.id === id)) {
135
- closeTopOverlay();
136
- e.stopImmediatePropagation();
137
- return;
138
- }
139
- e.stopImmediatePropagation();
140
- if (typeof id === "number" && seenSyntheticIds.has(id)) {
141
- window.history.back();
142
- }
143
- }
144
- },
145
- true
146
- // capture phase
147
- );
148
- window.addEventListener("popstate", handlePop);
149
- patchHistory();
150
- }
151
- function closeTopOverlay() {
152
- const top = overlayStack.pop();
153
- if (top === void 0) return;
154
- if (top.close === void 0) return;
155
- const closeFn = top.close;
156
- top.close = void 0;
157
- closeFn();
158
- }
159
- function handlePop() {
160
- if (suppressPopCount > 0) {
161
- suppressPopCount--;
162
- return;
163
- }
164
- closeTopOverlay();
165
- }
166
- function removeFromStack(id) {
167
- const idx = overlayStack.findIndex((e) => e.id === id);
168
- if (idx === -1) return { removed: false, parkedBelow: 0 };
169
- const wasTop = idx === overlayStack.length - 1;
170
- if (!wasTop) {
171
- const entry = overlayStack[idx];
172
- if (entry !== void 0) entry.close = void 0;
173
- return { removed: true, parkedBelow: 0 };
174
- }
175
- overlayStack.pop();
176
- const remaining = overlayStack.splice(0, overlayStack.length);
177
- const active = remaining.filter((e) => e.close !== void 0);
178
- const parkedBelow = remaining.length - active.length;
179
- overlayStack.push(...active);
180
- return { removed: true, parkedBelow };
181
- }
182
- function scheduleStateRestore(id, baseState, parkedBelow) {
183
- function check() {
184
- const currentState = window.history.state;
185
- if (currentState === null || typeof currentState !== "object" || !(HISTORY_KEY in currentState) || currentState[HISTORY_KEY] !== id) {
186
- sweepParkedEntries();
187
- return;
188
- }
189
- const totalBacks = 1 + parkedBelow;
190
- let done = false;
191
- function restore() {
192
- if (done) return;
193
- done = true;
194
- window.removeEventListener("popstate", onPop);
195
- window.history.replaceState(baseState, "");
196
- const sweptIds = sweepParkedEntries();
197
- cleanupSeenIds(sweptIds);
198
- }
199
- function onPop() {
200
- if (suppressPopCount > 0) {
201
- suppressPopCount--;
202
- return;
203
- }
204
- restore();
205
- }
206
- window.addEventListener("popstate", onPop);
207
- suppressPopCount += totalBacks;
208
- for (let i = 0; i < totalBacks; i++) {
209
- window.history.back();
210
- }
211
- }
212
- let disposed = false;
213
- let rafId;
214
- function run() {
215
- if (disposed) return;
216
- disposed = true;
217
- if (rafId !== void 0) {
218
- cancelAnimationFrame(rafId);
219
- }
220
- check();
221
- }
222
- rafId = requestAnimationFrame(run);
223
- }
224
- function sweepParkedEntries() {
225
- const sweptIds = [];
226
- for (let i = overlayStack.length - 1; i >= 0; i--) {
227
- const entry = overlayStack[i];
228
- if (entry !== void 0 && entry.close === void 0) {
229
- sweptIds.push(entry.id);
230
- overlayStack.splice(i, 1);
231
- }
232
- }
233
- return sweptIds;
234
- }
235
- function cleanupSeenIds(sweptIds) {
236
- const activeIds = new Set(overlayStack.map((e) => e.id));
237
- for (const id of sweptIds) {
238
- if (!activeIds.has(id)) {
239
- seenSyntheticIds.delete(id);
240
- }
241
- }
242
- }
243
- function useMobileBackToClose(open, onOpenChange) {
244
- const idRef = useRef(void 0);
245
- const onChangeRef = useRef(onOpenChange);
246
- onChangeRef.current = onOpenChange;
247
- useEffect(() => {
248
- if (typeof window === "undefined") return;
249
- if (onChangeRef.current === void 0) return;
250
- if (!isBelowMd()) return;
251
- ensurePopListener();
252
- if (open === true && idRef.current === void 0) {
253
- const id = ++nextOverlayId;
254
- idRef.current = id;
255
- seenSyntheticIds.add(id);
256
- const baseState = window.history.state ?? null;
257
- window.history.pushState(
258
- {
259
- ...baseState ?? {},
260
- [HISTORY_KEY]: id
261
- },
262
- ""
263
- );
264
- overlayStack.push({
265
- id,
266
- baseState,
267
- close() {
268
- idRef.current = void 0;
269
- onChangeRef.current?.(false);
270
- }
271
- });
272
- return;
273
- }
274
- if (open !== true && idRef.current !== void 0) {
275
- const id = idRef.current;
276
- idRef.current = void 0;
277
- const entryIdx = overlayStack.findIndex((e) => e.id === id);
278
- const entry = entryIdx !== -1 ? overlayStack[entryIdx] : void 0;
279
- const { removed, parkedBelow } = removeFromStack(id);
280
- if (removed && entry !== void 0) {
281
- scheduleStateRestore(id, entry.baseState, parkedBelow);
282
- }
283
- }
284
- }, [open]);
285
- useEffect(() => {
286
- return () => {
287
- if (idRef.current !== void 0) {
288
- const id = idRef.current;
289
- idRef.current = void 0;
290
- const entryIdx = overlayStack.findIndex((e) => e.id === id);
291
- const entry = entryIdx !== -1 ? overlayStack[entryIdx] : void 0;
292
- const { removed, parkedBelow } = removeFromStack(id);
293
- if (removed && entry !== void 0) {
294
- scheduleStateRestore(id, entry.baseState, parkedBelow);
295
- }
296
- }
297
- };
298
- }, []);
299
- }
300
- function Mark({
301
- d,
302
- filled,
303
- className
304
- }) {
305
- return /* @__PURE__ */ jsx(
306
- "svg",
307
- {
308
- xmlns: "http://www.w3.org/2000/svg",
309
- viewBox: "0 0 24 24",
310
- fill: "none",
311
- className,
312
- children: filled ? /* @__PURE__ */ jsx("path", { d, fill: "currentColor" }) : /* @__PURE__ */ jsx(
313
- "path",
314
- {
315
- d,
316
- stroke: "currentColor",
317
- strokeWidth: "2",
318
- strokeLinecap: "round",
319
- strokeLinejoin: "round"
320
- }
321
- )
322
- }
323
- );
324
- }
325
- function Check(props) {
326
- return /* @__PURE__ */ jsx(Mark, { ...props, d: "M5 12.8l4.7 4.7L19 7.2" });
327
- }
328
- function Cross(props) {
329
- return /* @__PURE__ */ jsx(Mark, { ...props, d: "M6 6l12 12M18 6L6 18" });
330
- }
331
- function Dialog({
332
- open,
333
- defaultOpen,
334
- onOpenChange,
335
- ...props
336
- }) {
337
- const [uncontrolledOpen, setUncontrolledOpen] = React.useState(
338
- defaultOpen ?? false
339
- );
340
- const isControlled = open !== void 0;
341
- const currentOpen = isControlled ? open : uncontrolledOpen;
342
- function handleOpenChange(next, eventDetails) {
343
- if (!isControlled) setUncontrolledOpen(next);
344
- onOpenChange?.(next, eventDetails);
345
- }
346
- useMobileBackToClose(currentOpen, handleOpenChange);
347
- return /* @__PURE__ */ jsx(
348
- Dialog$1.Root,
349
- {
350
- "data-slot": "dialog",
351
- open: currentOpen,
352
- onOpenChange: handleOpenChange,
353
- ...props
354
- }
355
- );
356
- }
357
- function DialogPortal({ ...props }) {
358
- return /* @__PURE__ */ jsx(Dialog$1.Portal, { "data-slot": "dialog-portal", ...props });
359
- }
360
- function DialogOverlay({
361
- className,
362
- ...props
363
- }) {
364
- return /* @__PURE__ */ jsx(
365
- Dialog$1.Backdrop,
366
- {
367
- "data-slot": "dialog-overlay",
368
- className: cn(
369
- // The dialog layer: a static whisper-of-ink scrim plus
370
- // backdrop blur — part of the surface definition, not motion.
371
- "fixed inset-0 isolate z-50 bg-foreground/5 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-sm",
372
- className
373
- ),
374
- ...props
375
- }
376
- );
377
- }
378
- function DialogContent({
379
- className,
380
- children,
381
- showCloseButton = true,
382
- overlayClassName,
383
- contentMotion = "default",
384
- ...props
385
- }) {
386
- const { t } = useTranslation("ui", { useSuspense: false });
387
- const arranged = arrangeDialogChildren(children);
388
- const motionClasses = contentMotion === "minimal" ? "data-ending-style:opacity-0 data-starting-style:opacity-0" : cn(
389
- "data-ending-style:translate-y-10 data-ending-style:opacity-0 data-starting-style:translate-y-10 data-starting-style:opacity-0",
390
- // ≥ sm the popup is centred with -translate-y-1/2, so the
391
- // starting/ending styles must keep that offset (zoom + fade
392
- // only, no slide) instead of clobbering it with translate-y-0.
393
- "sm:data-ending-style:-translate-y-1/2 sm:data-ending-style:scale-95 sm:data-starting-style:-translate-y-1/2 sm:data-starting-style:scale-95"
394
- );
395
- return /* @__PURE__ */ jsxs(DialogPortal, { children: [
396
- /* @__PURE__ */ jsx(DialogOverlay, { className: overlayClassName }),
397
- /* @__PURE__ */ jsxs(
398
- Dialog$1.Popup,
399
- {
400
- "data-slot": "dialog-content",
401
- className: cn(
402
- // The floating-card anatomy: `bg-card`
403
- // hairline-bordered surface with the system's one deep shadow.
404
- // Mobile: bottom sheet occupying most of the viewport so edit
405
- // forms have room to breathe. The component never scrolls
406
- // itself; only the inner DialogBody does. Header/body/footer
407
- // parts are held apart by the card's section gap
408
- // (`gap-4` between the header document, the body and the
409
- // hairline footer).
410
- "fixed z-50 flex flex-col gap-4 bg-card text-sm text-card-foreground shadow-dialog outline-hidden transition duration-200 ease-in-out",
411
- "inset-x-0 bottom-0 max-h-[85svh] overflow-hidden rounded-t-2xl rounded-b-none border border-b-0 border-border",
412
- motionClasses,
413
- // ≥ sm: centred modal, allow up to 90vh.
414
- "sm:inset-x-auto sm:bottom-auto sm:top-1/2 sm:left-1/2 sm:w-full sm:max-w-md sm:max-h-[90vh] sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-2xl",
415
- className
416
- ),
417
- ...props,
418
- children: [
419
- arranged,
420
- showCloseButton && /* @__PURE__ */ jsxs(
421
- Dialog$1.Close,
422
- {
423
- "data-slot": "dialog-close",
424
- className: "absolute top-3 right-3 z-20 flex size-6 items-center justify-center rounded-md text-muted-foreground transition-colors duration-150 hover:bg-muted hover:text-foreground",
425
- children: [
426
- /* @__PURE__ */ jsx(Cross, { className: "size-3" }),
427
- /* @__PURE__ */ jsx("span", { className: "sr-only", children: t("aria.close") })
428
- ]
429
- }
430
- )
431
- ]
432
- }
433
- )
434
- ] });
435
- }
436
- function DialogHeader({ className, ...props }) {
437
- return /* @__PURE__ */ jsx(
438
- "div",
439
- {
440
- "data-slot": "dialog-header",
441
- className: cn(
442
- // The header document: the card's `p-5`
443
- // rhythm — 20px top and sides, no bottom padding — with the
444
- // eyebrow, title row and description stacked tight; the section
445
- // gap below separates it from the body.
446
- "flex shrink-0 flex-col bg-card px-5 pt-5",
447
- className
448
- ),
449
- ...props
450
- }
451
- );
452
- }
453
- function DialogBody({ className, ...props }) {
454
- return /* @__PURE__ */ jsx(
455
- "div",
456
- {
457
- "data-slot": "dialog-body",
458
- className: cn(
459
- "flex-1 overflow-y-auto overscroll-contain px-5",
460
- className
461
- ),
462
- ...props
463
- }
464
- );
465
- }
466
- function DialogFooter({
467
- className,
468
- flush = false,
469
- showCloseButton = false,
470
- children,
471
- ...props
472
- }) {
473
- return /* @__PURE__ */ jsxs(
474
- "div",
475
- {
476
- "data-slot": "dialog-footer",
477
- className: cn("flex shrink-0 flex-col bg-card", className),
478
- ...props,
479
- children: [
480
- /* @__PURE__ */ jsx(
481
- "div",
482
- {
483
- className: cn(
484
- "border-t border-border",
485
- flush ? "mx-4" : "mx-5"
486
- )
487
- }
488
- ),
489
- /* @__PURE__ */ jsxs(
490
- "div",
491
- {
492
- className: cn(
493
- // The hairline action bar: 16px above the
494
- // buttons, the card's bottom padding (20px) below.
495
- "flex flex-row justify-end flex-wrap gap-2",
496
- flush ? "p-4" : "px-5 pt-4 pb-5"
497
- ),
498
- children: [
499
- children,
500
- showCloseButton && /* @__PURE__ */ jsx(Dialog$1.Close, { render: /* @__PURE__ */ jsx(Button, { variant: "outline" }), children: "Close" })
501
- ]
502
- }
503
- )
504
- ]
505
- }
506
- );
507
- }
508
- function DialogTitle({ className, ...props }) {
509
- return /* @__PURE__ */ jsx(
510
- Dialog$1.Title,
511
- {
512
- "data-slot": "dialog-title",
513
- className: cn("text-sm font-semibold", className),
514
- ...props
515
- }
516
- );
517
- }
518
- function DialogDescription({
519
- className,
520
- ...props
521
- }) {
522
- return /* @__PURE__ */ jsx(
523
- Dialog$1.Description,
524
- {
525
- "data-slot": "dialog-description",
526
- className: cn(
527
- "text-xs leading-5 text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
528
- className
529
- ),
530
- ...props
531
- }
532
- );
533
- }
534
- function arrangeDialogChildren(children) {
535
- const headers = [];
536
- const footers = [];
537
- const bodyNodes = [];
538
- let hasExplicitBody = false;
539
- React.Children.forEach(children, (child) => {
540
- if (!React.isValidElement(child)) {
541
- bodyNodes.push(child);
542
- return;
543
- }
544
- if (child.type === DialogHeader) {
545
- headers.push(child);
546
- return;
547
- }
548
- if (child.type === DialogFooter) {
549
- footers.push(child);
550
- return;
551
- }
552
- if (child.type === DialogBody) {
553
- hasExplicitBody = true;
554
- bodyNodes.push(child);
555
- return;
556
- }
557
- bodyNodes.push(child);
558
- });
559
- const body = hasExplicitBody ? bodyNodes : /* @__PURE__ */ jsx(DialogBody, { children: bodyNodes });
560
- return /* @__PURE__ */ jsxs(Fragment, { children: [
561
- headers,
562
- body,
563
- footers
564
- ] });
565
- }
566
- var DialogFooterActionsContext = createContext(null);
567
- var sizeClasses = {
568
- sm: "sm:max-w-sm",
569
- md: "sm:max-w-md",
570
- lg: "sm:max-w-2xl",
571
- xl: "sm:max-w-3xl",
572
- "2xl": "sm:max-w-4xl"
573
- };
574
- function AppDialog(props) {
575
- const {
576
- open,
577
- onOpenChange,
578
- title,
579
- eyebrow,
580
- icon,
581
- danger,
582
- size,
583
- flush,
584
- description,
585
- children,
586
- footer,
587
- contentClassName,
588
- overlayClassName,
589
- contentMotion,
590
- suppressAutoFocus = true,
591
- contentTestId
592
- } = props;
593
- const contentRef = useRef(null);
594
- const [footerActions, setFooterActions] = useState(null);
595
- const actionsValue = useMemo(
596
- () => ({ setFooterActions }),
597
- [setFooterActions]
598
- );
599
- return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(
600
- DialogContent,
601
- {
602
- ref: contentRef,
603
- className: cn(
604
- size !== void 0 && sizeClasses[size],
605
- flush && "p-0",
606
- contentClassName
607
- ),
608
- overlayClassName,
609
- contentMotion,
610
- initialFocus: suppressAutoFocus ? contentRef : void 0,
611
- "data-testid": contentTestId,
612
- children: [
613
- /* @__PURE__ */ jsxs(DialogHeader, { className: flush ? "gap-4" : void 0, children: [
614
- eyebrow !== void 0 ? /* @__PURE__ */ jsx(
615
- "span",
616
- {
617
- className: cn(
618
- "text-tiny font-semibold tracking-label uppercase",
619
- danger ? "text-destructive" : "text-muted-foreground"
620
- ),
621
- children: eyebrow
622
- }
623
- ) : null,
624
- /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-3 pr-6", children: [
625
- icon,
626
- /* @__PURE__ */ jsx(
627
- DialogTitle,
628
- {
629
- className: cn("truncate", danger && "text-destructive"),
630
- children: title
631
- }
632
- )
633
- ] }),
634
- description !== void 0 ? /* @__PURE__ */ jsx(DialogDescription, { children: description }) : null
635
- ] }),
636
- /* @__PURE__ */ jsx(DialogBody, { className: flush ? "p-0" : void 0, children: /* @__PURE__ */ jsx(DialogFooterActionsContext.Provider, { value: actionsValue, children }) }),
637
- footer !== void 0 && footer !== null || footerActions !== null ? /* @__PURE__ */ jsxs(DialogFooter, { flush, children: [
638
- footer,
639
- footerActions
640
- ] }) : null
641
- ]
642
- }
643
- ) });
644
- }
645
- function Checkbox({ className, ...props }) {
646
- return /* @__PURE__ */ jsx(
647
- Checkbox$1.Root,
648
- {
649
- "data-slot": "checkbox",
650
- className: cn(
651
- "peer relative flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-sm bg-muted outline-none group-has-disabled/field:opacity-50 focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:bg-destructive/20 aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-checked:bg-primary data-checked:text-primary-foreground",
652
- className
653
- ),
654
- ...props,
655
- children: /* @__PURE__ */ jsx(
656
- Checkbox$1.Indicator,
657
- {
658
- "data-slot": "checkbox-indicator",
659
- className: "grid place-content-center text-current [&>svg]:size-3",
660
- children: /* @__PURE__ */ jsx(Check, {})
661
- }
662
- )
663
- }
664
- );
665
- }
666
16
  function CloseConfirmDialog(props) {
667
17
  const { open, onOpenChange, onDecide } = props;
668
18
  const { t } = useTranslation("ui", { useSuspense: false });