@godxjp/ui 5.0.2 → 6.0.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 +101 -142
- package/package.json +124 -128
- package/scripts/ui-audit.mjs +179 -0
- package/src/app/__tests__/app-provider.test.tsx +232 -0
- package/src/app/__tests__/date-format-labels.test.ts +36 -0
- package/src/app/__tests__/date-formats.test.ts +44 -0
- package/src/app/__tests__/timezones.test.ts +65 -0
- package/src/app/app-provider.tsx +227 -0
- package/src/app/date-format-labels.ts +21 -0
- package/src/app/date-formats.ts +30 -0
- package/src/app/index.ts +40 -0
- package/src/app/locales.ts +32 -0
- package/src/app/request-headers.ts +31 -0
- package/src/app/storage.ts +44 -0
- package/src/app/time-format-labels.ts +19 -0
- package/src/app/time-formats.ts +15 -0
- package/src/app/timezones.ts +208 -0
- package/src/app/types.ts +39 -0
- package/src/app/use-formatting.ts +47 -0
- package/src/components/__tests__/accessibility-primitives.test.tsx +65 -0
- package/src/components/__tests__/docs-parity.test.ts +41 -0
- package/src/components/__tests__/shadcn-release-guardrails.test.ts +71 -0
- package/src/components/__tests__/theme-axes-integration.test.tsx +242 -0
- package/src/components/admin/index.ts +76 -0
- package/src/components/data-display/__tests__/card-table.test.tsx +328 -0
- package/src/components/data-display/__tests__/data-display.test.tsx +73 -0
- package/src/components/data-display/__tests__/data-table.test.tsx +84 -0
- package/src/components/data-display/__tests__/popover.test.tsx +92 -0
- package/src/components/data-display/__tests__/scroll-area-collapsible.test.tsx +66 -0
- package/src/components/data-display/badge.tsx +27 -0
- package/src/components/data-display/card.tsx +194 -0
- package/src/components/data-display/code-badge.tsx +28 -0
- package/src/components/data-display/collapsible.tsx +5 -0
- package/src/components/data-display/data-table.tsx +476 -0
- package/src/components/data-display/empty-state.tsx +22 -0
- package/src/components/data-display/index.ts +41 -0
- package/src/components/data-display/key-value-grid.tsx +46 -0
- package/src/components/data-display/popover.tsx +62 -0
- package/src/components/data-display/progress-meter.tsx +20 -0
- package/src/components/data-display/scan-panel.tsx +16 -0
- package/src/components/data-display/scroll-area.tsx +42 -0
- package/src/components/data-display/status-badge.tsx +83 -0
- package/src/components/data-display/table.tsx +59 -0
- package/src/components/data-display/timeline.tsx +42 -0
- package/src/components/data-display/tree-list.tsx +42 -0
- package/src/components/data-entry/__fixtures__/tree-options.ts +80 -0
- package/src/components/data-entry/__tests__/cascader-tree-transfer.test.tsx +417 -0
- package/src/components/data-entry/__tests__/checkbox-group.test.tsx +40 -0
- package/src/components/data-entry/__tests__/checkbox.test.tsx +20 -0
- package/src/components/data-entry/__tests__/date-autocomplete.test.tsx +94 -0
- package/src/components/data-entry/__tests__/form-field.test.tsx +49 -0
- package/src/components/data-entry/__tests__/input-textarea.test.tsx +38 -0
- package/src/components/data-entry/__tests__/label-select.test.tsx +62 -0
- package/src/components/data-entry/__tests__/pickers.test.tsx +74 -0
- package/src/components/data-entry/__tests__/radio.test.tsx +46 -0
- package/src/components/data-entry/__tests__/search-input.test.tsx +32 -0
- package/src/components/data-entry/__tests__/switch-field.test.tsx +52 -0
- package/src/components/data-entry/__tests__/upload.test.tsx +125 -0
- package/src/components/data-entry/autocomplete.tsx +91 -0
- package/src/components/data-entry/calendar.tsx +90 -0
- package/src/components/data-entry/cascader.tsx +305 -0
- package/src/components/data-entry/checkbox-group.tsx +90 -0
- package/src/components/data-entry/checkbox.tsx +30 -0
- package/src/components/data-entry/choice-field.tsx +27 -0
- package/src/components/data-entry/choice-option.ts +20 -0
- package/src/components/data-entry/color-picker.tsx +75 -0
- package/src/components/data-entry/command.tsx +56 -0
- package/src/components/data-entry/country-select.tsx +88 -0
- package/src/components/data-entry/date-picker.tsx +69 -0
- package/src/components/data-entry/date-range-picker.tsx +75 -0
- package/src/components/data-entry/form-field.tsx +59 -0
- package/src/components/data-entry/index.ts +62 -0
- package/src/components/data-entry/input.tsx +26 -0
- package/src/components/data-entry/label.tsx +25 -0
- package/src/components/data-entry/radio.tsx +109 -0
- package/src/components/data-entry/search-input.tsx +103 -0
- package/src/components/data-entry/select.tsx +149 -0
- package/src/components/data-entry/slider.tsx +38 -0
- package/src/components/data-entry/switch-field.tsx +91 -0
- package/src/components/data-entry/switch.tsx +24 -0
- package/src/components/data-entry/textarea.tsx +12 -0
- package/src/components/data-entry/time-picker.tsx +214 -0
- package/src/components/data-entry/transfer.tsx +231 -0
- package/src/components/data-entry/tree-select-strategy.ts +6 -0
- package/src/components/data-entry/tree-select.tsx +279 -0
- package/src/components/data-entry/tree-utils.ts +221 -0
- package/src/components/data-entry/upload-crop-dialog.tsx +109 -0
- package/src/components/data-entry/upload-types.ts +86 -0
- package/src/components/data-entry/upload.tsx +498 -0
- package/src/components/data-entry/use-upload-draft.ts +93 -0
- package/src/components/feedback/__tests__/alert.test.tsx +127 -0
- package/src/components/feedback/__tests__/dialog.test.tsx +290 -0
- package/src/components/feedback/__tests__/sheet.test.tsx +94 -0
- package/src/components/feedback/__tests__/skeleton.test.tsx +25 -0
- package/src/components/feedback/__tests__/toast.test.tsx +52 -0
- package/src/components/feedback/alert.tsx +167 -0
- package/src/components/feedback/dialog.tsx +325 -0
- package/src/components/feedback/index.ts +53 -0
- package/src/components/feedback/sheet.tsx +130 -0
- package/src/components/feedback/skeleton.tsx +95 -0
- package/src/components/feedback/sonner.tsx +54 -0
- package/src/components/feedback/toaster.tsx +1 -0
- package/src/components/feedback/use-toast.ts +62 -0
- package/src/components/general/__tests__/button.test.tsx +71 -0
- package/src/components/general/button.tsx +61 -0
- package/src/components/general/index.ts +2 -0
- package/src/components/layout/__tests__/page-container.test.tsx +69 -0
- package/src/components/layout/__tests__/page-inset.test.tsx +14 -0
- package/src/components/layout/__tests__/stack-inline.test.tsx +39 -0
- package/src/components/layout/app-shell.tsx +42 -0
- package/src/components/layout/breadcrumb.tsx +35 -0
- package/src/components/layout/index.ts +31 -0
- package/src/components/layout/inline.tsx +13 -0
- package/src/components/layout/menu.tsx +34 -0
- package/src/components/layout/mobile-frame.tsx +57 -0
- package/src/components/layout/page-container.tsx +81 -0
- package/src/components/layout/page-inset.tsx +16 -0
- package/src/components/layout/responsive-grid.tsx +14 -0
- package/src/components/layout/shell-app.tsx +30 -0
- package/src/components/layout/sidebar.tsx +98 -0
- package/src/components/layout/split-pane.tsx +16 -0
- package/src/components/layout/stack.tsx +13 -0
- package/src/components/layout/topbar.tsx +108 -0
- package/src/components/navigation/__tests__/app-pickers.test.tsx +118 -0
- package/src/components/navigation/__tests__/dropdown-menu.test.tsx +104 -0
- package/src/components/navigation/__tests__/navigation.test.tsx +61 -0
- package/src/components/navigation/__tests__/pagination-steps-tabs.test.tsx +76 -0
- package/src/components/navigation/date-format-picker.tsx +55 -0
- package/src/components/navigation/dropdown-menu.tsx +190 -0
- package/src/components/navigation/filter-bar.tsx +38 -0
- package/src/components/navigation/index.ts +28 -0
- package/src/components/navigation/locale-picker.tsx +49 -0
- package/src/components/navigation/page-header.tsx +50 -0
- package/src/components/navigation/pagination-utils.ts +35 -0
- package/src/components/navigation/pagination.tsx +168 -0
- package/src/components/navigation/steps.tsx +163 -0
- package/src/components/navigation/tabs-items.tsx +69 -0
- package/src/components/navigation/tabs.tsx +67 -0
- package/src/components/navigation/time-format-picker.tsx +55 -0
- package/src/components/navigation/timezone-picker.tsx +63 -0
- package/src/components/query/__tests__/data-state.test.tsx +214 -0
- package/src/components/query/__tests__/infinite-prefetch.test.tsx +105 -0
- package/src/components/query/__tests__/query-helpers.test.tsx +61 -0
- package/src/components/query/data-state.tsx +58 -0
- package/src/components/query/index.ts +10 -0
- package/src/components/query/infinite-query-state.tsx +99 -0
- package/src/components/query/mutation-feedback.tsx +31 -0
- package/src/components/query/prefetch-link.tsx +45 -0
- package/src/components/query/query-refetch-button.tsx +41 -0
- package/src/components/ui/alert-dialog.tsx +1 -0
- package/src/components/ui/alert.tsx +1 -0
- package/src/components/ui/autocomplete.tsx +1 -0
- package/src/components/ui/badge.tsx +1 -0
- package/src/components/ui/button.tsx +1 -0
- package/src/components/ui/calendar.tsx +1 -0
- package/src/components/ui/card.tsx +1 -0
- package/src/components/ui/checkbox.tsx +1 -0
- package/src/components/ui/color-picker.tsx +1 -0
- package/src/components/ui/command.tsx +1 -0
- package/src/components/ui/date-picker.tsx +1 -0
- package/src/components/ui/date-range-picker.tsx +1 -0
- package/src/components/ui/dialog.tsx +1 -0
- package/src/components/ui/dropdown-menu.tsx +1 -0
- package/src/components/ui/index.tsx +31 -0
- package/src/components/ui/input.tsx +1 -0
- package/src/components/ui/label.tsx +1 -0
- package/src/components/ui/pagination.tsx +1 -0
- package/src/components/ui/popover.tsx +1 -0
- package/src/components/ui/radio.tsx +1 -0
- package/src/components/ui/scroll-area.tsx +1 -0
- package/src/components/ui/select.tsx +1 -0
- package/src/components/ui/sheet.tsx +1 -0
- package/src/components/ui/slider.tsx +1 -0
- package/src/components/ui/sonner.tsx +1 -0
- package/src/components/ui/switch.tsx +1 -0
- package/src/components/ui/table.tsx +1 -0
- package/src/components/ui/tabs-items.tsx +1 -0
- package/src/components/ui/tabs.tsx +1 -0
- package/src/components/ui/textarea.tsx +1 -0
- package/src/components/ui/time-picker.tsx +1 -0
- package/src/components/ui/upload.tsx +1 -0
- package/src/form/__tests__/use-zod-form.test.tsx +97 -0
- package/src/form/form-field-control.tsx +44 -0
- package/src/form/form-root.tsx +29 -0
- package/src/form/index.ts +7 -0
- package/src/form/use-zod-form.ts +29 -0
- package/src/i18n/__tests__/translate.test.ts +23 -0
- package/src/i18n/index.ts +9 -0
- package/src/i18n/messages/en.json +171 -0
- package/src/i18n/messages/ja.json +171 -0
- package/src/i18n/messages/vi.json +171 -0
- package/src/i18n/translate.ts +74 -0
- package/src/i18n/use-translation.ts +53 -0
- package/src/index.ts +3 -0
- package/src/lib/__tests__/control-styles.test.ts +78 -0
- package/src/lib/__tests__/datetime.test.ts +77 -0
- package/src/lib/__tests__/format-date.test.ts +97 -0
- package/src/lib/__tests__/format.test.ts +62 -0
- package/src/lib/__tests__/theme-tokens-audit.test.ts +176 -0
- package/src/lib/__tests__/theme-tokens-css.test.ts +118 -0
- package/src/lib/__tests__/token-governance.test.ts +191 -0
- package/src/lib/__tests__/variants.test.ts +18 -0
- package/src/lib/control-styles.ts +33 -0
- package/src/lib/datetime/detect.ts +25 -0
- package/src/lib/datetime/format-date.ts +100 -0
- package/src/lib/datetime/format.ts +140 -0
- package/src/lib/datetime/index.ts +25 -0
- package/src/lib/datetime/parse.ts +51 -0
- package/src/lib/datetime/sync.ts +48 -0
- package/src/lib/format.ts +114 -0
- package/src/lib/hooks.ts +54 -0
- package/src/lib/utils.ts +6 -0
- package/src/lib/variants.ts +40 -0
- package/src/props/components/app.prop.ts +99 -0
- package/src/props/components/data-display.prop.ts +73 -0
- package/src/props/components/data-entry.prop.ts +334 -0
- package/src/props/components/feedback.prop.ts +80 -0
- package/src/props/components/form.prop.ts +46 -0
- package/src/props/components/general.prop.ts +18 -0
- package/src/props/components/index.ts +99 -0
- package/src/props/components/layout.prop.ts +130 -0
- package/src/props/components/navigation.prop.ts +88 -0
- package/src/props/components/query.prop.ts +94 -0
- package/src/props/index.ts +17 -0
- package/src/props/registry.ts +603 -0
- package/src/props/vocabulary/content.prop.ts +35 -0
- package/src/props/vocabulary/data.prop.ts +46 -0
- package/src/props/vocabulary/index.ts +73 -0
- package/src/props/vocabulary/interaction.prop.ts +42 -0
- package/src/props/vocabulary/layout.prop.ts +25 -0
- package/src/props/vocabulary/navigation.prop.ts +19 -0
- package/src/props/vocabulary/shared.prop.ts +59 -0
- package/src/styles/alert-layout.css +191 -0
- package/src/styles/badge-layout.css +22 -0
- package/src/styles/card-layout.css +373 -0
- package/src/styles/control.css +504 -0
- package/src/styles/data-display-layout.css +246 -0
- package/src/styles/density.css +43 -0
- package/src/styles/dialog-layout.css +84 -0
- package/src/styles/index.css +105 -0
- package/src/styles/layout.css +479 -0
- package/src/styles/shell-layout.css +604 -0
- package/src/styles/table-layout.css +109 -0
- package/src/test/__tests__/render-loop-guard.test.tsx +38 -0
- package/src/test/jest-dom.d.ts +4 -0
- package/src/test/render-loop-guard.tsx +50 -0
- package/src/test/render.tsx +29 -0
- package/src/test/theme-globals.test.ts +77 -0
- package/src/test/theme-globals.ts +134 -0
- package/src/test/theme-test-utils.tsx +67 -0
- package/src/theme/example.service.css +37 -0
- package/src/tokens/base.css +13 -0
- package/src/tokens/foundation.css +151 -0
- package/src/tokens/primitives/badge.css +13 -0
- package/src/tokens/primitives/card.css +29 -0
- package/src/tokens/primitives/control.css +55 -0
- package/src/tokens/primitives/feedback.css +17 -0
- package/src/tokens/primitives/layout.css +20 -0
- package/src/tokens/primitives/navigation.css +13 -0
- package/src/tokens/primitives/table.css +10 -0
- package/BRAND.md +0 -296
- package/CHANGELOG.md +0 -668
- package/config/eslint.js +0 -54
- package/config/prettier.cjs +0 -20
- package/config/tsconfig.base.json +0 -22
- package/config/vitest.base.ts +0 -26
- package/dist/MiniMonth-YAmPGEpC.d.ts +0 -143
- package/dist/Table.types-BbsxoIYE.d.ts +0 -352
- package/dist/color-DO0qqUAb.d.ts +0 -38
- package/dist/components/composites.d.ts +0 -963
- package/dist/components/composites.js +0 -7343
- package/dist/components/composites.js.map +0 -1
- package/dist/components/primitives.d.ts +0 -2744
- package/dist/components/primitives.js +0 -7356
- package/dist/components/primitives.js.map +0 -1
- package/dist/components/shell.d.ts +0 -182
- package/dist/components/shell.js +0 -774
- package/dist/components/shell.js.map +0 -1
- package/dist/hooks.d.ts +0 -100
- package/dist/hooks.js +0 -558
- package/dist/hooks.js.map +0 -1
- package/dist/i18n.d.ts +0 -61
- package/dist/i18n.js +0 -860
- package/dist/i18n.js.map +0 -1
- package/dist/index.d.ts +0 -33
- package/dist/index.js +0 -13062
- package/dist/index.js.map +0 -1
- package/dist/padding-DY0JV5Ja.d.ts +0 -16
- package/dist/preferences.d.ts +0 -132
- package/dist/preferences.js +0 -262
- package/dist/preferences.js.map +0 -1
- package/dist/props.d.ts +0 -86
- package/dist/props.js +0 -16
- package/dist/props.js.map +0 -1
- package/dist/size-CQwNvOWd.d.ts +0 -19
- package/dist/types-LTj-2bl-.d.ts +0 -30
- package/dist/useTableViews-D5NIAJ7h.d.ts +0 -154
- package/src/tokens/tailwind.css +0 -158
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { renderWithUi, screen, userEvent, waitFor } from "@/test/render";
|
|
3
|
+
import { Label } from "../label";
|
|
4
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../select";
|
|
5
|
+
|
|
6
|
+
describe("Label", () => {
|
|
7
|
+
it("associates with control via htmlFor", () => {
|
|
8
|
+
renderWithUi(
|
|
9
|
+
<>
|
|
10
|
+
<Label htmlFor="hawb">Mã HAWB</Label>
|
|
11
|
+
<input id="hawb" aria-label="Mã HAWB" />
|
|
12
|
+
</>,
|
|
13
|
+
);
|
|
14
|
+
expect(screen.getByText("Mã HAWB")).toHaveAttribute("for", "hawb");
|
|
15
|
+
expect(screen.getByText("Mã HAWB")).toHaveAttribute("data-slot", "label");
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
describe("Select", () => {
|
|
20
|
+
it("opens listbox and selects an option", async () => {
|
|
21
|
+
const user = userEvent.setup();
|
|
22
|
+
const onChange = vi.fn();
|
|
23
|
+
renderWithUi(
|
|
24
|
+
<Select onValueChange={onChange}>
|
|
25
|
+
<SelectTrigger aria-label="Hub">
|
|
26
|
+
<SelectValue placeholder="Chọn hub" />
|
|
27
|
+
</SelectTrigger>
|
|
28
|
+
<SelectContent>
|
|
29
|
+
<SelectItem value="osaka">Osaka</SelectItem>
|
|
30
|
+
<SelectItem value="tokyo">Tokyo</SelectItem>
|
|
31
|
+
</SelectContent>
|
|
32
|
+
</Select>,
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
await user.click(screen.getByRole("combobox", { name: "Hub" }));
|
|
36
|
+
await waitFor(() => {
|
|
37
|
+
expect(screen.getByRole("option", { name: "Osaka" })).toHaveAttribute(
|
|
38
|
+
"data-slot",
|
|
39
|
+
"select-item",
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
await user.click(screen.getByRole("option", { name: "Osaka" }));
|
|
43
|
+
expect(onChange).toHaveBeenCalledWith("osaka");
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("SelectTrigger uses ui-control from control-styles", () => {
|
|
47
|
+
renderWithUi(
|
|
48
|
+
<Select>
|
|
49
|
+
<SelectTrigger aria-label="Hub">
|
|
50
|
+
<SelectValue placeholder="Chọn hub" />
|
|
51
|
+
</SelectTrigger>
|
|
52
|
+
<SelectContent>
|
|
53
|
+
<SelectItem value="osaka">Osaka</SelectItem>
|
|
54
|
+
</SelectContent>
|
|
55
|
+
</Select>,
|
|
56
|
+
);
|
|
57
|
+
const trigger = screen.getByRole("combobox", { name: "Hub" });
|
|
58
|
+
expect(trigger).toHaveClass("ui-control");
|
|
59
|
+
expect(trigger).toHaveAttribute("data-slot", "select-trigger");
|
|
60
|
+
expect(trigger).toHaveAttribute("data-size", "default");
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { renderWithUi, screen, userEvent } from "@/test/render";
|
|
3
|
+
import { Switch } from "../switch";
|
|
4
|
+
import { Slider } from "../slider";
|
|
5
|
+
import { ColorPicker } from "../color-picker";
|
|
6
|
+
import { TimePicker } from "../time-picker";
|
|
7
|
+
|
|
8
|
+
describe("Switch", () => {
|
|
9
|
+
it("toggles checked state", async () => {
|
|
10
|
+
const user = userEvent.setup();
|
|
11
|
+
renderWithUi(<Switch aria-label="Notify" />);
|
|
12
|
+
const control = screen.getByRole("switch", { name: "Notify" });
|
|
13
|
+
expect(control).toHaveAttribute("data-slot", "switch");
|
|
14
|
+
expect(control).toHaveAttribute("data-size", "default");
|
|
15
|
+
expect(control).toHaveAttribute("data-state", "unchecked");
|
|
16
|
+
await user.click(control);
|
|
17
|
+
expect(control).toHaveAttribute("data-state", "checked");
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
describe("Slider", () => {
|
|
22
|
+
it("renders thumb control", () => {
|
|
23
|
+
const { container } = renderWithUi(<Slider defaultValue={[40]} aria-label="Percent" />);
|
|
24
|
+
expect(container.querySelector('[data-slot="slider"]')).toBeInTheDocument();
|
|
25
|
+
expect(screen.getAllByRole("slider")[0]).toHaveAttribute("data-slot", "slider-thumb");
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe("ColorPicker", () => {
|
|
30
|
+
it("calls onChange with hex value on blur", async () => {
|
|
31
|
+
const user = userEvent.setup();
|
|
32
|
+
const onChange = vi.fn();
|
|
33
|
+
renderWithUi(<ColorPicker value="#2563eb" onChange={onChange} />);
|
|
34
|
+
const hexInput = screen.getByRole("textbox");
|
|
35
|
+
await user.clear(hexInput);
|
|
36
|
+
await user.type(hexInput, "#ff0000");
|
|
37
|
+
await user.tab();
|
|
38
|
+
expect(onChange).toHaveBeenCalledWith("#ff0000");
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe("TimePicker", () => {
|
|
43
|
+
it("renders trigger button with clock and formatted time", () => {
|
|
44
|
+
renderWithUi(<TimePicker defaultValue="09:30" id="cutoff" />);
|
|
45
|
+
expect(screen.getByRole("button", { name: /09:30|9:30/i })).toBeInTheDocument();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("opens panel and selects minute", async () => {
|
|
49
|
+
const user = userEvent.setup();
|
|
50
|
+
const onChange = vi.fn();
|
|
51
|
+
renderWithUi(<TimePicker defaultValue="09:00" onChange={onChange} minuteStep={15} id="t" />);
|
|
52
|
+
|
|
53
|
+
await user.click(screen.getByRole("button"));
|
|
54
|
+
expect(screen.getByText("Giờ")).toBeInTheDocument();
|
|
55
|
+
expect(screen.getByText("Phút")).toBeInTheDocument();
|
|
56
|
+
|
|
57
|
+
const minute45 = screen
|
|
58
|
+
.getAllByRole("button", { name: "45" })
|
|
59
|
+
.find((el) => el.closest(".h-52"));
|
|
60
|
+
expect(minute45).toBeDefined();
|
|
61
|
+
await user.click(minute45!);
|
|
62
|
+
expect(onChange).toHaveBeenCalledWith("09:45");
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("opens scroll columns for hour and minute", async () => {
|
|
66
|
+
const user = userEvent.setup();
|
|
67
|
+
renderWithUi(<TimePicker defaultValue="09:00" minuteStep={15} id="t" />);
|
|
68
|
+
|
|
69
|
+
await user.click(screen.getByRole("button"));
|
|
70
|
+
expect(screen.getByText("Giờ")).toBeInTheDocument();
|
|
71
|
+
expect(screen.getByText("Phút")).toBeInTheDocument();
|
|
72
|
+
expect(screen.getByLabelText("Nhập giờ HH:mm")).toBeInTheDocument();
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { renderWithUi, screen, userEvent } from "@/test/render";
|
|
3
|
+
import { Radio } from "../radio";
|
|
4
|
+
|
|
5
|
+
const shipMethods = [
|
|
6
|
+
{ label: "Air — 3–5 ngày", value: "air" },
|
|
7
|
+
{ label: "Sea — 14–21 ngày", value: "sea" },
|
|
8
|
+
{ label: "Express Osaka", value: "express", disabled: true },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
describe("Radio.Group", () => {
|
|
12
|
+
it("renders radiogroup from options", () => {
|
|
13
|
+
renderWithUi(<Radio.Group options={shipMethods} defaultValue="air" aria-label="Ship method" />);
|
|
14
|
+
expect(screen.getByRole("radiogroup")).toHaveAttribute("data-slot", "radio-group");
|
|
15
|
+
expect(screen.getByRole("radio", { name: /Air/ })).toHaveAttribute(
|
|
16
|
+
"data-slot",
|
|
17
|
+
"radio-group-item",
|
|
18
|
+
);
|
|
19
|
+
expect(screen.getByRole("radio", { name: /Air/ })).toBeChecked();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("calls onValueChange when selection changes", async () => {
|
|
23
|
+
const user = userEvent.setup();
|
|
24
|
+
const onValueChange = vi.fn();
|
|
25
|
+
renderWithUi(
|
|
26
|
+
<Radio.Group options={shipMethods} defaultValue="air" onValueChange={onValueChange} />,
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
await user.click(screen.getByRole("radio", { name: /Sea/ }));
|
|
30
|
+
expect(onValueChange).toHaveBeenCalledWith("sea");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("skips disabled options", async () => {
|
|
34
|
+
const user = userEvent.setup();
|
|
35
|
+
renderWithUi(<Radio.Group options={shipMethods} defaultValue="air" />);
|
|
36
|
+
expect(screen.getByRole("radio", { name: /Express Osaka/ })).toBeDisabled();
|
|
37
|
+
await user.click(screen.getByRole("radio", { name: /Express Osaka/ }));
|
|
38
|
+
expect(screen.getByRole("radio", { name: /Air/ })).toBeChecked();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe("Radio namespace", () => {
|
|
43
|
+
it("exposes Group on Radio.Group", () => {
|
|
44
|
+
expect(Radio.Group).toBeDefined();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { renderWithUi, screen, userEvent, waitFor } from "@/test/render";
|
|
3
|
+
import { SearchInput } from "../search-input";
|
|
4
|
+
|
|
5
|
+
describe("SearchInput", () => {
|
|
6
|
+
it("debounces onSearch callback", async () => {
|
|
7
|
+
vi.useFakeTimers({ shouldAdvanceTime: true });
|
|
8
|
+
const onSearch = vi.fn();
|
|
9
|
+
renderWithUi(<SearchInput onSearch={onSearch} debounce={200} label="Search" />);
|
|
10
|
+
|
|
11
|
+
const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime });
|
|
12
|
+
await user.type(screen.getByRole("searchbox"), "hello");
|
|
13
|
+
|
|
14
|
+
expect(onSearch).not.toHaveBeenCalledWith("hello");
|
|
15
|
+
await vi.advanceTimersByTimeAsync(200);
|
|
16
|
+
await waitFor(() => {
|
|
17
|
+
expect(onSearch).toHaveBeenCalledWith("hello");
|
|
18
|
+
});
|
|
19
|
+
vi.useRealTimers();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("shows clear button when value present and clears on click", async () => {
|
|
23
|
+
const user = userEvent.setup();
|
|
24
|
+
renderWithUi(
|
|
25
|
+
<SearchInput onSearch={() => undefined} debounce={9999} label="Search" defaultValue="x" />,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
expect(screen.getAllByRole("button", { name: "Xóa tìm kiếm" })).toHaveLength(1);
|
|
29
|
+
await user.click(screen.getByRole("button", { name: "Xóa tìm kiếm" }));
|
|
30
|
+
expect(screen.getByRole("searchbox")).toHaveValue("");
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { renderWithUi, screen } from "@/test/render";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
|
|
5
|
+
import { SwitchField } from "../switch-field";
|
|
6
|
+
|
|
7
|
+
describe("SwitchField", () => {
|
|
8
|
+
it("links label to switch and submits hidden 0/1", async () => {
|
|
9
|
+
const user = userEvent.setup();
|
|
10
|
+
|
|
11
|
+
renderWithUi(
|
|
12
|
+
<form aria-label="test">
|
|
13
|
+
<SwitchField id="active" name="is_active" label="Active" defaultChecked={false} />
|
|
14
|
+
</form>,
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
const toggle = screen.getByRole("switch", { name: "Active" });
|
|
18
|
+
expect(toggle).toHaveAttribute("aria-checked", "false");
|
|
19
|
+
|
|
20
|
+
const hidden = document.querySelector('input[type="hidden"][name="is_active"]');
|
|
21
|
+
expect(hidden).toHaveValue("0");
|
|
22
|
+
|
|
23
|
+
await user.click(toggle);
|
|
24
|
+
expect(toggle).toHaveAttribute("aria-checked", "true");
|
|
25
|
+
expect(hidden).toHaveValue("1");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("shows error and wires aria-invalid on the switch", () => {
|
|
29
|
+
renderWithUi(<SwitchField id="flag" name="flag" label="Flag" error="Invalid" defaultChecked />);
|
|
30
|
+
|
|
31
|
+
expect(screen.getByRole("alert")).toHaveTextContent("Invalid");
|
|
32
|
+
expect(screen.getByRole("switch")).toHaveAttribute("aria-invalid", "true");
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("supports controlled checked state", async () => {
|
|
36
|
+
const user = userEvent.setup();
|
|
37
|
+
const onCheckedChange = vi.fn();
|
|
38
|
+
|
|
39
|
+
renderWithUi(
|
|
40
|
+
<SwitchField
|
|
41
|
+
id="dg"
|
|
42
|
+
name="is_dg"
|
|
43
|
+
label="Dangerous goods"
|
|
44
|
+
checked={false}
|
|
45
|
+
onCheckedChange={onCheckedChange}
|
|
46
|
+
/>,
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
await user.click(screen.getByRole("switch"));
|
|
50
|
+
expect(onCheckedChange).toHaveBeenCalledWith(true);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { renderHook, act } from "@testing-library/react";
|
|
4
|
+
import { renderWithUi, screen, userEvent } from "@/test/render";
|
|
5
|
+
import { Upload } from "../upload";
|
|
6
|
+
import { collectUploadCommitActions, type UploadFileItem } from "../upload-types";
|
|
7
|
+
import { useUploadDraft } from "../use-upload-draft";
|
|
8
|
+
|
|
9
|
+
describe("collectUploadCommitActions", () => {
|
|
10
|
+
it("collects delete + promote for avatar replace", () => {
|
|
11
|
+
const items: UploadFileItem[] = [
|
|
12
|
+
{
|
|
13
|
+
uid: "1",
|
|
14
|
+
name: "new.jpg",
|
|
15
|
+
size: 100,
|
|
16
|
+
mediaId: "temp-new",
|
|
17
|
+
status: "done",
|
|
18
|
+
pendingReplace: true,
|
|
19
|
+
replacesMediaId: "old-perm",
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
expect(collectUploadCommitActions(items)).toEqual({
|
|
23
|
+
deleteMediaIds: ["old-perm"],
|
|
24
|
+
promoteMediaIds: ["temp-new"],
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("collects delete only for pending delete", () => {
|
|
29
|
+
const items: UploadFileItem[] = [
|
|
30
|
+
{
|
|
31
|
+
uid: "1",
|
|
32
|
+
name: "avatar.jpg",
|
|
33
|
+
size: 100,
|
|
34
|
+
mediaId: "perm-1",
|
|
35
|
+
status: "removed",
|
|
36
|
+
pendingDelete: true,
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
expect(collectUploadCommitActions(items)).toEqual({
|
|
40
|
+
deleteMediaIds: ["perm-1"],
|
|
41
|
+
promoteMediaIds: [],
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
describe("useUploadDraft", () => {
|
|
47
|
+
const baseline: UploadFileItem = {
|
|
48
|
+
uid: "b",
|
|
49
|
+
name: "avatar.jpg",
|
|
50
|
+
size: 1,
|
|
51
|
+
mediaId: "media-old",
|
|
52
|
+
previewUrl: "https://cdn/avatar.jpg",
|
|
53
|
+
status: "done",
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
it("marks remove and undo restores baseline", () => {
|
|
57
|
+
const onChange = vi.fn();
|
|
58
|
+
const { result, rerender } = renderHook(({ value }) => useUploadDraft({ value, onChange }), {
|
|
59
|
+
initialProps: { value: baseline },
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
act(() => result.current.markRemove());
|
|
63
|
+
expect(onChange).toHaveBeenCalledWith(
|
|
64
|
+
expect.objectContaining({ pendingDelete: true, mediaId: "media-old" }),
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
rerender({ value: { ...baseline, pendingDelete: true, status: "removed" } });
|
|
68
|
+
act(() => result.current.undoRemove());
|
|
69
|
+
expect(onChange).toHaveBeenLastCalledWith(
|
|
70
|
+
expect.objectContaining({ pendingDelete: false, mediaId: "media-old" }),
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("getCommitActions returns promote + delete on replace", () => {
|
|
75
|
+
const replaced: UploadFileItem = {
|
|
76
|
+
uid: "n",
|
|
77
|
+
name: "new.jpg",
|
|
78
|
+
size: 2,
|
|
79
|
+
mediaId: "media-new",
|
|
80
|
+
status: "done",
|
|
81
|
+
pendingReplace: true,
|
|
82
|
+
replacesMediaId: "media-old",
|
|
83
|
+
};
|
|
84
|
+
const { result } = renderHook(() => useUploadDraft({ value: replaced }));
|
|
85
|
+
expect(result.current.getCommitActions()).toEqual({
|
|
86
|
+
deleteMediaIds: ["media-old"],
|
|
87
|
+
promoteMediaIds: ["media-new"],
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
describe("Upload", () => {
|
|
93
|
+
it("renders dropzone variant", () => {
|
|
94
|
+
renderWithUi(<Upload variant="dropzone" />);
|
|
95
|
+
expect(screen.getByRole("button", { name: /tải file lên/i })).toBeInTheDocument();
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("shows undo banner after avatar remove", async () => {
|
|
99
|
+
const user = userEvent.setup();
|
|
100
|
+
|
|
101
|
+
function AvatarDemo() {
|
|
102
|
+
const [items, setItems] = React.useState<UploadFileItem[]>([
|
|
103
|
+
{
|
|
104
|
+
uid: "1",
|
|
105
|
+
name: "avatar.jpg",
|
|
106
|
+
size: 100,
|
|
107
|
+
mediaId: "m1",
|
|
108
|
+
previewUrl: "https://example.com/a.jpg",
|
|
109
|
+
status: "done",
|
|
110
|
+
},
|
|
111
|
+
]);
|
|
112
|
+
return <Upload variant="avatar" value={items} onChange={setItems} removable />;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
renderWithUi(<AvatarDemo />);
|
|
116
|
+
await user.click(screen.getByRole("button", { name: /xóa ảnh/i }));
|
|
117
|
+
expect(screen.getByText(/ảnh sẽ bị xóa khi bạn lưu/i)).toBeInTheDocument();
|
|
118
|
+
expect(screen.getByRole("button", { name: /hoàn tác/i })).toBeInTheDocument();
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("renders avatar placeholder when empty", () => {
|
|
122
|
+
renderWithUi(<Upload variant="avatar" value={[]} onChange={() => undefined} />);
|
|
123
|
+
expect(screen.getByRole("button", { name: /ảnh đại diện/i })).toBeInTheDocument();
|
|
124
|
+
});
|
|
125
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Check, ChevronsUpDown } from "lucide-react";
|
|
3
|
+
import { useTranslation } from "../../i18n/use-translation";
|
|
4
|
+
import { cn } from "../../lib/utils";
|
|
5
|
+
import { Button } from "../general/button";
|
|
6
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../data-display/popover";
|
|
7
|
+
import {
|
|
8
|
+
Command,
|
|
9
|
+
CommandEmpty,
|
|
10
|
+
CommandGroup,
|
|
11
|
+
CommandInput,
|
|
12
|
+
CommandItem,
|
|
13
|
+
CommandList,
|
|
14
|
+
} from "./command";
|
|
15
|
+
import type { AutocompleteProp } from "../../props/components/data-entry.prop";
|
|
16
|
+
|
|
17
|
+
export type {
|
|
18
|
+
AutocompleteProp,
|
|
19
|
+
AutocompleteProp as AutocompleteProps,
|
|
20
|
+
} from "../../props/components/data-entry.prop";
|
|
21
|
+
|
|
22
|
+
export function Autocomplete({
|
|
23
|
+
options,
|
|
24
|
+
value,
|
|
25
|
+
onValueChange,
|
|
26
|
+
placeholder,
|
|
27
|
+
emptyMessage,
|
|
28
|
+
disabled,
|
|
29
|
+
className,
|
|
30
|
+
id,
|
|
31
|
+
searchPlaceholder,
|
|
32
|
+
}: AutocompleteProp) {
|
|
33
|
+
const { t } = useTranslation();
|
|
34
|
+
const [open, setOpen] = React.useState(false);
|
|
35
|
+
const selected = options.find((option) => option.value === value);
|
|
36
|
+
const resolvedPlaceholder = placeholder ?? t("dataEntry.autocomplete.placeholder");
|
|
37
|
+
const resolvedEmpty = emptyMessage ?? t("dataEntry.autocomplete.empty");
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<Popover open={open} onOpenChange={setOpen}>
|
|
41
|
+
<PopoverTrigger asChild>
|
|
42
|
+
<Button
|
|
43
|
+
id={id}
|
|
44
|
+
type="button"
|
|
45
|
+
variant="outline"
|
|
46
|
+
role="combobox"
|
|
47
|
+
aria-expanded={open}
|
|
48
|
+
disabled={disabled}
|
|
49
|
+
className={cn(
|
|
50
|
+
"w-full justify-between font-normal",
|
|
51
|
+
!selected && "text-muted-foreground",
|
|
52
|
+
className,
|
|
53
|
+
)}
|
|
54
|
+
>
|
|
55
|
+
<span className="truncate">{selected?.label ?? resolvedPlaceholder}</span>
|
|
56
|
+
<ChevronsUpDown className="ml-2 size-4 shrink-0 opacity-50" aria-hidden="true" />
|
|
57
|
+
</Button>
|
|
58
|
+
</PopoverTrigger>
|
|
59
|
+
<PopoverContent className="w-[var(--radix-popover-trigger-width)] p-0" align="start">
|
|
60
|
+
<Command>
|
|
61
|
+
<CommandInput placeholder={searchPlaceholder ?? resolvedPlaceholder} />
|
|
62
|
+
<CommandList>
|
|
63
|
+
<CommandEmpty>{resolvedEmpty}</CommandEmpty>
|
|
64
|
+
<CommandGroup>
|
|
65
|
+
{options.map((option) => (
|
|
66
|
+
<CommandItem
|
|
67
|
+
key={option.value}
|
|
68
|
+
value={option.label}
|
|
69
|
+
keywords={[option.value, option.label]}
|
|
70
|
+
onSelect={() => {
|
|
71
|
+
onValueChange?.(option.value);
|
|
72
|
+
setOpen(false);
|
|
73
|
+
}}
|
|
74
|
+
>
|
|
75
|
+
<Check
|
|
76
|
+
className={cn(
|
|
77
|
+
"mr-2 size-4",
|
|
78
|
+
value === option.value ? "opacity-100" : "opacity-0",
|
|
79
|
+
)}
|
|
80
|
+
aria-hidden="true"
|
|
81
|
+
/>
|
|
82
|
+
{option.label}
|
|
83
|
+
</CommandItem>
|
|
84
|
+
))}
|
|
85
|
+
</CommandGroup>
|
|
86
|
+
</CommandList>
|
|
87
|
+
</Command>
|
|
88
|
+
</PopoverContent>
|
|
89
|
+
</Popover>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
2
|
+
import { DayPicker } from "react-day-picker";
|
|
3
|
+
import { cn } from "../../lib/utils";
|
|
4
|
+
import { controlIconSmClass } from "../../lib/control-styles";
|
|
5
|
+
import { buttonVariants } from "../general/button";
|
|
6
|
+
import type { CalendarProp } from "../../props/components/data-entry.prop";
|
|
7
|
+
|
|
8
|
+
export type {
|
|
9
|
+
CalendarProp,
|
|
10
|
+
CalendarProp as CalendarProps,
|
|
11
|
+
} from "../../props/components/data-entry.prop";
|
|
12
|
+
|
|
13
|
+
export function Calendar({
|
|
14
|
+
className,
|
|
15
|
+
classNames,
|
|
16
|
+
showOutsideDays = true,
|
|
17
|
+
...props
|
|
18
|
+
}: CalendarProp) {
|
|
19
|
+
return (
|
|
20
|
+
<DayPicker
|
|
21
|
+
showOutsideDays={showOutsideDays}
|
|
22
|
+
className={cn("p-3", className)}
|
|
23
|
+
classNames={{
|
|
24
|
+
months: cn("flex flex-col gap-4 sm:flex-row", classNames?.months),
|
|
25
|
+
month: cn("relative flex flex-col gap-4", classNames?.month),
|
|
26
|
+
month_caption: cn(
|
|
27
|
+
"flex h-[length:var(--control-height)] w-full items-center justify-center px-8",
|
|
28
|
+
classNames?.month_caption,
|
|
29
|
+
),
|
|
30
|
+
caption_label: cn("text-sm font-medium", classNames?.caption_label),
|
|
31
|
+
nav: cn("absolute inset-x-0 top-3 flex items-center justify-between px-1", classNames?.nav),
|
|
32
|
+
button_previous: cn(
|
|
33
|
+
buttonVariants({ variant: "outline" }),
|
|
34
|
+
controlIconSmClass,
|
|
35
|
+
"bg-transparent p-0 opacity-70 hover:opacity-100",
|
|
36
|
+
classNames?.button_previous,
|
|
37
|
+
),
|
|
38
|
+
button_next: cn(
|
|
39
|
+
buttonVariants({ variant: "outline" }),
|
|
40
|
+
controlIconSmClass,
|
|
41
|
+
"bg-transparent p-0 opacity-70 hover:opacity-100",
|
|
42
|
+
classNames?.button_next,
|
|
43
|
+
),
|
|
44
|
+
month_grid: cn("mt-4 w-full border-collapse", classNames?.month_grid),
|
|
45
|
+
weekdays: cn("flex", classNames?.weekdays),
|
|
46
|
+
weekday: cn(
|
|
47
|
+
"w-[length:var(--control-height)] rounded-md text-xs font-normal text-muted-foreground",
|
|
48
|
+
classNames?.weekday,
|
|
49
|
+
),
|
|
50
|
+
week: cn("mt-2 flex w-full", classNames?.week),
|
|
51
|
+
day: cn(
|
|
52
|
+
"relative p-0 text-center text-sm focus-within:relative focus-within:z-20",
|
|
53
|
+
"[&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50",
|
|
54
|
+
"[&:has([aria-selected].day-range-end)]:rounded-r-md",
|
|
55
|
+
classNames?.day,
|
|
56
|
+
),
|
|
57
|
+
day_button: cn(
|
|
58
|
+
buttonVariants({ variant: "ghost" }),
|
|
59
|
+
"size-[length:var(--control-height)] p-0 font-normal aria-selected:opacity-100",
|
|
60
|
+
classNames?.day_button,
|
|
61
|
+
),
|
|
62
|
+
range_start: cn("day-range-start rounded-l-md", classNames?.range_start),
|
|
63
|
+
range_end: cn("day-range-end rounded-r-md", classNames?.range_end),
|
|
64
|
+
range_middle: cn(
|
|
65
|
+
"aria-selected:bg-accent aria-selected:text-accent-foreground",
|
|
66
|
+
classNames?.range_middle,
|
|
67
|
+
),
|
|
68
|
+
selected: cn(
|
|
69
|
+
"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
|
|
70
|
+
classNames?.selected,
|
|
71
|
+
),
|
|
72
|
+
today: cn("bg-accent text-accent-foreground", classNames?.today),
|
|
73
|
+
outside: cn(
|
|
74
|
+
"day-outside text-muted-foreground aria-selected:text-muted-foreground",
|
|
75
|
+
classNames?.outside,
|
|
76
|
+
),
|
|
77
|
+
disabled: cn("text-muted-foreground opacity-50", classNames?.disabled),
|
|
78
|
+
hidden: cn("invisible", classNames?.hidden),
|
|
79
|
+
...classNames,
|
|
80
|
+
}}
|
|
81
|
+
components={{
|
|
82
|
+
Chevron: ({ orientation, className: chevronClassName }) => {
|
|
83
|
+
const Icon = orientation === "left" ? ChevronLeft : ChevronRight;
|
|
84
|
+
return <Icon className={cn("size-4", chevronClassName)} aria-hidden="true" />;
|
|
85
|
+
},
|
|
86
|
+
}}
|
|
87
|
+
{...props}
|
|
88
|
+
/>
|
|
89
|
+
);
|
|
90
|
+
}
|