@iquji-web/web-component 0.1.10 → 0.1.12

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.
@@ -0,0 +1,38 @@
1
+ import { type ReactNode } from "react";
2
+ export type IqujiLogLevel = "debug" | "info" | "warn" | "error";
3
+ export type IqujiLogEntry = {
4
+ id?: string | undefined;
5
+ timestamp?: string | undefined;
6
+ level?: IqujiLogLevel | string | undefined;
7
+ source?: string | undefined;
8
+ phase?: string | undefined;
9
+ message: string;
10
+ errorSummary?: string | undefined;
11
+ };
12
+ export type IqujiLogViewerProps = {
13
+ /** 日志条目列表,可为结构化对象或纯文本行列表(自动解析时间戳与等级) */
14
+ logs: ReadonlyArray<IqujiLogEntry | string>;
15
+ /** 区域可访问名称 */
16
+ label?: string | undefined;
17
+ /** 最大高度,默认 380px */
18
+ maxHeight?: number | string | undefined;
19
+ /** 是否显示工具栏(搜索、等级过滤、复制、换行切换),默认 true */
20
+ toolbar?: boolean | undefined;
21
+ /** 是否显示行号,默认 true */
22
+ showLineNumbers?: boolean | undefined;
23
+ /** 是否显示时间戳,默认 true */
24
+ showTimestamps?: boolean | undefined;
25
+ /** 是否默认自动换行,默认 false(水平滚动) */
26
+ wrapLines?: boolean | undefined;
27
+ /** 加载中状态 */
28
+ loading?: boolean | undefined;
29
+ /** 空状态文案 */
30
+ emptyLabel?: string | undefined;
31
+ /** 额外的工具栏操作按钮(例如“刷新”) */
32
+ actions?: ReactNode | undefined;
33
+ /** 复制完成回调 */
34
+ onCopy?: ((text: string) => void) | undefined;
35
+ className?: string | undefined;
36
+ };
37
+ export declare function parseLogLine(raw: string, index: number): IqujiLogEntry;
38
+ export declare function IqujiLogViewer({ actions, className, emptyLabel, label, loading, logs, maxHeight, onCopy, showLineNumbers, showTimestamps, toolbar, wrapLines, }: IqujiLogViewerProps): import("react/jsx-runtime").JSX.Element;
package/dist/styles.css CHANGED
@@ -4529,6 +4529,585 @@
4529
4529
  background: none;
4530
4530
  }
4531
4531
 
4532
+ /* src/log-viewer.css */
4533
+ .iquji-log-viewer {
4534
+ --iquji-log-bg: #101216;
4535
+ --iquji-log-header-bg: #181b22;
4536
+ --iquji-log-text: #e1e4ea;
4537
+ --iquji-log-muted: #6e7687;
4538
+ --iquji-log-border: #262a33;
4539
+ --iquji-log-num: #4e5564;
4540
+ --iquji-log-hover: #161920;
4541
+ --iquji-log-err-bg: #ef44441a;
4542
+ --iquji-log-err-border: #ef4444;
4543
+ --iquji-log-warn-bg: #f59e0b14;
4544
+ --iquji-log-warn-border: #f59e0b;
4545
+ background: var(--iquji-log-bg);
4546
+ border: 1px solid var(--iquji-log-border);
4547
+ border-radius: var(--iquji-radius-panel);
4548
+ color: var(--iquji-log-text);
4549
+ display: flex;
4550
+ font-family: var(--iquji-font-mono);
4551
+ overflow: hidden;
4552
+ position: relative;
4553
+ flex-direction: column;
4554
+ width: 100%;
4555
+ font-size: 12px;
4556
+ line-height: 1.6;
4557
+ }
4558
+
4559
+ .iquji-log-viewer__toolbar {
4560
+ background: var(--iquji-log-header-bg);
4561
+ border-bottom: 1px solid var(--iquji-log-border);
4562
+ display: flex;
4563
+ align-items: center;
4564
+ gap: var(--iquji-space-2);
4565
+ flex-wrap: wrap;
4566
+ justify-content: space-between;
4567
+ padding: 8px 12px;
4568
+ }
4569
+
4570
+ .iquji-log-viewer__toolbar-left {
4571
+ display: flex;
4572
+ align-items: center;
4573
+ gap: var(--iquji-space-2);
4574
+ flex-wrap: wrap;
4575
+ flex: 1;
4576
+ min-width: 200px;
4577
+ }
4578
+
4579
+ .iquji-log-viewer__search {
4580
+ border: 1px solid var(--iquji-log-border);
4581
+ border-radius: var(--iquji-radius-control);
4582
+ color: var(--iquji-log-text);
4583
+ display: inline-flex;
4584
+ background: #ffffff0f;
4585
+ align-items: center;
4586
+ gap: 6px;
4587
+ padding: 3px 8px;
4588
+ transition: border-color .15s, background .15s;
4589
+ }
4590
+
4591
+ .iquji-log-viewer__search:focus-within {
4592
+ background: #ffffff17;
4593
+ border-color: #3b82f6;
4594
+ }
4595
+
4596
+ .iquji-log-viewer__search-input {
4597
+ color: inherit;
4598
+ outline: none;
4599
+ background: none;
4600
+ border: none;
4601
+ min-width: 140px;
4602
+ font-family: inherit;
4603
+ font-size: 12px;
4604
+ }
4605
+
4606
+ .iquji-log-viewer__search-input::placeholder {
4607
+ color: var(--iquji-log-muted);
4608
+ }
4609
+
4610
+ .iquji-log-viewer__filters {
4611
+ display: inline-flex;
4612
+ align-items: center;
4613
+ gap: 2px;
4614
+ }
4615
+
4616
+ .iquji-log-viewer__filter-btn {
4617
+ border-radius: var(--iquji-radius-control);
4618
+ color: var(--iquji-log-muted);
4619
+ cursor: pointer;
4620
+ display: inline-flex;
4621
+ background: none;
4622
+ border: none;
4623
+ align-items: center;
4624
+ gap: 4px;
4625
+ padding: 3px 8px;
4626
+ transition: all .15s;
4627
+ font-family: inherit;
4628
+ font-size: 11px;
4629
+ font-weight: 500;
4630
+ }
4631
+
4632
+ .iquji-log-viewer__filter-btn:hover {
4633
+ color: var(--iquji-log-text);
4634
+ background: #ffffff0f;
4635
+ }
4636
+
4637
+ .iquji-log-viewer__filter-btn[data-active="true"] {
4638
+ color: #fff;
4639
+ background: #ffffff1f;
4640
+ }
4641
+
4642
+ .iquji-log-viewer__filter-btn[data-tone="error"][data-active="true"] {
4643
+ color: #f87171;
4644
+ background: #ef444433;
4645
+ }
4646
+
4647
+ .iquji-log-viewer__toolbar-right {
4648
+ display: inline-flex;
4649
+ align-items: center;
4650
+ gap: 6px;
4651
+ }
4652
+
4653
+ .iquji-log-viewer__tool-btn {
4654
+ border: 1px solid var(--iquji-log-border);
4655
+ border-radius: var(--iquji-radius-control);
4656
+ color: var(--iquji-log-muted);
4657
+ cursor: pointer;
4658
+ display: inline-flex;
4659
+ user-select: none;
4660
+ background: #ffffff0d;
4661
+ align-items: center;
4662
+ gap: 5px;
4663
+ padding: 4px 9px;
4664
+ transition: all .15s;
4665
+ font-family: inherit;
4666
+ font-size: 11px;
4667
+ }
4668
+
4669
+ .iquji-log-viewer__tool-btn:hover:not(:disabled) {
4670
+ color: var(--iquji-log-text);
4671
+ background: #ffffff1a;
4672
+ }
4673
+
4674
+ .iquji-log-viewer__tool-btn[data-active="true"] {
4675
+ color: #60a5fa;
4676
+ background: #3b82f626;
4677
+ border-color: #3b82f6;
4678
+ }
4679
+
4680
+ .iquji-log-viewer__tool-btn:disabled {
4681
+ cursor: not-allowed;
4682
+ opacity: .5;
4683
+ }
4684
+
4685
+ .iquji-log-viewer__scroll {
4686
+ background: var(--iquji-log-bg);
4687
+ box-sizing: border-box;
4688
+ display: block;
4689
+ overflow: auto;
4690
+ position: relative;
4691
+ width: 100%;
4692
+ }
4693
+
4694
+ .iquji-log-viewer__lines {
4695
+ display: flex;
4696
+ flex-direction: column;
4697
+ width: max-content;
4698
+ min-width: 100%;
4699
+ padding: 8px 0;
4700
+ }
4701
+
4702
+ .iquji-log-viewer[data-wrap="true"] .iquji-log-viewer__lines {
4703
+ width: 100%;
4704
+ }
4705
+
4706
+ .iquji-log-viewer__line {
4707
+ box-sizing: border-box;
4708
+ display: flex;
4709
+ white-space: pre;
4710
+ align-items: baseline;
4711
+ gap: 8px;
4712
+ min-height: 22px;
4713
+ padding: 1px 12px;
4714
+ transition: background .1s;
4715
+ }
4716
+
4717
+ .iquji-log-viewer[data-wrap="true"] .iquji-log-viewer__line {
4718
+ white-space: pre-wrap;
4719
+ word-break: break-all;
4720
+ }
4721
+
4722
+ .iquji-log-viewer__line:hover {
4723
+ background: var(--iquji-log-hover);
4724
+ }
4725
+
4726
+ .iquji-log-viewer__line[data-level="error"] {
4727
+ background: var(--iquji-log-err-bg);
4728
+ border-left: 3px solid var(--iquji-log-err-border);
4729
+ padding-left: 9px;
4730
+ }
4731
+
4732
+ .iquji-log-viewer__line[data-level="warn"] {
4733
+ background: var(--iquji-log-warn-bg);
4734
+ border-left: 3px solid var(--iquji-log-warn-border);
4735
+ padding-left: 9px;
4736
+ }
4737
+
4738
+ .iquji-log-viewer__num {
4739
+ color: var(--iquji-log-num);
4740
+ display: inline-block;
4741
+ text-align: right;
4742
+ user-select: none;
4743
+ flex-shrink: 0;
4744
+ min-width: 32px;
4745
+ font-size: 11px;
4746
+ }
4747
+
4748
+ .iquji-log-viewer__time {
4749
+ color: var(--iquji-log-muted);
4750
+ user-select: none;
4751
+ flex-shrink: 0;
4752
+ font-size: 11px;
4753
+ }
4754
+
4755
+ .iquji-log-viewer__level {
4756
+ display: inline-block;
4757
+ letter-spacing: .5px;
4758
+ text-align: center;
4759
+ text-transform: uppercase;
4760
+ user-select: none;
4761
+ border-radius: 3px;
4762
+ flex-shrink: 0;
4763
+ padding: 1px 5px;
4764
+ font-size: 10px;
4765
+ font-weight: 600;
4766
+ line-height: 14px;
4767
+ }
4768
+
4769
+ .iquji-log-viewer__level[data-level="info"] {
4770
+ color: #38bdf8;
4771
+ background: #38bdf81f;
4772
+ }
4773
+
4774
+ .iquji-log-viewer__level[data-level="warn"] {
4775
+ color: #fbbf24;
4776
+ background: #fbbf2426;
4777
+ }
4778
+
4779
+ .iquji-log-viewer__level[data-level="error"] {
4780
+ color: #f87171;
4781
+ background: #f8717133;
4782
+ }
4783
+
4784
+ .iquji-log-viewer__level[data-level="debug"] {
4785
+ color: #94a3b8;
4786
+ background: #94a3b81f;
4787
+ }
4788
+
4789
+ .iquji-log-viewer__tag {
4790
+ color: #a5b4fc;
4791
+ user-select: none;
4792
+ background: #6366f11f;
4793
+ border: 1px solid #6366f140;
4794
+ border-radius: 3px;
4795
+ flex-shrink: 0;
4796
+ padding: 0 4px;
4797
+ font-size: 10px;
4798
+ line-height: 14px;
4799
+ }
4800
+
4801
+ .iquji-log-viewer__msg {
4802
+ color: var(--iquji-log-text);
4803
+ flex: 1;
4804
+ }
4805
+
4806
+ .iquji-log-viewer__highlight {
4807
+ color: #fef3c7;
4808
+ background: #f59e0b59;
4809
+ border-radius: 2px;
4810
+ padding: 0 2px;
4811
+ }
4812
+
4813
+ .iquji-log-viewer__status {
4814
+ background: var(--iquji-log-header-bg);
4815
+ border-top: 1px solid var(--iquji-log-border);
4816
+ color: var(--iquji-log-muted);
4817
+ display: flex;
4818
+ justify-content: space-between;
4819
+ align-items: center;
4820
+ gap: 12px;
4821
+ padding: 6px 12px;
4822
+ font-size: 11px;
4823
+ }
4824
+
4825
+ .iquji-log-viewer__empty, .iquji-log-viewer__loading {
4826
+ box-sizing: border-box;
4827
+ color: var(--iquji-log-muted);
4828
+ display: flex;
4829
+ text-align: center;
4830
+ flex-direction: column;
4831
+ justify-content: center;
4832
+ align-items: center;
4833
+ gap: 8px;
4834
+ min-height: 160px;
4835
+ padding: 24px;
4836
+ }
4837
+
4838
+ /* src/diagnostic.css */
4839
+ .iquji-diagnostic-banner {
4840
+ background: var(--iquji-color-critical-fill);
4841
+ border: 1px solid var(--iquji-color-critical-border);
4842
+ border-left: 3.5px solid var(--iquji-color-critical-text);
4843
+ border-radius: var(--iquji-radius-panel);
4844
+ color: var(--iquji-color-critical-text);
4845
+ display: flex;
4846
+ position: relative;
4847
+ flex-direction: column;
4848
+ gap: 6px;
4849
+ padding: 10px 14px;
4850
+ }
4851
+
4852
+ .iquji-diagnostic-banner[data-tone="warning"] {
4853
+ background: var(--iquji-color-warning-fill);
4854
+ border-color: var(--iquji-color-warning-border);
4855
+ border-left-color: var(--iquji-color-warning-text);
4856
+ color: var(--iquji-color-warning-text);
4857
+ }
4858
+
4859
+ .iquji-diagnostic-banner[data-tone="info"] {
4860
+ background: var(--iquji-color-info-fill);
4861
+ border-color: var(--iquji-color-info-border);
4862
+ border-left-color: var(--iquji-color-info-text);
4863
+ color: var(--iquji-color-info-text);
4864
+ }
4865
+
4866
+ .iquji-diagnostic-banner[data-tone="success"] {
4867
+ background: var(--iquji-color-positive-fill);
4868
+ border-color: var(--iquji-color-positive-border);
4869
+ border-left-color: var(--iquji-color-positive-text);
4870
+ color: var(--iquji-color-positive-text);
4871
+ }
4872
+
4873
+ .iquji-diagnostic-banner__header {
4874
+ display: flex;
4875
+ justify-content: space-between;
4876
+ align-items: center;
4877
+ gap: 10px;
4878
+ }
4879
+
4880
+ .iquji-diagnostic-banner__lead {
4881
+ display: inline-flex;
4882
+ align-items: center;
4883
+ gap: 8px;
4884
+ }
4885
+
4886
+ .iquji-diagnostic-banner__icon {
4887
+ display: inline-flex;
4888
+ flex-shrink: 0;
4889
+ justify-content: center;
4890
+ align-items: center;
4891
+ }
4892
+
4893
+ .iquji-diagnostic-banner__title {
4894
+ font-size: var(--iquji-font-size-body-sm);
4895
+ margin: 0;
4896
+ font-weight: 600;
4897
+ line-height: 1.4;
4898
+ }
4899
+
4900
+ .iquji-diagnostic-banner__code {
4901
+ appearance: none;
4902
+ background: var(--iquji-color-surface, #fff);
4903
+ border: 1px solid var(--iquji-color-critical-border);
4904
+ border-radius: var(--iquji-radius-control);
4905
+ color: var(--iquji-color-critical-text);
4906
+ cursor: pointer;
4907
+ display: inline-flex;
4908
+ font-family: var(--iquji-font-mono);
4909
+ outline: none;
4910
+ user-select: all;
4911
+ -webkit-appearance: none;
4912
+ align-items: center;
4913
+ gap: 5px;
4914
+ padding: 2px 7px;
4915
+ transition: all .15s;
4916
+ font-size: 11px;
4917
+ font-weight: 500;
4918
+ line-height: 1.4;
4919
+ }
4920
+
4921
+ .iquji-diagnostic-banner__code:hover {
4922
+ background: color-mix(in srgb, var(--iquji-color-critical-fill) 40%, #fff);
4923
+ border-color: var(--iquji-color-critical-text);
4924
+ }
4925
+
4926
+ .iquji-diagnostic-banner[data-tone="warning"] .iquji-diagnostic-banner__code {
4927
+ border-color: var(--iquji-color-warning-border);
4928
+ color: var(--iquji-color-warning-text);
4929
+ }
4930
+
4931
+ .iquji-diagnostic-banner[data-tone="info"] .iquji-diagnostic-banner__code {
4932
+ border-color: var(--iquji-color-info-border);
4933
+ color: var(--iquji-color-info-text);
4934
+ }
4935
+
4936
+ .iquji-diagnostic-banner__desc {
4937
+ color: var(--iquji-color-text, #1e293b);
4938
+ font-size: var(--iquji-font-size-body-sm);
4939
+ opacity: .92;
4940
+ margin: 0;
4941
+ line-height: 1.55;
4942
+ }
4943
+
4944
+ .iquji-diagnostic-meta {
4945
+ display: flex;
4946
+ align-items: center;
4947
+ gap: var(--iquji-space-2);
4948
+ margin-bottom: var(--iquji-space-1);
4949
+ flex-wrap: wrap;
4950
+ }
4951
+
4952
+ .iquji-diagnostic-meta__item {
4953
+ background: var(--iquji-color-neutral-fill);
4954
+ border-radius: var(--iquji-radius-control);
4955
+ color: var(--iquji-color-neutral-text);
4956
+ display: inline-flex;
4957
+ font-family: var(--iquji-font-mono);
4958
+ align-items: center;
4959
+ gap: 6px;
4960
+ padding: 3px 8px;
4961
+ font-size: 11px;
4962
+ }
4963
+
4964
+ .iquji-diagnostic-meta__btn {
4965
+ appearance: none;
4966
+ color: inherit;
4967
+ cursor: pointer;
4968
+ display: inline-flex;
4969
+ outline: none;
4970
+ background: none;
4971
+ border: none;
4972
+ padding: 0;
4973
+ transition: opacity .15s;
4974
+ }
4975
+
4976
+ .iquji-diagnostic-meta__btn:hover {
4977
+ opacity: .7;
4978
+ }
4979
+
4980
+ .iquji-diagnostic-dialog-body {
4981
+ display: flex;
4982
+ flex-direction: column;
4983
+ gap: 12px;
4984
+ width: 100%;
4985
+ }
4986
+
4987
+ .iquji-diagnostic-dialog-header {
4988
+ display: flex;
4989
+ flex-direction: column;
4990
+ gap: 4px;
4991
+ width: 100%;
4992
+ }
4993
+
4994
+ .iquji-diagnostic-dialog-header__lead {
4995
+ display: flex;
4996
+ flex-wrap: wrap;
4997
+ align-items: center;
4998
+ gap: 8px;
4999
+ }
5000
+
5001
+ .iquji-diagnostic-dialog-header__title {
5002
+ color: var(--iquji-color-text);
5003
+ font-size: var(--iquji-font-size-title-sm);
5004
+ font-weight: 600;
5005
+ line-height: 1.3;
5006
+ }
5007
+
5008
+ .iquji-diagnostic-dialog-header__badge {
5009
+ background: var(--iquji-color-neutral-fill);
5010
+ color: var(--iquji-color-neutral-text);
5011
+ display: inline-flex;
5012
+ border-radius: 999px;
5013
+ align-items: center;
5014
+ gap: 5px;
5015
+ padding: 3px 8px;
5016
+ font-size: 11px;
5017
+ font-weight: 500;
5018
+ line-height: 1;
5019
+ }
5020
+
5021
+ .iquji-diagnostic-dialog-header__badge[data-tone="danger"] {
5022
+ background: var(--iquji-color-critical-fill);
5023
+ color: var(--iquji-color-critical-text);
5024
+ }
5025
+
5026
+ .iquji-diagnostic-dialog-header__badge[data-tone="info"] {
5027
+ background: var(--iquji-color-info-fill);
5028
+ color: var(--iquji-color-info-text);
5029
+ }
5030
+
5031
+ .iquji-diagnostic-dialog-header__badge[data-tone="success"] {
5032
+ background: var(--iquji-color-positive-fill);
5033
+ color: var(--iquji-color-positive-text);
5034
+ }
5035
+
5036
+ .iquji-diagnostic-dialog-header__badge-dot {
5037
+ display: inline-block;
5038
+ background: currentColor;
5039
+ border-radius: 999px;
5040
+ width: 6px;
5041
+ height: 6px;
5042
+ }
5043
+
5044
+ .iquji-diagnostic-dialog-header__meta {
5045
+ color: var(--iquji-color-muted);
5046
+ display: flex;
5047
+ font-family: var(--iquji-font-mono);
5048
+ flex-wrap: wrap;
5049
+ align-items: center;
5050
+ gap: 6px;
5051
+ font-size: 12px;
5052
+ line-height: 1.4;
5053
+ }
5054
+
5055
+ .iquji-diagnostic-dialog-header__action {
5056
+ color: var(--iquji-color-text);
5057
+ font-weight: 500;
5058
+ }
5059
+
5060
+ .iquji-diagnostic-dialog-header__sep {
5061
+ opacity: .4;
5062
+ }
5063
+
5064
+ .iquji-diagnostic-dialog-header__task {
5065
+ display: inline-flex;
5066
+ align-items: center;
5067
+ gap: 4px;
5068
+ }
5069
+
5070
+ .iquji-diagnostic-dialog-header__copy-btn {
5071
+ appearance: none;
5072
+ color: var(--iquji-color-muted);
5073
+ cursor: pointer;
5074
+ display: inline-flex;
5075
+ outline: none;
5076
+ background: none;
5077
+ border: none;
5078
+ align-items: center;
5079
+ padding: 1px;
5080
+ transition: color .15s;
5081
+ }
5082
+
5083
+ .iquji-diagnostic-dialog-header__copy-btn:hover {
5084
+ color: var(--iquji-color-text);
5085
+ }
5086
+
5087
+ .iquji-diagnostic-dialog__footer {
5088
+ display: flex;
5089
+ justify-content: space-between;
5090
+ align-items: center;
5091
+ width: 100%;
5092
+ }
5093
+
5094
+ .iquji-diagnostic-dialog__footer-hint {
5095
+ color: var(--iquji-color-muted);
5096
+ display: flex;
5097
+ font-size: var(--iquji-font-size-caption);
5098
+ align-items: center;
5099
+ }
5100
+
5101
+ .iquji-diagnostic-dialog__footer-actions {
5102
+ display: flex;
5103
+ align-items: center;
5104
+ gap: 8px;
5105
+ }
5106
+
5107
+ .iquji-diagnostic-dialog__copy-btn {
5108
+ font-weight: 500;
5109
+ }
5110
+
4532
5111
  /* src/emoji-picker.css */
4533
5112
  .iquji-emoji-picker {
4534
5113
  display: grid;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iquji-web/web-component",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "files": [
@@ -24,8 +24,8 @@
24
24
  "react": "19.2.4"
25
25
  },
26
26
  "dependencies": {
27
- "@iquji-web/web-icons": "0.1.10",
28
- "@iquji-web/web-theme": "0.1.10",
27
+ "@iquji-web/web-icons": "0.1.12",
28
+ "@iquji-web/web-theme": "0.1.12",
29
29
  "@tanstack/react-table": "8.21.3"
30
30
  },
31
31
  "description": "React 通用交互组件与布局。",