@object-ui/components 0.3.1 → 2.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/.turbo/turbo-build.log +34 -0
- package/CHANGELOG.md +13 -0
- package/README.md +13 -0
- package/dist/index.css +1 -1
- package/dist/index.js +36430 -25529
- package/dist/index.umd.cjs +53 -32
- package/dist/src/SchemaRenderer.d.ts +3 -0
- package/dist/src/custom/action-param-dialog.d.ts +21 -0
- package/dist/src/{ui → custom}/button-group.d.ts +1 -1
- package/dist/src/custom/field.d.ts +19 -0
- package/dist/src/custom/index.d.ts +14 -0
- package/dist/src/custom/input-group.d.ts +14 -0
- package/dist/src/{ui → custom}/item.d.ts +1 -1
- package/dist/src/custom/native-select.d.ts +12 -0
- package/dist/src/custom/navigation-overlay.d.ts +50 -0
- package/dist/src/custom/sort-builder.d.ts +22 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/renderers/action/action-button.d.ts +11 -0
- package/dist/src/renderers/action/action-group.d.ts +25 -0
- package/dist/src/renderers/action/action-icon.d.ts +10 -0
- package/dist/src/renderers/action/action-menu.d.ts +19 -0
- package/dist/src/renderers/action/index.d.ts +0 -0
- package/dist/src/renderers/action/resolve-icon.d.ts +6 -0
- package/dist/src/renderers/data-display/table.d.ts +1 -1
- package/dist/src/renderers/layout/page.d.ts +1 -1
- package/dist/src/renderers/placeholders.d.ts +1 -1
- package/dist/src/ui/accordion.d.ts +4 -4
- package/dist/src/ui/alert-dialog.d.ts +17 -11
- package/dist/src/ui/alert.d.ts +4 -5
- package/dist/src/ui/aspect-ratio.d.ts +1 -1
- package/dist/src/ui/avatar.d.ts +3 -3
- package/dist/src/ui/badge.d.ts +3 -3
- package/dist/src/ui/breadcrumb.d.ts +16 -8
- package/dist/src/ui/calendar.d.ts +7 -7
- package/dist/src/ui/card.d.ts +7 -8
- package/dist/src/ui/carousel.d.ts +5 -6
- package/dist/src/ui/chart.d.ts +62 -0
- package/dist/src/ui/checkbox.d.ts +1 -1
- package/dist/src/ui/collapsible.d.ts +3 -3
- package/dist/src/ui/command.d.ts +78 -16
- package/dist/src/ui/context-menu.d.ts +14 -12
- package/dist/src/ui/dialog.d.ts +17 -13
- package/dist/src/ui/drawer.d.ts +19 -10
- package/dist/src/ui/dropdown-menu.d.ts +20 -18
- package/dist/src/ui/form.d.ts +6 -7
- package/dist/src/ui/hover-card.d.ts +3 -3
- package/dist/src/ui/index.d.ts +2 -8
- package/dist/src/ui/input-otp.d.ts +30 -7
- package/dist/src/ui/label.d.ts +2 -1
- package/dist/src/ui/menubar.d.ts +19 -17
- package/dist/src/ui/navigation-menu.d.ts +9 -11
- package/dist/src/ui/pagination.d.ts +25 -10
- package/dist/src/ui/popover.d.ts +4 -5
- package/dist/src/ui/progress.d.ts +1 -1
- package/dist/src/ui/radio-group.d.ts +2 -2
- package/dist/src/ui/resizable.d.ts +5 -8
- package/dist/src/ui/scroll-area.d.ts +2 -2
- package/dist/src/ui/select.d.ts +11 -13
- package/dist/src/ui/sheet.d.ts +23 -11
- package/dist/src/ui/sidebar.d.ts +27 -29
- package/dist/src/ui/skeleton.d.ts +1 -1
- package/dist/src/ui/slider.d.ts +1 -1
- package/dist/src/ui/sonner.d.ts +2 -1
- package/dist/src/ui/switch.d.ts +2 -2
- package/dist/src/ui/tabs.d.ts +1 -1
- package/dist/src/ui/textarea.d.ts +1 -1
- package/dist/src/ui/toast.d.ts +22 -0
- package/dist/src/ui/toggle-group.d.ts +8 -3
- package/dist/src/ui/toggle.d.ts +4 -1
- package/dist/src/ui/tooltip.d.ts +4 -4
- package/dist/src/ui/typography.d.ts +21 -0
- package/package.json +20 -9
- package/shadcn-components.json +52 -47
- package/src/SchemaRenderer.tsx +28 -0
- package/src/__tests__/PageRendererRegions.test.tsx +668 -0
- package/src/__tests__/Registry.test.ts +21 -0
- package/src/__tests__/basic-renderers.test.tsx +1 -1
- package/src/__tests__/complex-disclosure-renderers.test.tsx +3 -2
- package/src/__tests__/compliance.test.tsx +72 -0
- package/src/__tests__/feedback-overlay-renderers.test.tsx +1 -1
- package/src/__tests__/form-renderers.test.tsx +1 -1
- package/src/__tests__/layout-data-renderers.test.tsx +1 -1
- package/src/__tests__/navigation-overlay.test.tsx +273 -0
- package/src/__tests__/view-compliance.test.tsx +153 -0
- package/src/custom/action-param-dialog.tsx +264 -0
- package/src/{ui → custom}/button-group.tsx +1 -1
- package/src/{ui → custom}/combobox.tsx +3 -3
- package/src/{ui → custom}/date-picker.tsx +3 -3
- package/src/custom/field.tsx +81 -0
- package/src/{ui → custom}/filter-builder.tsx +3 -3
- package/src/custom/index.ts +14 -0
- package/src/custom/input-group.tsx +53 -0
- package/src/{ui → custom}/item.tsx +1 -1
- package/src/custom/native-select.tsx +33 -0
- package/src/custom/navigation-overlay.tsx +296 -0
- package/src/custom/sort-builder.tsx +129 -0
- package/src/index.css +20 -1
- package/src/index.ts +2 -0
- package/src/renderers/action/action-button.tsx +147 -0
- package/src/renderers/action/action-group.tsx +270 -0
- package/src/renderers/action/action-icon.tsx +150 -0
- package/src/renderers/action/action-menu.tsx +203 -0
- package/src/renderers/action/index.ts +18 -0
- package/src/renderers/action/resolve-icon.ts +35 -0
- package/src/renderers/basic/button-group.tsx +1 -0
- package/src/renderers/basic/div.tsx +12 -1
- package/src/renderers/basic/html.tsx +1 -0
- package/src/renderers/basic/icon.tsx +1 -0
- package/src/renderers/basic/image.tsx +1 -0
- package/src/renderers/basic/navigation-menu.tsx +1 -0
- package/src/renderers/basic/pagination.tsx +31 -4
- package/src/renderers/basic/separator.tsx +1 -0
- package/src/renderers/basic/span.tsx +12 -1
- package/src/renderers/basic/text.tsx +4 -2
- package/src/renderers/complex/__tests__/data-table-batch-editing.test.tsx +275 -0
- package/src/renderers/complex/__tests__/data-table-cell-renderer.test.tsx +120 -0
- package/src/renderers/complex/__tests__/data-table-editing.test.tsx +221 -0
- package/src/renderers/complex/carousel.tsx +1 -0
- package/src/renderers/complex/data-table.tsx +355 -95
- package/src/renderers/complex/filter-builder.tsx +2 -1
- package/src/renderers/complex/resizable.tsx +2 -1
- package/src/renderers/complex/scroll-area.tsx +25 -7
- package/src/renderers/complex/table.tsx +1 -0
- package/src/renderers/data-display/alert.tsx +1 -0
- package/src/renderers/data-display/avatar.tsx +1 -0
- package/src/renderers/data-display/badge.tsx +1 -0
- package/src/renderers/data-display/breadcrumb.tsx +1 -0
- package/src/renderers/data-display/kbd.tsx +1 -0
- package/src/renderers/data-display/list.tsx +21 -49
- package/src/renderers/data-display/statistic.tsx +21 -5
- package/src/renderers/data-display/table.tsx +21 -11
- package/src/renderers/data-display/tree-view.tsx +7 -1
- package/src/renderers/disclosure/accordion.tsx +1 -0
- package/src/renderers/disclosure/collapsible.tsx +1 -0
- package/src/renderers/disclosure/toggle-group.tsx +2 -0
- package/src/renderers/feedback/empty.tsx +1 -0
- package/src/renderers/feedback/loading.tsx +2 -1
- package/src/renderers/feedback/progress.tsx +1 -0
- package/src/renderers/feedback/skeleton.tsx +1 -0
- package/src/renderers/feedback/sonner.tsx +1 -0
- package/src/renderers/feedback/spinner.tsx +1 -0
- package/src/renderers/feedback/toast.tsx +1 -0
- package/src/renderers/feedback/toaster.tsx +1 -0
- package/src/renderers/form/button.tsx +35 -1
- package/src/renderers/form/calendar.tsx +1 -0
- package/src/renderers/form/checkbox.tsx +38 -16
- package/src/renderers/form/combobox.tsx +2 -1
- package/src/renderers/form/command.tsx +1 -0
- package/src/renderers/form/date-picker.tsx +1 -0
- package/src/renderers/form/file-upload.tsx +1 -0
- package/src/renderers/form/form.tsx +115 -19
- package/src/renderers/form/input-otp.tsx +1 -0
- package/src/renderers/form/input.tsx +3 -0
- package/src/renderers/form/label.tsx +1 -0
- package/src/renderers/form/radio-group.tsx +1 -0
- package/src/renderers/form/select.tsx +35 -15
- package/src/renderers/form/slider.tsx +1 -0
- package/src/renderers/form/switch.tsx +1 -0
- package/src/renderers/form/textarea.tsx +50 -27
- package/src/renderers/form/toggle.tsx +3 -45
- package/src/renderers/index.ts +1 -0
- package/src/renderers/layout/aspect-ratio.tsx +2 -1
- package/src/renderers/layout/card.tsx +10 -2
- package/src/renderers/layout/container.tsx +1 -0
- package/src/renderers/layout/flex.tsx +1 -0
- package/src/renderers/layout/grid.tsx +23 -8
- package/src/renderers/layout/page.tsx +433 -57
- package/src/renderers/layout/semantic.tsx +1 -0
- package/src/renderers/layout/stack.tsx +2 -1
- package/src/renderers/layout/tabs.tsx +43 -17
- package/src/renderers/navigation/header-bar.tsx +1 -0
- package/src/renderers/navigation/sidebar.tsx +11 -0
- package/src/renderers/overlay/alert-dialog.tsx +1 -0
- package/src/renderers/overlay/context-menu.tsx +1 -0
- package/src/renderers/overlay/dialog.tsx +1 -0
- package/src/renderers/overlay/drawer.tsx +1 -0
- package/src/renderers/overlay/dropdown-menu.tsx +1 -0
- package/src/renderers/overlay/hover-card.tsx +1 -0
- package/src/renderers/overlay/menubar.tsx +1 -0
- package/src/renderers/overlay/popover.tsx +1 -0
- package/src/renderers/overlay/sheet.tsx +1 -0
- package/src/renderers/overlay/tooltip.tsx +1 -0
- package/src/renderers/placeholders.tsx +4 -4
- package/src/stories/CRMApp.stories.tsx +706 -0
- package/src/stories/Guide.mdx +55 -0
- package/src/stories/Introduction.mdx +61 -0
- package/src/stories/MockedData.stories.tsx +121 -0
- package/src/stories/assets/accessibility.png +0 -0
- package/src/stories/assets/accessibility.svg +1 -0
- package/src/stories/assets/addon-library.png +0 -0
- package/src/stories/assets/assets.png +0 -0
- package/src/stories/assets/avif-test-image.avif +0 -0
- package/src/stories/assets/context.png +0 -0
- package/src/stories/assets/discord.svg +1 -0
- package/src/stories/assets/docs.png +0 -0
- package/src/stories/assets/figma-plugin.png +0 -0
- package/src/stories/assets/github.svg +1 -0
- package/src/stories/assets/share.png +0 -0
- package/src/stories/assets/styling.png +0 -0
- package/src/stories/assets/testing.png +0 -0
- package/src/stories/assets/theming.png +0 -0
- package/src/stories/assets/tutorials.svg +1 -0
- package/src/stories/assets/youtube.svg +1 -0
- package/src/stories/button.css +30 -0
- package/src/stories/header.css +32 -0
- package/src/stories/page.css +68 -0
- package/src/stories-json/accordion.stories.tsx +43 -0
- package/src/stories-json/aggrid.stories.tsx +103 -0
- package/src/stories-json/alert.stories.tsx +39 -0
- package/src/stories-json/aspect-ratio.stories.tsx +34 -0
- package/src/stories-json/avatar.stories.tsx +38 -0
- package/src/stories-json/badge.stories.tsx +53 -0
- package/src/stories-json/breadcrumb.stories.tsx +30 -0
- package/src/stories-json/button-group.stories.tsx +43 -0
- package/src/stories-json/button.stories.tsx +73 -0
- package/src/stories-json/calendar.stories.tsx +85 -0
- package/src/stories-json/card.stories.tsx +48 -0
- package/src/stories-json/carousel.stories.tsx +33 -0
- package/src/stories-json/charts.stories.tsx +195 -0
- package/src/stories-json/chatbot.stories.tsx +248 -0
- package/src/stories-json/code-editor.stories.tsx +92 -0
- package/src/stories-json/collapsible.stories.tsx +40 -0
- package/src/stories-json/controls.stories.tsx +36 -0
- package/src/stories-json/crm-live-data.stories.tsx +154 -0
- package/src/stories-json/dashboard.stories.tsx +318 -0
- package/src/stories-json/data-table.stories.tsx +136 -0
- package/src/stories-json/data_display_extras.stories.tsx +102 -0
- package/src/stories-json/date-picker.stories.tsx +28 -0
- package/src/stories-json/detail-view.stories.tsx +258 -0
- package/src/stories-json/dialog.stories.tsx +43 -0
- package/src/stories-json/feedback_extras.stories.tsx +40 -0
- package/src/stories-json/feedback_others.stories.tsx +46 -0
- package/src/stories-json/form-variants.stories.tsx +210 -0
- package/src/stories-json/form_advanced.stories.tsx +117 -0
- package/src/stories-json/form_extras.stories.tsx +123 -0
- package/src/stories-json/grid.stories.tsx +56 -0
- package/src/stories-json/icon.stories.tsx +36 -0
- package/src/stories-json/input.stories.tsx +52 -0
- package/src/stories-json/kanban.stories.tsx +295 -0
- package/src/stories-json/layout_extended.stories.tsx +76 -0
- package/src/stories-json/layout_flex.stories.tsx +107 -0
- package/src/stories-json/list-view.stories.tsx +97 -0
- package/src/stories-json/markdown.stories.tsx +129 -0
- package/src/stories-json/menus.stories.tsx +63 -0
- package/src/stories-json/metric-card.stories.tsx +143 -0
- package/src/stories-json/navigation-menu.stories.tsx +37 -0
- package/src/stories-json/object-aggrid-advanced.stories.tsx +389 -0
- package/src/stories-json/object-aggrid.stories.tsx +252 -0
- package/src/stories-json/object-form.stories.tsx +130 -0
- package/src/stories-json/object-gantt.stories.tsx +114 -0
- package/src/stories-json/object-grid.stories.tsx +315 -0
- package/src/stories-json/object-map.stories.tsx +116 -0
- package/src/stories-json/object-view.stories.tsx +118 -0
- package/src/stories-json/overlay_extras.stories.tsx +113 -0
- package/src/stories-json/overlay_others.stories.tsx +76 -0
- package/src/stories-json/page.stories.tsx +55 -0
- package/src/stories-json/reports.stories.tsx +163 -0
- package/src/stories-json/resizable.stories.tsx +44 -0
- package/src/stories-json/select.stories.tsx +34 -0
- package/src/stories-json/separator.stories.tsx +41 -0
- package/src/stories-json/sidebar.stories.tsx +147 -0
- package/src/stories-json/statistic.stories.tsx +44 -0
- package/src/stories-json/tabs.stories.tsx +51 -0
- package/src/stories-json/timeline.stories.tsx +188 -0
- package/src/stories-json/typography.stories.tsx +45 -0
- package/src/ui/accordion.tsx +47 -53
- package/src/ui/alert-dialog.tsx +103 -117
- package/src/ui/alert.tsx +35 -36
- package/src/ui/aspect-ratio.tsx +1 -5
- package/src/ui/avatar.tsx +41 -42
- package/src/ui/badge.tsx +6 -15
- package/src/ui/breadcrumb.tsx +81 -75
- package/src/ui/button.tsx +10 -11
- package/src/ui/calendar.tsx +178 -51
- package/src/ui/card.tsx +51 -110
- package/src/ui/carousel.tsx +136 -113
- package/src/ui/chart.tsx +367 -0
- package/src/ui/checkbox.tsx +20 -22
- package/src/ui/collapsible.tsx +5 -25
- package/src/ui/command.tsx +106 -135
- package/src/ui/context-menu.tsx +69 -116
- package/src/ui/dialog.tsx +94 -113
- package/src/ui/drawer.tsx +82 -99
- package/src/ui/dropdown-menu.tsx +134 -188
- package/src/ui/form.tsx +51 -40
- package/src/ui/hover-card.tsx +18 -33
- package/src/ui/index.ts +2 -8
- package/src/ui/input-otp.tsx +42 -52
- package/src/ui/input.tsx +13 -15
- package/src/ui/label.tsx +17 -15
- package/src/ui/menubar.tsx +188 -206
- package/src/ui/navigation-menu.tsx +96 -136
- package/src/ui/pagination.tsx +86 -96
- package/src/ui/popover.tsx +24 -41
- package/src/ui/progress.tsx +21 -22
- package/src/ui/radio-group.tsx +19 -20
- package/src/ui/resizable.tsx +32 -42
- package/src/ui/scroll-area.tsx +38 -48
- package/src/ui/select.tsx +129 -157
- package/src/ui/separator.tsx +2 -2
- package/src/ui/sheet.tsx +110 -107
- package/src/ui/sidebar.tsx +442 -408
- package/src/ui/skeleton.tsx +6 -11
- package/src/ui/slider.tsx +19 -54
- package/src/ui/sonner.tsx +19 -1
- package/src/ui/switch.tsx +19 -21
- package/src/ui/tabs.tsx +6 -37
- package/src/ui/textarea.tsx +8 -4
- package/src/ui/toast.tsx +137 -0
- package/src/ui/toggle-group.tsx +28 -37
- package/src/ui/toggle.tsx +19 -19
- package/src/ui/tooltip.tsx +21 -52
- package/src/ui/typography.tsx +85 -0
- package/tsconfig.json +1 -1
- package/vite.config.ts +9 -1
- package/vitest.config.ts +5 -0
- package/ISSUES_FOUND.md +0 -128
- /package/dist/src/{ui → custom}/combobox.d.ts +0 -0
- /package/dist/src/{ui → custom}/date-picker.d.ts +0 -0
- /package/dist/src/{ui → custom}/empty.d.ts +0 -0
- /package/dist/src/{ui → custom}/filter-builder.d.ts +0 -0
- /package/dist/src/{ui → custom}/kbd.d.ts +0 -0
- /package/dist/src/{ui → custom}/spinner.d.ts +0 -0
- /package/src/{ui → custom}/empty.tsx +0 -0
- /package/src/{ui → custom}/kbd.tsx +0 -0
- /package/src/{ui → custom}/spinner.tsx +0 -0
|
@@ -13,6 +13,16 @@ import { forwardRef } from 'react';
|
|
|
13
13
|
|
|
14
14
|
const DivRenderer = forwardRef<HTMLDivElement, { schema: DivSchema; className?: string; [key: string]: any }>(
|
|
15
15
|
({ schema, className, ...props }, ref) => {
|
|
16
|
+
// Deprecation warning
|
|
17
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
18
|
+
console.warn(
|
|
19
|
+
'[ObjectUI] The "div" component is deprecated. Please use Shadcn components instead:\n' +
|
|
20
|
+
' - For containers: use "card", "flex", or semantic layout components\n' +
|
|
21
|
+
' - For simple wrappers: use layout components like "container", "stack", or "grid"\n' +
|
|
22
|
+
'See documentation at https://www.objectui.org/docs/components for alternatives.'
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
16
26
|
// Extract designer-related props
|
|
17
27
|
const {
|
|
18
28
|
'data-obj-id': dataObjId,
|
|
@@ -38,7 +48,8 @@ const DivRenderer = forwardRef<HTMLDivElement, { schema: DivSchema; className?:
|
|
|
38
48
|
ComponentRegistry.register('div',
|
|
39
49
|
DivRenderer,
|
|
40
50
|
{
|
|
41
|
-
|
|
51
|
+
namespace: 'ui',
|
|
52
|
+
label: 'Container (Deprecated)',
|
|
42
53
|
inputs: [
|
|
43
54
|
{ name: 'className', type: 'string', label: 'CSS Class' }
|
|
44
55
|
],
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { ComponentRegistry } from '@object-ui/core';
|
|
10
10
|
import type { PaginationSchema } from '@object-ui/types';
|
|
11
11
|
import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious } from '../../ui/pagination';
|
|
12
|
+
import React from 'react';
|
|
12
13
|
|
|
13
14
|
ComponentRegistry.register('pagination',
|
|
14
15
|
({ schema, ...props }: { schema: PaginationSchema; [key: string]: any }) => {
|
|
@@ -16,13 +17,23 @@ ComponentRegistry.register('pagination',
|
|
|
16
17
|
'data-obj-id': dataObjId,
|
|
17
18
|
'data-obj-type': dataObjType,
|
|
18
19
|
style,
|
|
20
|
+
onPageChange,
|
|
19
21
|
...paginationProps
|
|
20
22
|
} = props;
|
|
21
23
|
|
|
22
24
|
const currentPage = schema.currentPage || schema.page || 1;
|
|
23
25
|
const totalPages = schema.totalPages || 1;
|
|
24
|
-
const showEllipsis = totalPages > 7;
|
|
25
26
|
|
|
27
|
+
const handlePageChange = (page: number, e: React.MouseEvent) => {
|
|
28
|
+
e.preventDefault();
|
|
29
|
+
if (page === currentPage) return;
|
|
30
|
+
if (page < 1 || page > totalPages) return;
|
|
31
|
+
|
|
32
|
+
if (onPageChange) {
|
|
33
|
+
onPageChange(page);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
26
37
|
const getPageNumbers = () => {
|
|
27
38
|
if (totalPages <= 7) {
|
|
28
39
|
return Array.from({ length: totalPages }, (_, i) => i + 1);
|
|
@@ -47,27 +58,43 @@ ComponentRegistry.register('pagination',
|
|
|
47
58
|
>
|
|
48
59
|
<PaginationContent>
|
|
49
60
|
<PaginationItem>
|
|
50
|
-
<PaginationPrevious
|
|
61
|
+
<PaginationPrevious
|
|
62
|
+
href="#"
|
|
63
|
+
onClick={(e) => handlePageChange(currentPage - 1, e)}
|
|
64
|
+
className={currentPage <= 1 ? "pointer-events-none opacity-50" : "cursor-pointer"}
|
|
65
|
+
aria-disabled={currentPage <= 1}
|
|
66
|
+
/>
|
|
51
67
|
</PaginationItem>
|
|
52
68
|
{getPageNumbers().map((page, idx) => (
|
|
53
69
|
<PaginationItem key={idx}>
|
|
54
70
|
{page === -1 ? (
|
|
55
71
|
<PaginationEllipsis />
|
|
56
72
|
) : (
|
|
57
|
-
<PaginationLink
|
|
73
|
+
<PaginationLink
|
|
74
|
+
href="#"
|
|
75
|
+
isActive={page === currentPage}
|
|
76
|
+
onClick={(e) => handlePageChange(page, e)}
|
|
77
|
+
className="cursor-pointer"
|
|
78
|
+
>
|
|
58
79
|
{page}
|
|
59
80
|
</PaginationLink>
|
|
60
81
|
)}
|
|
61
82
|
</PaginationItem>
|
|
62
83
|
))}
|
|
63
84
|
<PaginationItem>
|
|
64
|
-
<PaginationNext
|
|
85
|
+
<PaginationNext
|
|
86
|
+
href="#"
|
|
87
|
+
onClick={(e) => handlePageChange(currentPage + 1, e)}
|
|
88
|
+
className={currentPage >= totalPages ? "pointer-events-none opacity-50" : "cursor-pointer"}
|
|
89
|
+
aria-disabled={currentPage >= totalPages}
|
|
90
|
+
/>
|
|
65
91
|
</PaginationItem>
|
|
66
92
|
</PaginationContent>
|
|
67
93
|
</Pagination>
|
|
68
94
|
);
|
|
69
95
|
},
|
|
70
96
|
{
|
|
97
|
+
namespace: 'ui',
|
|
71
98
|
label: 'Pagination',
|
|
72
99
|
inputs: [
|
|
73
100
|
{ name: 'currentPage', type: 'number', label: 'Current Page', defaultValue: 1 },
|
|
@@ -13,6 +13,16 @@ import { forwardRef } from 'react';
|
|
|
13
13
|
|
|
14
14
|
const SpanRenderer = forwardRef<HTMLSpanElement, { schema: SpanSchema; className?: string; [key: string]: any }>(
|
|
15
15
|
({ schema, className, ...props }, ref) => {
|
|
16
|
+
// Deprecation warning
|
|
17
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
18
|
+
console.warn(
|
|
19
|
+
'[ObjectUI] The "span" component is deprecated. Please use Shadcn components instead:\n' +
|
|
20
|
+
' - For badges/labels: use "badge" component\n' +
|
|
21
|
+
' - For inline text emphasis: use "text" component with appropriate className\n' +
|
|
22
|
+
'See documentation at https://www.objectui.org/docs/components for alternatives.'
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
16
26
|
// Extract designer-related props
|
|
17
27
|
const {
|
|
18
28
|
'data-obj-id': dataObjId,
|
|
@@ -38,7 +48,8 @@ const SpanRenderer = forwardRef<HTMLSpanElement, { schema: SpanSchema; className
|
|
|
38
48
|
ComponentRegistry.register('span',
|
|
39
49
|
SpanRenderer,
|
|
40
50
|
{
|
|
41
|
-
|
|
51
|
+
namespace: 'ui',
|
|
52
|
+
label: 'Inline Container (Deprecated)',
|
|
42
53
|
inputs: [
|
|
43
54
|
{ name: 'className', type: 'string', label: 'CSS Class' }
|
|
44
55
|
],
|
|
@@ -22,13 +22,14 @@ ComponentRegistry.register('text',
|
|
|
22
22
|
...rest
|
|
23
23
|
} = props;
|
|
24
24
|
|
|
25
|
-
// If we have designer props, we must wrap it to make it selectable
|
|
26
|
-
if (dataObjId) {
|
|
25
|
+
// If we have designer props or className, we must wrap it to make it selectable and styleable
|
|
26
|
+
if (dataObjId || schema.className || rest.className) {
|
|
27
27
|
return (
|
|
28
28
|
<span
|
|
29
29
|
data-obj-id={dataObjId}
|
|
30
30
|
data-obj-type={dataObjType}
|
|
31
31
|
style={style}
|
|
32
|
+
className={schema.className || rest.className}
|
|
32
33
|
{...rest}
|
|
33
34
|
>
|
|
34
35
|
{schema.content || schema.value}
|
|
@@ -39,6 +40,7 @@ ComponentRegistry.register('text',
|
|
|
39
40
|
return <>{schema.content || schema.value}</>;
|
|
40
41
|
},
|
|
41
42
|
{
|
|
43
|
+
namespace: 'ui',
|
|
42
44
|
label: 'Text',
|
|
43
45
|
inputs: [
|
|
44
46
|
{ name: 'content', type: 'string', label: 'Content', required: true }
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectUI
|
|
3
|
+
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
10
|
+
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import type { DataTableSchema } from '@object-ui/types';
|
|
13
|
+
|
|
14
|
+
// Import the component
|
|
15
|
+
import '../data-table';
|
|
16
|
+
import { ComponentRegistry } from '@object-ui/core';
|
|
17
|
+
|
|
18
|
+
describe('Data Table - Batch Editing', () => {
|
|
19
|
+
const mockData = [
|
|
20
|
+
{ id: 1, name: 'John Doe', email: 'john@example.com', age: 30 },
|
|
21
|
+
{ id: 2, name: 'Jane Smith', email: 'jane@example.com', age: 25 },
|
|
22
|
+
{ id: 3, name: 'Bob Johnson', email: 'bob@example.com', age: 35 },
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
const mockColumns = [
|
|
26
|
+
{ header: 'ID', accessorKey: 'id', editable: false },
|
|
27
|
+
{ header: 'Name', accessorKey: 'name' },
|
|
28
|
+
{ header: 'Email', accessorKey: 'email' },
|
|
29
|
+
{ header: 'Age', accessorKey: 'age' },
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
it('should track pending changes across multiple cells', async () => {
|
|
33
|
+
const onRowSave = vi.fn();
|
|
34
|
+
|
|
35
|
+
const schema: DataTableSchema = {
|
|
36
|
+
type: 'data-table',
|
|
37
|
+
columns: mockColumns,
|
|
38
|
+
data: mockData,
|
|
39
|
+
editable: true,
|
|
40
|
+
pagination: false,
|
|
41
|
+
searchable: false,
|
|
42
|
+
rowActions: true,
|
|
43
|
+
onRowSave,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const DataTableRenderer = ComponentRegistry.get('data-table');
|
|
47
|
+
if (!DataTableRenderer) throw new Error('DataTableRenderer not found');
|
|
48
|
+
|
|
49
|
+
const { container } = render(<DataTableRenderer schema={schema} />);
|
|
50
|
+
|
|
51
|
+
// Edit first cell in row
|
|
52
|
+
const nameCell = screen.getByText('John Doe').closest('td');
|
|
53
|
+
if (nameCell) {
|
|
54
|
+
fireEvent.doubleClick(nameCell);
|
|
55
|
+
|
|
56
|
+
await waitFor(() => {
|
|
57
|
+
const input = nameCell.querySelector('input');
|
|
58
|
+
expect(input).toBeInTheDocument();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const input = nameCell.querySelector('input');
|
|
62
|
+
if (input) {
|
|
63
|
+
fireEvent.change(input, { target: { value: 'John Smith' } });
|
|
64
|
+
fireEvent.keyDown(input, { key: 'Enter' });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Wait for the edit to be saved to pending changes
|
|
69
|
+
await waitFor(() => {
|
|
70
|
+
const modifiedIndicator = screen.getByText(/1 row modified/i);
|
|
71
|
+
expect(modifiedIndicator).toBeInTheDocument();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// Edit second cell in same row - find by searching through all cells
|
|
75
|
+
const emailCell = Array.from(container.querySelectorAll('td')).find(el =>
|
|
76
|
+
el.textContent?.includes('john@example.com')
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
expect(emailCell).toBeInTheDocument();
|
|
80
|
+
if (emailCell) {
|
|
81
|
+
fireEvent.doubleClick(emailCell);
|
|
82
|
+
|
|
83
|
+
await waitFor(() => {
|
|
84
|
+
const input = emailCell.querySelector('input');
|
|
85
|
+
expect(input).toBeInTheDocument();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const input = emailCell.querySelector('input');
|
|
89
|
+
if (input) {
|
|
90
|
+
fireEvent.change(input, { target: { value: 'johnsmith@example.com' } });
|
|
91
|
+
fireEvent.keyDown(input, { key: 'Enter' });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Row should still show as modified (still just 1 row)
|
|
96
|
+
await waitFor(() => {
|
|
97
|
+
const modifiedIndicator = screen.getByText(/1 row modified/i);
|
|
98
|
+
expect(modifiedIndicator).toBeInTheDocument();
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('should save a single row with multiple changes', async () => {
|
|
103
|
+
const onRowSave = vi.fn().mockResolvedValue(undefined);
|
|
104
|
+
|
|
105
|
+
const schema: DataTableSchema = {
|
|
106
|
+
type: 'data-table',
|
|
107
|
+
columns: mockColumns,
|
|
108
|
+
data: mockData,
|
|
109
|
+
editable: true,
|
|
110
|
+
pagination: false,
|
|
111
|
+
searchable: false,
|
|
112
|
+
rowActions: true,
|
|
113
|
+
onRowSave,
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const DataTableRenderer = ComponentRegistry.get('data-table');
|
|
117
|
+
if (!DataTableRenderer) throw new Error('DataTableRenderer not found');
|
|
118
|
+
|
|
119
|
+
render(<DataTableRenderer schema={schema} />);
|
|
120
|
+
|
|
121
|
+
// Edit name
|
|
122
|
+
const nameCell = screen.getByText('John Doe').closest('td');
|
|
123
|
+
if (nameCell) {
|
|
124
|
+
fireEvent.doubleClick(nameCell);
|
|
125
|
+
await waitFor(() => {
|
|
126
|
+
const input = nameCell.querySelector('input');
|
|
127
|
+
expect(input).toBeInTheDocument();
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const input = nameCell.querySelector('input');
|
|
131
|
+
if (input) {
|
|
132
|
+
fireEvent.change(input, { target: { value: 'John Smith' } });
|
|
133
|
+
fireEvent.keyDown(input, { key: 'Enter' });
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Find and click save button for row
|
|
138
|
+
await waitFor(() => {
|
|
139
|
+
const saveButtons = screen.getAllByTitle('Save row');
|
|
140
|
+
expect(saveButtons.length).toBeGreaterThan(0);
|
|
141
|
+
fireEvent.click(saveButtons[0]);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// Verify callback was called with correct data
|
|
145
|
+
await waitFor(() => {
|
|
146
|
+
expect(onRowSave).toHaveBeenCalledWith(
|
|
147
|
+
0,
|
|
148
|
+
{ name: 'John Smith' },
|
|
149
|
+
mockData[0]
|
|
150
|
+
);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('should save all modified rows with batch save', async () => {
|
|
155
|
+
const onBatchSave = vi.fn().mockResolvedValue(undefined);
|
|
156
|
+
|
|
157
|
+
const schema: DataTableSchema = {
|
|
158
|
+
type: 'data-table',
|
|
159
|
+
columns: mockColumns,
|
|
160
|
+
data: mockData,
|
|
161
|
+
editable: true,
|
|
162
|
+
pagination: false,
|
|
163
|
+
searchable: false,
|
|
164
|
+
onBatchSave,
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const DataTableRenderer = ComponentRegistry.get('data-table');
|
|
168
|
+
if (!DataTableRenderer) throw new Error('DataTableRenderer not found');
|
|
169
|
+
|
|
170
|
+
render(<DataTableRenderer schema={schema} />);
|
|
171
|
+
|
|
172
|
+
// Edit row 1
|
|
173
|
+
const nameCell1 = screen.getByText('John Doe').closest('td');
|
|
174
|
+
if (nameCell1) {
|
|
175
|
+
fireEvent.doubleClick(nameCell1);
|
|
176
|
+
await waitFor(() => {
|
|
177
|
+
const input = nameCell1.querySelector('input');
|
|
178
|
+
expect(input).toBeInTheDocument();
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
const input = nameCell1.querySelector('input');
|
|
182
|
+
if (input) {
|
|
183
|
+
fireEvent.change(input, { target: { value: 'John Smith' } });
|
|
184
|
+
fireEvent.keyDown(input, { key: 'Enter' });
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// Edit row 2
|
|
189
|
+
await waitFor(() => {
|
|
190
|
+
const nameCell2 = screen.getByText('Jane Smith').closest('td');
|
|
191
|
+
expect(nameCell2).toBeInTheDocument();
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const nameCell2 = screen.getByText('Jane Smith').closest('td');
|
|
195
|
+
if (nameCell2) {
|
|
196
|
+
fireEvent.doubleClick(nameCell2);
|
|
197
|
+
await waitFor(() => {
|
|
198
|
+
const input = nameCell2.querySelector('input');
|
|
199
|
+
expect(input).toBeInTheDocument();
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
const input = nameCell2.querySelector('input');
|
|
203
|
+
if (input) {
|
|
204
|
+
fireEvent.change(input, { target: { value: 'Jane Doe' } });
|
|
205
|
+
fireEvent.keyDown(input, { key: 'Enter' });
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Click save all button
|
|
210
|
+
await waitFor(() => {
|
|
211
|
+
const saveAllButton = screen.getByText(/Save All \(2\)/i);
|
|
212
|
+
expect(saveAllButton).toBeInTheDocument();
|
|
213
|
+
fireEvent.click(saveAllButton);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
// Verify callback was called
|
|
217
|
+
await waitFor(() => {
|
|
218
|
+
expect(onBatchSave).toHaveBeenCalledWith([
|
|
219
|
+
{ rowIndex: 0, changes: { name: 'John Smith' }, row: mockData[0] },
|
|
220
|
+
{ rowIndex: 1, changes: { name: 'Jane Doe' }, row: mockData[1] },
|
|
221
|
+
]);
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
it('should cancel all changes', async () => {
|
|
226
|
+
const onBatchSave = vi.fn();
|
|
227
|
+
|
|
228
|
+
const schema: DataTableSchema = {
|
|
229
|
+
type: 'data-table',
|
|
230
|
+
columns: mockColumns,
|
|
231
|
+
data: mockData,
|
|
232
|
+
editable: true,
|
|
233
|
+
pagination: false,
|
|
234
|
+
searchable: false,
|
|
235
|
+
onBatchSave,
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
const DataTableRenderer = ComponentRegistry.get('data-table');
|
|
239
|
+
if (!DataTableRenderer) throw new Error('DataTableRenderer not found');
|
|
240
|
+
|
|
241
|
+
render(<DataTableRenderer schema={schema} />);
|
|
242
|
+
|
|
243
|
+
// Edit a cell
|
|
244
|
+
const nameCell = screen.getByText('John Doe').closest('td');
|
|
245
|
+
if (nameCell) {
|
|
246
|
+
fireEvent.doubleClick(nameCell);
|
|
247
|
+
await waitFor(() => {
|
|
248
|
+
const input = nameCell.querySelector('input');
|
|
249
|
+
expect(input).toBeInTheDocument();
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
const input = nameCell.querySelector('input');
|
|
253
|
+
if (input) {
|
|
254
|
+
fireEvent.change(input, { target: { value: 'John Smith' } });
|
|
255
|
+
fireEvent.keyDown(input, { key: 'Enter' });
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Click cancel all button
|
|
260
|
+
await waitFor(() => {
|
|
261
|
+
const cancelButton = screen.getByText(/Cancel All/i);
|
|
262
|
+
expect(cancelButton).toBeInTheDocument();
|
|
263
|
+
fireEvent.click(cancelButton);
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
// Verify changes indicator is gone
|
|
267
|
+
await waitFor(() => {
|
|
268
|
+
const modifiedIndicator = screen.queryByText(/row modified/i);
|
|
269
|
+
expect(modifiedIndicator).not.toBeInTheDocument();
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
// Original value should be restored
|
|
273
|
+
expect(screen.getByText('John Doe')).toBeInTheDocument();
|
|
274
|
+
});
|
|
275
|
+
});
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data Table - Custom Cell Renderer Tests
|
|
3
|
+
*
|
|
4
|
+
* Tests that data-table respects col.cell() function for custom cell rendering.
|
|
5
|
+
*/
|
|
6
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
7
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
8
|
+
import '@testing-library/jest-dom';
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { SchemaRenderer } from '@object-ui/react';
|
|
11
|
+
|
|
12
|
+
// Import data-table to ensure it's registered
|
|
13
|
+
import '../data-table';
|
|
14
|
+
|
|
15
|
+
describe('Data Table: col.cell() custom renderer', () => {
|
|
16
|
+
it('should invoke col.cell function to render cell content', async () => {
|
|
17
|
+
const cellFn = vi.fn((value: any, _row: any) => (
|
|
18
|
+
<span data-testid="custom-cell">{`Custom: ${value}`}</span>
|
|
19
|
+
));
|
|
20
|
+
|
|
21
|
+
const schema = {
|
|
22
|
+
type: 'data-table',
|
|
23
|
+
columns: [
|
|
24
|
+
{ header: 'Name', accessorKey: 'name', cell: cellFn },
|
|
25
|
+
{ header: 'Email', accessorKey: 'email' },
|
|
26
|
+
],
|
|
27
|
+
data: [
|
|
28
|
+
{ name: 'Alice', email: 'alice@test.com' },
|
|
29
|
+
{ name: 'Bob', email: 'bob@test.com' },
|
|
30
|
+
],
|
|
31
|
+
pagination: false,
|
|
32
|
+
searchable: false,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
render(<SchemaRenderer schema={schema} />);
|
|
36
|
+
|
|
37
|
+
await waitFor(() => {
|
|
38
|
+
expect(screen.getByText('Custom: Alice')).toBeInTheDocument();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
expect(screen.getByText('Custom: Bob')).toBeInTheDocument();
|
|
42
|
+
expect(cellFn).toHaveBeenCalledTimes(2);
|
|
43
|
+
|
|
44
|
+
// Non-custom cell should render value directly
|
|
45
|
+
expect(screen.getByText('alice@test.com')).toBeInTheDocument();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('should pass both value and row to cell function', async () => {
|
|
49
|
+
const cellFn = vi.fn((value: any, row: any) => (
|
|
50
|
+
<span data-testid="combo-cell">{`${value} (${row.email})`}</span>
|
|
51
|
+
));
|
|
52
|
+
|
|
53
|
+
const schema = {
|
|
54
|
+
type: 'data-table',
|
|
55
|
+
columns: [
|
|
56
|
+
{ header: 'Name', accessorKey: 'name', cell: cellFn },
|
|
57
|
+
],
|
|
58
|
+
data: [
|
|
59
|
+
{ name: 'Alice', email: 'alice@test.com' },
|
|
60
|
+
],
|
|
61
|
+
pagination: false,
|
|
62
|
+
searchable: false,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
render(<SchemaRenderer schema={schema} />);
|
|
66
|
+
|
|
67
|
+
await waitFor(() => {
|
|
68
|
+
expect(screen.getByText('Alice (alice@test.com)')).toBeInTheDocument();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
expect(cellFn).toHaveBeenCalledWith('Alice', expect.objectContaining({ name: 'Alice', email: 'alice@test.com' }));
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('should render raw value when no cell function is provided', async () => {
|
|
75
|
+
const schema = {
|
|
76
|
+
type: 'data-table',
|
|
77
|
+
columns: [
|
|
78
|
+
{ header: 'Name', accessorKey: 'name' },
|
|
79
|
+
],
|
|
80
|
+
data: [
|
|
81
|
+
{ name: 'Alice' },
|
|
82
|
+
],
|
|
83
|
+
pagination: false,
|
|
84
|
+
searchable: false,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
render(<SchemaRenderer schema={schema} />);
|
|
88
|
+
|
|
89
|
+
await waitFor(() => {
|
|
90
|
+
expect(screen.getByText('Alice')).toBeInTheDocument();
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('should prefer editing state over cell function when in edit mode', async () => {
|
|
95
|
+
// The editing state should take precedence over custom cell renderer
|
|
96
|
+
// This test verifies the rendering priority: editing > cell > raw value
|
|
97
|
+
const cellFn = vi.fn((value: any) => (
|
|
98
|
+
<span>{`Custom: ${value}`}</span>
|
|
99
|
+
));
|
|
100
|
+
|
|
101
|
+
const schema = {
|
|
102
|
+
type: 'data-table',
|
|
103
|
+
columns: [
|
|
104
|
+
{ header: 'Name', accessorKey: 'name', cell: cellFn },
|
|
105
|
+
],
|
|
106
|
+
data: [
|
|
107
|
+
{ name: 'Alice' },
|
|
108
|
+
],
|
|
109
|
+
pagination: false,
|
|
110
|
+
searchable: false,
|
|
111
|
+
editable: false,
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
render(<SchemaRenderer schema={schema} />);
|
|
115
|
+
|
|
116
|
+
await waitFor(() => {
|
|
117
|
+
expect(screen.getByText('Custom: Alice')).toBeInTheDocument();
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
});
|