@xk2800/nextjs-template 0.7.1-beta.11 → 0.7.1-beta.13

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.
@@ -0,0 +1,164 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { Check, ChevronDown, Plus } from "lucide-react"
5
+ import { cn } from "../../lib/utils"
6
+ import { Button } from "./button"
7
+ import { Input } from "./input"
8
+ import {
9
+ Command,
10
+ CommandEmpty,
11
+ CommandGroup,
12
+ CommandInput,
13
+ CommandItem,
14
+ CommandList,
15
+ CommandSeparator,
16
+ } from "./command"
17
+ import { Popover, PopoverContent, PopoverTrigger } from "./popover"
18
+ import { Disclaimer } from "./disclaimer"
19
+ import type { SuggestionGroup } from "./category-selector"
20
+
21
+ interface SourceSelectorProps {
22
+ /** The user's existing sources. The value is the source name. */
23
+ sources: { id: string | number; name: string }[]
24
+ isLoading?: boolean
25
+ value?: string
26
+ onSourceChange?: (sourceName: string) => void
27
+ onNewSourceChange?: (newSourceName: string) => void
28
+ newSourceValue?: string
29
+ className?: string
30
+ placeholder?: string
31
+ disabled?: boolean
32
+ /** Extra names offered below the user's own sources; picking one selects that name. */
33
+ suggestionGroups?: SuggestionGroup[]
34
+ /** Small print under the new-source input. */
35
+ newSourceNote?: string
36
+ }
37
+
38
+ /** Combobox over named sources (selected by name), with optional suggestion groups and "Add new source". */
39
+ export function SourceSelector({
40
+ sources,
41
+ isLoading = false,
42
+ value,
43
+ onSourceChange,
44
+ onNewSourceChange,
45
+ newSourceValue = "",
46
+ className,
47
+ placeholder = "Select a source...",
48
+ disabled = false,
49
+ suggestionGroups,
50
+ newSourceNote,
51
+ }: SourceSelectorProps) {
52
+ const [open, setOpen] = React.useState(false)
53
+ const [showNewInput, setShowNewInput] = React.useState(false)
54
+ const groups = suggestionGroups?.filter((g) => g.items.length > 0) ?? []
55
+
56
+ const handleSourceSelect = (name: string) => {
57
+ onSourceChange?.(name)
58
+ onNewSourceChange?.("")
59
+ setShowNewInput(false)
60
+ setOpen(false)
61
+ }
62
+
63
+ const handleAddNew = () => {
64
+ onSourceChange?.("")
65
+ setShowNewInput(true)
66
+ setOpen(false)
67
+ }
68
+
69
+ const triggerLabel = isLoading
70
+ ? "Loading..."
71
+ : value
72
+ ? value
73
+ : showNewInput
74
+ ? "Add new source"
75
+ : placeholder
76
+
77
+ return (
78
+ <div className={cn("space-y-2", className)}>
79
+ <Popover open={open} onOpenChange={setOpen}>
80
+ <PopoverTrigger asChild>
81
+ <Button
82
+ variant="outline"
83
+ role="combobox"
84
+ aria-expanded={open}
85
+ className="w-full justify-between"
86
+ disabled={disabled || isLoading}
87
+ >
88
+ {triggerLabel}
89
+ <ChevronDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
90
+ </Button>
91
+ </PopoverTrigger>
92
+ <PopoverContent className="w-full p-0">
93
+ <Command>
94
+ <CommandInput placeholder="Search sources..." />
95
+ <CommandList>
96
+ <CommandEmpty>No sources found.</CommandEmpty>
97
+
98
+ <CommandGroup heading={groups.length ? "My Sources" : undefined}>
99
+ {sources.map((source) => (
100
+ <CommandItem
101
+ key={source.id}
102
+ value={source.name}
103
+ onSelect={() => handleSourceSelect(source.name)}
104
+ >
105
+ {source.name}
106
+ <Check
107
+ className={cn(
108
+ "ml-auto h-4 w-4",
109
+ value === source.name ? "opacity-100" : "opacity-0"
110
+ )}
111
+ />
112
+ </CommandItem>
113
+ ))}
114
+ <CommandItem onSelect={handleAddNew}>
115
+ <Plus className="mr-2 h-4 w-4" />
116
+ Add new source
117
+ </CommandItem>
118
+ </CommandGroup>
119
+
120
+ {groups.map((group) => (
121
+ <React.Fragment key={group.heading}>
122
+ <CommandSeparator />
123
+ <CommandGroup heading={group.heading}>
124
+ {group.items.map((s) => (
125
+ <CommandItem
126
+ key={s.name}
127
+ value={s.name}
128
+ onSelect={() => handleSourceSelect(s.name)}
129
+ >
130
+ <div className="flex flex-col">
131
+ <span>{s.name}</span>
132
+ {s.note && <span className="text-xs text-muted-foreground">{s.note}</span>}
133
+ </div>
134
+ <Check
135
+ className={cn(
136
+ "ml-auto h-4 w-4 shrink-0",
137
+ value === s.name ? "opacity-100" : "opacity-0"
138
+ )}
139
+ />
140
+ </CommandItem>
141
+ ))}
142
+ </CommandGroup>
143
+ </React.Fragment>
144
+ ))}
145
+ </CommandList>
146
+ </Command>
147
+ </PopoverContent>
148
+ </Popover>
149
+
150
+ {showNewInput && (
151
+ <>
152
+ <Input
153
+ placeholder="Enter new source name..."
154
+ value={newSourceValue}
155
+ onChange={(e) => onNewSourceChange?.(e.target.value)}
156
+ disabled={disabled}
157
+ autoFocus
158
+ />
159
+ {newSourceNote && <Disclaimer disclaimerText={newSourceNote} />}
160
+ </>
161
+ )}
162
+ </div>
163
+ )
164
+ }
@@ -1,4 +1,4 @@
1
- import { A as ActivityActionEnum } from '../schema-CN_Y6EXv.mjs';
1
+ import { A as ActivityActionEnum } from '../schema-lgO4CzE4.mjs';
2
2
  import 'drizzle-orm';
3
3
  import 'drizzle-orm/pg-core';
4
4
 
@@ -1,4 +1,4 @@
1
- import { A as ActivityActionEnum } from '../schema-CN_Y6EXv.js';
1
+ import { A as ActivityActionEnum } from '../schema-lgO4CzE4.js';
2
2
  import 'drizzle-orm';
3
3
  import 'drizzle-orm/pg-core';
4
4
 
@@ -891,7 +891,7 @@ declare function createAuth(overrides?: AuthOverrides): better_auth.Auth<{
891
891
  $Infer: {
892
892
  body: {
893
893
  permissions: {
894
- readonly user?: ("delete" | "update" | "list" | "set-role" | "create" | "ban" | "impersonate" | "impersonate-admins" | "set-password" | "set-email" | "get")[] | undefined;
894
+ readonly user?: ("set-role" | "delete" | "update" | "list" | "create" | "ban" | "impersonate" | "impersonate-admins" | "set-password" | "set-email" | "get")[] | undefined;
895
895
  readonly session?: ("delete" | "list" | "revoke")[] | undefined;
896
896
  };
897
897
  } & {
@@ -3175,7 +3175,7 @@ declare const auth: better_auth.Auth<{
3175
3175
  $Infer: {
3176
3176
  body: {
3177
3177
  permissions: {
3178
- readonly user?: ("delete" | "update" | "list" | "set-role" | "create" | "ban" | "impersonate" | "impersonate-admins" | "set-password" | "set-email" | "get")[] | undefined;
3178
+ readonly user?: ("set-role" | "delete" | "update" | "list" | "create" | "ban" | "impersonate" | "impersonate-admins" | "set-password" | "set-email" | "get")[] | undefined;
3179
3179
  readonly session?: ("delete" | "list" | "revoke")[] | undefined;
3180
3180
  };
3181
3181
  } & {
@@ -891,7 +891,7 @@ declare function createAuth(overrides?: AuthOverrides): better_auth.Auth<{
891
891
  $Infer: {
892
892
  body: {
893
893
  permissions: {
894
- readonly user?: ("delete" | "update" | "list" | "set-role" | "create" | "ban" | "impersonate" | "impersonate-admins" | "set-password" | "set-email" | "get")[] | undefined;
894
+ readonly user?: ("set-role" | "delete" | "update" | "list" | "create" | "ban" | "impersonate" | "impersonate-admins" | "set-password" | "set-email" | "get")[] | undefined;
895
895
  readonly session?: ("delete" | "list" | "revoke")[] | undefined;
896
896
  };
897
897
  } & {
@@ -3175,7 +3175,7 @@ declare const auth: better_auth.Auth<{
3175
3175
  $Infer: {
3176
3176
  body: {
3177
3177
  permissions: {
3178
- readonly user?: ("delete" | "update" | "list" | "set-role" | "create" | "ban" | "impersonate" | "impersonate-admins" | "set-password" | "set-email" | "get")[] | undefined;
3178
+ readonly user?: ("set-role" | "delete" | "update" | "list" | "create" | "ban" | "impersonate" | "impersonate-admins" | "set-password" | "set-email" | "get")[] | undefined;
3179
3179
  readonly session?: ("delete" | "list" | "revoke")[] | undefined;
3180
3180
  };
3181
3181
  } & {
@@ -1,4 +1,4 @@
1
- import { a as schema } from '../schema-CN_Y6EXv.mjs';
1
+ import { a as schema } from '../schema-lgO4CzE4.mjs';
2
2
  import { PostgresJsDatabase } from 'drizzle-orm/postgres-js';
3
3
  import { NeonHttpDatabase } from 'drizzle-orm/neon-http';
4
4
  import 'drizzle-orm';
@@ -1,4 +1,4 @@
1
- import { a as schema } from '../schema-CN_Y6EXv.js';
1
+ import { a as schema } from '../schema-lgO4CzE4.js';
2
2
  import { PostgresJsDatabase } from 'drizzle-orm/postgres-js';
3
3
  import { NeonHttpDatabase } from 'drizzle-orm/neon-http';
4
4
  import 'drizzle-orm';
@@ -1,3 +1,3 @@
1
1
  import 'drizzle-orm';
2
2
  import 'drizzle-orm/pg-core';
3
- export { A as ActivityActionEnum, R as RoleEnum, b as accounts, c as activityLogs, d as authThrottle, e as consentLog, f as deviceFingerprints, g as errorRefs, p as passkeys, h as sessions, s as systemSettings, t as twoFactors, u as users, v as verifications } from '../schema-CN_Y6EXv.mjs';
3
+ export { A as ActivityActionEnum, R as RoleEnum, b as accounts, c as activityLogs, d as authThrottle, e as consentLog, f as deviceFingerprints, g as errorRefs, p as passkeys, h as sessions, s as systemSettings, t as twoFactors, u as users, v as verifications } from '../schema-lgO4CzE4.mjs';
@@ -1,3 +1,3 @@
1
1
  import 'drizzle-orm';
2
2
  import 'drizzle-orm/pg-core';
3
- export { A as ActivityActionEnum, R as RoleEnum, b as accounts, c as activityLogs, d as authThrottle, e as consentLog, f as deviceFingerprints, g as errorRefs, p as passkeys, h as sessions, s as systemSettings, t as twoFactors, u as users, v as verifications } from '../schema-CN_Y6EXv.js';
3
+ export { A as ActivityActionEnum, R as RoleEnum, b as accounts, c as activityLogs, d as authThrottle, e as consentLog, f as deviceFingerprints, g as errorRefs, p as passkeys, h as sessions, s as systemSettings, t as twoFactors, u as users, v as verifications } from '../schema-lgO4CzE4.js';
@@ -1142,7 +1142,7 @@ declare const activityLogs: drizzle_orm_pg_core.PgTableWithColumns<{
1142
1142
  tableName: "activity_log";
1143
1143
  dataType: "string";
1144
1144
  columnType: "PgEnumColumn";
1145
- data: "login" | "logout" | "login_failed" | "password_changed" | "email_changed" | "profile_updated" | "session_revoked" | "user_deleted" | "user_banned" | "user_unbanned" | "role_changed" | "impersonation_started" | "impersonation_stopped" | "settings_changed" | "passkey_added" | "passkey_removed";
1145
+ data: "login_failed" | "login" | "logout" | "password_changed" | "email_changed" | "profile_updated" | "session_revoked" | "user_deleted" | "user_banned" | "user_unbanned" | "role_changed" | "impersonation_started" | "impersonation_stopped" | "settings_changed" | "passkey_added" | "passkey_removed";
1146
1146
  driverParam: string;
1147
1147
  notNull: true;
1148
1148
  hasDefault: false;
@@ -1142,7 +1142,7 @@ declare const activityLogs: drizzle_orm_pg_core.PgTableWithColumns<{
1142
1142
  tableName: "activity_log";
1143
1143
  dataType: "string";
1144
1144
  columnType: "PgEnumColumn";
1145
- data: "login" | "logout" | "login_failed" | "password_changed" | "email_changed" | "profile_updated" | "session_revoked" | "user_deleted" | "user_banned" | "user_unbanned" | "role_changed" | "impersonation_started" | "impersonation_stopped" | "settings_changed" | "passkey_added" | "passkey_removed";
1145
+ data: "login_failed" | "login" | "logout" | "password_changed" | "email_changed" | "profile_updated" | "session_revoked" | "user_deleted" | "user_banned" | "user_unbanned" | "role_changed" | "impersonation_started" | "impersonation_stopped" | "settings_changed" | "passkey_added" | "passkey_removed";
1146
1146
  driverParam: string;
1147
1147
  notNull: true;
1148
1148
  hasDefault: false;
@@ -1,4 +1,4 @@
1
- import { s as systemSettings } from '../schema-CN_Y6EXv.mjs';
1
+ import { s as systemSettings } from '../schema-lgO4CzE4.mjs';
2
2
  import 'drizzle-orm';
3
3
  import 'drizzle-orm/pg-core';
4
4
 
@@ -1,4 +1,4 @@
1
- import { s as systemSettings } from '../schema-CN_Y6EXv.js';
1
+ import { s as systemSettings } from '../schema-lgO4CzE4.js';
2
2
  import 'drizzle-orm';
3
3
  import 'drizzle-orm/pg-core';
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xk2800/nextjs-template",
3
- "version": "0.7.1-beta.11",
3
+ "version": "0.7.1-beta.13",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -285,7 +285,11 @@
285
285
  "lucide-react": "^1.16.0",
286
286
  "react-icons": "^5.5.0",
287
287
  "next-themes": "^0.4.0",
288
- "sonner": "^2.0.0"
288
+ "sonner": "^2.0.0",
289
+ "cmdk": "^1.1.1",
290
+ "date-fns": "^4.1.0",
291
+ "react-day-picker": "^10.0.0",
292
+ "recharts": "^3.8.1"
289
293
  },
290
294
  "devDependencies": {
291
295
  "@eslint/eslintrc": "^3",
@@ -310,6 +314,8 @@
310
314
  "bun-types": "^1.4.2",
311
315
  "class-variance-authority": "^0.7.1",
312
316
  "clsx": "^2.1.1",
317
+ "cmdk": "^1.1.1",
318
+ "date-fns": "^4.1.0",
313
319
  "dotenv": "^17.2.3",
314
320
  "drizzle-kit": "^0.31.1",
315
321
  "eslint": "^10",
@@ -319,8 +325,10 @@
319
325
  "next-themes": "^0.4.6",
320
326
  "playwright": "^1.62.0",
321
327
  "react": "^19.0.0",
328
+ "react-day-picker": "^10.0.0",
322
329
  "react-dom": "^19.0.0",
323
330
  "react-icons": "^5.5.0",
331
+ "recharts": "^3.8.1",
324
332
  "sonner": "^2.0.7",
325
333
  "storybook": "10.6.2",
326
334
  "tailwind-merge": "^3.3.1",
@@ -330,5 +338,19 @@
330
338
  "tw-animate-css": "^1.3.6",
331
339
  "typescript": "^6.0.3",
332
340
  "vite": "^8.3.4"
341
+ },
342
+ "peerDependenciesMeta": {
343
+ "cmdk": {
344
+ "optional": true
345
+ },
346
+ "date-fns": {
347
+ "optional": true
348
+ },
349
+ "react-day-picker": {
350
+ "optional": true
351
+ },
352
+ "recharts": {
353
+ "optional": true
354
+ }
333
355
  }
334
356
  }