@vitnode/core 1.2.0-canary.22 → 1.2.0-canary.23

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 (42) hide show
  1. package/dist/src/app_admin/core/users/page.js +1 -1
  2. package/dist/src/components/form/auto-form.js +1 -1
  3. package/dist/src/components/form/fields/combobox-async.d.ts +21 -0
  4. package/dist/src/components/form/fields/combobox-async.d.ts.map +1 -0
  5. package/dist/src/components/form/fields/combobox-async.js +115 -0
  6. package/dist/src/components/form/fields/combobox.d.ts +2 -1
  7. package/dist/src/components/form/fields/combobox.d.ts.map +1 -1
  8. package/dist/src/components/form/fields/combobox.js +4 -5
  9. package/dist/src/components/table/content.js +1 -1
  10. package/dist/src/components/table/pagination.js +3 -3
  11. package/dist/src/components/ui/alert-dialog.js +2 -2
  12. package/dist/src/components/ui/dialog.d.ts.map +1 -1
  13. package/dist/src/components/ui/dialog.js +1 -1
  14. package/dist/src/lib/fetcher/core.d.ts +15 -0
  15. package/dist/src/lib/fetcher/core.d.ts.map +1 -0
  16. package/dist/src/lib/fetcher/core.js +39 -0
  17. package/dist/src/lib/fetcher/helpers-server.d.ts +3 -0
  18. package/dist/src/lib/fetcher/helpers-server.d.ts.map +1 -0
  19. package/dist/src/lib/fetcher/helpers-server.js +18 -0
  20. package/dist/src/lib/fetcher/helpers.d.ts +0 -1
  21. package/dist/src/lib/fetcher/helpers.d.ts.map +1 -1
  22. package/dist/src/lib/fetcher/helpers.js +0 -17
  23. package/dist/src/lib/fetcher-client.d.ts +8 -0
  24. package/dist/src/lib/fetcher-client.d.ts.map +1 -0
  25. package/dist/src/lib/fetcher-client.js +11 -0
  26. package/dist/src/lib/fetcher.d.ts +2 -1
  27. package/dist/src/lib/fetcher.d.ts.map +1 -1
  28. package/dist/src/lib/fetcher.js +14 -33
  29. package/dist/src/lib/helpers/auto-form.d.ts.map +1 -1
  30. package/dist/src/lib/helpers/auto-form.js +28 -16
  31. package/dist/src/lib/helpers/auto-form.test.js +49 -0
  32. package/dist/src/views/admin/layouts/sidebar/nav/item.d.ts.map +1 -1
  33. package/dist/src/views/admin/layouts/sidebar/nav/item.js +24 -3
  34. package/dist/src/views/admin/views/core/dashboard/dashboard-admin-view.js +1 -1
  35. package/dist/src/views/admin/views/core/test.d.ts.map +1 -1
  36. package/dist/src/views/admin/views/core/test.js +108 -103
  37. package/dist/src/views/layouts/theme/header/header.d.ts.map +1 -1
  38. package/dist/src/views/layouts/theme/header/header.js +24 -21
  39. package/dist/tsconfig.tsbuildinfo +1 -1
  40. package/package.json +3 -2
  41. package/src/app_admin/core/users/page.tsx +1 -1
  42. package/src/locales/en.json +2 -0
@@ -117,6 +117,55 @@ describe('auto-form helpers', ()=>{
117
117
  const defaults = getDefaultValues(schema);
118
118
  expect(defaults).toEqual({});
119
119
  });
120
+ it('should handle complex default values with conditional logic', ()=>{
121
+ const data = {
122
+ category: {
123
+ id: 123,
124
+ title: 'Technology'
125
+ }
126
+ };
127
+ const schema = z.object({
128
+ title: z.string().default('Default Title'),
129
+ categoryId: z.object({
130
+ value: z.string(),
131
+ label: z.string()
132
+ }).default(data?.category ? {
133
+ value: data.category.id.toString(),
134
+ label: data.category.title
135
+ } : {
136
+ value: '',
137
+ label: ''
138
+ })
139
+ });
140
+ const defaults = getDefaultValues(schema);
141
+ expect(defaults).toEqual({
142
+ title: 'Default Title',
143
+ categoryId: {
144
+ value: '123',
145
+ label: 'Technology'
146
+ }
147
+ });
148
+ });
149
+ it('should handle complex default values with falsy data', ()=>{
150
+ // Test with a simpler approach - using a function that returns the default value
151
+ const getDefaultCategoryId = ()=>({
152
+ value: '',
153
+ label: ''
154
+ });
155
+ const schema = z.object({
156
+ categoryId: z.object({
157
+ value: z.string(),
158
+ label: z.string()
159
+ }).default(getDefaultCategoryId())
160
+ });
161
+ const defaults = getDefaultValues(schema);
162
+ expect(defaults).toEqual({
163
+ categoryId: {
164
+ value: '',
165
+ label: ''
166
+ }
167
+ });
168
+ });
120
169
  it('should return empty object for schema without shape', ()=>{
121
170
  const schema = z.string();
122
171
  const defaults = getDefaultValues(schema);
@@ -1 +1 @@
1
- {"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../../../../../../src/views/admin/layouts/sidebar/nav/item.tsx"],"names":[],"mappings":"AAoBA,UAAU,iBAAiB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,YAAY,GAAI,+CAM1B,iBAAiB,GAAG;IACrB,KAAK,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,EAAE,CAAC;CAC3C,4CA2EA,CAAC"}
1
+ {"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../../../../../../src/views/admin/layouts/sidebar/nav/item.tsx"],"names":[],"mappings":"AAoBA,UAAU,iBAAiB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,YAAY,GAAI,+CAM1B,iBAAiB,GAAG;IACrB,KAAK,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,EAAE,CAAC;CAC3C,4CAuHA,CAAC"}
@@ -5,11 +5,22 @@ import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "../../../..
5
5
  import { SidebarMenuButton, useSidebar } from "../../../../../components/ui/sidebar.js";
6
6
  import { SidebarMenuItem, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem } from "../../../../../components/ui/sidebar.js";
7
7
  import { useIsMobile } from "../../../../../hooks/use-mobile.js";
8
- import { Link } from "../../../../../lib/navigation.js";
8
+ import { Link, usePathname } from "../../../../../lib/navigation.js";
9
9
  import { cn } from "../../../../../lib/utils.js";
10
10
  export const ItemNavAdmin = ({ href, title, icon, items = [], isOpenInNewTab })=>{
11
11
  const { toggleSidebar } = useSidebar();
12
12
  const isMobile = useIsMobile();
13
+ const pathname = usePathname();
14
+ // Helper function to normalize URLs for comparison
15
+ const normalizeUrl = (url)=>{
16
+ return url.endsWith('/') && url.length > 1 ? url.slice(0, -1) : url;
17
+ };
18
+ // Check if current path matches href (with normalization)
19
+ const isActive = normalizeUrl(pathname) === normalizeUrl(href);
20
+ // Check if any child item is active
21
+ const hasActiveChild = items.some((item)=>normalizeUrl(pathname) === normalizeUrl(item.href));
22
+ // Open collapsible by default if has active child
23
+ const defaultOpen = hasActiveChild;
13
24
  const content = /*#__PURE__*/ _jsxs(_Fragment, {
14
25
  children: [
15
26
  icon ?? /*#__PURE__*/ _jsx(MenuIcon, {}),
@@ -22,8 +33,10 @@ export const ItemNavAdmin = ({ href, title, icon, items = [], isOpenInNewTab })=
22
33
  return /*#__PURE__*/ _jsx(SidebarMenuItem, {
23
34
  children: /*#__PURE__*/ _jsx(SidebarMenuButton, {
24
35
  asChild: true,
36
+ isActive: isActive,
25
37
  tooltip: title,
26
38
  children: /*#__PURE__*/ _jsx(Link, {
39
+ className: cn('relative', isActive && 'before:bg-primary before:absolute before:bottom-1 before:left-0 before:top-1 before:h-auto before:w-1 before:rounded-r-sm'),
27
40
  href: href,
28
41
  onClick: ()=>{
29
42
  if (isMobile) {
@@ -41,11 +54,14 @@ export const ItemNavAdmin = ({ href, title, icon, items = [], isOpenInNewTab })=
41
54
  return /*#__PURE__*/ _jsx(Collapsible, {
42
55
  asChild: true,
43
56
  className: "group/collapsible",
57
+ defaultOpen: defaultOpen,
44
58
  children: /*#__PURE__*/ _jsxs(SidebarMenuItem, {
45
59
  children: [
46
60
  /*#__PURE__*/ _jsx(CollapsibleTrigger, {
47
61
  asChild: true,
48
62
  children: /*#__PURE__*/ _jsxs(SidebarMenuButton, {
63
+ className: cn('relative', (isActive || hasActiveChild) && 'before:bg-primary before:absolute before:bottom-1 before:left-0 before:top-1 before:h-auto before:w-1 before:rounded-r-sm'),
64
+ isActive: isActive || hasActiveChild,
49
65
  tooltip: title,
50
66
  children: [
51
67
  content,
@@ -58,10 +74,14 @@ export const ItemNavAdmin = ({ href, title, icon, items = [], isOpenInNewTab })=
58
74
  /*#__PURE__*/ _jsx(CollapsibleContent, {
59
75
  className: cn('text-popover-foreground 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 outline-none'),
60
76
  children: /*#__PURE__*/ _jsx(SidebarMenuSub, {
61
- children: items.map((item)=>/*#__PURE__*/ _jsx(SidebarMenuSubItem, {
77
+ children: items.map((item)=>{
78
+ const isChildActive = normalizeUrl(pathname) === normalizeUrl(item.href);
79
+ return /*#__PURE__*/ _jsx(SidebarMenuSubItem, {
62
80
  children: /*#__PURE__*/ _jsx(SidebarMenuSubButton, {
63
81
  asChild: true,
82
+ isActive: isChildActive,
64
83
  children: /*#__PURE__*/ _jsx(Link, {
84
+ className: cn('relative', isChildActive && 'before:bg-primary before:absolute before:bottom-1 before:left-0 before:top-1 before:h-auto before:w-1 before:rounded-r-sm'),
65
85
  href: item.href,
66
86
  onClick: ()=>{
67
87
  if (isMobile) {
@@ -74,7 +94,8 @@ export const ItemNavAdmin = ({ href, title, icon, items = [], isOpenInNewTab })=
74
94
  children: item.title
75
95
  })
76
96
  })
77
- }, item.href))
97
+ }, item.href);
98
+ })
78
99
  })
79
100
  })
80
101
  ]
@@ -11,7 +11,7 @@ export const DashboardAdminView = async ()=>{
11
11
  if (!session) return null;
12
12
  const { vitnode_version } = session;
13
13
  return /*#__PURE__*/ _jsxs("div", {
14
- className: "container mx-auto p-4",
14
+ className: "p-4",
15
15
  children: [
16
16
  /*#__PURE__*/ _jsx(HeaderContent, {
17
17
  desc: t('version', {
@@ -1 +1 @@
1
- {"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../../../../../src/views/admin/views/core/test.tsx"],"names":[],"mappings":"AAaA,eAAO,MAAM,QAAQ,+CA0IpB,CAAC"}
1
+ {"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../../../../../src/views/admin/views/core/test.tsx"],"names":[],"mappings":"AAcA,eAAO,MAAM,QAAQ,+CA6IpB,CAAC"}
@@ -9,6 +9,7 @@ import { AutoFormRadioGroup } from "../../../../components/form/fields/radio-gro
9
9
  import { AutoFormSelect } from "../../../../components/form/fields/select.js";
10
10
  import { AutoFormSwitch } from "../../../../components/form/fields/switch.js";
11
11
  import { AutoFormTextarea } from "../../../../components/form/fields/textarea.js";
12
+ import { Card } from "../../../../components/ui/card.js";
12
13
  export const TestView = ()=>{
13
14
  const formSchema = z.object({
14
15
  provider: z.string().min(1, {
@@ -37,110 +38,114 @@ export const TestView = ()=>{
37
38
  ])
38
39
  });
39
40
  return /*#__PURE__*/ _jsx("div", {
40
- className: "container mx-auto p-4",
41
- children: /*#__PURE__*/ _jsx(AutoForm, {
42
- fields: [
43
- {
44
- id: 'provider',
45
- component: (props)=>/*#__PURE__*/ _jsx(AutoFormInput, {
46
- description: "This is the provider for your application. It should be a valid provider name.",
47
- label: "Provider",
48
- ...props
49
- })
50
- },
51
- {
52
- id: 'client_secret',
53
- component: (props)=>/*#__PURE__*/ _jsx(AutoFormTextarea, {
54
- description: "This is the client secret for your application. It should be kept secret and not shared with anyone.",
55
- label: "Client Secret",
56
- ...props
57
- })
58
- },
59
- {
60
- id: 'terms',
61
- component: (props)=>/*#__PURE__*/ _jsx(AutoFormCheckbox, {
62
- description: "By checking this box, you agree to the terms and conditions.",
63
- label: "I agree to the terms and conditions",
64
- ...props
65
- })
66
- },
67
- {
68
- id: 'options',
69
- component: (props)=>/*#__PURE__*/ _jsx(AutoFormRadioGroup, {
70
- description: "By checking this box, you agree to the terms and conditions.",
71
- label: "I agree to the terms and conditions",
72
- labels: [
73
- {
74
- value: 'option1',
75
- label: 'Option 1 with a very long label that should be truncated'
76
- },
77
- {
78
- value: 'option2',
79
- label: 'Option 2'
80
- },
81
- {
82
- value: 'option3',
83
- label: 'Option 3'
84
- }
85
- ],
86
- ...props
87
- })
88
- },
89
- {
90
- id: 'options_long',
91
- component: (props)=>/*#__PURE__*/ _jsx(AutoFormSelect, {
92
- description: "By checking this box, you agree to the terms and conditions.",
93
- label: "I agree to the terms and conditions",
94
- labels: [
95
- {
96
- value: 'option1',
97
- label: 'Option 1 with a very long label that should be truncated'
98
- },
99
- {
100
- value: 'option2',
101
- label: 'Option 2'
102
- },
103
- {
104
- value: 'option3',
105
- label: 'Option 3'
106
- }
107
- ],
108
- placeholder: "Select an option from the list",
109
- ...props
110
- })
111
- },
112
- {
113
- id: 'switch',
114
- component: (props)=>/*#__PURE__*/ _jsx(AutoFormSwitch, {
115
- description: "By checking this box, you agree to the terms and conditions.",
116
- label: "I agree to the terms and conditions",
117
- ...props
118
- })
119
- },
120
- {
121
- id: 'type',
122
- component: (props)=>/*#__PURE__*/ _jsx(AutoFormCombobox, {
123
- description: "By checking this box, you agree to the terms and conditions.",
124
- label: "Type",
125
- labels: [
126
- {
127
- value: 'option-one',
128
- label: 'Option One'
129
- },
130
- {
131
- value: 'option-two',
132
- label: 'Option Two'
133
- }
134
- ],
135
- ...props
136
- })
41
+ className: "p-4",
42
+ children: /*#__PURE__*/ _jsx(Card, {
43
+ className: "p-6",
44
+ children: /*#__PURE__*/ _jsx(AutoForm, {
45
+ fields: [
46
+ {
47
+ id: 'provider',
48
+ component: (props)=>/*#__PURE__*/ _jsx(AutoFormInput, {
49
+ description: "This is the provider for your application. It should be a valid provider name.",
50
+ label: "Provider",
51
+ ...props
52
+ })
53
+ },
54
+ {
55
+ id: 'client_secret',
56
+ component: (props)=>/*#__PURE__*/ _jsx(AutoFormTextarea, {
57
+ description: "This is the client secret for your application. It should be kept secret and not shared with anyone.",
58
+ label: "Client Secret",
59
+ ...props
60
+ })
61
+ },
62
+ {
63
+ id: 'terms',
64
+ component: (props)=>/*#__PURE__*/ _jsx(AutoFormCheckbox, {
65
+ description: "By checking this box, you agree to the terms and conditions.",
66
+ label: "I agree to the terms and conditions",
67
+ ...props
68
+ })
69
+ },
70
+ {
71
+ id: 'options',
72
+ component: (props)=>/*#__PURE__*/ _jsx(AutoFormRadioGroup, {
73
+ description: "By checking this box, you agree to the terms and conditions.",
74
+ label: "I agree to the terms and conditions",
75
+ labels: [
76
+ {
77
+ value: 'option1',
78
+ label: 'Option 1 with a very long label that should be truncated'
79
+ },
80
+ {
81
+ value: 'option2',
82
+ label: 'Option 2'
83
+ },
84
+ {
85
+ value: 'option3',
86
+ label: 'Option 3'
87
+ }
88
+ ],
89
+ ...props
90
+ })
91
+ },
92
+ {
93
+ id: 'options_long',
94
+ component: (props)=>/*#__PURE__*/ _jsx(AutoFormSelect, {
95
+ description: "By checking this box, you agree to the terms and conditions.",
96
+ label: "I agree to the terms and conditions",
97
+ labels: [
98
+ {
99
+ value: 'option1',
100
+ label: 'Option 1 with a very long label that should be truncated'
101
+ },
102
+ {
103
+ value: 'option2',
104
+ label: 'Option 2'
105
+ },
106
+ {
107
+ value: 'option3',
108
+ label: 'Option 3'
109
+ }
110
+ ],
111
+ placeholder: "Select an option from the list",
112
+ ...props
113
+ })
114
+ },
115
+ {
116
+ id: 'switch',
117
+ component: (props)=>/*#__PURE__*/ _jsx(AutoFormSwitch, {
118
+ description: "By checking this box, you agree to the terms and conditions.",
119
+ label: "I agree to the terms and conditions",
120
+ ...props
121
+ })
122
+ },
123
+ {
124
+ id: 'type',
125
+ component: (props)=>/*#__PURE__*/ _jsx(AutoFormCombobox, {
126
+ description: "By checking this box, you agree to the terms and conditions.",
127
+ label: "Type",
128
+ labels: [
129
+ {
130
+ value: 'option-one',
131
+ label: 'Option One'
132
+ },
133
+ {
134
+ value: 'option-two',
135
+ label: 'Option Two'
136
+ }
137
+ ],
138
+ ...props
139
+ })
140
+ }
141
+ ],
142
+ formSchema: formSchema,
143
+ onSubmit: async (values)=>{
144
+ // eslint-disable-next-line no-console
145
+ console.log('Form submitted', values);
146
+ await new Promise((resolve)=>setTimeout(resolve, 3000));
137
147
  }
138
- ],
139
- formSchema: formSchema,
140
- onSubmit: (values)=>{
141
- // eslint-disable-next-line no-console
142
- console.log('Form submitted', values);
143
- }
148
+ })
144
149
  })
145
150
  });
146
151
  };
@@ -1 +1 @@
1
- {"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../../../../src/views/layouts/theme/header/header.tsx"],"names":[],"mappings":"AASA,eAAO,MAAM,YAAY,GAAI,+BAI1B,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG;IAAE,IAAI,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,4CAqB5D,CAAC"}
1
+ {"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../../../../src/views/layouts/theme/header/header.tsx"],"names":[],"mappings":"AASA,eAAO,MAAM,YAAY,GAAI,+BAI1B,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG;IAAE,IAAI,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,4CAuB5D,CAAC"}
@@ -6,27 +6,30 @@ import { Link } from "../../../../lib/navigation.js";
6
6
  import { cn } from "../../../../lib/utils.js";
7
7
  import { UserHeader } from "./user/user.js";
8
8
  export const HeaderLayout = ({ logo, className, ...props })=>{
9
- return /*#__PURE__*/ _jsxs("header", {
10
- className: cn('bg-background/75 container sticky top-0 z-20 mx-auto flex w-full items-center border-b px-4 py-2 backdrop-blur sm:top-2 sm:rounded-xl sm:border', className),
9
+ return /*#__PURE__*/ _jsx("header", {
10
+ className: cn('bg-card/75 sticky top-0 z-20 w-full border-b shadow-sm backdrop-blur', className),
11
11
  ...props,
12
- children: [
13
- /*#__PURE__*/ _jsx(Link, {
14
- href: "/",
15
- prefetch: true,
16
- children: logo
17
- }),
18
- /*#__PURE__*/ _jsxs("div", {
19
- className: "ml-auto flex items-center gap-2",
20
- children: [
21
- /*#__PURE__*/ _jsx(ThemeSwitcher, {}),
22
- /*#__PURE__*/ _jsx(Suspense, {
23
- fallback: /*#__PURE__*/ _jsx(Skeleton, {
24
- className: "h-9 w-32"
25
- }),
26
- children: /*#__PURE__*/ _jsx(UserHeader, {})
27
- })
28
- ]
29
- })
30
- ]
12
+ children: /*#__PURE__*/ _jsxs("div", {
13
+ className: "container mx-auto flex h-14 items-center px-4 py-2",
14
+ children: [
15
+ /*#__PURE__*/ _jsx(Link, {
16
+ href: "/",
17
+ prefetch: true,
18
+ children: logo
19
+ }),
20
+ /*#__PURE__*/ _jsxs("div", {
21
+ className: "ml-auto flex items-center gap-2",
22
+ children: [
23
+ /*#__PURE__*/ _jsx(ThemeSwitcher, {}),
24
+ /*#__PURE__*/ _jsx(Suspense, {
25
+ fallback: /*#__PURE__*/ _jsx(Skeleton, {
26
+ className: "h-9 w-32"
27
+ }),
28
+ children: /*#__PURE__*/ _jsx(UserHeader, {})
29
+ })
30
+ ]
31
+ })
32
+ ]
33
+ })
31
34
  });
32
35
  };