@stll/folio-react 0.0.1-placeholder.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE.md +29 -0
- package/README.md +64 -0
- package/dist/CommentsSidebar-BsYOInaX.js +823 -0
- package/dist/FindReplaceDialog-CG1VKA_g.js +358 -0
- package/dist/FootnotePropertiesDialog-MuW4D3gt.js +265 -0
- package/dist/ImagePositionDialog-BQnOnDf4.js +393 -0
- package/dist/ImagePropertiesDialog-Dn4N7qZv.js +196 -0
- package/dist/PageSetupDialog-CxJUEkoC.js +310 -0
- package/dist/TablePropertiesDialog-mQMnGfHu.js +157 -0
- package/dist/TextContextMenu-DzTbp2sn.js +313 -0
- package/dist/contained-handler-4uiqUVRn.js +45 -0
- package/dist/editor.css +1 -0
- package/dist/folio-ui-o_rftArH.js +483 -0
- package/dist/index.d.ts +1063 -0
- package/dist/index.js +12321 -0
- package/dist/messages.d.ts +13 -0
- package/dist/messages.js +2167 -0
- package/dist/useFindReplace-MZ8wi31A.js +354 -0
- package/package.json +83 -2
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import { r as useFolioUI } from "./folio-ui-o_rftArH.js";
|
|
2
|
+
import { useEffect, useId, useState } from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/dialogs/ImagePositionDialog.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Image Position Dialog
|
|
7
|
+
*
|
|
8
|
+
* Modal for editing image positioning settings:
|
|
9
|
+
* - Horizontal: alignment or offset, relative to page/column/margin/paragraph
|
|
10
|
+
* - Vertical: alignment or offset, relative to page/margin/paragraph/line
|
|
11
|
+
* - Distance from text (top/bottom/left/right)
|
|
12
|
+
*/
|
|
13
|
+
function ImagePositionDialog({ isOpen, onClose, onApply, currentData }) {
|
|
14
|
+
const { Root: Dialog, Portal: DialogPortal, Backdrop: DialogBackdrop, Popup: DialogPopup, Title: DialogTitle, Close: DialogClose } = useFolioUI().Dialog;
|
|
15
|
+
const id = useId();
|
|
16
|
+
const [hMode, setHMode] = useState("align");
|
|
17
|
+
const [hAlign, setHAlign] = useState("center");
|
|
18
|
+
const [hRelativeTo, setHRelativeTo] = useState("column");
|
|
19
|
+
const [hOffset, setHOffset] = useState(0);
|
|
20
|
+
const [vMode, setVMode] = useState("align");
|
|
21
|
+
const [vAlign, setVAlign] = useState("top");
|
|
22
|
+
const [vRelativeTo, setVRelativeTo] = useState("paragraph");
|
|
23
|
+
const [vOffset, setVOffset] = useState(0);
|
|
24
|
+
const [distTop, setDistTop] = useState(0);
|
|
25
|
+
const [distBottom, setDistBottom] = useState(0);
|
|
26
|
+
const [distLeft, setDistLeft] = useState(0);
|
|
27
|
+
const [distRight, setDistRight] = useState(0);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (!isOpen) return;
|
|
30
|
+
const h = currentData?.horizontal;
|
|
31
|
+
const v = currentData?.vertical;
|
|
32
|
+
if (h?.align) {
|
|
33
|
+
setHMode("align");
|
|
34
|
+
setHAlign(h.align);
|
|
35
|
+
} else if (h?.posOffset !== void 0) {
|
|
36
|
+
setHMode("offset");
|
|
37
|
+
setHOffset(h.posOffset);
|
|
38
|
+
}
|
|
39
|
+
if (h?.relativeTo) setHRelativeTo(h.relativeTo);
|
|
40
|
+
if (v?.align) {
|
|
41
|
+
setVMode("align");
|
|
42
|
+
setVAlign(v.align);
|
|
43
|
+
} else if (v?.posOffset !== void 0) {
|
|
44
|
+
setVMode("offset");
|
|
45
|
+
setVOffset(v.posOffset);
|
|
46
|
+
}
|
|
47
|
+
if (v?.relativeTo) setVRelativeTo(v.relativeTo);
|
|
48
|
+
setDistTop(currentData?.distTop ?? 0);
|
|
49
|
+
setDistBottom(currentData?.distBottom ?? 0);
|
|
50
|
+
setDistLeft(currentData?.distLeft ?? 0);
|
|
51
|
+
setDistRight(currentData?.distRight ?? 0);
|
|
52
|
+
}, [isOpen, currentData]);
|
|
53
|
+
const handleApply = () => {
|
|
54
|
+
const data = {};
|
|
55
|
+
data.horizontal = {
|
|
56
|
+
relativeTo: hRelativeTo,
|
|
57
|
+
...hMode === "align" ? { align: hAlign } : { posOffset: hOffset }
|
|
58
|
+
};
|
|
59
|
+
data.vertical = {
|
|
60
|
+
relativeTo: vRelativeTo,
|
|
61
|
+
...vMode === "align" ? { align: vAlign } : { posOffset: vOffset }
|
|
62
|
+
};
|
|
63
|
+
data.distTop = distTop;
|
|
64
|
+
data.distBottom = distBottom;
|
|
65
|
+
data.distLeft = distLeft;
|
|
66
|
+
data.distRight = distRight;
|
|
67
|
+
onApply(data);
|
|
68
|
+
onClose();
|
|
69
|
+
};
|
|
70
|
+
const labelCls = "w-[75px] text-muted-foreground text-xs";
|
|
71
|
+
const inputCls = "border-input bg-background text-foreground flex-1 rounded border px-1.5 py-1 text-xs outline-none";
|
|
72
|
+
const sectionLabelCls = "text-foreground text-[13px] font-semibold";
|
|
73
|
+
const distLabelCls = "w-[45px] text-muted-foreground text-xs";
|
|
74
|
+
const fieldIds = {
|
|
75
|
+
hMode: `${id}-img-pos-h-mode`,
|
|
76
|
+
hAlign: `${id}-img-pos-h-align`,
|
|
77
|
+
hOffset: `${id}-img-pos-h-offset`,
|
|
78
|
+
hRelativeTo: `${id}-img-pos-h-rel`,
|
|
79
|
+
vMode: `${id}-img-pos-v-mode`,
|
|
80
|
+
vAlign: `${id}-img-pos-v-align`,
|
|
81
|
+
vOffset: `${id}-img-pos-v-offset`,
|
|
82
|
+
vRelativeTo: `${id}-img-pos-v-rel`,
|
|
83
|
+
distTop: `${id}-img-pos-dist-top`,
|
|
84
|
+
distBottom: `${id}-img-pos-dist-bottom`,
|
|
85
|
+
distLeft: `${id}-img-pos-dist-left`,
|
|
86
|
+
distRight: `${id}-img-pos-dist-right`
|
|
87
|
+
};
|
|
88
|
+
return /* @__PURE__ */ jsx(Dialog, {
|
|
89
|
+
open: isOpen,
|
|
90
|
+
onOpenChange: (open) => {
|
|
91
|
+
if (!open) onClose();
|
|
92
|
+
},
|
|
93
|
+
children: /* @__PURE__ */ jsxs(DialogPortal, { children: [/* @__PURE__ */ jsx(DialogBackdrop, { className: "fixed inset-0 z-[10000] bg-black/50" }), /* @__PURE__ */ jsxs(DialogPopup, {
|
|
94
|
+
className: "bg-popover fixed start-1/2 top-1/2 z-[10001] w-full max-w-[480px] min-w-[400px] -translate-x-1/2 -translate-y-1/2 rounded-lg border shadow-xl",
|
|
95
|
+
children: [
|
|
96
|
+
/* @__PURE__ */ jsx(DialogTitle, {
|
|
97
|
+
className: "border-b px-5 py-3 text-base font-semibold",
|
|
98
|
+
children: "Image Position"
|
|
99
|
+
}),
|
|
100
|
+
/* @__PURE__ */ jsxs("div", {
|
|
101
|
+
className: "flex flex-col gap-4 px-5 py-4",
|
|
102
|
+
children: [
|
|
103
|
+
/* @__PURE__ */ jsxs("div", {
|
|
104
|
+
className: "flex flex-col gap-2",
|
|
105
|
+
children: [
|
|
106
|
+
/* @__PURE__ */ jsx("div", {
|
|
107
|
+
className: sectionLabelCls,
|
|
108
|
+
children: "Horizontal"
|
|
109
|
+
}),
|
|
110
|
+
/* @__PURE__ */ jsxs("div", {
|
|
111
|
+
className: "flex items-center gap-2",
|
|
112
|
+
children: [/* @__PURE__ */ jsx("label", {
|
|
113
|
+
className: labelCls,
|
|
114
|
+
htmlFor: fieldIds.hMode,
|
|
115
|
+
children: "Position"
|
|
116
|
+
}), /* @__PURE__ */ jsxs("select", {
|
|
117
|
+
className: inputCls,
|
|
118
|
+
id: fieldIds.hMode,
|
|
119
|
+
value: hMode,
|
|
120
|
+
onChange: (e) => setHMode(e.target.value),
|
|
121
|
+
children: [/* @__PURE__ */ jsx("option", {
|
|
122
|
+
value: "align",
|
|
123
|
+
children: "Alignment"
|
|
124
|
+
}), /* @__PURE__ */ jsx("option", {
|
|
125
|
+
value: "offset",
|
|
126
|
+
children: "Offset"
|
|
127
|
+
})]
|
|
128
|
+
})]
|
|
129
|
+
}),
|
|
130
|
+
hMode === "align" ? /* @__PURE__ */ jsxs("div", {
|
|
131
|
+
className: "flex items-center gap-2",
|
|
132
|
+
children: [/* @__PURE__ */ jsx("label", {
|
|
133
|
+
className: labelCls,
|
|
134
|
+
htmlFor: fieldIds.hAlign,
|
|
135
|
+
children: "Align"
|
|
136
|
+
}), /* @__PURE__ */ jsxs("select", {
|
|
137
|
+
className: inputCls,
|
|
138
|
+
id: fieldIds.hAlign,
|
|
139
|
+
value: hAlign,
|
|
140
|
+
onChange: (e) => setHAlign(e.target.value),
|
|
141
|
+
children: [
|
|
142
|
+
/* @__PURE__ */ jsx("option", {
|
|
143
|
+
value: "left",
|
|
144
|
+
children: "Left"
|
|
145
|
+
}),
|
|
146
|
+
/* @__PURE__ */ jsx("option", {
|
|
147
|
+
value: "center",
|
|
148
|
+
children: "Center"
|
|
149
|
+
}),
|
|
150
|
+
/* @__PURE__ */ jsx("option", {
|
|
151
|
+
value: "right",
|
|
152
|
+
children: "Right"
|
|
153
|
+
})
|
|
154
|
+
]
|
|
155
|
+
})]
|
|
156
|
+
}) : /* @__PURE__ */ jsxs("div", {
|
|
157
|
+
className: "flex items-center gap-2",
|
|
158
|
+
children: [/* @__PURE__ */ jsx("label", {
|
|
159
|
+
className: labelCls,
|
|
160
|
+
htmlFor: fieldIds.hOffset,
|
|
161
|
+
children: "Offset (px)"
|
|
162
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
163
|
+
className: inputCls,
|
|
164
|
+
id: fieldIds.hOffset,
|
|
165
|
+
type: "number",
|
|
166
|
+
value: hOffset,
|
|
167
|
+
onChange: (e) => setHOffset(Number(e.target.value) || 0)
|
|
168
|
+
})]
|
|
169
|
+
}),
|
|
170
|
+
/* @__PURE__ */ jsxs("div", {
|
|
171
|
+
className: "flex items-center gap-2",
|
|
172
|
+
children: [/* @__PURE__ */ jsx("label", {
|
|
173
|
+
className: labelCls,
|
|
174
|
+
htmlFor: fieldIds.hRelativeTo,
|
|
175
|
+
children: "Relative to"
|
|
176
|
+
}), /* @__PURE__ */ jsxs("select", {
|
|
177
|
+
className: inputCls,
|
|
178
|
+
id: fieldIds.hRelativeTo,
|
|
179
|
+
value: hRelativeTo,
|
|
180
|
+
onChange: (e) => setHRelativeTo(e.target.value),
|
|
181
|
+
children: [
|
|
182
|
+
/* @__PURE__ */ jsx("option", {
|
|
183
|
+
value: "page",
|
|
184
|
+
children: "Page"
|
|
185
|
+
}),
|
|
186
|
+
/* @__PURE__ */ jsx("option", {
|
|
187
|
+
value: "column",
|
|
188
|
+
children: "Column"
|
|
189
|
+
}),
|
|
190
|
+
/* @__PURE__ */ jsx("option", {
|
|
191
|
+
value: "margin",
|
|
192
|
+
children: "Margin"
|
|
193
|
+
}),
|
|
194
|
+
/* @__PURE__ */ jsx("option", {
|
|
195
|
+
value: "character",
|
|
196
|
+
children: "Character"
|
|
197
|
+
})
|
|
198
|
+
]
|
|
199
|
+
})]
|
|
200
|
+
})
|
|
201
|
+
]
|
|
202
|
+
}),
|
|
203
|
+
/* @__PURE__ */ jsxs("div", {
|
|
204
|
+
className: "flex flex-col gap-2",
|
|
205
|
+
children: [
|
|
206
|
+
/* @__PURE__ */ jsx("div", {
|
|
207
|
+
className: sectionLabelCls,
|
|
208
|
+
children: "Vertical"
|
|
209
|
+
}),
|
|
210
|
+
/* @__PURE__ */ jsxs("div", {
|
|
211
|
+
className: "flex items-center gap-2",
|
|
212
|
+
children: [/* @__PURE__ */ jsx("label", {
|
|
213
|
+
className: labelCls,
|
|
214
|
+
htmlFor: fieldIds.vMode,
|
|
215
|
+
children: "Position"
|
|
216
|
+
}), /* @__PURE__ */ jsxs("select", {
|
|
217
|
+
className: inputCls,
|
|
218
|
+
id: fieldIds.vMode,
|
|
219
|
+
value: vMode,
|
|
220
|
+
onChange: (e) => setVMode(e.target.value),
|
|
221
|
+
children: [/* @__PURE__ */ jsx("option", {
|
|
222
|
+
value: "align",
|
|
223
|
+
children: "Alignment"
|
|
224
|
+
}), /* @__PURE__ */ jsx("option", {
|
|
225
|
+
value: "offset",
|
|
226
|
+
children: "Offset"
|
|
227
|
+
})]
|
|
228
|
+
})]
|
|
229
|
+
}),
|
|
230
|
+
vMode === "align" ? /* @__PURE__ */ jsxs("div", {
|
|
231
|
+
className: "flex items-center gap-2",
|
|
232
|
+
children: [/* @__PURE__ */ jsx("label", {
|
|
233
|
+
className: labelCls,
|
|
234
|
+
htmlFor: fieldIds.vAlign,
|
|
235
|
+
children: "Align"
|
|
236
|
+
}), /* @__PURE__ */ jsxs("select", {
|
|
237
|
+
className: inputCls,
|
|
238
|
+
id: fieldIds.vAlign,
|
|
239
|
+
value: vAlign,
|
|
240
|
+
onChange: (e) => setVAlign(e.target.value),
|
|
241
|
+
children: [
|
|
242
|
+
/* @__PURE__ */ jsx("option", {
|
|
243
|
+
value: "top",
|
|
244
|
+
children: "Top"
|
|
245
|
+
}),
|
|
246
|
+
/* @__PURE__ */ jsx("option", {
|
|
247
|
+
value: "center",
|
|
248
|
+
children: "Center"
|
|
249
|
+
}),
|
|
250
|
+
/* @__PURE__ */ jsx("option", {
|
|
251
|
+
value: "bottom",
|
|
252
|
+
children: "Bottom"
|
|
253
|
+
})
|
|
254
|
+
]
|
|
255
|
+
})]
|
|
256
|
+
}) : /* @__PURE__ */ jsxs("div", {
|
|
257
|
+
className: "flex items-center gap-2",
|
|
258
|
+
children: [/* @__PURE__ */ jsx("label", {
|
|
259
|
+
className: labelCls,
|
|
260
|
+
htmlFor: fieldIds.vOffset,
|
|
261
|
+
children: "Offset (px)"
|
|
262
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
263
|
+
className: inputCls,
|
|
264
|
+
id: fieldIds.vOffset,
|
|
265
|
+
type: "number",
|
|
266
|
+
value: vOffset,
|
|
267
|
+
onChange: (e) => setVOffset(Number(e.target.value) || 0)
|
|
268
|
+
})]
|
|
269
|
+
}),
|
|
270
|
+
/* @__PURE__ */ jsxs("div", {
|
|
271
|
+
className: "flex items-center gap-2",
|
|
272
|
+
children: [/* @__PURE__ */ jsx("label", {
|
|
273
|
+
className: labelCls,
|
|
274
|
+
htmlFor: fieldIds.vRelativeTo,
|
|
275
|
+
children: "Relative to"
|
|
276
|
+
}), /* @__PURE__ */ jsxs("select", {
|
|
277
|
+
className: inputCls,
|
|
278
|
+
id: fieldIds.vRelativeTo,
|
|
279
|
+
value: vRelativeTo,
|
|
280
|
+
onChange: (e) => setVRelativeTo(e.target.value),
|
|
281
|
+
children: [
|
|
282
|
+
/* @__PURE__ */ jsx("option", {
|
|
283
|
+
value: "page",
|
|
284
|
+
children: "Page"
|
|
285
|
+
}),
|
|
286
|
+
/* @__PURE__ */ jsx("option", {
|
|
287
|
+
value: "margin",
|
|
288
|
+
children: "Margin"
|
|
289
|
+
}),
|
|
290
|
+
/* @__PURE__ */ jsx("option", {
|
|
291
|
+
value: "paragraph",
|
|
292
|
+
children: "Paragraph"
|
|
293
|
+
}),
|
|
294
|
+
/* @__PURE__ */ jsx("option", {
|
|
295
|
+
value: "line",
|
|
296
|
+
children: "Line"
|
|
297
|
+
})
|
|
298
|
+
]
|
|
299
|
+
})]
|
|
300
|
+
})
|
|
301
|
+
]
|
|
302
|
+
}),
|
|
303
|
+
/* @__PURE__ */ jsxs("div", {
|
|
304
|
+
className: "flex flex-col gap-2",
|
|
305
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
306
|
+
className: sectionLabelCls,
|
|
307
|
+
children: "Distance from text (px)"
|
|
308
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
309
|
+
className: "grid grid-cols-2 gap-2",
|
|
310
|
+
children: [
|
|
311
|
+
/* @__PURE__ */ jsxs("div", {
|
|
312
|
+
className: "flex items-center gap-2",
|
|
313
|
+
children: [/* @__PURE__ */ jsx("label", {
|
|
314
|
+
className: distLabelCls,
|
|
315
|
+
htmlFor: fieldIds.distTop,
|
|
316
|
+
children: "Top"
|
|
317
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
318
|
+
className: inputCls,
|
|
319
|
+
id: fieldIds.distTop,
|
|
320
|
+
min: 0,
|
|
321
|
+
type: "number",
|
|
322
|
+
value: distTop,
|
|
323
|
+
onChange: (e) => setDistTop(Number(e.target.value) || 0)
|
|
324
|
+
})]
|
|
325
|
+
}),
|
|
326
|
+
/* @__PURE__ */ jsxs("div", {
|
|
327
|
+
className: "flex items-center gap-2",
|
|
328
|
+
children: [/* @__PURE__ */ jsx("label", {
|
|
329
|
+
className: distLabelCls,
|
|
330
|
+
htmlFor: fieldIds.distBottom,
|
|
331
|
+
children: "Bottom"
|
|
332
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
333
|
+
className: inputCls,
|
|
334
|
+
id: fieldIds.distBottom,
|
|
335
|
+
min: 0,
|
|
336
|
+
type: "number",
|
|
337
|
+
value: distBottom,
|
|
338
|
+
onChange: (e) => setDistBottom(Number(e.target.value) || 0)
|
|
339
|
+
})]
|
|
340
|
+
}),
|
|
341
|
+
/* @__PURE__ */ jsxs("div", {
|
|
342
|
+
className: "flex items-center gap-2",
|
|
343
|
+
children: [/* @__PURE__ */ jsx("label", {
|
|
344
|
+
className: distLabelCls,
|
|
345
|
+
htmlFor: fieldIds.distLeft,
|
|
346
|
+
children: "Left"
|
|
347
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
348
|
+
className: inputCls,
|
|
349
|
+
id: fieldIds.distLeft,
|
|
350
|
+
min: 0,
|
|
351
|
+
type: "number",
|
|
352
|
+
value: distLeft,
|
|
353
|
+
onChange: (e) => setDistLeft(Number(e.target.value) || 0)
|
|
354
|
+
})]
|
|
355
|
+
}),
|
|
356
|
+
/* @__PURE__ */ jsxs("div", {
|
|
357
|
+
className: "flex items-center gap-2",
|
|
358
|
+
children: [/* @__PURE__ */ jsx("label", {
|
|
359
|
+
className: distLabelCls,
|
|
360
|
+
htmlFor: fieldIds.distRight,
|
|
361
|
+
children: "Right"
|
|
362
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
363
|
+
className: inputCls,
|
|
364
|
+
id: fieldIds.distRight,
|
|
365
|
+
min: 0,
|
|
366
|
+
type: "number",
|
|
367
|
+
value: distRight,
|
|
368
|
+
onChange: (e) => setDistRight(Number(e.target.value) || 0)
|
|
369
|
+
})]
|
|
370
|
+
})
|
|
371
|
+
]
|
|
372
|
+
})]
|
|
373
|
+
})
|
|
374
|
+
]
|
|
375
|
+
}),
|
|
376
|
+
/* @__PURE__ */ jsxs("div", {
|
|
377
|
+
className: "flex justify-end gap-2 border-t px-5 py-3",
|
|
378
|
+
children: [/* @__PURE__ */ jsx(DialogClose, {
|
|
379
|
+
className: "border-input rounded border px-4 py-1.5 text-[13px]",
|
|
380
|
+
children: "Cancel"
|
|
381
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
382
|
+
className: "bg-primary text-primary-foreground rounded px-4 py-1.5 text-[13px] font-medium",
|
|
383
|
+
onClick: handleApply,
|
|
384
|
+
type: "button",
|
|
385
|
+
children: "Apply"
|
|
386
|
+
})]
|
|
387
|
+
})
|
|
388
|
+
]
|
|
389
|
+
})] })
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
//#endregion
|
|
393
|
+
export { ImagePositionDialog };
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { r as useFolioUI } from "./folio-ui-o_rftArH.js";
|
|
2
|
+
import { useEffect, useId, useState } from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/dialogs/ImagePropertiesDialog.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Image Properties Dialog
|
|
7
|
+
*
|
|
8
|
+
* Modal for editing image properties:
|
|
9
|
+
* - Alt text for accessibility
|
|
10
|
+
* - Border/outline style, color, and width
|
|
11
|
+
*/
|
|
12
|
+
function ImagePropertiesDialog({ isOpen, onClose, onApply, currentData }) {
|
|
13
|
+
const { Root: Dialog, Portal: DialogPortal, Backdrop: DialogBackdrop, Popup: DialogPopup, Title: DialogTitle, Close: DialogClose } = useFolioUI().Dialog;
|
|
14
|
+
const id = useId();
|
|
15
|
+
const [alt, setAlt] = useState("");
|
|
16
|
+
const [borderWidth, setBorderWidth] = useState(0);
|
|
17
|
+
const [borderColor, setBorderColor] = useState("#000000");
|
|
18
|
+
const [borderStyle, setBorderStyle] = useState("solid");
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (!isOpen) return;
|
|
21
|
+
setAlt(currentData?.alt ?? "");
|
|
22
|
+
setBorderWidth(currentData?.borderWidth ?? 0);
|
|
23
|
+
setBorderColor(currentData?.borderColor ?? "#000000");
|
|
24
|
+
setBorderStyle(currentData?.borderStyle ?? "solid");
|
|
25
|
+
}, [isOpen, currentData]);
|
|
26
|
+
const handleApply = () => {
|
|
27
|
+
onApply({
|
|
28
|
+
...alt ? { alt } : {},
|
|
29
|
+
...borderWidth > 0 ? {
|
|
30
|
+
borderWidth,
|
|
31
|
+
borderColor,
|
|
32
|
+
borderStyle
|
|
33
|
+
} : {}
|
|
34
|
+
});
|
|
35
|
+
onClose();
|
|
36
|
+
};
|
|
37
|
+
const labelCls = "w-[60px] text-muted-foreground text-xs";
|
|
38
|
+
const inputCls = "border-input bg-background text-foreground flex-1 rounded border px-1.5 py-1 text-xs outline-none";
|
|
39
|
+
const sectionLabelCls = "text-foreground text-[13px] font-semibold";
|
|
40
|
+
const fieldIds = {
|
|
41
|
+
borderWidth: `${id}-img-border-width`,
|
|
42
|
+
borderStyle: `${id}-img-border-style`,
|
|
43
|
+
borderColor: `${id}-img-border-color`
|
|
44
|
+
};
|
|
45
|
+
return /* @__PURE__ */ jsx(Dialog, {
|
|
46
|
+
open: isOpen,
|
|
47
|
+
onOpenChange: (open) => {
|
|
48
|
+
if (!open) onClose();
|
|
49
|
+
},
|
|
50
|
+
children: /* @__PURE__ */ jsxs(DialogPortal, { children: [/* @__PURE__ */ jsx(DialogBackdrop, { className: "fixed inset-0 z-[10000] bg-black/50" }), /* @__PURE__ */ jsxs(DialogPopup, {
|
|
51
|
+
className: "bg-popover fixed start-1/2 top-1/2 z-[10001] w-full max-w-[440px] min-w-[380px] -translate-x-1/2 -translate-y-1/2 rounded-lg border shadow-xl",
|
|
52
|
+
children: [
|
|
53
|
+
/* @__PURE__ */ jsx(DialogTitle, {
|
|
54
|
+
className: "border-b px-5 py-3 text-base font-semibold",
|
|
55
|
+
children: "Image Properties"
|
|
56
|
+
}),
|
|
57
|
+
/* @__PURE__ */ jsxs("div", {
|
|
58
|
+
className: "flex flex-col gap-4 px-5 py-4",
|
|
59
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
60
|
+
className: "flex flex-col gap-2",
|
|
61
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
62
|
+
className: sectionLabelCls,
|
|
63
|
+
children: "Alt Text"
|
|
64
|
+
}), /* @__PURE__ */ jsx("textarea", {
|
|
65
|
+
className: "border-input bg-background text-foreground font-inherit min-h-[60px] resize-y rounded border px-1.5 py-1 text-xs outline-none",
|
|
66
|
+
value: alt,
|
|
67
|
+
onChange: (e) => setAlt(e.target.value),
|
|
68
|
+
placeholder: "Describe this image for accessibility..."
|
|
69
|
+
})]
|
|
70
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
71
|
+
className: "flex flex-col gap-2",
|
|
72
|
+
children: [
|
|
73
|
+
/* @__PURE__ */ jsx("div", {
|
|
74
|
+
className: sectionLabelCls,
|
|
75
|
+
children: "Border"
|
|
76
|
+
}),
|
|
77
|
+
/* @__PURE__ */ jsxs("div", {
|
|
78
|
+
className: "flex items-center gap-2",
|
|
79
|
+
children: [
|
|
80
|
+
/* @__PURE__ */ jsx("label", {
|
|
81
|
+
htmlFor: fieldIds.borderWidth,
|
|
82
|
+
className: labelCls,
|
|
83
|
+
children: "Width"
|
|
84
|
+
}),
|
|
85
|
+
/* @__PURE__ */ jsx("input", {
|
|
86
|
+
id: fieldIds.borderWidth,
|
|
87
|
+
type: "number",
|
|
88
|
+
className: `${inputCls} max-w-[80px]`,
|
|
89
|
+
min: 0,
|
|
90
|
+
max: 20,
|
|
91
|
+
step: .5,
|
|
92
|
+
value: borderWidth,
|
|
93
|
+
onChange: (e) => setBorderWidth(Number(e.target.value) || 0)
|
|
94
|
+
}),
|
|
95
|
+
/* @__PURE__ */ jsx("span", {
|
|
96
|
+
className: "text-muted-foreground text-xs",
|
|
97
|
+
children: "px"
|
|
98
|
+
})
|
|
99
|
+
]
|
|
100
|
+
}),
|
|
101
|
+
/* @__PURE__ */ jsxs("div", {
|
|
102
|
+
className: "flex items-center gap-2",
|
|
103
|
+
children: [/* @__PURE__ */ jsx("label", {
|
|
104
|
+
htmlFor: fieldIds.borderStyle,
|
|
105
|
+
className: labelCls,
|
|
106
|
+
children: "Style"
|
|
107
|
+
}), /* @__PURE__ */ jsxs("select", {
|
|
108
|
+
id: fieldIds.borderStyle,
|
|
109
|
+
className: inputCls,
|
|
110
|
+
value: borderStyle,
|
|
111
|
+
onChange: (e) => setBorderStyle(e.target.value),
|
|
112
|
+
children: [
|
|
113
|
+
/* @__PURE__ */ jsx("option", {
|
|
114
|
+
value: "solid",
|
|
115
|
+
children: "Solid"
|
|
116
|
+
}),
|
|
117
|
+
/* @__PURE__ */ jsx("option", {
|
|
118
|
+
value: "dashed",
|
|
119
|
+
children: "Dashed"
|
|
120
|
+
}),
|
|
121
|
+
/* @__PURE__ */ jsx("option", {
|
|
122
|
+
value: "dotted",
|
|
123
|
+
children: "Dotted"
|
|
124
|
+
}),
|
|
125
|
+
/* @__PURE__ */ jsx("option", {
|
|
126
|
+
value: "double",
|
|
127
|
+
children: "Double"
|
|
128
|
+
}),
|
|
129
|
+
/* @__PURE__ */ jsx("option", {
|
|
130
|
+
value: "groove",
|
|
131
|
+
children: "Groove"
|
|
132
|
+
}),
|
|
133
|
+
/* @__PURE__ */ jsx("option", {
|
|
134
|
+
value: "ridge",
|
|
135
|
+
children: "Ridge"
|
|
136
|
+
}),
|
|
137
|
+
/* @__PURE__ */ jsx("option", {
|
|
138
|
+
value: "inset",
|
|
139
|
+
children: "Inset"
|
|
140
|
+
}),
|
|
141
|
+
/* @__PURE__ */ jsx("option", {
|
|
142
|
+
value: "outset",
|
|
143
|
+
children: "Outset"
|
|
144
|
+
})
|
|
145
|
+
]
|
|
146
|
+
})]
|
|
147
|
+
}),
|
|
148
|
+
/* @__PURE__ */ jsxs("div", {
|
|
149
|
+
className: "flex items-center gap-2",
|
|
150
|
+
children: [
|
|
151
|
+
/* @__PURE__ */ jsx("label", {
|
|
152
|
+
htmlFor: fieldIds.borderColor,
|
|
153
|
+
className: labelCls,
|
|
154
|
+
children: "Color"
|
|
155
|
+
}),
|
|
156
|
+
/* @__PURE__ */ jsx("input", {
|
|
157
|
+
id: fieldIds.borderColor,
|
|
158
|
+
type: "color",
|
|
159
|
+
value: borderColor,
|
|
160
|
+
onChange: (e) => setBorderColor(e.target.value),
|
|
161
|
+
className: "border-input h-6 w-8 cursor-pointer rounded border p-0"
|
|
162
|
+
}),
|
|
163
|
+
/* @__PURE__ */ jsx("input", {
|
|
164
|
+
type: "text",
|
|
165
|
+
className: `${inputCls} max-w-[90px]`,
|
|
166
|
+
value: borderColor,
|
|
167
|
+
onChange: (e) => setBorderColor(e.target.value)
|
|
168
|
+
})
|
|
169
|
+
]
|
|
170
|
+
}),
|
|
171
|
+
borderWidth > 0 && /* @__PURE__ */ jsx("div", {
|
|
172
|
+
className: "text-muted-foreground mt-1 rounded p-2 text-center text-[11px]",
|
|
173
|
+
style: { border: `${borderWidth}px ${borderStyle} ${borderColor}` },
|
|
174
|
+
children: "Preview"
|
|
175
|
+
})
|
|
176
|
+
]
|
|
177
|
+
})]
|
|
178
|
+
}),
|
|
179
|
+
/* @__PURE__ */ jsxs("div", {
|
|
180
|
+
className: "flex justify-end gap-2 border-t px-5 py-3",
|
|
181
|
+
children: [/* @__PURE__ */ jsx(DialogClose, {
|
|
182
|
+
className: "border-input rounded border px-4 py-1.5 text-[13px]",
|
|
183
|
+
children: "Cancel"
|
|
184
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
185
|
+
className: "bg-primary text-primary-foreground rounded px-4 py-1.5 text-[13px] font-medium",
|
|
186
|
+
onClick: handleApply,
|
|
187
|
+
type: "button",
|
|
188
|
+
children: "Apply"
|
|
189
|
+
})]
|
|
190
|
+
})
|
|
191
|
+
]
|
|
192
|
+
})] })
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
//#endregion
|
|
196
|
+
export { ImagePropertiesDialog };
|