drawui-react 0.2.2 → 0.3.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/dist/styles.css CHANGED
@@ -82,7 +82,7 @@
82
82
  }
83
83
  .drawui-toolbar {
84
84
  position: fixed;
85
- top: 20px;
85
+ top: 5px;
86
86
  left: 50%;
87
87
  transform: translateX(-50%);
88
88
  display: flex;
@@ -98,6 +98,7 @@
98
98
  z-index: 100;
99
99
  }
100
100
  .drawui-toolbar-button {
101
+ position: relative;
101
102
  display: flex;
102
103
  align-items: center;
103
104
  justify-content: center;
@@ -137,7 +138,7 @@
137
138
  }
138
139
  .drawui-toolbar-container {
139
140
  position: fixed;
140
- top: 20px;
141
+ top: 5px;
141
142
  left: 50%;
142
143
  transform: translateX(-50%);
143
144
  z-index: 100;
@@ -147,7 +148,7 @@
147
148
  }
148
149
  .drawui-toolbar-shape-grid {
149
150
  position: absolute;
150
- top: calc(100% + 8px);
151
+ top: calc(100% + 14px);
151
152
  left: 50%;
152
153
  transform: translateX(-50%);
153
154
  display: grid;
@@ -162,6 +163,87 @@
162
163
  border: 1px solid var(--dw-panel-border);
163
164
  background: var(--dw-panel-bg-deep);
164
165
  animation: dropdownFadeIn 0.15s cubic-bezier(0.4, 0, 0.2, 1);
166
+ z-index: 500;
167
+ }
168
+ .drawui-shape-menu {
169
+ display: flex;
170
+ flex-direction: column;
171
+ width: max-content;
172
+ max-height: min(72vh, 560px);
173
+ padding: 8px;
174
+ }
175
+ .drawui-shape-menu-scroll {
176
+ flex: 1 1 auto;
177
+ min-height: 0;
178
+ overflow-y: auto;
179
+ overflow-x: hidden;
180
+ scrollbar-gutter: stable;
181
+ padding-right: 6px;
182
+ }
183
+ .drawui-shape-menu-scroll::-webkit-scrollbar {
184
+ width: 6px;
185
+ }
186
+ .drawui-shape-menu-scroll::-webkit-scrollbar-track {
187
+ background: transparent;
188
+ }
189
+ .drawui-shape-menu-scroll::-webkit-scrollbar-thumb {
190
+ background: var(--dw-dash);
191
+ border-radius: 3px;
192
+ }
193
+ .drawui-shape-menu-scroll::-webkit-scrollbar-thumb:hover {
194
+ background: var(--dw-text-muted);
195
+ }
196
+ .drawui-shape-tip {
197
+ position: absolute;
198
+ z-index: 2000;
199
+ transform: translateX(-50%);
200
+ width: max-content;
201
+ max-width: 240px;
202
+ padding: 5px 9px;
203
+ font-size: 12px;
204
+ line-height: 1.4;
205
+ white-space: nowrap;
206
+ color: var(--dw-tooltip-text);
207
+ background: var(--dw-tooltip-bg);
208
+ border-radius: 8px;
209
+ box-shadow: var(--dw-shadow-tooltip);
210
+ pointer-events: none;
211
+ }
212
+ .drawui-shape-tip::after {
213
+ content: '';
214
+ position: absolute;
215
+ left: 50%;
216
+ margin-left: -4px;
217
+ border: 4px solid transparent;
218
+ }
219
+ .drawui-shape-tip.is-below::after {
220
+ top: -8px;
221
+ border-bottom-color: var(--dw-tooltip-bg);
222
+ }
223
+ .drawui-shape-tip.is-above {
224
+ transform: translate(-50%, -100%);
225
+ }
226
+ .drawui-shape-tip.is-above::after {
227
+ bottom: -8px;
228
+ border-top-color: var(--dw-tooltip-bg);
229
+ }
230
+ .drawui-shape-group + .drawui-shape-group {
231
+ margin-top: 8px;
232
+ padding-top: 8px;
233
+ border-top: 1px solid var(--dw-dash);
234
+ }
235
+ .drawui-shape-group-title {
236
+ margin: 0 0 4px 2px;
237
+ font-size: 11px;
238
+ font-weight: 500;
239
+ line-height: 1;
240
+ color: var(--dw-text-muted);
241
+ user-select: none;
242
+ }
243
+ .drawui-shape-group-grid {
244
+ display: grid;
245
+ grid-template-columns: repeat(6, 36px);
246
+ gap: 2px;
165
247
  }
166
248
  @keyframes dropdownFadeIn {
167
249
  from {
@@ -210,9 +292,41 @@
210
292
  white-space: nowrap;
211
293
  justify-content: flex-start;
212
294
  }
295
+ .drawui-toolbar-color-chip {
296
+ position: absolute;
297
+ right: 4px;
298
+ bottom: 4px;
299
+ width: 10px;
300
+ height: 10px;
301
+ border-radius: 50%;
302
+ border: 1.5px solid #fff;
303
+ box-shadow: 0 0 0 1px var(--dw-swatch-border);
304
+ pointer-events: none;
305
+ }
306
+ .drawui-toolbar-highlighter-grid {
307
+ grid-template-columns: repeat(3, 26px);
308
+ gap: 8px;
309
+ padding: 10px;
310
+ }
311
+ .drawui-highlighter-swatch {
312
+ box-sizing: border-box;
313
+ width: 26px;
314
+ height: 26px;
315
+ border-radius: 50%;
316
+ border: 1px solid rgba(0, 0, 0, 0.08);
317
+ cursor: pointer;
318
+ padding: 0;
319
+ transition: transform 0.12s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.12s cubic-bezier(0.4, 0, 0.2, 1);
320
+ }
321
+ .drawui-highlighter-swatch:hover {
322
+ transform: scale(1.1);
323
+ }
324
+ .drawui-highlighter-swatch.active {
325
+ box-shadow: inset 0 0 0 2px #fff, 0 0 0 2px var(--dw-primary);
326
+ }
213
327
  .drawui-zoom-control {
214
328
  position: fixed;
215
- top: 20px;
329
+ top: 5px;
216
330
  right: 20px;
217
331
  display: flex;
218
332
  flex-direction: column;
@@ -255,9 +369,8 @@
255
369
  }
256
370
  .drawui-status-bar {
257
371
  position: fixed;
258
- bottom: 20px;
259
- left: 50%;
260
- transform: translateX(-50%);
372
+ right: 20px;
373
+ bottom: calc(20px + var(--dw-status-bar-lift, 0px));
261
374
  display: flex;
262
375
  align-items: center;
263
376
  gap: 16px;
@@ -312,6 +425,43 @@
312
425
  transform: translateY(0);
313
426
  }
314
427
  }
428
+ [data-drawui-tip] {
429
+ position: relative;
430
+ }
431
+ [data-drawui-tip]::after {
432
+ content: attr(data-drawui-tip);
433
+ position: absolute;
434
+ left: 50%;
435
+ top: calc(100% + 8px);
436
+ transform: translateX(-50%);
437
+ width: max-content;
438
+ max-width: 240px;
439
+ padding: 5px 9px;
440
+ font-size: 12px;
441
+ font-weight: 400;
442
+ line-height: 1.4;
443
+ text-align: center;
444
+ word-break: break-word;
445
+ color: var(--dw-tooltip-text);
446
+ background: var(--dw-tooltip-bg);
447
+ backdrop-filter: blur(8px);
448
+ -webkit-backdrop-filter: blur(8px);
449
+ border-radius: 8px;
450
+ box-shadow: var(--dw-shadow-tooltip);
451
+ opacity: 0;
452
+ pointer-events: none;
453
+ transition: opacity 0.12s cubic-bezier(0.4, 0, 0.2, 1);
454
+ z-index: 2000;
455
+ }
456
+ [data-drawui-tip]:hover::after,
457
+ [data-drawui-tip]:focus-visible::after {
458
+ opacity: 1;
459
+ transition-delay: 0.35s;
460
+ }
461
+ [data-drawui-tip][data-drawui-tip-pos='top']::after {
462
+ top: auto;
463
+ bottom: calc(100% + 8px);
464
+ }
315
465
  .drawui-toast {
316
466
  position: absolute;
317
467
  top: 20px;
@@ -349,80 +499,220 @@
349
499
  transform: translateX(-50%) translateY(0) scale(1);
350
500
  }
351
501
  }
352
- .drawui-style-panel {
502
+ .drawui-style-floating {
353
503
  position: fixed;
354
- bottom: 60px;
355
- left: 50%;
356
- transform: translateX(-50%);
504
+ inset: 0;
505
+ z-index: 100;
506
+ pointer-events: none;
507
+ }
508
+ .drawui-style-toolbar {
509
+ position: absolute;
357
510
  display: flex;
358
- align-items: stretch;
359
- gap: 0;
360
- padding: 10px 16px;
511
+ align-items: center;
512
+ gap: 2px;
513
+ padding: 5px;
361
514
  background: var(--dw-panel-bg);
362
515
  backdrop-filter: blur(16px);
363
516
  -webkit-backdrop-filter: blur(16px);
364
517
  border-radius: 12px;
365
- box-shadow: var(--dw-shadow-xl);
518
+ box-shadow: var(--dw-shadow-lg);
366
519
  border: 1px solid var(--dw-panel-border);
367
- z-index: 100;
368
- animation: drawui-style-panel-in 0.2s cubic-bezier(0.4, 0, 0.2, 1);
369
- }
370
- @keyframes drawui-style-panel-in {
371
- from {
372
- opacity: 0;
373
- transform: translateX(-50%) translateY(8px) scale(0.97);
374
- }
375
- to {
376
- opacity: 1;
377
- transform: translateX(-50%) translateY(0) scale(1);
378
- }
520
+ pointer-events: auto;
521
+ /* 只做淡入、不做位移/缩放,避免出现"抖动一下"的观感 */
522
+ animation: drawui-style-toolbar-in 0.12s cubic-bezier(0.4, 0, 0.2, 1);
379
523
  }
380
- .drawui-style-col {
524
+ .drawui-style-tool-btn {
381
525
  display: flex;
382
- flex-direction: column;
383
- gap: 8px;
384
- padding: 0 12px;
526
+ align-items: center;
527
+ justify-content: center;
528
+ width: 32px;
529
+ height: 32px;
530
+ padding: 0;
531
+ border: none;
532
+ background: transparent;
533
+ border-radius: 8px;
534
+ color: var(--dw-text-ink);
535
+ font-size: 15px;
536
+ line-height: 1;
537
+ cursor: pointer;
538
+ transition: background 0.12s cubic-bezier(0.4, 0, 0.2, 1);
385
539
  }
386
- .drawui-style-col:first-child {
387
- padding-left: 0;
540
+ .drawui-style-tool-btn:hover {
541
+ background: var(--dw-hover-bg);
388
542
  }
389
- .drawui-style-col:last-child {
390
- padding-right: 0;
543
+ .drawui-style-tool-btn.active {
544
+ background: var(--dw-primary-weak);
391
545
  }
392
- .drawui-style-divider {
393
- width: 1px;
394
- align-self: stretch;
395
- background-image: repeating-linear-gradient(to bottom, var(--dw-dash) 0, var(--dw-dash) 4px, transparent 4px, transparent 8px);
546
+ .drawui-st-swatch {
547
+ width: 18px;
548
+ height: 18px;
549
+ border-radius: 5px;
550
+ border: 1.5px solid var(--dw-swatch-border);
551
+ }
552
+ .drawui-st-none {
553
+ background: #fff linear-gradient(45deg, #ccc 25%, transparent 25%, transparent 75%, #ccc 75%) 0 0 / 6px 6px;
554
+ }
555
+ .drawui-st-frame {
556
+ box-sizing: border-box;
557
+ width: 18px;
558
+ height: 18px;
559
+ border-radius: 4px;
560
+ border-width: 3px;
561
+ border-style: solid;
562
+ }
563
+ /* 无色边框:白底 + 格纹,避免图标看起来是"空的" */
564
+ .drawui-st-frame-none {
565
+ border-color: var(--dw-border-strong);
566
+ background: #fff linear-gradient(45deg, #ccc 25%, transparent 25%, transparent 75%, #ccc 75%) 0 0 / 6px 6px;
396
567
  }
397
- .drawui-style-group {
568
+ .drawui-st-line {
569
+ width: 18px;
570
+ height: 4px;
571
+ border-radius: 2px;
572
+ }
573
+ .drawui-st-line-none {
574
+ background: var(--dw-border-strong);
575
+ }
576
+ .drawui-st-text {
577
+ font-size: 16px;
578
+ font-weight: 700;
579
+ }
580
+ .drawui-st-hl {
581
+ display: flex;
582
+ align-items: center;
583
+ justify-content: center;
584
+ width: 18px;
585
+ height: 18px;
586
+ border-radius: 5px;
587
+ border: 1.5px solid var(--dw-swatch-border);
588
+ font-size: 11px;
589
+ font-weight: 700;
590
+ color: #1f2937;
591
+ }
592
+ .drawui-style-popover {
593
+ position: absolute;
398
594
  display: flex;
399
595
  flex-direction: column;
400
- gap: 4px;
596
+ gap: 8px;
597
+ min-width: 228px;
598
+ padding: 10px 12px;
599
+ background: var(--dw-panel-bg);
600
+ backdrop-filter: blur(16px);
601
+ -webkit-backdrop-filter: blur(16px);
602
+ border-radius: 12px;
603
+ box-shadow: var(--dw-shadow-xl);
604
+ border: 1px solid var(--dw-panel-border);
605
+ background: var(--dw-panel-bg-deep);
606
+ pointer-events: auto;
607
+ animation: drawui-style-pop-in 0.12s cubic-bezier(0.4, 0, 0.2, 1);
401
608
  }
402
- .drawui-style-group-label {
609
+ .drawui-style-popover-title {
403
610
  font-size: 11px;
404
611
  font-weight: 500;
405
612
  color: var(--dw-text-muted);
406
613
  line-height: 1;
407
614
  }
615
+ .drawui-muted-hint {
616
+ max-width: 180px;
617
+ font-size: 11px;
618
+ line-height: 1.5;
619
+ color: var(--dw-text-muted);
620
+ }
621
+ .drawui-arrow-menu {
622
+ display: block;
623
+ width: max-content;
624
+ padding: 10px 12px;
625
+ }
626
+ .drawui-arrow-menu .drawui-style-popover-title {
627
+ margin-bottom: 6px;
628
+ }
629
+ .drawui-arrow-menu .drawui-connection-row + .drawui-style-popover-title {
630
+ margin-top: 10px;
631
+ }
632
+ @keyframes drawui-style-toolbar-in {
633
+ from {
634
+ opacity: 0;
635
+ }
636
+ to {
637
+ opacity: 1;
638
+ }
639
+ }
640
+ @keyframes drawui-style-pop-in {
641
+ from {
642
+ opacity: 0;
643
+ transform: scale(0.97);
644
+ }
645
+ to {
646
+ opacity: 1;
647
+ transform: scale(1);
648
+ }
649
+ }
408
650
  .drawui-color-row {
409
- display: flex;
410
- align-items: center;
411
- gap: 3px;
651
+ display: grid;
652
+ grid-template-columns: repeat(9, 20px);
653
+ gap: 6px;
412
654
  }
413
655
  .drawui-color-swatch {
414
- width: 18px;
415
- height: 18px;
656
+ box-sizing: border-box;
657
+ width: 20px;
658
+ height: 20px;
416
659
  border-radius: 50%;
417
660
  border: 1.5px solid var(--dw-swatch-border);
418
661
  cursor: pointer;
419
662
  padding: 0;
420
- transition: all 0.12s cubic-bezier(0.4, 0, 0.2, 1);
663
+ transition: transform 0.12s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.12s cubic-bezier(0.4, 0, 0.2, 1);
664
+ /* 当前选中色:内白环 + 主色外环 */
421
665
  }
422
666
  .drawui-color-swatch:hover {
423
- transform: scale(1.18);
667
+ transform: scale(1.14);
424
668
  border-color: var(--dw-swatch-border-hover);
425
669
  }
670
+ .drawui-color-swatch.active {
671
+ box-shadow: inset 0 0 0 2px #fff, 0 0 0 2px var(--dw-primary);
672
+ }
673
+ /* 自定义色:右下角小三角标记,区分内置色 */
674
+ .drawui-color-custom {
675
+ position: relative;
676
+ }
677
+ .drawui-color-custom::before {
678
+ content: '';
679
+ position: absolute;
680
+ right: 0;
681
+ bottom: 0;
682
+ width: 0;
683
+ height: 0;
684
+ border-style: solid;
685
+ border-width: 0 0 7px 7px;
686
+ border-color: transparent transparent var(--dw-primary) transparent;
687
+ border-bottom-right-radius: 50%;
688
+ }
689
+ /* 添加颜色:内嵌原生取色器 */
690
+ .drawui-color-add {
691
+ position: relative;
692
+ display: flex;
693
+ align-items: center;
694
+ justify-content: center;
695
+ background: var(--dw-panel-bg-solid);
696
+ border-style: dashed;
697
+ color: var(--dw-text-muted);
698
+ font-size: 15px;
699
+ line-height: 1;
700
+ }
701
+ .drawui-color-add:hover {
702
+ color: var(--dw-primary);
703
+ border-color: var(--dw-primary);
704
+ transform: scale(1.06);
705
+ }
706
+ .drawui-color-add-input {
707
+ position: absolute;
708
+ inset: 0;
709
+ width: 100%;
710
+ height: 100%;
711
+ padding: 0;
712
+ border: none;
713
+ opacity: 0;
714
+ cursor: pointer;
715
+ }
426
716
  .drawui-color-swatch-transparent {
427
717
  position: relative;
428
718
  background: #fff linear-gradient(45deg, #ccc 25%, transparent 25%, transparent 75%, #ccc 75%) 0 0 / 6px 6px;
@@ -437,6 +727,72 @@
437
727
  background: var(--dw-danger);
438
728
  transform: rotate(-45deg);
439
729
  }
730
+ .drawui-opacity-row {
731
+ display: flex;
732
+ align-items: center;
733
+ gap: 8px;
734
+ margin-top: 2px;
735
+ }
736
+ .drawui-opacity-label {
737
+ font-size: 11px;
738
+ color: var(--dw-text-muted);
739
+ white-space: nowrap;
740
+ }
741
+ .drawui-opacity-value {
742
+ font-size: 11px;
743
+ color: var(--dw-text-muted);
744
+ min-width: 34px;
745
+ text-align: right;
746
+ }
747
+ .drawui-opacity-slider {
748
+ flex: 1;
749
+ -webkit-appearance: none;
750
+ appearance: none;
751
+ /* 关键:把 input 本身撑高到 16px,否则命中区域只有 4px 高 → 滑块基本拖不动 */
752
+ height: 16px;
753
+ margin: 0;
754
+ background: transparent;
755
+ outline: none;
756
+ cursor: pointer;
757
+ }
758
+ .drawui-opacity-slider::-webkit-slider-runnable-track {
759
+ height: 4px;
760
+ border-radius: 2px;
761
+ background: var(--dw-border-strong);
762
+ }
763
+ .drawui-opacity-slider::-moz-range-track {
764
+ height: 4px;
765
+ border-radius: 2px;
766
+ background: var(--dw-border-strong);
767
+ }
768
+ .drawui-opacity-slider::-webkit-slider-thumb {
769
+ -webkit-appearance: none;
770
+ appearance: none;
771
+ width: 14px;
772
+ height: 14px;
773
+ /* (轨道高 4 - 滑块高 14) / 2,使滑块在轨道上垂直居中 */
774
+ margin-top: -5px;
775
+ border-radius: 50%;
776
+ background: #ffffff;
777
+ border: 2px solid var(--dw-primary);
778
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
779
+ transition: transform 0.12s cubic-bezier(0.4, 0, 0.2, 1);
780
+ }
781
+ .drawui-opacity-slider::-moz-range-thumb {
782
+ width: 14px;
783
+ height: 14px;
784
+ border-radius: 50%;
785
+ background: #ffffff;
786
+ border: 2px solid var(--dw-primary);
787
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
788
+ transition: transform 0.12s cubic-bezier(0.4, 0, 0.2, 1);
789
+ }
790
+ .drawui-opacity-slider:hover::-webkit-slider-thumb {
791
+ transform: scale(1.1);
792
+ }
793
+ .drawui-opacity-slider:hover::-moz-range-thumb {
794
+ transform: scale(1.1);
795
+ }
440
796
  .drawui-connection-row {
441
797
  display: flex;
442
798
  align-items: center;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drawui-react",
3
- "version": "0.2.2",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "description": "React wrapper for drawui-core canvas drawing (PNG / SVG / PDF export, UML, mind map)",
6
6
  "license": "MIT",
@@ -30,7 +30,7 @@
30
30
  "access": "public"
31
31
  },
32
32
  "dependencies": {
33
- "drawui-core": "0.2.2"
33
+ "drawui-core": "0.3.1"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "react": "^18.3.1"