one-design-next 0.0.41 → 0.0.42
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.
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
import HoverFill from "../hover-fill";
|
|
3
3
|
import Icon from "../icon";
|
|
4
|
+
import Image from "../image";
|
|
5
|
+
import Tooltip from "../tooltip";
|
|
4
6
|
import "./style";
|
|
5
7
|
var categoryMap = {
|
|
6
8
|
sheet: {
|
|
@@ -127,18 +129,24 @@ function formatSize(bytes) {
|
|
|
127
129
|
if (bytes < 1024 * 1024) return "".concat((bytes / 1024).toFixed(1), " KB");
|
|
128
130
|
return "".concat((bytes / (1024 * 1024)).toFixed(1), " MB");
|
|
129
131
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
132
|
+
|
|
133
|
+
/** image/* 附件缩略:统一走 Image leaf,不再内联裸 `<img>`。 */
|
|
134
|
+
function AttachmentImage(_ref) {
|
|
135
|
+
var attachment = _ref.attachment;
|
|
136
|
+
if (!attachment.url) return null;
|
|
137
|
+
return /*#__PURE__*/React.createElement(Image, {
|
|
138
|
+
url: attachment.url,
|
|
139
|
+
alt: attachment.name
|
|
140
|
+
});
|
|
133
141
|
}
|
|
134
|
-
export function Attachments(
|
|
135
|
-
var attachments =
|
|
136
|
-
onRemove =
|
|
137
|
-
onFileClick =
|
|
138
|
-
onRetry =
|
|
139
|
-
onDownload =
|
|
140
|
-
|
|
141
|
-
compact =
|
|
142
|
+
export function Attachments(_ref2) {
|
|
143
|
+
var attachments = _ref2.attachments,
|
|
144
|
+
onRemove = _ref2.onRemove,
|
|
145
|
+
onFileClick = _ref2.onFileClick,
|
|
146
|
+
onRetry = _ref2.onRetry,
|
|
147
|
+
onDownload = _ref2.onDownload,
|
|
148
|
+
_ref2$compact = _ref2.compact,
|
|
149
|
+
compact = _ref2$compact === void 0 ? false : _ref2$compact;
|
|
142
150
|
if (attachments.length === 0) return null;
|
|
143
151
|
|
|
144
152
|
/**
|
|
@@ -157,8 +165,7 @@ export function Attachments(_ref) {
|
|
|
157
165
|
var isUploading = status === 'uploading';
|
|
158
166
|
var isError = status === 'error';
|
|
159
167
|
var isExpired = status === 'expired';
|
|
160
|
-
var clickable = !!onFileClick && !isUploading && !isExpired;
|
|
161
|
-
var retryable = !!onRetry && isError;
|
|
168
|
+
var clickable = !!onFileClick && !isUploading && !isExpired && !isError;
|
|
162
169
|
var thumbCardInner = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
163
170
|
"data-odn-attachments-thumb-card-thumb": true,
|
|
164
171
|
style: isImage && !isUploading && !isError ? undefined : isUploading || isError ? undefined : {
|
|
@@ -177,9 +184,8 @@ export function Attachments(_ref) {
|
|
|
177
184
|
style: {
|
|
178
185
|
color: 'var(--odn-color-error)'
|
|
179
186
|
}
|
|
180
|
-
}) : isImage ? /*#__PURE__*/React.createElement(
|
|
181
|
-
|
|
182
|
-
alt: ""
|
|
187
|
+
}) : isImage ? /*#__PURE__*/React.createElement(AttachmentImage, {
|
|
188
|
+
attachment: a
|
|
183
189
|
}) : /*#__PURE__*/React.createElement(Icon, {
|
|
184
190
|
name: meta.icon,
|
|
185
191
|
size: 16,
|
|
@@ -192,8 +198,8 @@ export function Attachments(_ref) {
|
|
|
192
198
|
"data-odn-attachments-thumb-card-name": true
|
|
193
199
|
}, a.name), /*#__PURE__*/React.createElement("div", {
|
|
194
200
|
"data-odn-attachments-thumb-card-type": true
|
|
195
|
-
},
|
|
196
|
-
|
|
201
|
+
}, isExpired ? '已过期' : formatType(a.type, a.name))));
|
|
202
|
+
var cardEl = /*#__PURE__*/React.createElement("div", {
|
|
197
203
|
key: i,
|
|
198
204
|
"data-odn-attachments-item": true,
|
|
199
205
|
"data-odn-attachments-state": status,
|
|
@@ -206,17 +212,10 @@ export function Attachments(_ref) {
|
|
|
206
212
|
"data-odn-attachments-thumb-card": true,
|
|
207
213
|
"data-odn-attachments-thumb-card-image": isImage || undefined,
|
|
208
214
|
"data-odn-attachments-clickable": ""
|
|
209
|
-
}, thumbCardInner) : retryable ? /*#__PURE__*/React.createElement("button", {
|
|
210
|
-
type: "button",
|
|
211
|
-
onClick: function onClick() {
|
|
212
|
-
return onRetry(i);
|
|
213
|
-
},
|
|
214
|
-
"data-odn-attachments-thumb-card": true,
|
|
215
|
-
"data-odn-attachments-thumb-card-image": isImage || undefined,
|
|
216
|
-
"data-odn-attachments-retryable": ""
|
|
217
215
|
}, thumbCardInner) : /*#__PURE__*/React.createElement("div", {
|
|
218
216
|
"data-odn-attachments-thumb-card": true,
|
|
219
|
-
"data-odn-attachments-thumb-card-image": isImage || undefined
|
|
217
|
+
"data-odn-attachments-thumb-card-image": isImage || undefined,
|
|
218
|
+
"data-odn-attachments-error": isError || undefined
|
|
220
219
|
}, thumbCardInner), onRemove && /*#__PURE__*/React.createElement("button", {
|
|
221
220
|
onClick: function onClick() {
|
|
222
221
|
return onRemove(i);
|
|
@@ -226,10 +225,18 @@ export function Attachments(_ref) {
|
|
|
226
225
|
name: "x",
|
|
227
226
|
size: 10
|
|
228
227
|
})));
|
|
228
|
+
if (isError) {
|
|
229
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
230
|
+
key: i,
|
|
231
|
+
placement: "top",
|
|
232
|
+
popup: a.errorMessage || '上传失败'
|
|
233
|
+
}, cardEl);
|
|
234
|
+
}
|
|
235
|
+
return cardEl;
|
|
229
236
|
}
|
|
230
237
|
|
|
231
238
|
/**
|
|
232
|
-
* image-thumb
|
|
239
|
+
* image-thumb 渲染:纯图缩略方块(48×48 cover,与 file-card 等高)。
|
|
233
240
|
*
|
|
234
241
|
* 与文件信息卡(data-odn-attachments-card)严格同源——共享
|
|
235
242
|
* data-odn-attachments-state 三态机、remove 角标。composer 待发送区把 image/*
|
|
@@ -242,10 +249,9 @@ export function Attachments(_ref) {
|
|
|
242
249
|
var isError = status === 'error';
|
|
243
250
|
var isExpired = status === 'expired';
|
|
244
251
|
var clickable = !!onFileClick && !isUploading && !isError && !isExpired;
|
|
245
|
-
var thumb = /*#__PURE__*/React.createElement(
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
});
|
|
252
|
+
var thumb = a.url ? /*#__PURE__*/React.createElement(AttachmentImage, {
|
|
253
|
+
attachment: a
|
|
254
|
+
}) : null;
|
|
249
255
|
return /*#__PURE__*/React.createElement("div", {
|
|
250
256
|
key: i,
|
|
251
257
|
"data-odn-attachments-item": true,
|
|
@@ -266,25 +272,21 @@ export function Attachments(_ref) {
|
|
|
266
272
|
name: "loading",
|
|
267
273
|
size: 16,
|
|
268
274
|
spin: true
|
|
269
|
-
})), isError &&
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}, /*#__PURE__*/React.createElement(
|
|
278
|
-
name: "alert-triangle",
|
|
279
|
-
size: 16
|
|
280
|
-
}), /*#__PURE__*/React.createElement("span", null, "\u91CD\u8BD5")) : /*#__PURE__*/React.createElement("div", {
|
|
275
|
+
})), isError &&
|
|
276
|
+
/*#__PURE__*/
|
|
277
|
+
// 图片缩略方块太小塞不下错误文案:错误态只留居中的告警图标,
|
|
278
|
+
// 具体原因(errorMessage,来自业务层回写)走 hover 向上的 Tooltip。
|
|
279
|
+
// 图片上传不支持重试——overlay 不承载点击。
|
|
280
|
+
React.createElement(Tooltip, {
|
|
281
|
+
placement: "top",
|
|
282
|
+
popup: a.errorMessage || '上传失败'
|
|
283
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
281
284
|
"data-odn-attachments-image-overlay": true,
|
|
282
|
-
"data-odn-attachments-image-overlay-error": ""
|
|
283
|
-
title: a.errorMessage || '上传失败'
|
|
285
|
+
"data-odn-attachments-image-overlay-error": ""
|
|
284
286
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
285
287
|
name: "alert-triangle",
|
|
286
288
|
size: 16
|
|
287
|
-
})
|
|
289
|
+
}))), onRemove && /*#__PURE__*/React.createElement("button", {
|
|
288
290
|
onClick: function onClick() {
|
|
289
291
|
return onRemove(i);
|
|
290
292
|
},
|
|
@@ -427,8 +429,7 @@ export function Attachments(_ref) {
|
|
|
427
429
|
var isUploading = status === 'uploading';
|
|
428
430
|
var isError = status === 'error';
|
|
429
431
|
var isExpired = status === 'expired';
|
|
430
|
-
var clickable = !!onFileClick && !isUploading && !isExpired;
|
|
431
|
-
var retryable = !!onRetry && isError;
|
|
432
|
+
var clickable = !!onFileClick && !isUploading && !isExpired && !isError;
|
|
432
433
|
var fileCardInner = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
433
434
|
"data-odn-attachments-file-icon": true,
|
|
434
435
|
style: isUploading || isError ? undefined : {
|
|
@@ -459,8 +460,8 @@ export function Attachments(_ref) {
|
|
|
459
460
|
"data-odn-attachments-name": true
|
|
460
461
|
}, a.name), /*#__PURE__*/React.createElement("div", {
|
|
461
462
|
"data-odn-attachments-meta": true
|
|
462
|
-
},
|
|
463
|
-
|
|
463
|
+
}, isExpired ? '已过期' : "".concat(formatType(a.type, a.name)).concat(a.size ? " \xB7 ".concat(formatSize(a.size)) : ''))));
|
|
464
|
+
var cardEl = /*#__PURE__*/React.createElement("div", _extends({
|
|
464
465
|
key: i,
|
|
465
466
|
"data-odn-attachments-item": true,
|
|
466
467
|
"data-odn-attachments-state": status
|
|
@@ -473,15 +474,9 @@ export function Attachments(_ref) {
|
|
|
473
474
|
},
|
|
474
475
|
"data-odn-attachments-card": true,
|
|
475
476
|
"data-odn-attachments-clickable": ""
|
|
476
|
-
}, fileCardInner) : retryable ? /*#__PURE__*/React.createElement("button", {
|
|
477
|
-
type: "button",
|
|
478
|
-
onClick: function onClick() {
|
|
479
|
-
return onRetry(i);
|
|
480
|
-
},
|
|
481
|
-
"data-odn-attachments-card": true,
|
|
482
|
-
"data-odn-attachments-retryable": ""
|
|
483
477
|
}, fileCardInner) : /*#__PURE__*/React.createElement("div", {
|
|
484
|
-
"data-odn-attachments-card": true
|
|
478
|
+
"data-odn-attachments-card": true,
|
|
479
|
+
"data-odn-attachments-error": isError || undefined
|
|
485
480
|
}, fileCardInner), onRemove && /*#__PURE__*/React.createElement("button", {
|
|
486
481
|
onClick: function onClick() {
|
|
487
482
|
return onRemove(i);
|
|
@@ -491,6 +486,14 @@ export function Attachments(_ref) {
|
|
|
491
486
|
name: "x",
|
|
492
487
|
size: 10
|
|
493
488
|
})));
|
|
489
|
+
if (isError) {
|
|
490
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
491
|
+
key: i,
|
|
492
|
+
placement: "top",
|
|
493
|
+
popup: a.errorMessage || '上传失败'
|
|
494
|
+
}, cardEl);
|
|
495
|
+
}
|
|
496
|
+
return cardEl;
|
|
494
497
|
}));
|
|
495
498
|
}
|
|
496
499
|
Attachments.displayName = 'Attachments';
|
|
@@ -83,15 +83,8 @@
|
|
|
83
83
|
[data-odn-attachments-card][data-odn-attachments-clickable]:hover {
|
|
84
84
|
border-color: color-mix(in srgb, var(--odn-color-primary) 50%, transparent);
|
|
85
85
|
}
|
|
86
|
-
[data-odn-attachments-card][data-odn-attachments-
|
|
87
|
-
|
|
88
|
-
border: 1px solid color-mix(in srgb, var(--odn-color-error) 35%, var(--odn-color-black-6));
|
|
89
|
-
font: inherit;
|
|
90
|
-
text-align: left;
|
|
91
|
-
appearance: none;
|
|
92
|
-
}
|
|
93
|
-
[data-odn-attachments-card][data-odn-attachments-retryable]:hover {
|
|
94
|
-
border-color: color-mix(in srgb, var(--odn-color-error) 55%, transparent);
|
|
86
|
+
[data-odn-attachments-card][data-odn-attachments-error] {
|
|
87
|
+
border-color: color-mix(in srgb, var(--odn-color-error) 35%, var(--odn-color-black-6));
|
|
95
88
|
}
|
|
96
89
|
|
|
97
90
|
[data-odn-attachments-file-icon] {
|
|
@@ -133,10 +126,6 @@
|
|
|
133
126
|
color: var(--odn-color-black-8);
|
|
134
127
|
}
|
|
135
128
|
|
|
136
|
-
[data-odn-attachments-item][data-odn-attachments-state=error] [data-odn-attachments-meta] {
|
|
137
|
-
color: var(--odn-color-error);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
129
|
[data-odn-attachments-item][data-odn-attachments-state=expired] {
|
|
141
130
|
opacity: 0.55;
|
|
142
131
|
}
|
|
@@ -190,7 +179,7 @@
|
|
|
190
179
|
grid-template-columns: auto 1fr;
|
|
191
180
|
gap: 8px;
|
|
192
181
|
padding: 6px 10px 6px 6px;
|
|
193
|
-
min-height:
|
|
182
|
+
min-height: 48px;
|
|
194
183
|
border-radius: 6px;
|
|
195
184
|
border: 1px solid var(--odn-color-black-6);
|
|
196
185
|
background: var(--odn-color-solid-black-1);
|
|
@@ -207,12 +196,8 @@
|
|
|
207
196
|
[data-odn-attachments-thumb-card][data-odn-attachments-clickable]:hover {
|
|
208
197
|
border-color: color-mix(in srgb, var(--odn-color-primary) 50%, transparent);
|
|
209
198
|
}
|
|
210
|
-
[data-odn-attachments-thumb-card][data-odn-attachments-
|
|
211
|
-
|
|
212
|
-
border: 1px solid color-mix(in srgb, var(--odn-color-error) 35%, var(--odn-color-black-6));
|
|
213
|
-
}
|
|
214
|
-
[data-odn-attachments-thumb-card][data-odn-attachments-retryable]:hover {
|
|
215
|
-
border-color: color-mix(in srgb, var(--odn-color-error) 55%, transparent);
|
|
199
|
+
[data-odn-attachments-thumb-card][data-odn-attachments-error] {
|
|
200
|
+
border-color: color-mix(in srgb, var(--odn-color-error) 35%, var(--odn-color-black-6));
|
|
216
201
|
}
|
|
217
202
|
|
|
218
203
|
/* 图片保持原先「无边框」视觉,仅与文件卡片对齐高度。 */
|
|
@@ -220,7 +205,7 @@
|
|
|
220
205
|
border: none;
|
|
221
206
|
background: transparent;
|
|
222
207
|
}
|
|
223
|
-
[data-odn-attachments-thumb-card][data-odn-attachments-thumb-card-image][data-odn-attachments-clickable]:hover
|
|
208
|
+
[data-odn-attachments-thumb-card][data-odn-attachments-thumb-card-image][data-odn-attachments-clickable]:hover {
|
|
224
209
|
border: none;
|
|
225
210
|
}
|
|
226
211
|
|
|
@@ -234,6 +219,11 @@
|
|
|
234
219
|
border-radius: 3px;
|
|
235
220
|
overflow: hidden;
|
|
236
221
|
}
|
|
222
|
+
[data-odn-attachments-thumb-card-thumb] [data-odn-image] {
|
|
223
|
+
display: block;
|
|
224
|
+
width: 100%;
|
|
225
|
+
height: 100%;
|
|
226
|
+
}
|
|
237
227
|
[data-odn-attachments-thumb-card-thumb] img {
|
|
238
228
|
width: 100%;
|
|
239
229
|
height: 100%;
|
|
@@ -275,12 +265,12 @@
|
|
|
275
265
|
[data-odn-attachments-card]:not([data-odn-attachments-image-card]),
|
|
276
266
|
[data-odn-attachments-thumb-card] {
|
|
277
267
|
width: 192px;
|
|
278
|
-
min-height:
|
|
268
|
+
min-height: 48px;
|
|
279
269
|
}
|
|
280
270
|
|
|
281
271
|
/* ==========================================================================
|
|
282
|
-
* image-thumb
|
|
283
|
-
*
|
|
272
|
+
* image-thumb 变体(纯图缩略方块)
|
|
273
|
+
* 48×48 cover(与 file-card 等高),承载 image/* + url。缩略走 Image leaf(不再裸 `<img>`)。
|
|
284
274
|
* 同源:共享 data-odn-attachments-state 三态机、remove 角标、fresh-done。
|
|
285
275
|
* composer 待发送区即以此变体让"图片大预览 + 文件信息卡"并列同行、等高同源。
|
|
286
276
|
* ========================================================================== */
|
|
@@ -290,8 +280,8 @@
|
|
|
290
280
|
|
|
291
281
|
[data-odn-attachments-image-thumb] {
|
|
292
282
|
position: relative;
|
|
293
|
-
width:
|
|
294
|
-
height:
|
|
283
|
+
width: 48px;
|
|
284
|
+
height: 48px;
|
|
295
285
|
border-radius: 6px;
|
|
296
286
|
overflow: hidden;
|
|
297
287
|
padding: 0;
|
|
@@ -299,6 +289,11 @@
|
|
|
299
289
|
background: var(--odn-color-black-2);
|
|
300
290
|
box-sizing: border-box;
|
|
301
291
|
}
|
|
292
|
+
[data-odn-attachments-image-thumb] [data-odn-image] {
|
|
293
|
+
display: block;
|
|
294
|
+
width: 100%;
|
|
295
|
+
height: 100%;
|
|
296
|
+
}
|
|
302
297
|
[data-odn-attachments-image-thumb] img {
|
|
303
298
|
width: 100%;
|
|
304
299
|
height: 100%;
|
|
@@ -342,20 +337,10 @@
|
|
|
342
337
|
}
|
|
343
338
|
[data-odn-attachments-image-overlay][data-odn-attachments-image-overlay-error] {
|
|
344
339
|
background: var(--odn-color-solid-black-1);
|
|
345
|
-
flex-direction: column;
|
|
346
340
|
border: 1px solid color-mix(in srgb, var(--odn-color-error) 35%, var(--odn-color-black-6));
|
|
347
341
|
color: var(--odn-color-error);
|
|
348
|
-
}
|
|
349
|
-
[data-odn-attachments-image-overlay][data-odn-attachments-image-overlay-error]:is(button) {
|
|
350
|
-
cursor: pointer;
|
|
351
|
-
appearance: none;
|
|
352
|
-
font: inherit;
|
|
353
|
-
font-size: 10px;
|
|
354
342
|
pointer-events: auto;
|
|
355
343
|
}
|
|
356
|
-
[data-odn-attachments-image-overlay][data-odn-attachments-image-overlay-error]:is(button):hover {
|
|
357
|
-
border-color: color-mix(in srgb, var(--odn-color-error) 55%, transparent);
|
|
358
|
-
}
|
|
359
344
|
|
|
360
345
|
/* ==========================================================================
|
|
361
346
|
* Report 变体(AI 生成报告入口卡片)
|
package/dist/composer/index.js
CHANGED
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
border: 1px solid var(--odn-color-black-6);
|
|
27
27
|
background: var(--odn-color-bg-elevated);
|
|
28
28
|
transition: border-color 0.15s;
|
|
29
|
+
max-height: 50vh;
|
|
30
|
+
min-height: 120px;
|
|
29
31
|
}
|
|
30
32
|
[data-odn-composer-box]:focus-within {
|
|
31
33
|
border-color: color-mix(in srgb, var(--odn-color-brand-6) 50%, transparent);
|
|
@@ -175,6 +177,12 @@
|
|
|
175
177
|
* ScrollArea root 的 height transition 按"目标态"分别定义在 lite 单行 /
|
|
176
178
|
* lite 升格 selector 上,做出「先上再左 / 先右再下」的对称两段动效。
|
|
177
179
|
* ----------------------------------------------------------------- */
|
|
180
|
+
[data-odn-composer] .odn-composer-editor-scroll {
|
|
181
|
+
flex: 1 1 auto;
|
|
182
|
+
min-height: 0;
|
|
183
|
+
overflow: hidden;
|
|
184
|
+
}
|
|
185
|
+
|
|
178
186
|
[data-odn-composer] [data-odn-composer-editor] {
|
|
179
187
|
position: relative;
|
|
180
188
|
width: 100%;
|
|
@@ -435,7 +443,7 @@ p[data-odn-composer-hint] {
|
|
|
435
443
|
* 三态机 / remove 角标 / fresh-done 全部下沉到 Attachments 组件。
|
|
436
444
|
* ----------------------------------------------------------------- */
|
|
437
445
|
[data-odn-composer-attachments] {
|
|
438
|
-
--odn-composer-attachment-h:
|
|
446
|
+
--odn-composer-attachment-h: 48px;
|
|
439
447
|
display: flex;
|
|
440
448
|
flex-wrap: wrap;
|
|
441
449
|
align-items: flex-start;
|