@363045841yyt/klinechart 0.7.4 → 0.7.5

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,199 +1,199 @@
1
- <template>
2
- <div
3
- class="drawing-style-toolbar"
4
- @pointerdown.stop
5
- @pointermove.stop
6
- @pointerup.stop
7
- >
8
- <div class="toolbar-item color-item" title="颜色">
9
- <span class="color-swatch" :style="{ background: drawing.style.stroke ?? '#2962ff' }"></span>
10
- <input
11
- type="color"
12
- class="color-input"
13
- :value="drawing.style.stroke ?? '#2962ff'"
14
- @input="onColorChange(($event.target as HTMLInputElement).value)"
15
- />
16
- </div>
17
-
18
- <select
19
- class="toolbar-select"
20
- :value="drawing.style.strokeWidth ?? 1"
21
- @change="onWidthChange(Number(($event.target as HTMLSelectElement).value))"
22
- title="线宽"
23
- >
24
- <option :value="1">1px</option>
25
- <option :value="2">2px</option>
26
- <option :value="3">3px</option>
27
- <option :value="4">4px</option>
28
- </select>
29
-
30
- <select
31
- class="toolbar-select"
32
- :value="drawing.style.strokeStyle ?? 'solid'"
33
- @change="onLineStyleChange(($event.target as HTMLSelectElement).value as 'solid' | 'dashed' | 'dotted')"
34
- title="线型"
35
- >
36
- <option value="solid">实线</option>
37
- <option value="dashed">虚线</option>
38
- <option value="dotted">点线</option>
39
- </select>
40
-
41
- <button type="button" class="toolbar-btn delete-btn" title="删除" @click="$emit('delete')">
42
- <svg class="delete-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
43
- <path d="M3 6h18" />
44
- <path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6" />
45
- <path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2" />
46
- </svg>
47
- </button>
48
- </div>
49
- </template>
50
-
51
- <script setup lang="ts">
52
- import { onMounted, onUnmounted } from 'vue'
53
-
54
- export interface DrawingStyle {
55
- stroke?: string
56
- strokeWidth?: number
57
- strokeStyle?: 'solid' | 'dashed' | 'dotted'
58
- fill?: string
59
- }
60
-
61
- export interface DrawingObject {
62
- id: string
63
- type: string
64
- points: { x: number; y: number }[]
65
- style: DrawingStyle
66
- }
67
-
68
- const props = defineProps<{
69
- drawing: DrawingObject
70
- }>()
71
-
72
- const emit = defineEmits<{
73
- (e: 'updateStyle', style: Partial<DrawingStyle>): void
74
- (e: 'delete'): void
75
- }>()
76
-
77
- function onKeyDown(e: KeyboardEvent) {
78
- if (e.key === 'Delete') {
79
- e.preventDefault()
80
- emit('delete')
81
- }
82
- }
83
-
84
- onMounted(() => document.addEventListener('keydown', onKeyDown))
85
- onUnmounted(() => document.removeEventListener('keydown', onKeyDown))
86
-
87
- function onColorChange(color: string) {
88
- emit('updateStyle', { stroke: color })
89
- }
90
-
91
- function onWidthChange(width: number) {
92
- emit('updateStyle', { strokeWidth: width })
93
- }
94
-
95
- function onLineStyleChange(style: 'solid' | 'dashed' | 'dotted') {
96
- emit('updateStyle', { strokeStyle: style })
97
- }
98
- </script>
99
-
100
- <style scoped>
101
- .drawing-style-toolbar {
102
- position: absolute;
103
- left: 50%;
104
- top: 8px;
105
- transform: translateX(-50%);
106
- display: flex;
107
- align-items: center;
108
- gap: 6px;
109
- padding: 4px 8px;
110
- height: 32px;
111
- background: rgba(250, 251, 252, 0.88);
112
- backdrop-filter: blur(8px);
113
- -webkit-backdrop-filter: blur(8px);
114
- border: 1px solid #e5e7eb;
115
- border-radius: 6px;
116
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
117
- z-index: 100;
118
- user-select: none;
119
- pointer-events: auto;
120
- }
121
-
122
- .toolbar-item {
123
- display: inline-flex;
124
- align-items: center;
125
- justify-content: center;
126
- }
127
-
128
- .color-item {
129
- position: relative;
130
- width: 24px;
131
- height: 24px;
132
- }
133
-
134
- .color-swatch {
135
- display: block;
136
- width: 100%;
137
- height: 100%;
138
- border: 1px solid #d1d5db;
139
- border-radius: 4px;
140
- cursor: pointer;
141
- }
142
-
143
- .color-input {
144
- position: absolute;
145
- inset: 0;
146
- opacity: 0;
147
- cursor: pointer;
148
- width: 100%;
149
- height: 100%;
150
- }
151
-
152
- .toolbar-select {
153
- height: 24px;
154
- padding: 0 4px;
155
- border: 1px solid #d1d5db;
156
- border-radius: 4px;
157
- background: #fff;
158
- color: #374151;
159
- font-size: 12px;
160
- cursor: pointer;
161
- outline: none;
162
- }
163
-
164
- .toolbar-select:hover {
165
- border-color: #9ca3af;
166
- }
167
-
168
- .toolbar-btn {
169
- display: inline-flex;
170
- align-items: center;
171
- justify-content: center;
172
- width: 24px;
173
- height: 24px;
174
- padding: 0;
175
- border: 1px solid transparent;
176
- border-radius: 4px;
177
- background: transparent;
178
- color: #6b7280;
179
- cursor: pointer;
180
- transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
181
- }
182
-
183
- .toolbar-btn:hover {
184
- border-color: #d1d5db;
185
- background: #f3f4f6;
186
- color: #374151;
187
- }
188
-
189
- .delete-btn:hover {
190
- color: #dc2626;
191
- border-color: #fca5a5;
192
- background: #fef2f2;
193
- }
194
-
195
- .delete-icon {
196
- width: 14px;
197
- height: 14px;
198
- }
199
- </style>
1
+ <template>
2
+ <div
3
+ class="drawing-style-toolbar"
4
+ @pointerdown.stop
5
+ @pointermove.stop
6
+ @pointerup.stop
7
+ >
8
+ <div class="toolbar-item color-item" title="颜色">
9
+ <span class="color-swatch" :style="{ background: drawing.style.stroke ?? '#2962ff' }"></span>
10
+ <input
11
+ type="color"
12
+ class="color-input"
13
+ :value="drawing.style.stroke ?? '#2962ff'"
14
+ @input="onColorChange(($event.target as HTMLInputElement).value)"
15
+ />
16
+ </div>
17
+
18
+ <select
19
+ class="toolbar-select"
20
+ :value="drawing.style.strokeWidth ?? 1"
21
+ @change="onWidthChange(Number(($event.target as HTMLSelectElement).value))"
22
+ title="线宽"
23
+ >
24
+ <option :value="1">1px</option>
25
+ <option :value="2">2px</option>
26
+ <option :value="3">3px</option>
27
+ <option :value="4">4px</option>
28
+ </select>
29
+
30
+ <select
31
+ class="toolbar-select"
32
+ :value="drawing.style.strokeStyle ?? 'solid'"
33
+ @change="onLineStyleChange(($event.target as HTMLSelectElement).value as 'solid' | 'dashed' | 'dotted')"
34
+ title="线型"
35
+ >
36
+ <option value="solid">实线</option>
37
+ <option value="dashed">虚线</option>
38
+ <option value="dotted">点线</option>
39
+ </select>
40
+
41
+ <button type="button" class="toolbar-btn delete-btn" title="删除" @click="$emit('delete')">
42
+ <svg class="delete-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
43
+ <path d="M3 6h18" />
44
+ <path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6" />
45
+ <path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2" />
46
+ </svg>
47
+ </button>
48
+ </div>
49
+ </template>
50
+
51
+ <script setup lang="ts">
52
+ import { onMounted, onUnmounted } from 'vue'
53
+
54
+ export interface DrawingStyle {
55
+ stroke?: string
56
+ strokeWidth?: number
57
+ strokeStyle?: 'solid' | 'dashed' | 'dotted'
58
+ fill?: string
59
+ }
60
+
61
+ export interface DrawingObject {
62
+ id: string
63
+ type: string
64
+ points: { x: number; y: number }[]
65
+ style: DrawingStyle
66
+ }
67
+
68
+ const props = defineProps<{
69
+ drawing: DrawingObject
70
+ }>()
71
+
72
+ const emit = defineEmits<{
73
+ (e: 'updateStyle', style: Partial<DrawingStyle>): void
74
+ (e: 'delete'): void
75
+ }>()
76
+
77
+ function onKeyDown(e: KeyboardEvent) {
78
+ if (e.key === 'Delete') {
79
+ e.preventDefault()
80
+ emit('delete')
81
+ }
82
+ }
83
+
84
+ onMounted(() => document.addEventListener('keydown', onKeyDown))
85
+ onUnmounted(() => document.removeEventListener('keydown', onKeyDown))
86
+
87
+ function onColorChange(color: string) {
88
+ emit('updateStyle', { stroke: color })
89
+ }
90
+
91
+ function onWidthChange(width: number) {
92
+ emit('updateStyle', { strokeWidth: width })
93
+ }
94
+
95
+ function onLineStyleChange(style: 'solid' | 'dashed' | 'dotted') {
96
+ emit('updateStyle', { strokeStyle: style })
97
+ }
98
+ </script>
99
+
100
+ <style scoped>
101
+ .drawing-style-toolbar {
102
+ position: absolute;
103
+ left: 50%;
104
+ top: 8px;
105
+ transform: translateX(-50%);
106
+ display: flex;
107
+ align-items: center;
108
+ gap: 6px;
109
+ padding: 4px 8px;
110
+ height: 32px;
111
+ background: rgba(250, 251, 252, 0.88);
112
+ backdrop-filter: blur(8px);
113
+ -webkit-backdrop-filter: blur(8px);
114
+ border: 1px solid #e5e7eb;
115
+ border-radius: 6px;
116
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
117
+ z-index: 100;
118
+ user-select: none;
119
+ pointer-events: auto;
120
+ }
121
+
122
+ .toolbar-item {
123
+ display: inline-flex;
124
+ align-items: center;
125
+ justify-content: center;
126
+ }
127
+
128
+ .color-item {
129
+ position: relative;
130
+ width: 24px;
131
+ height: 24px;
132
+ }
133
+
134
+ .color-swatch {
135
+ display: block;
136
+ width: 100%;
137
+ height: 100%;
138
+ border: 1px solid #d1d5db;
139
+ border-radius: 4px;
140
+ cursor: pointer;
141
+ }
142
+
143
+ .color-input {
144
+ position: absolute;
145
+ inset: 0;
146
+ opacity: 0;
147
+ cursor: pointer;
148
+ width: 100%;
149
+ height: 100%;
150
+ }
151
+
152
+ .toolbar-select {
153
+ height: 24px;
154
+ padding: 0 4px;
155
+ border: 1px solid #d1d5db;
156
+ border-radius: 4px;
157
+ background: #fff;
158
+ color: #374151;
159
+ font-size: 12px;
160
+ cursor: pointer;
161
+ outline: none;
162
+ }
163
+
164
+ .toolbar-select:hover {
165
+ border-color: #9ca3af;
166
+ }
167
+
168
+ .toolbar-btn {
169
+ display: inline-flex;
170
+ align-items: center;
171
+ justify-content: center;
172
+ width: 24px;
173
+ height: 24px;
174
+ padding: 0;
175
+ border: 1px solid transparent;
176
+ border-radius: 4px;
177
+ background: transparent;
178
+ color: #6b7280;
179
+ cursor: pointer;
180
+ transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
181
+ }
182
+
183
+ .toolbar-btn:hover {
184
+ border-color: #d1d5db;
185
+ background: #f3f4f6;
186
+ color: #374151;
187
+ }
188
+
189
+ .delete-btn:hover {
190
+ color: #dc2626;
191
+ border-color: #fca5a5;
192
+ background: #fef2f2;
193
+ }
194
+
195
+ .delete-icon {
196
+ width: 14px;
197
+ height: 14px;
198
+ }
199
+ </style>