@foundrykit/components 0.1.0

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,57 @@
1
+ import { ComponentConfig } from '@foundrykit/types';
2
+
3
+ export const searchBarConfig: ComponentConfig = {
4
+ name: 'Search Bar',
5
+ description: 'Search input component with search functionality',
6
+ category: 'components',
7
+ tags: ['search', 'input', 'form'],
8
+ preview: {
9
+ type: 'static',
10
+ html: '<div class="flex h-12 w-full items-center rounded-md border border-gray-300 bg-gray-100 px-3"><div class="mr-2 h-3 w-3 rounded-full border border-gray-400"></div><div class="h-2 w-12 rounded bg-gray-400"></div></div>',
11
+ },
12
+ variants: [
13
+ {
14
+ name: 'Default',
15
+ description: 'Default search bar',
16
+ code: '<SearchBar placeholder="Search..." onSearch={(query) => console.log(query)} />',
17
+ preview: {
18
+ type: 'component',
19
+ component: 'SearchBar',
20
+ props: {
21
+ placeholder: 'Search...',
22
+ onSearch: (query: string) => console.log(query),
23
+ },
24
+ },
25
+ },
26
+ {
27
+ name: 'With Value',
28
+ description: 'Search bar with initial value',
29
+ code: '<SearchBar placeholder="Search..." value="React" onSearch={(query) => console.log(query)} />',
30
+ preview: {
31
+ type: 'component',
32
+ component: 'SearchBar',
33
+ props: {
34
+ placeholder: 'Search...',
35
+ value: 'React',
36
+ onSearch: (query: string) => console.log(query),
37
+ },
38
+ },
39
+ },
40
+ {
41
+ name: 'Custom Style',
42
+ description: 'Search bar with custom styling',
43
+ code: '<SearchBar className="h-12 text-lg" placeholder="Search..." onSearch={(query) => console.log(query)} />',
44
+ preview: {
45
+ type: 'component',
46
+ component: 'SearchBar',
47
+ props: {
48
+ className: 'h-12 text-lg',
49
+ placeholder: 'Search...',
50
+ onSearch: (query: string) => console.log(query),
51
+ },
52
+ },
53
+ },
54
+ ],
55
+ dependencies: ['primitives', 'utils'],
56
+ files: ['components/search-bar/index.tsx'],
57
+ };
@@ -0,0 +1,64 @@
1
+ import * as React from 'react';
2
+ import { Search } from 'lucide-react';
3
+
4
+ import { Input } from '@foundrykit/primitives';
5
+ import { cn } from '@foundrykit/utils';
6
+
7
+ export interface SearchBarProps
8
+ extends React.InputHTMLAttributes<HTMLInputElement> {
9
+ onSearch?: (query: string) => void;
10
+ placeholder?: string;
11
+ className?: string;
12
+ value?: string;
13
+ onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
14
+ }
15
+
16
+ const SearchBar = React.forwardRef<HTMLInputElement, SearchBarProps>(
17
+ (
18
+ {
19
+ className,
20
+ onSearch,
21
+ placeholder = 'Search...',
22
+ value: externalValue,
23
+ onChange: externalOnChange,
24
+ ...props
25
+ },
26
+ ref
27
+ ) => {
28
+ const [internalQuery, setInternalQuery] = React.useState('');
29
+
30
+ // Use external value if provided, otherwise use internal state
31
+ const query = externalValue !== undefined ? externalValue : internalQuery;
32
+ const isControlled = externalValue !== undefined;
33
+
34
+ const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
35
+ const value = e.target.value;
36
+
37
+ if (!isControlled) {
38
+ setInternalQuery(value);
39
+ }
40
+
41
+ onSearch?.(value);
42
+ externalOnChange?.(e);
43
+ };
44
+
45
+ return (
46
+ <div className={cn('relative', className)}>
47
+ <Search className='text-muted-foreground absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2' />
48
+ <Input
49
+ ref={ref}
50
+ type='search'
51
+ placeholder={placeholder}
52
+ value={query}
53
+ onChange={handleChange}
54
+ className='pl-10'
55
+ {...props}
56
+ />
57
+ </div>
58
+ );
59
+ }
60
+ );
61
+
62
+ SearchBar.displayName = 'SearchBar';
63
+
64
+ export { SearchBar };
package/src/index.ts ADDED
@@ -0,0 +1,19 @@
1
+ // Export all components
2
+ export { SearchBar } from './components/search-bar/index.js';
3
+ export { DatePicker } from './components/date-picker/index.js';
4
+ export { Calendar } from './components/calendar/index.js';
5
+ export { Pagination, PaginationContent, PaginationItem, PaginationLink, PaginationPrevious, PaginationNext, PaginationEllipsis } from './components/pagination/index.js';
6
+ export {
7
+ Command,
8
+ CommandDialog,
9
+ CommandInput,
10
+ CommandList,
11
+ CommandEmpty,
12
+ CommandGroup,
13
+ CommandItem,
14
+ CommandShortcut,
15
+ CommandSeparator,
16
+ } from './components/command/index.js';
17
+
18
+ // Export utilities from utils package
19
+ export { cn } from '@foundrykit/utils';
package/tsconfig.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "@foundrykit/typescript-config/react-library.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "paths": {
6
+ "@foundrykit/components/*": ["./src/*"]
7
+ }
8
+ },
9
+ "include": ["."],
10
+ "exclude": ["node_modules", "dist"]
11
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "@foundrykit/typescript-config/react-library.json",
3
+ "compilerOptions": {
4
+ "outDir": "dist"
5
+ },
6
+ "include": ["src", "turbo"],
7
+ "exclude": ["node_modules", "dist"]
8
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { defineConfig } from 'tsup';
2
+
3
+ export default defineConfig({
4
+ entry: ['src/index.ts'],
5
+ format: ['esm'],
6
+ dts: true,
7
+ splitting: false,
8
+ sourcemap: true,
9
+ clean: true,
10
+ external: ['react', 'react-dom'],
11
+ });