@api7/ui-components 0.4.0 → 0.6.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/README.md +221 -30
- package/dist/animations.css +12 -0
- package/dist/components/alert/alert.d.ts +0 -2
- package/dist/components/alert/alert.js +8 -9
- package/dist/components/avatar/avatar.d.ts +4 -6
- package/dist/components/avatar/avatar.js +7 -8
- package/dist/components/badge/badge.d.ts +0 -2
- package/dist/components/badge/badge.js +15 -16
- package/dist/components/button/button.d.ts +1 -4
- package/dist/components/button/button.js +15 -16
- package/dist/components/calendar/calendar.d.ts +1 -3
- package/dist/components/calendar/calendar.js +29 -30
- package/dist/components/checkbox/checkbox.d.ts +0 -2
- package/dist/components/checkbox/checkbox.js +4 -5
- package/dist/components/combobox/combobox.d.ts +0 -2
- package/dist/components/combobox/combobox.js +25 -25
- package/dist/components/data-table/data-table.d.ts +0 -2
- package/dist/components/data-table/data-table.js +8 -9
- package/dist/components/data-table/filter-header.d.ts +1 -3
- package/dist/components/data-table/filter-header.js +5 -6
- package/dist/components/data-table/sort-header.js +3 -4
- package/dist/components/date-picker/date-picker.d.ts +0 -2
- package/dist/components/date-picker/date-picker.js +15 -16
- package/dist/components/description-list/description-list.d.ts +24 -0
- package/dist/components/description-list/description-list.js +88 -0
- package/dist/components/dialog/dialog.d.ts +0 -2
- package/dist/components/dialog/dialog.js +12 -13
- package/dist/components/drawer/drawer.d.ts +0 -2
- package/dist/components/drawer/drawer.js +13 -14
- package/dist/components/empty/empty.d.ts +0 -2
- package/dist/components/empty/empty.js +9 -10
- package/dist/components/field/field.d.ts +0 -2
- package/dist/components/field/field.js +7 -8
- package/dist/components/field/labeled-field.d.ts +33 -0
- package/dist/components/field/labeled-field.js +67 -0
- package/dist/components/form/choice-fields.d.ts +1 -3
- package/dist/components/form/choice-fields.js +1 -2
- package/dist/components/form/date-fields.d.ts +0 -2
- package/dist/components/form/date-fields.js +2 -3
- package/dist/components/form/errors.d.ts +1 -3
- package/dist/components/form/errors.js +1 -2
- package/dist/components/form/form-context.d.ts +1 -3
- package/dist/components/form/form-context.js +1 -2
- package/dist/components/form/form-item.d.ts +6 -17
- package/dist/components/form/form-item.js +9 -58
- package/dist/components/form/form.d.ts +1 -3
- package/dist/components/form/form.js +1 -2
- package/dist/components/form/lazy-field-components.js +2 -3
- package/dist/components/form/submit-button.d.ts +1 -3
- package/dist/components/form/submit-button.js +1 -2
- package/dist/components/form/text-field.d.ts +1 -3
- package/dist/components/form/text-field.js +1 -2
- package/dist/components/form/toggle-fields.d.ts +1 -3
- package/dist/components/form/toggle-fields.js +30 -46
- package/dist/components/input/input.d.ts +0 -2
- package/dist/components/input/input.js +2 -3
- package/dist/components/input-group/input-group.d.ts +0 -2
- package/dist/components/input-group/input-group.js +12 -13
- package/dist/components/menu/menu.d.ts +14 -4
- package/dist/components/menu/menu.js +43 -31
- package/dist/components/number-field/number-field.d.ts +0 -2
- package/dist/components/number-field/number-field.js +8 -9
- package/dist/components/pagination/pagination.d.ts +1 -3
- package/dist/components/pagination/pagination.js +13 -14
- package/dist/components/popover/popover.d.ts +3 -3
- package/dist/components/popover/popover.js +14 -7
- package/dist/components/progress/progress.d.ts +17 -0
- package/dist/components/progress/progress.js +35 -0
- package/dist/components/radio-group/radio-group.d.ts +0 -2
- package/dist/components/radio-group/radio-group.js +4 -5
- package/dist/components/select/select.d.ts +0 -2
- package/dist/components/select/select.js +18 -18
- package/dist/components/separator/separator.d.ts +0 -2
- package/dist/components/separator/separator.js +2 -3
- package/dist/components/sidebar/sidebar.d.ts +0 -2
- package/dist/components/sidebar/sidebar.js +11 -12
- package/dist/components/skeleton/skeleton.d.ts +0 -2
- package/dist/components/skeleton/skeleton.js +2 -3
- package/dist/components/spinner/spinner.d.ts +12 -0
- package/dist/components/spinner/spinner.js +27 -0
- package/dist/components/switch/switch.d.ts +0 -2
- package/dist/components/switch/switch.js +3 -4
- package/dist/components/table/table.d.ts +0 -2
- package/dist/components/table/table.js +8 -9
- package/dist/components/tabs/tabs.d.ts +0 -2
- package/dist/components/tabs/tabs.js +5 -6
- package/dist/components/textarea/textarea.d.ts +0 -2
- package/dist/components/textarea/textarea.js +2 -3
- package/dist/components/toast/toast.d.ts +0 -2
- package/dist/components/toast/toast.js +19 -20
- package/dist/components/tooltip/tooltip.d.ts +0 -2
- package/dist/components/tooltip/tooltip.js +5 -4
- package/dist/config/config-provider.d.ts +1 -3
- package/dist/config/config-provider.js +1 -2
- package/dist/config/messages.d.ts +5 -3
- package/dist/config/messages.js +3 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +7 -3
- package/dist/lib/cn.js +5 -6
- package/dist/lib/control.js +4 -5
- package/dist/lib/popup.js +6 -6
- package/dist/theme.css +220 -0
- package/dist/tokens/contrast.d.ts +1 -3
- package/dist/tokens/contrast.js +1 -2
- package/dist/tokens/palette.d.ts +0 -2
- package/dist/tokens/palette.js +1 -2
- package/dist/tokens/scale.js +1 -2
- package/dist/tokens/semantic.d.ts +0 -2
- package/dist/tokens/semantic.js +0 -1
- package/dist/tokens/types.d.ts +1 -3
- package/dist/tokens/types.js +1 -2
- package/package.json +11 -9
- package/dist/styles.css +0 -2
|
@@ -5,27 +5,27 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
5
5
|
import { cva } from "class-variance-authority";
|
|
6
6
|
import { LoaderCircle } from "lucide-react";
|
|
7
7
|
import { Button } from "@base-ui/react/button";
|
|
8
|
-
|
|
9
|
-
const buttonVariants = cva("
|
|
8
|
+
// src/components/button/button.tsx
|
|
9
|
+
const buttonVariants = cva("inline-flex shrink-0 items-center justify-center gap-2 rounded-md border border-transparent text-sm font-medium whitespace-nowrap transition-colors outline-none select-none focus-visible:ring-2 focus-visible:ring-ring/40 disabled:pointer-events-none disabled:opacity-50 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5", {
|
|
10
10
|
variants: {
|
|
11
11
|
variant: {
|
|
12
|
-
primary: "
|
|
13
|
-
secondary: "
|
|
14
|
-
outline: "
|
|
15
|
-
ghost: "
|
|
16
|
-
destructive: "
|
|
17
|
-
link: "
|
|
12
|
+
primary: "bg-primary text-primary-foreground hover:bg-primary-hover",
|
|
13
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary-hover",
|
|
14
|
+
outline: "border-input bg-background text-foreground hover:bg-accent hover:text-accent-foreground",
|
|
15
|
+
ghost: "text-foreground hover:bg-accent hover:text-accent-foreground",
|
|
16
|
+
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive-hover",
|
|
17
|
+
link: "text-primary-text underline-offset-4 hover:underline"
|
|
18
18
|
},
|
|
19
19
|
size: {
|
|
20
|
-
sm: "
|
|
21
|
-
md: "
|
|
22
|
-
lg: "
|
|
23
|
-
icon: "
|
|
20
|
+
sm: "h-6 px-2 text-xs",
|
|
21
|
+
md: "h-8 px-3",
|
|
22
|
+
lg: "h-10 px-4",
|
|
23
|
+
icon: "size-8 px-0"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
compoundVariants: [{
|
|
27
27
|
variant: "link",
|
|
28
|
-
className: "
|
|
28
|
+
className: "h-auto px-0"
|
|
29
29
|
}],
|
|
30
30
|
defaultVariants: {
|
|
31
31
|
variant: "primary",
|
|
@@ -48,15 +48,14 @@ function Button$1({ className, variant, size, loading = false, loadingLabel, dis
|
|
|
48
48
|
children: [
|
|
49
49
|
loading && /* @__PURE__ */ jsx(LoaderCircle, {
|
|
50
50
|
"aria-hidden": "true",
|
|
51
|
-
className: "
|
|
51
|
+
className: "animate-spin"
|
|
52
52
|
}),
|
|
53
53
|
loading && /* @__PURE__ */ jsx("span", {
|
|
54
|
-
className: "
|
|
54
|
+
className: "sr-only",
|
|
55
55
|
children: `${loadingLabel ?? messages.button.loading} `
|
|
56
56
|
}),
|
|
57
57
|
children
|
|
58
58
|
]
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
-
//#endregion
|
|
62
61
|
export { Button$1 as Button, buttonVariants };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ComponentProps } from "react";
|
|
2
2
|
import { DayPicker } from "react-day-picker";
|
|
3
|
-
//#region src/components/calendar/calendar.d.ts
|
|
4
3
|
export type CalendarProps = ComponentProps<typeof DayPicker>;
|
|
5
4
|
/**
|
|
6
5
|
* Wraps react-day-picker's DayPicker with this library's visual conventions. Locale falls back to
|
|
@@ -12,8 +11,7 @@ export type CalendarProps = ComponentProps<typeof DayPicker>;
|
|
|
12
11
|
* look of their own, such as `today`, with the app's own class; the library's state looks (for
|
|
13
12
|
* example `selected`) cannot be replaced. Today is not highlighted unless `classNames.today` is set,
|
|
14
13
|
* for example `classNames={{ today: 'my-today' }}` with `.my-today > button { border: 1px solid
|
|
15
|
-
* var(--
|
|
14
|
+
* var(--color-primary); }` in the app's CSS.
|
|
16
15
|
*/
|
|
17
16
|
declare function Calendar({ className, classNames, locale, navLayout, components, ...props }: CalendarProps): import("react").JSX.Element;
|
|
18
|
-
//#endregion
|
|
19
17
|
export { Calendar };
|
|
@@ -7,10 +7,10 @@ import { jsx } from "react/jsx-runtime";
|
|
|
7
7
|
import { ChevronDown, ChevronLeft, ChevronRight } from "lucide-react";
|
|
8
8
|
import { DayPicker, getDefaultClassNames } from "react-day-picker";
|
|
9
9
|
import { enUS, zhCN } from "react-day-picker/locale";
|
|
10
|
-
|
|
10
|
+
// src/components/calendar/calendar.tsx
|
|
11
11
|
/** Merges a consumer's `classNames` prop with ours key by key. Consumer classes are appended to the
|
|
12
12
|
* key's own classes (the cell's fixed size, range-band fillers and state looks), which they cannot
|
|
13
|
-
* replace: only
|
|
13
|
+
* replace: only `` utilities take part in `cn`'s conflict resolution. */
|
|
14
14
|
function mergeClassNames(base, overrides = {}) {
|
|
15
15
|
const merged = { ...base };
|
|
16
16
|
for (const key of Object.keys(overrides)) merged[key] = cn(base[key], overrides[key]);
|
|
@@ -36,15 +36,15 @@ function CalendarRoot({ className: rootClassName, rootRef, ...rootProps }) {
|
|
|
36
36
|
/** Module-scope for stable identity (see CalendarRoot). */
|
|
37
37
|
function CalendarChevron({ className: chevronClassName, orientation, ...chevronProps }) {
|
|
38
38
|
if (orientation === "left") return /* @__PURE__ */ jsx(ChevronLeft, {
|
|
39
|
-
className: cn("
|
|
39
|
+
className: cn("size-4", chevronClassName),
|
|
40
40
|
...chevronProps
|
|
41
41
|
});
|
|
42
42
|
if (orientation === "right") return /* @__PURE__ */ jsx(ChevronRight, {
|
|
43
|
-
className: cn("
|
|
43
|
+
className: cn("size-4", chevronClassName),
|
|
44
44
|
...chevronProps
|
|
45
45
|
});
|
|
46
46
|
return /* @__PURE__ */ jsx(ChevronDown, {
|
|
47
|
-
className: cn("
|
|
47
|
+
className: cn("size-4", chevronClassName),
|
|
48
48
|
...chevronProps
|
|
49
49
|
});
|
|
50
50
|
}
|
|
@@ -76,7 +76,7 @@ function CalendarDay({ day, modifiers, ...dayProps }) {
|
|
|
76
76
|
* look of their own, such as `today`, with the app's own class; the library's state looks (for
|
|
77
77
|
* example `selected`) cannot be replaced. Today is not highlighted unless `classNames.today` is set,
|
|
78
78
|
* for example `classNames={{ today: 'my-today' }}` with `.my-today > button { border: 1px solid
|
|
79
|
-
* var(--
|
|
79
|
+
* var(--color-primary); }` in the app's CSS.
|
|
80
80
|
*/
|
|
81
81
|
function Calendar({ className, classNames, locale, navLayout, components, ...props }) {
|
|
82
82
|
const configLocale = useLocale();
|
|
@@ -96,37 +96,37 @@ function Calendar({ className, classNames, locale, navLayout, components, ...pro
|
|
|
96
96
|
}), [components]);
|
|
97
97
|
const ownClassNames = {
|
|
98
98
|
root: cn(defaultClassNames.root),
|
|
99
|
-
months: cn("
|
|
100
|
-
month: cn("
|
|
101
|
-
button_previous: cn(buttonVariants({ variant: "ghost" }), "
|
|
102
|
-
button_next: cn(buttonVariants({ variant: "ghost" }), "
|
|
103
|
-
month_caption: cn("
|
|
104
|
-
caption_label: cn("
|
|
105
|
-
dropdowns: cn("
|
|
106
|
-
dropdown_root: cn("
|
|
107
|
-
dropdown: cn("
|
|
108
|
-
month_grid: cn("
|
|
109
|
-
weekdays: cn("
|
|
110
|
-
weekday: cn("
|
|
111
|
-
week: cn("
|
|
112
|
-
week_number_header: cn("
|
|
113
|
-
week_number: cn("
|
|
114
|
-
day: cn("
|
|
99
|
+
months: cn("flex flex-col gap-4 sm:flex-row", defaultClassNames.months),
|
|
100
|
+
month: cn("relative flex w-full flex-col gap-3", defaultClassNames.month),
|
|
101
|
+
button_previous: cn(buttonVariants({ variant: "ghost" }), "absolute top-0 left-0 size-7 rounded-sm p-0 hover:bg-accent-hover", defaultClassNames.button_previous),
|
|
102
|
+
button_next: cn(buttonVariants({ variant: "ghost" }), "absolute top-0 right-0 size-7 rounded-sm p-0 hover:bg-accent-hover", defaultClassNames.button_next),
|
|
103
|
+
month_caption: cn("flex h-7 items-center justify-center", defaultClassNames.month_caption),
|
|
104
|
+
caption_label: cn("text-sm font-medium select-none", props.captionLayout?.startsWith("dropdown") && "flex items-center gap-1 rounded-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground", defaultClassNames.caption_label),
|
|
105
|
+
dropdowns: cn("flex items-center justify-center gap-1.5 text-sm font-medium", defaultClassNames.dropdowns),
|
|
106
|
+
dropdown_root: cn("relative rounded-sm has-focus-visible:ring-2 has-focus-visible:ring-ring/40", defaultClassNames.dropdown_root),
|
|
107
|
+
dropdown: cn("absolute inset-0 opacity-0", defaultClassNames.dropdown),
|
|
108
|
+
month_grid: cn("w-full border-collapse", defaultClassNames.month_grid),
|
|
109
|
+
weekdays: cn("flex", defaultClassNames.weekdays),
|
|
110
|
+
weekday: cn("flex size-8 items-center justify-center text-xs font-normal text-muted-foreground", defaultClassNames.weekday),
|
|
111
|
+
week: cn("mt-1 flex", defaultClassNames.week),
|
|
112
|
+
week_number_header: cn("size-8", defaultClassNames.week_number_header),
|
|
113
|
+
week_number: cn("flex size-8 items-center justify-center text-xs text-muted-foreground", defaultClassNames.week_number),
|
|
114
|
+
day: cn("relative size-8 p-0 text-center align-middle", "data-join-next:after:absolute data-join-next:after:top-1/2 data-join-next:after:right-0 data-join-next:after:h-6 data-join-next:after:w-1 data-join-next:after:-translate-y-1/2 data-join-next:after:bg-info-subtle", "data-join-prev:after:absolute data-join-prev:after:top-1/2 data-join-prev:after:left-0 data-join-prev:after:h-6 data-join-prev:after:w-1 data-join-prev:after:-translate-y-1/2 data-join-prev:after:bg-info-subtle", defaultClassNames.day),
|
|
115
115
|
range_start: cn(defaultClassNames.range_start),
|
|
116
|
-
range_middle: cn("
|
|
116
|
+
range_middle: cn("relative before:absolute before:inset-x-0 before:inset-y-1 before:bg-info-subtle", "data-row-start:before:start-1 data-row-end:before:end-1", defaultClassNames.range_middle),
|
|
117
117
|
range_end: cn(defaultClassNames.range_end),
|
|
118
|
-
hidden: cn("
|
|
118
|
+
hidden: cn("invisible", defaultClassNames.hidden),
|
|
119
119
|
today: cn(defaultClassNames.today),
|
|
120
|
-
selected: cn("
|
|
121
|
-
disabled: cn("
|
|
122
|
-
outside: cn("
|
|
120
|
+
selected: cn("[&:not([data-range-middle])>button]:bg-primary [&:not([data-range-middle])>button]:text-primary-foreground [&:not([data-range-middle])>button]:hover:bg-primary", defaultClassNames.selected),
|
|
121
|
+
disabled: cn("[&>button]:pointer-events-none [&>button]:text-muted-foreground [&>button]:opacity-50", defaultClassNames.disabled),
|
|
122
|
+
outside: cn("[&>button]:text-muted-foreground [&>button]:opacity-50", defaultClassNames.outside)
|
|
123
123
|
};
|
|
124
124
|
return /* @__PURE__ */ jsx(CalendarDayContext.Provider, {
|
|
125
125
|
value: dayContextValue,
|
|
126
126
|
children: /* @__PURE__ */ jsx(DayPicker, {
|
|
127
127
|
locale: resolvedLocale,
|
|
128
128
|
navLayout: navLayout ?? "around",
|
|
129
|
-
className: cn("
|
|
129
|
+
className: cn("w-fit select-none", className),
|
|
130
130
|
classNames: mergeClassNames(ownClassNames, classNames),
|
|
131
131
|
components: mergedComponents,
|
|
132
132
|
...props.mode === "range" ? { resetOnSelect: true } : {},
|
|
@@ -156,8 +156,7 @@ function CalendarDayButton({ className, day, modifiers, ref: forwardedRef, ...pr
|
|
|
156
156
|
else if (forwardedRef) forwardedRef.current = node;
|
|
157
157
|
},
|
|
158
158
|
"data-slot": "calendar-day",
|
|
159
|
-
className: cn("
|
|
159
|
+
className: cn("absolute inset-0 m-auto flex size-6 items-center justify-center rounded-sm text-sm outline-none hover:bg-accent-hover focus-visible:ring-2 focus-visible:ring-ring/40", className)
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
|
-
//#endregion
|
|
163
162
|
export { Calendar };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Checkbox } from "@base-ui/react/checkbox";
|
|
2
|
-
//#region src/components/checkbox/checkbox.d.ts
|
|
3
2
|
export type CheckboxProps = Omit<Checkbox.Root.Props, 'className'> & {
|
|
4
3
|
className?: string;
|
|
5
4
|
};
|
|
6
5
|
declare function Checkbox$1({ className, ...props }: CheckboxProps): import("react").JSX.Element;
|
|
7
|
-
//#endregion
|
|
8
6
|
export { Checkbox$1 as Checkbox };
|
|
@@ -3,22 +3,21 @@ import { cn } from "../../lib/cn.js";
|
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import { CheckIcon, MinusIcon } from "lucide-react";
|
|
5
5
|
import { Checkbox } from "@base-ui/react/checkbox";
|
|
6
|
-
|
|
6
|
+
// src/components/checkbox/checkbox.tsx
|
|
7
7
|
function Checkbox$1({ className, ...props }) {
|
|
8
8
|
return /* @__PURE__ */ jsx(Checkbox.Root, {
|
|
9
9
|
"data-base-ui-swipe-ignore": true,
|
|
10
|
-
className: cn("
|
|
10
|
+
className: cn("peer inline-flex size-4 shrink-0 items-center justify-center rounded-sm border border-input bg-background text-primary-foreground transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring/40 data-checked:border-primary data-checked:bg-primary data-indeterminate:border-primary data-indeterminate:bg-primary data-disabled:cursor-not-allowed data-disabled:opacity-50 aria-invalid:border-destructive", className),
|
|
11
11
|
...props,
|
|
12
12
|
"data-slot": "checkbox",
|
|
13
13
|
children: /* @__PURE__ */ jsx(Checkbox.Indicator, {
|
|
14
|
-
className: "
|
|
14
|
+
className: "flex items-center justify-center",
|
|
15
15
|
"data-slot": "checkbox-indicator",
|
|
16
16
|
render: (indicatorProps, state) => /* @__PURE__ */ jsx("span", {
|
|
17
17
|
...indicatorProps,
|
|
18
|
-
children: state.indeterminate ? /* @__PURE__ */ jsx(MinusIcon, { className: "
|
|
18
|
+
children: state.indeterminate ? /* @__PURE__ */ jsx(MinusIcon, { className: "size-3" }) : /* @__PURE__ */ jsx(CheckIcon, { className: "size-3" })
|
|
19
19
|
})
|
|
20
20
|
})
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
-
//#endregion
|
|
24
23
|
export { Checkbox$1 as Checkbox };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { Combobox } from "@base-ui/react/combobox";
|
|
3
|
-
//#region src/components/combobox/combobox.d.ts
|
|
4
3
|
type WithClassName<P> = Omit<P, 'className'> & {
|
|
5
4
|
className?: string;
|
|
6
5
|
};
|
|
@@ -44,5 +43,4 @@ export type ComboboxChipProps = WithClassName<Combobox.Chip.Props> & {
|
|
|
44
43
|
declare function ComboboxChip({ className, children, removeLabel, ...props }: ComboboxChipProps): import("react").JSX.Element;
|
|
45
44
|
export type ComboboxChipsInputProps = WithClassName<Combobox.Input.Props>;
|
|
46
45
|
declare function ComboboxChipsInput({ className, ...props }: ComboboxChipsInputProps): import("react").JSX.Element;
|
|
47
|
-
//#endregion
|
|
48
46
|
export { Combobox$1 as Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxGroupLabel, ComboboxInput, ComboboxItem, ComboboxValue };
|
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useMessages } from "../../config/config-provider.js";
|
|
3
3
|
import { cn } from "../../lib/cn.js";
|
|
4
|
-
import { listItemClassName, listboxClassName } from "../../lib/popup.js";
|
|
4
|
+
import { listItemClassName, listboxClassName, popupLayerClassName } from "../../lib/popup.js";
|
|
5
5
|
import { controlFocus, controlFocusWithin, controlSurface } from "../../lib/control.js";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { CheckIcon, ChevronDownIcon, XIcon } from "lucide-react";
|
|
8
8
|
import { Combobox } from "@base-ui/react/combobox";
|
|
9
|
-
|
|
9
|
+
// src/components/combobox/combobox.tsx
|
|
10
10
|
function Combobox$1(props) {
|
|
11
11
|
return /* @__PURE__ */ jsx(Combobox.Root, { ...props });
|
|
12
12
|
}
|
|
13
13
|
function ComboboxInput({ className, clearLabel, toggleLabel, ...props }) {
|
|
14
14
|
const messages = useMessages();
|
|
15
15
|
return /* @__PURE__ */ jsxs("div", {
|
|
16
|
-
className: "
|
|
16
|
+
className: "relative",
|
|
17
17
|
"data-slot": "combobox-input-group",
|
|
18
18
|
children: [/* @__PURE__ */ jsx(Combobox.Input, {
|
|
19
|
-
className: cn(controlSurface, controlFocus, "
|
|
19
|
+
className: cn(controlSurface, controlFocus, "h-8 w-full pr-16 pl-3", className),
|
|
20
20
|
...props,
|
|
21
21
|
"data-slot": "combobox-input"
|
|
22
22
|
}), /* @__PURE__ */ jsxs("span", {
|
|
23
|
-
className: "
|
|
23
|
+
className: "absolute top-1/2 right-2 flex -translate-y-1/2 items-center gap-2",
|
|
24
24
|
children: [/* @__PURE__ */ jsx(Combobox.Clear, {
|
|
25
25
|
"aria-label": clearLabel ?? messages.combobox.clear,
|
|
26
|
-
className: "
|
|
26
|
+
className: "text-muted-foreground hover:text-foreground",
|
|
27
27
|
"data-slot": "combobox-clear",
|
|
28
|
-
children: /* @__PURE__ */ jsx(XIcon, { className: "
|
|
28
|
+
children: /* @__PURE__ */ jsx(XIcon, { className: "size-3" })
|
|
29
29
|
}), /* @__PURE__ */ jsx(Combobox.Trigger, {
|
|
30
30
|
"aria-label": toggleLabel ?? messages.combobox.toggle,
|
|
31
|
-
className: "
|
|
31
|
+
className: "flex items-center",
|
|
32
32
|
"data-slot": "combobox-trigger",
|
|
33
33
|
children: /* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
34
34
|
"aria-hidden": "true",
|
|
35
|
-
className: "
|
|
35
|
+
className: "size-5 shrink-0 text-foreground"
|
|
36
36
|
})
|
|
37
37
|
})]
|
|
38
38
|
})]
|
|
@@ -40,11 +40,12 @@ function ComboboxInput({ className, clearLabel, toggleLabel, ...props }) {
|
|
|
40
40
|
}
|
|
41
41
|
function ComboboxContent({ className, side = "bottom", sideOffset = 4, align = "start", children, empty = /* @__PURE__ */ jsx(ComboboxEmpty, {}), ...props }) {
|
|
42
42
|
return /* @__PURE__ */ jsx(Combobox.Portal, { children: /* @__PURE__ */ jsx(Combobox.Positioner, {
|
|
43
|
+
className: popupLayerClassName,
|
|
43
44
|
side,
|
|
44
45
|
sideOffset,
|
|
45
46
|
align,
|
|
46
47
|
children: /* @__PURE__ */ jsxs(Combobox.Popup, {
|
|
47
|
-
className: cn(listboxClassName, "
|
|
48
|
+
className: cn(listboxClassName, "min-w-(--anchor-width) outline-none", className),
|
|
48
49
|
...props,
|
|
49
50
|
"data-slot": "combobox-content",
|
|
50
51
|
children: [/* @__PURE__ */ jsx(Combobox.List, {
|
|
@@ -56,22 +57,22 @@ function ComboboxContent({ className, side = "bottom", sideOffset = 4, align = "
|
|
|
56
57
|
}
|
|
57
58
|
function ComboboxItem({ className, children, ...props }) {
|
|
58
59
|
return /* @__PURE__ */ jsxs(Combobox.Item, {
|
|
59
|
-
className: cn(listItemClassName, "
|
|
60
|
+
className: cn(listItemClassName, "border-b border-border last:border-b-0", className),
|
|
60
61
|
...props,
|
|
61
62
|
"data-slot": "combobox-item",
|
|
62
63
|
children: [/* @__PURE__ */ jsx("span", {
|
|
63
|
-
className: "
|
|
64
|
+
className: "min-w-0 flex-1 truncate",
|
|
64
65
|
children
|
|
65
66
|
}), /* @__PURE__ */ jsx(Combobox.ItemIndicator, {
|
|
66
|
-
className: "
|
|
67
|
-
children: /* @__PURE__ */ jsx(CheckIcon, { className: "
|
|
67
|
+
className: "flex size-4 shrink-0 items-center justify-center",
|
|
68
|
+
children: /* @__PURE__ */ jsx(CheckIcon, { className: "size-4" })
|
|
68
69
|
})]
|
|
69
70
|
});
|
|
70
71
|
}
|
|
71
72
|
function ComboboxEmpty({ className, children, ...props }) {
|
|
72
73
|
const messages = useMessages();
|
|
73
74
|
return /* @__PURE__ */ jsx(Combobox.Empty, {
|
|
74
|
-
className: cn("
|
|
75
|
+
className: cn("px-4 py-2.5 text-sm text-muted-foreground empty:p-0", className),
|
|
75
76
|
...props,
|
|
76
77
|
"data-slot": "combobox-empty",
|
|
77
78
|
children: children ?? messages.combobox.empty
|
|
@@ -86,7 +87,7 @@ function ComboboxGroup({ className, ...props }) {
|
|
|
86
87
|
}
|
|
87
88
|
function ComboboxGroupLabel({ className, ...props }) {
|
|
88
89
|
return /* @__PURE__ */ jsx(Combobox.GroupLabel, {
|
|
89
|
-
className: cn("
|
|
90
|
+
className: cn("px-4 py-2 text-xs font-medium text-muted-foreground", className),
|
|
90
91
|
...props,
|
|
91
92
|
"data-slot": "combobox-group-label"
|
|
92
93
|
});
|
|
@@ -97,17 +98,17 @@ function ComboboxValue(props) {
|
|
|
97
98
|
function ComboboxChips({ className, clearLabel, ...props }) {
|
|
98
99
|
const messages = useMessages();
|
|
99
100
|
return /* @__PURE__ */ jsxs(Combobox.InputGroup, {
|
|
100
|
-
className: cn(controlSurface, controlFocusWithin, "
|
|
101
|
+
className: cn(controlSurface, controlFocusWithin, "flex min-h-8 items-start gap-1 px-2 py-1", className),
|
|
101
102
|
"data-slot": "combobox-chips-group",
|
|
102
103
|
children: [/* @__PURE__ */ jsx(Combobox.Chips, {
|
|
103
|
-
className: "
|
|
104
|
+
className: "flex min-w-0 flex-1 flex-wrap items-center gap-1",
|
|
104
105
|
...props,
|
|
105
106
|
"data-slot": "combobox-chips"
|
|
106
107
|
}), /* @__PURE__ */ jsx(Combobox.Clear, {
|
|
107
108
|
"aria-label": clearLabel ?? messages.combobox.clear,
|
|
108
|
-
className: "
|
|
109
|
+
className: "flex h-6 shrink-0 items-center text-muted-foreground hover:text-foreground",
|
|
109
110
|
"data-slot": "combobox-chips-clear",
|
|
110
|
-
children: /* @__PURE__ */ jsx(XIcon, { className: "
|
|
111
|
+
children: /* @__PURE__ */ jsx(XIcon, { className: "size-3" })
|
|
111
112
|
})]
|
|
112
113
|
});
|
|
113
114
|
}
|
|
@@ -116,26 +117,25 @@ function ComboboxChip({ className, children, removeLabel, ...props }) {
|
|
|
116
117
|
const defaultLabel = typeof children === "string" ? children : void 0;
|
|
117
118
|
return /* @__PURE__ */ jsxs(Combobox.Chip, {
|
|
118
119
|
"aria-label": defaultLabel,
|
|
119
|
-
className: cn("
|
|
120
|
+
className: cn("inline-flex h-6 items-center gap-1 rounded-full bg-secondary px-2 text-sm text-secondary-foreground", className),
|
|
120
121
|
...props,
|
|
121
122
|
"data-slot": "combobox-chip",
|
|
122
123
|
children: [children, /* @__PURE__ */ jsx(Combobox.ChipRemove, {
|
|
123
124
|
"aria-label": removeLabel ?? (defaultLabel ? `${messages.combobox.remove} ${defaultLabel}` : messages.combobox.remove),
|
|
124
|
-
className: "
|
|
125
|
+
className: "flex items-center text-secondary-foreground/70 hover:text-secondary-foreground",
|
|
125
126
|
"data-slot": "combobox-chip-remove",
|
|
126
127
|
children: /* @__PURE__ */ jsx(XIcon, {
|
|
127
128
|
"aria-hidden": "true",
|
|
128
|
-
className: "
|
|
129
|
+
className: "size-3"
|
|
129
130
|
})
|
|
130
131
|
})]
|
|
131
132
|
});
|
|
132
133
|
}
|
|
133
134
|
function ComboboxChipsInput({ className, ...props }) {
|
|
134
135
|
return /* @__PURE__ */ jsx(Combobox.Input, {
|
|
135
|
-
className: cn("
|
|
136
|
+
className: cn("h-6 min-w-16 flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50", className),
|
|
136
137
|
...props,
|
|
137
138
|
"data-slot": "combobox-chips-input"
|
|
138
139
|
});
|
|
139
140
|
}
|
|
140
|
-
//#endregion
|
|
141
141
|
export { Combobox$1 as Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxGroupLabel, ComboboxInput, ComboboxItem, ComboboxValue };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DataTableColumnFilter } from "./filter-header.js";
|
|
2
2
|
import { ComponentProps, ReactNode } from "react";
|
|
3
3
|
import { ColumnDef, ColumnFiltersState, PaginationState, RowData, SortingState, TableFeatures } from "@tanstack/react-table";
|
|
4
|
-
//#region src/components/data-table/data-table.d.ts
|
|
5
4
|
declare const dataTableFeatures: {
|
|
6
5
|
columnFilteringFeature: import("@tanstack/react-table").TableFeature;
|
|
7
6
|
columnVisibilityFeature: import("@tanstack/react-table").TableFeature;
|
|
@@ -84,5 +83,4 @@ export interface DataTableProps<TData extends RowData> {
|
|
|
84
83
|
}
|
|
85
84
|
declare function DataTable<TData extends RowData>({ columns, data, getRowId, sorting, defaultSorting, onSortingChange, manualSorting, columnFilters, onColumnFiltersChange, manualFiltering, pagination, defaultPagination, onPaginationChange, manualPagination, rowCount, pageSizeOptions, hidePagination, paginationLabel, loading, empty, toolbar, className }: DataTableProps<TData>): import("react").JSX.Element;
|
|
86
85
|
declare function DataTableRowActions({ className, ...props }: ComponentProps<'div'>): import("react").JSX.Element;
|
|
87
|
-
//#endregion
|
|
88
86
|
export { DataTable, type DataTableColumnDef, type DataTableFeatures, DataTableRowActions, createDataTableColumnHelper, dataTableFeatures };
|
|
@@ -9,7 +9,7 @@ import { SortHeader } from "./sort-header.js";
|
|
|
9
9
|
import { useEffect, useState } from "react";
|
|
10
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
import { columnFilteringFeature, columnVisibilityFeature, constructFilterFn, createColumnHelper, createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, flexRender, rowPaginationFeature, rowSortingFeature, sortFn_alphanumeric, sortFn_basic, sortFn_datetime, sortFn_text, tableFeatures, useTable } from "@tanstack/react-table";
|
|
12
|
-
|
|
12
|
+
// src/components/data-table/data-table.tsx
|
|
13
13
|
const LOADING_ROW_COUNT = 4;
|
|
14
14
|
const filterFn_oneOf = constructFilterFn({
|
|
15
15
|
filter: (value, chosen) => chosen.includes(String(value)),
|
|
@@ -110,11 +110,11 @@ function DataTable({ columns, data, getRowId, sorting, defaultSorting, onSorting
|
|
|
110
110
|
hidePagination
|
|
111
111
|
]);
|
|
112
112
|
return /* @__PURE__ */ jsxs("div", {
|
|
113
|
-
className: cn("
|
|
113
|
+
className: cn("w-full", className),
|
|
114
114
|
"data-slot": "data-table",
|
|
115
115
|
children: [
|
|
116
116
|
toolbar ? /* @__PURE__ */ jsx("div", {
|
|
117
|
-
className: "
|
|
117
|
+
className: "flex justify-end gap-2 pb-3",
|
|
118
118
|
"data-slot": "data-table-toolbar",
|
|
119
119
|
children: toolbar
|
|
120
120
|
}) : null,
|
|
@@ -132,7 +132,7 @@ function DataTable({ columns, data, getRowId, sorting, defaultSorting, onSorting
|
|
|
132
132
|
className: header.column.columnDef.meta?.className,
|
|
133
133
|
"aria-sort": ariaSort,
|
|
134
134
|
children: header.isPlaceholder ? null : filter ? /* @__PURE__ */ jsxs("div", {
|
|
135
|
-
className: "
|
|
135
|
+
className: "flex items-center gap-1",
|
|
136
136
|
children: [title, /* @__PURE__ */ jsx(FilterHeader, {
|
|
137
137
|
column: header.column,
|
|
138
138
|
filter
|
|
@@ -140,11 +140,11 @@ function DataTable({ columns, data, getRowId, sorting, defaultSorting, onSorting
|
|
|
140
140
|
}) : title
|
|
141
141
|
}, header.id);
|
|
142
142
|
}) }, headerGroup.id)) }), /* @__PURE__ */ jsx(TableBody, { children: loading ? Array.from({ length: LOADING_ROW_COUNT }).map((_, rowIndex) => /* @__PURE__ */ jsx(TableRow, {
|
|
143
|
-
className: "
|
|
144
|
-
children: table.getVisibleLeafColumns().map((column) => /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "
|
|
143
|
+
className: "h-14",
|
|
144
|
+
children: table.getVisibleLeafColumns().map((column) => /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-full" }) }, column.id))
|
|
145
145
|
}, `skeleton-${rowIndex}`)) : table.getRowModel().rows.length === 0 ? /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, {
|
|
146
146
|
colSpan: table.getVisibleLeafColumns().length,
|
|
147
|
-
className: "
|
|
147
|
+
className: "h-[200px] text-center text-xl font-medium text-muted-foreground",
|
|
148
148
|
children: empty ?? messages.dataTable.empty
|
|
149
149
|
}) }) : table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx(TableRow, { children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(TableCell, {
|
|
150
150
|
className: cell.column.columnDef.meta?.className,
|
|
@@ -170,10 +170,9 @@ function DataTable({ columns, data, getRowId, sorting, defaultSorting, onSorting
|
|
|
170
170
|
}
|
|
171
171
|
function DataTableRowActions({ className, ...props }) {
|
|
172
172
|
return /* @__PURE__ */ jsx("div", {
|
|
173
|
-
className: cn("
|
|
173
|
+
className: cn("opacity-0 group-hover/row:opacity-100 group-focus-within/row:opacity-100", className),
|
|
174
174
|
...props,
|
|
175
175
|
"data-slot": "data-table-row-actions"
|
|
176
176
|
});
|
|
177
177
|
}
|
|
178
|
-
//#endregion
|
|
179
178
|
export { DataTable, DataTableRowActions, createDataTableColumnHelper, dataTableFeatures };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "./data-table.js";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
import { RowData } from "@tanstack/react-table";
|
|
4
|
-
//#region src/components/data-table/filter-header.d.ts
|
|
5
4
|
export interface DataTableColumnFilterOption {
|
|
6
5
|
value: string;
|
|
7
6
|
label: ReactNode;
|
|
@@ -18,5 +17,4 @@ export interface DataTableColumnFilter {
|
|
|
18
17
|
* checked: the last checked value cannot be unchecked, and Reset checks the default again.
|
|
19
18
|
*/
|
|
20
19
|
defaultValue?: string[];
|
|
21
|
-
}
|
|
22
|
-
//#endregion
|
|
20
|
+
}
|
|
@@ -4,7 +4,7 @@ import { Button } from "../button/button.js";
|
|
|
4
4
|
import { Menu, MenuCheckboxItem, MenuContent, MenuItem, MenuSeparator, MenuTrigger } from "../menu/menu.js";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { Funnel } from "lucide-react";
|
|
7
|
-
|
|
7
|
+
// src/components/data-table/filter-header.tsx
|
|
8
8
|
function FilterHeader({ column, filter }) {
|
|
9
9
|
const messages = useMessages();
|
|
10
10
|
const filterValue = column.getFilterValue();
|
|
@@ -19,7 +19,7 @@ function FilterHeader({ column, filter }) {
|
|
|
19
19
|
render: /* @__PURE__ */ jsx(Button, {
|
|
20
20
|
variant: "ghost",
|
|
21
21
|
size: "icon",
|
|
22
|
-
className: "
|
|
22
|
+
className: "size-6",
|
|
23
23
|
"aria-label": active ? messages.dataTable.filterActive({
|
|
24
24
|
label: filter.label,
|
|
25
25
|
count: chosen.length
|
|
@@ -27,18 +27,18 @@ function FilterHeader({ column, filter }) {
|
|
|
27
27
|
}),
|
|
28
28
|
children: /* @__PURE__ */ jsx(Funnel, {
|
|
29
29
|
"aria-hidden": "true",
|
|
30
|
-
className: active ? "
|
|
30
|
+
className: active ? "text-primary-text fill-current" : "text-muted-foreground"
|
|
31
31
|
})
|
|
32
32
|
}), /* @__PURE__ */ jsxs(MenuContent, {
|
|
33
33
|
align: "start",
|
|
34
|
-
className: "
|
|
34
|
+
className: "min-w-48",
|
|
35
35
|
children: [
|
|
36
36
|
filter.options.map((option) => /* @__PURE__ */ jsxs(MenuCheckboxItem, {
|
|
37
37
|
checked: chosen.includes(option.value),
|
|
38
38
|
disabled: required && chosen.length === 1 && chosen.includes(option.value),
|
|
39
39
|
onCheckedChange: (on) => change(on ? [...chosen, option.value] : chosen.filter((value) => value !== option.value)),
|
|
40
40
|
children: [option.label, option.count !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
41
|
-
className: "
|
|
41
|
+
className: "ml-auto pl-4 text-muted-foreground",
|
|
42
42
|
children: option.count
|
|
43
43
|
})]
|
|
44
44
|
}, option.value)),
|
|
@@ -51,5 +51,4 @@ function FilterHeader({ column, filter }) {
|
|
|
51
51
|
]
|
|
52
52
|
})] });
|
|
53
53
|
}
|
|
54
|
-
//#endregion
|
|
55
54
|
export { FilterHeader };
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
import { cn } from "../../lib/cn.js";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { ArrowDown, ArrowUp, ChevronsUpDown } from "lucide-react";
|
|
5
|
-
|
|
5
|
+
// src/components/data-table/sort-header.tsx
|
|
6
6
|
function SortHeader({ column, children }) {
|
|
7
7
|
const sorted = column.getIsSorted();
|
|
8
8
|
const Icon = sorted === "asc" ? ArrowUp : sorted === "desc" ? ArrowDown : ChevronsUpDown;
|
|
9
9
|
return /* @__PURE__ */ jsxs("button", {
|
|
10
10
|
type: "button",
|
|
11
11
|
onClick: column.getToggleSortingHandler(),
|
|
12
|
-
className: cn("
|
|
13
|
-
children: [children, /* @__PURE__ */ jsx(Icon, { className: "
|
|
12
|
+
className: cn("inline-flex items-center gap-1 outline-none focus-visible:ring-2 focus-visible:ring-ring/40", sorted ? "text-foreground" : "text-muted-foreground"),
|
|
13
|
+
children: [children, /* @__PURE__ */ jsx(Icon, { className: "size-3.5" })]
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
//#endregion
|
|
17
16
|
export { SortHeader };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { CalendarProps } from "../calendar/calendar.js";
|
|
2
2
|
import { FocusEventHandler } from "react";
|
|
3
3
|
import { DateRange, DateRange as DateRange$1 } from "react-day-picker";
|
|
4
|
-
//#region src/components/date-picker/date-picker.d.ts
|
|
5
4
|
export interface DatePickerProps {
|
|
6
5
|
/** Controlled value. Passing the `value` key at all makes the picker controlled, so `value={undefined}` clears it. */
|
|
7
6
|
value?: Date;
|
|
@@ -51,5 +50,4 @@ export interface DateRangePickerProps {
|
|
|
51
50
|
}
|
|
52
51
|
/** Popover trigger + two-month range Calendar, with optional preset ranges listed beside the calendar. */
|
|
53
52
|
declare function DateRangePicker(props: DateRangePickerProps): import("react").JSX.Element;
|
|
54
|
-
//#endregion
|
|
55
53
|
export { DatePicker, type DateRange$1 as DateRange, DateRangePicker };
|