@icen.ai/ui 0.2.1 → 0.4.0

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.
Files changed (121) hide show
  1. package/README.md +29 -16
  2. package/dist/base.css +389 -48
  3. package/dist/behaviors/accordion.mjs +20 -0
  4. package/dist/behaviors/carousel.mjs +30 -1
  5. package/dist/behaviors/charts.mjs +356 -0
  6. package/dist/behaviors/copy.mjs +4 -3
  7. package/dist/behaviors/datatable.mjs +968 -0
  8. package/dist/behaviors/input.mjs +20 -1
  9. package/dist/behaviors/modal.mjs +14 -0
  10. package/dist/behaviors/nav.mjs +31 -4
  11. package/dist/behaviors/sidebar.mjs +12 -0
  12. package/dist/behaviors/slider.mjs +35 -3
  13. package/dist/behaviors/tabs.mjs +100 -9
  14. package/dist/behaviors/tag-input.mjs +11 -0
  15. package/dist/behaviors/theme.mjs +26 -0
  16. package/dist/behaviors/toast.mjs +83 -15
  17. package/dist/behaviors/tree.mjs +57 -1
  18. package/dist/behaviors/upload.mjs +2 -3
  19. package/dist/cli.mjs +74 -0
  20. package/dist/components/accordion.mjs +3 -0
  21. package/dist/components/alert.mjs +2 -0
  22. package/dist/components/avatar.mjs +2 -0
  23. package/dist/components/breadcrumb.css +91 -18
  24. package/dist/components/breadcrumb.mjs +2 -0
  25. package/dist/components/btn.css +174 -14
  26. package/dist/components/btn.mjs +2 -0
  27. package/dist/components/card.css +118 -18
  28. package/dist/components/card.mjs +2 -0
  29. package/dist/components/carousel.mjs +3 -0
  30. package/dist/components/chart-area.css +15 -0
  31. package/dist/components/chart-area.mjs +4 -0
  32. package/dist/components/chart-bar.css +79 -0
  33. package/dist/components/chart-bar.mjs +4 -0
  34. package/dist/components/chart-gauge.css +38 -0
  35. package/dist/components/chart-gauge.mjs +4 -0
  36. package/dist/components/chart-heatmap.css +52 -0
  37. package/dist/components/chart-heatmap.mjs +4 -0
  38. package/dist/components/chart-line.css +15 -0
  39. package/dist/components/chart-line.mjs +4 -0
  40. package/dist/components/chart-pie.css +26 -0
  41. package/dist/components/chart-pie.mjs +4 -0
  42. package/dist/components/chart-radar.css +19 -0
  43. package/dist/components/chart-radar.mjs +4 -0
  44. package/dist/components/chart-sparkline.css +14 -0
  45. package/dist/components/chart-sparkline.mjs +4 -0
  46. package/dist/components/chart-stack.css +30 -0
  47. package/dist/components/chart-stack.mjs +4 -0
  48. package/dist/components/charts.css +66 -74
  49. package/dist/components/charts.mjs +12 -0
  50. package/dist/components/content.css +256 -74
  51. package/dist/components/context-menu.mjs +3 -0
  52. package/dist/components/datatable.css +429 -0
  53. package/dist/components/datatable.mjs +4 -0
  54. package/dist/components/desc.mjs +2 -0
  55. package/dist/components/dropdown.mjs +3 -0
  56. package/dist/components/empty.css +50 -10
  57. package/dist/components/empty.mjs +2 -0
  58. package/dist/components/feedback.css +158 -47
  59. package/dist/components/form.css +139 -22
  60. package/dist/components/input.css +165 -45
  61. package/dist/components/input.mjs +3 -0
  62. package/dist/components/kbd.mjs +2 -0
  63. package/dist/components/layout.mjs +2 -0
  64. package/dist/components/list.mjs +2 -0
  65. package/dist/components/media-card.mjs +2 -0
  66. package/dist/components/media.css +187 -40
  67. package/dist/components/menu.css +159 -32
  68. package/dist/components/modal.css +140 -34
  69. package/dist/components/modal.mjs +3 -0
  70. package/dist/components/nav.css +134 -32
  71. package/dist/components/nav.mjs +3 -0
  72. package/dist/components/pagination.css +105 -19
  73. package/dist/components/pagination.mjs +2 -0
  74. package/dist/components/panel.css +61 -6
  75. package/dist/components/panel.mjs +2 -0
  76. package/dist/components/pill.css +74 -14
  77. package/dist/components/pill.mjs +2 -0
  78. package/dist/components/popover.css +109 -7
  79. package/dist/components/popover.mjs +3 -0
  80. package/dist/components/progress.mjs +2 -0
  81. package/dist/components/rating.mjs +2 -0
  82. package/dist/components/result.mjs +2 -0
  83. package/dist/components/segmented.css +199 -50
  84. package/dist/components/segmented.mjs +2 -0
  85. package/dist/components/select.css +140 -39
  86. package/dist/components/select.mjs +3 -0
  87. package/dist/components/sidebar.css +162 -34
  88. package/dist/components/sidebar.mjs +3 -0
  89. package/dist/components/skeleton.mjs +2 -0
  90. package/dist/components/slider.css +169 -31
  91. package/dist/components/slider.mjs +3 -0
  92. package/dist/components/spinner.mjs +2 -0
  93. package/dist/components/stat.css +103 -8
  94. package/dist/components/stat.mjs +2 -0
  95. package/dist/components/steps.css +105 -31
  96. package/dist/components/steps.mjs +2 -0
  97. package/dist/components/switch.css +171 -54
  98. package/dist/components/switch.mjs +2 -0
  99. package/dist/components/table.css +114 -12
  100. package/dist/components/table.mjs +2 -0
  101. package/dist/components/tabs.css +104 -17
  102. package/dist/components/tabs.mjs +3 -0
  103. package/dist/components/tag-input.css +119 -23
  104. package/dist/components/tag-input.mjs +3 -0
  105. package/dist/components/timeline.mjs +2 -0
  106. package/dist/components/toast.css +85 -12
  107. package/dist/components/toast.mjs +3 -0
  108. package/dist/components/tooltip.css +86 -26
  109. package/dist/components/tooltip.mjs +2 -0
  110. package/dist/components/tree.mjs +3 -0
  111. package/dist/components/upload.css +144 -17
  112. package/dist/components/upload.mjs +3 -0
  113. package/dist/index.mjs +811 -42
  114. package/dist/registry.json +310 -2
  115. package/dist/retro-effects.css +264 -0
  116. package/dist/tokens/colors.css +18 -90
  117. package/dist/tokens/retro-effects.css +264 -0
  118. package/dist/tokens/style-profiles.css +47 -47
  119. package/dist/tokens.css +65 -137
  120. package/dist/ui.css +5069 -1026
  121. package/package.json +9 -1
@@ -1,26 +1,113 @@
1
1
  /*
2
- * @icen.ai/ui — Component: tabs(分区导航)
3
- * .page-tabs > .page-tab(页面内分区,active 加粗)
4
- * .admin-tabs > a(顶部子导航)
5
- * 窄屏换行不滚动(overflow 纪律:tab 条永不出现滚动条)。
2
+ * @icen.ai/ui — Component: tabs(分区导航 / 子导航)
3
+ *
4
+ * 完整契约:
5
+ * <div class="page-tabs" role="tablist"> ← 页面内分区
6
+ * <button class="page-tab [.active]" role="tab" [aria-selected="true"]>…</button>
7
+ * </div>
8
+ *
9
+ * <nav class="admin-tabs" role="navigation"> ← 顶部子导航(a 链接)
10
+ * <a class="[.active]" [aria-current="page"] href="…">…</a>
11
+ * </nav>
12
+ *
13
+ * 与 behaviors/tabs 配套:[data-tabs] > [data-tab] + [data-tab-panel],行为层维护 aria。
14
+ * 窄屏换行不滚动(CLAUDE.md 纪律:tab 条永不出现滚动条)。
6
15
  */
7
16
 
8
- .page-tabs, .admin-tabs {
9
- display: flex; gap: 2px; flex-wrap: wrap;
10
- border-bottom: 1px solid var(--token-line-soft); margin-bottom: 26px;
17
+ .page-tabs,
18
+ .admin-tabs {
19
+ display: flex;
20
+ gap: 2px;
21
+ flex-wrap: wrap;
22
+ border-bottom: 1px solid var(--token-line-soft);
23
+ margin-bottom: var(--density-space-lg);
11
24
  }
25
+
12
26
  .page-tab {
13
- background: none; border: 0; cursor: pointer;
14
- padding: 9px 14px; font-family: var(--font-mono); font-size: 13px; letter-spacing: 1px;
15
- color: var(--token-text-muted); border-bottom: 2px solid transparent;
16
- margin-bottom: -1px; white-space: nowrap;
27
+ background: none;
28
+ border: 0;
29
+ cursor: pointer;
30
+ padding: var(--density-space-sm) var(--density-space-md);
31
+ font-family: var(--font-mono);
32
+ font-size: var(--density-font-size-md);
33
+ letter-spacing: 0.05em;
34
+ color: var(--token-text-muted);
35
+ border-bottom: 2px solid transparent;
36
+ margin-bottom: -1px;
37
+ white-space: nowrap;
38
+ transition:
39
+ color var(--icen-tx-fast),
40
+ border-color var(--icen-tx-fast);
41
+ }
42
+ .page-tab:hover {
43
+ color: var(--token-accent);
44
+ }
45
+ .page-tab:focus-visible {
46
+ outline: none;
47
+ border-radius: var(--radius-sm);
48
+ box-shadow: var(--icen-ring);
49
+ }
50
+ .page-tab.active,
51
+ .page-tab[aria-selected='true'] {
52
+ color: var(--token-accent);
53
+ border-bottom-color: var(--token-accent);
54
+ font-weight: 700;
17
55
  }
18
- .page-tab:hover { color: var(--token-accent); }
19
- .page-tab.active { color: var(--token-accent); border-bottom-color: var(--token-accent); font-weight: 700; }
20
56
 
21
57
  .admin-tabs a {
22
- padding: 9px 14px; font-size: 13px; color: var(--token-text-muted);
23
- border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
58
+ padding: var(--density-space-sm) var(--density-space-md);
59
+ font-size: var(--density-font-size-md);
60
+ color: var(--token-text-muted);
61
+ border-bottom: 2px solid transparent;
62
+ margin-bottom: -1px;
63
+ white-space: nowrap;
64
+ text-decoration: none;
65
+ transition:
66
+ color var(--icen-tx-fast),
67
+ border-color var(--icen-tx-fast);
68
+ }
69
+ .admin-tabs a:hover {
70
+ color: var(--token-accent);
71
+ text-decoration: none;
72
+ }
73
+ .admin-tabs a:focus-visible {
74
+ outline: none;
75
+ border-radius: var(--radius-sm);
76
+ box-shadow: var(--icen-ring);
77
+ }
78
+ .admin-tabs a.active,
79
+ .admin-tabs a[aria-current='page'] {
80
+ color: var(--token-accent);
81
+ border-bottom-color: var(--token-accent);
82
+ }
83
+
84
+ /* 卡片变体(可选 .page-tabs--cards):tab 变成 pill,没有底边线 */
85
+ .page-tabs--cards {
86
+ border-bottom: 0;
87
+ gap: var(--density-space-xs);
88
+ margin-bottom: var(--density-space-md);
89
+ }
90
+ .page-tabs--cards .page-tab {
91
+ padding: var(--density-space-xs) var(--density-space-md);
92
+ border: 1px solid var(--token-outline-soft);
93
+ border-radius: var(--radius-full);
94
+ margin-bottom: 0;
95
+ }
96
+ .page-tabs--cards .page-tab.active,
97
+ .page-tabs--cards .page-tab[aria-selected='true'] {
98
+ background: var(--token-accent);
99
+ color: var(--token-on-accent, #fff);
100
+ border-color: var(--token-accent);
101
+ font-weight: 500;
102
+ }
103
+
104
+ /* 等宽变体:tab 平均占满容器 */
105
+ .page-tabs--equal .page-tab,
106
+ .admin-tabs--equal a {
107
+ flex: 1;
108
+ text-align: center;
109
+ }
110
+
111
+ @media (prefers-reduced-motion: reduce) {
112
+ .page-tab, .admin-tabs a { transition: none; }
24
113
  }
25
- .admin-tabs a:hover { color: var(--token-accent); text-decoration: none; }
26
- .admin-tabs a.active { color: var(--token-accent); border-bottom-color: var(--token-accent); }
@@ -0,0 +1,3 @@
1
+ // @icen.ai/ui — kit: tabs(CSS + behavior 一行入口;构建产物,勿手改)
2
+ import './tabs.css';
3
+ export * from '../behaviors/tabs.mjs';
@@ -2,47 +2,143 @@
2
2
  * @icen.ai/ui — Component: tag-input(多值标签编辑)
3
3
  * 规格源自 opengal primitives/advanced-input.tsx 的 TagInput;与 behaviors/tag-input.ts 配套。
4
4
  *
5
- * 契约:
6
- * <div class="tag-input control" data-tags="初始,标签" data-max="5">
5
+ * 完整契约:
6
+ * <div class="tag-input control [.tag-input--sm|.tag-input--lg] [.is-disabled]"
7
+ * data-tags="初始,标签" data-max="5" data-duplicate="false|true">
7
8
  * <input class="tag-input-field" placeholder="…" />
8
9
  * </div>
9
- * behavior 按 data-tags 渲染 .tag-chip(含 .tag-chip-x 删除钮),并回写 data-tags;
10
- * 达到 data-max 时容器加 .is-max(warning 色边框)并拒加。
10
+ *
11
+ * behavior 渲染:
12
+ * - 解析 data-tags → 渲染 .tag-chip(含 .tag-chip-x 删除钮),input 放在末尾
13
+ * - 达到 data-max 时容器加 .is-max(warning 色边框)并拒加
14
+ * - data-duplicate="false" 时重复值被拒绝(短暂 .is-shake 抖动反馈)
15
+ * - 删除钮 Enter/Space 触发,删后 input 自动聚焦
11
16
  */
12
17
 
13
18
  .tag-input {
14
- display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
15
- padding: 6px; min-height: 36px;
19
+ display: flex;
20
+ flex-wrap: wrap;
21
+ align-items: center;
22
+ gap: var(--density-space-xs);
23
+ padding: var(--density-space-xs);
24
+ min-height: var(--density-input-height-md);
16
25
  background: var(--token-control);
17
26
  border: 1px solid var(--token-outline-soft);
18
- border-radius: var(--radius-lg);
27
+ border-radius: var(--radius-md);
28
+ box-shadow: var(--token-shadow-inset);
29
+ transition:
30
+ border-color var(--icen-tx-fast),
31
+ box-shadow var(--icen-tx-fast);
32
+ }
33
+ .tag-input:hover {
34
+ border-color: var(--icen-hover-border);
19
35
  }
20
- .tag-input:focus-within { border-color: var(--token-accent); }
21
- .tag-input.is-max, .tag-input.is-max:focus-within {
36
+ .tag-input:focus-within {
37
+ border-color: var(--icen-control-focus-border);
38
+ box-shadow: var(--icen-control-focus-shadow);
39
+ }
40
+ .tag-input.is-max,
41
+ .tag-input.is-max:focus-within {
22
42
  border-color: color-mix(in srgb, var(--token-warning) 60%, transparent);
43
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--token-warning) 14%, transparent);
44
+ }
45
+ .tag-input.is-disabled,
46
+ .tag-input[aria-disabled='true'],
47
+ .tag-input[data-disabled] {
48
+ opacity: var(--icen-disabled-opacity);
49
+ background: var(--token-bg-soft);
50
+ cursor: not-allowed;
51
+ pointer-events: none;
23
52
  }
24
- .tag-input.is-disabled { opacity: 0.4; }
25
53
  .tag-input.is-disabled .tag-input-field { cursor: not-allowed; }
54
+ .tag-input.is-disabled .tag-chip-x { pointer-events: none; }
55
+
56
+ .tag-input--sm { min-height: var(--density-input-height-sm); }
57
+ .tag-input--lg { min-height: var(--density-input-height-lg); }
26
58
 
27
59
  .tag-chip {
28
- display: inline-flex; align-items: center; gap: 4px;
29
- padding: 2px 4px 2px 8px;
60
+ display: inline-flex;
61
+ align-items: center;
62
+ gap: 4px;
63
+ padding: 2px 4px 2px var(--density-space-xs);
30
64
  border-radius: var(--radius-full);
31
- background: var(--token-accent-subtle); color: var(--token-accent);
32
- font-size: 11px; font-weight: 500;
65
+ background: var(--token-accent-subtle);
66
+ color: var(--token-accent);
67
+ font-size: var(--density-font-size-xs);
68
+ font-weight: 500;
69
+ line-height: 1.4;
70
+ max-width: 100%;
71
+ animation: tag-pop var(--icen-tx-fast);
72
+ }
73
+ .tag-chip-label {
74
+ white-space: nowrap;
75
+ overflow: hidden;
76
+ text-overflow: ellipsis;
77
+ max-width: 200px;
78
+ }
79
+ .tag-chip--readonly { background: var(--token-fill-2); color: var(--token-text-muted); }
80
+
81
+ @keyframes tag-pop {
82
+ from { opacity: 0; transform: scale(0.85); }
83
+ to { opacity: 1; transform: scale(1); }
84
+ }
85
+ @media (prefers-reduced-motion: reduce) {
86
+ .tag-chip { animation: none; }
33
87
  }
34
88
 
35
89
  .tag-chip-x {
36
- display: inline-flex; align-items: center; justify-content: center;
37
- padding: 2px; border: none; background: transparent; cursor: pointer;
38
- border-radius: var(--radius-full); color: inherit; font-size: 11px; line-height: 1;
39
- transition: background-color var(--duration-normal) var(--ease-out);
90
+ display: inline-flex;
91
+ align-items: center;
92
+ justify-content: center;
93
+ width: 16px;
94
+ height: 16px;
95
+ padding: 0;
96
+ border: none;
97
+ background: transparent;
98
+ cursor: pointer;
99
+ border-radius: var(--radius-full);
100
+ color: inherit;
101
+ font-size: 11px;
102
+ line-height: 1;
103
+ opacity: 0.7;
104
+ transition:
105
+ background-color var(--icen-tx-fast),
106
+ opacity var(--icen-tx-fast),
107
+ color var(--icen-tx-fast);
108
+ }
109
+ .tag-chip-x:hover {
110
+ opacity: 1;
111
+ background: color-mix(in srgb, currentColor 18%, transparent);
112
+ color: var(--token-on-accent, #fff);
113
+ }
114
+ .tag-chip-x:focus-visible {
115
+ outline: none;
116
+ opacity: 1;
117
+ box-shadow: var(--icen-ring);
40
118
  }
41
- .tag-chip-x:hover { background: var(--token-fill-2); }
119
+ .tag-chip-x svg { width: 10px; height: 10px; }
42
120
 
43
121
  .tag-input-field {
44
- flex: 1; min-width: 80px; padding: 4px;
45
- background: transparent; border: none; outline: none;
46
- color: var(--token-text); font: inherit; font-size: 12px;
122
+ flex: 1;
123
+ min-width: 80px;
124
+ padding: 2px;
125
+ background: transparent;
126
+ border: none;
127
+ outline: none;
128
+ color: var(--token-text);
129
+ font: inherit;
130
+ font-size: var(--density-font-size-sm);
131
+ }
132
+ .tag-input-field::placeholder {
133
+ color: color-mix(in srgb, var(--token-text-faint) 60%, transparent);
134
+ }
135
+
136
+ /* 重复值抖动反馈(behavior 短暂挂 is-shake) */
137
+ .tag-input.is-shake {
138
+ animation: tag-shake 0.32s var(--ease-out);
139
+ }
140
+ @keyframes tag-shake {
141
+ 0%, 100% { transform: translateX(0); }
142
+ 20%, 60% { transform: translateX(-3px); }
143
+ 40%, 80% { transform: translateX(3px); }
47
144
  }
48
- .tag-input-field::placeholder { color: color-mix(in srgb, var(--token-text-faint) 60%, transparent); }
@@ -0,0 +1,3 @@
1
+ // @icen.ai/ui — kit: tag-input(CSS + behavior 一行入口;构建产物,勿手改)
2
+ import './tag-input.css';
3
+ export * from '../behaviors/tag-input.mjs';
@@ -0,0 +1,2 @@
1
+ // @icen.ai/ui — kit: timeline(CSS + behavior 一行入口;构建产物,勿手改)
2
+ import './content.css';
@@ -1,27 +1,100 @@
1
1
  /*
2
2
  * @icen.ai/ui — Component: toast(轻提示,与 behaviors/toast 配套)
3
+ *
3
4
  * 容器固定在右下角,左缘 3px 语义色条;滑入动画用 motion token。
5
+ *
6
+ * 完整契约:
7
+ * <div class="toast-container" role="status" aria-live="polite">
8
+ * <div class="toast [ok|err|warn]" role="status|alert">
9
+ * <span class="toast-msg">文本</span>
10
+ * <button class="toast-action">撤销</button> ← 可选 action
11
+ * </div>
12
+ * </div>
13
+ *
14
+ * behavior 自动维护 role 与 aria-live。
4
15
  */
5
16
 
6
17
  .toast-container {
7
- position: fixed; right: 20px; bottom: 20px; z-index: var(--z-toast);
8
- display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
18
+ position: fixed;
19
+ right: var(--density-space-md);
20
+ bottom: var(--density-space-md);
21
+ z-index: var(--z-toast);
22
+ display: flex;
23
+ flex-direction: column;
24
+ gap: var(--density-space-sm);
25
+ align-items: flex-end;
9
26
  pointer-events: none;
10
27
  }
28
+
11
29
  .toast {
12
30
  pointer-events: auto;
13
- background: var(--token-surface); color: var(--token-text);
14
- border: 1px solid var(--token-line-soft); border-left: 3px solid var(--token-line-strong);
15
- border-radius: var(--radius-sm); box-shadow: var(--token-shadow-overlay);
16
- padding: 11px 16px; font-size: 13px; max-width: 360px;
17
- animation: icen-toast-in var(--duration-slow) var(--ease-out);
18
- }
19
- .toast.ok { border-left-color: var(--token-success); }
20
- .toast.err { border-left-color: var(--token-error); }
31
+ display: inline-flex;
32
+ align-items: center;
33
+ gap: var(--density-space-sm);
34
+ background: var(--token-surface);
35
+ color: var(--token-text);
36
+ border: 1px solid var(--token-line-soft);
37
+ border-left: 3px solid var(--token-line-strong);
38
+ border-radius: var(--radius-sm);
39
+ box-shadow: var(--token-shadow-overlay);
40
+ padding: var(--density-space-sm) var(--density-space-md);
41
+ font-size: var(--density-font-size-md);
42
+ line-height: 1.4;
43
+ max-width: 380px;
44
+ animation: icen-toast-in var(--icen-tx-slow);
45
+ }
46
+
47
+ /* 语义色:左缘 3px 强调 */
48
+ .toast.ok { border-left-color: var(--token-success); }
49
+ .toast.err { border-left-color: var(--token-error); }
21
50
  .toast.warn { border-left-color: var(--token-warning); }
22
- .toast.leaving { opacity: 0; transform: translateY(8px); transition: opacity var(--duration-normal) var(--ease-out), transform var(--duration-normal) var(--ease-out); }
51
+
52
+ .toast-msg {
53
+ flex: 1;
54
+ min-width: 0;
55
+ word-break: break-word;
56
+ }
57
+
58
+ .toast-action {
59
+ flex-shrink: 0;
60
+ padding: 0;
61
+ background: none;
62
+ border: 0;
63
+ cursor: pointer;
64
+ color: var(--token-accent);
65
+ font: inherit;
66
+ font-size: var(--density-font-size-sm);
67
+ font-weight: 500;
68
+ text-decoration: underline;
69
+ text-underline-offset: 3px;
70
+ -webkit-tap-highlight-color: transparent;
71
+ transition: color var(--icen-tx-fast);
72
+ }
73
+ .toast-action:hover { color: var(--token-accent-deep, var(--token-accent)); }
74
+ .toast-action:focus-visible {
75
+ outline: none;
76
+ border-radius: var(--radius-xs);
77
+ box-shadow: var(--icen-ring);
78
+ }
79
+
80
+ .toast.leaving {
81
+ opacity: 0;
82
+ transform: translateY(8px);
83
+ transition:
84
+ opacity var(--icen-tx-normal),
85
+ transform var(--icen-tx-normal);
86
+ }
23
87
 
24
88
  @keyframes icen-toast-in {
25
89
  from { opacity: 0; transform: translateY(8px); }
26
- to { opacity: 1; transform: translateY(0); }
90
+ to { opacity: 1; transform: translateY(0); }
91
+ }
92
+
93
+ @media (max-width: 480px) {
94
+ .toast-container { right: var(--density-space-sm); bottom: var(--density-space-sm); left: var(--density-space-sm); align-items: stretch; }
95
+ .toast { max-width: none; }
96
+ }
97
+
98
+ @media (prefers-reduced-motion: reduce) {
99
+ .toast { animation: none; }
27
100
  }
@@ -0,0 +1,3 @@
1
+ // @icen.ai/ui — kit: toast(CSS + behavior 一行入口;构建产物,勿手改)
2
+ import './toast.css';
3
+ export * from '../behaviors/toast.mjs';
@@ -1,56 +1,116 @@
1
1
  /*
2
2
  * @icen.ai/ui — Component: tooltip(纯 CSS 气泡提示,无 JS)
3
- * 契约:任意元素加 data-tooltip="文案";默认在上方,
4
- * data-tooltip-side="top|bottom|left|right" 换方向。
5
- * hover 延迟 400ms 出现,focus-visible 立即出现。
3
+ *
4
+ * 完整契约:
5
+ * <button data-tooltip="提示文案" data-tooltip-side="top|bottom|left|right" data-tooltip-align="start|center|end">
6
+ * 多行:data-tooltip-multiline="true" 允许换行(默认 whitespace nowrap 截断)
7
+ * 无障碍:键盘 :focus-visible 立即出现(无延迟),鼠标 hover 延迟 400ms。
6
8
  */
7
9
 
8
10
  [data-tooltip] { position: relative; }
9
11
 
10
12
  [data-tooltip]::after {
11
13
  content: attr(data-tooltip);
12
- position: absolute; z-index: var(--z-tooltip);
13
- width: max-content; max-width: min(260px, calc(100vw - 32px));
14
- padding: 4px 8px;
15
- font-size: 11px; font-weight: 400; line-height: 1.375; white-space: normal; text-align: left;
16
- background: var(--token-card-strong); color: var(--token-text);
17
- border: 1px solid var(--token-outline-soft);
18
- box-shadow: var(--token-shadow-overlay);
19
- border-radius: var(--radius-md);
20
- opacity: 0; pointer-events: none;
21
- transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out);
14
+ position: absolute;
15
+ z-index: var(--z-tooltip);
16
+ width: max-content;
17
+ max-width: min(260px, calc(100vw - 32px));
18
+ padding: 4px var(--density-space-xs);
19
+ font-size: var(--density-font-size-xs);
20
+ font-weight: 400;
21
+ line-height: 1.4;
22
+ white-space: nowrap;
23
+ text-overflow: ellipsis;
24
+ overflow: hidden;
25
+ background: color-mix(in srgb, var(--token-text) 92%, var(--token-bg));
26
+ color: var(--token-bg);
27
+ border: 1px solid var(--token-line);
28
+ box-shadow: var(--token-shadow-elevated);
29
+ border-radius: var(--radius-sm);
30
+ opacity: 0;
31
+ pointer-events: none;
32
+ transition:
33
+ opacity var(--icen-tx-fast),
34
+ transform var(--icen-tx-fast);
22
35
  transition-delay: 400ms;
23
36
 
24
- /* 默认:上方 */
25
- bottom: calc(100% + 4px); left: 50%;
37
+ /* 默认:上方、水平居中 */
38
+ bottom: calc(100% + 6px);
39
+ left: 50%;
26
40
  transform: translate(-50%, 4px);
27
41
  }
28
42
 
43
+ /* 多行模式 */
44
+ [data-tooltip-multiline='true']::after {
45
+ white-space: normal;
46
+ max-width: min(320px, calc(100vw - 32px));
47
+ }
48
+
49
+ /* ── 方向 ── */
29
50
  [data-tooltip-side='bottom']::after {
30
- bottom: auto; top: calc(100% + 4px); left: 50%;
51
+ bottom: auto;
52
+ top: calc(100% + 6px);
53
+ left: 50%;
31
54
  transform: translate(-50%, -4px);
32
55
  }
33
56
  [data-tooltip-side='left']::after {
34
- bottom: auto; top: 50%; left: auto; right: calc(100% + 4px);
57
+ bottom: auto;
58
+ top: 50%;
59
+ left: auto;
60
+ right: calc(100% + 6px);
35
61
  transform: translate(4px, -50%);
36
62
  }
37
63
  [data-tooltip-side='right']::after {
38
- bottom: auto; top: 50%; right: auto; left: calc(100% + 4px);
64
+ bottom: auto;
65
+ top: 50%;
66
+ right: auto;
67
+ left: calc(100% + 6px);
39
68
  transform: translate(-4px, -50%);
40
69
  }
41
70
 
42
- [data-tooltip]:hover::after, [data-tooltip]:focus-visible::after {
43
- opacity: 1; transform: translate(-50%, 0);
71
+ /* ── 对齐(仅 top/bottom 方向生效)── */
72
+ [data-tooltip-align='start']::after { left: 0; transform: translate(0, 4px); }
73
+ [data-tooltip-align='end']::after { left: auto; right: 0; transform: translate(0, 4px); }
74
+ [data-tooltip-side='bottom'][data-tooltip-align='start']::after { transform: translate(0, -4px); }
75
+ [data-tooltip-side='bottom'][data-tooltip-align='end']::after { transform: translate(0, -4px); }
76
+
77
+ /* ── 出现:hover/focus-visible ── */
78
+ [data-tooltip]:hover::after,
79
+ [data-tooltip]:focus-visible::after {
80
+ opacity: 1;
81
+ transform: translate(-50%, 0);
44
82
  }
45
- [data-tooltip-side='bottom']:hover::after, [data-tooltip-side='bottom']:focus-visible::after {
46
- opacity: 1; transform: translate(-50%, 0);
83
+ [data-tooltip-side='bottom']:hover::after,
84
+ [data-tooltip-side='bottom']:focus-visible::after {
85
+ transform: translate(-50%, 0);
47
86
  }
48
- [data-tooltip-side='left']:hover::after, [data-tooltip-side='left']:focus-visible::after {
49
- opacity: 1; transform: translate(0, -50%);
87
+ [data-tooltip-side='left']:hover::after,
88
+ [data-tooltip-side='left']:focus-visible::after {
89
+ transform: translate(0, -50%);
50
90
  }
51
- [data-tooltip-side='right']:hover::after, [data-tooltip-side='right']:focus-visible::after {
52
- opacity: 1; transform: translate(0, -50%);
91
+ [data-tooltip-side='right']:hover::after,
92
+ [data-tooltip-side='right']:focus-visible::after {
93
+ transform: translate(0, -50%);
53
94
  }
54
95
 
96
+ /* align 起效(覆盖 translateX 的 -50%) */
97
+ [data-tooltip-align='start']:hover::after,
98
+ [data-tooltip-align='start']:focus-visible::after { transform: translate(0, 0); }
99
+ [data-tooltip-align='end']:hover::after,
100
+ [data-tooltip-align='end']:focus-visible::after { transform: translate(0, 0); }
101
+ [data-tooltip-side='bottom'][data-tooltip-align='start']:hover::after,
102
+ [data-tooltip-side='bottom'][data-tooltip-align='start']:focus-visible::after { transform: translate(0, 0); }
103
+ [data-tooltip-side='bottom'][data-tooltip-align='end']:hover::after,
104
+ [data-tooltip-side='bottom'][data-tooltip-align='end']:focus-visible::after { transform: translate(0, 0); }
105
+
55
106
  /* 键盘聚焦立即出现(覆盖 400ms 延迟) */
56
107
  [data-tooltip]:focus-visible::after { transition-delay: 0ms; }
108
+
109
+ @media (prefers-reduced-motion: reduce) {
110
+ [data-tooltip]::after {
111
+ transition: opacity var(--icen-tx-fast);
112
+ transform: none !important;
113
+ }
114
+ [data-tooltip]:hover::after,
115
+ [data-tooltip]:focus-visible::after { transform: none !important; }
116
+ }
@@ -0,0 +1,2 @@
1
+ // @icen.ai/ui — kit: tooltip(CSS + behavior 一行入口;构建产物,勿手改)
2
+ import './tooltip.css';
@@ -0,0 +1,3 @@
1
+ // @icen.ai/ui — kit: tree(CSS + behavior 一行入口;构建产物,勿手改)
2
+ import './content.css';
3
+ export * from '../behaviors/tree.mjs';