@placetostand/ui 0.0.0-stage → 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.
- package/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/README.md +91 -2
- package/accordion.d.ts +7 -0
- package/accordion.js +18 -0
- package/alert-dialog.d.ts +18 -0
- package/alert-dialog.js +43 -0
- package/alert.d.ts +12 -0
- package/alert.js +32 -0
- package/avatar.d.ts +16 -0
- package/avatar.js +29 -0
- package/badge-tints.d.ts +20 -0
- package/badge-tints.js +69 -0
- package/badge.d.ts +9 -0
- package/badge.js +22 -0
- package/breadcrumb.d.ts +11 -0
- package/breadcrumb.js +36 -0
- package/button.d.ts +14 -0
- package/button.js +34 -0
- package/calendar.d.ts +8 -0
- package/calendar.js +76 -0
- package/card.d.ts +9 -0
- package/card.js +24 -0
- package/checkbox.d.ts +4 -0
- package/checkbox.js +9 -0
- package/cn.d.ts +2 -0
- package/cn.js +8 -0
- package/collapsible.d.ts +6 -0
- package/collapsible.js +13 -0
- package/company-time-zone.d.ts +3 -0
- package/company-time-zone.js +6 -0
- package/confirm-dialog.d.ts +16 -0
- package/confirm-dialog.js +29 -0
- package/context-menu.d.ts +32 -0
- package/context-menu.js +51 -0
- package/dates.d.ts +16 -0
- package/dates.js +129 -0
- package/dialog.d.ts +21 -0
- package/dialog.js +43 -0
- package/dropdown-menu.d.ts +38 -0
- package/dropdown-menu.js +70 -0
- package/empty-state.d.ts +12 -0
- package/empty-state.js +13 -0
- package/hooks/use-mobile.d.ts +1 -0
- package/hooks/use-mobile.js +15 -0
- package/input.d.ts +3 -0
- package/input.js +6 -0
- package/kbd.d.ts +9 -0
- package/kbd.js +10 -0
- package/label.d.ts +3 -0
- package/label.js +7 -0
- package/numbers.d.ts +14 -0
- package/numbers.js +50 -0
- package/package.json +202 -4
- package/popover.d.ts +12 -0
- package/popover.js +38 -0
- package/popup-align.d.ts +1 -0
- package/popup-align.js +1 -0
- package/progress.d.ts +4 -0
- package/progress.js +8 -0
- package/row-action-button.d.ts +11 -0
- package/row-action-button.js +11 -0
- package/segmented-control.d.ts +18 -0
- package/segmented-control.js +9 -0
- package/select.d.ts +27 -0
- package/select.js +78 -0
- package/separator.d.ts +6 -0
- package/separator.js +8 -0
- package/skeleton.d.ts +3 -0
- package/skeleton.js +6 -0
- package/slot.d.ts +8 -0
- package/slot.js +30 -0
- package/styles/theme.css +192 -0
- package/switch.d.ts +6 -0
- package/switch.js +8 -0
- package/table.d.ts +18 -0
- package/table.js +47 -0
- package/tabs.d.ts +17 -0
- package/tabs.js +26 -0
- package/textarea.d.ts +3 -0
- package/textarea.js +6 -0
- package/theme-provider.d.ts +13 -0
- package/theme-provider.js +57 -0
- package/tooltip.d.ts +16 -0
- package/tooltip.js +23 -0
package/input.d.ts
ADDED
package/input.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from './cn.js';
|
|
3
|
+
function Input({ className, type, ...props }) {
|
|
4
|
+
return (_jsx("input", { type: type, "data-slot": 'input', className: cn('file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm', 'focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]', 'aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive', className), ...props }));
|
|
5
|
+
}
|
|
6
|
+
export { Input };
|
package/kbd.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
declare const SIZES: {
|
|
3
|
+
readonly default: "h-5 min-w-5 px-1.5 text-xs";
|
|
4
|
+
readonly sm: "min-w-4 px-1 text-micro";
|
|
5
|
+
};
|
|
6
|
+
declare function Kbd({ className, size, ...props }: React.ComponentProps<'kbd'> & {
|
|
7
|
+
size?: keyof typeof SIZES;
|
|
8
|
+
}): React.JSX.Element;
|
|
9
|
+
export { Kbd };
|
package/kbd.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from './cn.js';
|
|
3
|
+
const SIZES = {
|
|
4
|
+
default: 'h-5 min-w-5 px-1.5 text-xs',
|
|
5
|
+
sm: 'min-w-4 px-1 text-micro',
|
|
6
|
+
};
|
|
7
|
+
function Kbd({ className, size = 'default', ...props }) {
|
|
8
|
+
return (_jsx("kbd", { "data-slot": 'kbd', className: cn('bg-muted text-muted-foreground pointer-events-none inline-flex items-center justify-center rounded-sm border font-[system-ui] leading-none whitespace-nowrap select-none', 'in-data-[slot=tooltip-content]:border-primary-foreground/25 in-data-[slot=tooltip-content]:bg-primary-foreground/10 in-data-[slot=tooltip-content]:text-primary-foreground', SIZES[size], className), ...props }));
|
|
9
|
+
}
|
|
10
|
+
export { Kbd };
|
package/label.d.ts
ADDED
package/label.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from './cn.js';
|
|
4
|
+
function Label({ className, ...props }) {
|
|
5
|
+
return (_jsx("label", { "data-slot": 'label', className: cn('flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50 peer-data-[slot=switch]:cursor-pointer peer-data-[slot=switch]:peer-data-[disabled]:cursor-not-allowed', className), ...props }));
|
|
6
|
+
}
|
|
7
|
+
export { Label };
|
package/numbers.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type NumericInput = number | string;
|
|
2
|
+
type SignOptions = {
|
|
3
|
+
signed?: boolean;
|
|
4
|
+
};
|
|
5
|
+
export type CurrencyOptions = SignOptions & {
|
|
6
|
+
cents?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type PercentOptions = {
|
|
9
|
+
maxDecimals?: number;
|
|
10
|
+
};
|
|
11
|
+
export declare function formatHours(hours: NumericInput, options?: SignOptions): string;
|
|
12
|
+
export declare function formatCurrency(amount: NumericInput, options?: CurrencyOptions): string;
|
|
13
|
+
export declare function formatPercent(ratio: NumericInput, options?: PercentOptions): string;
|
|
14
|
+
export {};
|
package/numbers.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const MINUS = '−';
|
|
2
|
+
const HOURS = new Intl.NumberFormat('en-US', {
|
|
3
|
+
maximumFractionDigits: 2,
|
|
4
|
+
signDisplay: 'negative',
|
|
5
|
+
});
|
|
6
|
+
const CURRENCY = new Intl.NumberFormat('en-US', {
|
|
7
|
+
style: 'currency',
|
|
8
|
+
currency: 'USD',
|
|
9
|
+
minimumFractionDigits: 2,
|
|
10
|
+
maximumFractionDigits: 2,
|
|
11
|
+
signDisplay: 'negative',
|
|
12
|
+
});
|
|
13
|
+
const WHOLE_DOLLARS = new Intl.NumberFormat('en-US', {
|
|
14
|
+
style: 'currency',
|
|
15
|
+
currency: 'USD',
|
|
16
|
+
minimumFractionDigits: 0,
|
|
17
|
+
maximumFractionDigits: 0,
|
|
18
|
+
signDisplay: 'negative',
|
|
19
|
+
});
|
|
20
|
+
function toNumber(value) {
|
|
21
|
+
return typeof value === 'string' ? Number(value) : value;
|
|
22
|
+
}
|
|
23
|
+
function format(value, formatter, signed) {
|
|
24
|
+
if (!signed)
|
|
25
|
+
return formatter.format(value);
|
|
26
|
+
return `${value < 0 ? MINUS : '+'}${formatter.format(Math.abs(value))}`;
|
|
27
|
+
}
|
|
28
|
+
export function formatHours(hours, options = {}) {
|
|
29
|
+
return `${format(toNumber(hours), HOURS, options.signed)}h`;
|
|
30
|
+
}
|
|
31
|
+
export function formatCurrency(amount, options = {}) {
|
|
32
|
+
const formatter = options.cents === false ? WHOLE_DOLLARS : CURRENCY;
|
|
33
|
+
return format(toNumber(amount), formatter, options.signed);
|
|
34
|
+
}
|
|
35
|
+
const PERCENT_FORMATTERS = new Map();
|
|
36
|
+
function percentFormatter(maxDecimals) {
|
|
37
|
+
let formatter = PERCENT_FORMATTERS.get(maxDecimals);
|
|
38
|
+
if (!formatter) {
|
|
39
|
+
formatter = new Intl.NumberFormat('en-US', {
|
|
40
|
+
style: 'percent',
|
|
41
|
+
maximumFractionDigits: maxDecimals,
|
|
42
|
+
signDisplay: 'negative',
|
|
43
|
+
});
|
|
44
|
+
PERCENT_FORMATTERS.set(maxDecimals, formatter);
|
|
45
|
+
}
|
|
46
|
+
return formatter;
|
|
47
|
+
}
|
|
48
|
+
export function formatPercent(ratio, options = {}) {
|
|
49
|
+
return percentFormatter(options.maxDecimals ?? 2).format(toNumber(ratio));
|
|
50
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,204 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@placetostand/ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "React components and a Tailwind CSS theme from Place To Stand Agency: buttons, dialogs, menus, tables, a date picker and more, on Base UI.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Place To Stand Agency LLC",
|
|
7
|
+
"homepage": "https://github.com/place-to-stand/place-to-stand-portal/tree/main/packages/ui#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/place-to-stand/place-to-stand-portal.git",
|
|
11
|
+
"directory": "packages/ui"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"react",
|
|
15
|
+
"tailwindcss",
|
|
16
|
+
"base-ui",
|
|
17
|
+
"components",
|
|
18
|
+
"design-system"
|
|
19
|
+
],
|
|
20
|
+
"type": "module",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@base-ui/react": "^1.9.0",
|
|
23
|
+
"class-variance-authority": "^0.7.1",
|
|
24
|
+
"clsx": "^2.1.1",
|
|
25
|
+
"lucide-react": "^1.70.0",
|
|
26
|
+
"react-day-picker": "^10.0.2",
|
|
27
|
+
"tailwind-merge": "^3.7.0"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"react": "^19.0.0",
|
|
31
|
+
"react-dom": "^19.0.0",
|
|
32
|
+
"tw-animate-css": "^1.4.0"
|
|
33
|
+
},
|
|
34
|
+
"exports": {
|
|
35
|
+
"./accordion": {
|
|
36
|
+
"types": "./accordion.d.ts",
|
|
37
|
+
"default": "./accordion.js"
|
|
38
|
+
},
|
|
39
|
+
"./alert": {
|
|
40
|
+
"types": "./alert.d.ts",
|
|
41
|
+
"default": "./alert.js"
|
|
42
|
+
},
|
|
43
|
+
"./alert-dialog": {
|
|
44
|
+
"types": "./alert-dialog.d.ts",
|
|
45
|
+
"default": "./alert-dialog.js"
|
|
46
|
+
},
|
|
47
|
+
"./avatar": {
|
|
48
|
+
"types": "./avatar.d.ts",
|
|
49
|
+
"default": "./avatar.js"
|
|
50
|
+
},
|
|
51
|
+
"./badge": {
|
|
52
|
+
"types": "./badge.d.ts",
|
|
53
|
+
"default": "./badge.js"
|
|
54
|
+
},
|
|
55
|
+
"./badge-tints": {
|
|
56
|
+
"types": "./badge-tints.d.ts",
|
|
57
|
+
"default": "./badge-tints.js"
|
|
58
|
+
},
|
|
59
|
+
"./breadcrumb": {
|
|
60
|
+
"types": "./breadcrumb.d.ts",
|
|
61
|
+
"default": "./breadcrumb.js"
|
|
62
|
+
},
|
|
63
|
+
"./button": {
|
|
64
|
+
"types": "./button.d.ts",
|
|
65
|
+
"default": "./button.js"
|
|
66
|
+
},
|
|
67
|
+
"./calendar": {
|
|
68
|
+
"types": "./calendar.d.ts",
|
|
69
|
+
"default": "./calendar.js"
|
|
70
|
+
},
|
|
71
|
+
"./card": {
|
|
72
|
+
"types": "./card.d.ts",
|
|
73
|
+
"default": "./card.js"
|
|
74
|
+
},
|
|
75
|
+
"./checkbox": {
|
|
76
|
+
"types": "./checkbox.d.ts",
|
|
77
|
+
"default": "./checkbox.js"
|
|
78
|
+
},
|
|
79
|
+
"./cn": {
|
|
80
|
+
"types": "./cn.d.ts",
|
|
81
|
+
"default": "./cn.js"
|
|
82
|
+
},
|
|
83
|
+
"./collapsible": {
|
|
84
|
+
"types": "./collapsible.d.ts",
|
|
85
|
+
"default": "./collapsible.js"
|
|
86
|
+
},
|
|
87
|
+
"./confirm-dialog": {
|
|
88
|
+
"types": "./confirm-dialog.d.ts",
|
|
89
|
+
"default": "./confirm-dialog.js"
|
|
90
|
+
},
|
|
91
|
+
"./context-menu": {
|
|
92
|
+
"types": "./context-menu.d.ts",
|
|
93
|
+
"default": "./context-menu.js"
|
|
94
|
+
},
|
|
95
|
+
"./dates": {
|
|
96
|
+
"types": "./dates.d.ts",
|
|
97
|
+
"default": "./dates.js"
|
|
98
|
+
},
|
|
99
|
+
"./company-time-zone": {
|
|
100
|
+
"types": "./company-time-zone.d.ts",
|
|
101
|
+
"default": "./company-time-zone.js"
|
|
102
|
+
},
|
|
103
|
+
"./dialog": {
|
|
104
|
+
"types": "./dialog.d.ts",
|
|
105
|
+
"default": "./dialog.js"
|
|
106
|
+
},
|
|
107
|
+
"./dropdown-menu": {
|
|
108
|
+
"types": "./dropdown-menu.d.ts",
|
|
109
|
+
"default": "./dropdown-menu.js"
|
|
110
|
+
},
|
|
111
|
+
"./empty-state": {
|
|
112
|
+
"types": "./empty-state.d.ts",
|
|
113
|
+
"default": "./empty-state.js"
|
|
114
|
+
},
|
|
115
|
+
"./hooks/use-mobile": {
|
|
116
|
+
"types": "./hooks/use-mobile.d.ts",
|
|
117
|
+
"default": "./hooks/use-mobile.js"
|
|
118
|
+
},
|
|
119
|
+
"./input": {
|
|
120
|
+
"types": "./input.d.ts",
|
|
121
|
+
"default": "./input.js"
|
|
122
|
+
},
|
|
123
|
+
"./kbd": {
|
|
124
|
+
"types": "./kbd.d.ts",
|
|
125
|
+
"default": "./kbd.js"
|
|
126
|
+
},
|
|
127
|
+
"./label": {
|
|
128
|
+
"types": "./label.d.ts",
|
|
129
|
+
"default": "./label.js"
|
|
130
|
+
},
|
|
131
|
+
"./numbers": {
|
|
132
|
+
"types": "./numbers.d.ts",
|
|
133
|
+
"default": "./numbers.js"
|
|
134
|
+
},
|
|
135
|
+
"./popup-align": {
|
|
136
|
+
"types": "./popup-align.d.ts",
|
|
137
|
+
"default": "./popup-align.js"
|
|
138
|
+
},
|
|
139
|
+
"./popover": {
|
|
140
|
+
"types": "./popover.d.ts",
|
|
141
|
+
"default": "./popover.js"
|
|
142
|
+
},
|
|
143
|
+
"./progress": {
|
|
144
|
+
"types": "./progress.d.ts",
|
|
145
|
+
"default": "./progress.js"
|
|
146
|
+
},
|
|
147
|
+
"./row-action-button": {
|
|
148
|
+
"types": "./row-action-button.d.ts",
|
|
149
|
+
"default": "./row-action-button.js"
|
|
150
|
+
},
|
|
151
|
+
"./segmented-control": {
|
|
152
|
+
"types": "./segmented-control.d.ts",
|
|
153
|
+
"default": "./segmented-control.js"
|
|
154
|
+
},
|
|
155
|
+
"./select": {
|
|
156
|
+
"types": "./select.d.ts",
|
|
157
|
+
"default": "./select.js"
|
|
158
|
+
},
|
|
159
|
+
"./separator": {
|
|
160
|
+
"types": "./separator.d.ts",
|
|
161
|
+
"default": "./separator.js"
|
|
162
|
+
},
|
|
163
|
+
"./skeleton": {
|
|
164
|
+
"types": "./skeleton.d.ts",
|
|
165
|
+
"default": "./skeleton.js"
|
|
166
|
+
},
|
|
167
|
+
"./slot": {
|
|
168
|
+
"types": "./slot.d.ts",
|
|
169
|
+
"default": "./slot.js"
|
|
170
|
+
},
|
|
171
|
+
"./switch": {
|
|
172
|
+
"types": "./switch.d.ts",
|
|
173
|
+
"default": "./switch.js"
|
|
174
|
+
},
|
|
175
|
+
"./table": {
|
|
176
|
+
"types": "./table.d.ts",
|
|
177
|
+
"default": "./table.js"
|
|
178
|
+
},
|
|
179
|
+
"./tabs": {
|
|
180
|
+
"types": "./tabs.d.ts",
|
|
181
|
+
"default": "./tabs.js"
|
|
182
|
+
},
|
|
183
|
+
"./textarea": {
|
|
184
|
+
"types": "./textarea.d.ts",
|
|
185
|
+
"default": "./textarea.js"
|
|
186
|
+
},
|
|
187
|
+
"./theme-provider": {
|
|
188
|
+
"types": "./theme-provider.d.ts",
|
|
189
|
+
"default": "./theme-provider.js"
|
|
190
|
+
},
|
|
191
|
+
"./tooltip": {
|
|
192
|
+
"types": "./tooltip.d.ts",
|
|
193
|
+
"default": "./tooltip.js"
|
|
194
|
+
},
|
|
195
|
+
"./styles/theme.css": "./styles/theme.css"
|
|
196
|
+
},
|
|
197
|
+
"sideEffects": [
|
|
198
|
+
"*.css"
|
|
199
|
+
],
|
|
200
|
+
"publishConfig": {
|
|
201
|
+
"access": "public",
|
|
202
|
+
"provenance": true
|
|
203
|
+
}
|
|
204
|
+
}
|
package/popover.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Popover as PopoverPrimitive } from '@base-ui/react/popover';
|
|
3
|
+
import type { PopupAlign } from './popup-align.js';
|
|
4
|
+
declare function Popover({ ...props }: PopoverPrimitive.Root.Props): React.JSX.Element;
|
|
5
|
+
declare function PopoverTrigger({ asChild, children, ...props }: PopoverPrimitive.Trigger.Props & {
|
|
6
|
+
asChild?: boolean;
|
|
7
|
+
}): React.JSX.Element;
|
|
8
|
+
declare function PopoverContent({ className, align, alignOffset, side, sideOffset, ...props }: PopoverPrimitive.Popup.Props & Pick<PopoverPrimitive.Positioner.Props, 'alignOffset' | 'side' | 'sideOffset'> & {
|
|
9
|
+
align?: PopupAlign;
|
|
10
|
+
}): React.JSX.Element;
|
|
11
|
+
declare function PopoverAnchor({ ...props }: React.ComponentProps<'div'>): React.JSX.Element;
|
|
12
|
+
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };
|
package/popover.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { Popover as PopoverPrimitive } from '@base-ui/react/popover';
|
|
5
|
+
import { cn } from './cn.js';
|
|
6
|
+
function Popover({ ...props }) {
|
|
7
|
+
return _jsx(PopoverPrimitive.Root, { "data-slot": 'popover', ...props });
|
|
8
|
+
}
|
|
9
|
+
function PopoverTrigger({ asChild, children, ...props }) {
|
|
10
|
+
if (asChild && React.isValidElement(children)) {
|
|
11
|
+
return (_jsx(PopoverPrimitive.Trigger, { "data-slot": 'popover-trigger', render: children, ...props }));
|
|
12
|
+
}
|
|
13
|
+
return (_jsx(PopoverPrimitive.Trigger, { "data-slot": 'popover-trigger', ...props, children: children }));
|
|
14
|
+
}
|
|
15
|
+
function PopoverContent({ className, align, alignOffset = 0, side = 'bottom', sideOffset = 4, ...props }) {
|
|
16
|
+
return (_jsx(PopoverPrimitive.Portal, { children: _jsx(StickySidePositioner, { align: align ?? 'start', alignOffset: alignOffset, side: side, sideOffset: sideOffset, children: _jsx(PopoverPrimitive.Popup, { "data-slot": 'popover-content', className: cn('bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fill-mode-forwards data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 shadow-popover z-50 w-72 origin-(--transform-origin) rounded-md border p-4 outline-hidden', className), ...props }) }) }));
|
|
17
|
+
}
|
|
18
|
+
function StickySidePositioner({ side, children, ...props }) {
|
|
19
|
+
const ref = React.useRef(null);
|
|
20
|
+
const [lockedSide, setLockedSide] = React.useState(null);
|
|
21
|
+
React.useEffect(() => {
|
|
22
|
+
if (lockedSide)
|
|
23
|
+
return;
|
|
24
|
+
let frame = requestAnimationFrame(() => {
|
|
25
|
+
frame = requestAnimationFrame(() => {
|
|
26
|
+
const resolved = ref.current?.dataset.side;
|
|
27
|
+
if (resolved)
|
|
28
|
+
setLockedSide(resolved);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
return () => cancelAnimationFrame(frame);
|
|
32
|
+
}, [lockedSide]);
|
|
33
|
+
return (_jsx(PopoverPrimitive.Positioner, { ref: ref, side: lockedSide ?? side, collisionAvoidance: lockedSide ? { side: 'none' } : undefined, className: 'pointer-events-auto isolate z-50', ...props, children: children }));
|
|
34
|
+
}
|
|
35
|
+
function PopoverAnchor({ ...props }) {
|
|
36
|
+
return _jsx("div", { "data-slot": 'popover-anchor', ...props });
|
|
37
|
+
}
|
|
38
|
+
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };
|
package/popup-align.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type PopupAlign = 'center' | 'end';
|
package/popup-align.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/progress.d.ts
ADDED
package/progress.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Progress as ProgressPrimitive } from '@base-ui/react/progress';
|
|
4
|
+
import { cn } from './cn.js';
|
|
5
|
+
function Progress({ className, value, ...props }) {
|
|
6
|
+
return (_jsx(ProgressPrimitive.Root, { "data-slot": 'progress', value: value, className: cn('bg-primary/20 relative h-2 w-full overflow-hidden rounded-full', className), ...props, children: _jsx(ProgressPrimitive.Indicator, { "data-slot": 'progress-indicator', className: 'bg-primary h-full w-full flex-1 transition-all' }) }));
|
|
7
|
+
}
|
|
8
|
+
export { Progress };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from 'react';
|
|
2
|
+
import { buttonVariants, type IconSize } from './button.js';
|
|
3
|
+
type RowActionButtonProps = Omit<ComponentProps<'button'>, 'children' | 'title' | 'aria-label'> & Pick<Parameters<typeof buttonVariants>[0] & {}, 'variant'> & {
|
|
4
|
+
label: string;
|
|
5
|
+
icon: ReactNode;
|
|
6
|
+
shortcut?: ReactNode;
|
|
7
|
+
size?: IconSize;
|
|
8
|
+
tooltip?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare function RowActionButton({ label, icon, shortcut, variant, size, tooltip, className, ...props }: RowActionButtonProps): import("react").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { buttonVariants } from './button.js';
|
|
4
|
+
import { cn } from './cn.js';
|
|
5
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from './tooltip.js';
|
|
6
|
+
export function RowActionButton({ label, icon, shortcut, variant = 'ghost', size = 'icon-sm', tooltip = true, className, ...props }) {
|
|
7
|
+
const button = (_jsx("button", { "data-slot": 'button', "aria-label": label, className: cn(buttonVariants({ variant, size, className })), ...props, children: icon }));
|
|
8
|
+
if (!tooltip)
|
|
9
|
+
return button;
|
|
10
|
+
return (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: button }), _jsxs(TooltipContent, { children: [label, shortcut ? _jsx("span", { className: 'ml-2', children: shortcut }) : null] })] }));
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export type SegmentedOption<T extends string> = {
|
|
3
|
+
value: T;
|
|
4
|
+
label: React.ReactNode;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
};
|
|
7
|
+
type SegmentedControlProps<T extends string> = {
|
|
8
|
+
value: T;
|
|
9
|
+
onValueChange?: (value: T) => void;
|
|
10
|
+
options: readonly SegmentedOption<T>[];
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
'aria-label'?: string;
|
|
13
|
+
'aria-labelledby'?: string;
|
|
14
|
+
id?: string;
|
|
15
|
+
className?: string;
|
|
16
|
+
};
|
|
17
|
+
declare function SegmentedControl<T extends string>({ value, onValueChange, options, disabled, className, ...props }: SegmentedControlProps<T>): React.JSX.Element;
|
|
18
|
+
export { SegmentedControl };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Radio } from '@base-ui/react/radio';
|
|
4
|
+
import { RadioGroup } from '@base-ui/react/radio-group';
|
|
5
|
+
import { cn } from './cn.js';
|
|
6
|
+
function SegmentedControl({ value, onValueChange, options, disabled = false, className, ...props }) {
|
|
7
|
+
return (_jsx(RadioGroup, { "data-slot": 'segmented-control', value: value, onValueChange: next => onValueChange?.(next), disabled: disabled, className: cn('bg-muted text-muted-foreground inline-flex h-9 w-fit max-w-full items-center rounded-lg p-[3px]', className), ...props, children: options.map(option => (_jsx(Radio.Root, { value: option.value, disabled: option.disabled, "data-slot": 'segmented-control-item', className: cn('text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 cursor-pointer items-center justify-center gap-1.5 rounded-md border border-transparent px-3 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] outline-none select-none', 'focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]', 'not-data-checked:hover:bg-muted/60 not-data-checked:hover:text-foreground', 'data-checked:bg-background dark:data-checked:border-input dark:data-checked:bg-input/30 dark:data-checked:text-foreground data-checked:shadow-sm', 'data-disabled:cursor-not-allowed data-disabled:opacity-50 data-disabled:not-data-checked:hover:bg-transparent', 'data-checked:data-disabled:opacity-80'), children: option.label }, option.value))) }));
|
|
8
|
+
}
|
|
9
|
+
export { SegmentedControl };
|
package/select.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Select as SelectPrimitive } from '@base-ui/react/select';
|
|
3
|
+
import type { PopupAlign } from './popup-align.js';
|
|
4
|
+
interface SelectRadixCompatProps {
|
|
5
|
+
value?: string;
|
|
6
|
+
defaultValue?: string;
|
|
7
|
+
onValueChange?(value: string): void;
|
|
8
|
+
onOpenChange?(open: boolean): void;
|
|
9
|
+
}
|
|
10
|
+
type SelectProps = Omit<SelectPrimitive.Root.Props<string, false>, 'value' | 'defaultValue' | 'onValueChange' | 'onOpenChange' | 'items' | 'multiple'> & SelectRadixCompatProps;
|
|
11
|
+
declare function Select({ children, onValueChange, onOpenChange, ...props }: SelectProps): React.JSX.Element;
|
|
12
|
+
declare function SelectGroup({ ...props }: SelectPrimitive.Group.Props): React.JSX.Element;
|
|
13
|
+
declare function SelectValue({ children, ...props }: SelectPrimitive.Value.Props): React.JSX.Element;
|
|
14
|
+
declare function SelectTrigger({ className, size, children, ...props }: SelectPrimitive.Trigger.Props & {
|
|
15
|
+
size?: 'xs' | 'sm' | 'default';
|
|
16
|
+
}): React.JSX.Element;
|
|
17
|
+
declare function SelectContent({ className, children, position, align, alignOffset, side, sideOffset, style, ...props }: SelectPrimitive.Popup.Props & Pick<SelectPrimitive.Positioner.Props, 'alignOffset' | 'side' | 'sideOffset'> & {
|
|
18
|
+
align?: PopupAlign;
|
|
19
|
+
} & {
|
|
20
|
+
position?: 'popper' | 'item-aligned';
|
|
21
|
+
}): React.JSX.Element;
|
|
22
|
+
declare function SelectLabel({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
|
|
23
|
+
declare function SelectItem({ className, children, ...props }: SelectPrimitive.Item.Props): React.JSX.Element;
|
|
24
|
+
declare function SelectSeparator({ className, ...props }: SelectPrimitive.Separator.Props): React.JSX.Element;
|
|
25
|
+
declare function SelectScrollUpButton({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.ScrollUpArrow>): React.JSX.Element;
|
|
26
|
+
declare function SelectScrollDownButton({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.ScrollDownArrow>): React.JSX.Element;
|
|
27
|
+
export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, };
|
package/select.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { Select as SelectPrimitive } from '@base-ui/react/select';
|
|
5
|
+
import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from 'lucide-react';
|
|
6
|
+
import { cn } from './cn.js';
|
|
7
|
+
function collectSelectItems(children, acc) {
|
|
8
|
+
React.Children.forEach(children, child => {
|
|
9
|
+
if (!React.isValidElement(child)) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const props = child.props;
|
|
13
|
+
if (typeof props.value === 'string') {
|
|
14
|
+
acc.push({ value: props.value, label: props.children });
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (props.children) {
|
|
18
|
+
collectSelectItems(props.children, acc);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function Select({ children, onValueChange, onOpenChange, ...props }) {
|
|
23
|
+
const items = React.useMemo(() => {
|
|
24
|
+
const acc = [];
|
|
25
|
+
collectSelectItems(children, acc);
|
|
26
|
+
return acc;
|
|
27
|
+
}, [children]);
|
|
28
|
+
const handleValueChange = React.useMemo(() => {
|
|
29
|
+
if (!onValueChange) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
return (value) => {
|
|
33
|
+
if (typeof value === 'string') {
|
|
34
|
+
onValueChange(value);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}, [onValueChange]);
|
|
38
|
+
const handleOpenChange = React.useMemo(() => {
|
|
39
|
+
if (!onOpenChange) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
return (open) => {
|
|
43
|
+
onOpenChange(open);
|
|
44
|
+
};
|
|
45
|
+
}, [onOpenChange]);
|
|
46
|
+
return (_jsx(SelectPrimitive.Root, { "data-slot": 'select', items: items, onValueChange: handleValueChange, onOpenChange: handleOpenChange, ...props, children: children }));
|
|
47
|
+
}
|
|
48
|
+
function SelectGroup({ ...props }) {
|
|
49
|
+
return _jsx(SelectPrimitive.Group, { "data-slot": 'select-group', ...props });
|
|
50
|
+
}
|
|
51
|
+
function SelectValue({ children, ...props }) {
|
|
52
|
+
const resolvedChildren = children == null || children === false ? undefined : children;
|
|
53
|
+
return (_jsx(SelectPrimitive.Value, { "data-slot": 'select-value', ...props, children: resolvedChildren }));
|
|
54
|
+
}
|
|
55
|
+
function SelectTrigger({ className, size = 'default', children, ...props }) {
|
|
56
|
+
return (_jsxs(SelectPrimitive.Trigger, { "data-slot": 'select-trigger', "data-size": size, className: cn('border-input data-placeholder:text-muted-foreground [&_svg]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-full items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-left text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 data-[size=xs]:h-7 data-[size=xs]:px-2 data-[size=xs]:text-xs *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0', className), ...props, children: [children, _jsx(SelectPrimitive.Icon, { render: _jsx(ChevronDownIcon, { className: 'size-4 opacity-50' }) })] }));
|
|
57
|
+
}
|
|
58
|
+
function SelectContent({ className, children, position = 'popper', align, alignOffset = 0, side = 'bottom', sideOffset = 0, style, ...props }) {
|
|
59
|
+
return (_jsx(SelectPrimitive.Portal, { children: _jsx(SelectPrimitive.Positioner, { align: align ?? 'start', alignOffset: alignOffset, side: side, sideOffset: sideOffset, alignItemWithTrigger: position === 'item-aligned', className: 'pointer-events-auto isolate z-50', children: _jsxs(SelectPrimitive.Popup, { "data-slot": 'select-content', style: style, className: cn('bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fill-mode-forwards data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 shadow-popover relative z-50 max-h-(--available-height) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md border', position === 'popper' &&
|
|
60
|
+
'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1', className), ...props, children: [_jsx(SelectScrollUpButton, {}), _jsx(SelectPrimitive.List, { className: cn('p-1', position === 'popper' &&
|
|
61
|
+
'w-full min-w-(--anchor-width) scroll-my-1'), children: children }), _jsx(SelectScrollDownButton, {})] }) }) }));
|
|
62
|
+
}
|
|
63
|
+
function SelectLabel({ className, ...props }) {
|
|
64
|
+
return (_jsx("div", { "data-slot": 'select-label', className: cn('text-muted-foreground px-2 py-1.5 text-xs', className), ...props }));
|
|
65
|
+
}
|
|
66
|
+
function SelectItem({ className, children, ...props }) {
|
|
67
|
+
return (_jsxs(SelectPrimitive.Item, { "data-slot": 'select-item', className: cn('focus:bg-accent focus:text-accent-foreground data-highlighted:bg-accent data-highlighted:text-accent-foreground hover:bg-accent hover:text-accent-foreground [&_svg]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2', className), ...props, children: [_jsx("span", { className: 'absolute right-2 flex size-3.5 items-center justify-center', children: _jsx(SelectPrimitive.ItemIndicator, { children: _jsx(CheckIcon, { className: 'size-4' }) }) }), _jsx(SelectPrimitive.ItemText, { children: children })] }));
|
|
68
|
+
}
|
|
69
|
+
function SelectSeparator({ className, ...props }) {
|
|
70
|
+
return (_jsx(SelectPrimitive.Separator, { "data-slot": 'select-separator', className: cn('bg-border pointer-events-none -mx-1 my-1 h-px', className), ...props }));
|
|
71
|
+
}
|
|
72
|
+
function SelectScrollUpButton({ className, ...props }) {
|
|
73
|
+
return (_jsx(SelectPrimitive.ScrollUpArrow, { "data-slot": 'select-scroll-up-button', className: cn('flex cursor-default items-center justify-center py-1', 'bg-popover top-0 z-10 w-full', className), ...props, children: _jsx(ChevronUpIcon, { className: 'size-4' }) }));
|
|
74
|
+
}
|
|
75
|
+
function SelectScrollDownButton({ className, ...props }) {
|
|
76
|
+
return (_jsx(SelectPrimitive.ScrollDownArrow, { "data-slot": 'select-scroll-down-button', className: cn('flex cursor-default items-center justify-center py-1', 'bg-popover bottom-0 z-10 w-full', className), ...props, children: _jsx(ChevronDownIcon, { className: 'size-4' }) }));
|
|
77
|
+
}
|
|
78
|
+
export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, };
|
package/separator.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Separator as SeparatorPrimitive } from '@base-ui/react/separator';
|
|
3
|
+
declare function Separator({ className, orientation, decorative, ...props }: SeparatorPrimitive.Props & {
|
|
4
|
+
decorative?: boolean;
|
|
5
|
+
}): React.JSX.Element;
|
|
6
|
+
export { Separator };
|
package/separator.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Separator as SeparatorPrimitive } from '@base-ui/react/separator';
|
|
4
|
+
import { cn } from './cn.js';
|
|
5
|
+
function Separator({ className, orientation = 'horizontal', decorative = true, ...props }) {
|
|
6
|
+
return (_jsx(SeparatorPrimitive, { "data-slot": 'separator', orientation: orientation, role: decorative ? 'none' : undefined, className: cn('bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px', className), ...props }));
|
|
7
|
+
}
|
|
8
|
+
export { Separator };
|
package/skeleton.d.ts
ADDED
package/skeleton.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from './cn.js';
|
|
3
|
+
function Skeleton({ className, ...props }) {
|
|
4
|
+
return (_jsx("div", { "data-slot": 'skeleton', className: cn('bg-accent animate-pulse rounded-md', className), ...props }));
|
|
5
|
+
}
|
|
6
|
+
export { Skeleton };
|
package/slot.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
declare function Slot({ children: rawChildren, ref, ...props }: React.ComponentProps<'span'> & {
|
|
3
|
+
ref?: React.Ref<HTMLElement>;
|
|
4
|
+
}): React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | null;
|
|
5
|
+
declare const SlotNamespace: {
|
|
6
|
+
Root: typeof Slot;
|
|
7
|
+
};
|
|
8
|
+
export { Slot, SlotNamespace };
|
package/slot.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
5
|
+
const NO_CHILD = _jsx("span", {});
|
|
6
|
+
const REACT_LAZY_TYPE = Symbol.for('react.lazy');
|
|
7
|
+
function isLazyNode(node) {
|
|
8
|
+
return (typeof node === 'object' &&
|
|
9
|
+
node !== null &&
|
|
10
|
+
node.$$typeof === REACT_LAZY_TYPE &&
|
|
11
|
+
typeof node._payload?.then === 'function');
|
|
12
|
+
}
|
|
13
|
+
function Slot({ children: rawChildren, ref, ...props }) {
|
|
14
|
+
const children = isLazyNode(rawChildren)
|
|
15
|
+
? React.use(rawChildren._payload)
|
|
16
|
+
: rawChildren;
|
|
17
|
+
const child = React.isValidElement(children) ? children : null;
|
|
18
|
+
if (process?.env?.NODE_ENV !== 'production' && children != null && !child) {
|
|
19
|
+
console.error('Slot expected a single React element child (this is what `asChild` ' +
|
|
20
|
+
'forwards props onto), but received %s. Nothing will render.', typeof children);
|
|
21
|
+
}
|
|
22
|
+
const rendered = useRender({
|
|
23
|
+
render: child ?? NO_CHILD,
|
|
24
|
+
props,
|
|
25
|
+
ref: ref,
|
|
26
|
+
});
|
|
27
|
+
return child ? rendered : null;
|
|
28
|
+
}
|
|
29
|
+
const SlotNamespace = { Root: Slot };
|
|
30
|
+
export { Slot, SlotNamespace };
|