@fileverse-dev/fortune-react 1.1.90 → 1.1.91

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.
@@ -448,58 +448,58 @@ export var CurrencySelector = function CurrencySelector(_a) {
448
448
  }));
449
449
  };
450
450
  var Toolbar = function Toolbar(_a) {
451
- var _b, _c, _d;
451
+ var _b, _c, _d, _e;
452
452
  var setMoreItems = _a.setMoreItems,
453
453
  moreItemsOpen = _a.moreItemsOpen,
454
454
  onMoreToolbarItemsClose = _a.onMoreToolbarItemsClose,
455
455
  moreToolbarItems = _a.moreToolbarItems;
456
- var _e = useContext(WorkbookContext),
457
- context = _e.context,
458
- setContext = _e.setContext,
459
- refs = _e.refs,
460
- settings = _e.settings,
461
- handleUndo = _e.handleUndo,
462
- handleRedo = _e.handleRedo;
456
+ var _f = useContext(WorkbookContext),
457
+ context = _f.context,
458
+ setContext = _f.setContext,
459
+ refs = _f.refs,
460
+ settings = _f.settings,
461
+ handleUndo = _f.handleUndo,
462
+ handleRedo = _f.handleRedo;
463
463
  var contextRef = useRef(context);
464
464
  var containerRef = useRef(null);
465
- var _f = useState(-1),
466
- toolbarWrapIndex = _f[0],
467
- setToolbarWrapIndex = _f[1];
468
- var _g = useState([]),
469
- itemLocations = _g[0],
470
- setItemLocations = _g[1];
471
- var _h = useState(false),
472
- showDuneModal = _h[0],
473
- setShowDuneModal = _h[1];
474
- var _j = useState(window.innerWidth >= 1280),
475
- isDesktop = _j[0],
476
- setIsDesktop = _j[1];
477
- var _k = useDialog(),
478
- showDialog = _k.showDialog,
479
- hideDialog = _k.hideDialog;
465
+ var _g = useState(-1),
466
+ toolbarWrapIndex = _g[0],
467
+ setToolbarWrapIndex = _g[1];
468
+ var _h = useState([]),
469
+ itemLocations = _h[0],
470
+ setItemLocations = _h[1];
471
+ var _j = useState(false),
472
+ showDuneModal = _j[0],
473
+ setShowDuneModal = _j[1];
474
+ var _k = useState(window.innerWidth >= 1280),
475
+ isDesktop = _k[0],
476
+ setIsDesktop = _k[1];
477
+ var _l = useDialog(),
478
+ showDialog = _l.showDialog,
479
+ hideDialog = _l.hideDialog;
480
480
  var firstSelection = (_b = context.luckysheet_select_save) === null || _b === void 0 ? void 0 : _b[0];
481
481
  var flowdata = getFlowdata(context);
482
482
  contextRef.current = context;
483
483
  var row = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus;
484
484
  var col = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus;
485
485
  var cell = flowdata && row != null && col != null ? (_c = flowdata === null || flowdata === void 0 ? void 0 : flowdata[row]) === null || _c === void 0 ? void 0 : _c[col] : undefined;
486
- var _l = locale(context),
487
- toolbar = _l.toolbar,
488
- merge = _l.merge,
489
- border = _l.border,
490
- freezen = _l.freezen,
491
- defaultFmt = _l.defaultFmt,
492
- formula = _l.formula,
493
- sort = _l.sort,
494
- align = _l.align,
495
- textWrap = _l.textWrap,
496
- rotation = _l.rotation,
497
- screenshot = _l.screenshot,
498
- filter = _l.filter,
499
- splitText = _l.splitText,
500
- findAndReplace = _l.findAndReplace,
501
- comment = _l.comment,
502
- fontarray = _l.fontarray;
486
+ var _m = locale(context),
487
+ toolbar = _m.toolbar,
488
+ merge = _m.merge,
489
+ border = _m.border,
490
+ freezen = _m.freezen,
491
+ defaultFmt = _m.defaultFmt,
492
+ formula = _m.formula,
493
+ sort = _m.sort,
494
+ align = _m.align,
495
+ textWrap = _m.textWrap,
496
+ rotation = _m.rotation,
497
+ screenshot = _m.screenshot,
498
+ filter = _m.filter,
499
+ splitText = _m.splitText,
500
+ findAndReplace = _m.findAndReplace,
501
+ comment = _m.comment,
502
+ fontarray = _m.fontarray;
503
503
  var toolbarFormat = locale(context).format;
504
504
  var sheetWidth = context.luckysheetTableContentHW[0];
505
505
  var currency = settings.currency;
@@ -534,6 +534,9 @@ var Toolbar = function Toolbar(_a) {
534
534
  subMenu.style.display = "none";
535
535
  }, []);
536
536
  useEffect(function () {
537
+ window.getDataValidationComponent = function () {
538
+ return /*#__PURE__*/React.createElement(DataVerification, null);
539
+ };
537
540
  var handleResize = function handleResize() {
538
541
  setIsDesktop(window.innerWidth >= 1280);
539
542
  };
@@ -965,8 +968,8 @@ var Toolbar = function Toolbar(_a) {
965
968
  tooltip: tooltip,
966
969
  key: name,
967
970
  onClick: function onClick() {
968
- if (context.allowEdit === false) return;
969
- showDialog(/*#__PURE__*/React.createElement(DataVerification, null), undefined, toolbar.dataVerification);
971
+ var _a;
972
+ (_a = document.getElementById("data-verification-button")) === null || _a === void 0 ? void 0 : _a.click();
970
973
  }
971
974
  });
972
975
  }
@@ -1643,7 +1646,7 @@ var Toolbar = function Toolbar(_a) {
1643
1646
  });
1644
1647
  }
1645
1648
  }));
1646
- }, [toolbar, cell, setContext, refs.cellInput, refs.fxInput, refs.globalCache, defaultFormat, align, handleUndo, handleRedo, flowdata, formula, showDuneModal, merge, border, freezen, screenshot, sort, textWrap, rotation, filter, splitText, findAndReplace, context.luckysheet_select_save, context.defaultFontSize, context.allowEdit, comment, fontarray, hideSubMenu, showSubMenu, refs.canvas, customColor, customStyle, toolbarFormat.moreCurrency]);
1649
+ }, [toolbar, cell, setContext, refs.cellInput, refs.fxInput, refs.globalCache, defaultFormat, align, handleUndo, handleRedo, flowdata, formula, showDuneModal, merge, border, freezen, screenshot, sort, textWrap, rotation, filter, splitText, findAndReplace, context.luckysheet_select_save, context.defaultFontSize, context.allowEdit, comment, fontarray, hideSubMenu, showSubMenu, refs.canvas, customColor, customStyle, toolbarFormat.moreCurrency, (_d = context.dataVerification) === null || _d === void 0 ? void 0 : _d.dataRegulation]);
1647
1650
  return /*#__PURE__*/React.createElement("div", {
1648
1651
  ref: containerRef,
1649
1652
  className: "fortune-toolbar",
@@ -1660,7 +1663,7 @@ var Toolbar = function Toolbar(_a) {
1660
1663
  icon: n.icon,
1661
1664
  iconName: n.iconName
1662
1665
  }, n.children);
1663
- }), ((_d = settings.customToolbarItems) === null || _d === void 0 ? void 0 : _d.length) > 0 ? (/*#__PURE__*/React.createElement(Divider, {
1666
+ }), ((_e = settings.customToolbarItems) === null || _e === void 0 ? void 0 : _e.length) > 0 ? (/*#__PURE__*/React.createElement(Divider, {
1664
1667
  key: "customDivider"
1665
1668
  })) : null, (toolbarWrapIndex === -1 || isDesktop ? settings.toolbarItems : settings.toolbarItems.slice(0, toolbarWrapIndex + 1)).map(function (name, i) {
1666
1669
  return getToolbarItem(name, i);
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ export declare const TEXT_COLORS: {
3
+ name: string;
4
+ value: string;
5
+ }[];
6
+ export declare const ColorSection: ({ onPick, trigerColor, }: {
7
+ onPick: (color: string) => void;
8
+ trigerColor: string;
9
+ }) => React.JSX.Element;
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.TEXT_COLORS = exports.ColorSection = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _lucideReact = require("lucide-react");
10
+ var _ui = require("@fileverse/ui");
11
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
12
+ var TEXT_COLORS = exports.TEXT_COLORS = [{
13
+ name: "Light Gray",
14
+ value: "228, 232, 237"
15
+ }, {
16
+ name: "White",
17
+ value: "249, 249, 249"
18
+ }, {
19
+ name: "Pink",
20
+ value: "244, 217, 227"
21
+ }, {
22
+ name: "Peach",
23
+ value: "247, 229, 207"
24
+ }, {
25
+ name: "Blue",
26
+ value: "217, 234, 244"
27
+ }, {
28
+ name: "Green",
29
+ value: "222, 239, 222"
30
+ }, {
31
+ name: "Light Green",
32
+ value: "239, 239, 239"
33
+ }, {
34
+ name: "Rose",
35
+ value: "244, 230, 230"
36
+ }, {
37
+ name: "Yellow",
38
+ value: "247, 239, 217"
39
+ }, {
40
+ name: "Purple",
41
+ value: "230, 230, 244"
42
+ }, {
43
+ name: "Cyan",
44
+ value: "217, 244, 244"
45
+ }, {
46
+ name: "Cream",
47
+ value: "244, 239, 234"
48
+ }];
49
+ var ColorSection = exports.ColorSection = function ColorSection(_a) {
50
+ var onPick = _a.onPick,
51
+ trigerColor = _a.trigerColor;
52
+ var _b = (0, _react.useState)(false),
53
+ isOpen = _b[0],
54
+ setIsOpen = _b[1];
55
+ return /*#__PURE__*/_react.default.createElement(_ui.Popover, {
56
+ open: isOpen,
57
+ onOpenChange: function onOpenChange(open) {
58
+ setIsOpen(open);
59
+ }
60
+ }, /*#__PURE__*/_react.default.createElement(_ui.PopoverTrigger, {
61
+ className: "hover:bg-red",
62
+ style: {
63
+ backgroundColor: "red!important"
64
+ }
65
+ }, /*#__PURE__*/_react.default.createElement("div", {
66
+ className: "flex items-center justify-between color-picker rounded transition-all cursor-pointer border border-gray-300",
67
+ style: {
68
+ padding: "7px"
69
+ }
70
+ }, /*#__PURE__*/_react.default.createElement("div", {
71
+ className: "flex items-center gap-3 color-text-secondary"
72
+ }, /*#__PURE__*/_react.default.createElement("div", {
73
+ className: "w-5 h-5 rounded-full",
74
+ style: {
75
+ backgroundColor: "rgb(".concat(trigerColor, ")")
76
+ }
77
+ }), /*#__PURE__*/_react.default.createElement(_lucideReact.ChevronDown, {
78
+ size: 18,
79
+ className: "transition-transform ".concat(isOpen ? "rotate-180" : "")
80
+ })))), /*#__PURE__*/_react.default.createElement(_ui.PopoverContent, {
81
+ align: "start",
82
+ alignOffset: 0,
83
+ className: "w-[200px] export-content-popover",
84
+ elevation: 2,
85
+ side: "bottom",
86
+ sideOffset: 4
87
+ }, /*#__PURE__*/_react.default.createElement("div", {
88
+ className: "transition-all p-2 duration-200 w-full"
89
+ }, /*#__PURE__*/_react.default.createElement("div", {
90
+ className: "flex gap-2 flex-wrap w-full"
91
+ }, TEXT_COLORS.map(function (color) {
92
+ return /*#__PURE__*/_react.default.createElement("button", {
93
+ type: "button",
94
+ key: color.value,
95
+ onClick: function onClick() {
96
+ onPick(color.value);
97
+ setIsOpen(false);
98
+ },
99
+ className: "w-7 h-7 rounded-full transition-all hover:scale-110 hover:shadow-md",
100
+ style: {
101
+ backgroundColor: "rgb(".concat(color.value, ")")
102
+ },
103
+ title: color.name
104
+ });
105
+ })))));
106
+ };
@@ -30,11 +30,10 @@ var DropDownList = function DropDownList() {
30
30
  var _e = (0, _react.useState)([]),
31
31
  selected = _e[0],
32
32
  setSelected = _e[1];
33
- var close = (0, _react.useCallback)(function () {
34
- setContext(function (ctx) {
35
- ctx.dataVerificationDropDownList = false;
36
- });
37
- }, [setContext]);
33
+ var _f = (0, _react.useState)([]),
34
+ rbgColor = _f[0],
35
+ setRbgColor = _f[1];
36
+ var close = (0, _react.useCallback)(function () {}, [setContext]);
38
37
  (0, _useOutsideClick.useOutsideClick)(containerRef, close, [close]);
39
38
  (0, _react.useEffect)(function () {
40
39
  var _a, _b;
@@ -54,19 +53,30 @@ var DropDownList = function DropDownList() {
54
53
  }
55
54
  var index = (0, _fortuneCore.getSheetIndex)(context, context.currentSheetId);
56
55
  var dataVerification = context.luckysheetfile[index].dataVerification;
56
+ if (!dataVerification) return;
57
57
  var item = dataVerification["".concat(rowIndex, "_").concat(colIndex)];
58
+ if (!item) return;
58
59
  var dropdownList = (0, _fortuneCore.getDropdownList)(context, item.value1);
59
60
  var cellValue = (0, _fortuneCore.getCellValue)(rowIndex, colIndex, d);
60
61
  if (cellValue) {
61
62
  setSelected(cellValue.toString().split(","));
62
63
  }
64
+ var color = item.color;
65
+ var colorValues = color === null || color === void 0 ? void 0 : color.split(",").map(function (v) {
66
+ return v.trim();
67
+ });
68
+ var rbgColorArr = [];
69
+ for (var i = 0; i < colorValues.length; i += 3) {
70
+ rbgColorArr.push(colorValues.slice(i, i + 3).join(", "));
71
+ }
72
+ setRbgColor(rbgColorArr);
63
73
  setList(dropdownList);
64
74
  setPosition({
65
75
  left: col_pre,
66
76
  top: row
67
77
  });
68
78
  setIsMul(item.type2 === "true");
69
- }, []);
79
+ }, [context.luckysheet_select_save]);
70
80
  (0, _react.useEffect)(function () {
71
81
  if (!context.luckysheet_select_save) return;
72
82
  var last = context.luckysheet_select_save[context.luckysheet_select_save.length - 1];
@@ -75,7 +85,9 @@ var DropDownList = function DropDownList() {
75
85
  if (rowIndex == null || colIndex == null) return;
76
86
  var index = (0, _fortuneCore.getSheetIndex)(context, context.currentSheetId);
77
87
  var dataVerification = context.luckysheetfile[index].dataVerification;
88
+ if (!dataVerification) return;
78
89
  var item = dataVerification["".concat(rowIndex, "_").concat(colIndex)];
90
+ if (!item) return;
79
91
  if (item.type2 !== "true") return;
80
92
  var d = (0, _fortuneCore.getFlowdata)(context);
81
93
  if (!d) return;
@@ -106,7 +118,10 @@ var DropDownList = function DropDownList() {
106
118
  tabIndex: 0
107
119
  }, list.map(function (v, i) {
108
120
  return /*#__PURE__*/_react.default.createElement("div", {
109
- className: "dropdown-List-item",
121
+ className: "dropdown-List-item mb-1",
122
+ style: {
123
+ backgroundColor: "rgb(".concat(rbgColor[i], ")") || "red"
124
+ },
110
125
  key: i,
111
126
  onClick: function onClick() {
112
127
  setContext(function (ctx) {
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ type Item = {
3
+ id: string;
4
+ value: string;
5
+ color?: string | null;
6
+ };
7
+ declare const DynamicInputList: ({ optionItems, setOptionItems, }: {
8
+ optionItems: Item[];
9
+ setOptionItems: React.Dispatch<React.SetStateAction<Item[]>>;
10
+ }) => React.JSX.Element;
11
+ export default DynamicInputList;
@@ -0,0 +1,271 @@
1
+ "use strict";
2
+ "use client";
3
+
4
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _ui = require("@fileverse/ui");
11
+ var _ColorPicker = require("./ColorPicker");
12
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
13
+ var __assign = void 0 && (void 0).__assign || function () {
14
+ __assign = Object.assign || function (t) {
15
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
16
+ s = arguments[i];
17
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
18
+ }
19
+ return t;
20
+ };
21
+ return __assign.apply(this, arguments);
22
+ };
23
+ var __spreadArray = void 0 && (void 0).__spreadArray || function (to, from, pack) {
24
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
25
+ if (ar || !(i in from)) {
26
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
27
+ ar[i] = from[i];
28
+ }
29
+ }
30
+ return to.concat(ar || Array.prototype.slice.call(from));
31
+ };
32
+ function createId() {
33
+ return "".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2));
34
+ }
35
+ var DynamicInputList = function DynamicInputList(_a) {
36
+ var optionItems = _a.optionItems,
37
+ setOptionItems = _a.setOptionItems;
38
+ var dragFromIndexRef = (0, _react.useRef)(null);
39
+ var _b = (0, _react.useState)(null),
40
+ draggingIndex = _b[0],
41
+ setDraggingIndex = _b[1];
42
+ var _c = (0, _react.useState)(null),
43
+ overPosition = _c[0],
44
+ setOverPosition = _c[1];
45
+ var dragPreviewRef = (0, _react.useRef)(null);
46
+ var handleAdd = function handleAdd() {
47
+ var nextNum = optionItems.length + 1;
48
+ setOptionItems(function (prev) {
49
+ return __spreadArray(__spreadArray([], prev, true), [{
50
+ id: createId(),
51
+ value: "Option ".concat(nextNum),
52
+ color: "228, 232, 237"
53
+ }], false);
54
+ });
55
+ };
56
+ (0, _react.useEffect)(function () {
57
+ handleAdd();
58
+ }, []);
59
+ var handleRemove = function handleRemove(index) {
60
+ setOptionItems(function (prev) {
61
+ return prev.filter(function (_, i) {
62
+ return i !== index;
63
+ });
64
+ });
65
+ };
66
+ var handleChange = function handleChange(index, v) {
67
+ setOptionItems(function (prev) {
68
+ var next = prev.slice();
69
+ next[index] = __assign(__assign({}, next[index]), {
70
+ value: v
71
+ });
72
+ return next;
73
+ });
74
+ };
75
+ function createDragPreview(node, cursorX, cursorY) {
76
+ if (cursorX === void 0) {
77
+ cursorX = 20;
78
+ }
79
+ if (cursorY === void 0) {
80
+ cursorY = 10;
81
+ }
82
+ var rect = node.getBoundingClientRect();
83
+ var clone = node.cloneNode(true);
84
+ clone.style.position = "fixed";
85
+ clone.style.top = "".concat(rect.top, "px");
86
+ clone.style.left = "".concat(rect.left, "px");
87
+ clone.style.width = "".concat(rect.width, "px");
88
+ clone.style.pointerEvents = "none";
89
+ clone.style.zIndex = "9999";
90
+ clone.style.transform = "scale(0.98)";
91
+ clone.style.borderRadius = "12px";
92
+ clone.style.background = getComputedStyle(document.documentElement).getPropertyValue("--color-card") || "white";
93
+ clone.style.boxShadow = "0 8px 24px rgba(0,0,0,0.15), 0 2px 6px rgba(0,0,0,0.08)";
94
+ clone.style.opacity = "0.95";
95
+ document.body.appendChild(clone);
96
+ return {
97
+ clone: clone,
98
+ offsetX: cursorX,
99
+ offsetY: cursorY
100
+ };
101
+ }
102
+ var _onDragStart = function onDragStart(index, e) {
103
+ dragFromIndexRef.current = index;
104
+ setDraggingIndex(index);
105
+ e.dataTransfer.effectAllowed = "move";
106
+ e.dataTransfer.setData("text/plain", String(index));
107
+ var handle = e.currentTarget;
108
+ var row = handle.closest("li");
109
+ if (row) {
110
+ var preview = createDragPreview(row);
111
+ dragPreviewRef.current = preview.clone;
112
+ try {
113
+ e.dataTransfer.setDragImage(preview.clone, preview.offsetX, preview.offsetY);
114
+ } catch (_a) {}
115
+ }
116
+ };
117
+ var onDragEnd = function onDragEnd() {
118
+ if (dragPreviewRef.current && dragPreviewRef.current.parentNode) {
119
+ dragPreviewRef.current.parentNode.removeChild(dragPreviewRef.current);
120
+ }
121
+ dragPreviewRef.current = null;
122
+ setDraggingIndex(null);
123
+ setOverPosition(null);
124
+ dragFromIndexRef.current = null;
125
+ };
126
+ var onDragOverRow = function onDragOverRow(index, e) {
127
+ e.preventDefault();
128
+ e.dataTransfer.dropEffect = "move";
129
+ var target = e.currentTarget;
130
+ var rect = target.getBoundingClientRect();
131
+ var halfway = rect.top + rect.height / 2;
132
+ var pos = e.clientY < halfway ? "before" : "after";
133
+ setOverPosition(pos);
134
+ };
135
+ var onDragLeaveRow = function onDragLeaveRow() {};
136
+ function move(list, from, to) {
137
+ var result = list.slice();
138
+ var removed = result.splice(from, 1)[0];
139
+ result.splice(to, 0, removed);
140
+ return result;
141
+ }
142
+ var onDropRow = function onDropRow(index, e) {
143
+ e.preventDefault();
144
+ var fromText = e.dataTransfer.getData("text/plain");
145
+ var fromIndex = Number.isNaN(Number(fromText)) ? dragFromIndexRef.current : Number(fromText);
146
+ if (fromIndex == null) {
147
+ setOverPosition(null);
148
+ return;
149
+ }
150
+ var dest = index;
151
+ if (overPosition === "after") {
152
+ dest = index + 1;
153
+ }
154
+ var adjustedDest = fromIndex < dest ? dest - 1 : dest;
155
+ if (fromIndex !== adjustedDest) {
156
+ setOptionItems(function (prev) {
157
+ return move(prev, fromIndex, Math.max(0, Math.min(prev.length, adjustedDest)));
158
+ });
159
+ }
160
+ setOverPosition(null);
161
+ dragFromIndexRef.current = null;
162
+ setDraggingIndex(null);
163
+ if (dragPreviewRef.current && dragPreviewRef.current.parentNode) {
164
+ dragPreviewRef.current.parentNode.removeChild(dragPreviewRef.current);
165
+ dragPreviewRef.current = null;
166
+ }
167
+ };
168
+ var handleColorChange = function handleColorChange(index, color) {
169
+ setOptionItems(function (prev) {
170
+ var next = prev.slice();
171
+ next[index] = __assign(__assign({}, next[index]), {
172
+ color: color
173
+ });
174
+ return next;
175
+ });
176
+ };
177
+ return /*#__PURE__*/_react.default.createElement("div", {
178
+ className: "mx-auto max-w-2xl"
179
+ }, /*#__PURE__*/_react.default.createElement("ul", {
180
+ className: "flex flex-col"
181
+ }, optionItems.map(function (item, index) {
182
+ return /*#__PURE__*/_react.default.createElement("li", {
183
+ key: item.id,
184
+ className: (0, _ui.cn)("relative flex optionItems-center gap-3 transition mb-4", draggingIndex === index && "scale-[0.99] opacity-80 shadow-lg rounded-xl"),
185
+ onDragOver: function onDragOver(e) {
186
+ return onDragOverRow(index, e);
187
+ },
188
+ onDragLeave: onDragLeaveRow,
189
+ onDrop: function onDrop(e) {
190
+ return onDropRow(index, e);
191
+ }
192
+ }, /*#__PURE__*/_react.default.createElement("div", {
193
+ className: "cursor-grab p-2 text-muted-foreground hover:text-foreground active:cursor-grabbing",
194
+ draggable: true,
195
+ onDragStart: function onDragStart(e) {
196
+ return _onDragStart(index, e);
197
+ },
198
+ onDragEnd: onDragEnd,
199
+ "aria-label": "Drag handle for row ".concat(index + 1),
200
+ title: "Drag to reorder",
201
+ style: {
202
+ cursor: "grab"
203
+ }
204
+ }, /*#__PURE__*/_react.default.createElement("svg", {
205
+ xmlns: "http://www.w3.org/2000/svg",
206
+ width: "16",
207
+ height: "20",
208
+ viewBox: "0 0 16 20",
209
+ fill: "currentColor",
210
+ "aria-hidden": "true"
211
+ }, /*#__PURE__*/_react.default.createElement("circle", {
212
+ cx: "4",
213
+ cy: "5",
214
+ r: "1.5"
215
+ }), /*#__PURE__*/_react.default.createElement("circle", {
216
+ cx: "4",
217
+ cy: "10",
218
+ r: "1.5"
219
+ }), /*#__PURE__*/_react.default.createElement("circle", {
220
+ cx: "4",
221
+ cy: "15",
222
+ r: "1.5"
223
+ }), /*#__PURE__*/_react.default.createElement("circle", {
224
+ cx: "10",
225
+ cy: "5",
226
+ r: "1.5"
227
+ }), /*#__PURE__*/_react.default.createElement("circle", {
228
+ cx: "10",
229
+ cy: "10",
230
+ r: "1.5"
231
+ }), /*#__PURE__*/_react.default.createElement("circle", {
232
+ cx: "10",
233
+ cy: "15",
234
+ r: "1.5"
235
+ }))), /*#__PURE__*/_react.default.createElement("div", {
236
+ className: "flex optionItems-center"
237
+ }, /*#__PURE__*/_react.default.createElement(_ColorPicker.ColorSection, {
238
+ onPick: function onPick(c) {
239
+ return handleColorChange(index, c);
240
+ },
241
+ trigerColor: item.color
242
+ })), /*#__PURE__*/_react.default.createElement("div", {
243
+ className: "flex flex-1 optionItems-center transition"
244
+ }, /*#__PURE__*/_react.default.createElement(_ui.TextField, {
245
+ className: "w-full",
246
+ placeholder: "Option ".concat(index + 1),
247
+ value: item.value,
248
+ onChange: function onChange(e) {
249
+ return handleChange(index, e.target.value);
250
+ },
251
+ "aria-label": "Option ".concat(index + 1)
252
+ })), /*#__PURE__*/_react.default.createElement(_ui.IconButton, {
253
+ icon: "Trash2",
254
+ type: "button",
255
+ variant: "ghost",
256
+ onClick: function onClick() {
257
+ return handleRemove(index);
258
+ },
259
+ className: "",
260
+ "aria-label": "Delete row ".concat(index + 1),
261
+ title: "Delete"
262
+ }));
263
+ })), /*#__PURE__*/_react.default.createElement("div", {
264
+ className: "mt-8"
265
+ }, /*#__PURE__*/_react.default.createElement(_ui.Button, {
266
+ variant: "secondary",
267
+ onClick: handleAdd,
268
+ className: ""
269
+ }, "Add another item")));
270
+ };
271
+ var _default = exports.default = DynamicInputList;
@@ -199,4 +199,8 @@
199
199
 
200
200
  .data-verification-checkbox-label {
201
201
  min-width: 100px;
202
+ }
203
+
204
+ .color-picker:hover {
205
+ background: hsl(var(--color-bg-default-hover, #F2F4F5));
202
206
  }