@synertech/ui 0.43.0 → 0.45.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/.claude/skills/use-synertech-ui/SKILL.md +178 -5
- package/README.md +36 -8
- package/dist/components/accordion/Accordion.cjs +1 -0
- package/dist/components/accordion/Accordion.js +1 -0
- package/dist/components/accordion/index.cjs +1 -0
- package/dist/components/accordion/index.js +1 -0
- package/dist/components/advance-detachable/AdvanceDetachable.cjs +1 -0
- package/dist/components/advance-detachable/AdvanceDetachable.js +1 -0
- package/dist/components/advance-detachable/index.cjs +1 -0
- package/dist/components/advance-detachable/index.js +1 -0
- package/dist/components/area-chart/AreaChart.cjs +1 -0
- package/dist/components/area-chart/AreaChart.js +1 -0
- package/dist/components/area-chart/index.cjs +1 -0
- package/dist/components/area-chart/index.js +1 -0
- package/dist/components/avatar/Avatar.cjs +1 -0
- package/dist/components/avatar/Avatar.js +1 -0
- package/dist/components/avatar/index.cjs +1 -0
- package/dist/components/avatar/index.js +1 -0
- package/dist/components/badge/Badge.cjs +1 -0
- package/dist/components/badge/Badge.js +1 -0
- package/dist/components/badge/index.cjs +1 -0
- package/dist/components/badge/index.js +1 -0
- package/dist/components/banner/Banner.cjs +1 -0
- package/dist/components/banner/Banner.js +1 -0
- package/dist/components/banner/index.cjs +1 -0
- package/dist/components/banner/index.js +1 -0
- package/dist/components/bar-chart/BarChart.cjs +1 -0
- package/dist/components/bar-chart/BarChart.js +1 -0
- package/dist/components/bar-chart/index.cjs +1 -0
- package/dist/components/bar-chart/index.js +1 -0
- package/dist/components/box-plot/BoxPlot.cjs +1 -0
- package/dist/components/box-plot/BoxPlot.js +1 -0
- package/dist/components/box-plot/index.cjs +1 -0
- package/dist/components/box-plot/index.js +1 -0
- package/dist/components/breadcrumb/Breadcrumb.cjs +1 -0
- package/dist/components/breadcrumb/Breadcrumb.js +1 -0
- package/dist/components/breadcrumb/index.cjs +1 -0
- package/dist/components/breadcrumb/index.js +1 -0
- package/dist/components/bullet-chart/BulletChart.cjs +1 -0
- package/dist/components/bullet-chart/BulletChart.js +1 -0
- package/dist/components/bullet-chart/index.cjs +1 -0
- package/dist/components/bullet-chart/index.js +1 -0
- package/dist/components/button/Button.cjs +1 -0
- package/dist/components/button/Button.js +1 -0
- package/dist/components/button/index.cjs +1 -0
- package/dist/components/button/index.js +1 -0
- package/dist/components/button-group/ButtonGroup.cjs +1 -0
- package/dist/components/button-group/ButtonGroup.js +1 -0
- package/dist/components/button-group/index.cjs +1 -0
- package/dist/components/button-group/index.js +1 -0
- package/dist/components/calendar/Calendar.cjs +1 -0
- package/dist/components/calendar/Calendar.js +1 -0
- package/dist/components/calendar/index.cjs +1 -0
- package/dist/components/calendar/index.js +1 -0
- package/dist/components/candlestick-chart/CandlestickChart.cjs +1 -0
- package/dist/components/candlestick-chart/CandlestickChart.js +1 -0
- package/dist/components/candlestick-chart/index.cjs +1 -0
- package/dist/components/candlestick-chart/index.js +1 -0
- package/dist/components/card/Card.cjs +1 -0
- package/dist/components/card/Card.js +1 -0
- package/dist/components/card/CardBody.cjs +1 -0
- package/dist/components/card/CardBody.js +1 -0
- package/dist/components/card/CardDescription.cjs +1 -0
- package/dist/components/card/CardDescription.js +1 -0
- package/dist/components/card/CardFooter.cjs +1 -0
- package/dist/components/card/CardFooter.js +1 -0
- package/dist/components/card/CardHeader.cjs +1 -0
- package/dist/components/card/CardHeader.js +1 -0
- package/dist/components/card/CardImage.cjs +1 -0
- package/dist/components/card/CardImage.js +1 -0
- package/dist/components/card/CardTitle.cjs +1 -0
- package/dist/components/card/CardTitle.js +1 -0
- package/dist/components/card/index.cjs +1 -0
- package/dist/components/card/index.js +1 -0
- package/dist/components/chart/ChartAnnotations.cjs +1 -0
- package/dist/components/chart/ChartAnnotations.js +1 -0
- package/dist/components/chart/ChartAxis.cjs +1 -0
- package/dist/components/chart/ChartAxis.js +1 -0
- package/dist/components/chart/ChartBrush.cjs +1 -0
- package/dist/components/chart/ChartBrush.js +1 -0
- package/dist/components/chart/ChartContainer.cjs +1 -0
- package/dist/components/chart/ChartContainer.js +1 -0
- package/dist/components/chart/ChartExportButton.cjs +1 -0
- package/dist/components/chart/ChartExportButton.js +1 -0
- package/dist/components/chart/ChartFacets.cjs +1 -0
- package/dist/components/chart/ChartFacets.js +1 -0
- package/dist/components/chart/ChartFilterBar.cjs +1 -0
- package/dist/components/chart/ChartFilterBar.js +1 -0
- package/dist/components/chart/ChartGrid.cjs +1 -0
- package/dist/components/chart/ChartGrid.js +1 -0
- package/dist/components/chart/ChartLegend.cjs +1 -0
- package/dist/components/chart/ChartLegend.js +1 -0
- package/dist/components/chart/ChartPatterns.cjs +1 -0
- package/dist/components/chart/ChartPatterns.js +1 -0
- package/dist/components/chart/ChartPeriodPicker.cjs +1 -0
- package/dist/components/chart/ChartPeriodPicker.js +1 -0
- package/dist/components/chart/ChartScaleLegend.cjs +1 -0
- package/dist/components/chart/ChartScaleLegend.js +1 -0
- package/dist/components/chart/ChartSync.cjs +1 -0
- package/dist/components/chart/ChartSync.js +1 -0
- package/dist/components/chart/ChartTableView.cjs +1 -0
- package/dist/components/chart/ChartTableView.js +1 -0
- package/dist/components/chart/ChartTooltip.cjs +1 -0
- package/dist/components/chart/ChartTooltip.js +1 -0
- package/dist/components/chart/chart.types.cjs +1 -0
- package/dist/components/chart/chart.types.js +0 -0
- package/dist/components/chart/index.cjs +1 -0
- package/dist/components/chart/index.js +1 -0
- package/dist/components/chart/palette.cjs +1 -0
- package/dist/components/chart/palette.js +1 -0
- package/dist/components/chart/useChartSize.cjs +1 -0
- package/dist/components/chart/useChartSize.js +1 -0
- package/dist/components/chart/utils/bins.cjs +1 -0
- package/dist/components/chart/utils/bins.js +1 -0
- package/dist/components/chart/utils/cartesian.cjs +1 -0
- package/dist/components/chart/utils/cartesian.js +1 -0
- package/dist/components/chart/utils/data.cjs +1 -0
- package/dist/components/chart/utils/data.js +1 -0
- package/dist/components/chart/utils/decimate.cjs +1 -0
- package/dist/components/chart/utils/decimate.js +1 -0
- package/dist/components/chart/utils/export.cjs +2 -0
- package/dist/components/chart/utils/export.js +2 -0
- package/dist/components/chart/utils/format.cjs +1 -0
- package/dist/components/chart/utils/format.js +1 -0
- package/dist/components/chart/utils/path.cjs +1 -0
- package/dist/components/chart/utils/path.js +1 -0
- package/dist/components/chart/utils/period.cjs +1 -0
- package/dist/components/chart/utils/period.js +1 -0
- package/dist/components/chart/utils/quantile.cjs +1 -0
- package/dist/components/chart/utils/quantile.js +1 -0
- package/dist/components/chart/utils/scales.cjs +1 -0
- package/dist/components/chart/utils/scales.js +1 -0
- package/dist/components/chart/utils/stack.cjs +1 -0
- package/dist/components/chart/utils/stack.js +1 -0
- package/dist/components/chart/utils/text.cjs +1 -0
- package/dist/components/chart/utils/text.js +1 -0
- package/dist/components/chart/utils/ticks.cjs +1 -0
- package/dist/components/chart/utils/ticks.js +1 -0
- package/dist/components/chart/utils/time.cjs +1 -0
- package/dist/components/chart/utils/time.js +1 -0
- package/dist/components/checkbox/Checkbox.cjs +1 -0
- package/dist/components/checkbox/Checkbox.js +1 -0
- package/dist/components/checkbox/CheckboxGroup.cjs +1 -0
- package/dist/components/checkbox/CheckboxGroup.js +1 -0
- package/dist/components/checkbox/index.cjs +1 -0
- package/dist/components/checkbox/index.js +1 -0
- package/dist/components/chip/Chip.cjs +1 -0
- package/dist/components/chip/Chip.js +1 -0
- package/dist/components/chip/index.cjs +1 -0
- package/dist/components/chip/index.js +1 -0
- package/dist/components/circular-progress/CircularProgress.cjs +1 -0
- package/dist/components/circular-progress/CircularProgress.js +1 -0
- package/dist/components/circular-progress/index.cjs +1 -0
- package/dist/components/circular-progress/index.js +1 -0
- package/dist/components/datagrid/DataGrid.cjs +2 -0
- package/dist/components/datagrid/DataGrid.js +2 -0
- package/dist/components/datagrid/index.cjs +1 -0
- package/dist/components/datagrid/index.js +1 -0
- package/dist/components/detachable/Detachable.cjs +1 -0
- package/dist/components/detachable/Detachable.js +1 -0
- package/dist/components/detachable/index.cjs +1 -0
- package/dist/components/detachable/index.js +1 -0
- package/dist/components/device-mockup/DeviceMockup.cjs +1 -0
- package/dist/components/device-mockup/DeviceMockup.js +1 -0
- package/dist/components/device-mockup/index.cjs +1 -0
- package/dist/components/device-mockup/index.js +1 -0
- package/dist/components/divider/Divider.cjs +1 -0
- package/dist/components/divider/Divider.js +1 -0
- package/dist/components/divider/index.cjs +1 -0
- package/dist/components/divider/index.js +1 -0
- package/dist/components/drawer/Drawer.cjs +1 -0
- package/dist/components/drawer/Drawer.js +1 -0
- package/dist/components/drawer/index.cjs +1 -0
- package/dist/components/drawer/index.js +1 -0
- package/dist/components/dropdown/Dropdown.cjs +1 -0
- package/dist/components/dropdown/Dropdown.js +1 -0
- package/dist/components/dropdown/DropdownCheckboxItem.cjs +1 -0
- package/dist/components/dropdown/DropdownCheckboxItem.js +1 -0
- package/dist/components/dropdown/DropdownContent.cjs +1 -0
- package/dist/components/dropdown/DropdownContent.js +1 -0
- package/dist/components/dropdown/DropdownItem.cjs +1 -0
- package/dist/components/dropdown/DropdownItem.js +1 -0
- package/dist/components/dropdown/DropdownRadio.cjs +1 -0
- package/dist/components/dropdown/DropdownRadio.js +1 -0
- package/dist/components/dropdown/DropdownSeparator.cjs +1 -0
- package/dist/components/dropdown/DropdownSeparator.js +1 -0
- package/dist/components/dropdown/DropdownSubMenu.cjs +1 -0
- package/dist/components/dropdown/DropdownSubMenu.js +1 -0
- package/dist/components/dropdown/DropdownTrigger.cjs +1 -0
- package/dist/components/dropdown/DropdownTrigger.js +1 -0
- package/dist/components/dropdown/hooks/index.cjs +1 -0
- package/dist/components/dropdown/hooks/index.js +1 -0
- package/dist/components/dropdown/hooks/useClickOutside.cjs +1 -0
- package/dist/components/dropdown/hooks/useClickOutside.js +1 -0
- package/dist/components/dropdown/hooks/useKeyboardNavigation.cjs +1 -0
- package/dist/components/dropdown/hooks/useKeyboardNavigation.js +1 -0
- package/dist/components/dropdown/hooks/useLatest.cjs +1 -0
- package/dist/components/dropdown/hooks/useLatest.js +1 -0
- package/dist/components/dropdown/hooks/usePositioning.cjs +1 -0
- package/dist/components/dropdown/hooks/usePositioning.js +1 -0
- package/dist/components/dropdown/index.cjs +1 -0
- package/dist/components/dropdown/index.js +1 -0
- package/dist/components/dumbbell-chart/DumbbellChart.cjs +1 -0
- package/dist/components/dumbbell-chart/DumbbellChart.js +1 -0
- package/dist/components/dumbbell-chart/index.cjs +1 -0
- package/dist/components/dumbbell-chart/index.js +1 -0
- package/dist/components/file-selector/FileSelector.cjs +1 -0
- package/dist/components/file-selector/FileSelector.js +1 -0
- package/dist/components/file-selector/index.cjs +1 -0
- package/dist/components/file-selector/index.js +1 -0
- package/dist/components/footer/Footer.cjs +1 -0
- package/dist/components/footer/Footer.js +1 -0
- package/dist/components/footer/FooterBottom.cjs +1 -0
- package/dist/components/footer/FooterBottom.js +1 -0
- package/dist/components/footer/FooterColumn.cjs +1 -0
- package/dist/components/footer/FooterColumn.js +1 -0
- package/dist/components/footer/FooterLink.cjs +1 -0
- package/dist/components/footer/FooterLink.js +1 -0
- package/dist/components/footer/FooterSection.cjs +1 -0
- package/dist/components/footer/FooterSection.js +1 -0
- package/dist/components/footer/FooterSocial.cjs +1 -0
- package/dist/components/footer/FooterSocial.js +1 -0
- package/dist/components/footer/index.cjs +1 -0
- package/dist/components/footer/index.js +1 -0
- package/dist/components/form/index.cjs +1 -0
- package/dist/components/form/index.js +1 -0
- package/dist/components/form/input/Input.cjs +1 -0
- package/dist/components/form/input/Input.js +1 -0
- package/dist/components/form/input/index.cjs +1 -0
- package/dist/components/form/input/index.js +1 -0
- package/dist/components/form/mention-input/MentionInput.cjs +1 -0
- package/dist/components/form/mention-input/MentionInput.js +1 -0
- package/dist/components/form/mention-input/index.cjs +1 -0
- package/dist/components/form/mention-input/index.js +1 -0
- package/dist/components/form/number-input/NumberInput.cjs +1 -0
- package/dist/components/form/number-input/NumberInput.js +1 -0
- package/dist/components/form/number-input/index.cjs +1 -0
- package/dist/components/form/number-input/index.js +1 -0
- package/dist/components/form/shared/InputWrapper.cjs +1 -0
- package/dist/components/form/shared/InputWrapper.js +1 -0
- package/dist/components/form/shared/inputStyles.cjs +1 -0
- package/dist/components/form/shared/inputStyles.js +1 -0
- package/dist/components/form/types/mention.cjs +1 -0
- package/dist/components/form/types/mention.js +0 -0
- package/dist/components/funnel-chart/FunnelChart.cjs +1 -0
- package/dist/components/funnel-chart/FunnelChart.js +1 -0
- package/dist/components/funnel-chart/index.cjs +1 -0
- package/dist/components/funnel-chart/index.js +1 -0
- package/dist/components/gantt-chart/GanttChart.cjs +1 -0
- package/dist/components/gantt-chart/GanttChart.js +1 -0
- package/dist/components/gantt-chart/index.cjs +1 -0
- package/dist/components/gantt-chart/index.js +1 -0
- package/dist/components/header/Header.cjs +1 -0
- package/dist/components/header/Header.js +1 -0
- package/dist/components/header/index.cjs +1 -0
- package/dist/components/header/index.js +1 -0
- package/dist/components/heat-map/Heatmap.cjs +1 -0
- package/dist/components/heat-map/Heatmap.js +1 -0
- package/dist/components/heat-map/index.cjs +1 -0
- package/dist/components/heat-map/index.js +1 -0
- package/dist/components/help-button/HelpButton.cjs +22 -0
- package/dist/components/help-button/HelpButton.js +22 -0
- package/dist/components/help-button/MarkdownEditor.cjs +1 -0
- package/dist/components/help-button/MarkdownEditor.js +1 -0
- package/dist/components/help-button/index.cjs +1 -0
- package/dist/components/help-button/index.js +1 -0
- package/dist/components/help-button/types.cjs +1 -0
- package/dist/components/help-button/types.js +0 -0
- package/dist/components/image-uploader/ImageUploader.cjs +1 -0
- package/dist/components/image-uploader/ImageUploader.js +1 -0
- package/dist/components/image-uploader/index.cjs +1 -0
- package/dist/components/image-uploader/index.js +1 -0
- package/dist/components/index.cjs +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/indicator/Indicator.cjs +1 -0
- package/dist/components/indicator/Indicator.js +1 -0
- package/dist/components/indicator/index.cjs +1 -0
- package/dist/components/indicator/index.js +1 -0
- package/dist/components/label/Label.cjs +1 -0
- package/dist/components/label/Label.js +1 -0
- package/dist/components/label/index.cjs +1 -0
- package/dist/components/label/index.js +1 -0
- package/dist/components/line-chart/LineChart.cjs +1 -0
- package/dist/components/line-chart/LineChart.js +1 -0
- package/dist/components/line-chart/index.cjs +1 -0
- package/dist/components/line-chart/index.js +1 -0
- package/dist/components/modal/Modal.cjs +1 -0
- package/dist/components/modal/Modal.js +1 -0
- package/dist/components/modal/index.cjs +1 -0
- package/dist/components/modal/index.js +1 -0
- package/dist/components/pagination/Pagination.cjs +1 -0
- package/dist/components/pagination/Pagination.js +1 -0
- package/dist/components/pagination/index.cjs +1 -0
- package/dist/components/pagination/index.js +1 -0
- package/dist/components/pie-chart/PieChart.cjs +1 -0
- package/dist/components/pie-chart/PieChart.js +1 -0
- package/dist/components/pie-chart/index.cjs +1 -0
- package/dist/components/pie-chart/index.js +1 -0
- package/dist/components/progress-bar/ProgressBar.cjs +1 -0
- package/dist/components/progress-bar/ProgressBar.js +1 -0
- package/dist/components/progress-bar/index.cjs +1 -0
- package/dist/components/progress-bar/index.js +1 -0
- package/dist/components/radio-button/RadioButton.cjs +1 -0
- package/dist/components/radio-button/RadioButton.js +1 -0
- package/dist/components/radio-button/index.cjs +1 -0
- package/dist/components/radio-button/index.js +1 -0
- package/dist/components/scatter-chart/ScatterChart.cjs +1 -0
- package/dist/components/scatter-chart/ScatterChart.js +1 -0
- package/dist/components/scatter-chart/index.cjs +1 -0
- package/dist/components/scatter-chart/index.js +1 -0
- package/dist/components/schema-editor/SchemaEditor.cjs +1 -0
- package/dist/components/schema-editor/SchemaEditor.js +1 -0
- package/dist/components/schema-editor/SchemaEditor.types.cjs +1 -0
- package/dist/components/schema-editor/SchemaEditor.types.js +0 -0
- package/dist/components/schema-editor/canvas/GridLayer.cjs +1 -0
- package/dist/components/schema-editor/canvas/GridLayer.js +1 -0
- package/dist/components/schema-editor/index.cjs +1 -0
- package/dist/components/schema-editor/index.js +1 -0
- package/dist/components/schema-editor/legend/SchemaLegend.cjs +1 -0
- package/dist/components/schema-editor/legend/SchemaLegend.js +1 -0
- package/dist/components/schema-editor/minimap/SchemaMinimap.cjs +1 -0
- package/dist/components/schema-editor/minimap/SchemaMinimap.js +1 -0
- package/dist/components/schema-editor/relations/SchemaRelationRenderer.cjs +1 -0
- package/dist/components/schema-editor/relations/SchemaRelationRenderer.js +1 -0
- package/dist/components/schema-editor/tables/SchemaTableRenderer.cjs +1 -0
- package/dist/components/schema-editor/tables/SchemaTableRenderer.js +1 -0
- package/dist/components/schema-editor/toolbar/SchemaToolbar.cjs +1 -0
- package/dist/components/schema-editor/toolbar/SchemaToolbar.js +1 -0
- package/dist/components/schema-editor/utils/auto-layout.cjs +1 -0
- package/dist/components/schema-editor/utils/auto-layout.js +1 -0
- package/dist/components/schema-editor/utils/geometry.cjs +1 -0
- package/dist/components/schema-editor/utils/geometry.js +1 -0
- package/dist/components/schema-editor/utils/schema-helpers.cjs +1 -0
- package/dist/components/schema-editor/utils/schema-helpers.js +1 -0
- package/dist/components/schema-editor/utils/sql-export.cjs +9 -0
- package/dist/components/schema-editor/utils/sql-export.js +9 -0
- package/dist/components/select/Select.cjs +1 -0
- package/dist/components/select/Select.js +1 -0
- package/dist/components/select/index.cjs +1 -0
- package/dist/components/select/index.js +1 -0
- package/dist/components/sidebar/Sidebar.cjs +1 -0
- package/dist/components/sidebar/Sidebar.js +1 -0
- package/dist/components/sidebar/index.cjs +1 -0
- package/dist/components/sidebar/index.js +1 -0
- package/dist/components/skeleton/Skeleton.cjs +1 -0
- package/dist/components/skeleton/Skeleton.js +1 -0
- package/dist/components/skeleton/index.cjs +1 -0
- package/dist/components/skeleton/index.js +1 -0
- package/dist/components/slider/Slider.cjs +1 -0
- package/dist/components/slider/Slider.js +1 -0
- package/dist/components/slider/index.cjs +1 -0
- package/dist/components/slider/index.js +1 -0
- package/dist/components/sparkline/Sparkline.cjs +1 -0
- package/dist/components/sparkline/Sparkline.js +1 -0
- package/dist/components/sparkline/index.cjs +1 -0
- package/dist/components/sparkline/index.js +1 -0
- package/dist/components/stat-card/StatCard.cjs +1 -0
- package/dist/components/stat-card/StatCard.js +1 -0
- package/dist/components/stat-card/StatCardGroup.cjs +1 -0
- package/dist/components/stat-card/StatCardGroup.js +1 -0
- package/dist/components/stat-card/index.cjs +1 -0
- package/dist/components/stat-card/index.js +1 -0
- package/dist/components/table/Table.cjs +1 -0
- package/dist/components/table/Table.js +1 -0
- package/dist/components/table/TableBody.cjs +1 -0
- package/dist/components/table/TableBody.js +1 -0
- package/dist/components/table/TableCell.cjs +1 -0
- package/dist/components/table/TableCell.js +1 -0
- package/dist/components/table/TableHeader.cjs +1 -0
- package/dist/components/table/TableHeader.js +1 -0
- package/dist/components/table/TableHeaderCell.cjs +1 -0
- package/dist/components/table/TableHeaderCell.js +1 -0
- package/dist/components/table/TableRow.cjs +1 -0
- package/dist/components/table/TableRow.js +1 -0
- package/dist/components/table/index.cjs +1 -0
- package/dist/components/table/index.js +1 -0
- package/dist/components/tabs/Tabs.cjs +1 -0
- package/dist/components/tabs/Tabs.js +1 -0
- package/dist/components/tabs/TabsContent.cjs +1 -0
- package/dist/components/tabs/TabsContent.js +1 -0
- package/dist/components/tabs/TabsContext.cjs +1 -0
- package/dist/components/tabs/TabsContext.js +1 -0
- package/dist/components/tabs/TabsList.cjs +1 -0
- package/dist/components/tabs/TabsList.js +1 -0
- package/dist/components/tabs/TabsTrigger.cjs +1 -0
- package/dist/components/tabs/TabsTrigger.js +1 -0
- package/dist/components/tabs/index.cjs +1 -0
- package/dist/components/tabs/index.js +1 -0
- package/dist/components/toast/Toast.cjs +1 -0
- package/dist/components/toast/Toast.js +1 -0
- package/dist/components/toast/index.cjs +1 -0
- package/dist/components/toast/index.js +1 -0
- package/dist/components/tooltip/Tooltip.cjs +1 -0
- package/dist/components/tooltip/Tooltip.js +1 -0
- package/dist/components/tooltip/index.cjs +1 -0
- package/dist/components/tooltip/index.js +1 -0
- package/dist/components/waterfall-chart/WaterfallChart.cjs +1 -0
- package/dist/components/waterfall-chart/WaterfallChart.js +1 -0
- package/dist/components/waterfall-chart/index.cjs +1 -0
- package/dist/components/waterfall-chart/index.js +1 -0
- package/dist/components/wizard/Wizard.cjs +1 -0
- package/dist/components/wizard/Wizard.js +1 -0
- package/dist/components/wizard/index.cjs +1 -0
- package/dist/components/wizard/index.js +1 -0
- package/dist/components/workflow-editor/WorkflowEditor.cjs +1 -0
- package/dist/components/workflow-editor/WorkflowEditor.js +1 -0
- package/dist/components/workflow-editor/WorkflowEditor.types.cjs +1 -0
- package/dist/components/workflow-editor/WorkflowEditor.types.js +0 -0
- package/dist/components/workflow-editor/canvas/GridLayer.cjs +1 -0
- package/dist/components/workflow-editor/canvas/GridLayer.js +1 -0
- package/dist/components/workflow-editor/edges/WorkflowEdgeRenderer.cjs +1 -0
- package/dist/components/workflow-editor/edges/WorkflowEdgeRenderer.js +1 -0
- package/dist/components/workflow-editor/index.cjs +1 -0
- package/dist/components/workflow-editor/index.js +1 -0
- package/dist/components/workflow-editor/nodes/WorkflowNodeRenderer.cjs +1 -0
- package/dist/components/workflow-editor/nodes/WorkflowNodeRenderer.js +1 -0
- package/dist/components/workflow-editor/toolbar/WorkflowToolbar.cjs +1 -0
- package/dist/components/workflow-editor/toolbar/WorkflowToolbar.js +1 -0
- package/dist/components/workflow-editor/utils/geometry.cjs +1 -0
- package/dist/components/workflow-editor/utils/geometry.js +1 -0
- package/dist/hooks/index.cjs +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useDialogA11y.cjs +1 -0
- package/dist/hooks/useDialogA11y.js +1 -0
- package/dist/index.cjs +1 -31
- package/dist/index.d.cts +778 -106
- package/dist/index.d.ts +778 -106
- package/dist/index.js +1 -31
- package/dist/lib/aria-hide.cjs +1 -0
- package/dist/lib/aria-hide.js +1 -0
- package/dist/lib/cn.cjs +1 -0
- package/dist/lib/cn.js +1 -0
- package/dist/lib/dialog-stack.cjs +1 -0
- package/dist/lib/dialog-stack.js +1 -0
- package/dist/lib/focus.cjs +1 -0
- package/dist/lib/focus.js +1 -0
- package/dist/lib/i18n.cjs +1 -0
- package/dist/lib/i18n.js +1 -0
- package/dist/markdown-editor.cjs +1 -1
- package/dist/markdown-editor.js +1 -1
- package/dist/styles.css +139 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{memo as ue,useCallback as U,useMemo as N,useState as se}from"react";import{ChartAxis as ee}from"../chart/ChartAxis.js";import{ChartContainer as de}from"../chart/ChartContainer.js";import{ChartGrid as me}from"../chart/ChartGrid.js";import{ChartLegend as he}from"../chart/ChartLegend.js";import{ChartTableView as fe}from"../chart/ChartTableView.js";import{ChartTooltip as ge,ChartTooltipContent as ye}from"../chart/ChartTooltip.js";import{CHART_ALL_PAIRS_LIMIT as te,getSeriesLabel as re,resolveSeriesColor as pe,toLegendItems as be}from"../chart/palette.js";import{buildCartesianGeometry as xe,createPlotContext as Ce,splitOverlay as ve}from"../chart/utils/cartesian.js";import{collectAllValues as ne,readNumber as ie}from"../chart/utils/data.js";import{sampleEvenly as Se,warnPointBudget as ke}from"../chart/utils/decimate.js";import{formatAuto as oe,formatXValue as Pe}from"../chart/utils/format.js";import{toNumber as j}from"../chart/utils/scales.js";import{extent as ae}from"../chart/utils/ticks.js";import{Fragment as we,jsx as l,jsxs as F}from"react/jsx-runtime";var Ve=4.5,Le=48,J=!1,Re=ue(function({points:m}){return l("g",{children:m.map(r=>l("circle",{cx:r.cx,cy:r.cy,r:r.r,fill:r.color,fillOpacity:.85,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},`${r.seriesKey}-${r.index}`))})});function Te({width:y,height:m,data:r,resolvedSeries:w,x:p,y:A,grid:S,size:E,bubble:h,trendLine:I,quadrants:W,pointRadius:X,overlay:M,maxPoints:P,margin:z,tooltip:V,onPointClick:$,plotLabel:O,formatValue:x,formatX:L}){let[t,D]=se(null),e=N(()=>{let i=w.filter(a=>!a.hidden),K=i.map(a=>a.key),o=xe({width:y,height:m,data:r,x:{...p,scale:p.scale==="time"?"time":"linear"},y:A,bounds:ae(ne(r,K)),margin:z,formatValue:x,formatX:L}),C=h?ne(r,[h.key]):[],R=h?ae(C):null,[b,k]=h?.range??[4,14],T=a=>{if(!h||!R)return X;let c=ie(a,h.key);if(c===null)return b;let[f,g]=R,v=g===f?1:(c-f)/(g-f);return Math.sqrt(b*b+v*(k*k-b*b))},G=[],d=[];i.forEach(a=>{let c=[];r.forEach((f,g)=>{let v=ie(f,a.key),n=o.categoryPositions[g];v===null||!Number.isFinite(n)||c.push({seriesKey:a.key,seriesLabel:re(a),color:a.color,index:g,cx:n,cy:o.valueScale(v),r:T(f),xValue:j(o.xValues[g]),yValue:v})}),P||ke("ScatterChart",c.length),d.push(...c),G.push(...P&&P>0?Se(c,P):c)});let H=null;if(I&&d.length>1){let a=d.length,c=d.reduce((u,s)=>u+s.xValue,0),f=d.reduce((u,s)=>u+s.yValue,0),g=d.reduce((u,s)=>u+s.xValue*s.yValue,0),v=d.reduce((u,s)=>u+s.xValue*s.xValue,0),n=a*v-c*c;if(n!==0){let u=(a*g-c*f)/n,s=(f-u*c)/a,Q=d.map(q=>q.xValue),[le,ce]=[Math.min(...Q),Math.max(...Q)],Z=d.map(q=>q.cx);H={x1:Math.min(...Z),y1:o.valueScale(u*le+s),x2:Math.max(...Z),y2:o.valueScale(u*ce+s)}}}return{visible:i,points:G,plot:Ce({geometry:o,width:y,height:m,data:r,series:i,formatValue:x,formatX:L}),trend:H,xTicks:o.categoryTicks,yTicks:o.valueTicks,valueScale:o.valueScale,positions:o.categoryPositions,innerWidth:o.innerWidth,innerHeight:o.innerHeight,margin:o.margin,xValues:o.xValues}},[r,w,p,A,y,m,z,h,I,X,P,x,L]),Y=U(i=>{if(V===!1||e.points.length===0)return;let K=i.currentTarget.getBoundingClientRect(),o=i.clientX-K.left-e.margin.left,C=i.clientY-K.top-e.margin.top,R=null,b=Le;for(let k of e.points){let T=Math.hypot(k.cx-o,k.cy-C);T<b&&(b=T,R=k)}D(R)},[V,e.points,e.margin]),_=U(()=>{if(!$||!t)return;let i=r[t.index];i&&$({seriesKey:t.seriesKey,seriesLabel:t.seriesLabel,color:t.color,value:t.yValue,formattedValue:x(t.yValue),datum:i,index:t.index,x:e.xValues[t.index]})},[$,t,x,r,e.xValues]),B=ve(M);return F(we,{children:[F("svg",{width:y,height:m,role:"img","aria-label":O??e.visible.map(i=>re(i)).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:Y,onPointerLeave:()=>D(null),onBlur:()=>D(null),onClick:_,children:[F("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[l(me,{width:e.innerWidth,height:e.innerHeight,horizontal:S==="y"||S==="both"?e.yTicks.map(i=>i.offset):void 0,vertical:S==="x"||S==="both"?e.xTicks.map(i=>i.offset):void 0}),W?.y!==void 0?l("line",{x1:0,y1:e.valueScale(W.y),x2:e.innerWidth,y2:e.valueScale(W.y),stroke:"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:"4 4"}):null,B.under?.(e.plot),e.trend?l("line",{x1:e.trend.x1,y1:e.trend.y1,x2:e.trend.x2,y2:e.trend.y2,stroke:"var(--color-chart-muted)",strokeWidth:1.5,strokeDasharray:"4 4"}):null,l(Re,{points:e.points}),B.over?.(e.plot),t?l("circle",{cx:t.cx,cy:t.cy,r:t.r+3,fill:"none",stroke:t.color,strokeWidth:2,"aria-hidden":"true"}):null]}),l("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:p.hidden?null:l(ee,{orientation:"bottom",ticks:e.xTicks,length:e.innerWidth,label:p.label,size:E})}),l("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:A?.hidden?null:l(ee,{orientation:"left",ticks:e.yTicks,length:e.innerHeight,showLine:!1,label:A?.label,size:E})})]}),t&&r[t.index]&&V!==!1?l(ge,{x:e.margin.left+t.cx,y:e.margin.top+t.cy,containerWidth:y,children:typeof V=="function"?V({x:e.xValues[t.index],xLabel:L(e.xValues[t.index],t.index),index:t.index,points:[{seriesKey:t.seriesKey,seriesLabel:t.seriesLabel,color:t.color,value:t.yValue,formattedValue:x(t.yValue),datum:r[t.index]}]}):l(ye,{title:`${p.label??p.key} ${L(e.xValues[t.index],t.index)}`,points:[{seriesKey:t.seriesKey,seriesLabel:t.seriesLabel,color:t.color,value:t.yValue,formattedValue:x(t.yValue),datum:r[t.index]}]})}):null]})}function Oe({data:y,series:m,x:r,y:w,height:p=280,width:A,size:S="md",grid:E="both",legend:h,tooltip:I=!0,tableView:W=!1,emphasis:X,title:M,description:P,loading:z=!1,emptyState:V,error:$=!1,errorState:O,onRetry:x,actions:L,onPointClick:t,bubble:D,trendLine:e=!1,quadrants:Y,pointRadius:_=Ve,overlay:B,legendToggle:i=!0,maxPoints:K,margin:o,locale:C,plotLabel:R,className:b,...k}){let[T,G]=se(()=>new Set);m.length>te&&!J&&(J=!0,console.warn(`[@synertech/ui] A ScatterChart was given ${m.length} series. Any two marks can sit side by side here, and only the first ${te} palette slots stay tellable apart under that test: facet the chart instead.`));let d=N(()=>m.map((n,u)=>({...n,hidden:n.hidden||T.has(n.key),color:pe(n,u,X)})),[m,T,X]),H=N(()=>w?.format??(n=>oe(n,C)),[w?.format,C]),a=N(()=>r.format??(n=>r.scale==="time"?Pe(n instanceof Date?n:new Date(j(n)),C):oe(j(n),C)),[r.format,r.scale,C]),c=U(n=>{G(u=>{let s=new Set(u);return s.has(n)?s.delete(n):s.add(n),s})},[]),f=h===void 0?m.length>=2:h!==!1,g=typeof h=="string"?h:"bottom",v=d.filter(n=>!n.hidden).length;return l(de,{title:M,description:P,height:p,width:A,size:S,loading:z,empty:y.length===0||v===0,emptyState:V,error:$,errorState:O,onRetry:x,actions:L,tableView:W,legendPosition:g,legend:f?l(he,{items:be(d,X),position:g,marker:"dot",size:S,onToggle:i?c:void 0}):void 0,table:W?l(fe,{data:y,series:d,xKey:r.key,xLabel:r.label??r.key,formatX:a,formatValue:H,caption:typeof M=="string"?M:void 0}):void 0,className:b,...k,children:({width:n})=>l(Te,{width:n,height:p,data:y,resolvedSeries:d,x:r,y:w,grid:E,size:S,bubble:D,trendLine:e,quadrants:Y,pointRadius:_,overlay:B,maxPoints:K,margin:o,tooltip:I,onPointClick:t,plotLabel:R,formatValue:H,formatX:a})})}function Ye(){J=!1}export{Oe as ScatterChart,Ye as resetScatterWarnings};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var o=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var f=(r,t)=>{for(var e in t)o(r,e,{get:t[e],enumerable:!0})},m=(r,t,e,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of C(t))!S.call(r,a)&&a!==e&&o(r,a,{get:()=>t[a],enumerable:!(p=h(t,a))||p.enumerable});return r};var x=r=>m(o({},"__esModule",{value:!0}),r);var s={};f(s,{ScatterChart:()=>c.ScatterChart});module.exports=x(s);var c=require("./ScatterChart.cjs");0&&(module.exports={ScatterChart});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ScatterChart as a}from"./ScatterChart.js";export{a as ScatterChart};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";"use client";var ge=Object.defineProperty;var wt=Object.getOwnPropertyDescriptor;var zt=Object.getOwnPropertyNames;var Ft=Object.prototype.hasOwnProperty;var Dt=(R,S)=>{for(var g in S)ge(R,g,{get:S[g],enumerable:!0})},xt=(R,S,g,J)=>{if(S&&typeof S=="object"||typeof S=="function")for(let F of zt(S))!Ft.call(R,F)&&F!==g&&ge(R,F,{get:()=>S[F],enumerable:!(J=wt(S,F))||J.enumerable});return R};var Mt=R=>xt(ge({},"__esModule",{value:!0}),R);var Ht={};Dt(Ht,{SchemaEditor:()=>$e});module.exports=Mt(Ht);var o=require("react"),Ke=require("../../lib/cn.cjs"),Oe=require("./canvas/GridLayer.cjs"),Pe=require("./tables/SchemaTableRenderer.cjs"),Be=require("./relations/SchemaRelationRenderer.cjs"),We=require("./toolbar/SchemaToolbar.cjs"),Ge=require("./legend/SchemaLegend.cjs"),Je=require("./minimap/SchemaMinimap.cjs"),a=require("./utils/geometry.cjs"),_=require("./utils/schema-helpers.cjs"),Ie=require("./utils/sql-export.cjs"),Qe=require("./utils/auto-layout.cjs"),I=require("react/jsx-runtime"),pe={x:0,y:0,zoom:1},ye=.1,Xt=.1,Yt=3,Ct=20,Lt=50;function At({value:R,defaultValue:S,onValueChange:g,fieldTypes:J=_.DEFAULT_FIELD_TYPES,onTableClick:F,onTableDoubleClick:Z,onTableContextMenu:ee,onFieldClick:Nt,onFieldDoubleClick:_t,readOnly:D=!1,disabled:h=!1,draggableTables:Ee=!0,panOnDrag:Re=!0,zoomOnWheel:Te=!0,editable:Y=!0,minZoom:C=Xt,maxZoom:L=Yt,snapToGrid:Se=!1,gridSize:te=Ct,showGrid:qe=!0,toolbar:je=!0,legend:ve=!0,autoFit:we=!1,className:Ze},et){let k=R!==void 0,[tt,ne]=(0,o.useState)(()=>S??{tables:[],relations:[],viewport:{...pe}}),z=k?R:tt,T=z.tables,re=z.relations,s=z.viewport??pe,x=(0,o.useRef)(null),A=(0,o.useRef)(null),[U,O]=(0,o.useState)(null),[P,B]=(0,o.useState)(null),[M,oe]=(0,o.useState)(null),[ze,Fe]=(0,o.useState)(null),[ie,nt]=(0,o.useState)({width:0,height:0}),v=(0,o.useRef)([]),w=(0,o.useRef)(-1),W=(0,o.useRef)(!1),Q=(0,o.useRef)(s);Q.current=s;let De=(0,o.useRef)(T);De.current=T;let xe=(0,o.useRef)(re);xe.current=re;let Me=(0,o.useRef)(Se);Me.current=Se;let se=(0,o.useRef)(te);se.current=te;let Xe=(0,o.useRef)(Y);Xe.current=Y;let le=(0,o.useCallback)(e=>{if(W.current)return;let t=v.current,r=w.current;v.current=t.slice(0,r+1),v.current.push(e),v.current.length>Lt&&v.current.shift(),w.current=v.current.length-1},[]),l=(0,o.useCallback)(e=>{if(k){let t=e(R);le(t),g?.(t)}else ne(t=>{let r=e(t);return le(r),g?.(r),r})},[k,R,g,le]),$=(0,o.useRef)(l);$.current=l;let E=(0,o.useCallback)(e=>{l(t=>({...t,viewport:e}))},[l]),Ye=(0,o.useRef)(E);Ye.current=E,(0,o.useEffect)(()=>{function e(n){let i=A.current;if(!i)return;let u=x.current?.getBoundingClientRect();if(!u)return;let f=Q.current;if(i.type==="pan"){let m=n.clientX-i.startX,c=n.clientY-i.startY;Ye.current({...f,x:i.startVpX+m,y:i.startVpY+c})}if(i.type==="table"){let m=(0,a.screenToCanvas)(n.clientX,n.clientY,f,u),c=m.x-i.offsetX,p=m.y-i.offsetY;Me.current&&(c=(0,a.snapValue)(c,se.current),p=(0,a.snapValue)(p,se.current)),$.current(d=>({...d,tables:d.tables.map(y=>y.id===i.tableId?{...y,x:c,y:p}:y)}))}if(i.type==="relation"){let m=(0,a.screenToCanvas)(n.clientX,n.clientY,f,u);A.current={...i,currentX:m.x,currentY:m.y},oe({fromX:i.fromX,fromY:i.fromY,currentX:m.x,currentY:m.y})}if(i.type==="resize"){let m=(n.clientX-i.startX)/f.zoom,c=(n.clientY-i.startY)/f.zoom,p=180,d=80,y=Math.max(p,i.startWidth+m),b=Math.max(d,i.startHeight+c);$.current(H=>({...H,tables:H.tables.map(X=>X.id===i.tableId?{...X,width:y,height:b}:X)}))}}function t(n,i,u,f){let m=Q.current,c=(0,a.screenToCanvas)(n,i,m,u),p=1/0,d=null,y=null;for(let b of f){if(b.collapsed)continue;let H=b.fields.length;if(H===0)continue;let X=b.width??a.DEFAULT_TABLE_WIDTH,K=a.HEADER_HEIGHT+H*a.FIELD_ROW_HEIGHT+(Xe.current?a.ADD_BUTTON_HEIGHT:0),N=40;if(!(c.x<b.x-N||c.x>b.x+X+N||c.y<b.y-N||c.y>b.y+K+N))for(let j=0;j<b.fields.length;j++){let vt=b.y+(0,a.getFieldConnectionY)(j,!!b.notes),Ve=Math.abs(c.y-vt);Ve<p&&(p=Ve,d=b.id,y=b.fields[j].id)}}return d&&y?{tableId:d,fieldId:y}:null}function r(n){let i=A.current;if(i){if(i.type==="relation"){let u=x.current?.getBoundingClientRect();if(u){let f=xe.current,m=De.current,c=t(n.clientX,n.clientY,u,m);if(c&&c.tableId!==i.fromTableId&&!f.some(d=>d.from.tableId===i.fromTableId&&d.from.fieldId===i.fromFieldId&&d.to.tableId===c.tableId&&d.to.fieldId===c.fieldId)){let d=i.fromTableId,y=i.fromFieldId,b=c.tableId,H=c.fieldId;$.current(X=>({...X,tables:X.tables.map(K=>K.id===b?{...K,fields:K.fields.map(N=>N.id===H?{...N,foreignKey:{tableId:d,fieldId:y}}:N)}:K),relations:[...X.relations,{id:(0,_.generateRelationId)(),from:{tableId:d,fieldId:y},to:{tableId:b,fieldId:H},cardinality:"1:n"}]}))}}oe(null),Fe(null)}A.current=null}}return document.addEventListener("mousemove",e),document.addEventListener("mouseup",r),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",r)}},[]);let rt=(0,o.useCallback)(e=>{if(!Te||h)return;e.preventDefault();let t=x.current?.getBoundingClientRect();if(!t)return;let r=e.clientX-t.left,n=e.clientY-t.top,i=e.deltaY<0?1:-1,u=(0,a.clampZoom)(s.zoom+i*ye,C,L),f=u/s.zoom;E({x:r-(r-s.x)*f,y:n-(n-s.y)*f,zoom:u})},[Te,h,s,C,L,E]),ot=(0,o.useCallback)(e=>{if(h)return;let t=e.target,r=t.tagName,n=r==="INPUT"||r==="SELECT"||r==="TEXTAREA"||r==="BUTTON";if(t.closest("[data-resize-handle]"))return;let i=t.closest("[data-connection-side]");if(i&&!n){if(D)return;e.preventDefault();let f=i.getAttribute("data-table-id"),m=i.getAttribute("data-field-id");if(!f||!m)return;let c=T.find(y=>y.id===f);if(!c)return;let p=i.getAttribute("data-connection-side"),d=(0,a.getFieldConnectionPosition)(c,m,p);if(!d)return;A.current={type:"relation",fromTableId:f,fromFieldId:m,fromX:d.x,fromY:d.y,currentX:d.x,currentY:d.y},oe({fromX:d.x,fromY:d.y,currentX:d.x,currentY:d.y}),Fe(f);return}let u=t.closest("[data-table-id]");if(u){if(D)return;let f=u.getAttribute("data-table-id");if(B(null),O(f),n)return;if(Ee){let m=x.current?.getBoundingClientRect();if(!m)return;let c=T.find(d=>d.id===f);if(!c||c.locked)return;let p=(0,a.screenToCanvas)(e.clientX,e.clientY,s,m);A.current={type:"table",tableId:f,offsetX:p.x-c.x,offsetY:p.y-c.y}}return}O(null),B(null),Re&&e.button===0&&(A.current={type:"pan",startX:e.clientX,startY:e.clientY,startVpX:s.x,startVpY:s.y})},[h,D,Ee,Re,s,T]),V=(0,o.useCallback)(e=>{let t=e.target;if(t.closest("[data-connection-side]"))return null;let r=t.closest("[data-table-id]");if(!r)return null;let n=r.getAttribute("data-table-id");return T.find(i=>i.id===n)??null},[T]),it=(0,o.useCallback)(e=>{if(h)return;let t=V(e);t&&F&&F({table:t,nativeEvent:e.nativeEvent})},[F,h,V]),st=(0,o.useCallback)(e=>{if(h)return;let t=V(e);t&&Z&&Z({table:t,nativeEvent:e.nativeEvent})},[Z,h,V]),lt=(0,o.useCallback)(e=>{if(h)return;let t=V(e);t&&ee&&(e.preventDefault(),ee({table:t,nativeEvent:e.nativeEvent}))},[ee,h,V]),at=(0,o.useCallback)((e,t)=>{h||(t.stopPropagation(),O(null),B(e))},[h]),ct=(0,o.useCallback)((e,t)=>{l(r=>({...r,relations:r.relations.map(n=>n.id===e?{...n,cardinality:t}:n)}))},[l]),dt=w.current>0,ut=w.current<v.current.length-1,ae=(0,o.useCallback)(()=>{if(w.current<=0)return;W.current=!0,w.current--;let e=v.current[w.current];k||ne(e),g?.(e),W.current=!1},[k,g]),ce=(0,o.useCallback)(()=>{if(w.current>=v.current.length-1)return;W.current=!0,w.current++;let e=v.current[w.current];k||ne(e),g?.(e),W.current=!1},[k,g]),ft=(0,o.useCallback)(()=>(0,Ie.generateSQL)(z),[z]),mt=(0,o.useCallback)(()=>{l(e=>({...e,tables:(0,Qe.autoLayoutTables)(e.tables,Y)}))},[l,Y]),ht=(0,o.useCallback)((e,t,r)=>{t!==r&&l(n=>({...n,tables:n.tables.map(i=>{if(i.id!==e)return i;let u=[...i.fields],[f]=u.splice(t,1);return u.splice(r,0,f),{...i,fields:u}})}))},[l]);(0,o.useEffect)(()=>{let e=x.current;if(!e)return;let t=new ResizeObserver(r=>{for(let n of r)nt({width:n.contentRect.width,height:n.contentRect.height})});return t.observe(e),()=>t.disconnect()},[]);let Ce=(0,o.useRef)(!1);Ce.current||(Ce.current=!0,v.current=[z],w.current=0);let bt=(0,o.useCallback)(e=>{if(!(D||h)){if((e.ctrlKey||e.metaKey)&&e.key==="z"&&!e.shiftKey){e.preventDefault(),ae();return}if((e.ctrlKey||e.metaKey)&&(e.key==="y"||e.key==="z"&&e.shiftKey)){e.preventDefault(),ce();return}if(e.key==="Delete"||e.key==="Backspace"){let t=e.target;if(t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT")return;U&&(l(r=>({...r,tables:r.tables.filter(n=>n.id!==U),relations:r.relations.filter(n=>n.from.tableId!==U&&n.to.tableId!==U)})),O(null)),P&&(l(r=>{let n=r.relations.find(i=>i.id===P);return{...r,tables:n?r.tables.map(i=>i.id===n.to.tableId?{...i,fields:i.fields.map(u=>u.id===n.to.fieldId?{...u,foreignKey:void 0}:u)}:i):r.tables,relations:r.relations.filter(i=>i.id!==P)}}),B(null))}e.key==="Escape"&&(O(null),B(null))}},[D,h,U,P,l,ae,ce]),gt=(0,o.useCallback)((e,t)=>{l(r=>({...r,tables:r.tables.map(n=>n.id===e?{...n,name:t}:n)}))},[l]),pt=(0,o.useCallback)((e,t)=>{l(r=>({...r,tables:r.tables.map(n=>n.id===e?{...n,notes:t}:n)}))},[l]),yt=(0,o.useCallback)(e=>{l(t=>({...t,tables:t.tables.map(r=>r.id===e?{...r,collapsed:!r.collapsed}:r)}))},[l]),It=(0,o.useCallback)((e,t,r)=>{l(n=>({...n,tables:n.tables.map(i=>i.id===e?{...i,fields:i.fields.map(u=>u.id===t?{...u,...r}:u)}:i)}))},[l]),Et=(0,o.useCallback)(e=>{l(t=>({...t,tables:t.tables.map(r=>r.id===e?{...r,fields:[...r.fields,(0,_.createDefaultField)()]}:r)}))},[l]),de=(0,o.useCallback)((e,t)=>{l(r=>({...r,tables:r.tables.map(n=>n.id===e?{...n,fields:n.fields.filter(i=>i.id!==t)}:n),relations:r.relations.filter(n=>!(n.from.tableId===e&&n.from.fieldId===t)&&!(n.to.tableId===e&&n.to.fieldId===t))}))},[l]),Rt=(0,o.useCallback)((e,t,r,n,i)=>{A.current={type:"resize",tableId:e,startX:t,startY:r,startWidth:n,startHeight:i}},[]),ue=(0,o.useCallback)(()=>{let e=(0,a.clampZoom)(s.zoom+ye,C,L);E({...s,zoom:e})},[s,C,L,E]),fe=(0,o.useCallback)(()=>{let e=(0,a.clampZoom)(s.zoom-ye,C,L);E({...s,zoom:e})},[s,C,L,E]),me=(0,o.useCallback)(()=>{E({...pe})},[E]),G=(0,o.useCallback)(()=>{let e=x.current?.getBoundingClientRect();if(!e)return;let t=(0,a.fitViewport)(T,e.width,e.height,Y),r=(0,a.clampZoom)(t.zoom,C,L);E({...t,zoom:r})},[T,Y,C,L,E]),q=(0,o.useCallback)(e=>{l(t=>({...t,tables:[...t.tables,e]}))},[l]),Le=(0,o.useCallback)(e=>{l(t=>({...t,tables:t.tables.filter(r=>r.id!==e),relations:t.relations.filter(r=>r.from.tableId!==e&&r.to.tableId!==e)}))},[l]),Ae=(0,o.useCallback)((e,t)=>{l(r=>({...r,tables:r.tables.map(n=>n.id===e?{...n,fields:[...n.fields,t]}:n)}))},[l]),He=(0,o.useCallback)((e,t)=>{de(e,t)},[de]),Ne=(0,o.useCallback)(e=>{l(t=>({...t,tables:t.tables.map(r=>r.id===e.to.tableId?{...r,fields:r.fields.map(n=>n.id===e.to.fieldId?{...n,foreignKey:{tableId:e.from.tableId,fieldId:e.from.fieldId}}:n)}:r),relations:[...t.relations,e]}))},[l]),_e=(0,o.useCallback)(e=>{l(t=>{let r=t.relations.find(n=>n.id===e);return{...t,tables:r?t.tables.map(n=>n.id===r.to.tableId?{...n,fields:n.fields.map(i=>i.id===r.to.fieldId?{...i,foreignKey:void 0}:i)}:n):t.tables,relations:t.relations.filter(n=>n.id!==e)}})},[l]),he=(0,o.useCallback)(()=>JSON.stringify(z,null,2),[z]),be=(0,o.useCallback)(e=>{try{let t=JSON.parse(e);t&&Array.isArray(t.tables)&&Array.isArray(t.relations)&&l(()=>t)}catch{}},[l]),Tt=(0,o.useCallback)(()=>{let e=x.current?.getBoundingClientRect(),t=Q.current,r=100,n=100;e&&(r=(e.width/2-t.x)/t.zoom-a.DEFAULT_TABLE_WIDTH/2,n=(e.height/2-t.y)/t.zoom-60),q((0,_.createDefaultTable)(r,n))},[q]),ke=(0,o.useCallback)(()=>(0,Ie.generateSQL)(z),[z]);(0,o.useImperativeHandle)(et,()=>({zoomIn:ue,zoomOut:fe,resetView:me,fitToContent:G,addTable:q,removeTable:Le,addField:Ae,removeField:He,addRelation:Ne,removeRelation:_e,toJSON:he,loadJSON:be,toSQL:ke}),[ue,fe,me,G,q,Le,Ae,He,Ne,_e,he,be,ke]);let Ue=(0,o.useRef)(!1);(0,o.useEffect)(()=>{we&&!Ue.current&&x.current&&(Ue.current=!0,G())},[we,G]);let St=(0,o.useMemo)(()=>({transform:`translate(${s.x}px, ${s.y}px) scale(${s.zoom})`,transformOrigin:"0 0"}),[s.x,s.y,s.zoom]);return(0,I.jsxs)("div",{ref:x,"data-testid":"schema-editor",className:(0,Ke.cn)("relative w-full overflow-hidden bg-gray-50 dark:bg-gray-900 select-none",h&&"opacity-60 pointer-events-none",Ze),tabIndex:0,onWheel:rt,onMouseDown:ot,onClick:it,onDoubleClick:st,onContextMenu:lt,onKeyDown:bt,children:[qe&&(0,I.jsx)(Oe.GridLayer,{gridSize:te,zoom:s.zoom}),je&&!D&&(0,I.jsx)(We.SchemaToolbar,{zoom:s.zoom,onZoomIn:ue,onZoomOut:fe,onResetView:me,onFitToContent:G,onAddTable:Tt,onExportJSON:he,onImportJSON:be,onExportSQL:ft,onUndo:ae,onRedo:ce,canUndo:dt,canRedo:ut,onAutoLayout:mt,disabled:h}),ve&&(0,I.jsx)(Ge.SchemaLegend,{}),(0,I.jsx)(Be.SchemaRelationRenderer,{relations:re,tables:T,viewport:s,selectedRelationId:P,disabled:h||D,onRelationClick:at,onCardinalityChange:ct}),(0,I.jsx)("div",{style:St,children:T.map(e=>(0,I.jsx)(Pe.SchemaTableRenderer,{table:e,selected:U===e.id,disabled:h||D,readOnly:D,editable:Y,dropTarget:ze!==null&&ze!==e.id&&!e.collapsed,fieldTypes:J,onTableNameChange:gt,onTableNotesChange:pt,onToggleCollapse:yt,onFieldChange:It,onFieldAdd:Et,onFieldRemove:de,onFieldReorder:ht,onResizeStart:Rt},e.id))}),M&&(0,I.jsxs)("svg",{"data-testid":"drag-relation-overlay",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:1e3,overflow:"visible"},children:[(0,I.jsx)("path",{d:(0,a.computeBezierPath)(M.fromX*s.zoom+s.x,M.fromY*s.zoom+s.y,M.currentX*s.zoom+s.x,M.currentY*s.zoom+s.y),fill:"none",stroke:"#3b82f6",strokeWidth:2.5,strokeDasharray:"8 4"}),(0,I.jsx)("circle",{cx:M.fromX*s.zoom+s.x,cy:M.fromY*s.zoom+s.y,r:5,fill:"#3b82f6"}),(0,I.jsx)("circle",{cx:M.currentX*s.zoom+s.x,cy:M.currentY*s.zoom+s.y,r:4,fill:"#3b82f6",opacity:.6})]}),ve&&ie.width>0&&(0,I.jsx)(Je.SchemaMinimap,{tables:T,viewport:s,containerWidth:ie.width,containerHeight:ie.height,editable:Y,onViewportChange:E})]})}var $e=(0,o.forwardRef)(At);$e.displayName="SchemaEditor";0&&(module.exports={SchemaEditor});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{forwardRef as Rt,useCallback as s,useEffect as ge,useImperativeHandle as Tt,useMemo as St,useRef as b,useState as k}from"react";import{cn as vt}from"../../lib/cn.js";import{GridLayer as wt}from"./canvas/GridLayer.js";import{SchemaTableRenderer as zt}from"./tables/SchemaTableRenderer.js";import{SchemaRelationRenderer as Ft}from"./relations/SchemaRelationRenderer.js";import{SchemaToolbar as Dt}from"./toolbar/SchemaToolbar.js";import{SchemaLegend as xt}from"./legend/SchemaLegend.js";import{SchemaMinimap as Mt}from"./minimap/SchemaMinimap.js";import{ADD_BUTTON_HEIGHT as Xt,clampZoom as $,computeBezierPath as Yt,DEFAULT_TABLE_WIDTH as Ve,FIELD_ROW_HEIGHT as Ct,fitViewport as Lt,getFieldConnectionPosition as At,getFieldConnectionY as Ht,HEADER_HEIGHT as Nt,screenToCanvas as q,snapValue as Ke}from"./utils/geometry.js";import{createDefaultField as _t,createDefaultTable as kt,DEFAULT_FIELD_TYPES as Ut,generateRelationId as Vt}from"./utils/schema-helpers.js";import{generateSQL as Oe}from"./utils/sql-export.js";import{autoLayoutTables as Kt}from"./utils/auto-layout.js";import{jsx as S,jsxs as Pe}from"react/jsx-runtime";var pe={x:0,y:0,zoom:1},ye=.1,Ot=.1,Pt=3,Bt=20,Wt=50;function Gt({value:B,defaultValue:Be,onValueChange:v,fieldTypes:We=Ut,onTableClick:j,onTableDoubleClick:Z,onTableContextMenu:ee,onFieldClick:Qt,onFieldDoubleClick:$t,readOnly:w=!1,disabled:m=!1,draggableTables:Ie=!0,panOnDrag:Ee=!0,zoomOnWheel:Re=!0,editable:x=!0,minZoom:M=Ot,maxZoom:X=Pt,snapToGrid:Te=!1,gridSize:te=Bt,showGrid:Ge=!0,toolbar:Je=!0,legend:Se=!0,autoFit:ve=!1,className:Qe},$e){let A=B!==void 0,[qe,ne]=k(()=>Be??{tables:[],relations:[],viewport:{...pe}}),T=A?B:qe,I=T.tables,re=T.relations,i=T.viewport??pe,z=b(null),Y=b(null),[H,U]=k(null),[V,K]=k(null),[F,oe]=k(null),[we,ze]=k(null),[ie,je]=k({width:0,height:0}),E=b([]),R=b(-1),O=b(!1),W=b(i);W.current=i;let Fe=b(I);Fe.current=I;let De=b(re);De.current=re;let xe=b(Te);xe.current=Te;let se=b(te);se.current=te;let Me=b(x);Me.current=x;let le=s(e=>{if(O.current)return;let t=E.current,r=R.current;E.current=t.slice(0,r+1),E.current.push(e),E.current.length>Wt&&E.current.shift(),R.current=E.current.length-1},[]),l=s(e=>{if(A){let t=e(B);le(t),v?.(t)}else ne(t=>{let r=e(t);return le(r),v?.(r),r})},[A,B,v,le]),G=b(l);G.current=l;let y=s(e=>{l(t=>({...t,viewport:e}))},[l]),Xe=b(y);Xe.current=y,ge(()=>{function e(n){let o=Y.current;if(!o)return;let d=z.current?.getBoundingClientRect();if(!d)return;let u=W.current;if(o.type==="pan"){let f=n.clientX-o.startX,a=n.clientY-o.startY;Xe.current({...u,x:o.startVpX+f,y:o.startVpY+a})}if(o.type==="table"){let f=q(n.clientX,n.clientY,u,d),a=f.x-o.offsetX,g=f.y-o.offsetY;xe.current&&(a=Ke(a,se.current),g=Ke(g,se.current)),G.current(c=>({...c,tables:c.tables.map(p=>p.id===o.tableId?{...p,x:a,y:g}:p)}))}if(o.type==="relation"){let f=q(n.clientX,n.clientY,u,d);Y.current={...o,currentX:f.x,currentY:f.y},oe({fromX:o.fromX,fromY:o.fromY,currentX:f.x,currentY:f.y})}if(o.type==="resize"){let f=(n.clientX-o.startX)/u.zoom,a=(n.clientY-o.startY)/u.zoom,g=180,c=80,p=Math.max(g,o.startWidth+f),h=Math.max(c,o.startHeight+a);G.current(C=>({...C,tables:C.tables.map(D=>D.id===o.tableId?{...D,width:p,height:h}:D)}))}}function t(n,o,d,u){let f=W.current,a=q(n,o,f,d),g=1/0,c=null,p=null;for(let h of u){if(h.collapsed)continue;let C=h.fields.length;if(C===0)continue;let D=h.width??Ve,_=Nt+C*Ct+(Me.current?Xt:0),L=40;if(!(a.x<h.x-L||a.x>h.x+D+L||a.y<h.y-L||a.y>h.y+_+L))for(let Q=0;Q<h.fields.length;Q++){let Et=h.y+Ht(Q,!!h.notes),Ue=Math.abs(a.y-Et);Ue<g&&(g=Ue,c=h.id,p=h.fields[Q].id)}}return c&&p?{tableId:c,fieldId:p}:null}function r(n){let o=Y.current;if(o){if(o.type==="relation"){let d=z.current?.getBoundingClientRect();if(d){let u=De.current,f=Fe.current,a=t(n.clientX,n.clientY,d,f);if(a&&a.tableId!==o.fromTableId&&!u.some(c=>c.from.tableId===o.fromTableId&&c.from.fieldId===o.fromFieldId&&c.to.tableId===a.tableId&&c.to.fieldId===a.fieldId)){let c=o.fromTableId,p=o.fromFieldId,h=a.tableId,C=a.fieldId;G.current(D=>({...D,tables:D.tables.map(_=>_.id===h?{..._,fields:_.fields.map(L=>L.id===C?{...L,foreignKey:{tableId:c,fieldId:p}}:L)}:_),relations:[...D.relations,{id:Vt(),from:{tableId:c,fieldId:p},to:{tableId:h,fieldId:C},cardinality:"1:n"}]}))}}oe(null),ze(null)}Y.current=null}}return document.addEventListener("mousemove",e),document.addEventListener("mouseup",r),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",r)}},[]);let Ze=s(e=>{if(!Re||m)return;e.preventDefault();let t=z.current?.getBoundingClientRect();if(!t)return;let r=e.clientX-t.left,n=e.clientY-t.top,o=e.deltaY<0?1:-1,d=$(i.zoom+o*ye,M,X),u=d/i.zoom;y({x:r-(r-i.x)*u,y:n-(n-i.y)*u,zoom:d})},[Re,m,i,M,X,y]),et=s(e=>{if(m)return;let t=e.target,r=t.tagName,n=r==="INPUT"||r==="SELECT"||r==="TEXTAREA"||r==="BUTTON";if(t.closest("[data-resize-handle]"))return;let o=t.closest("[data-connection-side]");if(o&&!n){if(w)return;e.preventDefault();let u=o.getAttribute("data-table-id"),f=o.getAttribute("data-field-id");if(!u||!f)return;let a=I.find(p=>p.id===u);if(!a)return;let g=o.getAttribute("data-connection-side"),c=At(a,f,g);if(!c)return;Y.current={type:"relation",fromTableId:u,fromFieldId:f,fromX:c.x,fromY:c.y,currentX:c.x,currentY:c.y},oe({fromX:c.x,fromY:c.y,currentX:c.x,currentY:c.y}),ze(u);return}let d=t.closest("[data-table-id]");if(d){if(w)return;let u=d.getAttribute("data-table-id");if(K(null),U(u),n)return;if(Ie){let f=z.current?.getBoundingClientRect();if(!f)return;let a=I.find(c=>c.id===u);if(!a||a.locked)return;let g=q(e.clientX,e.clientY,i,f);Y.current={type:"table",tableId:u,offsetX:g.x-a.x,offsetY:g.y-a.y}}return}U(null),K(null),Ee&&e.button===0&&(Y.current={type:"pan",startX:e.clientX,startY:e.clientY,startVpX:i.x,startVpY:i.y})},[m,w,Ie,Ee,i,I]),N=s(e=>{let t=e.target;if(t.closest("[data-connection-side]"))return null;let r=t.closest("[data-table-id]");if(!r)return null;let n=r.getAttribute("data-table-id");return I.find(o=>o.id===n)??null},[I]),tt=s(e=>{if(m)return;let t=N(e);t&&j&&j({table:t,nativeEvent:e.nativeEvent})},[j,m,N]),nt=s(e=>{if(m)return;let t=N(e);t&&Z&&Z({table:t,nativeEvent:e.nativeEvent})},[Z,m,N]),rt=s(e=>{if(m)return;let t=N(e);t&&ee&&(e.preventDefault(),ee({table:t,nativeEvent:e.nativeEvent}))},[ee,m,N]),ot=s((e,t)=>{m||(t.stopPropagation(),U(null),K(e))},[m]),it=s((e,t)=>{l(r=>({...r,relations:r.relations.map(n=>n.id===e?{...n,cardinality:t}:n)}))},[l]),st=R.current>0,lt=R.current<E.current.length-1,ae=s(()=>{if(R.current<=0)return;O.current=!0,R.current--;let e=E.current[R.current];A||ne(e),v?.(e),O.current=!1},[A,v]),ce=s(()=>{if(R.current>=E.current.length-1)return;O.current=!0,R.current++;let e=E.current[R.current];A||ne(e),v?.(e),O.current=!1},[A,v]),at=s(()=>Oe(T),[T]),ct=s(()=>{l(e=>({...e,tables:Kt(e.tables,x)}))},[l,x]),dt=s((e,t,r)=>{t!==r&&l(n=>({...n,tables:n.tables.map(o=>{if(o.id!==e)return o;let d=[...o.fields],[u]=d.splice(t,1);return d.splice(r,0,u),{...o,fields:d}})}))},[l]);ge(()=>{let e=z.current;if(!e)return;let t=new ResizeObserver(r=>{for(let n of r)je({width:n.contentRect.width,height:n.contentRect.height})});return t.observe(e),()=>t.disconnect()},[]);let Ye=b(!1);Ye.current||(Ye.current=!0,E.current=[T],R.current=0);let ut=s(e=>{if(!(w||m)){if((e.ctrlKey||e.metaKey)&&e.key==="z"&&!e.shiftKey){e.preventDefault(),ae();return}if((e.ctrlKey||e.metaKey)&&(e.key==="y"||e.key==="z"&&e.shiftKey)){e.preventDefault(),ce();return}if(e.key==="Delete"||e.key==="Backspace"){let t=e.target;if(t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT")return;H&&(l(r=>({...r,tables:r.tables.filter(n=>n.id!==H),relations:r.relations.filter(n=>n.from.tableId!==H&&n.to.tableId!==H)})),U(null)),V&&(l(r=>{let n=r.relations.find(o=>o.id===V);return{...r,tables:n?r.tables.map(o=>o.id===n.to.tableId?{...o,fields:o.fields.map(d=>d.id===n.to.fieldId?{...d,foreignKey:void 0}:d)}:o):r.tables,relations:r.relations.filter(o=>o.id!==V)}}),K(null))}e.key==="Escape"&&(U(null),K(null))}},[w,m,H,V,l,ae,ce]),ft=s((e,t)=>{l(r=>({...r,tables:r.tables.map(n=>n.id===e?{...n,name:t}:n)}))},[l]),mt=s((e,t)=>{l(r=>({...r,tables:r.tables.map(n=>n.id===e?{...n,notes:t}:n)}))},[l]),ht=s(e=>{l(t=>({...t,tables:t.tables.map(r=>r.id===e?{...r,collapsed:!r.collapsed}:r)}))},[l]),bt=s((e,t,r)=>{l(n=>({...n,tables:n.tables.map(o=>o.id===e?{...o,fields:o.fields.map(d=>d.id===t?{...d,...r}:d)}:o)}))},[l]),gt=s(e=>{l(t=>({...t,tables:t.tables.map(r=>r.id===e?{...r,fields:[...r.fields,_t()]}:r)}))},[l]),de=s((e,t)=>{l(r=>({...r,tables:r.tables.map(n=>n.id===e?{...n,fields:n.fields.filter(o=>o.id!==t)}:n),relations:r.relations.filter(n=>!(n.from.tableId===e&&n.from.fieldId===t)&&!(n.to.tableId===e&&n.to.fieldId===t))}))},[l]),pt=s((e,t,r,n,o)=>{Y.current={type:"resize",tableId:e,startX:t,startY:r,startWidth:n,startHeight:o}},[]),ue=s(()=>{let e=$(i.zoom+ye,M,X);y({...i,zoom:e})},[i,M,X,y]),fe=s(()=>{let e=$(i.zoom-ye,M,X);y({...i,zoom:e})},[i,M,X,y]),me=s(()=>{y({...pe})},[y]),P=s(()=>{let e=z.current?.getBoundingClientRect();if(!e)return;let t=Lt(I,e.width,e.height,x),r=$(t.zoom,M,X);y({...t,zoom:r})},[I,x,M,X,y]),J=s(e=>{l(t=>({...t,tables:[...t.tables,e]}))},[l]),Ce=s(e=>{l(t=>({...t,tables:t.tables.filter(r=>r.id!==e),relations:t.relations.filter(r=>r.from.tableId!==e&&r.to.tableId!==e)}))},[l]),Le=s((e,t)=>{l(r=>({...r,tables:r.tables.map(n=>n.id===e?{...n,fields:[...n.fields,t]}:n)}))},[l]),Ae=s((e,t)=>{de(e,t)},[de]),He=s(e=>{l(t=>({...t,tables:t.tables.map(r=>r.id===e.to.tableId?{...r,fields:r.fields.map(n=>n.id===e.to.fieldId?{...n,foreignKey:{tableId:e.from.tableId,fieldId:e.from.fieldId}}:n)}:r),relations:[...t.relations,e]}))},[l]),Ne=s(e=>{l(t=>{let r=t.relations.find(n=>n.id===e);return{...t,tables:r?t.tables.map(n=>n.id===r.to.tableId?{...n,fields:n.fields.map(o=>o.id===r.to.fieldId?{...o,foreignKey:void 0}:o)}:n):t.tables,relations:t.relations.filter(n=>n.id!==e)}})},[l]),he=s(()=>JSON.stringify(T,null,2),[T]),be=s(e=>{try{let t=JSON.parse(e);t&&Array.isArray(t.tables)&&Array.isArray(t.relations)&&l(()=>t)}catch{}},[l]),yt=s(()=>{let e=z.current?.getBoundingClientRect(),t=W.current,r=100,n=100;e&&(r=(e.width/2-t.x)/t.zoom-Ve/2,n=(e.height/2-t.y)/t.zoom-60),J(kt(r,n))},[J]),_e=s(()=>Oe(T),[T]);Tt($e,()=>({zoomIn:ue,zoomOut:fe,resetView:me,fitToContent:P,addTable:J,removeTable:Ce,addField:Le,removeField:Ae,addRelation:He,removeRelation:Ne,toJSON:he,loadJSON:be,toSQL:_e}),[ue,fe,me,P,J,Ce,Le,Ae,He,Ne,he,be,_e]);let ke=b(!1);ge(()=>{ve&&!ke.current&&z.current&&(ke.current=!0,P())},[ve,P]);let It=St(()=>({transform:`translate(${i.x}px, ${i.y}px) scale(${i.zoom})`,transformOrigin:"0 0"}),[i.x,i.y,i.zoom]);return Pe("div",{ref:z,"data-testid":"schema-editor",className:vt("relative w-full overflow-hidden bg-gray-50 dark:bg-gray-900 select-none",m&&"opacity-60 pointer-events-none",Qe),tabIndex:0,onWheel:Ze,onMouseDown:et,onClick:tt,onDoubleClick:nt,onContextMenu:rt,onKeyDown:ut,children:[Ge&&S(wt,{gridSize:te,zoom:i.zoom}),Je&&!w&&S(Dt,{zoom:i.zoom,onZoomIn:ue,onZoomOut:fe,onResetView:me,onFitToContent:P,onAddTable:yt,onExportJSON:he,onImportJSON:be,onExportSQL:at,onUndo:ae,onRedo:ce,canUndo:st,canRedo:lt,onAutoLayout:ct,disabled:m}),Se&&S(xt,{}),S(Ft,{relations:re,tables:I,viewport:i,selectedRelationId:V,disabled:m||w,onRelationClick:ot,onCardinalityChange:it}),S("div",{style:It,children:I.map(e=>S(zt,{table:e,selected:H===e.id,disabled:m||w,readOnly:w,editable:x,dropTarget:we!==null&&we!==e.id&&!e.collapsed,fieldTypes:We,onTableNameChange:ft,onTableNotesChange:mt,onToggleCollapse:ht,onFieldChange:bt,onFieldAdd:gt,onFieldRemove:de,onFieldReorder:dt,onResizeStart:pt},e.id))}),F&&Pe("svg",{"data-testid":"drag-relation-overlay",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:1e3,overflow:"visible"},children:[S("path",{d:Yt(F.fromX*i.zoom+i.x,F.fromY*i.zoom+i.y,F.currentX*i.zoom+i.x,F.currentY*i.zoom+i.y),fill:"none",stroke:"#3b82f6",strokeWidth:2.5,strokeDasharray:"8 4"}),S("circle",{cx:F.fromX*i.zoom+i.x,cy:F.fromY*i.zoom+i.y,r:5,fill:"#3b82f6"}),S("circle",{cx:F.currentX*i.zoom+i.x,cy:F.currentY*i.zoom+i.y,r:4,fill:"#3b82f6",opacity:.6})]}),Se&&ie.width>0&&S(Mt,{tables:I,viewport:i,containerWidth:ie.width,containerHeight:ie.height,editable:x,onViewportChange:y})]})}var Jt=Rt(Gt);Jt.displayName="SchemaEditor";export{Jt as SchemaEditor};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var o=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var r=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var b=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of r(e))!d.call(t,a)&&a!==i&&o(t,a,{get:()=>e[a],enumerable:!(n=l(e,a))||n.enumerable});return t};var m=t=>b(o({},"__esModule",{value:!0}),t);var s={};module.exports=m(s);
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var n=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var f=(r,e)=>{for(var i in e)n(r,i,{get:e[i],enumerable:!0})},u=(r,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of c(e))!p.call(r,a)&&a!==i&&n(r,a,{get:()=>e[a],enumerable:!(s=o(e,a))||s.enumerable});return r};var g=r=>u(n({},"__esModule",{value:!0}),r);var m={};f(m,{GridLayer:()=>h});module.exports=g(m);var l=require("react"),t=require("react/jsx-runtime"),d="se-grid-pattern",h=(0,l.memo)(function({gridSize:e,zoom:i}){let s=e*i;return(0,t.jsxs)("svg",{className:"absolute inset-0 w-full h-full pointer-events-none","aria-hidden":"true",children:[(0,t.jsx)("defs",{children:(0,t.jsx)("pattern",{id:d,width:s,height:s,patternUnits:"userSpaceOnUse",children:(0,t.jsx)("circle",{cx:1,cy:1,r:1,className:"fill-gray-300 dark:fill-gray-600"})})}),(0,t.jsx)("rect",{width:"100%",height:"100%",fill:`url(#${d})`})]})});0&&(module.exports={GridLayer});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{memo as a}from"react";import{jsx as e,jsxs as n}from"react/jsx-runtime";var t="se-grid-pattern",o=a(function({gridSize:i,zoom:s}){let r=i*s;return n("svg",{className:"absolute inset-0 w-full h-full pointer-events-none","aria-hidden":"true",children:[e("defs",{children:e("pattern",{id:t,width:r,height:r,patternUnits:"userSpaceOnUse",children:e("circle",{cx:1,cy:1,r:1,className:"fill-gray-300 dark:fill-gray-600"})})}),e("rect",{width:"100%",height:"100%",fill:`url(#${t})`})]})});export{o as GridLayer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var m=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var n=Object.prototype.hasOwnProperty;var p=(t,a)=>{for(var o in a)m(t,o,{get:a[o],enumerable:!0})},E=(t,a,o,l)=>{if(a&&typeof a=="object"||typeof a=="function")for(let r of h(a))!n.call(t,r)&&r!==o&&m(t,r,{get:()=>a[r],enumerable:!(l=d(a,r))||l.enumerable});return t};var f=t=>E(m({},"__esModule",{value:!0}),t);var T={};p(T,{DEFAULT_FIELD_TYPES:()=>e.DEFAULT_FIELD_TYPES,SchemaEditor:()=>c.SchemaEditor,autoLayoutTables:()=>S.autoLayoutTables,createDefaultField:()=>e.createDefaultField,createDefaultTable:()=>e.createDefaultTable,generateFieldId:()=>e.generateFieldId,generateRelationId:()=>e.generateRelationId,generateSQL:()=>i.generateSQL,generateTableId:()=>e.generateTableId});module.exports=f(T);var c=require("./SchemaEditor.cjs"),e=require("./utils/schema-helpers.cjs"),i=require("./utils/sql-export.cjs"),S=require("./utils/auto-layout.cjs");0&&(module.exports={DEFAULT_FIELD_TYPES,SchemaEditor,autoLayoutTables,createDefaultField,createDefaultTable,generateFieldId,generateRelationId,generateSQL,generateTableId});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{SchemaEditor as t}from"./SchemaEditor.js";import{createDefaultTable as o,createDefaultField as m,generateTableId as l,generateFieldId as c,generateRelationId as i,DEFAULT_FIELD_TYPES as S}from"./utils/schema-helpers.js";import{generateSQL as h}from"./utils/sql-export.js";import{autoLayoutTables as p}from"./utils/auto-layout.js";export{S as DEFAULT_FIELD_TYPES,t as SchemaEditor,p as autoLayoutTables,m as createDefaultField,o as createDefaultTable,c as generateFieldId,i as generateRelationId,h as generateSQL,l as generateTableId};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var n=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var g=(a,t)=>{for(var r in t)n(a,r,{get:t[r],enumerable:!0})},m=(a,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of d(t))!x.call(a,s)&&s!==r&&n(a,s,{get:()=>t[s],enumerable:!(o=l(t,s))||o.enumerable});return a};var p=a=>m(n({},"__esModule",{value:!0}),a);var f={};g(f,{SchemaLegend:()=>N});module.exports=p(f);var i=require("react"),c=require("../../../lib/cn.cjs"),e=require("react/jsx-runtime"),v=()=>(0,e.jsxs)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,e.jsx)("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),(0,e.jsx)("circle",{cx:"4.5",cy:"11.5",r:"3"})]}),h=()=>(0,e.jsx)("span",{className:"text-xs font-bold text-gray-500 w-3.5 text-center",children:"?"}),y=()=>(0,e.jsxs)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:[(0,e.jsx)("circle",{cx:"8",cy:"8",r:"6",className:"fill-blue-500"}),(0,e.jsx)("path",{d:"M5 8h6M8 5l3 3-3 3",stroke:"white",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]}),k=()=>(0,e.jsx)("svg",{className:"w-3.5 h-3.5 text-amber-500",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,e.jsx)("path",{d:"M3 2v12M7 4h6M7 8h4M7 12h5"})}),u=()=>(0,e.jsx)("svg",{className:"w-3.5 h-3.5 text-purple-500",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,e.jsx)("path",{d:"M4 2v8a4 4 0 008 0V2"})}),N=(0,i.memo)(function({className:t}){return(0,e.jsxs)("div",{className:(0,c.cn)("absolute top-3 right-3 z-20 flex items-center gap-4 bg-white dark:bg-gray-800 rounded-lg shadow-md border border-gray-200 dark:border-gray-600 px-3 py-2",t),"data-testid":"schema-legend",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)(v,{}),(0,e.jsx)("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Primary Key"})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)(h,{}),(0,e.jsx)("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Nullable"})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)(y,{}),(0,e.jsx)("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Foreign Key"})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)(k,{}),(0,e.jsx)("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Index"})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)(u,{}),(0,e.jsx)("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Unique"})]})]})});0&&(module.exports={SchemaLegend});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{memo as s}from"react";import{cn as r}from"../../../lib/cn.js";import{jsx as e,jsxs as t}from"react/jsx-runtime";var n=()=>t("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),e("circle",{cx:"4.5",cy:"11.5",r:"3"})]}),o=()=>e("span",{className:"text-xs font-bold text-gray-500 w-3.5 text-center",children:"?"}),i=()=>t("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:[e("circle",{cx:"8",cy:"8",r:"6",className:"fill-blue-500"}),e("path",{d:"M5 8h6M8 5l3 3-3 3",stroke:"white",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]}),c=()=>e("svg",{className:"w-3.5 h-3.5 text-amber-500",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e("path",{d:"M3 2v12M7 4h6M7 8h4M7 12h5"})}),l=()=>e("svg",{className:"w-3.5 h-3.5 text-purple-500",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e("path",{d:"M4 2v8a4 4 0 008 0V2"})}),m=s(function({className:a}){return t("div",{className:r("absolute top-3 right-3 z-20 flex items-center gap-4 bg-white dark:bg-gray-800 rounded-lg shadow-md border border-gray-200 dark:border-gray-600 px-3 py-2",a),"data-testid":"schema-legend",children:[t("div",{className:"flex items-center gap-1.5",children:[e(n,{}),e("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Primary Key"})]}),t("div",{className:"flex items-center gap-1.5",children:[e(o,{}),e("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Nullable"})]}),t("div",{className:"flex items-center gap-1.5",children:[e(i,{}),e("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Foreign Key"})]}),t("div",{className:"flex items-center gap-1.5",children:[e(c,{}),e("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Index"})]}),t("div",{className:"flex items-center gap-1.5",children:[e(l,{}),e("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Unique"})]})]})});export{m as SchemaLegend};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var I=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var J=Object.prototype.hasOwnProperty;var K=(a,n)=>{for(var o in n)I(a,o,{get:n[o],enumerable:!0})},O=(a,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of q(n))!J.call(a,s)&&s!==o&&I(a,s,{get:()=>n[s],enumerable:!(r=U(n,s))||r.enumerable});return a};var Q=a=>O(I({},"__esModule",{value:!0}),a);var $={};K($,{SchemaMinimap:()=>Z});module.exports=Q($);var h=require("react"),E=require("../../../lib/cn.cjs"),d=require("../utils/geometry.cjs"),u=require("react/jsx-runtime"),x=180,g=120,M=10,Z=(0,h.memo)(function({tables:n,viewport:o,containerWidth:r,containerHeight:s,editable:b,onViewportChange:X,className:P}){let Y=(0,h.useRef)(null),m=(0,h.useMemo)(()=>{if(n.length===0)return null;let t=1/0,e=1/0,c=-1/0,i=-1/0;for(let l of n){let W=l.width??d.DEFAULT_TABLE_WIDTH,F=(0,d.getTableHeight)(l,b);t=Math.min(t,l.x),e=Math.min(e,l.y),c=Math.max(c,l.x+W),i=Math.max(i,l.y+F)}let y=-o.x/o.zoom,p=-o.y/o.zoom,R=y+r/o.zoom,V=p+s/o.zoom;t=Math.min(t,y),e=Math.min(e,p),c=Math.max(c,R),i=Math.max(i,V);let v=c-t+M*2,D=i-e+M*2,z=Math.min((x-4)/v,(g-4)/D),B=(x-v*z)/2,G=(g-D*z)/2;return{minX:t,minY:e,scale:z,offsetX:B,offsetY:G,vpMinX:y,vpMinY:p}},[n,o,r,s,b]),w=(0,h.useCallback)(t=>{if(!m)return;let e=Y.current?.getBoundingClientRect();if(!e)return;let c=t.clientX-e.left,i=t.clientY-e.top,y=(c-m.offsetX)/m.scale+m.minX-M,p=(i-m.offsetY)/m.scale+m.minY-M;X({...o,x:-(y-r/(2*o.zoom))*o.zoom,y:-(p-s/(2*o.zoom))*o.zoom})},[m,o,r,s,X]);if(!m)return null;let{minX:A,minY:N,scale:f,offsetX:C,offsetY:H,vpMinX:L,vpMinY:_}=m,S=(t,e)=>({x:(t-A+M)*f+C,y:(e-N+M)*f+H}),k=S(L,_),T={w:r/o.zoom*f,h:s/o.zoom*f};return(0,u.jsx)("div",{ref:Y,className:(0,E.cn)("absolute bottom-3 right-3 z-20 bg-white/90 dark:bg-gray-800/90 rounded-lg shadow-md border border-gray-200 dark:border-gray-600 cursor-pointer overflow-hidden",P),style:{width:x,height:g},onClick:w,onMouseDown:t=>t.stopPropagation(),"data-testid":"schema-minimap",children:(0,u.jsxs)("svg",{width:x,height:g,children:[n.map(t=>{let e=t.width??d.DEFAULT_TABLE_WIDTH,c=(0,d.getTableHeight)(t,b),i=S(t.x,t.y);return(0,u.jsx)("rect",{x:i.x,y:i.y,width:e*f,height:c*f,fill:t.color??"#e5e7eb",stroke:"#9ca3af",strokeWidth:.5,rx:1},t.id)}),(0,u.jsx)("rect",{x:k.x,y:k.y,width:T.w,height:T.h,fill:"rgba(59, 130, 246, 0.1)",stroke:"#3b82f6",strokeWidth:1,rx:1})]})})});0&&(module.exports={SchemaMinimap});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{memo as G,useCallback as W,useRef as F,useMemo as U}from"react";import{cn as q}from"../../../lib/cn.js";import{DEFAULT_TABLE_WIDTH as k,getTableHeight as T}from"../utils/geometry.js";import{jsx as x,jsxs as J}from"react/jsx-runtime";var u=180,d=120,a=10,$=G(function({tables:M,viewport:t,containerWidth:r,containerHeight:h,editable:y,onViewportChange:g,className:v}){let b=F(null),e=U(()=>{if(M.length===0)return null;let o=1/0,n=1/0,m=-1/0,s=-1/0;for(let c of M){let V=c.width??k,B=T(c,y);o=Math.min(o,c.x),n=Math.min(n,c.y),m=Math.max(m,c.x+V),s=Math.max(s,c.y+B)}let f=-t.x/t.zoom,l=-t.y/t.zoom,H=f+r/t.zoom,L=l+h/t.zoom;o=Math.min(o,f),n=Math.min(n,l),m=Math.max(m,H),s=Math.max(s,L);let Y=m-o+a*2,S=s-n+a*2,p=Math.min((u-4)/Y,(d-4)/S),_=(u-Y*p)/2,R=(d-S*p)/2;return{minX:o,minY:n,scale:p,offsetX:_,offsetY:R,vpMinX:f,vpMinY:l}},[M,t,r,h,y]),D=W(o=>{if(!e)return;let n=b.current?.getBoundingClientRect();if(!n)return;let m=o.clientX-n.left,s=o.clientY-n.top,f=(m-e.offsetX)/e.scale+e.minX-a,l=(s-e.offsetY)/e.scale+e.minY-a;g({...t,x:-(f-r/(2*t.zoom))*t.zoom,y:-(l-h/(2*t.zoom))*t.zoom})},[e,t,r,h,g]);if(!e)return null;let{minX:E,minY:P,scale:i,offsetX:w,offsetY:A,vpMinX:N,vpMinY:C}=e,z=(o,n)=>({x:(o-E+a)*i+w,y:(n-P+a)*i+A}),I=z(N,C),X={w:r/t.zoom*i,h:h/t.zoom*i};return x("div",{ref:b,className:q("absolute bottom-3 right-3 z-20 bg-white/90 dark:bg-gray-800/90 rounded-lg shadow-md border border-gray-200 dark:border-gray-600 cursor-pointer overflow-hidden",v),style:{width:u,height:d},onClick:D,onMouseDown:o=>o.stopPropagation(),"data-testid":"schema-minimap",children:J("svg",{width:u,height:d,children:[M.map(o=>{let n=o.width??k,m=T(o,y),s=z(o.x,o.y);return x("rect",{x:s.x,y:s.y,width:n*i,height:m*i,fill:o.color??"#e5e7eb",stroke:"#9ca3af",strokeWidth:.5,rx:1},o.id)}),x("rect",{x:I.x,y:I.y,width:X.w,height:X.h,fill:"rgba(59, 130, 246, 0.1)",stroke:"#3b82f6",strokeWidth:1,rx:1})]})})});export{$ as SchemaMinimap};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var g=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var E=(e,t)=>{for(var n in t)g(e,n,{get:t[n],enumerable:!0})},F=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of T(t))!w.call(e,r)&&r!==n&&g(e,r,{get:()=>t[r],enumerable:!(i=v(t,r))||i.enumerable});return e};var N=e=>F(g({},"__esModule",{value:!0}),e);var P={};E(P,{SchemaRelationRenderer:()=>A});module.exports=N(P);var k=require("react"),l=require("../utils/geometry.cjs"),o=require("react/jsx-runtime");function W(e,t){let n=t.find(a=>a.id===e.from.tableId),i=t.find(a=>a.id===e.to.tableId);if(!n||!i||n.collapsed||i.collapsed)return null;let r=n.fields.findIndex(a=>a.id===e.from.fieldId),m=i.fields.findIndex(a=>a.id===e.to.fieldId);if(r===-1||m===-1)return null;let y=n.width??l.DEFAULT_TABLE_WIDTH,x=i.width??l.DEFAULT_TABLE_WIDTH,c=n.x+y/2,p=i.x+x/2,h=n.y+(0,l.getFieldConnectionY)(r,!!n.notes),u=i.y+(0,l.getFieldConnectionY)(m,!!i.notes),d,s;return c<=p?(d=n.x+y,s=i.x):(d=n.x,s=i.x+x),{x1:d,y1:h,x2:s,y2:u,cardinality:e.cardinality??"1:n"}}var R=["1:1","1:n","n:1","n:n"];function Y(e){let t=R.indexOf(e);return R[(t+1)%R.length]}var A=(0,k.memo)(function({relations:t,tables:n,viewport:i,selectedRelationId:r,disabled:m,onRelationClick:y,onCardinalityChange:x}){return(0,o.jsx)("svg",{className:"absolute top-0 left-0 pointer-events-none",style:{width:"100%",height:"100%",overflow:"visible"},children:(0,o.jsx)("g",{transform:`translate(${i.x}, ${i.y}) scale(${i.zoom})`,children:t.map(c=>{let p=W(c,n);if(!p)return null;let{x1:h,y1:u,x2:d,y2:s,cardinality:a}=p,S=(0,l.computeBezierPath)(h,u,d,s),f=r===c.id,C=(h+d)/2,I=(u+s)/2;return(0,o.jsxs)("g",{children:[(0,o.jsx)("path",{d:S,fill:"none",stroke:"transparent",strokeWidth:16,className:"pointer-events-auto cursor-pointer",onClick:b=>{m||y?.(c.id,b)}}),(0,o.jsx)("path",{d:S,fill:"none",stroke:f?"#3b82f6":"#9ca3af",strokeWidth:f?2.5:1.5,className:"transition-colors"}),(0,o.jsx)("circle",{cx:h,cy:u,r:3,fill:f?"#3b82f6":"#9ca3af"}),(0,o.jsx)("circle",{cx:d,cy:s,r:3,fill:f?"#3b82f6":"#9ca3af"}),a&&(0,o.jsxs)("g",{className:m?void 0:"pointer-events-auto cursor-pointer",onClick:m?void 0:b=>{b.stopPropagation(),x?.(c.id,Y(a))},children:[(0,o.jsx)("rect",{x:C-14,y:I-9,width:28,height:18,rx:4,fill:"white",stroke:f?"#3b82f6":"#d1d5db",strokeWidth:1}),(0,o.jsx)("text",{x:C,y:I+4,textAnchor:"middle",className:"text-[10px] font-mono",fill:f?"#3b82f6":"#6b7280",children:a})]})]},c.id)})})})});0&&(module.exports={SchemaRelationRenderer});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{memo as v}from"react";import{computeBezierPath as T,DEFAULT_TABLE_WIDTH as C,getFieldConnectionY as I}from"../utils/geometry.js";import{jsx as o,jsxs as k}from"react/jsx-runtime";function w(i,c){let t=c.find(n=>n.id===i.from.tableId),e=c.find(n=>n.id===i.to.tableId);if(!t||!e||t.collapsed||e.collapsed)return null;let h=t.fields.findIndex(n=>n.id===i.from.fieldId),d=e.fields.findIndex(n=>n.id===i.to.fieldId);if(h===-1||d===-1)return null;let u=t.width??C,y=e.width??C,a=t.x+u/2,x=e.x+y/2,m=t.y+I(h,!!t.notes),f=e.y+I(d,!!e.notes),r,l;return a<=x?(r=t.x+u,l=e.x):(r=t.x,l=e.x+y),{x1:r,y1:m,x2:l,y2:f,cardinality:i.cardinality??"1:n"}}var b=["1:1","1:n","n:1","n:n"];function E(i){let c=b.indexOf(i);return b[(c+1)%b.length]}var W=v(function({relations:c,tables:t,viewport:e,selectedRelationId:h,disabled:d,onRelationClick:u,onCardinalityChange:y}){return o("svg",{className:"absolute top-0 left-0 pointer-events-none",style:{width:"100%",height:"100%",overflow:"visible"},children:o("g",{transform:`translate(${e.x}, ${e.y}) scale(${e.zoom})`,children:c.map(a=>{let x=w(a,t);if(!x)return null;let{x1:m,y1:f,x2:r,y2:l,cardinality:n}=x,g=T(m,f,r,l),s=h===a.id,R=(m+r)/2,S=(f+l)/2;return k("g",{children:[o("path",{d:g,fill:"none",stroke:"transparent",strokeWidth:16,className:"pointer-events-auto cursor-pointer",onClick:p=>{d||u?.(a.id,p)}}),o("path",{d:g,fill:"none",stroke:s?"#3b82f6":"#9ca3af",strokeWidth:s?2.5:1.5,className:"transition-colors"}),o("circle",{cx:m,cy:f,r:3,fill:s?"#3b82f6":"#9ca3af"}),o("circle",{cx:r,cy:l,r:3,fill:s?"#3b82f6":"#9ca3af"}),n&&k("g",{className:d?void 0:"pointer-events-auto cursor-pointer",onClick:d?void 0:p=>{p.stopPropagation(),y?.(a.id,E(n))},children:[o("rect",{x:R-14,y:S-9,width:28,height:18,rx:4,fill:"white",stroke:s?"#3b82f6":"#d1d5db",strokeWidth:1}),o("text",{x:R,y:S+4,textAnchor:"middle",className:"text-[10px] font-mono",fill:s?"#3b82f6":"#6b7280",children:n})]})]},a.id)})})})});export{W as SchemaRelationRenderer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var T=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var Y=Object.prototype.hasOwnProperty;var $=(d,o)=>{for(var h in o)T(d,h,{get:o[h],enumerable:!0})},X=(d,o,h,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of G(o))!Y.call(d,a)&&a!==h&&T(d,a,{get:()=>o[a],enumerable:!(s=U(o,a))||s.enumerable});return d};var J=d=>X(T({},"__esModule",{value:!0}),d);var oe={};$(oe,{SchemaTableRenderer:()=>te});module.exports=J(oe);var i=require("react"),g=require("../../../lib/cn.cjs"),c=require("../utils/geometry.cjs"),_=require("../utils/schema-helpers.cjs"),e=require("react/jsx-runtime"),D=()=>(0,e.jsxs)("svg",{className:"w-3.5 h-3.5 text-indigo-500 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,e.jsx)("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),(0,e.jsx)("circle",{cx:"4.5",cy:"11.5",r:"3"})]}),S=()=>(0,e.jsxs)("svg",{className:"w-3.5 h-3.5 flex-shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:[(0,e.jsx)("circle",{cx:"8",cy:"8",r:"6",className:"fill-blue-500"}),(0,e.jsx)("path",{d:"M5 8h6M8 5l3 3-3 3",stroke:"white",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]}),Q=({collapsed:d})=>(0,e.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:d?(0,e.jsx)("path",{d:"M6 3l5 5-5 5V3z"}):(0,e.jsx)("path",{d:"M3 6l5 5 5-5H3z"})}),E=()=>(0,e.jsx)("svg",{className:"w-3.5 h-3.5 text-amber-500 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,e.jsx)("path",{d:"M3 2v12M7 4h6M7 8h4M7 12h5"})}),H=()=>(0,e.jsx)("svg",{className:"w-3.5 h-3.5 text-purple-500 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,e.jsx)("path",{d:"M4 2v8a4 4 0 008 0V2"})}),Z=()=>(0,e.jsx)("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:(0,e.jsx)("path",{d:"M4 8h8"})}),O=()=>(0,e.jsxs)("svg",{className:"w-3 h-3 text-gray-300",viewBox:"0 0 16 16",fill:"currentColor",children:[(0,e.jsx)("circle",{cx:"5",cy:"4",r:"1.5"}),(0,e.jsx)("circle",{cx:"11",cy:"4",r:"1.5"}),(0,e.jsx)("circle",{cx:"5",cy:"8",r:"1.5"}),(0,e.jsx)("circle",{cx:"11",cy:"8",r:"1.5"}),(0,e.jsx)("circle",{cx:"5",cy:"12",r:"1.5"}),(0,e.jsx)("circle",{cx:"11",cy:"12",r:"1.5"})]}),ee=(0,i.memo)(function({field:o,tableId:h,editable:s,readOnly:a,disabled:l,onFieldChange:y}){let[k,x]=(0,i.useState)(!1),[f,b]=(0,i.useState)(o.defaultValue??""),p=s&&!a&&!l,v=()=>{x(!1),y?.(h,o.id,{defaultValue:f||void 0})};return p?k?(0,e.jsx)("input",{className:"text-xs w-16 text-emerald-500 bg-transparent border-b border-emerald-300 outline-none focus:ring-0 p-0 flex-shrink-0","aria-label":`Default value for ${o.name}`,value:f,onChange:u=>b(u.target.value),onBlur:v,onKeyDown:u=>{u.key==="Enter"&&v(),u.key==="Escape"&&x(!1)},onMouseDown:u=>u.stopPropagation(),autoFocus:!0}):o.defaultValue?(0,e.jsxs)("button",{type:"button",className:"text-xs text-emerald-500 flex-shrink-0 truncate max-w-16 cursor-pointer",onClick:u=>{u.stopPropagation(),b(o.defaultValue??""),x(!0)},onMouseDown:u=>u.stopPropagation(),title:`Default: ${o.defaultValue}`,children:["= ",o.defaultValue]}):(0,e.jsx)("button",{type:"button",className:"text-xs text-gray-300 flex-shrink-0 opacity-0 group-hover:opacity-30 hover:!opacity-100 cursor-pointer transition-opacity",onClick:u=>{u.stopPropagation(),b(""),x(!0)},onMouseDown:u=>u.stopPropagation(),title:"Set default value",children:"= \u2205"}):o.defaultValue?(0,e.jsxs)("span",{className:"text-xs text-emerald-500 flex-shrink-0 truncate max-w-16",title:`Default: ${o.defaultValue}`,children:["= ",o.defaultValue]}):null}),te=(0,i.memo)(function({table:o,selected:h,disabled:s,readOnly:a,editable:l,dropTarget:y,fieldTypes:k,onTableNameChange:x,onTableNotesChange:f,onToggleCollapse:b,onFieldChange:p,onFieldAdd:v,onFieldRemove:u,onFieldReorder:R,onResizeStart:V}){let I=o.width??c.DEFAULT_TABLE_WIDTH,w=o.collapsed??!1,C=k.length>0?k:_.DEFAULT_FIELD_TYPES,[F,P]=(0,i.useState)(null),[L,N]=(0,i.useState)(null),m=(0,i.useRef)(null),K=(0,i.useCallback)(t=>{x?.(o.id,t.target.value)},[o.id,x]),B=(0,i.useCallback)((t,n)=>{p?.(o.id,t,{name:n})},[o.id,p]),z=(0,i.useCallback)((t,n)=>{p?.(o.id,t,{type:n})},[o.id,p]),M=(0,i.useCallback)((t,n)=>{p?.(o.id,t,{primaryKey:!n})},[o.id,p]),W=(0,i.useCallback)((t,n)=>{p?.(o.id,t,{nullable:!n})},[o.id,p]),A=(0,i.useCallback)((t,n)=>{p?.(o.id,t,{indexed:!n})},[o.id,p]),q=(0,i.useCallback)((t,n)=>{p?.(o.id,t,{unique:!n})},[o.id,p]),j=(0,i.useCallback)(()=>{v?.(o.id)},[o.id,v]);return(0,e.jsxs)("div",{"data-table-id":o.id,className:(0,g.cn)("absolute bg-white dark:bg-gray-800 border-2 border-dashed rounded-lg shadow-sm cursor-grab active:cursor-grabbing",o.height?"flex flex-col":void 0,y?"border-green-400 shadow-green-100 dark:shadow-green-900/30 shadow-md":h?"border-blue-500 shadow-blue-100 dark:shadow-blue-900/30":"border-gray-300 dark:border-gray-600",s&&"opacity-60",o.locked&&"!cursor-default"),style:{left:o.x,top:o.y,width:I,height:o.height,userSelect:"none",overflow:o.height?"hidden":void 0},children:[(0,e.jsxs)("div",{className:(0,g.cn)("flex items-center justify-between px-3 gap-2","bg-gray-50 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600"),style:{height:c.HEADER_HEIGHT},children:[l&&!a&&!s?(0,e.jsx)("input",{className:"flex-1 min-w-0 text-sm font-semibold text-gray-800 dark:text-gray-100 bg-transparent border-none outline-none focus:ring-0 p-0 truncate cursor-text","aria-label":"Table name",value:o.name,onChange:K,onMouseDown:t=>t.stopPropagation()}):(0,e.jsx)("span",{className:"flex-1 min-w-0 text-sm font-semibold text-gray-800 dark:text-gray-100 truncate",children:o.name}),(0,e.jsx)("button",{type:"button",className:"flex-shrink-0 p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-500 dark:text-gray-400",onClick:t=>{t.stopPropagation(),b?.(o.id)},onMouseDown:t=>t.stopPropagation(),"aria-label":w?"Expand table":"Collapse table",children:(0,e.jsx)(Q,{collapsed:w})})]}),!w&&(l&&!a&&!s?(0,e.jsx)("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:c.NOTES_ROW_HEIGHT},children:(0,e.jsx)("input",{className:"w-full text-xs italic text-gray-400 dark:text-gray-500 bg-transparent border-none outline-none focus:ring-0 p-0 placeholder-gray-400 dark:placeholder-gray-500","aria-label":"Table notes",placeholder:"Add notes...",value:o.notes??"",onChange:t=>f?.(o.id,t.target.value),onMouseDown:t=>t.stopPropagation()})}):o.notes?(0,e.jsx)("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:c.NOTES_ROW_HEIGHT},children:(0,e.jsx)("span",{className:"text-xs italic text-gray-400 dark:text-gray-500 truncate",children:o.notes})}):null),!w&&(0,e.jsxs)("div",{className:o.height?"overflow-y-auto flex-1 min-h-0":void 0,children:[o.fields.map((t,n)=>(0,e.jsxs)("div",{"data-field-id":t.id,"data-table-id":o.id,className:(0,g.cn)("flex items-center gap-1.5 pr-2 relative group",l&&!a&&!s?"pl-[18px]":"pl-2","border-b border-gray-100 dark:border-gray-700 last:border-b-0",y?"bg-blue-50/50 dark:bg-blue-900/10":"hover:bg-gray-50 dark:hover:bg-gray-750",F===n&&"opacity-40",L===n&&"!border-t-2 !border-t-blue-400"),style:{height:c.FIELD_ROW_HEIGHT},draggable:l&&!a&&!s,onDragStart:r=>{!l||a||s||(r.stopPropagation(),m.current=n,P(n),r.dataTransfer.effectAllowed="move",r.dataTransfer.setData("text/plain",String(n)))},onDragOver:r=>{m.current!==null&&(r.preventDefault(),r.stopPropagation(),N(n))},onDragLeave:()=>{L===n&&N(null)},onDrop:r=>{r.preventDefault(),r.stopPropagation(),m.current!==null&&m.current!==n&&R?.(o.id,m.current,n),m.current=null,P(null),N(null)},onDragEnd:()=>{m.current=null,P(null),N(null)},children:[(0,e.jsx)("div",{"data-connection-side":"left","data-field-id":t.id,"data-table-id":o.id,className:(0,g.cn)("absolute -left-[5px] w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 cursor-crosshair z-10 transition-all",y?"opacity-100 bg-green-400 scale-150 shadow-[0_0_6px_rgba(74,222,128,0.6)]":"opacity-0 group-hover:opacity-100 bg-blue-400"),style:{top:c.FIELD_ROW_HEIGHT/2-5}}),l&&!a&&!s&&(0,e.jsx)("span",{className:"absolute left-[3px] cursor-grab active:cursor-grabbing opacity-0 group-hover:opacity-100 transition-opacity z-10",style:{top:c.FIELD_ROW_HEIGHT/2-6},children:(0,e.jsx)(O,{})}),l&&!a&&!s?(0,e.jsx)("button",{type:"button",className:(0,g.cn)("w-4 text-xs font-bold flex-shrink-0 text-center cursor-pointer",t.nullable?"text-gray-400":"text-transparent"),onClick:r=>{r.stopPropagation(),W(t.id,t.nullable??!1)},onMouseDown:r=>r.stopPropagation(),title:t.nullable?"Nullable":"Not nullable",children:"?"}):(0,e.jsx)("span",{className:(0,g.cn)("w-4 text-xs font-bold flex-shrink-0 text-center",t.nullable?"text-gray-400":"text-transparent"),children:t.nullable?"?":""}),t.primaryKey&&t.foreignKey?(0,e.jsxs)("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[l&&!a&&!s?(0,e.jsx)("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:r=>{r.stopPropagation(),M(t.id,!0)},onMouseDown:r=>r.stopPropagation(),title:"Primary Key (click to remove)",children:(0,e.jsx)(D,{})}):(0,e.jsx)(D,{}),(0,e.jsx)(S,{})]}):t.primaryKey?l&&!a&&!s?(0,e.jsx)("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:r=>{r.stopPropagation(),M(t.id,!0)},onMouseDown:r=>r.stopPropagation(),title:"Primary Key (click to remove)",children:(0,e.jsx)(D,{})}):(0,e.jsx)(D,{}):t.foreignKey?(0,e.jsx)(S,{}):l&&!a&&!s?(0,e.jsx)("button",{type:"button",className:"w-3.5 h-3.5 flex-shrink-0 rounded text-gray-300 hover:text-indigo-400 transition-colors cursor-pointer",onClick:r=>{r.stopPropagation(),M(t.id,!1)},onMouseDown:r=>r.stopPropagation(),title:"Set as Primary Key","aria-label":"Set as primary key",children:(0,e.jsxs)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",opacity:"0.3",children:[(0,e.jsx)("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),(0,e.jsx)("circle",{cx:"4.5",cy:"11.5",r:"3"})]})}):(0,e.jsx)("span",{className:"w-3.5 flex-shrink-0"}),l&&!a&&!s?(0,e.jsx)("input",{className:(0,g.cn)("flex-1 min-w-0 text-xs bg-transparent border-none outline-none focus:ring-0 p-0 truncate cursor-text",t.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),"aria-label":"Field name",value:t.name,onChange:r=>B(t.id,r.target.value),onMouseDown:r=>r.stopPropagation()}):(0,e.jsx)("span",{className:(0,g.cn)("flex-1 min-w-0 text-xs truncate",t.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),children:t.name}),l&&!a&&!s?(0,e.jsxs)("select",{className:"text-xs text-gray-400 dark:text-gray-500 bg-transparent border-none outline-none focus:ring-0 p-0 cursor-pointer text-right",value:t.type,onChange:r=>z(t.id,r.target.value),onMouseDown:r=>r.stopPropagation(),children:[C.map(r=>(0,e.jsx)("option",{value:r,children:r},r)),!C.includes(t.type)&&(0,e.jsx)("option",{value:t.type,children:t.type})]}):(0,e.jsx)("span",{className:"text-xs text-gray-400 dark:text-gray-500 flex-shrink-0",children:t.type}),(0,e.jsx)(ee,{field:t,tableId:o.id,editable:l,readOnly:a,disabled:s,onFieldChange:p}),t.indexed&&(0,e.jsx)(E,{}),t.unique&&(0,e.jsx)(H,{}),l&&!a&&!s&&(0,e.jsxs)("div",{className:"absolute right-1 top-0 bottom-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity bg-gradient-to-l from-white via-white to-transparent dark:from-gray-800 dark:via-gray-800 pl-4 pr-1 z-10",children:[(0,e.jsx)("button",{type:"button",className:(0,g.cn)("cursor-pointer transition-opacity",t.indexed?"opacity-100":"opacity-30 hover:opacity-100"),onClick:r=>{r.stopPropagation(),A(t.id,t.indexed??!1)},onMouseDown:r=>r.stopPropagation(),title:t.indexed?"Indexed (click to remove)":"Add index",children:(0,e.jsx)(E,{})}),(0,e.jsx)("button",{type:"button",className:(0,g.cn)("cursor-pointer transition-opacity",t.unique?"opacity-100":"opacity-30 hover:opacity-100"),onClick:r=>{r.stopPropagation(),q(t.id,t.unique??!1)},onMouseDown:r=>r.stopPropagation(),title:t.unique?"Unique (click to remove)":"Add unique constraint",children:(0,e.jsx)(H,{})}),(0,e.jsx)("button",{type:"button",className:"p-0.5 rounded text-gray-300 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 cursor-pointer",onClick:r=>{r.stopPropagation(),u?.(o.id,t.id)},onMouseDown:r=>r.stopPropagation(),title:"Remove field",children:(0,e.jsx)(Z,{})})]}),(0,e.jsx)("div",{"data-connection-side":"right","data-field-id":t.id,"data-table-id":o.id,className:(0,g.cn)("absolute -right-[5px] w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 cursor-crosshair z-10 transition-all",y?"opacity-100 bg-green-400 scale-150 shadow-[0_0_6px_rgba(74,222,128,0.6)]":"opacity-0 group-hover:opacity-100 bg-green-400"),style:{top:c.FIELD_ROW_HEIGHT/2-5}})]},t.id)),l&&!a&&!s&&(0,e.jsxs)("button",{type:"button",className:"flex items-center justify-center w-full gap-1 text-xs text-gray-400 hover:text-blue-500 hover:bg-gray-50 dark:hover:bg-gray-750 transition-colors cursor-pointer",style:{height:c.ADD_BUTTON_HEIGHT},onClick:t=>{t.stopPropagation(),j()},onMouseDown:t=>t.stopPropagation(),children:[(0,e.jsx)("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:(0,e.jsx)("path",{d:"M8 4v8M4 8h8"})}),"Add field"]})]}),!s&&!a&&(0,e.jsx)("div",{"data-resize-handle":"corner",className:"absolute -bottom-[5px] -right-[5px] w-[14px] h-[14px] cursor-nwse-resize z-20 group/resize",onMouseDown:t=>{t.stopPropagation(),t.preventDefault();let n=o.height??(0,c.getTableHeight)(o,l);V?.(o.id,t.clientX,t.clientY,I,n)},children:(0,e.jsxs)("svg",{className:"w-full h-full text-gray-300 group-hover/resize:text-blue-400 transition-colors",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[(0,e.jsx)("path",{d:"M12 2v10H2",opacity:"0"}),(0,e.jsx)("path",{d:"M6 12L12 6"}),(0,e.jsx)("path",{d:"M10 12L12 10"})]})})]})});0&&(module.exports={SchemaTableRenderer});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{memo as V,useCallback as g,useRef as Y,useState as D}from"react";import{cn as p}from"../../../lib/cn.js";import{ADD_BUTTON_HEIGHT as $,DEFAULT_TABLE_WIDTH as X,FIELD_ROW_HEIGHT as w,getTableHeight as J,HEADER_HEIGHT as Q,NOTES_ROW_HEIGHT as E}from"../utils/geometry.js";import{DEFAULT_FIELD_TYPES as Z}from"../utils/schema-helpers.js";import{jsx as t,jsxs as c}from"react/jsx-runtime";var N=()=>c("svg",{className:"w-3.5 h-3.5 text-indigo-500 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),t("circle",{cx:"4.5",cy:"11.5",r:"3"})]}),H=()=>c("svg",{className:"w-3.5 h-3.5 flex-shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:[t("circle",{cx:"8",cy:"8",r:"6",className:"fill-blue-500"}),t("path",{d:"M5 8h6M8 5l3 3-3 3",stroke:"white",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]}),O=({collapsed:P})=>t("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:P?t("path",{d:"M6 3l5 5-5 5V3z"}):t("path",{d:"M3 6l5 5 5-5H3z"})}),_=()=>t("svg",{className:"w-3.5 h-3.5 text-amber-500 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t("path",{d:"M3 2v12M7 4h6M7 8h4M7 12h5"})}),R=()=>t("svg",{className:"w-3.5 h-3.5 text-purple-500 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t("path",{d:"M4 2v8a4 4 0 008 0V2"})}),ee=()=>t("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:t("path",{d:"M4 8h8"})}),te=()=>c("svg",{className:"w-3 h-3 text-gray-300",viewBox:"0 0 16 16",fill:"currentColor",children:[t("circle",{cx:"5",cy:"4",r:"1.5"}),t("circle",{cx:"11",cy:"4",r:"1.5"}),t("circle",{cx:"5",cy:"8",r:"1.5"}),t("circle",{cx:"11",cy:"8",r:"1.5"}),t("circle",{cx:"5",cy:"12",r:"1.5"}),t("circle",{cx:"11",cy:"12",r:"1.5"})]}),oe=V(function({field:o,tableId:M,editable:n,readOnly:s,disabled:i,onFieldChange:x}){let[b,d]=D(!1),[v,m]=D(o.defaultValue??""),u=n&&!s&&!i,y=()=>{d(!1),x?.(M,o.id,{defaultValue:v||void 0})};return u?b?t("input",{className:"text-xs w-16 text-emerald-500 bg-transparent border-b border-emerald-300 outline-none focus:ring-0 p-0 flex-shrink-0","aria-label":`Default value for ${o.name}`,value:v,onChange:l=>m(l.target.value),onBlur:y,onKeyDown:l=>{l.key==="Enter"&&y(),l.key==="Escape"&&d(!1)},onMouseDown:l=>l.stopPropagation(),autoFocus:!0}):o.defaultValue?c("button",{type:"button",className:"text-xs text-emerald-500 flex-shrink-0 truncate max-w-16 cursor-pointer",onClick:l=>{l.stopPropagation(),m(o.defaultValue??""),d(!0)},onMouseDown:l=>l.stopPropagation(),title:`Default: ${o.defaultValue}`,children:["= ",o.defaultValue]}):t("button",{type:"button",className:"text-xs text-gray-300 flex-shrink-0 opacity-0 group-hover:opacity-30 hover:!opacity-100 cursor-pointer transition-opacity",onClick:l=>{l.stopPropagation(),m(""),d(!0)},onMouseDown:l=>l.stopPropagation(),title:"Set default value",children:"= \u2205"}):o.defaultValue?c("span",{className:"text-xs text-emerald-500 flex-shrink-0 truncate max-w-16",title:`Default: ${o.defaultValue}`,children:["= ",o.defaultValue]}):null}),ie=V(function({table:o,selected:M,disabled:n,readOnly:s,editable:i,dropTarget:x,fieldTypes:b,onTableNameChange:d,onTableNotesChange:v,onToggleCollapse:m,onFieldChange:u,onFieldAdd:y,onFieldRemove:l,onFieldReorder:F,onResizeStart:K}){let C=o.width??X,k=o.collapsed??!1,L=b.length>0?b:Z,[B,T]=D(null),[S,f]=D(null),h=Y(null),z=g(e=>{d?.(o.id,e.target.value)},[o.id,d]),W=g((e,a)=>{u?.(o.id,e,{name:a})},[o.id,u]),A=g((e,a)=>{u?.(o.id,e,{type:a})},[o.id,u]),I=g((e,a)=>{u?.(o.id,e,{primaryKey:!a})},[o.id,u]),q=g((e,a)=>{u?.(o.id,e,{nullable:!a})},[o.id,u]),j=g((e,a)=>{u?.(o.id,e,{indexed:!a})},[o.id,u]),U=g((e,a)=>{u?.(o.id,e,{unique:!a})},[o.id,u]),G=g(()=>{y?.(o.id)},[o.id,y]);return c("div",{"data-table-id":o.id,className:p("absolute bg-white dark:bg-gray-800 border-2 border-dashed rounded-lg shadow-sm cursor-grab active:cursor-grabbing",o.height?"flex flex-col":void 0,x?"border-green-400 shadow-green-100 dark:shadow-green-900/30 shadow-md":M?"border-blue-500 shadow-blue-100 dark:shadow-blue-900/30":"border-gray-300 dark:border-gray-600",n&&"opacity-60",o.locked&&"!cursor-default"),style:{left:o.x,top:o.y,width:C,height:o.height,userSelect:"none",overflow:o.height?"hidden":void 0},children:[c("div",{className:p("flex items-center justify-between px-3 gap-2","bg-gray-50 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600"),style:{height:Q},children:[i&&!s&&!n?t("input",{className:"flex-1 min-w-0 text-sm font-semibold text-gray-800 dark:text-gray-100 bg-transparent border-none outline-none focus:ring-0 p-0 truncate cursor-text","aria-label":"Table name",value:o.name,onChange:z,onMouseDown:e=>e.stopPropagation()}):t("span",{className:"flex-1 min-w-0 text-sm font-semibold text-gray-800 dark:text-gray-100 truncate",children:o.name}),t("button",{type:"button",className:"flex-shrink-0 p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-500 dark:text-gray-400",onClick:e=>{e.stopPropagation(),m?.(o.id)},onMouseDown:e=>e.stopPropagation(),"aria-label":k?"Expand table":"Collapse table",children:t(O,{collapsed:k})})]}),!k&&(i&&!s&&!n?t("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:E},children:t("input",{className:"w-full text-xs italic text-gray-400 dark:text-gray-500 bg-transparent border-none outline-none focus:ring-0 p-0 placeholder-gray-400 dark:placeholder-gray-500","aria-label":"Table notes",placeholder:"Add notes...",value:o.notes??"",onChange:e=>v?.(o.id,e.target.value),onMouseDown:e=>e.stopPropagation()})}):o.notes?t("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:E},children:t("span",{className:"text-xs italic text-gray-400 dark:text-gray-500 truncate",children:o.notes})}):null),!k&&c("div",{className:o.height?"overflow-y-auto flex-1 min-h-0":void 0,children:[o.fields.map((e,a)=>c("div",{"data-field-id":e.id,"data-table-id":o.id,className:p("flex items-center gap-1.5 pr-2 relative group",i&&!s&&!n?"pl-[18px]":"pl-2","border-b border-gray-100 dark:border-gray-700 last:border-b-0",x?"bg-blue-50/50 dark:bg-blue-900/10":"hover:bg-gray-50 dark:hover:bg-gray-750",B===a&&"opacity-40",S===a&&"!border-t-2 !border-t-blue-400"),style:{height:w},draggable:i&&!s&&!n,onDragStart:r=>{!i||s||n||(r.stopPropagation(),h.current=a,T(a),r.dataTransfer.effectAllowed="move",r.dataTransfer.setData("text/plain",String(a)))},onDragOver:r=>{h.current!==null&&(r.preventDefault(),r.stopPropagation(),f(a))},onDragLeave:()=>{S===a&&f(null)},onDrop:r=>{r.preventDefault(),r.stopPropagation(),h.current!==null&&h.current!==a&&F?.(o.id,h.current,a),h.current=null,T(null),f(null)},onDragEnd:()=>{h.current=null,T(null),f(null)},children:[t("div",{"data-connection-side":"left","data-field-id":e.id,"data-table-id":o.id,className:p("absolute -left-[5px] w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 cursor-crosshair z-10 transition-all",x?"opacity-100 bg-green-400 scale-150 shadow-[0_0_6px_rgba(74,222,128,0.6)]":"opacity-0 group-hover:opacity-100 bg-blue-400"),style:{top:w/2-5}}),i&&!s&&!n&&t("span",{className:"absolute left-[3px] cursor-grab active:cursor-grabbing opacity-0 group-hover:opacity-100 transition-opacity z-10",style:{top:w/2-6},children:t(te,{})}),i&&!s&&!n?t("button",{type:"button",className:p("w-4 text-xs font-bold flex-shrink-0 text-center cursor-pointer",e.nullable?"text-gray-400":"text-transparent"),onClick:r=>{r.stopPropagation(),q(e.id,e.nullable??!1)},onMouseDown:r=>r.stopPropagation(),title:e.nullable?"Nullable":"Not nullable",children:"?"}):t("span",{className:p("w-4 text-xs font-bold flex-shrink-0 text-center",e.nullable?"text-gray-400":"text-transparent"),children:e.nullable?"?":""}),e.primaryKey&&e.foreignKey?c("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[i&&!s&&!n?t("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:r=>{r.stopPropagation(),I(e.id,!0)},onMouseDown:r=>r.stopPropagation(),title:"Primary Key (click to remove)",children:t(N,{})}):t(N,{}),t(H,{})]}):e.primaryKey?i&&!s&&!n?t("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:r=>{r.stopPropagation(),I(e.id,!0)},onMouseDown:r=>r.stopPropagation(),title:"Primary Key (click to remove)",children:t(N,{})}):t(N,{}):e.foreignKey?t(H,{}):i&&!s&&!n?t("button",{type:"button",className:"w-3.5 h-3.5 flex-shrink-0 rounded text-gray-300 hover:text-indigo-400 transition-colors cursor-pointer",onClick:r=>{r.stopPropagation(),I(e.id,!1)},onMouseDown:r=>r.stopPropagation(),title:"Set as Primary Key","aria-label":"Set as primary key",children:c("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",opacity:"0.3",children:[t("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),t("circle",{cx:"4.5",cy:"11.5",r:"3"})]})}):t("span",{className:"w-3.5 flex-shrink-0"}),i&&!s&&!n?t("input",{className:p("flex-1 min-w-0 text-xs bg-transparent border-none outline-none focus:ring-0 p-0 truncate cursor-text",e.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),"aria-label":"Field name",value:e.name,onChange:r=>W(e.id,r.target.value),onMouseDown:r=>r.stopPropagation()}):t("span",{className:p("flex-1 min-w-0 text-xs truncate",e.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),children:e.name}),i&&!s&&!n?c("select",{className:"text-xs text-gray-400 dark:text-gray-500 bg-transparent border-none outline-none focus:ring-0 p-0 cursor-pointer text-right",value:e.type,onChange:r=>A(e.id,r.target.value),onMouseDown:r=>r.stopPropagation(),children:[L.map(r=>t("option",{value:r,children:r},r)),!L.includes(e.type)&&t("option",{value:e.type,children:e.type})]}):t("span",{className:"text-xs text-gray-400 dark:text-gray-500 flex-shrink-0",children:e.type}),t(oe,{field:e,tableId:o.id,editable:i,readOnly:s,disabled:n,onFieldChange:u}),e.indexed&&t(_,{}),e.unique&&t(R,{}),i&&!s&&!n&&c("div",{className:"absolute right-1 top-0 bottom-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity bg-gradient-to-l from-white via-white to-transparent dark:from-gray-800 dark:via-gray-800 pl-4 pr-1 z-10",children:[t("button",{type:"button",className:p("cursor-pointer transition-opacity",e.indexed?"opacity-100":"opacity-30 hover:opacity-100"),onClick:r=>{r.stopPropagation(),j(e.id,e.indexed??!1)},onMouseDown:r=>r.stopPropagation(),title:e.indexed?"Indexed (click to remove)":"Add index",children:t(_,{})}),t("button",{type:"button",className:p("cursor-pointer transition-opacity",e.unique?"opacity-100":"opacity-30 hover:opacity-100"),onClick:r=>{r.stopPropagation(),U(e.id,e.unique??!1)},onMouseDown:r=>r.stopPropagation(),title:e.unique?"Unique (click to remove)":"Add unique constraint",children:t(R,{})}),t("button",{type:"button",className:"p-0.5 rounded text-gray-300 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 cursor-pointer",onClick:r=>{r.stopPropagation(),l?.(o.id,e.id)},onMouseDown:r=>r.stopPropagation(),title:"Remove field",children:t(ee,{})})]}),t("div",{"data-connection-side":"right","data-field-id":e.id,"data-table-id":o.id,className:p("absolute -right-[5px] w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 cursor-crosshair z-10 transition-all",x?"opacity-100 bg-green-400 scale-150 shadow-[0_0_6px_rgba(74,222,128,0.6)]":"opacity-0 group-hover:opacity-100 bg-green-400"),style:{top:w/2-5}})]},e.id)),i&&!s&&!n&&c("button",{type:"button",className:"flex items-center justify-center w-full gap-1 text-xs text-gray-400 hover:text-blue-500 hover:bg-gray-50 dark:hover:bg-gray-750 transition-colors cursor-pointer",style:{height:$},onClick:e=>{e.stopPropagation(),G()},onMouseDown:e=>e.stopPropagation(),children:[t("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:t("path",{d:"M8 4v8M4 8h8"})}),"Add field"]})]}),!n&&!s&&t("div",{"data-resize-handle":"corner",className:"absolute -bottom-[5px] -right-[5px] w-[14px] h-[14px] cursor-nwse-resize z-20 group/resize",onMouseDown:e=>{e.stopPropagation(),e.preventDefault();let a=o.height??J(o,i);K?.(o.id,e.clientX,e.clientY,C,a)},children:c("svg",{className:"w-full h-full text-gray-300 group-hover/resize:text-blue-400 transition-colors",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[t("path",{d:"M12 2v10H2",opacity:"0"}),t("path",{d:"M6 12L12 6"}),t("path",{d:"M10 12L12 10"})]})})]})});export{ie as SchemaTableRenderer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var y=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var j=Object.prototype.hasOwnProperty;var K=(i,r)=>{for(var n in r)y(i,n,{get:r[n],enumerable:!0})},W=(i,r,n,g)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of Y(r))!j.call(i,s)&&s!==n&&y(i,s,{get:()=>r[s],enumerable:!(g=U(r,s))||g.enumerable});return i};var X=i=>W(y({},"__esModule",{value:!0}),i);var d0={};K(d0,{SchemaToolbar:()=>g0});module.exports=X(d0);var a=require("react"),M=require("../../../lib/cn.cjs"),e=require("../../button/Button.cjs"),u=require("../../button-group/ButtonGroup.cjs"),t=require("../../tooltip/Tooltip.cjs"),m=require("../../modal/Modal.cjs"),v=require("../../form/input/Input.cjs"),o=require("react/jsx-runtime"),_=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z",clipRule:"evenodd"})}),$=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M5 10a1 1 0 011-1h8a1 1 0 110 2H6a1 1 0 01-1-1z",clipRule:"evenodd"})}),o0=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z",clipRule:"evenodd"})}),a0=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{d:"M3 4a1 1 0 011-1h4a1 1 0 010 2H6.414l2.293 2.293a1 1 0 01-1.414 1.414L5 6.414V8a1 1 0 01-2 0V4zm9 1a1 1 0 010-2h4a1 1 0 011 1v4a1 1 0 01-2 0V6.414l-2.293 2.293a1 1 0 11-1.414-1.414L13.586 5H12zm-9 7a1 1 0 012 0v1.586l2.293-2.293a1 1 0 011.414 1.414L6.414 15H8a1 1 0 010 2H4a1 1 0 01-1-1v-4zm13 0a1 1 0 01-2 0v-1.586l-2.293 2.293a1 1 0 01-1.414-1.414L13.586 9H12a1 1 0 010-2h4a1 1 0 011 1v4z"})}),e0=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M6 2a2 2 0 00-2 2v12a2 2 0 002 2h8a2 2 0 002-2V4a2 2 0 00-2-2H6zm4 5a1 1 0 011 1v1h1a1 1 0 110 2h-1v1a1 1 0 11-2 0v-1H8a1 1 0 110-2h1V8a1 1 0 011-1z",clipRule:"evenodd"})}),t0=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm3.293-7.707a1 1 0 011.414 0L9 10.586V3a1 1 0 112 0v7.586l1.293-1.293a1 1 0 111.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z",clipRule:"evenodd"})}),r0=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM6.293 6.707a1 1 0 010-1.414l3-3a1 1 0 011.414 0l3 3a1 1 0 01-1.414 1.414L11 5.414V13a1 1 0 11-2 0V5.414L7.707 6.707a1 1 0 01-1.414 0z",clipRule:"evenodd"})}),l0=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M2 5a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2V5zm14 1a1 1 0 11-2 0 1 1 0 012 0zM2 13a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2v-2zm14 1a1 1 0 11-2 0 1 1 0 012 0z",clipRule:"evenodd"})}),i0=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M7.707 3.293a1 1 0 010 1.414L5.414 7H11a7 7 0 017 7v2a1 1 0 11-2 0v-2a5 5 0 00-5-5H5.414l2.293 2.293a1 1 0 11-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z",clipRule:"evenodd"})}),s0=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M12.293 3.293a1 1 0 011.414 0l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414-1.414L14.586 9H9a5 5 0 00-5 5v2a1 1 0 11-2 0v-2a7 7 0 017-7h5.586l-2.293-2.293a1 1 0 010-1.414z",clipRule:"evenodd"})}),n0=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{d:"M3 3h4v4H3V3zm0 10h4v4H3v-4zm10-10h4v4h-4V3zm0 10h4v4h-4v-4zM7 5h6v1H7V5zm0 8h6v1H7v-1zM5 7v6h1V7H5zm8 0v6h1V7h-1z"})}),g0=(0,a.memo)(function({zoom:r,onZoomIn:n,onZoomOut:g,onResetView:s,onFitToContent:N,onAddTable:R,onExportJSON:x,onImportJSON:C,onExportSQL:d,onUndo:z,onRedo:k,canUndo:H=!1,canRedo:I=!1,onAutoLayout:f,disabled:l,className:O}){let[L,w]=(0,a.useState)(!1),[T,b]=(0,a.useState)(!1),[V,S]=(0,a.useState)(!1),[B,E]=(0,a.useState)(""),[c,h]=(0,a.useState)(""),[A,Z]=(0,a.useState)(""),J=(0,a.useCallback)(()=>{E(x()),w(!0)},[x]),D=(0,a.useCallback)(()=>{c.trim()&&(C(c.trim()),h(""),b(!1))},[c,C]),P=(0,a.useCallback)(()=>{h(""),b(!1)},[]),Q=(0,a.useCallback)(()=>{w(!1)},[]),q=(0,a.useCallback)(()=>{d&&(Z(d()),S(!0))},[d]),F=(0,a.useCallback)(()=>{S(!1)},[]),G=Math.round(r*100);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:(0,M.cn)("absolute top-3 left-3 z-20 flex items-center gap-2 bg-white dark:bg-gray-800 rounded-lg shadow-md border border-gray-200 dark:border-gray-600 px-2 py-1.5",O),"data-testid":"schema-toolbar",onMouseDown:p=>p.stopPropagation(),children:[(0,o.jsxs)(u.ButtonGroup,{size:"sm",children:[(0,o.jsx)(t.Tooltip,{content:"Zoom in",size:"sm",position:"bottom",children:(0,o.jsx)(e.Button,{icon:(0,o.jsx)(_,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:n,disabled:l,"aria-label":"Zoom in"})}),(0,o.jsx)(t.Tooltip,{content:"Zoom out",size:"sm",position:"bottom",children:(0,o.jsx)(e.Button,{icon:(0,o.jsx)($,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:g,disabled:l,"aria-label":"Zoom out"})})]}),(0,o.jsxs)("span",{className:"text-xs font-mono text-gray-500 dark:text-gray-400 min-w-[3ch] text-center select-none",children:[G,"%"]}),(0,o.jsx)("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),(0,o.jsx)(t.Tooltip,{content:"Reset view",size:"sm",position:"bottom",children:(0,o.jsx)(e.Button,{icon:(0,o.jsx)(o0,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:s,disabled:l,"aria-label":"Reset view"})}),(0,o.jsx)(t.Tooltip,{content:"Fit to content",size:"sm",position:"bottom",children:(0,o.jsx)(e.Button,{icon:(0,o.jsx)(a0,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:N,disabled:l,"aria-label":"Fit to content"})}),(0,o.jsx)("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),(0,o.jsx)(t.Tooltip,{content:"Add table",size:"sm",position:"bottom",children:(0,o.jsx)(e.Button,{icon:(0,o.jsx)(e0,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:R,disabled:l,"aria-label":"Add table"})}),(0,o.jsx)("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),(0,o.jsx)(t.Tooltip,{content:"Export JSON",size:"sm",position:"bottom",children:(0,o.jsx)(e.Button,{icon:(0,o.jsx)(t0,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:J,disabled:l,"aria-label":"Export JSON"})}),(0,o.jsx)(t.Tooltip,{content:"Import JSON",size:"sm",position:"bottom",children:(0,o.jsx)(e.Button,{icon:(0,o.jsx)(r0,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:()=>b(!0),disabled:l,"aria-label":"Import JSON"})}),d&&(0,o.jsx)(t.Tooltip,{content:"Export SQL",size:"sm",position:"bottom",children:(0,o.jsx)(e.Button,{icon:(0,o.jsx)(l0,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:q,disabled:l,"aria-label":"Export SQL"})}),(z||k)&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),(0,o.jsxs)(u.ButtonGroup,{size:"sm",children:[(0,o.jsx)(t.Tooltip,{content:"Undo (Ctrl+Z)",size:"sm",position:"bottom",children:(0,o.jsx)(e.Button,{icon:(0,o.jsx)(i0,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:z,disabled:l||!H,"aria-label":"Undo"})}),(0,o.jsx)(t.Tooltip,{content:"Redo (Ctrl+Y)",size:"sm",position:"bottom",children:(0,o.jsx)(e.Button,{icon:(0,o.jsx)(s0,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:k,disabled:l||!I,"aria-label":"Redo"})})]})]}),f&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),(0,o.jsx)(t.Tooltip,{content:"Auto layout",size:"sm",position:"bottom",children:(0,o.jsx)(e.Button,{icon:(0,o.jsx)(n0,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:f,disabled:l,"aria-label":"Auto layout"})})]})]}),(0,o.jsx)(m.Modal,{isOpen:L,onClose:Q,title:"Export Schema",description:"Copy the JSON below to save your schema.",size:"lg",showSubmit:!1,showCancel:!0,cancelLabel:"Close",children:(0,o.jsx)(v.Input,{label:"Schema JSON",multiline:!0,rows:12,value:B,readOnly:!0,size:"sm"})}),(0,o.jsx)(m.Modal,{isOpen:T,onClose:P,title:"Import Schema",description:"Paste schema JSON to load it into the editor.",size:"lg",showSubmit:!0,submitLabel:"Import",onSubmitClick:D,showCancel:!0,cancelLabel:"Cancel",children:(0,o.jsx)(v.Input,{label:"Schema JSON",multiline:!0,rows:12,value:c,onChange:p=>h(p.target.value),placeholder:'{"tables": [], "relations": []}',size:"sm"})}),(0,o.jsx)(m.Modal,{isOpen:V,onClose:F,title:"Export SQL",description:"Generated PostgreSQL CREATE TABLE statements.",size:"lg",showSubmit:!1,showCancel:!0,cancelLabel:"Close",children:(0,o.jsx)(v.Input,{label:"SQL",multiline:!0,rows:16,value:A,readOnly:!0,size:"sm"})})]})});0&&(module.exports={SchemaToolbar});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{memo as U,useState as l,useCallback as i}from"react";import{cn as Y}from"../../../lib/cn.js";import{Button as e}from"../../button/Button.js";import{ButtonGroup as k}from"../../button-group/ButtonGroup.js";import{Tooltip as t}from"../../tooltip/Tooltip.js";import{Modal as m}from"../../modal/Modal.js";import{Input as v}from"../../form/input/Input.js";import{Fragment as b,jsx as o,jsxs as r}from"react/jsx-runtime";var j=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z",clipRule:"evenodd"})}),K=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M5 10a1 1 0 011-1h8a1 1 0 110 2H6a1 1 0 01-1-1z",clipRule:"evenodd"})}),W=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z",clipRule:"evenodd"})}),X=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{d:"M3 4a1 1 0 011-1h4a1 1 0 010 2H6.414l2.293 2.293a1 1 0 01-1.414 1.414L5 6.414V8a1 1 0 01-2 0V4zm9 1a1 1 0 010-2h4a1 1 0 011 1v4a1 1 0 01-2 0V6.414l-2.293 2.293a1 1 0 11-1.414-1.414L13.586 5H12zm-9 7a1 1 0 012 0v1.586l2.293-2.293a1 1 0 011.414 1.414L6.414 15H8a1 1 0 010 2H4a1 1 0 01-1-1v-4zm13 0a1 1 0 01-2 0v-1.586l-2.293 2.293a1 1 0 01-1.414-1.414L13.586 9H12a1 1 0 010-2h4a1 1 0 011 1v4z"})}),_=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M6 2a2 2 0 00-2 2v12a2 2 0 002 2h8a2 2 0 002-2V4a2 2 0 00-2-2H6zm4 5a1 1 0 011 1v1h1a1 1 0 110 2h-1v1a1 1 0 11-2 0v-1H8a1 1 0 110-2h1V8a1 1 0 011-1z",clipRule:"evenodd"})}),$=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm3.293-7.707a1 1 0 011.414 0L9 10.586V3a1 1 0 112 0v7.586l1.293-1.293a1 1 0 111.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z",clipRule:"evenodd"})}),o0=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM6.293 6.707a1 1 0 010-1.414l3-3a1 1 0 011.414 0l3 3a1 1 0 01-1.414 1.414L11 5.414V13a1 1 0 11-2 0V5.414L7.707 6.707a1 1 0 01-1.414 0z",clipRule:"evenodd"})}),a0=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M2 5a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2V5zm14 1a1 1 0 11-2 0 1 1 0 012 0zM2 13a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2v-2zm14 1a1 1 0 11-2 0 1 1 0 012 0z",clipRule:"evenodd"})}),e0=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M7.707 3.293a1 1 0 010 1.414L5.414 7H11a7 7 0 017 7v2a1 1 0 11-2 0v-2a5 5 0 00-5-5H5.414l2.293 2.293a1 1 0 11-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z",clipRule:"evenodd"})}),t0=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M12.293 3.293a1 1 0 011.414 0l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414-1.414L14.586 9H9a5 5 0 00-5 5v2a1 1 0 11-2 0v-2a7 7 0 017-7h5.586l-2.293-2.293a1 1 0 010-1.414z",clipRule:"evenodd"})}),r0=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{d:"M3 3h4v4H3V3zm0 10h4v4H3v-4zm10-10h4v4h-4V3zm0 10h4v4h-4v-4zM7 5h6v1H7V5zm0 8h6v1H7v-1zM5 7v6h1V7H5zm8 0v6h1V7h-1z"})}),v0=U(function({zoom:f,onZoomIn:w,onZoomOut:S,onResetView:M,onFitToContent:N,onAddTable:R,onExportJSON:h,onImportJSON:p,onExportSQL:s,onUndo:y,onRedo:u,canUndo:H=!1,canRedo:I=!1,onAutoLayout:x,disabled:a,className:O}){let[L,C]=l(!1),[T,g]=l(!1),[V,z]=l(!1),[B,E]=l(""),[n,d]=l(""),[A,Z]=l(""),J=i(()=>{E(h()),C(!0)},[h]),D=i(()=>{n.trim()&&(p(n.trim()),d(""),g(!1))},[n,p]),P=i(()=>{d(""),g(!1)},[]),Q=i(()=>{C(!1)},[]),q=i(()=>{s&&(Z(s()),z(!0))},[s]),F=i(()=>{z(!1)},[]),G=Math.round(f*100);return r(b,{children:[r("div",{className:Y("absolute top-3 left-3 z-20 flex items-center gap-2 bg-white dark:bg-gray-800 rounded-lg shadow-md border border-gray-200 dark:border-gray-600 px-2 py-1.5",O),"data-testid":"schema-toolbar",onMouseDown:c=>c.stopPropagation(),children:[r(k,{size:"sm",children:[o(t,{content:"Zoom in",size:"sm",position:"bottom",children:o(e,{icon:o(j,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:w,disabled:a,"aria-label":"Zoom in"})}),o(t,{content:"Zoom out",size:"sm",position:"bottom",children:o(e,{icon:o(K,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:S,disabled:a,"aria-label":"Zoom out"})})]}),r("span",{className:"text-xs font-mono text-gray-500 dark:text-gray-400 min-w-[3ch] text-center select-none",children:[G,"%"]}),o("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),o(t,{content:"Reset view",size:"sm",position:"bottom",children:o(e,{icon:o(W,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:M,disabled:a,"aria-label":"Reset view"})}),o(t,{content:"Fit to content",size:"sm",position:"bottom",children:o(e,{icon:o(X,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:N,disabled:a,"aria-label":"Fit to content"})}),o("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),o(t,{content:"Add table",size:"sm",position:"bottom",children:o(e,{icon:o(_,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:R,disabled:a,"aria-label":"Add table"})}),o("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),o(t,{content:"Export JSON",size:"sm",position:"bottom",children:o(e,{icon:o($,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:J,disabled:a,"aria-label":"Export JSON"})}),o(t,{content:"Import JSON",size:"sm",position:"bottom",children:o(e,{icon:o(o0,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:()=>g(!0),disabled:a,"aria-label":"Import JSON"})}),s&&o(t,{content:"Export SQL",size:"sm",position:"bottom",children:o(e,{icon:o(a0,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:q,disabled:a,"aria-label":"Export SQL"})}),(y||u)&&r(b,{children:[o("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),r(k,{size:"sm",children:[o(t,{content:"Undo (Ctrl+Z)",size:"sm",position:"bottom",children:o(e,{icon:o(e0,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:y,disabled:a||!H,"aria-label":"Undo"})}),o(t,{content:"Redo (Ctrl+Y)",size:"sm",position:"bottom",children:o(e,{icon:o(t0,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:u,disabled:a||!I,"aria-label":"Redo"})})]})]}),x&&r(b,{children:[o("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),o(t,{content:"Auto layout",size:"sm",position:"bottom",children:o(e,{icon:o(r0,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:x,disabled:a,"aria-label":"Auto layout"})})]})]}),o(m,{isOpen:L,onClose:Q,title:"Export Schema",description:"Copy the JSON below to save your schema.",size:"lg",showSubmit:!1,showCancel:!0,cancelLabel:"Close",children:o(v,{label:"Schema JSON",multiline:!0,rows:12,value:B,readOnly:!0,size:"sm"})}),o(m,{isOpen:T,onClose:P,title:"Import Schema",description:"Paste schema JSON to load it into the editor.",size:"lg",showSubmit:!0,submitLabel:"Import",onSubmitClick:D,showCancel:!0,cancelLabel:"Cancel",children:o(v,{label:"Schema JSON",multiline:!0,rows:12,value:n,onChange:c=>d(c.target.value),placeholder:'{"tables": [], "relations": []}',size:"sm"})}),o(m,{isOpen:V,onClose:F,title:"Export SQL",description:"Generated PostgreSQL CREATE TABLE statements.",size:"lg",showSubmit:!1,showCancel:!0,cancelLabel:"Close",children:o(v,{label:"SQL",multiline:!0,rows:16,value:A,readOnly:!0,size:"sm"})})]})});export{v0 as SchemaToolbar};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var g=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var A=(o,n)=>{for(var i in n)g(o,i,{get:n[i],enumerable:!0})},x=(o,n,i,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of S(n))!y.call(o,s)&&s!==i&&g(o,s,{get:()=>n[s],enumerable:!(r=M(n,s))||r.enumerable});return o};var L=o=>x(g({},"__esModule",{value:!0}),o);var I={};A(I,{autoLayoutTables:()=>H});module.exports=L(I);var h=require("./geometry.cjs"),D=60,E=40;function H(o,n){if(o.length===0)return o;let i=new Map;for(let e of o){let t=new Set;for(let c of e.fields)c.foreignKey&&t.add(c.foreignKey.tableId);i.set(e.id,t)}let r=new Map;for(let e of o)r.set(e.id,0);for(let[,e]of i)for(let t of e)r.has(t);for(let[e,t]of i)r.set(e,t.size);let s=[],f=[];for(let[e,t]of r)t===0&&f.push(e);for(;f.length>0;){let e=f.shift();s.push(e);for(let[t,c]of i)if(c.has(e)){let d=(r.get(t)??0)-1;r.set(t,d),d===0&&f.push(t)}}let u=new Set(s);for(let e of o)u.has(e.id)||(s.push(e.id),u.add(e.id));let w=new Map(o.map(e=>[e.id,e])),b=Math.max(1,Math.ceil(Math.sqrt(s.length))),l=0,m=0,p=0,a=0,T=[];for(let e of s){let t=w.get(e);if(!t)continue;let c=t.width??h.DEFAULT_TABLE_WIDTH,d=(0,h.getTableHeight)(t,n);T.push({...t,x:l,y:m}),a=Math.max(a,d),p++,p>=b?(p=0,l=0,m+=a+E,a=0):l+=c+D}return T}0&&(module.exports={autoLayoutTables});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{DEFAULT_TABLE_WIDTH as w,getTableHeight as b}from"./geometry.js";var M=60,S=40;function A(o,u){if(o.length===0)return o;let r=new Map;for(let e of o){let t=new Set;for(let s of e.fields)s.foreignKey&&t.add(s.foreignKey.tableId);r.set(e.id,t)}let n=new Map;for(let e of o)n.set(e.id,0);for(let[,e]of r)for(let t of e)n.has(t);for(let[e,t]of r)n.set(e,t.size);let i=[],c=[];for(let[e,t]of n)t===0&&c.push(e);for(;c.length>0;){let e=c.shift();i.push(e);for(let[t,s]of r)if(s.has(e)){let a=(n.get(t)??0)-1;n.set(t,a),a===0&&c.push(t)}}let l=new Set(i);for(let e of o)l.has(e.id)||(i.push(e.id),l.add(e.id));let m=new Map(o.map(e=>[e.id,e])),T=Math.max(1,Math.ceil(Math.sqrt(i.length))),d=0,p=0,h=0,f=0,g=[];for(let e of i){let t=m.get(e);if(!t)continue;let s=t.width??w,a=b(t,u);g.push({...t,x:d,y:p}),f=Math.max(f,a),h++,h>=T?(h=0,d=0,p+=f+S,f=0):d+=s+M}return g}export{A as autoLayoutTables};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var H=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var p=(n,t)=>{for(var e in t)H(n,e,{get:t[e],enumerable:!0})},y=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of D(t))!l.call(n,o)&&o!==e&&H(n,o,{get:()=>t[o],enumerable:!(r=b(t,o))||r.enumerable});return n};var F=n=>y(H({},"__esModule",{value:!0}),n);var $={};p($,{ADD_BUTTON_HEIGHT:()=>A,DEFAULT_TABLE_WIDTH:()=>N,FIELD_ROW_HEIGHT:()=>S,HEADER_HEIGHT:()=>G,NOTES_ROW_HEIGHT:()=>M,clampZoom:()=>L,computeBezierPath:()=>g,fitViewport:()=>d,getFieldConnectionPosition:()=>R,getFieldConnectionY:()=>h,getTableHeight:()=>f,screenToCanvas:()=>W,snapValue:()=>C});module.exports=F($);var N=260,G=40,S=32,A=36,M=24;function f(n,t){return n.collapsed?40:n.height?n.height:40+(n.notes?24:0)+n.fields.length*32+(t?36:0)}function h(n,t){return 40+(t?24:0)+n*32+32/2}function R(n,t,e){let r=n.fields.findIndex(s=>s.id===t);if(r===-1)return null;let o=n.width??260,c=!!n.notes,m=n.y+h(r,c);return{x:e==="left"?n.x+0:n.x+o-0,y:m}}function C(n,t){return Math.round(n/t)*t}function L(n,t,e){return Math.min(e,Math.max(t,n))}function W(n,t,e,r){return{x:(n-r.left-e.x)/e.zoom,y:(t-r.top-e.y)/e.zoom}}function g(n,t,e,r){let o=Math.abs(e-n),c=Math.max(50,o*.5),m=n+c,u=t,s=e-c;return`M ${n} ${t} C ${m} ${u}, ${s} ${r}, ${e} ${r}`}function d(n,t,e,r,o=40){if(n.length===0)return{x:0,y:0,zoom:1};let c=1/0,m=1/0,u=-1/0,s=-1/0;for(let i of n){let O=i.width??260,a=f(i,r);c=Math.min(c,i.x),m=Math.min(m,i.y),u=Math.max(u,i.x+O),s=Math.max(s,i.y+a)}let E=u-c+o*2,_=s-m+o*2,T=Math.min(t/E,e/_,1),x=(t-E*T)/2-(c-o)*T,I=(e-_*T)/2-(m-o)*T;return{x,y:I,zoom:T}}0&&(module.exports={ADD_BUTTON_HEIGHT,DEFAULT_TABLE_WIDTH,FIELD_ROW_HEIGHT,HEADER_HEIGHT,NOTES_ROW_HEIGHT,clampZoom,computeBezierPath,fitViewport,getFieldConnectionPosition,getFieldConnectionY,getTableHeight,screenToCanvas,snapValue});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a=260,b=40,D=32,l=36,p=24;function I(n,t){return n.collapsed?40:n.height?n.height:40+(n.notes?24:0)+n.fields.length*32+(t?36:0)}function O(n,t){return 40+(t?24:0)+n*32+32/2}function y(n,t,e){let o=n.fields.findIndex(s=>s.id===t);if(o===-1)return null;let c=n.width??260,r=!!n.notes,m=n.y+O(o,r);return{x:e==="left"?n.x+0:n.x+c-0,y:m}}function F(n,t){return Math.round(n/t)*t}function N(n,t,e){return Math.min(e,Math.max(t,n))}function G(n,t,e,o){return{x:(n-o.left-e.x)/e.zoom,y:(t-o.top-e.y)/e.zoom}}function S(n,t,e,o){let c=Math.abs(e-n),r=Math.max(50,c*.5),m=n+r,u=t,s=e-r;return`M ${n} ${t} C ${m} ${u}, ${s} ${o}, ${e} ${o}`}function A(n,t,e,o,c=40){if(n.length===0)return{x:0,y:0,zoom:1};let r=1/0,m=1/0,u=-1/0,s=-1/0;for(let i of n){let h=i.width??260,x=I(i,o);r=Math.min(r,i.x),m=Math.min(m,i.y),u=Math.max(u,i.x+h),s=Math.max(s,i.y+x)}let E=u-r+c*2,H=s-m+c*2,T=Math.min(t/E,e/H,1),_=(t-E*T)/2-(r-c)*T,f=(e-H*T)/2-(m-c)*T;return{x:_,y:f,zoom:T}}export{l as ADD_BUTTON_HEIGHT,a as DEFAULT_TABLE_WIDTH,D as FIELD_ROW_HEIGHT,b as HEADER_HEIGHT,p as NOTES_ROW_HEIGHT,N as clampZoom,S as computeBezierPath,A as fitViewport,y as getFieldConnectionPosition,O as getFieldConnectionY,I as getTableHeight,G as screenToCanvas,F as snapValue};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var n=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var p=(e,t)=>{for(var a in t)n(e,a,{get:t[a],enumerable:!0})},u=(e,t,a,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of d(t))!c.call(e,i)&&i!==a&&n(e,i,{get:()=>t[i],enumerable:!(l=m(t,i))||l.enumerable});return e};var s=e=>u(n({},"__esModule",{value:!0}),e);var S={};p(S,{DEFAULT_FIELD_TYPES:()=>b,createDefaultField:()=>h,createDefaultTable:()=>y,generateFieldId:()=>r,generateRelationId:()=>f,generateTableId:()=>o});module.exports=s(S);var b=["text","varchar","char","int2","int4","int8","serial","bigserial","float4","float8","numeric","decimal","bool","date","time","timestamp","timestamptz","uuid","json","jsonb","bytea"];function o(){return`table-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function r(){return`field-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function f(){return`rel-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function h(e="new_field"){return{id:r(),name:e,type:"text",nullable:!0}}function y(e,t,a="new_table"){return{id:o(),name:a,x:e,y:t,fields:[{id:r(),name:"id",type:"serial",primaryKey:!0},{id:r(),name:"createdAt",type:"timestamp"},{id:r(),name:"updatedAt",type:"timestamp"}]}}0&&(module.exports={DEFAULT_FIELD_TYPES,createDefaultField,createDefaultTable,generateFieldId,generateRelationId,generateTableId});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var n=["text","varchar","char","int2","int4","int8","serial","bigserial","float4","float8","numeric","decimal","bool","date","time","timestamp","timestamptz","uuid","json","jsonb","bytea"];function r(){return`table-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function e(){return`field-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function l(){return`rel-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function o(t="new_field"){return{id:e(),name:t,type:"text",nullable:!0}}function m(t,a,i="new_table"){return{id:r(),name:i,x:t,y:a,fields:[{id:e(),name:"id",type:"serial",primaryKey:!0},{id:e(),name:"createdAt",type:"timestamp"},{id:e(),name:"updatedAt",type:"timestamp"}]}}export{n as DEFAULT_FIELD_TYPES,o as createDefaultField,m as createDefaultTable,e as generateFieldId,l as generateRelationId,r as generateTableId};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";var l=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var I=(e,n)=>{for(var r in n)l(e,r,{get:n[r],enumerable:!0})},S=(e,n,r,m)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of d(n))!g.call(e,i)&&i!==r&&l(e,i,{get:()=>n[i],enumerable:!(m=T(n,i))||m.enumerable});return e};var h=e=>S(l({},"__esModule",{value:!0}),e);var N={};I(N,{generateSQL:()=>A});module.exports=h(N);function s(e){return`"${e.replace(/"/g,'""')}"`}function E(e){return{text:"TEXT",varchar:"VARCHAR(255)",char:"CHAR(1)",int2:"SMALLINT",int4:"INTEGER",int8:"BIGINT",serial:"SERIAL",bigserial:"BIGSERIAL",float4:"REAL",float8:"DOUBLE PRECISION",numeric:"NUMERIC",decimal:"DECIMAL",bool:"BOOLEAN",date:"DATE",time:"TIME",timestamp:"TIMESTAMP",timestamptz:"TIMESTAMP WITH TIME ZONE",uuid:"UUID",json:"JSON",jsonb:"JSONB",bytea:"BYTEA"}[e]??e.toUpperCase()}function y(e){let n=[s(e.name)];return e.type==="serial"||e.type,n.push(E(e.type)),e.primaryKey&&n.push("PRIMARY KEY"),!e.nullable&&!e.primaryKey&&n.push("NOT NULL"),e.unique&&!e.primaryKey&&n.push("UNIQUE"),e.defaultValue&&n.push(`DEFAULT ${e.defaultValue}`)," "+n.join(" ")}function R(e,n,r){let m=[],i=[];for(let t of e.fields)m.push(y(t));for(let t of e.fields)if(t.foreignKey){let o=r.find(u=>u.id===t.foreignKey.tableId),p=o?.fields.find(u=>u.id===t.foreignKey.fieldId);o&&p&&i.push(` CONSTRAINT ${s(`fk_${e.name}_${t.name}`)} FOREIGN KEY (${s(t.name)}) REFERENCES ${s(o.name)} (${s(p.name)})`)}let a=[];for(let t of e.fields)t.indexed&&!t.primaryKey&&!t.unique&&a.push(`CREATE INDEX ${s(`idx_${e.name}_${t.name}`)} ON ${s(e.name)} (${s(t.name)});`);let f=[...m,...i],c=`CREATE TABLE ${s(e.name)} (
|
|
2
|
+
${f.join(`,
|
|
3
|
+
`)}
|
|
4
|
+
);`;return a.length>0?c+`
|
|
5
|
+
|
|
6
|
+
`+a.join(`
|
|
7
|
+
`):c}function A(e){let{tables:n,relations:r}=e;return n.length===0?"-- No tables defined":[...n].sort((a,f)=>{let c=a.fields.some(o=>o.foreignKey),t=f.fields.some(o=>o.foreignKey);return c&&!t?1:!c&&t?-1:0}).map(a=>R(a,r,n)).join(`
|
|
8
|
+
|
|
9
|
+
`)}0&&(module.exports={generateSQL});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
function i(e){return`"${e.replace(/"/g,'""')}"`}function p(e){return{text:"TEXT",varchar:"VARCHAR(255)",char:"CHAR(1)",int2:"SMALLINT",int4:"INTEGER",int8:"BIGINT",serial:"SERIAL",bigserial:"BIGSERIAL",float4:"REAL",float8:"DOUBLE PRECISION",numeric:"NUMERIC",decimal:"DECIMAL",bool:"BOOLEAN",date:"DATE",time:"TIME",timestamp:"TIMESTAMP",timestamptz:"TIMESTAMP WITH TIME ZONE",uuid:"UUID",json:"JSON",jsonb:"JSONB",bytea:"BYTEA"}[e]??e.toUpperCase()}function E(e){let t=[i(e.name)];return e.type==="serial"||e.type,t.push(p(e.type)),e.primaryKey&&t.push("PRIMARY KEY"),!e.nullable&&!e.primaryKey&&t.push("NOT NULL"),e.unique&&!e.primaryKey&&t.push("UNIQUE"),e.defaultValue&&t.push(`DEFAULT ${e.defaultValue}`)," "+t.join(" ")}function T(e,t,o){let m=[],c=[];for(let n of e.fields)m.push(E(n));for(let n of e.fields)if(n.foreignKey){let r=o.find(u=>u.id===n.foreignKey.tableId),l=r?.fields.find(u=>u.id===n.foreignKey.fieldId);r&&l&&c.push(` CONSTRAINT ${i(`fk_${e.name}_${n.name}`)} FOREIGN KEY (${i(n.name)}) REFERENCES ${i(r.name)} (${i(l.name)})`)}let s=[];for(let n of e.fields)n.indexed&&!n.primaryKey&&!n.unique&&s.push(`CREATE INDEX ${i(`idx_${e.name}_${n.name}`)} ON ${i(e.name)} (${i(n.name)});`);let f=[...m,...c],a=`CREATE TABLE ${i(e.name)} (
|
|
2
|
+
${f.join(`,
|
|
3
|
+
`)}
|
|
4
|
+
);`;return s.length>0?a+`
|
|
5
|
+
|
|
6
|
+
`+s.join(`
|
|
7
|
+
`):a}function d(e){let{tables:t,relations:o}=e;return t.length===0?"-- No tables defined":[...t].sort((s,f)=>{let a=s.fields.some(r=>r.foreignKey),n=f.fields.some(r=>r.foreignKey);return a&&!n?1:!a&&n?-1:0}).map(s=>T(s,o,t)).join(`
|
|
8
|
+
|
|
9
|
+
`)}export{d as generateSQL};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";"use client";var U=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var Ee=Object.getOwnPropertyNames;var Ne=Object.prototype.hasOwnProperty;var Le=(a,o)=>{for(var c in o)U(a,c,{get:o[c],enumerable:!0})},Ie=(a,o,c,l)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of Ee(o))!Ne.call(a,i)&&i!==c&&U(a,i,{get:()=>o[i],enumerable:!(l=ye(o,i))||l.enumerable});return a};var De=a=>Ie(U({},"__esModule",{value:!0}),a);var Ke={};Le(Ke,{Select:()=>He});module.exports=De(Ke);var r=require("react"),ce=require("react-dom"),ue=require("../../lib/aria-hide.cjs"),n=require("react/jsx-runtime"),_=()=>{},Ce=[],Se=(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,n.jsx)("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Me=(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,n.jsx)("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ae=(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[(0,n.jsx)("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),(0,n.jsx)("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),Oe=(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,n.jsx)("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),O={sm:{trigger:"h-8 px-2.5 text-xs gap-1.5",content:"text-xs",option:"px-2.5 py-1.5",searchInput:"px-2.5 py-1.5 text-xs"},md:{trigger:"h-10 px-3 text-sm gap-2",content:"text-sm",option:"px-3 py-2",searchInput:"px-3 py-2 text-sm"},lg:{trigger:"h-12 px-4 text-base gap-2.5",content:"text-base",option:"px-4 py-2.5",searchInput:"px-4 py-2.5 text-base"}},ie={default:{trigger:"border border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-800",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"},outlined:{trigger:"border-2 border-gray-300 bg-transparent dark:border-gray-600",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"},filled:{trigger:"border border-transparent bg-gray-100 dark:bg-gray-700",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}};function k(...a){let o="";for(let c=0;c<a.length;c++){let l=a[c];l&&(o&&(o+=" "),o+=l)}return o}function Re(a,o){if(!o)return a;let c=o.toLowerCase();return a.filter(l=>{if(l.label.toLowerCase().includes(c)||l.value.toLowerCase().includes(c))return!0;if(l.keywords){for(let i of l.keywords)if(i.toLowerCase().includes(c))return!0}return!1})}var Te=(0,r.memo)((0,r.forwardRef)(function({option:o,isSelected:c,isHighlighted:l,isDisabled:i,sizeKey:P,optionId:g,onClick:m,onMouseEnter:I,index:w},R){let V=()=>{i||m(o.value)},E=()=>{i||I(w)};return(0,n.jsxs)("div",{ref:R,id:g,role:"option","aria-selected":c,"aria-disabled":i||void 0,"data-highlighted":l||void 0,className:k(O[P].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",l&&!i&&"bg-blue-50 dark:bg-blue-900/30",c&&!l&&"bg-gray-50 dark:bg-gray-700/50",i&&"opacity-50 cursor-not-allowed"),onClick:V,onMouseEnter:E,children:[o.icon?(0,n.jsx)("span",{className:"flex shrink-0 items-center",children:o.icon}):null,(0,n.jsxs)("span",{className:"flex flex-col min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"truncate",children:o.label}),o.description?(0,n.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:o.description}):null]}),c?(0,n.jsx)("span",{className:"ml-auto text-blue-600 dark:text-blue-400",children:Oe}):null]})}));function He({options:a=Ce,value:o,defaultValue:c,onValueChange:l,searchable:i=!1,clearable:P=!1,disabled:g=!1,readOnly:m=!1,loading:I=!1,size:w="md",variant:R="default",placeholder:V="Select...",label:E,description:q,helperText:F,error:D,required:Q=!1,noOptionsText:de="No options",onSearchChange:X,name:Z,className:pe,triggerClassName:fe,contentClassName:ge,maxHeight:B=256}){let C=(0,r.useId)(),$=`${C}-label`,G=`${C}-trigger`,J=`${C}-listbox`,v=(0,r.useRef)(null),W=(0,r.useRef)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)([]),S=o!==void 0,[be,ne]=(0,r.useState)(c??""),N=S?o:be,[u,Y]=(0,r.useState)(!1),[j,M]=(0,r.useState)(""),[s,f]=(0,r.useState)(-1),[T,re]=(0,r.useState)(null),p=(0,r.useMemo)(()=>i?Re(a,j):a,[a,j,i]),H=(0,r.useMemo)(()=>a.find(e=>e.value===N)??null,[a,N]),x=(0,r.useMemo)(()=>{let e=new Set;for(let t of a)t.disabled&&e.add(t.value);return e},[a]),L=(0,r.useCallback)(e=>{S||ne(e),(l??_)(e),Y(!1),M(""),f(-1),v.current?.focus()},[S,l]),me=(0,r.useCallback)(e=>{e.stopPropagation(),S||ne(""),(l??_)(""),M(""),v.current?.focus()},[S,l]),A=(0,r.useCallback)(()=>{g||m||(Y(!0),M(""),f(-1))},[g,m]),b=(0,r.useCallback)(()=>{Y(!1),M(""),f(-1),v.current?.focus()},[]),he=(0,r.useCallback)(()=>{u?b():A()},[u,b,A]),h=(0,r.useCallback)((e,t)=>{let d=p.length;if(d===0)return-1;let y=e;for(let K=0;K<d;K++)if(y=((y+t)%d+d)%d,!x.has(p[y].value))return y;return-1},[p,x]),ve=(0,r.useCallback)(e=>{if(!(g||m)){if(u){switch(e.key){case"ArrowDown":{e.preventDefault();let t=h(s,1);t!==-1&&f(t);break}case"ArrowUp":{e.preventDefault();let t=h(s,-1);t!==-1&&f(t);break}case"Home":{e.preventDefault();let t=h(-1,1);t!==-1&&f(t);break}case"End":{e.preventDefault();let t=h(p.length,-1);t!==-1&&f(t);break}case"Enter":{if(e.preventDefault(),s>=0&&s<p.length){let t=p[s];x.has(t.value)||L(t.value)}break}case" ":if(e.preventDefault(),s>=0&&s<p.length){let t=p[s];x.has(t.value)||L(t.value)}else b();break;case"Escape":e.preventDefault(),b();break;case"Tab":b();break}return}switch(e.key){case"ArrowDown":case"ArrowUp":e.preventDefault(),A();break;case"Enter":case" ":e.preventDefault(),A();break}}},[g,m,u,A,b,s,p,x,h,L]),oe=(0,r.useCallback)(e=>{switch(e.key){case"ArrowDown":{e.preventDefault();let t=h(s,1);t!==-1&&f(t);break}case"ArrowUp":{e.preventDefault();let t=h(s,-1);t!==-1&&f(t);break}case"Home":{e.preventDefault();let t=h(-1,1);t!==-1&&f(t);break}case"End":{e.preventDefault();let t=h(p.length,-1);t!==-1&&f(t);break}case"Enter":{if(e.preventDefault(),s>=0&&s<p.length){let t=p[s];x.has(t.value)||L(t.value)}break}case"Escape":e.preventDefault(),b();break;case"Tab":b();break}},[s,p,x,h,L,b]),xe=(0,r.useCallback)(e=>{let t=e.target.value;M(t),f(-1),(X??_)(t)},[X]);(0,r.useEffect)(()=>{if(!u)return;let e=t=>{let d=t.target;v.current?.contains(d)||W.current?.contains(d)||b()};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e,{passive:!0}),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[u,b]),(0,r.useEffect)(()=>{if(!u||!v.current){re(null);return}let e=()=>{let t=v.current;if(!t)return;let d=t.getBoundingClientRect(),y=window.innerHeight-d.bottom,K=d.top,se=B+8,le=y<se&&K>y?"top":"bottom";re({top:le==="bottom"?d.bottom+window.scrollY+4:d.top+window.scrollY-se,left:d.left+window.scrollX,width:d.width,placement:le})};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[u,B]),(0,r.useEffect)(()=>{u&&i&&ee.current?.focus()},[u,i]),(0,r.useEffect)(()=>{let e=W.current;if(!(!u||!e))return(0,ue.registerFloatingLayer)(e,()=>v.current)},[u]),(0,r.useEffect)(()=>{if(s>=0){let e=te.current[s];e&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}},[s]);let z=N!==""&&N!==void 0,ke=P&&z&&!g&&!m&&!I,ae=!g&&!m,we=k("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",O[w].trigger,ie[R].trigger,!D&&ae&&ie[R].focus,D&&"border-red-500 dark:border-red-400 focus:ring-2 focus:ring-red-500 focus:border-red-500",g&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",m&&"cursor-default",!g&&!m&&"cursor-pointer",fe);return(0,n.jsxs)("div",{className:k("flex flex-col gap-1",pe),children:[E?(0,n.jsxs)("label",{id:$,htmlFor:G,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[E,Q?(0,n.jsx)("span",{className:"text-red-500 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,q?(0,n.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:q}):null,(0,n.jsxs)("button",{ref:v,id:G,type:"button",role:"combobox","aria-expanded":u,"aria-haspopup":"listbox","aria-controls":u?J:void 0,"aria-labelledby":E?$:void 0,"aria-required":Q||void 0,"aria-invalid":D?!0:void 0,"aria-activedescendant":u&&s>=0?`${C}-option-${s}`:void 0,disabled:g,className:we,onClick:ae?he:void 0,onKeyDown:ve,children:[(0,n.jsxs)("span",{className:k("flex items-center gap-2 min-w-0 flex-1 truncate",!z&&"text-gray-400 dark:text-gray-500"),children:[H?.icon?(0,n.jsx)("span",{className:"flex shrink-0 items-center",children:H.icon}):null,(0,n.jsx)("span",{className:"truncate",children:z&&H?H.label:V})]}),(0,n.jsxs)("span",{className:"flex items-center gap-1 shrink-0",children:[I?(0,n.jsx)("span",{className:"text-gray-400",children:Ae}):null,ke?(0,n.jsx)("span",{role:"button",tabIndex:-1,"aria-label":"Clear selection",className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onClick:me,onMouseDown:e=>e.preventDefault(),children:Me}):null,(0,n.jsx)("span",{className:k("text-gray-400 transition-transform duration-200",u&&"rotate-180"),children:Se})]})]}),D?(0,n.jsx)("p",{role:"alert",className:"text-xs text-red-500 dark:text-red-400",children:D}):F?(0,n.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:F}):null,Z?(0,n.jsx)("input",{type:"hidden",name:Z,value:N??""}):null,u&&T?(0,ce.createPortal)((0,n.jsxs)("div",{ref:W,role:"listbox",id:J,"aria-labelledby":E?$:void 0,className:k("fixed z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700","rounded-md shadow-lg overflow-hidden","animate-in fade-in-0 zoom-in-95",O[w].content,ge),style:{top:T.top,left:T.left,width:T.width,position:"absolute"},onKeyDown:oe,children:[i?(0,n.jsx)("div",{className:"border-b border-gray-200 dark:border-gray-700",children:(0,n.jsx)("input",{ref:ee,type:"text",role:"searchbox","aria-label":"Search options",className:k(O[w].searchInput,"w-full outline-none bg-transparent text-gray-900 dark:text-gray-100","placeholder:text-gray-400 dark:placeholder:text-gray-500"),placeholder:"Search...",value:j,onChange:xe,onKeyDown:oe})}):null,(0,n.jsx)("div",{className:"overflow-y-auto",style:{maxHeight:B},children:p.length===0?(0,n.jsx)("div",{className:k(O[w].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:de}):p.map((e,t)=>(0,n.jsx)(Te,{option:e,isSelected:e.value===N,isHighlighted:t===s,isDisabled:I||x.has(e.value),sizeKey:w,optionId:`${C}-option-${t}`,onClick:L,onMouseEnter:f,index:t,ref:d=>{te.current[t]=d}},e.value))})]}),document.body):null]})}0&&(module.exports={Select});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{useState as R,useRef as $,useEffect as T,useCallback as h,useMemo as Q,useId as Ne,memo as Le,forwardRef as Ie}from"react";import{createPortal as De}from"react-dom";import{registerFloatingLayer as Ce}from"../../lib/aria-hide.js";import{jsx as n,jsxs as v}from"react/jsx-runtime";var X=()=>{},Se=[],Me=n("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:n("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ae=n("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:n("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Oe=v("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[n("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),n("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),Re=n("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:n("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),H={sm:{trigger:"h-8 px-2.5 text-xs gap-1.5",content:"text-xs",option:"px-2.5 py-1.5",searchInput:"px-2.5 py-1.5 text-xs"},md:{trigger:"h-10 px-3 text-sm gap-2",content:"text-sm",option:"px-3 py-2",searchInput:"px-3 py-2 text-sm"},lg:{trigger:"h-12 px-4 text-base gap-2.5",content:"text-base",option:"px-4 py-2.5",searchInput:"px-4 py-2.5 text-base"}},pe={default:{trigger:"border border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-800",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"},outlined:{trigger:"border-2 border-gray-300 bg-transparent dark:border-gray-600",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"},filled:{trigger:"border border-transparent bg-gray-100 dark:bg-gray-700",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}};function w(...c){let o="";for(let u=0;u<c.length;u++){let l=c[u];l&&(o&&(o+=" "),o+=l)}return o}function Te(c,o){if(!o)return c;let u=o.toLowerCase();return c.filter(l=>{if(l.label.toLowerCase().includes(u)||l.value.toLowerCase().includes(u))return!0;if(l.keywords){for(let d of l.keywords)if(d.toLowerCase().includes(u))return!0}return!1})}var He=Le(Ie(function({option:o,isSelected:u,isHighlighted:l,isDisabled:d,sizeKey:W,optionId:f,onClick:b,onMouseEnter:D,index:y},K){let Y=()=>{d||b(o.value)},N=()=>{d||D(y)};return v("div",{ref:K,id:f,role:"option","aria-selected":u,"aria-disabled":d||void 0,"data-highlighted":l||void 0,className:w(H[W].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",l&&!d&&"bg-blue-50 dark:bg-blue-900/30",u&&!l&&"bg-gray-50 dark:bg-gray-700/50",d&&"opacity-50 cursor-not-allowed"),onClick:Y,onMouseEnter:N,children:[o.icon?n("span",{className:"flex shrink-0 items-center",children:o.icon}):null,v("span",{className:"flex flex-col min-w-0 flex-1",children:[n("span",{className:"truncate",children:o.label}),o.description?n("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:o.description}):null]}),u?n("span",{className:"ml-auto text-blue-600 dark:text-blue-400",children:Re}):null]})}));function Be({options:c=Se,value:o,defaultValue:u,onValueChange:l,searchable:d=!1,clearable:W=!1,disabled:f=!1,readOnly:b=!1,loading:D=!1,size:y="md",variant:K="default",placeholder:Y="Select...",label:N,description:Z,helperText:G,error:C,required:J=!1,noOptionsText:fe="No options",onSearchChange:ee,name:te,className:ge,triggerClassName:be,contentClassName:me,maxHeight:j=256}){let S=Ne(),z=`${S}-label`,ne=`${S}-trigger`,re=`${S}-listbox`,x=$(null),U=$(null),oe=$(null),ae=$([]),M=o!==void 0,[he,se]=R(u??""),L=M?o:he,[a,_]=R(!1),[q,A]=R(""),[r,p]=R(-1),[P,le]=R(null),i=Q(()=>d?Te(c,q):c,[c,q,d]),V=Q(()=>c.find(e=>e.value===L)??null,[c,L]),k=Q(()=>{let e=new Set;for(let t of c)t.disabled&&e.add(t.value);return e},[c]),I=h(e=>{M||se(e),(l??X)(e),_(!1),A(""),p(-1),x.current?.focus()},[M,l]),ve=h(e=>{e.stopPropagation(),M||se(""),(l??X)(""),A(""),x.current?.focus()},[M,l]),O=h(()=>{f||b||(_(!0),A(""),p(-1))},[f,b]),g=h(()=>{_(!1),A(""),p(-1),x.current?.focus()},[]),xe=h(()=>{a?g():O()},[a,g,O]),m=h((e,t)=>{let s=i.length;if(s===0)return-1;let E=e;for(let B=0;B<s;B++)if(E=((E+t)%s+s)%s,!k.has(i[E].value))return E;return-1},[i,k]),ke=h(e=>{if(!(f||b)){if(a){switch(e.key){case"ArrowDown":{e.preventDefault();let t=m(r,1);t!==-1&&p(t);break}case"ArrowUp":{e.preventDefault();let t=m(r,-1);t!==-1&&p(t);break}case"Home":{e.preventDefault();let t=m(-1,1);t!==-1&&p(t);break}case"End":{e.preventDefault();let t=m(i.length,-1);t!==-1&&p(t);break}case"Enter":{if(e.preventDefault(),r>=0&&r<i.length){let t=i[r];k.has(t.value)||I(t.value)}break}case" ":if(e.preventDefault(),r>=0&&r<i.length){let t=i[r];k.has(t.value)||I(t.value)}else g();break;case"Escape":e.preventDefault(),g();break;case"Tab":g();break}return}switch(e.key){case"ArrowDown":case"ArrowUp":e.preventDefault(),O();break;case"Enter":case" ":e.preventDefault(),O();break}}},[f,b,a,O,g,r,i,k,m,I]),ie=h(e=>{switch(e.key){case"ArrowDown":{e.preventDefault();let t=m(r,1);t!==-1&&p(t);break}case"ArrowUp":{e.preventDefault();let t=m(r,-1);t!==-1&&p(t);break}case"Home":{e.preventDefault();let t=m(-1,1);t!==-1&&p(t);break}case"End":{e.preventDefault();let t=m(i.length,-1);t!==-1&&p(t);break}case"Enter":{if(e.preventDefault(),r>=0&&r<i.length){let t=i[r];k.has(t.value)||I(t.value)}break}case"Escape":e.preventDefault(),g();break;case"Tab":g();break}},[r,i,k,m,I,g]),we=h(e=>{let t=e.target.value;A(t),p(-1),(ee??X)(t)},[ee]);T(()=>{if(!a)return;let e=t=>{let s=t.target;x.current?.contains(s)||U.current?.contains(s)||g()};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e,{passive:!0}),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[a,g]),T(()=>{if(!a||!x.current){le(null);return}let e=()=>{let t=x.current;if(!t)return;let s=t.getBoundingClientRect(),E=window.innerHeight-s.bottom,B=s.top,ue=j+8,de=E<ue&&B>E?"top":"bottom";le({top:de==="bottom"?s.bottom+window.scrollY+4:s.top+window.scrollY-ue,left:s.left+window.scrollX,width:s.width,placement:de})};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[a,j]),T(()=>{a&&d&&oe.current?.focus()},[a,d]),T(()=>{let e=U.current;if(!(!a||!e))return Ce(e,()=>x.current)},[a]),T(()=>{if(r>=0){let e=ae.current[r];e&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}},[r]);let F=L!==""&&L!==void 0,ye=W&&F&&!f&&!b&&!D,ce=!f&&!b,Ee=w("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",H[y].trigger,pe[K].trigger,!C&&ce&&pe[K].focus,C&&"border-red-500 dark:border-red-400 focus:ring-2 focus:ring-red-500 focus:border-red-500",f&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",b&&"cursor-default",!f&&!b&&"cursor-pointer",be);return v("div",{className:w("flex flex-col gap-1",ge),children:[N?v("label",{id:z,htmlFor:ne,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[N,J?n("span",{className:"text-red-500 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,Z?n("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:Z}):null,v("button",{ref:x,id:ne,type:"button",role:"combobox","aria-expanded":a,"aria-haspopup":"listbox","aria-controls":a?re:void 0,"aria-labelledby":N?z:void 0,"aria-required":J||void 0,"aria-invalid":C?!0:void 0,"aria-activedescendant":a&&r>=0?`${S}-option-${r}`:void 0,disabled:f,className:Ee,onClick:ce?xe:void 0,onKeyDown:ke,children:[v("span",{className:w("flex items-center gap-2 min-w-0 flex-1 truncate",!F&&"text-gray-400 dark:text-gray-500"),children:[V?.icon?n("span",{className:"flex shrink-0 items-center",children:V.icon}):null,n("span",{className:"truncate",children:F&&V?V.label:Y})]}),v("span",{className:"flex items-center gap-1 shrink-0",children:[D?n("span",{className:"text-gray-400",children:Oe}):null,ye?n("span",{role:"button",tabIndex:-1,"aria-label":"Clear selection",className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onClick:ve,onMouseDown:e=>e.preventDefault(),children:Ae}):null,n("span",{className:w("text-gray-400 transition-transform duration-200",a&&"rotate-180"),children:Me})]})]}),C?n("p",{role:"alert",className:"text-xs text-red-500 dark:text-red-400",children:C}):G?n("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:G}):null,te?n("input",{type:"hidden",name:te,value:L??""}):null,a&&P?De(v("div",{ref:U,role:"listbox",id:re,"aria-labelledby":N?z:void 0,className:w("fixed z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700","rounded-md shadow-lg overflow-hidden","animate-in fade-in-0 zoom-in-95",H[y].content,me),style:{top:P.top,left:P.left,width:P.width,position:"absolute"},onKeyDown:ie,children:[d?n("div",{className:"border-b border-gray-200 dark:border-gray-700",children:n("input",{ref:oe,type:"text",role:"searchbox","aria-label":"Search options",className:w(H[y].searchInput,"w-full outline-none bg-transparent text-gray-900 dark:text-gray-100","placeholder:text-gray-400 dark:placeholder:text-gray-500"),placeholder:"Search...",value:q,onChange:we,onKeyDown:ie})}):null,n("div",{className:"overflow-y-auto",style:{maxHeight:j},children:i.length===0?n("div",{className:w(H[y].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:fe}):i.map((e,t)=>n(He,{option:e,isSelected:e.value===L,isHighlighted:t===r,isDisabled:D||k.has(e.value),sizeKey:y,optionId:`${S}-option-${t}`,onClick:I,onMouseEnter:p,index:t,ref:s=>{ae.current[t]=s}},e.value))})]}),document.body):null]})}export{Be as Select};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var r=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var x=(t,e)=>{for(var p in e)r(t,p,{get:e[p],enumerable:!0})},i=(t,e,p,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of f(e))!m.call(t,o)&&o!==p&&r(t,o,{get:()=>e[o],enumerable:!(c=S(e,o))||c.enumerable});return t};var n=t=>i(r({},"__esModule",{value:!0}),t);var s={};x(s,{Select:()=>l.Select});module.exports=n(s);var l=require("./Select.cjs");0&&(module.exports={Select});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Select as o}from"./Select.js";export{o as Select};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";"use client";var T=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var ee=(t,r)=>{for(var a in r)T(t,a,{get:r[a],enumerable:!0})},te=(t,r,a,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of Z(r))!_.call(t,s)&&s!==a&&T(t,s,{get:()=>r[s],enumerable:!(n=K(r,s))||n.enumerable});return t};var re=t=>te(T({},"__esModule",{value:!0}),t);var ge={};ee(ge,{Sidebar:()=>se,SidebarContent:()=>de,SidebarFooter:()=>ce,SidebarGroup:()=>ue,SidebarHeader:()=>le,SidebarItem:()=>be,SidebarSubMenu:()=>pe,SidebarToggle:()=>fe,useSidebar:()=>ae});module.exports=re(ge);var o=require("react"),j=require("../../hooks/useDialogA11y.cjs"),i=require("../../lib/cn.cjs"),M=require("../../lib/i18n.cjs"),e=require("react/jsx-runtime"),E=(0,o.createContext)(null);function y(){let t=(0,o.useContext)(E);if(!t)throw new Error("Sidebar sub-components must be used within <Sidebar>");return t}function ae(){return y()}var oe=({className:t})=>(0,e.jsx)("svg",{className:(0,i.cn)("w-4 h-4",t),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,e.jsx)("path",{fillRule:"evenodd",d:"M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z",clipRule:"evenodd"})}),ne=({className:t})=>(0,e.jsx)("svg",{className:(0,i.cn)("w-4 h-4",t),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,e.jsx)("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),ie=({className:t})=>(0,e.jsx)("svg",{className:(0,i.cn)("w-5 h-5",t),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"})});function B({text:t,position:r,children:a}){let[n,s]=(0,o.useState)(!1),[c,f]=(0,o.useState)({top:0,left:0}),u=(0,o.useRef)(null);return(0,e.jsxs)("div",{ref:u,onMouseEnter:()=>{if(u.current){let d=u.current.getBoundingClientRect();f({top:d.top+d.height/2,left:r==="left"?d.right+8:d.left-8})}s(!0)},onMouseLeave:()=>s(!1),className:"relative",children:[a,n&&(0,e.jsx)("div",{className:(0,i.cn)("fixed z-[9999] px-2.5 py-1.5 text-xs font-medium text-white bg-gray-900 dark:bg-gray-700 rounded-md shadow-lg whitespace-nowrap pointer-events-none",r==="right"&&"-translate-x-full"),style:{top:c.top,left:c.left,transform:`translateY(-50%)${r==="right"?" translateX(-100%)":""}`},role:"tooltip",children:t})]})}function se({collapsed:t,defaultCollapsed:r=!1,onCollapsedChange:a,expandedWidth:n=260,collapsedWidth:s=64,position:c="left",variant:f="default",mobileBreakpoint:u=768,mobileOpen:x,onMobileOpenChange:d,className:m,"aria-label":b,closeLabel:N,trapFocus:g=!0,initialFocus:S,returnFocus:k,lockScroll:C=!0,children:O}){let G=(0,M.useUILabels)(),D=(0,o.useRef)(null),F=(0,o.useRef)(null),[q,Q]=(0,o.useState)(r),[W,R]=(0,o.useState)(!1),[p,$]=(0,o.useState)(!1),L=t!==void 0,w=L?t:q,v=x!==void 0,h=v?x:W;(0,o.useEffect)(()=>{let l=window.matchMedia(`(max-width: ${u}px)`),I=A=>{$(A.matches),A.matches||(v||R(!1),d?.(!1))};return I(l),l.addEventListener("change",I),()=>l.removeEventListener("change",I)},[u,v,d]);let U=(0,o.useCallback)(()=>{if(p){let l=!h;v||R(l),d?.(l)}else{let l=!w;L||Q(l),a?.(l)}},[p,h,w,v,L,d,a]),P=(0,o.useCallback)(()=>{v||R(!1),d?.(!1)},[v,d]);(0,o.useEffect)(()=>{let l=F.current;l&&(p&&!h?(l.setAttribute("inert",""),l.setAttribute("aria-hidden","true")):(l.removeAttribute("inert"),l.removeAttribute("aria-hidden")))},[p,h]);let{dialogRef:X,dialogProps:Y}=(0,j.useDialogA11y)({open:p&&h,onClose:P,trapFocus:g,initialFocus:S,returnFocus:k,lockScroll:C,keepInteractive:[D]}),J={default:"bg-white dark:bg-gray-900",bordered:(0,i.cn)("bg-white dark:bg-gray-900",c==="left"?"border-r border-gray-200 dark:border-gray-700":"border-l border-gray-200 dark:border-gray-700"),floating:"bg-white dark:bg-gray-900 m-3 rounded-xl shadow-xl border border-gray-200 dark:border-gray-700"},H=w&&!p?s:n,V=(0,e.jsx)("aside",{className:(0,i.cn)("flex flex-col h-full overflow-hidden transition-[width] duration-200 ease-in-out",J[f],m),style:{width:p?n:H,minWidth:p?n:H},"data-testid":"sidebar","data-collapsed":w&&!p,"data-mobile":p,"data-position":c,children:O}),z={collapsed:w&&!p,isMobile:p,mobileOpen:h,position:c,variant:f,expandedWidth:n,collapsedWidth:s,toggle:U,closeMobile:P,closeLabel:N};return p?(0,e.jsxs)(E.Provider,{value:z,children:[h&&(0,e.jsx)("div",{ref:D,className:"fixed inset-0 z-40 bg-black/50 transition-opacity",onClick:P,"aria-hidden":"true","data-testid":"sidebar-overlay"}),(0,e.jsx)("div",{ref:l=>{F.current=l,X.current=l},...Y,"aria-label":b??G.sidebar,className:(0,i.cn)("fixed top-0 z-50 h-full transition-transform duration-200 ease-in-out focus:outline-none",c==="left"?"left-0":"right-0",h?"translate-x-0":c==="left"?"-translate-x-full":"translate-x-full"),children:V})]}):(0,e.jsx)(E.Provider,{value:z,children:V})}function le({className:t,children:r}){let a=y(),n=(0,M.useUILabels)();return(0,e.jsxs)("div",{className:(0,i.cn)("flex items-center shrink-0 px-4 h-14 overflow-hidden",a.collapsed&&"justify-center px-2",t),"data-testid":"sidebar-header",children:[r,a.isMobile&&a.mobileOpen&&(0,e.jsx)("button",{type:"button",onClick:a.closeMobile,className:"ml-auto p-1 rounded-md text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer","aria-label":a.closeLabel??n.closeSidebar,children:(0,e.jsx)(ie,{})})]})}function de({className:t,children:r}){return(0,e.jsx)("div",{className:(0,i.cn)("flex-1 overflow-y-auto overflow-x-hidden py-2",t),"data-testid":"sidebar-content",children:r})}function ce({className:t,children:r}){let a=y();return(0,e.jsx)("div",{className:(0,i.cn)("shrink-0 border-t border-gray-200 dark:border-gray-700 px-4 py-3 overflow-hidden",a.collapsed&&"px-2 flex justify-center",t),"data-testid":"sidebar-footer",children:r})}function ue({label:t,className:r,children:a}){let n=y();return(0,e.jsxs)("div",{className:(0,i.cn)("py-2",r),"data-testid":"sidebar-group",children:[t&&!n.collapsed&&(0,e.jsx)("div",{className:"px-4 py-1.5 text-[11px] font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500",children:t}),t&&n.collapsed&&(0,e.jsx)("div",{className:"mx-auto my-1 w-6 border-t border-gray-200 dark:border-gray-700"}),(0,e.jsx)("div",{className:"space-y-0.5 px-2",children:a})]})}function be({icon:t,label:r,badge:a,badgeColor:n="bg-blue-600 text-white",active:s=!1,disabled:c=!1,href:f,onClick:u,tooltip:x,className:d}){let m=y(),b=m.collapsed,N=x??r,g=(0,e.jsxs)(e.Fragment,{children:[t&&(0,e.jsx)("span",{className:(0,i.cn)("shrink-0 w-5 h-5",b&&"w-5 h-5"),children:t}),!b&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"flex-1 truncate",children:r}),a!=null&&(0,e.jsx)("span",{className:(0,i.cn)("shrink-0 inline-flex items-center justify-center rounded-full text-[10px] font-semibold min-w-[18px] h-[18px] px-1",n),children:a})]}),b&&a!==void 0&&a!==null&&(0,e.jsx)("span",{className:"absolute top-1 right-1 w-2 h-2 rounded-full bg-blue-600"})]}),S=(0,i.cn)("relative flex items-center gap-3 rounded-md text-sm font-medium transition-colors w-full",b?"justify-center px-2 py-2.5":"px-3 py-2",s?"bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800",c&&"opacity-50 pointer-events-none",!c&&"cursor-pointer",d),k=()=>{c||(u?.(),m.isMobile&&m.closeMobile())},C=f?(0,e.jsx)("a",{href:c?void 0:f,className:S,onClick:k,"aria-current":s?"page":void 0,"data-testid":"sidebar-item",children:g}):(0,e.jsx)("button",{type:"button",className:S,onClick:k,disabled:c,"aria-current":s?"page":void 0,"data-testid":"sidebar-item",children:g});return b?(0,e.jsx)(B,{text:N,position:m.position,children:C}):C}function pe({icon:t,label:r,badge:a,defaultOpen:n=!1,className:s,children:c}){let f=y(),[u,x]=(0,o.useState)(n),d=(0,o.useRef)(null),[m,b]=(0,o.useState)(n?void 0:0),N=(0,o.useRef)(!0);return(0,o.useEffect)(()=>{if(N.current){N.current=!1,b(u?void 0:0);return}if(u){let g=d.current;if(g){b(g.scrollHeight);let S=setTimeout(()=>b(void 0),200);return()=>clearTimeout(S)}}else{let g=d.current;g&&(b(g.scrollHeight),requestAnimationFrame(()=>b(0)))}},[u]),f.collapsed?(0,e.jsx)(B,{text:r,position:f.position,children:(0,e.jsxs)("button",{type:"button",className:(0,i.cn)("relative flex items-center justify-center gap-3 rounded-md text-sm font-medium transition-colors w-full px-2 py-2.5","text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer",s),onClick:()=>{f.toggle(),x(!0)},"data-testid":"sidebar-submenu-trigger",children:[t&&(0,e.jsx)("span",{className:"shrink-0 w-5 h-5",children:t}),a!=null&&(0,e.jsx)("span",{className:"absolute top-1 right-1 w-2 h-2 rounded-full bg-blue-600"})]})}):(0,e.jsxs)("div",{className:s,"data-testid":"sidebar-submenu",children:[(0,e.jsxs)("button",{type:"button",className:(0,i.cn)("flex items-center gap-3 rounded-md text-sm font-medium transition-colors w-full px-3 py-2","text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer"),onClick:()=>x(!u),"aria-expanded":u,"data-testid":"sidebar-submenu-trigger",children:[t&&(0,e.jsx)("span",{className:"shrink-0 w-5 h-5",children:t}),(0,e.jsx)("span",{className:"flex-1 truncate text-left",children:r}),a!=null&&(0,e.jsx)("span",{className:"shrink-0 inline-flex items-center justify-center rounded-full text-[10px] font-semibold min-w-[18px] h-[18px] px-1 bg-blue-600 text-white",children:a}),(0,e.jsx)(ne,{className:(0,i.cn)("shrink-0 text-gray-400 transition-transform duration-200",u&&"rotate-180")})]}),(0,e.jsx)("div",{className:"overflow-hidden transition-[height] duration-200 ease-in-out",style:{height:m===void 0?"auto":m},children:(0,e.jsx)("div",{ref:d,className:"pl-4 py-0.5",children:c})})]})}function fe({className:t}){let r=y(),a=(0,M.useUILabels)(),n=r.isMobile?r.mobileOpen?r.closeLabel??a.closeSidebar:a.openSidebar:r.collapsed?a.expandSidebar:a.collapseSidebar;return(0,e.jsx)("button",{type:"button",onClick:r.toggle,className:(0,i.cn)("p-1.5 rounded-md text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors cursor-pointer",t),"aria-label":n,"data-testid":"sidebar-toggle",children:(0,e.jsx)(oe,{className:(0,i.cn)("transition-transform duration-200",r.collapsed&&"rotate-180",r.position==="right"&&!r.collapsed&&"rotate-180",r.position==="right"&&r.collapsed&&"rotate-0")})})}0&&(module.exports={Sidebar,SidebarContent,SidebarFooter,SidebarGroup,SidebarHeader,SidebarItem,SidebarSubMenu,SidebarToggle,useSidebar});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{createContext as ee,useContext as te,useState as y,useCallback as O,useEffect as E,useRef as C}from"react";import{useDialogA11y as re}from"../../hooks/useDialogA11y.js";import{cn as o}from"../../lib/cn.js";import{useUILabels as F}from"../../lib/i18n.js";import{Fragment as G,jsx as e,jsxs as m}from"react/jsx-runtime";var D=ee(null);function N(){let t=te(D);if(!t)throw new Error("Sidebar sub-components must be used within <Sidebar>");return t}function ce(){return N()}var ae=({className:t})=>e("svg",{className:o("w-4 h-4",t),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:e("path",{fillRule:"evenodd",d:"M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z",clipRule:"evenodd"})}),oe=({className:t})=>e("svg",{className:o("w-4 h-4",t),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:e("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),ne=({className:t})=>e("svg",{className:o("w-5 h-5",t),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:e("path",{d:"M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"})});function q({text:t,position:a,children:r}){let[n,b]=y(!1),[l,p]=y({top:0,left:0}),d=C(null);return m("div",{ref:d,onMouseEnter:()=>{if(d.current){let s=d.current.getBoundingClientRect();p({top:s.top+s.height/2,left:a==="left"?s.right+8:s.left-8})}b(!0)},onMouseLeave:()=>b(!1),className:"relative",children:[r,n&&e("div",{className:o("fixed z-[9999] px-2.5 py-1.5 text-xs font-medium text-white bg-gray-900 dark:bg-gray-700 rounded-md shadow-lg whitespace-nowrap pointer-events-none",a==="right"&&"-translate-x-full"),style:{top:l.top,left:l.left,transform:`translateY(-50%)${a==="right"?" translateX(-100%)":""}`},role:"tooltip",children:t})]})}function ue({collapsed:t,defaultCollapsed:a=!1,onCollapsedChange:r,expandedWidth:n=260,collapsedWidth:b=64,position:l="left",variant:p="default",mobileBreakpoint:d=768,mobileOpen:x,onMobileOpenChange:s,className:g,"aria-label":c,closeLabel:S,trapFocus:f=!0,initialFocus:w,returnFocus:M,lockScroll:R=!0,children:Q}){let W=F(),H=C(null),V=C(null),[$,U]=y(a),[X,L]=y(!1),[u,Y]=y(!1),P=t!==void 0,k=P?t:$,v=x!==void 0,h=v?x:X;E(()=>{let i=window.matchMedia(`(max-width: ${d}px)`),T=B=>{Y(B.matches),B.matches||(v||L(!1),s?.(!1))};return T(i),i.addEventListener("change",T),()=>i.removeEventListener("change",T)},[d,v,s]);let J=O(()=>{if(u){let i=!h;v||L(i),s?.(i)}else{let i=!k;P||U(i),r?.(i)}},[u,h,k,v,P,s,r]),I=O(()=>{v||L(!1),s?.(!1)},[v,s]);E(()=>{let i=V.current;i&&(u&&!h?(i.setAttribute("inert",""),i.setAttribute("aria-hidden","true")):(i.removeAttribute("inert"),i.removeAttribute("aria-hidden")))},[u,h]);let{dialogRef:K,dialogProps:Z}=re({open:u&&h,onClose:I,trapFocus:f,initialFocus:w,returnFocus:M,lockScroll:R,keepInteractive:[H]}),_={default:"bg-white dark:bg-gray-900",bordered:o("bg-white dark:bg-gray-900",l==="left"?"border-r border-gray-200 dark:border-gray-700":"border-l border-gray-200 dark:border-gray-700"),floating:"bg-white dark:bg-gray-900 m-3 rounded-xl shadow-xl border border-gray-200 dark:border-gray-700"},z=k&&!u?b:n,A=e("aside",{className:o("flex flex-col h-full overflow-hidden transition-[width] duration-200 ease-in-out",_[p],g),style:{width:u?n:z,minWidth:u?n:z},"data-testid":"sidebar","data-collapsed":k&&!u,"data-mobile":u,"data-position":l,children:Q}),j={collapsed:k&&!u,isMobile:u,mobileOpen:h,position:l,variant:p,expandedWidth:n,collapsedWidth:b,toggle:J,closeMobile:I,closeLabel:S};return u?m(D.Provider,{value:j,children:[h&&e("div",{ref:H,className:"fixed inset-0 z-40 bg-black/50 transition-opacity",onClick:I,"aria-hidden":"true","data-testid":"sidebar-overlay"}),e("div",{ref:i=>{V.current=i,K.current=i},...Z,"aria-label":c??W.sidebar,className:o("fixed top-0 z-50 h-full transition-transform duration-200 ease-in-out focus:outline-none",l==="left"?"left-0":"right-0",h?"translate-x-0":l==="left"?"-translate-x-full":"translate-x-full"),children:A})]}):e(D.Provider,{value:j,children:A})}function be({className:t,children:a}){let r=N(),n=F();return m("div",{className:o("flex items-center shrink-0 px-4 h-14 overflow-hidden",r.collapsed&&"justify-center px-2",t),"data-testid":"sidebar-header",children:[a,r.isMobile&&r.mobileOpen&&e("button",{type:"button",onClick:r.closeMobile,className:"ml-auto p-1 rounded-md text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer","aria-label":r.closeLabel??n.closeSidebar,children:e(ne,{})})]})}function pe({className:t,children:a}){return e("div",{className:o("flex-1 overflow-y-auto overflow-x-hidden py-2",t),"data-testid":"sidebar-content",children:a})}function fe({className:t,children:a}){let r=N();return e("div",{className:o("shrink-0 border-t border-gray-200 dark:border-gray-700 px-4 py-3 overflow-hidden",r.collapsed&&"px-2 flex justify-center",t),"data-testid":"sidebar-footer",children:a})}function ge({label:t,className:a,children:r}){let n=N();return m("div",{className:o("py-2",a),"data-testid":"sidebar-group",children:[t&&!n.collapsed&&e("div",{className:"px-4 py-1.5 text-[11px] font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500",children:t}),t&&n.collapsed&&e("div",{className:"mx-auto my-1 w-6 border-t border-gray-200 dark:border-gray-700"}),e("div",{className:"space-y-0.5 px-2",children:r})]})}function me({icon:t,label:a,badge:r,badgeColor:n="bg-blue-600 text-white",active:b=!1,disabled:l=!1,href:p,onClick:d,tooltip:x,className:s}){let g=N(),c=g.collapsed,S=x??a,f=m(G,{children:[t&&e("span",{className:o("shrink-0 w-5 h-5",c&&"w-5 h-5"),children:t}),!c&&m(G,{children:[e("span",{className:"flex-1 truncate",children:a}),r!=null&&e("span",{className:o("shrink-0 inline-flex items-center justify-center rounded-full text-[10px] font-semibold min-w-[18px] h-[18px] px-1",n),children:r})]}),c&&r!==void 0&&r!==null&&e("span",{className:"absolute top-1 right-1 w-2 h-2 rounded-full bg-blue-600"})]}),w=o("relative flex items-center gap-3 rounded-md text-sm font-medium transition-colors w-full",c?"justify-center px-2 py-2.5":"px-3 py-2",b?"bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800",l&&"opacity-50 pointer-events-none",!l&&"cursor-pointer",s),M=()=>{l||(d?.(),g.isMobile&&g.closeMobile())},R=p?e("a",{href:l?void 0:p,className:w,onClick:M,"aria-current":b?"page":void 0,"data-testid":"sidebar-item",children:f}):e("button",{type:"button",className:w,onClick:M,disabled:l,"aria-current":b?"page":void 0,"data-testid":"sidebar-item",children:f});return c?e(q,{text:S,position:g.position,children:R}):R}function xe({icon:t,label:a,badge:r,defaultOpen:n=!1,className:b,children:l}){let p=N(),[d,x]=y(n),s=C(null),[g,c]=y(n?void 0:0),S=C(!0);return E(()=>{if(S.current){S.current=!1,c(d?void 0:0);return}if(d){let f=s.current;if(f){c(f.scrollHeight);let w=setTimeout(()=>c(void 0),200);return()=>clearTimeout(w)}}else{let f=s.current;f&&(c(f.scrollHeight),requestAnimationFrame(()=>c(0)))}},[d]),p.collapsed?e(q,{text:a,position:p.position,children:m("button",{type:"button",className:o("relative flex items-center justify-center gap-3 rounded-md text-sm font-medium transition-colors w-full px-2 py-2.5","text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer",b),onClick:()=>{p.toggle(),x(!0)},"data-testid":"sidebar-submenu-trigger",children:[t&&e("span",{className:"shrink-0 w-5 h-5",children:t}),r!=null&&e("span",{className:"absolute top-1 right-1 w-2 h-2 rounded-full bg-blue-600"})]})}):m("div",{className:b,"data-testid":"sidebar-submenu",children:[m("button",{type:"button",className:o("flex items-center gap-3 rounded-md text-sm font-medium transition-colors w-full px-3 py-2","text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer"),onClick:()=>x(!d),"aria-expanded":d,"data-testid":"sidebar-submenu-trigger",children:[t&&e("span",{className:"shrink-0 w-5 h-5",children:t}),e("span",{className:"flex-1 truncate text-left",children:a}),r!=null&&e("span",{className:"shrink-0 inline-flex items-center justify-center rounded-full text-[10px] font-semibold min-w-[18px] h-[18px] px-1 bg-blue-600 text-white",children:r}),e(oe,{className:o("shrink-0 text-gray-400 transition-transform duration-200",d&&"rotate-180")})]}),e("div",{className:"overflow-hidden transition-[height] duration-200 ease-in-out",style:{height:g===void 0?"auto":g},children:e("div",{ref:s,className:"pl-4 py-0.5",children:l})})]})}function he({className:t}){let a=N(),r=F(),n=a.isMobile?a.mobileOpen?a.closeLabel??r.closeSidebar:r.openSidebar:a.collapsed?r.expandSidebar:r.collapseSidebar;return e("button",{type:"button",onClick:a.toggle,className:o("p-1.5 rounded-md text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors cursor-pointer",t),"aria-label":n,"data-testid":"sidebar-toggle",children:e(ae,{className:o("transition-transform duration-200",a.collapsed&&"rotate-180",a.position==="right"&&!a.collapsed&&"rotate-180",a.position==="right"&&a.collapsed&&"rotate-0")})})}export{ue as Sidebar,pe as SidebarContent,fe as SidebarFooter,ge as SidebarGroup,be as SidebarHeader,me as SidebarItem,xe as SidebarSubMenu,he as SidebarToggle,ce as useSidebar};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var b=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var t=Object.prototype.hasOwnProperty;var s=(a,e)=>{for(var i in e)b(a,i,{get:e[i],enumerable:!0})},P=(a,e,i,d)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of p(e))!t.call(a,o)&&o!==i&&b(a,o,{get:()=>e[o],enumerable:!(d=S(e,o))||d.enumerable});return a};var n=a=>P(b({},"__esModule",{value:!0}),a);var u={};s(u,{Sidebar:()=>r.Sidebar,SidebarContent:()=>r.SidebarContent,SidebarFooter:()=>r.SidebarFooter,SidebarGroup:()=>r.SidebarGroup,SidebarHeader:()=>r.SidebarHeader,SidebarItem:()=>r.SidebarItem,SidebarSubMenu:()=>r.SidebarSubMenu,SidebarToggle:()=>r.SidebarToggle,useSidebar:()=>r.useSidebar});module.exports=n(u);var r=require("./Sidebar.cjs");0&&(module.exports={Sidebar,SidebarContent,SidebarFooter,SidebarGroup,SidebarHeader,SidebarItem,SidebarSubMenu,SidebarToggle,useSidebar});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Sidebar as a,SidebarHeader as o,SidebarContent as i,SidebarFooter as b,SidebarGroup as d,SidebarItem as S,SidebarSubMenu as p,SidebarToggle as t,useSidebar as s}from"./Sidebar.js";export{a as Sidebar,i as SidebarContent,b as SidebarFooter,d as SidebarGroup,o as SidebarHeader,S as SidebarItem,p as SidebarSubMenu,t as SidebarToggle,s as useSidebar};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var l=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var k=(n,e)=>{for(var r in e)l(n,r,{get:e[r],enumerable:!0})},v=(n,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of f(e))!S.call(n,a)&&a!==r&&l(n,a,{get:()=>e[a],enumerable:!(t=g(e,a))||t.enumerable});return n};var b=n=>v(l({},"__esModule",{value:!0}),n);var N={};k(N,{Skeleton:()=>m});module.exports=b(N);var d=require("../../lib/cn.cjs"),i=require("react/jsx-runtime"),x={text:"rounded h-4 w-full",circular:"rounded-full",rectangular:"rounded-none",rounded:"rounded-lg"},C={pulse:"animate-pulse",wave:"animate-shimmer bg-gradient-to-r from-gray-200 via-gray-100 to-gray-200 dark:from-gray-700 dark:via-gray-600 dark:to-gray-700 bg-[length:200%_100%]",none:""},A="bg-gray-200 dark:bg-gray-700";function m({variant:n="text",animation:e="pulse",width:r,height:t,count:a=1,className:p,style:c,...s}){let o={...r!==void 0&&{width:typeof r=="number"?`${r}px`:r},...t!==void 0&&{height:typeof t=="number"?`${t}px`:t},...c};n==="circular"&&r&&!t&&(o.height=o.width);let u=(0,d.cn)(A,x[n],C[e],p);return a===1?(0,i.jsx)("div",{className:u,style:o,"aria-busy":"true","aria-live":"polite",...s}):(0,i.jsx)("div",{className:"space-y-2",children:Array.from({length:a}).map((P,y)=>(0,i.jsx)("div",{className:u,style:o,"aria-busy":"true","aria-live":"polite",...s},y))})}m.displayName="Skeleton";0&&(module.exports={Skeleton});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{cn as p}from"../../lib/cn.js";import{jsx as t}from"react/jsx-runtime";var c={text:"rounded h-4 w-full",circular:"rounded-full",rectangular:"rounded-none",rounded:"rounded-lg"},y={pulse:"animate-pulse",wave:"animate-shimmer bg-gradient-to-r from-gray-200 via-gray-100 to-gray-200 dark:from-gray-700 dark:via-gray-600 dark:to-gray-700 bg-[length:200%_100%]",none:""},g="bg-gray-200 dark:bg-gray-700";function f({variant:a="text",animation:s="pulse",width:e,height:n,count:o=1,className:u,style:d,...i}){let r={...e!==void 0&&{width:typeof e=="number"?`${e}px`:e},...n!==void 0&&{height:typeof n=="number"?`${n}px`:n},...d};a==="circular"&&e&&!n&&(r.height=r.width);let l=p(g,c[a],y[s],u);return o===1?t("div",{className:l,style:r,"aria-busy":"true","aria-live":"polite",...i}):t("div",{className:"space-y-2",children:Array.from({length:o}).map((S,m)=>t("div",{className:l,style:r,"aria-busy":"true","aria-live":"polite",...i},m))})}f.displayName="Skeleton";export{f as Skeleton};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var r=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var i=(o,e)=>{for(var n in e)r(o,n,{get:e[n],enumerable:!0})},m=(o,e,n,k)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of p(e))!a.call(o,t)&&t!==n&&r(o,t,{get:()=>e[t],enumerable:!(k=S(e,t))||k.enumerable});return o};var f=o=>m(r({},"__esModule",{value:!0}),o);var x={};i(x,{Skeleton:()=>l.Skeleton});module.exports=f(x);var l=require("./Skeleton.cjs");0&&(module.exports={Skeleton});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Skeleton as t}from"./Skeleton.js";export{t as Skeleton};
|