@burger-editor/client 4.0.0-alpha.7 → 4.0.0-alpha.71
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 +153 -2
- package/dist/animate-insertion.d.ts +17 -0
- package/dist/animate-insertion.d.ts.map +1 -0
- package/dist/burger-editor-root.d.ts +11 -0
- package/dist/burger-editor-root.d.ts.map +1 -0
- package/dist/client.css +851 -577
- package/dist/client.js +32941 -13779
- package/dist/client.js.map +1 -1
- package/dist/commands/register-engine-commands.d.ts +17 -0
- package/dist/commands/register-engine-commands.d.ts.map +1 -0
- package/dist/components/block-catalog.d.ts +20 -0
- package/dist/components/block-catalog.d.ts.map +1 -0
- package/dist/components/block-menu-button.d.ts +28 -0
- package/dist/components/block-menu-button.d.ts.map +1 -0
- package/dist/components/block-menu.d.ts +23 -0
- package/dist/components/block-menu.d.ts.map +1 -0
- package/dist/components/block-options.d.ts +25 -0
- package/dist/components/block-options.d.ts.map +1 -0
- package/dist/components/draft-switcher.d.ts +23 -0
- package/dist/components/draft-switcher.d.ts.map +1 -0
- package/dist/components/editable-area-view.d.ts +44 -0
- package/dist/components/editable-area-view.d.ts.map +1 -0
- package/dist/components/file-list.d.ts +19 -0
- package/dist/components/file-list.d.ts.map +1 -0
- package/dist/components/file-uploader.d.ts +18 -0
- package/dist/components/file-uploader.d.ts.map +1 -0
- package/dist/components/index.d.ts +16 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/initial-insertion-button.d.ts +10 -0
- package/dist/components/initial-insertion-button.d.ts.map +1 -0
- package/dist/components/item-editor-host.d.ts +23 -0
- package/dist/components/item-editor-host.d.ts.map +1 -0
- package/dist/components/preview.d.ts +18 -0
- package/dist/components/preview.d.ts.map +1 -0
- package/dist/components/table-editor.d.ts +28 -0
- package/dist/components/table-editor.d.ts.map +1 -0
- package/dist/components/tabs.d.ts +27 -0
- package/dist/components/tabs.d.ts.map +1 -0
- package/dist/components/thumbnail.d.ts +17 -0
- package/dist/components/thumbnail.d.ts.map +1 -0
- package/dist/components/wysiwyg-field.d.ts +40 -0
- package/dist/components/wysiwyg-field.d.ts.map +1 -0
- package/dist/editor-dialog.d.ts +41 -0
- package/dist/editor-dialog.d.ts.map +1 -0
- package/dist/form/checkbox.d.ts +34 -0
- package/dist/form/checkbox.d.ts.map +1 -0
- package/dist/form/fieldset.d.ts +31 -0
- package/dist/form/fieldset.d.ts.map +1 -0
- package/dist/form/index.d.ts +8 -0
- package/dist/form/index.d.ts.map +1 -0
- package/dist/form/number-field.d.ts +37 -0
- package/dist/form/number-field.d.ts.map +1 -0
- package/dist/form/radio-group.d.ts +38 -0
- package/dist/form/radio-group.d.ts.map +1 -0
- package/dist/form/select-field.d.ts +38 -0
- package/dist/form/select-field.d.ts.map +1 -0
- package/dist/form/text-area.d.ts +33 -0
- package/dist/form/text-area.d.ts.map +1 -0
- package/dist/form/text-field.d.ts +35 -0
- package/dist/form/text-field.d.ts.map +1 -0
- package/dist/index.d.ts +34 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/initial-insertion-button-DMGBvuDE.js +9147 -0
- package/dist/initial-insertion-button-DMGBvuDE.js.map +1 -0
- package/dist/invoker-commands.d.ts +24 -0
- package/dist/invoker-commands.d.ts.map +1 -0
- package/dist/mount.d.ts +18 -0
- package/dist/mount.d.ts.map +1 -0
- package/dist/replace-element.d.ts.map +1 -1
- package/dist/ui.d.ts +10 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +989 -0
- package/dist/ui.js.map +1 -0
- package/dist/use-command.d.ts +29 -0
- package/dist/use-command.d.ts.map +1 -0
- package/dist/use-engine.d.ts +53 -0
- package/dist/use-engine.d.ts.map +1 -0
- package/dist/view/create-react-view.d.ts +17 -0
- package/dist/view/create-react-view.d.ts.map +1 -0
- package/package.json +29 -15
- package/dist/block-catalog.svelte.d.ts +0 -1
- package/dist/block-menu-button.svelte.d.ts +0 -1
- package/dist/block-menu.svelte.d.ts +0 -1
- package/dist/block-options.svelte.d.ts +0 -1
- package/dist/draft-switcher.svelte.d.ts +0 -1
- package/dist/file-list.svelte.d.ts +0 -1
- package/dist/file-uploader.svelte.d.ts +0 -1
- package/dist/preview.svelte.d.ts +0 -1
- package/dist/svelte-mount.d.ts +0 -10
- package/dist/svelte-mount.d.ts.map +0 -1
- package/dist/table-editor.svelte.d.ts +0 -1
- package/dist/tabs.svelte.d.ts +0 -1
- package/dist/thumbnail.svelte.d.ts +0 -1
package/dist/ui.js
ADDED
|
@@ -0,0 +1,989 @@
|
|
|
1
|
+
import { useState, useId, useRef, Fragment, useEffect } from 'react';
|
|
2
|
+
import { k as dayjs, l as createReactComponent, m as useComponentEvent, n as useCommand, o as IconRowInsertBottom, p as IconTrash } from './initial-insertion-button-DMGBvuDE.js';
|
|
3
|
+
export { e as BlockCatalog, h as BlockMenu, q as BlockMenuButton, f as BlockOptions, D as DraftSwitcher, d as EditorDialog, i as InitialInsertionButton, g as ItemEditorHost, r as reactMount, j as registerEngineCommands, u as useUIState } from './initial-insertion-button-DMGBvuDE.js';
|
|
4
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 数値をバイトサイズ単位にフォーマットする
|
|
8
|
+
* @param byteSize 対象の数値
|
|
9
|
+
* @param digits 小数点の桁数
|
|
10
|
+
* @param autoFormat SI接頭辞をつけるかどうか
|
|
11
|
+
* @returns フォーマットされた文字列
|
|
12
|
+
*/
|
|
13
|
+
function formatByteSize(byteSize, digits = 2, autoFormat = true) {
|
|
14
|
+
let compute = byteSize;
|
|
15
|
+
let counter = 0;
|
|
16
|
+
const unit = ['byte', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB'];
|
|
17
|
+
if (autoFormat) {
|
|
18
|
+
while (compute > 1024) {
|
|
19
|
+
compute /= 1024;
|
|
20
|
+
counter += 1;
|
|
21
|
+
}
|
|
22
|
+
if (counter === 0) {
|
|
23
|
+
digits = 0;
|
|
24
|
+
}
|
|
25
|
+
return compute.toFixed(digits) + unit[counter];
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return byteSize + unit[0];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Unixタイムスタンプを日付文字列に変換する
|
|
33
|
+
* @param timestamp Unixタイムスタンプ
|
|
34
|
+
* @param format フォーマット
|
|
35
|
+
*/
|
|
36
|
+
function formatDate(timestamp, format) {
|
|
37
|
+
return dayjs.unix(timestamp).format(format);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @license @tabler/icons-react v3.45.0 - MIT
|
|
42
|
+
*
|
|
43
|
+
* This source code is licensed under the MIT license.
|
|
44
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
const __iconNode$7 = [["path", { "d": "M17 3v6", "key": "svg-0" }], ["path", { "d": "M10 18l-3 3l-3 -3", "key": "svg-1" }], ["path", { "d": "M7 21v-18", "key": "svg-2" }], ["path", { "d": "M20 6l-3 -3l-3 3", "key": "svg-3" }], ["path", { "d": "M17 21v-2", "key": "svg-4" }], ["path", { "d": "M17 15v-2", "key": "svg-5" }]];
|
|
49
|
+
const IconArrowsTransferDown = createReactComponent("outline", "arrows-transfer-down", "ArrowsTransferDown", __iconNode$7);
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @license @tabler/icons-react v3.45.0 - MIT
|
|
53
|
+
*
|
|
54
|
+
* This source code is licensed under the MIT license.
|
|
55
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
const __iconNode$6 = [["path", { "d": "M14 3v4a1 1 0 0 0 1 1h4", "key": "svg-0" }], ["path", { "d": "M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4", "key": "svg-1" }], ["path", { "d": "M5 15v6h1a2 2 0 0 0 2 -2v-2a2 2 0 0 0 -2 -2h-1", "key": "svg-2" }], ["path", { "d": "M20 16.5a1.5 1.5 0 0 0 -3 0v3a1.5 1.5 0 0 0 3 0", "key": "svg-3" }], ["path", { "d": "M12.5 15a1.5 1.5 0 0 1 1.5 1.5v3a1.5 1.5 0 0 1 -3 0v-3a1.5 1.5 0 0 1 1.5 -1.5", "key": "svg-4" }]];
|
|
60
|
+
const IconFileTypeDoc = createReactComponent("outline", "file-type-doc", "FileTypeDoc", __iconNode$6);
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @license @tabler/icons-react v3.45.0 - MIT
|
|
64
|
+
*
|
|
65
|
+
* This source code is licensed under the MIT license.
|
|
66
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
const __iconNode$5 = [["path", { "d": "M14 3v4a1 1 0 0 0 1 1h4", "key": "svg-0" }], ["path", { "d": "M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4", "key": "svg-1" }], ["path", { "d": "M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6", "key": "svg-2" }], ["path", { "d": "M17 18h2", "key": "svg-3" }], ["path", { "d": "M20 15h-3v6", "key": "svg-4" }], ["path", { "d": "M11 15v6h1a2 2 0 0 0 2 -2v-2a2 2 0 0 0 -2 -2h-1", "key": "svg-5" }]];
|
|
71
|
+
const IconFileTypePdf = createReactComponent("outline", "file-type-pdf", "FileTypePdf", __iconNode$5);
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @license @tabler/icons-react v3.45.0 - MIT
|
|
75
|
+
*
|
|
76
|
+
* This source code is licensed under the MIT license.
|
|
77
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
const __iconNode$4 = [["path", { "d": "M14 3v4a1 1 0 0 0 1 1h4", "key": "svg-0" }], ["path", { "d": "M14 3v4a1 1 0 0 0 1 1h4", "key": "svg-1" }], ["path", { "d": "M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6", "key": "svg-2" }], ["path", { "d": "M11 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6", "key": "svg-3" }], ["path", { "d": "M16.5 15h3", "key": "svg-4" }], ["path", { "d": "M18 15v6", "key": "svg-5" }], ["path", { "d": "M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4", "key": "svg-6" }]];
|
|
82
|
+
const IconFileTypePpt = createReactComponent("outline", "file-type-ppt", "FileTypePpt", __iconNode$4);
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @license @tabler/icons-react v3.45.0 - MIT
|
|
86
|
+
*
|
|
87
|
+
* This source code is licensed under the MIT license.
|
|
88
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
const __iconNode$3 = [["path", { "d": "M14 3v4a1 1 0 0 0 1 1h4", "key": "svg-0" }], ["path", { "d": "M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4", "key": "svg-1" }], ["path", { "d": "M4 15l4 6", "key": "svg-2" }], ["path", { "d": "M4 21l4 -6", "key": "svg-3" }], ["path", { "d": "M17 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75", "key": "svg-4" }], ["path", { "d": "M11 15v6h3", "key": "svg-5" }]];
|
|
93
|
+
const IconFileTypeXls = createReactComponent("outline", "file-type-xls", "FileTypeXls", __iconNode$3);
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* @license @tabler/icons-react v3.45.0 - MIT
|
|
97
|
+
*
|
|
98
|
+
* This source code is licensed under the MIT license.
|
|
99
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
const __iconNode$2 = [["path", { "d": "M14 3v4a1 1 0 0 0 1 1h4", "key": "svg-0" }], ["path", { "d": "M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2", "key": "svg-1" }]];
|
|
104
|
+
const IconFile = createReactComponent("outline", "file", "File", __iconNode$2);
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @license @tabler/icons-react v3.45.0 - MIT
|
|
108
|
+
*
|
|
109
|
+
* This source code is licensed under the MIT license.
|
|
110
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
const __iconNode$1 = [["path", { "d": "M4 15a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v3a2 2 0 0 1 -2 2h-1a2 2 0 0 1 -2 -2l0 -3", "key": "svg-0" }], ["path", { "d": "M15 15a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v3a2 2 0 0 1 -2 2h-1a2 2 0 0 1 -2 -2l0 -3", "key": "svg-1" }], ["path", { "d": "M4 15v-3a8 8 0 0 1 16 0v3", "key": "svg-2" }]];
|
|
115
|
+
const IconHeadphones = createReactComponent("outline", "headphones", "Headphones", __iconNode$1);
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* @license @tabler/icons-react v3.45.0 - MIT
|
|
119
|
+
*
|
|
120
|
+
* This source code is licensed under the MIT license.
|
|
121
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
122
|
+
*/
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
const __iconNode = [["path", { "d": "M15 10l4.553 -2.276a1 1 0 0 1 1.447 .894v6.764a1 1 0 0 1 -1.447 .894l-4.553 -2.276v-4", "key": "svg-0" }], ["path", { "d": "M3 8a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2l0 -8", "key": "svg-1" }]];
|
|
126
|
+
const IconVideo = createReactComponent("outline", "video", "Video", __iconNode);
|
|
127
|
+
|
|
128
|
+
const ctrl = "_ctrl_1vnsv_1";
|
|
129
|
+
const pagination = "_pagination_1vnsv_7";
|
|
130
|
+
const page = "_page_1vnsv_19";
|
|
131
|
+
const list = "_list_1vnsv_25";
|
|
132
|
+
const file = "_file_1vnsv_44";
|
|
133
|
+
const thumbnail$1 = "_thumbnail_1vnsv_58";
|
|
134
|
+
const attr = "_attr_1vnsv_65";
|
|
135
|
+
const styles$5 = {
|
|
136
|
+
ctrl: ctrl,
|
|
137
|
+
pagination: pagination,
|
|
138
|
+
page: page,
|
|
139
|
+
list: list,
|
|
140
|
+
"delete": "_delete_1vnsv_39",
|
|
141
|
+
file: file,
|
|
142
|
+
thumbnail: thumbnail$1,
|
|
143
|
+
attr: attr
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
function getExt(src) {
|
|
147
|
+
const ext = src.split(".").pop()?.toLowerCase() ?? "";
|
|
148
|
+
const isImage = ["jpg", "jpeg", "png", "gif", "webp", "svg"].includes(ext);
|
|
149
|
+
const isVideo = ["mp4", "webm", "mov", "avi"].includes(ext);
|
|
150
|
+
const isAudio = ["mp3", "wav", "m4a", "ogg", "flac"].includes(ext);
|
|
151
|
+
const isDoc = ["doc", "docx"].includes(ext);
|
|
152
|
+
const isPpt = ["ppt", "pptx"].includes(ext);
|
|
153
|
+
const isXls = ["xls", "xlsx"].includes(ext);
|
|
154
|
+
const isPdf = ["pdf"].includes(ext);
|
|
155
|
+
return {
|
|
156
|
+
ext,
|
|
157
|
+
isImage,
|
|
158
|
+
isVideo,
|
|
159
|
+
isAudio,
|
|
160
|
+
isDoc,
|
|
161
|
+
isPpt,
|
|
162
|
+
isXls,
|
|
163
|
+
isPdf
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const thumbnail = "_thumbnail_bi2ve_1";
|
|
168
|
+
const styles$4 = {
|
|
169
|
+
thumbnail: thumbnail
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
function Thumbnail({ src }) {
|
|
173
|
+
const [isLoaded, setIsLoaded] = useState(false);
|
|
174
|
+
const file = getExt(src);
|
|
175
|
+
return /* @__PURE__ */ jsx(
|
|
176
|
+
"span",
|
|
177
|
+
{
|
|
178
|
+
className: styles$4["thumbnail"],
|
|
179
|
+
"data-bge-editor-ui-component": "thumbnail",
|
|
180
|
+
"data-loaded": isLoaded,
|
|
181
|
+
children: file.isImage ? /* @__PURE__ */ jsx(
|
|
182
|
+
"img",
|
|
183
|
+
{
|
|
184
|
+
src,
|
|
185
|
+
alt: "画像のプレビュー",
|
|
186
|
+
loading: "lazy",
|
|
187
|
+
onLoad: () => setIsLoaded(true)
|
|
188
|
+
}
|
|
189
|
+
) : file.isVideo ? /* @__PURE__ */ jsxs("video", { controls: false, playsInline: true, children: [
|
|
190
|
+
/* @__PURE__ */ jsx("source", { src, type: `video/${file.ext}` }),
|
|
191
|
+
/* @__PURE__ */ jsx("track", { kind: "captions", src: "" }),
|
|
192
|
+
/* @__PURE__ */ jsx(IconVideo, {})
|
|
193
|
+
] }) : file.isAudio ? /* @__PURE__ */ jsx(IconHeadphones, {}) : file.isDoc ? /* @__PURE__ */ jsx(IconFileTypeDoc, {}) : file.isPpt ? /* @__PURE__ */ jsx(IconFileTypePpt, {}) : file.isXls ? /* @__PURE__ */ jsx(IconFileTypeXls, {}) : file.isPdf ? /* @__PURE__ */ jsx(IconFileTypePdf, {}) : /* @__PURE__ */ jsx(IconFile, {})
|
|
194
|
+
}
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function FileList({
|
|
199
|
+
engine,
|
|
200
|
+
fileType
|
|
201
|
+
}) {
|
|
202
|
+
const rootId = useId();
|
|
203
|
+
const getFileList = engine.serverAPI.getFileList;
|
|
204
|
+
const deleteFile = engine.serverAPI.deleteFile;
|
|
205
|
+
const [fileList, setFileList] = useState([]);
|
|
206
|
+
const [selectedPath, setSelectedPath] = useState("");
|
|
207
|
+
const [searchWord, setSearchWord] = useState("");
|
|
208
|
+
const [currentPage, setCurrentPage] = useState(0);
|
|
209
|
+
const [totalPage, setTotalPage] = useState(1);
|
|
210
|
+
const [progress, setProgress] = useState({ uploaded: 0, total: 100 });
|
|
211
|
+
const requestDebounce = useRef(-1);
|
|
212
|
+
useComponentEvent(engine, "file-select", async ({ path, isMounted }) => {
|
|
213
|
+
setSelectedPath(path);
|
|
214
|
+
if (!isMounted && // On initial mount
|
|
215
|
+
getFileList) {
|
|
216
|
+
const result = await getFileList(fileType, {
|
|
217
|
+
filter: "",
|
|
218
|
+
page: 0,
|
|
219
|
+
selected: path
|
|
220
|
+
});
|
|
221
|
+
setFileList(result.data);
|
|
222
|
+
setCurrentPage(result.pagination.current);
|
|
223
|
+
setTotalPage(result.pagination.total);
|
|
224
|
+
}
|
|
225
|
+
if (path.startsWith("blob:")) {
|
|
226
|
+
setFileList((prev) => [
|
|
227
|
+
{
|
|
228
|
+
fileId: "",
|
|
229
|
+
name: "",
|
|
230
|
+
size: 0,
|
|
231
|
+
timestamp: Date.now(),
|
|
232
|
+
url: path,
|
|
233
|
+
sizes: {}
|
|
234
|
+
},
|
|
235
|
+
...prev.filter((file) => !file.url.startsWith("blob:"))
|
|
236
|
+
]);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
useComponentEvent(engine, "file-upload-progress", (p) => {
|
|
240
|
+
if (p.blob === selectedPath) {
|
|
241
|
+
setProgress({ uploaded: p.uploaded, total: p.total });
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
useComponentEvent(engine, "file-listup", ({ data }) => {
|
|
245
|
+
setFileList(data);
|
|
246
|
+
});
|
|
247
|
+
const paginate = (page) => {
|
|
248
|
+
page = Number.isNaN(page) ? 0 : Math.min(Math.max(0, page), totalPage - 1);
|
|
249
|
+
if (currentPage === page) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
setCurrentPage(page);
|
|
253
|
+
window.clearTimeout(requestDebounce.current);
|
|
254
|
+
requestDebounce.current = window.setTimeout(async () => {
|
|
255
|
+
const result = await getFileList?.(fileType, { page });
|
|
256
|
+
if (result) {
|
|
257
|
+
setFileList(result.data);
|
|
258
|
+
setCurrentPage(result.pagination.current);
|
|
259
|
+
setTotalPage(result.pagination.total);
|
|
260
|
+
}
|
|
261
|
+
}, 100);
|
|
262
|
+
};
|
|
263
|
+
const search = (value) => {
|
|
264
|
+
if (searchWord === value) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
setSearchWord(value);
|
|
268
|
+
window.clearTimeout(requestDebounce.current);
|
|
269
|
+
requestDebounce.current = window.setTimeout(async () => {
|
|
270
|
+
const result = await getFileList?.(fileType, { filter: value });
|
|
271
|
+
if (result) {
|
|
272
|
+
setFileList(result.data);
|
|
273
|
+
setCurrentPage(result.pagination.current);
|
|
274
|
+
setTotalPage(result.pagination.total);
|
|
275
|
+
}
|
|
276
|
+
}, 300);
|
|
277
|
+
};
|
|
278
|
+
const rootRef = useCommand({
|
|
279
|
+
"--paginate": (e) => {
|
|
280
|
+
const direction = e.source?.value;
|
|
281
|
+
paginate(direction === "prev" ? currentPage - 1 : currentPage + 1);
|
|
282
|
+
},
|
|
283
|
+
"--select-file": (e) => {
|
|
284
|
+
const source = e.source;
|
|
285
|
+
if (!source) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
engine.componentObserver.notify("file-select", {
|
|
289
|
+
path: source.value,
|
|
290
|
+
fileSize: Number(source.dataset["size"] ?? "0"),
|
|
291
|
+
isEmpty: false,
|
|
292
|
+
isMounted: true
|
|
293
|
+
});
|
|
294
|
+
},
|
|
295
|
+
"--delete-file": (e) => {
|
|
296
|
+
const url = e.source?.value;
|
|
297
|
+
if (!url) {
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
void (async () => {
|
|
301
|
+
const res = await deleteFile?.(fileType, url);
|
|
302
|
+
if (!res || res.error) {
|
|
303
|
+
throw new Error(`Failed to delete file: ${url}`);
|
|
304
|
+
}
|
|
305
|
+
const result = await getFileList?.(fileType, {
|
|
306
|
+
page: currentPage,
|
|
307
|
+
filter: searchWord
|
|
308
|
+
});
|
|
309
|
+
if (result) {
|
|
310
|
+
setFileList(result.data);
|
|
311
|
+
setCurrentPage(result.pagination.current);
|
|
312
|
+
setTotalPage(result.pagination.total);
|
|
313
|
+
}
|
|
314
|
+
})().catch(() => {
|
|
315
|
+
alert("ファイルの削除に失敗しました。");
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
const marked = (text) => {
|
|
320
|
+
if (!searchWord) {
|
|
321
|
+
return text;
|
|
322
|
+
}
|
|
323
|
+
const chars = text.split(searchWord);
|
|
324
|
+
return chars.map((char, i) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
325
|
+
i === 0 ? null : /* @__PURE__ */ jsx("mark", { children: searchWord }),
|
|
326
|
+
char
|
|
327
|
+
] }, char + i));
|
|
328
|
+
};
|
|
329
|
+
return /* @__PURE__ */ jsxs("div", { ref: rootRef, id: rootId, children: [
|
|
330
|
+
/* @__PURE__ */ jsxs("div", { className: styles$5["ctrl"], children: [
|
|
331
|
+
/* @__PURE__ */ jsxs("div", { className: styles$5["pagination"], children: [
|
|
332
|
+
/* @__PURE__ */ jsx(
|
|
333
|
+
"button",
|
|
334
|
+
{
|
|
335
|
+
type: "button",
|
|
336
|
+
disabled: currentPage === 0,
|
|
337
|
+
command: "--paginate",
|
|
338
|
+
commandfor: rootId,
|
|
339
|
+
value: "prev",
|
|
340
|
+
children: "前へ"
|
|
341
|
+
}
|
|
342
|
+
),
|
|
343
|
+
/* @__PURE__ */ jsxs("div", { className: styles$5["page"], children: [
|
|
344
|
+
/* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(
|
|
345
|
+
"input",
|
|
346
|
+
{
|
|
347
|
+
type: "number",
|
|
348
|
+
value: currentPage + 1,
|
|
349
|
+
min: "1",
|
|
350
|
+
max: totalPage,
|
|
351
|
+
onChange: (e) => paginate(e.currentTarget.valueAsNumber - 1),
|
|
352
|
+
"aria-label": "ページ番号"
|
|
353
|
+
}
|
|
354
|
+
) }),
|
|
355
|
+
/* @__PURE__ */ jsx("span", { children: "/" }),
|
|
356
|
+
/* @__PURE__ */ jsx("span", { children: totalPage })
|
|
357
|
+
] }),
|
|
358
|
+
/* @__PURE__ */ jsx(
|
|
359
|
+
"button",
|
|
360
|
+
{
|
|
361
|
+
type: "button",
|
|
362
|
+
disabled: currentPage === totalPage - 1,
|
|
363
|
+
command: "--paginate",
|
|
364
|
+
commandfor: rootId,
|
|
365
|
+
value: "next",
|
|
366
|
+
children: "次へ"
|
|
367
|
+
}
|
|
368
|
+
)
|
|
369
|
+
] }),
|
|
370
|
+
/* @__PURE__ */ jsx(
|
|
371
|
+
"input",
|
|
372
|
+
{
|
|
373
|
+
type: "search",
|
|
374
|
+
placeholder: "検索",
|
|
375
|
+
value: searchWord,
|
|
376
|
+
onChange: (e) => search(e.currentTarget.value)
|
|
377
|
+
}
|
|
378
|
+
)
|
|
379
|
+
] }),
|
|
380
|
+
/* @__PURE__ */ jsx("ul", { className: styles$5["list"], children: fileList.map((file) => /* @__PURE__ */ jsxs("li", { children: [
|
|
381
|
+
/* @__PURE__ */ jsxs(
|
|
382
|
+
"button",
|
|
383
|
+
{
|
|
384
|
+
ref: file.url === selectedPath ? scrollToSelected : void 0,
|
|
385
|
+
className: styles$5["file"],
|
|
386
|
+
type: "button",
|
|
387
|
+
"aria-pressed": file.url === selectedPath,
|
|
388
|
+
command: "--select-file",
|
|
389
|
+
commandfor: rootId,
|
|
390
|
+
value: file.url,
|
|
391
|
+
"data-size": file.size,
|
|
392
|
+
children: [
|
|
393
|
+
/* @__PURE__ */ jsx("span", { className: styles$5["thumbnail"], children: /* @__PURE__ */ jsx(Thumbnail, { src: file.url }) }),
|
|
394
|
+
file.url.startsWith("blob:") ? /* @__PURE__ */ jsxs("span", { children: [
|
|
395
|
+
"アップロード中...",
|
|
396
|
+
" ",
|
|
397
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
398
|
+
Math.floor(progress.uploaded / progress.total * 100),
|
|
399
|
+
"%"
|
|
400
|
+
] })
|
|
401
|
+
] }) : /* @__PURE__ */ jsxs("span", { className: styles$5["attr"], children: [
|
|
402
|
+
/* @__PURE__ */ jsx("span", { children: "ID" }),
|
|
403
|
+
/* @__PURE__ */ jsx("span", { children: marked(file.fileId) }),
|
|
404
|
+
/* @__PURE__ */ jsx("span", { children: "名称" }),
|
|
405
|
+
/* @__PURE__ */ jsx("span", { children: marked(file.name) }),
|
|
406
|
+
/* @__PURE__ */ jsx("span", { children: "更新" }),
|
|
407
|
+
/* @__PURE__ */ jsx("span", { children: formatDate(file.timestamp / 1e3, "YYYY-MM-DD HH:mm") }),
|
|
408
|
+
/* @__PURE__ */ jsx("span", { children: "サイズ" }),
|
|
409
|
+
/* @__PURE__ */ jsx("span", { children: formatByteSize(file.size) })
|
|
410
|
+
] })
|
|
411
|
+
]
|
|
412
|
+
}
|
|
413
|
+
),
|
|
414
|
+
!file.url.startsWith("blob:") && deleteFile ? /* @__PURE__ */ jsx(
|
|
415
|
+
"button",
|
|
416
|
+
{
|
|
417
|
+
className: styles$5["delete"],
|
|
418
|
+
type: "button",
|
|
419
|
+
command: "--delete-file",
|
|
420
|
+
commandfor: rootId,
|
|
421
|
+
value: file.url,
|
|
422
|
+
children: "削除"
|
|
423
|
+
}
|
|
424
|
+
) : null
|
|
425
|
+
] }, file.url)) })
|
|
426
|
+
] });
|
|
427
|
+
}
|
|
428
|
+
function scrollToSelected(el) {
|
|
429
|
+
el?.scrollIntoView({
|
|
430
|
+
behavior: "smooth",
|
|
431
|
+
block: "nearest"
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
const uploader = "_uploader_obiwu_1";
|
|
436
|
+
const styles$3 = {
|
|
437
|
+
uploader: uploader
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
function FileUploader({
|
|
441
|
+
engine,
|
|
442
|
+
fileType
|
|
443
|
+
}) {
|
|
444
|
+
const rootId = useId();
|
|
445
|
+
const inputRef = useRef(null);
|
|
446
|
+
const accept = fileType === "image" ? "image/*" : "*";
|
|
447
|
+
const rootRef = useCommand({
|
|
448
|
+
"--open-file-picker": () => {
|
|
449
|
+
inputRef.current?.showPicker();
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
const stageFile = async () => {
|
|
453
|
+
const inputFile = inputRef.current;
|
|
454
|
+
const file = inputFile?.files?.[0];
|
|
455
|
+
if (!file) {
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
const path = URL.createObjectURL(file);
|
|
459
|
+
engine.componentObserver.notify("file-select", {
|
|
460
|
+
path,
|
|
461
|
+
fileSize: file.size,
|
|
462
|
+
isEmpty: false
|
|
463
|
+
});
|
|
464
|
+
try {
|
|
465
|
+
const res = await engine.serverAPI.postFile?.(fileType, file, (uploaded, total) => {
|
|
466
|
+
engine.componentObserver.notify("file-upload-progress", {
|
|
467
|
+
blob: path,
|
|
468
|
+
uploaded,
|
|
469
|
+
total
|
|
470
|
+
});
|
|
471
|
+
});
|
|
472
|
+
if (!res || res.error) {
|
|
473
|
+
throw new Error(`Failed to upload file: ${file.name}`);
|
|
474
|
+
}
|
|
475
|
+
engine.componentObserver.notify("file-listup", {
|
|
476
|
+
fileType,
|
|
477
|
+
data: [res.uploaded]
|
|
478
|
+
});
|
|
479
|
+
engine.componentObserver.notify("file-select", {
|
|
480
|
+
path: res.uploaded.url,
|
|
481
|
+
fileSize: res.uploaded.size,
|
|
482
|
+
isEmpty: false
|
|
483
|
+
});
|
|
484
|
+
} catch {
|
|
485
|
+
alert(`ファイルのアップロードに失敗しました: ${file.name}`);
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
return /* @__PURE__ */ jsxs("div", { ref: rootRef, id: rootId, className: styles$3["uploader"], children: [
|
|
489
|
+
/* @__PURE__ */ jsx(
|
|
490
|
+
"input",
|
|
491
|
+
{
|
|
492
|
+
type: "file",
|
|
493
|
+
ref: inputRef,
|
|
494
|
+
onChange: () => void stageFile(),
|
|
495
|
+
accept
|
|
496
|
+
}
|
|
497
|
+
),
|
|
498
|
+
/* @__PURE__ */ jsx("button", { type: "button", command: "--open-file-picker", commandfor: rootId, children: "ファイルを追加アップロードする" })
|
|
499
|
+
] });
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
const img = "_img_18j28_1";
|
|
503
|
+
const uploading = "_uploading_18j28_26";
|
|
504
|
+
const progress = "_progress_18j28_30";
|
|
505
|
+
const meta = "_meta_18j28_40";
|
|
506
|
+
const path = "_path_18j28_60";
|
|
507
|
+
const upload = "_upload_18j28_26";
|
|
508
|
+
const dimension = "_dimension_18j28_72";
|
|
509
|
+
const styles$2 = {
|
|
510
|
+
img: img,
|
|
511
|
+
uploading: uploading,
|
|
512
|
+
progress: progress,
|
|
513
|
+
meta: meta,
|
|
514
|
+
path: path,
|
|
515
|
+
upload: upload,
|
|
516
|
+
dimension: dimension
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
function Preview({
|
|
520
|
+
engine,
|
|
521
|
+
path
|
|
522
|
+
}) {
|
|
523
|
+
const [dimension, setDimension] = useState(null);
|
|
524
|
+
const [progress, setProgress] = useState({ uploaded: 0, total: 100 });
|
|
525
|
+
const [prevPath, setPrevPath] = useState(path);
|
|
526
|
+
if (prevPath !== path) {
|
|
527
|
+
setPrevPath(path);
|
|
528
|
+
setDimension(null);
|
|
529
|
+
}
|
|
530
|
+
const file = path ? getExt(path) : null;
|
|
531
|
+
const isUploadingMode = path.startsWith("blob:");
|
|
532
|
+
useComponentEvent(engine, "file-upload-progress", (p) => {
|
|
533
|
+
if (p.blob === path) {
|
|
534
|
+
setProgress({ uploaded: p.uploaded, total: p.total });
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
useEffect(() => {
|
|
538
|
+
const file2 = path ? getExt(path) : null;
|
|
539
|
+
let aborted = false;
|
|
540
|
+
if (file2?.isImage) {
|
|
541
|
+
const image = new Image();
|
|
542
|
+
image.src = path;
|
|
543
|
+
image.addEventListener(
|
|
544
|
+
"load",
|
|
545
|
+
() => {
|
|
546
|
+
if (!aborted) {
|
|
547
|
+
setDimension({ width: image.naturalWidth, height: image.naturalHeight });
|
|
548
|
+
}
|
|
549
|
+
},
|
|
550
|
+
{ once: true }
|
|
551
|
+
);
|
|
552
|
+
} else if (file2?.isVideo) {
|
|
553
|
+
const video = document.createElement("video");
|
|
554
|
+
video.src = path;
|
|
555
|
+
video.addEventListener(
|
|
556
|
+
"loadedmetadata",
|
|
557
|
+
() => {
|
|
558
|
+
if (!aborted) {
|
|
559
|
+
setDimension({ width: video.videoWidth, height: video.videoHeight });
|
|
560
|
+
}
|
|
561
|
+
},
|
|
562
|
+
{ once: true }
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
return () => {
|
|
566
|
+
aborted = true;
|
|
567
|
+
};
|
|
568
|
+
}, [path]);
|
|
569
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
570
|
+
/* @__PURE__ */ jsxs(
|
|
571
|
+
"div",
|
|
572
|
+
{
|
|
573
|
+
className: `${styles$2["img"]} ${isUploadingMode ? styles$2["uploading"] : ""}`.trim(),
|
|
574
|
+
children: [
|
|
575
|
+
file?.isImage ? /* @__PURE__ */ jsx("img", { src: path, alt: "画像プレビュー" }) : file?.isVideo ? /* @__PURE__ */ jsxs("video", { controls: true, playsInline: true, children: [
|
|
576
|
+
/* @__PURE__ */ jsx("source", { src: path, type: `video/${file.ext}` }),
|
|
577
|
+
/* @__PURE__ */ jsx("track", { kind: "captions", src: "" })
|
|
578
|
+
] }) : file?.isAudio ? /* @__PURE__ */ jsxs("audio", { controls: true, children: [
|
|
579
|
+
/* @__PURE__ */ jsx("source", { src: path, type: `audio/${file.ext}` }),
|
|
580
|
+
/* @__PURE__ */ jsx("track", { kind: "metadata", src: "" })
|
|
581
|
+
] }) : file?.isDoc || file?.isPpt || file?.isXls || file?.isPdf ? /* @__PURE__ */ jsx(
|
|
582
|
+
"object",
|
|
583
|
+
{
|
|
584
|
+
data: path,
|
|
585
|
+
type: `application/${file.ext}`,
|
|
586
|
+
title: `${file.ext}ファイルのプレビュー`,
|
|
587
|
+
children: /* @__PURE__ */ jsx("p", { children: "プレビューできません" })
|
|
588
|
+
}
|
|
589
|
+
) : /* @__PURE__ */ jsx("p", { children: "プレビューできません" }),
|
|
590
|
+
isUploadingMode ? /* @__PURE__ */ jsx(
|
|
591
|
+
"div",
|
|
592
|
+
{
|
|
593
|
+
className: styles$2["progress"],
|
|
594
|
+
style: { translate: `${progress.uploaded / progress.total * 100}%` }
|
|
595
|
+
}
|
|
596
|
+
) : null
|
|
597
|
+
]
|
|
598
|
+
}
|
|
599
|
+
),
|
|
600
|
+
/* @__PURE__ */ jsxs("ul", { className: styles$2["meta"], children: [
|
|
601
|
+
isUploadingMode ? /* @__PURE__ */ jsxs("li", { className: styles$2["upload"], children: [
|
|
602
|
+
/* @__PURE__ */ jsx("span", { children: "アップロード..." }),
|
|
603
|
+
/* @__PURE__ */ jsxs("span", { className: styles$2["progress"], children: [
|
|
604
|
+
Math.round(progress.uploaded / progress.total * 100),
|
|
605
|
+
"% (",
|
|
606
|
+
progress.uploaded,
|
|
607
|
+
"/",
|
|
608
|
+
progress.total,
|
|
609
|
+
")"
|
|
610
|
+
] })
|
|
611
|
+
] }) : /* @__PURE__ */ jsx("li", { className: styles$2["path"], children: /* @__PURE__ */ jsx("a", { href: path, target: "_blank", children: path }) }),
|
|
612
|
+
dimension ? /* @__PURE__ */ jsxs("li", { className: styles$2["dimension"], children: [
|
|
613
|
+
dimension.width,
|
|
614
|
+
"x",
|
|
615
|
+
dimension.height
|
|
616
|
+
] }) : null
|
|
617
|
+
] })
|
|
618
|
+
] });
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
const table = "_table_1qb61_1";
|
|
622
|
+
const row = "_row_1qb61_7";
|
|
623
|
+
const btn = "_btn_1qb61_19";
|
|
624
|
+
const styles$1 = {
|
|
625
|
+
table: table,
|
|
626
|
+
row: row,
|
|
627
|
+
btn: btn
|
|
628
|
+
};
|
|
629
|
+
|
|
630
|
+
function TableEditor({
|
|
631
|
+
value,
|
|
632
|
+
onChange
|
|
633
|
+
}) {
|
|
634
|
+
const rootId = useId();
|
|
635
|
+
const rows = value.th.map((th, i) => [
|
|
636
|
+
th,
|
|
637
|
+
value.td[i] ?? ""
|
|
638
|
+
]);
|
|
639
|
+
const commit = (next) => {
|
|
640
|
+
onChange({
|
|
641
|
+
th: next.map(([th]) => th),
|
|
642
|
+
td: next.map(([, td]) => td)
|
|
643
|
+
});
|
|
644
|
+
};
|
|
645
|
+
const rootRef = useCommand({
|
|
646
|
+
"--add-row": (e) => {
|
|
647
|
+
const index = Number(e.source?.value);
|
|
648
|
+
commit(rows.toSpliced(index + 1, 0, ["", ""]));
|
|
649
|
+
},
|
|
650
|
+
"--remove-row": (e) => {
|
|
651
|
+
const index = Number(e.source?.value);
|
|
652
|
+
commit(rows.toSpliced(index, 1));
|
|
653
|
+
},
|
|
654
|
+
"--move-row-down": (e) => {
|
|
655
|
+
const from = Number(e.source?.value);
|
|
656
|
+
const to = from + 1;
|
|
657
|
+
const fromRow = rows[from];
|
|
658
|
+
const toRow = rows[to];
|
|
659
|
+
if (!fromRow || !toRow) {
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
commit(rows.toSpliced(from, 1, toRow).toSpliced(to, 1, fromRow));
|
|
663
|
+
}
|
|
664
|
+
});
|
|
665
|
+
return /* @__PURE__ */ jsx("div", { className: styles$1["table"], ref: rootRef, id: rootId, children: rows.map(([th, td], i) => /* @__PURE__ */ jsxs("div", { className: styles$1["row"], children: [
|
|
666
|
+
/* @__PURE__ */ jsx("div", { className: styles$1["th"], children: /* @__PURE__ */ jsx(
|
|
667
|
+
"textarea",
|
|
668
|
+
{
|
|
669
|
+
"aria-label": `${i}行目の見出しセル`,
|
|
670
|
+
name: `bge-th-${i}`,
|
|
671
|
+
value: th,
|
|
672
|
+
onChange: (e) => {
|
|
673
|
+
commit(rows.with(i, [e.currentTarget.value, td]));
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
) }),
|
|
677
|
+
/* @__PURE__ */ jsx("div", { className: styles$1["td"], children: /* @__PURE__ */ jsx(
|
|
678
|
+
"textarea",
|
|
679
|
+
{
|
|
680
|
+
"aria-label": `${i}行目の内容セル`,
|
|
681
|
+
name: `bge-td-${i}`,
|
|
682
|
+
value: td,
|
|
683
|
+
onChange: (e) => {
|
|
684
|
+
commit(rows.with(i, [th, e.currentTarget.value]));
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
) }),
|
|
688
|
+
/* @__PURE__ */ jsx("div", { className: styles$1["btn"], children: /* @__PURE__ */ jsxs("ul", { children: [
|
|
689
|
+
/* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
|
|
690
|
+
"button",
|
|
691
|
+
{
|
|
692
|
+
type: "button",
|
|
693
|
+
title: "下に追加",
|
|
694
|
+
command: "--add-row",
|
|
695
|
+
commandfor: rootId,
|
|
696
|
+
value: i,
|
|
697
|
+
children: /* @__PURE__ */ jsx(IconRowInsertBottom, {})
|
|
698
|
+
}
|
|
699
|
+
) }),
|
|
700
|
+
/* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
|
|
701
|
+
"button",
|
|
702
|
+
{
|
|
703
|
+
type: "button",
|
|
704
|
+
title: "削除",
|
|
705
|
+
disabled: rows.length === 1,
|
|
706
|
+
command: "--remove-row",
|
|
707
|
+
commandfor: rootId,
|
|
708
|
+
value: i,
|
|
709
|
+
children: /* @__PURE__ */ jsx(IconTrash, {})
|
|
710
|
+
}
|
|
711
|
+
) }),
|
|
712
|
+
/* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
|
|
713
|
+
"button",
|
|
714
|
+
{
|
|
715
|
+
type: "button",
|
|
716
|
+
title: "下に移動",
|
|
717
|
+
disabled: i === rows.length - 1,
|
|
718
|
+
command: "--move-row-down",
|
|
719
|
+
commandfor: rootId,
|
|
720
|
+
value: i,
|
|
721
|
+
children: /* @__PURE__ */ jsx(IconArrowsTransferDown, { className: "icon" })
|
|
722
|
+
}
|
|
723
|
+
) })
|
|
724
|
+
] }) })
|
|
725
|
+
] }, i)) });
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
const tablist = "_tablist_1hyld_1";
|
|
729
|
+
const styles = {
|
|
730
|
+
tablist: tablist
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
function Tabs({
|
|
734
|
+
current,
|
|
735
|
+
onChange,
|
|
736
|
+
contentId,
|
|
737
|
+
length = 2,
|
|
738
|
+
createLabel = (index) => `画像${index + 1}`
|
|
739
|
+
}) {
|
|
740
|
+
const listId = useId();
|
|
741
|
+
const refs = useRef([]);
|
|
742
|
+
const update = (index) => {
|
|
743
|
+
refs.current[index]?.focus();
|
|
744
|
+
onChange(index);
|
|
745
|
+
};
|
|
746
|
+
const rootRef = useCommand({
|
|
747
|
+
"--select-tab": (e) => {
|
|
748
|
+
const value = e.source?.value;
|
|
749
|
+
update(Number(value));
|
|
750
|
+
}
|
|
751
|
+
});
|
|
752
|
+
const onKeyDown = (event) => {
|
|
753
|
+
if (event.key === "ArrowLeft") {
|
|
754
|
+
update(Math.max(0, current - 1));
|
|
755
|
+
} else if (event.key === "ArrowRight") {
|
|
756
|
+
update(Math.min(length - 1, current + 1));
|
|
757
|
+
}
|
|
758
|
+
};
|
|
759
|
+
return /* @__PURE__ */ jsx("div", { role: "tablist", ref: rootRef, id: listId, className: styles["tablist"], children: Array.from({ length }, (_, index) => /* @__PURE__ */ jsx(
|
|
760
|
+
"button",
|
|
761
|
+
{
|
|
762
|
+
ref: (el) => {
|
|
763
|
+
refs.current[index] = el;
|
|
764
|
+
},
|
|
765
|
+
type: "button",
|
|
766
|
+
role: "tab",
|
|
767
|
+
"aria-controls": contentId,
|
|
768
|
+
"aria-selected": current === index,
|
|
769
|
+
tabIndex: current === index ? 0 : -1,
|
|
770
|
+
command: "--select-tab",
|
|
771
|
+
commandfor: listId,
|
|
772
|
+
value: index,
|
|
773
|
+
onKeyDown,
|
|
774
|
+
children: createLabel(index)
|
|
775
|
+
},
|
|
776
|
+
index
|
|
777
|
+
)) });
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
function WysiwygField({
|
|
781
|
+
value,
|
|
782
|
+
onChange,
|
|
783
|
+
itemName,
|
|
784
|
+
commands,
|
|
785
|
+
label
|
|
786
|
+
}) {
|
|
787
|
+
const ref = useRef(null);
|
|
788
|
+
const initialValue = useRef(value);
|
|
789
|
+
const onChangeRef = useRef(onChange);
|
|
790
|
+
useEffect(() => {
|
|
791
|
+
onChangeRef.current = onChange;
|
|
792
|
+
});
|
|
793
|
+
useEffect(() => {
|
|
794
|
+
const el = ref.current;
|
|
795
|
+
if (!el) {
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
el.innerHTML = initialValue.current;
|
|
799
|
+
const inner = el.querySelector("bge-wysiwyg");
|
|
800
|
+
const onTransaction = () => {
|
|
801
|
+
onChangeRef.current(el.value);
|
|
802
|
+
};
|
|
803
|
+
inner?.addEventListener("transaction", onTransaction);
|
|
804
|
+
return () => {
|
|
805
|
+
inner?.removeEventListener("transaction", onTransaction);
|
|
806
|
+
};
|
|
807
|
+
}, []);
|
|
808
|
+
return /* @__PURE__ */ jsx(
|
|
809
|
+
"bge-wysiwyg-editor",
|
|
810
|
+
{
|
|
811
|
+
ref: (el) => {
|
|
812
|
+
ref.current = el;
|
|
813
|
+
},
|
|
814
|
+
"item-name": itemName,
|
|
815
|
+
commands,
|
|
816
|
+
label
|
|
817
|
+
}
|
|
818
|
+
);
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
function Checkbox({
|
|
822
|
+
label,
|
|
823
|
+
checked,
|
|
824
|
+
onChange,
|
|
825
|
+
name,
|
|
826
|
+
disabled,
|
|
827
|
+
describedBy
|
|
828
|
+
}) {
|
|
829
|
+
return /* @__PURE__ */ jsxs("label", { children: [
|
|
830
|
+
/* @__PURE__ */ jsx(
|
|
831
|
+
"input",
|
|
832
|
+
{
|
|
833
|
+
type: "checkbox",
|
|
834
|
+
name,
|
|
835
|
+
checked,
|
|
836
|
+
disabled,
|
|
837
|
+
"aria-describedby": describedBy,
|
|
838
|
+
onChange: (e) => onChange(e.currentTarget.checked)
|
|
839
|
+
}
|
|
840
|
+
),
|
|
841
|
+
label
|
|
842
|
+
] });
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
function Fieldset({
|
|
846
|
+
legend,
|
|
847
|
+
id,
|
|
848
|
+
disabled,
|
|
849
|
+
children
|
|
850
|
+
}) {
|
|
851
|
+
return /* @__PURE__ */ jsxs("fieldset", { id, disabled, children: [
|
|
852
|
+
/* @__PURE__ */ jsx("legend", { children: legend }),
|
|
853
|
+
children
|
|
854
|
+
] });
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
function NumberField({
|
|
858
|
+
label,
|
|
859
|
+
value,
|
|
860
|
+
onChange,
|
|
861
|
+
name,
|
|
862
|
+
min,
|
|
863
|
+
max,
|
|
864
|
+
step,
|
|
865
|
+
disabled
|
|
866
|
+
}) {
|
|
867
|
+
return /* @__PURE__ */ jsxs("label", { children: [
|
|
868
|
+
/* @__PURE__ */ jsx("span", { children: label }),
|
|
869
|
+
/* @__PURE__ */ jsx(
|
|
870
|
+
"input",
|
|
871
|
+
{
|
|
872
|
+
type: "number",
|
|
873
|
+
name,
|
|
874
|
+
value: Number.isFinite(value) ? value : "",
|
|
875
|
+
min,
|
|
876
|
+
max,
|
|
877
|
+
step,
|
|
878
|
+
disabled,
|
|
879
|
+
onChange: (e) => onChange(e.currentTarget.valueAsNumber)
|
|
880
|
+
}
|
|
881
|
+
)
|
|
882
|
+
] });
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
function RadioGroup({
|
|
886
|
+
label,
|
|
887
|
+
value,
|
|
888
|
+
onChange,
|
|
889
|
+
options,
|
|
890
|
+
name,
|
|
891
|
+
disabled
|
|
892
|
+
}) {
|
|
893
|
+
const labelId = useId();
|
|
894
|
+
return /* @__PURE__ */ jsxs("div", { role: "radiogroup", "aria-labelledby": labelId, children: [
|
|
895
|
+
/* @__PURE__ */ jsx("div", { id: labelId, children: label }),
|
|
896
|
+
options.map((option) => /* @__PURE__ */ jsxs("label", { children: [
|
|
897
|
+
/* @__PURE__ */ jsx(
|
|
898
|
+
"input",
|
|
899
|
+
{
|
|
900
|
+
type: "radio",
|
|
901
|
+
name,
|
|
902
|
+
value: option.value,
|
|
903
|
+
checked: value === option.value,
|
|
904
|
+
disabled,
|
|
905
|
+
onChange: (e) => {
|
|
906
|
+
if (e.currentTarget.checked) {
|
|
907
|
+
onChange(option.value);
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
),
|
|
912
|
+
option.label
|
|
913
|
+
] }, option.value))
|
|
914
|
+
] });
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
function SelectField({
|
|
918
|
+
label,
|
|
919
|
+
value,
|
|
920
|
+
onChange,
|
|
921
|
+
options,
|
|
922
|
+
name,
|
|
923
|
+
disabled
|
|
924
|
+
}) {
|
|
925
|
+
return /* @__PURE__ */ jsxs("label", { children: [
|
|
926
|
+
/* @__PURE__ */ jsx("span", { children: label }),
|
|
927
|
+
/* @__PURE__ */ jsx(
|
|
928
|
+
"select",
|
|
929
|
+
{
|
|
930
|
+
name,
|
|
931
|
+
value,
|
|
932
|
+
disabled,
|
|
933
|
+
onChange: (e) => onChange(e.currentTarget.value),
|
|
934
|
+
children: options.map((option) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, option.value))
|
|
935
|
+
}
|
|
936
|
+
)
|
|
937
|
+
] });
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
function TextArea({
|
|
941
|
+
label,
|
|
942
|
+
value,
|
|
943
|
+
onChange,
|
|
944
|
+
name,
|
|
945
|
+
rows,
|
|
946
|
+
disabled
|
|
947
|
+
}) {
|
|
948
|
+
return /* @__PURE__ */ jsxs("label", { children: [
|
|
949
|
+
/* @__PURE__ */ jsx("span", { children: label }),
|
|
950
|
+
/* @__PURE__ */ jsx(
|
|
951
|
+
"textarea",
|
|
952
|
+
{
|
|
953
|
+
name,
|
|
954
|
+
value,
|
|
955
|
+
rows,
|
|
956
|
+
disabled,
|
|
957
|
+
onChange: (e) => onChange(e.currentTarget.value)
|
|
958
|
+
}
|
|
959
|
+
)
|
|
960
|
+
] });
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
function TextField({
|
|
964
|
+
label,
|
|
965
|
+
value,
|
|
966
|
+
onChange,
|
|
967
|
+
type = "text",
|
|
968
|
+
name,
|
|
969
|
+
disabled,
|
|
970
|
+
placeholder
|
|
971
|
+
}) {
|
|
972
|
+
return /* @__PURE__ */ jsxs("label", { children: [
|
|
973
|
+
/* @__PURE__ */ jsx("span", { children: label }),
|
|
974
|
+
/* @__PURE__ */ jsx(
|
|
975
|
+
"input",
|
|
976
|
+
{
|
|
977
|
+
type,
|
|
978
|
+
name,
|
|
979
|
+
value,
|
|
980
|
+
disabled,
|
|
981
|
+
placeholder,
|
|
982
|
+
onChange: (e) => onChange(e.currentTarget.value)
|
|
983
|
+
}
|
|
984
|
+
)
|
|
985
|
+
] });
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
export { Checkbox, Fieldset, FileList, FileUploader, NumberField, Preview, RadioGroup, SelectField, TableEditor, Tabs, TextArea, TextField, Thumbnail, WysiwygField, useCommand, useComponentEvent };
|
|
989
|
+
//# sourceMappingURL=ui.js.map
|