tekivex-ui 2.2.0 → 2.5.1
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/TkxForm-BWK4LqY3.js +1461 -0
- package/dist/TkxForm-ljQjX7KD.cjs +15 -0
- package/dist/charts.cjs +1 -0
- package/dist/charts.js +480 -0
- package/dist/headless.cjs +1 -0
- package/dist/headless.js +258 -0
- package/dist/index-BINBzXuY.cjs +2 -0
- package/dist/index-eT_U4qB2.js +512 -0
- package/dist/index.cjs +63 -14
- package/dist/index.d.ts +33 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11396 -6336
- package/dist/src/charts/TkxAreaChart.d.ts +29 -0
- package/dist/src/charts/TkxAreaChart.d.ts.map +1 -0
- package/dist/src/charts/TkxBarChart.d.ts +28 -0
- package/dist/src/charts/TkxBarChart.d.ts.map +1 -0
- package/dist/src/charts/TkxDonutChart.d.ts +23 -0
- package/dist/src/charts/TkxDonutChart.d.ts.map +1 -0
- package/dist/src/charts/TkxLineChart.d.ts +35 -0
- package/dist/src/charts/TkxLineChart.d.ts.map +1 -0
- package/dist/src/charts/TkxPieChart.d.ts +19 -0
- package/dist/src/charts/TkxPieChart.d.ts.map +1 -0
- package/dist/src/charts/TkxRadarChart.d.ts +20 -0
- package/dist/src/charts/TkxRadarChart.d.ts.map +1 -0
- package/dist/src/charts/TkxScatterChart.d.ts +28 -0
- package/dist/src/charts/TkxScatterChart.d.ts.map +1 -0
- package/dist/src/charts/index.d.ts +15 -0
- package/dist/src/charts/index.d.ts.map +1 -0
- package/dist/src/charts/shared.d.ts +33 -0
- package/dist/src/charts/shared.d.ts.map +1 -0
- package/dist/src/components/TkxAffix.d.ts +10 -0
- package/dist/src/components/TkxAffix.d.ts.map +1 -0
- package/dist/src/components/TkxAnchor.d.ts +14 -0
- package/dist/src/components/TkxAnchor.d.ts.map +1 -0
- package/dist/src/components/TkxCascader.d.ts +16 -0
- package/dist/src/components/TkxCascader.d.ts.map +1 -0
- package/dist/src/components/TkxDataGrid.d.ts +19 -1
- package/dist/src/components/TkxDataGrid.d.ts.map +1 -1
- package/dist/src/components/TkxForm.d.ts +33 -3
- package/dist/src/components/TkxForm.d.ts.map +1 -1
- package/dist/src/components/TkxImage.d.ts.map +1 -1
- package/dist/src/components/TkxList.d.ts +24 -0
- package/dist/src/components/TkxList.d.ts.map +1 -0
- package/dist/src/components/TkxMentions.d.ts +15 -0
- package/dist/src/components/TkxMentions.d.ts.map +1 -0
- package/dist/src/components/TkxQRCode.d.ts +11 -0
- package/dist/src/components/TkxQRCode.d.ts.map +1 -0
- package/dist/src/components/TkxResult.d.ts +11 -0
- package/dist/src/components/TkxResult.d.ts.map +1 -0
- package/dist/src/components/TkxSegmented.d.ts +16 -0
- package/dist/src/components/TkxSegmented.d.ts.map +1 -0
- package/dist/src/components/TkxSelect.d.ts +5 -1
- package/dist/src/components/TkxSelect.d.ts.map +1 -1
- package/dist/src/components/TkxTour.d.ts +15 -0
- package/dist/src/components/TkxTour.d.ts.map +1 -0
- package/dist/src/components/TkxTypography.d.ts +1 -1
- package/dist/src/components/TkxTypography.d.ts.map +1 -1
- package/dist/src/components/TkxWatermark.d.ts +12 -0
- package/dist/src/components/TkxWatermark.d.ts.map +1 -0
- package/dist/src/components/index.d.ts +10 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/engine/tkx.d.ts +38 -0
- package/dist/src/engine/tkx.d.ts.map +1 -1
- package/dist/src/headless/index.d.ts +18 -0
- package/dist/src/headless/index.d.ts.map +1 -0
- package/dist/src/headless/useControllable.d.ts +20 -0
- package/dist/src/headless/useControllable.d.ts.map +1 -0
- package/dist/src/headless/useDebounce.d.ts +14 -0
- package/dist/src/headless/useDebounce.d.ts.map +1 -0
- package/dist/src/headless/useDisclosure.d.ts +20 -0
- package/dist/src/headless/useDisclosure.d.ts.map +1 -0
- package/dist/src/headless/useFormState.d.ts +44 -0
- package/dist/src/headless/useFormState.d.ts.map +1 -0
- package/dist/src/headless/useIntersectionObserver.d.ts +23 -0
- package/dist/src/headless/useIntersectionObserver.d.ts.map +1 -0
- package/dist/src/headless/useListSelection.d.ts +29 -0
- package/dist/src/headless/useListSelection.d.ts.map +1 -0
- package/dist/src/headless/useLocalStorage.d.ts +9 -0
- package/dist/src/headless/useLocalStorage.d.ts.map +1 -0
- package/dist/src/headless/useMediaQuery.d.ts +21 -0
- package/dist/src/headless/useMediaQuery.d.ts.map +1 -0
- package/dist/src/headless/useRovingTabIndex.d.ts +33 -0
- package/dist/src/headless/useRovingTabIndex.d.ts.map +1 -0
- package/dist/src/headless/useThrottle.d.ts +9 -0
- package/dist/src/headless/useThrottle.d.ts.map +1 -0
- package/dist/src/i18n/index.d.ts +47 -2
- package/dist/src/i18n/index.d.ts.map +1 -1
- package/dist/src/themes/index.d.ts.map +1 -1
- package/package.json +61 -7
- package/src/charts/TkxAreaChart.tsx +119 -0
- package/src/charts/TkxBarChart.tsx +115 -0
- package/src/charts/TkxDonutChart.tsx +145 -0
- package/src/charts/TkxLineChart.tsx +135 -0
- package/src/charts/TkxPieChart.tsx +82 -0
- package/src/charts/TkxRadarChart.tsx +90 -0
- package/src/charts/TkxScatterChart.tsx +102 -0
- package/src/charts/index.ts +20 -0
- package/src/charts/shared.ts +45 -0
- package/src/components/TkxAffix.tsx +138 -0
- package/src/components/TkxAnchor.tsx +193 -0
- package/src/components/TkxCascader.tsx +276 -0
- package/src/components/TkxDataGrid.tsx +557 -230
- package/src/components/TkxForm.tsx +67 -15
- package/src/components/TkxImage.tsx +1 -1
- package/src/components/TkxList.tsx +242 -0
- package/src/components/TkxMentions.tsx +210 -0
- package/src/components/TkxQRCode.tsx +174 -0
- package/src/components/TkxResult.tsx +128 -0
- package/src/components/TkxSegmented.tsx +169 -0
- package/src/components/TkxSelect.tsx +209 -6
- package/src/components/TkxTour.tsx +239 -0
- package/src/components/TkxTypography.tsx +4 -2
- package/src/components/TkxWatermark.tsx +143 -0
- package/src/components/index.ts +10 -0
- package/src/engine/tkx.ts +122 -3
- package/src/headless/index.ts +44 -0
- package/src/headless/useControllable.ts +40 -0
- package/src/headless/useDebounce.ts +35 -0
- package/src/headless/useDisclosure.ts +28 -0
- package/src/headless/useFormState.ts +111 -0
- package/src/headless/useIntersectionObserver.ts +51 -0
- package/src/headless/useListSelection.ts +101 -0
- package/src/headless/useLocalStorage.ts +46 -0
- package/src/headless/useMediaQuery.ts +37 -0
- package/src/headless/useRovingTabIndex.ts +84 -0
- package/src/headless/useThrottle.ts +46 -0
- package/src/i18n/I18nProvider.tsx +1 -1
- package/src/i18n/index.ts +678 -38
- package/src/themes/index.ts +31 -4
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { useState, useCallback, useRef, type KeyboardEvent } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface UseRovingTabIndexOptions {
|
|
4
|
+
count: number;
|
|
5
|
+
initialIndex?: number;
|
|
6
|
+
orientation?: 'horizontal' | 'vertical' | 'both';
|
|
7
|
+
/** Wrap around at boundaries. Default: true */
|
|
8
|
+
loop?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface UseRovingTabIndexReturn {
|
|
12
|
+
focusedIndex: number;
|
|
13
|
+
setFocusedIndex: (index: number) => void;
|
|
14
|
+
getItemProps: (index: number) => {
|
|
15
|
+
tabIndex: number;
|
|
16
|
+
onKeyDown: (e: KeyboardEvent) => void;
|
|
17
|
+
onFocus: () => void;
|
|
18
|
+
'data-focused': boolean;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Implements the WAI-ARIA roving tabIndex pattern for composite widgets
|
|
24
|
+
* (toolbars, tab lists, radio groups, menu items, etc.)
|
|
25
|
+
*
|
|
26
|
+
* Only one item in the group is in the tab sequence at a time.
|
|
27
|
+
* Arrow keys move focus within the group.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* const { getItemProps } = useRovingTabIndex({ count: tabs.length });
|
|
31
|
+
* return tabs.map((tab, i) => (
|
|
32
|
+
* <button key={tab.id} {...getItemProps(i)}>{tab.label}</button>
|
|
33
|
+
* ));
|
|
34
|
+
*/
|
|
35
|
+
export function useRovingTabIndex({
|
|
36
|
+
count,
|
|
37
|
+
initialIndex = 0,
|
|
38
|
+
orientation = 'horizontal',
|
|
39
|
+
loop = true,
|
|
40
|
+
}: UseRovingTabIndexOptions): UseRovingTabIndexReturn {
|
|
41
|
+
const [focusedIndex, setFocusedIndex] = useState(initialIndex);
|
|
42
|
+
const itemRefs = useRef<(HTMLElement | null)[]>([]);
|
|
43
|
+
|
|
44
|
+
const moveFocus = useCallback(
|
|
45
|
+
(delta: number) => {
|
|
46
|
+
setFocusedIndex(prev => {
|
|
47
|
+
let next = prev + delta;
|
|
48
|
+
if (loop) {
|
|
49
|
+
next = ((next % count) + count) % count;
|
|
50
|
+
} else {
|
|
51
|
+
next = Math.max(0, Math.min(count - 1, next));
|
|
52
|
+
}
|
|
53
|
+
// Focus the element after state update
|
|
54
|
+
requestAnimationFrame(() => {
|
|
55
|
+
itemRefs.current[next]?.focus();
|
|
56
|
+
});
|
|
57
|
+
return next;
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
[count, loop],
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const getItemProps = useCallback(
|
|
64
|
+
(index: number) => ({
|
|
65
|
+
tabIndex: index === focusedIndex ? 0 : -1,
|
|
66
|
+
'data-focused': index === focusedIndex,
|
|
67
|
+
onFocus: () => setFocusedIndex(index),
|
|
68
|
+
onKeyDown: (e: KeyboardEvent) => {
|
|
69
|
+
const isHorizontal = orientation === 'horizontal' || orientation === 'both';
|
|
70
|
+
const isVertical = orientation === 'vertical' || orientation === 'both';
|
|
71
|
+
|
|
72
|
+
if (isHorizontal && e.key === 'ArrowRight') { e.preventDefault(); moveFocus(1); }
|
|
73
|
+
if (isHorizontal && e.key === 'ArrowLeft') { e.preventDefault(); moveFocus(-1); }
|
|
74
|
+
if (isVertical && e.key === 'ArrowDown') { e.preventDefault(); moveFocus(1); }
|
|
75
|
+
if (isVertical && e.key === 'ArrowUp') { e.preventDefault(); moveFocus(-1); }
|
|
76
|
+
if (e.key === 'Home') { e.preventDefault(); setFocusedIndex(0); requestAnimationFrame(() => itemRefs.current[0]?.focus()); }
|
|
77
|
+
if (e.key === 'End') { e.preventDefault(); setFocusedIndex(count - 1); requestAnimationFrame(() => itemRefs.current[count - 1]?.focus()); }
|
|
78
|
+
},
|
|
79
|
+
}),
|
|
80
|
+
[focusedIndex, moveFocus, orientation, count],
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
return { focusedIndex, setFocusedIndex, getItemProps };
|
|
84
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useState, useEffect, useCallback, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns a throttled version of the value — updates at most once per interval.
|
|
5
|
+
*/
|
|
6
|
+
export function useThrottle<T>(value: T, interval: number): T {
|
|
7
|
+
const [throttledValue, setThrottledValue] = useState(value);
|
|
8
|
+
const lastUpdated = useRef(Date.now());
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const now = Date.now();
|
|
12
|
+
const remaining = interval - (now - lastUpdated.current);
|
|
13
|
+
if (remaining <= 0) {
|
|
14
|
+
lastUpdated.current = now;
|
|
15
|
+
setThrottledValue(value);
|
|
16
|
+
} else {
|
|
17
|
+
const timer = setTimeout(() => {
|
|
18
|
+
lastUpdated.current = Date.now();
|
|
19
|
+
setThrottledValue(value);
|
|
20
|
+
}, remaining);
|
|
21
|
+
return () => clearTimeout(timer);
|
|
22
|
+
}
|
|
23
|
+
}, [value, interval]);
|
|
24
|
+
|
|
25
|
+
return throttledValue;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Returns a throttled callback — executes at most once per interval.
|
|
30
|
+
*/
|
|
31
|
+
export function useThrottledCallback<T extends (...args: any[]) => any>(
|
|
32
|
+
fn: T,
|
|
33
|
+
interval: number,
|
|
34
|
+
): (...args: Parameters<T>) => void {
|
|
35
|
+
const fnRef = useRef(fn);
|
|
36
|
+
fnRef.current = fn;
|
|
37
|
+
const lastCalledRef = useRef(0);
|
|
38
|
+
|
|
39
|
+
return useCallback((...args: Parameters<T>) => {
|
|
40
|
+
const now = Date.now();
|
|
41
|
+
if (now - lastCalledRef.current >= interval) {
|
|
42
|
+
lastCalledRef.current = now;
|
|
43
|
+
fnRef.current(...args);
|
|
44
|
+
}
|
|
45
|
+
}, [interval]);
|
|
46
|
+
}
|
|
@@ -28,7 +28,7 @@ export function I18nProvider({
|
|
|
28
28
|
|
|
29
29
|
return (
|
|
30
30
|
<I18nContext.Provider value={value}>
|
|
31
|
-
<div dir={value.direction} style={{ direction: value.direction }}>
|
|
31
|
+
<div dir={value.direction} style={{ direction: value.direction, display: 'contents' }}>
|
|
32
32
|
{children}
|
|
33
33
|
</div>
|
|
34
34
|
</I18nContext.Provider>
|