hazo_ui 2.2.3 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +255 -0
- package/dist/index.cjs +2685 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +60 -13
- package/dist/index.d.ts +60 -13
- package/dist/index.js +2650 -35
- package/dist/index.js.map +1 -1
- package/dist/styles.css +41 -49
- package/package.json +29 -3
- package/tailwind.preset.js +6 -2
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var React6 = require('react');
|
|
3
|
+
var React23 = require('react');
|
|
5
4
|
var reactSlot = require('@radix-ui/react-slot');
|
|
6
5
|
var classVarianceAuthority = require('class-variance-authority');
|
|
7
6
|
var clsx = require('clsx');
|
|
8
7
|
var tailwindMerge = require('tailwind-merge');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
9
|
var DialogPrimitive = require('@radix-ui/react-dialog');
|
|
10
10
|
var lucideReact = require('lucide-react');
|
|
11
11
|
var PopoverPrimitive = require('@radix-ui/react-popover');
|
|
@@ -14,7 +14,7 @@ var TooltipPrimitive = require('@radix-ui/react-tooltip');
|
|
|
14
14
|
var reactDayPicker = require('react-day-picker');
|
|
15
15
|
var dateFns = require('date-fns');
|
|
16
16
|
var SwitchPrimitives = require('@radix-ui/react-switch');
|
|
17
|
-
var core = require('@dnd-kit/core');
|
|
17
|
+
var core$1 = require('@dnd-kit/core');
|
|
18
18
|
var sortable = require('@dnd-kit/sortable');
|
|
19
19
|
var utilities = require('@dnd-kit/utilities');
|
|
20
20
|
var RadioGroupPrimitive = require('@radix-ui/react-radio-group');
|
|
@@ -29,6 +29,32 @@ var IoIcons = require('react-icons/io5');
|
|
|
29
29
|
var RiIcons = require('react-icons/ri');
|
|
30
30
|
var TbIcons = require('react-icons/tb');
|
|
31
31
|
var CiIcons = require('react-icons/ci');
|
|
32
|
+
var react = require('@tiptap/react');
|
|
33
|
+
var StarterKit = require('@tiptap/starter-kit');
|
|
34
|
+
var extensionTextStyle = require('@tiptap/extension-text-style');
|
|
35
|
+
var FontFamily = require('@tiptap/extension-font-family');
|
|
36
|
+
var Underline = require('@tiptap/extension-underline');
|
|
37
|
+
var Subscript = require('@tiptap/extension-subscript');
|
|
38
|
+
var Superscript = require('@tiptap/extension-superscript');
|
|
39
|
+
var Link = require('@tiptap/extension-link');
|
|
40
|
+
var TextAlign = require('@tiptap/extension-text-align');
|
|
41
|
+
var Highlight = require('@tiptap/extension-highlight');
|
|
42
|
+
var Color = require('@tiptap/extension-color');
|
|
43
|
+
var Image = require('@tiptap/extension-image');
|
|
44
|
+
var Placeholder = require('@tiptap/extension-placeholder');
|
|
45
|
+
var HorizontalRule = require('@tiptap/extension-horizontal-rule');
|
|
46
|
+
var extensionTable = require('@tiptap/extension-table');
|
|
47
|
+
var TableRow = require('@tiptap/extension-table-row');
|
|
48
|
+
var TableCell = require('@tiptap/extension-table-cell');
|
|
49
|
+
var TableHeader = require('@tiptap/extension-table-header');
|
|
50
|
+
var TaskList = require('@tiptap/extension-task-list');
|
|
51
|
+
var TaskItem = require('@tiptap/extension-task-item');
|
|
52
|
+
var lu = require('react-icons/lu');
|
|
53
|
+
var rx = require('react-icons/rx');
|
|
54
|
+
var core = require('@tiptap/core');
|
|
55
|
+
var TabsPrimitive = require('@radix-ui/react-tabs');
|
|
56
|
+
|
|
57
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
32
58
|
|
|
33
59
|
function _interopNamespace(e) {
|
|
34
60
|
if (e && e.__esModule) return e;
|
|
@@ -48,7 +74,7 @@ function _interopNamespace(e) {
|
|
|
48
74
|
return Object.freeze(n);
|
|
49
75
|
}
|
|
50
76
|
|
|
51
|
-
var
|
|
77
|
+
var React23__namespace = /*#__PURE__*/_interopNamespace(React23);
|
|
52
78
|
var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
|
|
53
79
|
var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
|
|
54
80
|
var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive);
|
|
@@ -66,10 +92,82 @@ var IoIcons__namespace = /*#__PURE__*/_interopNamespace(IoIcons);
|
|
|
66
92
|
var RiIcons__namespace = /*#__PURE__*/_interopNamespace(RiIcons);
|
|
67
93
|
var TbIcons__namespace = /*#__PURE__*/_interopNamespace(TbIcons);
|
|
68
94
|
var CiIcons__namespace = /*#__PURE__*/_interopNamespace(CiIcons);
|
|
95
|
+
var StarterKit__default = /*#__PURE__*/_interopDefault(StarterKit);
|
|
96
|
+
var FontFamily__default = /*#__PURE__*/_interopDefault(FontFamily);
|
|
97
|
+
var Underline__default = /*#__PURE__*/_interopDefault(Underline);
|
|
98
|
+
var Subscript__default = /*#__PURE__*/_interopDefault(Subscript);
|
|
99
|
+
var Superscript__default = /*#__PURE__*/_interopDefault(Superscript);
|
|
100
|
+
var Link__default = /*#__PURE__*/_interopDefault(Link);
|
|
101
|
+
var TextAlign__default = /*#__PURE__*/_interopDefault(TextAlign);
|
|
102
|
+
var Highlight__default = /*#__PURE__*/_interopDefault(Highlight);
|
|
103
|
+
var Color__default = /*#__PURE__*/_interopDefault(Color);
|
|
104
|
+
var Image__default = /*#__PURE__*/_interopDefault(Image);
|
|
105
|
+
var Placeholder__default = /*#__PURE__*/_interopDefault(Placeholder);
|
|
106
|
+
var HorizontalRule__default = /*#__PURE__*/_interopDefault(HorizontalRule);
|
|
107
|
+
var TableRow__default = /*#__PURE__*/_interopDefault(TableRow);
|
|
108
|
+
var TableCell__default = /*#__PURE__*/_interopDefault(TableCell);
|
|
109
|
+
var TableHeader__default = /*#__PURE__*/_interopDefault(TableHeader);
|
|
110
|
+
var TaskList__default = /*#__PURE__*/_interopDefault(TaskList);
|
|
111
|
+
var TaskItem__default = /*#__PURE__*/_interopDefault(TaskItem);
|
|
112
|
+
var TabsPrimitive__namespace = /*#__PURE__*/_interopNamespace(TabsPrimitive);
|
|
69
113
|
|
|
70
|
-
var
|
|
71
|
-
|
|
114
|
+
var __create = Object.create;
|
|
115
|
+
var __defProp = Object.defineProperty;
|
|
116
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
117
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
118
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
119
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
120
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
121
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
122
|
+
};
|
|
123
|
+
var __copyProps = (to, from, except, desc) => {
|
|
124
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
125
|
+
for (let key of __getOwnPropNames(from))
|
|
126
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
127
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
128
|
+
}
|
|
129
|
+
return to;
|
|
72
130
|
};
|
|
131
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
132
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
133
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
134
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
135
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
136
|
+
!mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
137
|
+
mod
|
|
138
|
+
));
|
|
139
|
+
|
|
140
|
+
// node_modules/@babel/runtime/helpers/extends.js
|
|
141
|
+
var require_extends = __commonJS({
|
|
142
|
+
"node_modules/@babel/runtime/helpers/extends.js"(exports$1, module) {
|
|
143
|
+
function _extends11() {
|
|
144
|
+
return module.exports = _extends11 = Object.assign ? Object.assign.bind() : function(n) {
|
|
145
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
146
|
+
var t = arguments[e];
|
|
147
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
148
|
+
}
|
|
149
|
+
return n;
|
|
150
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _extends11.apply(null, arguments);
|
|
151
|
+
}
|
|
152
|
+
module.exports = _extends11, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// node_modules/@babel/runtime/helpers/objectWithoutPropertiesLoose.js
|
|
157
|
+
var require_objectWithoutPropertiesLoose = __commonJS({
|
|
158
|
+
"node_modules/@babel/runtime/helpers/objectWithoutPropertiesLoose.js"(exports$1, module) {
|
|
159
|
+
function _objectWithoutPropertiesLoose10(r, e) {
|
|
160
|
+
if (null == r) return {};
|
|
161
|
+
var t = {};
|
|
162
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
163
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
164
|
+
t[n] = r[n];
|
|
165
|
+
}
|
|
166
|
+
return t;
|
|
167
|
+
}
|
|
168
|
+
module.exports = _objectWithoutPropertiesLoose10, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
169
|
+
}
|
|
170
|
+
});
|
|
73
171
|
function cn(...inputs) {
|
|
74
172
|
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
75
173
|
}
|
|
@@ -98,7 +196,7 @@ var buttonVariants = classVarianceAuthority.cva(
|
|
|
98
196
|
}
|
|
99
197
|
}
|
|
100
198
|
);
|
|
101
|
-
var Button =
|
|
199
|
+
var Button = React23__namespace.forwardRef(
|
|
102
200
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
103
201
|
const Comp = asChild ? reactSlot.Slot : "button";
|
|
104
202
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -115,7 +213,7 @@ Button.displayName = "Button";
|
|
|
115
213
|
var Dialog = DialogPrimitive__namespace.Root;
|
|
116
214
|
var DialogTrigger = DialogPrimitive__namespace.Trigger;
|
|
117
215
|
var DialogPortal = DialogPrimitive__namespace.Portal;
|
|
118
|
-
var DialogOverlay =
|
|
216
|
+
var DialogOverlay = React23__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
119
217
|
DialogPrimitive__namespace.Overlay,
|
|
120
218
|
{
|
|
121
219
|
ref,
|
|
@@ -127,7 +225,7 @@ var DialogOverlay = React6__namespace.forwardRef(({ className, ...props }, ref)
|
|
|
127
225
|
}
|
|
128
226
|
));
|
|
129
227
|
DialogOverlay.displayName = DialogPrimitive__namespace.Overlay.displayName;
|
|
130
|
-
var DialogContent =
|
|
228
|
+
var DialogContent = React23__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(DialogPortal, { children: [
|
|
131
229
|
/* @__PURE__ */ jsxRuntime.jsx(DialogOverlay, {}),
|
|
132
230
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
133
231
|
DialogPrimitive__namespace.Content,
|
|
@@ -177,7 +275,7 @@ var DialogFooter = ({
|
|
|
177
275
|
}
|
|
178
276
|
);
|
|
179
277
|
DialogFooter.displayName = "DialogFooter";
|
|
180
|
-
var DialogTitle =
|
|
278
|
+
var DialogTitle = React23__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
181
279
|
DialogPrimitive__namespace.Title,
|
|
182
280
|
{
|
|
183
281
|
ref,
|
|
@@ -189,7 +287,7 @@ var DialogTitle = React6__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
189
287
|
}
|
|
190
288
|
));
|
|
191
289
|
DialogTitle.displayName = DialogPrimitive__namespace.Title.displayName;
|
|
192
|
-
var DialogDescription =
|
|
290
|
+
var DialogDescription = React23__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
193
291
|
DialogPrimitive__namespace.Description,
|
|
194
292
|
{
|
|
195
293
|
ref,
|
|
@@ -198,7 +296,7 @@ var DialogDescription = React6__namespace.forwardRef(({ className, ...props }, r
|
|
|
198
296
|
}
|
|
199
297
|
));
|
|
200
298
|
DialogDescription.displayName = DialogPrimitive__namespace.Description.displayName;
|
|
201
|
-
var Command =
|
|
299
|
+
var Command = React23__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
202
300
|
"div",
|
|
203
301
|
{
|
|
204
302
|
ref,
|
|
@@ -210,7 +308,7 @@ var Command = React6__namespace.forwardRef(({ className, ...props }, ref) => /*
|
|
|
210
308
|
}
|
|
211
309
|
));
|
|
212
310
|
Command.displayName = "Command";
|
|
213
|
-
var CommandInput =
|
|
311
|
+
var CommandInput = React23__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
214
312
|
"input",
|
|
215
313
|
{
|
|
216
314
|
ref,
|
|
@@ -222,7 +320,7 @@ var CommandInput = React6__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
222
320
|
}
|
|
223
321
|
));
|
|
224
322
|
CommandInput.displayName = "CommandInput";
|
|
225
|
-
var CommandList =
|
|
323
|
+
var CommandList = React23__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
226
324
|
"div",
|
|
227
325
|
{
|
|
228
326
|
ref,
|
|
@@ -231,7 +329,7 @@ var CommandList = React6__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
231
329
|
}
|
|
232
330
|
));
|
|
233
331
|
CommandList.displayName = "CommandList";
|
|
234
|
-
var CommandEmpty =
|
|
332
|
+
var CommandEmpty = React23__namespace.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
235
333
|
"div",
|
|
236
334
|
{
|
|
237
335
|
ref,
|
|
@@ -240,7 +338,7 @@ var CommandEmpty = React6__namespace.forwardRef((props, ref) => /* @__PURE__ */
|
|
|
240
338
|
}
|
|
241
339
|
));
|
|
242
340
|
CommandEmpty.displayName = "CommandEmpty";
|
|
243
|
-
var CommandGroup =
|
|
341
|
+
var CommandGroup = React23__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
244
342
|
"div",
|
|
245
343
|
{
|
|
246
344
|
ref,
|
|
@@ -252,7 +350,7 @@ var CommandGroup = React6__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
252
350
|
}
|
|
253
351
|
));
|
|
254
352
|
CommandGroup.displayName = "CommandGroup";
|
|
255
|
-
var CommandItem =
|
|
353
|
+
var CommandItem = React23__namespace.forwardRef(({ className, onSelect, value, ...props }, ref) => {
|
|
256
354
|
const handleClick = () => {
|
|
257
355
|
if (onSelect && value) {
|
|
258
356
|
onSelect(value);
|
|
@@ -274,7 +372,7 @@ var CommandItem = React6__namespace.forwardRef(({ className, onSelect, value, ..
|
|
|
274
372
|
CommandItem.displayName = "CommandItem";
|
|
275
373
|
var Popover = PopoverPrimitive__namespace.Root;
|
|
276
374
|
var PopoverTrigger = PopoverPrimitive__namespace.Trigger;
|
|
277
|
-
var PopoverContent =
|
|
375
|
+
var PopoverContent = React23__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
278
376
|
PopoverPrimitive__namespace.Content,
|
|
279
377
|
{
|
|
280
378
|
ref,
|
|
@@ -288,7 +386,7 @@ var PopoverContent = React6__namespace.forwardRef(({ className, align = "center"
|
|
|
288
386
|
}
|
|
289
387
|
) }));
|
|
290
388
|
PopoverContent.displayName = PopoverPrimitive__namespace.Content.displayName;
|
|
291
|
-
var Input =
|
|
389
|
+
var Input = React23__namespace.forwardRef(
|
|
292
390
|
({ className, type, ...props }, ref) => {
|
|
293
391
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
294
392
|
"input",
|
|
@@ -307,7 +405,7 @@ var Input = React6__namespace.forwardRef(
|
|
|
307
405
|
Input.displayName = "Input";
|
|
308
406
|
var Select = SelectPrimitive__namespace.Root;
|
|
309
407
|
var SelectValue = SelectPrimitive__namespace.Value;
|
|
310
|
-
var SelectTrigger =
|
|
408
|
+
var SelectTrigger = React23__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
311
409
|
SelectPrimitive__namespace.Trigger,
|
|
312
410
|
{
|
|
313
411
|
ref,
|
|
@@ -323,7 +421,7 @@ var SelectTrigger = React6__namespace.forwardRef(({ className, children, ...prop
|
|
|
323
421
|
}
|
|
324
422
|
));
|
|
325
423
|
SelectTrigger.displayName = SelectPrimitive__namespace.Trigger.displayName;
|
|
326
|
-
var SelectScrollUpButton =
|
|
424
|
+
var SelectScrollUpButton = React23__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
327
425
|
SelectPrimitive__namespace.ScrollUpButton,
|
|
328
426
|
{
|
|
329
427
|
ref,
|
|
@@ -336,7 +434,7 @@ var SelectScrollUpButton = React6__namespace.forwardRef(({ className, ...props }
|
|
|
336
434
|
}
|
|
337
435
|
));
|
|
338
436
|
SelectScrollUpButton.displayName = SelectPrimitive__namespace.ScrollUpButton.displayName;
|
|
339
|
-
var SelectScrollDownButton =
|
|
437
|
+
var SelectScrollDownButton = React23__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
340
438
|
SelectPrimitive__namespace.ScrollDownButton,
|
|
341
439
|
{
|
|
342
440
|
ref,
|
|
@@ -349,7 +447,7 @@ var SelectScrollDownButton = React6__namespace.forwardRef(({ className, ...props
|
|
|
349
447
|
}
|
|
350
448
|
));
|
|
351
449
|
SelectScrollDownButton.displayName = SelectPrimitive__namespace.ScrollDownButton.displayName;
|
|
352
|
-
var SelectContent =
|
|
450
|
+
var SelectContent = React23__namespace.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
353
451
|
SelectPrimitive__namespace.Content,
|
|
354
452
|
{
|
|
355
453
|
ref,
|
|
@@ -377,7 +475,7 @@ var SelectContent = React6__namespace.forwardRef(({ className, children, positio
|
|
|
377
475
|
}
|
|
378
476
|
) }));
|
|
379
477
|
SelectContent.displayName = SelectPrimitive__namespace.Content.displayName;
|
|
380
|
-
var SelectLabel =
|
|
478
|
+
var SelectLabel = React23__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
381
479
|
SelectPrimitive__namespace.Label,
|
|
382
480
|
{
|
|
383
481
|
ref,
|
|
@@ -386,7 +484,7 @@ var SelectLabel = React6__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
386
484
|
}
|
|
387
485
|
));
|
|
388
486
|
SelectLabel.displayName = SelectPrimitive__namespace.Label.displayName;
|
|
389
|
-
var SelectItem =
|
|
487
|
+
var SelectItem = React23__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
390
488
|
SelectPrimitive__namespace.Item,
|
|
391
489
|
{
|
|
392
490
|
ref,
|
|
@@ -402,7 +500,7 @@ var SelectItem = React6__namespace.forwardRef(({ className, children, ...props }
|
|
|
402
500
|
}
|
|
403
501
|
));
|
|
404
502
|
SelectItem.displayName = SelectPrimitive__namespace.Item.displayName;
|
|
405
|
-
var SelectSeparator =
|
|
503
|
+
var SelectSeparator = React23__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
406
504
|
SelectPrimitive__namespace.Separator,
|
|
407
505
|
{
|
|
408
506
|
ref,
|
|
@@ -414,7 +512,7 @@ SelectSeparator.displayName = SelectPrimitive__namespace.Separator.displayName;
|
|
|
414
512
|
var TooltipProvider = TooltipPrimitive__namespace.Provider;
|
|
415
513
|
var Tooltip = TooltipPrimitive__namespace.Root;
|
|
416
514
|
var TooltipTrigger = TooltipPrimitive__namespace.Trigger;
|
|
417
|
-
var TooltipContent =
|
|
515
|
+
var TooltipContent = React23__namespace.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
418
516
|
TooltipPrimitive__namespace.Content,
|
|
419
517
|
{
|
|
420
518
|
ref,
|
|
@@ -482,7 +580,7 @@ function FilterFieldItem({
|
|
|
482
580
|
onOperatorChange,
|
|
483
581
|
onDelete
|
|
484
582
|
}) {
|
|
485
|
-
const [isCalendarOpen, setIsCalendarOpen] =
|
|
583
|
+
const [isCalendarOpen, setIsCalendarOpen] = React23.useState(false);
|
|
486
584
|
const renderInput = () => {
|
|
487
585
|
switch (fieldConfig.type) {
|
|
488
586
|
case "text":
|
|
@@ -669,10 +767,10 @@ function HazoUiMultiFilterDialog({
|
|
|
669
767
|
title = "Filter",
|
|
670
768
|
description = "Add multiple fields to filter by. Select a field and set its filter value."
|
|
671
769
|
}) {
|
|
672
|
-
const [isOpen, setIsOpen] =
|
|
673
|
-
const [filterFields, setFilterFields] =
|
|
674
|
-
const [isComboboxOpen, setIsComboboxOpen] =
|
|
675
|
-
|
|
770
|
+
const [isOpen, setIsOpen] = React23.useState(false);
|
|
771
|
+
const [filterFields, setFilterFields] = React23.useState(initialFilters);
|
|
772
|
+
const [isComboboxOpen, setIsComboboxOpen] = React23.useState(false);
|
|
773
|
+
React23.useEffect(() => {
|
|
676
774
|
if (isOpen) {
|
|
677
775
|
setFilterFields(initialFilters);
|
|
678
776
|
}
|
|
@@ -885,7 +983,7 @@ function HazoUiMultiFilterDialog({
|
|
|
885
983
|
] })
|
|
886
984
|
] });
|
|
887
985
|
}
|
|
888
|
-
var Switch =
|
|
986
|
+
var Switch = React23__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
889
987
|
SwitchPrimitives__namespace.Root,
|
|
890
988
|
{
|
|
891
989
|
className: cn(
|
|
@@ -905,7 +1003,7 @@ var Switch = React6__namespace.forwardRef(({ className, ...props }, ref) => /* @
|
|
|
905
1003
|
}
|
|
906
1004
|
));
|
|
907
1005
|
Switch.displayName = SwitchPrimitives__namespace.Root.displayName;
|
|
908
|
-
var Label2 =
|
|
1006
|
+
var Label2 = React23__namespace.forwardRef(
|
|
909
1007
|
({ className, ...props }, ref) => {
|
|
910
1008
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
911
1009
|
"label",
|
|
@@ -991,16 +1089,16 @@ function HazoUiMultiSortDialog({
|
|
|
991
1089
|
title = "Sort",
|
|
992
1090
|
description = "Add multiple fields to sort by and reorder them. Use the switch to toggle between ascending and descending."
|
|
993
1091
|
}) {
|
|
994
|
-
const [isOpen, setIsOpen] =
|
|
995
|
-
const [sortFields, setSortFields] =
|
|
996
|
-
const [isComboboxOpen, setIsComboboxOpen] =
|
|
997
|
-
const sensors = core.useSensors(
|
|
998
|
-
core.useSensor(core.PointerSensor),
|
|
999
|
-
core.useSensor(core.KeyboardSensor, {
|
|
1092
|
+
const [isOpen, setIsOpen] = React23.useState(false);
|
|
1093
|
+
const [sortFields, setSortFields] = React23.useState(initialSortFields);
|
|
1094
|
+
const [isComboboxOpen, setIsComboboxOpen] = React23.useState(false);
|
|
1095
|
+
const sensors = core$1.useSensors(
|
|
1096
|
+
core$1.useSensor(core$1.PointerSensor),
|
|
1097
|
+
core$1.useSensor(core$1.KeyboardSensor, {
|
|
1000
1098
|
coordinateGetter: sortable.sortableKeyboardCoordinates
|
|
1001
1099
|
})
|
|
1002
1100
|
);
|
|
1003
|
-
|
|
1101
|
+
React23.useEffect(() => {
|
|
1004
1102
|
if (isOpen) {
|
|
1005
1103
|
setSortFields(initialSortFields);
|
|
1006
1104
|
}
|
|
@@ -1140,10 +1238,10 @@ function HazoUiMultiSortDialog({
|
|
|
1140
1238
|
] }) })
|
|
1141
1239
|
] }) }),
|
|
1142
1240
|
sortFields.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_sort_fields_list space-y-2", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1143
|
-
core.DndContext,
|
|
1241
|
+
core$1.DndContext,
|
|
1144
1242
|
{
|
|
1145
1243
|
sensors,
|
|
1146
|
-
collisionDetection: core.closestCenter,
|
|
1244
|
+
collisionDetection: core$1.closestCenter,
|
|
1147
1245
|
onDragEnd: handleDragEnd,
|
|
1148
1246
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1149
1247
|
sortable.SortableContext,
|
|
@@ -1199,7 +1297,7 @@ function HazoUiMultiSortDialog({
|
|
|
1199
1297
|
] })
|
|
1200
1298
|
] });
|
|
1201
1299
|
}
|
|
1202
|
-
var RadioGroup =
|
|
1300
|
+
var RadioGroup = React23__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
1203
1301
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1204
1302
|
RadioGroupPrimitive__namespace.Root,
|
|
1205
1303
|
{
|
|
@@ -1210,7 +1308,7 @@ var RadioGroup = React6__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
1210
1308
|
);
|
|
1211
1309
|
});
|
|
1212
1310
|
RadioGroup.displayName = RadioGroupPrimitive__namespace.Root.displayName;
|
|
1213
|
-
var RadioGroupItem =
|
|
1311
|
+
var RadioGroupItem = React23__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
1214
1312
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1215
1313
|
RadioGroupPrimitive__namespace.Item,
|
|
1216
1314
|
{
|
|
@@ -1564,7 +1662,7 @@ function filterInputValue(value, input_type, num_decimals) {
|
|
|
1564
1662
|
}
|
|
1565
1663
|
}
|
|
1566
1664
|
}
|
|
1567
|
-
var HazoUiFlexInput =
|
|
1665
|
+
var HazoUiFlexInput = React23__namespace.forwardRef(
|
|
1568
1666
|
({
|
|
1569
1667
|
className,
|
|
1570
1668
|
input_type = "mixed",
|
|
@@ -1581,13 +1679,13 @@ var HazoUiFlexInput = React6__namespace.forwardRef(
|
|
|
1581
1679
|
onBlur,
|
|
1582
1680
|
...props
|
|
1583
1681
|
}, ref) => {
|
|
1584
|
-
const [internalValue, setInternalValue] =
|
|
1682
|
+
const [internalValue, setInternalValue] = React23__namespace.useState(
|
|
1585
1683
|
typeof controlledValue === "string" ? controlledValue : typeof controlledValue === "number" ? String(controlledValue) : ""
|
|
1586
1684
|
);
|
|
1587
|
-
const [errorMessage, setErrorMessage] =
|
|
1685
|
+
const [errorMessage, setErrorMessage] = React23__namespace.useState();
|
|
1588
1686
|
const isControlled = controlledValue !== void 0;
|
|
1589
1687
|
const currentValue = isControlled ? typeof controlledValue === "string" ? controlledValue : String(controlledValue || "") : internalValue;
|
|
1590
|
-
|
|
1688
|
+
React23__namespace.useEffect(() => {
|
|
1591
1689
|
if (isControlled) {
|
|
1592
1690
|
const newValue = typeof controlledValue === "string" ? controlledValue : String(controlledValue || "");
|
|
1593
1691
|
if (newValue !== internalValue) {
|
|
@@ -1667,11 +1765,2548 @@ var HazoUiFlexInput = React6__namespace.forwardRef(
|
|
|
1667
1765
|
}
|
|
1668
1766
|
);
|
|
1669
1767
|
HazoUiFlexInput.displayName = "HazoUiFlexInput";
|
|
1768
|
+
var ToolbarButton = React23__namespace.forwardRef(
|
|
1769
|
+
({ onClick, is_active = false, disabled = false, tooltip, className, children }, ref) => {
|
|
1770
|
+
const button = /* @__PURE__ */ jsxRuntime.jsx(
|
|
1771
|
+
"button",
|
|
1772
|
+
{
|
|
1773
|
+
ref,
|
|
1774
|
+
type: "button",
|
|
1775
|
+
onClick,
|
|
1776
|
+
disabled,
|
|
1777
|
+
className: cn(
|
|
1778
|
+
"cls_rte_toolbar_button",
|
|
1779
|
+
"inline-flex items-center justify-center",
|
|
1780
|
+
"h-8 w-8 rounded-md",
|
|
1781
|
+
"text-sm font-medium",
|
|
1782
|
+
"transition-colors duration-150",
|
|
1783
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1784
|
+
// Default state
|
|
1785
|
+
"bg-transparent text-muted-foreground hover:bg-accent hover:text-accent-foreground",
|
|
1786
|
+
// Active state
|
|
1787
|
+
is_active && "bg-accent text-accent-foreground",
|
|
1788
|
+
// Disabled state
|
|
1789
|
+
disabled && "opacity-50 cursor-not-allowed hover:bg-transparent hover:text-muted-foreground",
|
|
1790
|
+
className
|
|
1791
|
+
),
|
|
1792
|
+
children
|
|
1793
|
+
}
|
|
1794
|
+
);
|
|
1795
|
+
if (tooltip) {
|
|
1796
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
|
|
1797
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: button }),
|
|
1798
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { side: "bottom", className: "text-xs", children: tooltip })
|
|
1799
|
+
] });
|
|
1800
|
+
}
|
|
1801
|
+
return button;
|
|
1802
|
+
}
|
|
1803
|
+
);
|
|
1804
|
+
ToolbarButton.displayName = "ToolbarButton";
|
|
1805
|
+
|
|
1806
|
+
// node_modules/@uiw/react-color-sketch/esm/index.js
|
|
1807
|
+
var import_extends10 = __toESM(require_extends());
|
|
1808
|
+
var import_objectWithoutPropertiesLoose9 = __toESM(require_objectWithoutPropertiesLoose());
|
|
1809
|
+
|
|
1810
|
+
// node_modules/@uiw/react-color-saturation/esm/index.js
|
|
1811
|
+
var import_extends3 = __toESM(require_extends());
|
|
1812
|
+
var import_objectWithoutPropertiesLoose2 = __toESM(require_objectWithoutPropertiesLoose());
|
|
1813
|
+
|
|
1814
|
+
// node_modules/@uiw/color-convert/esm/index.js
|
|
1815
|
+
var import_extends = __toESM(require_extends());
|
|
1816
|
+
var RGB_MAX = 255;
|
|
1817
|
+
var SV_MAX = 100;
|
|
1818
|
+
var rgbaToHsva = (_ref) => {
|
|
1819
|
+
var {
|
|
1820
|
+
r,
|
|
1821
|
+
g,
|
|
1822
|
+
b,
|
|
1823
|
+
a
|
|
1824
|
+
} = _ref;
|
|
1825
|
+
var max = Math.max(r, g, b);
|
|
1826
|
+
var delta = max - Math.min(r, g, b);
|
|
1827
|
+
var hh = delta ? max === r ? (g - b) / delta : max === g ? 2 + (b - r) / delta : 4 + (r - g) / delta : 0;
|
|
1828
|
+
return {
|
|
1829
|
+
h: 60 * (hh < 0 ? hh + 6 : hh),
|
|
1830
|
+
s: max ? delta / max * SV_MAX : 0,
|
|
1831
|
+
v: max / RGB_MAX * SV_MAX,
|
|
1832
|
+
a
|
|
1833
|
+
};
|
|
1834
|
+
};
|
|
1835
|
+
var hsvaToHslaString = (hsva) => {
|
|
1836
|
+
var {
|
|
1837
|
+
h,
|
|
1838
|
+
s,
|
|
1839
|
+
l,
|
|
1840
|
+
a
|
|
1841
|
+
} = hsvaToHsla(hsva);
|
|
1842
|
+
return "hsla(" + h + ", " + s + "%, " + l + "%, " + a + ")";
|
|
1843
|
+
};
|
|
1844
|
+
var hsvaToHsla = (_ref5) => {
|
|
1845
|
+
var {
|
|
1846
|
+
h,
|
|
1847
|
+
s,
|
|
1848
|
+
v,
|
|
1849
|
+
a
|
|
1850
|
+
} = _ref5;
|
|
1851
|
+
var hh = (200 - s) * v / SV_MAX;
|
|
1852
|
+
return {
|
|
1853
|
+
h,
|
|
1854
|
+
s: hh > 0 && hh < 200 ? s * v / SV_MAX / (hh <= SV_MAX ? hh : 200 - hh) * SV_MAX : 0,
|
|
1855
|
+
l: hh / 2,
|
|
1856
|
+
a
|
|
1857
|
+
};
|
|
1858
|
+
};
|
|
1859
|
+
var rgbToHex = (_ref7) => {
|
|
1860
|
+
var {
|
|
1861
|
+
r,
|
|
1862
|
+
g,
|
|
1863
|
+
b
|
|
1864
|
+
} = _ref7;
|
|
1865
|
+
var bin = r << 16 | g << 8 | b;
|
|
1866
|
+
return "#" + ((h) => new Array(7 - h.length).join("0") + h)(bin.toString(16));
|
|
1867
|
+
};
|
|
1868
|
+
var rgbaToHexa = (_ref8) => {
|
|
1869
|
+
var {
|
|
1870
|
+
r,
|
|
1871
|
+
g,
|
|
1872
|
+
b,
|
|
1873
|
+
a
|
|
1874
|
+
} = _ref8;
|
|
1875
|
+
var alpha = typeof a === "number" && (a * 255 | 1 << 8).toString(16).slice(1);
|
|
1876
|
+
return "" + rgbToHex({
|
|
1877
|
+
r,
|
|
1878
|
+
g,
|
|
1879
|
+
b
|
|
1880
|
+
}) + (alpha ? alpha : "");
|
|
1881
|
+
};
|
|
1882
|
+
var hexToHsva = (hex) => rgbaToHsva(hexToRgba(hex));
|
|
1883
|
+
var hexToRgba = (hex) => {
|
|
1884
|
+
var htemp = hex.replace("#", "");
|
|
1885
|
+
if (/^#?/.test(hex) && htemp.length === 3) {
|
|
1886
|
+
hex = "#" + htemp.charAt(0) + htemp.charAt(0) + htemp.charAt(1) + htemp.charAt(1) + htemp.charAt(2) + htemp.charAt(2);
|
|
1887
|
+
}
|
|
1888
|
+
var reg = new RegExp("[A-Za-z0-9]{2}", "g");
|
|
1889
|
+
var [r, g, b = 0, a] = hex.match(reg).map((v) => parseInt(v, 16));
|
|
1890
|
+
return {
|
|
1891
|
+
r,
|
|
1892
|
+
g,
|
|
1893
|
+
b,
|
|
1894
|
+
a: (a != null ? a : 255) / RGB_MAX
|
|
1895
|
+
};
|
|
1896
|
+
};
|
|
1897
|
+
var hsvaToRgba = (_ref9) => {
|
|
1898
|
+
var {
|
|
1899
|
+
h,
|
|
1900
|
+
s,
|
|
1901
|
+
v,
|
|
1902
|
+
a
|
|
1903
|
+
} = _ref9;
|
|
1904
|
+
var _h = h / 60, _s = s / SV_MAX, _v = v / SV_MAX, hi = Math.floor(_h) % 6;
|
|
1905
|
+
var f = _h - Math.floor(_h), _p = RGB_MAX * _v * (1 - _s), _q = RGB_MAX * _v * (1 - _s * f), _t = RGB_MAX * _v * (1 - _s * (1 - f));
|
|
1906
|
+
_v *= RGB_MAX;
|
|
1907
|
+
var rgba = {};
|
|
1908
|
+
switch (hi) {
|
|
1909
|
+
case 0:
|
|
1910
|
+
rgba.r = _v;
|
|
1911
|
+
rgba.g = _t;
|
|
1912
|
+
rgba.b = _p;
|
|
1913
|
+
break;
|
|
1914
|
+
case 1:
|
|
1915
|
+
rgba.r = _q;
|
|
1916
|
+
rgba.g = _v;
|
|
1917
|
+
rgba.b = _p;
|
|
1918
|
+
break;
|
|
1919
|
+
case 2:
|
|
1920
|
+
rgba.r = _p;
|
|
1921
|
+
rgba.g = _v;
|
|
1922
|
+
rgba.b = _t;
|
|
1923
|
+
break;
|
|
1924
|
+
case 3:
|
|
1925
|
+
rgba.r = _p;
|
|
1926
|
+
rgba.g = _q;
|
|
1927
|
+
rgba.b = _v;
|
|
1928
|
+
break;
|
|
1929
|
+
case 4:
|
|
1930
|
+
rgba.r = _t;
|
|
1931
|
+
rgba.g = _p;
|
|
1932
|
+
rgba.b = _v;
|
|
1933
|
+
break;
|
|
1934
|
+
case 5:
|
|
1935
|
+
rgba.r = _v;
|
|
1936
|
+
rgba.g = _p;
|
|
1937
|
+
rgba.b = _q;
|
|
1938
|
+
break;
|
|
1939
|
+
}
|
|
1940
|
+
rgba.r = Math.round(rgba.r);
|
|
1941
|
+
rgba.g = Math.round(rgba.g);
|
|
1942
|
+
rgba.b = Math.round(rgba.b);
|
|
1943
|
+
return (0, import_extends.default)({}, rgba, {
|
|
1944
|
+
a
|
|
1945
|
+
});
|
|
1946
|
+
};
|
|
1947
|
+
var hsvaToRgbaString = (hsva) => {
|
|
1948
|
+
var {
|
|
1949
|
+
r,
|
|
1950
|
+
g,
|
|
1951
|
+
b,
|
|
1952
|
+
a
|
|
1953
|
+
} = hsvaToRgba(hsva);
|
|
1954
|
+
return "rgba(" + r + ", " + g + ", " + b + ", " + a + ")";
|
|
1955
|
+
};
|
|
1956
|
+
var rgbaToRgb = (_ref0) => {
|
|
1957
|
+
var {
|
|
1958
|
+
r,
|
|
1959
|
+
g,
|
|
1960
|
+
b
|
|
1961
|
+
} = _ref0;
|
|
1962
|
+
return {
|
|
1963
|
+
r,
|
|
1964
|
+
g,
|
|
1965
|
+
b
|
|
1966
|
+
};
|
|
1967
|
+
};
|
|
1968
|
+
var hslaToHsl = (_ref1) => {
|
|
1969
|
+
var {
|
|
1970
|
+
h,
|
|
1971
|
+
s,
|
|
1972
|
+
l
|
|
1973
|
+
} = _ref1;
|
|
1974
|
+
return {
|
|
1975
|
+
h,
|
|
1976
|
+
s,
|
|
1977
|
+
l
|
|
1978
|
+
};
|
|
1979
|
+
};
|
|
1980
|
+
var hsvaToHex = (hsva) => rgbToHex(hsvaToRgba(hsva));
|
|
1981
|
+
var hsvaToHsv = (_ref10) => {
|
|
1982
|
+
var {
|
|
1983
|
+
h,
|
|
1984
|
+
s,
|
|
1985
|
+
v
|
|
1986
|
+
} = _ref10;
|
|
1987
|
+
return {
|
|
1988
|
+
h,
|
|
1989
|
+
s,
|
|
1990
|
+
v
|
|
1991
|
+
};
|
|
1992
|
+
};
|
|
1993
|
+
var rgbToXY = (_ref12) => {
|
|
1994
|
+
var {
|
|
1995
|
+
r,
|
|
1996
|
+
g,
|
|
1997
|
+
b
|
|
1998
|
+
} = _ref12;
|
|
1999
|
+
var translateColor = function translateColor2(color2) {
|
|
2000
|
+
return color2 <= 0.04045 ? color2 / 12.92 : Math.pow((color2 + 0.055) / 1.055, 2.4);
|
|
2001
|
+
};
|
|
2002
|
+
var red = translateColor(r / 255);
|
|
2003
|
+
var green = translateColor(g / 255);
|
|
2004
|
+
var blue = translateColor(b / 255);
|
|
2005
|
+
var xyz = {};
|
|
2006
|
+
xyz.x = red * 0.4124 + green * 0.3576 + blue * 0.1805;
|
|
2007
|
+
xyz.y = red * 0.2126 + green * 0.7152 + blue * 0.0722;
|
|
2008
|
+
xyz.bri = red * 0.0193 + green * 0.1192 + blue * 0.9505;
|
|
2009
|
+
return xyz;
|
|
2010
|
+
};
|
|
2011
|
+
var color = (str) => {
|
|
2012
|
+
var rgb;
|
|
2013
|
+
var hsl;
|
|
2014
|
+
var hsv;
|
|
2015
|
+
var rgba;
|
|
2016
|
+
var hsla;
|
|
2017
|
+
var hsva;
|
|
2018
|
+
var xy;
|
|
2019
|
+
var hex;
|
|
2020
|
+
var hexa;
|
|
2021
|
+
if (typeof str === "string" && validHex(str)) {
|
|
2022
|
+
hsva = hexToHsva(str);
|
|
2023
|
+
hex = str;
|
|
2024
|
+
} else if (typeof str !== "string") {
|
|
2025
|
+
hsva = str;
|
|
2026
|
+
}
|
|
2027
|
+
if (hsva) {
|
|
2028
|
+
hsv = hsvaToHsv(hsva);
|
|
2029
|
+
hsla = hsvaToHsla(hsva);
|
|
2030
|
+
rgba = hsvaToRgba(hsva);
|
|
2031
|
+
hexa = rgbaToHexa(rgba);
|
|
2032
|
+
hex = hsvaToHex(hsva);
|
|
2033
|
+
hsl = hslaToHsl(hsla);
|
|
2034
|
+
rgb = rgbaToRgb(rgba);
|
|
2035
|
+
xy = rgbToXY(rgb);
|
|
2036
|
+
}
|
|
2037
|
+
return {
|
|
2038
|
+
rgb,
|
|
2039
|
+
hsl,
|
|
2040
|
+
hsv,
|
|
2041
|
+
rgba,
|
|
2042
|
+
hsla,
|
|
2043
|
+
hsva,
|
|
2044
|
+
hex,
|
|
2045
|
+
hexa,
|
|
2046
|
+
xy
|
|
2047
|
+
};
|
|
2048
|
+
};
|
|
2049
|
+
var validHex = (hex) => /^#?([A-Fa-f0-9]{3,4}){1,2}$/.test(hex);
|
|
2050
|
+
|
|
2051
|
+
// node_modules/@uiw/react-drag-event-interactive/esm/index.js
|
|
2052
|
+
var import_extends2 = __toESM(require_extends());
|
|
2053
|
+
var import_objectWithoutPropertiesLoose = __toESM(require_objectWithoutPropertiesLoose());
|
|
2054
|
+
function useEventCallback(handler) {
|
|
2055
|
+
var callbackRef = React23.useRef(handler);
|
|
2056
|
+
React23.useEffect(() => {
|
|
2057
|
+
callbackRef.current = handler;
|
|
2058
|
+
});
|
|
2059
|
+
return React23.useCallback((value, event) => callbackRef.current && callbackRef.current(value, event), []);
|
|
2060
|
+
}
|
|
2061
|
+
var isTouch = (event) => "touches" in event;
|
|
2062
|
+
var preventDefaultMove = (event) => {
|
|
2063
|
+
!isTouch(event) && event.preventDefault && event.preventDefault();
|
|
2064
|
+
};
|
|
2065
|
+
var clamp = function clamp2(number, min, max) {
|
|
2066
|
+
if (min === void 0) {
|
|
2067
|
+
min = 0;
|
|
2068
|
+
}
|
|
2069
|
+
if (max === void 0) {
|
|
2070
|
+
max = 1;
|
|
2071
|
+
}
|
|
2072
|
+
return number > max ? max : number < min ? min : number;
|
|
2073
|
+
};
|
|
2074
|
+
var getRelativePosition = (node, event) => {
|
|
2075
|
+
var rect = node.getBoundingClientRect();
|
|
2076
|
+
var pointer = isTouch(event) ? event.touches[0] : event;
|
|
2077
|
+
return {
|
|
2078
|
+
left: clamp((pointer.pageX - (rect.left + window.pageXOffset)) / rect.width),
|
|
2079
|
+
top: clamp((pointer.pageY - (rect.top + window.pageYOffset)) / rect.height),
|
|
2080
|
+
width: rect.width,
|
|
2081
|
+
height: rect.height,
|
|
2082
|
+
x: pointer.pageX - (rect.left + window.pageXOffset),
|
|
2083
|
+
y: pointer.pageY - (rect.top + window.pageYOffset)
|
|
2084
|
+
};
|
|
2085
|
+
};
|
|
2086
|
+
var _excluded = ["prefixCls", "className", "onMove", "onDown"];
|
|
2087
|
+
var Interactive = /* @__PURE__ */ React23__namespace.default.forwardRef((props, ref) => {
|
|
2088
|
+
var {
|
|
2089
|
+
prefixCls = "w-color-interactive",
|
|
2090
|
+
className,
|
|
2091
|
+
onMove,
|
|
2092
|
+
onDown
|
|
2093
|
+
} = props, reset = (0, import_objectWithoutPropertiesLoose.default)(props, _excluded);
|
|
2094
|
+
var container = React23.useRef(null);
|
|
2095
|
+
var hasTouched = React23.useRef(false);
|
|
2096
|
+
var [isDragging, setDragging] = React23.useState(false);
|
|
2097
|
+
var onMoveCallback = useEventCallback(onMove);
|
|
2098
|
+
var onKeyCallback = useEventCallback(onDown);
|
|
2099
|
+
var isValid = (event) => {
|
|
2100
|
+
if (hasTouched.current && !isTouch(event)) return false;
|
|
2101
|
+
hasTouched.current = isTouch(event);
|
|
2102
|
+
return true;
|
|
2103
|
+
};
|
|
2104
|
+
var handleMove = React23.useCallback((event) => {
|
|
2105
|
+
preventDefaultMove(event);
|
|
2106
|
+
if (!container.current) return;
|
|
2107
|
+
var isDown = isTouch(event) ? event.touches.length > 0 : event.buttons > 0;
|
|
2108
|
+
if (!isDown) {
|
|
2109
|
+
setDragging(false);
|
|
2110
|
+
return;
|
|
2111
|
+
}
|
|
2112
|
+
onMoveCallback == null || onMoveCallback(getRelativePosition(container.current, event), event);
|
|
2113
|
+
}, [onMoveCallback]);
|
|
2114
|
+
var handleMoveEnd = React23.useCallback(() => setDragging(false), []);
|
|
2115
|
+
var toggleDocumentEvents = React23.useCallback((state) => {
|
|
2116
|
+
if (state) {
|
|
2117
|
+
window.addEventListener(hasTouched.current ? "touchmove" : "mousemove", handleMove);
|
|
2118
|
+
window.addEventListener(hasTouched.current ? "touchend" : "mouseup", handleMoveEnd);
|
|
2119
|
+
} else {
|
|
2120
|
+
window.removeEventListener("mousemove", handleMove);
|
|
2121
|
+
window.removeEventListener("mouseup", handleMoveEnd);
|
|
2122
|
+
window.removeEventListener("touchmove", handleMove);
|
|
2123
|
+
window.removeEventListener("touchend", handleMoveEnd);
|
|
2124
|
+
}
|
|
2125
|
+
}, [handleMove, handleMoveEnd]);
|
|
2126
|
+
React23.useEffect(() => {
|
|
2127
|
+
toggleDocumentEvents(isDragging);
|
|
2128
|
+
return () => {
|
|
2129
|
+
toggleDocumentEvents(false);
|
|
2130
|
+
};
|
|
2131
|
+
}, [isDragging, handleMove, handleMoveEnd, toggleDocumentEvents]);
|
|
2132
|
+
var handleMoveStart = React23.useCallback((event) => {
|
|
2133
|
+
var activeEl = document.activeElement;
|
|
2134
|
+
activeEl == null || activeEl.blur();
|
|
2135
|
+
preventDefaultMove(event.nativeEvent);
|
|
2136
|
+
if (!isValid(event.nativeEvent)) return;
|
|
2137
|
+
if (!container.current) return;
|
|
2138
|
+
onKeyCallback == null || onKeyCallback(getRelativePosition(container.current, event.nativeEvent), event.nativeEvent);
|
|
2139
|
+
setDragging(true);
|
|
2140
|
+
}, [onKeyCallback]);
|
|
2141
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", (0, import_extends2.default)({}, reset, {
|
|
2142
|
+
className: [prefixCls, className || ""].filter(Boolean).join(" "),
|
|
2143
|
+
style: (0, import_extends2.default)({}, reset.style, {
|
|
2144
|
+
touchAction: "none"
|
|
2145
|
+
}),
|
|
2146
|
+
ref: container,
|
|
2147
|
+
tabIndex: 0,
|
|
2148
|
+
onMouseDown: handleMoveStart,
|
|
2149
|
+
onTouchStart: handleMoveStart
|
|
2150
|
+
}));
|
|
2151
|
+
});
|
|
2152
|
+
Interactive.displayName = "Interactive";
|
|
2153
|
+
var esm_default = Interactive;
|
|
2154
|
+
var Pointer = (_ref) => {
|
|
2155
|
+
var {
|
|
2156
|
+
className,
|
|
2157
|
+
color: color2,
|
|
2158
|
+
left,
|
|
2159
|
+
top,
|
|
2160
|
+
prefixCls
|
|
2161
|
+
} = _ref;
|
|
2162
|
+
var style = {
|
|
2163
|
+
position: "absolute",
|
|
2164
|
+
top,
|
|
2165
|
+
left
|
|
2166
|
+
};
|
|
2167
|
+
var stylePointer = {
|
|
2168
|
+
"--saturation-pointer-box-shadow": "rgb(255 255 255) 0px 0px 0px 1.5px, rgb(0 0 0 / 30%) 0px 0px 1px 1px inset, rgb(0 0 0 / 40%) 0px 0px 1px 2px",
|
|
2169
|
+
width: 6,
|
|
2170
|
+
height: 6,
|
|
2171
|
+
transform: "translate(-3px, -3px)",
|
|
2172
|
+
boxShadow: "var(--saturation-pointer-box-shadow)",
|
|
2173
|
+
borderRadius: "50%",
|
|
2174
|
+
backgroundColor: color2
|
|
2175
|
+
};
|
|
2176
|
+
return React23.useMemo(() => /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
2177
|
+
className: prefixCls + "-pointer " + (className || ""),
|
|
2178
|
+
style,
|
|
2179
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
2180
|
+
className: prefixCls + "-fill",
|
|
2181
|
+
style: stylePointer
|
|
2182
|
+
})
|
|
2183
|
+
}), [top, left, color2, className, prefixCls]);
|
|
2184
|
+
};
|
|
2185
|
+
var _excluded2 = ["prefixCls", "radius", "pointer", "className", "hue", "style", "hsva", "onChange"];
|
|
2186
|
+
var Saturation = /* @__PURE__ */ React23__namespace.default.forwardRef((props, ref) => {
|
|
2187
|
+
var _hsva$h;
|
|
2188
|
+
var {
|
|
2189
|
+
prefixCls = "w-color-saturation",
|
|
2190
|
+
radius = 0,
|
|
2191
|
+
pointer,
|
|
2192
|
+
className,
|
|
2193
|
+
hue = 0,
|
|
2194
|
+
style,
|
|
2195
|
+
hsva,
|
|
2196
|
+
onChange
|
|
2197
|
+
} = props, other = (0, import_objectWithoutPropertiesLoose2.default)(props, _excluded2);
|
|
2198
|
+
var containerStyle = (0, import_extends3.default)({
|
|
2199
|
+
width: 200,
|
|
2200
|
+
height: 200,
|
|
2201
|
+
borderRadius: radius
|
|
2202
|
+
}, style, {
|
|
2203
|
+
position: "relative"
|
|
2204
|
+
});
|
|
2205
|
+
var handleChange = (interaction, event) => {
|
|
2206
|
+
onChange && hsva && onChange({
|
|
2207
|
+
h: hsva.h,
|
|
2208
|
+
s: interaction.left * 100,
|
|
2209
|
+
v: (1 - interaction.top) * 100,
|
|
2210
|
+
a: hsva.a
|
|
2211
|
+
// source: 'hsv',
|
|
2212
|
+
});
|
|
2213
|
+
};
|
|
2214
|
+
var handleKeyDown = React23.useCallback((event) => {
|
|
2215
|
+
if (!hsva || !onChange) return;
|
|
2216
|
+
var step = 1;
|
|
2217
|
+
var newS = hsva.s;
|
|
2218
|
+
var newV = hsva.v;
|
|
2219
|
+
var changed = false;
|
|
2220
|
+
switch (event.key) {
|
|
2221
|
+
case "ArrowLeft":
|
|
2222
|
+
newS = Math.max(0, hsva.s - step);
|
|
2223
|
+
changed = true;
|
|
2224
|
+
event.preventDefault();
|
|
2225
|
+
break;
|
|
2226
|
+
case "ArrowRight":
|
|
2227
|
+
newS = Math.min(100, hsva.s + step);
|
|
2228
|
+
changed = true;
|
|
2229
|
+
event.preventDefault();
|
|
2230
|
+
break;
|
|
2231
|
+
case "ArrowUp":
|
|
2232
|
+
newV = Math.min(100, hsva.v + step);
|
|
2233
|
+
changed = true;
|
|
2234
|
+
event.preventDefault();
|
|
2235
|
+
break;
|
|
2236
|
+
case "ArrowDown":
|
|
2237
|
+
newV = Math.max(0, hsva.v - step);
|
|
2238
|
+
changed = true;
|
|
2239
|
+
event.preventDefault();
|
|
2240
|
+
break;
|
|
2241
|
+
default:
|
|
2242
|
+
return;
|
|
2243
|
+
}
|
|
2244
|
+
if (changed) {
|
|
2245
|
+
onChange({
|
|
2246
|
+
h: hsva.h,
|
|
2247
|
+
s: newS,
|
|
2248
|
+
v: newV,
|
|
2249
|
+
a: hsva.a
|
|
2250
|
+
});
|
|
2251
|
+
}
|
|
2252
|
+
}, [hsva, onChange]);
|
|
2253
|
+
var pointerElement = React23.useMemo(() => {
|
|
2254
|
+
if (!hsva) return null;
|
|
2255
|
+
var comProps = {
|
|
2256
|
+
top: 100 - hsva.v + "%",
|
|
2257
|
+
left: hsva.s + "%",
|
|
2258
|
+
color: hsvaToHslaString(hsva)
|
|
2259
|
+
};
|
|
2260
|
+
if (pointer && typeof pointer === "function") {
|
|
2261
|
+
return pointer((0, import_extends3.default)({
|
|
2262
|
+
prefixCls
|
|
2263
|
+
}, comProps));
|
|
2264
|
+
}
|
|
2265
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Pointer, (0, import_extends3.default)({
|
|
2266
|
+
prefixCls
|
|
2267
|
+
}, comProps));
|
|
2268
|
+
}, [hsva, pointer, prefixCls]);
|
|
2269
|
+
var handleClick = React23.useCallback((event) => {
|
|
2270
|
+
event.target.focus();
|
|
2271
|
+
}, []);
|
|
2272
|
+
return /* @__PURE__ */ jsxRuntime.jsx(esm_default, (0, import_extends3.default)({
|
|
2273
|
+
className: [prefixCls, className || ""].filter(Boolean).join(" ")
|
|
2274
|
+
}, other, {
|
|
2275
|
+
style: (0, import_extends3.default)({
|
|
2276
|
+
position: "absolute",
|
|
2277
|
+
inset: 0,
|
|
2278
|
+
cursor: "crosshair",
|
|
2279
|
+
backgroundImage: "linear-gradient(0deg, #000, transparent), linear-gradient(90deg, #fff, hsl(" + ((_hsva$h = hsva == null ? void 0 : hsva.h) != null ? _hsva$h : hue) + ", 100%, 50%))"
|
|
2280
|
+
}, containerStyle, {
|
|
2281
|
+
outline: "none"
|
|
2282
|
+
}),
|
|
2283
|
+
ref,
|
|
2284
|
+
onMove: handleChange,
|
|
2285
|
+
onDown: handleChange,
|
|
2286
|
+
onKeyDown: handleKeyDown,
|
|
2287
|
+
onClick: handleClick,
|
|
2288
|
+
children: pointerElement
|
|
2289
|
+
}));
|
|
2290
|
+
});
|
|
2291
|
+
Saturation.displayName = "Saturation";
|
|
2292
|
+
var esm_default2 = Saturation;
|
|
2293
|
+
|
|
2294
|
+
// node_modules/@uiw/react-color-alpha/esm/index.js
|
|
2295
|
+
var import_extends5 = __toESM(require_extends());
|
|
2296
|
+
var import_objectWithoutPropertiesLoose4 = __toESM(require_objectWithoutPropertiesLoose());
|
|
2297
|
+
|
|
2298
|
+
// node_modules/@uiw/react-color-alpha/esm/Pointer.js
|
|
2299
|
+
var import_extends4 = __toESM(require_extends());
|
|
2300
|
+
var import_objectWithoutPropertiesLoose3 = __toESM(require_objectWithoutPropertiesLoose());
|
|
2301
|
+
var _excluded3 = ["className", "prefixCls", "left", "top", "style", "fillProps"];
|
|
2302
|
+
var Pointer2 = (_ref) => {
|
|
2303
|
+
var {
|
|
2304
|
+
className,
|
|
2305
|
+
prefixCls,
|
|
2306
|
+
left,
|
|
2307
|
+
top,
|
|
2308
|
+
style,
|
|
2309
|
+
fillProps
|
|
2310
|
+
} = _ref, reset = (0, import_objectWithoutPropertiesLoose3.default)(_ref, _excluded3);
|
|
2311
|
+
var styleWrapper = (0, import_extends4.default)({}, style, {
|
|
2312
|
+
position: "absolute",
|
|
2313
|
+
left,
|
|
2314
|
+
top
|
|
2315
|
+
});
|
|
2316
|
+
var stylePointer = (0, import_extends4.default)({
|
|
2317
|
+
width: 18,
|
|
2318
|
+
height: 18,
|
|
2319
|
+
boxShadow: "var(--alpha-pointer-box-shadow)",
|
|
2320
|
+
borderRadius: "50%",
|
|
2321
|
+
backgroundColor: "var(--alpha-pointer-background-color)"
|
|
2322
|
+
}, fillProps == null ? void 0 : fillProps.style, {
|
|
2323
|
+
transform: left ? "translate(-9px, -1px)" : "translate(-1px, -9px)"
|
|
2324
|
+
});
|
|
2325
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", (0, import_extends4.default)({
|
|
2326
|
+
className: prefixCls + "-pointer " + (className || ""),
|
|
2327
|
+
style: styleWrapper
|
|
2328
|
+
}, reset, {
|
|
2329
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", (0, import_extends4.default)({
|
|
2330
|
+
className: prefixCls + "-fill"
|
|
2331
|
+
}, fillProps, {
|
|
2332
|
+
style: stylePointer
|
|
2333
|
+
}))
|
|
2334
|
+
}));
|
|
2335
|
+
};
|
|
2336
|
+
var _excluded4 = ["prefixCls", "className", "hsva", "background", "bgProps", "innerProps", "pointerProps", "radius", "width", "height", "direction", "style", "onChange", "pointer"];
|
|
2337
|
+
var BACKGROUND_IMG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg==";
|
|
2338
|
+
var Alpha = /* @__PURE__ */ React23__namespace.default.forwardRef((props, ref) => {
|
|
2339
|
+
var {
|
|
2340
|
+
prefixCls = "w-color-alpha",
|
|
2341
|
+
className,
|
|
2342
|
+
hsva,
|
|
2343
|
+
background,
|
|
2344
|
+
bgProps = {},
|
|
2345
|
+
innerProps = {},
|
|
2346
|
+
pointerProps = {},
|
|
2347
|
+
radius = 0,
|
|
2348
|
+
width,
|
|
2349
|
+
height = 16,
|
|
2350
|
+
direction = "horizontal",
|
|
2351
|
+
style,
|
|
2352
|
+
onChange,
|
|
2353
|
+
pointer
|
|
2354
|
+
} = props, other = (0, import_objectWithoutPropertiesLoose4.default)(props, _excluded4);
|
|
2355
|
+
var handleChange = (offset) => {
|
|
2356
|
+
onChange && onChange((0, import_extends5.default)({}, hsva, {
|
|
2357
|
+
a: direction === "horizontal" ? offset.left : offset.top
|
|
2358
|
+
}), offset);
|
|
2359
|
+
};
|
|
2360
|
+
var colorTo = hsvaToHslaString(Object.assign({}, hsva, {
|
|
2361
|
+
a: 1
|
|
2362
|
+
}));
|
|
2363
|
+
var innerBackground = "linear-gradient(to " + (direction === "horizontal" ? "right" : "bottom") + ", rgba(244, 67, 54, 0) 0%, " + colorTo + " 100%)";
|
|
2364
|
+
var comProps = {};
|
|
2365
|
+
if (direction === "horizontal") {
|
|
2366
|
+
comProps.left = hsva.a * 100 + "%";
|
|
2367
|
+
} else {
|
|
2368
|
+
comProps.top = hsva.a * 100 + "%";
|
|
2369
|
+
}
|
|
2370
|
+
var styleWrapper = (0, import_extends5.default)({
|
|
2371
|
+
"--alpha-background-color": "#fff",
|
|
2372
|
+
"--alpha-pointer-background-color": "rgb(248, 248, 248)",
|
|
2373
|
+
"--alpha-pointer-box-shadow": "rgb(0 0 0 / 37%) 0px 1px 4px 0px",
|
|
2374
|
+
borderRadius: radius,
|
|
2375
|
+
background: "url(" + BACKGROUND_IMG + ") left center",
|
|
2376
|
+
backgroundColor: "var(--alpha-background-color)"
|
|
2377
|
+
}, {
|
|
2378
|
+
width,
|
|
2379
|
+
height
|
|
2380
|
+
}, style, {
|
|
2381
|
+
position: "relative"
|
|
2382
|
+
});
|
|
2383
|
+
var handleKeyDown = React23.useCallback((event) => {
|
|
2384
|
+
var step = 0.01;
|
|
2385
|
+
var currentAlpha = hsva.a;
|
|
2386
|
+
var newAlpha = currentAlpha;
|
|
2387
|
+
switch (event.key) {
|
|
2388
|
+
case "ArrowLeft":
|
|
2389
|
+
if (direction === "horizontal") {
|
|
2390
|
+
newAlpha = Math.max(0, currentAlpha - step);
|
|
2391
|
+
event.preventDefault();
|
|
2392
|
+
}
|
|
2393
|
+
break;
|
|
2394
|
+
case "ArrowRight":
|
|
2395
|
+
if (direction === "horizontal") {
|
|
2396
|
+
newAlpha = Math.min(1, currentAlpha + step);
|
|
2397
|
+
event.preventDefault();
|
|
2398
|
+
}
|
|
2399
|
+
break;
|
|
2400
|
+
case "ArrowUp":
|
|
2401
|
+
if (direction === "vertical") {
|
|
2402
|
+
newAlpha = Math.max(0, currentAlpha - step);
|
|
2403
|
+
event.preventDefault();
|
|
2404
|
+
}
|
|
2405
|
+
break;
|
|
2406
|
+
case "ArrowDown":
|
|
2407
|
+
if (direction === "vertical") {
|
|
2408
|
+
newAlpha = Math.min(1, currentAlpha + step);
|
|
2409
|
+
event.preventDefault();
|
|
2410
|
+
}
|
|
2411
|
+
break;
|
|
2412
|
+
default:
|
|
2413
|
+
return;
|
|
2414
|
+
}
|
|
2415
|
+
if (newAlpha !== currentAlpha) {
|
|
2416
|
+
var syntheticOffset = {
|
|
2417
|
+
left: direction === "horizontal" ? newAlpha : hsva.a,
|
|
2418
|
+
top: direction === "vertical" ? newAlpha : hsva.a,
|
|
2419
|
+
width: 0,
|
|
2420
|
+
height: 0,
|
|
2421
|
+
x: 0,
|
|
2422
|
+
y: 0
|
|
2423
|
+
};
|
|
2424
|
+
onChange && onChange((0, import_extends5.default)({}, hsva, {
|
|
2425
|
+
a: newAlpha
|
|
2426
|
+
}), syntheticOffset);
|
|
2427
|
+
}
|
|
2428
|
+
}, [hsva, direction, onChange]);
|
|
2429
|
+
var handleClick = React23.useCallback((event) => {
|
|
2430
|
+
event.target.focus();
|
|
2431
|
+
}, []);
|
|
2432
|
+
var pointerElement = pointer && typeof pointer === "function" ? pointer((0, import_extends5.default)({
|
|
2433
|
+
prefixCls
|
|
2434
|
+
}, pointerProps, comProps)) : /* @__PURE__ */ jsxRuntime.jsx(Pointer2, (0, import_extends5.default)({}, pointerProps, {
|
|
2435
|
+
prefixCls
|
|
2436
|
+
}, comProps));
|
|
2437
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", (0, import_extends5.default)({}, other, {
|
|
2438
|
+
className: [prefixCls, prefixCls + "-" + direction, className || ""].filter(Boolean).join(" "),
|
|
2439
|
+
style: styleWrapper,
|
|
2440
|
+
ref,
|
|
2441
|
+
children: [/* @__PURE__ */ jsxRuntime.jsx("div", (0, import_extends5.default)({}, bgProps, {
|
|
2442
|
+
style: (0, import_extends5.default)({
|
|
2443
|
+
inset: 0,
|
|
2444
|
+
position: "absolute",
|
|
2445
|
+
background: background || innerBackground,
|
|
2446
|
+
borderRadius: radius
|
|
2447
|
+
}, bgProps.style)
|
|
2448
|
+
})), /* @__PURE__ */ jsxRuntime.jsx(esm_default, (0, import_extends5.default)({}, innerProps, {
|
|
2449
|
+
style: (0, import_extends5.default)({}, innerProps.style, {
|
|
2450
|
+
inset: 0,
|
|
2451
|
+
zIndex: 1,
|
|
2452
|
+
position: "absolute",
|
|
2453
|
+
outline: "none"
|
|
2454
|
+
}),
|
|
2455
|
+
onMove: handleChange,
|
|
2456
|
+
onDown: handleChange,
|
|
2457
|
+
onClick: handleClick,
|
|
2458
|
+
onKeyDown: handleKeyDown,
|
|
2459
|
+
children: pointerElement
|
|
2460
|
+
}))]
|
|
2461
|
+
}));
|
|
2462
|
+
});
|
|
2463
|
+
Alpha.displayName = "Alpha";
|
|
2464
|
+
var esm_default3 = Alpha;
|
|
2465
|
+
|
|
2466
|
+
// node_modules/@uiw/react-color-editable-input/esm/index.js
|
|
2467
|
+
var import_extends6 = __toESM(require_extends());
|
|
2468
|
+
var import_objectWithoutPropertiesLoose5 = __toESM(require_objectWithoutPropertiesLoose());
|
|
2469
|
+
var _excluded5 = ["prefixCls", "placement", "label", "value", "className", "style", "labelStyle", "inputStyle", "onChange", "onBlur", "renderInput"];
|
|
2470
|
+
var validHex2 = (hex) => /^#?([A-Fa-f0-9]{3,4}){1,2}$/.test(hex);
|
|
2471
|
+
var getNumberValue = (value) => Number(String(value).replace(/%/g, ""));
|
|
2472
|
+
var EditableInput = /* @__PURE__ */ React23__namespace.default.forwardRef((props, ref) => {
|
|
2473
|
+
var {
|
|
2474
|
+
prefixCls = "w-color-editable-input",
|
|
2475
|
+
placement = "bottom",
|
|
2476
|
+
label,
|
|
2477
|
+
value: initValue,
|
|
2478
|
+
className,
|
|
2479
|
+
style,
|
|
2480
|
+
labelStyle,
|
|
2481
|
+
inputStyle,
|
|
2482
|
+
onChange,
|
|
2483
|
+
onBlur,
|
|
2484
|
+
renderInput
|
|
2485
|
+
} = props, other = (0, import_objectWithoutPropertiesLoose5.default)(props, _excluded5);
|
|
2486
|
+
var [value, setValue] = React23.useState(initValue);
|
|
2487
|
+
var isFocus = React23.useRef(false);
|
|
2488
|
+
React23.useEffect(() => {
|
|
2489
|
+
if (props.value !== value) {
|
|
2490
|
+
if (!isFocus.current) {
|
|
2491
|
+
setValue(props.value);
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
}, [props.value]);
|
|
2495
|
+
function handleChange(evn, valInit) {
|
|
2496
|
+
var value2 = (valInit || evn.target.value).trim().replace(/^#/, "");
|
|
2497
|
+
if (validHex2(value2)) {
|
|
2498
|
+
onChange && onChange(evn, value2);
|
|
2499
|
+
}
|
|
2500
|
+
var val = getNumberValue(value2);
|
|
2501
|
+
if (!isNaN(val)) {
|
|
2502
|
+
onChange && onChange(evn, val);
|
|
2503
|
+
}
|
|
2504
|
+
setValue(value2);
|
|
2505
|
+
}
|
|
2506
|
+
function handleBlur(evn) {
|
|
2507
|
+
isFocus.current = false;
|
|
2508
|
+
setValue(props.value);
|
|
2509
|
+
onBlur && onBlur(evn);
|
|
2510
|
+
}
|
|
2511
|
+
var placementStyle = {};
|
|
2512
|
+
if (placement === "bottom") {
|
|
2513
|
+
placementStyle["flexDirection"] = "column";
|
|
2514
|
+
}
|
|
2515
|
+
if (placement === "top") {
|
|
2516
|
+
placementStyle["flexDirection"] = "column-reverse";
|
|
2517
|
+
}
|
|
2518
|
+
if (placement === "left") {
|
|
2519
|
+
placementStyle["flexDirection"] = "row-reverse";
|
|
2520
|
+
}
|
|
2521
|
+
var wrapperStyle = (0, import_extends6.default)({
|
|
2522
|
+
"--editable-input-label-color": "rgb(153, 153, 153)",
|
|
2523
|
+
"--editable-input-box-shadow": "rgb(204 204 204) 0px 0px 0px 1px inset",
|
|
2524
|
+
"--editable-input-color": "#666",
|
|
2525
|
+
position: "relative",
|
|
2526
|
+
alignItems: "center",
|
|
2527
|
+
display: "flex",
|
|
2528
|
+
fontSize: 11
|
|
2529
|
+
}, placementStyle, style);
|
|
2530
|
+
var editableStyle = (0, import_extends6.default)({
|
|
2531
|
+
width: "100%",
|
|
2532
|
+
paddingTop: 2,
|
|
2533
|
+
paddingBottom: 2,
|
|
2534
|
+
paddingLeft: 3,
|
|
2535
|
+
paddingRight: 3,
|
|
2536
|
+
fontSize: 11,
|
|
2537
|
+
background: "transparent",
|
|
2538
|
+
boxSizing: "border-box",
|
|
2539
|
+
border: "none",
|
|
2540
|
+
color: "var(--editable-input-color)",
|
|
2541
|
+
boxShadow: "var(--editable-input-box-shadow)"
|
|
2542
|
+
}, inputStyle);
|
|
2543
|
+
var inputProps = (0, import_extends6.default)({
|
|
2544
|
+
value,
|
|
2545
|
+
onChange: handleChange,
|
|
2546
|
+
onBlur: handleBlur,
|
|
2547
|
+
autoComplete: "off",
|
|
2548
|
+
onFocus: () => isFocus.current = true
|
|
2549
|
+
}, other, {
|
|
2550
|
+
style: editableStyle,
|
|
2551
|
+
onFocusCapture: (e) => {
|
|
2552
|
+
var elm = e.target;
|
|
2553
|
+
elm.setSelectionRange(elm.value.length, elm.value.length);
|
|
2554
|
+
}
|
|
2555
|
+
});
|
|
2556
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
2557
|
+
className: [prefixCls, className || ""].filter(Boolean).join(" "),
|
|
2558
|
+
style: wrapperStyle,
|
|
2559
|
+
children: [renderInput ? renderInput(inputProps, ref) : /* @__PURE__ */ jsxRuntime.jsx("input", (0, import_extends6.default)({
|
|
2560
|
+
ref
|
|
2561
|
+
}, inputProps)), label && /* @__PURE__ */ jsxRuntime.jsx("span", {
|
|
2562
|
+
style: (0, import_extends6.default)({
|
|
2563
|
+
color: "var(--editable-input-label-color)",
|
|
2564
|
+
textTransform: "capitalize"
|
|
2565
|
+
}, labelStyle),
|
|
2566
|
+
children: label
|
|
2567
|
+
})]
|
|
2568
|
+
});
|
|
2569
|
+
});
|
|
2570
|
+
EditableInput.displayName = "EditableInput";
|
|
2571
|
+
var esm_default4 = EditableInput;
|
|
2572
|
+
|
|
2573
|
+
// node_modules/@uiw/react-color-editable-input-rgba/esm/index.js
|
|
2574
|
+
var import_extends7 = __toESM(require_extends());
|
|
2575
|
+
var import_objectWithoutPropertiesLoose6 = __toESM(require_objectWithoutPropertiesLoose());
|
|
2576
|
+
var _excluded6 = ["prefixCls", "hsva", "placement", "rProps", "gProps", "bProps", "aProps", "className", "style", "onChange"];
|
|
2577
|
+
var EditableInputRGBA = /* @__PURE__ */ React23__namespace.default.forwardRef((props, ref) => {
|
|
2578
|
+
var {
|
|
2579
|
+
prefixCls = "w-color-editable-input-rgba",
|
|
2580
|
+
hsva,
|
|
2581
|
+
placement = "bottom",
|
|
2582
|
+
rProps = {},
|
|
2583
|
+
gProps = {},
|
|
2584
|
+
bProps = {},
|
|
2585
|
+
aProps = {},
|
|
2586
|
+
className,
|
|
2587
|
+
style,
|
|
2588
|
+
onChange
|
|
2589
|
+
} = props, other = (0, import_objectWithoutPropertiesLoose6.default)(props, _excluded6);
|
|
2590
|
+
var rgba = hsva ? hsvaToRgba(hsva) : {};
|
|
2591
|
+
function handleBlur(evn) {
|
|
2592
|
+
var value = Number(evn.target.value);
|
|
2593
|
+
if (value && value > 255) {
|
|
2594
|
+
evn.target.value = "255";
|
|
2595
|
+
}
|
|
2596
|
+
if (value && value < 0) {
|
|
2597
|
+
evn.target.value = "0";
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
var handleAlphaBlur = (evn) => {
|
|
2601
|
+
var value = Number(evn.target.value);
|
|
2602
|
+
if (value && value > 100) {
|
|
2603
|
+
evn.target.value = "100";
|
|
2604
|
+
}
|
|
2605
|
+
if (value && value < 0) {
|
|
2606
|
+
evn.target.value = "0";
|
|
2607
|
+
}
|
|
2608
|
+
};
|
|
2609
|
+
var handleChange = (value, type, evn) => {
|
|
2610
|
+
if (typeof value === "number") {
|
|
2611
|
+
if (type === "a") {
|
|
2612
|
+
if (value < 0) value = 0;
|
|
2613
|
+
if (value > 100) value = 100;
|
|
2614
|
+
onChange && onChange(color(rgbaToHsva((0, import_extends7.default)({}, rgba, {
|
|
2615
|
+
a: value / 100
|
|
2616
|
+
}))));
|
|
2617
|
+
}
|
|
2618
|
+
if (value > 255) {
|
|
2619
|
+
value = 255;
|
|
2620
|
+
evn.target.value = "255";
|
|
2621
|
+
}
|
|
2622
|
+
if (value < 0) {
|
|
2623
|
+
value = 0;
|
|
2624
|
+
evn.target.value = "0";
|
|
2625
|
+
}
|
|
2626
|
+
if (type === "r") {
|
|
2627
|
+
onChange && onChange(color(rgbaToHsva((0, import_extends7.default)({}, rgba, {
|
|
2628
|
+
r: value
|
|
2629
|
+
}))));
|
|
2630
|
+
}
|
|
2631
|
+
if (type === "g") {
|
|
2632
|
+
onChange && onChange(color(rgbaToHsva((0, import_extends7.default)({}, rgba, {
|
|
2633
|
+
g: value
|
|
2634
|
+
}))));
|
|
2635
|
+
}
|
|
2636
|
+
if (type === "b") {
|
|
2637
|
+
onChange && onChange(color(rgbaToHsva((0, import_extends7.default)({}, rgba, {
|
|
2638
|
+
b: value
|
|
2639
|
+
}))));
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2642
|
+
};
|
|
2643
|
+
var roundedAlpha = rgba.a ? Math.round(rgba.a * 100) / 100 : 0;
|
|
2644
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", (0, import_extends7.default)({
|
|
2645
|
+
ref,
|
|
2646
|
+
className: [prefixCls, className || ""].filter(Boolean).join(" ")
|
|
2647
|
+
}, other, {
|
|
2648
|
+
style: (0, import_extends7.default)({
|
|
2649
|
+
fontSize: 11,
|
|
2650
|
+
display: "flex"
|
|
2651
|
+
}, style),
|
|
2652
|
+
children: [/* @__PURE__ */ jsxRuntime.jsx(esm_default4, (0, import_extends7.default)({
|
|
2653
|
+
label: "R",
|
|
2654
|
+
value: rgba.r || 0,
|
|
2655
|
+
onBlur: handleBlur,
|
|
2656
|
+
placement,
|
|
2657
|
+
onChange: (evn, val) => handleChange(val, "r", evn)
|
|
2658
|
+
}, rProps, {
|
|
2659
|
+
style: (0, import_extends7.default)({}, rProps.style)
|
|
2660
|
+
})), /* @__PURE__ */ jsxRuntime.jsx(esm_default4, (0, import_extends7.default)({
|
|
2661
|
+
label: "G",
|
|
2662
|
+
value: rgba.g || 0,
|
|
2663
|
+
onBlur: handleBlur,
|
|
2664
|
+
placement,
|
|
2665
|
+
onChange: (evn, val) => handleChange(val, "g", evn)
|
|
2666
|
+
}, gProps, {
|
|
2667
|
+
style: (0, import_extends7.default)({
|
|
2668
|
+
marginLeft: 5
|
|
2669
|
+
}, rProps.style)
|
|
2670
|
+
})), /* @__PURE__ */ jsxRuntime.jsx(esm_default4, (0, import_extends7.default)({
|
|
2671
|
+
label: "B",
|
|
2672
|
+
value: rgba.b || 0,
|
|
2673
|
+
onBlur: handleBlur,
|
|
2674
|
+
placement,
|
|
2675
|
+
onChange: (evn, val) => handleChange(val, "b", evn)
|
|
2676
|
+
}, bProps, {
|
|
2677
|
+
style: (0, import_extends7.default)({
|
|
2678
|
+
marginLeft: 5
|
|
2679
|
+
}, bProps.style)
|
|
2680
|
+
})), aProps && /* @__PURE__ */ jsxRuntime.jsx(esm_default4, (0, import_extends7.default)({
|
|
2681
|
+
label: "A",
|
|
2682
|
+
value: parseInt(String(roundedAlpha * 100), 10),
|
|
2683
|
+
onBlur: handleAlphaBlur,
|
|
2684
|
+
placement,
|
|
2685
|
+
onChange: (evn, val) => handleChange(val, "a", evn)
|
|
2686
|
+
}, aProps, {
|
|
2687
|
+
style: (0, import_extends7.default)({
|
|
2688
|
+
marginLeft: 5
|
|
2689
|
+
}, aProps.style)
|
|
2690
|
+
}))]
|
|
2691
|
+
}));
|
|
2692
|
+
});
|
|
2693
|
+
EditableInputRGBA.displayName = "EditableInputRGBA";
|
|
2694
|
+
var esm_default5 = EditableInputRGBA;
|
|
2695
|
+
|
|
2696
|
+
// node_modules/@uiw/react-color-hue/esm/index.js
|
|
2697
|
+
var import_extends8 = __toESM(require_extends());
|
|
2698
|
+
var import_objectWithoutPropertiesLoose7 = __toESM(require_objectWithoutPropertiesLoose());
|
|
2699
|
+
var _excluded7 = ["prefixCls", "className", "hue", "onChange", "direction"];
|
|
2700
|
+
var Hue = /* @__PURE__ */ React23__namespace.default.forwardRef((props, ref) => {
|
|
2701
|
+
var {
|
|
2702
|
+
prefixCls = "w-color-hue",
|
|
2703
|
+
className,
|
|
2704
|
+
hue = 0,
|
|
2705
|
+
onChange: _onChange,
|
|
2706
|
+
direction = "horizontal"
|
|
2707
|
+
} = props, other = (0, import_objectWithoutPropertiesLoose7.default)(props, _excluded7);
|
|
2708
|
+
return /* @__PURE__ */ jsxRuntime.jsx(esm_default3, (0, import_extends8.default)({
|
|
2709
|
+
ref,
|
|
2710
|
+
className: prefixCls + " " + (className || "")
|
|
2711
|
+
}, other, {
|
|
2712
|
+
direction,
|
|
2713
|
+
background: "linear-gradient(to " + (direction === "horizontal" ? "right" : "bottom") + ", rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)",
|
|
2714
|
+
hsva: {
|
|
2715
|
+
h: hue,
|
|
2716
|
+
s: 100,
|
|
2717
|
+
v: 100,
|
|
2718
|
+
a: hue / 360
|
|
2719
|
+
},
|
|
2720
|
+
onChange: (_, interaction) => {
|
|
2721
|
+
_onChange && _onChange({
|
|
2722
|
+
h: direction === "horizontal" ? 360 * interaction.left : 360 * interaction.top
|
|
2723
|
+
});
|
|
2724
|
+
}
|
|
2725
|
+
}));
|
|
2726
|
+
});
|
|
2727
|
+
Hue.displayName = "Hue";
|
|
2728
|
+
var esm_default6 = Hue;
|
|
2729
|
+
|
|
2730
|
+
// node_modules/@uiw/react-color-swatch/esm/index.js
|
|
2731
|
+
var import_extends9 = __toESM(require_extends());
|
|
2732
|
+
var import_objectWithoutPropertiesLoose8 = __toESM(require_objectWithoutPropertiesLoose());
|
|
2733
|
+
var _excluded8 = ["prefixCls", "className", "color", "colors", "style", "rectProps", "onChange", "addonAfter", "addonBefore", "rectRender"];
|
|
2734
|
+
var Swatch = /* @__PURE__ */ React23__namespace.default.forwardRef((props, ref) => {
|
|
2735
|
+
var {
|
|
2736
|
+
prefixCls = "w-color-swatch",
|
|
2737
|
+
className,
|
|
2738
|
+
color: color2,
|
|
2739
|
+
colors = [],
|
|
2740
|
+
style,
|
|
2741
|
+
rectProps = {},
|
|
2742
|
+
onChange,
|
|
2743
|
+
addonAfter,
|
|
2744
|
+
addonBefore,
|
|
2745
|
+
rectRender
|
|
2746
|
+
} = props, other = (0, import_objectWithoutPropertiesLoose8.default)(props, _excluded8);
|
|
2747
|
+
var rectStyle = (0, import_extends9.default)({
|
|
2748
|
+
"--swatch-background-color": "rgb(144, 19, 254)",
|
|
2749
|
+
background: "var(--swatch-background-color)",
|
|
2750
|
+
height: 15,
|
|
2751
|
+
width: 15,
|
|
2752
|
+
marginRight: 5,
|
|
2753
|
+
marginBottom: 5,
|
|
2754
|
+
cursor: "pointer",
|
|
2755
|
+
position: "relative",
|
|
2756
|
+
outline: "none",
|
|
2757
|
+
borderRadius: 2
|
|
2758
|
+
}, rectProps.style);
|
|
2759
|
+
var handleClick = (hex, evn) => {
|
|
2760
|
+
onChange && onChange(hexToHsva(hex), color(hexToHsva(hex)), evn);
|
|
2761
|
+
};
|
|
2762
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", (0, import_extends9.default)({
|
|
2763
|
+
ref
|
|
2764
|
+
}, other, {
|
|
2765
|
+
className: [prefixCls, className || ""].filter(Boolean).join(" "),
|
|
2766
|
+
style: (0, import_extends9.default)({
|
|
2767
|
+
display: "flex",
|
|
2768
|
+
flexWrap: "wrap",
|
|
2769
|
+
position: "relative"
|
|
2770
|
+
}, style),
|
|
2771
|
+
children: [addonBefore && /* @__PURE__ */ React23__namespace.default.isValidElement(addonBefore) && addonBefore, colors && Array.isArray(colors) && colors.map((item, idx) => {
|
|
2772
|
+
var title = "";
|
|
2773
|
+
var background = "";
|
|
2774
|
+
if (typeof item === "string") {
|
|
2775
|
+
title = item;
|
|
2776
|
+
background = item;
|
|
2777
|
+
}
|
|
2778
|
+
if (typeof item === "object" && item.color) {
|
|
2779
|
+
title = item.title || item.color;
|
|
2780
|
+
background = item.color;
|
|
2781
|
+
}
|
|
2782
|
+
var checked = color2 && color2.toLocaleLowerCase() === background.toLocaleLowerCase();
|
|
2783
|
+
var render = rectRender && rectRender({
|
|
2784
|
+
title,
|
|
2785
|
+
color: background,
|
|
2786
|
+
checked: !!checked,
|
|
2787
|
+
style: (0, import_extends9.default)({}, rectStyle, {
|
|
2788
|
+
background
|
|
2789
|
+
}),
|
|
2790
|
+
onClick: (evn) => handleClick(background, evn)
|
|
2791
|
+
});
|
|
2792
|
+
if (render) {
|
|
2793
|
+
return /* @__PURE__ */ jsxRuntime.jsx(React23.Fragment, {
|
|
2794
|
+
children: render
|
|
2795
|
+
}, idx);
|
|
2796
|
+
}
|
|
2797
|
+
var child = rectProps.children && /* @__PURE__ */ React23__namespace.default.isValidElement(rectProps.children) ? /* @__PURE__ */ React23__namespace.default.cloneElement(rectProps.children, {
|
|
2798
|
+
color: background,
|
|
2799
|
+
checked
|
|
2800
|
+
}) : null;
|
|
2801
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", (0, import_extends9.default)({
|
|
2802
|
+
tabIndex: 0,
|
|
2803
|
+
title,
|
|
2804
|
+
onClick: (evn) => handleClick(background, evn)
|
|
2805
|
+
}, rectProps, {
|
|
2806
|
+
children: child,
|
|
2807
|
+
style: (0, import_extends9.default)({}, rectStyle, {
|
|
2808
|
+
background
|
|
2809
|
+
})
|
|
2810
|
+
}), idx);
|
|
2811
|
+
}), addonAfter && /* @__PURE__ */ React23__namespace.default.isValidElement(addonAfter) && addonAfter]
|
|
2812
|
+
}));
|
|
2813
|
+
});
|
|
2814
|
+
Swatch.displayName = "Swatch";
|
|
2815
|
+
var esm_default7 = Swatch;
|
|
2816
|
+
var _excluded9 = ["prefixCls", "className", "onChange", "width", "presetColors", "color", "editableDisable", "disableAlpha", "style"];
|
|
2817
|
+
var PRESET_COLORS = ["#D0021B", "#F5A623", "#f8e61b", "#8B572A", "#7ED321", "#417505", "#BD10E0", "#9013FE", "#4A90E2", "#50E3C2", "#B8E986", "#000000", "#4A4A4A", "#9B9B9B", "#FFFFFF"];
|
|
2818
|
+
var Bar = (props) => /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
2819
|
+
style: {
|
|
2820
|
+
boxShadow: "rgb(0 0 0 / 60%) 0px 0px 2px",
|
|
2821
|
+
width: 4,
|
|
2822
|
+
top: 1,
|
|
2823
|
+
bottom: 1,
|
|
2824
|
+
left: props.left,
|
|
2825
|
+
borderRadius: 1,
|
|
2826
|
+
position: "absolute",
|
|
2827
|
+
backgroundColor: "#fff"
|
|
2828
|
+
}
|
|
2829
|
+
});
|
|
2830
|
+
var Sketch = /* @__PURE__ */ React23__namespace.default.forwardRef((props, ref) => {
|
|
2831
|
+
var {
|
|
2832
|
+
prefixCls = "w-color-sketch",
|
|
2833
|
+
className,
|
|
2834
|
+
onChange,
|
|
2835
|
+
width = 218,
|
|
2836
|
+
presetColors = PRESET_COLORS,
|
|
2837
|
+
color: color2,
|
|
2838
|
+
editableDisable = true,
|
|
2839
|
+
disableAlpha = false,
|
|
2840
|
+
style
|
|
2841
|
+
} = props, other = (0, import_objectWithoutPropertiesLoose9.default)(props, _excluded9);
|
|
2842
|
+
var [hsva, setHsva] = React23.useState({
|
|
2843
|
+
h: 209,
|
|
2844
|
+
s: 36,
|
|
2845
|
+
v: 90,
|
|
2846
|
+
a: 1
|
|
2847
|
+
});
|
|
2848
|
+
React23.useEffect(() => {
|
|
2849
|
+
if (typeof color2 === "string" && validHex(color2)) {
|
|
2850
|
+
setHsva(hexToHsva(color2));
|
|
2851
|
+
}
|
|
2852
|
+
if (typeof color2 === "object") {
|
|
2853
|
+
setHsva(color2);
|
|
2854
|
+
}
|
|
2855
|
+
}, [color2]);
|
|
2856
|
+
var handleChange = (hsv) => {
|
|
2857
|
+
setHsva(hsv);
|
|
2858
|
+
onChange && onChange(color(hsv));
|
|
2859
|
+
};
|
|
2860
|
+
var handleHex = (value, evn) => {
|
|
2861
|
+
if (typeof value === "string" && validHex(value) && /(3|6)/.test(String(value.length))) {
|
|
2862
|
+
handleChange(hexToHsva(value));
|
|
2863
|
+
}
|
|
2864
|
+
};
|
|
2865
|
+
var handleAlphaChange = (newAlpha) => handleChange((0, import_extends10.default)({}, hsva, {
|
|
2866
|
+
a: newAlpha.a
|
|
2867
|
+
}));
|
|
2868
|
+
var handleSaturationChange = (newColor) => handleChange((0, import_extends10.default)({}, hsva, newColor, {
|
|
2869
|
+
a: hsva.a
|
|
2870
|
+
}));
|
|
2871
|
+
var styleMain = (0, import_extends10.default)({
|
|
2872
|
+
"--sketch-background": "rgb(255, 255, 255)",
|
|
2873
|
+
"--sketch-box-shadow": "rgb(0 0 0 / 15%) 0px 0px 0px 1px, rgb(0 0 0 / 15%) 0px 8px 16px",
|
|
2874
|
+
"--sketch-swatch-box-shadow": "rgb(0 0 0 / 15%) 0px 0px 0px 1px inset",
|
|
2875
|
+
"--sketch-alpha-box-shadow": "rgb(0 0 0 / 15%) 0px 0px 0px 1px inset, rgb(0 0 0 / 25%) 0px 0px 4px inset",
|
|
2876
|
+
"--sketch-swatch-border-top": "1px solid rgb(238, 238, 238)",
|
|
2877
|
+
background: "var(--sketch-background)",
|
|
2878
|
+
borderRadius: 4,
|
|
2879
|
+
boxShadow: "var(--sketch-box-shadow)",
|
|
2880
|
+
width
|
|
2881
|
+
}, style);
|
|
2882
|
+
var styleAlpha = {
|
|
2883
|
+
borderRadius: 2,
|
|
2884
|
+
background: hsvaToRgbaString(hsva),
|
|
2885
|
+
boxShadow: "var(--sketch-alpha-box-shadow)"
|
|
2886
|
+
};
|
|
2887
|
+
var styleSwatch = {
|
|
2888
|
+
borderTop: "var(--sketch-swatch-border-top)",
|
|
2889
|
+
paddingTop: 10,
|
|
2890
|
+
paddingLeft: 10
|
|
2891
|
+
};
|
|
2892
|
+
var styleSwatchRect = {
|
|
2893
|
+
marginRight: 10,
|
|
2894
|
+
marginBottom: 10,
|
|
2895
|
+
borderRadius: 3,
|
|
2896
|
+
boxShadow: "var(--sketch-swatch-box-shadow)"
|
|
2897
|
+
};
|
|
2898
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", (0, import_extends10.default)({}, other, {
|
|
2899
|
+
className: prefixCls + " " + (className || ""),
|
|
2900
|
+
ref,
|
|
2901
|
+
style: styleMain,
|
|
2902
|
+
children: [/* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
2903
|
+
style: {
|
|
2904
|
+
padding: "10px 10px 8px"
|
|
2905
|
+
},
|
|
2906
|
+
children: [/* @__PURE__ */ jsxRuntime.jsx(esm_default2, {
|
|
2907
|
+
hsva,
|
|
2908
|
+
style: {
|
|
2909
|
+
width: "auto",
|
|
2910
|
+
height: 150
|
|
2911
|
+
},
|
|
2912
|
+
onChange: handleSaturationChange
|
|
2913
|
+
}), /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
2914
|
+
style: {
|
|
2915
|
+
display: "flex",
|
|
2916
|
+
marginTop: 4
|
|
2917
|
+
},
|
|
2918
|
+
children: [/* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
2919
|
+
style: {
|
|
2920
|
+
flex: 1
|
|
2921
|
+
},
|
|
2922
|
+
children: [/* @__PURE__ */ jsxRuntime.jsx(esm_default6, {
|
|
2923
|
+
width: "auto",
|
|
2924
|
+
height: 10,
|
|
2925
|
+
hue: hsva.h,
|
|
2926
|
+
pointer: Bar,
|
|
2927
|
+
innerProps: {
|
|
2928
|
+
style: {
|
|
2929
|
+
marginLeft: 1,
|
|
2930
|
+
marginRight: 5
|
|
2931
|
+
}
|
|
2932
|
+
},
|
|
2933
|
+
onChange: (newHue) => handleChange((0, import_extends10.default)({}, hsva, newHue))
|
|
2934
|
+
}), !disableAlpha && /* @__PURE__ */ jsxRuntime.jsx(esm_default3, {
|
|
2935
|
+
width: "auto",
|
|
2936
|
+
height: 10,
|
|
2937
|
+
hsva,
|
|
2938
|
+
pointer: Bar,
|
|
2939
|
+
style: {
|
|
2940
|
+
marginTop: 4
|
|
2941
|
+
},
|
|
2942
|
+
innerProps: {
|
|
2943
|
+
style: {
|
|
2944
|
+
marginLeft: 1,
|
|
2945
|
+
marginRight: 5
|
|
2946
|
+
}
|
|
2947
|
+
},
|
|
2948
|
+
onChange: handleAlphaChange
|
|
2949
|
+
})]
|
|
2950
|
+
}), !disableAlpha && /* @__PURE__ */ jsxRuntime.jsx(esm_default3, {
|
|
2951
|
+
width: 24,
|
|
2952
|
+
height: 24,
|
|
2953
|
+
hsva,
|
|
2954
|
+
radius: 2,
|
|
2955
|
+
style: {
|
|
2956
|
+
marginLeft: 4
|
|
2957
|
+
},
|
|
2958
|
+
bgProps: {
|
|
2959
|
+
style: {
|
|
2960
|
+
background: "transparent"
|
|
2961
|
+
}
|
|
2962
|
+
},
|
|
2963
|
+
innerProps: {
|
|
2964
|
+
style: styleAlpha
|
|
2965
|
+
},
|
|
2966
|
+
pointer: () => /* @__PURE__ */ jsxRuntime.jsx(React23.Fragment, {})
|
|
2967
|
+
})]
|
|
2968
|
+
})]
|
|
2969
|
+
}), editableDisable && /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
2970
|
+
style: {
|
|
2971
|
+
display: "flex",
|
|
2972
|
+
margin: "0 10px 3px 10px"
|
|
2973
|
+
},
|
|
2974
|
+
children: [/* @__PURE__ */ jsxRuntime.jsx(esm_default4, {
|
|
2975
|
+
label: "Hex",
|
|
2976
|
+
value: hsvaToHex(hsva).replace(/^#/, "").toLocaleUpperCase(),
|
|
2977
|
+
onChange: (evn, val) => handleHex(val),
|
|
2978
|
+
style: {
|
|
2979
|
+
minWidth: 58
|
|
2980
|
+
}
|
|
2981
|
+
}), /* @__PURE__ */ jsxRuntime.jsx(esm_default5, {
|
|
2982
|
+
hsva,
|
|
2983
|
+
style: {
|
|
2984
|
+
marginLeft: 6
|
|
2985
|
+
},
|
|
2986
|
+
aProps: !disableAlpha ? {} : false,
|
|
2987
|
+
onChange: (result) => handleChange(result.hsva)
|
|
2988
|
+
})]
|
|
2989
|
+
}), presetColors && presetColors.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(esm_default7, {
|
|
2990
|
+
style: styleSwatch,
|
|
2991
|
+
colors: presetColors,
|
|
2992
|
+
color: hsvaToHex(hsva),
|
|
2993
|
+
onChange: (hsvColor) => handleChange(hsvColor),
|
|
2994
|
+
rectProps: {
|
|
2995
|
+
style: styleSwatchRect
|
|
2996
|
+
}
|
|
2997
|
+
})]
|
|
2998
|
+
}));
|
|
2999
|
+
});
|
|
3000
|
+
Sketch.displayName = "Sketch";
|
|
3001
|
+
var esm_default8 = Sketch;
|
|
3002
|
+
|
|
3003
|
+
// src/components/hazo_ui_rte/types.ts
|
|
3004
|
+
var FONT_FAMILIES = [
|
|
3005
|
+
{ label: "Arial", value: "Arial, sans-serif" },
|
|
3006
|
+
{ label: "Verdana", value: "Verdana, sans-serif" },
|
|
3007
|
+
{ label: "Times New Roman", value: "Times New Roman, serif" },
|
|
3008
|
+
{ label: "Georgia", value: "Georgia, serif" },
|
|
3009
|
+
{ label: "Courier New", value: "Courier New, monospace" },
|
|
3010
|
+
{ label: "Trebuchet MS", value: "Trebuchet MS, sans-serif" }
|
|
3011
|
+
];
|
|
3012
|
+
var FONT_SIZE_CONFIG = {
|
|
3013
|
+
default: 16,
|
|
3014
|
+
min: 8,
|
|
3015
|
+
max: 72,
|
|
3016
|
+
step: 2
|
|
3017
|
+
};
|
|
3018
|
+
var BLOCK_TYPES = [
|
|
3019
|
+
{ label: "Paragraph", value: "paragraph", icon: "paragraph" },
|
|
3020
|
+
{ label: "Heading 1", value: "heading-1", icon: "h1" },
|
|
3021
|
+
{ label: "Heading 2", value: "heading-2", icon: "h2" },
|
|
3022
|
+
{ label: "Heading 3", value: "heading-3", icon: "h3" },
|
|
3023
|
+
{ label: "Numbered List", value: "ordered-list", icon: "list-ordered" },
|
|
3024
|
+
{ label: "Bulleted List", value: "bullet-list", icon: "list" },
|
|
3025
|
+
{ label: "Check List", value: "task-list", icon: "list-checks" },
|
|
3026
|
+
{ label: "Code Block", value: "code-block", icon: "code" },
|
|
3027
|
+
{ label: "Quote", value: "blockquote", icon: "quote" }
|
|
3028
|
+
];
|
|
3029
|
+
|
|
3030
|
+
// src/components/hazo_ui_rte/utils.ts
|
|
3031
|
+
function file_to_base64(file) {
|
|
3032
|
+
return new Promise((resolve, reject) => {
|
|
3033
|
+
const reader = new FileReader();
|
|
3034
|
+
reader.onload = () => {
|
|
3035
|
+
const result = reader.result;
|
|
3036
|
+
const base64 = result.split(",")[1];
|
|
3037
|
+
resolve(base64);
|
|
3038
|
+
};
|
|
3039
|
+
reader.onerror = reject;
|
|
3040
|
+
reader.readAsDataURL(file);
|
|
3041
|
+
});
|
|
3042
|
+
}
|
|
3043
|
+
async function file_to_attachment(file) {
|
|
3044
|
+
const data = await file_to_base64(file);
|
|
3045
|
+
return {
|
|
3046
|
+
filename: file.name,
|
|
3047
|
+
mime_type: file.type || "application/octet-stream",
|
|
3048
|
+
data
|
|
3049
|
+
};
|
|
3050
|
+
}
|
|
3051
|
+
function file_to_data_url(file) {
|
|
3052
|
+
return new Promise((resolve, reject) => {
|
|
3053
|
+
const reader = new FileReader();
|
|
3054
|
+
reader.onload = () => resolve(reader.result);
|
|
3055
|
+
reader.onerror = reject;
|
|
3056
|
+
reader.readAsDataURL(file);
|
|
3057
|
+
});
|
|
3058
|
+
}
|
|
3059
|
+
function format_file_size(bytes) {
|
|
3060
|
+
if (bytes === 0) return "0 B";
|
|
3061
|
+
const k = 1024;
|
|
3062
|
+
const sizes = ["B", "KB", "MB", "GB"];
|
|
3063
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
3064
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(1))} ${sizes[i]}`;
|
|
3065
|
+
}
|
|
3066
|
+
function get_file_extension(filename) {
|
|
3067
|
+
const parts = filename.split(".");
|
|
3068
|
+
return parts.length > 1 ? parts.pop()?.toLowerCase() || "" : "";
|
|
3069
|
+
}
|
|
3070
|
+
function is_image_file(mime_type) {
|
|
3071
|
+
return mime_type.startsWith("image/");
|
|
3072
|
+
}
|
|
3073
|
+
var ToolbarSeparator = () => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_rte_toolbar_separator mx-1 h-6 w-px bg-border" });
|
|
3074
|
+
var Toolbar = ({
|
|
3075
|
+
editor,
|
|
3076
|
+
variables = [],
|
|
3077
|
+
attachments,
|
|
3078
|
+
on_attachments_change,
|
|
3079
|
+
disabled = false
|
|
3080
|
+
}) => {
|
|
3081
|
+
const [link_url, set_link_url] = React23__namespace.useState("https://");
|
|
3082
|
+
const [link_popover_open, set_link_popover_open] = React23__namespace.useState(false);
|
|
3083
|
+
const [text_color_open, set_text_color_open] = React23__namespace.useState(false);
|
|
3084
|
+
const [highlight_color_open, set_highlight_color_open] = React23__namespace.useState(false);
|
|
3085
|
+
const [variables_menu_open, set_variables_menu_open] = React23__namespace.useState(false);
|
|
3086
|
+
const [table_menu_open, set_table_menu_open] = React23__namespace.useState(false);
|
|
3087
|
+
const [text_color, set_text_color] = React23__namespace.useState("#000000");
|
|
3088
|
+
const [highlight_color, set_highlight_color] = React23__namespace.useState("#ffff00");
|
|
3089
|
+
const [table_rows, set_table_rows] = React23__namespace.useState(3);
|
|
3090
|
+
const [table_cols, set_table_cols] = React23__namespace.useState(3);
|
|
3091
|
+
const [hovered_cell, set_hovered_cell] = React23__namespace.useState(null);
|
|
3092
|
+
const file_input_ref = React23__namespace.useRef(null);
|
|
3093
|
+
const image_input_ref = React23__namespace.useRef(null);
|
|
3094
|
+
if (!editor) {
|
|
3095
|
+
return null;
|
|
3096
|
+
}
|
|
3097
|
+
const get_current_font_size = () => {
|
|
3098
|
+
const attrs = editor.getAttributes("textStyle");
|
|
3099
|
+
return attrs.fontSize || FONT_SIZE_CONFIG.default;
|
|
3100
|
+
};
|
|
3101
|
+
const get_current_font_family = () => {
|
|
3102
|
+
const attrs = editor.getAttributes("textStyle");
|
|
3103
|
+
return attrs.fontFamily || FONT_FAMILIES[0].value;
|
|
3104
|
+
};
|
|
3105
|
+
const get_current_block_type = () => {
|
|
3106
|
+
if (editor.isActive("heading", { level: 1 })) return "heading-1";
|
|
3107
|
+
if (editor.isActive("heading", { level: 2 })) return "heading-2";
|
|
3108
|
+
if (editor.isActive("heading", { level: 3 })) return "heading-3";
|
|
3109
|
+
if (editor.isActive("bulletList")) return "bullet-list";
|
|
3110
|
+
if (editor.isActive("orderedList")) return "ordered-list";
|
|
3111
|
+
if (editor.isActive("taskList")) return "task-list";
|
|
3112
|
+
if (editor.isActive("codeBlock")) return "code-block";
|
|
3113
|
+
if (editor.isActive("blockquote")) return "blockquote";
|
|
3114
|
+
return "paragraph";
|
|
3115
|
+
};
|
|
3116
|
+
const handle_block_type_change = (value) => {
|
|
3117
|
+
switch (value) {
|
|
3118
|
+
case "paragraph":
|
|
3119
|
+
editor.chain().focus().setParagraph().run();
|
|
3120
|
+
break;
|
|
3121
|
+
case "heading-1":
|
|
3122
|
+
editor.chain().focus().toggleHeading({ level: 1 }).run();
|
|
3123
|
+
break;
|
|
3124
|
+
case "heading-2":
|
|
3125
|
+
editor.chain().focus().toggleHeading({ level: 2 }).run();
|
|
3126
|
+
break;
|
|
3127
|
+
case "heading-3":
|
|
3128
|
+
editor.chain().focus().toggleHeading({ level: 3 }).run();
|
|
3129
|
+
break;
|
|
3130
|
+
case "bullet-list":
|
|
3131
|
+
editor.chain().focus().toggleBulletList().run();
|
|
3132
|
+
break;
|
|
3133
|
+
case "ordered-list":
|
|
3134
|
+
editor.chain().focus().toggleOrderedList().run();
|
|
3135
|
+
break;
|
|
3136
|
+
case "task-list":
|
|
3137
|
+
editor.chain().focus().toggleTaskList().run();
|
|
3138
|
+
break;
|
|
3139
|
+
case "code-block":
|
|
3140
|
+
editor.chain().focus().toggleCodeBlock().run();
|
|
3141
|
+
break;
|
|
3142
|
+
case "blockquote":
|
|
3143
|
+
editor.chain().focus().toggleBlockquote().run();
|
|
3144
|
+
break;
|
|
3145
|
+
}
|
|
3146
|
+
};
|
|
3147
|
+
const handle_font_family_change = (value) => {
|
|
3148
|
+
editor.chain().focus().setFontFamily(value).run();
|
|
3149
|
+
};
|
|
3150
|
+
const handle_font_size_change = (delta) => {
|
|
3151
|
+
const current = get_current_font_size();
|
|
3152
|
+
const new_size = Math.min(
|
|
3153
|
+
FONT_SIZE_CONFIG.max,
|
|
3154
|
+
Math.max(FONT_SIZE_CONFIG.min, current + delta)
|
|
3155
|
+
);
|
|
3156
|
+
editor.chain().focus().setFontSizeNum(new_size).run();
|
|
3157
|
+
};
|
|
3158
|
+
const handle_set_link = () => {
|
|
3159
|
+
if (link_url && link_url !== "https://") {
|
|
3160
|
+
editor.chain().focus().setLink({ href: link_url }).run();
|
|
3161
|
+
set_link_url("https://");
|
|
3162
|
+
set_link_popover_open(false);
|
|
3163
|
+
}
|
|
3164
|
+
};
|
|
3165
|
+
const handle_remove_link = () => {
|
|
3166
|
+
editor.chain().focus().unsetLink().run();
|
|
3167
|
+
set_link_popover_open(false);
|
|
3168
|
+
};
|
|
3169
|
+
const handle_text_color_change = (color2) => {
|
|
3170
|
+
set_text_color(color2.hex);
|
|
3171
|
+
editor.chain().focus().setColor(color2.hex).run();
|
|
3172
|
+
};
|
|
3173
|
+
const handle_highlight_color_change = (color2) => {
|
|
3174
|
+
set_highlight_color(color2.hex);
|
|
3175
|
+
editor.chain().focus().setHighlight({ color: color2.hex }).run();
|
|
3176
|
+
};
|
|
3177
|
+
const handle_image_insert = async (e) => {
|
|
3178
|
+
const file = e.target.files?.[0];
|
|
3179
|
+
if (file && file.type.startsWith("image/")) {
|
|
3180
|
+
const data_url = await file_to_data_url(file);
|
|
3181
|
+
editor.chain().focus().setImage({ src: data_url }).run();
|
|
3182
|
+
}
|
|
3183
|
+
if (image_input_ref.current) {
|
|
3184
|
+
image_input_ref.current.value = "";
|
|
3185
|
+
}
|
|
3186
|
+
};
|
|
3187
|
+
const handle_file_attach = async (e) => {
|
|
3188
|
+
const file = e.target.files?.[0];
|
|
3189
|
+
if (file) {
|
|
3190
|
+
const attachment = await file_to_attachment(file);
|
|
3191
|
+
on_attachments_change([...attachments, attachment]);
|
|
3192
|
+
}
|
|
3193
|
+
if (file_input_ref.current) {
|
|
3194
|
+
file_input_ref.current.value = "";
|
|
3195
|
+
}
|
|
3196
|
+
};
|
|
3197
|
+
const handle_table_insert = (rows, cols) => {
|
|
3198
|
+
editor.chain().focus().insertTable({ rows, cols, withHeaderRow: true }).run();
|
|
3199
|
+
set_table_menu_open(false);
|
|
3200
|
+
set_table_rows(3);
|
|
3201
|
+
set_table_cols(3);
|
|
3202
|
+
set_hovered_cell(null);
|
|
3203
|
+
};
|
|
3204
|
+
const handle_add_row_before = () => {
|
|
3205
|
+
editor.chain().focus().addRowBefore().run();
|
|
3206
|
+
};
|
|
3207
|
+
const handle_add_row_after = () => {
|
|
3208
|
+
editor.chain().focus().addRowAfter().run();
|
|
3209
|
+
};
|
|
3210
|
+
const handle_delete_row = () => {
|
|
3211
|
+
editor.chain().focus().deleteRow().run();
|
|
3212
|
+
};
|
|
3213
|
+
const handle_add_col_before = () => {
|
|
3214
|
+
editor.chain().focus().addColumnBefore().run();
|
|
3215
|
+
};
|
|
3216
|
+
const handle_add_col_after = () => {
|
|
3217
|
+
editor.chain().focus().addColumnAfter().run();
|
|
3218
|
+
};
|
|
3219
|
+
const handle_delete_col = () => {
|
|
3220
|
+
editor.chain().focus().deleteColumn().run();
|
|
3221
|
+
};
|
|
3222
|
+
const handle_delete_table = () => {
|
|
3223
|
+
editor.chain().focus().deleteTable().run();
|
|
3224
|
+
};
|
|
3225
|
+
const handle_hr_insert = () => {
|
|
3226
|
+
editor.chain().focus().setHorizontalRule().run();
|
|
3227
|
+
};
|
|
3228
|
+
const handle_variable_insert = (variable_name) => {
|
|
3229
|
+
editor.chain().focus().insertVariable(variable_name).run();
|
|
3230
|
+
set_variables_menu_open(false);
|
|
3231
|
+
};
|
|
3232
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { delayDuration: 300, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3233
|
+
"div",
|
|
3234
|
+
{
|
|
3235
|
+
className: cn(
|
|
3236
|
+
"cls_rte_toolbar",
|
|
3237
|
+
"flex flex-wrap items-center gap-0.5",
|
|
3238
|
+
"p-1.5 rounded-t-md",
|
|
3239
|
+
"bg-muted border-b border-border",
|
|
3240
|
+
disabled && "opacity-50 pointer-events-none"
|
|
3241
|
+
),
|
|
3242
|
+
children: [
|
|
3243
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3244
|
+
ToolbarButton,
|
|
3245
|
+
{
|
|
3246
|
+
onClick: () => editor.chain().focus().undo().run(),
|
|
3247
|
+
disabled: !editor.can().undo(),
|
|
3248
|
+
tooltip: "Undo",
|
|
3249
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuUndo2, { className: "h-4 w-4" })
|
|
3250
|
+
}
|
|
3251
|
+
),
|
|
3252
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3253
|
+
ToolbarButton,
|
|
3254
|
+
{
|
|
3255
|
+
onClick: () => editor.chain().focus().redo().run(),
|
|
3256
|
+
disabled: !editor.can().redo(),
|
|
3257
|
+
tooltip: "Redo",
|
|
3258
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuRedo2, { className: "h-4 w-4" })
|
|
3259
|
+
}
|
|
3260
|
+
),
|
|
3261
|
+
/* @__PURE__ */ jsxRuntime.jsx(ToolbarSeparator, {}),
|
|
3262
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Select, { value: get_current_block_type(), onValueChange: handle_block_type_change, children: [
|
|
3263
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 w-[130px] text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, {}) }),
|
|
3264
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: BLOCK_TYPES.map((type) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: type.value, className: "text-xs", children: type.label }, type.value)) })
|
|
3265
|
+
] }),
|
|
3266
|
+
/* @__PURE__ */ jsxRuntime.jsx(ToolbarSeparator, {}),
|
|
3267
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Select, { value: get_current_font_family(), onValueChange: handle_font_family_change, children: [
|
|
3268
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 w-[120px] text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, {}) }),
|
|
3269
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: FONT_FAMILIES.map((font) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3270
|
+
SelectItem,
|
|
3271
|
+
{
|
|
3272
|
+
value: font.value,
|
|
3273
|
+
className: "text-xs",
|
|
3274
|
+
style: { fontFamily: font.value },
|
|
3275
|
+
children: font.label
|
|
3276
|
+
},
|
|
3277
|
+
font.value
|
|
3278
|
+
)) })
|
|
3279
|
+
] }),
|
|
3280
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center", children: [
|
|
3281
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3282
|
+
ToolbarButton,
|
|
3283
|
+
{
|
|
3284
|
+
onClick: () => handle_font_size_change(-2),
|
|
3285
|
+
tooltip: "Decrease font size",
|
|
3286
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuMinus, { className: "h-3 w-3" })
|
|
3287
|
+
}
|
|
3288
|
+
),
|
|
3289
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-8 text-center text-xs tabular-nums", children: get_current_font_size() }),
|
|
3290
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3291
|
+
ToolbarButton,
|
|
3292
|
+
{
|
|
3293
|
+
onClick: () => handle_font_size_change(FONT_SIZE_CONFIG.step),
|
|
3294
|
+
tooltip: "Increase font size",
|
|
3295
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuPlus, { className: "h-3 w-3" })
|
|
3296
|
+
}
|
|
3297
|
+
)
|
|
3298
|
+
] }),
|
|
3299
|
+
/* @__PURE__ */ jsxRuntime.jsx(ToolbarSeparator, {}),
|
|
3300
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3301
|
+
ToolbarButton,
|
|
3302
|
+
{
|
|
3303
|
+
onClick: () => editor.chain().focus().toggleBold().run(),
|
|
3304
|
+
is_active: editor.isActive("bold"),
|
|
3305
|
+
tooltip: "Bold",
|
|
3306
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuBold, { className: "h-4 w-4" })
|
|
3307
|
+
}
|
|
3308
|
+
),
|
|
3309
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3310
|
+
ToolbarButton,
|
|
3311
|
+
{
|
|
3312
|
+
onClick: () => editor.chain().focus().toggleItalic().run(),
|
|
3313
|
+
is_active: editor.isActive("italic"),
|
|
3314
|
+
tooltip: "Italic",
|
|
3315
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuItalic, { className: "h-4 w-4" })
|
|
3316
|
+
}
|
|
3317
|
+
),
|
|
3318
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3319
|
+
ToolbarButton,
|
|
3320
|
+
{
|
|
3321
|
+
onClick: () => editor.chain().focus().toggleUnderline().run(),
|
|
3322
|
+
is_active: editor.isActive("underline"),
|
|
3323
|
+
tooltip: "Underline",
|
|
3324
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuUnderline, { className: "h-4 w-4" })
|
|
3325
|
+
}
|
|
3326
|
+
),
|
|
3327
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3328
|
+
ToolbarButton,
|
|
3329
|
+
{
|
|
3330
|
+
onClick: () => editor.chain().focus().toggleStrike().run(),
|
|
3331
|
+
is_active: editor.isActive("strike"),
|
|
3332
|
+
tooltip: "Strikethrough",
|
|
3333
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuStrikethrough, { className: "h-4 w-4" })
|
|
3334
|
+
}
|
|
3335
|
+
),
|
|
3336
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3337
|
+
ToolbarButton,
|
|
3338
|
+
{
|
|
3339
|
+
onClick: () => editor.chain().focus().toggleSubscript().run(),
|
|
3340
|
+
is_active: editor.isActive("subscript"),
|
|
3341
|
+
tooltip: "Subscript",
|
|
3342
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuSubscript, { className: "h-4 w-4" })
|
|
3343
|
+
}
|
|
3344
|
+
),
|
|
3345
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3346
|
+
ToolbarButton,
|
|
3347
|
+
{
|
|
3348
|
+
onClick: () => editor.chain().focus().toggleSuperscript().run(),
|
|
3349
|
+
is_active: editor.isActive("superscript"),
|
|
3350
|
+
tooltip: "Superscript",
|
|
3351
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuSuperscript, { className: "h-4 w-4" })
|
|
3352
|
+
}
|
|
3353
|
+
),
|
|
3354
|
+
/* @__PURE__ */ jsxRuntime.jsx(ToolbarSeparator, {}),
|
|
3355
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Popover, { open: link_popover_open, onOpenChange: set_link_popover_open, children: [
|
|
3356
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ToolbarButton, { is_active: editor.isActive("link"), tooltip: "Link", children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuLink, { className: "h-4 w-4" }) }) }),
|
|
3357
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-80 p-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
3358
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3359
|
+
Input,
|
|
3360
|
+
{
|
|
3361
|
+
value: link_url,
|
|
3362
|
+
onChange: (e) => set_link_url(e.target.value),
|
|
3363
|
+
placeholder: "https://example.com",
|
|
3364
|
+
className: "h-8 text-sm"
|
|
3365
|
+
}
|
|
3366
|
+
),
|
|
3367
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", children: [
|
|
3368
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Button, { size: "sm", onClick: handle_set_link, className: "flex-1", children: [
|
|
3369
|
+
editor.isActive("link") ? "Update" : "Add",
|
|
3370
|
+
" Link"
|
|
3371
|
+
] }),
|
|
3372
|
+
editor.isActive("link") && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3373
|
+
Button,
|
|
3374
|
+
{
|
|
3375
|
+
size: "sm",
|
|
3376
|
+
variant: "destructive",
|
|
3377
|
+
onClick: handle_remove_link,
|
|
3378
|
+
children: "Remove"
|
|
3379
|
+
}
|
|
3380
|
+
)
|
|
3381
|
+
] })
|
|
3382
|
+
] }) })
|
|
3383
|
+
] }),
|
|
3384
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3385
|
+
ToolbarButton,
|
|
3386
|
+
{
|
|
3387
|
+
onClick: () => editor.chain().focus().unsetAllMarks().clearNodes().run(),
|
|
3388
|
+
tooltip: "Clear formatting",
|
|
3389
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuRemoveFormatting, { className: "h-4 w-4" })
|
|
3390
|
+
}
|
|
3391
|
+
),
|
|
3392
|
+
/* @__PURE__ */ jsxRuntime.jsx(ToolbarSeparator, {}),
|
|
3393
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Popover, { open: text_color_open, onOpenChange: set_text_color_open, children: [
|
|
3394
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ToolbarButton, { tooltip: "Text color", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center", children: [
|
|
3395
|
+
/* @__PURE__ */ jsxRuntime.jsx(lu.LuPalette, { className: "h-4 w-4" }),
|
|
3396
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3397
|
+
"div",
|
|
3398
|
+
{
|
|
3399
|
+
className: "h-0.5 w-4 mt-0.5 rounded-full",
|
|
3400
|
+
style: { backgroundColor: text_color }
|
|
3401
|
+
}
|
|
3402
|
+
)
|
|
3403
|
+
] }) }) }),
|
|
3404
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-auto p-0", align: "start", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3405
|
+
esm_default8,
|
|
3406
|
+
{
|
|
3407
|
+
color: text_color,
|
|
3408
|
+
onChange: handle_text_color_change,
|
|
3409
|
+
presetColors: [
|
|
3410
|
+
"#000000",
|
|
3411
|
+
"#434343",
|
|
3412
|
+
"#666666",
|
|
3413
|
+
"#999999",
|
|
3414
|
+
"#cccccc",
|
|
3415
|
+
"#ffffff",
|
|
3416
|
+
"#ff0000",
|
|
3417
|
+
"#ff9900",
|
|
3418
|
+
"#ffff00",
|
|
3419
|
+
"#00ff00",
|
|
3420
|
+
"#00ffff",
|
|
3421
|
+
"#0000ff",
|
|
3422
|
+
"#9900ff",
|
|
3423
|
+
"#ff00ff",
|
|
3424
|
+
"#f4cccc",
|
|
3425
|
+
"#fce5cd",
|
|
3426
|
+
"#fff2cc",
|
|
3427
|
+
"#d9ead3"
|
|
3428
|
+
]
|
|
3429
|
+
}
|
|
3430
|
+
) })
|
|
3431
|
+
] }),
|
|
3432
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Popover, { open: highlight_color_open, onOpenChange: set_highlight_color_open, children: [
|
|
3433
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ToolbarButton, { tooltip: "Highlight color", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center", children: [
|
|
3434
|
+
/* @__PURE__ */ jsxRuntime.jsx(lu.LuHighlighter, { className: "h-4 w-4" }),
|
|
3435
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3436
|
+
"div",
|
|
3437
|
+
{
|
|
3438
|
+
className: "h-0.5 w-4 mt-0.5 rounded-full",
|
|
3439
|
+
style: { backgroundColor: highlight_color }
|
|
3440
|
+
}
|
|
3441
|
+
)
|
|
3442
|
+
] }) }) }),
|
|
3443
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-auto p-0", align: "start", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3444
|
+
esm_default8,
|
|
3445
|
+
{
|
|
3446
|
+
color: highlight_color,
|
|
3447
|
+
onChange: handle_highlight_color_change,
|
|
3448
|
+
presetColors: [
|
|
3449
|
+
"#ffff00",
|
|
3450
|
+
"#00ff00",
|
|
3451
|
+
"#00ffff",
|
|
3452
|
+
"#ff00ff",
|
|
3453
|
+
"#ff0000",
|
|
3454
|
+
"#0000ff",
|
|
3455
|
+
"#fff2cc",
|
|
3456
|
+
"#d9ead3",
|
|
3457
|
+
"#cfe2f3",
|
|
3458
|
+
"#ead1dc",
|
|
3459
|
+
"#fce5cd",
|
|
3460
|
+
"#d0e0e3"
|
|
3461
|
+
]
|
|
3462
|
+
}
|
|
3463
|
+
) })
|
|
3464
|
+
] }),
|
|
3465
|
+
/* @__PURE__ */ jsxRuntime.jsx(ToolbarSeparator, {}),
|
|
3466
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3467
|
+
ToolbarButton,
|
|
3468
|
+
{
|
|
3469
|
+
onClick: () => editor.chain().focus().setTextAlign("left").run(),
|
|
3470
|
+
is_active: editor.isActive({ textAlign: "left" }),
|
|
3471
|
+
tooltip: "Align left",
|
|
3472
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuAlignLeft, { className: "h-4 w-4" })
|
|
3473
|
+
}
|
|
3474
|
+
),
|
|
3475
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3476
|
+
ToolbarButton,
|
|
3477
|
+
{
|
|
3478
|
+
onClick: () => editor.chain().focus().setTextAlign("center").run(),
|
|
3479
|
+
is_active: editor.isActive({ textAlign: "center" }),
|
|
3480
|
+
tooltip: "Align center",
|
|
3481
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuAlignCenter, { className: "h-4 w-4" })
|
|
3482
|
+
}
|
|
3483
|
+
),
|
|
3484
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3485
|
+
ToolbarButton,
|
|
3486
|
+
{
|
|
3487
|
+
onClick: () => editor.chain().focus().setTextAlign("right").run(),
|
|
3488
|
+
is_active: editor.isActive({ textAlign: "right" }),
|
|
3489
|
+
tooltip: "Align right",
|
|
3490
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuAlignRight, { className: "h-4 w-4" })
|
|
3491
|
+
}
|
|
3492
|
+
),
|
|
3493
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3494
|
+
ToolbarButton,
|
|
3495
|
+
{
|
|
3496
|
+
onClick: () => editor.chain().focus().setTextAlign("justify").run(),
|
|
3497
|
+
is_active: editor.isActive({ textAlign: "justify" }),
|
|
3498
|
+
tooltip: "Justify",
|
|
3499
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuAlignJustify, { className: "h-4 w-4" })
|
|
3500
|
+
}
|
|
3501
|
+
),
|
|
3502
|
+
/* @__PURE__ */ jsxRuntime.jsx(ToolbarSeparator, {}),
|
|
3503
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3504
|
+
ToolbarButton,
|
|
3505
|
+
{
|
|
3506
|
+
onClick: () => editor.chain().focus().toggleBulletList().run(),
|
|
3507
|
+
is_active: editor.isActive("bulletList"),
|
|
3508
|
+
tooltip: "Bullet list",
|
|
3509
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuList, { className: "h-4 w-4" })
|
|
3510
|
+
}
|
|
3511
|
+
),
|
|
3512
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3513
|
+
ToolbarButton,
|
|
3514
|
+
{
|
|
3515
|
+
onClick: () => editor.chain().focus().toggleOrderedList().run(),
|
|
3516
|
+
is_active: editor.isActive("orderedList"),
|
|
3517
|
+
tooltip: "Numbered list",
|
|
3518
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuListOrdered, { className: "h-4 w-4" })
|
|
3519
|
+
}
|
|
3520
|
+
),
|
|
3521
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3522
|
+
ToolbarButton,
|
|
3523
|
+
{
|
|
3524
|
+
onClick: () => editor.chain().focus().toggleTaskList().run(),
|
|
3525
|
+
is_active: editor.isActive("taskList"),
|
|
3526
|
+
tooltip: "Checklist",
|
|
3527
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuListChecks, { className: "h-4 w-4" })
|
|
3528
|
+
}
|
|
3529
|
+
),
|
|
3530
|
+
/* @__PURE__ */ jsxRuntime.jsx(ToolbarSeparator, {}),
|
|
3531
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3532
|
+
ToolbarButton,
|
|
3533
|
+
{
|
|
3534
|
+
onClick: () => {
|
|
3535
|
+
if (editor.isActive("listItem")) {
|
|
3536
|
+
editor.chain().focus().liftListItem("listItem").run();
|
|
3537
|
+
} else if (editor.isActive("taskItem")) {
|
|
3538
|
+
editor.chain().focus().liftListItem("taskItem").run();
|
|
3539
|
+
}
|
|
3540
|
+
},
|
|
3541
|
+
disabled: !editor.can().liftListItem("listItem") && !editor.can().liftListItem("taskItem"),
|
|
3542
|
+
tooltip: "Decrease indent",
|
|
3543
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuIndentDecrease, { className: "h-4 w-4" })
|
|
3544
|
+
}
|
|
3545
|
+
),
|
|
3546
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3547
|
+
ToolbarButton,
|
|
3548
|
+
{
|
|
3549
|
+
onClick: () => {
|
|
3550
|
+
if (editor.isActive("listItem")) {
|
|
3551
|
+
editor.chain().focus().sinkListItem("listItem").run();
|
|
3552
|
+
} else if (editor.isActive("taskItem")) {
|
|
3553
|
+
editor.chain().focus().sinkListItem("taskItem").run();
|
|
3554
|
+
}
|
|
3555
|
+
},
|
|
3556
|
+
disabled: !editor.can().sinkListItem("listItem") && !editor.can().sinkListItem("taskItem"),
|
|
3557
|
+
tooltip: "Increase indent",
|
|
3558
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuIndentIncrease, { className: "h-4 w-4" })
|
|
3559
|
+
}
|
|
3560
|
+
),
|
|
3561
|
+
/* @__PURE__ */ jsxRuntime.jsx(ToolbarSeparator, {}),
|
|
3562
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3563
|
+
ToolbarButton,
|
|
3564
|
+
{
|
|
3565
|
+
onClick: handle_hr_insert,
|
|
3566
|
+
tooltip: "Horizontal rule",
|
|
3567
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(rx.RxDividerHorizontal, { className: "h-4 w-4" })
|
|
3568
|
+
}
|
|
3569
|
+
),
|
|
3570
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3571
|
+
ToolbarButton,
|
|
3572
|
+
{
|
|
3573
|
+
onClick: () => image_input_ref.current?.click(),
|
|
3574
|
+
tooltip: "Insert image",
|
|
3575
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuImage, { className: "h-4 w-4" })
|
|
3576
|
+
}
|
|
3577
|
+
),
|
|
3578
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Popover, { open: table_menu_open, onOpenChange: set_table_menu_open, children: [
|
|
3579
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3580
|
+
ToolbarButton,
|
|
3581
|
+
{
|
|
3582
|
+
is_active: editor.isActive("table"),
|
|
3583
|
+
tooltip: "Table",
|
|
3584
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuTable, { className: "h-4 w-4" })
|
|
3585
|
+
}
|
|
3586
|
+
) }),
|
|
3587
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-auto p-3", align: "start", children: editor.isActive("table") ? (
|
|
3588
|
+
// Table editing controls when inside a table
|
|
3589
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
3590
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs font-medium mb-1", children: "Table Operations" }),
|
|
3591
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-1", children: [
|
|
3592
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3593
|
+
Button,
|
|
3594
|
+
{
|
|
3595
|
+
variant: "ghost",
|
|
3596
|
+
size: "sm",
|
|
3597
|
+
className: "justify-start text-xs h-7",
|
|
3598
|
+
onClick: handle_add_row_before,
|
|
3599
|
+
children: [
|
|
3600
|
+
/* @__PURE__ */ jsxRuntime.jsx(lu.LuTableRowsSplit, { className: "h-3 w-3 mr-1" }),
|
|
3601
|
+
"Add row above"
|
|
3602
|
+
]
|
|
3603
|
+
}
|
|
3604
|
+
),
|
|
3605
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3606
|
+
Button,
|
|
3607
|
+
{
|
|
3608
|
+
variant: "ghost",
|
|
3609
|
+
size: "sm",
|
|
3610
|
+
className: "justify-start text-xs h-7",
|
|
3611
|
+
onClick: handle_add_row_after,
|
|
3612
|
+
children: [
|
|
3613
|
+
/* @__PURE__ */ jsxRuntime.jsx(lu.LuTableRowsSplit, { className: "h-3 w-3 mr-1" }),
|
|
3614
|
+
"Add row below"
|
|
3615
|
+
]
|
|
3616
|
+
}
|
|
3617
|
+
),
|
|
3618
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3619
|
+
Button,
|
|
3620
|
+
{
|
|
3621
|
+
variant: "ghost",
|
|
3622
|
+
size: "sm",
|
|
3623
|
+
className: "justify-start text-xs h-7",
|
|
3624
|
+
onClick: handle_add_col_before,
|
|
3625
|
+
children: [
|
|
3626
|
+
/* @__PURE__ */ jsxRuntime.jsx(lu.LuTableColumnsSplit, { className: "h-3 w-3 mr-1" }),
|
|
3627
|
+
"Add col left"
|
|
3628
|
+
]
|
|
3629
|
+
}
|
|
3630
|
+
),
|
|
3631
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3632
|
+
Button,
|
|
3633
|
+
{
|
|
3634
|
+
variant: "ghost",
|
|
3635
|
+
size: "sm",
|
|
3636
|
+
className: "justify-start text-xs h-7",
|
|
3637
|
+
onClick: handle_add_col_after,
|
|
3638
|
+
children: [
|
|
3639
|
+
/* @__PURE__ */ jsxRuntime.jsx(lu.LuTableColumnsSplit, { className: "h-3 w-3 mr-1" }),
|
|
3640
|
+
"Add col right"
|
|
3641
|
+
]
|
|
3642
|
+
}
|
|
3643
|
+
),
|
|
3644
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3645
|
+
Button,
|
|
3646
|
+
{
|
|
3647
|
+
variant: "ghost",
|
|
3648
|
+
size: "sm",
|
|
3649
|
+
className: "justify-start text-xs h-7 text-destructive hover:text-destructive",
|
|
3650
|
+
onClick: handle_delete_row,
|
|
3651
|
+
children: [
|
|
3652
|
+
/* @__PURE__ */ jsxRuntime.jsx(lu.LuTrash2, { className: "h-3 w-3 mr-1" }),
|
|
3653
|
+
"Delete row"
|
|
3654
|
+
]
|
|
3655
|
+
}
|
|
3656
|
+
),
|
|
3657
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3658
|
+
Button,
|
|
3659
|
+
{
|
|
3660
|
+
variant: "ghost",
|
|
3661
|
+
size: "sm",
|
|
3662
|
+
className: "justify-start text-xs h-7 text-destructive hover:text-destructive",
|
|
3663
|
+
onClick: handle_delete_col,
|
|
3664
|
+
children: [
|
|
3665
|
+
/* @__PURE__ */ jsxRuntime.jsx(lu.LuTrash2, { className: "h-3 w-3 mr-1" }),
|
|
3666
|
+
"Delete col"
|
|
3667
|
+
]
|
|
3668
|
+
}
|
|
3669
|
+
)
|
|
3670
|
+
] }),
|
|
3671
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3672
|
+
Button,
|
|
3673
|
+
{
|
|
3674
|
+
variant: "destructive",
|
|
3675
|
+
size: "sm",
|
|
3676
|
+
className: "justify-center text-xs h-7 mt-1",
|
|
3677
|
+
onClick: handle_delete_table,
|
|
3678
|
+
children: [
|
|
3679
|
+
/* @__PURE__ */ jsxRuntime.jsx(lu.LuTrash2, { className: "h-3 w-3 mr-1" }),
|
|
3680
|
+
"Delete table"
|
|
3681
|
+
]
|
|
3682
|
+
}
|
|
3683
|
+
)
|
|
3684
|
+
] })
|
|
3685
|
+
) : (
|
|
3686
|
+
// Table size picker when not in a table
|
|
3687
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
3688
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs font-medium mb-1", children: "Insert Table" }),
|
|
3689
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid gap-0.5", children: Array.from({ length: 6 }).map((_, row_idx) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-0.5", children: Array.from({ length: 6 }).map((_2, col_idx) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3690
|
+
"div",
|
|
3691
|
+
{
|
|
3692
|
+
className: cn(
|
|
3693
|
+
"w-5 h-5 border rounded-sm cursor-pointer transition-colors",
|
|
3694
|
+
hovered_cell && row_idx < hovered_cell.row && col_idx < hovered_cell.col ? "bg-primary border-primary" : "border-border hover:border-primary/50"
|
|
3695
|
+
),
|
|
3696
|
+
onMouseEnter: () => set_hovered_cell({ row: row_idx + 1, col: col_idx + 1 }),
|
|
3697
|
+
onMouseLeave: () => set_hovered_cell(null),
|
|
3698
|
+
onClick: () => handle_table_insert(row_idx + 1, col_idx + 1)
|
|
3699
|
+
},
|
|
3700
|
+
col_idx
|
|
3701
|
+
)) }, row_idx)) }),
|
|
3702
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-center text-muted-foreground", children: hovered_cell ? `${hovered_cell.col} x ${hovered_cell.row}` : "Select size" }),
|
|
3703
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-t pt-2 mt-1", children: [
|
|
3704
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-muted-foreground mb-2", children: "Custom size" }),
|
|
3705
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
3706
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3707
|
+
Input,
|
|
3708
|
+
{
|
|
3709
|
+
type: "number",
|
|
3710
|
+
min: 1,
|
|
3711
|
+
max: 20,
|
|
3712
|
+
value: table_cols,
|
|
3713
|
+
onChange: (e) => set_table_cols(Math.max(1, Math.min(20, parseInt(e.target.value) || 1))),
|
|
3714
|
+
className: "h-7 w-14 text-xs"
|
|
3715
|
+
}
|
|
3716
|
+
),
|
|
3717
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs", children: "x" }),
|
|
3718
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3719
|
+
Input,
|
|
3720
|
+
{
|
|
3721
|
+
type: "number",
|
|
3722
|
+
min: 1,
|
|
3723
|
+
max: 20,
|
|
3724
|
+
value: table_rows,
|
|
3725
|
+
onChange: (e) => set_table_rows(Math.max(1, Math.min(20, parseInt(e.target.value) || 1))),
|
|
3726
|
+
className: "h-7 w-14 text-xs"
|
|
3727
|
+
}
|
|
3728
|
+
),
|
|
3729
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3730
|
+
Button,
|
|
3731
|
+
{
|
|
3732
|
+
size: "sm",
|
|
3733
|
+
className: "h-7 text-xs",
|
|
3734
|
+
onClick: () => handle_table_insert(table_rows, table_cols),
|
|
3735
|
+
children: [
|
|
3736
|
+
/* @__PURE__ */ jsxRuntime.jsx(lu.LuGrid3X3, { className: "h-3 w-3 mr-1" }),
|
|
3737
|
+
"Insert"
|
|
3738
|
+
]
|
|
3739
|
+
}
|
|
3740
|
+
)
|
|
3741
|
+
] })
|
|
3742
|
+
] })
|
|
3743
|
+
] })
|
|
3744
|
+
) })
|
|
3745
|
+
] }),
|
|
3746
|
+
/* @__PURE__ */ jsxRuntime.jsx(ToolbarSeparator, {}),
|
|
3747
|
+
variables.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open: variables_menu_open, onOpenChange: set_variables_menu_open, children: [
|
|
3748
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ToolbarButton, { tooltip: "Insert variable", children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuVariable, { className: "h-4 w-4" }) }) }),
|
|
3749
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-64 p-0", align: "start", children: /* @__PURE__ */ jsxRuntime.jsxs(Command, { children: [
|
|
3750
|
+
/* @__PURE__ */ jsxRuntime.jsx(CommandInput, { placeholder: "Search variables...", className: "h-8 text-xs" }),
|
|
3751
|
+
/* @__PURE__ */ jsxRuntime.jsxs(CommandList, { children: [
|
|
3752
|
+
/* @__PURE__ */ jsxRuntime.jsx(CommandEmpty, { children: "No variables found." }),
|
|
3753
|
+
/* @__PURE__ */ jsxRuntime.jsx(CommandGroup, { children: variables.map((variable) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3754
|
+
CommandItem,
|
|
3755
|
+
{
|
|
3756
|
+
value: variable.name,
|
|
3757
|
+
onSelect: () => handle_variable_insert(variable.name),
|
|
3758
|
+
className: "text-xs",
|
|
3759
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
3760
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: `{{${variable.name}}}` }),
|
|
3761
|
+
variable.description && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-[10px]", children: variable.description })
|
|
3762
|
+
] })
|
|
3763
|
+
},
|
|
3764
|
+
variable.name
|
|
3765
|
+
)) })
|
|
3766
|
+
] })
|
|
3767
|
+
] }) })
|
|
3768
|
+
] }),
|
|
3769
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3770
|
+
ToolbarButton,
|
|
3771
|
+
{
|
|
3772
|
+
onClick: () => file_input_ref.current?.click(),
|
|
3773
|
+
tooltip: "Attach file",
|
|
3774
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuPaperclip, { className: "h-4 w-4" })
|
|
3775
|
+
}
|
|
3776
|
+
),
|
|
3777
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3778
|
+
"input",
|
|
3779
|
+
{
|
|
3780
|
+
ref: file_input_ref,
|
|
3781
|
+
type: "file",
|
|
3782
|
+
className: "hidden",
|
|
3783
|
+
onChange: handle_file_attach
|
|
3784
|
+
}
|
|
3785
|
+
),
|
|
3786
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3787
|
+
"input",
|
|
3788
|
+
{
|
|
3789
|
+
ref: image_input_ref,
|
|
3790
|
+
type: "file",
|
|
3791
|
+
accept: "image/*",
|
|
3792
|
+
className: "hidden",
|
|
3793
|
+
onChange: handle_image_insert
|
|
3794
|
+
}
|
|
3795
|
+
)
|
|
3796
|
+
]
|
|
3797
|
+
}
|
|
3798
|
+
) });
|
|
3799
|
+
};
|
|
3800
|
+
var get_file_icon = (mime_type, filename) => {
|
|
3801
|
+
if (is_image_file(mime_type)) {
|
|
3802
|
+
return /* @__PURE__ */ jsxRuntime.jsx(lu.LuImage, { className: "h-4 w-4" });
|
|
3803
|
+
}
|
|
3804
|
+
const ext = get_file_extension(filename);
|
|
3805
|
+
if (["txt", "md", "doc", "docx", "pdf"].includes(ext)) {
|
|
3806
|
+
return /* @__PURE__ */ jsxRuntime.jsx(lu.LuFileText, { className: "h-4 w-4" });
|
|
3807
|
+
}
|
|
3808
|
+
if (["js", "ts", "jsx", "tsx", "json", "html", "css"].includes(ext)) {
|
|
3809
|
+
return /* @__PURE__ */ jsxRuntime.jsx(lu.LuFileCode, { className: "h-4 w-4" });
|
|
3810
|
+
}
|
|
3811
|
+
return /* @__PURE__ */ jsxRuntime.jsx(lu.LuFile, { className: "h-4 w-4" });
|
|
3812
|
+
};
|
|
3813
|
+
var get_base64_size = (base64) => {
|
|
3814
|
+
const padding = (base64.match(/=+$/) || [""])[0].length;
|
|
3815
|
+
return Math.floor(base64.length * 3 / 4) - padding;
|
|
3816
|
+
};
|
|
3817
|
+
var AttachmentsList = ({
|
|
3818
|
+
attachments,
|
|
3819
|
+
on_remove,
|
|
3820
|
+
disabled = false
|
|
3821
|
+
}) => {
|
|
3822
|
+
if (attachments.length === 0) {
|
|
3823
|
+
return null;
|
|
3824
|
+
}
|
|
3825
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3826
|
+
"div",
|
|
3827
|
+
{
|
|
3828
|
+
className: cn(
|
|
3829
|
+
"cls_rte_attachments",
|
|
3830
|
+
"flex flex-wrap gap-2 p-2",
|
|
3831
|
+
"border-t border-border bg-muted/50 rounded-b-md"
|
|
3832
|
+
),
|
|
3833
|
+
children: attachments.map((attachment, index) => {
|
|
3834
|
+
const size = get_base64_size(attachment.data);
|
|
3835
|
+
const is_image = is_image_file(attachment.mime_type);
|
|
3836
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3837
|
+
"div",
|
|
3838
|
+
{
|
|
3839
|
+
className: cn(
|
|
3840
|
+
"cls_rte_attachment_item",
|
|
3841
|
+
"flex items-center gap-2",
|
|
3842
|
+
"px-2 py-1.5 rounded-md",
|
|
3843
|
+
"bg-background border border-border",
|
|
3844
|
+
"text-xs"
|
|
3845
|
+
),
|
|
3846
|
+
children: [
|
|
3847
|
+
is_image ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3848
|
+
"img",
|
|
3849
|
+
{
|
|
3850
|
+
src: `data:${attachment.mime_type};base64,${attachment.data}`,
|
|
3851
|
+
alt: attachment.filename,
|
|
3852
|
+
className: "h-8 w-8 rounded object-cover"
|
|
3853
|
+
}
|
|
3854
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-8 w-8 items-center justify-center rounded bg-muted", children: get_file_icon(attachment.mime_type, attachment.filename) }),
|
|
3855
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col min-w-0", children: [
|
|
3856
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate max-w-[120px] font-medium", children: attachment.filename }),
|
|
3857
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-[10px]", children: format_file_size(size) })
|
|
3858
|
+
] }),
|
|
3859
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3860
|
+
Button,
|
|
3861
|
+
{
|
|
3862
|
+
variant: "ghost",
|
|
3863
|
+
size: "icon",
|
|
3864
|
+
className: "h-5 w-5 ml-1",
|
|
3865
|
+
onClick: () => on_remove(index),
|
|
3866
|
+
disabled,
|
|
3867
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuX, { className: "h-3 w-3" })
|
|
3868
|
+
}
|
|
3869
|
+
)
|
|
3870
|
+
]
|
|
3871
|
+
},
|
|
3872
|
+
`${attachment.filename}-${index}`
|
|
3873
|
+
);
|
|
3874
|
+
})
|
|
3875
|
+
}
|
|
3876
|
+
);
|
|
3877
|
+
};
|
|
3878
|
+
var FontSizeExtension = core.Extension.create({
|
|
3879
|
+
name: "fontSizeCustom",
|
|
3880
|
+
addOptions() {
|
|
3881
|
+
return {
|
|
3882
|
+
types: ["textStyle"],
|
|
3883
|
+
default_size: 16,
|
|
3884
|
+
min_size: 8,
|
|
3885
|
+
max_size: 72,
|
|
3886
|
+
step: 2
|
|
3887
|
+
};
|
|
3888
|
+
},
|
|
3889
|
+
addGlobalAttributes() {
|
|
3890
|
+
return [
|
|
3891
|
+
{
|
|
3892
|
+
types: this.options.types,
|
|
3893
|
+
attributes: {
|
|
3894
|
+
fontSize: {
|
|
3895
|
+
default: null,
|
|
3896
|
+
parseHTML: (element) => {
|
|
3897
|
+
const size = element.style.fontSize?.replace(/['"px]/g, "");
|
|
3898
|
+
return size ? parseInt(size, 10) : null;
|
|
3899
|
+
},
|
|
3900
|
+
renderHTML: (attributes) => {
|
|
3901
|
+
if (!attributes.fontSize) {
|
|
3902
|
+
return {};
|
|
3903
|
+
}
|
|
3904
|
+
return {
|
|
3905
|
+
style: `font-size: ${attributes.fontSize}px`
|
|
3906
|
+
};
|
|
3907
|
+
}
|
|
3908
|
+
}
|
|
3909
|
+
}
|
|
3910
|
+
}
|
|
3911
|
+
];
|
|
3912
|
+
},
|
|
3913
|
+
addCommands() {
|
|
3914
|
+
return {
|
|
3915
|
+
setFontSizeNum: (size) => ({ chain }) => {
|
|
3916
|
+
const clampedSize = Math.min(
|
|
3917
|
+
this.options.max_size,
|
|
3918
|
+
Math.max(this.options.min_size, size)
|
|
3919
|
+
);
|
|
3920
|
+
return chain().setMark("textStyle", { fontSize: clampedSize }).run();
|
|
3921
|
+
},
|
|
3922
|
+
unsetFontSizeNum: () => ({ chain }) => {
|
|
3923
|
+
return chain().setMark("textStyle", { fontSize: null }).removeEmptyTextStyle().run();
|
|
3924
|
+
}
|
|
3925
|
+
};
|
|
3926
|
+
}
|
|
3927
|
+
});
|
|
3928
|
+
var VariablePill = ({ node, selected }) => {
|
|
3929
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.NodeViewWrapper, { as: "span", className: "inline", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3930
|
+
"span",
|
|
3931
|
+
{
|
|
3932
|
+
className: cn(
|
|
3933
|
+
"cls_rte_variable_pill",
|
|
3934
|
+
"inline-flex items-center",
|
|
3935
|
+
"px-2 py-0.5 mx-0.5",
|
|
3936
|
+
"rounded-full",
|
|
3937
|
+
"text-sm font-medium",
|
|
3938
|
+
"bg-primary/10 text-primary",
|
|
3939
|
+
"border border-primary/20",
|
|
3940
|
+
"cursor-default select-none",
|
|
3941
|
+
selected && "ring-2 ring-primary ring-offset-1"
|
|
3942
|
+
),
|
|
3943
|
+
contentEditable: false,
|
|
3944
|
+
"data-variable": node.attrs.name,
|
|
3945
|
+
children: `{{${node.attrs.name}}}`
|
|
3946
|
+
}
|
|
3947
|
+
) });
|
|
3948
|
+
};
|
|
3949
|
+
var VariableExtension = core.Node.create({
|
|
3950
|
+
name: "variable",
|
|
3951
|
+
group: "inline",
|
|
3952
|
+
inline: true,
|
|
3953
|
+
// Atomic means the node cannot be split or merged
|
|
3954
|
+
atom: true,
|
|
3955
|
+
// Draggable in the editor
|
|
3956
|
+
draggable: true,
|
|
3957
|
+
// Selectable as a whole unit
|
|
3958
|
+
selectable: true,
|
|
3959
|
+
addAttributes() {
|
|
3960
|
+
return {
|
|
3961
|
+
name: {
|
|
3962
|
+
default: null,
|
|
3963
|
+
parseHTML: (element) => element.getAttribute("data-variable"),
|
|
3964
|
+
renderHTML: (attributes) => ({
|
|
3965
|
+
"data-variable": attributes.name
|
|
3966
|
+
})
|
|
3967
|
+
}
|
|
3968
|
+
};
|
|
3969
|
+
},
|
|
3970
|
+
parseHTML() {
|
|
3971
|
+
return [
|
|
3972
|
+
{
|
|
3973
|
+
tag: "span[data-variable]"
|
|
3974
|
+
}
|
|
3975
|
+
];
|
|
3976
|
+
},
|
|
3977
|
+
renderHTML({ HTMLAttributes }) {
|
|
3978
|
+
return [
|
|
3979
|
+
"span",
|
|
3980
|
+
core.mergeAttributes(HTMLAttributes, {
|
|
3981
|
+
class: "cls_rte_variable_pill",
|
|
3982
|
+
contenteditable: "false"
|
|
3983
|
+
}),
|
|
3984
|
+
`{{${HTMLAttributes["data-variable"]}}}`
|
|
3985
|
+
];
|
|
3986
|
+
},
|
|
3987
|
+
renderText({ node }) {
|
|
3988
|
+
return `{{${node.attrs.name}}}`;
|
|
3989
|
+
},
|
|
3990
|
+
addNodeView() {
|
|
3991
|
+
return react.ReactNodeViewRenderer(VariablePill);
|
|
3992
|
+
},
|
|
3993
|
+
addCommands() {
|
|
3994
|
+
return {
|
|
3995
|
+
insertVariable: (name) => ({ commands }) => {
|
|
3996
|
+
return commands.insertContent({
|
|
3997
|
+
type: this.name,
|
|
3998
|
+
attrs: { name }
|
|
3999
|
+
});
|
|
4000
|
+
}
|
|
4001
|
+
};
|
|
4002
|
+
},
|
|
4003
|
+
// Keyboard behavior - delete entire node on backspace
|
|
4004
|
+
addKeyboardShortcuts() {
|
|
4005
|
+
return {
|
|
4006
|
+
Backspace: () => this.editor.commands.command(({ tr, state }) => {
|
|
4007
|
+
let is_variable = false;
|
|
4008
|
+
const { selection } = state;
|
|
4009
|
+
const { empty, anchor } = selection;
|
|
4010
|
+
if (!empty) {
|
|
4011
|
+
return false;
|
|
4012
|
+
}
|
|
4013
|
+
state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
|
|
4014
|
+
if (node.type.name === this.name) {
|
|
4015
|
+
is_variable = true;
|
|
4016
|
+
tr.insertText("", pos, pos + node.nodeSize);
|
|
4017
|
+
return false;
|
|
4018
|
+
}
|
|
4019
|
+
});
|
|
4020
|
+
return is_variable;
|
|
4021
|
+
})
|
|
4022
|
+
};
|
|
4023
|
+
}
|
|
4024
|
+
});
|
|
4025
|
+
var Tabs = TabsPrimitive__namespace.Root;
|
|
4026
|
+
var TabsList = React23__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4027
|
+
TabsPrimitive__namespace.List,
|
|
4028
|
+
{
|
|
4029
|
+
ref,
|
|
4030
|
+
className: cn(
|
|
4031
|
+
"inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",
|
|
4032
|
+
className
|
|
4033
|
+
),
|
|
4034
|
+
...props
|
|
4035
|
+
}
|
|
4036
|
+
));
|
|
4037
|
+
TabsList.displayName = TabsPrimitive__namespace.List.displayName;
|
|
4038
|
+
var TabsTrigger = React23__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4039
|
+
TabsPrimitive__namespace.Trigger,
|
|
4040
|
+
{
|
|
4041
|
+
ref,
|
|
4042
|
+
className: cn(
|
|
4043
|
+
"inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",
|
|
4044
|
+
className
|
|
4045
|
+
),
|
|
4046
|
+
...props
|
|
4047
|
+
}
|
|
4048
|
+
));
|
|
4049
|
+
TabsTrigger.displayName = TabsPrimitive__namespace.Trigger.displayName;
|
|
4050
|
+
var TabsContent = React23__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4051
|
+
TabsPrimitive__namespace.Content,
|
|
4052
|
+
{
|
|
4053
|
+
ref,
|
|
4054
|
+
className: cn(
|
|
4055
|
+
"mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
4056
|
+
className
|
|
4057
|
+
),
|
|
4058
|
+
...props
|
|
4059
|
+
}
|
|
4060
|
+
));
|
|
4061
|
+
TabsContent.displayName = TabsPrimitive__namespace.Content.displayName;
|
|
4062
|
+
function debounce_fn(func, wait) {
|
|
4063
|
+
let timeout_id = null;
|
|
4064
|
+
return (output) => {
|
|
4065
|
+
if (timeout_id) {
|
|
4066
|
+
clearTimeout(timeout_id);
|
|
4067
|
+
}
|
|
4068
|
+
timeout_id = setTimeout(() => {
|
|
4069
|
+
func(output);
|
|
4070
|
+
}, wait);
|
|
4071
|
+
};
|
|
4072
|
+
}
|
|
4073
|
+
var HazoUiRte = ({
|
|
4074
|
+
html = "",
|
|
4075
|
+
attachments: initial_attachments = [],
|
|
4076
|
+
variables = [],
|
|
4077
|
+
on_change,
|
|
4078
|
+
placeholder = "Start typing...",
|
|
4079
|
+
min_height = "200px",
|
|
4080
|
+
max_height = "400px",
|
|
4081
|
+
disabled = false,
|
|
4082
|
+
className,
|
|
4083
|
+
show_output_viewer = false
|
|
4084
|
+
}) => {
|
|
4085
|
+
const [attachments, set_attachments] = React23__namespace.useState(
|
|
4086
|
+
initial_attachments
|
|
4087
|
+
);
|
|
4088
|
+
const [active_tab, set_active_tab] = React23__namespace.useState("html");
|
|
4089
|
+
const is_view_only = active_tab !== "html";
|
|
4090
|
+
const attachments_ref = React23__namespace.useRef(attachments);
|
|
4091
|
+
attachments_ref.current = attachments;
|
|
4092
|
+
const debounced_on_change = React23__namespace.useMemo(
|
|
4093
|
+
() => debounce_fn((output) => {
|
|
4094
|
+
if (on_change) {
|
|
4095
|
+
on_change(output);
|
|
4096
|
+
}
|
|
4097
|
+
}, 300),
|
|
4098
|
+
[on_change]
|
|
4099
|
+
);
|
|
4100
|
+
const editor = react.useEditor({
|
|
4101
|
+
extensions: [
|
|
4102
|
+
StarterKit__default.default.configure({
|
|
4103
|
+
heading: {
|
|
4104
|
+
levels: [1, 2, 3]
|
|
4105
|
+
}
|
|
4106
|
+
}),
|
|
4107
|
+
extensionTextStyle.TextStyle,
|
|
4108
|
+
FontFamily__default.default,
|
|
4109
|
+
FontSizeExtension,
|
|
4110
|
+
Underline__default.default,
|
|
4111
|
+
Subscript__default.default,
|
|
4112
|
+
Superscript__default.default,
|
|
4113
|
+
Link__default.default.configure({
|
|
4114
|
+
openOnClick: false,
|
|
4115
|
+
HTMLAttributes: {
|
|
4116
|
+
class: "cls_rte_link text-primary underline cursor-pointer"
|
|
4117
|
+
}
|
|
4118
|
+
}),
|
|
4119
|
+
TextAlign__default.default.configure({
|
|
4120
|
+
types: ["heading", "paragraph"]
|
|
4121
|
+
}),
|
|
4122
|
+
Highlight__default.default.configure({
|
|
4123
|
+
multicolor: true
|
|
4124
|
+
}),
|
|
4125
|
+
Color__default.default,
|
|
4126
|
+
Image__default.default.configure({
|
|
4127
|
+
inline: true,
|
|
4128
|
+
allowBase64: true,
|
|
4129
|
+
HTMLAttributes: {
|
|
4130
|
+
class: "cls_rte_image max-w-full h-auto rounded"
|
|
4131
|
+
}
|
|
4132
|
+
}),
|
|
4133
|
+
Placeholder__default.default.configure({
|
|
4134
|
+
placeholder
|
|
4135
|
+
}),
|
|
4136
|
+
HorizontalRule__default.default,
|
|
4137
|
+
extensionTable.Table.configure({
|
|
4138
|
+
resizable: true,
|
|
4139
|
+
HTMLAttributes: {
|
|
4140
|
+
class: "cls_rte_table border-collapse w-full"
|
|
4141
|
+
}
|
|
4142
|
+
}),
|
|
4143
|
+
TableRow__default.default,
|
|
4144
|
+
TableCell__default.default.configure({
|
|
4145
|
+
HTMLAttributes: {
|
|
4146
|
+
class: "border border-border p-2"
|
|
4147
|
+
}
|
|
4148
|
+
}),
|
|
4149
|
+
TableHeader__default.default.configure({
|
|
4150
|
+
HTMLAttributes: {
|
|
4151
|
+
class: "border border-border p-2 bg-muted font-semibold"
|
|
4152
|
+
}
|
|
4153
|
+
}),
|
|
4154
|
+
TaskList__default.default.configure({
|
|
4155
|
+
HTMLAttributes: {
|
|
4156
|
+
class: "cls_rte_task_list list-none pl-0"
|
|
4157
|
+
}
|
|
4158
|
+
}),
|
|
4159
|
+
TaskItem__default.default.configure({
|
|
4160
|
+
nested: true,
|
|
4161
|
+
HTMLAttributes: {
|
|
4162
|
+
class: "cls_rte_task_item flex items-start gap-2"
|
|
4163
|
+
}
|
|
4164
|
+
}),
|
|
4165
|
+
VariableExtension
|
|
4166
|
+
],
|
|
4167
|
+
content: html,
|
|
4168
|
+
editable: !disabled,
|
|
4169
|
+
editorProps: {
|
|
4170
|
+
attributes: {
|
|
4171
|
+
class: cn(
|
|
4172
|
+
"cls_rte_editor",
|
|
4173
|
+
"prose prose-sm dark:prose-invert max-w-none",
|
|
4174
|
+
"p-4 focus:outline-none",
|
|
4175
|
+
"min-h-[inherit] overflow-auto"
|
|
4176
|
+
),
|
|
4177
|
+
style: `min-height: ${min_height}; max-height: ${max_height}`
|
|
4178
|
+
}
|
|
4179
|
+
},
|
|
4180
|
+
onUpdate: ({ editor: editor2 }) => {
|
|
4181
|
+
const output = {
|
|
4182
|
+
html: editor2.getHTML(),
|
|
4183
|
+
plain_text: editor2.getText(),
|
|
4184
|
+
attachments: attachments_ref.current
|
|
4185
|
+
};
|
|
4186
|
+
debounced_on_change(output);
|
|
4187
|
+
}
|
|
4188
|
+
});
|
|
4189
|
+
React23__namespace.useEffect(() => {
|
|
4190
|
+
if (editor && html !== void 0) {
|
|
4191
|
+
const current_html = editor.getHTML();
|
|
4192
|
+
if (html !== current_html && !editor.isFocused) {
|
|
4193
|
+
editor.commands.setContent(html, { emitUpdate: false });
|
|
4194
|
+
}
|
|
4195
|
+
}
|
|
4196
|
+
}, [html, editor]);
|
|
4197
|
+
React23__namespace.useEffect(() => {
|
|
4198
|
+
if (editor) {
|
|
4199
|
+
editor.setEditable(!disabled);
|
|
4200
|
+
}
|
|
4201
|
+
}, [disabled, editor]);
|
|
4202
|
+
const attachments_from_props_ref = React23__namespace.useRef(false);
|
|
4203
|
+
const prev_initial_attachments_ref = React23__namespace.useRef(initial_attachments);
|
|
4204
|
+
React23__namespace.useEffect(() => {
|
|
4205
|
+
if (JSON.stringify(initial_attachments) !== JSON.stringify(prev_initial_attachments_ref.current)) {
|
|
4206
|
+
prev_initial_attachments_ref.current = initial_attachments;
|
|
4207
|
+
attachments_from_props_ref.current = true;
|
|
4208
|
+
set_attachments(initial_attachments);
|
|
4209
|
+
}
|
|
4210
|
+
}, [initial_attachments]);
|
|
4211
|
+
React23__namespace.useEffect(() => {
|
|
4212
|
+
if (attachments_from_props_ref.current) {
|
|
4213
|
+
attachments_from_props_ref.current = false;
|
|
4214
|
+
return;
|
|
4215
|
+
}
|
|
4216
|
+
if (editor && on_change) {
|
|
4217
|
+
const output = {
|
|
4218
|
+
html: editor.getHTML(),
|
|
4219
|
+
plain_text: editor.getText(),
|
|
4220
|
+
attachments
|
|
4221
|
+
};
|
|
4222
|
+
on_change(output);
|
|
4223
|
+
}
|
|
4224
|
+
}, [attachments]);
|
|
4225
|
+
const handle_remove_attachment = (index) => {
|
|
4226
|
+
set_attachments((prev) => prev.filter((_, i) => i !== index));
|
|
4227
|
+
};
|
|
4228
|
+
const handle_attachments_change = (new_attachments) => {
|
|
4229
|
+
set_attachments(new_attachments);
|
|
4230
|
+
};
|
|
4231
|
+
const format_html = (html_str) => {
|
|
4232
|
+
let formatted = "";
|
|
4233
|
+
let indent = 0;
|
|
4234
|
+
const tags = html_str.split(/(<[^>]+>)/g).filter(Boolean);
|
|
4235
|
+
for (const tag of tags) {
|
|
4236
|
+
if (tag.startsWith("</")) {
|
|
4237
|
+
indent = Math.max(0, indent - 1);
|
|
4238
|
+
formatted += " ".repeat(indent) + tag + "\n";
|
|
4239
|
+
} else if (tag.startsWith("<") && !tag.startsWith("<!") && !tag.endsWith("/>")) {
|
|
4240
|
+
formatted += " ".repeat(indent) + tag + "\n";
|
|
4241
|
+
if (!tag.includes("br") && !tag.includes("hr") && !tag.includes("img")) {
|
|
4242
|
+
indent++;
|
|
4243
|
+
}
|
|
4244
|
+
} else if (tag.startsWith("<")) {
|
|
4245
|
+
formatted += " ".repeat(indent) + tag + "\n";
|
|
4246
|
+
} else if (tag.trim()) {
|
|
4247
|
+
formatted += " ".repeat(indent) + tag.trim() + "\n";
|
|
4248
|
+
}
|
|
4249
|
+
}
|
|
4250
|
+
return formatted.trim();
|
|
4251
|
+
};
|
|
4252
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4253
|
+
"div",
|
|
4254
|
+
{
|
|
4255
|
+
className: cn(
|
|
4256
|
+
"cls_rte_container",
|
|
4257
|
+
"rounded-md border border-input bg-background",
|
|
4258
|
+
"focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",
|
|
4259
|
+
disabled && "opacity-50 cursor-not-allowed",
|
|
4260
|
+
className
|
|
4261
|
+
),
|
|
4262
|
+
children: [
|
|
4263
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4264
|
+
Toolbar,
|
|
4265
|
+
{
|
|
4266
|
+
editor,
|
|
4267
|
+
variables,
|
|
4268
|
+
attachments,
|
|
4269
|
+
on_attachments_change: handle_attachments_change,
|
|
4270
|
+
disabled: disabled || is_view_only
|
|
4271
|
+
}
|
|
4272
|
+
),
|
|
4273
|
+
show_output_viewer && editor && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_rte_tabs border-b border-border px-2 pt-2", children: /* @__PURE__ */ jsxRuntime.jsx(Tabs, { value: active_tab, onValueChange: (v) => set_active_tab(v), children: /* @__PURE__ */ jsxRuntime.jsxs(TabsList, { className: "h-9", children: [
|
|
4274
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabsTrigger, { value: "html", className: "text-sm", children: "HTML" }),
|
|
4275
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabsTrigger, { value: "plain_text", className: "text-sm", children: "Plain Text" }),
|
|
4276
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabsTrigger, { value: "raw_html", className: "text-sm", children: "Raw HTML" })
|
|
4277
|
+
] }) }) }),
|
|
4278
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { minHeight: min_height, maxHeight: max_height }, className: "overflow-auto", children: [
|
|
4279
|
+
active_tab === "html" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4280
|
+
react.EditorContent,
|
|
4281
|
+
{
|
|
4282
|
+
editor,
|
|
4283
|
+
className: cn(
|
|
4284
|
+
"cls_rte_content",
|
|
4285
|
+
disabled && "pointer-events-none"
|
|
4286
|
+
)
|
|
4287
|
+
}
|
|
4288
|
+
),
|
|
4289
|
+
active_tab === "plain_text" && /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "cls_rte_plain_text p-4 text-sm whitespace-pre-wrap font-mono h-full", children: editor?.getText() || "(empty)" }),
|
|
4290
|
+
active_tab === "raw_html" && /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "cls_rte_raw_html p-4 text-xs whitespace-pre-wrap font-mono text-muted-foreground h-full", children: format_html(editor?.getHTML() || "") || "(empty)" })
|
|
4291
|
+
] }),
|
|
4292
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4293
|
+
AttachmentsList,
|
|
4294
|
+
{
|
|
4295
|
+
attachments,
|
|
4296
|
+
on_remove: handle_remove_attachment,
|
|
4297
|
+
disabled
|
|
4298
|
+
}
|
|
4299
|
+
)
|
|
4300
|
+
]
|
|
4301
|
+
}
|
|
4302
|
+
);
|
|
4303
|
+
};
|
|
4304
|
+
HazoUiRte.displayName = "HazoUiRte";
|
|
1670
4305
|
|
|
1671
|
-
exports.ExampleComponent = ExampleComponent;
|
|
1672
4306
|
exports.HazoUiFlexInput = HazoUiFlexInput;
|
|
1673
4307
|
exports.HazoUiFlexRadio = HazoUiFlexRadio;
|
|
1674
4308
|
exports.HazoUiMultiFilterDialog = HazoUiMultiFilterDialog;
|
|
1675
4309
|
exports.HazoUiMultiSortDialog = HazoUiMultiSortDialog;
|
|
4310
|
+
exports.HazoUiRte = HazoUiRte;
|
|
1676
4311
|
//# sourceMappingURL=index.cjs.map
|
|
1677
4312
|
//# sourceMappingURL=index.cjs.map
|