@icen.ai/ui 0.9.0 → 0.10.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 (281) hide show
  1. package/AGENTS.md +138 -80
  2. package/README.md +66 -91
  3. package/dist/base.css +208 -179
  4. package/dist/behaviors/accordion.mjs +8 -8
  5. package/dist/behaviors/ai-branch.d.mts +1 -1
  6. package/dist/behaviors/ai-branch.mjs +1010 -94
  7. package/dist/behaviors/ai-chat.d.mts +7 -7
  8. package/dist/behaviors/ai-chat.mjs +1071 -161
  9. package/dist/behaviors/ai-composer.d.mts +44 -12
  10. package/dist/behaviors/ai-composer.mjs +1997 -524
  11. package/dist/behaviors/ai-core.d.mts +1 -1
  12. package/dist/behaviors/ai-core.mjs +1016 -107
  13. package/dist/behaviors/ai-diff.mjs +1019 -127
  14. package/dist/behaviors/ai-feedback.d.mts +1 -1
  15. package/dist/behaviors/ai-feedback.mjs +1035 -126
  16. package/dist/behaviors/ai-panel.d.mts +8 -8
  17. package/dist/behaviors/ai-panel.mjs +1284 -266
  18. package/dist/behaviors/ai-provider.mjs +1003 -101
  19. package/dist/behaviors/ai-threads.d.mts +1 -1
  20. package/dist/behaviors/ai-threads.mjs +1068 -154
  21. package/dist/behaviors/ai-tool.d.mts +2 -2
  22. package/dist/behaviors/ai-tool.mjs +2037 -396
  23. package/dist/behaviors/ai-tools.d.mts +89 -16
  24. package/dist/behaviors/ai-tools.mjs +4448 -372
  25. package/dist/behaviors/autocomplete.d.mts +53 -0
  26. package/dist/behaviors/autocomplete.mjs +1600 -0
  27. package/dist/behaviors/back-top.d.mts +1 -1
  28. package/dist/behaviors/back-top.mjs +951 -14
  29. package/dist/behaviors/carousel.d.mts +1 -1
  30. package/dist/behaviors/carousel.mjs +906 -11
  31. package/dist/behaviors/cascader.d.mts +48 -0
  32. package/dist/behaviors/cascader.mjs +1853 -0
  33. package/dist/behaviors/charts.d.mts +72 -8
  34. package/dist/behaviors/charts.mjs +1901 -256
  35. package/dist/behaviors/code-block.d.mts +36 -0
  36. package/dist/behaviors/code-block.mjs +1611 -0
  37. package/dist/behaviors/command-palette.d.mts +9 -6
  38. package/dist/behaviors/command-palette.mjs +161 -59
  39. package/dist/behaviors/context-menu.d.mts +9 -8
  40. package/dist/behaviors/context-menu.mjs +1112 -44
  41. package/dist/behaviors/controls.d.mts +13 -13
  42. package/dist/behaviors/controls.mjs +989 -130
  43. package/dist/behaviors/copy.d.mts +21 -2
  44. package/dist/behaviors/copy.mjs +1206 -42
  45. package/dist/behaviors/datatable.d.mts +53 -3
  46. package/dist/behaviors/datatable.mjs +1963 -207
  47. package/dist/behaviors/date-picker.d.mts +0 -1
  48. package/dist/behaviors/date-picker.mjs +1340 -293
  49. package/dist/behaviors/design.d.mts +54 -0
  50. package/dist/behaviors/design.mjs +109 -0
  51. package/dist/behaviors/dropdown.d.mts +5 -6
  52. package/dist/behaviors/dropdown.mjs +262 -110
  53. package/dist/behaviors/events.d.mts +120 -3
  54. package/dist/behaviors/events.mjs +47 -2
  55. package/dist/behaviors/feedback.d.mts +30 -0
  56. package/dist/behaviors/feedback.mjs +296 -0
  57. package/dist/behaviors/focus.d.mts +8 -0
  58. package/dist/behaviors/focus.mjs +24 -0
  59. package/dist/behaviors/form-validate.d.mts +102 -0
  60. package/dist/behaviors/form-validate.mjs +6091 -0
  61. package/dist/behaviors/i18n.d.mts +789 -0
  62. package/dist/behaviors/i18n.mjs +1711 -0
  63. package/dist/behaviors/icons.d.mts +93 -0
  64. package/dist/behaviors/icons.mjs +113 -0
  65. package/dist/behaviors/input.d.mts +9 -1
  66. package/dist/behaviors/input.mjs +1056 -60
  67. package/dist/behaviors/kb-access.d.mts +1 -1
  68. package/dist/behaviors/kb-access.mjs +2129 -239
  69. package/dist/behaviors/kb-acl.d.mts +6 -6
  70. package/dist/behaviors/kb-acl.mjs +1119 -179
  71. package/dist/behaviors/kb-answer.mjs +2070 -418
  72. package/dist/behaviors/kb-audit.d.mts +1 -1
  73. package/dist/behaviors/kb-audit.mjs +1076 -154
  74. package/dist/behaviors/kb-canvas.mjs +1100 -177
  75. package/dist/behaviors/kb-chain.mjs +1022 -100
  76. package/dist/behaviors/kb-checkpoint.d.mts +1 -1
  77. package/dist/behaviors/kb-checkpoint.mjs +1319 -169
  78. package/dist/behaviors/kb-chunks.mjs +1152 -213
  79. package/dist/behaviors/kb-citation.d.mts +1 -1
  80. package/dist/behaviors/kb-citation.mjs +1201 -179
  81. package/dist/behaviors/kb-clarify.mjs +1058 -130
  82. package/dist/behaviors/kb-conflict.mjs +1041 -119
  83. package/dist/behaviors/kb-connector.mjs +1104 -176
  84. package/dist/behaviors/kb-core.d.mts +6 -1
  85. package/dist/behaviors/kb-core.mjs +1077 -162
  86. package/dist/behaviors/kb-eval.mjs +1971 -144
  87. package/dist/behaviors/kb-explain.d.mts +1 -1
  88. package/dist/behaviors/kb-explain.mjs +1024 -102
  89. package/dist/behaviors/kb-filter.mjs +2008 -178
  90. package/dist/behaviors/kb-gap.d.mts +1 -1
  91. package/dist/behaviors/kb-gap.mjs +1043 -121
  92. package/dist/behaviors/kb-hittest.d.mts +1 -1
  93. package/dist/behaviors/kb-hittest.mjs +1093 -150
  94. package/dist/behaviors/kb-metadata.mjs +1052 -130
  95. package/dist/behaviors/kb-passage.d.mts +2 -2
  96. package/dist/behaviors/kb-passage.mjs +1101 -161
  97. package/dist/behaviors/kb-pipeline.d.mts +2 -2
  98. package/dist/behaviors/kb-pipeline.mjs +1082 -162
  99. package/dist/behaviors/kb-qa.mjs +1088 -160
  100. package/dist/behaviors/kb-rerank.mjs +1047 -114
  101. package/dist/behaviors/kb-retrieval.mjs +2063 -224
  102. package/dist/behaviors/kb-review.mjs +1990 -159
  103. package/dist/behaviors/kb-sandbox.d.mts +1 -1
  104. package/dist/behaviors/kb-sandbox.mjs +1026 -104
  105. package/dist/behaviors/kb-segment.mjs +1111 -179
  106. package/dist/behaviors/kb-select.d.mts +24 -0
  107. package/dist/behaviors/kb-select.mjs +1989 -0
  108. package/dist/behaviors/kb-sources.d.mts +1 -1
  109. package/dist/behaviors/kb-sources.mjs +1084 -170
  110. package/dist/behaviors/kb-sql.d.mts +1 -1
  111. package/dist/behaviors/kb-sql.mjs +1143 -226
  112. package/dist/behaviors/kb-trace.d.mts +1 -1
  113. package/dist/behaviors/kb-trace.mjs +1042 -128
  114. package/dist/behaviors/kb-visibility.mjs +1086 -158
  115. package/dist/behaviors/kb-who-can.mjs +1974 -137
  116. package/dist/behaviors/mentions.d.mts +93 -0
  117. package/dist/behaviors/mentions.mjs +2152 -0
  118. package/dist/behaviors/modal.d.mts +4 -3
  119. package/dist/behaviors/modal.mjs +1055 -33
  120. package/dist/behaviors/nav.d.mts +1 -1
  121. package/dist/behaviors/nav.mjs +6 -6
  122. package/dist/behaviors/notification.d.mts +16 -8
  123. package/dist/behaviors/notification.mjs +1615 -265
  124. package/dist/behaviors/panel.d.mts +4 -0
  125. package/dist/behaviors/panel.mjs +994 -0
  126. package/dist/behaviors/popover.d.mts +28 -5
  127. package/dist/behaviors/popover.mjs +225 -24
  128. package/dist/behaviors/select.d.mts +5 -2
  129. package/dist/behaviors/select.mjs +1410 -117
  130. package/dist/behaviors/sidebar.d.mts +1 -1
  131. package/dist/behaviors/sidebar.mjs +13 -13
  132. package/dist/behaviors/slider.d.mts +1 -1
  133. package/dist/behaviors/slider.mjs +9 -9
  134. package/dist/behaviors/split-pane.d.mts +1 -1
  135. package/dist/behaviors/split-pane.mjs +7 -7
  136. package/dist/behaviors/suggestions.d.mts +27 -0
  137. package/dist/behaviors/suggestions.mjs +1089 -0
  138. package/dist/behaviors/svg-parse.d.mts +14 -0
  139. package/dist/behaviors/svg-parse.mjs +37 -0
  140. package/dist/behaviors/tabs.d.mts +2 -2
  141. package/dist/behaviors/tabs.mjs +25 -25
  142. package/dist/behaviors/tag-input.d.mts +23 -5
  143. package/dist/behaviors/tag-input.mjs +1359 -104
  144. package/dist/behaviors/theme-switcher.d.mts +24 -0
  145. package/dist/behaviors/theme-switcher.mjs +1981 -0
  146. package/dist/behaviors/theme.d.mts +15 -8
  147. package/dist/behaviors/theme.mjs +390 -28
  148. package/dist/behaviors/toast.d.mts +24 -25
  149. package/dist/behaviors/toast.mjs +1266 -88
  150. package/dist/behaviors/tooltip.d.mts +4 -0
  151. package/dist/behaviors/tooltip.mjs +378 -0
  152. package/dist/behaviors/tree-select.d.mts +69 -0
  153. package/dist/behaviors/tree-select.mjs +1907 -0
  154. package/dist/behaviors/tree.d.mts +1 -1
  155. package/dist/behaviors/tree.mjs +15 -15
  156. package/dist/behaviors/upload.d.mts +3 -2
  157. package/dist/behaviors/upload.mjs +1076 -66
  158. package/dist/cli.mjs +5 -6
  159. package/dist/components/ai-chat.css +666 -573
  160. package/dist/components/ai-diff.css +153 -132
  161. package/dist/components/ai-panel.css +351 -343
  162. package/dist/components/ai-tool.css +393 -238
  163. package/dist/components/autocomplete.css +61 -0
  164. package/dist/components/autocomplete.mjs +3 -0
  165. package/dist/components/back-top.css +34 -31
  166. package/dist/components/badge.css +44 -41
  167. package/dist/components/breadcrumb.css +67 -46
  168. package/dist/components/btn.css +80 -74
  169. package/dist/components/card.css +117 -106
  170. package/dist/components/cascader.css +311 -0
  171. package/dist/components/cascader.mjs +3 -0
  172. package/dist/components/chart-area.css +8 -2
  173. package/dist/components/chart-bar.css +95 -33
  174. package/dist/components/chart-gauge.css +14 -11
  175. package/dist/components/chart-graph.css +20 -17
  176. package/dist/components/chart-heatmap.css +96 -90
  177. package/dist/components/chart-line.css +8 -3
  178. package/dist/components/chart-pie.css +9 -6
  179. package/dist/components/chart-radar.css +8 -5
  180. package/dist/components/chart-scatter.css +9 -6
  181. package/dist/components/chart-sparkline.css +5 -2
  182. package/dist/components/chart-stack.css +14 -11
  183. package/dist/components/charts.css +164 -73
  184. package/dist/components/code-block.css +418 -0
  185. package/dist/components/code-block.mjs +4 -0
  186. package/dist/components/command-palette.css +138 -117
  187. package/dist/components/content.css +257 -251
  188. package/dist/components/copy.css +72 -44
  189. package/dist/components/datatable.css +423 -181
  190. package/dist/components/date-picker.css +135 -104
  191. package/dist/components/empty.css +68 -65
  192. package/dist/components/feedback.css +201 -183
  193. package/dist/components/form-validate.css +120 -0
  194. package/dist/components/form-validate.mjs +3 -0
  195. package/dist/components/form.css +150 -127
  196. package/dist/components/icon.css +102 -0
  197. package/dist/components/icon.mjs +3 -0
  198. package/dist/components/input.css +159 -104
  199. package/dist/components/kb-agent.css +188 -173
  200. package/dist/components/kb-data.css +257 -253
  201. package/dist/components/kb-ground.css +197 -185
  202. package/dist/components/kb-ingest.css +334 -350
  203. package/dist/components/kb-ops.css +265 -259
  204. package/dist/components/kb-perm.css +260 -271
  205. package/dist/components/kb-search.css +317 -360
  206. package/dist/components/kb.css +120 -109
  207. package/dist/components/layout.css +85 -82
  208. package/dist/components/material-chinese.css +73 -0
  209. package/dist/components/material-soviet.css +76 -0
  210. package/dist/components/material.css +275 -0
  211. package/dist/components/media.css +220 -166
  212. package/dist/components/mentions.css +189 -0
  213. package/dist/components/mentions.mjs +3 -0
  214. package/dist/components/menu.css +113 -105
  215. package/dist/components/modal.css +107 -112
  216. package/dist/components/nav.css +118 -115
  217. package/dist/components/notification.css +238 -174
  218. package/dist/components/pagination.css +56 -53
  219. package/dist/components/panel.css +66 -63
  220. package/dist/components/panel.mjs +1 -0
  221. package/dist/components/pill.css +81 -71
  222. package/dist/components/popover.css +67 -53
  223. package/dist/components/scroll-area.css +113 -110
  224. package/dist/components/segmented.css +146 -143
  225. package/dist/components/select.css +206 -186
  226. package/dist/components/sidebar.css +137 -127
  227. package/dist/components/slider.css +117 -114
  228. package/dist/components/split-pane.css +112 -109
  229. package/dist/components/stat.css +112 -106
  230. package/dist/components/steps.css +109 -103
  231. package/dist/components/switch.css +138 -134
  232. package/dist/components/table.css +131 -107
  233. package/dist/components/tabs.css +114 -108
  234. package/dist/components/tag-input.css +48 -133
  235. package/dist/components/tag.css +81 -71
  236. package/dist/components/theme-switcher.css +105 -0
  237. package/dist/components/theme-switcher.mjs +3 -0
  238. package/dist/components/toast.css +100 -86
  239. package/dist/components/toolbar.css +45 -42
  240. package/dist/components/tooltip.css +102 -43
  241. package/dist/components/tooltip.mjs +1 -0
  242. package/dist/components/tree-select.css +416 -0
  243. package/dist/components/tree-select.mjs +3 -0
  244. package/dist/components/upload.css +135 -92
  245. package/dist/fonts/LICENSES/ark-pixel/OFL.txt +96 -0
  246. package/dist/fonts/LICENSES/cubic-11/OFL.txt +108 -0
  247. package/dist/fonts/LICENSES/galmuri/LICENSE.txt +93 -0
  248. package/dist/fonts/OFL.txt +96 -0
  249. package/dist/fonts/README.md +14 -0
  250. package/dist/fonts/fusion-pixel-12px-zh-hans.woff2 +0 -0
  251. package/dist/index.d.mts +28 -14
  252. package/dist/index.mjs +20705 -9601
  253. package/dist/react.d.mts +91 -0
  254. package/dist/react.mjs +8208 -0
  255. package/dist/registry.json +130 -13
  256. package/dist/tokens/chinese.css +44 -0
  257. package/dist/tokens/colors.css +365 -1222
  258. package/dist/tokens/design.css +109 -0
  259. package/dist/tokens/dtcg.json +11198 -0
  260. package/dist/tokens/figma.variables.json +7017 -0
  261. package/dist/tokens/icon-masks.css +78 -0
  262. package/dist/tokens/pixel.css +50 -0
  263. package/dist/tokens/soviet.css +44 -0
  264. package/dist/tokens/style-profiles.css +36 -547
  265. package/dist/tokens/themes.json +308 -0
  266. package/dist/tokens/tokens-studio.json +6728 -0
  267. package/dist/tokens/typography.css +21 -18
  268. package/dist/tokens.css +1555 -1801
  269. package/dist/ui.css +11975 -9831
  270. package/dist/vue.d.mts +344 -0
  271. package/dist/vue.mjs +7781 -0
  272. package/docs/spec/ai-input-experience.md +75 -0
  273. package/docs/spec/ai-native.md +238 -147
  274. package/docs/spec/design-philosophy.md +189 -0
  275. package/docs/spec/design-primitives.md +196 -0
  276. package/docs/spec/kb-family.md +147 -115
  277. package/package.json +43 -8
  278. package/dist/retro-effects.css +0 -255
  279. package/dist/tokens/retro-effects.css +0 -255
  280. package/docs/research/2026-10-03-ai-kb-components.md +0 -392
  281. package/docs/research/2026-10-03-kb-permissions.md +0 -992
@@ -2,12 +2,15 @@ import { ChartEventDetail } from './charts.js';
2
2
  import { AiUsage } from './ai-core.js';
3
3
  import { AiDoneEventDetail } from './ai-provider.js';
4
4
  import { AiComposerRefSource } from './ai-composer.js';
5
+ import { MentionEntity, MentionValue } from './mentions.js';
5
6
  import { KbCitation, KbSegmentConfig, KbRetrievalQuery, KbFilterNode, KbCheckpointScope, KbSandboxMessage, KbChainStep, KbAclEntry, KbIdentity, KbAclDecision, KbAccessRequest, KbRole, KbAuditChannel, KbHygieneIssue } from './kb-core.js';
7
+ import './icons.js';
6
8
  import './popover.js';
7
9
  import './ai-panel.js';
10
+ import './suggestions.js';
8
11
 
9
12
  interface IcenGestureDetail {
10
- /** 手势命中源:最近的 [data-gestures] 宿主 */
13
+ /** 手势命中源:最近的 [data-icen-gestures] 宿主 */
11
14
  source: HTMLElement;
12
15
  /** 原始 DOM 事件(click / contextmenu / pointerdown / mouseup…) */
13
16
  originalEvent: Event;
@@ -20,6 +23,8 @@ interface IcenGestureDetail {
20
23
  type IcenPolicy = (e: CustomEvent<IcenGestureDetail>) => void;
21
24
  /** 手势层事件名(策略层只认这五种,编译期收死)。 */
22
25
  type IcenGestureEvent = 'icen:click' | 'icen:dblclick' | 'icen:contextmenu' | 'icen:longpress' | 'icen:text-select';
26
+ /** 滑动手势事件名(策略层不收——swipe 只有事件语义,无全站默认行为需求)。 */
27
+ type IcenSwipeEvent = 'icen:swipe-left' | 'icen:swipe-right' | 'icen:swipe-up' | 'icen:swipe-down';
23
28
  /**
24
29
  * 全库事件注册表:事件名 → detail 契约。onIcen 推断、emitIcen 校验,双侧同表。
25
30
  * 新增事件必须在此登记(模板签名兜底只留给宿主自定义事件)。
@@ -30,6 +35,25 @@ interface IcenEventMap {
30
35
  'icen:contextmenu': IcenGestureDetail;
31
36
  'icen:longpress': IcenGestureDetail;
32
37
  'icen:text-select': IcenGestureDetail;
38
+ 'icen:swipe-left': IcenGestureDetail & {
39
+ dx: number;
40
+ dy: number;
41
+ };
42
+ 'icen:swipe-right': IcenGestureDetail & {
43
+ dx: number;
44
+ dy: number;
45
+ };
46
+ 'icen:swipe-up': IcenGestureDetail & {
47
+ dx: number;
48
+ dy: number;
49
+ };
50
+ 'icen:swipe-down': IcenGestureDetail & {
51
+ dx: number;
52
+ dy: number;
53
+ };
54
+ 'icen:locale-change': {
55
+ changed: string[];
56
+ };
33
57
  'icen:chart-hover': ChartEventDetail;
34
58
  'icen:chart-click': ChartEventDetail;
35
59
  'icen:chart-dblclick': ChartEventDetail;
@@ -42,6 +66,12 @@ interface IcenEventMap {
42
66
  'icen:chart-legend-visibility': {
43
67
  visible: boolean;
44
68
  };
69
+ /** 缩放/刷选(renderChart spec.zoom):类目索引区间 [from, to](含端点) */
70
+ 'icen:chart-zoom': {
71
+ chart: string;
72
+ from: number;
73
+ to: number;
74
+ };
45
75
  'icen:tab-change': {
46
76
  tab: HTMLElement | null;
47
77
  panel: HTMLElement | null;
@@ -118,6 +148,11 @@ interface IcenEventMap {
118
148
  text: string;
119
149
  reason: string;
120
150
  };
151
+ 'icen:code-block-toggle': {
152
+ el: HTMLElement;
153
+ action: 'num' | 'wrap' | 'fold';
154
+ value: boolean;
155
+ };
121
156
  'icen:back-top': Record<string, never>;
122
157
  'icen:modal-open': {
123
158
  id: string;
@@ -142,6 +177,10 @@ interface IcenEventMap {
142
177
  value: string;
143
178
  date: Date | null;
144
179
  };
180
+ 'icen:panel-toggle': {
181
+ panel: HTMLElement;
182
+ expanded: boolean;
183
+ };
145
184
  'icen:accordion-toggle': {
146
185
  item: HTMLElement;
147
186
  index: number;
@@ -199,6 +238,65 @@ interface IcenEventMap {
199
238
  'icen:table-export': {
200
239
  count: number;
201
240
  };
241
+ /** 单元格编辑提交(editable 列;宿主应用数据后调 handle.updateCell 或 setData) */
242
+ 'icen:table-cell-edit': {
243
+ rowKey: string;
244
+ field: string;
245
+ value: unknown;
246
+ row: unknown;
247
+ };
248
+ /** 列拖拽重排完成 */
249
+ 'icen:table-column-reorder': {
250
+ key: string;
251
+ fromIndex: number;
252
+ toIndex: number;
253
+ };
254
+ /** 分组行展开/折叠 */
255
+ 'icen:table-group-toggle': {
256
+ key: string;
257
+ collapsed: boolean;
258
+ };
259
+ /** 列宽拖拽完成(拖动过程中不派发,防事件洪泛) */
260
+ 'icen:table-column-resize': {
261
+ key: string;
262
+ width: string;
263
+ };
264
+ 'icen:form-field-validate': {
265
+ name: string;
266
+ valid: boolean;
267
+ message?: string;
268
+ };
269
+ 'icen:form-valid': {
270
+ names: string[];
271
+ };
272
+ 'icen:form-invalid': {
273
+ errors: Record<string, string>;
274
+ first: string | null;
275
+ };
276
+ 'icen:cascader-change': {
277
+ value: string[];
278
+ path: string[];
279
+ };
280
+ 'icen:tree-select-change': {
281
+ value: string[];
282
+ labels: string[];
283
+ };
284
+ 'icen:mention-select': {
285
+ item: MentionEntity<unknown>;
286
+ query: string;
287
+ };
288
+ 'icen:mention-change': {
289
+ value: MentionValue<unknown>[];
290
+ text: string;
291
+ mentions: MentionEntity<unknown>[];
292
+ };
293
+ 'icen:autocomplete-select': {
294
+ value: string;
295
+ label: string;
296
+ };
297
+ 'icen:autocomplete-change': {
298
+ value: string;
299
+ };
202
300
  'icen:upload': {
203
301
  files: File[];
204
302
  };
@@ -235,10 +333,14 @@ interface IcenEventMap {
235
333
  };
236
334
  'icen:ai-send': {
237
335
  text: string;
336
+ refs?: AiComposerRefSource[];
337
+ files?: File[];
238
338
  };
239
339
  'icen:ai-stop': Record<string, never>;
240
340
  'icen:ai-queue': {
241
341
  text: string;
342
+ refs?: AiComposerRefSource[];
343
+ files?: File[];
242
344
  };
243
345
  'icen:ai-dequeue': {
244
346
  index: number;
@@ -246,6 +348,10 @@ interface IcenEventMap {
246
348
  'icen:ai-attach': {
247
349
  files: File[];
248
350
  };
351
+ 'icen:ai-attachment-remove': {
352
+ file: File;
353
+ files: File[];
354
+ };
249
355
  'icen:ai-model-change': {
250
356
  provider: string;
251
357
  model: string;
@@ -283,6 +389,17 @@ interface IcenEventMap {
283
389
  name: string;
284
390
  el: HTMLElement;
285
391
  };
392
+ /** 工具审批(requiresApproval 的工具在挂载卡上等待宿主裁决;approve 才执行 run) */
393
+ 'icen:ai-tool-approve': {
394
+ name: string;
395
+ input: Record<string, unknown>;
396
+ el: HTMLElement;
397
+ };
398
+ 'icen:ai-tool-reject': {
399
+ name: string;
400
+ input: Record<string, unknown>;
401
+ el: HTMLElement;
402
+ };
286
403
  'icen:ai-usage': AiUsage;
287
404
  'icen:ai-done': AiDoneEventDetail;
288
405
  'icen:ai-thread-select': {
@@ -491,7 +608,7 @@ interface IcenListenOptions {
491
608
  /**
492
609
  * 统一绑定器(全库事件一个入口):
493
610
  * onIcen('icen:tab-change', (e) => e.detail.index) 全局
494
- * onIcen('icen:chart-click', '.chart', (e) => …) 选择器委托
611
+ * onIcen('icen:chart-click', '.icen-chart', (e) => …) 选择器委托
495
612
  * onIcen('icen:upload', (e) => …, { within: formEl }) 子树限定
496
613
  * onIcen('icen:ai-done', (e) => …, { signal: ctrl.signal }) 广播 + 信号解绑
497
614
  * 返回解绑函数 —— React useEffect / Vue onUnmounted 直接 return。
@@ -520,4 +637,4 @@ declare function initGestures(): () => void;
520
637
  /** 摘除手势层委托(等同 initGestures 返回的销毁函数;未启动时为 no-op)。 */
521
638
  declare function destroyGestures(): void;
522
639
 
523
- export { type IcenEventMap, type IcenGestureDetail, type IcenGestureEvent, type IcenListenOptions, type IcenPolicy, destroyGestures, emitIcen, getEventPolicy, initGestures, onIcen, resetEventPolicies, setEventPolicy };
640
+ export { type IcenEventMap, type IcenGestureDetail, type IcenGestureEvent, type IcenListenOptions, type IcenPolicy, type IcenSwipeEvent, destroyGestures, emitIcen, getEventPolicy, initGestures, onIcen, resetEventPolicies, setEventPolicy };
@@ -55,10 +55,13 @@ var LONGPRESS_MS = 520;
55
55
  var LONGPRESS_MOVE = 12;
56
56
  var CLICK_DELAY = 220;
57
57
  var CLICK_DRAG_TOLERANCE = 5;
58
+ var SWIPE_MIN = 48;
59
+ var SWIPE_AXIS_RATIO = 2;
60
+ var SWIPE_SCROLL_HINT = 12;
58
61
  function gestureHost(e, name) {
59
62
  const t = e.target;
60
63
  if (!(t instanceof Element)) return null;
61
- return t.closest(`[data-gestures~="${name}"]`);
64
+ return t.closest(`[data-icen-gestures~="${name}"]`);
62
65
  }
63
66
  function pointOf(e) {
64
67
  return e instanceof MouseEvent || typeof PointerEvent !== "undefined" && e instanceof PointerEvent ? { x: e.clientX, y: e.clientY } : { x: 0, y: 0 };
@@ -105,7 +108,7 @@ function initGestures() {
105
108
  return;
106
109
  }
107
110
  if (isDragRelease(e)) return;
108
- if (host.matches('[data-gestures~="dblclick"]')) {
111
+ if (host.matches('[data-icen-gestures~="dblclick"]')) {
109
112
  if (clickTimer) clearTimeout(clickTimer);
110
113
  pending = { host, e };
111
114
  clickTimer = setTimeout(() => {
@@ -160,6 +163,39 @@ function initGestures() {
160
163
  if (!lp) return;
161
164
  if (Math.hypot(e.clientX - lp.x, e.clientY - lp.y) > LONGPRESS_MOVE) clearLp();
162
165
  };
166
+ let sw = null;
167
+ const clearSwipe = () => {
168
+ sw = null;
169
+ };
170
+ const onSwipeDown = (e) => {
171
+ const host = gestureHost(e, "swipe");
172
+ if (!host) return;
173
+ sw = { host, x: e.clientX, y: e.clientY, scroll: false };
174
+ };
175
+ const onSwipeMove = (e) => {
176
+ if (!sw) return;
177
+ const adx = Math.abs(e.clientX - sw.x);
178
+ const ady = Math.abs(e.clientY - sw.y);
179
+ if (ady > adx && ady >= SWIPE_SCROLL_HINT) sw.scroll = true;
180
+ };
181
+ const onSwipeUp = (e) => {
182
+ const cur = sw;
183
+ sw = null;
184
+ if (!cur) return;
185
+ const dx = e.clientX - cur.x;
186
+ const dy = e.clientY - cur.y;
187
+ const adx = Math.abs(dx);
188
+ const ady = Math.abs(dy);
189
+ const main = Math.max(adx, ady);
190
+ if (main < SWIPE_MIN) return;
191
+ if (Math.min(adx, ady) * SWIPE_AXIS_RATIO >= main) return;
192
+ let dir;
193
+ if (adx >= ady) dir = dx < 0 ? "left" : "right";
194
+ else dir = dy < 0 ? "up" : "down";
195
+ if (cur.scroll && (dir === "left" || dir === "right")) return;
196
+ const { x, y } = pointOf(e);
197
+ emitIcen(cur.host, `icen:swipe-${dir}`, { source: cur.host, originalEvent: e, x, y, dx, dy });
198
+ };
163
199
  const onTextSelect = (e) => {
164
200
  const host = gestureHost(e, "text-select");
165
201
  if (!host) return;
@@ -176,6 +212,10 @@ function initGestures() {
176
212
  document.addEventListener("pointermove", onLpMove);
177
213
  document.addEventListener("pointerup", clearLp);
178
214
  document.addEventListener("pointercancel", clearLp);
215
+ document.addEventListener("pointerdown", onSwipeDown);
216
+ document.addEventListener("pointermove", onSwipeMove);
217
+ document.addEventListener("pointerup", onSwipeUp);
218
+ document.addEventListener("pointercancel", clearSwipe);
179
219
  document.addEventListener("mouseup", onTextSelect);
180
220
  gesturesTeardown = () => {
181
221
  document.removeEventListener("pointerdown", onDownPos);
@@ -186,9 +226,14 @@ function initGestures() {
186
226
  document.removeEventListener("pointermove", onLpMove);
187
227
  document.removeEventListener("pointerup", clearLp);
188
228
  document.removeEventListener("pointercancel", clearLp);
229
+ document.removeEventListener("pointerdown", onSwipeDown);
230
+ document.removeEventListener("pointermove", onSwipeMove);
231
+ document.removeEventListener("pointerup", onSwipeUp);
232
+ document.removeEventListener("pointercancel", clearSwipe);
189
233
  document.removeEventListener("mouseup", onTextSelect);
190
234
  cancelPendingClick();
191
235
  clearLp();
236
+ clearSwipe();
192
237
  gesturesInit = false;
193
238
  gesturesTeardown = null;
194
239
  };
@@ -0,0 +1,30 @@
1
+ interface CountdownState {
2
+ duration: number;
3
+ remaining: number;
4
+ paused: boolean;
5
+ timer: number;
6
+ startedAt: number;
7
+ }
8
+ interface FeedbackClock {
9
+ pause(reason?: string): void;
10
+ resume(reason?: string): void;
11
+ reset(ms: number): void;
12
+ destroy(): void;
13
+ }
14
+ declare function createFeedbackClock(el: HTMLElement, state: CountdownState, expire: () => void, progress: string, pauseOnHover?: () => boolean): FeedbackClock;
15
+ type FeedbackAction = (signal: AbortSignal) => void | boolean | Promise<void | boolean>;
16
+ /** Cancel the UI continuation and signal cooperative work; stale promises never
17
+ * dismiss a replaced card or resurrect controls after the owner was destroyed. */
18
+ declare function cancelFeedbackAction(card: HTMLElement): void;
19
+ declare function runFeedbackAction(card: HTMLElement, button: HTMLButtonElement, action: FeedbackAction, hooks: {
20
+ busy(value: boolean): void;
21
+ complete(accepted: boolean): void;
22
+ error(error: unknown): void;
23
+ }): void;
24
+ declare function setFeedbackError(host: HTMLElement, message?: string): void;
25
+ /** Isolate caller text from the layout direction (CJK/Latin in an RTL shell). */
26
+ declare function setFeedbackText(host: HTMLElement, value: string): void;
27
+ declare function rememberFeedbackOrigin(card: HTMLElement): void;
28
+ declare function restoreFeedbackFocus(card: HTMLElement): void;
29
+
30
+ export { type CountdownState, type FeedbackAction, type FeedbackClock, cancelFeedbackAction, createFeedbackClock, rememberFeedbackOrigin, restoreFeedbackFocus, runFeedbackAction, setFeedbackError, setFeedbackText };
@@ -0,0 +1,296 @@
1
+ // src/behaviors/icons.ts
2
+ var ICON_PATHS = {
3
+ file: "M6 2.5h5.5L16 7v9.5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1v-12a2 2 0 0 1 2-2ZM11.5 2.5V7H16",
4
+ folder: "M3 5a1.5 1.5 0 0 1 1.5-1.5H8l2 2h5.5A1.5 1.5 0 0 1 17 7v8a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 3 15Z",
5
+ globe: "M17.5 10a7.5 7.5 0 1 1-15 0 7.5 7.5 0 0 1 15 0ZM2.5 10h15M10 2.5c-4 4-4 11 0 15 4-4 4-11 0-15Z",
6
+ document: "M6 2.5h5.5L16 7v9.5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1v-12a2 2 0 0 1 2-2ZM11.5 2.5V7H16M7 10.5h6M7 13.5h6",
7
+ agent: "M10 6V3M8 3h2M5 6h10a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2ZM1.5 10h1.5M17 10h1.5M7 10v2M13 10v2M8 14h4",
8
+ paperclip: "M14 7 8.3 12.7a1.6 1.6 0 0 1-2.3-2.3l6.3-6.3a3.2 3.2 0 0 1 4.5 4.5l-7 7a4.7 4.7 0 0 1-6.7-6.7l7-7",
9
+ stop: "M6.5 5h7A1.5 1.5 0 0 1 15 6.5v7a1.5 1.5 0 0 1-1.5 1.5h-7A1.5 1.5 0 0 1 5 13.5v-7A1.5 1.5 0 0 1 6.5 5Z",
10
+ terminal: "M5 3.5h10a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-9a2 2 0 0 1 2-2ZM6 7l3 3-3 3M11 13h3",
11
+ branch: "M6 6v8M14 6v2a4 4 0 0 1-4 4H6M8 4a2 2 0 1 1-4 0 2 2 0 0 1 4 0ZM8 16a2 2 0 1 1-4 0 2 2 0 0 1 4 0ZM16 4a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z",
12
+ "line-numbers": "M3 5h2M3 10h2M3 15h2M8 5h9M8 10h9M8 15h9",
13
+ wrap: "M3 5h14M3 10h10a3 3 0 0 1 0 6h-3M12.5 13.5 10 16l2.5 2.5",
14
+ calendar: "M5.5 4h9A2.5 2.5 0 0 1 17 6.5v8a2.5 2.5 0 0 1-2.5 2.5h-9A2.5 2.5 0 0 1 3 14.5v-8A2.5 2.5 0 0 1 5.5 4ZM6.5 2.5v3M13.5 2.5v3M3 8h14M6.5 11h.1M10 11h.1M13.5 11h.1M6.5 14h.1M10 14h.1",
15
+ close: "M6 6l8 8M14 6l-8 8",
16
+ check: "M4.5 10.2l3.6 3.6 7.4-7.6",
17
+ "chevron-down": "M5.5 7.75 10 12.25l4.5-4.5",
18
+ "chevron-up": "M5.5 12.25 10 7.75l4.5 4.5",
19
+ "chevron-right": "M7.75 5.5 12.25 10l-4.5 4.5",
20
+ "chevron-left": "M12.25 5.5 7.75 10l4.5 4.5",
21
+ "arrow-right": "M3.5 10h13M11 4.5l5.5 5.5-5.5 5.5",
22
+ "arrow-left": "M16.5 10h-13M9 4.5 3.5 10 9 15.5",
23
+ "arrow-up": "M10 16.5v-13M4.5 9 10 3.5 15.5 9",
24
+ "arrow-down": "M10 3.5v13M4.5 11l5.5 5.5 5.5-5.5",
25
+ plus: "M10 4v12M4 10h12",
26
+ minus: "M4 10h12",
27
+ sort: "M6 15V4M3 7l3-3 3 3M14 5v11M11 13l3 3 3-3",
28
+ search: "M13.3 13.3 17 17M14.5 8.5a6 6 0 1 1-12 0 6 6 0 0 1 12 0",
29
+ sun: "M13.5 10a3.5 3.5 0 1 1-7 0 3.5 3.5 0 0 1 7 0M10 1.75v1.5M10 16.75v1.5M1.75 10h1.5M16.75 10h1.5M4.17 4.17l1.06 1.06M14.77 14.77l1.06 1.06M4.17 15.83l1.06-1.06M14.77 5.23l1.06-1.06",
30
+ moon: "M17.25 11.15A7.5 7.5 0 0 1 8.85 2.75a7.5 7.5 0 1 0 8.4 8.4Z",
31
+ modern: "M6.5 3h7A3.5 3.5 0 0 1 17 6.5v7a3.5 3.5 0 0 1-3.5 3.5h-7A3.5 3.5 0 0 1 3 13.5v-7A3.5 3.5 0 0 1 6.5 3ZM7 10l3-3 3 3-3 3Z",
32
+ pixel: "M3 3h5v5H3ZM12 3h5v5h-5ZM3 12h5v5H3ZM12 12h5v5h-5Z",
33
+ chinese: "M3 8c3 0 5-2 7-5 2 3 4 5 7 5M4 8h12M6 8v8m8-8v8M3 16h14M8 16v-5h4v5",
34
+ soviet: "M3 17h14M5 17V8h4v9m0-12h6v12M7 8V5h2m2 3h2m-2 3h2m-2 3h2M10 5V3h4v2",
35
+ more: "M4 9.9v.2M10 9.9v.2M16 9.9v.2",
36
+ copy: "M7 7h8a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2V7ZM13 7V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",
37
+ edit: "M11.5 4.5l4 4M4 12l9-9a1.4 1.4 0 0 1 2 0l2 2a1.4 1.4 0 0 1 0 2l-9 9-5 1Z",
38
+ link: "M8 6l2-2a4.2 4.2 0 0 1 6 6l-2 2M12 14l-2 2a4.2 4.2 0 0 1-6-6l2-2M7 13l6-6",
39
+ trash: "M3.5 5.5h13M7 5.5V3h6v2.5M5 5.5l.7 11.5h8.6L15 5.5M8 9v5M12 9v5",
40
+ spinner: "M10 3a7 7 0 1 1-7 7",
41
+ "circle-check": "M18 10a8 8 0 1 1-16 0 8 8 0 0 1 16 0ZM6 10l2.7 2.7 5.3-5.4",
42
+ "circle-error": "M18 10a8 8 0 1 1-16 0 8 8 0 0 1 16 0ZM7.2 7.2l5.6 5.6M12.8 7.2l-5.6 5.6",
43
+ "circle-info": "M18 10a8 8 0 1 1-16 0 8 8 0 0 1 16 0ZM10 9v5M10 6.1v.15",
44
+ "triangle-alert": "M8.7 3.5a1.5 1.5 0 0 1 2.6 0l6.4 11.3a1.5 1.5 0 0 1-1.3 2.2H3.6a1.5 1.5 0 0 1-1.3-2.2ZM10 7.2v4.4M10 14v.15",
45
+ refresh: "M16.5 7.2A7 7 0 0 0 4.3 5.9L2.5 8M2.5 3.5V8H7M3.5 12.8a7 7 0 0 0 12.2 1.3l1.8-2.1M13 12h4.5v4.5",
46
+ external: "M11.5 3H17v5.5M17 3l-8 8M8 3H5a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3",
47
+ home: "M3.5 10.25 10 4l6.5 6.25M5.75 8.75v7a.75.75 0 0 0 .75.75h7.5a.75.75 0 0 0 .75-.75v-7",
48
+ settings: "M3.5 5.5h13M3.5 10h13M3.5 14.5h13M7 4v3M12.5 8.5v3M8 13v3",
49
+ star: "M10 2.5l2.4 5.1 5.6.4-4.2 3.7 1.3 5.5-5.1-3-5.1 3 1.3-5.5L1.8 8l5.6-.4Z",
50
+ eye: "M2.2 10s3-5.4 7.8-5.4S17.8 10 17.8 10s-3 5.4-7.8 5.4S2.2 10 2.2 10ZM10 12.4a2.4 2.4 0 1 0 0-4.8 2.4 2.4 0 0 0 0 4.8Z",
51
+ "eye-off": "M2.2 10s3-5.4 7.8-5.4S17.8 10 17.8 10s-3 5.4-7.8 5.4S2.2 10 2.2 10ZM10 12.4a2.4 2.4 0 1 0 0-4.8 2.4 2.4 0 0 0 0 4.8ZM3.5 3.5l13 13",
52
+ inbox: "M3.5 12.25h3.7l1.5 2.5h2.6l1.5-2.5h3.7M4.7 5.5l-1.2 6.75v3.25a1.5 1.5 0 0 0 1.5 1.5h10a1.5 1.5 0 0 0 1.5-1.5v-3.25L15.3 5.5a1.3 1.3 0 0 0-1.25-1H5.95a1.3 1.3 0 0 0-1.25 1Z",
53
+ bell: "M10 3.5a4.5 4.5 0 0 1 4.5 4.5c0 4.5 1.8 5.7 2.5 6.5H3c.7-.8 2.5-2 2.5-6.5A4.5 4.5 0 0 1 10 3.5ZM8.5 16.5a1.6 1.6 0 0 0 3 0",
54
+ users: "M13.8 16.5v-1.5a3.5 3.5 0 0 0-3.5-3.5H6.3a3.5 3.5 0 0 0-3.5 3.5v1.5M8.3 8.9a2.7 2.7 0 1 0 0-5.4 2.7 2.7 0 0 0 0 5.4ZM16.5 16.5v-1.3a3.3 3.3 0 0 0-2.3-3.1M12.3 3.7a2.7 2.7 0 0 1 0 5.2",
55
+ activity: "M17 10h-2.6l-2 5.8L8 4.2 6 10H3",
56
+ "trend-up": "M3.5 14.5l4.2-4.2 2.8 2.8 5.9-5.9M12.4 7.2h4.2v4.2",
57
+ "trend-down": "M3.5 5.5l4.2 4.2 2.8-2.8 5.9 5.9M12.4 12.8h4.2V8.6",
58
+ rocket: "M10 2.5c2 1.5 3.2 4 3.2 6.8 0 1.5-.3 2.9-.8 4.2H7.6c-.5-1.3-.8-2.7-.8-4.2 0-2.8 1.2-5.3 3.2-6.8ZM10 8.6a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3ZM7.6 12.5 5.6 15.4c-.9.3-1.6 1-2 2M12.4 12.5l2 2.9c.9.3 1.6 1 2 2M8.7 13.8c0 1.8.5 3.1 1.3 4.2.8-1.1 1.3-2.4 1.3-4.2",
59
+ bold: "M6.5 4h4.2a3 3 0 0 1 0 6H6.5M6.5 10h5a3 3 0 0 1 0 6H6.5M6.5 4v12",
60
+ italic: "M8.5 4.5h7M4.5 15.5h7M12.5 4.5l-5 11",
61
+ underline: "M6 4v5.5a4 4 0 0 0 8 0V4M4.5 16h11",
62
+ "align-left": "M3.5 4.5h13M3.5 10h8.5M3.5 15.5h11",
63
+ "align-center": "M3.5 4.5h13M5.75 10h8.5M4.5 15.5h11",
64
+ "align-right": "M3.5 4.5h13M8 10h8.5M5.5 15.5h11",
65
+ list: "M6.5 5h10M6.5 10h10M6.5 15h10M3.5 5h.01M3.5 10h.01M3.5 15h.01",
66
+ server: "M3 3h14a1.5 1.5 0 0 1 1.5 1.5v2A1.5 1.5 0 0 1 17 8H3a1.5 1.5 0 0 1-1.5-1.5v-2A1.5 1.5 0 0 1 3 3ZM3 12h14a1.5 1.5 0 0 1 1.5 1.5v2A1.5 1.5 0 0 1 17 17H3a1.5 1.5 0 0 1-1.5-1.5v-2A1.5 1.5 0 0 1 3 12ZM5 5.5h.01M5 14.5h.01",
67
+ sparkle: "M10 2.5l1.6 4.3 4.3 1.6-4.3 1.6L10 14.3l-1.6-4.3-4.3-1.6 4.3-1.6ZM15.5 12.5l.8 2.1 2.1.8-2.1.8-.8 2.1-.8-2.1-2.1-.8 2.1-.8Z",
68
+ play: "M6.5 4.8v10.4c0 .9 1 1.5 1.8 1l8.3-5.2a1.2 1.2 0 0 0 0-2L8.3 3.8a1.2 1.2 0 0 0-1.8 1Z",
69
+ "chart-line": "M3.5 3.5v13h13M6.5 12l2.8-2.8 2.2 2.2 4-4.4",
70
+ layers: "M10 3.2 3.6 6.5 10 9.8l6.4-3.3ZM4.5 10.4 10 13.2l5.5-2.8M4.5 13.6 10 16.4l5.5-2.8",
71
+ box: "M17 6 10 3.2 3 6v8l7 2.8 7-2.8ZM3 6l7 2.8L17 6M10 9v7.8",
72
+ filter: "M4 4.5h12l-4.4 5.1v5l-3.2-1.6V9.6Z",
73
+ columns: "M3.5 4h13v12h-13ZM8.2 4v12M12.8 4v12",
74
+ download: "M10 3.5v8M6.8 8.3 10 11.5l3.2-3.2M4 15v2.5a1.5 1.5 0 0 0 1.5 1.5h9a1.5 1.5 0 0 0 1.5-1.5V15"
75
+ };
76
+ var custom = /* @__PURE__ */ new Map();
77
+ function iconPath(name) {
78
+ return Object.hasOwn(ICON_PATHS, name) ? ICON_PATHS[name] : custom.get(name) ?? null;
79
+ }
80
+ function iconAttributes(o = {}) {
81
+ const size = Number.isFinite(o.size) && o.size > 0 ? o.size : 16;
82
+ return { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", width: String(size), height: String(size), fill: "none", stroke: "currentColor", "stroke-width": "1.6", "stroke-linecap": "round", "stroke-linejoin": "round", focusable: "false", class: ["icen-symbol", o.className].filter(Boolean).join(" "), ...o.label ? { role: "img", "aria-label": o.label } : { "aria-hidden": "true" } };
83
+ }
84
+ function createIcon(name, o = {}) {
85
+ if (typeof document === "undefined") return null;
86
+ const path = iconPath(name);
87
+ if (!path) return null;
88
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
89
+ for (const [key, value] of Object.entries(iconAttributes(o))) svg.setAttribute(key, value);
90
+ const line = document.createElementNS(svg.namespaceURI, "path");
91
+ line.setAttribute("d", path);
92
+ svg.append(line);
93
+ return svg;
94
+ }
95
+
96
+ // src/behaviors/feedback.ts
97
+ function createFeedbackClock(el, state, expire, progress, pauseOnHover = () => true) {
98
+ if (typeof document === "undefined") return { pause() {
99
+ }, resume() {
100
+ }, reset() {
101
+ }, destroy() {
102
+ } };
103
+ const reasons = /* @__PURE__ */ new Set();
104
+ const ac = new AbortController();
105
+ let destroyed = false;
106
+ function sync(reset = false) {
107
+ state.paused = state.duration > 0 && reasons.size > 0;
108
+ el.classList.toggle("is-paused", state.paused);
109
+ const fill = el.querySelector(progress);
110
+ if (fill) {
111
+ if (reset) {
112
+ fill.style.animationName = "none";
113
+ void fill.offsetWidth;
114
+ fill.style.animationName = "";
115
+ fill.style.animationDuration = `${state.duration}ms`;
116
+ }
117
+ fill.style.animationPlayState = state.paused ? "paused" : "running";
118
+ }
119
+ }
120
+ function stop() {
121
+ if (!state.timer) return;
122
+ window.clearTimeout(state.timer);
123
+ state.timer = 0;
124
+ state.remaining = Math.max(0, state.remaining - (Date.now() - state.startedAt));
125
+ }
126
+ function start() {
127
+ if (destroyed || state.duration <= 0 || reasons.size || state.timer) return;
128
+ if (state.remaining <= 0) {
129
+ expire();
130
+ return;
131
+ }
132
+ state.startedAt = Date.now();
133
+ state.timer = window.setTimeout(() => {
134
+ state.timer = 0;
135
+ state.remaining = 0;
136
+ if (!destroyed) expire();
137
+ }, state.remaining);
138
+ }
139
+ const clock = {
140
+ pause(reason = "manual") {
141
+ if (destroyed) return;
142
+ reasons.add(reason);
143
+ stop();
144
+ sync();
145
+ },
146
+ resume(reason = "manual") {
147
+ if (destroyed) return;
148
+ reasons.delete(reason);
149
+ sync();
150
+ start();
151
+ },
152
+ reset(ms) {
153
+ if (destroyed) return;
154
+ stop();
155
+ state.duration = Number.isFinite(ms) ? Math.max(0, ms) : 0;
156
+ state.remaining = state.duration;
157
+ sync(true);
158
+ start();
159
+ },
160
+ destroy() {
161
+ if (destroyed) return;
162
+ destroyed = true;
163
+ stop();
164
+ reasons.clear();
165
+ ac.abort();
166
+ }
167
+ };
168
+ el.addEventListener("mouseenter", () => {
169
+ if (pauseOnHover()) clock.pause("hover");
170
+ }, { signal: ac.signal });
171
+ el.addEventListener("mouseleave", () => clock.resume("hover"), { signal: ac.signal });
172
+ el.addEventListener("focusin", () => clock.pause("focus"), { signal: ac.signal });
173
+ el.addEventListener("focusout", (event) => {
174
+ if (!(event.relatedTarget instanceof Node) || !el.contains(event.relatedTarget)) clock.resume("focus");
175
+ }, { signal: ac.signal });
176
+ const visibility = () => document.hidden ? clock.pause("visibility") : clock.resume("visibility");
177
+ document.addEventListener("visibilitychange", visibility, { signal: ac.signal });
178
+ if (document.hidden) reasons.add("visibility");
179
+ if (el.contains(document.activeElement)) reasons.add("focus");
180
+ clock.reset(state.duration);
181
+ return clock;
182
+ }
183
+ var pending = /* @__PURE__ */ new WeakMap();
184
+ function cancelFeedbackAction(card) {
185
+ pending.get(card)?.abort();
186
+ }
187
+ function runFeedbackAction(card, button, action, hooks) {
188
+ if (typeof document === "undefined") return;
189
+ if (pending.has(card) || card.classList.contains("is-leaving") || !card.isConnected) return;
190
+ const ac = new AbortController();
191
+ const controls = Array.from(card.querySelectorAll(".icen-toast-action,.icen-notification-action"));
192
+ const original = controls.map((item) => item.getAttribute("aria-disabled"));
193
+ let spinner = null;
194
+ let busy = false;
195
+ let signalled = false;
196
+ const restore = () => {
197
+ if (busy) {
198
+ busy = false;
199
+ controls.forEach((item, index) => original[index] == null ? item.removeAttribute("aria-disabled") : item.setAttribute("aria-disabled", original[index]));
200
+ button.removeAttribute("aria-busy");
201
+ spinner?.remove();
202
+ }
203
+ if (signalled) {
204
+ signalled = false;
205
+ hooks.busy(false);
206
+ }
207
+ };
208
+ const operation = { abort() {
209
+ ac.abort();
210
+ if (pending.get(card) === operation) {
211
+ pending.delete(card);
212
+ restore();
213
+ }
214
+ } };
215
+ pending.set(card, operation);
216
+ const finish = (result, error) => {
217
+ if (ac.signal.aborted || pending.get(card) !== operation) return;
218
+ pending.delete(card);
219
+ try {
220
+ if (card.isConnected && !card.classList.contains("is-leaving")) {
221
+ if (error !== void 0) hooks.error(error);
222
+ else hooks.complete(result !== false);
223
+ }
224
+ } finally {
225
+ restore();
226
+ }
227
+ };
228
+ try {
229
+ signalled = true;
230
+ hooks.busy(true);
231
+ const result = action(ac.signal);
232
+ if (result && typeof result.then === "function") {
233
+ busy = true;
234
+ controls.forEach((item) => item.setAttribute("aria-disabled", "true"));
235
+ button.setAttribute("aria-busy", "true");
236
+ let label = button.querySelector(".icen-feedback-action-label");
237
+ if (!label) {
238
+ label = document.createElement("span");
239
+ label.className = "icen-feedback-action-label";
240
+ while (button.firstChild) label.append(button.firstChild);
241
+ button.append(label);
242
+ }
243
+ spinner = document.createElement("span");
244
+ spinner.className = "icen-feedback-action-spinner";
245
+ spinner.setAttribute("aria-hidden", "true");
246
+ spinner.append(createIcon("spinner"));
247
+ button.append(spinner);
248
+ void Promise.resolve(result).then((value) => finish(value), (error) => finish(false, error ?? new Error("Action rejected")));
249
+ } else finish(result);
250
+ } catch (error) {
251
+ finish(false, error ?? new Error("Action failed"));
252
+ }
253
+ }
254
+ function setFeedbackError(host, message) {
255
+ if (typeof document === "undefined") return;
256
+ let error = host.querySelector(":scope > .icen-feedback-error");
257
+ if (!message) {
258
+ error?.remove();
259
+ return;
260
+ }
261
+ if (!error) {
262
+ error = document.createElement("span");
263
+ error.className = "icen-feedback-error";
264
+ error.setAttribute("role", "alert");
265
+ host.append(error);
266
+ }
267
+ setFeedbackText(error, message);
268
+ }
269
+ function setFeedbackText(host, value) {
270
+ if (typeof document === "undefined") return;
271
+ const text = document.createElement("bdi");
272
+ text.textContent = value;
273
+ host.replaceChildren(text);
274
+ }
275
+ var origins = /* @__PURE__ */ new WeakMap();
276
+ function rememberFeedbackOrigin(card) {
277
+ if (typeof document === "undefined") return;
278
+ const focused = document.activeElement instanceof HTMLElement ? document.activeElement : null;
279
+ const previous = focused?.closest(".icen-toast,.icen-notification");
280
+ const chain = [...focused ? [focused] : [], ...previous ? origins.get(previous) ?? [] : []];
281
+ origins.set(card, [...new Set(chain)].filter((item) => item.isConnected));
282
+ }
283
+ function restoreFeedbackFocus(card) {
284
+ if (typeof document === "undefined") return;
285
+ const origin = origins.get(card)?.find((item) => item.isConnected && !item.closest("[hidden],[inert],.is-leaving") && !item.matches(':disabled,[aria-disabled="true"]'));
286
+ if (card.contains(document.activeElement)) origin?.focus({ preventScroll: true });
287
+ }
288
+ export {
289
+ cancelFeedbackAction,
290
+ createFeedbackClock,
291
+ rememberFeedbackOrigin,
292
+ restoreFeedbackFocus,
293
+ runFeedbackAction,
294
+ setFeedbackError,
295
+ setFeedbackText
296
+ };
@@ -0,0 +1,8 @@
1
+ /** Shared native focus contract. Geometry-free visibility checks also include
2
+ * fixed-position controls, which offsetParent incorrectly excludes. */
3
+ declare const FOCUSABLE = "button, [href], input:not([type=\"hidden\"]), select, textarea, icen-input, icen-select, icen-textarea, [tabindex], [contenteditable]:not([contenteditable=\"false\"]), audio[controls], video[controls], details>summary";
4
+ /** Availability also applies to intentionally programmatic tabindex=-1 targets. */
5
+ declare function isAvailableForFocus(el: HTMLElement): boolean;
6
+ declare function focusableWithin(root: ParentNode): HTMLElement[];
7
+
8
+ export { FOCUSABLE, focusableWithin, isAvailableForFocus };
@@ -0,0 +1,24 @@
1
+ // src/behaviors/focus.ts
2
+ var FOCUSABLE = 'button, [href], input:not([type="hidden"]), select, textarea, icen-input, icen-select, icen-textarea, [tabindex], [contenteditable]:not([contenteditable="false"]), audio[controls], video[controls], details>summary';
3
+ function isAvailableForFocus(el) {
4
+ if (typeof document === "undefined" || !el.isConnected || el.matches(':disabled,[disabled],[aria-disabled="true"]')) return false;
5
+ if (el.closest('[hidden],[inert],[aria-hidden="true"]')) return false;
6
+ const closed = el.closest("details:not([open])");
7
+ if (closed && !closed.querySelector(":scope > summary")?.contains(el)) return false;
8
+ if (["hidden", "collapse"].includes(getComputedStyle(el).visibility)) return false;
9
+ for (let ancestor = el; ancestor; ancestor = ancestor.parentElement) {
10
+ if (getComputedStyle(ancestor).display === "none") return false;
11
+ }
12
+ return true;
13
+ }
14
+ function focusableWithin(root) {
15
+ if (typeof document === "undefined") return [];
16
+ return Array.from(root.querySelectorAll(FOCUSABLE)).filter((el) => {
17
+ return !(el.hasAttribute("tabindex") && el.tabIndex < 0) && isAvailableForFocus(el);
18
+ });
19
+ }
20
+ export {
21
+ FOCUSABLE,
22
+ focusableWithin,
23
+ isAvailableForFocus
24
+ };