@teja-app/ui 0.0.1 → 0.0.2
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/dist/components/Badge/Badge.d.ts +13 -0
- package/dist/components/Badge/Badge.d.ts.map +1 -0
- package/dist/components/Badge/Badge.types.d.ts +12 -0
- package/dist/components/Badge/Badge.types.d.ts.map +1 -0
- package/dist/components/Badge/index.d.ts +3 -0
- package/dist/components/Badge/index.d.ts.map +1 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +18 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts.map +1 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.types.d.ts +20 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.types.d.ts.map +1 -0
- package/dist/components/Breadcrumbs/index.d.ts +3 -0
- package/dist/components/Breadcrumbs/index.d.ts.map +1 -0
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/Card/Card.d.ts +18 -0
- package/dist/components/Card/Card.d.ts.map +1 -0
- package/dist/components/Card/Card.types.d.ts +14 -0
- package/dist/components/Card/Card.types.d.ts.map +1 -0
- package/dist/components/Card/index.d.ts +3 -0
- package/dist/components/Card/index.d.ts.map +1 -0
- package/dist/components/Checkbox/Checkbox.d.ts +13 -0
- package/dist/components/Checkbox/Checkbox.d.ts.map +1 -0
- package/dist/components/Checkbox/Checkbox.types.d.ts +19 -0
- package/dist/components/Checkbox/Checkbox.types.d.ts.map +1 -0
- package/dist/components/Checkbox/index.d.ts +3 -0
- package/dist/components/Checkbox/index.d.ts.map +1 -0
- package/dist/components/Combobox/Combobox.d.ts +24 -0
- package/dist/components/Combobox/Combobox.d.ts.map +1 -0
- package/dist/components/Combobox/Combobox.types.d.ts +41 -0
- package/dist/components/Combobox/Combobox.types.d.ts.map +1 -0
- package/dist/components/Combobox/index.d.ts +3 -0
- package/dist/components/Combobox/index.d.ts.map +1 -0
- package/dist/components/ConfirmDialog/ConfirmDialog.d.ts +23 -0
- package/dist/components/ConfirmDialog/ConfirmDialog.d.ts.map +1 -0
- package/dist/components/ConfirmDialog/ConfirmDialog.types.d.ts +22 -0
- package/dist/components/ConfirmDialog/ConfirmDialog.types.d.ts.map +1 -0
- package/dist/components/ConfirmDialog/index.d.ts +3 -0
- package/dist/components/ConfirmDialog/index.d.ts.map +1 -0
- package/dist/components/Drawer/Drawer.d.ts +27 -0
- package/dist/components/Drawer/Drawer.d.ts.map +1 -0
- package/dist/components/Drawer/Drawer.types.d.ts +23 -0
- package/dist/components/Drawer/Drawer.types.d.ts.map +1 -0
- package/dist/components/Drawer/index.d.ts +3 -0
- package/dist/components/Drawer/index.d.ts.map +1 -0
- package/dist/components/EmptyState/EmptyState.d.ts +34 -0
- package/dist/components/EmptyState/EmptyState.d.ts.map +1 -0
- package/dist/components/EmptyState/EmptyState.types.d.ts +17 -0
- package/dist/components/EmptyState/EmptyState.types.d.ts.map +1 -0
- package/dist/components/EmptyState/index.d.ts +3 -0
- package/dist/components/EmptyState/index.d.ts.map +1 -0
- package/dist/components/Input/Input.d.ts +13 -0
- package/dist/components/Input/Input.d.ts.map +1 -0
- package/dist/components/Input/Input.types.d.ts +18 -0
- package/dist/components/Input/Input.types.d.ts.map +1 -0
- package/dist/components/Input/index.d.ts +3 -0
- package/dist/components/Input/index.d.ts.map +1 -0
- package/dist/components/Modal/Modal.d.ts +28 -0
- package/dist/components/Modal/Modal.d.ts.map +1 -0
- package/dist/components/Modal/Modal.types.d.ts +27 -0
- package/dist/components/Modal/Modal.types.d.ts.map +1 -0
- package/dist/components/Modal/index.d.ts +3 -0
- package/dist/components/Modal/index.d.ts.map +1 -0
- package/dist/components/MultiSelect/MultiSelect.d.ts +26 -0
- package/dist/components/MultiSelect/MultiSelect.d.ts.map +1 -0
- package/dist/components/MultiSelect/MultiSelect.types.d.ts +49 -0
- package/dist/components/MultiSelect/MultiSelect.types.d.ts.map +1 -0
- package/dist/components/MultiSelect/index.d.ts +3 -0
- package/dist/components/MultiSelect/index.d.ts.map +1 -0
- package/dist/components/Pagination/Pagination.d.ts +35 -0
- package/dist/components/Pagination/Pagination.d.ts.map +1 -0
- package/dist/components/Pagination/Pagination.types.d.ts +29 -0
- package/dist/components/Pagination/Pagination.types.d.ts.map +1 -0
- package/dist/components/Pagination/index.d.ts +3 -0
- package/dist/components/Pagination/index.d.ts.map +1 -0
- package/dist/components/PasswordInput/PasswordInput.d.ts +12 -0
- package/dist/components/PasswordInput/PasswordInput.d.ts.map +1 -0
- package/dist/components/PasswordInput/PasswordInput.types.d.ts +14 -0
- package/dist/components/PasswordInput/PasswordInput.types.d.ts.map +1 -0
- package/dist/components/PasswordInput/index.d.ts +3 -0
- package/dist/components/PasswordInput/index.d.ts.map +1 -0
- package/dist/components/Radio/Radio.d.ts +12 -0
- package/dist/components/Radio/Radio.d.ts.map +1 -0
- package/dist/components/Radio/Radio.types.d.ts +45 -0
- package/dist/components/Radio/Radio.types.d.ts.map +1 -0
- package/dist/components/Radio/RadioGroup.d.ts +23 -0
- package/dist/components/Radio/RadioGroup.d.ts.map +1 -0
- package/dist/components/Radio/index.d.ts +4 -0
- package/dist/components/Radio/index.d.ts.map +1 -0
- package/dist/components/Select/Select.d.ts +22 -0
- package/dist/components/Select/Select.d.ts.map +1 -0
- package/dist/components/Select/Select.types.d.ts +37 -0
- package/dist/components/Select/Select.types.d.ts.map +1 -0
- package/dist/components/Select/index.d.ts +3 -0
- package/dist/components/Select/index.d.ts.map +1 -0
- package/dist/components/Skeleton/Skeleton.d.ts +22 -0
- package/dist/components/Skeleton/Skeleton.d.ts.map +1 -0
- package/dist/components/Skeleton/Skeleton.types.d.ts +17 -0
- package/dist/components/Skeleton/Skeleton.types.d.ts.map +1 -0
- package/dist/components/Skeleton/index.d.ts +3 -0
- package/dist/components/Skeleton/index.d.ts.map +1 -0
- package/dist/components/Spinner/Spinner.d.ts +13 -0
- package/dist/components/Spinner/Spinner.d.ts.map +1 -0
- package/dist/components/Spinner/Spinner.types.d.ts +12 -0
- package/dist/components/Spinner/Spinner.types.d.ts.map +1 -0
- package/dist/components/Spinner/index.d.ts +3 -0
- package/dist/components/Spinner/index.d.ts.map +1 -0
- package/dist/components/Table/Table.d.ts +44 -0
- package/dist/components/Table/Table.d.ts.map +1 -0
- package/dist/components/Table/Table.types.d.ts +33 -0
- package/dist/components/Table/Table.types.d.ts.map +1 -0
- package/dist/components/Table/index.d.ts +3 -0
- package/dist/components/Table/index.d.ts.map +1 -0
- package/dist/components/Tabs/Tabs.d.ts +43 -0
- package/dist/components/Tabs/Tabs.d.ts.map +1 -0
- package/dist/components/Tabs/Tabs.types.d.ts +38 -0
- package/dist/components/Tabs/Tabs.types.d.ts.map +1 -0
- package/dist/components/Tabs/index.d.ts +3 -0
- package/dist/components/Tabs/index.d.ts.map +1 -0
- package/dist/components/Textarea/Textarea.d.ts +13 -0
- package/dist/components/Textarea/Textarea.d.ts.map +1 -0
- package/dist/components/Textarea/Textarea.types.d.ts +20 -0
- package/dist/components/Textarea/Textarea.types.d.ts.map +1 -0
- package/dist/components/Textarea/index.d.ts +3 -0
- package/dist/components/Textarea/index.d.ts.map +1 -0
- package/dist/components/Toggle/Toggle.d.ts +20 -0
- package/dist/components/Toggle/Toggle.d.ts.map +1 -0
- package/dist/components/Toggle/Toggle.types.d.ts +20 -0
- package/dist/components/Toggle/Toggle.types.d.ts.map +1 -0
- package/dist/components/Toggle/index.d.ts +3 -0
- package/dist/components/Toggle/index.d.ts.map +1 -0
- package/dist/components/index.d.ts +21 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/hooks/index.cjs +7 -0
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.ts +6 -9
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +8 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useDebounce.d.ts +65 -0
- package/dist/hooks/useDebounce.d.ts.map +1 -0
- package/dist/hooks/useDebounce.test.d.ts +2 -0
- package/dist/hooks/useDebounce.test.d.ts.map +1 -0
- package/dist/hooks/useSelection.d.ts +84 -0
- package/dist/hooks/useSelection.d.ts.map +1 -0
- package/dist/hooks/useSelection.test.d.ts +2 -0
- package/dist/hooks/useSelection.test.d.ts.map +1 -0
- package/dist/hooks/useTable.d.ts +91 -0
- package/dist/hooks/useTable.d.ts.map +1 -0
- package/dist/hooks/useTable.test.d.ts +2 -0
- package/dist/hooks/useTable.test.d.ts.map +1 -0
- package/dist/index.cjs +9451 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9435 -11
- package/dist/index.js.map +1 -1
- package/dist/tailwind/colors.d.ts +28 -2
- package/dist/tailwind/colors.d.ts.map +1 -1
- package/dist/tailwind/index.cjs +33 -3
- package/dist/tailwind/index.cjs.map +1 -1
- package/dist/tailwind/index.js +33 -3
- package/dist/tailwind/index.js.map +1 -1
- package/dist/useSelection-BK6u5Ezx.js +359 -0
- package/dist/useSelection-BK6u5Ezx.js.map +1 -0
- package/dist/useSelection-DyXUWnGK.cjs +358 -0
- package/dist/useSelection-DyXUWnGK.cjs.map +1 -0
- package/package.json +4 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { TabsProps, TabPanelsProps } from './Tabs.types';
|
|
2
|
+
/**
|
|
3
|
+
* Tabs component for sectioned content navigation.
|
|
4
|
+
* Built on Headless UI Tab for accessibility.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* const [activeTab, setActiveTab] = useState('overview');
|
|
9
|
+
*
|
|
10
|
+
* <Tabs
|
|
11
|
+
* tabs={[
|
|
12
|
+
* { key: 'overview', label: 'Overview' },
|
|
13
|
+
* { key: 'notes', label: 'Notes', count: 12 },
|
|
14
|
+
* { key: 'billing', label: 'Billing' },
|
|
15
|
+
* ]}
|
|
16
|
+
* activeTab={activeTab}
|
|
17
|
+
* onChange={setActiveTab}
|
|
18
|
+
* />
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function Tabs({ tabs, activeTab, onChange, fullWidth, variant, size, className, 'aria-label': ariaLabel, ...props }: TabsProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare namespace Tabs {
|
|
23
|
+
var displayName: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Tab panels component for rendering tab content.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* <TabPanels tabs={tabs} activeTab={activeTab}>
|
|
31
|
+
* {{
|
|
32
|
+
* overview: <OverviewPanel />,
|
|
33
|
+
* notes: <NotesPanel />,
|
|
34
|
+
* billing: <BillingPanel />,
|
|
35
|
+
* }}
|
|
36
|
+
* </TabPanels>
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function TabContentPanels({ tabs: _tabs, activeTab, children, className, isLoading, ...props }: TabPanelsProps): import("react/jsx-runtime").JSX.Element;
|
|
40
|
+
export declare namespace TabContentPanels {
|
|
41
|
+
var displayName: string;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=Tabs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../../src/components/Tabs/Tabs.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAQ9D;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,IAAI,CAAC,EACnB,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,SAAiB,EACjB,OAAmB,EACnB,IAAW,EACX,SAAS,EACT,YAAY,EAAE,SAA6B,EAC3C,GAAG,KAAK,EACT,EAAE,SAAS,2CA2EX;yBArFe,IAAI;;;AAyFpB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,IAAI,EAAE,KAAK,EACX,SAAS,EACT,QAAQ,EACR,SAAS,EACT,SAAiB,EACjB,GAAG,KAAK,EACT,EAAE,cAAc,2CAiBhB;yBAxBe,gBAAgB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export interface TabItem {
|
|
3
|
+
/** Unique key for the tab */
|
|
4
|
+
key: string;
|
|
5
|
+
/** Tab label */
|
|
6
|
+
label: ReactNode;
|
|
7
|
+
/** Optional count/badge */
|
|
8
|
+
count?: number;
|
|
9
|
+
/** Disabled state */
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface TabsProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
13
|
+
/** Tab items */
|
|
14
|
+
tabs: TabItem[];
|
|
15
|
+
/** Currently active tab key */
|
|
16
|
+
activeTab?: string;
|
|
17
|
+
/** Callback when tab changes */
|
|
18
|
+
onChange?: (key: string) => void;
|
|
19
|
+
/** Full width tabs (stretch to fill) */
|
|
20
|
+
fullWidth?: boolean;
|
|
21
|
+
/** Visual variant */
|
|
22
|
+
variant?: 'default' | 'pills';
|
|
23
|
+
/** Tab size */
|
|
24
|
+
size?: 'sm' | 'md' | 'lg';
|
|
25
|
+
/** Accessible label for the tab list (required for a11y) */
|
|
26
|
+
'aria-label'?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface TabPanelsProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
29
|
+
/** Tab items (must match tabs prop) */
|
|
30
|
+
tabs: TabItem[];
|
|
31
|
+
/** Currently active tab key */
|
|
32
|
+
activeTab?: string;
|
|
33
|
+
/** Panel content keyed by tab key */
|
|
34
|
+
children: Record<string, ReactNode>;
|
|
35
|
+
/** Shows loading spinner overlay on content */
|
|
36
|
+
isLoading?: boolean;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=Tabs.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Tabs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAChD,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TextareaProps } from './Textarea.types';
|
|
2
|
+
/**
|
|
3
|
+
* Textarea component with label, error states, and optional character count.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* <Textarea label="Notes" placeholder="Enter session notes..." />
|
|
8
|
+
* <Textarea label="Description" maxLength={500} showCharCount />
|
|
9
|
+
* <Textarea label="Content" autoResize />
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare const Textarea: import("react").ForwardRefExoticComponent<TextareaProps & import("react").RefAttributes<HTMLTextAreaElement>>;
|
|
13
|
+
//# sourceMappingURL=Textarea.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Textarea.d.ts","sourceRoot":"","sources":["../../../src/components/Textarea/Textarea.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD;;;;;;;;;GASG;AACH,eAAO,MAAM,QAAQ,+GA6JpB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TextareaHTMLAttributes } from 'react';
|
|
2
|
+
export interface TextareaProps extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'rows'> {
|
|
3
|
+
/** Textarea label displayed above the field */
|
|
4
|
+
label?: string;
|
|
5
|
+
/** Error message - displays in red below the field */
|
|
6
|
+
error?: string;
|
|
7
|
+
/** Helper text - displays below the field (hidden when error is present) */
|
|
8
|
+
helperText?: string;
|
|
9
|
+
/** Makes textarea take full width of container */
|
|
10
|
+
fullWidth?: boolean;
|
|
11
|
+
/** Number of visible text lines (default: 4) */
|
|
12
|
+
rows?: number;
|
|
13
|
+
/** Show character count when maxLength is set */
|
|
14
|
+
showCharCount?: boolean;
|
|
15
|
+
/** Enable auto-resize based on content */
|
|
16
|
+
autoResize?: boolean;
|
|
17
|
+
/** Shows loading spinner in corner */
|
|
18
|
+
isLoading?: boolean;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=Textarea.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Textarea.types.d.ts","sourceRoot":"","sources":["../../../src/components/Textarea/Textarea.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,OAAO,CAAC;AAEpD,MAAM,WAAW,aACf,SAAQ,IAAI,CAAC,sBAAsB,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IACjE,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,0CAA0C;IAC1C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,sCAAsC;IACtC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Textarea/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ToggleProps } from './Toggle.types';
|
|
2
|
+
/**
|
|
3
|
+
* Toggle component for boolean settings.
|
|
4
|
+
* Built on Headless UI Switch for accessibility.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* <Toggle
|
|
9
|
+
* enabled={notifications}
|
|
10
|
+
* onChange={setNotifications}
|
|
11
|
+
* label="Enable notifications"
|
|
12
|
+
* description="Receive email notifications for important updates"
|
|
13
|
+
* />
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function Toggle({ enabled, onChange, label, description, disabled, size, className, isLoading, }: ToggleProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare namespace Toggle {
|
|
18
|
+
var displayName: string;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=Toggle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toggle.d.ts","sourceRoot":"","sources":["../../../src/components/Toggle/Toggle.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAc,MAAM,gBAAgB,CAAC;AAqB9D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,MAAM,CAAC,EACrB,OAAO,EACP,QAAQ,EACR,KAAK,EACL,WAAW,EACX,QAAgB,EAChB,IAAW,EACX,SAAS,EACT,SAAiB,GAClB,EAAE,WAAW,2CAkEb;yBA3Ee,MAAM"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type ToggleSize = 'sm' | 'md' | 'lg';
|
|
2
|
+
export interface ToggleProps {
|
|
3
|
+
/** Controlled enabled state */
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
/** Callback when toggle state changes */
|
|
6
|
+
onChange: (enabled: boolean) => void;
|
|
7
|
+
/** Toggle label */
|
|
8
|
+
label?: string;
|
|
9
|
+
/** Description text below label */
|
|
10
|
+
description?: string;
|
|
11
|
+
/** Disabled state */
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
/** Toggle size */
|
|
14
|
+
size?: ToggleSize;
|
|
15
|
+
/** Additional class name */
|
|
16
|
+
className?: string;
|
|
17
|
+
/** Shows loading spinner and disables toggle */
|
|
18
|
+
isLoading?: boolean;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=Toggle.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toggle.types.d.ts","sourceRoot":"","sources":["../../../src/components/Toggle/Toggle.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5C,MAAM,WAAW,WAAW;IAC1B,+BAA+B;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,yCAAyC;IACzC,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACrC,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kBAAkB;IAClB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gDAAgD;IAChD,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Toggle/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -2,4 +2,25 @@
|
|
|
2
2
|
* Component exports for @teja-app/ui
|
|
3
3
|
*/
|
|
4
4
|
export * from './Button';
|
|
5
|
+
export * from './Input';
|
|
6
|
+
export * from './PasswordInput';
|
|
7
|
+
export * from './Textarea';
|
|
8
|
+
export * from './Select';
|
|
9
|
+
export * from './Modal';
|
|
10
|
+
export * from './Drawer';
|
|
11
|
+
export * from './ConfirmDialog';
|
|
12
|
+
export * from './Card';
|
|
13
|
+
export * from './Checkbox';
|
|
14
|
+
export * from './Radio';
|
|
15
|
+
export * from './Toggle';
|
|
16
|
+
export * from './Combobox';
|
|
17
|
+
export * from './Badge';
|
|
18
|
+
export * from './Table';
|
|
19
|
+
export * from './Tabs';
|
|
20
|
+
export * from './Breadcrumbs';
|
|
21
|
+
export * from './Spinner';
|
|
22
|
+
export * from './Skeleton';
|
|
23
|
+
export * from './EmptyState';
|
|
24
|
+
export * from './Pagination';
|
|
25
|
+
export * from './MultiSelect';
|
|
5
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
|
package/dist/hooks/index.cjs
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const useSelection = require("../useSelection-DyXUWnGK.cjs");
|
|
4
|
+
exports.useDebounce = useSelection.useDebounce;
|
|
5
|
+
exports.useDebouncedCallback = useSelection.useDebouncedCallback;
|
|
6
|
+
exports.useDebouncedCallbackWithControl = useSelection.useDebouncedCallbackWithControl;
|
|
7
|
+
exports.useSelection = useSelection.useSelection;
|
|
8
|
+
exports.useTable = useSelection.useTable;
|
|
2
9
|
//# sourceMappingURL=index.cjs.map
|
package/dist/hooks/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* ```
|
|
8
|
-
*/
|
|
9
|
-
export {};
|
|
1
|
+
export { useDebounce, useDebouncedCallback, useDebouncedCallbackWithControl } from './useDebounce';
|
|
2
|
+
export { useTable } from './useTable';
|
|
3
|
+
export type { UseTableOptions, UseTableReturn, SortState } from './useTable';
|
|
4
|
+
export type { SortDirection as TableSortDirection } from './useTable';
|
|
5
|
+
export { useSelection } from './useSelection';
|
|
6
|
+
export type { UseSelectionOptions, UseSelectionReturn } from './useSelection';
|
|
10
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AACnG,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC7E,YAAY,EAAE,aAAa,IAAI,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/hooks/index.js
CHANGED
package/dist/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debounces a value, returning the debounced value after the specified delay.
|
|
3
|
+
*
|
|
4
|
+
* @param value - The value to debounce
|
|
5
|
+
* @param delay - The delay in milliseconds (default: 300ms)
|
|
6
|
+
* @returns The debounced value
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* const [searchTerm, setSearchTerm] = useState('');
|
|
11
|
+
* const debouncedSearch = useDebounce(searchTerm, 300);
|
|
12
|
+
*
|
|
13
|
+
* useEffect(() => {
|
|
14
|
+
* // This will only run after the user stops typing for 300ms
|
|
15
|
+
* fetchResults(debouncedSearch);
|
|
16
|
+
* }, [debouncedSearch]);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function useDebounce<T>(value: T, delay?: number): T;
|
|
20
|
+
/**
|
|
21
|
+
* Returns a debounced version of the provided callback function.
|
|
22
|
+
*
|
|
23
|
+
* @param callback - The function to debounce
|
|
24
|
+
* @param delay - The delay in milliseconds (default: 300ms)
|
|
25
|
+
* @returns A debounced version of the callback
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* const handleSearch = useDebouncedCallback((query: string) => {
|
|
30
|
+
* fetchSearchResults(query);
|
|
31
|
+
* }, 300);
|
|
32
|
+
*
|
|
33
|
+
* // In your component:
|
|
34
|
+
* <input onChange={(e) => handleSearch(e.target.value)} />
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function useDebouncedCallback<T extends (...args: Parameters<T>) => ReturnType<T>>(callback: T, delay?: number): (...args: Parameters<T>) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Returns a debounced callback with cancel functionality.
|
|
40
|
+
*
|
|
41
|
+
* @param callback - The function to debounce
|
|
42
|
+
* @param delay - The delay in milliseconds (default: 300ms)
|
|
43
|
+
* @returns An object with the debounced callback and cancel/flush methods
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* const { debouncedFn, cancel, flush } = useDebouncedCallbackWithControl(
|
|
48
|
+
* (query: string) => fetchResults(query),
|
|
49
|
+
* 300
|
|
50
|
+
* );
|
|
51
|
+
*
|
|
52
|
+
* // Cancel pending execution
|
|
53
|
+
* cancel();
|
|
54
|
+
*
|
|
55
|
+
* // Execute immediately
|
|
56
|
+
* flush();
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function useDebouncedCallbackWithControl<T extends (...args: Parameters<T>) => ReturnType<T>>(callback: T, delay?: number): {
|
|
60
|
+
debouncedFn: (...args: Parameters<T>) => void;
|
|
61
|
+
cancel: () => void;
|
|
62
|
+
flush: () => void;
|
|
63
|
+
isPending: () => boolean;
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=useDebounce.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDebounce.d.ts","sourceRoot":"","sources":["../../src/hooks/useDebounce.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,GAAE,MAAY,GAAG,CAAC,CAc/D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,EACtF,QAAQ,EAAE,CAAC,EACX,KAAK,GAAE,MAAY,GAClB,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAgClC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,+BAA+B,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,EACjG,QAAQ,EAAE,CAAC,EACX,KAAK,GAAE,MAAY,GAClB;IACD,WAAW,EAAE,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAC9C,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,SAAS,EAAE,MAAM,OAAO,CAAC;CAC1B,CAyDA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDebounce.test.d.ts","sourceRoot":"","sources":["../../src/hooks/useDebounce.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export interface UseSelectionOptions<T, K extends string | number = string> {
|
|
2
|
+
/** Array of items to select from */
|
|
3
|
+
items: T[];
|
|
4
|
+
/** Function to get the unique identifier from an item */
|
|
5
|
+
getItemId: (item: T) => K;
|
|
6
|
+
/** Initial selected IDs */
|
|
7
|
+
initialSelected?: K[];
|
|
8
|
+
/** Callback when selection changes */
|
|
9
|
+
onSelectionChange?: (selectedIds: K[]) => void;
|
|
10
|
+
/** Optional filter for selectable items (e.g., exclude disabled items) */
|
|
11
|
+
isSelectable?: (item: T) => boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface UseSelectionReturn<K extends string | number = string> {
|
|
14
|
+
/** Currently selected IDs */
|
|
15
|
+
selectedIds: K[];
|
|
16
|
+
/** Set of selected IDs for O(1) lookup */
|
|
17
|
+
selectedSet: Set<K>;
|
|
18
|
+
/** Number of selected items */
|
|
19
|
+
selectedCount: number;
|
|
20
|
+
/** Whether all selectable items are selected */
|
|
21
|
+
allSelected: boolean;
|
|
22
|
+
/** Whether some (but not all) items are selected */
|
|
23
|
+
someSelected: boolean;
|
|
24
|
+
/** Whether no items are selected */
|
|
25
|
+
noneSelected: boolean;
|
|
26
|
+
/** Check if a specific item is selected */
|
|
27
|
+
isSelected: (id: K) => boolean;
|
|
28
|
+
/** Toggle selection for a single item */
|
|
29
|
+
toggle: (id: K) => void;
|
|
30
|
+
/** Select a single item */
|
|
31
|
+
select: (id: K) => void;
|
|
32
|
+
/** Deselect a single item */
|
|
33
|
+
deselect: (id: K) => void;
|
|
34
|
+
/** Select all selectable items */
|
|
35
|
+
selectAll: () => void;
|
|
36
|
+
/** Clear all selections */
|
|
37
|
+
clearSelection: () => void;
|
|
38
|
+
/** Toggle between select all and clear all */
|
|
39
|
+
toggleAll: () => void;
|
|
40
|
+
/** Select multiple items */
|
|
41
|
+
selectMany: (ids: K[]) => void;
|
|
42
|
+
/** Deselect multiple items */
|
|
43
|
+
deselectMany: (ids: K[]) => void;
|
|
44
|
+
/** Replace selection with new IDs */
|
|
45
|
+
setSelection: (ids: K[]) => void;
|
|
46
|
+
/** Get selected items from the original array */
|
|
47
|
+
getSelectedItems: () => unknown[];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Hook for managing batch selection in tables and lists.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```tsx
|
|
54
|
+
* const {
|
|
55
|
+
* selectedIds,
|
|
56
|
+
* allSelected,
|
|
57
|
+
* someSelected,
|
|
58
|
+
* isSelected,
|
|
59
|
+
* toggle,
|
|
60
|
+
* selectAll,
|
|
61
|
+
* clearSelection,
|
|
62
|
+
* toggleAll,
|
|
63
|
+
* } = useSelection({
|
|
64
|
+
* items: users,
|
|
65
|
+
* getItemId: (user) => user.id,
|
|
66
|
+
* isSelectable: (user) => !user.disabled,
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* // In table header:
|
|
70
|
+
* <Checkbox
|
|
71
|
+
* checked={allSelected}
|
|
72
|
+
* indeterminate={someSelected && !allSelected}
|
|
73
|
+
* onChange={toggleAll}
|
|
74
|
+
* />
|
|
75
|
+
*
|
|
76
|
+
* // In table row:
|
|
77
|
+
* <Checkbox
|
|
78
|
+
* checked={isSelected(user.id)}
|
|
79
|
+
* onChange={() => toggle(user.id)}
|
|
80
|
+
* />
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export declare function useSelection<T, K extends string | number = string>({ items, getItemId, initialSelected, onSelectionChange, isSelectable, }: UseSelectionOptions<T, K>): UseSelectionReturn<K>;
|
|
84
|
+
//# sourceMappingURL=useSelection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSelection.d.ts","sourceRoot":"","sources":["../../src/hooks/useSelection.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,mBAAmB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM;IACxE,oCAAoC;IACpC,KAAK,EAAE,CAAC,EAAE,CAAC;IAEX,yDAAyD;IACzD,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;IAE1B,2BAA2B;IAC3B,eAAe,CAAC,EAAE,CAAC,EAAE,CAAC;IAEtB,sCAAsC;IACtC,iBAAiB,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IAE/C,0EAA0E;IAC1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;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,EAClE,KAAK,EACL,SAAS,EACT,eAAoB,EACpB,iBAAiB,EACjB,YAAyB,GAC1B,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CA8InD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSelection.test.d.ts","sourceRoot":"","sources":["../../src/hooks/useSelection.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export type SortDirection = 'asc' | 'desc';
|
|
2
|
+
export interface SortState {
|
|
3
|
+
column: string | null;
|
|
4
|
+
direction: SortDirection;
|
|
5
|
+
}
|
|
6
|
+
export interface UseTableOptions<T> {
|
|
7
|
+
/** The data array to manage */
|
|
8
|
+
data: T[];
|
|
9
|
+
/** Initial sort column */
|
|
10
|
+
initialSortColumn?: string;
|
|
11
|
+
/** Initial sort direction */
|
|
12
|
+
initialSortDirection?: SortDirection;
|
|
13
|
+
/** Initial page (1-based) */
|
|
14
|
+
initialPage?: number;
|
|
15
|
+
/** Initial page size */
|
|
16
|
+
initialPageSize?: number;
|
|
17
|
+
/** Enable server-side mode (disables client-side sorting/pagination) */
|
|
18
|
+
serverSide?: boolean;
|
|
19
|
+
/** Callback when sort changes (server-side mode) */
|
|
20
|
+
onSort?: (column: string, direction: SortDirection) => void;
|
|
21
|
+
/** Callback when page changes (server-side mode) */
|
|
22
|
+
onPageChange?: (page: number) => void;
|
|
23
|
+
/** Callback when page size changes (server-side mode) */
|
|
24
|
+
onPageSizeChange?: (pageSize: number) => void;
|
|
25
|
+
/** Custom sort function for client-side sorting */
|
|
26
|
+
sortFn?: (data: T[], column: string, direction: SortDirection) => T[];
|
|
27
|
+
/** Key extractor for getting sortable value from item */
|
|
28
|
+
getValueByColumn?: (item: T, column: string) => unknown;
|
|
29
|
+
/** Total items count (for server-side pagination) */
|
|
30
|
+
totalItems?: number;
|
|
31
|
+
}
|
|
32
|
+
export interface UseTableReturn<T> {
|
|
33
|
+
/** Current page data (paginated if not server-side) */
|
|
34
|
+
pageData: T[];
|
|
35
|
+
/** All sorted data (before pagination) */
|
|
36
|
+
sortedData: T[];
|
|
37
|
+
/** Current sort column */
|
|
38
|
+
sortColumn: string | null;
|
|
39
|
+
/** Current sort direction */
|
|
40
|
+
sortDirection: SortDirection;
|
|
41
|
+
/** Handle sort - toggles direction if same column, resets to asc if different */
|
|
42
|
+
handleSort: (column: string) => void;
|
|
43
|
+
/** Set sort directly */
|
|
44
|
+
setSort: (column: string | null, direction: SortDirection) => void;
|
|
45
|
+
/** Current page (1-based) */
|
|
46
|
+
currentPage: number;
|
|
47
|
+
/** Current page size */
|
|
48
|
+
pageSize: number;
|
|
49
|
+
/** Total number of pages */
|
|
50
|
+
totalPages: number;
|
|
51
|
+
/** Total items count */
|
|
52
|
+
totalItems: number;
|
|
53
|
+
/** Go to specific page */
|
|
54
|
+
goToPage: (page: number) => void;
|
|
55
|
+
/** Go to next page */
|
|
56
|
+
nextPage: () => void;
|
|
57
|
+
/** Go to previous page */
|
|
58
|
+
previousPage: () => void;
|
|
59
|
+
/** Set page size */
|
|
60
|
+
setPageSize: (size: number) => void;
|
|
61
|
+
/** Reset to initial state */
|
|
62
|
+
reset: () => void;
|
|
63
|
+
/** Whether currently on first page */
|
|
64
|
+
isFirstPage: boolean;
|
|
65
|
+
/** Whether currently on last page */
|
|
66
|
+
isLastPage: boolean;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Hook for managing table state including sorting and pagination.
|
|
70
|
+
* Supports both client-side and server-side modes.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```tsx
|
|
74
|
+
* // Client-side (default)
|
|
75
|
+
* const { pageData, sortColumn, sortDirection, handleSort, currentPage, goToPage } = useTable({
|
|
76
|
+
* data: users,
|
|
77
|
+
* initialPageSize: 10,
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* // Server-side
|
|
81
|
+
* const { handleSort, goToPage } = useTable({
|
|
82
|
+
* data: users,
|
|
83
|
+
* serverSide: true,
|
|
84
|
+
* totalItems: 1000,
|
|
85
|
+
* onSort: (col, dir) => fetchUsers({ sort: col, order: dir }),
|
|
86
|
+
* onPageChange: (page) => fetchUsers({ page }),
|
|
87
|
+
* });
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare function useTable<T>({ data, initialSortColumn, initialSortDirection, initialPage, initialPageSize, serverSide, onSort, onPageChange, onPageSizeChange, sortFn, getValueByColumn, totalItems: totalItemsProp, }: UseTableOptions<T>): UseTableReturn<T>;
|
|
91
|
+
//# sourceMappingURL=useTable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTable.d.ts","sourceRoot":"","sources":["../../src/hooks/useTable.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,CAAC;AAE3C,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,aAAa,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,+BAA+B;IAC/B,IAAI,EAAE,CAAC,EAAE,CAAC;IAEV,0BAA0B;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,6BAA6B;IAC7B,oBAAoB,CAAC,EAAE,aAAa,CAAC;IAErC,6BAA6B;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,wBAAwB;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,wEAAwE;IACxE,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,oDAAoD;IACpD,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,K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