@ayasofyazilim/ui 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mocks__/canvas.ts +8 -0
- package/components.json +21 -0
- package/eslint.config.js +4 -0
- package/jest-environment.js +37 -0
- package/jest.config.ts +47 -0
- package/jest.setup.ts +69 -0
- package/package.json +124 -0
- package/postcss.config.mjs +6 -0
- package/src/aria/index.tsx +1 -0
- package/src/aria/number-field.tsx +41 -0
- package/src/components/.gitkeep +0 -0
- package/src/components/accordion.tsx +66 -0
- package/src/components/alert-dialog.tsx +157 -0
- package/src/components/alert.tsx +70 -0
- package/src/components/aspect-ratio.tsx +11 -0
- package/src/components/avatar.tsx +53 -0
- package/src/components/badge.tsx +67 -0
- package/src/components/breadcrumb.tsx +109 -0
- package/src/components/button-group.tsx +83 -0
- package/src/components/button.tsx +68 -0
- package/src/components/calendar.tsx +219 -0
- package/src/components/card.tsx +92 -0
- package/src/components/carousel.tsx +241 -0
- package/src/components/chart.tsx +363 -0
- package/src/components/checkbox.tsx +32 -0
- package/src/components/collapsible.tsx +33 -0
- package/src/components/command.tsx +184 -0
- package/src/components/context-menu.tsx +252 -0
- package/src/components/dialog.tsx +144 -0
- package/src/components/drawer.tsx +135 -0
- package/src/components/dropdown-menu.tsx +258 -0
- package/src/components/empty.tsx +100 -0
- package/src/components/field.tsx +248 -0
- package/src/components/form.tsx +169 -0
- package/src/components/hover-card.tsx +44 -0
- package/src/components/input-group.tsx +170 -0
- package/src/components/input-otp.tsx +77 -0
- package/src/components/input.tsx +21 -0
- package/src/components/item.tsx +193 -0
- package/src/components/kbd.tsx +28 -0
- package/src/components/label.tsx +24 -0
- package/src/components/menubar.tsx +276 -0
- package/src/components/navigation-menu.tsx +168 -0
- package/src/components/pagination.tsx +130 -0
- package/src/components/popover.tsx +88 -0
- package/src/components/progress.tsx +31 -0
- package/src/components/radio-group.tsx +45 -0
- package/src/components/resizable.tsx +56 -0
- package/src/components/scroll-area.tsx +58 -0
- package/src/components/select.tsx +189 -0
- package/src/components/separator.tsx +28 -0
- package/src/components/sheet.tsx +140 -0
- package/src/components/sidebar.tsx +862 -0
- package/src/components/skeleton.tsx +13 -0
- package/src/components/slider.tsx +63 -0
- package/src/components/sonner.tsx +40 -0
- package/src/components/spinner.tsx +16 -0
- package/src/components/stepper.tsx +291 -0
- package/src/components/switch.tsx +31 -0
- package/src/components/table.tsx +133 -0
- package/src/components/tabs.tsx +66 -0
- package/src/components/textarea.tsx +18 -0
- package/src/components/toggle-group.tsx +83 -0
- package/src/components/toggle.tsx +47 -0
- package/src/components/tooltip.tsx +66 -0
- package/src/custom/action-button.tsx +48 -0
- package/src/custom/async-select.tsx +287 -0
- package/src/custom/awesome-not-found.tsx +116 -0
- package/src/custom/charts/area-chart.tsx +147 -0
- package/src/custom/charts/bar-chart.tsx +233 -0
- package/src/custom/charts/chart-card.tsx +103 -0
- package/src/custom/charts/index.tsx +16 -0
- package/src/custom/charts/pie-chart.tsx +168 -0
- package/src/custom/charts/radar-chart.tsx +126 -0
- package/src/custom/checkbox-tree.tsx +100 -0
- package/src/custom/combobox.tsx +296 -0
- package/src/custom/confirm-dialog.tsx +102 -0
- package/src/custom/country-selector.tsx +204 -0
- package/src/custom/date-picker/calendar-rac.tsx +109 -0
- package/src/custom/date-picker/datefield-rac.tsx +84 -0
- package/src/custom/date-picker/index.tsx +273 -0
- package/src/custom/date-picker/types/index.ts +4 -0
- package/src/custom/date-picker/utils/index.ts +42 -0
- package/src/custom/date-picker-old.tsx +50 -0
- package/src/custom/date-tooltip.tsx +98 -0
- package/src/custom/document-scanner/consts.ts +5 -0
- package/src/custom/document-scanner/corner-adjustment/action-buttons.tsx +33 -0
- package/src/custom/document-scanner/corner-adjustment/corner-handle.tsx +43 -0
- package/src/custom/document-scanner/corner-adjustment/hooks/use-corner-drag.ts +85 -0
- package/src/custom/document-scanner/corner-adjustment/index.tsx +125 -0
- package/src/custom/document-scanner/corner-adjustment/types.ts +53 -0
- package/src/custom/document-scanner/corner-adjustment/utils/clip-path.ts +22 -0
- package/src/custom/document-scanner/corner-adjustment/zoom-magnifier.tsx +115 -0
- package/src/custom/document-scanner/hooks/use-document-capture.ts +81 -0
- package/src/custom/document-scanner/hooks/use-document-scanner.ts +80 -0
- package/src/custom/document-scanner/hooks/use-perspective-crop.ts +38 -0
- package/src/custom/document-scanner/index.tsx +255 -0
- package/src/custom/document-scanner/lib.ts +407 -0
- package/src/custom/document-scanner/types.ts +205 -0
- package/src/custom/document-scanner/utils/perspective-correction.ts +139 -0
- package/src/custom/document-viewer/controllers.tsx +98 -0
- package/src/custom/document-viewer/index.tsx +43 -0
- package/src/custom/document-viewer/renderers/image.tsx +37 -0
- package/src/custom/document-viewer/renderers/index.tsx +2 -0
- package/src/custom/document-viewer/renderers/pdf.tsx +105 -0
- package/src/custom/email-input/domains.json +159 -0
- package/src/custom/email-input/email.tsx +229 -0
- package/src/custom/email-input/index.tsx +4 -0
- package/src/custom/email-input/types.ts +104 -0
- package/src/custom/file-uploader.tsx +541 -0
- package/src/custom/filter-component/fields/async-select.tsx +33 -0
- package/src/custom/filter-component/fields/date.tsx +60 -0
- package/src/custom/filter-component/fields/multi-select.tsx +30 -0
- package/src/custom/filter-component/index.tsx +217 -0
- package/src/custom/image-canvas.tsx +260 -0
- package/src/custom/json-editor.tsx +22 -0
- package/src/custom/master-data-grid/components/dialogs/column-settings-dialog.tsx +100 -0
- package/src/custom/master-data-grid/components/dialogs/index.ts +1 -0
- package/src/custom/master-data-grid/components/filters/client-filter.tsx +368 -0
- package/src/custom/master-data-grid/components/filters/filter-input.tsx +256 -0
- package/src/custom/master-data-grid/components/filters/index.ts +3 -0
- package/src/custom/master-data-grid/components/filters/inline-column-filter.tsx +233 -0
- package/src/custom/master-data-grid/components/filters/multi-filter-dialog.tsx +90 -0
- package/src/custom/master-data-grid/components/filters/server-filter.tsx +255 -0
- package/src/custom/master-data-grid/components/master-data-grid.tsx +472 -0
- package/src/custom/master-data-grid/components/pagination/index.ts +1 -0
- package/src/custom/master-data-grid/components/pagination/pagination.tsx +178 -0
- package/src/custom/master-data-grid/components/table/cell-renderer.tsx +634 -0
- package/src/custom/master-data-grid/components/table/header-cell.tsx +162 -0
- package/src/custom/master-data-grid/components/table/index.ts +4 -0
- package/src/custom/master-data-grid/components/table/table-body-renderer.tsx +113 -0
- package/src/custom/master-data-grid/components/table/virtual-body.tsx +138 -0
- package/src/custom/master-data-grid/components/toolbar/index.ts +1 -0
- package/src/custom/master-data-grid/components/toolbar/toolbar.tsx +314 -0
- package/src/custom/master-data-grid/hooks/index.ts +3 -0
- package/src/custom/master-data-grid/hooks/use-columns.tsx +332 -0
- package/src/custom/master-data-grid/hooks/use-editing.ts +106 -0
- package/src/custom/master-data-grid/hooks/use-table-state-reducer.ts +157 -0
- package/src/custom/master-data-grid/hooks/use-table-state.ts +31 -0
- package/src/custom/master-data-grid/index.ts +16 -0
- package/src/custom/master-data-grid/types.ts +466 -0
- package/src/custom/master-data-grid/utils/column-generator.tsx +306 -0
- package/src/custom/master-data-grid/utils/export-utils.ts +67 -0
- package/src/custom/master-data-grid/utils/filter-fns.ts +290 -0
- package/src/custom/master-data-grid/utils/index.ts +8 -0
- package/src/custom/master-data-grid/utils/pinning-utils.ts +88 -0
- package/src/custom/master-data-grid/utils/translation-utils.ts +42 -0
- package/src/custom/multi-select.tsx +432 -0
- package/src/custom/password-input.tsx +194 -0
- package/src/custom/phone-input.tsx +172 -0
- package/src/custom/schema-form/custom/index.tsx +1 -0
- package/src/custom/schema-form/custom/label.tsx +53 -0
- package/src/custom/schema-form/fields/base-input-field.tsx +82 -0
- package/src/custom/schema-form/fields/field.tsx +67 -0
- package/src/custom/schema-form/fields/index.tsx +5 -0
- package/src/custom/schema-form/fields/object.tsx +12 -0
- package/src/custom/schema-form/fields/table-array/array-field-item.tsx +90 -0
- package/src/custom/schema-form/fields/table-array/array-field-template.tsx +115 -0
- package/src/custom/schema-form/index.tsx +259 -0
- package/src/custom/schema-form/templates/description.tsx +20 -0
- package/src/custom/schema-form/templates/index.tsx +2 -0
- package/src/custom/schema-form/templates/submit.tsx +32 -0
- package/src/custom/schema-form/types.ts +64 -0
- package/src/custom/schema-form/utils/index.ts +4 -0
- package/src/custom/schema-form/utils/schema-dependency.ts +655 -0
- package/src/custom/schema-form/utils/schemas.ts +289 -0
- package/src/custom/schema-form/utils/validation.ts +23 -0
- package/src/custom/schema-form/widgets/boolean.tsx +77 -0
- package/src/custom/schema-form/widgets/combobox.tsx +274 -0
- package/src/custom/schema-form/widgets/date.tsx +59 -0
- package/src/custom/schema-form/widgets/email.tsx +34 -0
- package/src/custom/schema-form/widgets/index.tsx +10 -0
- package/src/custom/schema-form/widgets/password.tsx +40 -0
- package/src/custom/schema-form/widgets/phone.tsx +40 -0
- package/src/custom/schema-form/widgets/select.tsx +105 -0
- package/src/custom/schema-form/widgets/selectable.tsx +25 -0
- package/src/custom/schema-form/widgets/string-array.tsx +296 -0
- package/src/custom/schema-form/widgets/url.tsx +56 -0
- package/src/custom/section-layout-v2.tsx +212 -0
- package/src/custom/select-tabs.tsx +109 -0
- package/src/custom/selectable.tsx +316 -0
- package/src/custom/stepper.tsx +236 -0
- package/src/custom/tab-layout.tsx +213 -0
- package/src/custom/tanstack-table/fields/index.tsx +12 -0
- package/src/custom/tanstack-table/fields/tanstack-table-action-dialogs.tsx +89 -0
- package/src/custom/tanstack-table/fields/tanstack-table-column-header.tsx +66 -0
- package/src/custom/tanstack-table/fields/tanstack-table-filter-date.tsx +180 -0
- package/src/custom/tanstack-table/fields/tanstack-table-filter-faceted.tsx +158 -0
- package/src/custom/tanstack-table/fields/tanstack-table-filter-text.tsx +76 -0
- package/src/custom/tanstack-table/fields/tanstack-table-pagination.tsx +136 -0
- package/src/custom/tanstack-table/fields/tanstack-table-plain-table.tsx +142 -0
- package/src/custom/tanstack-table/fields/tanstack-table-row-actions-confirmation.tsx +77 -0
- package/src/custom/tanstack-table/fields/tanstack-table-row-actions-custom-dialog.tsx +87 -0
- package/src/custom/tanstack-table/fields/tanstack-table-row-actions.tsx +151 -0
- package/src/custom/tanstack-table/fields/tanstack-table-table-actions-custom-dialog.tsx +88 -0
- package/src/custom/tanstack-table/fields/tanstack-table-table-actions-schemaform-dialog.tsx +47 -0
- package/src/custom/tanstack-table/fields/tanstack-table-toolbar.tsx +143 -0
- package/src/custom/tanstack-table/fields/tanstack-table-view-options.tsx +171 -0
- package/src/custom/tanstack-table/index.tsx +244 -0
- package/src/custom/tanstack-table/types/index.ts +328 -0
- package/src/custom/tanstack-table/utils/cell-with-actions.tsx +21 -0
- package/src/custom/tanstack-table/utils/column-names.ts +26 -0
- package/src/custom/tanstack-table/utils/columns-by-row-data.tsx +312 -0
- package/src/custom/tanstack-table/utils/editable-columns-by-row-data.tsx +219 -0
- package/src/custom/tanstack-table/utils/faceted-boolean-options.tsx +22 -0
- package/src/custom/tanstack-table/utils/index.tsx +10 -0
- package/src/custom/tanstack-table/utils/pinning-styles.ts +57 -0
- package/src/custom/tanstack-table/utils/table.tsx +83 -0
- package/src/custom/tanstack-table/utils/test-conditions.ts +17 -0
- package/src/custom/timeline.tsx +208 -0
- package/src/custom/tree.tsx +200 -0
- package/src/custom/tscanify/browser.ts +66 -0
- package/src/custom/tscanify/index.ts +51 -0
- package/src/custom/tscanify/tscanify-browser.ts +522 -0
- package/src/custom/tscanify/tscanify.ts +262 -0
- package/src/custom/tscanify/types.ts +22 -0
- package/src/custom/webcam.tsx +737 -0
- package/src/hooks/.gitkeep +0 -0
- package/src/hooks/use-callback-ref.ts +27 -0
- package/src/hooks/use-controllable-state.ts +67 -0
- package/src/hooks/use-debounce.ts +19 -0
- package/src/hooks/use-is-visible.ts +23 -0
- package/src/hooks/use-media-query.ts +21 -0
- package/src/hooks/use-mobile.ts +21 -0
- package/src/hooks/use-on-window-resize.ts +15 -0
- package/src/hooks/use-scroll.tsx +22 -0
- package/src/lib/utils.ts +61 -0
- package/src/lib/zod.ts +2 -0
- package/src/styles/core.css +57 -0
- package/src/styles/globals.css +130 -0
- package/src/test/email-input.test.tsx +217 -0
- package/src/test/password-input.test.tsx +92 -0
- package/src/test/select-tabs.test.tsx +302 -0
- package/src/test/selectable.test.tsx +1093 -0
- package/tsconfig.json +13 -0
- package/tsconfig.lint.json +8 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use no memo";
|
|
3
|
+
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { ItemInstance } from "@headless-tree/core";
|
|
6
|
+
import { ChevronDownIcon } from "lucide-react";
|
|
7
|
+
import { Slot } from "radix-ui";
|
|
8
|
+
export * from "@headless-tree/core";
|
|
9
|
+
export * from "@headless-tree/react";
|
|
10
|
+
import { cn } from "@repo/ayasofyazilim-ui/lib/utils";
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
interface TreeContextValue<T = any> {
|
|
13
|
+
indent: number;
|
|
14
|
+
currentItem?: ItemInstance<T>;
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
tree?: any;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const TreeContext = React.createContext<TreeContextValue>({
|
|
20
|
+
indent: 20,
|
|
21
|
+
currentItem: undefined,
|
|
22
|
+
tree: undefined,
|
|
23
|
+
});
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
+
function useTreeContext<T = any>() {
|
|
26
|
+
return React.useContext(TreeContext) as TreeContextValue<T>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface TreeProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
30
|
+
indent?: number;
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
|
+
tree?: any;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function Tree({ indent = 20, tree, className, ...props }: TreeProps) {
|
|
36
|
+
const containerProps =
|
|
37
|
+
tree && typeof tree.getContainerProps === "function"
|
|
38
|
+
? tree.getContainerProps()
|
|
39
|
+
: {};
|
|
40
|
+
const mergedProps = { ...props, ...containerProps };
|
|
41
|
+
|
|
42
|
+
// Extract style from mergedProps to merge with our custom styles
|
|
43
|
+
const { style: propStyle, ...otherProps } = mergedProps;
|
|
44
|
+
|
|
45
|
+
// Merge styles
|
|
46
|
+
const mergedStyle = {
|
|
47
|
+
...propStyle,
|
|
48
|
+
"--tree-indent": `${indent}px`,
|
|
49
|
+
} as React.CSSProperties;
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<TreeContext.Provider value={{ indent, tree }}>
|
|
53
|
+
<div
|
|
54
|
+
data-slot="tree"
|
|
55
|
+
style={mergedStyle}
|
|
56
|
+
className={cn("flex flex-col", className)}
|
|
57
|
+
{...otherProps}
|
|
58
|
+
/>
|
|
59
|
+
</TreeContext.Provider>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
64
|
+
interface TreeItemProps<T = any>
|
|
65
|
+
extends React.HTMLAttributes<HTMLButtonElement> {
|
|
66
|
+
item: ItemInstance<T>;
|
|
67
|
+
indent?: number;
|
|
68
|
+
asChild?: boolean;
|
|
69
|
+
}
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
71
|
+
function TreeItem<T = any>({
|
|
72
|
+
item,
|
|
73
|
+
className,
|
|
74
|
+
asChild,
|
|
75
|
+
children,
|
|
76
|
+
...props
|
|
77
|
+
}: Omit<TreeItemProps<T>, "indent">) {
|
|
78
|
+
const { indent } = useTreeContext<T>();
|
|
79
|
+
|
|
80
|
+
const itemProps = typeof item.getProps === "function" ? item.getProps() : {};
|
|
81
|
+
const mergedProps = { ...props, ...itemProps };
|
|
82
|
+
|
|
83
|
+
// Extract style from mergedProps to merge with our custom styles
|
|
84
|
+
const { style: propStyle, ...otherProps } = mergedProps;
|
|
85
|
+
|
|
86
|
+
// Merge styles
|
|
87
|
+
const mergedStyle = {
|
|
88
|
+
...propStyle,
|
|
89
|
+
"--tree-padding": `${item.getItemMeta().level * indent}px`,
|
|
90
|
+
} as React.CSSProperties;
|
|
91
|
+
|
|
92
|
+
const Comp = asChild ? Slot.Root : "button";
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<TreeContext.Provider value={{ indent, currentItem: item }}>
|
|
96
|
+
<Comp
|
|
97
|
+
data-slot="tree-item"
|
|
98
|
+
style={mergedStyle}
|
|
99
|
+
className={cn(
|
|
100
|
+
"z-10 ps-(--tree-padding) outline-hidden select-none not-last:pb-0.5 focus:z-20 data-disabled:pointer-events-none data-disabled:opacity-50",
|
|
101
|
+
className
|
|
102
|
+
)}
|
|
103
|
+
data-focus={
|
|
104
|
+
typeof item.isFocused === "function"
|
|
105
|
+
? item.isFocused() || false
|
|
106
|
+
: undefined
|
|
107
|
+
}
|
|
108
|
+
data-folder={
|
|
109
|
+
typeof item.isFolder === "function"
|
|
110
|
+
? item.isFolder() || false
|
|
111
|
+
: undefined
|
|
112
|
+
}
|
|
113
|
+
data-selected={
|
|
114
|
+
typeof item.isSelected === "function"
|
|
115
|
+
? item.isSelected() || false
|
|
116
|
+
: undefined
|
|
117
|
+
}
|
|
118
|
+
data-drag-target={
|
|
119
|
+
typeof item.isDragTarget === "function"
|
|
120
|
+
? item.isDragTarget() || false
|
|
121
|
+
: undefined
|
|
122
|
+
}
|
|
123
|
+
data-search-match={
|
|
124
|
+
typeof item.isMatchingSearch === "function"
|
|
125
|
+
? item.isMatchingSearch() || false
|
|
126
|
+
: undefined
|
|
127
|
+
}
|
|
128
|
+
aria-expanded={item.isExpanded()}
|
|
129
|
+
{...otherProps}
|
|
130
|
+
>
|
|
131
|
+
{children}
|
|
132
|
+
</Comp>
|
|
133
|
+
</TreeContext.Provider>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
137
|
+
interface TreeItemLabelProps<T = any>
|
|
138
|
+
extends React.HTMLAttributes<HTMLSpanElement> {
|
|
139
|
+
item?: ItemInstance<T>;
|
|
140
|
+
}
|
|
141
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
142
|
+
function TreeItemLabel<T = any>({
|
|
143
|
+
item: propItem,
|
|
144
|
+
children,
|
|
145
|
+
className,
|
|
146
|
+
...props
|
|
147
|
+
}: TreeItemLabelProps<T>) {
|
|
148
|
+
const { currentItem } = useTreeContext<T>();
|
|
149
|
+
const item = propItem || currentItem;
|
|
150
|
+
|
|
151
|
+
if (!item) {
|
|
152
|
+
console.warn("TreeItemLabel: No item provided via props or context");
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return (
|
|
157
|
+
<span
|
|
158
|
+
data-slot="tree-item-label"
|
|
159
|
+
className={cn(
|
|
160
|
+
"flex items-center gap-1 rounded-sm bg-background px-2 py-1.5 text-sm transition-colors not-in-data-[folder=true]:ps-7 hover:bg-accent in-focus-visible:ring-[3px] in-focus-visible:ring-ring/50 in-data-[drag-target=true]:bg-accent in-data-[search-match=true]:bg-blue-400/20! in-data-[selected=true]:bg-accent in-data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
161
|
+
className
|
|
162
|
+
)}
|
|
163
|
+
{...props}
|
|
164
|
+
>
|
|
165
|
+
{item.isFolder() && (
|
|
166
|
+
<ChevronDownIcon className="size-4 text-muted-foreground in-aria-[expanded=false]:-rotate-90" />
|
|
167
|
+
)}
|
|
168
|
+
{children ||
|
|
169
|
+
(typeof item.getItemName === "function" ? item.getItemName() : null)}
|
|
170
|
+
</span>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function TreeDragLine({
|
|
175
|
+
className,
|
|
176
|
+
...props
|
|
177
|
+
}: React.HTMLAttributes<HTMLDivElement>) {
|
|
178
|
+
const { tree } = useTreeContext();
|
|
179
|
+
|
|
180
|
+
if (!tree || typeof tree.getDragLineStyle !== "function") {
|
|
181
|
+
console.warn(
|
|
182
|
+
"TreeDragLine: No tree provided via context or tree does not have getDragLineStyle method"
|
|
183
|
+
);
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const dragLine = tree.getDragLineStyle();
|
|
188
|
+
return (
|
|
189
|
+
<div
|
|
190
|
+
style={dragLine}
|
|
191
|
+
className={cn(
|
|
192
|
+
"absolute z-30 -mt-px h-0.5 w-[unset] bg-primary before:absolute before:-top-[3px] before:left-0 before:size-2 before:rounded-full before:border-2 before:border-primary before:bg-background",
|
|
193
|
+
className
|
|
194
|
+
)}
|
|
195
|
+
{...props}
|
|
196
|
+
/>
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export { Tree, TreeItem, TreeItemLabel, TreeDragLine };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/*! tscanify browser entry point v1.0.0 | MIT License */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is a specific entry point for browser environments.
|
|
5
|
+
* It only exports the browser-compatible implementation and avoids importing
|
|
6
|
+
* any Node.js-specific modules like 'canvas' or 'jsdom'.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Export the browser-specific implementation
|
|
10
|
+
export { TScanifyBrowser } from "./tscanify-browser";
|
|
11
|
+
|
|
12
|
+
// Re-export types
|
|
13
|
+
export * from "./types";
|
|
14
|
+
|
|
15
|
+
// Re-export opencv-ts for convenience
|
|
16
|
+
import cv from "opencv-ts";
|
|
17
|
+
import type { Mat, MatVector, Size, Rect } from "opencv-ts";
|
|
18
|
+
export { cv };
|
|
19
|
+
export type { Mat, MatVector, Size, Rect };
|
|
20
|
+
|
|
21
|
+
// Initialize OpenCV if needed (browser environment only)
|
|
22
|
+
if (typeof window !== "undefined") {
|
|
23
|
+
// Check if OpenCV is already available globally
|
|
24
|
+
if (
|
|
25
|
+
!(window as unknown as WindowWithCV).cv ||
|
|
26
|
+
!(window as unknown as WindowWithCV).cv.Mat
|
|
27
|
+
) {
|
|
28
|
+
(window as unknown as WindowWithCV).cv = cv;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Export the browser implementation as the default for convenience
|
|
33
|
+
import { TScanifyBrowser } from "./tscanify-browser";
|
|
34
|
+
import { WindowWithCV } from "./types";
|
|
35
|
+
export default TScanifyBrowser;
|
|
36
|
+
|
|
37
|
+
// Helper function to create a new instance and ensure OpenCV is ready
|
|
38
|
+
export function createScanner(): TScanifyBrowser {
|
|
39
|
+
const scanner = new TScanifyBrowser();
|
|
40
|
+
|
|
41
|
+
// If in browser, ensure OpenCV is available
|
|
42
|
+
if (typeof window !== "undefined") {
|
|
43
|
+
// Try to make cv from opencv-ts available globally if not already
|
|
44
|
+
if (
|
|
45
|
+
!(window as unknown as WindowWithCV).cv ||
|
|
46
|
+
!(window as unknown as WindowWithCV).cv.Mat
|
|
47
|
+
) {
|
|
48
|
+
if (cv && (cv as typeof cv).Mat) {
|
|
49
|
+
(window as unknown as WindowWithCV).cv = cv;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return scanner;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Helper function to check if OpenCV is loaded
|
|
58
|
+
export function isOpenCVReady(): boolean {
|
|
59
|
+
if (typeof window !== "undefined") {
|
|
60
|
+
return (
|
|
61
|
+
!!(window as unknown as WindowWithCV).cv &&
|
|
62
|
+
!!(window as unknown as WindowWithCV).cv.Mat
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
return !!cv && !!(cv as typeof cv).Mat;
|
|
66
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*! tscanify index v1.0.0 | MIT License */
|
|
2
|
+
|
|
3
|
+
// Export types
|
|
4
|
+
export * from "./types";
|
|
5
|
+
|
|
6
|
+
// Re-export opencv-ts for convenience
|
|
7
|
+
import type { Mat, MatVector, Size, Rect } from "opencv-ts";
|
|
8
|
+
export type { Mat, MatVector, Size, Rect };
|
|
9
|
+
|
|
10
|
+
// Dynamic imports based on environment
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
let TScanify: any;
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
let TScanifyNode: any;
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
let TScanifyBrowser: any;
|
|
17
|
+
|
|
18
|
+
// Detect browser environment
|
|
19
|
+
const isBrowser =
|
|
20
|
+
typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
21
|
+
|
|
22
|
+
// Use dynamic imports to avoid loading Node.js modules in the browser
|
|
23
|
+
if (isBrowser) {
|
|
24
|
+
// In browser environments, only import the browser version
|
|
25
|
+
import("./tscanify-browser").then((module) => {
|
|
26
|
+
TScanifyBrowser = module.TScanifyBrowser;
|
|
27
|
+
TScanify = TScanifyBrowser;
|
|
28
|
+
});
|
|
29
|
+
} else {
|
|
30
|
+
// In Node.js environments, we can safely import the Node versions
|
|
31
|
+
import("./tscanify").then((module) => {
|
|
32
|
+
TScanify = module.TScanify;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Use dynamic import approach in function form for better browser bundling
|
|
37
|
+
export async function createTScanify() {
|
|
38
|
+
if (isBrowser) {
|
|
39
|
+
const { TScanifyBrowser } = await import("./tscanify-browser");
|
|
40
|
+
return new TScanifyBrowser();
|
|
41
|
+
} else {
|
|
42
|
+
const { TScanify } = await import("./tscanify");
|
|
43
|
+
return new TScanify();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Export for backward compatibility
|
|
48
|
+
export { TScanify, TScanifyBrowser, TScanifyNode };
|
|
49
|
+
|
|
50
|
+
// Default export for backward compatibility
|
|
51
|
+
export default TScanify;
|