one-design-next 0.0.25 → 0.0.26

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,15 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import './style';
3
- export interface ArtifactShimmerOptions {
4
- durationMs?: number;
5
- /** 每秒扫光次数(优先级高于 durationMs)。 */
6
- frequencyHz?: number;
7
- angleDeg?: number;
8
- bandSizePercent?: number;
9
- baseOpacity?: number;
10
- highlightOpacity?: number;
11
- easing?: string;
12
- }
13
3
  export interface ArtifactProps {
14
4
  title: string;
15
5
  statRange: string;
@@ -17,15 +7,16 @@ export interface ArtifactProps {
17
7
  /** 预留字段:当前卡片不展示。 */
18
8
  type?: string;
19
9
  status?: 'Generating' | 'Done' | (string & {});
20
- shimmer?: ArtifactShimmerOptions;
21
10
  thumbnailUrl?: string;
11
+ /** 右上角品牌 LOGO(16x16),不传时展示兜底占位块。 */
12
+ brandLogoUrl?: string;
22
13
  onOpen?: () => void;
23
14
  }
24
15
  /**
25
16
  * 对话流内的单个产物摘要卡片。
26
17
  * 本期聚焦单项展示,保留 `type` 字段以支持未来“报告 / 人群”等产物类型扩展。
27
18
  */
28
- export declare function Artifact({ title, statRange, createdAt, status, shimmer, thumbnailUrl, onOpen, }: ArtifactProps): import("react").JSX.Element;
19
+ export declare function Artifact({ title, statRange, createdAt, status, thumbnailUrl, brandLogoUrl, onOpen, }: ArtifactProps): import("react").JSX.Element;
29
20
  export declare namespace Artifact {
30
21
  var displayName: string;
31
22
  }
@@ -11,21 +11,48 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
11
11
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
13
  import { useState } from 'react';
14
+ import { motion } from 'motion/react';
14
15
  import Icon from "../icon";
15
16
  import "./style";
17
+ var PEN_VARIANTS = {
18
+ normal: {
19
+ rotate: 0,
20
+ x: 0,
21
+ y: 0
22
+ },
23
+ animate: {
24
+ rotate: [-0.3, 0.2, -0.4],
25
+ x: [0, -0.5, 1, 0],
26
+ y: [0, 1, -0.5, 0],
27
+ transition: {
28
+ duration: 0.5,
29
+ repeat: Number.POSITIVE_INFINITY,
30
+ repeatDelay: 0.45,
31
+ ease: 'easeInOut'
32
+ }
33
+ }
34
+ };
35
+ function formatCreatedAtToMinute(date) {
36
+ var year = date.getFullYear();
37
+ var month = "".concat(date.getMonth() + 1).padStart(2, '0');
38
+ var day = "".concat(date.getDate()).padStart(2, '0');
39
+ var hours = "".concat(date.getHours()).padStart(2, '0');
40
+ var minutes = "".concat(date.getMinutes()).padStart(2, '0');
41
+ return "\u521B\u5EFA\u65F6\u95F4\uFF1A".concat(year, "-").concat(month, "-").concat(day, " ").concat(hours, ":").concat(minutes);
42
+ }
43
+
16
44
  /**
17
45
  * 对话流内的单个产物摘要卡片。
18
46
  * 本期聚焦单项展示,保留 `type` 字段以支持未来“报告 / 人群”等产物类型扩展。
19
47
  */
20
48
  export function Artifact(_ref) {
21
- var _shimmer$durationMs, _shimmer$angleDeg, _shimmer$bandSizePerc, _shimmer$baseOpacity, _shimmer$highlightOpa, _shimmer$easing;
22
49
  var title = _ref.title,
23
50
  statRange = _ref.statRange,
24
51
  createdAt = _ref.createdAt,
25
52
  _ref$status = _ref.status,
26
53
  status = _ref$status === void 0 ? 'Done' : _ref$status,
27
- shimmer = _ref.shimmer,
28
54
  thumbnailUrl = _ref.thumbnailUrl,
55
+ brandLogoUrl = _ref.brandLogoUrl,
29
56
  onOpen = _ref.onOpen;
30
57
  var isGenerating = status === 'Generating';
31
58
  var isInteractive = !!onOpen && !isGenerating;
@@ -60,28 +87,15 @@ export function Artifact(_ref) {
60
87
  });
61
88
  });
62
89
  };
63
- var shimmerConfig = {
64
- durationMs: (_shimmer$durationMs = shimmer === null || shimmer === void 0 ? void 0 : shimmer.durationMs) !== null && _shimmer$durationMs !== void 0 ? _shimmer$durationMs : 4200,
65
- frequencyHz: shimmer === null || shimmer === void 0 ? void 0 : shimmer.frequencyHz,
66
- angleDeg: (_shimmer$angleDeg = shimmer === null || shimmer === void 0 ? void 0 : shimmer.angleDeg) !== null && _shimmer$angleDeg !== void 0 ? _shimmer$angleDeg : 110,
67
- bandSizePercent: (_shimmer$bandSizePerc = shimmer === null || shimmer === void 0 ? void 0 : shimmer.bandSizePercent) !== null && _shimmer$bandSizePerc !== void 0 ? _shimmer$bandSizePerc : 16,
68
- baseOpacity: (_shimmer$baseOpacity = shimmer === null || shimmer === void 0 ? void 0 : shimmer.baseOpacity) !== null && _shimmer$baseOpacity !== void 0 ? _shimmer$baseOpacity : 0.42,
69
- highlightOpacity: (_shimmer$highlightOpa = shimmer === null || shimmer === void 0 ? void 0 : shimmer.highlightOpacity) !== null && _shimmer$highlightOpa !== void 0 ? _shimmer$highlightOpa : 0.92,
70
- easing: (_shimmer$easing = shimmer === null || shimmer === void 0 ? void 0 : shimmer.easing) !== null && _shimmer$easing !== void 0 ? _shimmer$easing : 'cubic-bezier(0.22, 1, 0.36, 1)'
71
- };
72
- var resolvedDurationMs = shimmerConfig.frequencyHz && shimmerConfig.frequencyHz > 0 ? 1000 / shimmerConfig.frequencyHz : shimmerConfig.durationMs;
73
90
  var spotlightStyle = {
74
91
  '--odn-artifact-spot-x': "".concat(spotlight.x, "px"),
75
92
  '--odn-artifact-spot-y': "".concat(spotlight.y, "px"),
76
- '--odn-artifact-spot-opacity': spotlight.active && !isGenerating ? 1 : 0,
77
- '--odn-artifact-shimmer-duration': "".concat(Math.max(300, resolvedDurationMs), "ms"),
78
- '--odn-artifact-shimmer-angle': "".concat(shimmerConfig.angleDeg, "deg"),
79
- '--odn-artifact-shimmer-band': "".concat(Math.max(4, Math.min(40, shimmerConfig.bandSizePercent)), "%"),
80
- '--odn-artifact-shimmer-base-color': "rgba(51, 55, 61, ".concat(Math.max(0, Math.min(1, shimmerConfig.baseOpacity)), ")"),
81
- '--odn-artifact-shimmer-highlight-color': "rgba(13, 13, 13, ".concat(Math.max(0, Math.min(1, shimmerConfig.highlightOpacity)), ")"),
82
- '--odn-artifact-shimmer-easing': shimmerConfig.easing
93
+ '--odn-artifact-spot-opacity': spotlight.active && !isGenerating ? 1 : 0
83
94
  };
84
- var thirdLineText = status === 'Generating' ? '生成中' : createdAt !== null && createdAt !== void 0 ? createdAt : '创建时间:--';
95
+ var createdAtText = createdAt !== null && createdAt !== void 0 ? createdAt : formatCreatedAtToMinute(new Date());
96
+ var secondLineText = createdAtText;
97
+ var isDone = status === 'Done';
98
+ var thirdLineText = status === 'Generating' ? '生成中' : isDone ? '查看详情' : createdAt !== null && createdAt !== void 0 ? createdAt : '创建时间:--';
85
99
  var content = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
86
100
  "data-odn-artifact-spotlight": true,
87
101
  "aria-hidden": true
@@ -91,27 +105,82 @@ export function Artifact(_ref) {
91
105
  "data-odn-artifact-title": true
92
106
  }, title), /*#__PURE__*/React.createElement("p", {
93
107
  "data-odn-artifact-stat-range": true
94
- }, statRange), /*#__PURE__*/React.createElement("p", {
108
+ }, secondLineText), /*#__PURE__*/React.createElement("p", {
95
109
  "data-odn-artifact-created-at": true
96
- }, thirdLineText)), /*#__PURE__*/React.createElement("div", {
110
+ }, /*#__PURE__*/React.createElement("span", null, thirdLineText), isDone && /*#__PURE__*/React.createElement("span", {
111
+ "data-odn-artifact-detail-icon": true,
112
+ "aria-hidden": true
113
+ }, /*#__PURE__*/React.createElement(Icon, {
114
+ name: "arrowRight",
115
+ size: 16
116
+ })))), /*#__PURE__*/React.createElement("div", {
97
117
  "data-odn-artifact-visual-wrap": true
98
118
  }, /*#__PURE__*/React.createElement("div", {
99
119
  "data-odn-artifact-visual": true,
100
120
  "aria-hidden": true
101
- }, thumbnailUrl ? /*#__PURE__*/React.createElement("div", {
121
+ }, !isGenerating && (thumbnailUrl ? /*#__PURE__*/React.createElement("div", {
102
122
  "data-odn-artifact-visual-inner": true
103
123
  }, /*#__PURE__*/React.createElement("img", {
104
124
  src: thumbnailUrl,
105
125
  alt: "",
106
126
  "data-odn-artifact-visual-image": true
107
- })) : /*#__PURE__*/React.createElement("div", {
108
- "data-odn-artifact-visual-inner": true,
109
- "data-odn-artifact-visual-inner-placeholder": true
110
- }, /*#__PURE__*/React.createElement("span", {
111
- "data-odn-artifact-visual-placeholder": true
112
- }, /*#__PURE__*/React.createElement(Icon, {
113
- name: "file-text",
114
- size: 18
127
+ })) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
128
+ "data-odn-artifact-visual-block": true,
129
+ "data-odn-artifact-visual-block-a": true
130
+ }), /*#__PURE__*/React.createElement("span", {
131
+ "data-odn-artifact-visual-block": true,
132
+ "data-odn-artifact-visual-block-b": true
133
+ }), brandLogoUrl ? /*#__PURE__*/React.createElement("span", {
134
+ "data-odn-artifact-visual-logo": true
135
+ }, /*#__PURE__*/React.createElement("img", {
136
+ src: brandLogoUrl,
137
+ alt: "",
138
+ "data-odn-artifact-visual-logo-image": true
139
+ })) : /*#__PURE__*/React.createElement("span", {
140
+ "data-odn-artifact-visual-block": true,
141
+ "data-odn-artifact-visual-block-e": true
142
+ }), /*#__PURE__*/React.createElement("span", {
143
+ "data-odn-artifact-visual-block": true,
144
+ "data-odn-artifact-visual-block-c": true
145
+ }), /*#__PURE__*/React.createElement("span", {
146
+ "data-odn-artifact-visual-block": true,
147
+ "data-odn-artifact-visual-block-d": true
148
+ }))), isGenerating && /*#__PURE__*/React.createElement("div", {
149
+ "data-odn-artifact-generating-icon": true
150
+ }, /*#__PURE__*/React.createElement("svg", {
151
+ fill: "none",
152
+ height: "24",
153
+ stroke: "currentColor",
154
+ strokeLinecap: "round",
155
+ strokeLinejoin: "round",
156
+ strokeWidth: "2",
157
+ viewBox: "0 0 24 24",
158
+ width: "24",
159
+ xmlns: "http://www.w3.org/2000/svg"
160
+ }, /*#__PURE__*/React.createElement("path", {
161
+ d: "m18 5-2.414-2.414A2 2 0 0 0 14.172 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2"
162
+ }), /*#__PURE__*/React.createElement(motion.path, {
163
+ d: "M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",
164
+ initial: "normal",
165
+ animate: "animate",
166
+ variants: PEN_VARIANTS
167
+ }), /*#__PURE__*/React.createElement(motion.path, {
168
+ d: "M8 18h1",
169
+ initial: "normal",
170
+ animate: "animate",
171
+ transition: {
172
+ duration: 0.5,
173
+ repeat: Number.POSITIVE_INFINITY,
174
+ repeatDelay: 0.45
175
+ },
176
+ variants: {
177
+ normal: {
178
+ d: 'M8 18h1'
179
+ },
180
+ animate: {
181
+ d: 'M8 18h5'
182
+ }
183
+ }
115
184
  }))))));
116
185
  return isInteractive ? /*#__PURE__*/React.createElement("button", {
117
186
  type: "button",
@@ -1,24 +1,19 @@
1
1
  html {
2
2
  --odn-artifact-padding-y: 20px;
3
- --odn-artifact-padding-x: 24px;
3
+ --odn-artifact-padding-left: 24px;
4
+ --odn-artifact-padding-right: 0px;
4
5
  --odn-artifact-radius: 12px;
5
6
  --odn-artifact-content-gap: 24px;
6
- --odn-artifact-copy-width: 280px;
7
+ --odn-artifact-copy-width: 216px;
7
8
  --odn-artifact-copy-height: 120px;
8
9
  --odn-artifact-visual-width: 136px;
9
10
  --odn-artifact-visual-inner-width: 96px;
10
11
  --odn-artifact-visual-height: 120px;
11
- --odn-artifact-shimmer-duration: 1.8s;
12
- --odn-artifact-shimmer-angle: 110deg;
13
- --odn-artifact-shimmer-band: 16%;
14
- --odn-artifact-shimmer-base-color: rgba(51, 55, 61, 0.42);
15
- --odn-artifact-shimmer-highlight-color: rgba(13, 13, 13, 0.92);
16
- --odn-artifact-shimmer-easing: cubic-bezier(0.22, 1, 0.36, 1);
17
12
  }
18
13
 
19
14
  [data-odn-artifact] {
20
15
  position: relative;
21
- width: min(100%, 416px);
16
+ width: min(100%, 376px);
22
17
  height: var(--odn-artifact-copy-height);
23
18
  display: grid;
24
19
  grid-template-columns: var(--odn-artifact-copy-width) var(--odn-artifact-visual-width);
@@ -51,7 +46,7 @@ button[data-odn-artifact] {
51
46
  z-index: 1;
52
47
  width: var(--odn-artifact-copy-width);
53
48
  height: var(--odn-artifact-copy-height);
54
- padding: var(--odn-artifact-padding-y) var(--odn-artifact-padding-x);
49
+ padding: var(--odn-artifact-padding-y) var(--odn-artifact-padding-right) var(--odn-artifact-padding-y) var(--odn-artifact-padding-left);
55
50
  box-sizing: border-box;
56
51
  display: flex;
57
52
  flex-direction: column;
@@ -87,11 +82,36 @@ button[data-odn-artifact] {
87
82
  font-size: var(--odn-font-size-text-mn);
88
83
  line-height: var(--odn-font-leading-text-mn);
89
84
  color: var(--odn-color-black-8);
85
+ display: inline-flex;
86
+ align-items: center;
87
+ gap: 4px;
90
88
  white-space: nowrap;
91
89
  overflow: hidden;
92
90
  text-overflow: ellipsis;
93
91
  }
94
92
 
93
+ [data-odn-artifact][data-odn-artifact-status=Done] [data-odn-artifact-created-at] {
94
+ color: var(--odn-color-brand-6);
95
+ font-size: 14px;
96
+ }
97
+
98
+ [data-odn-artifact][data-odn-artifact-status=Generating] [data-odn-artifact-created-at] {
99
+ font-size: 14px;
100
+ }
101
+
102
+ [data-odn-artifact-detail-icon] {
103
+ display: inline-flex;
104
+ align-items: center;
105
+ transform: translateX(-6px);
106
+ opacity: 0;
107
+ transition: transform 0.2s ease, opacity 0.2s ease;
108
+ }
109
+
110
+ [data-odn-artifact][data-odn-artifact-status=Done]:hover [data-odn-artifact-detail-icon] {
111
+ transform: translateX(0);
112
+ opacity: 1;
113
+ }
114
+
95
115
  [data-odn-artifact-visual-wrap] {
96
116
  position: relative;
97
117
  z-index: 1;
@@ -103,6 +123,7 @@ button[data-odn-artifact] {
103
123
  }
104
124
 
105
125
  [data-odn-artifact-visual] {
126
+ position: relative;
106
127
  width: var(--odn-artifact-visual-inner-width);
107
128
  min-width: var(--odn-artifact-visual-inner-width);
108
129
  height: var(--odn-artifact-visual-height);
@@ -138,44 +159,74 @@ button[data-odn-artifact] {
138
159
  object-fit: cover;
139
160
  }
140
161
 
141
- [data-odn-artifact-visual-placeholder] {
142
- display: inline-flex;
143
- flex-direction: column;
144
- align-items: center;
145
- gap: 4px;
146
- font-size: var(--odn-font-size-text-sm);
147
- line-height: var(--odn-font-leading-text-sm);
148
- color: var(--odn-color-black-8);
162
+ [data-odn-artifact-generating-icon] {
163
+ position: absolute;
164
+ left: 50%;
165
+ top: 48px;
166
+ transform: translate(-50%, -50%);
167
+ z-index: 2;
168
+ color: #95a0b0;
169
+ pointer-events: none;
170
+ }
171
+
172
+ [data-odn-artifact-visual-block] {
173
+ position: absolute;
174
+ border-radius: 2px;
175
+ background: #ecf2fe;
176
+ z-index: 1;
177
+ }
178
+
179
+ [data-odn-artifact-visual-block-a] {
180
+ width: 40px;
181
+ height: 6px;
182
+ left: 12px;
183
+ top: 12px;
184
+ }
185
+
186
+ [data-odn-artifact-visual-block-b] {
187
+ width: 24px;
188
+ height: 6px;
189
+ left: 12px;
190
+ top: 22px;
191
+ }
192
+
193
+ [data-odn-artifact-visual-block-e] {
194
+ width: 16px;
195
+ height: 16px;
196
+ left: 68px;
197
+ top: 12px;
198
+ border-radius: 3.2px;
199
+ }
200
+
201
+ [data-odn-artifact-visual-logo] {
202
+ position: absolute;
203
+ width: 16px;
204
+ height: 16px;
205
+ left: 68px;
206
+ top: 12px;
207
+ border-radius: 3.2px;
208
+ overflow: hidden;
209
+ z-index: 1;
210
+ background: #ecf2fe;
211
+ }
212
+
213
+ [data-odn-artifact-visual-logo-image] {
214
+ width: 100%;
215
+ height: 100%;
216
+ display: block;
217
+ object-fit: cover;
218
+ }
219
+
220
+ [data-odn-artifact-visual-block-c] {
221
+ width: 72px;
222
+ height: 32px;
223
+ left: 12px;
224
+ top: 40px;
149
225
  }
150
226
 
151
- [data-odn-artifact][data-odn-artifact-status=Generating] p,
152
- [data-odn-artifact][data-odn-artifact-status=Generating] [data-odn-artifact-visual-placeholder],
153
- [data-odn-artifact][data-odn-artifact-status=Generating] [data-odn-artifact-visual-placeholder] span {
154
- color: transparent !important;
155
- background-image: linear-gradient(var(--odn-artifact-shimmer-angle), var(--odn-artifact-shimmer-base-color) calc(50% - var(--odn-artifact-shimmer-band)), var(--odn-artifact-shimmer-highlight-color) 50%, var(--odn-artifact-shimmer-base-color) calc(50% + var(--odn-artifact-shimmer-band)));
156
- background-size: 260% 100%;
157
- background-position: 120% 50%;
158
- /* stylelint-disable-next-line property-no-vendor-prefix */
159
- -webkit-background-clip: text;
160
- background-clip: text;
161
- /* stylelint-disable-next-line property-no-vendor-prefix */
162
- -webkit-text-fill-color: transparent;
163
- animation: odn-artifact-text-shimmer var(--odn-artifact-shimmer-duration) var(--odn-artifact-shimmer-easing) infinite alternate;
164
- }
165
-
166
- @keyframes odn-artifact-text-shimmer {
167
- 0% {
168
- background-position: 120% 50%;
169
- }
170
- 100% {
171
- background-position: -20% 50%;
172
- }
173
- }
174
- @media (prefers-reduced-motion: reduce) {
175
- [data-odn-artifact][data-odn-artifact-status=Generating] p,
176
- [data-odn-artifact][data-odn-artifact-status=Generating] [data-odn-artifact-visual-placeholder],
177
- [data-odn-artifact][data-odn-artifact-status=Generating] [data-odn-artifact-visual-placeholder] span {
178
- animation: none;
179
- background-position: 50% 50%;
180
- }
227
+ [data-odn-artifact-visual-block-d] {
228
+ width: 72px;
229
+ height: 32px;
230
+ left: 12px;
231
+ top: 78px;
181
232
  }
@@ -0,0 +1,19 @@
1
+ export declare function getCurrentLine(node: Node | null | undefined, editor: HTMLElement): HTMLDivElement | null;
2
+ export declare function findChipHostBeforeCaret(range: Range): HTMLElement | null;
3
+ export declare function findChipHostAfterCaret(range: Range): HTMLElement | null;
4
+ export declare function normalizeCollapsedCaretAtChipBoundary(range: Range, editor: HTMLElement): {
5
+ node: Node;
6
+ offset: number;
7
+ } | null;
8
+ export declare function resolveCaretMove(range: Range, direction: 'left' | 'right' | 'up' | 'down', editor: HTMLElement): {
9
+ node: Node;
10
+ offset: number;
11
+ } | null;
12
+ export declare function splitLineAt(range: Range, editor: HTMLElement): {
13
+ newLine: HTMLDivElement;
14
+ caret: {
15
+ node: Node;
16
+ offset: number;
17
+ };
18
+ } | null;
19
+ export declare function mergeLineIntoPreviousAtCaretStart(range: Range, editor: HTMLElement, sel: Selection): boolean;