@foundrykit/components 2.2.0 → 2.2.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 (105) hide show
  1. package/dist/chunk-4WYKNDYY.js +91 -0
  2. package/dist/chunk-4WYKNDYY.js.map +1 -0
  3. package/dist/chunk-5CXNMTIN.js +84 -0
  4. package/dist/chunk-5CXNMTIN.js.map +1 -0
  5. package/dist/chunk-B5ZTF5MZ.js +203 -0
  6. package/dist/chunk-B5ZTF5MZ.js.map +1 -0
  7. package/dist/chunk-EDNWBEKV.js +51 -0
  8. package/dist/chunk-EDNWBEKV.js.map +1 -0
  9. package/dist/chunk-ID7BFTID.js +248 -0
  10. package/dist/chunk-ID7BFTID.js.map +1 -0
  11. package/dist/chunk-IYBHXVCH.js +181 -0
  12. package/dist/chunk-IYBHXVCH.js.map +1 -0
  13. package/dist/chunk-KQZEF7PS.js +71 -0
  14. package/dist/chunk-KQZEF7PS.js.map +1 -0
  15. package/dist/chunk-P3GSYR7O.js +889 -0
  16. package/dist/chunk-P3GSYR7O.js.map +1 -0
  17. package/dist/chunk-PKSRYDN4.js +168 -0
  18. package/dist/chunk-PKSRYDN4.js.map +1 -0
  19. package/dist/chunk-SFM7ZMG2.js +104 -0
  20. package/dist/chunk-SFM7ZMG2.js.map +1 -0
  21. package/dist/chunk-TLQQZJUR.js +126 -0
  22. package/dist/chunk-TLQQZJUR.js.map +1 -0
  23. package/dist/chunk-UE7CDYEN.js +59 -0
  24. package/dist/chunk-UE7CDYEN.js.map +1 -0
  25. package/dist/chunk-UG7YS3D5.js +198 -0
  26. package/dist/chunk-UG7YS3D5.js.map +1 -0
  27. package/dist/components/advanced-search-bar/index.d.ts +308 -0
  28. package/dist/components/advanced-search-bar/index.js +34 -0
  29. package/dist/components/advanced-search-bar/index.js.map +1 -0
  30. package/dist/components/calendar/index.d.ts +20 -0
  31. package/dist/components/calendar/index.js +11 -0
  32. package/dist/components/calendar/index.js.map +1 -0
  33. package/dist/components/carousel/index.d.ts +40 -0
  34. package/dist/components/carousel/index.js +17 -0
  35. package/dist/components/carousel/index.js.map +1 -0
  36. package/dist/components/chart/index.d.ts +59 -0
  37. package/dist/components/chart/index.js +21 -0
  38. package/dist/components/chart/index.js.map +1 -0
  39. package/dist/components/combobox/index.d.ts +33 -0
  40. package/dist/components/combobox/index.js +10 -0
  41. package/dist/components/combobox/index.js.map +1 -0
  42. package/dist/components/command/index.d.ts +33 -0
  43. package/dist/components/command/index.js +25 -0
  44. package/dist/components/command/index.js.map +1 -0
  45. package/dist/components/data-table/index.d.ts +17 -0
  46. package/dist/components/data-table/index.js +9 -0
  47. package/dist/components/data-table/index.js.map +1 -0
  48. package/dist/components/date-picker/index.d.ts +17 -0
  49. package/dist/components/date-picker/index.js +9 -0
  50. package/dist/components/date-picker/index.js.map +1 -0
  51. package/dist/components/form/index.d.ts +37 -0
  52. package/dist/components/form/index.js +23 -0
  53. package/dist/components/form/index.js.map +1 -0
  54. package/dist/components/input-otp/index.d.ts +30 -0
  55. package/dist/components/input-otp/index.js +15 -0
  56. package/dist/components/input-otp/index.js.map +1 -0
  57. package/dist/components/pagination/index.d.ts +26 -0
  58. package/dist/components/pagination/index.js +20 -0
  59. package/dist/components/pagination/index.js.map +1 -0
  60. package/dist/components/search-bar/index.d.ts +17 -0
  61. package/dist/components/search-bar/index.js +9 -0
  62. package/dist/components/search-bar/index.js.map +1 -0
  63. package/dist/components/sidebar/index.d.ts +70 -0
  64. package/dist/components/sidebar/index.js +652 -0
  65. package/dist/components/sidebar/index.js.map +1 -0
  66. package/dist/components/theme-toggle/index.d.ts +20 -0
  67. package/dist/components/theme-toggle/index.js +9 -0
  68. package/dist/components/theme-toggle/index.js.map +1 -0
  69. package/dist/index.d.ts +27 -605
  70. package/dist/index.js +73 -2337
  71. package/dist/index.js.map +1 -1
  72. package/package.json +17 -10
  73. package/CHANGELOG.md +0 -362
  74. package/src/components/advanced-search-bar/config.ts +0 -223
  75. package/src/components/advanced-search-bar/index.tsx +0 -1415
  76. package/src/components/calendar/config.ts +0 -51
  77. package/src/components/calendar/index.tsx +0 -225
  78. package/src/components/carousel/config.ts +0 -28
  79. package/src/components/carousel/index.tsx +0 -258
  80. package/src/components/chart/config.ts +0 -28
  81. package/src/components/chart/index.tsx +0 -365
  82. package/src/components/combobox/config.ts +0 -28
  83. package/src/components/combobox/index.tsx +0 -111
  84. package/src/components/command/config.ts +0 -804
  85. package/src/components/command/index.tsx +0 -195
  86. package/src/components/data-table/config.ts +0 -28
  87. package/src/components/data-table/index.tsx +0 -124
  88. package/src/components/date-picker/config.ts +0 -55
  89. package/src/components/date-picker/index.tsx +0 -207
  90. package/src/components/form/config.ts +0 -21
  91. package/src/components/form/index.tsx +0 -150
  92. package/src/components/input-otp/config.ts +0 -28
  93. package/src/components/input-otp/index.tsx +0 -92
  94. package/src/components/pagination/config.ts +0 -367
  95. package/src/components/pagination/index.tsx +0 -135
  96. package/src/components/search-bar/config.ts +0 -58
  97. package/src/components/search-bar/index.tsx +0 -70
  98. package/src/components/sidebar/config.ts +0 -29
  99. package/src/components/sidebar/index.tsx +0 -723
  100. package/src/components/theme-toggle/config.ts +0 -27
  101. package/src/components/theme-toggle/index.tsx +0 -63
  102. package/src/index.ts +0 -83
  103. package/tsconfig.json +0 -12
  104. package/tsconfig.lint.json +0 -8
  105. package/tsup.config.ts +0 -11
@@ -1,365 +0,0 @@
1
- 'use client';
2
-
3
- import { cn } from '@foundrykit/utils';
4
- import * as React from 'react';
5
- import * as RechartsPrimitive from 'recharts';
6
-
7
- // Format: { THEME_NAME: CSS_SELECTOR }
8
- const THEMES = { light: '', dark: '.dark' } as const;
9
-
10
- export type ChartConfig = {
11
- [k in string]: {
12
- label?: React.ReactNode;
13
- icon?: React.ComponentType;
14
- } & (
15
- | { color?: string; theme?: never }
16
- | { color?: never; theme: Record<keyof typeof THEMES, string> }
17
- );
18
- };
19
-
20
- type ChartContextProps = {
21
- config: ChartConfig;
22
- };
23
-
24
- const ChartContext = React.createContext<ChartContextProps | null>(null);
25
-
26
- function useChart() {
27
- const context = React.useContext(ChartContext);
28
-
29
- if (!context) {
30
- throw new Error('useChart must be used within a <ChartContainer />');
31
- }
32
-
33
- return context;
34
- }
35
-
36
- /**
37
- * Responsive chart wrapper that shares config (labels, colors) with its parts.
38
- *
39
- * @example
40
- * ```tsx
41
- * <ChartContainer config={config}>
42
- * <BarChart data={data}>
43
- * <Bar dataKey='total' fill='var(--color-total)' />
44
- * </BarChart>
45
- * </ChartContainer>
46
- * ```
47
- */
48
- function ChartContainer({
49
- id,
50
- className,
51
- children,
52
- config,
53
- ...props
54
- }: React.ComponentProps<'div'> & {
55
- config: ChartConfig;
56
- children: React.ComponentProps<
57
- typeof RechartsPrimitive.ResponsiveContainer
58
- >['children'];
59
- }) {
60
- const uniqueId = React.useId();
61
- const chartId = `chart-${id || uniqueId.replace(/:/g, '')}`;
62
-
63
- return (
64
- <ChartContext.Provider value={{ config }}>
65
- <div
66
- data-slot='chart'
67
- data-chart={chartId}
68
- className={cn(
69
- "[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
70
- className
71
- )}
72
- {...props}
73
- >
74
- <ChartStyle id={chartId} config={config} />
75
- <RechartsPrimitive.ResponsiveContainer>
76
- {children}
77
- </RechartsPrimitive.ResponsiveContainer>
78
- </div>
79
- </ChartContext.Provider>
80
- );
81
- }
82
-
83
- function ChartStyle({ id, config }: { id: string; config: ChartConfig }) {
84
- const colorConfig = Object.entries(config).filter(
85
- ([, itemConfig]) => itemConfig.theme || itemConfig.color
86
- );
87
-
88
- if (!colorConfig.length) {
89
- return null;
90
- }
91
-
92
- return (
93
- <style
94
- dangerouslySetInnerHTML={{
95
- __html: Object.entries(THEMES)
96
- .map(
97
- ([theme, prefix]) => `
98
- ${prefix} [data-chart=${id}] {
99
- ${colorConfig
100
- .map(([key, itemConfig]) => {
101
- const color =
102
- itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ||
103
- itemConfig.color;
104
- return color ? ` --color-${key}: ${color};` : null;
105
- })
106
- .join('\n')}
107
- }
108
- `
109
- )
110
- .join('\n'),
111
- }}
112
- />
113
- );
114
- }
115
-
116
- const ChartTooltip = RechartsPrimitive.Tooltip;
117
-
118
- function ChartTooltipContent({
119
- active,
120
- payload,
121
- className,
122
- indicator = 'dot',
123
- hideLabel = false,
124
- hideIndicator = false,
125
- label,
126
- labelFormatter,
127
- labelClassName,
128
- formatter,
129
- color,
130
- nameKey,
131
- labelKey,
132
- }: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
133
- React.ComponentProps<'div'> & {
134
- hideLabel?: boolean;
135
- hideIndicator?: boolean;
136
- indicator?: 'line' | 'dot' | 'dashed';
137
- nameKey?: string;
138
- labelKey?: string;
139
- }) {
140
- const { config } = useChart();
141
-
142
- const tooltipLabel = React.useMemo(() => {
143
- if (hideLabel || !payload?.length) {
144
- return null;
145
- }
146
-
147
- const [item] = payload;
148
- const key = `${labelKey || item?.dataKey || item?.name || 'value'}`;
149
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
150
- const value =
151
- !labelKey && typeof label === 'string'
152
- ? config[label as keyof typeof config]?.label || label
153
- : itemConfig?.label;
154
-
155
- if (labelFormatter) {
156
- return (
157
- <div className={cn('font-medium', labelClassName)}>
158
- {labelFormatter(value, payload)}
159
- </div>
160
- );
161
- }
162
-
163
- if (!value) {
164
- return null;
165
- }
166
-
167
- return <div className={cn('font-medium', labelClassName)}>{value}</div>;
168
- }, [
169
- label,
170
- labelFormatter,
171
- payload,
172
- hideLabel,
173
- labelClassName,
174
- config,
175
- labelKey,
176
- ]);
177
-
178
- if (!active || !payload?.length) {
179
- return null;
180
- }
181
-
182
- const nestLabel = payload.length === 1 && indicator !== 'dot';
183
-
184
- return (
185
- <div
186
- data-slot='chart-tooltip-content'
187
- className={cn(
188
- 'border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl',
189
- className
190
- )}
191
- >
192
- {!nestLabel ? tooltipLabel : null}
193
- <div className='grid gap-1.5'>
194
- {payload.map((item, index) => {
195
- const key = `${nameKey || item.name || item.dataKey || 'value'}`;
196
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
197
- const indicatorColor = color || item.payload.fill || item.color;
198
-
199
- return (
200
- <div
201
- key={item.dataKey}
202
- className={cn(
203
- '[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5',
204
- indicator === 'dot' && 'items-center'
205
- )}
206
- >
207
- {formatter && item?.value !== undefined && item.name ? (
208
- formatter(item.value, item.name, item, index, item.payload)
209
- ) : (
210
- <>
211
- {itemConfig?.icon ? (
212
- <itemConfig.icon />
213
- ) : (
214
- !hideIndicator && (
215
- <div
216
- className={cn(
217
- 'shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)',
218
- {
219
- 'h-2.5 w-2.5': indicator === 'dot',
220
- 'w-1': indicator === 'line',
221
- 'w-0 border-[1.5px] border-dashed bg-transparent':
222
- indicator === 'dashed',
223
- 'my-0.5': nestLabel && indicator === 'dashed',
224
- }
225
- )}
226
- style={
227
- {
228
- '--color-bg': indicatorColor,
229
- '--color-border': indicatorColor,
230
- } as React.CSSProperties
231
- }
232
- />
233
- )
234
- )}
235
- <div
236
- className={cn(
237
- 'flex flex-1 justify-between leading-none',
238
- nestLabel ? 'items-end' : 'items-center'
239
- )}
240
- >
241
- <div className='grid gap-1.5'>
242
- {nestLabel ? tooltipLabel : null}
243
- <span className='text-muted-foreground'>
244
- {itemConfig?.label || item.name}
245
- </span>
246
- </div>
247
- {item.value && (
248
- <span className='text-foreground font-mono font-medium tabular-nums'>
249
- {item.value.toLocaleString()}
250
- </span>
251
- )}
252
- </div>
253
- </>
254
- )}
255
- </div>
256
- );
257
- })}
258
- </div>
259
- </div>
260
- );
261
- }
262
-
263
- const ChartLegend = RechartsPrimitive.Legend;
264
-
265
- function ChartLegendContent({
266
- className,
267
- hideIcon = false,
268
- payload,
269
- verticalAlign = 'bottom',
270
- nameKey,
271
- }: React.ComponentProps<'div'> &
272
- Pick<RechartsPrimitive.LegendProps, 'payload' | 'verticalAlign'> & {
273
- hideIcon?: boolean;
274
- nameKey?: string;
275
- }) {
276
- const { config } = useChart();
277
-
278
- if (!payload?.length) {
279
- return null;
280
- }
281
-
282
- return (
283
- <div
284
- data-slot='chart-legend-content'
285
- className={cn(
286
- 'flex items-center justify-center gap-4',
287
- verticalAlign === 'top' ? 'pb-3' : 'pt-3',
288
- className
289
- )}
290
- >
291
- {payload.map(item => {
292
- const key = `${nameKey || item.dataKey || 'value'}`;
293
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
294
-
295
- return (
296
- <div
297
- key={item.value}
298
- className={cn(
299
- '[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3'
300
- )}
301
- >
302
- {itemConfig?.icon && !hideIcon ? (
303
- <itemConfig.icon />
304
- ) : (
305
- <div
306
- className='h-2 w-2 shrink-0 rounded-[2px]'
307
- style={{ backgroundColor: item.color }}
308
- />
309
- )}
310
- {itemConfig?.label}
311
- </div>
312
- );
313
- })}
314
- </div>
315
- );
316
- }
317
-
318
- // Helper to extract item config from a payload.
319
- function getPayloadConfigFromPayload(
320
- config: ChartConfig,
321
- payload: unknown,
322
- key: string
323
- ) {
324
- if (typeof payload !== 'object' || payload === null) {
325
- return undefined;
326
- }
327
-
328
- const payloadPayload =
329
- 'payload' in payload &&
330
- typeof payload.payload === 'object' &&
331
- payload.payload !== null
332
- ? payload.payload
333
- : undefined;
334
-
335
- let configLabelKey: string = key;
336
-
337
- if (
338
- key in payload &&
339
- typeof payload[key as keyof typeof payload] === 'string'
340
- ) {
341
- configLabelKey = payload[key as keyof typeof payload] as string;
342
- } else if (
343
- payloadPayload &&
344
- key in payloadPayload &&
345
- typeof payloadPayload[key as keyof typeof payloadPayload] === 'string'
346
- ) {
347
- configLabelKey = payloadPayload[
348
- key as keyof typeof payloadPayload
349
- ] as string;
350
- }
351
-
352
- return configLabelKey in config
353
- ? config[configLabelKey]
354
- : config[key as keyof typeof config];
355
- }
356
-
357
- export {
358
- ChartContainer,
359
- ChartLegend,
360
- ChartLegendContent,
361
- ChartStyle,
362
- ChartTooltip,
363
- ChartTooltipContent,
364
- useChart,
365
- };
@@ -1,28 +0,0 @@
1
- import type { ComponentConfig } from '@foundrykit/types';
2
-
3
- export const ComboboxConfig: ComponentConfig = {
4
- name: 'Combobox',
5
- description:
6
- 'A searchable single-select input that combines a popover with a filterable command list.',
7
- category: 'components',
8
- tags: ['combobox', 'select', 'search', 'interactive', 'form'],
9
- preview: {
10
- type: 'static',
11
- html: '<div class="flex h-9 w-[200px] items-center justify-between rounded-md border border-gray-300 bg-white px-3"><span class="text-sm text-gray-600">Select framework...</span><div class="h-4 w-4 opacity-50">⇅</div></div>',
12
- },
13
- variants: [
14
- {
15
- name: 'Default',
16
- description: 'Default combobox with searchable options',
17
- code: '<Combobox options={[{ value: "next", label: "Next.js" }]} placeholder="Select framework..." />',
18
- preview: {
19
- type: 'component',
20
- component: 'Combobox',
21
- props: {},
22
- },
23
- },
24
- ],
25
- dependencies: ['utils', 'primitives', 'command'],
26
- packageDependencies: ['lucide-react'],
27
- files: ['components/combobox/index.tsx'],
28
- };
@@ -1,111 +0,0 @@
1
- 'use client';
2
-
3
- import {
4
- Button,
5
- Popover,
6
- PopoverContent,
7
- PopoverTrigger,
8
- } from '@foundrykit/primitives';
9
- import { cn } from '@foundrykit/utils';
10
- import { CheckIcon, ChevronsUpDownIcon } from 'lucide-react';
11
- import * as React from 'react';
12
-
13
- import {
14
- Command,
15
- CommandEmpty,
16
- CommandGroup,
17
- CommandInput,
18
- CommandItem,
19
- CommandList,
20
- } from '../command/index.js';
21
-
22
- type ComboboxOption = {
23
- value: string;
24
- label: string;
25
- };
26
-
27
- /**
28
- * Searchable single-select combobox composed from `Popover` and `Command`.
29
- * `role="combobox"` takes no name from its text, so give it a label: `aria-label`
30
- * or an `id` paired with `<Label htmlFor>`.
31
- *
32
- * @example
33
- * ```tsx
34
- * <Combobox
35
- * options={[{ value: 'next', label: 'Next.js' }]}
36
- * value={value}
37
- * onValueChange={setValue}
38
- * placeholder='Select framework...'
39
- * />
40
- * ```
41
- */
42
- function Combobox({
43
- options,
44
- value,
45
- onValueChange,
46
- placeholder = 'Select an option...',
47
- id,
48
- 'aria-label': ariaLabel,
49
- }: {
50
- options: ComboboxOption[];
51
- value?: string;
52
- onValueChange?: (value: string) => void;
53
- placeholder?: string;
54
- /** Lets a `<Label htmlFor>` name the trigger. */
55
- id?: string;
56
- /** Names the trigger when there is no visible label. */
57
- 'aria-label'?: string;
58
- }) {
59
- const [open, setOpen] = React.useState(false);
60
-
61
- const selected = options.find(option => option.value === value);
62
-
63
- return (
64
- <Popover open={open} onOpenChange={setOpen}>
65
- <PopoverTrigger asChild>
66
- <Button
67
- data-slot='combobox-trigger'
68
- variant='outline'
69
- role='combobox'
70
- id={id}
71
- aria-label={ariaLabel}
72
- aria-expanded={open}
73
- className='w-[200px] justify-between'
74
- >
75
- {selected ? selected.label : placeholder}
76
- <ChevronsUpDownIcon className='ml-2 size-4 shrink-0 opacity-50' />
77
- </Button>
78
- </PopoverTrigger>
79
- <PopoverContent data-slot='combobox-content' className='w-[200px] p-0'>
80
- <Command>
81
- <CommandInput placeholder={placeholder} className='h-9' />
82
- <CommandList>
83
- <CommandEmpty>No option found.</CommandEmpty>
84
- <CommandGroup>
85
- {options.map(option => (
86
- <CommandItem
87
- key={option.value}
88
- value={option.value}
89
- onSelect={currentValue => {
90
- onValueChange?.(currentValue === value ? '' : currentValue);
91
- setOpen(false);
92
- }}
93
- >
94
- {option.label}
95
- <CheckIcon
96
- className={cn(
97
- 'ml-auto size-4',
98
- value === option.value ? 'opacity-100' : 'opacity-0'
99
- )}
100
- />
101
- </CommandItem>
102
- ))}
103
- </CommandGroup>
104
- </CommandList>
105
- </Command>
106
- </PopoverContent>
107
- </Popover>
108
- );
109
- }
110
-
111
- export { Combobox };