@goplusvn/core 0.1.1 → 0.1.3

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 (223) hide show
  1. package/package.json +31 -175
  2. package/dist/audit/index.d.mts +0 -115
  3. package/dist/audit/index.d.ts +0 -115
  4. package/dist/audit/index.js +0 -204
  5. package/dist/audit/index.js.map +0 -1
  6. package/dist/audit/index.mjs +0 -200
  7. package/dist/audit/index.mjs.map +0 -1
  8. package/dist/auth/index.d.mts +0 -86
  9. package/dist/auth/index.d.ts +0 -86
  10. package/dist/auth/index.js +0 -210
  11. package/dist/auth/index.js.map +0 -1
  12. package/dist/auth/index.mjs +0 -198
  13. package/dist/auth/index.mjs.map +0 -1
  14. package/dist/button-1dWvP9Ib.d.mts +0 -30
  15. package/dist/button-1dWvP9Ib.d.ts +0 -30
  16. package/dist/calendar-2QzdEo1z.d.mts +0 -20
  17. package/dist/calendar-2QzdEo1z.d.ts +0 -20
  18. package/dist/code-generation/index.d.mts +0 -30
  19. package/dist/code-generation/index.d.ts +0 -30
  20. package/dist/code-generation/index.js +0 -31
  21. package/dist/code-generation/index.js.map +0 -1
  22. package/dist/code-generation/index.mjs +0 -28
  23. package/dist/code-generation/index.mjs.map +0 -1
  24. package/dist/configs/index.d.mts +0 -175
  25. package/dist/configs/index.d.ts +0 -175
  26. package/dist/configs/index.js +0 -254
  27. package/dist/configs/index.js.map +0 -1
  28. package/dist/configs/index.mjs +0 -233
  29. package/dist/configs/index.mjs.map +0 -1
  30. package/dist/crud/index.d.mts +0 -646
  31. package/dist/crud/index.d.ts +0 -646
  32. package/dist/crud/index.js +0 -11772
  33. package/dist/crud/index.js.map +0 -1
  34. package/dist/crud/index.mjs +0 -11665
  35. package/dist/crud/index.mjs.map +0 -1
  36. package/dist/crud/server.d.mts +0 -20
  37. package/dist/crud/server.d.ts +0 -20
  38. package/dist/crud/server.js +0 -123
  39. package/dist/crud/server.js.map +0 -1
  40. package/dist/crud/server.mjs +0 -120
  41. package/dist/crud/server.mjs.map +0 -1
  42. package/dist/data-table-skeleton-12NA8Mjx.d.mts +0 -39
  43. package/dist/data-table-skeleton-12NA8Mjx.d.ts +0 -39
  44. package/dist/dialog-bKfjZMTd.d.mts +0 -22
  45. package/dist/dialog-bKfjZMTd.d.ts +0 -22
  46. package/dist/dynamic-icon-DrGIiu2N.d.mts +0 -10
  47. package/dist/dynamic-icon-DrGIiu2N.d.ts +0 -10
  48. package/dist/home/index.d.mts +0 -269
  49. package/dist/home/index.d.ts +0 -269
  50. package/dist/home/index.js +0 -1678
  51. package/dist/home/index.js.map +0 -1
  52. package/dist/home/index.mjs +0 -1635
  53. package/dist/home/index.mjs.map +0 -1
  54. package/dist/hooks/index.d.mts +0 -7
  55. package/dist/hooks/index.d.ts +0 -7
  56. package/dist/hooks/index.js +0 -8316
  57. package/dist/hooks/index.js.map +0 -1
  58. package/dist/hooks/index.mjs +0 -8255
  59. package/dist/hooks/index.mjs.map +0 -1
  60. package/dist/index-50hpiPrV.d.ts +0 -116
  61. package/dist/index-B9zQVEVi.d.mts +0 -116
  62. package/dist/index.d.mts +0 -5
  63. package/dist/index.d.ts +0 -5
  64. package/dist/index.js +0 -123
  65. package/dist/index.js.map +0 -1
  66. package/dist/index.mjs +0 -118
  67. package/dist/index.mjs.map +0 -1
  68. package/dist/infrastructure/index.d.mts +0 -423
  69. package/dist/infrastructure/index.d.ts +0 -423
  70. package/dist/infrastructure/index.js +0 -633
  71. package/dist/infrastructure/index.js.map +0 -1
  72. package/dist/infrastructure/index.mjs +0 -619
  73. package/dist/infrastructure/index.mjs.map +0 -1
  74. package/dist/label-DWTEkNPo.d.ts +0 -226
  75. package/dist/label-LPpdcoBx.d.mts +0 -226
  76. package/dist/layout/index.d.mts +0 -48
  77. package/dist/layout/index.d.ts +0 -48
  78. package/dist/layout/index.js +0 -117
  79. package/dist/layout/index.js.map +0 -1
  80. package/dist/layout/index.mjs +0 -90
  81. package/dist/layout/index.mjs.map +0 -1
  82. package/dist/navigation/index.d.mts +0 -16
  83. package/dist/navigation/index.d.ts +0 -16
  84. package/dist/navigation/index.js +0 -53
  85. package/dist/navigation/index.js.map +0 -1
  86. package/dist/navigation/index.mjs +0 -50
  87. package/dist/navigation/index.mjs.map +0 -1
  88. package/dist/notification/index.d.mts +0 -105
  89. package/dist/notification/index.d.ts +0 -105
  90. package/dist/notification/index.js +0 -278
  91. package/dist/notification/index.js.map +0 -1
  92. package/dist/notification/index.mjs +0 -274
  93. package/dist/notification/index.mjs.map +0 -1
  94. package/dist/organization/index.d.mts +0 -99
  95. package/dist/organization/index.d.ts +0 -99
  96. package/dist/organization/index.js +0 -360
  97. package/dist/organization/index.js.map +0 -1
  98. package/dist/organization/index.mjs +0 -352
  99. package/dist/organization/index.mjs.map +0 -1
  100. package/dist/plugin/index.d.mts +0 -83
  101. package/dist/plugin/index.d.ts +0 -83
  102. package/dist/plugin/index.js +0 -86
  103. package/dist/plugin/index.js.map +0 -1
  104. package/dist/plugin/index.mjs +0 -84
  105. package/dist/plugin/index.mjs.map +0 -1
  106. package/dist/providers/index.d.mts +0 -25
  107. package/dist/providers/index.d.ts +0 -25
  108. package/dist/providers/index.js +0 -84
  109. package/dist/providers/index.js.map +0 -1
  110. package/dist/providers/index.mjs +0 -77
  111. package/dist/providers/index.mjs.map +0 -1
  112. package/dist/rbac/index.d.mts +0 -226
  113. package/dist/rbac/index.d.ts +0 -226
  114. package/dist/rbac/index.js +0 -4784
  115. package/dist/rbac/index.js.map +0 -1
  116. package/dist/rbac/index.mjs +0 -4722
  117. package/dist/rbac/index.mjs.map +0 -1
  118. package/dist/rbac/permissions.d.mts +0 -26
  119. package/dist/rbac/permissions.d.ts +0 -26
  120. package/dist/rbac/permissions.js +0 -94
  121. package/dist/rbac/permissions.js.map +0 -1
  122. package/dist/rbac/permissions.mjs +0 -90
  123. package/dist/rbac/permissions.mjs.map +0 -1
  124. package/dist/rbac/server.d.mts +0 -1
  125. package/dist/rbac/server.d.ts +0 -1
  126. package/dist/rbac/server.js +0 -128
  127. package/dist/rbac/server.js.map +0 -1
  128. package/dist/rbac/server.mjs +0 -124
  129. package/dist/rbac/server.mjs.map +0 -1
  130. package/dist/schemas/index.d.mts +0 -1257
  131. package/dist/schemas/index.d.ts +0 -1257
  132. package/dist/schemas/index.js +0 -572
  133. package/dist/schemas/index.js.map +0 -1
  134. package/dist/schemas/index.mjs +0 -523
  135. package/dist/schemas/index.mjs.map +0 -1
  136. package/dist/server-QuYCTa89.d.mts +0 -83
  137. package/dist/server-QuYCTa89.d.ts +0 -83
  138. package/dist/sonner-C74GlRDQ.d.mts +0 -71
  139. package/dist/sonner-C74GlRDQ.d.ts +0 -71
  140. package/dist/status-BOXZgIqX.d.mts +0 -12
  141. package/dist/status-BOXZgIqX.d.ts +0 -12
  142. package/dist/system/index.d.mts +0 -77
  143. package/dist/system/index.d.ts +0 -77
  144. package/dist/system/index.js +0 -102
  145. package/dist/system/index.js.map +0 -1
  146. package/dist/system/index.mjs +0 -100
  147. package/dist/system/index.mjs.map +0 -1
  148. package/dist/tabs-C6FfBwPY.d.mts +0 -18
  149. package/dist/tabs-C6FfBwPY.d.ts +0 -18
  150. package/dist/tenant-provider-B8eC_Wpb.d.mts +0 -27
  151. package/dist/tenant-provider-B8eC_Wpb.d.ts +0 -27
  152. package/dist/types/index.d.mts +0 -469
  153. package/dist/types/index.d.ts +0 -469
  154. package/dist/types/index.js +0 -25
  155. package/dist/types/index.js.map +0 -1
  156. package/dist/types/index.mjs +0 -21
  157. package/dist/types/index.mjs.map +0 -1
  158. package/dist/ui/auth.d.mts +0 -39
  159. package/dist/ui/auth.d.ts +0 -39
  160. package/dist/ui/auth.js +0 -4941
  161. package/dist/ui/auth.js.map +0 -1
  162. package/dist/ui/auth.mjs +0 -4896
  163. package/dist/ui/auth.mjs.map +0 -1
  164. package/dist/ui/crud.d.mts +0 -2
  165. package/dist/ui/crud.d.ts +0 -2
  166. package/dist/ui/crud.js +0 -4
  167. package/dist/ui/crud.js.map +0 -1
  168. package/dist/ui/crud.mjs +0 -3
  169. package/dist/ui/crud.mjs.map +0 -1
  170. package/dist/ui/data-display.d.mts +0 -596
  171. package/dist/ui/data-display.d.ts +0 -596
  172. package/dist/ui/data-display.js +0 -5307
  173. package/dist/ui/data-display.js.map +0 -1
  174. package/dist/ui/data-display.mjs +0 -5212
  175. package/dist/ui/data-display.mjs.map +0 -1
  176. package/dist/ui/feedback.d.mts +0 -55
  177. package/dist/ui/feedback.d.ts +0 -55
  178. package/dist/ui/feedback.js +0 -2608
  179. package/dist/ui/feedback.js.map +0 -1
  180. package/dist/ui/feedback.mjs +0 -2526
  181. package/dist/ui/feedback.mjs.map +0 -1
  182. package/dist/ui/forms.d.mts +0 -309
  183. package/dist/ui/forms.d.ts +0 -309
  184. package/dist/ui/forms.js +0 -4656
  185. package/dist/ui/forms.js.map +0 -1
  186. package/dist/ui/forms.mjs +0 -4571
  187. package/dist/ui/forms.mjs.map +0 -1
  188. package/dist/ui/index.d.mts +0 -331
  189. package/dist/ui/index.d.ts +0 -331
  190. package/dist/ui/index.js +0 -16953
  191. package/dist/ui/index.js.map +0 -1
  192. package/dist/ui/index.mjs +0 -16598
  193. package/dist/ui/index.mjs.map +0 -1
  194. package/dist/ui/primitives/client.d.mts +0 -61
  195. package/dist/ui/primitives/client.d.ts +0 -61
  196. package/dist/ui/primitives/client.js +0 -3408
  197. package/dist/ui/primitives/client.js.map +0 -1
  198. package/dist/ui/primitives/client.mjs +0 -3256
  199. package/dist/ui/primitives/client.mjs.map +0 -1
  200. package/dist/ui/primitives.d.mts +0 -113
  201. package/dist/ui/primitives.d.ts +0 -113
  202. package/dist/ui/primitives.js +0 -3356
  203. package/dist/ui/primitives.js.map +0 -1
  204. package/dist/ui/primitives.mjs +0 -3227
  205. package/dist/ui/primitives.mjs.map +0 -1
  206. package/dist/user/index.d.mts +0 -228
  207. package/dist/user/index.d.ts +0 -228
  208. package/dist/user/index.js +0 -4306
  209. package/dist/user/index.js.map +0 -1
  210. package/dist/user/index.mjs +0 -4260
  211. package/dist/user/index.mjs.map +0 -1
  212. package/dist/utils/index.d.mts +0 -205
  213. package/dist/utils/index.d.ts +0 -205
  214. package/dist/utils/index.js +0 -574
  215. package/dist/utils/index.js.map +0 -1
  216. package/dist/utils/index.mjs +0 -514
  217. package/dist/utils/index.mjs.map +0 -1
  218. package/dist/workflow/index.d.mts +0 -40
  219. package/dist/workflow/index.d.ts +0 -40
  220. package/dist/workflow/index.js +0 -3710
  221. package/dist/workflow/index.js.map +0 -1
  222. package/dist/workflow/index.mjs +0 -3677
  223. package/dist/workflow/index.mjs.map +0 -1
@@ -1,4784 +0,0 @@
1
- 'use strict';
2
-
3
- var clsx = require('clsx');
4
- var tailwindMerge = require('tailwind-merge');
5
- var React12 = require('react');
6
- var classVarianceAuthority = require('class-variance-authority');
7
- var reactSlot = require('@radix-ui/react-slot');
8
- var jsxRuntime = require('react/jsx-runtime');
9
- var CheckboxPrimitive = require('@radix-ui/react-checkbox');
10
- var lucideReact = require('lucide-react');
11
- require('@radix-ui/react-dropdown-menu');
12
- var DialogPrimitive = require('@radix-ui/react-dialog');
13
- var TabsPrimitive = require('@radix-ui/react-tabs');
14
- require('next/link');
15
- var navigation = require('next/navigation');
16
- require('next/image');
17
- require('react-day-picker');
18
- var ScrollAreaPrimitive = require('@radix-ui/react-scroll-area');
19
- var SelectPrimitive = require('@radix-ui/react-select');
20
- require('@radix-ui/react-popover');
21
- require('@radix-ui/react-switch');
22
- var LabelPrimitive = require('@radix-ui/react-label');
23
- var TooltipPrimitive = require('@radix-ui/react-tooltip');
24
- require('react-resizable-panels');
25
- require('@radix-ui/react-slider');
26
- require('@radix-ui/react-toggle');
27
- require('@radix-ui/react-toggle-group');
28
- require('@radix-ui/react-menubar');
29
- require('@radix-ui/react-navigation-menu');
30
- require('@radix-ui/react-context-menu');
31
- require('vaul');
32
- require('@radix-ui/react-progress');
33
- var sonner = require('sonner');
34
- require('framer-motion');
35
- var AvatarPrimitive = require('@radix-ui/react-avatar');
36
- var react = require('next-auth/react');
37
- require('react-use');
38
- require('@radix-ui/react-direction');
39
- var AlertDialogPrimitive = require('@radix-ui/react-alert-dialog');
40
- require('@radix-ui/react-radio-group');
41
- require('cmdk');
42
- require('date-fns');
43
- var dynamic = require('next/dynamic');
44
- require('emoji-picker-react');
45
- require('react-dropzone');
46
- require('input-otp');
47
- require('react-phone-number-input');
48
- require('@tiptap/extension-color');
49
- require('@tiptap/extension-image');
50
- require('@tiptap/extension-link');
51
- require('@tiptap/extension-placeholder');
52
- require('@tiptap/extension-text-align');
53
- require('@tiptap/extension-text-style');
54
- require('@tiptap/extension-typography');
55
- require('@tiptap/extension-underline');
56
- require('@tiptap/react');
57
- require('@tiptap/starter-kit');
58
- require('react-hook-form');
59
- require('recharts');
60
- require('embla-carousel-react');
61
- require('@radix-ui/react-accordion');
62
- require('@dnd-kit/sortable');
63
- require('@dnd-kit/utilities');
64
- require('@dnd-kit/core');
65
- require('react-dom');
66
- require('@radix-ui/react-aspect-ratio');
67
- require('hast-util-to-jsx-runtime');
68
- require('shiki/bundle/web');
69
- require('@radix-ui/react-collapsible');
70
- require('@radix-ui/react-hover-card');
71
- require('@hookform/resolvers/zod');
72
- var useSWR = require('swr');
73
-
74
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
75
-
76
- function _interopNamespace(e) {
77
- if (e && e.__esModule) return e;
78
- var n = Object.create(null);
79
- if (e) {
80
- Object.keys(e).forEach(function (k) {
81
- if (k !== 'default') {
82
- var d = Object.getOwnPropertyDescriptor(e, k);
83
- Object.defineProperty(n, k, d.get ? d : {
84
- enumerable: true,
85
- get: function () { return e[k]; }
86
- });
87
- }
88
- });
89
- }
90
- n.default = e;
91
- return Object.freeze(n);
92
- }
93
-
94
- var React12__namespace = /*#__PURE__*/_interopNamespace(React12);
95
- var CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespace(CheckboxPrimitive);
96
- var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
97
- var TabsPrimitive__namespace = /*#__PURE__*/_interopNamespace(TabsPrimitive);
98
- var ScrollAreaPrimitive__namespace = /*#__PURE__*/_interopNamespace(ScrollAreaPrimitive);
99
- var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive);
100
- var LabelPrimitive__namespace = /*#__PURE__*/_interopNamespace(LabelPrimitive);
101
- var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitive);
102
- var AvatarPrimitive__namespace = /*#__PURE__*/_interopNamespace(AvatarPrimitive);
103
- var AlertDialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(AlertDialogPrimitive);
104
- var dynamic__default = /*#__PURE__*/_interopDefault(dynamic);
105
- var useSWR__default = /*#__PURE__*/_interopDefault(useSWR);
106
-
107
- var __getOwnPropNames = Object.getOwnPropertyNames;
108
- var __esm = (fn, res) => function __init() {
109
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
110
- };
111
- function cn(...inputs) {
112
- return tailwindMerge.twMerge(clsx.clsx(inputs));
113
- }
114
- var Logger, logger;
115
- var init_utils = __esm({
116
- "src/utils/index.ts"() {
117
- Logger = class {
118
- log(level, message, context, error) {
119
- const entry = {
120
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
121
- level,
122
- message,
123
- context
124
- };
125
- if (error instanceof Error) {
126
- entry.error = {
127
- name: error.name,
128
- message: error.message,
129
- stack: error.stack
130
- };
131
- } else if (error) {
132
- entry.error = error;
133
- }
134
- const logString = JSON.stringify(entry);
135
- switch (level) {
136
- case "error":
137
- console.error(logString);
138
- break;
139
- case "warn":
140
- console.warn(logString);
141
- break;
142
- case "debug":
143
- if (process.env.NODE_ENV === "development") console.debug(logString);
144
- break;
145
- default:
146
- console.log(logString);
147
- }
148
- }
149
- info(message, context) {
150
- this.log("info", message, context);
151
- }
152
- warn(message, context) {
153
- this.log("warn", message, context);
154
- }
155
- error(message, error, context) {
156
- this.log("error", message, context, error);
157
- }
158
- debug(message, context) {
159
- this.log("debug", message, context);
160
- }
161
- };
162
- logger = new Logger();
163
- }
164
- });
165
- var buttonVariants, Button;
166
- var init_button = __esm({
167
- "src/ui/primitives/button.tsx"() {
168
- init_utils();
169
- buttonVariants = classVarianceAuthority.cva(
170
- "inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
171
- {
172
- variants: {
173
- variant: {
174
- // Existing variants (backwards-compatible)
175
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
176
- destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
177
- outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
178
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
179
- ghost: "hover:bg-accent hover:text-accent-foreground",
180
- link: "text-primary underline-offset-4 hover:underline",
181
- // New Plane-inspired variants using semantic tokens
182
- accent: "bg-accent-primary text-text-on-color hover:bg-accent-primary-hover active:bg-accent-primary-active disabled:bg-layer-disabled disabled:text-text-disabled",
183
- danger: "bg-danger text-text-on-color hover:bg-danger-hover active:bg-danger-hover disabled:bg-layer-disabled disabled:text-text-disabled",
184
- "danger-outline": "border border-danger bg-layer-2 text-danger-text hover:bg-danger-subtle active:bg-danger-subtle disabled:border-border-subtle disabled:bg-layer-2 disabled:text-text-disabled",
185
- success: "bg-success-semantic text-text-on-color hover:bg-success-semantic/90 active:bg-success-semantic/80 disabled:bg-layer-disabled disabled:text-text-disabled",
186
- tertiary: "bg-layer-3 text-text-secondary hover:bg-layer-3-hover active:bg-layer-3-hover disabled:bg-transparent disabled:text-text-disabled"
187
- },
188
- size: {
189
- // Existing sizes (backwards-compatible)
190
- default: "h-10 px-4 py-2",
191
- sm: "h-9 rounded-md px-3",
192
- lg: "h-11 rounded-md px-8",
193
- icon: "h-10 w-10",
194
- // New ERP-specific compact sizes
195
- xs: "h-7 rounded-sm px-2 text-xs",
196
- compact: "h-8 rounded-md px-3 text-xs",
197
- "icon-sm": "h-8 w-8",
198
- "icon-xs": "h-7 w-7"
199
- }
200
- },
201
- defaultVariants: {
202
- variant: "default",
203
- size: "default"
204
- }
205
- }
206
- );
207
- Button = React12__namespace.forwardRef(
208
- ({ className, variant, size, asChild = false, loading = false, prependIcon, appendIcon, children, disabled, ...props }, ref) => {
209
- if (asChild) {
210
- return /* @__PURE__ */ jsxRuntime.jsx(
211
- reactSlot.Slot,
212
- {
213
- className: cn(buttonVariants({ variant, size }), className),
214
- ref,
215
- ...{ disabled: disabled || loading },
216
- ...props,
217
- children: React12__namespace.isValidElement(children) && (prependIcon || appendIcon) ? React12__namespace.cloneElement(children, {}, /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
218
- prependIcon && React12__namespace.cloneElement(prependIcon, {
219
- className: cn("shrink-0", size === "xs" || size === "compact" ? "size-3.5" : "size-4")
220
- }),
221
- children.props.children,
222
- appendIcon && React12__namespace.cloneElement(appendIcon, {
223
- className: cn("shrink-0", size === "xs" || size === "compact" ? "size-3.5" : "size-4")
224
- })
225
- ] })) : children
226
- }
227
- );
228
- }
229
- return /* @__PURE__ */ jsxRuntime.jsxs(
230
- "button",
231
- {
232
- className: cn(buttonVariants({ variant, size }), className),
233
- ref,
234
- disabled: disabled || loading,
235
- ...props,
236
- children: [
237
- prependIcon && React12__namespace.cloneElement(prependIcon, {
238
- className: cn("shrink-0", size === "xs" || size === "compact" ? "size-3.5" : "size-4")
239
- }),
240
- children,
241
- appendIcon && React12__namespace.cloneElement(appendIcon, {
242
- className: cn("shrink-0", size === "xs" || size === "compact" ? "size-3.5" : "size-4")
243
- })
244
- ]
245
- }
246
- );
247
- }
248
- );
249
- Button.displayName = "Button";
250
- }
251
- });
252
- function Badge({ className, variant, size, ...props }) {
253
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(badgeVariants({ variant, size }), className), ...props });
254
- }
255
- var badgeVariants;
256
- var init_badge = __esm({
257
- "src/ui/primitives/badge.tsx"() {
258
- init_utils();
259
- badgeVariants = classVarianceAuthority.cva(
260
- "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
261
- {
262
- variants: {
263
- variant: {
264
- // Existing variants (backwards-compatible)
265
- default: "border-transparent bg-primary text-primary-foreground",
266
- secondary: "border-transparent bg-secondary text-secondary-foreground",
267
- destructive: "border-transparent bg-destructive text-destructive-foreground",
268
- outline: "text-foreground",
269
- // Enhanced semantic variants (using Design Tokens)
270
- success: "border-transparent bg-success-subtle text-success-text",
271
- warning: "border-transparent bg-warning-subtle text-warning-text",
272
- danger: "border-transparent bg-danger-subtle text-danger-text",
273
- info: "border-transparent bg-info-subtle text-info-text",
274
- accent: "border-transparent bg-accent-primary-subtle text-accent-primary"
275
- },
276
- size: {
277
- default: "",
278
- sm: "px-1.5 py-0 text-[10px]",
279
- lg: "px-3 py-1 text-sm"
280
- }
281
- },
282
- defaultVariants: {
283
- variant: "default",
284
- size: "default"
285
- }
286
- }
287
- );
288
- }
289
- });
290
- var Input;
291
- var init_input = __esm({
292
- "src/ui/primitives/input.tsx"() {
293
- init_utils();
294
- Input = React12__namespace.forwardRef(
295
- ({ className, type, ...props }, ref) => {
296
- return /* @__PURE__ */ jsxRuntime.jsx(
297
- "input",
298
- {
299
- type,
300
- className: cn(
301
- "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
302
- className
303
- ),
304
- ref,
305
- ...props
306
- }
307
- );
308
- }
309
- );
310
- Input.displayName = "Input";
311
- }
312
- });
313
- var Checkbox;
314
- var init_checkbox = __esm({
315
- "src/ui/primitives/checkbox.tsx"() {
316
- "use client";
317
- init_utils();
318
- Checkbox = React12__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
319
- CheckboxPrimitive__namespace.Root,
320
- {
321
- ref,
322
- className: cn(
323
- "peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
324
- className
325
- ),
326
- ...props,
327
- children: /* @__PURE__ */ jsxRuntime.jsx(
328
- CheckboxPrimitive__namespace.Indicator,
329
- {
330
- className: cn("flex items-center justify-center text-current"),
331
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4" })
332
- }
333
- )
334
- }
335
- ));
336
- Checkbox.displayName = CheckboxPrimitive__namespace.Root.displayName;
337
- }
338
- });
339
- var Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter;
340
- var init_card = __esm({
341
- "src/ui/primitives/card.tsx"() {
342
- init_utils();
343
- Card = React12__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
344
- "div",
345
- {
346
- ref,
347
- className: cn(
348
- "rounded-lg border bg-card text-card-foreground shadow-sm",
349
- className
350
- ),
351
- ...props
352
- }
353
- ));
354
- Card.displayName = "Card";
355
- CardHeader = React12__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
356
- "div",
357
- {
358
- ref,
359
- className: cn("flex flex-col space-y-1.5 p-6", className),
360
- ...props
361
- }
362
- ));
363
- CardHeader.displayName = "CardHeader";
364
- CardTitle = React12__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
365
- "h3",
366
- {
367
- ref,
368
- className: cn(
369
- "text-2xl font-semibold leading-none tracking-tight",
370
- className
371
- ),
372
- ...props
373
- }
374
- ));
375
- CardTitle.displayName = "CardTitle";
376
- CardDescription = React12__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
377
- "p",
378
- {
379
- ref,
380
- className: cn("text-sm text-muted-foreground", className),
381
- ...props
382
- }
383
- ));
384
- CardDescription.displayName = "CardDescription";
385
- CardContent = React12__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("p-6 pt-0", className), ...props }));
386
- CardContent.displayName = "CardContent";
387
- CardFooter = React12__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
388
- "div",
389
- {
390
- ref,
391
- className: cn("flex items-center p-6 pt-0", className),
392
- ...props
393
- }
394
- ));
395
- CardFooter.displayName = "CardFooter";
396
- }
397
- });
398
- var Separator;
399
- var init_separator = __esm({
400
- "src/ui/primitives/separator.tsx"() {
401
- init_utils();
402
- Separator = React12__namespace.forwardRef(
403
- ({ className, orientation = "horizontal", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
404
- "div",
405
- {
406
- ref,
407
- className: cn(
408
- "shrink-0 bg-border",
409
- orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
410
- className
411
- ),
412
- ...props
413
- }
414
- )
415
- );
416
- Separator.displayName = "Separator";
417
- }
418
- });
419
- var Table, TableHeader, TableBody, TableFooter, TableRow, TableHead, TableCell, TableCaption;
420
- var init_table = __esm({
421
- "src/ui/primitives/table.tsx"() {
422
- init_utils();
423
- Table = React12__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative w-full overflow-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
424
- "table",
425
- {
426
- ref,
427
- className: cn("w-max min-w-full caption-bottom text-xs", className),
428
- ...props
429
- }
430
- ) }));
431
- Table.displayName = "Table";
432
- TableHeader = React12__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("thead", { ref, className: cn("[&_tr]:border-b", className), ...props }));
433
- TableHeader.displayName = "TableHeader";
434
- TableBody = React12__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
435
- "tbody",
436
- {
437
- ref,
438
- className: cn("[&_tr:last-child]:border-0", className),
439
- ...props
440
- }
441
- ));
442
- TableBody.displayName = "TableBody";
443
- TableFooter = React12__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
444
- "tfoot",
445
- {
446
- ref,
447
- className: cn(
448
- "border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",
449
- className
450
- ),
451
- ...props
452
- }
453
- ));
454
- TableFooter.displayName = "TableFooter";
455
- TableRow = React12__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
456
- "tr",
457
- {
458
- ref,
459
- className: cn(
460
- "border-b transition-colors even:bg-muted/30 data-[state=selected]:bg-muted",
461
- className
462
- ),
463
- ...props
464
- }
465
- ));
466
- TableRow.displayName = "TableRow";
467
- TableHead = React12__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
468
- "th",
469
- {
470
- ref,
471
- className: cn(
472
- "h-9 px-3 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",
473
- className
474
- ),
475
- ...props
476
- }
477
- ));
478
- TableHead.displayName = "TableHead";
479
- TableCell = React12__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
480
- "td",
481
- {
482
- ref,
483
- className: cn("px-3 py-1.5 align-middle [&:has([role=checkbox])]:pr-0 text-xs", className),
484
- ...props
485
- }
486
- ));
487
- TableCell.displayName = "TableCell";
488
- TableCaption = React12__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
489
- "caption",
490
- {
491
- ref,
492
- className: cn("mt-4 text-sm text-muted-foreground", className),
493
- ...props
494
- }
495
- ));
496
- TableCaption.displayName = "TableCaption";
497
- }
498
- });
499
- var init_dropdown_menu = __esm({
500
- "src/ui/primitives/dropdown-menu.tsx"() {
501
- "use client";
502
- }
503
- });
504
- var Dialog, DialogPortal, DialogOverlay, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription;
505
- var init_dialog = __esm({
506
- "src/ui/primitives/dialog.tsx"() {
507
- "use client";
508
- init_utils();
509
- Dialog = DialogPrimitive__namespace.Root;
510
- DialogPortal = DialogPrimitive__namespace.Portal;
511
- DialogOverlay = React12__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
512
- DialogPrimitive__namespace.Overlay,
513
- {
514
- ref,
515
- className: cn(
516
- "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
517
- className
518
- ),
519
- ...props
520
- }
521
- ));
522
- DialogOverlay.displayName = DialogPrimitive__namespace.Overlay.displayName;
523
- DialogContent = React12__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(DialogPortal, { children: [
524
- /* @__PURE__ */ jsxRuntime.jsx(DialogOverlay, {}),
525
- /* @__PURE__ */ jsxRuntime.jsxs(
526
- DialogPrimitive__namespace.Content,
527
- {
528
- ref,
529
- className: cn(
530
- "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
531
- className
532
- ),
533
- ...props,
534
- children: [
535
- children,
536
- /* @__PURE__ */ jsxRuntime.jsxs(DialogPrimitive__namespace.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground", children: [
537
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-4 w-4" }),
538
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Close" })
539
- ] })
540
- ]
541
- }
542
- )
543
- ] }));
544
- DialogContent.displayName = DialogPrimitive__namespace.Content.displayName;
545
- DialogHeader = ({
546
- className,
547
- ...props
548
- }) => /* @__PURE__ */ jsxRuntime.jsx(
549
- "div",
550
- {
551
- className: cn(
552
- "flex flex-col space-y-1.5 text-center sm:text-left",
553
- className
554
- ),
555
- ...props
556
- }
557
- );
558
- DialogHeader.displayName = "DialogHeader";
559
- DialogFooter = ({
560
- className,
561
- ...props
562
- }) => /* @__PURE__ */ jsxRuntime.jsx(
563
- "div",
564
- {
565
- className: cn(
566
- "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
567
- className
568
- ),
569
- ...props
570
- }
571
- );
572
- DialogFooter.displayName = "DialogFooter";
573
- DialogTitle = React12__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
574
- DialogPrimitive__namespace.Title,
575
- {
576
- ref,
577
- className: cn(
578
- "text-lg font-semibold leading-none tracking-tight",
579
- className
580
- ),
581
- ...props
582
- }
583
- ));
584
- DialogTitle.displayName = DialogPrimitive__namespace.Title.displayName;
585
- DialogDescription = React12__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
586
- DialogPrimitive__namespace.Description,
587
- {
588
- ref,
589
- className: cn("text-sm text-muted-foreground", className),
590
- ...props
591
- }
592
- ));
593
- DialogDescription.displayName = DialogPrimitive__namespace.Description.displayName;
594
- }
595
- });
596
- var TabsList, TabsTrigger, TabsContent;
597
- var init_tabs = __esm({
598
- "src/ui/primitives/tabs.tsx"() {
599
- "use client";
600
- init_utils();
601
- TabsList = React12__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
602
- TabsPrimitive__namespace.List,
603
- {
604
- ref,
605
- className: cn(
606
- "inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",
607
- className
608
- ),
609
- ...props
610
- }
611
- ));
612
- TabsList.displayName = TabsPrimitive__namespace.List.displayName;
613
- TabsTrigger = React12__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
614
- TabsPrimitive__namespace.Trigger,
615
- {
616
- ref,
617
- className: cn(
618
- "inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",
619
- className
620
- ),
621
- ...props
622
- }
623
- ));
624
- TabsTrigger.displayName = TabsPrimitive__namespace.Trigger.displayName;
625
- TabsContent = React12__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
626
- TabsPrimitive__namespace.Content,
627
- {
628
- ref,
629
- className: cn(
630
- "mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
631
- className
632
- ),
633
- ...props
634
- }
635
- ));
636
- TabsContent.displayName = TabsPrimitive__namespace.Content.displayName;
637
- }
638
- });
639
- var init_breadcrumb = __esm({
640
- "src/ui/primitives/breadcrumb.tsx"() {
641
- }
642
- });
643
- var init_keyboard = __esm({
644
- "src/ui/primitives/keyboard.tsx"() {
645
- }
646
- });
647
- var init_pagination = __esm({
648
- "src/ui/primitives/pagination.tsx"() {
649
- }
650
- });
651
- var init_status_badge = __esm({
652
- "src/ui/primitives/status-badge.tsx"() {
653
- }
654
- });
655
- var init_command_menu = __esm({
656
- "src/ui/layout/command-menu.tsx"() {
657
- "use client";
658
- }
659
- });
660
- var init_logo = __esm({
661
- "src/ui/layout/logo.tsx"() {
662
- "use client";
663
- }
664
- });
665
- var init_sidebar_group_icon_menu = __esm({
666
- "src/ui/layout/sidebar-group-icon-menu.tsx"() {
667
- "use client";
668
- }
669
- });
670
- var init_sidebar = __esm({
671
- "src/ui/layout/sidebar.tsx"() {
672
- "use client";
673
- }
674
- });
675
- var init_calendar = __esm({
676
- "src/ui/primitives/calendar.tsx"() {
677
- "use client";
678
- init_utils();
679
- init_button();
680
- }
681
- });
682
- function ScrollArea({
683
- orientation,
684
- className,
685
- children,
686
- ...props
687
- }) {
688
- return /* @__PURE__ */ jsxRuntime.jsxs(
689
- ScrollAreaPrimitive__namespace.Root,
690
- {
691
- "data-slot": "scroll-area",
692
- className: cn("relative overflow-hidden", className),
693
- ...props,
694
- children: [
695
- /* @__PURE__ */ jsxRuntime.jsx(
696
- ScrollAreaPrimitive__namespace.Viewport,
697
- {
698
- "data-slot": "scroll-area-viewport",
699
- className: "h-full w-full rounded-[inherit]",
700
- children
701
- }
702
- ),
703
- /* @__PURE__ */ jsxRuntime.jsx(ScrollBar, { orientation }),
704
- /* @__PURE__ */ jsxRuntime.jsx(ScrollAreaPrimitive__namespace.Corner, {})
705
- ]
706
- }
707
- );
708
- }
709
- function ScrollBar({
710
- className,
711
- orientation = "vertical",
712
- ...props
713
- }) {
714
- return /* @__PURE__ */ jsxRuntime.jsx(
715
- ScrollAreaPrimitive__namespace.ScrollAreaScrollbar,
716
- {
717
- "data-slot": "scroll-area-scrollbar",
718
- orientation,
719
- className: cn(
720
- "flex touch-none select-none transition-colors",
721
- orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent p-[1px]",
722
- orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent p-[1px]",
723
- className
724
- ),
725
- ...props,
726
- children: /* @__PURE__ */ jsxRuntime.jsx(ScrollAreaPrimitive__namespace.ScrollAreaThumb, { className: "relative flex-1 rounded-full bg-border" })
727
- }
728
- );
729
- }
730
- var init_scroll_area = __esm({
731
- "src/ui/primitives/scroll-area.tsx"() {
732
- "use client";
733
- init_utils();
734
- }
735
- });
736
- var init_combobox = __esm({
737
- "src/ui/primitives/combobox.tsx"() {
738
- "use client";
739
- }
740
- });
741
- function Select({
742
- ...props
743
- }) {
744
- return /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Root, { "data-slot": "select", ...props });
745
- }
746
- function SelectValue({
747
- ...props
748
- }) {
749
- return /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Value, { "data-slot": "select-value", ...props });
750
- }
751
- function SelectTrigger({
752
- className,
753
- children,
754
- ...props
755
- }) {
756
- return /* @__PURE__ */ jsxRuntime.jsxs(
757
- SelectPrimitive__namespace.Trigger,
758
- {
759
- "data-slot": "select-trigger",
760
- className: cn(
761
- "cursor-pointer flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-hidden focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
762
- className
763
- ),
764
- ...props,
765
- children: [
766
- children,
767
- /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Icon, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "h-4 w-4 opacity-50" }) })
768
- ]
769
- }
770
- );
771
- }
772
- function SelectScrollUpButton({
773
- className,
774
- ...props
775
- }) {
776
- return /* @__PURE__ */ jsxRuntime.jsx(
777
- SelectPrimitive__namespace.ScrollUpButton,
778
- {
779
- "data-slot": "select-scroll-up-button",
780
- className: cn(
781
- "flex cursor-pointer items-center justify-center py-1",
782
- className
783
- ),
784
- ...props,
785
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUp, { className: "h-4 w-4" })
786
- }
787
- );
788
- }
789
- function SelectScrollDownButton({
790
- className,
791
- ...props
792
- }) {
793
- return /* @__PURE__ */ jsxRuntime.jsx(
794
- SelectPrimitive__namespace.ScrollDownButton,
795
- {
796
- "data-slot": "select-scroll-down-button",
797
- className: cn(
798
- "flex cursor-pointer items-center justify-center py-1",
799
- className
800
- ),
801
- ...props,
802
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "h-4 w-4" })
803
- }
804
- );
805
- }
806
- function SelectContent({
807
- className,
808
- children,
809
- position = "popper",
810
- ...props
811
- }) {
812
- return /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
813
- SelectPrimitive__namespace.Content,
814
- {
815
- "data-slot": "select-content",
816
- className: cn(
817
- "relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
818
- position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
819
- className
820
- ),
821
- position,
822
- ...props,
823
- children: [
824
- /* @__PURE__ */ jsxRuntime.jsx(SelectScrollUpButton, {}),
825
- /* @__PURE__ */ jsxRuntime.jsx(
826
- SelectPrimitive__namespace.Viewport,
827
- {
828
- className: cn(
829
- "p-1",
830
- position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
831
- ),
832
- children
833
- }
834
- ),
835
- /* @__PURE__ */ jsxRuntime.jsx(SelectScrollDownButton, {})
836
- ]
837
- }
838
- ) });
839
- }
840
- function SelectItem({
841
- className,
842
- children,
843
- ...props
844
- }) {
845
- return /* @__PURE__ */ jsxRuntime.jsxs(
846
- SelectPrimitive__namespace.Item,
847
- {
848
- "data-slot": "select-item",
849
- className: cn(
850
- "relative flex w-full cursor-pointer select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-hidden focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50",
851
- className
852
- ),
853
- ...props,
854
- children: [
855
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.ItemIndicator, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4" }) }) }),
856
- /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.ItemText, { children })
857
- ]
858
- }
859
- );
860
- }
861
- var init_select = __esm({
862
- "src/ui/primitives/select.tsx"() {
863
- "use client";
864
- init_utils();
865
- }
866
- });
867
- var init_popover = __esm({
868
- "src/ui/primitives/popover.tsx"() {
869
- "use client";
870
- }
871
- });
872
- var init_switch = __esm({
873
- "src/ui/primitives/switch.tsx"() {
874
- "use client";
875
- }
876
- });
877
- var Label3;
878
- var init_label = __esm({
879
- "src/ui/primitives/label.tsx"() {
880
- "use client";
881
- init_utils();
882
- Label3 = React12__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
883
- LabelPrimitive__namespace.Root,
884
- {
885
- ref,
886
- className: cn(
887
- "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
888
- className
889
- ),
890
- ...props
891
- }
892
- ));
893
- Label3.displayName = LabelPrimitive__namespace.Root.displayName;
894
- }
895
- });
896
- function TooltipProvider({
897
- delayDuration = 0,
898
- ...props
899
- }) {
900
- return /* @__PURE__ */ jsxRuntime.jsx(
901
- TooltipPrimitive__namespace.Provider,
902
- {
903
- "data-slot": "tooltip-provider",
904
- delayDuration,
905
- ...props
906
- }
907
- );
908
- }
909
- function Tooltip({
910
- ...props
911
- }) {
912
- return /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Root, { "data-slot": "tooltip", ...props }) });
913
- }
914
- function TooltipTrigger({
915
- className,
916
- ...props
917
- }) {
918
- return /* @__PURE__ */ jsxRuntime.jsx(
919
- TooltipPrimitive__namespace.Trigger,
920
- {
921
- "data-slot": "tooltip-trigger",
922
- className: cn("cursor-pointer", className),
923
- ...props
924
- }
925
- );
926
- }
927
- function TooltipContent({
928
- className,
929
- sideOffset = 0,
930
- ...props
931
- }) {
932
- return /* @__PURE__ */ jsxRuntime.jsx(
933
- TooltipPrimitive__namespace.Content,
934
- {
935
- "data-slot": "tooltip-content",
936
- sideOffset,
937
- className: cn(
938
- "z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-sm text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
939
- className
940
- ),
941
- ...props
942
- }
943
- );
944
- }
945
- var init_tooltip = __esm({
946
- "src/ui/primitives/tooltip.tsx"() {
947
- "use client";
948
- init_utils();
949
- }
950
- });
951
- var init_resizable = __esm({
952
- "src/ui/primitives/resizable.tsx"() {
953
- "use client";
954
- }
955
- });
956
- var init_slider = __esm({
957
- "src/ui/primitives/slider.tsx"() {
958
- "use client";
959
- }
960
- });
961
- var init_toggle = __esm({
962
- "src/ui/primitives/toggle.tsx"() {
963
- "use client";
964
- classVarianceAuthority.cva(
965
- "cursor-pointer inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",
966
- {
967
- variants: {
968
- variant: {
969
- default: "bg-transparent",
970
- outline: "border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"
971
- },
972
- size: {
973
- default: "h-9 px-3",
974
- sm: "h-8 px-2",
975
- lg: "h-10 px-3"
976
- }
977
- },
978
- defaultVariants: {
979
- variant: "default",
980
- size: "default"
981
- }
982
- }
983
- );
984
- }
985
- });
986
- var init_toggle_group = __esm({
987
- "src/ui/primitives/toggle-group.tsx"() {
988
- "use client";
989
- React12.createContext({
990
- size: "default",
991
- variant: "default"
992
- });
993
- }
994
- });
995
- var init_menubar = __esm({
996
- "src/ui/primitives/menubar.tsx"() {
997
- "use client";
998
- }
999
- });
1000
- var init_navigation_menu = __esm({
1001
- "src/ui/primitives/navigation-menu.tsx"() {
1002
- classVarianceAuthority.cva(
1003
- "group cursor-pointer inline-flex h-9 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=open]:hover:bg-accent data-[state=open]:text-accent-foreground data-[state=open]:focus:bg-accent data-[state=open]:bg-accent/50 focus-visible:ring-ring/50 outline-none transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1"
1004
- );
1005
- }
1006
- });
1007
- var init_sticky_layout = __esm({
1008
- "src/ui/primitives/sticky-layout.tsx"() {
1009
- }
1010
- });
1011
- var init_prefetch_link = __esm({
1012
- "src/ui/primitives/prefetch-link.tsx"() {
1013
- "use client";
1014
- }
1015
- });
1016
- var init_dynamic_icon = __esm({
1017
- "src/ui/primitives/dynamic-icon.tsx"() {
1018
- "use client";
1019
- }
1020
- });
1021
- var InputNumber;
1022
- var init_input_number = __esm({
1023
- "src/ui/primitives/input-number.tsx"() {
1024
- "use client";
1025
- init_utils();
1026
- init_input();
1027
- InputNumber = React12__namespace.forwardRef(
1028
- ({ value, onChange, className, decimalScale = 0, suffix, ...props }, ref) => {
1029
- const [displayValue, setDisplayValue] = React12__namespace.useState("");
1030
- const parseDisplayValue = (val) => {
1031
- const clean = val.replace(/\./g, "").replace(",", ".");
1032
- return Number(clean);
1033
- };
1034
- const formatNumber = React12__namespace.useCallback(
1035
- (num) => {
1036
- return new Intl.NumberFormat("vi-VN", {
1037
- maximumFractionDigits: decimalScale,
1038
- minimumFractionDigits: 0
1039
- }).format(num);
1040
- },
1041
- [decimalScale]
1042
- );
1043
- React12__namespace.useEffect(() => {
1044
- if (value === null || value === void 0 || value === "") {
1045
- setDisplayValue("");
1046
- return;
1047
- }
1048
- const numValue = Number(value);
1049
- if (isNaN(numValue)) return;
1050
- const currentNum = parseDisplayValue(displayValue);
1051
- if (currentNum !== numValue) {
1052
- setDisplayValue(formatNumber(numValue));
1053
- }
1054
- }, [value, decimalScale, displayValue, formatNumber]);
1055
- const handleChange = (e) => {
1056
- const rawValue = e.target.value;
1057
- let cleanVal = rawValue.replace(/[^0-9,]/g, "");
1058
- const parts = cleanVal.split(",");
1059
- if (parts.length > 2) {
1060
- cleanVal = parts[0] + "," + parts.slice(1).join("");
1061
- }
1062
- if (cleanVal === "") {
1063
- setDisplayValue("");
1064
- onChange?.(null);
1065
- return;
1066
- }
1067
- const [integerPart, decimalPart] = cleanVal.split(",");
1068
- let formattedInteger = integerPart;
1069
- if (integerPart) {
1070
- formattedInteger = new Intl.NumberFormat("vi-VN").format(
1071
- Number(integerPart)
1072
- );
1073
- }
1074
- let newDisplayValue = formattedInteger;
1075
- let finalDecimalPart = decimalPart;
1076
- if (decimalPart !== void 0) {
1077
- if (decimalScale !== void 0 && decimalPart.length > decimalScale) {
1078
- finalDecimalPart = decimalPart.substring(0, decimalScale);
1079
- }
1080
- newDisplayValue += "," + finalDecimalPart;
1081
- }
1082
- setDisplayValue(newDisplayValue);
1083
- let numStr = integerPart;
1084
- if (finalDecimalPart !== void 0) {
1085
- numStr += "." + finalDecimalPart;
1086
- }
1087
- const numValue = Number(numStr.replace(/\./g, ""));
1088
- onChange?.(numValue);
1089
- };
1090
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
1091
- /* @__PURE__ */ jsxRuntime.jsx(
1092
- Input,
1093
- {
1094
- ...props,
1095
- ref,
1096
- type: "text",
1097
- inputMode: "numeric",
1098
- value: displayValue,
1099
- onChange: handleChange,
1100
- className: cn("pr-8", className)
1101
- }
1102
- ),
1103
- suffix && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none text-muted-foreground text-sm", children: suffix })
1104
- ] });
1105
- }
1106
- );
1107
- InputNumber.displayName = "InputNumber";
1108
- }
1109
- });
1110
- function Sheet({
1111
- ...props
1112
- }) {
1113
- return /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Root, { "data-slot": "sheet", ...props });
1114
- }
1115
- function SheetPortal({
1116
- ...props
1117
- }) {
1118
- return /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Portal, { "data-slot": "sheet-portal", ...props });
1119
- }
1120
- function SheetOverlay({
1121
- className,
1122
- ...props
1123
- }) {
1124
- return /* @__PURE__ */ jsxRuntime.jsx(
1125
- DialogPrimitive__namespace.Overlay,
1126
- {
1127
- "data-slot": "sheet-overlay",
1128
- className: cn(
1129
- "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
1130
- className
1131
- ),
1132
- ...props
1133
- }
1134
- );
1135
- }
1136
- function SheetContent({
1137
- className,
1138
- children,
1139
- side = "right",
1140
- ...props
1141
- }) {
1142
- return /* @__PURE__ */ jsxRuntime.jsxs(SheetPortal, { children: [
1143
- /* @__PURE__ */ jsxRuntime.jsx(SheetOverlay, {}),
1144
- /* @__PURE__ */ jsxRuntime.jsx(
1145
- DialogPrimitive__namespace.Content,
1146
- {
1147
- "data-slot": "sheet-content",
1148
- className: cn(sheetVariants({ side }), className),
1149
- ...props,
1150
- children
1151
- }
1152
- )
1153
- ] });
1154
- }
1155
- function SheetTitle({
1156
- className,
1157
- ...props
1158
- }) {
1159
- return /* @__PURE__ */ jsxRuntime.jsx(
1160
- DialogPrimitive__namespace.Title,
1161
- {
1162
- "data-slot": "sheet-title",
1163
- className: cn("text-lg font-semibold text-foreground", className),
1164
- ...props
1165
- }
1166
- );
1167
- }
1168
- var sheetVariants;
1169
- var init_sheet = __esm({
1170
- "src/ui/feedback/sheet.tsx"() {
1171
- "use client";
1172
- init_utils();
1173
- sheetVariants = classVarianceAuthority.cva(
1174
- "fixed z-50 gap-4 bg-background p-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",
1175
- {
1176
- variants: {
1177
- side: {
1178
- top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
1179
- bottom: "inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
1180
- left: "inset-y-0 left-0 h-full w-72 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
1181
- right: "inset-y-0 right-0 h-full w-72 border-s data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",
1182
- start: "inset-y-0 start-0 h-full w-72 border-e data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left data-[state=closed]:rtl:slide-out-to-right data-[state=open]:rtl:slide-in-from-right sm:max-w-sm",
1183
- end: "inset-y-0 end-0 h-full w-72 border-s data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right data-[state=closed]:rtl:slide-out-to-left data-[state=open]:rtl:slide-in-from-left sm:max-w-sm"
1184
- }
1185
- },
1186
- defaultVariants: {
1187
- side: "right"
1188
- }
1189
- }
1190
- );
1191
- }
1192
- });
1193
- var init_context_menu = __esm({
1194
- "src/ui/feedback/context-menu.tsx"() {
1195
- "use client";
1196
- }
1197
- });
1198
- var init_drawer = __esm({
1199
- "src/ui/feedback/drawer.tsx"() {
1200
- "use client";
1201
- }
1202
- });
1203
- var init_progress = __esm({
1204
- "src/ui/feedback/progress.tsx"() {
1205
- "use client";
1206
- }
1207
- });
1208
- var init_sonner = __esm({
1209
- "src/ui/feedback/sonner.tsx"() {
1210
- "use client";
1211
- }
1212
- });
1213
-
1214
- // src/ui/primitives/client.ts
1215
- var init_client = __esm({
1216
- "src/ui/primitives/client.ts"() {
1217
- "use client";
1218
- init_calendar();
1219
- init_combobox();
1220
- init_scroll_area();
1221
- init_select();
1222
- init_popover();
1223
- init_dropdown_menu();
1224
- init_switch();
1225
- init_checkbox();
1226
- init_label();
1227
- init_tooltip();
1228
- init_sidebar2();
1229
- init_resizable();
1230
- init_slider();
1231
- init_toggle();
1232
- init_toggle_group();
1233
- init_menubar();
1234
- init_navigation_menu();
1235
- init_sticky_layout();
1236
- init_prefetch_link();
1237
- init_dynamic_icon();
1238
- init_input_number();
1239
- init_sheet();
1240
- init_context_menu();
1241
- init_drawer();
1242
- init_progress();
1243
- init_sonner();
1244
- }
1245
- });
1246
- var init_language_dropdown = __esm({
1247
- "src/ui/layout/language-dropdown.tsx"() {
1248
- "use client";
1249
- }
1250
- });
1251
- var init_footer = __esm({
1252
- "src/ui/layout/footer.tsx"() {
1253
- }
1254
- });
1255
- var init_header_breadcrumb = __esm({
1256
- "src/ui/layout/header-breadcrumb.tsx"() {
1257
- "use client";
1258
- }
1259
- });
1260
- var init_animated_list = __esm({
1261
- "src/ui/layout/animated-list.tsx"() {
1262
- }
1263
- });
1264
- var init_animated_sidebar = __esm({
1265
- "src/ui/layout/animated-sidebar.tsx"() {
1266
- "use client";
1267
- }
1268
- });
1269
- var init_customizer = __esm({
1270
- "src/ui/layout/customizer.tsx"() {
1271
- "use client";
1272
- }
1273
- });
1274
- function Avatar({
1275
- className,
1276
- ...props
1277
- }) {
1278
- return /* @__PURE__ */ jsxRuntime.jsx(
1279
- AvatarPrimitive__namespace.Root,
1280
- {
1281
- "data-slot": "avatar",
1282
- className: cn("relative flex h-10 w-10 shrink-0", className),
1283
- ...props
1284
- }
1285
- );
1286
- }
1287
- function AvatarImage({
1288
- className,
1289
- ...props
1290
- }) {
1291
- return /* @__PURE__ */ jsxRuntime.jsx(
1292
- AvatarPrimitive__namespace.Image,
1293
- {
1294
- "data-slot": "avatar-image",
1295
- className: cn(
1296
- "aspect-square h-full w-full bg-muted rounded-lg object-cover",
1297
- className
1298
- ),
1299
- ...props
1300
- }
1301
- );
1302
- }
1303
- function AvatarFallback({
1304
- className,
1305
- ...props
1306
- }) {
1307
- return /* @__PURE__ */ jsxRuntime.jsx(
1308
- AvatarPrimitive__namespace.Fallback,
1309
- {
1310
- className: cn(
1311
- "flex h-full w-full items-center justify-center bg-muted rounded-lg",
1312
- className
1313
- ),
1314
- ...props
1315
- }
1316
- );
1317
- }
1318
- var init_avatar = __esm({
1319
- "src/ui/data-display/avatar.tsx"() {
1320
- "use client";
1321
- init_utils();
1322
- classVarianceAuthority.cva(
1323
- "transition duration-300 hover:scale-105 hover:z-10",
1324
- {
1325
- variants: {
1326
- size: {
1327
- default: "h-10 w-10",
1328
- sm: "h-9 w-9 text-sm",
1329
- lg: "h-11 w-11"
1330
- }
1331
- },
1332
- defaultVariants: {
1333
- size: "default"
1334
- }
1335
- }
1336
- );
1337
- }
1338
- });
1339
- function useTabContentCache() {
1340
- const context = React12.useContext(TabContentCacheContext);
1341
- return context ?? noopTabContentCache;
1342
- }
1343
- var TabContentCacheContext, noopTabContentCache;
1344
- var init_tab_content_cache = __esm({
1345
- "src/ui/layout/tab-content-cache.tsx"() {
1346
- "use client";
1347
- TabContentCacheContext = React12.createContext(void 0);
1348
- noopTabContentCache = {
1349
- getCachedContent: () => null,
1350
- setCachedContent: () => {
1351
- },
1352
- clearCache: () => {
1353
- },
1354
- clearAllCache: () => {
1355
- },
1356
- isCached: () => false
1357
- };
1358
- }
1359
- });
1360
- function useTabNavigation() {
1361
- const context = React12.useContext(TabNavigationContext);
1362
- return context ?? noopTabNavigation;
1363
- }
1364
- var TabNavigationContext, noopTabNavigation;
1365
- var init_tab_navigation_provider = __esm({
1366
- "src/ui/layout/tab-navigation-provider.tsx"() {
1367
- "use client";
1368
- TabNavigationContext = React12.createContext(void 0);
1369
- noopTabNavigation = {
1370
- tabs: [],
1371
- activeTabId: null,
1372
- addTab: () => {
1373
- },
1374
- removeTab: () => {
1375
- },
1376
- setActiveTab: () => {
1377
- },
1378
- clearTabs: () => {
1379
- },
1380
- removeOtherTabs: () => {
1381
- },
1382
- removeTabsToRight: () => {
1383
- },
1384
- goToNextTab: () => {
1385
- },
1386
- goToPreviousTab: () => {
1387
- },
1388
- goToTabByIndex: () => {
1389
- },
1390
- closeAndGoToParent: () => {
1391
- }
1392
- };
1393
- }
1394
- });
1395
- var init_user_dropdown = __esm({
1396
- "src/ui/layout/user-dropdown.tsx"() {
1397
- "use client";
1398
- }
1399
- });
1400
- var init_notification_dropdown = __esm({
1401
- "src/ui/layout/notification-dropdown.tsx"() {
1402
- "use client";
1403
- }
1404
- });
1405
- var init_mode_dropdown = __esm({
1406
- "src/ui/layout/mode-dropdown.tsx"() {
1407
- "use client";
1408
- }
1409
- });
1410
- var init_full_screen_toggle = __esm({
1411
- "src/ui/layout/full-screen-toggle.tsx"() {
1412
- "use client";
1413
- }
1414
- });
1415
- var init_route_cache = __esm({
1416
- "src/ui/layout/route-cache.tsx"() {
1417
- "use client";
1418
- React12.createContext(
1419
- void 0
1420
- );
1421
- }
1422
- });
1423
- var init_page_tabs = __esm({
1424
- "src/ui/layout/page-tabs.tsx"() {
1425
- "use client";
1426
- }
1427
- });
1428
- var init_toggle_mobile_sidebar = __esm({
1429
- "src/ui/layout/toggle-mobile-sidebar.tsx"() {
1430
- "use client";
1431
- }
1432
- });
1433
- var init_top_bar_header_menubar = __esm({
1434
- "src/ui/layout/top-bar-header-menubar.tsx"() {
1435
- "use client";
1436
- }
1437
- });
1438
- var init_vertical_layout_header = __esm({
1439
- "src/ui/layout/vertical-layout-header.tsx"() {
1440
- "use client";
1441
- }
1442
- });
1443
- var init_horizontal_layout_header = __esm({
1444
- "src/ui/layout/horizontal-layout-header.tsx"() {
1445
- "use client";
1446
- }
1447
- });
1448
- var init_vertical_layout = __esm({
1449
- "src/ui/layout/vertical-layout.tsx"() {
1450
- "use client";
1451
- }
1452
- });
1453
- var init_horizontal_layout = __esm({
1454
- "src/ui/layout/horizontal-layout.tsx"() {
1455
- "use client";
1456
- }
1457
- });
1458
- var init_main_layout = __esm({
1459
- "src/ui/layout/main-layout.tsx"() {
1460
- "use client";
1461
- }
1462
- });
1463
-
1464
- // src/ui/layout/index.tsx
1465
- var init_layout = __esm({
1466
- "src/ui/layout/index.tsx"() {
1467
- init_sidebar();
1468
- init_language_dropdown();
1469
- init_footer();
1470
- init_logo();
1471
- init_header_breadcrumb();
1472
- init_animated_list();
1473
- init_animated_sidebar();
1474
- init_command_menu();
1475
- init_sidebar_group_icon_menu();
1476
- init_customizer();
1477
- init_user_dropdown();
1478
- init_notification_dropdown();
1479
- init_mode_dropdown();
1480
- init_full_screen_toggle();
1481
- init_page_tabs();
1482
- init_tab_navigation_provider();
1483
- init_route_cache();
1484
- init_toggle_mobile_sidebar();
1485
- init_top_bar_header_menubar();
1486
- init_vertical_layout_header();
1487
- init_horizontal_layout_header();
1488
- init_vertical_layout();
1489
- init_horizontal_layout();
1490
- init_main_layout();
1491
- init_tab_content_cache();
1492
- }
1493
- });
1494
-
1495
- // src/hooks/use-tenant.ts
1496
- var init_use_tenant = __esm({
1497
- "src/hooks/use-tenant.ts"() {
1498
- }
1499
- });
1500
- function useMediaQuery(query) {
1501
- const [matches, setMatches] = React12.useState(false);
1502
- React12.useEffect(() => {
1503
- if (typeof window !== "undefined") {
1504
- const media = window.matchMedia(query);
1505
- setMatches(media.matches);
1506
- const listener = (event) => setMatches(event.matches);
1507
- media.addEventListener("change", listener);
1508
- return () => media.removeEventListener("change", listener);
1509
- }
1510
- }, [query]);
1511
- return matches;
1512
- }
1513
- function useMobile() {
1514
- return useMediaQuery("(max-width: 768px)");
1515
- }
1516
- var init_hooks = __esm({
1517
- "src/hooks/index.tsx"() {
1518
- "use client";
1519
- init_use_tenant();
1520
- React12.createContext(null);
1521
- }
1522
- });
1523
- var init_alert = __esm({
1524
- "src/ui/feedback/alert.tsx"() {
1525
- classVarianceAuthority.cva(
1526
- "relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",
1527
- {
1528
- variants: {
1529
- variant: {
1530
- default: "bg-background text-foreground",
1531
- destructive: "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"
1532
- }
1533
- },
1534
- defaultVariants: {
1535
- variant: "default"
1536
- }
1537
- }
1538
- );
1539
- }
1540
- });
1541
- var GlobalErrorEmitter;
1542
- var init_error_dialog = __esm({
1543
- "src/ui/feedback/error-dialog.tsx"() {
1544
- "use client";
1545
- GlobalErrorEmitter = class {
1546
- constructor() {
1547
- this.listeners = [];
1548
- }
1549
- subscribe(listener) {
1550
- this.listeners.push(listener);
1551
- return () => {
1552
- this.listeners = this.listeners.filter((l) => l !== listener);
1553
- };
1554
- }
1555
- emit(data) {
1556
- this.listeners.forEach((listener) => listener(data));
1557
- }
1558
- };
1559
- new GlobalErrorEmitter();
1560
- React12.createContext(null);
1561
- }
1562
- });
1563
- function AlertDialog({
1564
- ...props
1565
- }) {
1566
- return /* @__PURE__ */ jsxRuntime.jsx(AlertDialogPrimitive__namespace.Root, { "data-slot": "alert-dialog", ...props });
1567
- }
1568
- function AlertDialogPortal({
1569
- ...props
1570
- }) {
1571
- return /* @__PURE__ */ jsxRuntime.jsx(AlertDialogPrimitive__namespace.Portal, { "data-slot": "alert-dialog-portal", ...props });
1572
- }
1573
- function AlertDialogOverlay({
1574
- className,
1575
- ...props
1576
- }) {
1577
- return /* @__PURE__ */ jsxRuntime.jsx(
1578
- AlertDialogPrimitive__namespace.Overlay,
1579
- {
1580
- "data-slot": "alert-dialog-overlay",
1581
- className: cn(
1582
- "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
1583
- className
1584
- ),
1585
- ...props
1586
- }
1587
- );
1588
- }
1589
- function AlertDialogContent({
1590
- className,
1591
- ...props
1592
- }) {
1593
- return /* @__PURE__ */ jsxRuntime.jsxs(AlertDialogPortal, { children: [
1594
- /* @__PURE__ */ jsxRuntime.jsx(AlertDialogOverlay, {}),
1595
- /* @__PURE__ */ jsxRuntime.jsx(
1596
- AlertDialogPrimitive__namespace.Content,
1597
- {
1598
- "data-slot": "alert-dialog-content",
1599
- className: cn(
1600
- "fixed top-[50%] left-[50%] z-50 w-full max-w-[calc(100%-2rem)] grid bg-background translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:max-w-lg",
1601
- className
1602
- ),
1603
- ...props
1604
- }
1605
- )
1606
- ] });
1607
- }
1608
- function AlertDialogHeader({
1609
- className,
1610
- ...props
1611
- }) {
1612
- return /* @__PURE__ */ jsxRuntime.jsx(
1613
- "div",
1614
- {
1615
- "data-slot": "alert-dialog-header",
1616
- className: cn(
1617
- "flex flex-col space-y-2 text-center sm:text-left",
1618
- className
1619
- ),
1620
- ...props
1621
- }
1622
- );
1623
- }
1624
- function AlertDialogFooter({
1625
- className,
1626
- ...props
1627
- }) {
1628
- return /* @__PURE__ */ jsxRuntime.jsx(
1629
- "div",
1630
- {
1631
- "data-slot": "alert-dialog-footer",
1632
- className: cn(
1633
- "flex flex-col-reverse sm:flex-row sm:justify-end sm:gap-x-2",
1634
- className
1635
- ),
1636
- ...props
1637
- }
1638
- );
1639
- }
1640
- function AlertDialogTitle({
1641
- className,
1642
- ...props
1643
- }) {
1644
- return /* @__PURE__ */ jsxRuntime.jsx(
1645
- AlertDialogPrimitive__namespace.Title,
1646
- {
1647
- "data-slot": "alert-dialog-title",
1648
- className: cn("text-lg font-semibold", className),
1649
- ...props
1650
- }
1651
- );
1652
- }
1653
- function AlertDialogDescription({
1654
- className,
1655
- ...props
1656
- }) {
1657
- return /* @__PURE__ */ jsxRuntime.jsx(
1658
- AlertDialogPrimitive__namespace.Description,
1659
- {
1660
- "data-slot": "alert-dialog-description",
1661
- className: cn("text-sm text-muted-foreground", className),
1662
- ...props
1663
- }
1664
- );
1665
- }
1666
- function AlertDialogAction({
1667
- className,
1668
- ...props
1669
- }) {
1670
- return /* @__PURE__ */ jsxRuntime.jsx(
1671
- AlertDialogPrimitive__namespace.Action,
1672
- {
1673
- className: cn(buttonVariants(), className),
1674
- ...props
1675
- }
1676
- );
1677
- }
1678
- function AlertDialogCancel({
1679
- className,
1680
- ...props
1681
- }) {
1682
- return /* @__PURE__ */ jsxRuntime.jsx(
1683
- AlertDialogPrimitive__namespace.Cancel,
1684
- {
1685
- className: cn(
1686
- buttonVariants({ variant: "outline" }),
1687
- "mt-2 sm:mt-0",
1688
- className
1689
- ),
1690
- ...props
1691
- }
1692
- );
1693
- }
1694
- var init_feedback = __esm({
1695
- "src/ui/feedback/index.tsx"() {
1696
- init_primitives();
1697
- init_utils();
1698
- init_primitives();
1699
- init_progress();
1700
- init_sheet();
1701
- init_alert();
1702
- init_context_menu();
1703
- init_drawer();
1704
- init_sonner();
1705
- init_error_dialog();
1706
- }
1707
- });
1708
- function useSidebar() {
1709
- const context = React12__namespace.useContext(SidebarContext);
1710
- if (!context) {
1711
- throw new Error("useSidebar must be used within a SidebarProvider.");
1712
- }
1713
- return context;
1714
- }
1715
- var SIDEBAR_WIDTH, SIDEBAR_WIDTH_MOBILE, SIDEBAR_WIDTH_ICON, SIDEBAR_KEYBOARD_SHORTCUT, SidebarContext, SidebarProvider, Sidebar, SidebarTrigger, SidebarRail, SidebarInset, SidebarInput, SidebarHeader, SidebarFooter, SidebarSeparator, SidebarContent, SidebarGroup, SidebarGroupLabel, SidebarGroupAction, SidebarGroupContent, SidebarMenu, SidebarMenuItem, sidebarMenuButtonVariants, SidebarMenuButton, SidebarMenuAction, SidebarMenuBadge, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubItem, SidebarMenuSubButton;
1716
- var init_sidebar2 = __esm({
1717
- "src/ui/primitives/sidebar.tsx"() {
1718
- "use client";
1719
- init_hooks();
1720
- init_utils();
1721
- init_button();
1722
- init_feedback();
1723
- init_tooltip();
1724
- SIDEBAR_WIDTH = "16rem";
1725
- SIDEBAR_WIDTH_MOBILE = "18rem";
1726
- SIDEBAR_WIDTH_ICON = "3rem";
1727
- SIDEBAR_KEYBOARD_SHORTCUT = "b";
1728
- SidebarContext = React12__namespace.createContext(null);
1729
- SidebarProvider = React12__namespace.forwardRef(
1730
- ({
1731
- defaultOpen = false,
1732
- open: openProp,
1733
- onOpenChange: setOpenProp,
1734
- className,
1735
- style,
1736
- children,
1737
- ...props
1738
- }, ref) => {
1739
- const isMobile = useMobile();
1740
- const [openMobile, setOpenMobile] = React12__namespace.useState(false);
1741
- const [hoverOpen, setHoverOpen] = React12__namespace.useState(false);
1742
- const [_open, _setOpen] = React12__namespace.useState(defaultOpen);
1743
- const open = openProp ?? _open;
1744
- const setOpen = React12__namespace.useCallback(
1745
- (value) => {
1746
- if (setOpenProp) {
1747
- return setOpenProp(typeof value === "function" ? value(open) : value);
1748
- }
1749
- _setOpen(value);
1750
- },
1751
- [setOpenProp, open]
1752
- );
1753
- const toggleSidebar = React12__namespace.useCallback(() => {
1754
- return isMobile ? setOpenMobile((open2) => !open2) : setOpen((open2) => !open2);
1755
- }, [isMobile, setOpen, setOpenMobile]);
1756
- React12__namespace.useEffect(() => {
1757
- const handleKeyDown = (event) => {
1758
- if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
1759
- event.preventDefault();
1760
- toggleSidebar();
1761
- }
1762
- };
1763
- window.addEventListener("keydown", handleKeyDown);
1764
- return () => window.removeEventListener("keydown", handleKeyDown);
1765
- }, [toggleSidebar]);
1766
- const state = open ? "expanded" : "collapsed";
1767
- const isHoverExpanded = !open && hoverOpen;
1768
- const contextValue = React12__namespace.useMemo(
1769
- () => ({
1770
- state,
1771
- open,
1772
- setOpen,
1773
- isMobile,
1774
- openMobile,
1775
- setOpenMobile,
1776
- toggleSidebar,
1777
- hoverOpen,
1778
- setHoverOpen,
1779
- isHoverExpanded
1780
- }),
1781
- [
1782
- state,
1783
- open,
1784
- setOpen,
1785
- isMobile,
1786
- openMobile,
1787
- setOpenMobile,
1788
- toggleSidebar,
1789
- hoverOpen,
1790
- setHoverOpen,
1791
- isHoverExpanded
1792
- ]
1793
- );
1794
- return /* @__PURE__ */ jsxRuntime.jsx(SidebarContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { delayDuration: 0, children: /* @__PURE__ */ jsxRuntime.jsx(
1795
- "div",
1796
- {
1797
- style: {
1798
- "--sidebar-width": SIDEBAR_WIDTH,
1799
- "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
1800
- ...style
1801
- },
1802
- className: cn(
1803
- "group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",
1804
- className
1805
- ),
1806
- ref,
1807
- ...props,
1808
- children
1809
- }
1810
- ) }) });
1811
- }
1812
- );
1813
- SidebarProvider.displayName = "SidebarProvider";
1814
- Sidebar = React12__namespace.forwardRef(
1815
- ({
1816
- side = "left",
1817
- variant = "sidebar",
1818
- collapsible = "offcanvas",
1819
- hoverExpandEnabled = true,
1820
- className,
1821
- children,
1822
- ...props
1823
- }, ref) => {
1824
- const {
1825
- isMobile,
1826
- state,
1827
- openMobile,
1828
- setOpenMobile,
1829
- setHoverOpen,
1830
- isHoverExpanded
1831
- } = useSidebar();
1832
- const handleMouseEnter = React12__namespace.useCallback(() => {
1833
- if (hoverExpandEnabled && state === "collapsed" && collapsible === "icon") {
1834
- setHoverOpen(true);
1835
- }
1836
- }, [hoverExpandEnabled, state, collapsible, setHoverOpen]);
1837
- const handleMouseLeave = React12__namespace.useCallback(() => {
1838
- if (hoverExpandEnabled) {
1839
- setHoverOpen(false);
1840
- }
1841
- }, [hoverExpandEnabled, setHoverOpen]);
1842
- if (collapsible === "none") {
1843
- return /* @__PURE__ */ jsxRuntime.jsx(
1844
- "div",
1845
- {
1846
- className: cn(
1847
- "flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",
1848
- className
1849
- ),
1850
- ref,
1851
- ...props,
1852
- children
1853
- }
1854
- );
1855
- }
1856
- if (isMobile) {
1857
- return /* @__PURE__ */ jsxRuntime.jsx(Sheet, { open: openMobile, onOpenChange: setOpenMobile, ...props, children: /* @__PURE__ */ jsxRuntime.jsxs(
1858
- SheetContent,
1859
- {
1860
- "data-sidebar": "sidebar",
1861
- "data-mobile": "true",
1862
- className: "w-(--sidebar-width) bg-background p-0 text-foreground [&>button]:hidden",
1863
- style: {
1864
- "--sidebar-width": SIDEBAR_WIDTH_MOBILE
1865
- },
1866
- side,
1867
- children: [
1868
- /* @__PURE__ */ jsxRuntime.jsx(SheetTitle, { className: "sr-only", children: "Mobile Menu" }),
1869
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full w-full flex-col", children })
1870
- ]
1871
- }
1872
- ) });
1873
- }
1874
- return /* @__PURE__ */ jsxRuntime.jsxs(
1875
- "div",
1876
- {
1877
- ref,
1878
- className: cn(
1879
- "group peer hidden md:block transition-colors duration-200",
1880
- // Blue bg + white text when collapsed, white bg + dark text when expanded/hover
1881
- state === "collapsed" && !isHoverExpanded ? "text-sidebar-foreground" : "text-foreground"
1882
- ),
1883
- "data-state": state,
1884
- "data-hover-expanded": isHoverExpanded,
1885
- "data-collapsible": state === "collapsed" ? collapsible : "",
1886
- "data-variant": variant,
1887
- "data-side": side,
1888
- onMouseEnter: handleMouseEnter,
1889
- onMouseLeave: handleMouseLeave,
1890
- children: [
1891
- /* @__PURE__ */ jsxRuntime.jsx(
1892
- "div",
1893
- {
1894
- className: cn(
1895
- "duration-200 relative h-svh w-(--sidebar-width) bg-transparent transition-[width] ease-linear",
1896
- "group-data-[collapsible=offcanvas]:w-0",
1897
- "group-data-[collapsible=icon]:w-(--sidebar-width-icon)",
1898
- variant === "floating" || variant === "inset" ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_2px)]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)"
1899
- )
1900
- }
1901
- ),
1902
- /* @__PURE__ */ jsxRuntime.jsx(
1903
- "div",
1904
- {
1905
- className: cn(
1906
- "duration-200 fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] ease-linear md:flex",
1907
- side === "left" ? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]" : "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
1908
- // Adjustments for collapsible=icon
1909
- variant === "floating" || variant === "inset" ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_8px)] group-data-[collapsible=icon]:px-2.5" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[collapsible=icon]:border-r group-data-[collapsible=icon]:px-0",
1910
- // Hover expand - override icon width to full width on hover
1911
- "group-data-[hover-expanded=true]:!w-(--sidebar-width) group-data-[hover-expanded=true]:shadow-xl group-data-[hover-expanded=true]:z-[100]",
1912
- className
1913
- ),
1914
- ...props,
1915
- children: /* @__PURE__ */ jsxRuntime.jsx(
1916
- "div",
1917
- {
1918
- "data-sidebar": "sidebar",
1919
- className: cn(
1920
- "flex h-full w-full flex-col border-r transition-colors duration-200",
1921
- // Blue background when collapsed, white when expanded/hover
1922
- "group-data-[state=collapsed]:bg-sidebar group-data-[state=collapsed]:border-sidebar-border",
1923
- "group-data-[state=expanded]:bg-background group-data-[state=expanded]:border-border",
1924
- "group-data-[hover-expanded=true]:!bg-background group-data-[hover-expanded=true]:!border-border",
1925
- "group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow"
1926
- ),
1927
- children
1928
- }
1929
- )
1930
- }
1931
- )
1932
- ]
1933
- }
1934
- );
1935
- }
1936
- );
1937
- Sidebar.displayName = "Sidebar";
1938
- SidebarTrigger = React12__namespace.forwardRef(({ className, onClick, ...props }, ref) => {
1939
- const { toggleSidebar } = useSidebar();
1940
- return /* @__PURE__ */ jsxRuntime.jsxs(
1941
- Button,
1942
- {
1943
- ref,
1944
- "data-sidebar": "trigger",
1945
- variant: "ghost",
1946
- size: "icon",
1947
- className: cn("h-7 w-7", className),
1948
- onClick: (event) => {
1949
- onClick?.(event);
1950
- toggleSidebar();
1951
- },
1952
- ...props,
1953
- children: [
1954
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PanelLeft, {}),
1955
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Toggle Sidebar" })
1956
- ]
1957
- }
1958
- );
1959
- });
1960
- SidebarTrigger.displayName = "SidebarTrigger";
1961
- SidebarRail = React12__namespace.forwardRef(({ className, ...props }, ref) => {
1962
- const { toggleSidebar } = useSidebar();
1963
- return /* @__PURE__ */ jsxRuntime.jsx(
1964
- "button",
1965
- {
1966
- ref,
1967
- "data-sidebar": "rail",
1968
- "aria-label": "Toggle Sidebar",
1969
- tabIndex: -1,
1970
- onClick: toggleSidebar,
1971
- title: "Toggle Sidebar",
1972
- className: cn(
1973
- "absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex",
1974
- "[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize",
1975
- "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
1976
- "group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar",
1977
- "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
1978
- "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
1979
- className
1980
- ),
1981
- ...props
1982
- }
1983
- );
1984
- });
1985
- SidebarRail.displayName = "SidebarRail";
1986
- SidebarInset = React12__namespace.forwardRef(({ className, ...props }, ref) => {
1987
- return /* @__PURE__ */ jsxRuntime.jsx(
1988
- "main",
1989
- {
1990
- ref,
1991
- className: cn(
1992
- "relative flex min-h-svh flex-1 flex-col bg-muted/40 transition-[margin] duration-200 ease-linear",
1993
- "peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",
1994
- className
1995
- ),
1996
- ...props
1997
- }
1998
- );
1999
- });
2000
- SidebarInset.displayName = "SidebarInset";
2001
- SidebarInput = React12__namespace.forwardRef(({ className, ...props }, ref) => {
2002
- return /* @__PURE__ */ jsxRuntime.jsx(
2003
- "input",
2004
- {
2005
- ref,
2006
- "data-sidebar": "input",
2007
- className: cn(
2008
- "flex h-8 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sidebar-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
2009
- className
2010
- ),
2011
- ...props
2012
- }
2013
- );
2014
- });
2015
- SidebarInput.displayName = "SidebarInput";
2016
- SidebarHeader = React12__namespace.forwardRef(({ className, ...props }, ref) => {
2017
- return /* @__PURE__ */ jsxRuntime.jsx(
2018
- "div",
2019
- {
2020
- ref,
2021
- "data-sidebar": "header",
2022
- className: cn("flex flex-col gap-2 p-2", className),
2023
- ...props
2024
- }
2025
- );
2026
- });
2027
- SidebarHeader.displayName = "SidebarHeader";
2028
- SidebarFooter = React12__namespace.forwardRef(({ className, ...props }, ref) => {
2029
- return /* @__PURE__ */ jsxRuntime.jsx(
2030
- "div",
2031
- {
2032
- ref,
2033
- "data-sidebar": "footer",
2034
- className: cn("flex flex-col gap-2 p-2", className),
2035
- ...props
2036
- }
2037
- );
2038
- });
2039
- SidebarFooter.displayName = "SidebarFooter";
2040
- SidebarSeparator = React12__namespace.forwardRef(({ className, ...props }, ref) => {
2041
- return /* @__PURE__ */ jsxRuntime.jsx(
2042
- "div",
2043
- {
2044
- ref,
2045
- "data-sidebar": "separator",
2046
- className: cn("mx-2 h-[1px] w-auto bg-sidebar-border", className),
2047
- ...props
2048
- }
2049
- );
2050
- });
2051
- SidebarSeparator.displayName = "SidebarSeparator";
2052
- SidebarContent = React12__namespace.forwardRef(({ className, ...props }, ref) => {
2053
- return /* @__PURE__ */ jsxRuntime.jsx(
2054
- "div",
2055
- {
2056
- ref,
2057
- "data-sidebar": "content",
2058
- className: cn(
2059
- "flex min-h-0 flex-1 flex-col gap-2 overflow-auto",
2060
- // Hide overflow when collapsed, but show when hover-expanded
2061
- "group-data-[collapsible=icon]:overflow-hidden group-data-[hover-expanded=true]:!overflow-auto",
2062
- className
2063
- ),
2064
- ...props
2065
- }
2066
- );
2067
- });
2068
- SidebarContent.displayName = "SidebarContent";
2069
- SidebarGroup = React12__namespace.forwardRef(({ className, ...props }, ref) => {
2070
- return /* @__PURE__ */ jsxRuntime.jsx(
2071
- "div",
2072
- {
2073
- ref,
2074
- "data-sidebar": "group",
2075
- className: cn("relative flex w-full min-w-0 flex-col p-2", className),
2076
- ...props
2077
- }
2078
- );
2079
- });
2080
- SidebarGroup.displayName = "SidebarGroup";
2081
- SidebarGroupLabel = React12__namespace.forwardRef(({ className, asChild = false, ...props }, ref) => {
2082
- const Comp = asChild ? reactSlot.Slot : "div";
2083
- return /* @__PURE__ */ jsxRuntime.jsx(
2084
- Comp,
2085
- {
2086
- ref,
2087
- "data-sidebar": "group-label",
2088
- className: cn(
2089
- "duration-200 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-bold text-primary uppercase tracking-wider outline-none ring-sidebar-ring transition-[margin,opa] ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
2090
- // Hide when collapsed, show when hover-expanded
2091
- "group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
2092
- "group-data-[hover-expanded=true]:!mt-0 group-data-[hover-expanded=true]:!opacity-100",
2093
- className
2094
- ),
2095
- ...props
2096
- }
2097
- );
2098
- });
2099
- SidebarGroupLabel.displayName = "SidebarGroupLabel";
2100
- SidebarGroupAction = React12__namespace.forwardRef(({ className, asChild = false, ...props }, ref) => {
2101
- const Comp = asChild ? reactSlot.Slot : "button";
2102
- return /* @__PURE__ */ jsxRuntime.jsx(
2103
- Comp,
2104
- {
2105
- ref,
2106
- "data-sidebar": "group-action",
2107
- className: cn(
2108
- "absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
2109
- // Increases the hit area of the button on mobile.
2110
- "after:absolute after:-inset-2 after:md:hidden",
2111
- "group-data-[collapsible=icon]:hidden",
2112
- className
2113
- ),
2114
- ...props
2115
- }
2116
- );
2117
- });
2118
- SidebarGroupAction.displayName = "SidebarGroupAction";
2119
- SidebarGroupContent = React12__namespace.forwardRef(({ className, ...props }, ref) => {
2120
- return /* @__PURE__ */ jsxRuntime.jsx(
2121
- "div",
2122
- {
2123
- ref,
2124
- "data-sidebar": "group-content",
2125
- className: cn("w-full text-sm", className),
2126
- ...props
2127
- }
2128
- );
2129
- });
2130
- SidebarGroupContent.displayName = "SidebarGroupContent";
2131
- SidebarMenu = React12__namespace.forwardRef(({ className, ...props }, ref) => {
2132
- return /* @__PURE__ */ jsxRuntime.jsx(
2133
- "ul",
2134
- {
2135
- ref,
2136
- "data-sidebar": "menu",
2137
- className: cn("flex w-full min-w-0 flex-col gap-1", className),
2138
- ...props
2139
- }
2140
- );
2141
- });
2142
- SidebarMenu.displayName = "SidebarMenu";
2143
- SidebarMenuItem = React12__namespace.forwardRef(({ className, ...props }, ref) => {
2144
- return /* @__PURE__ */ jsxRuntime.jsx(
2145
- "li",
2146
- {
2147
- ref,
2148
- "data-sidebar": "menu-item",
2149
- className: cn("group/menu-item relative", className),
2150
- ...props
2151
- }
2152
- );
2153
- });
2154
- SidebarMenuItem.displayName = "SidebarMenuItem";
2155
- sidebarMenuButtonVariants = classVarianceAuthority.cva(
2156
- // Base styles + hover-expand overrides
2157
- "peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 group-data-[hover-expanded=true]:!size-auto group-data-[hover-expanded=true]:!w-full group-data-[hover-expanded=true]:!p-2",
2158
- {
2159
- variants: {
2160
- variant: {
2161
- default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
2162
- outline: "bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"
2163
- },
2164
- size: {
2165
- default: "h-8 text-sm",
2166
- sm: "h-7 text-xs",
2167
- lg: "h-12 text-sm group-data-[collapsible=icon]:!p-0"
2168
- },
2169
- isActive: {
2170
- true: "bg-primary/10 text-primary font-bold"
2171
- }
2172
- },
2173
- defaultVariants: {
2174
- variant: "default",
2175
- size: "default"
2176
- }
2177
- }
2178
- );
2179
- SidebarMenuButton = React12__namespace.forwardRef(
2180
- ({
2181
- asChild = false,
2182
- isActive = false,
2183
- variant = "default",
2184
- size = "default",
2185
- tooltip,
2186
- className,
2187
- ...props
2188
- }, ref) => {
2189
- const Comp = asChild ? reactSlot.Slot : "button";
2190
- const { isMobile, state } = useSidebar();
2191
- const button = /* @__PURE__ */ jsxRuntime.jsx(
2192
- Comp,
2193
- {
2194
- ref,
2195
- "data-sidebar": "menu-button",
2196
- "data-size": size,
2197
- "data-active": isActive,
2198
- className: cn(
2199
- sidebarMenuButtonVariants({ variant, size, isActive }),
2200
- className
2201
- ),
2202
- ...props
2203
- }
2204
- );
2205
- if (!tooltip) {
2206
- return button;
2207
- }
2208
- if (typeof tooltip === "string") {
2209
- tooltip = {
2210
- children: tooltip
2211
- };
2212
- }
2213
- return /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
2214
- /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: button }),
2215
- /* @__PURE__ */ jsxRuntime.jsx(
2216
- TooltipContent,
2217
- {
2218
- side: "right",
2219
- align: "center",
2220
- hidden: state !== "collapsed" || isMobile,
2221
- ...tooltip
2222
- }
2223
- )
2224
- ] });
2225
- }
2226
- );
2227
- SidebarMenuButton.displayName = "SidebarMenuButton";
2228
- SidebarMenuAction = React12__namespace.forwardRef(({ className, asChild = false, showOnHover = false, ...props }, ref) => {
2229
- const Comp = asChild ? reactSlot.Slot : "button";
2230
- return /* @__PURE__ */ jsxRuntime.jsx(
2231
- Comp,
2232
- {
2233
- ref,
2234
- "data-sidebar": "menu-action",
2235
- className: cn(
2236
- "absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
2237
- // Increases the hit area of the button on mobile.
2238
- "after:absolute after:-inset-2 after:md:hidden",
2239
- "peer-data-[size=sm]/menu-button:top-1",
2240
- "peer-data-[size=default]/menu-button:top-1.5",
2241
- "peer-data-[size=lg]/menu-button:top-2.5",
2242
- "group-data-[collapsible=icon]:hidden",
2243
- showOnHover && "group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 md:opacity-0",
2244
- className
2245
- ),
2246
- ...props
2247
- }
2248
- );
2249
- });
2250
- SidebarMenuAction.displayName = "SidebarMenuAction";
2251
- SidebarMenuBadge = React12__namespace.forwardRef(({ className, ...props }, ref) => {
2252
- return /* @__PURE__ */ jsxRuntime.jsx(
2253
- "div",
2254
- {
2255
- ref,
2256
- "data-sidebar": "menu-badge",
2257
- className: cn(
2258
- "pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none",
2259
- "peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground",
2260
- "peer-data-[size=sm]/menu-button:top-1",
2261
- "peer-data-[size=default]/menu-button:top-1.5",
2262
- "peer-data-[size=lg]/menu-button:top-2.5",
2263
- "group-data-[collapsible=icon]:hidden",
2264
- className
2265
- ),
2266
- ...props
2267
- }
2268
- );
2269
- });
2270
- SidebarMenuBadge.displayName = "SidebarMenuBadge";
2271
- SidebarMenuSkeleton = React12__namespace.forwardRef(({ className, showIcon = false, ...props }, ref) => {
2272
- const width = React12__namespace.useMemo(() => {
2273
- return `${Math.floor(Math.random() * 40) + 50}%`;
2274
- }, []);
2275
- return /* @__PURE__ */ jsxRuntime.jsxs(
2276
- "div",
2277
- {
2278
- ref,
2279
- "data-sidebar": "menu-skeleton",
2280
- className: cn("flex h-8 items-center gap-2 rounded-md px-2", className),
2281
- ...props,
2282
- children: [
2283
- showIcon && /* @__PURE__ */ jsxRuntime.jsx(
2284
- "div",
2285
- {
2286
- className: "size-4 rounded-md animate-pulse bg-muted",
2287
- "data-sidebar": "menu-skeleton-icon"
2288
- }
2289
- ),
2290
- /* @__PURE__ */ jsxRuntime.jsx(
2291
- "div",
2292
- {
2293
- className: "h-4 flex-1 max-w-[--skeleton-width] animate-pulse bg-muted rounded-full",
2294
- "data-sidebar": "menu-skeleton-text",
2295
- style: {
2296
- "--skeleton-width": width
2297
- }
2298
- }
2299
- )
2300
- ]
2301
- }
2302
- );
2303
- });
2304
- SidebarMenuSkeleton.displayName = "SidebarMenuSkeleton";
2305
- SidebarMenuSub = React12__namespace.forwardRef(({ className, ...props }, ref) => {
2306
- return /* @__PURE__ */ jsxRuntime.jsx(
2307
- "ul",
2308
- {
2309
- ref,
2310
- "data-sidebar": "menu-sub",
2311
- className: cn(
2312
- "mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5",
2313
- // Hide when collapsed, show when hover-expanded
2314
- "group-data-[collapsible=icon]:hidden group-data-[hover-expanded=true]:!flex",
2315
- className
2316
- ),
2317
- ...props
2318
- }
2319
- );
2320
- });
2321
- SidebarMenuSub.displayName = "SidebarMenuSub";
2322
- SidebarMenuSubItem = React12__namespace.forwardRef(({ ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("li", { ref, ...props }));
2323
- SidebarMenuSubItem.displayName = "SidebarMenuSubItem";
2324
- SidebarMenuSubButton = React12__namespace.forwardRef(({ asChild = false, size = "md", isActive, className, ...props }, ref) => {
2325
- const Comp = asChild ? reactSlot.Slot : "a";
2326
- return /* @__PURE__ */ jsxRuntime.jsx(
2327
- Comp,
2328
- {
2329
- ref,
2330
- "data-sidebar": "menu-sub-button",
2331
- "data-size": size,
2332
- "data-active": isActive,
2333
- className: cn(
2334
- "flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 text-xs",
2335
- "data-[active=true]:bg-primary/15 data-[active=true]:!text-primary data-[active=true]:font-bold",
2336
- size === "sm" && "text-xs",
2337
- size === "md" && "text-sm",
2338
- className
2339
- ),
2340
- ...props
2341
- }
2342
- );
2343
- });
2344
- SidebarMenuSubButton.displayName = "SidebarMenuSubButton";
2345
- }
2346
- });
2347
- function Spinner({ size = "md", className }) {
2348
- const sizeClasses = {
2349
- sm: "h-4 w-4",
2350
- md: "h-6 w-6",
2351
- lg: "h-8 w-8"
2352
- };
2353
- return /* @__PURE__ */ jsxRuntime.jsx(
2354
- "div",
2355
- {
2356
- className: cn(
2357
- "animate-spin rounded-full border-2 border-current border-t-transparent",
2358
- sizeClasses[size],
2359
- className
2360
- )
2361
- }
2362
- );
2363
- }
2364
- var Textarea, ButtonLoading;
2365
- var init_primitives = __esm({
2366
- "src/ui/primitives/index.tsx"() {
2367
- init_utils();
2368
- init_button();
2369
- init_badge();
2370
- init_button();
2371
- init_input();
2372
- init_checkbox();
2373
- init_card();
2374
- init_separator();
2375
- init_card();
2376
- init_table();
2377
- init_dropdown_menu();
2378
- init_dialog();
2379
- init_tabs();
2380
- init_breadcrumb();
2381
- init_keyboard();
2382
- init_pagination();
2383
- init_status_badge();
2384
- init_sidebar2();
2385
- init_popover();
2386
- init_scroll_area();
2387
- init_calendar();
2388
- init_resizable();
2389
- init_slider();
2390
- init_switch();
2391
- init_tooltip();
2392
- init_select();
2393
- init_menubar();
2394
- init_navigation_menu();
2395
- init_toggle();
2396
- init_toggle_group();
2397
- init_combobox();
2398
- init_label();
2399
- Textarea = React12__namespace.forwardRef(
2400
- ({ className, ...props }, ref) => {
2401
- return /* @__PURE__ */ jsxRuntime.jsx(
2402
- "textarea",
2403
- {
2404
- className: cn(
2405
- "flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
2406
- className
2407
- ),
2408
- ref,
2409
- ...props
2410
- }
2411
- );
2412
- }
2413
- );
2414
- Textarea.displayName = "Textarea";
2415
- ButtonLoading = React12__namespace.forwardRef(({ className, isLoading, children, disabled, ...props }, ref) => {
2416
- return /* @__PURE__ */ jsxRuntime.jsxs(
2417
- Button,
2418
- {
2419
- className: cn("gap-2", className),
2420
- disabled: isLoading || disabled,
2421
- ref,
2422
- ...props,
2423
- children: [
2424
- isLoading && /* @__PURE__ */ jsxRuntime.jsx(Spinner, { size: "sm" }),
2425
- children
2426
- ]
2427
- }
2428
- );
2429
- });
2430
- ButtonLoading.displayName = "ButtonLoading";
2431
- }
2432
- });
2433
- var init_radio_group = __esm({
2434
- "src/ui/forms/radio-group.tsx"() {
2435
- "use client";
2436
- }
2437
- });
2438
- var init_rating = __esm({
2439
- "src/ui/forms/rating.tsx"() {
2440
- "use client";
2441
- classVarianceAuthority.cva(
2442
- "transition-all duration-100 ease-in-out hover:scale-110",
2443
- {
2444
- variants: {
2445
- size: {
2446
- sm: "w-4 h-4",
2447
- default: "w-6 h-6",
2448
- lg: "w-8 h-8"
2449
- },
2450
- variant: {
2451
- default: "text-yellow-400",
2452
- primary: "text-primary",
2453
- muted: "text-muted-foreground"
2454
- },
2455
- filled: {
2456
- true: "",
2457
- false: "text-gray-200"
2458
- }
2459
- },
2460
- defaultVariants: {
2461
- size: "default",
2462
- variant: "default",
2463
- filled: false
2464
- }
2465
- }
2466
- );
2467
- }
2468
- });
2469
- var init_command = __esm({
2470
- "src/ui/forms/command.tsx"() {
2471
- "use client";
2472
- }
2473
- });
2474
- var MultiSelect;
2475
- var init_multi_select = __esm({
2476
- "src/ui/forms/multi-select.tsx"() {
2477
- "use client";
2478
- init_utils();
2479
- init_primitives();
2480
- init_client();
2481
- MultiSelect = React12__namespace.forwardRef(
2482
- ({
2483
- options,
2484
- value: controlledValue,
2485
- onValueChange,
2486
- defaultValue = [],
2487
- placeholder = "Select options...",
2488
- searchPlaceholder = "Search...",
2489
- emptyText = "No option found.",
2490
- maxCount = 3,
2491
- disabled = false,
2492
- responsive = false,
2493
- className,
2494
- id
2495
- }, ref) => {
2496
- const [internalValue, setInternalValue] = React12.useState(defaultValue);
2497
- const [open, setOpen] = React12.useState(false);
2498
- const [searchValue, setSearchValue] = React12.useState("");
2499
- const isControlled = controlledValue !== void 0;
2500
- const value = isControlled ? controlledValue : internalValue;
2501
- const containerRef = React12.useRef(null);
2502
- const searchInputRef = React12.useRef(null);
2503
- const dropdownRef = React12.useRef(null);
2504
- const buttonRef = React12.useRef(null);
2505
- const [politeMessage, setPoliteMessage] = React12.useState("");
2506
- const [assertiveMessage, setAssertiveMessage] = React12.useState("");
2507
- const prevSelectedCount = React12.useRef(value.length);
2508
- const announce = React12.useCallback(
2509
- (message, priority = "polite") => {
2510
- if (priority === "assertive") {
2511
- setAssertiveMessage(message);
2512
- setTimeout(() => setAssertiveMessage(""), 100);
2513
- } else {
2514
- setPoliteMessage(message);
2515
- setTimeout(() => setPoliteMessage(""), 100);
2516
- }
2517
- },
2518
- []
2519
- );
2520
- const [screenSize, setScreenSize] = React12.useState("desktop");
2521
- React12.useEffect(() => {
2522
- if (typeof window === "undefined") return;
2523
- const handleResize = () => {
2524
- const width = window.innerWidth;
2525
- if (width < 640) {
2526
- setScreenSize("mobile");
2527
- } else if (width < 1024) {
2528
- setScreenSize("tablet");
2529
- } else {
2530
- setScreenSize("desktop");
2531
- }
2532
- };
2533
- handleResize();
2534
- window.addEventListener("resize", handleResize);
2535
- return () => window.removeEventListener("resize", handleResize);
2536
- }, []);
2537
- const getResponsiveSettings = React12.useCallback(() => {
2538
- if (!responsive) {
2539
- return {
2540
- maxCount,
2541
- compactMode: false
2542
- };
2543
- }
2544
- if (responsive === true) {
2545
- const defaultResponsive = {
2546
- mobile: { maxCount: 2, compactMode: true },
2547
- tablet: { maxCount: 4, compactMode: false },
2548
- desktop: { maxCount: 6, compactMode: false }
2549
- };
2550
- const currentSettings2 = defaultResponsive[screenSize];
2551
- return {
2552
- maxCount: currentSettings2?.maxCount ?? maxCount,
2553
- compactMode: currentSettings2?.compactMode ?? false
2554
- };
2555
- }
2556
- const currentSettings = responsive[screenSize];
2557
- return {
2558
- maxCount: currentSettings?.maxCount ?? maxCount,
2559
- compactMode: currentSettings?.compactMode ?? false
2560
- };
2561
- }, [responsive, screenSize, maxCount]);
2562
- const responsiveSettings = getResponsiveSettings();
2563
- const filteredOptions = React12.useMemo(() => {
2564
- if (!searchValue.trim()) {
2565
- return options;
2566
- }
2567
- const searchLower = searchValue.toLowerCase();
2568
- return options.filter(
2569
- (option) => option.label.toLowerCase().includes(searchLower) || String(option.value).toLowerCase().includes(searchLower)
2570
- );
2571
- }, [options, searchValue]);
2572
- React12.useEffect(() => {
2573
- if (!open) {
2574
- setSearchValue("");
2575
- }
2576
- }, [open]);
2577
- React12.useEffect(() => {
2578
- if (open && searchInputRef.current) {
2579
- setTimeout(() => {
2580
- searchInputRef.current?.focus();
2581
- }, 50);
2582
- }
2583
- }, [open]);
2584
- React12.useEffect(() => {
2585
- if (!open) return;
2586
- const handleClickOutside = (event) => {
2587
- const target = event.target;
2588
- if (containerRef.current && !containerRef.current.contains(target) && dropdownRef.current && !dropdownRef.current.contains(target)) {
2589
- if (target.closest('[data-slot="dialog-content"]')) {
2590
- return;
2591
- }
2592
- setOpen(false);
2593
- }
2594
- };
2595
- const handleEscape = (event) => {
2596
- if (event.key === "Escape" && open) {
2597
- event.stopPropagation();
2598
- setOpen(false);
2599
- }
2600
- };
2601
- document.addEventListener("mousedown", handleClickOutside, true);
2602
- document.addEventListener("keydown", handleEscape, true);
2603
- return () => {
2604
- document.removeEventListener("mousedown", handleClickOutside, true);
2605
- document.removeEventListener("keydown", handleEscape, true);
2606
- };
2607
- }, [open]);
2608
- React12.useEffect(() => {
2609
- const selectedCount = value.length;
2610
- const totalOptions = options.filter((opt) => !opt.disabled).length;
2611
- if (selectedCount !== prevSelectedCount.current) {
2612
- const diff = selectedCount - prevSelectedCount.current;
2613
- if (diff > 0) {
2614
- announce(`${selectedCount} of ${totalOptions} options selected.`);
2615
- } else if (diff < 0) {
2616
- announce(
2617
- `Option removed. ${selectedCount} of ${totalOptions} options selected.`
2618
- );
2619
- }
2620
- prevSelectedCount.current = selectedCount;
2621
- }
2622
- }, [value, announce, options]);
2623
- const updateValue = React12.useCallback(
2624
- (newValue) => {
2625
- if (!isControlled) {
2626
- setInternalValue(newValue);
2627
- }
2628
- onValueChange?.(newValue);
2629
- },
2630
- [isControlled, onValueChange]
2631
- );
2632
- const handleSelect = React12.useCallback(
2633
- (optionValue) => {
2634
- const option = options.find((opt) => opt.value === optionValue);
2635
- if (option?.disabled) {
2636
- return;
2637
- }
2638
- const newValue = value.includes(optionValue) ? value.filter((v) => v !== optionValue) : [...value, optionValue];
2639
- updateValue(newValue);
2640
- },
2641
- [value, options, updateValue]
2642
- );
2643
- const handleSelectAll = React12.useCallback(() => {
2644
- updateValue(
2645
- filteredOptions.filter((opt) => !opt.disabled).map((opt) => opt.value)
2646
- );
2647
- }, [updateValue, filteredOptions]);
2648
- const handleClearAll = React12.useCallback(() => {
2649
- updateValue([]);
2650
- }, [updateValue]);
2651
- const handleRemove = React12.useCallback(
2652
- (optionValue, e) => {
2653
- e.stopPropagation();
2654
- updateValue(value.filter((v) => v !== optionValue));
2655
- },
2656
- [updateValue, value]
2657
- );
2658
- const clearExtraOptions = React12.useCallback(() => {
2659
- const newSelectedValues = value.slice(0, responsiveSettings.maxCount);
2660
- updateValue(newSelectedValues);
2661
- }, [value, responsiveSettings.maxCount, updateValue]);
2662
- React12__namespace.useImperativeHandle(
2663
- ref,
2664
- () => ({
2665
- reset: () => {
2666
- updateValue(defaultValue);
2667
- setOpen(false);
2668
- setSearchValue("");
2669
- },
2670
- getSelectedValues: () => value,
2671
- setSelectedValues: (values) => {
2672
- updateValue(values);
2673
- },
2674
- clear: () => {
2675
- updateValue([]);
2676
- },
2677
- focus: () => {
2678
- buttonRef.current?.focus();
2679
- }
2680
- }),
2681
- [value, defaultValue, updateValue]
2682
- );
2683
- const selectedOptions = options.filter(
2684
- (option) => value.includes(option.value)
2685
- );
2686
- const getBadgeColor = (index) => {
2687
- const colors = [
2688
- "bg-blue-100 text-blue-700 hover:bg-blue-200",
2689
- "bg-green-100 text-green-700 hover:bg-green-200",
2690
- "bg-purple-100 text-purple-700 hover:bg-purple-200",
2691
- "bg-orange-100 text-orange-700 hover:bg-orange-200",
2692
- "bg-pink-100 text-pink-700 hover:bg-pink-200",
2693
- "bg-cyan-100 text-cyan-700 hover:bg-cyan-200"
2694
- ];
2695
- return colors[index % colors.length];
2696
- };
2697
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: "relative w-full", children: [
2698
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sr-only", children: [
2699
- /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-live": "polite", "aria-atomic": "true", role: "status", children: politeMessage }),
2700
- /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-live": "assertive", "aria-atomic": "true", role: "alert", children: assertiveMessage })
2701
- ] }),
2702
- /* @__PURE__ */ jsxRuntime.jsxs(
2703
- Button,
2704
- {
2705
- ref: buttonRef,
2706
- type: "button",
2707
- variant: "outline",
2708
- role: "combobox",
2709
- "aria-expanded": open,
2710
- disabled,
2711
- className: cn(
2712
- "w-full justify-between h-auto min-h-10 px-3 py-2",
2713
- responsiveSettings.compactMode && "min-h-8 text-sm",
2714
- className
2715
- ),
2716
- id,
2717
- onClick: (e) => {
2718
- e.stopPropagation();
2719
- setOpen(!open);
2720
- },
2721
- children: [
2722
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-1", children: selectedOptions.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2723
- selectedOptions.slice(0, responsiveSettings.maxCount).map((option, index) => /* @__PURE__ */ jsxRuntime.jsxs(
2724
- Badge,
2725
- {
2726
- className: cn(
2727
- "mr-1 mb-1",
2728
- getBadgeColor(index),
2729
- responsiveSettings.compactMode && "text-xs px-1.5 py-0.5"
2730
- ),
2731
- onClick: (e) => handleRemove(option.value, e),
2732
- children: [
2733
- option.icon && !responsiveSettings.compactMode && /* @__PURE__ */ jsxRuntime.jsx(option.icon, { className: "mr-2 h-4 w-4" }),
2734
- option.label,
2735
- /* @__PURE__ */ jsxRuntime.jsx(
2736
- "div",
2737
- {
2738
- role: "button",
2739
- tabIndex: 0,
2740
- className: "ml-1 ring-offset-background rounded-full outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 cursor-pointer",
2741
- onKeyDown: (e) => {
2742
- if (e.key === "Enter") {
2743
- handleRemove(option.value, e);
2744
- }
2745
- },
2746
- onMouseDown: (e) => {
2747
- e.preventDefault();
2748
- e.stopPropagation();
2749
- },
2750
- onClick: (e) => handleRemove(option.value, e),
2751
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-3 w-3 text-muted-foreground hover:text-foreground" })
2752
- }
2753
- )
2754
- ]
2755
- },
2756
- String(option.value)
2757
- )),
2758
- value.length > responsiveSettings.maxCount && /* @__PURE__ */ jsxRuntime.jsxs(
2759
- Badge,
2760
- {
2761
- className: cn(
2762
- "mr-1 mb-1 bg-muted text-muted-foreground hover:bg-muted",
2763
- responsiveSettings.compactMode && "text-xs px-1.5 py-0.5"
2764
- ),
2765
- children: [
2766
- "+",
2767
- value.length - responsiveSettings.maxCount,
2768
- " more",
2769
- /* @__PURE__ */ jsxRuntime.jsx(
2770
- "div",
2771
- {
2772
- role: "button",
2773
- tabIndex: 0,
2774
- className: "ml-1 ring-offset-background rounded-full outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 cursor-pointer",
2775
- onClick: (e) => {
2776
- e.stopPropagation();
2777
- clearExtraOptions();
2778
- },
2779
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-3 w-3" })
2780
- }
2781
- )
2782
- ]
2783
- }
2784
- )
2785
- ] }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: placeholder }) }),
2786
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsUpDown, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
2787
- ]
2788
- }
2789
- ),
2790
- open && /* @__PURE__ */ jsxRuntime.jsx(
2791
- "div",
2792
- {
2793
- ref: dropdownRef,
2794
- className: "absolute z-[100] mt-1 w-full rounded-md border bg-popover text-popover-foreground shadow-md",
2795
- style: {
2796
- top: "100%",
2797
- left: 0
2798
- },
2799
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
2800
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center border-b px-3 py-2", children: [
2801
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
2802
- /* @__PURE__ */ jsxRuntime.jsx(
2803
- Input,
2804
- {
2805
- ref: searchInputRef,
2806
- placeholder: searchPlaceholder,
2807
- value: searchValue,
2808
- onChange: (e) => {
2809
- e.stopPropagation();
2810
- setSearchValue(e.target.value);
2811
- },
2812
- onKeyDown: (e) => {
2813
- e.stopPropagation();
2814
- if (e.key === "Escape") {
2815
- e.preventDefault();
2816
- setOpen(false);
2817
- }
2818
- },
2819
- onClick: (e) => {
2820
- e.stopPropagation();
2821
- },
2822
- onFocus: (e) => {
2823
- e.stopPropagation();
2824
- },
2825
- className: "border-0 focus-visible:ring-0 focus-visible:ring-offset-0 h-9 bg-transparent px-0"
2826
- }
2827
- ),
2828
- searchValue && /* @__PURE__ */ jsxRuntime.jsx(
2829
- Button,
2830
- {
2831
- type: "button",
2832
- variant: "ghost",
2833
- size: "sm",
2834
- className: "h-6 w-6 p-0",
2835
- onClick: (e) => {
2836
- e.stopPropagation();
2837
- setSearchValue("");
2838
- searchInputRef.current?.focus();
2839
- },
2840
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-3 w-3" })
2841
- }
2842
- )
2843
- ] }),
2844
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between border-b p-1", children: [
2845
- /* @__PURE__ */ jsxRuntime.jsx(
2846
- Button,
2847
- {
2848
- type: "button",
2849
- variant: "ghost",
2850
- size: "sm",
2851
- className: "h-8 px-2 text-xs",
2852
- onClick: (e) => {
2853
- e.stopPropagation();
2854
- handleSelectAll();
2855
- },
2856
- children: "Select All"
2857
- }
2858
- ),
2859
- /* @__PURE__ */ jsxRuntime.jsx(
2860
- Button,
2861
- {
2862
- type: "button",
2863
- variant: "ghost",
2864
- size: "sm",
2865
- className: "h-8 px-2 text-xs",
2866
- onClick: (e) => {
2867
- e.stopPropagation();
2868
- handleClearAll();
2869
- },
2870
- children: "Clear All"
2871
- }
2872
- )
2873
- ] }),
2874
- /* @__PURE__ */ jsxRuntime.jsx(ScrollArea, { className: "max-h-[300px]", children: filteredOptions.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-6 text-center text-sm text-muted-foreground", children: emptyText }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-1", children: filteredOptions.map((option) => {
2875
- const isSelected = value.includes(option.value);
2876
- const isDisabled = option.disabled || false;
2877
- return /* @__PURE__ */ jsxRuntime.jsxs(
2878
- "div",
2879
- {
2880
- role: "option",
2881
- "aria-selected": isSelected,
2882
- "aria-disabled": isDisabled,
2883
- className: cn(
2884
- "relative flex select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none",
2885
- isDisabled ? "cursor-not-allowed opacity-50" : "cursor-pointer hover:bg-accent hover:text-accent-foreground",
2886
- isSelected && !isDisabled && "bg-accent text-accent-foreground"
2887
- ),
2888
- onMouseDown: (e) => {
2889
- e.preventDefault();
2890
- e.stopPropagation();
2891
- },
2892
- onClick: (e) => {
2893
- e.preventDefault();
2894
- e.stopPropagation();
2895
- if (!isDisabled) {
2896
- handleSelect(option.value);
2897
- }
2898
- },
2899
- children: [
2900
- /* @__PURE__ */ jsxRuntime.jsx(
2901
- "div",
2902
- {
2903
- className: cn(
2904
- "mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",
2905
- isSelected ? "bg-primary text-primary-foreground" : "opacity-50 [&_svg]:invisible"
2906
- ),
2907
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: cn("h-4 w-4") })
2908
- }
2909
- ),
2910
- option.icon && /* @__PURE__ */ jsxRuntime.jsx(option.icon, { className: "mr-2 h-4 w-4 text-muted-foreground" }),
2911
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1 truncate", children: option.label })
2912
- ]
2913
- },
2914
- String(option.value)
2915
- );
2916
- }) }) }),
2917
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t p-2", children: /* @__PURE__ */ jsxRuntime.jsx(
2918
- Button,
2919
- {
2920
- type: "button",
2921
- variant: "outline",
2922
- size: "sm",
2923
- className: "w-full h-8 text-xs",
2924
- onClick: (e) => {
2925
- e.stopPropagation();
2926
- setOpen(false);
2927
- },
2928
- children: "Close"
2929
- }
2930
- ) })
2931
- ] })
2932
- }
2933
- )
2934
- ] });
2935
- }
2936
- );
2937
- MultiSelect.displayName = "MultiSelect";
2938
- }
2939
- });
2940
- var init_date_picker = __esm({
2941
- "src/ui/forms/date-picker.tsx"() {
2942
- "use client";
2943
- }
2944
- });
2945
- var init_date_range_picker = __esm({
2946
- "src/ui/forms/date-range-picker.tsx"() {
2947
- "use client";
2948
- }
2949
- });
2950
- var init_input_time = __esm({
2951
- "src/ui/forms/input-time.tsx"() {
2952
- "use client";
2953
- }
2954
- });
2955
- var init_date_time_picker = __esm({
2956
- "src/ui/forms/date-time-picker.tsx"() {
2957
- "use client";
2958
- }
2959
- });
2960
- var init_emoji_picker = __esm({
2961
- "src/ui/forms/emoji-picker.tsx"() {
2962
- "use client";
2963
- dynamic__default.default(
2964
- () => {
2965
- return import('emoji-picker-react');
2966
- },
2967
- { ssr: false }
2968
- );
2969
- }
2970
- });
2971
- var init_file_thumbnail = __esm({
2972
- "src/ui/forms/file-thumbnail.tsx"() {
2973
- }
2974
- });
2975
- var init_file_dropzone = __esm({
2976
- "src/ui/forms/file-dropzone.tsx"() {
2977
- "use client";
2978
- }
2979
- });
2980
- var init_input_file = __esm({
2981
- "src/ui/forms/input-file.tsx"() {
2982
- "use client";
2983
- }
2984
- });
2985
- var init_input_group = __esm({
2986
- "src/ui/forms/input-group.tsx"() {
2987
- "use client";
2988
- }
2989
- });
2990
- var init_input_otp = __esm({
2991
- "src/ui/forms/input-otp.tsx"() {
2992
- "use client";
2993
- }
2994
- });
2995
- var init_input_phone = __esm({
2996
- "src/ui/forms/input-phone.tsx"() {
2997
- "use client";
2998
- }
2999
- });
3000
- var init_input_spin = __esm({
3001
- "src/ui/forms/input-spin.tsx"() {
3002
- "use client";
3003
- }
3004
- });
3005
- var init_input_tags = __esm({
3006
- "src/ui/forms/input-tags.tsx"() {
3007
- "use client";
3008
- }
3009
- });
3010
- var init_multiple_date_picker = __esm({
3011
- "src/ui/forms/multiple-date-picker.tsx"() {
3012
- "use client";
3013
- }
3014
- });
3015
- var init_time_picker = __esm({
3016
- "src/ui/forms/time-picker.tsx"() {
3017
- "use client";
3018
- }
3019
- });
3020
- var init_editor = __esm({
3021
- "src/ui/forms/editor/index.tsx"() {
3022
- "use client";
3023
- }
3024
- });
3025
- var init_forms = __esm({
3026
- "src/ui/forms/index.tsx"() {
3027
- "use client";
3028
- init_radio_group();
3029
- init_rating();
3030
- init_command();
3031
- init_multi_select();
3032
- init_date_picker();
3033
- init_date_range_picker();
3034
- init_date_time_picker();
3035
- init_emoji_picker();
3036
- init_file_dropzone();
3037
- init_file_thumbnail();
3038
- init_input_file();
3039
- init_input_group();
3040
- init_input_otp();
3041
- init_input_phone();
3042
- init_input_spin();
3043
- init_input_tags();
3044
- init_input_time();
3045
- init_multiple_date_picker();
3046
- init_time_picker();
3047
- init_editor();
3048
- React12.createContext(
3049
- {}
3050
- );
3051
- React12.createContext(
3052
- {}
3053
- );
3054
- }
3055
- });
3056
- var init_formatted_number_input = __esm({
3057
- "src/ui/data-display/formatted-number-input.tsx"() {
3058
- "use client";
3059
- }
3060
- });
3061
- var init_data_table_pagination = __esm({
3062
- "src/ui/data-display/data-table-pagination.tsx"() {
3063
- "use client";
3064
- }
3065
- });
3066
- var init_kpi_card = __esm({
3067
- "src/ui/data-display/kpi-card.tsx"() {
3068
- "use client";
3069
- }
3070
- });
3071
- var THEME_STYLES, CompactStatBar;
3072
- var init_compact_stat_bar = __esm({
3073
- "src/ui/data-display/compact-stat-bar.tsx"() {
3074
- init_utils();
3075
- THEME_STYLES = {
3076
- dark: {
3077
- wrapper: "hover:bg-[#181d26]/5 dark:hover:bg-slate-100/5",
3078
- box: "bg-[#181d26] group-hover:bg-[#0a2e0e] dark:bg-slate-800 dark:group-hover:bg-slate-700",
3079
- icon: "text-white",
3080
- label: "text-[#181d26] dark:text-slate-300"
3081
- },
3082
- green: {
3083
- wrapper: "hover:bg-[#006400]/10",
3084
- box: "bg-[#006400] group-hover:bg-[#39bf45]",
3085
- icon: "text-white",
3086
- label: "text-[#006400] dark:text-[#39bf45]"
3087
- },
3088
- blue: {
3089
- wrapper: "hover:bg-[#254fad]/10",
3090
- box: "bg-[#254fad] group-hover:bg-[#1d3d8f]",
3091
- icon: "text-white",
3092
- label: "text-[#254fad] dark:text-[#60a5fa]"
3093
- },
3094
- purple: {
3095
- wrapper: "hover:bg-[#7C3AED]/10",
3096
- box: "bg-[#7C3AED] group-hover:bg-[#6D28D9]",
3097
- icon: "text-white",
3098
- label: "text-[#7C3AED] dark:text-[#a78bfa]"
3099
- },
3100
- orange: {
3101
- wrapper: "hover:bg-[#EA580C]/10",
3102
- box: "bg-[#EA580C] group-hover:bg-[#C2410C]",
3103
- icon: "text-white",
3104
- label: "text-[#EA580C] dark:text-[#fb923c]"
3105
- },
3106
- emerald: {
3107
- wrapper: "hover:bg-[#059669]/10",
3108
- box: "bg-[#059669] group-hover:bg-[#047857]",
3109
- icon: "text-white",
3110
- label: "text-[#059669] dark:text-[#34d399]"
3111
- },
3112
- primary: {
3113
- wrapper: "hover:bg-primary/10",
3114
- box: "bg-primary group-hover:bg-primary/90",
3115
- icon: "text-primary-foreground",
3116
- label: "text-primary"
3117
- },
3118
- destructive: {
3119
- wrapper: "hover:bg-destructive/10",
3120
- box: "bg-destructive group-hover:bg-destructive/90",
3121
- icon: "text-destructive-foreground",
3122
- label: "text-destructive"
3123
- },
3124
- muted: {
3125
- wrapper: "hover:bg-muted/50",
3126
- box: "bg-muted group-hover:bg-muted-foreground/20",
3127
- icon: "text-muted-foreground",
3128
- label: "text-muted-foreground"
3129
- },
3130
- rose: {
3131
- wrapper: "hover:bg-[#E11D48]/10",
3132
- box: "bg-[#E11D48] group-hover:bg-[#BE123C]",
3133
- icon: "text-white",
3134
- label: "text-[#E11D48] dark:text-[#fb7185]"
3135
- }
3136
- };
3137
- CompactStatBar = React12.memo(function CompactStatBar2({
3138
- items,
3139
- className
3140
- }) {
3141
- if (!items || items.length === 0) return null;
3142
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("flex flex-col md:flex-row md:items-stretch gap-2 pb-1", className), children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-stretch overflow-x-auto no-scrollbar flex-1 bg-white dark:bg-[#1e293b] border border-slate-200 dark:border-slate-800 shadow-sm rounded-[10px] divide-x divide-slate-100 dark:divide-slate-800", children: items.map((item) => {
3143
- const theme = THEME_STYLES[item.colorTheme || "dark"];
3144
- const Icon2 = item.icon;
3145
- return /* @__PURE__ */ jsxRuntime.jsxs(
3146
- "div",
3147
- {
3148
- className: cn(
3149
- "flex items-center gap-3 min-w-fit px-5 py-2 flex-1 transition-colors group cursor-default",
3150
- theme.wrapper
3151
- ),
3152
- children: [
3153
- /* @__PURE__ */ jsxRuntime.jsx(
3154
- "div",
3155
- {
3156
- className: cn(
3157
- "p-1.5 rounded-md transition-colors shadow-sm shrink-0",
3158
- theme.box
3159
- ),
3160
- children: /* @__PURE__ */ jsxRuntime.jsx(Icon2, { className: cn("w-3.5 h-3.5", theme.icon), strokeWidth: 2.5 })
3161
- }
3162
- ),
3163
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
3164
- /* @__PURE__ */ jsxRuntime.jsx(
3165
- "span",
3166
- {
3167
- className: cn(
3168
- "text-[9px] font-bold uppercase tracking-wider mb-0.5",
3169
- item.isHighlighted ? "text-emerald-600 dark:text-emerald-400" : theme.label
3170
- ),
3171
- children: item.label
3172
- }
3173
- ),
3174
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(
3175
- "font-black leading-none",
3176
- item.isHighlighted ? "text-[22px] text-emerald-700 dark:text-emerald-400" : "text-[17px] text-slate-900 dark:text-white"
3177
- ), children: item.value })
3178
- ] })
3179
- ]
3180
- },
3181
- item.id
3182
- );
3183
- }) }) });
3184
- });
3185
- }
3186
- });
3187
- var init_show_more_text = __esm({
3188
- "src/ui/data-display/show-more-text.tsx"() {
3189
- "use client";
3190
- }
3191
- });
3192
- var init_chart = __esm({
3193
- "src/ui/data-display/chart.tsx"() {
3194
- "use client";
3195
- React12.createContext(null);
3196
- }
3197
- });
3198
- var init_carousel = __esm({
3199
- "src/ui/data-display/carousel.tsx"() {
3200
- "use client";
3201
- React12.createContext(null);
3202
- }
3203
- });
3204
- var init_accordion = __esm({
3205
- "src/ui/data-display/accordion.tsx"() {
3206
- "use client";
3207
- }
3208
- });
3209
- var init_kanban_item = __esm({
3210
- "src/ui/data-display/kanban/kanban-item.tsx"() {
3211
- }
3212
- });
3213
- var init_kanban_column = __esm({
3214
- "src/ui/data-display/kanban/kanban-column.tsx"() {
3215
- }
3216
- });
3217
- var init_kanban_board = __esm({
3218
- "src/ui/data-display/kanban/kanban-board.tsx"() {
3219
- }
3220
- });
3221
-
3222
- // src/ui/data-display/kanban/kanban-types.ts
3223
- var init_kanban_types = __esm({
3224
- "src/ui/data-display/kanban/kanban-types.ts"() {
3225
- }
3226
- });
3227
-
3228
- // src/ui/data-display/kanban/index.ts
3229
- var init_kanban = __esm({
3230
- "src/ui/data-display/kanban/index.ts"() {
3231
- init_kanban_board();
3232
- init_kanban_column();
3233
- init_kanban_item();
3234
- init_kanban_types();
3235
- }
3236
- });
3237
- var init_aspect_ratio = __esm({
3238
- "src/ui/data-display/aspect-ratio.tsx"() {
3239
- "use client";
3240
- }
3241
- });
3242
- var init_bento_grid = __esm({
3243
- "src/ui/data-display/bento-grid.tsx"() {
3244
- }
3245
- });
3246
- var init_highlight = __esm({
3247
- "src/ui/data-display/highlight.tsx"() {
3248
- }
3249
- });
3250
- var init_code_block_highlight = __esm({
3251
- "src/ui/data-display/code-block-highlight.tsx"() {
3252
- "use client";
3253
- }
3254
- });
3255
- var init_collapsible = __esm({
3256
- "src/ui/data-display/collapsible.tsx"() {
3257
- "use client";
3258
- }
3259
- });
3260
- var init_hover_card = __esm({
3261
- "src/ui/data-display/hover-card.tsx"() {
3262
- "use client";
3263
- }
3264
- });
3265
- var init_iphone_15_pro = __esm({
3266
- "src/ui/data-display/iphone-15-pro.tsx"() {
3267
- }
3268
- });
3269
- var init_media_grid = __esm({
3270
- "src/ui/data-display/media-grid.tsx"() {
3271
- "use client";
3272
- }
3273
- });
3274
- var init_safari = __esm({
3275
- "src/ui/data-display/safari.tsx"() {
3276
- }
3277
- });
3278
- var init_timeline = __esm({
3279
- "src/ui/data-display/timeline.tsx"() {
3280
- classVarianceAuthority.cva("grid", {
3281
- variants: {
3282
- align: {
3283
- left: "[&>li]:grid-cols-[0_min-content_1fr]",
3284
- right: "[&>li]:grid-cols-[1fr_min-content]",
3285
- center: "[&>li]:grid-cols-[1fr_min-content_1fr]"
3286
- }
3287
- },
3288
- defaultVariants: {
3289
- align: "left"
3290
- }
3291
- });
3292
- classVarianceAuthority.cva("grid items-center gap-x-2", {
3293
- variants: {
3294
- status: {
3295
- done: "text-foreground",
3296
- default: "text-muted-foreground"
3297
- }
3298
- },
3299
- defaultVariants: {
3300
- status: "default"
3301
- }
3302
- });
3303
- classVarianceAuthority.cva("row-start-2 row-end-2 pb-8", {
3304
- variants: {
3305
- side: {
3306
- start: "col-start-3 col-end-4 me-auto text-start",
3307
- end: "col-start-1 col-end-2 ms-auto text-end"
3308
- }
3309
- },
3310
- defaultVariants: {
3311
- side: "start"
3312
- }
3313
- });
3314
- classVarianceAuthority.cva(
3315
- "row-start-1 row-end-1 line-clamp-1 max-w-full truncate",
3316
- {
3317
- variants: {
3318
- side: {
3319
- start: "col-start-3 col-end-4 me-auto text-start",
3320
- end: "col-start-1 col-end-2 ms-auto text-end"
3321
- },
3322
- variant: {
3323
- primary: "text-base font-medium text-foreground",
3324
- secondary: "text-sm font-light text-muted-foreground"
3325
- }
3326
- },
3327
- defaultVariants: {
3328
- side: "start",
3329
- variant: "primary"
3330
- }
3331
- }
3332
- );
3333
- }
3334
- });
3335
-
3336
- // src/ui/data-display/data-table/index.ts
3337
- var init_data_table = __esm({
3338
- "src/ui/data-display/data-table/index.ts"() {
3339
- }
3340
- });
3341
-
3342
- // src/ui/data-display/index.tsx
3343
- var init_data_display = __esm({
3344
- "src/ui/data-display/index.tsx"() {
3345
- "use client";
3346
- init_formatted_number_input();
3347
- init_data_table_pagination();
3348
- init_avatar();
3349
- init_kpi_card();
3350
- init_compact_stat_bar();
3351
- init_show_more_text();
3352
- init_chart();
3353
- init_carousel();
3354
- init_accordion();
3355
- init_kanban();
3356
- init_aspect_ratio();
3357
- init_bento_grid();
3358
- init_code_block_highlight();
3359
- init_collapsible();
3360
- init_highlight();
3361
- init_hover_card();
3362
- init_iphone_15_pro();
3363
- init_media_grid();
3364
- init_safari();
3365
- init_timeline();
3366
- init_data_table();
3367
- }
3368
- });
3369
- var init_auth_layout = __esm({
3370
- "src/ui/auth/auth-layout.tsx"() {
3371
- "use client";
3372
- }
3373
- });
3374
- var init_sign_in_form = __esm({
3375
- "src/ui/auth/sign-in-form.tsx"() {
3376
- "use client";
3377
- }
3378
- });
3379
- var init_register_form = __esm({
3380
- "src/ui/auth/register-form.tsx"() {
3381
- "use client";
3382
- }
3383
- });
3384
- var init_oauth_links = __esm({
3385
- "src/ui/auth/oauth-links.tsx"() {
3386
- "use client";
3387
- }
3388
- });
3389
- var init_forgot_password_form = __esm({
3390
- "src/ui/auth/forgot-password-form.tsx"() {
3391
- "use client";
3392
- }
3393
- });
3394
- var init_new_password_form = __esm({
3395
- "src/ui/auth/new-password-form.tsx"() {
3396
- "use client";
3397
- }
3398
- });
3399
- var init_verify_email_form = __esm({
3400
- "src/ui/auth/verify-email-form.tsx"() {
3401
- "use client";
3402
- }
3403
- });
3404
-
3405
- // src/ui/auth/index.tsx
3406
- var init_auth = __esm({
3407
- "src/ui/auth/index.tsx"() {
3408
- init_auth_layout();
3409
- init_sign_in_form();
3410
- init_register_form();
3411
- init_oauth_links();
3412
- init_forgot_password_form();
3413
- init_new_password_form();
3414
- init_verify_email_form();
3415
- }
3416
- });
3417
- var init_job_management = __esm({
3418
- "src/ui/management/job-management.tsx"() {
3419
- "use client";
3420
- }
3421
- });
3422
- var init_audit_log_page = __esm({
3423
- "src/ui/management/audit-log-page.tsx"() {
3424
- "use client";
3425
- }
3426
- });
3427
- var init_cache_management = __esm({
3428
- "src/ui/management/cache-management.tsx"() {
3429
- "use client";
3430
- }
3431
- });
3432
-
3433
- // src/ui/management/index.ts
3434
- var init_management = __esm({
3435
- "src/ui/management/index.ts"() {
3436
- init_job_management();
3437
- init_audit_log_page();
3438
- init_cache_management();
3439
- }
3440
- });
3441
- var init_not_found = __esm({
3442
- "src/ui/pages/not-found.tsx"() {
3443
- }
3444
- });
3445
-
3446
- // src/ui/index.tsx
3447
- var init_ui = __esm({
3448
- "src/ui/index.tsx"() {
3449
- init_primitives();
3450
- init_client();
3451
- init_forms();
3452
- init_data_display();
3453
- init_feedback();
3454
- init_layout();
3455
- init_auth();
3456
- init_management();
3457
- init_not_found();
3458
- }
3459
- });
3460
-
3461
- // src/rbac/index.ts
3462
- init_utils();
3463
-
3464
- // src/infrastructure/cache/cache.ts
3465
- var MemoryCache = class {
3466
- constructor(options) {
3467
- this.store = /* @__PURE__ */ new Map();
3468
- this.name = options.name;
3469
- this.defaultTtl = options.ttl || 3600;
3470
- this.maxSize = options.max || 1e3;
3471
- this.prefix = options.prefix || "";
3472
- }
3473
- getFullKey(key) {
3474
- return this.prefix ? `${this.prefix}:${this.name}:${key}` : `${this.name}:${key}`;
3475
- }
3476
- isExpired(entry) {
3477
- if (entry.expireAt === null) return false;
3478
- return Date.now() > entry.expireAt;
3479
- }
3480
- cleanup() {
3481
- for (const [key, entry] of this.store.entries()) {
3482
- if (this.isExpired(entry)) {
3483
- this.store.delete(key);
3484
- }
3485
- }
3486
- }
3487
- async get(key) {
3488
- const fullKey = this.getFullKey(key);
3489
- const entry = this.store.get(fullKey);
3490
- if (!entry) return void 0;
3491
- if (this.isExpired(entry)) {
3492
- this.store.delete(fullKey);
3493
- return void 0;
3494
- }
3495
- return entry.value;
3496
- }
3497
- async set(key, value, ttl) {
3498
- const fullKey = this.getFullKey(key);
3499
- const ttlSeconds = ttl ?? this.defaultTtl;
3500
- if (this.store.size >= this.maxSize) {
3501
- this.cleanup();
3502
- if (this.store.size >= this.maxSize) {
3503
- const firstKey = this.store.keys().next().value;
3504
- if (firstKey) this.store.delete(firstKey);
3505
- }
3506
- }
3507
- this.store.set(fullKey, {
3508
- value,
3509
- expireAt: ttlSeconds > 0 ? Date.now() + ttlSeconds * 1e3 : null
3510
- });
3511
- }
3512
- async del(key) {
3513
- const fullKey = this.getFullKey(key);
3514
- this.store.delete(fullKey);
3515
- }
3516
- async has(key) {
3517
- const value = await this.get(key);
3518
- return value !== void 0;
3519
- }
3520
- async reset() {
3521
- const prefix = this.getFullKey("");
3522
- for (const key of this.store.keys()) {
3523
- if (key.startsWith(prefix)) {
3524
- this.store.delete(key);
3525
- }
3526
- }
3527
- }
3528
- async keys() {
3529
- this.cleanup();
3530
- const prefix = this.getFullKey("");
3531
- const result = [];
3532
- for (const key of this.store.keys()) {
3533
- if (key.startsWith(prefix)) {
3534
- result.push(key.slice(prefix.length));
3535
- }
3536
- }
3537
- return result;
3538
- }
3539
- /** Get cache info for admin dashboard */
3540
- getInfo() {
3541
- return {
3542
- name: this.name,
3543
- ttl: this.defaultTtl,
3544
- maxSize: this.maxSize
3545
- };
3546
- }
3547
- };
3548
-
3549
- // src/infrastructure/cache/cache-manager.ts
3550
- var CacheManagerImpl = class {
3551
- constructor(options = {}) {
3552
- this.caches = /* @__PURE__ */ new Map();
3553
- this.options = {
3554
- defaultTtl: options.defaultTtl || 3600,
3555
- prefix: options.prefix || ""
3556
- };
3557
- }
3558
- create(options) {
3559
- const existing = this.caches.get(options.name);
3560
- if (existing) {
3561
- return existing;
3562
- }
3563
- const cache = new MemoryCache({
3564
- ...options,
3565
- ttl: options.ttl || this.options.defaultTtl,
3566
- prefix: this.options.prefix
3567
- });
3568
- this.caches.set(options.name, cache);
3569
- return cache;
3570
- }
3571
- get(name) {
3572
- return this.caches.get(name);
3573
- }
3574
- async flushAll() {
3575
- const promises = [];
3576
- for (const cache of this.caches.values()) {
3577
- promises.push(cache.reset());
3578
- }
3579
- await Promise.all(promises);
3580
- }
3581
- /** Get all cache names */
3582
- getAllCaches() {
3583
- return Array.from(this.caches.keys());
3584
- }
3585
- /** Get stats for all caches (for admin dashboard) */
3586
- async getStats() {
3587
- const stats = [];
3588
- for (const [name, cache] of this.caches.entries()) {
3589
- const keys = await cache.keys();
3590
- stats.push({
3591
- name,
3592
- itemCount: keys.length,
3593
- ttl: cache.getInfo().ttl
3594
- });
3595
- }
3596
- return stats;
3597
- }
3598
- /** Clear a specific cache by name */
3599
- async clearCache(name) {
3600
- const cache = this.caches.get(name);
3601
- if (cache) {
3602
- await cache.reset();
3603
- return true;
3604
- }
3605
- return false;
3606
- }
3607
- };
3608
- var globalForCache = globalThis;
3609
- var cacheManager = globalForCache.coreCacheManager ?? new CacheManagerImpl();
3610
- if (process.env.NODE_ENV !== "production") {
3611
- globalForCache.coreCacheManager = cacheManager;
3612
- }
3613
-
3614
- // src/rbac/permission-service.ts
3615
- init_utils();
3616
- async function getUserPermissionsFromDB(db, userId) {
3617
- try {
3618
- const userRoles = await db.userRole.findMany({
3619
- where: { userId },
3620
- select: {
3621
- roleCode: true,
3622
- role: {
3623
- select: {
3624
- rolePermissions: {
3625
- select: {
3626
- resourceCode: true,
3627
- actionCode: true
3628
- }
3629
- }
3630
- }
3631
- }
3632
- }
3633
- });
3634
- if (userRoles.length === 0) {
3635
- return [];
3636
- }
3637
- const allPermissions = userRoles.flatMap(
3638
- (ur) => ur.role.rolePermissions.map((rp) => ({
3639
- resourceCode: rp.resourceCode,
3640
- actionCode: rp.actionCode
3641
- }))
3642
- );
3643
- const uniquePermissions = Array.from(
3644
- new Map(
3645
- allPermissions.map((p) => [
3646
- `${p.resourceCode}:${p.actionCode}`,
3647
- {
3648
- resourceCode: p.resourceCode,
3649
- actionCode: p.actionCode
3650
- }
3651
- ])
3652
- ).values()
3653
- );
3654
- return uniquePermissions;
3655
- } catch (error) {
3656
- logger.error("Error fetching user permissions from DB", error);
3657
- return [];
3658
- }
3659
- }
3660
- async function getCachedUserPermissions(db, userId, opts) {
3661
- const force = opts?.forceRefresh === true;
3662
- if (!force) {
3663
- const cached = await getFromCache(userId);
3664
- if (cached) return cached;
3665
- }
3666
- const pendingQuery = pendingQueries.get(userId);
3667
- if (pendingQuery) {
3668
- return pendingQuery;
3669
- }
3670
- const queryPromise = getUserPermissionsFromDB(db, userId).then(async (perms) => {
3671
- await setToCache(userId, perms);
3672
- pendingQueries.delete(userId);
3673
- return perms;
3674
- }).catch((error) => {
3675
- pendingQueries.delete(userId);
3676
- throw error;
3677
- });
3678
- pendingQueries.set(userId, queryPromise);
3679
- return queryPromise;
3680
- }
3681
-
3682
- // src/rbac/role-service.ts
3683
- async function getRolesData(db, params = {}) {
3684
- const { page = 1, pageSize = 10, search, status } = params;
3685
- const whereConditions = [];
3686
- if (search) {
3687
- whereConditions.push({
3688
- OR: [
3689
- { name: { contains: search, mode: "insensitive" } },
3690
- { code: { contains: search, mode: "insensitive" } },
3691
- { description: { contains: search, mode: "insensitive" } }
3692
- ]
3693
- });
3694
- }
3695
- if (status && status !== "all") {
3696
- whereConditions.push({ status });
3697
- }
3698
- const where = whereConditions.length > 0 ? { AND: whereConditions } : {};
3699
- const [total, items] = await Promise.all([
3700
- db.role.count({ where }),
3701
- db.role.findMany({
3702
- where,
3703
- orderBy: { createdAt: "desc" },
3704
- skip: (page - 1) * pageSize,
3705
- take: pageSize,
3706
- include: {
3707
- userRoles: {
3708
- include: {
3709
- user: {
3710
- select: {
3711
- id: true,
3712
- name: true,
3713
- email: true,
3714
- image: true,
3715
- isActive: true
3716
- }
3717
- }
3718
- }
3719
- },
3720
- rolePermissions: {
3721
- include: {
3722
- resource: {
3723
- select: {
3724
- code: true,
3725
- name: true,
3726
- icon: true
3727
- }
3728
- },
3729
- action: {
3730
- select: {
3731
- code: true,
3732
- name: true
3733
- }
3734
- }
3735
- }
3736
- }
3737
- }
3738
- })
3739
- ]);
3740
- const transformedItems = items.map((role) => ({
3741
- id: role.id,
3742
- name: role.name,
3743
- code: role.code,
3744
- description: role.description || void 0,
3745
- status: role.status,
3746
- // Transform rolePermissions to array of "action:resource" strings
3747
- permissions: role.rolePermissions.map(
3748
- (rp) => `${rp.actionCode}:${rp.resourceCode}`
3749
- ),
3750
- usersCount: role.userRoles.length,
3751
- users: role.userRoles.map((ur) => ({
3752
- id: ur.user.id,
3753
- name: ur.user.name,
3754
- email: ur.user.email,
3755
- image: ur.user.image,
3756
- isActive: ur.user.isActive
3757
- })),
3758
- createdAt: role.createdAt.toISOString(),
3759
- updatedAt: role.updatedAt.toISOString(),
3760
- createdBy: role.createdBy || void 0,
3761
- updatedBy: role.updatedBy || void 0
3762
- }));
3763
- return { total, page, pageSize, items: transformedItems };
3764
- }
3765
-
3766
- // src/rbac/resource-service.ts
3767
- async function getResourcesData(db, params = {}) {
3768
- const { page = 1, pageSize = 10, search, status, group, type } = params;
3769
- const where = {
3770
- AND: [
3771
- search ? {
3772
- OR: [
3773
- { code: { contains: search, mode: "insensitive" } },
3774
- { name: { contains: search, mode: "insensitive" } },
3775
- { description: { contains: search, mode: "insensitive" } },
3776
- { path: { contains: search, mode: "insensitive" } }
3777
- ]
3778
- } : {},
3779
- status && status !== "all" ? { status: { equals: status, mode: "insensitive" } } : {},
3780
- group && group !== "all" ? { group } : {},
3781
- type && type !== "all" ? { type } : {}
3782
- ]
3783
- };
3784
- const [total, items] = await Promise.all([
3785
- db.resource.count({ where }),
3786
- db.resource.findMany({
3787
- where,
3788
- orderBy: [{ order: "asc" }, { updatedAt: "desc" }],
3789
- skip: (page - 1) * pageSize,
3790
- take: pageSize
3791
- })
3792
- ]);
3793
- const transformedItems = items.map((item) => ({
3794
- id: item.id,
3795
- code: item.code,
3796
- name: item.name,
3797
- group: item.group || void 0,
3798
- description: item.description || void 0,
3799
- status: item.status,
3800
- parentCode: item.parentCode || void 0,
3801
- order: item.order || void 0,
3802
- type: item.type || void 0,
3803
- icon: item.icon || void 0,
3804
- path: item.path || void 0,
3805
- config: item.config || void 0,
3806
- createdAt: item.createdAt.toISOString(),
3807
- updatedAt: item.updatedAt.toISOString()
3808
- }));
3809
- return { total, page, pageSize, items: transformedItems };
3810
- }
3811
- async function getResourcesForPermissionMatrix(db) {
3812
- return await db.resource.findMany({
3813
- where: {
3814
- status: "active"
3815
- },
3816
- orderBy: [{ group: "asc" }, { order: "asc" }, { name: "asc" }],
3817
- select: {
3818
- id: true,
3819
- code: true,
3820
- name: true,
3821
- group: true,
3822
- description: true,
3823
- icon: true,
3824
- order: true,
3825
- config: true
3826
- }
3827
- });
3828
- }
3829
- async function getActionsForPermissionMatrix(db) {
3830
- return await db.action.findMany({
3831
- where: {
3832
- status: "active"
3833
- },
3834
- orderBy: {
3835
- code: "asc"
3836
- },
3837
- select: {
3838
- id: true,
3839
- code: true,
3840
- name: true,
3841
- description: true,
3842
- isDefault: true
3843
- }
3844
- });
3845
- }
3846
-
3847
- // src/rbac/resource-validator.ts
3848
- var resourceCache = cacheManager.create({
3849
- name: "resource-codes",
3850
- ttl: 3600,
3851
- // 1 hour - resource codes rarely change
3852
- max: 1e3
3853
- });
3854
- async function isValidResourceCode(db, resourceCode) {
3855
- const cacheKey = `valid:${resourceCode}`;
3856
- const cached = await resourceCache.get(cacheKey);
3857
- if (cached !== void 0) {
3858
- return cached;
3859
- }
3860
- const resource = await db.resource.findUnique({
3861
- where: { code: resourceCode }
3862
- });
3863
- const isValid = resource !== null;
3864
- await resourceCache.set(cacheKey, isValid);
3865
- return isValid;
3866
- }
3867
- function getPermissionResourceCode(config, entityParam) {
3868
- if (config?.permissionResource) {
3869
- return config.permissionResource;
3870
- }
3871
- if (config?.name) {
3872
- return config.name;
3873
- }
3874
- return entityParam;
3875
- }
3876
- async function validatePermissionResource(db, config, entityParam) {
3877
- const resourceCode = getPermissionResourceCode(config, entityParam);
3878
- const isValid = await isValidResourceCode(db, resourceCode);
3879
- return { resourceCode, isValid };
3880
- }
3881
- async function preloadResourceCodes(db) {
3882
- const resources = await db.resource.findMany({
3883
- select: { code: true }
3884
- });
3885
- for (const resource of resources) {
3886
- await resourceCache.set(`valid:${resource.code}`, true);
3887
- }
3888
- }
3889
- async function clearResourceCache() {
3890
- await resourceCache.reset();
3891
- }
3892
-
3893
- // src/rbac/pages/role-list-page.tsx
3894
- init_ui();
3895
-
3896
- // src/rbac/components/roles/role-stats-cards.tsx
3897
- init_compact_stat_bar();
3898
- var RoleStatsCards = React12.memo(function RoleStatsCards2({
3899
- totalRoles,
3900
- activeRoles,
3901
- totalPermissions,
3902
- totalUsers
3903
- }) {
3904
- const items = [
3905
- { id: "total", label: "T\u1ED5ng vai tr\xF2", value: totalRoles || 0, icon: lucideReact.Shield, colorTheme: "dark" },
3906
- { id: "active", label: "Ho\u1EA1t \u0111\u1ED9ng", value: activeRoles || 0, icon: lucideReact.ShieldCheck, colorTheme: "green" },
3907
- { id: "perms", label: "T\u1ED5ng quy\u1EC1n h\u1EA1n", value: totalPermissions || 0, icon: lucideReact.Key, colorTheme: "purple" },
3908
- { id: "users", label: "T\u1ED5ng ng\u01B0\u1EDDi d\xF9ng", value: totalUsers || 0, icon: lucideReact.Users, colorTheme: "orange" }
3909
- ];
3910
- return /* @__PURE__ */ jsxRuntime.jsx(CompactStatBar, { items });
3911
- });
3912
-
3913
- // src/rbac/components/roles/role-toolbar.tsx
3914
- init_ui();
3915
- var RoleToolbar = React12.memo(function RoleToolbar2({
3916
- dictionary,
3917
- totalRows,
3918
- searchTerm,
3919
- statusFilter,
3920
- onSearchChange,
3921
- onStatusFilterChange,
3922
- lang,
3923
- canCreate,
3924
- canImport,
3925
- canExport
3926
- }) {
3927
- const router = navigation.useRouter();
3928
- const [localSearchTerm, setLocalSearchTerm] = React12.useState(searchTerm);
3929
- React12.useEffect(() => {
3930
- setLocalSearchTerm(searchTerm);
3931
- }, [searchTerm]);
3932
- React12.useEffect(() => {
3933
- const handler = setTimeout(() => {
3934
- if (localSearchTerm !== searchTerm) {
3935
- onSearchChange(localSearchTerm);
3936
- }
3937
- }, 500);
3938
- return () => {
3939
- clearTimeout(handler);
3940
- };
3941
- }, [localSearchTerm, onSearchChange, searchTerm]);
3942
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 flex-wrap", children: [
3943
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
3944
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "absolute left-3 top-2.5 h-4 w-4 text-muted-foreground" }),
3945
- /* @__PURE__ */ jsxRuntime.jsx(
3946
- Input,
3947
- {
3948
- placeholder: "T\xECm ki\u1EBFm vai tr\xF2...",
3949
- value: localSearchTerm,
3950
- onChange: (e) => setLocalSearchTerm(e.target.value),
3951
- className: "h-9 w-[220px] lg:w-[280px] pl-9 text-[13px] bg-[#ffffff] dark:bg-[#181d26] border-[#dddddd] dark:border-[#333840] hover:bg-slate-50 transition-colors shadow-sm rounded-[6px] focus-visible:ring-1 focus-visible:ring-primary"
3952
- }
3953
- ),
3954
- localSearchTerm && /* @__PURE__ */ jsxRuntime.jsx(
3955
- Button,
3956
- {
3957
- variant: "ghost",
3958
- size: "sm",
3959
- className: "absolute right-1 top-1/2 -translate-y-1/2 h-7 w-7 p-0 rounded-md hover:bg-muted",
3960
- onClick: () => setLocalSearchTerm(""),
3961
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-3.5 w-3.5" })
3962
- }
3963
- )
3964
- ] }),
3965
- /* @__PURE__ */ jsxRuntime.jsxs(Select, { value: statusFilter, onValueChange: onStatusFilterChange, children: [
3966
- /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-9 w-[160px] text-[13px] bg-[#ffffff] dark:bg-[#181d26] border-[#dddddd] dark:border-[#333840] hover:bg-slate-50 transition-colors shadow-sm rounded-[6px] focus-visible:ring-primary", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Tr\u1EA1ng th\xE1i" }) }),
3967
- /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { className: "rounded-lg", children: [
3968
- /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "all", children: "T\u1EA5t c\u1EA3" }),
3969
- /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "active", children: "Ho\u1EA1t \u0111\u1ED9ng" }),
3970
- /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "inactive", children: "Kh\xF4ng ho\u1EA1t \u0111\u1ED9ng" })
3971
- ] })
3972
- ] }),
3973
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ml-auto flex items-center gap-2", children: [
3974
- canImport && /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "outline", size: "sm", className: "h-9 px-3 rounded-[6px] shadow-sm bg-[#ffffff] dark:bg-[#181d26] border-[#dddddd] dark:border-[#333840] hover:bg-slate-50", children: [
3975
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Upload, { className: "h-4 w-4 lg:mr-2" }),
3976
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "hidden lg:inline text-[13px]", children: "Nh\u1EADp" })
3977
- ] }),
3978
- canExport && /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "outline", size: "sm", className: "h-9 px-3 rounded-[6px] shadow-sm bg-[#ffffff] dark:bg-[#181d26] border-[#dddddd] dark:border-[#333840] hover:bg-slate-50", children: [
3979
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Download, { className: "h-4 w-4 lg:mr-2" }),
3980
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "hidden lg:inline text-[13px]", children: "Xu\u1EA5t" })
3981
- ] }),
3982
- canCreate && /* @__PURE__ */ jsxRuntime.jsxs(
3983
- Button,
3984
- {
3985
- onClick: () => router.push(`/${lang}/roles/new`),
3986
- size: "sm",
3987
- className: "h-9 px-4 text-[13px] bg-primary hover:bg-primary/90 text-primary-foreground shadow-sm rounded-[6px] font-medium border-0",
3988
- children: [
3989
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "mr-1.5 h-4 w-4" }),
3990
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Th\xEAm m\u1EDBi" })
3991
- ]
3992
- }
3993
- )
3994
- ] })
3995
- ] });
3996
- });
3997
-
3998
- // src/rbac/components/roles/role-card.tsx
3999
- init_ui();
4000
- var roleColors = {
4001
- admin: "bg-red-500",
4002
- finance_manager: "bg-blue-500",
4003
- purchasing_staff: "bg-green-500",
4004
- kitchen_manager: "bg-orange-500",
4005
- warehouse_staff: "bg-purple-500",
4006
- supplier: "bg-gray-500"
4007
- };
4008
- var RoleCard = React12.memo(function RoleCard2({
4009
- role,
4010
- lang,
4011
- canUpdate,
4012
- canCreate,
4013
- canDelete,
4014
- onDuplicate,
4015
- onDelete
4016
- }) {
4017
- const router = navigation.useRouter();
4018
- const permissionsCount = role.permissions.length;
4019
- const roleColor = roleColors[role.code] || "bg-indigo-500";
4020
- const handleEdit = React12.useCallback(() => {
4021
- router.push(`/${lang}/roles/${role.id}/edit`);
4022
- }, [router, lang, role.id]);
4023
- const handleDuplicate = React12.useCallback(() => {
4024
- onDuplicate(role);
4025
- }, [onDuplicate, role]);
4026
- const handleDelete = React12.useCallback(() => {
4027
- onDelete(role);
4028
- }, [onDelete, role]);
4029
- return /* @__PURE__ */ jsxRuntime.jsxs(Card, { className: "group relative transition-all duration-300 border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 rounded-[12px] shadow-sm hover:shadow-md hover:border-primary/40 overflow-hidden", children: [
4030
- /* @__PURE__ */ jsxRuntime.jsx(CardHeader, { className: "p-4 pb-2", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between", children: [
4031
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center space-x-3", children: [
4032
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: `w-3 h-3 rounded-full ${roleColor} ring-4 ring-slate-50 dark:ring-slate-800/50` }) }),
4033
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4034
- /* @__PURE__ */ jsxRuntime.jsx(CardTitle, { className: "text-[15px] font-bold text-slate-900 dark:text-slate-100 leading-tight", children: role.name }),
4035
- /* @__PURE__ */ jsxRuntime.jsx(CardDescription, { className: "text-[11px] font-mono text-slate-500 mt-0.5", children: role.code })
4036
- ] })
4037
- ] }),
4038
- role.status === "active" ? /* @__PURE__ */ jsxRuntime.jsx(
4039
- Badge,
4040
- {
4041
- variant: "outline",
4042
- className: "bg-emerald-50 text-emerald-600 border-emerald-200 dark:bg-emerald-500/10 dark:text-emerald-400 dark:border-emerald-500/20 text-[10px] px-2 py-0 h-5 font-semibold",
4043
- children: "Ho\u1EA1t \u0111\u1ED9ng"
4044
- }
4045
- ) : /* @__PURE__ */ jsxRuntime.jsx(
4046
- Badge,
4047
- {
4048
- variant: "outline",
4049
- className: "bg-slate-100 text-slate-500 border-slate-200 dark:bg-slate-800 dark:text-slate-400 dark:border-slate-700 text-[10px] px-2 py-0 h-5 font-semibold",
4050
- children: "Kh\xF3a"
4051
- }
4052
- )
4053
- ] }) }),
4054
- /* @__PURE__ */ jsxRuntime.jsxs(CardContent, { className: "p-4 pt-0 space-y-3", children: [
4055
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[13px] text-slate-500 dark:text-slate-400 line-clamp-2 min-h-[2.5rem] leading-relaxed", children: role.description || "Ch\u01B0a c\xF3 m\xF4 t\u1EA3 chi ti\u1EBFt cho vai tr\xF2 n\xE0y." }),
4056
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between bg-slate-50 dark:bg-slate-800/50 rounded-lg p-2.5 border border-slate-100 dark:border-slate-800", children: [
4057
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center flex-1 border-r border-slate-200 dark:border-slate-700", children: [
4058
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[16px] font-black text-primary leading-none mb-1", children: permissionsCount }),
4059
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[9px] text-slate-500 font-bold uppercase tracking-wider", children: "Quy\u1EC1n h\u1EA1n" })
4060
- ] }),
4061
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center flex-1", children: [
4062
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[16px] font-black text-emerald-600 dark:text-emerald-500 leading-none mb-1", children: role.usersCount }),
4063
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[9px] text-slate-500 font-bold uppercase tracking-wider", children: "Ng\u01B0\u1EDDi d\xF9ng" })
4064
- ] })
4065
- ] }),
4066
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2 pt-2", children: [
4067
- canUpdate && /* @__PURE__ */ jsxRuntime.jsxs(
4068
- Button,
4069
- {
4070
- variant: "outline",
4071
- size: "sm",
4072
- className: "flex-1 h-8 text-[12px] font-medium bg-white dark:bg-slate-900 border-slate-200 dark:border-slate-800 hover:bg-slate-50 dark:hover:bg-slate-800 hover:text-slate-900 dark:hover:text-slate-100 transition-colors rounded-[8px] shadow-sm",
4073
- onClick: handleEdit,
4074
- children: [
4075
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Edit, { className: "mr-1.5 h-3.5 w-3.5 text-slate-400" }),
4076
- "S\u1EEDa"
4077
- ]
4078
- }
4079
- ),
4080
- canCreate && /* @__PURE__ */ jsxRuntime.jsxs(
4081
- Button,
4082
- {
4083
- variant: "outline",
4084
- size: "sm",
4085
- className: "flex-1 h-8 text-[12px] font-medium bg-white dark:bg-slate-900 border-slate-200 dark:border-slate-800 hover:bg-slate-50 dark:hover:bg-slate-800 hover:text-slate-900 dark:hover:text-slate-100 transition-colors rounded-[8px] shadow-sm",
4086
- onClick: handleDuplicate,
4087
- children: [
4088
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Copy, { className: "mr-1.5 h-3.5 w-3.5 text-slate-400" }),
4089
- "Ch\xE9p"
4090
- ]
4091
- }
4092
- ),
4093
- canDelete && /* @__PURE__ */ jsxRuntime.jsxs(
4094
- Button,
4095
- {
4096
- variant: "outline",
4097
- size: "sm",
4098
- className: "flex-1 h-8 text-[12px] font-medium border-slate-200 dark:border-slate-800 text-red-600 dark:text-red-500 hover:bg-red-50 dark:hover:bg-red-500/10 hover:text-red-700 dark:hover:text-red-400 transition-colors bg-white dark:bg-slate-900 rounded-[8px] shadow-sm",
4099
- onClick: handleDelete,
4100
- children: [
4101
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { className: "mr-1.5 h-3.5 w-3.5" }),
4102
- "X\xF3a"
4103
- ]
4104
- }
4105
- )
4106
- ] })
4107
- ] })
4108
- ] });
4109
- });
4110
- var fetcher = (url) => fetch(url).then((res) => res.json());
4111
- function useRolesData(initialData) {
4112
- const [page, setPage] = React12.useState(1);
4113
- const [pageSize, setPageSize] = React12.useState(20);
4114
- const [searchTerm, setSearchTerm] = React12.useState("");
4115
- const [statusFilter, setStatusFilter] = React12.useState("all");
4116
- const queryParams = React12.useMemo(() => {
4117
- const params = new URLSearchParams({
4118
- page: page.toString(),
4119
- pageSize: pageSize.toString()
4120
- });
4121
- if (searchTerm) params.set("search", searchTerm);
4122
- if (statusFilter !== "all") params.set("status", statusFilter);
4123
- return params.toString();
4124
- }, [page, pageSize, searchTerm, statusFilter]);
4125
- const {
4126
- data: response,
4127
- error,
4128
- isLoading,
4129
- mutate
4130
- } = useSWR__default.default(`/api/roles?${queryParams}`, fetcher, {
4131
- fallbackData: initialData,
4132
- revalidateOnFocus: false,
4133
- revalidateOnReconnect: false,
4134
- keepPreviousData: true
4135
- });
4136
- const roles = response?.items || [];
4137
- const totalRows = response?.total || 0;
4138
- const activeRolesCount = React12.useMemo(
4139
- () => roles.filter((r) => r.status === "active").length,
4140
- [roles]
4141
- );
4142
- return {
4143
- roles,
4144
- totalRows,
4145
- activeRolesCount,
4146
- page,
4147
- pageSize,
4148
- searchTerm,
4149
- statusFilter,
4150
- setPage,
4151
- setPageSize,
4152
- setSearchTerm,
4153
- setStatusFilter,
4154
- error,
4155
- isLoading,
4156
- mutate
4157
- };
4158
- }
4159
-
4160
- // src/rbac/hooks/use-role-operations.ts
4161
- init_tab_content_cache();
4162
- init_tab_navigation_provider();
4163
- function useSafeSession() {
4164
- try {
4165
- return react.useSession();
4166
- } catch (error) {
4167
- console.warn("[useSafeSession] Context error caught. Fallback to unauthenticated state.");
4168
- return { data: null, status: "unauthenticated", update: async () => null };
4169
- }
4170
- }
4171
- function useRoleOperations(mutate) {
4172
- const router = navigation.useRouter();
4173
- const { update } = useSafeSession();
4174
- const { clearAllCache } = useTabContentCache();
4175
- const { clearTabs } = useTabNavigation();
4176
- const afterRbacChange = React12.useCallback(async () => {
4177
- try {
4178
- clearAllCache();
4179
- clearTabs();
4180
- if (typeof window !== "undefined") {
4181
- sessionStorage.removeItem("tab-content-cache");
4182
- sessionStorage.removeItem("tab-navigation-state");
4183
- }
4184
- } catch {
4185
- }
4186
- try {
4187
- await update();
4188
- } catch {
4189
- }
4190
- router.refresh();
4191
- }, [router, update, clearAllCache, clearTabs]);
4192
- const handleCreateRole = React12.useCallback(
4193
- async (roleData) => {
4194
- try {
4195
- const res = await fetch("/api/roles", {
4196
- method: "POST",
4197
- headers: { "Content-Type": "application/json" },
4198
- body: JSON.stringify(roleData)
4199
- });
4200
- if (!res.ok) {
4201
- const errorData = await res.json();
4202
- throw new Error(errorData.error || "Failed to create role");
4203
- }
4204
- sonner.toast.success("Th\xE0nh c\xF4ng", {
4205
- description: "\u0110\xE3 t\u1EA1o vai tr\xF2 m\u1EDBi th\xE0nh c\xF4ng"
4206
- });
4207
- mutate();
4208
- await afterRbacChange();
4209
- return true;
4210
- } catch (error) {
4211
- sonner.toast.error("L\u1ED7i", {
4212
- description: error.message
4213
- });
4214
- return false;
4215
- }
4216
- },
4217
- [mutate, afterRbacChange]
4218
- );
4219
- const handleEditRole = React12.useCallback(
4220
- async (roleId, roleData) => {
4221
- try {
4222
- const res = await fetch(`/api/roles/${roleId}`, {
4223
- method: "PUT",
4224
- headers: { "Content-Type": "application/json" },
4225
- body: JSON.stringify(roleData)
4226
- });
4227
- if (!res.ok) {
4228
- const errorData = await res.json();
4229
- throw new Error(errorData.error || "Failed to update role");
4230
- }
4231
- sonner.toast.success("Th\xE0nh c\xF4ng", {
4232
- description: "\u0110\xE3 c\u1EADp nh\u1EADt vai tr\xF2 th\xE0nh c\xF4ng"
4233
- });
4234
- mutate();
4235
- await afterRbacChange();
4236
- return true;
4237
- } catch (error) {
4238
- sonner.toast.error("L\u1ED7i", {
4239
- description: error.message
4240
- });
4241
- return false;
4242
- }
4243
- },
4244
- [mutate, afterRbacChange]
4245
- );
4246
- const handleDeleteRole = React12.useCallback(
4247
- async (roleId) => {
4248
- try {
4249
- const res = await fetch(`/api/roles/${roleId}`, {
4250
- method: "DELETE"
4251
- });
4252
- if (!res.ok) {
4253
- const errorData = await res.json();
4254
- throw new Error(errorData.error || "Failed to delete role");
4255
- }
4256
- sonner.toast.success("Th\xE0nh c\xF4ng", {
4257
- description: "\u0110\xE3 x\xF3a vai tr\xF2 th\xE0nh c\xF4ng"
4258
- });
4259
- mutate();
4260
- await afterRbacChange();
4261
- return true;
4262
- } catch (error) {
4263
- sonner.toast.error("L\u1ED7i", {
4264
- description: error.message
4265
- });
4266
- return false;
4267
- }
4268
- },
4269
- [mutate, afterRbacChange]
4270
- );
4271
- const handleDuplicateRole = React12.useCallback(
4272
- async (role) => {
4273
- const duplicatedRoleData = {
4274
- name: `${role.name} (Copy)`,
4275
- code: `${role.code}_copy_${Date.now()}`,
4276
- description: role.description,
4277
- status: role.status,
4278
- permissions: role.permissions
4279
- };
4280
- return handleCreateRole(duplicatedRoleData);
4281
- },
4282
- [handleCreateRole]
4283
- );
4284
- return {
4285
- handleCreateRole,
4286
- handleEditRole,
4287
- handleDeleteRole,
4288
- handleDuplicateRole
4289
- };
4290
- }
4291
-
4292
- // src/rbac/lib/permission-helpers.ts
4293
- function getPermissionDescription(permission) {
4294
- const descriptions = {
4295
- "dashboard:view": "Xem b\u1EA3ng \u0111i\u1EC1u khi\u1EC3n",
4296
- "users:view": "Xem danh s\xE1ch ng\u01B0\u1EDDi d\xF9ng",
4297
- "users:create": "T\u1EA1o ng\u01B0\u1EDDi d\xF9ng m\u1EDBi",
4298
- "users:update": "C\u1EADp nh\u1EADt th\xF4ng tin ng\u01B0\u1EDDi d\xF9ng",
4299
- "users:delete": "X\xF3a ng\u01B0\u1EDDi d\xF9ng",
4300
- "roles:view": "Xem danh s\xE1ch vai tr\xF2",
4301
- "roles:create": "T\u1EA1o vai tr\xF2 m\u1EDBi",
4302
- "roles:update": "C\u1EADp nh\u1EADt vai tr\xF2",
4303
- "roles:delete": "X\xF3a vai tr\xF2",
4304
- "reports:view": "Xem b\xE1o c\xE1o",
4305
- "reconciliation:view": "Xem \u0111\u1ED1i so\xE1t",
4306
- "reconciliation:manage": "Qu\u1EA3n l\xFD \u0111\u1ED1i so\xE1t",
4307
- "payment:approve": "Duy\u1EC7t thanh to\xE1n",
4308
- "supplier-pricing:view": "Xem gi\xE1 nh\xE0 cung c\u1EA5p",
4309
- "supplier-pricing:approve": "Duy\u1EC7t gi\xE1 nh\xE0 cung c\u1EA5p",
4310
- "purchase-request:view": "Xem y\xEAu c\u1EA7u mua h\xE0ng",
4311
- "purchase-request:create": "T\u1EA1o y\xEAu c\u1EA7u mua h\xE0ng",
4312
- "purchase-request:update": "C\u1EADp nh\u1EADt y\xEAu c\u1EA7u mua h\xE0ng",
4313
- "purchase-request:approve": "Duy\u1EC7t y\xEAu c\u1EA7u mua h\xE0ng",
4314
- "purchase-order:view": "Xem \u0111\u01A1n h\xE0ng mua",
4315
- "purchase-order:create": "T\u1EA1o \u0111\u01A1n h\xE0ng mua",
4316
- "purchase-order:update": "C\u1EADp nh\u1EADt \u0111\u01A1n h\xE0ng mua",
4317
- "purchase-order:approve": "Duy\u1EC7t \u0111\u01A1n h\xE0ng mua",
4318
- "supplier:view": "Xem nh\xE0 cung c\u1EA5p",
4319
- "supplier-pricing:update": "C\u1EADp nh\u1EADt gi\xE1 nh\xE0 cung c\u1EA5p",
4320
- "material:view": "Xem nguy\xEAn v\u1EADt li\u1EC7u",
4321
- "material-category:view": "Xem nh\xF3m nguy\xEAn v\u1EADt li\u1EC7u",
4322
- "warehouse:view": "Xem kho",
4323
- "goods-receipt:view": "Xem phi\u1EBFu nh\u1EADp kho",
4324
- "goods-receipt:create": "T\u1EA1o phi\u1EBFu nh\u1EADp kho",
4325
- "goods-receipt:update": "C\u1EADp nh\u1EADt phi\u1EBFu nh\u1EADp kho"
4326
- };
4327
- return descriptions[permission] || `Quy\u1EC1n ${permission}`;
4328
- }
4329
- function getUsersWithPermission(permission, roles) {
4330
- const usersWithPermission = [];
4331
- roles.forEach((role) => {
4332
- if (role.permissions.includes(permission)) {
4333
- usersWithPermission.push(...role.users);
4334
- }
4335
- });
4336
- return Array.from(
4337
- new Map(usersWithPermission.map((u) => [u.id, u])).values()
4338
- );
4339
- }
4340
- function RoleListPage({
4341
- dictionary,
4342
- permissions,
4343
- lang,
4344
- initialData,
4345
- resources,
4346
- actions
4347
- }) {
4348
- const canCreate = permissions.create;
4349
- const canUpdate = permissions.update;
4350
- const canDelete = permissions.delete;
4351
- const canImport = permissions.import;
4352
- const canExport = permissions.export;
4353
- const {
4354
- roles,
4355
- totalRows,
4356
- activeRolesCount,
4357
- searchTerm,
4358
- statusFilter,
4359
- setSearchTerm,
4360
- setStatusFilter,
4361
- error,
4362
- isLoading,
4363
- mutate
4364
- } = useRolesData(initialData);
4365
- const {
4366
- handleDeleteRole,
4367
- handleDuplicateRole
4368
- } = useRoleOperations(mutate);
4369
- const [isDeleteDialogOpen, setIsDeleteDialogOpen] = React12.useState(false);
4370
- const [roleToDelete, setRoleToDelete] = React12.useState(null);
4371
- const [isPermissionDetailOpen, setIsPermissionDetailOpen] = React12.useState(false);
4372
- const [selectedPermission, setSelectedPermission] = React12.useState(
4373
- null
4374
- );
4375
- const permissionMatrix = React12.useMemo(() => {
4376
- return resources.map((resource) => {
4377
- let allowedActions = [];
4378
- const defaultActions = actions.filter((a) => a.isDefault).map((a) => a.code);
4379
- const effectiveDefaultActions = defaultActions.length > 0 ? defaultActions : ["view", "create", "update", "delete"];
4380
- if (resource.config) {
4381
- try {
4382
- const config = typeof resource.config === "string" ? JSON.parse(resource.config) : resource.config;
4383
- if (config.actions && Array.isArray(config.actions)) {
4384
- const allowedCodes = config.actions;
4385
- allowedActions = actions.map((a) => a.code).filter((code) => allowedCodes.includes(code));
4386
- } else {
4387
- allowedActions = actions.map((a) => a.code).filter((code) => effectiveDefaultActions.includes(code));
4388
- }
4389
- } catch (e) {
4390
- console.warn("Failed to parse resource config", e);
4391
- allowedActions = actions.map((a) => a.code).filter((code) => effectiveDefaultActions.includes(code));
4392
- }
4393
- } else {
4394
- allowedActions = actions.map((a) => a.code).filter((code) => effectiveDefaultActions.includes(code));
4395
- }
4396
- return {
4397
- resource: resource.code,
4398
- name: resource.name,
4399
- icon: resource.icon || "\u{1F4C4}",
4400
- actions: allowedActions
4401
- };
4402
- });
4403
- }, [resources, actions]);
4404
- const totalPermissions = React12.useMemo(
4405
- () => permissionMatrix.flatMap((r) => r.actions).length,
4406
- [permissionMatrix]
4407
- );
4408
- const totalUsers = React12.useMemo(
4409
- () => roles.reduce((sum, role) => sum + role.usersCount, 0),
4410
- [roles]
4411
- );
4412
- const openDeleteDialog = React12.useCallback((role) => {
4413
- setRoleToDelete(role);
4414
- setIsDeleteDialogOpen(true);
4415
- }, []);
4416
- const handleDelete = React12.useCallback(async () => {
4417
- if (!roleToDelete) return;
4418
- const success = await handleDeleteRole(roleToDelete.id);
4419
- if (success) {
4420
- setIsDeleteDialogOpen(false);
4421
- setRoleToDelete(null);
4422
- }
4423
- }, [roleToDelete, handleDeleteRole]);
4424
- const getUsersForPermission = React12.useCallback(
4425
- (permission) => {
4426
- return getUsersWithPermission(permission, roles);
4427
- },
4428
- [roles]
4429
- );
4430
- if (isLoading) {
4431
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center h-96", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "h-8 w-8 animate-spin text-muted-foreground" }) });
4432
- }
4433
- if (error) {
4434
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-red-500", children: [
4435
- "Kh\xF4ng th\u1EC3 t\u1EA3i d\u1EEF li\u1EC7u: ",
4436
- error.message
4437
- ] });
4438
- }
4439
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
4440
- /* @__PURE__ */ jsxRuntime.jsx(
4441
- RoleStatsCards,
4442
- {
4443
- totalRoles: totalRows,
4444
- activeRoles: activeRolesCount,
4445
- totalPermissions,
4446
- totalUsers
4447
- }
4448
- ),
4449
- /* @__PURE__ */ jsxRuntime.jsx(
4450
- RoleToolbar,
4451
- {
4452
- dictionary,
4453
- totalRows,
4454
- searchTerm,
4455
- statusFilter,
4456
- onSearchChange: setSearchTerm,
4457
- onStatusFilterChange: setStatusFilter,
4458
- lang,
4459
- canCreate,
4460
- canImport,
4461
- canExport
4462
- }
4463
- ),
4464
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4", children: [
4465
- roles.length === 0 && !isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-span-full text-center py-8", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground", children: roles.length === 0 ? "Kh\xF4ng c\xF3 d\u1EEF li\u1EC7u roles" : "Kh\xF4ng t\xECm th\u1EA5y roles ph\xF9 h\u1EE3p v\u1EDBi b\u1ED9 l\u1ECDc" }) }) : null,
4466
- roles.map((role) => /* @__PURE__ */ jsxRuntime.jsx(
4467
- RoleCard,
4468
- {
4469
- role,
4470
- lang,
4471
- canUpdate,
4472
- canCreate,
4473
- canDelete,
4474
- onDuplicate: handleDuplicateRole,
4475
- onDelete: openDeleteDialog
4476
- },
4477
- role.id
4478
- ))
4479
- ] }),
4480
- /* @__PURE__ */ jsxRuntime.jsx(
4481
- AlertDialog,
4482
- {
4483
- open: isDeleteDialogOpen,
4484
- onOpenChange: setIsDeleteDialogOpen,
4485
- children: /* @__PURE__ */ jsxRuntime.jsxs(AlertDialogContent, { children: [
4486
- /* @__PURE__ */ jsxRuntime.jsxs(AlertDialogHeader, { children: [
4487
- /* @__PURE__ */ jsxRuntime.jsx(AlertDialogTitle, { children: "X\xE1c nh\u1EADn x\xF3a vai tr\xF2" }),
4488
- /* @__PURE__ */ jsxRuntime.jsxs(AlertDialogDescription, { children: [
4489
- 'B\u1EA1n c\xF3 ch\u1EAFc ch\u1EAFn mu\u1ED1n x\xF3a vai tr\xF2 "',
4490
- roleToDelete?.name,
4491
- '"? H\xE0nh \u0111\u1ED9ng n\xE0y kh\xF4ng th\u1EC3 ho\xE0n t\xE1c.'
4492
- ] })
4493
- ] }),
4494
- /* @__PURE__ */ jsxRuntime.jsxs(AlertDialogFooter, { children: [
4495
- /* @__PURE__ */ jsxRuntime.jsx(AlertDialogCancel, { onClick: () => setRoleToDelete(null), children: "H\u1EE7y" }),
4496
- /* @__PURE__ */ jsxRuntime.jsx(AlertDialogAction, { onClick: handleDelete, children: "X\xF3a" })
4497
- ] })
4498
- ] })
4499
- }
4500
- ),
4501
- /* @__PURE__ */ jsxRuntime.jsx(
4502
- Dialog,
4503
- {
4504
- open: isPermissionDetailOpen,
4505
- onOpenChange: setIsPermissionDetailOpen,
4506
- children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "max-w-2xl", children: [
4507
- /* @__PURE__ */ jsxRuntime.jsxs(DialogHeader, { children: [
4508
- /* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: "flex items-center space-x-2", children: [
4509
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.KeyRound, { className: "h-5 w-5" }),
4510
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Chi ti\u1EBFt Quy\u1EC1n h\u1EA1n" })
4511
- ] }),
4512
- /* @__PURE__ */ jsxRuntime.jsx(DialogDescription, { children: "Xem danh s\xE1ch ng\u01B0\u1EDDi d\xF9ng \u0111\u01B0\u1EE3c g\xE1n quy\u1EC1n h\u1EA1n n\xE0y" })
4513
- ] }),
4514
- selectedPermission && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
4515
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-4 bg-muted/50 rounded-lg", children: [
4516
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center space-x-2 mb-2", children: [
4517
- /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "outline", className: "text-sm", children: selectedPermission.split(":")[0] }),
4518
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: ":" }),
4519
- /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "outline", className: "text-sm", children: selectedPermission.split(":")[1] })
4520
- ] }),
4521
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: getPermissionDescription(selectedPermission) })
4522
- ] }),
4523
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4524
- /* @__PURE__ */ jsxRuntime.jsxs("h4", { className: "font-medium mb-3", children: [
4525
- "Ng\u01B0\u1EDDi d\xF9ng c\xF3 quy\u1EC1n n\xE0y (",
4526
- getUsersForPermission(selectedPermission).length,
4527
- ")"
4528
- ] }),
4529
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-2 max-h-60 overflow-y-auto", children: getUsersForPermission(selectedPermission).length > 0 ? getUsersForPermission(selectedPermission).map((user) => /* @__PURE__ */ jsxRuntime.jsxs(
4530
- "div",
4531
- {
4532
- className: "flex items-center space-x-3 p-3 bg-muted/30 rounded-lg",
4533
- children: [
4534
- /* @__PURE__ */ jsxRuntime.jsxs(Avatar, { className: "h-10 w-10", children: [
4535
- /* @__PURE__ */ jsxRuntime.jsx(
4536
- AvatarImage,
4537
- {
4538
- src: user.image || void 0,
4539
- alt: user.name || ""
4540
- }
4541
- ),
4542
- /* @__PURE__ */ jsxRuntime.jsx(AvatarFallback, { children: (user.name || "U").split(" ").map((n) => n[0]).join("") })
4543
- ] }),
4544
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
4545
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium", children: user.name }),
4546
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: user.jobTitle || "N/A" }),
4547
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: user.email })
4548
- ] }),
4549
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center space-x-2", children: user.isActive ? /* @__PURE__ */ jsxRuntime.jsxs(Badge, { variant: "default", className: "text-xs", children: [
4550
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.UserCheck, { className: "h-3 w-3 mr-1" }),
4551
- "Active"
4552
- ] }) : /* @__PURE__ */ jsxRuntime.jsxs(Badge, { variant: "secondary", className: "text-xs", children: [
4553
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.UserX, { className: "h-3 w-3 mr-1" }),
4554
- "Inactive"
4555
- ] }) })
4556
- ]
4557
- },
4558
- user.id
4559
- )) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center p-6 text-muted-foreground", children: [
4560
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.UserX, { className: "h-12 w-12 mx-auto mb-3 opacity-50" }),
4561
- /* @__PURE__ */ jsxRuntime.jsx("p", { children: "Kh\xF4ng c\xF3 ng\u01B0\u1EDDi d\xF9ng n\xE0o c\xF3 quy\u1EC1n n\xE0y" })
4562
- ] }) })
4563
- ] })
4564
- ] }),
4565
- /* @__PURE__ */ jsxRuntime.jsx(DialogFooter, { children: /* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => setIsPermissionDetailOpen(false), children: "\u0110\xF3ng" }) })
4566
- ] })
4567
- }
4568
- )
4569
- ] });
4570
- }
4571
-
4572
- // src/rbac/index.ts
4573
- var CRUD_ACTIONS = {
4574
- create: "create",
4575
- view: "view",
4576
- update: "update",
4577
- delete: "delete",
4578
- export: "export",
4579
- import: "import",
4580
- approve: "approve",
4581
- reject: "reject"
4582
- };
4583
- function getActionCode(operation) {
4584
- return CRUD_ACTIONS[operation];
4585
- }
4586
- function getAllCrudActionCodes() {
4587
- return Object.values(CRUD_ACTIONS);
4588
- }
4589
- function isCrudAction(actionCode) {
4590
- return Object.values(CRUD_ACTIONS).includes(actionCode);
4591
- }
4592
- var DEFAULT_PERMISSIONS_CACHE_TTL_SECONDS = 5 * 60;
4593
- var PERMISSIONS_TTL_SECONDS = (() => {
4594
- const ttlEnv = process.env.PERMISSIONS_CACHE_TTL_MS;
4595
- if (!ttlEnv) {
4596
- return DEFAULT_PERMISSIONS_CACHE_TTL_SECONDS;
4597
- }
4598
- const parsedTtlMs = Number.parseInt(ttlEnv, 10);
4599
- if (Number.isNaN(parsedTtlMs) || parsedTtlMs <= 0) {
4600
- logger.warn(
4601
- `Invalid PERMISSIONS_CACHE_TTL_MS="${ttlEnv}". Falling back to default ${DEFAULT_PERMISSIONS_CACHE_TTL_SECONDS}s`
4602
- );
4603
- return DEFAULT_PERMISSIONS_CACHE_TTL_SECONDS;
4604
- }
4605
- return Math.floor(parsedTtlMs / 1e3);
4606
- })();
4607
- var permissionCache = cacheManager.create({
4608
- name: "rbac-permissions",
4609
- ttl: PERMISSIONS_TTL_SECONDS,
4610
- max: 1e4
4611
- });
4612
- async function getFromCache(userId) {
4613
- return permissionCache.get(userId);
4614
- }
4615
- async function setToCache(userId, data) {
4616
- await permissionCache.set(userId, data);
4617
- }
4618
- var pendingQueries = /* @__PURE__ */ new Map();
4619
- async function clearAllPermissionsCache() {
4620
- await permissionCache.reset();
4621
- pendingQueries.clear();
4622
- }
4623
- async function clearUserPermissionsCache(userId) {
4624
- await permissionCache.del(userId);
4625
- pendingQueries.delete(userId);
4626
- }
4627
- async function invalidateUserPermissions(userId) {
4628
- await permissionCache.del(userId);
4629
- pendingQueries.delete(userId);
4630
- }
4631
- function getUserPermissions(session) {
4632
- if (!session?.user) return [];
4633
- const user = session.user;
4634
- if (!user.permissions) {
4635
- return [];
4636
- }
4637
- return user.permissions;
4638
- }
4639
- var BYPASS_AUTH = process.env.BYPASS_AUTH === "true" || process.env.BYPASS_AUTH === "1";
4640
- var ADMIN_ROLE_CODES = ["admin", "SUPER_ADMIN"];
4641
- function getCrudPermissionsFromSession(session, entity) {
4642
- if (BYPASS_AUTH) {
4643
- return {
4644
- create: true,
4645
- view: true,
4646
- update: true,
4647
- delete: true,
4648
- export: true,
4649
- import: true,
4650
- approve: true,
4651
- reject: true
4652
- };
4653
- }
4654
- if (!session?.user) {
4655
- return {
4656
- create: false,
4657
- view: false,
4658
- update: false,
4659
- delete: false,
4660
- export: false,
4661
- import: false,
4662
- approve: false,
4663
- reject: false
4664
- };
4665
- }
4666
- const user = session.user;
4667
- if (!user.id) {
4668
- return {
4669
- create: false,
4670
- view: false,
4671
- update: false,
4672
- delete: false,
4673
- export: false,
4674
- import: false,
4675
- approve: false,
4676
- reject: false
4677
- };
4678
- }
4679
- const isAdmin = user.roles?.some((role) => ADMIN_ROLE_CODES.includes(role));
4680
- if (isAdmin) {
4681
- return {
4682
- create: true,
4683
- view: true,
4684
- update: true,
4685
- delete: true,
4686
- export: true,
4687
- import: true,
4688
- approve: true,
4689
- reject: true
4690
- };
4691
- }
4692
- const permissions = user.permissions || [];
4693
- const permissionKeys = new Set(
4694
- permissions.map((p) => `${p.resourceCode}:${p.actionCode}`)
4695
- );
4696
- const hasPermission2 = (action) => {
4697
- const key = `${entity}:${action}`;
4698
- return permissionKeys.has(key);
4699
- };
4700
- return {
4701
- create: hasPermission2(getActionCode("create")),
4702
- view: hasPermission2(getActionCode("view")),
4703
- update: hasPermission2(getActionCode("update")),
4704
- delete: hasPermission2(getActionCode("delete")),
4705
- export: hasPermission2(getActionCode("export")),
4706
- import: hasPermission2(getActionCode("import")),
4707
- approve: hasPermission2(getActionCode("approve")),
4708
- reject: hasPermission2(getActionCode("reject"))
4709
- };
4710
- }
4711
- function checkPermission(session, resourceCode, actionCode) {
4712
- if (BYPASS_AUTH) {
4713
- return true;
4714
- }
4715
- if (!session?.user) return false;
4716
- const user = session.user;
4717
- if (!user.permissions || user.permissions.length === 0) {
4718
- return false;
4719
- }
4720
- if (user.roles?.some((role) => ADMIN_ROLE_CODES.includes(role))) {
4721
- return true;
4722
- }
4723
- return user.permissions.some(
4724
- (p) => p.resourceCode === resourceCode && p.actionCode === actionCode
4725
- );
4726
- }
4727
- function hasPermission(session, resourceCode, actionCode) {
4728
- return checkPermission(session, resourceCode, actionCode);
4729
- }
4730
- function requirePermission(session, resourceCode, actionCode) {
4731
- if (!checkPermission(session, resourceCode, actionCode)) {
4732
- throw new Error(
4733
- `Unauthorized: User does not have permission ${actionCode} on ${resourceCode}`
4734
- );
4735
- }
4736
- }
4737
- function hasRole(session, roleCode) {
4738
- if (!session?.user) return false;
4739
- const user = session.user;
4740
- if (!user.roles) {
4741
- return false;
4742
- }
4743
- return user.roles.includes(roleCode);
4744
- }
4745
- function hasAnyRole(session, roleCodes) {
4746
- if (!session?.user) return false;
4747
- const user = session.user;
4748
- if (!user.roles) {
4749
- return false;
4750
- }
4751
- return roleCodes.some((role) => user.roles.includes(role));
4752
- }
4753
-
4754
- exports.CRUD_ACTIONS = CRUD_ACTIONS;
4755
- exports.RoleListPage = RoleListPage;
4756
- exports.checkPermission = checkPermission;
4757
- exports.clearAllPermissionsCache = clearAllPermissionsCache;
4758
- exports.clearResourceCache = clearResourceCache;
4759
- exports.clearUserPermissionsCache = clearUserPermissionsCache;
4760
- exports.getActionCode = getActionCode;
4761
- exports.getActionsForPermissionMatrix = getActionsForPermissionMatrix;
4762
- exports.getAllCrudActionCodes = getAllCrudActionCodes;
4763
- exports.getCachedUserPermissions = getCachedUserPermissions;
4764
- exports.getCrudPermissionsFromSession = getCrudPermissionsFromSession;
4765
- exports.getFromCache = getFromCache;
4766
- exports.getPermissionResourceCode = getPermissionResourceCode;
4767
- exports.getResourcesData = getResourcesData;
4768
- exports.getResourcesForPermissionMatrix = getResourcesForPermissionMatrix;
4769
- exports.getRolesData = getRolesData;
4770
- exports.getUserPermissions = getUserPermissions;
4771
- exports.getUserPermissionsFromDB = getUserPermissionsFromDB;
4772
- exports.hasAnyRole = hasAnyRole;
4773
- exports.hasPermission = hasPermission;
4774
- exports.hasRole = hasRole;
4775
- exports.invalidateUserPermissions = invalidateUserPermissions;
4776
- exports.isCrudAction = isCrudAction;
4777
- exports.isValidResourceCode = isValidResourceCode;
4778
- exports.pendingQueries = pendingQueries;
4779
- exports.preloadResourceCodes = preloadResourceCodes;
4780
- exports.requirePermission = requirePermission;
4781
- exports.setToCache = setToCache;
4782
- exports.validatePermissionResource = validatePermissionResource;
4783
- //# sourceMappingURL=index.js.map
4784
- //# sourceMappingURL=index.js.map