@loykin/datetime-range 0.0.1-dev.4 → 0.0.1
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/README.md +42 -0
- package/dist/UIAdapterContext-Bm35TZtL.d.cts +96 -0
- package/dist/UIAdapterContext-Bm35TZtL.d.ts +96 -0
- package/dist/adapters/shadcn.cjs +117 -0
- package/dist/adapters/shadcn.cjs.map +1 -0
- package/dist/adapters/shadcn.d.cts +41 -0
- package/dist/adapters/shadcn.d.ts +41 -0
- package/dist/adapters/shadcn.js +115 -0
- package/dist/adapters/shadcn.js.map +1 -0
- package/dist/index.cjs +412 -303
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -3
- package/dist/index.d.ts +36 -3
- package/dist/index.js +344 -237
- package/dist/index.js.map +1 -1
- package/dist/styles.css +226 -211
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -21,6 +21,48 @@ import '@loykin/datetime-range/styles'
|
|
|
21
21
|
/>
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
+
## UI Adapter
|
|
25
|
+
|
|
26
|
+
By default `DatetimeRange` renders with its own built-in `@base-ui/react`-backed
|
|
27
|
+
Button/Popover/Select/Tabs/Input/Switch/ScrollArea. If your app already has real
|
|
28
|
+
shadcn/ui components, pass `uiAdapter` to render with those instead — same
|
|
29
|
+
behavior, native look:
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { DatetimeRange } from '@loykin/datetime-range'
|
|
33
|
+
import { createShadcnAdapter } from '@loykin/datetime-range/adapters/shadcn'
|
|
34
|
+
import { Button } from '@/components/ui/button'
|
|
35
|
+
import { Popover, PopoverTrigger, PopoverContent } from '@/components/ui/popover'
|
|
36
|
+
import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from '@/components/ui/select'
|
|
37
|
+
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs'
|
|
38
|
+
import { Input } from '@/components/ui/input'
|
|
39
|
+
import { Switch } from '@/components/ui/switch'
|
|
40
|
+
|
|
41
|
+
// Build once at module scope — uiAdapter must be referentially stable, or the
|
|
42
|
+
// adapted subtree remounts on every render.
|
|
43
|
+
const shadcnAdapter = createShadcnAdapter({
|
|
44
|
+
Button, Popover, PopoverTrigger, PopoverContent,
|
|
45
|
+
Select, SelectTrigger, SelectValue, SelectContent, SelectItem,
|
|
46
|
+
Tabs, TabsList, TabsTrigger, TabsContent,
|
|
47
|
+
Input, Switch,
|
|
48
|
+
// ScrollArea is optional — omit it to keep the built-in one (TimePicker relies
|
|
49
|
+
// on a `viewportRef` contract a generic shadcn ScrollArea may not expose).
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
<DatetimeRange startTime={start} endTime={end} onChange={onChange} uiAdapter={shadcnAdapter} />
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`SidePanel` takes the same `uiAdapter` prop independently. Only
|
|
56
|
+
`createShadcnAdapter` ships today. For anything else, build a
|
|
57
|
+
`DatetimeRangeUIAdapter` by hand — every field is optional, and unset ones fall
|
|
58
|
+
back to the built-in implementation. Wrap a subtree in `DatetimeRangeProvider`
|
|
59
|
+
to apply one adapter to every `DatetimeRange`/`SidePanel` inside it without
|
|
60
|
+
passing `uiAdapter` on each.
|
|
61
|
+
|
|
62
|
+
Pair it with `calendarMode="inline"` to render the Absolute-mode calendar
|
|
63
|
+
always-expanded (shadcn-style) instead of behind a popover-in-popover — useful
|
|
64
|
+
for dashboard filter bars where a wide layout is already available.
|
|
65
|
+
|
|
24
66
|
React 18 and React 19 are supported. See the
|
|
25
67
|
[BaseKit repository](https://github.com/loykin/basekit) for the complete API,
|
|
26
68
|
theming tokens, and playground.
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { Button as Button$1 } from '@base-ui/react/button';
|
|
4
|
+
import { Popover as Popover$1 } from '@base-ui/react/popover';
|
|
5
|
+
import { Select as Select$1 } from '@base-ui/react/select';
|
|
6
|
+
import { Tabs as Tabs$1 } from '@base-ui/react/tabs';
|
|
7
|
+
import { Switch as Switch$1 } from '@base-ui/react/switch';
|
|
8
|
+
import { ScrollArea as ScrollArea$1 } from '@base-ui/react/scroll-area';
|
|
9
|
+
|
|
10
|
+
type ButtonVariant = 'default' | 'outline' | 'secondary' | 'ghost' | 'destructive' | 'link';
|
|
11
|
+
type ButtonSize = 'default' | 'xs' | 'sm' | 'lg' | 'icon' | 'icon-xs' | 'icon-sm' | 'icon-lg';
|
|
12
|
+
declare function Button({ className, variant, size, ...props }: Button$1.Props & {
|
|
13
|
+
variant?: ButtonVariant;
|
|
14
|
+
size?: ButtonSize;
|
|
15
|
+
}): React.JSX.Element;
|
|
16
|
+
|
|
17
|
+
declare function Popover({ ...props }: Popover$1.Root.Props): React.JSX.Element;
|
|
18
|
+
declare function PopoverTrigger({ ...props }: Popover$1.Trigger.Props): React.JSX.Element;
|
|
19
|
+
declare function PopoverContent({ className, align, alignOffset, side, sideOffset, disableAnchorTracking, collisionAvoidance, container, ...props }: Popover$1.Popup.Props & Pick<Popover$1.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'disableAnchorTracking' | 'collisionAvoidance'> & {
|
|
20
|
+
container?: Popover$1.Portal.Props['container'];
|
|
21
|
+
}): React.JSX.Element;
|
|
22
|
+
|
|
23
|
+
declare const Select: typeof Select$1.Root;
|
|
24
|
+
declare function SelectValue({ className, ...props }: Select$1.Value.Props): React.JSX.Element;
|
|
25
|
+
declare function SelectTrigger({ className, size, children, ...props }: Select$1.Trigger.Props & {
|
|
26
|
+
size?: 'sm' | 'default';
|
|
27
|
+
}): React.JSX.Element;
|
|
28
|
+
declare function SelectContent({ className, children, side, sideOffset, align, alignOffset, alignItemWithTrigger, ...props }: Select$1.Popup.Props & Pick<Select$1.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'alignItemWithTrigger'>): React.JSX.Element;
|
|
29
|
+
declare function SelectItem({ className, children, ...props }: Select$1.Item.Props): React.JSX.Element;
|
|
30
|
+
|
|
31
|
+
declare function Tabs({ className, orientation, ...props }: Tabs$1.Root.Props): React.JSX.Element;
|
|
32
|
+
declare function TabsList({ className, variant, ...props }: Tabs$1.List.Props & {
|
|
33
|
+
variant?: 'default' | 'line';
|
|
34
|
+
}): React.JSX.Element;
|
|
35
|
+
declare function TabsTrigger({ className, ...props }: Tabs$1.Tab.Props): React.JSX.Element;
|
|
36
|
+
declare function TabsContent({ className, ...props }: Tabs$1.Panel.Props): React.JSX.Element;
|
|
37
|
+
|
|
38
|
+
declare function Input({ className, type, ...props }: React.ComponentProps<'input'>): React.JSX.Element;
|
|
39
|
+
|
|
40
|
+
declare function Switch({ className, size, ...props }: Switch$1.Root.Props & {
|
|
41
|
+
size?: 'sm' | 'default';
|
|
42
|
+
}): React.JSX.Element;
|
|
43
|
+
|
|
44
|
+
declare function ScrollArea({ className, style, children, viewportRef, ...props }: ScrollArea$1.Root.Props & {
|
|
45
|
+
viewportRef?: React.Ref<HTMLDivElement>;
|
|
46
|
+
}): React.JSX.Element;
|
|
47
|
+
|
|
48
|
+
type ButtonProps = React__default.ComponentProps<typeof Button>;
|
|
49
|
+
type PopoverProps = React__default.ComponentProps<typeof Popover>;
|
|
50
|
+
type PopoverTriggerProps = React__default.ComponentProps<typeof PopoverTrigger>;
|
|
51
|
+
type PopoverContentProps = React__default.ComponentProps<typeof PopoverContent>;
|
|
52
|
+
type SelectProps = React__default.ComponentProps<typeof Select>;
|
|
53
|
+
type SelectTriggerProps = React__default.ComponentProps<typeof SelectTrigger>;
|
|
54
|
+
type SelectValueProps = React__default.ComponentProps<typeof SelectValue>;
|
|
55
|
+
type SelectContentProps = React__default.ComponentProps<typeof SelectContent>;
|
|
56
|
+
type SelectItemProps = React__default.ComponentProps<typeof SelectItem>;
|
|
57
|
+
type TabsProps = React__default.ComponentProps<typeof Tabs>;
|
|
58
|
+
type TabsListProps = React__default.ComponentProps<typeof TabsList>;
|
|
59
|
+
type TabsTriggerProps = React__default.ComponentProps<typeof TabsTrigger>;
|
|
60
|
+
type TabsContentProps = React__default.ComponentProps<typeof TabsContent>;
|
|
61
|
+
type InputProps = React__default.ComponentProps<typeof Input>;
|
|
62
|
+
type SwitchProps = React__default.ComponentProps<typeof Switch>;
|
|
63
|
+
type ScrollAreaProps = React__default.ComponentProps<typeof ScrollArea>;
|
|
64
|
+
/**
|
|
65
|
+
* Component-implementation slots DatetimeRange renders through. Every field is optional —
|
|
66
|
+
* an adapter only needs to supply the slots it wants to replace; anything omitted falls
|
|
67
|
+
* back to the built-in implementation.
|
|
68
|
+
*/
|
|
69
|
+
interface DatetimeRangeUIAdapter {
|
|
70
|
+
Button?: React__default.ComponentType<ButtonProps>;
|
|
71
|
+
Popover?: React__default.ComponentType<PopoverProps>;
|
|
72
|
+
PopoverTrigger?: React__default.ComponentType<PopoverTriggerProps>;
|
|
73
|
+
PopoverContent?: React__default.ComponentType<PopoverContentProps>;
|
|
74
|
+
Select?: React__default.ComponentType<SelectProps>;
|
|
75
|
+
SelectTrigger?: React__default.ComponentType<SelectTriggerProps>;
|
|
76
|
+
SelectValue?: React__default.ComponentType<SelectValueProps>;
|
|
77
|
+
SelectContent?: React__default.ComponentType<SelectContentProps>;
|
|
78
|
+
SelectItem?: React__default.ComponentType<SelectItemProps>;
|
|
79
|
+
Tabs?: React__default.ComponentType<TabsProps>;
|
|
80
|
+
TabsList?: React__default.ComponentType<TabsListProps>;
|
|
81
|
+
TabsTrigger?: React__default.ComponentType<TabsTriggerProps>;
|
|
82
|
+
TabsContent?: React__default.ComponentType<TabsContentProps>;
|
|
83
|
+
Input?: React__default.ComponentType<InputProps>;
|
|
84
|
+
Switch?: React__default.ComponentType<SwitchProps>;
|
|
85
|
+
ScrollArea?: React__default.ComponentType<ScrollAreaProps>;
|
|
86
|
+
}
|
|
87
|
+
type ResolvedDatetimeRangeUIAdapter = Required<DatetimeRangeUIAdapter>;
|
|
88
|
+
interface DatetimeRangeProviderProps {
|
|
89
|
+
adapter?: DatetimeRangeUIAdapter;
|
|
90
|
+
children: React__default.ReactNode;
|
|
91
|
+
}
|
|
92
|
+
/** Makes a `uiAdapter` ambient for every DatetimeRange/SidePanel instance nested below it. */
|
|
93
|
+
declare function DatetimeRangeProvider({ adapter, children }: DatetimeRangeProviderProps): React__default.JSX.Element;
|
|
94
|
+
declare function useDatetimeRangeUI(): ResolvedDatetimeRangeUIAdapter;
|
|
95
|
+
|
|
96
|
+
export { type DatetimeRangeUIAdapter as D, DatetimeRangeProvider as a, useDatetimeRangeUI as u };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { Button as Button$1 } from '@base-ui/react/button';
|
|
4
|
+
import { Popover as Popover$1 } from '@base-ui/react/popover';
|
|
5
|
+
import { Select as Select$1 } from '@base-ui/react/select';
|
|
6
|
+
import { Tabs as Tabs$1 } from '@base-ui/react/tabs';
|
|
7
|
+
import { Switch as Switch$1 } from '@base-ui/react/switch';
|
|
8
|
+
import { ScrollArea as ScrollArea$1 } from '@base-ui/react/scroll-area';
|
|
9
|
+
|
|
10
|
+
type ButtonVariant = 'default' | 'outline' | 'secondary' | 'ghost' | 'destructive' | 'link';
|
|
11
|
+
type ButtonSize = 'default' | 'xs' | 'sm' | 'lg' | 'icon' | 'icon-xs' | 'icon-sm' | 'icon-lg';
|
|
12
|
+
declare function Button({ className, variant, size, ...props }: Button$1.Props & {
|
|
13
|
+
variant?: ButtonVariant;
|
|
14
|
+
size?: ButtonSize;
|
|
15
|
+
}): React.JSX.Element;
|
|
16
|
+
|
|
17
|
+
declare function Popover({ ...props }: Popover$1.Root.Props): React.JSX.Element;
|
|
18
|
+
declare function PopoverTrigger({ ...props }: Popover$1.Trigger.Props): React.JSX.Element;
|
|
19
|
+
declare function PopoverContent({ className, align, alignOffset, side, sideOffset, disableAnchorTracking, collisionAvoidance, container, ...props }: Popover$1.Popup.Props & Pick<Popover$1.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'disableAnchorTracking' | 'collisionAvoidance'> & {
|
|
20
|
+
container?: Popover$1.Portal.Props['container'];
|
|
21
|
+
}): React.JSX.Element;
|
|
22
|
+
|
|
23
|
+
declare const Select: typeof Select$1.Root;
|
|
24
|
+
declare function SelectValue({ className, ...props }: Select$1.Value.Props): React.JSX.Element;
|
|
25
|
+
declare function SelectTrigger({ className, size, children, ...props }: Select$1.Trigger.Props & {
|
|
26
|
+
size?: 'sm' | 'default';
|
|
27
|
+
}): React.JSX.Element;
|
|
28
|
+
declare function SelectContent({ className, children, side, sideOffset, align, alignOffset, alignItemWithTrigger, ...props }: Select$1.Popup.Props & Pick<Select$1.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'alignItemWithTrigger'>): React.JSX.Element;
|
|
29
|
+
declare function SelectItem({ className, children, ...props }: Select$1.Item.Props): React.JSX.Element;
|
|
30
|
+
|
|
31
|
+
declare function Tabs({ className, orientation, ...props }: Tabs$1.Root.Props): React.JSX.Element;
|
|
32
|
+
declare function TabsList({ className, variant, ...props }: Tabs$1.List.Props & {
|
|
33
|
+
variant?: 'default' | 'line';
|
|
34
|
+
}): React.JSX.Element;
|
|
35
|
+
declare function TabsTrigger({ className, ...props }: Tabs$1.Tab.Props): React.JSX.Element;
|
|
36
|
+
declare function TabsContent({ className, ...props }: Tabs$1.Panel.Props): React.JSX.Element;
|
|
37
|
+
|
|
38
|
+
declare function Input({ className, type, ...props }: React.ComponentProps<'input'>): React.JSX.Element;
|
|
39
|
+
|
|
40
|
+
declare function Switch({ className, size, ...props }: Switch$1.Root.Props & {
|
|
41
|
+
size?: 'sm' | 'default';
|
|
42
|
+
}): React.JSX.Element;
|
|
43
|
+
|
|
44
|
+
declare function ScrollArea({ className, style, children, viewportRef, ...props }: ScrollArea$1.Root.Props & {
|
|
45
|
+
viewportRef?: React.Ref<HTMLDivElement>;
|
|
46
|
+
}): React.JSX.Element;
|
|
47
|
+
|
|
48
|
+
type ButtonProps = React__default.ComponentProps<typeof Button>;
|
|
49
|
+
type PopoverProps = React__default.ComponentProps<typeof Popover>;
|
|
50
|
+
type PopoverTriggerProps = React__default.ComponentProps<typeof PopoverTrigger>;
|
|
51
|
+
type PopoverContentProps = React__default.ComponentProps<typeof PopoverContent>;
|
|
52
|
+
type SelectProps = React__default.ComponentProps<typeof Select>;
|
|
53
|
+
type SelectTriggerProps = React__default.ComponentProps<typeof SelectTrigger>;
|
|
54
|
+
type SelectValueProps = React__default.ComponentProps<typeof SelectValue>;
|
|
55
|
+
type SelectContentProps = React__default.ComponentProps<typeof SelectContent>;
|
|
56
|
+
type SelectItemProps = React__default.ComponentProps<typeof SelectItem>;
|
|
57
|
+
type TabsProps = React__default.ComponentProps<typeof Tabs>;
|
|
58
|
+
type TabsListProps = React__default.ComponentProps<typeof TabsList>;
|
|
59
|
+
type TabsTriggerProps = React__default.ComponentProps<typeof TabsTrigger>;
|
|
60
|
+
type TabsContentProps = React__default.ComponentProps<typeof TabsContent>;
|
|
61
|
+
type InputProps = React__default.ComponentProps<typeof Input>;
|
|
62
|
+
type SwitchProps = React__default.ComponentProps<typeof Switch>;
|
|
63
|
+
type ScrollAreaProps = React__default.ComponentProps<typeof ScrollArea>;
|
|
64
|
+
/**
|
|
65
|
+
* Component-implementation slots DatetimeRange renders through. Every field is optional —
|
|
66
|
+
* an adapter only needs to supply the slots it wants to replace; anything omitted falls
|
|
67
|
+
* back to the built-in implementation.
|
|
68
|
+
*/
|
|
69
|
+
interface DatetimeRangeUIAdapter {
|
|
70
|
+
Button?: React__default.ComponentType<ButtonProps>;
|
|
71
|
+
Popover?: React__default.ComponentType<PopoverProps>;
|
|
72
|
+
PopoverTrigger?: React__default.ComponentType<PopoverTriggerProps>;
|
|
73
|
+
PopoverContent?: React__default.ComponentType<PopoverContentProps>;
|
|
74
|
+
Select?: React__default.ComponentType<SelectProps>;
|
|
75
|
+
SelectTrigger?: React__default.ComponentType<SelectTriggerProps>;
|
|
76
|
+
SelectValue?: React__default.ComponentType<SelectValueProps>;
|
|
77
|
+
SelectContent?: React__default.ComponentType<SelectContentProps>;
|
|
78
|
+
SelectItem?: React__default.ComponentType<SelectItemProps>;
|
|
79
|
+
Tabs?: React__default.ComponentType<TabsProps>;
|
|
80
|
+
TabsList?: React__default.ComponentType<TabsListProps>;
|
|
81
|
+
TabsTrigger?: React__default.ComponentType<TabsTriggerProps>;
|
|
82
|
+
TabsContent?: React__default.ComponentType<TabsContentProps>;
|
|
83
|
+
Input?: React__default.ComponentType<InputProps>;
|
|
84
|
+
Switch?: React__default.ComponentType<SwitchProps>;
|
|
85
|
+
ScrollArea?: React__default.ComponentType<ScrollAreaProps>;
|
|
86
|
+
}
|
|
87
|
+
type ResolvedDatetimeRangeUIAdapter = Required<DatetimeRangeUIAdapter>;
|
|
88
|
+
interface DatetimeRangeProviderProps {
|
|
89
|
+
adapter?: DatetimeRangeUIAdapter;
|
|
90
|
+
children: React__default.ReactNode;
|
|
91
|
+
}
|
|
92
|
+
/** Makes a `uiAdapter` ambient for every DatetimeRange/SidePanel instance nested below it. */
|
|
93
|
+
declare function DatetimeRangeProvider({ adapter, children }: DatetimeRangeProviderProps): React__default.JSX.Element;
|
|
94
|
+
declare function useDatetimeRangeUI(): ResolvedDatetimeRangeUIAdapter;
|
|
95
|
+
|
|
96
|
+
export { type DatetimeRangeUIAdapter as D, DatetimeRangeProvider as a, useDatetimeRangeUI as u };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
|
|
5
|
+
// src/adapters/shadcn.tsx
|
|
6
|
+
function resolveContainer(container) {
|
|
7
|
+
if (container && typeof container === "object" && "current" in container) {
|
|
8
|
+
return container.current;
|
|
9
|
+
}
|
|
10
|
+
return container;
|
|
11
|
+
}
|
|
12
|
+
var buttonSizeMap = {
|
|
13
|
+
default: "default",
|
|
14
|
+
xs: "sm",
|
|
15
|
+
sm: "sm",
|
|
16
|
+
lg: "lg",
|
|
17
|
+
icon: "icon",
|
|
18
|
+
"icon-xs": "icon-sm",
|
|
19
|
+
"icon-sm": "icon-sm",
|
|
20
|
+
"icon-lg": "icon-lg"
|
|
21
|
+
};
|
|
22
|
+
function createShadcnAdapter(components) {
|
|
23
|
+
const {
|
|
24
|
+
Button: ShadcnButton,
|
|
25
|
+
Popover: ShadcnPopover,
|
|
26
|
+
PopoverTrigger: ShadcnPopoverTrigger,
|
|
27
|
+
PopoverContent: ShadcnPopoverContent,
|
|
28
|
+
Select: ShadcnSelect,
|
|
29
|
+
SelectTrigger: ShadcnSelectTrigger,
|
|
30
|
+
SelectValue: ShadcnSelectValue,
|
|
31
|
+
SelectContent: ShadcnSelectContent,
|
|
32
|
+
SelectItem: ShadcnSelectItem,
|
|
33
|
+
Tabs: ShadcnTabs,
|
|
34
|
+
TabsList: ShadcnTabsList,
|
|
35
|
+
TabsTrigger: ShadcnTabsTrigger,
|
|
36
|
+
TabsContent: ShadcnTabsContent,
|
|
37
|
+
Switch: ShadcnSwitch,
|
|
38
|
+
Input: ShadcnInput,
|
|
39
|
+
ScrollArea: ShadcnScrollArea
|
|
40
|
+
} = components;
|
|
41
|
+
function Button({ size = "default", ...props }) {
|
|
42
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ShadcnButton, { size: buttonSizeMap[size], ...props });
|
|
43
|
+
}
|
|
44
|
+
function Popover(props) {
|
|
45
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ShadcnPopover, { ...props });
|
|
46
|
+
}
|
|
47
|
+
function PopoverTrigger({ render, disabled }) {
|
|
48
|
+
const rendered = typeof render === "function" ? render({}, { disabled: !!disabled, open: false }) : render;
|
|
49
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ShadcnPopoverTrigger, { asChild: true, disabled, children: rendered });
|
|
50
|
+
}
|
|
51
|
+
function PopoverContent({
|
|
52
|
+
disableAnchorTracking: _disableAnchorTracking,
|
|
53
|
+
collisionAvoidance: _collisionAvoidance,
|
|
54
|
+
container,
|
|
55
|
+
...props
|
|
56
|
+
}) {
|
|
57
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ShadcnPopoverContent, { ...props, container: resolveContainer(container) });
|
|
58
|
+
}
|
|
59
|
+
function Select(props) {
|
|
60
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ShadcnSelect, { ...props });
|
|
61
|
+
}
|
|
62
|
+
function SelectTrigger({ size: _size, ...props }) {
|
|
63
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ShadcnSelectTrigger, { ...props });
|
|
64
|
+
}
|
|
65
|
+
function SelectValue(props) {
|
|
66
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ShadcnSelectValue, { ...props });
|
|
67
|
+
}
|
|
68
|
+
function SelectContent({ alignItemWithTrigger: _alignItemWithTrigger, ...props }) {
|
|
69
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ShadcnSelectContent, { ...props });
|
|
70
|
+
}
|
|
71
|
+
function SelectItem(props) {
|
|
72
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ShadcnSelectItem, { ...props });
|
|
73
|
+
}
|
|
74
|
+
function Tabs(props) {
|
|
75
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ShadcnTabs, { ...props });
|
|
76
|
+
}
|
|
77
|
+
function TabsList({ variant: _variant, ...props }) {
|
|
78
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ShadcnTabsList, { ...props });
|
|
79
|
+
}
|
|
80
|
+
function TabsTrigger(props) {
|
|
81
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ShadcnTabsTrigger, { ...props });
|
|
82
|
+
}
|
|
83
|
+
function TabsContent(props) {
|
|
84
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ShadcnTabsContent, { ...props });
|
|
85
|
+
}
|
|
86
|
+
function Switch({ size: _size, ...props }) {
|
|
87
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ShadcnSwitch, { ...props });
|
|
88
|
+
}
|
|
89
|
+
function Input(props) {
|
|
90
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ShadcnInput, { ...props });
|
|
91
|
+
}
|
|
92
|
+
function ScrollArea(props) {
|
|
93
|
+
return ShadcnScrollArea ? /* @__PURE__ */ jsxRuntime.jsx(ShadcnScrollArea, { ...props }) : null;
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
Button,
|
|
97
|
+
Popover,
|
|
98
|
+
PopoverTrigger,
|
|
99
|
+
PopoverContent,
|
|
100
|
+
Select,
|
|
101
|
+
SelectTrigger,
|
|
102
|
+
SelectValue,
|
|
103
|
+
SelectContent,
|
|
104
|
+
SelectItem,
|
|
105
|
+
Tabs,
|
|
106
|
+
TabsList,
|
|
107
|
+
TabsTrigger,
|
|
108
|
+
TabsContent,
|
|
109
|
+
Switch,
|
|
110
|
+
Input,
|
|
111
|
+
...ShadcnScrollArea ? { ScrollArea } : {}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
exports.createShadcnAdapter = createShadcnAdapter;
|
|
116
|
+
//# sourceMappingURL=shadcn.cjs.map
|
|
117
|
+
//# sourceMappingURL=shadcn.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/shadcn.tsx"],"names":["jsx"],"mappings":";;;;;AAgDA,SAAS,iBAAiB,SAAA,EAA4F;AACpH,EAAA,IAAI,SAAA,IAAa,OAAO,SAAA,KAAc,QAAA,IAAY,aAAa,SAAA,EAAW;AACxE,IAAA,OAAO,SAAA,CAAU,OAAA;AAAA,EACnB;AACA,EAAA,OAAO,SAAA;AACT;AAEA,IAAM,aAAA,GAAkE;AAAA,EACtE,OAAA,EAAS,SAAA;AAAA,EACT,EAAA,EAAI,IAAA;AAAA,EACJ,EAAA,EAAI,IAAA;AAAA,EACJ,EAAA,EAAI,IAAA;AAAA,EACJ,IAAA,EAAM,MAAA;AAAA,EACN,SAAA,EA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EAAkB;AAChE,IAAA,uBAAOA,cAAA,CAAC,cAAA,EAAA,EAAgB,GAAG,KAAA,EAAO,CAAA;AAAA,EACpC;AAEA,EAAA,SAAS,YAAY,KAAA,EAAyB;AAC5C,IAAA,uBAAOA,cAAA,CAAC,iBAAA,EAAA,EAAmB,GAAG,KAAA,EAAO,CAAA;AAAA,EACvC;AAEA,EAAA,SAAS,YAAY,KAAA,EAAyB;AAC5C,IAAA,uBAAOA,cAAA,CAAC,iBAAA,EAAA,EAAmB,GAAG,KAAA,EAAO,CAAA;AAAA,EACvC;AAEA,EAAA,SAAS,OAAO,EAAE,IAAA,EAAM,KAAA,EAAO,GAAG,OAAM,EAAgB;AACtD,IAAA,uBAAOA,cAAA,CAAC,YAAA,EAAA,EAAc,GAAG,KAAA,EAAO,CAAA;AAAA,EAClC;AAEA,EAAA,SAAS,MAAM,KAAA,EAAmB;AAChC,IAAA,uBAAOA,cAAA,CAAC,WAAA,EAAA,EAAa,GAAG,KAAA,EAAO,CAAA;AAAA,EACjC;AAEA,EAAA,SAAS,WAAW,KAAA,EAAwB;AAC1C,IAAA,OAAO,gBAAA,mBAAmBA,cAAA,CAAC,gBAAA,EAAA,EAAkB,GAAG,OAAO,CAAA,GAAK,IAAA;AAAA,EAC9D;AAEA,EAAA,OAAO;AAAA,IACL,MAAA;AAAA,IACA,OAAA;AAAA,IACA,cAAA;AAAA,IACA,cAAA;AAAA,IACA,MAAA;AAAA,IACA,aAAA;AAAA,IACA,WAAA;AAAA,IACA,aAAA;AAAA,IACA,UAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,IACA,WAAA;AAAA,IACA,MAAA;AAAA,IACA,KAAA;AAAA,IACA,GAAI,gBAAA,GAAmB,EAAE,UAAA,KAAe;AAAC,GAC3C;AACF","file":"shadcn.cjs","sourcesContent":["import type { ElementType } from 'react';\nimport type {\n DatetimeRangeUIAdapter,\n ButtonProps,\n PopoverProps,\n PopoverTriggerProps,\n PopoverContentProps,\n SelectProps,\n SelectTriggerProps,\n SelectValueProps,\n SelectContentProps,\n SelectItemProps,\n TabsProps,\n TabsListProps,\n TabsTriggerProps,\n TabsContentProps,\n InputProps,\n SwitchProps,\n ScrollAreaProps,\n} from '../core/UIAdapterContext';\n\nexport interface ShadcnAdapterComponents {\n Button: ElementType;\n Popover: ElementType;\n PopoverTrigger: ElementType;\n PopoverContent: ElementType;\n Select: ElementType;\n SelectTrigger: ElementType;\n SelectValue: ElementType;\n SelectContent: ElementType;\n SelectItem: ElementType;\n Tabs: ElementType;\n TabsList: ElementType;\n TabsTrigger: ElementType;\n TabsContent: ElementType;\n Switch: ElementType;\n Input: ElementType;\n /**\n * Optional. `TimePicker`'s hour/minute/second lists scroll themselves to the selected\n * value via a `viewportRef` prop — a contract a generic shadcn ScrollArea may not expose.\n * Omit to keep the built-in scroll-to-selection behavior; only pass one that forwards\n * `viewportRef` to its scrollable viewport element.\n */\n ScrollArea?: ElementType;\n}\n\n// base-ui's `container` prop accepts a ref OR an element; Radix's Portal only accepts an\n// element. Unwrap so `portalContainer` (e.g. for a scoped custom theme) works either way.\nfunction resolveContainer(container: PopoverContentProps['container']): Element | DocumentFragment | null | undefined {\n if (container && typeof container === 'object' && 'current' in container) {\n return container.current as Element | null;\n }\n return container as Element | DocumentFragment | null | undefined;\n}\n\nconst buttonSizeMap: Record<NonNullable<ButtonProps['size']>, string> = {\n default: 'default',\n xs: 'sm',\n sm: 'sm',\n lg: 'lg',\n icon: 'icon',\n 'icon-xs': 'icon-sm',\n 'icon-sm': 'icon-sm',\n 'icon-lg': 'icon-lg',\n};\n\n/**\n * Bridges the consumer's own real shadcn/ui components (imported from their app, e.g.\n * `@/components/ui/button`) into a `DatetimeRangeUIAdapter` so `<DatetimeRange uiAdapter={...} />`\n * renders with them instead of the built-in @base-ui/react-backed components.\n */\nexport function createShadcnAdapter(components: ShadcnAdapterComponents): DatetimeRangeUIAdapter {\n const {\n Button: ShadcnButton,\n Popover: ShadcnPopover,\n PopoverTrigger: ShadcnPopoverTrigger,\n PopoverContent: ShadcnPopoverContent,\n Select: ShadcnSelect,\n SelectTrigger: ShadcnSelectTrigger,\n SelectValue: ShadcnSelectValue,\n SelectContent: ShadcnSelectContent,\n SelectItem: ShadcnSelectItem,\n Tabs: ShadcnTabs,\n TabsList: ShadcnTabsList,\n TabsTrigger: ShadcnTabsTrigger,\n TabsContent: ShadcnTabsContent,\n Switch: ShadcnSwitch,\n Input: ShadcnInput,\n ScrollArea: ShadcnScrollArea,\n } = components;\n\n function Button({ size = 'default', ...props }: ButtonProps) {\n return <ShadcnButton size={buttonSizeMap[size]} {...props} />;\n }\n\n function Popover(props: PopoverProps) {\n return <ShadcnPopover {...props} />;\n }\n\n function PopoverTrigger({ render, disabled }: PopoverTriggerProps) {\n // base-ui's render-prop contract: `render(props, state) => ReactElement`, or a bare\n // element. Radix's `asChild` clones whatever element we hand it and injects its own\n // onClick/aria/ref regardless of the placeholder props/state below.\n const rendered = typeof render === 'function' ? render({}, { disabled: !!disabled, open: false }) : render;\n\n return (\n <ShadcnPopoverTrigger asChild disabled={disabled}>\n {rendered}\n </ShadcnPopoverTrigger>\n );\n }\n\n function PopoverContent({\n disableAnchorTracking: _disableAnchorTracking,\n collisionAvoidance: _collisionAvoidance,\n container,\n ...props\n }: PopoverContentProps) {\n // disableAnchorTracking/collisionAvoidance are base-ui-only Positioner props with no\n // Radix equivalent — drop them so they don't leak onto a DOM node. container is real\n // (portalContainer support) but base-ui accepts a ref OR an element while Radix's\n // Portal only accepts an element, so unwrap a ref before forwarding it.\n return <ShadcnPopoverContent {...props} container={resolveContainer(container)} />;\n }\n\n function Select(props: SelectProps) {\n return <ShadcnSelect {...props} />;\n }\n\n function SelectTrigger({ size: _size, ...props }: SelectTriggerProps) {\n return <ShadcnSelectTrigger {...props} />;\n }\n\n function SelectValue(props: SelectValueProps) {\n return <ShadcnSelectValue {...props} />;\n }\n\n function SelectContent({ alignItemWithTrigger: _alignItemWithTrigger, ...props }: SelectContentProps) {\n // alignItemWithTrigger is a base-ui-only Positioner prop with no Radix equivalent.\n return <ShadcnSelectContent {...props} />;\n }\n\n function SelectItem(props: SelectItemProps) {\n return <ShadcnSelectItem {...props} />;\n }\n\n function Tabs(props: TabsProps) {\n return <ShadcnTabs {...props} />;\n }\n\n function TabsList({ variant: _variant, ...props }: TabsListProps) {\n return <ShadcnTabsList {...props} />;\n }\n\n function TabsTrigger(props: TabsTriggerProps) {\n return <ShadcnTabsTrigger {...props} />;\n }\n\n function TabsContent(props: TabsContentProps) {\n return <ShadcnTabsContent {...props} />;\n }\n\n function Switch({ size: _size, ...props }: SwitchProps) {\n return <ShadcnSwitch {...props} />;\n }\n\n function Input(props: InputProps) {\n return <ShadcnInput {...props} />;\n }\n\n function ScrollArea(props: ScrollAreaProps) {\n return ShadcnScrollArea ? <ShadcnScrollArea {...props} /> : null;\n }\n\n return {\n Button,\n Popover,\n PopoverTrigger,\n PopoverContent,\n Select,\n SelectTrigger,\n SelectValue,\n SelectContent,\n SelectItem,\n Tabs,\n TabsList,\n TabsTrigger,\n TabsContent,\n Switch,\n Input,\n ...(ShadcnScrollArea ? { ScrollArea } : {}),\n };\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ElementType } from 'react';
|
|
2
|
+
import { D as DatetimeRangeUIAdapter } from '../UIAdapterContext-Bm35TZtL.cjs';
|
|
3
|
+
import '@base-ui/react/button';
|
|
4
|
+
import '@base-ui/react/popover';
|
|
5
|
+
import '@base-ui/react/select';
|
|
6
|
+
import '@base-ui/react/tabs';
|
|
7
|
+
import '@base-ui/react/switch';
|
|
8
|
+
import '@base-ui/react/scroll-area';
|
|
9
|
+
|
|
10
|
+
interface ShadcnAdapterComponents {
|
|
11
|
+
Button: ElementType;
|
|
12
|
+
Popover: ElementType;
|
|
13
|
+
PopoverTrigger: ElementType;
|
|
14
|
+
PopoverContent: ElementType;
|
|
15
|
+
Select: ElementType;
|
|
16
|
+
SelectTrigger: ElementType;
|
|
17
|
+
SelectValue: ElementType;
|
|
18
|
+
SelectContent: ElementType;
|
|
19
|
+
SelectItem: ElementType;
|
|
20
|
+
Tabs: ElementType;
|
|
21
|
+
TabsList: ElementType;
|
|
22
|
+
TabsTrigger: ElementType;
|
|
23
|
+
TabsContent: ElementType;
|
|
24
|
+
Switch: ElementType;
|
|
25
|
+
Input: ElementType;
|
|
26
|
+
/**
|
|
27
|
+
* Optional. `TimePicker`'s hour/minute/second lists scroll themselves to the selected
|
|
28
|
+
* value via a `viewportRef` prop — a contract a generic shadcn ScrollArea may not expose.
|
|
29
|
+
* Omit to keep the built-in scroll-to-selection behavior; only pass one that forwards
|
|
30
|
+
* `viewportRef` to its scrollable viewport element.
|
|
31
|
+
*/
|
|
32
|
+
ScrollArea?: ElementType;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Bridges the consumer's own real shadcn/ui components (imported from their app, e.g.
|
|
36
|
+
* `@/components/ui/button`) into a `DatetimeRangeUIAdapter` so `<DatetimeRange uiAdapter={...} />`
|
|
37
|
+
* renders with them instead of the built-in @base-ui/react-backed components.
|
|
38
|
+
*/
|
|
39
|
+
declare function createShadcnAdapter(components: ShadcnAdapterComponents): DatetimeRangeUIAdapter;
|
|
40
|
+
|
|
41
|
+
export { type ShadcnAdapterComponents, createShadcnAdapter };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ElementType } from 'react';
|
|
2
|
+
import { D as DatetimeRangeUIAdapter } from '../UIAdapterContext-Bm35TZtL.js';
|
|
3
|
+
import '@base-ui/react/button';
|
|
4
|
+
import '@base-ui/react/popover';
|
|
5
|
+
import '@base-ui/react/select';
|
|
6
|
+
import '@base-ui/react/tabs';
|
|
7
|
+
import '@base-ui/react/switch';
|
|
8
|
+
import '@base-ui/react/scroll-area';
|
|
9
|
+
|
|
10
|
+
interface ShadcnAdapterComponents {
|
|
11
|
+
Button: ElementType;
|
|
12
|
+
Popover: ElementType;
|
|
13
|
+
PopoverTrigger: ElementType;
|
|
14
|
+
PopoverContent: ElementType;
|
|
15
|
+
Select: ElementType;
|
|
16
|
+
SelectTrigger: ElementType;
|
|
17
|
+
SelectValue: ElementType;
|
|
18
|
+
SelectContent: ElementType;
|
|
19
|
+
SelectItem: ElementType;
|
|
20
|
+
Tabs: ElementType;
|
|
21
|
+
TabsList: ElementType;
|
|
22
|
+
TabsTrigger: ElementType;
|
|
23
|
+
TabsContent: ElementType;
|
|
24
|
+
Switch: ElementType;
|
|
25
|
+
Input: ElementType;
|
|
26
|
+
/**
|
|
27
|
+
* Optional. `TimePicker`'s hour/minute/second lists scroll themselves to the selected
|
|
28
|
+
* value via a `viewportRef` prop — a contract a generic shadcn ScrollArea may not expose.
|
|
29
|
+
* Omit to keep the built-in scroll-to-selection behavior; only pass one that forwards
|
|
30
|
+
* `viewportRef` to its scrollable viewport element.
|
|
31
|
+
*/
|
|
32
|
+
ScrollArea?: ElementType;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Bridges the consumer's own real shadcn/ui components (imported from their app, e.g.
|
|
36
|
+
* `@/components/ui/button`) into a `DatetimeRangeUIAdapter` so `<DatetimeRange uiAdapter={...} />`
|
|
37
|
+
* renders with them instead of the built-in @base-ui/react-backed components.
|
|
38
|
+
*/
|
|
39
|
+
declare function createShadcnAdapter(components: ShadcnAdapterComponents): DatetimeRangeUIAdapter;
|
|
40
|
+
|
|
41
|
+
export { type ShadcnAdapterComponents, createShadcnAdapter };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
// src/adapters/shadcn.tsx
|
|
4
|
+
function resolveContainer(container) {
|
|
5
|
+
if (container && typeof container === "object" && "current" in container) {
|
|
6
|
+
return container.current;
|
|
7
|
+
}
|
|
8
|
+
return container;
|
|
9
|
+
}
|
|
10
|
+
var buttonSizeMap = {
|
|
11
|
+
default: "default",
|
|
12
|
+
xs: "sm",
|
|
13
|
+
sm: "sm",
|
|
14
|
+
lg: "lg",
|
|
15
|
+
icon: "icon",
|
|
16
|
+
"icon-xs": "icon-sm",
|
|
17
|
+
"icon-sm": "icon-sm",
|
|
18
|
+
"icon-lg": "icon-lg"
|
|
19
|
+
};
|
|
20
|
+
function createShadcnAdapter(components) {
|
|
21
|
+
const {
|
|
22
|
+
Button: ShadcnButton,
|
|
23
|
+
Popover: ShadcnPopover,
|
|
24
|
+
PopoverTrigger: ShadcnPopoverTrigger,
|
|
25
|
+
PopoverContent: ShadcnPopoverContent,
|
|
26
|
+
Select: ShadcnSelect,
|
|
27
|
+
SelectTrigger: ShadcnSelectTrigger,
|
|
28
|
+
SelectValue: ShadcnSelectValue,
|
|
29
|
+
SelectContent: ShadcnSelectContent,
|
|
30
|
+
SelectItem: ShadcnSelectItem,
|
|
31
|
+
Tabs: ShadcnTabs,
|
|
32
|
+
TabsList: ShadcnTabsList,
|
|
33
|
+
TabsTrigger: ShadcnTabsTrigger,
|
|
34
|
+
TabsContent: ShadcnTabsContent,
|
|
35
|
+
Switch: ShadcnSwitch,
|
|
36
|
+
Input: ShadcnInput,
|
|
37
|
+
ScrollArea: ShadcnScrollArea
|
|
38
|
+
} = components;
|
|
39
|
+
function Button({ size = "default", ...props }) {
|
|
40
|
+
return /* @__PURE__ */ jsx(ShadcnButton, { size: buttonSizeMap[size], ...props });
|
|
41
|
+
}
|
|
42
|
+
function Popover(props) {
|
|
43
|
+
return /* @__PURE__ */ jsx(ShadcnPopover, { ...props });
|
|
44
|
+
}
|
|
45
|
+
function PopoverTrigger({ render, disabled }) {
|
|
46
|
+
const rendered = typeof render === "function" ? render({}, { disabled: !!disabled, open: false }) : render;
|
|
47
|
+
return /* @__PURE__ */ jsx(ShadcnPopoverTrigger, { asChild: true, disabled, children: rendered });
|
|
48
|
+
}
|
|
49
|
+
function PopoverContent({
|
|
50
|
+
disableAnchorTracking: _disableAnchorTracking,
|
|
51
|
+
collisionAvoidance: _collisionAvoidance,
|
|
52
|
+
container,
|
|
53
|
+
...props
|
|
54
|
+
}) {
|
|
55
|
+
return /* @__PURE__ */ jsx(ShadcnPopoverContent, { ...props, container: resolveContainer(container) });
|
|
56
|
+
}
|
|
57
|
+
function Select(props) {
|
|
58
|
+
return /* @__PURE__ */ jsx(ShadcnSelect, { ...props });
|
|
59
|
+
}
|
|
60
|
+
function SelectTrigger({ size: _size, ...props }) {
|
|
61
|
+
return /* @__PURE__ */ jsx(ShadcnSelectTrigger, { ...props });
|
|
62
|
+
}
|
|
63
|
+
function SelectValue(props) {
|
|
64
|
+
return /* @__PURE__ */ jsx(ShadcnSelectValue, { ...props });
|
|
65
|
+
}
|
|
66
|
+
function SelectContent({ alignItemWithTrigger: _alignItemWithTrigger, ...props }) {
|
|
67
|
+
return /* @__PURE__ */ jsx(ShadcnSelectContent, { ...props });
|
|
68
|
+
}
|
|
69
|
+
function SelectItem(props) {
|
|
70
|
+
return /* @__PURE__ */ jsx(ShadcnSelectItem, { ...props });
|
|
71
|
+
}
|
|
72
|
+
function Tabs(props) {
|
|
73
|
+
return /* @__PURE__ */ jsx(ShadcnTabs, { ...props });
|
|
74
|
+
}
|
|
75
|
+
function TabsList({ variant: _variant, ...props }) {
|
|
76
|
+
return /* @__PURE__ */ jsx(ShadcnTabsList, { ...props });
|
|
77
|
+
}
|
|
78
|
+
function TabsTrigger(props) {
|
|
79
|
+
return /* @__PURE__ */ jsx(ShadcnTabsTrigger, { ...props });
|
|
80
|
+
}
|
|
81
|
+
function TabsContent(props) {
|
|
82
|
+
return /* @__PURE__ */ jsx(ShadcnTabsContent, { ...props });
|
|
83
|
+
}
|
|
84
|
+
function Switch({ size: _size, ...props }) {
|
|
85
|
+
return /* @__PURE__ */ jsx(ShadcnSwitch, { ...props });
|
|
86
|
+
}
|
|
87
|
+
function Input(props) {
|
|
88
|
+
return /* @__PURE__ */ jsx(ShadcnInput, { ...props });
|
|
89
|
+
}
|
|
90
|
+
function ScrollArea(props) {
|
|
91
|
+
return ShadcnScrollArea ? /* @__PURE__ */ jsx(ShadcnScrollArea, { ...props }) : null;
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
Button,
|
|
95
|
+
Popover,
|
|
96
|
+
PopoverTrigger,
|
|
97
|
+
PopoverContent,
|
|
98
|
+
Select,
|
|
99
|
+
SelectTrigger,
|
|
100
|
+
SelectValue,
|
|
101
|
+
SelectContent,
|
|
102
|
+
SelectItem,
|
|
103
|
+
Tabs,
|
|
104
|
+
TabsList,
|
|
105
|
+
TabsTrigger,
|
|
106
|
+
TabsContent,
|
|
107
|
+
Switch,
|
|
108
|
+
Input,
|
|
109
|
+
...ShadcnScrollArea ? { ScrollArea } : {}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export { createShadcnAdapter };
|
|
114
|
+
//# sourceMappingURL=shadcn.js.map
|
|
115
|
+
//# sourceMappingURL=shadcn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/shadcn.tsx"],"names":[],"mappings":";;;AAgDA,SAAS,iBAAiB,SAAA,EAA4F;AACpH,EAAA,IAAI,SAAA,IAAa,OAAO,SAAA,KAAc,QAAA,IAAY,aAAa,SAAA,EAAW;AACxE,IAAA,OAAO,SAAA,CAAU,OAAA;AAAA,EACnB;AACA,EAAA,OAAO,SAAA;AACT;AAEA,IAAM,aAAA,GAAkE;AAAA,EACtE,OAAA,EAAS,SAAA;AAAA,EACT,EAAA,EAAI,IAAA;AAAA,EACJ,EAAA,EAAI,IAAA;AAAA,EACJ,EAAA,EAAI,IAAA;AAAA,EACJ,IAAA,EAAM,MAAA;AAAA,EACN,SAAA,EAAW,SAAA;AAAA,EACX,SAAA,EAAW,SAAA;AAAA,EACX,SAAA,EAAW;AACb,CAAA;AAOO,SAAS,oBAAoB,UAAA,EAA6D;AAC/F,EAAA,MAAM;AAAA,IACJ,MAAA,EAAQ,YAAA;AAAA,IACR,OAAA,EAAS,aAAA;AAAA,IACT,cAAA,EAAgB,oBAAA;AAAA,I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AAS,YAAY,KAAA,EAAyB;AAC5C,IAAA,uBAAO,GAAA,CAAC,iBAAA,EAAA,EAAmB,GAAG,KAAA,EAAO,CAAA;AAAA,EACvC;AAEA,EAAA,SAAS,OAAO,EAAE,IAAA,EAAM,KAAA,EAAO,GAAG,OAAM,EAAgB;AACtD,IAAA,uBAAO,GAAA,CAAC,YAAA,EAAA,EAAc,GAAG,KAAA,EAAO,CAAA;AAAA,EAClC;AAEA,EAAA,SAAS,MAAM,KAAA,EAAmB;AAChC,IAAA,uBAAO,GAAA,CAAC,WAAA,EAAA,EAAa,GAAG,KAAA,EAAO,CAAA;AAAA,EACjC;AAEA,EAAA,SAAS,WAAW,KAAA,EAAwB;AAC1C,IAAA,OAAO,gBAAA,mBAAmB,GAAA,CAAC,gBAAA,EAAA,EAAkB,GAAG,OAAO,CAAA,GAAK,IAAA;AAAA,EAC9D;AAEA,EAAA,OAAO;AAAA,IACL,MAAA;AAAA,IACA,OAAA;AAAA,IACA,cAAA;AAAA,IACA,cAAA;AAAA,IACA,MAAA;AAAA,IACA,aAAA;AAAA,IACA,WAAA;AAAA,IACA,aAAA;AAAA,IACA,UAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,IACA,WAAA;AAAA,IACA,MAAA;AAAA,IACA,KAAA;AAAA,IACA,GAAI,gBAAA,GAAmB,EAAE,UAAA,KAAe;AAAC,GAC3C;AACF","file":"shadcn.js","sourcesContent":["import type { ElementType } from 'react';\nimport type {\n DatetimeRangeUIAdapter,\n ButtonProps,\n PopoverProps,\n PopoverTriggerProps,\n PopoverContentProps,\n SelectProps,\n SelectTriggerProps,\n SelectValueProps,\n SelectContentProps,\n SelectItemProps,\n TabsProps,\n TabsListProps,\n TabsTriggerProps,\n TabsContentProps,\n InputProps,\n SwitchProps,\n ScrollAreaProps,\n} from '../core/UIAdapterContext';\n\nexport interface ShadcnAdapterComponents {\n Button: ElementType;\n Popover: ElementType;\n PopoverTrigger: ElementType;\n PopoverContent: ElementType;\n Select: ElementType;\n SelectTrigger: ElementType;\n SelectValue: ElementType;\n SelectContent: ElementType;\n SelectItem: ElementType;\n Tabs: ElementType;\n TabsList: ElementType;\n TabsTrigger: ElementType;\n TabsContent: ElementType;\n Switch: ElementType;\n Input: ElementType;\n /**\n * Optional. `TimePicker`'s hour/minute/second lists scroll themselves to the selected\n * value via a `viewportRef` prop — a contract a generic shadcn ScrollArea may not expose.\n * Omit to keep the built-in scroll-to-selection behavior; only pass one that forwards\n * `viewportRef` to its scrollable viewport element.\n */\n ScrollArea?: ElementType;\n}\n\n// base-ui's `container` prop accepts a ref OR an element; Radix's Portal only accepts an\n// element. Unwrap so `portalContainer` (e.g. for a scoped custom theme) works either way.\nfunction resolveContainer(container: PopoverContentProps['container']): Element | DocumentFragment | null | undefined {\n if (container && typeof container === 'object' && 'current' in container) {\n return container.current as Element | null;\n }\n return container as Element | DocumentFragment | null | undefined;\n}\n\nconst buttonSizeMap: Record<NonNullable<ButtonProps['size']>, string> = {\n default: 'default',\n xs: 'sm',\n sm: 'sm',\n lg: 'lg',\n icon: 'icon',\n 'icon-xs': 'icon-sm',\n 'icon-sm': 'icon-sm',\n 'icon-lg': 'icon-lg',\n};\n\n/**\n * Bridges the consumer's own real shadcn/ui components (imported from their app, e.g.\n * `@/components/ui/button`) into a `DatetimeRangeUIAdapter` so `<DatetimeRange uiAdapter={...} />`\n * renders with them instead of the built-in @base-ui/react-backed components.\n */\nexport function createShadcnAdapter(components: ShadcnAdapterComponents): DatetimeRangeUIAdapter {\n const {\n Button: ShadcnButton,\n Popover: ShadcnPopover,\n PopoverTrigger: ShadcnPopoverTrigger,\n PopoverContent: ShadcnPopoverContent,\n Select: ShadcnSelect,\n SelectTrigger: ShadcnSelectTrigger,\n SelectValue: ShadcnSelectValue,\n SelectContent: ShadcnSelectContent,\n SelectItem: ShadcnSelectItem,\n Tabs: ShadcnTabs,\n TabsList: ShadcnTabsList,\n TabsTrigger: ShadcnTabsTrigger,\n TabsContent: ShadcnTabsContent,\n Switch: ShadcnSwitch,\n Input: ShadcnInput,\n ScrollArea: ShadcnScrollArea,\n } = components;\n\n function Button({ size = 'default', ...props }: ButtonProps) {\n return <ShadcnButton size={buttonSizeMap[size]} {...props} />;\n }\n\n function Popover(props: PopoverProps) {\n return <ShadcnPopover {...props} />;\n }\n\n function PopoverTrigger({ render, disabled }: PopoverTriggerProps) {\n // base-ui's render-prop contract: `render(props, state) => ReactElement`, or a bare\n // element. Radix's `asChild` clones whatever element we hand it and injects its own\n // onClick/aria/ref regardless of the placeholder props/state below.\n const rendered = typeof render === 'function' ? render({}, { disabled: !!disabled, open: false }) : render;\n\n return (\n <ShadcnPopoverTrigger asChild disabled={disabled}>\n {rendered}\n </ShadcnPopoverTrigger>\n );\n }\n\n function PopoverContent({\n disableAnchorTracking: _disableAnchorTracking,\n collisionAvoidance: _collisionAvoidance,\n container,\n ...props\n }: PopoverContentProps) {\n // disableAnchorTracking/collisionAvoidance are base-ui-only Positioner props with no\n // Radix equivalent — drop them so they don't leak onto a DOM node. container is real\n // (portalContainer support) but base-ui accepts a ref OR an element while Radix's\n // Portal only accepts an element, so unwrap a ref before forwarding it.\n return <ShadcnPopoverContent {...props} container={resolveContainer(container)} />;\n }\n\n function Select(props: SelectProps) {\n return <ShadcnSelect {...props} />;\n }\n\n function SelectTrigger({ size: _size, ...props }: SelectTriggerProps) {\n return <ShadcnSelectTrigger {...props} />;\n }\n\n function SelectValue(props: SelectValueProps) {\n return <ShadcnSelectValue {...props} />;\n }\n\n function SelectContent({ alignItemWithTrigger: _alignItemWithTrigger, ...props }: SelectContentProps) {\n // alignItemWithTrigger is a base-ui-only Positioner prop with no Radix equivalent.\n return <ShadcnSelectContent {...props} />;\n }\n\n function SelectItem(props: SelectItemProps) {\n return <ShadcnSelectItem {...props} />;\n }\n\n function Tabs(props: TabsProps) {\n return <ShadcnTabs {...props} />;\n }\n\n function TabsList({ variant: _variant, ...props }: TabsListProps) {\n return <ShadcnTabsList {...props} />;\n }\n\n function TabsTrigger(props: TabsTriggerProps) {\n return <ShadcnTabsTrigger {...props} />;\n }\n\n function TabsContent(props: TabsContentProps) {\n return <ShadcnTabsContent {...props} />;\n }\n\n function Switch({ size: _size, ...props }: SwitchProps) {\n return <ShadcnSwitch {...props} />;\n }\n\n function Input(props: InputProps) {\n return <ShadcnInput {...props} />;\n }\n\n function ScrollArea(props: ScrollAreaProps) {\n return ShadcnScrollArea ? <ShadcnScrollArea {...props} /> : null;\n }\n\n return {\n Button,\n Popover,\n PopoverTrigger,\n PopoverContent,\n Select,\n SelectTrigger,\n SelectValue,\n SelectContent,\n SelectItem,\n Tabs,\n TabsList,\n TabsTrigger,\n TabsContent,\n Switch,\n Input,\n ...(ShadcnScrollArea ? { ScrollArea } : {}),\n };\n}\n"]}
|