react-restyle-components 0.4.39 → 0.4.41
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/lib/index.js +3 -1
- package/lib/src/core-components/index.js +1 -1
- package/lib/src/core-components/src/components/Accordion/AccordionSection/Accordion.js +15 -1
- package/lib/src/core-components/src/components/Accordion/AccordionSection/AccordionContext.js +6 -1
- package/lib/src/core-components/src/components/Accordion/AccordionSection/AccordionSection.js +39 -1
- package/lib/src/core-components/src/components/Accordion/AccordionSection/Header.js +39 -1
- package/lib/src/core-components/src/components/Accordion/AccordionSection/elements.js +94 -57
- package/lib/src/core-components/src/components/Accordion/AccordionSection/hooks/useCurrentAccordionIndex.js +13 -1
- package/lib/src/core-components/src/components/Accordion/AccordionSection/index.js +3 -1
- package/lib/src/core-components/src/components/Accordion/AccordionSection/types.js +9 -1
- package/lib/src/core-components/src/components/Accordion/Collapsible/Collapsible2.component.js +249 -1
- package/lib/src/core-components/src/components/Action/types.js +8 -1
- package/lib/src/core-components/src/components/AlertBanner/AlertBanner.js +45 -1
- package/lib/src/core-components/src/components/AlertBanner/elements.js +120 -45
- package/lib/src/core-components/src/components/AlertBanner/index.js +2 -1
- package/lib/src/core-components/src/components/AlertBanner/types.js +10 -1
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-group-by-multiple-select-multiple-fields-display/auto-complete-filter-group-by-multiple-select-multiple-fields-display.component.js +334 -1
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-multi-select-multi-fields-display-drag-drop/auto-complete-filter-multi-select-multi-fields-display-drag-drop.component.js +229 -1
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-multi-select-selected-top-display/auto-complete-filter-multi-select-selected-top-display.component.js +174 -1
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-multiple-select-multiple-fields-display/auto-complete-filter-multiple-select-multiple-fields-display.component.js +129 -2
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-single-select/auto-complete-filter-single-select.component.js +55 -1
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-single-select-multiple-fields-display/auto-complete-filter-single-select-multiple-fields-display.component.js +308 -2
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-group-by/auto-complete-group-by.component.js +115 -1
- package/lib/src/core-components/src/components/AutoComplete/autocomplete/autocomplete.js +442 -2
- package/lib/src/core-components/src/components/AutoComplete/index.js +8 -1
- package/lib/src/core-components/src/components/Avatar/Avatar.js +148 -14
- package/lib/src/core-components/src/components/Badge/Badge.js +25 -2
- package/lib/src/core-components/src/components/Badge/InnerBadge/Inline.js +25 -1
- package/lib/src/core-components/src/components/Badge/InnerBadge/InnerBadge.js +25 -1
- package/lib/src/core-components/src/components/Badge/InnerBadge/elements.js +78 -32
- package/lib/src/core-components/src/components/Badge/InnerBadge/index.js +1 -1
- package/lib/src/core-components/src/components/Badge/index.js +1 -1
- package/lib/src/core-components/src/components/Badge/types.js +5 -1
- package/lib/src/core-components/src/components/Breadcrumb/Breadcrumb.js +83 -1
- package/lib/src/core-components/src/components/Breadcrumb/elements.js +166 -94
- package/lib/src/core-components/src/components/Breadcrumb/index.js +3 -1
- package/lib/src/core-components/src/components/Breadcrumb/types.js +3 -1
- package/lib/src/core-components/src/components/Button/button.component.js +18 -1
- package/lib/src/core-components/src/components/Button/buttonGroup/buttonGroup.component.js +4 -1
- package/lib/src/core-components/src/components/Button/index.js +2 -1
- package/lib/src/core-components/src/components/Button/types.js +1 -1
- package/lib/src/core-components/src/components/Chip/Chip.js +64 -1
- package/lib/src/core-components/src/components/Chip/elements.js +148 -48
- package/lib/src/core-components/src/components/Chip/index.js +2 -1
- package/lib/src/core-components/src/components/Chip/types.js +4 -1
- package/lib/src/core-components/src/components/Divider/Divider.js +25 -1
- package/lib/src/core-components/src/components/Divider/elements.js +68 -31
- package/lib/src/core-components/src/components/Divider/index.js +2 -1
- package/lib/src/core-components/src/components/Divider/types.js +4 -1
- package/lib/src/core-components/src/components/DynamicGrid/DynamicGrid.js +147 -1
- package/lib/src/core-components/src/components/DynamicGrid/GridContainer.js +24 -17
- package/lib/src/core-components/src/components/DynamicGrid/elements.js +162 -100
- package/lib/src/core-components/src/components/DynamicGrid/index.js +3 -1
- package/lib/src/core-components/src/components/DynamicGrid/types.js +28 -1
- package/lib/src/core-components/src/components/DynamicGrid/utils.js +193 -1
- package/lib/src/core-components/src/components/FormField/FormField.js +103 -1
- package/lib/src/core-components/src/components/FormField/components/CheckboxGroupInput.js +37 -1
- package/lib/src/core-components/src/components/FormField/components/CheckboxInput.js +8 -1
- package/lib/src/core-components/src/components/FormField/components/CssMultilineInput.js +192 -1
- package/lib/src/core-components/src/components/FormField/components/DatePickerInput.js +99 -1
- package/lib/src/core-components/src/components/FormField/components/DropdownInput.js +70 -1
- package/lib/src/core-components/src/components/FormField/components/OtpInput.js +81 -1
- package/lib/src/core-components/src/components/FormField/components/PasswordInput.js +40 -1
- package/lib/src/core-components/src/components/FormField/components/PinInput.js +75 -1
- package/lib/src/core-components/src/components/FormField/components/RadioInput.js +54 -1
- package/lib/src/core-components/src/components/FormField/components/TextDropdownInput.js +94 -1
- package/lib/src/core-components/src/components/FormField/components/ToggleInput.js +36 -1
- package/lib/src/core-components/src/components/FormField/components/index.js +11 -1
- package/lib/src/core-components/src/components/FormField/css-properties.js +161 -1
- package/lib/src/core-components/src/components/FormField/index.js +2 -1
- package/lib/src/core-components/src/components/Icon/Icon.js +79 -1
- package/lib/src/core-components/src/components/Icon/index.js +2 -1
- package/lib/src/core-components/src/components/Icon/types.js +9 -1
- package/lib/src/core-components/src/components/Loader/loader.component.js +215 -2
- package/lib/src/core-components/src/components/Masonry/Masonry.js +73 -1
- package/lib/src/core-components/src/components/Masonry/elements.js +46 -29
- package/lib/src/core-components/src/components/Masonry/hooks.js +100 -1
- package/lib/src/core-components/src/components/Masonry/index.js +3 -1
- package/lib/src/core-components/src/components/Masonry/types.js +1 -1
- package/lib/src/core-components/src/components/Modal/BasicModal/modal.component.js +116 -1
- package/lib/src/core-components/src/components/Modal/index.js +2 -1
- package/lib/src/core-components/src/components/Modal/modal-confirm/modal-confirm.component.js +147 -1
- package/lib/src/core-components/src/components/Picker/color-picker/color-picker.component.js +12 -1
- package/lib/src/core-components/src/components/Picker/color-picker-modal/color-picker-modal.component.js +40 -1
- package/lib/src/core-components/src/components/Picker/index.js +2 -1
- package/lib/src/core-components/src/components/Selection/index.js +4 -1
- package/lib/src/core-components/src/components/Selection/multi-select/multi-select.component.js +49 -1
- package/lib/src/core-components/src/components/Selection/multi-select-with-field/multi-select-with-field.component.js +58 -1
- package/lib/src/core-components/src/components/Selection/multi-selection-dropdown/multi-selection-dropdown.component.js +43 -1
- package/lib/src/core-components/src/components/Selection/single-select/single-select.component.js +87 -1
- package/lib/src/core-components/src/components/Skeleton/Skeleton.js +51 -1
- package/lib/src/core-components/src/components/Skeleton/elements.js +143 -54
- package/lib/src/core-components/src/components/Skeleton/index.js +2 -1
- package/lib/src/core-components/src/components/Skeleton/types.js +4 -1
- package/lib/src/core-components/src/components/SpeedDial/SpeedDial.js +128 -1
- package/lib/src/core-components/src/components/SpeedDial/elements.js +132 -62
- package/lib/src/core-components/src/components/SpeedDial/index.js +2 -1
- package/lib/src/core-components/src/components/SpeedDial/types.js +3 -1
- package/lib/src/core-components/src/components/Stepper2/stepper.component.js +139 -1
- package/lib/src/core-components/src/components/Switch/Switch.js +26 -1
- package/lib/src/core-components/src/components/Switch/elements.js +103 -34
- package/lib/src/core-components/src/components/Switch/index.js +2 -1
- package/lib/src/core-components/src/components/Switch/types.js +3 -1
- package/lib/src/core-components/src/components/Table/Table.js +1357 -1
- package/lib/src/core-components/src/components/Table/columnReorder.d.ts +128 -0
- package/lib/src/core-components/src/components/Table/columnReorder.js +530 -0
- package/lib/src/core-components/src/components/Table/columnResize.d.ts +99 -0
- package/lib/src/core-components/src/components/Table/columnResize.js +399 -0
- package/lib/src/core-components/src/components/Table/elements.d.ts +9 -1
- package/lib/src/core-components/src/components/Table/elements.js +324 -155
- package/lib/src/core-components/src/components/Table/filters.js +555 -30
- package/lib/src/core-components/src/components/Table/hooks.js +536 -2
- package/lib/src/core-components/src/components/Table/index.d.ts +4 -0
- package/lib/src/core-components/src/components/Table/index.js +6 -1
- package/lib/src/core-components/src/components/Table/types.d.ts +58 -0
- package/lib/src/core-components/src/components/Table/types.js +1 -1
- package/lib/src/core-components/src/components/Tabs/tabs.component.js +22 -1
- package/lib/src/core-components/src/components/Tags1/Tags.component.js +118 -1
- package/lib/src/core-components/src/components/Tags1/types.js +20 -1
- package/lib/src/core-components/src/components/Timer1/timer.component.js +76 -1
- package/lib/src/core-components/src/components/Toast/Toast.js +50 -1
- package/lib/src/core-components/src/components/Toast/elements.js +122 -41
- package/lib/src/core-components/src/components/Toast/index.js +2 -1
- package/lib/src/core-components/src/components/Toast/types.js +9 -1
- package/lib/src/core-components/src/components/Tooltip/Tooltip.js +200 -1
- package/lib/src/core-components/src/components/Tooltip/elements.js +117 -55
- package/lib/src/core-components/src/components/Tooltip/index.js +2 -1
- package/lib/src/core-components/src/components/Tooltip/types.js +17 -1
- package/lib/src/core-components/src/components/Tooltip/utils.js +140 -1
- package/lib/src/core-components/src/components/TreeSelect/TreeSelect.js +303 -1
- package/lib/src/core-components/src/components/TreeSelect/elements.js +216 -117
- package/lib/src/core-components/src/components/TreeSelect/hooks.js +252 -1
- package/lib/src/core-components/src/components/TreeSelect/index.js +3 -1
- package/lib/src/core-components/src/components/TreeSelect/types.js +1 -1
- package/lib/src/core-components/src/components/ag-grid/AgGrid.d.ts +11 -0
- package/lib/src/core-components/src/components/ag-grid/AgGrid.js +733 -0
- package/lib/src/core-components/src/components/ag-grid/elements.d.ts +246 -0
- package/lib/src/core-components/src/components/ag-grid/elements.js +1156 -0
- package/lib/src/core-components/src/components/ag-grid/hooks.d.ts +196 -0
- package/lib/src/core-components/src/components/ag-grid/hooks.js +943 -0
- package/lib/src/core-components/src/components/ag-grid/index.d.ts +9 -0
- package/lib/src/core-components/src/components/ag-grid/index.js +13 -0
- package/lib/src/core-components/src/components/ag-grid/types.d.ts +1367 -0
- package/lib/src/core-components/src/components/ag-grid/types.js +6 -0
- package/lib/src/core-components/src/components/index.d.ts +1 -0
- package/lib/src/core-components/src/components/index.js +31 -1
- package/lib/src/core-components/src/components/pdf/pdf-images.components.js +7 -1
- package/lib/src/core-components/src/components/pdf/pdf-table.components.js +48 -5
- package/lib/src/core-components/src/components/pdf/pdf-typography.components.js +70 -1
- package/lib/src/core-components/src/components/pdf/pdf-wrapped-view.components.js +50 -1
- package/lib/src/core-components/src/core-components/Avatar.js +33 -4
- package/lib/src/core-components/src/core-components/CoreButton/CoreButton.js +10 -1
- package/lib/src/core-components/src/core-components/CoreButton/elements.js +176 -67
- package/lib/src/core-components/src/core-components/CoreButton/index.js +3 -1
- package/lib/src/core-components/src/core-components/CoreButton/types.js +6 -1
- package/lib/src/core-components/src/core-components/CoreButton/utils.js +12 -1
- package/lib/src/core-components/src/core-components/Divider/Divider.js +19 -4
- package/lib/src/core-components/src/core-components/Divider/index.js +1 -1
- package/lib/src/core-components/src/core-components/SelectionCardStrip/index.js +1 -1
- package/lib/src/core-components/src/core-components/SelectionCardStrip/selectionCardStrip.js +33 -10
- package/lib/src/core-components/src/core-components/StateLayer.js +5 -3
- package/lib/src/core-components/src/core-components/ToggleCore/elements.js +50 -25
- package/lib/src/core-components/src/core-components/ToggleCore/index.js +2 -1
- package/lib/src/core-components/src/core-components/ToggleCore/toggleCore.js +14 -1
- package/lib/src/core-components/src/core-components/atoms/Input/Input.js +22 -1
- package/lib/src/core-components/src/core-components/atoms/Label/Label.js +21 -1
- package/lib/src/core-components/src/core-components/atoms/Textarea/Textarea.js +19 -1
- package/lib/src/core-components/src/core-components/index.js +3 -1
- package/lib/src/core-components/src/helpers/constants.js +11 -1
- package/lib/src/core-components/src/hooks/index.js +1 -1
- package/lib/src/core-components/src/hooks/outside.hook.js +28 -1
- package/lib/src/core-components/src/index.js +12 -1
- package/lib/src/core-components/src/tc.global.css +16 -3
- package/lib/src/core-components/src/tc.module.css +2 -2
- package/lib/src/core-components/src/utils/abstracts/breakpoints/index.js +28 -1
- package/lib/src/core-components/src/utils/abstracts/colors/index.js +49 -1
- package/lib/src/core-components/src/utils/abstracts/index.js +5 -1
- package/lib/src/core-components/src/utils/abstracts/space/index.js +26 -1
- package/lib/src/core-components/src/utils/abstracts/theme/ThemeBoundary.js +8 -1
- package/lib/src/core-components/src/utils/abstracts/theme/default-themes.js +30 -1
- package/lib/src/core-components/src/utils/abstracts/theme/index.js +3 -1
- package/lib/src/core-components/src/utils/abstracts/theme/theme.js +30 -1
- package/lib/src/core-components/src/utils/abstracts/theme/types.js +1 -1
- package/lib/src/core-components/src/utils/abstracts/theme/useTheme.js +17 -1
- package/lib/src/core-components/src/utils/abstracts/typography/index.js +25 -1
- package/lib/src/core-components/src/utils/context/DefaultsProvider.js +8 -1
- package/lib/src/core-components/src/utils/context/InternalProvider.js +24 -1
- package/lib/src/core-components/src/utils/context/index.js +2 -1
- package/lib/src/core-components/src/utils/designTokens.js +125 -1
- package/lib/src/core-components/src/utils/helpers/attachSubComponents.js +23 -1
- package/lib/src/core-components/src/utils/helpers/flattenChildren.js +11 -1
- package/lib/src/core-components/src/utils/helpers/getChildByType.js +3 -1
- package/lib/src/core-components/src/utils/helpers/index.js +5 -1
- package/lib/src/core-components/src/utils/helpers/isComponentType.js +16 -1
- package/lib/src/core-components/src/utils/helpers/separateChildrenByType.js +12 -1
- package/lib/src/core-components/src/utils/hooks/index.js +18 -1
- package/lib/src/core-components/src/utils/hooks/useClickOutside.js +18 -1
- package/lib/src/core-components/src/utils/hooks/useCombinedRefs.js +17 -1
- package/lib/src/core-components/src/utils/hooks/useDebouncedCallback.js +12 -1
- package/lib/src/core-components/src/utils/hooks/useDebouncedValue.js +20 -1
- package/lib/src/core-components/src/utils/hooks/useDeprecation.js +40 -1
- package/lib/src/core-components/src/utils/hooks/useDeviceDetect.js +10 -1
- package/lib/src/core-components/src/utils/hooks/useDeviceForm.js +24 -1
- package/lib/src/core-components/src/utils/hooks/useDisableBodyScroll.js +16 -1
- package/lib/src/core-components/src/utils/hooks/useHoverState.js +36 -1
- package/lib/src/core-components/src/utils/hooks/useId.js +7 -1
- package/lib/src/core-components/src/utils/hooks/useIsBrowser.js +11 -1
- package/lib/src/core-components/src/utils/hooks/useMediaQuery.js +16 -1
- package/lib/src/core-components/src/utils/hooks/useOverflow.js +22 -1
- package/lib/src/core-components/src/utils/hooks/useSafeLayoutEffect.js +5 -1
- package/lib/src/core-components/src/utils/hooks/useScrollingUp.js +18 -1
- package/lib/src/core-components/src/utils/hooks/useTrapFocus.js +30 -1
- package/lib/src/core-components/src/utils/hooks/useWindowDimensions.js +23 -1
- package/lib/src/core-components/src/utils/index.js +9 -1
- package/lib/src/core-components/src/utils/stories/Wrappers.js +23 -8
- package/lib/src/core-components/src/utils/stories/cleanProps.js +5 -1
- package/lib/src/core-components/src/utils/stories/index.js +4 -1
- package/lib/src/core-components/src/utils/stories/sleep.js +4 -1
- package/lib/src/core-components/src/utils/stories/view-ports.js +50 -1
- package/lib/src/core-components/src/utils/styling/calcWidthOfColumns.js +5 -1
- package/lib/src/core-components/src/utils/styling/createGridContainer.js +12 -6
- package/lib/src/core-components/src/utils/styling/createTransition.js +7 -2
- package/lib/src/core-components/src/utils/styling/forwardProps.js +10 -1
- package/lib/src/core-components/src/utils/styling/index.js +5 -1
- package/lib/src/core-components/src/utils/styling/pxToRem.js +6 -1
- package/lib/src/core-components/src/utils/testing/getComputedStyle.js +3 -1
- package/lib/src/core-components/src/utils/testing/index.js +1 -1
- package/lib/src/core-components/src/utils/utility.util.js +14 -1
- package/lib/src/core-components/tailwind.config.js +233 -1
- package/lib/src/core-hooks/index.js +3 -1
- package/lib/src/core-hooks/src/useClickOutside/useClickOutside.hook.js +46 -1
- package/lib/src/core-hooks/src/useDebounce/useDebounce.hook.js +30 -1
- package/lib/src/core-hooks/src/usePreventEKey/usePreventEKey.hook.js +8 -1
- package/lib/src/core-utils/index.js +7 -1
- package/lib/src/core-utils/src/calculation/calculation.util.js +89 -1
- package/lib/src/core-utils/src/colors/color.util.js +15 -1
- package/lib/src/core-utils/src/convert/numberToWords/numToWords.util.js +145 -1
- package/lib/src/core-utils/src/convert/typography/camelCaseToTitleCase.util.js +5 -1
- package/lib/src/core-utils/src/form-helper/form-helper.util.js +82 -1
- package/lib/src/core-utils/src/index.js +7 -1
- package/lib/src/core-utils/src/utility/utility.util.js +12 -1
- package/lib/src/core-utils/src/uuid/uuid.util.js +8 -1
- package/package.json +1 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Column Reorder Feature
|
|
3
|
+
*
|
|
4
|
+
* This file contains the column reordering (drag & drop) functionality for the Table component.
|
|
5
|
+
* It can be easily enabled/disabled via props without affecting core table logic.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Long press on header to start dragging
|
|
9
|
+
* - Drag column to new position
|
|
10
|
+
* - Visual feedback during drag (ghost element, drop indicators)
|
|
11
|
+
* - Callback when columns are reordered
|
|
12
|
+
*
|
|
13
|
+
* Usage:
|
|
14
|
+
* <Table
|
|
15
|
+
* reorderable={true}
|
|
16
|
+
* reorderConfig={{
|
|
17
|
+
* longPressDelay: 200,
|
|
18
|
+
* onReorder: (newColumns, fromIndex, toIndex) => console.log(newColumns),
|
|
19
|
+
* }}
|
|
20
|
+
* />
|
|
21
|
+
*/
|
|
22
|
+
import React from 'react';
|
|
23
|
+
import { TableColumn } from './types';
|
|
24
|
+
export interface ColumnReorderConfig<T = any> {
|
|
25
|
+
/** Long press delay in ms before drag starts (default: 200) */
|
|
26
|
+
longPressDelay?: number;
|
|
27
|
+
/** Callback when columns are reordered */
|
|
28
|
+
onReorder?: (newColumns: TableColumn<T>[], fromIndex: number, toIndex: number) => void;
|
|
29
|
+
/** Callback when drag starts */
|
|
30
|
+
onDragStart?: (column: TableColumn<T>, index: number) => void;
|
|
31
|
+
/** Callback when drag ends */
|
|
32
|
+
onDragEnd?: (column: TableColumn<T>, index: number) => void;
|
|
33
|
+
/** Disable specific columns from being dragged */
|
|
34
|
+
disabledColumns?: string[];
|
|
35
|
+
/** Ghost element opacity (default: 0.8) */
|
|
36
|
+
ghostOpacity?: number;
|
|
37
|
+
/** Drop indicator color */
|
|
38
|
+
dropIndicatorColor?: string;
|
|
39
|
+
/** Enable animation (default: true) */
|
|
40
|
+
animated?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export interface UseColumnReorderProps<T> {
|
|
43
|
+
columns: TableColumn<T>[];
|
|
44
|
+
config?: ColumnReorderConfig<T>;
|
|
45
|
+
enabled?: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface UseColumnReorderReturn<T> {
|
|
48
|
+
orderedColumns: TableColumn<T>[];
|
|
49
|
+
getDragHandleProps: (column: TableColumn<T>, index: number) => DragHandleProps;
|
|
50
|
+
isDragging: boolean;
|
|
51
|
+
draggedColumn: string | null;
|
|
52
|
+
dragOverColumn: string | null;
|
|
53
|
+
ghostPosition: {
|
|
54
|
+
x: number;
|
|
55
|
+
y: number;
|
|
56
|
+
};
|
|
57
|
+
ghostText: string;
|
|
58
|
+
resetOrder: () => void;
|
|
59
|
+
}
|
|
60
|
+
export interface DragHandleProps {
|
|
61
|
+
onMouseDown: (e: React.MouseEvent) => void;
|
|
62
|
+
onTouchStart: (e: React.TouchEvent) => void;
|
|
63
|
+
'data-draggable': boolean;
|
|
64
|
+
'data-dragging': boolean;
|
|
65
|
+
'data-drag-over': boolean;
|
|
66
|
+
style: React.CSSProperties;
|
|
67
|
+
}
|
|
68
|
+
export declare const DragGhost: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
69
|
+
$visible: boolean;
|
|
70
|
+
$x: number;
|
|
71
|
+
$y: number;
|
|
72
|
+
$opacity: number;
|
|
73
|
+
}>> & string;
|
|
74
|
+
export declare const DropIndicator: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
75
|
+
$visible: boolean;
|
|
76
|
+
$position: 'left' | 'right';
|
|
77
|
+
$color: string;
|
|
78
|
+
}>> & string;
|
|
79
|
+
export declare const DraggableHeader: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
80
|
+
$isDragging: boolean;
|
|
81
|
+
$isDragOver: boolean;
|
|
82
|
+
$isDisabled: boolean;
|
|
83
|
+
$animated: boolean;
|
|
84
|
+
}>> & string;
|
|
85
|
+
export declare function useColumnReorder<T>({ columns, config, enabled, }: UseColumnReorderProps<T>): UseColumnReorderReturn<T>;
|
|
86
|
+
interface ColumnReorderGhostProps {
|
|
87
|
+
visible: boolean;
|
|
88
|
+
x: number;
|
|
89
|
+
y: number;
|
|
90
|
+
text: string;
|
|
91
|
+
opacity?: number;
|
|
92
|
+
}
|
|
93
|
+
export declare const ColumnReorderGhost: React.FC<ColumnReorderGhostProps>;
|
|
94
|
+
interface ColumnDropIndicatorProps {
|
|
95
|
+
visible: boolean;
|
|
96
|
+
position: 'left' | 'right';
|
|
97
|
+
color?: string;
|
|
98
|
+
}
|
|
99
|
+
export declare const ColumnDropIndicator: React.FC<ColumnDropIndicatorProps>;
|
|
100
|
+
export declare function getReorderableHeaderProps<T>(column: TableColumn<T>, index: number, getDragHandleProps: (column: TableColumn<T>, index: number) => DragHandleProps, isDragging: boolean, draggedColumn: string | null, dragOverColumn: string | null): {
|
|
101
|
+
wrapperProps: DragHandleProps;
|
|
102
|
+
showDropIndicator: boolean;
|
|
103
|
+
dropPosition: 'left' | 'right';
|
|
104
|
+
};
|
|
105
|
+
declare const _default: {
|
|
106
|
+
useColumnReorder: typeof useColumnReorder;
|
|
107
|
+
DragGhost: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
108
|
+
$visible: boolean;
|
|
109
|
+
$x: number;
|
|
110
|
+
$y: number;
|
|
111
|
+
$opacity: number;
|
|
112
|
+
}>> & string;
|
|
113
|
+
DropIndicator: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
114
|
+
$visible: boolean;
|
|
115
|
+
$position: "left" | "right";
|
|
116
|
+
$color: string;
|
|
117
|
+
}>> & string;
|
|
118
|
+
DraggableHeader: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
119
|
+
$isDragging: boolean;
|
|
120
|
+
$isDragOver: boolean;
|
|
121
|
+
$isDisabled: boolean;
|
|
122
|
+
$animated: boolean;
|
|
123
|
+
}>> & string;
|
|
124
|
+
ColumnReorderGhost: React.FC<ColumnReorderGhostProps>;
|
|
125
|
+
ColumnDropIndicator: React.FC<ColumnDropIndicatorProps>;
|
|
126
|
+
getReorderableHeaderProps: typeof getReorderableHeaderProps;
|
|
127
|
+
};
|
|
128
|
+
export default _default;
|
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Column Reorder Feature
|
|
4
|
+
*
|
|
5
|
+
* This file contains the column reordering (drag & drop) functionality for the Table component.
|
|
6
|
+
* It can be easily enabled/disabled via props without affecting core table logic.
|
|
7
|
+
*
|
|
8
|
+
* Features:
|
|
9
|
+
* - Long press on header to start dragging
|
|
10
|
+
* - Drag column to new position
|
|
11
|
+
* - Visual feedback during drag (ghost element, drop indicators)
|
|
12
|
+
* - Callback when columns are reordered
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
* <Table
|
|
16
|
+
* reorderable={true}
|
|
17
|
+
* reorderConfig={{
|
|
18
|
+
* longPressDelay: 200,
|
|
19
|
+
* onReorder: (newColumns, fromIndex, toIndex) => console.log(newColumns),
|
|
20
|
+
* }}
|
|
21
|
+
* />
|
|
22
|
+
*/
|
|
23
|
+
import { useRef, useState, useCallback, useEffect, useMemo, } from 'react';
|
|
24
|
+
import { styled, css, keyframes } from 'styled-components';
|
|
25
|
+
// ============================================================================
|
|
26
|
+
// Animations
|
|
27
|
+
// ============================================================================
|
|
28
|
+
const shake = keyframes `
|
|
29
|
+
0%, 100% { transform: translateX(0) rotate(0deg); }
|
|
30
|
+
10% { transform: translateX(-2px) rotate(-0.5deg); }
|
|
31
|
+
20% { transform: translateX(2px) rotate(0.5deg); }
|
|
32
|
+
30% { transform: translateX(-2px) rotate(-0.5deg); }
|
|
33
|
+
40% { transform: translateX(2px) rotate(0.5deg); }
|
|
34
|
+
50% { transform: translateX(-1px) rotate(-0.3deg); }
|
|
35
|
+
60% { transform: translateX(1px) rotate(0.3deg); }
|
|
36
|
+
70% { transform: translateX(-1px) rotate(-0.2deg); }
|
|
37
|
+
80% { transform: translateX(1px) rotate(0.2deg); }
|
|
38
|
+
90% { transform: translateX(0) rotate(0deg); }
|
|
39
|
+
`;
|
|
40
|
+
const pulse = keyframes `
|
|
41
|
+
0%, 100% {
|
|
42
|
+
opacity: 1;
|
|
43
|
+
transform: scale(1);
|
|
44
|
+
}
|
|
45
|
+
50% {
|
|
46
|
+
opacity: 0.7;
|
|
47
|
+
transform: scale(0.98);
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
const float = keyframes `
|
|
51
|
+
0%, 100% { transform: translate(-50%, -50%) scale(1.05) rotate(-1deg); }
|
|
52
|
+
50% { transform: translate(-50%, -50%) scale(1.08) rotate(1deg); }
|
|
53
|
+
`;
|
|
54
|
+
const glowPulse = keyframes `
|
|
55
|
+
0%, 100% {
|
|
56
|
+
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3),
|
|
57
|
+
0 0 0 0 rgba(59, 130, 246, 0);
|
|
58
|
+
}
|
|
59
|
+
50% {
|
|
60
|
+
box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4),
|
|
61
|
+
0 0 20px 4px rgba(59, 130, 246, 0.3);
|
|
62
|
+
}
|
|
63
|
+
`;
|
|
64
|
+
const dropIndicatorPulse = keyframes `
|
|
65
|
+
0%, 100% {
|
|
66
|
+
opacity: 1;
|
|
67
|
+
transform: scaleY(1);
|
|
68
|
+
}
|
|
69
|
+
50% {
|
|
70
|
+
opacity: 0.8;
|
|
71
|
+
transform: scaleY(1.02);
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
const slideDown = keyframes `
|
|
75
|
+
from {
|
|
76
|
+
transform: translateY(-10px) scaleY(0.5);
|
|
77
|
+
opacity: 0;
|
|
78
|
+
}
|
|
79
|
+
to {
|
|
80
|
+
transform: translateY(0) scaleY(1);
|
|
81
|
+
opacity: 1;
|
|
82
|
+
}
|
|
83
|
+
`;
|
|
84
|
+
// ============================================================================
|
|
85
|
+
// Styled Components
|
|
86
|
+
// ============================================================================
|
|
87
|
+
export const DragGhost = styled.div `
|
|
88
|
+
position: fixed;
|
|
89
|
+
top: ${({ $y }) => $y}px;
|
|
90
|
+
left: ${({ $x }) => $x}px;
|
|
91
|
+
z-index: 10000;
|
|
92
|
+
pointer-events: none;
|
|
93
|
+
opacity: ${({ $visible, $opacity }) => ($visible ? $opacity : 0)};
|
|
94
|
+
transform: translate(-50%, -50%) scale(${({ $visible }) => ($visible ? 1.05 : 0.8)});
|
|
95
|
+
transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
96
|
+
|
|
97
|
+
/* Glass morphism effect */
|
|
98
|
+
background: linear-gradient(
|
|
99
|
+
135deg,
|
|
100
|
+
rgba(59, 130, 246, 0.95) 0%,
|
|
101
|
+
rgba(37, 99, 235, 0.9) 100%
|
|
102
|
+
);
|
|
103
|
+
backdrop-filter: blur(8px);
|
|
104
|
+
-webkit-backdrop-filter: blur(8px);
|
|
105
|
+
color: white;
|
|
106
|
+
padding: 10px 20px;
|
|
107
|
+
border-radius: 10px;
|
|
108
|
+
font-size: 13px;
|
|
109
|
+
font-weight: 600;
|
|
110
|
+
letter-spacing: 0.3px;
|
|
111
|
+
white-space: nowrap;
|
|
112
|
+
border: 1px solid rgba(255, 255, 255, 0.2);
|
|
113
|
+
|
|
114
|
+
/* Floating animation when visible */
|
|
115
|
+
${({ $visible }) => $visible &&
|
|
116
|
+
css `
|
|
117
|
+
animation: ${float} 2s ease-in-out infinite, ${glowPulse} 1.5s ease-in-out infinite;
|
|
118
|
+
`}
|
|
119
|
+
|
|
120
|
+
/* Icon with animation */
|
|
121
|
+
&::before {
|
|
122
|
+
content: '⋮⋮';
|
|
123
|
+
margin-right: 10px;
|
|
124
|
+
font-size: 14px;
|
|
125
|
+
opacity: 0.8;
|
|
126
|
+
letter-spacing: 1px;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/* Subtle gradient overlay */
|
|
130
|
+
&::after {
|
|
131
|
+
content: '';
|
|
132
|
+
position: absolute;
|
|
133
|
+
top: 0;
|
|
134
|
+
left: 0;
|
|
135
|
+
right: 0;
|
|
136
|
+
bottom: 0;
|
|
137
|
+
border-radius: 10px;
|
|
138
|
+
background: linear-gradient(
|
|
139
|
+
180deg,
|
|
140
|
+
rgba(255, 255, 255, 0.15) 0%,
|
|
141
|
+
transparent 50%,
|
|
142
|
+
rgba(0, 0, 0, 0.1) 100%
|
|
143
|
+
);
|
|
144
|
+
pointer-events: none;
|
|
145
|
+
}
|
|
146
|
+
`;
|
|
147
|
+
export const DropIndicator = styled.div `
|
|
148
|
+
position: absolute;
|
|
149
|
+
top: -4px;
|
|
150
|
+
bottom: -4px;
|
|
151
|
+
width: 4px;
|
|
152
|
+
z-index: 100;
|
|
153
|
+
opacity: ${({ $visible }) => ($visible ? 1 : 0)};
|
|
154
|
+
transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
155
|
+
transform-origin: center;
|
|
156
|
+
|
|
157
|
+
${({ $position }) => $position === 'left'
|
|
158
|
+
? css `left: -2px;`
|
|
159
|
+
: css `right: -2px;`}
|
|
160
|
+
|
|
161
|
+
/* Gradient background with glow */
|
|
162
|
+
background: linear-gradient(
|
|
163
|
+
to bottom,
|
|
164
|
+
transparent 0%,
|
|
165
|
+
${({ $color }) => $color} 10%,
|
|
166
|
+
${({ $color }) => $color} 90%,
|
|
167
|
+
transparent 100%
|
|
168
|
+
);
|
|
169
|
+
border-radius: 2px;
|
|
170
|
+
box-shadow:
|
|
171
|
+
0 0 8px ${({ $color }) => $color},
|
|
172
|
+
0 0 16px ${({ $color }) => $color}80;
|
|
173
|
+
|
|
174
|
+
/* Pulsing animation when visible */
|
|
175
|
+
${({ $visible }) => $visible &&
|
|
176
|
+
css `
|
|
177
|
+
animation: ${dropIndicatorPulse} 0.8s ease-in-out infinite, ${slideDown} 0.2s ease-out;
|
|
178
|
+
`}
|
|
179
|
+
|
|
180
|
+
/* Top arrow */
|
|
181
|
+
&::before {
|
|
182
|
+
content: '';
|
|
183
|
+
position: absolute;
|
|
184
|
+
top: 0;
|
|
185
|
+
left: 50%;
|
|
186
|
+
transform: translateX(-50%);
|
|
187
|
+
width: 0;
|
|
188
|
+
height: 0;
|
|
189
|
+
border-left: 8px solid transparent;
|
|
190
|
+
border-right: 8px solid transparent;
|
|
191
|
+
border-bottom: 8px solid ${({ $color }) => $color};
|
|
192
|
+
filter: drop-shadow(0 -2px 4px ${({ $color }) => $color}80);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/* Bottom arrow */
|
|
196
|
+
&::after {
|
|
197
|
+
content: '';
|
|
198
|
+
position: absolute;
|
|
199
|
+
bottom: 0;
|
|
200
|
+
left: 50%;
|
|
201
|
+
transform: translateX(-50%);
|
|
202
|
+
width: 0;
|
|
203
|
+
height: 0;
|
|
204
|
+
border-left: 8px solid transparent;
|
|
205
|
+
border-right: 8px solid transparent;
|
|
206
|
+
border-top: 8px solid ${({ $color }) => $color};
|
|
207
|
+
filter: drop-shadow(0 2px 4px ${({ $color }) => $color}80);
|
|
208
|
+
}
|
|
209
|
+
`;
|
|
210
|
+
export const DraggableHeader = styled.div `
|
|
211
|
+
position: relative;
|
|
212
|
+
cursor: ${({ $isDisabled }) => ($isDisabled ? 'default' : 'grab')};
|
|
213
|
+
user-select: none;
|
|
214
|
+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
215
|
+
|
|
216
|
+
/* Dragging state - semi-transparent with scale */
|
|
217
|
+
${({ $isDragging }) => $isDragging &&
|
|
218
|
+
css `
|
|
219
|
+
opacity: 0.35;
|
|
220
|
+
transform: scale(0.95);
|
|
221
|
+
cursor: grabbing;
|
|
222
|
+
filter: grayscale(50%);
|
|
223
|
+
|
|
224
|
+
&::after {
|
|
225
|
+
content: '';
|
|
226
|
+
position: absolute;
|
|
227
|
+
inset: 0;
|
|
228
|
+
background: repeating-linear-gradient(
|
|
229
|
+
45deg,
|
|
230
|
+
transparent,
|
|
231
|
+
transparent 5px,
|
|
232
|
+
rgba(59, 130, 246, 0.1) 5px,
|
|
233
|
+
rgba(59, 130, 246, 0.1) 10px
|
|
234
|
+
);
|
|
235
|
+
border-radius: 4px;
|
|
236
|
+
pointer-events: none;
|
|
237
|
+
}
|
|
238
|
+
`}
|
|
239
|
+
|
|
240
|
+
/* Drag over state - highlight target */
|
|
241
|
+
${({ $isDragOver, $animated }) => $isDragOver &&
|
|
242
|
+
css `
|
|
243
|
+
background: rgba(59, 130, 246, 0.15);
|
|
244
|
+
transform: scale(1.02);
|
|
245
|
+
box-shadow: inset 0 0 0 2px rgba(59, 130, 246, 0.4);
|
|
246
|
+
border-radius: 4px;
|
|
247
|
+
|
|
248
|
+
${$animated &&
|
|
249
|
+
css `
|
|
250
|
+
animation: ${pulse} 0.6s ease-in-out infinite;
|
|
251
|
+
`}
|
|
252
|
+
`}
|
|
253
|
+
|
|
254
|
+
/* Disabled state */
|
|
255
|
+
${({ $isDisabled }) => $isDisabled &&
|
|
256
|
+
css `
|
|
257
|
+
cursor: not-allowed;
|
|
258
|
+
opacity: 0.6;
|
|
259
|
+
|
|
260
|
+
&::before {
|
|
261
|
+
content: '🔒';
|
|
262
|
+
position: absolute;
|
|
263
|
+
top: 2px;
|
|
264
|
+
right: 2px;
|
|
265
|
+
font-size: 10px;
|
|
266
|
+
opacity: 0.5;
|
|
267
|
+
}
|
|
268
|
+
`}
|
|
269
|
+
|
|
270
|
+
&:active {
|
|
271
|
+
cursor: ${({ $isDisabled }) => ($isDisabled ? 'not-allowed' : 'grabbing')};
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/* Hover state for grabbable columns */
|
|
275
|
+
&:hover {
|
|
276
|
+
${({ $isDisabled, $isDragging }) => !$isDisabled &&
|
|
277
|
+
!$isDragging &&
|
|
278
|
+
css `
|
|
279
|
+
background: rgba(255, 255, 255, 0.1);
|
|
280
|
+
`}
|
|
281
|
+
}
|
|
282
|
+
`;
|
|
283
|
+
// ============================================================================
|
|
284
|
+
// Hook: useColumnReorder
|
|
285
|
+
// ============================================================================
|
|
286
|
+
export function useColumnReorder({ columns, config = {}, enabled = true, }) {
|
|
287
|
+
const { longPressDelay = 200, onReorder, onDragStart, onDragEnd, disabledColumns = [], ghostOpacity = 0.8, dropIndicatorColor = '#3b82f6', animated = true, } = config;
|
|
288
|
+
// State
|
|
289
|
+
const [orderedColumns, setOrderedColumns] = useState(columns);
|
|
290
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
291
|
+
const [draggedColumn, setDraggedColumn] = useState(null);
|
|
292
|
+
const [draggedIndex, setDraggedIndex] = useState(null);
|
|
293
|
+
const [dragOverColumn, setDragOverColumn] = useState(null);
|
|
294
|
+
const [ghostPosition, setGhostPosition] = useState({ x: 0, y: 0 });
|
|
295
|
+
const [ghostText, setGhostText] = useState('');
|
|
296
|
+
// Refs
|
|
297
|
+
const longPressTimerRef = useRef(null);
|
|
298
|
+
const startPosRef = useRef({ x: 0, y: 0 });
|
|
299
|
+
const isDraggingRef = useRef(false);
|
|
300
|
+
// Update ordered columns when columns prop changes
|
|
301
|
+
useEffect(() => {
|
|
302
|
+
setOrderedColumns(columns);
|
|
303
|
+
}, [columns]);
|
|
304
|
+
// Cleanup on unmount
|
|
305
|
+
useEffect(() => {
|
|
306
|
+
return () => {
|
|
307
|
+
if (longPressTimerRef.current) {
|
|
308
|
+
clearTimeout(longPressTimerRef.current);
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
}, []);
|
|
312
|
+
// Start drag after long press
|
|
313
|
+
const startDrag = useCallback((column, index, x, y) => {
|
|
314
|
+
if (disabledColumns.includes(column.dataField))
|
|
315
|
+
return;
|
|
316
|
+
isDraggingRef.current = true;
|
|
317
|
+
setIsDragging(true);
|
|
318
|
+
setDraggedColumn(column.dataField);
|
|
319
|
+
setDraggedIndex(index);
|
|
320
|
+
setGhostPosition({ x, y });
|
|
321
|
+
setGhostText(column.headerText || column.text);
|
|
322
|
+
onDragStart?.(column, index);
|
|
323
|
+
// Add global event listeners
|
|
324
|
+
document.addEventListener('mousemove', handleMouseMove);
|
|
325
|
+
document.addEventListener('mouseup', handleMouseUp);
|
|
326
|
+
document.addEventListener('touchmove', handleTouchMove, { passive: false });
|
|
327
|
+
document.addEventListener('touchend', handleTouchEnd);
|
|
328
|
+
document.body.style.cursor = 'grabbing';
|
|
329
|
+
document.body.style.userSelect = 'none';
|
|
330
|
+
}, [disabledColumns, onDragStart]);
|
|
331
|
+
// Handle mouse/touch move during drag
|
|
332
|
+
const handleMouseMove = useCallback((e) => {
|
|
333
|
+
if (!isDraggingRef.current)
|
|
334
|
+
return;
|
|
335
|
+
setGhostPosition({ x: e.clientX, y: e.clientY });
|
|
336
|
+
updateDragOver(e.clientX, e.clientY);
|
|
337
|
+
}, []);
|
|
338
|
+
const handleTouchMove = useCallback((e) => {
|
|
339
|
+
if (!isDraggingRef.current)
|
|
340
|
+
return;
|
|
341
|
+
e.preventDefault();
|
|
342
|
+
const touch = e.touches[0];
|
|
343
|
+
setGhostPosition({ x: touch.clientX, y: touch.clientY });
|
|
344
|
+
updateDragOver(touch.clientX, touch.clientY);
|
|
345
|
+
}, []);
|
|
346
|
+
// Update which column we're hovering over
|
|
347
|
+
const updateDragOver = useCallback((x, y) => {
|
|
348
|
+
const elements = document.elementsFromPoint(x, y);
|
|
349
|
+
const headerCell = elements.find((el) => el.getAttribute('data-draggable') === 'true');
|
|
350
|
+
if (headerCell) {
|
|
351
|
+
const dataField = headerCell.getAttribute('data-column');
|
|
352
|
+
if (dataField && dataField !== draggedColumn) {
|
|
353
|
+
setDragOverColumn(dataField);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
setDragOverColumn(null);
|
|
358
|
+
}
|
|
359
|
+
}, [draggedColumn]);
|
|
360
|
+
// End drag
|
|
361
|
+
const endDrag = useCallback(() => {
|
|
362
|
+
if (!isDraggingRef.current)
|
|
363
|
+
return;
|
|
364
|
+
isDraggingRef.current = false;
|
|
365
|
+
// Find the target index
|
|
366
|
+
if (draggedColumn && dragOverColumn && draggedIndex !== null) {
|
|
367
|
+
const fromIndex = draggedIndex;
|
|
368
|
+
const toIndex = orderedColumns.findIndex((c) => c.dataField === dragOverColumn);
|
|
369
|
+
if (fromIndex !== toIndex && toIndex !== -1) {
|
|
370
|
+
const newColumns = [...orderedColumns];
|
|
371
|
+
const [removed] = newColumns.splice(fromIndex, 1);
|
|
372
|
+
newColumns.splice(toIndex, 0, removed);
|
|
373
|
+
setOrderedColumns(newColumns);
|
|
374
|
+
onReorder?.(newColumns, fromIndex, toIndex);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
// Get the column for callback
|
|
378
|
+
const column = orderedColumns.find((c) => c.dataField === draggedColumn);
|
|
379
|
+
if (column && draggedIndex !== null) {
|
|
380
|
+
onDragEnd?.(column, draggedIndex);
|
|
381
|
+
}
|
|
382
|
+
// Reset state
|
|
383
|
+
setIsDragging(false);
|
|
384
|
+
setDraggedColumn(null);
|
|
385
|
+
setDraggedIndex(null);
|
|
386
|
+
setDragOverColumn(null);
|
|
387
|
+
// Remove global event listeners
|
|
388
|
+
document.removeEventListener('mousemove', handleMouseMove);
|
|
389
|
+
document.removeEventListener('mouseup', handleMouseUp);
|
|
390
|
+
document.removeEventListener('touchmove', handleTouchMove);
|
|
391
|
+
document.removeEventListener('touchend', handleTouchEnd);
|
|
392
|
+
document.body.style.cursor = '';
|
|
393
|
+
document.body.style.userSelect = '';
|
|
394
|
+
}, [
|
|
395
|
+
draggedColumn,
|
|
396
|
+
dragOverColumn,
|
|
397
|
+
draggedIndex,
|
|
398
|
+
orderedColumns,
|
|
399
|
+
onReorder,
|
|
400
|
+
onDragEnd,
|
|
401
|
+
handleMouseMove,
|
|
402
|
+
handleTouchMove,
|
|
403
|
+
]);
|
|
404
|
+
const handleMouseUp = useCallback(() => {
|
|
405
|
+
if (longPressTimerRef.current) {
|
|
406
|
+
clearTimeout(longPressTimerRef.current);
|
|
407
|
+
longPressTimerRef.current = null;
|
|
408
|
+
}
|
|
409
|
+
endDrag();
|
|
410
|
+
}, [endDrag]);
|
|
411
|
+
const handleTouchEnd = useCallback(() => {
|
|
412
|
+
if (longPressTimerRef.current) {
|
|
413
|
+
clearTimeout(longPressTimerRef.current);
|
|
414
|
+
longPressTimerRef.current = null;
|
|
415
|
+
}
|
|
416
|
+
endDrag();
|
|
417
|
+
}, [endDrag]);
|
|
418
|
+
// Mouse down handler - starts long press timer
|
|
419
|
+
const handleMouseDown = useCallback((e, column, index) => {
|
|
420
|
+
if (!enabled || disabledColumns.includes(column.dataField))
|
|
421
|
+
return;
|
|
422
|
+
e.preventDefault();
|
|
423
|
+
startPosRef.current = { x: e.clientX, y: e.clientY };
|
|
424
|
+
// Start long press timer
|
|
425
|
+
longPressTimerRef.current = setTimeout(() => {
|
|
426
|
+
startDrag(column, index, e.clientX, e.clientY);
|
|
427
|
+
}, longPressDelay);
|
|
428
|
+
// Add mouse move listener to cancel if moved too much
|
|
429
|
+
const handleEarlyMove = (moveEvent) => {
|
|
430
|
+
const dx = moveEvent.clientX - startPosRef.current.x;
|
|
431
|
+
const dy = moveEvent.clientY - startPosRef.current.y;
|
|
432
|
+
if (Math.sqrt(dx * dx + dy * dy) > 10) {
|
|
433
|
+
if (longPressTimerRef.current) {
|
|
434
|
+
clearTimeout(longPressTimerRef.current);
|
|
435
|
+
longPressTimerRef.current = null;
|
|
436
|
+
}
|
|
437
|
+
document.removeEventListener('mousemove', handleEarlyMove);
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
document.addEventListener('mousemove', handleEarlyMove);
|
|
441
|
+
// Cleanup early move listener on mouse up
|
|
442
|
+
const cleanup = () => {
|
|
443
|
+
document.removeEventListener('mousemove', handleEarlyMove);
|
|
444
|
+
document.removeEventListener('mouseup', cleanup);
|
|
445
|
+
if (longPressTimerRef.current && !isDraggingRef.current) {
|
|
446
|
+
clearTimeout(longPressTimerRef.current);
|
|
447
|
+
longPressTimerRef.current = null;
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
document.addEventListener('mouseup', cleanup);
|
|
451
|
+
}, [enabled, disabledColumns, longPressDelay, startDrag]);
|
|
452
|
+
// Touch start handler
|
|
453
|
+
const handleTouchStart = useCallback((e, column, index) => {
|
|
454
|
+
if (!enabled || disabledColumns.includes(column.dataField))
|
|
455
|
+
return;
|
|
456
|
+
const touch = e.touches[0];
|
|
457
|
+
startPosRef.current = { x: touch.clientX, y: touch.clientY };
|
|
458
|
+
// Start long press timer
|
|
459
|
+
longPressTimerRef.current = setTimeout(() => {
|
|
460
|
+
startDrag(column, index, touch.clientX, touch.clientY);
|
|
461
|
+
}, longPressDelay);
|
|
462
|
+
}, [enabled, disabledColumns, longPressDelay, startDrag]);
|
|
463
|
+
// Get drag handle props for a column header
|
|
464
|
+
const getDragHandleProps = useCallback((column, index) => {
|
|
465
|
+
const isDisabled = disabledColumns.includes(column.dataField);
|
|
466
|
+
const isThisDragging = draggedColumn === column.dataField;
|
|
467
|
+
const isThisDragOver = dragOverColumn === column.dataField;
|
|
468
|
+
return {
|
|
469
|
+
onMouseDown: (e) => handleMouseDown(e, column, index),
|
|
470
|
+
onTouchStart: (e) => handleTouchStart(e, column, index),
|
|
471
|
+
'data-draggable': enabled && !isDisabled,
|
|
472
|
+
'data-dragging': isThisDragging,
|
|
473
|
+
'data-drag-over': isThisDragOver,
|
|
474
|
+
style: {
|
|
475
|
+
cursor: enabled && !isDisabled ? 'grab' : 'default',
|
|
476
|
+
opacity: isThisDragging ? 0.4 : 1,
|
|
477
|
+
transition: 'opacity 0.2s ease',
|
|
478
|
+
},
|
|
479
|
+
};
|
|
480
|
+
}, [
|
|
481
|
+
enabled,
|
|
482
|
+
disabledColumns,
|
|
483
|
+
draggedColumn,
|
|
484
|
+
dragOverColumn,
|
|
485
|
+
handleMouseDown,
|
|
486
|
+
handleTouchStart,
|
|
487
|
+
]);
|
|
488
|
+
// Reset column order
|
|
489
|
+
const resetOrder = useCallback(() => {
|
|
490
|
+
setOrderedColumns(columns);
|
|
491
|
+
}, [columns]);
|
|
492
|
+
// Render ghost element (called from Table component)
|
|
493
|
+
const GhostElement = useMemo(() => (_jsx(DragGhost, { "$visible": isDragging, "$x": ghostPosition.x, "$y": ghostPosition.y, "$opacity": ghostOpacity, children: ghostText })), [isDragging, ghostPosition, ghostOpacity, ghostText]);
|
|
494
|
+
return {
|
|
495
|
+
orderedColumns,
|
|
496
|
+
getDragHandleProps,
|
|
497
|
+
isDragging,
|
|
498
|
+
draggedColumn,
|
|
499
|
+
dragOverColumn,
|
|
500
|
+
ghostPosition,
|
|
501
|
+
ghostText,
|
|
502
|
+
resetOrder,
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
export const ColumnReorderGhost = ({ visible, x, y, text, opacity = 0.8, }) => (_jsx(DragGhost, { "$visible": visible, "$x": x, "$y": y, "$opacity": opacity, children: text }));
|
|
506
|
+
export const ColumnDropIndicator = ({ visible, position, color = '#3b82f6', }) => _jsx(DropIndicator, { "$visible": visible, "$position": position, "$color": color });
|
|
507
|
+
// ============================================================================
|
|
508
|
+
// Helper: Get header cell wrapper props
|
|
509
|
+
// ============================================================================
|
|
510
|
+
export function getReorderableHeaderProps(column, index, getDragHandleProps, isDragging, draggedColumn, dragOverColumn) {
|
|
511
|
+
const wrapperProps = getDragHandleProps(column, index);
|
|
512
|
+
const showDropIndicator = isDragging && dragOverColumn === column.dataField && draggedColumn !== column.dataField;
|
|
513
|
+
return {
|
|
514
|
+
wrapperProps,
|
|
515
|
+
showDropIndicator,
|
|
516
|
+
dropPosition: 'left', // Always show on left side
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
// ============================================================================
|
|
520
|
+
// Export
|
|
521
|
+
// ============================================================================
|
|
522
|
+
export default {
|
|
523
|
+
useColumnReorder,
|
|
524
|
+
DragGhost,
|
|
525
|
+
DropIndicator,
|
|
526
|
+
DraggableHeader,
|
|
527
|
+
ColumnReorderGhost,
|
|
528
|
+
ColumnDropIndicator,
|
|
529
|
+
getReorderableHeaderProps,
|
|
530
|
+
};
|