@foundrykit/components 2.1.0 → 2.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.
- package/.turbo/turbo-build.log +17 -18
- package/.turbo/turbo-type-check.log +1 -1
- package/CHANGELOG.md +27 -0
- package/README.md +49 -145
- package/dist/index.d.ts +270 -60
- package/dist/index.js +2137 -1447
- package/dist/index.js.map +1 -1
- package/package.json +16 -9
- package/src/components/advanced-search-bar/index.tsx +121 -122
- package/src/components/calendar/config.ts +1 -1
- package/src/components/calendar/index.tsx +37 -25
- package/src/components/carousel/config.ts +28 -0
- package/src/components/carousel/index.tsx +258 -0
- package/src/components/chart/config.ts +28 -0
- package/src/components/chart/index.tsx +365 -0
- package/src/components/combobox/config.ts +28 -0
- package/src/components/combobox/index.tsx +101 -0
- package/src/components/command/config.ts +1 -1
- package/src/components/command/index.tsx +23 -12
- package/src/components/data-table/config.ts +28 -0
- package/src/components/data-table/index.tsx +124 -0
- package/src/components/date-picker/config.ts +1 -1
- package/src/components/date-picker/index.tsx +119 -51
- package/src/components/form/index.tsx +29 -11
- package/src/components/input-otp/config.ts +28 -0
- package/src/components/input-otp/index.tsx +92 -0
- package/src/components/pagination/config.ts +1 -1
- package/src/components/pagination/index.tsx +16 -8
- package/src/components/search-bar/config.ts +1 -1
- package/src/components/search-bar/index.tsx +9 -3
- package/src/components/sidebar/index.tsx +22 -25
- package/src/components/theme-toggle/index.tsx +2 -3
- package/src/index.ts +66 -37
- package/eslint.config.js +0 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foundrykit/components",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -21,39 +21,46 @@
|
|
|
21
21
|
"@hookform/resolvers": "^5.2.1",
|
|
22
22
|
"@radix-ui/react-label": "^2.1.7",
|
|
23
23
|
"@radix-ui/react-slot": "^1.2.3",
|
|
24
|
+
"@tanstack/react-table": "^8.21.3",
|
|
25
|
+
"class-variance-authority": "^0.7.1",
|
|
24
26
|
"clsx": "^2.1.1",
|
|
25
27
|
"cmdk": "^1.1.1",
|
|
26
28
|
"date-fns": "^3.6.0",
|
|
29
|
+
"embla-carousel-react": "^8.6.0",
|
|
30
|
+
"input-otp": "^1.4.2",
|
|
27
31
|
"lucide-react": "^0.475.0",
|
|
28
32
|
"react": "^19.1.1",
|
|
29
33
|
"react-day-picker": "^9.9.0",
|
|
30
34
|
"react-dom": "^19.1.1",
|
|
31
35
|
"react-hook-form": "^7.62.0",
|
|
36
|
+
"recharts": "^2.15.4",
|
|
32
37
|
"tailwind-merge": "^3.3.1",
|
|
33
38
|
"zod": "^3.25.76",
|
|
34
|
-
"@foundrykit/
|
|
35
|
-
"@foundrykit/
|
|
36
|
-
"@foundrykit/
|
|
37
|
-
"@foundrykit/utils": "1.0.
|
|
39
|
+
"@foundrykit/hooks": "2.0.7",
|
|
40
|
+
"@foundrykit/primitives": "2.0.7",
|
|
41
|
+
"@foundrykit/types": "2.0.7",
|
|
42
|
+
"@foundrykit/utils": "1.0.7"
|
|
38
43
|
},
|
|
39
44
|
"devDependencies": {
|
|
40
45
|
"@types/node": "^20.19.9",
|
|
41
46
|
"@types/react": "^19.1.9",
|
|
42
47
|
"@types/react-dom": "^19.1.7",
|
|
43
|
-
"eslint": "^9.0.0",
|
|
44
48
|
"tsup": "^8.0.0",
|
|
45
49
|
"typescript": "^5.9.2",
|
|
46
|
-
"@foundrykit/typescript-config": "1.0.
|
|
47
|
-
"@foundrykit/eslint-config": "1.0.5"
|
|
50
|
+
"@foundrykit/typescript-config": "1.0.6"
|
|
48
51
|
},
|
|
49
52
|
"peerDependencies": {
|
|
50
53
|
"react": "^19.1.1",
|
|
51
54
|
"react-dom": "^19.1.1"
|
|
52
55
|
},
|
|
56
|
+
"repository": {
|
|
57
|
+
"type": "git",
|
|
58
|
+
"url": "git+https://github.com/umi-labs/foundry.git",
|
|
59
|
+
"directory": "packages/components"
|
|
60
|
+
},
|
|
53
61
|
"scripts": {
|
|
54
62
|
"build": "tsup",
|
|
55
63
|
"dev": "tsup --watch",
|
|
56
|
-
"lint": "eslint . --max-warnings 0",
|
|
57
64
|
"type-check": "tsc --noEmit"
|
|
58
65
|
}
|
|
59
66
|
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { Slot } from '@radix-ui/react-slot';
|
|
5
|
-
import { cva, type VariantProps } from 'class-variance-authority';
|
|
6
|
-
import { Search, X, ChevronDown } from 'lucide-react';
|
|
7
|
-
|
|
8
|
-
import { cn } from '@foundrykit/utils';
|
|
9
3
|
import {
|
|
10
|
-
useAdvancedSearch,
|
|
11
|
-
SearchContext,
|
|
12
4
|
type EmptyStateBehavior,
|
|
5
|
+
SearchContext,
|
|
6
|
+
useAdvancedSearch,
|
|
13
7
|
} from '@foundrykit/hooks';
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
import {
|
|
9
|
+
Badge,
|
|
10
|
+
Button,
|
|
11
|
+
Input,
|
|
12
|
+
ScrollArea,
|
|
13
|
+
Separator,
|
|
14
|
+
} from '@foundrykit/primitives';
|
|
20
15
|
// Re-export types from hooks package
|
|
21
16
|
import type {
|
|
22
17
|
SearchResult,
|
|
23
18
|
SearchSection as SearchSectionType,
|
|
24
19
|
} from '@foundrykit/types';
|
|
20
|
+
import { cn } from '@foundrykit/utils';
|
|
21
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
22
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
23
|
+
import { ChevronDown, Search, X } from 'lucide-react';
|
|
24
|
+
import * as React from 'react';
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Props for the AdvancedSearchProvider component.
|
|
@@ -244,7 +244,7 @@ export function AdvancedSearchProvider({
|
|
|
244
244
|
* Variant styles for the search input wrapper.
|
|
245
245
|
* Controls the size and visual appearance of the search input container.
|
|
246
246
|
*/
|
|
247
|
-
const searchInputWrapperVariants = cva('relative flex items-center
|
|
247
|
+
const searchInputWrapperVariants = cva('relative flex w-full items-center', {
|
|
248
248
|
variants: {
|
|
249
249
|
size: {
|
|
250
250
|
sm: 'h-8',
|
|
@@ -253,7 +253,7 @@ const searchInputWrapperVariants = cva('relative flex items-center w-full', {
|
|
|
253
253
|
xl: 'h-14',
|
|
254
254
|
},
|
|
255
255
|
variant: {
|
|
256
|
-
default: 'border
|
|
256
|
+
default: 'border-input bg-background border',
|
|
257
257
|
ghost: 'bg-transparent',
|
|
258
258
|
filled: 'bg-muted',
|
|
259
259
|
},
|
|
@@ -708,7 +708,7 @@ export const SearchResults = React.forwardRef<
|
|
|
708
708
|
<div key={section.id}>
|
|
709
709
|
{index > 0 && <Separator className='my-4' />}
|
|
710
710
|
<div className='space-y-2'>
|
|
711
|
-
<h3 className='text-muted-foreground text-sm font-semibold
|
|
711
|
+
<h3 className='text-muted-foreground text-sm font-semibold tracking-wide uppercase'>
|
|
712
712
|
{section.title}
|
|
713
713
|
</h3>
|
|
714
714
|
<div className='space-y-1'>
|
|
@@ -914,119 +914,119 @@ export const AdvancedSearchBar = React.forwardRef<
|
|
|
914
914
|
},
|
|
915
915
|
ref
|
|
916
916
|
) => {
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
917
|
+
const { isOpen, setIsOpen, setActiveIndex } = useAdvancedSearch();
|
|
918
|
+
const rootRef = React.useRef<HTMLDivElement | null>(null);
|
|
919
|
+
const previousOpenRef = React.useRef(isOpen);
|
|
920
920
|
|
|
921
|
-
|
|
922
|
-
|
|
921
|
+
const isControlled = open !== undefined;
|
|
922
|
+
const isOpenState = isControlled ? open : isOpen;
|
|
923
923
|
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
924
|
+
React.useEffect(() => {
|
|
925
|
+
if (previousOpenRef.current !== isOpen) {
|
|
926
|
+
previousOpenRef.current = isOpen;
|
|
927
|
+
onOpenChange?.(isOpen);
|
|
928
|
+
}
|
|
929
|
+
}, [isOpen, onOpenChange]);
|
|
930
930
|
|
|
931
|
-
|
|
932
|
-
|
|
931
|
+
React.useEffect(() => {
|
|
932
|
+
if (!isOpenState) return;
|
|
933
|
+
|
|
934
|
+
const handlePointerDown = (event: PointerEvent) => {
|
|
935
|
+
if (!rootRef.current?.contains(event.target as Node)) {
|
|
936
|
+
setActiveIndex(-1);
|
|
937
|
+
setIsOpen(false);
|
|
938
|
+
onOpenChange?.(false);
|
|
939
|
+
}
|
|
940
|
+
};
|
|
933
941
|
|
|
934
|
-
|
|
935
|
-
|
|
942
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
943
|
+
if (event.key !== 'Escape') return;
|
|
936
944
|
setActiveIndex(-1);
|
|
937
945
|
setIsOpen(false);
|
|
938
946
|
onOpenChange?.(false);
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
947
|
+
const focusTarget = rootRef.current?.querySelector<HTMLElement>(
|
|
948
|
+
'input, button, [href], [tabindex]:not([tabindex="-1"])'
|
|
949
|
+
);
|
|
950
|
+
focusTarget?.focus();
|
|
951
|
+
};
|
|
952
|
+
|
|
953
|
+
document.addEventListener('pointerdown', handlePointerDown);
|
|
954
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
955
|
+
|
|
956
|
+
return () => {
|
|
957
|
+
document.removeEventListener('pointerdown', handlePointerDown);
|
|
958
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
959
|
+
};
|
|
960
|
+
}, [isOpenState, onOpenChange, setActiveIndex, setIsOpen]);
|
|
961
|
+
|
|
962
|
+
const setRefs = React.useCallback(
|
|
963
|
+
(node: HTMLDivElement | null) => {
|
|
964
|
+
rootRef.current = node;
|
|
965
|
+
if (typeof ref === 'function') {
|
|
966
|
+
ref(node);
|
|
967
|
+
} else if (ref) {
|
|
968
|
+
ref.current = node;
|
|
969
|
+
}
|
|
970
|
+
},
|
|
971
|
+
[ref]
|
|
972
|
+
);
|
|
952
973
|
|
|
953
|
-
|
|
954
|
-
|
|
974
|
+
const isSearchResultsChild = (child: React.ReactNode) => {
|
|
975
|
+
if (!React.isValidElement(child)) return false;
|
|
976
|
+
const childType = child.type as { displayName?: string };
|
|
955
977
|
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
978
|
+
return (
|
|
979
|
+
child.type === SearchResults ||
|
|
980
|
+
childType.displayName === SearchResults.displayName
|
|
981
|
+
);
|
|
959
982
|
};
|
|
960
|
-
}, [isOpenState, onOpenChange, setActiveIndex, setIsOpen]);
|
|
961
|
-
|
|
962
|
-
const setRefs = React.useCallback(
|
|
963
|
-
(node: HTMLDivElement | null) => {
|
|
964
|
-
rootRef.current = node;
|
|
965
|
-
if (typeof ref === 'function') {
|
|
966
|
-
ref(node);
|
|
967
|
-
} else if (ref) {
|
|
968
|
-
ref.current = node;
|
|
969
|
-
}
|
|
970
|
-
},
|
|
971
|
-
[ref]
|
|
972
|
-
);
|
|
973
983
|
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
const
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
child.type === SearchResults ||
|
|
980
|
-
childType.displayName === SearchResults.displayName
|
|
984
|
+
// Results are rendered in the positioned panel; every other authored child is a trigger/input.
|
|
985
|
+
const childrenArray = React.Children.toArray(children);
|
|
986
|
+
const resultsChildren = childrenArray.filter(isSearchResultsChild);
|
|
987
|
+
const triggerChildren = childrenArray.filter(
|
|
988
|
+
child => !isSearchResultsChild(child)
|
|
981
989
|
);
|
|
982
|
-
};
|
|
983
990
|
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
991
|
+
const triggerElement = triggerChildren.length ? (
|
|
992
|
+
triggerChildren
|
|
993
|
+
) : (
|
|
994
|
+
<SearchInput />
|
|
995
|
+
);
|
|
996
|
+
const resultsElement = resultsChildren.length ? (
|
|
997
|
+
resultsChildren
|
|
998
|
+
) : (
|
|
999
|
+
<SearchResults />
|
|
1000
|
+
);
|
|
990
1001
|
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1002
|
+
const resultsPanel = isOpenState ? (
|
|
1003
|
+
resultsMode === 'inline' ? (
|
|
1004
|
+
<div className={cn('w-full overflow-hidden', resultsClassName)}>
|
|
1005
|
+
{resultsElement}
|
|
1006
|
+
</div>
|
|
1007
|
+
) : (
|
|
1008
|
+
<div
|
|
1009
|
+
className={cn(
|
|
1010
|
+
'bg-popover text-popover-foreground border-border absolute top-full left-0 z-50 mt-1 max-h-[min(var(--results-max-height),calc(100vh-8rem))] w-full overflow-hidden rounded-md border shadow-lg',
|
|
1011
|
+
resultsClassName
|
|
1012
|
+
)}
|
|
1013
|
+
>
|
|
1014
|
+
{resultsElement}
|
|
1015
|
+
</div>
|
|
1016
|
+
)
|
|
1017
|
+
) : null;
|
|
1001
1018
|
|
|
1002
|
-
|
|
1003
|
-
resultsMode === 'inline' ? (
|
|
1004
|
-
<div className={cn('w-full overflow-hidden', resultsClassName)}>
|
|
1005
|
-
{resultsElement}
|
|
1006
|
-
</div>
|
|
1007
|
-
) : (
|
|
1019
|
+
return (
|
|
1008
1020
|
<div
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1021
|
+
ref={setRefs}
|
|
1022
|
+
data-state={isOpenState ? 'open' : 'closed'}
|
|
1023
|
+
className={cn('relative w-full', className)}
|
|
1024
|
+
{...props}
|
|
1013
1025
|
>
|
|
1014
|
-
{
|
|
1026
|
+
<div className={cn('w-full', triggerClassName)}>{triggerElement}</div>
|
|
1027
|
+
{resultsPanel}
|
|
1015
1028
|
</div>
|
|
1016
|
-
)
|
|
1017
|
-
) : null;
|
|
1018
|
-
|
|
1019
|
-
return (
|
|
1020
|
-
<div
|
|
1021
|
-
ref={setRefs}
|
|
1022
|
-
data-state={isOpenState ? 'open' : 'closed'}
|
|
1023
|
-
className={cn('relative w-full', className)}
|
|
1024
|
-
{...props}
|
|
1025
|
-
>
|
|
1026
|
-
<div className={cn('w-full', triggerClassName)}>{triggerElement}</div>
|
|
1027
|
-
{resultsPanel}
|
|
1028
|
-
</div>
|
|
1029
|
-
);
|
|
1029
|
+
);
|
|
1030
1030
|
}
|
|
1031
1031
|
);
|
|
1032
1032
|
AdvancedSearchBar.displayName = 'AdvancedSearchBar';
|
|
@@ -1068,7 +1068,7 @@ export const SearchSection = React.forwardRef<
|
|
|
1068
1068
|
return (
|
|
1069
1069
|
<div ref={ref} className={cn('space-y-2', className)} {...props}>
|
|
1070
1070
|
{title && (
|
|
1071
|
-
<h3 className='text-muted-foreground text-sm font-semibold
|
|
1071
|
+
<h3 className='text-muted-foreground text-sm font-semibold tracking-wide uppercase'>
|
|
1072
1072
|
{title}
|
|
1073
1073
|
</h3>
|
|
1074
1074
|
)}
|
|
@@ -1191,7 +1191,7 @@ export const SearchItem = React.forwardRef<HTMLDivElement, SearchItemProps>(
|
|
|
1191
1191
|
ref={ref as unknown as React.RefObject<HTMLButtonElement>}
|
|
1192
1192
|
type='button'
|
|
1193
1193
|
className={cn(
|
|
1194
|
-
'hover:bg-accent hover:text-accent-foreground focus-visible:border-ring focus-visible:ring-ring/50 w-full cursor-pointer rounded-md text-left outline-none
|
|
1194
|
+
'hover:bg-accent hover:text-accent-foreground focus-visible:border-ring focus-visible:ring-ring/50 w-full cursor-pointer rounded-md text-left transition-colors outline-none focus-visible:ring-[3px]',
|
|
1195
1195
|
className
|
|
1196
1196
|
)}
|
|
1197
1197
|
onClick={handleClick}
|
|
@@ -1250,23 +1250,22 @@ SearchItem.displayName = 'SearchItem';
|
|
|
1250
1250
|
* </SearchBar.Provider>
|
|
1251
1251
|
* ```
|
|
1252
1252
|
*/
|
|
1253
|
+
/**
|
|
1254
|
+
* Provider component exported separately to avoid naming conflicts.
|
|
1255
|
+
* This is the same as AdvancedSearchProvider but with a shorter name for compound pattern usage.
|
|
1256
|
+
*/
|
|
1253
1257
|
export {
|
|
1254
1258
|
AdvancedSearchBar as Root,
|
|
1259
|
+
AdvancedSearchProvider as Provider,
|
|
1255
1260
|
SearchInput as Input,
|
|
1256
|
-
|
|
1261
|
+
SearchItem as Item,
|
|
1257
1262
|
SearchResults as Results,
|
|
1258
1263
|
SearchSection as Section,
|
|
1259
|
-
|
|
1264
|
+
SearchTrigger as Trigger,
|
|
1260
1265
|
searchInputWrapperVariants,
|
|
1261
1266
|
searchResultsVariants,
|
|
1262
1267
|
};
|
|
1263
1268
|
|
|
1264
|
-
/**
|
|
1265
|
-
* Provider component exported separately to avoid naming conflicts.
|
|
1266
|
-
* This is the same as AdvancedSearchProvider but with a shorter name for compound pattern usage.
|
|
1267
|
-
*/
|
|
1268
|
-
export { AdvancedSearchProvider as Provider };
|
|
1269
|
-
|
|
1270
1269
|
/**
|
|
1271
1270
|
* Wrapper component for documentation and preview purposes.
|
|
1272
1271
|
* Provides a complete search implementation with mock data for testing and demos.
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { Button, buttonVariants } from '@foundrykit/primitives';
|
|
4
|
+
import { cn } from '@foundrykit/utils';
|
|
4
5
|
import {
|
|
5
6
|
ChevronDownIcon,
|
|
6
7
|
ChevronLeftIcon,
|
|
7
8
|
ChevronRightIcon,
|
|
8
9
|
} from 'lucide-react';
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
import * as React from 'react';
|
|
11
|
+
import {
|
|
12
|
+
type DayButton,
|
|
13
|
+
DayPicker,
|
|
14
|
+
getDefaultClassNames,
|
|
15
|
+
} from 'react-day-picker';
|
|
13
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Themed wrapper around `react-day-picker`'s `DayPicker`, styled with FoundryKit
|
|
19
|
+
* design tokens. Accepts all `DayPicker` props (`mode`, `selected`, `onSelect`,
|
|
20
|
+
* etc.) plus `buttonVariant` to control the nav button style.
|
|
21
|
+
*/
|
|
14
22
|
function Calendar({
|
|
15
23
|
className,
|
|
16
24
|
classNames,
|
|
@@ -43,72 +51,72 @@ function Calendar({
|
|
|
43
51
|
classNames={{
|
|
44
52
|
root: cn('w-fit', defaultClassNames.root),
|
|
45
53
|
months: cn(
|
|
46
|
-
'flex gap-4
|
|
54
|
+
'relative flex flex-col gap-4 md:flex-row',
|
|
47
55
|
defaultClassNames.months
|
|
48
56
|
),
|
|
49
|
-
month: cn('flex flex-col
|
|
57
|
+
month: cn('flex w-full flex-col gap-4', defaultClassNames.month),
|
|
50
58
|
nav: cn(
|
|
51
|
-
'
|
|
59
|
+
'absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1',
|
|
52
60
|
defaultClassNames.nav
|
|
53
61
|
),
|
|
54
62
|
button_previous: cn(
|
|
55
63
|
buttonVariants({ variant: buttonVariant }),
|
|
56
|
-
'size-(--cell-size) aria-disabled:opacity-50
|
|
64
|
+
'size-(--cell-size) p-0 select-none aria-disabled:opacity-50',
|
|
57
65
|
defaultClassNames.button_previous
|
|
58
66
|
),
|
|
59
67
|
button_next: cn(
|
|
60
68
|
buttonVariants({ variant: buttonVariant }),
|
|
61
|
-
'size-(--cell-size) aria-disabled:opacity-50
|
|
69
|
+
'size-(--cell-size) p-0 select-none aria-disabled:opacity-50',
|
|
62
70
|
defaultClassNames.button_next
|
|
63
71
|
),
|
|
64
72
|
month_caption: cn(
|
|
65
|
-
'flex
|
|
73
|
+
'flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)',
|
|
66
74
|
defaultClassNames.month_caption
|
|
67
75
|
),
|
|
68
76
|
dropdowns: cn(
|
|
69
|
-
'w-full
|
|
77
|
+
'flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium',
|
|
70
78
|
defaultClassNames.dropdowns
|
|
71
79
|
),
|
|
72
80
|
dropdown_root: cn(
|
|
73
|
-
'
|
|
81
|
+
'has-focus:border-ring border-input has-focus:ring-ring/50 relative rounded-md border shadow-xs has-focus:ring-[3px]',
|
|
74
82
|
defaultClassNames.dropdown_root
|
|
75
83
|
),
|
|
76
84
|
dropdown: cn(
|
|
77
|
-
'
|
|
85
|
+
'bg-popover absolute inset-0 opacity-0',
|
|
78
86
|
defaultClassNames.dropdown
|
|
79
87
|
),
|
|
80
88
|
caption_label: cn(
|
|
81
|
-
'select-none
|
|
89
|
+
'font-medium select-none',
|
|
82
90
|
captionLayout === 'label'
|
|
83
91
|
? 'text-sm'
|
|
84
|
-
: '
|
|
92
|
+
: '[&>svg]:text-muted-foreground flex h-8 items-center gap-1 rounded-md pr-1 pl-2 text-sm [&>svg]:size-3.5',
|
|
85
93
|
defaultClassNames.caption_label
|
|
86
94
|
),
|
|
87
95
|
table: 'w-full border-collapse',
|
|
88
96
|
weekdays: cn('flex', defaultClassNames.weekdays),
|
|
89
97
|
weekday: cn(
|
|
90
|
-
'text-muted-foreground
|
|
98
|
+
'text-muted-foreground flex-1 rounded-md text-[0.8rem] font-normal select-none',
|
|
91
99
|
defaultClassNames.weekday
|
|
92
100
|
),
|
|
93
|
-
week: cn('flex w-full
|
|
101
|
+
week: cn('mt-2 flex w-full', defaultClassNames.week),
|
|
94
102
|
week_number_header: cn(
|
|
95
|
-
'
|
|
103
|
+
'w-(--cell-size) select-none',
|
|
96
104
|
defaultClassNames.week_number_header
|
|
97
105
|
),
|
|
98
106
|
week_number: cn(
|
|
99
|
-
'text-[0.8rem] select-none
|
|
107
|
+
'text-muted-foreground text-[0.8rem] select-none',
|
|
100
108
|
defaultClassNames.week_number
|
|
101
109
|
),
|
|
102
110
|
day: cn(
|
|
103
|
-
'relative
|
|
111
|
+
'group/day relative aspect-square h-full w-full p-0 text-center select-none [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md',
|
|
104
112
|
defaultClassNames.day
|
|
105
113
|
),
|
|
106
114
|
range_start: cn(
|
|
107
|
-
'rounded-l-md
|
|
115
|
+
'bg-accent rounded-l-md',
|
|
108
116
|
defaultClassNames.range_start
|
|
109
117
|
),
|
|
110
118
|
range_middle: cn('rounded-none', defaultClassNames.range_middle),
|
|
111
|
-
range_end: cn('rounded-r-md
|
|
119
|
+
range_end: cn('bg-accent rounded-r-md', defaultClassNames.range_end),
|
|
112
120
|
today: cn(
|
|
113
121
|
'bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none',
|
|
114
122
|
defaultClassNames.today
|
|
@@ -159,7 +167,7 @@ function Calendar({
|
|
|
159
167
|
WeekNumber: ({ children, ...props }) => {
|
|
160
168
|
return (
|
|
161
169
|
<td {...props}>
|
|
162
|
-
<div className='size-(--cell-size)
|
|
170
|
+
<div className='flex size-(--cell-size) items-center justify-center text-center'>
|
|
163
171
|
{children}
|
|
164
172
|
</div>
|
|
165
173
|
</td>
|
|
@@ -172,6 +180,10 @@ function Calendar({
|
|
|
172
180
|
);
|
|
173
181
|
}
|
|
174
182
|
|
|
183
|
+
/**
|
|
184
|
+
* Individual day cell button used by {@link Calendar}. Applies selected/range
|
|
185
|
+
* data attributes for styling and auto-focuses when the day is focused.
|
|
186
|
+
*/
|
|
175
187
|
function CalendarDayButton({
|
|
176
188
|
className,
|
|
177
189
|
day,
|
|
@@ -201,7 +213,7 @@ function CalendarDayButton({
|
|
|
201
213
|
data-range-end={modifiers.range_end}
|
|
202
214
|
data-range-middle={modifiers.range_middle}
|
|
203
215
|
className={cn(
|
|
204
|
-
'data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 dark:hover:text-accent-foreground
|
|
216
|
+
'data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 dark:hover:text-accent-foreground flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md [&>span]:text-xs [&>span]:opacity-70',
|
|
205
217
|
defaultClassNames.day,
|
|
206
218
|
className
|
|
207
219
|
)}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ComponentConfig } from '@foundrykit/types';
|
|
2
|
+
|
|
3
|
+
export const CarouselConfig: ComponentConfig = {
|
|
4
|
+
name: 'Carousel',
|
|
5
|
+
description:
|
|
6
|
+
'A slideshow component for cycling through elements, built on Embla Carousel.',
|
|
7
|
+
category: 'components',
|
|
8
|
+
tags: ['carousel', 'slider', 'gallery', 'interactive', 'embla'],
|
|
9
|
+
preview: {
|
|
10
|
+
type: 'static',
|
|
11
|
+
html: '<div class="flex h-24 w-full items-center justify-center gap-2 rounded-md border border-gray-300 bg-gray-100"><div class="flex h-8 w-8 items-center justify-center rounded-full border border-gray-300 bg-white text-gray-600">‹</div><div class="flex h-16 w-32 items-center justify-center rounded-md border border-gray-300 bg-white text-sm text-gray-600">Slide</div><div class="flex h-8 w-8 items-center justify-center rounded-full border border-gray-300 bg-white text-gray-600">›</div></div>',
|
|
12
|
+
},
|
|
13
|
+
variants: [
|
|
14
|
+
{
|
|
15
|
+
name: 'Default',
|
|
16
|
+
description: 'Default horizontal carousel',
|
|
17
|
+
code: '<Carousel><CarouselContent><CarouselItem>...</CarouselItem></CarouselContent><CarouselPrevious /><CarouselNext /></Carousel>',
|
|
18
|
+
preview: {
|
|
19
|
+
type: 'component',
|
|
20
|
+
component: 'Carousel',
|
|
21
|
+
props: {},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
dependencies: ['utils', 'primitives'],
|
|
26
|
+
packageDependencies: ['embla-carousel-react', 'lucide-react'],
|
|
27
|
+
files: ['components/carousel/index.tsx'],
|
|
28
|
+
};
|