@icen.ai/ui 0.8.1 → 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.
- package/AGENTS.md +176 -75
- package/README.md +66 -88
- package/dist/base.css +208 -179
- package/dist/behaviors/accordion.mjs +8 -8
- package/dist/behaviors/ai-branch.d.mts +19 -0
- package/dist/behaviors/ai-branch.mjs +1133 -0
- package/dist/behaviors/ai-chat.d.mts +12 -10
- package/dist/behaviors/ai-chat.mjs +1125 -155
- package/dist/behaviors/ai-composer.d.mts +44 -12
- package/dist/behaviors/ai-composer.mjs +2084 -523
- package/dist/behaviors/ai-core.d.mts +1 -1
- package/dist/behaviors/ai-core.mjs +1016 -107
- package/dist/behaviors/ai-diff.mjs +1019 -127
- package/dist/behaviors/ai-feedback.d.mts +26 -0
- package/dist/behaviors/ai-feedback.mjs +1212 -0
- package/dist/behaviors/ai-panel.d.mts +21 -7
- package/dist/behaviors/ai-panel.mjs +1308 -264
- package/dist/behaviors/ai-provider.mjs +1003 -101
- package/dist/behaviors/ai-threads.d.mts +38 -0
- package/dist/behaviors/ai-threads.mjs +1233 -0
- package/dist/behaviors/ai-tool.d.mts +2 -2
- package/dist/behaviors/ai-tool.mjs +2042 -396
- package/dist/behaviors/ai-tools.d.mts +89 -16
- package/dist/behaviors/ai-tools.mjs +4453 -372
- package/dist/behaviors/autocomplete.d.mts +53 -0
- package/dist/behaviors/autocomplete.mjs +1600 -0
- package/dist/behaviors/back-top.d.mts +1 -1
- package/dist/behaviors/back-top.mjs +951 -14
- package/dist/behaviors/carousel.d.mts +1 -1
- package/dist/behaviors/carousel.mjs +906 -11
- package/dist/behaviors/cascader.d.mts +48 -0
- package/dist/behaviors/cascader.mjs +1853 -0
- package/dist/behaviors/charts.d.mts +174 -8
- package/dist/behaviors/charts.mjs +2632 -192
- package/dist/behaviors/code-block.d.mts +36 -0
- package/dist/behaviors/code-block.mjs +1611 -0
- package/dist/behaviors/command-palette.d.mts +9 -6
- package/dist/behaviors/command-palette.mjs +161 -59
- package/dist/behaviors/context-menu.d.mts +9 -8
- package/dist/behaviors/context-menu.mjs +1112 -44
- package/dist/behaviors/controls.d.mts +13 -13
- package/dist/behaviors/controls.mjs +989 -130
- package/dist/behaviors/copy.d.mts +21 -2
- package/dist/behaviors/copy.mjs +1206 -42
- package/dist/behaviors/datatable.d.mts +53 -3
- package/dist/behaviors/datatable.mjs +1963 -207
- package/dist/behaviors/date-picker.d.mts +0 -1
- package/dist/behaviors/date-picker.mjs +1340 -293
- package/dist/behaviors/design.d.mts +54 -0
- package/dist/behaviors/design.mjs +109 -0
- package/dist/behaviors/dropdown.d.mts +5 -6
- package/dist/behaviors/dropdown.mjs +262 -110
- package/dist/behaviors/events.d.mts +313 -3
- package/dist/behaviors/events.mjs +47 -2
- package/dist/behaviors/feedback.d.mts +30 -0
- package/dist/behaviors/feedback.mjs +296 -0
- package/dist/behaviors/focus.d.mts +8 -0
- package/dist/behaviors/focus.mjs +24 -0
- package/dist/behaviors/form-validate.d.mts +102 -0
- package/dist/behaviors/form-validate.mjs +6091 -0
- package/dist/behaviors/i18n.d.mts +789 -0
- package/dist/behaviors/i18n.mjs +1711 -0
- package/dist/behaviors/icons.d.mts +93 -0
- package/dist/behaviors/icons.mjs +113 -0
- package/dist/behaviors/input.d.mts +9 -1
- package/dist/behaviors/input.mjs +1056 -60
- package/dist/behaviors/kb-access.d.mts +34 -0
- package/dist/behaviors/kb-access.mjs +2459 -0
- package/dist/behaviors/kb-acl.d.mts +50 -0
- package/dist/behaviors/kb-acl.mjs +1345 -0
- package/dist/behaviors/kb-answer.d.mts +38 -0
- package/dist/behaviors/kb-answer.mjs +3707 -0
- package/dist/behaviors/kb-audit.d.mts +23 -0
- package/dist/behaviors/kb-audit.mjs +1297 -0
- package/dist/behaviors/kb-canvas.d.mts +44 -0
- package/dist/behaviors/kb-canvas.mjs +1512 -0
- package/dist/behaviors/kb-chain.d.mts +15 -0
- package/dist/behaviors/kb-chain.mjs +1192 -0
- package/dist/behaviors/kb-checkpoint.d.mts +16 -0
- package/dist/behaviors/kb-checkpoint.mjs +1492 -0
- package/dist/behaviors/kb-chunks.d.mts +31 -0
- package/dist/behaviors/kb-chunks.mjs +1414 -0
- package/dist/behaviors/kb-citation.d.mts +38 -0
- package/dist/behaviors/kb-citation.mjs +1699 -0
- package/dist/behaviors/kb-clarify.d.mts +20 -0
- package/dist/behaviors/kb-clarify.mjs +1176 -0
- package/dist/behaviors/kb-conflict.d.mts +22 -0
- package/dist/behaviors/kb-conflict.mjs +1206 -0
- package/dist/behaviors/kb-connector.d.mts +17 -0
- package/dist/behaviors/kb-connector.mjs +1303 -0
- package/dist/behaviors/kb-core.d.mts +534 -0
- package/dist/behaviors/kb-core.mjs +1805 -0
- package/dist/behaviors/kb-eval.d.mts +22 -0
- package/dist/behaviors/kb-eval.mjs +2235 -0
- package/dist/behaviors/kb-explain.d.mts +11 -0
- package/dist/behaviors/kb-explain.mjs +1165 -0
- package/dist/behaviors/kb-filter.d.mts +31 -0
- package/dist/behaviors/kb-filter.mjs +2417 -0
- package/dist/behaviors/kb-gap.d.mts +27 -0
- package/dist/behaviors/kb-gap.mjs +1195 -0
- package/dist/behaviors/kb-hittest.d.mts +34 -0
- package/dist/behaviors/kb-hittest.mjs +1352 -0
- package/dist/behaviors/kb-metadata.d.mts +29 -0
- package/dist/behaviors/kb-metadata.mjs +1248 -0
- package/dist/behaviors/kb-passage.d.mts +41 -0
- package/dist/behaviors/kb-passage.mjs +1469 -0
- package/dist/behaviors/kb-pipeline.d.mts +18 -0
- package/dist/behaviors/kb-pipeline.mjs +1301 -0
- package/dist/behaviors/kb-qa.d.mts +26 -0
- package/dist/behaviors/kb-qa.mjs +1260 -0
- package/dist/behaviors/kb-rerank.d.mts +20 -0
- package/dist/behaviors/kb-rerank.mjs +1248 -0
- package/dist/behaviors/kb-retrieval.d.mts +49 -0
- package/dist/behaviors/kb-retrieval.mjs +2585 -0
- package/dist/behaviors/kb-review.d.mts +44 -0
- package/dist/behaviors/kb-review.mjs +2282 -0
- package/dist/behaviors/kb-sandbox.d.mts +33 -0
- package/dist/behaviors/kb-sandbox.mjs +1247 -0
- package/dist/behaviors/kb-segment.d.mts +32 -0
- package/dist/behaviors/kb-segment.mjs +1431 -0
- package/dist/behaviors/kb-select.d.mts +24 -0
- package/dist/behaviors/kb-select.mjs +1989 -0
- package/dist/behaviors/kb-sources.d.mts +27 -0
- package/dist/behaviors/kb-sources.mjs +1287 -0
- package/dist/behaviors/kb-sql.d.mts +43 -0
- package/dist/behaviors/kb-sql.mjs +1865 -0
- package/dist/behaviors/kb-trace.d.mts +16 -0
- package/dist/behaviors/kb-trace.mjs +1328 -0
- package/dist/behaviors/kb-visibility.d.mts +44 -0
- package/dist/behaviors/kb-visibility.mjs +1331 -0
- package/dist/behaviors/kb-who-can.d.mts +32 -0
- package/dist/behaviors/kb-who-can.mjs +2216 -0
- package/dist/behaviors/mentions.d.mts +93 -0
- package/dist/behaviors/mentions.mjs +2152 -0
- package/dist/behaviors/modal.d.mts +4 -3
- package/dist/behaviors/modal.mjs +1055 -33
- package/dist/behaviors/nav.d.mts +1 -1
- package/dist/behaviors/nav.mjs +6 -6
- package/dist/behaviors/notification.d.mts +16 -8
- package/dist/behaviors/notification.mjs +1615 -265
- package/dist/behaviors/panel.d.mts +4 -0
- package/dist/behaviors/panel.mjs +994 -0
- package/dist/behaviors/popover.d.mts +28 -5
- package/dist/behaviors/popover.mjs +225 -24
- package/dist/behaviors/select.d.mts +5 -2
- package/dist/behaviors/select.mjs +1410 -117
- package/dist/behaviors/sidebar.d.mts +1 -1
- package/dist/behaviors/sidebar.mjs +13 -13
- package/dist/behaviors/slider.d.mts +1 -1
- package/dist/behaviors/slider.mjs +9 -9
- package/dist/behaviors/split-pane.d.mts +1 -1
- package/dist/behaviors/split-pane.mjs +7 -7
- package/dist/behaviors/suggestions.d.mts +27 -0
- package/dist/behaviors/suggestions.mjs +1089 -0
- package/dist/behaviors/svg-parse.d.mts +14 -0
- package/dist/behaviors/svg-parse.mjs +37 -0
- package/dist/behaviors/tabs.d.mts +2 -2
- package/dist/behaviors/tabs.mjs +25 -25
- package/dist/behaviors/tag-input.d.mts +23 -5
- package/dist/behaviors/tag-input.mjs +1359 -104
- package/dist/behaviors/theme-switcher.d.mts +24 -0
- package/dist/behaviors/theme-switcher.mjs +1981 -0
- package/dist/behaviors/theme.d.mts +15 -8
- package/dist/behaviors/theme.mjs +390 -28
- package/dist/behaviors/toast.d.mts +24 -25
- package/dist/behaviors/toast.mjs +1266 -88
- package/dist/behaviors/tooltip.d.mts +4 -0
- package/dist/behaviors/tooltip.mjs +378 -0
- package/dist/behaviors/tree-select.d.mts +69 -0
- package/dist/behaviors/tree-select.mjs +1907 -0
- package/dist/behaviors/tree.d.mts +1 -1
- package/dist/behaviors/tree.mjs +15 -15
- package/dist/behaviors/upload.d.mts +3 -2
- package/dist/behaviors/upload.mjs +1076 -66
- package/dist/cli.mjs +5 -6
- package/dist/components/ai-branch.mjs +3 -0
- package/dist/components/ai-chat.css +846 -458
- package/dist/components/ai-diff.css +153 -132
- package/dist/components/ai-feedback.mjs +3 -0
- package/dist/components/ai-panel.css +495 -270
- package/dist/components/ai-threads.mjs +3 -0
- package/dist/components/ai-tool.css +393 -238
- package/dist/components/autocomplete.css +61 -0
- package/dist/components/autocomplete.mjs +3 -0
- package/dist/components/back-top.css +34 -31
- package/dist/components/badge.css +44 -41
- package/dist/components/breadcrumb.css +67 -46
- package/dist/components/btn.css +80 -74
- package/dist/components/card.css +117 -106
- package/dist/components/cascader.css +311 -0
- package/dist/components/cascader.mjs +3 -0
- package/dist/components/chart-area.css +8 -2
- package/dist/components/chart-bar.css +95 -33
- package/dist/components/chart-gauge.css +14 -11
- package/dist/components/chart-graph.css +60 -0
- package/dist/components/chart-graph.mjs +4 -0
- package/dist/components/chart-heatmap.css +96 -90
- package/dist/components/chart-line.css +8 -3
- package/dist/components/chart-map.mjs +3 -0
- package/dist/components/chart-pie.css +9 -6
- package/dist/components/chart-radar.css +8 -5
- package/dist/components/chart-scatter.css +9 -6
- package/dist/components/chart-scatter.mjs +1 -1
- package/dist/components/chart-sparkline.css +5 -2
- package/dist/components/chart-stack.css +14 -11
- package/dist/components/charts.css +190 -67
- package/dist/components/charts.mjs +1 -0
- package/dist/components/code-block.css +418 -0
- package/dist/components/code-block.mjs +4 -0
- package/dist/components/command-palette.css +138 -117
- package/dist/components/content.css +257 -251
- package/dist/components/copy.css +72 -44
- package/dist/components/datatable.css +423 -181
- package/dist/components/date-picker.css +135 -104
- package/dist/components/empty.css +68 -65
- package/dist/components/feedback.css +201 -183
- package/dist/components/form-validate.css +120 -0
- package/dist/components/form-validate.mjs +3 -0
- package/dist/components/form.css +150 -127
- package/dist/components/icon.css +102 -0
- package/dist/components/icon.mjs +3 -0
- package/dist/components/input.css +159 -104
- package/dist/components/kb-access.mjs +4 -0
- package/dist/components/kb-acl.mjs +4 -0
- package/dist/components/kb-agent.css +496 -0
- package/dist/components/kb-answer.mjs +4 -0
- package/dist/components/kb-audit.mjs +4 -0
- package/dist/components/kb-canvas.mjs +4 -0
- package/dist/components/kb-chain.mjs +4 -0
- package/dist/components/kb-checkpoint.mjs +4 -0
- package/dist/components/kb-chunks.mjs +4 -0
- package/dist/components/kb-citation.mjs +4 -0
- package/dist/components/kb-clarify.mjs +4 -0
- package/dist/components/kb-conflict.mjs +4 -0
- package/dist/components/kb-connector.mjs +4 -0
- package/dist/components/kb-data.css +653 -0
- package/dist/components/kb-eval.mjs +4 -0
- package/dist/components/kb-explain.mjs +4 -0
- package/dist/components/kb-filter.mjs +4 -0
- package/dist/components/kb-gap.mjs +4 -0
- package/dist/components/kb-ground.css +578 -0
- package/dist/components/kb-hittest.mjs +4 -0
- package/dist/components/kb-ingest.css +882 -0
- package/dist/components/kb-metadata.mjs +4 -0
- package/dist/components/kb-ops.css +554 -0
- package/dist/components/kb-passage.mjs +4 -0
- package/dist/components/kb-perm.css +433 -0
- package/dist/components/kb-pipeline.mjs +4 -0
- package/dist/components/kb-qa.mjs +4 -0
- package/dist/components/kb-rerank.mjs +4 -0
- package/dist/components/kb-retrieval.mjs +4 -0
- package/dist/components/kb-review.mjs +4 -0
- package/dist/components/kb-sandbox.mjs +4 -0
- package/dist/components/kb-search.css +897 -0
- package/dist/components/kb-segment.mjs +4 -0
- package/dist/components/kb-sources.mjs +4 -0
- package/dist/components/kb-sql.mjs +4 -0
- package/dist/components/kb-trace.mjs +4 -0
- package/dist/components/kb-visibility.mjs +4 -0
- package/dist/components/kb-who-can.mjs +4 -0
- package/dist/components/kb.css +263 -0
- package/dist/components/kb.mjs +9 -0
- package/dist/components/layout.css +85 -82
- package/dist/components/material-chinese.css +73 -0
- package/dist/components/material-soviet.css +76 -0
- package/dist/components/material.css +275 -0
- package/dist/components/media.css +220 -166
- package/dist/components/mentions.css +189 -0
- package/dist/components/mentions.mjs +3 -0
- package/dist/components/menu.css +113 -105
- package/dist/components/modal.css +107 -112
- package/dist/components/nav.css +118 -115
- package/dist/components/notification.css +238 -174
- package/dist/components/pagination.css +56 -53
- package/dist/components/panel.css +66 -63
- package/dist/components/panel.mjs +1 -0
- package/dist/components/pill.css +81 -71
- package/dist/components/popover.css +67 -53
- package/dist/components/scroll-area.css +113 -110
- package/dist/components/segmented.css +146 -143
- package/dist/components/select.css +206 -186
- package/dist/components/sidebar.css +137 -127
- package/dist/components/slider.css +117 -114
- package/dist/components/split-pane.css +112 -109
- package/dist/components/stat.css +112 -106
- package/dist/components/steps.css +109 -103
- package/dist/components/switch.css +138 -134
- package/dist/components/table.css +131 -107
- package/dist/components/tabs.css +114 -108
- package/dist/components/tag-input.css +48 -133
- package/dist/components/tag.css +81 -71
- package/dist/components/theme-switcher.css +105 -0
- package/dist/components/theme-switcher.mjs +3 -0
- package/dist/components/toast.css +100 -86
- package/dist/components/toolbar.css +45 -42
- package/dist/components/tooltip.css +102 -43
- package/dist/components/tooltip.mjs +1 -0
- package/dist/components/tree-select.css +416 -0
- package/dist/components/tree-select.mjs +3 -0
- package/dist/components/upload.css +135 -92
- package/dist/fonts/LICENSES/ark-pixel/OFL.txt +96 -0
- package/dist/fonts/LICENSES/cubic-11/OFL.txt +108 -0
- package/dist/fonts/LICENSES/galmuri/LICENSE.txt +93 -0
- package/dist/fonts/OFL.txt +96 -0
- package/dist/fonts/README.md +14 -0
- package/dist/fonts/fusion-pixel-12px-zh-hans.woff2 +0 -0
- package/dist/index.d.mts +64 -15
- package/dist/index.mjs +28049 -8595
- package/dist/react.d.mts +91 -0
- package/dist/react.mjs +8208 -0
- package/dist/registry.json +454 -15
- package/dist/tokens/chinese.css +44 -0
- package/dist/tokens/colors.css +365 -1222
- package/dist/tokens/design.css +109 -0
- package/dist/tokens/dtcg.json +11198 -0
- package/dist/tokens/figma.variables.json +7017 -0
- package/dist/tokens/icon-masks.css +78 -0
- package/dist/tokens/pixel.css +50 -0
- package/dist/tokens/soviet.css +44 -0
- package/dist/tokens/style-profiles.css +36 -547
- package/dist/tokens/themes.json +308 -0
- package/dist/tokens/tokens-studio.json +6728 -0
- package/dist/tokens/typography.css +21 -18
- package/dist/tokens.css +1555 -1801
- package/dist/ui.css +16147 -8597
- package/dist/vue.d.mts +344 -0
- package/dist/vue.mjs +7781 -0
- package/docs/spec/ai-input-experience.md +75 -0
- package/docs/spec/ai-native.md +238 -147
- package/docs/spec/design-philosophy.md +189 -0
- package/docs/spec/design-primitives.md +196 -0
- package/docs/spec/kb-family.md +475 -0
- package/package.json +42 -7
- package/dist/retro-effects.css +0 -255
- package/dist/tokens/retro-effects.css +0 -255
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/** 可校验字段元素。 */
|
|
2
|
+
type FieldElement = HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;
|
|
3
|
+
/** 一条校验规则(rule 名 = 消息 key)。 */
|
|
4
|
+
interface FieldRule {
|
|
5
|
+
/** required / email / url / number / minlength / maxlength / pattern / min / max / icen-step / matches / <custom> */
|
|
6
|
+
rule: string;
|
|
7
|
+
/** matches 的目标字段名、自定义规则的参数(data-icen-validate="matches:pwd unique:username") */
|
|
8
|
+
arg?: string;
|
|
9
|
+
/** 原生属性原文(min/max/step/minlength/maxlength/pattern),消息占位符用 */
|
|
10
|
+
attr?: string;
|
|
11
|
+
}
|
|
12
|
+
/** 自定义校验函数:通过返回 true;失败返回错误消息字符串(可异步)。 */
|
|
13
|
+
type CustomValidatorFn = (value: string, field: FieldElement, form: HTMLFormElement | null) => true | string | Promise<true | string>;
|
|
14
|
+
interface FormValidateStrategy {
|
|
15
|
+
/** 'submit' = 仅提交时校验(默认策略:提交后出错字段 input 复验 + 未触碰字段 blur 补验) */
|
|
16
|
+
on?: 'submit' | 'blur' | 'input';
|
|
17
|
+
/** input 复验防抖(默认 160ms) */
|
|
18
|
+
debounceMs?: number;
|
|
19
|
+
}
|
|
20
|
+
interface FormValidateOptions {
|
|
21
|
+
strategy?: FormValidateStrategy;
|
|
22
|
+
/** 提交失败时聚焦第一个错误字段并 scrollIntoView(默认 true) */
|
|
23
|
+
scrollToError?: boolean;
|
|
24
|
+
}
|
|
25
|
+
interface FormValidator {
|
|
26
|
+
readonly form: HTMLFormElement;
|
|
27
|
+
/** 全量校验(提交语义):更新呈现 + 汇总 + 派 icen:form-valid / icen:form-invalid */
|
|
28
|
+
validate(): Promise<boolean>;
|
|
29
|
+
/** 单字段校验:更新呈现并派 icen:form-field-validate */
|
|
30
|
+
validateField(name: string): Promise<boolean>;
|
|
31
|
+
/** 复位校验状态与呈现(不动表单值) */
|
|
32
|
+
reset(): void;
|
|
33
|
+
/** 当前错误表(字段名 → 消息) */
|
|
34
|
+
errors(): Record<string, string>;
|
|
35
|
+
/** 摘除监听与计时器、清呈现(handle 失效) */
|
|
36
|
+
destroy(): void;
|
|
37
|
+
}
|
|
38
|
+
/** i18n 全局消息表:setValidateMessages({ required: '必填', email: '…' });传空串删回默认。 */
|
|
39
|
+
declare function setValidateMessages(messages: Record<string, string | undefined>): void;
|
|
40
|
+
/** 注册具名自定义校验(覆盖同名);fn 可异步返回 true | string 错误消息。 */
|
|
41
|
+
declare function registerValidator(name: string, fn: CustomValidatorFn): void;
|
|
42
|
+
/** 下架具名自定义校验。 */
|
|
43
|
+
declare function unregisterValidator(name: string): void;
|
|
44
|
+
/**
|
|
45
|
+
* 从字段元素解析规则集(原生约束 → data-icen-validate 额外规则,顺序即优先级)。
|
|
46
|
+
* HTML5 属性即 schema;未注册语义的 data-icen-validate token 进入规则集但校验时放行。
|
|
47
|
+
*/
|
|
48
|
+
declare function resolveFieldRules(field: FieldElement): FieldRule[];
|
|
49
|
+
/** 字段取值:勾选类取 checked 语义,其余取 value。 */
|
|
50
|
+
declare function fieldValue(field: FieldElement): string;
|
|
51
|
+
/** 字段标签(消息 {label} 占位符 + 错误汇总链接文案):label 元素 > aria-label > placeholder > name > fallback。 */
|
|
52
|
+
declare function fieldLabel(field: FieldElement | null | undefined, fallback?: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* 顺序求值规则集,首个失败即返回其消息(原生约束优先于自定义规则)。
|
|
55
|
+
* 空值语义对齐 HTML5:非 required 规则对空值放行(valueMissing 归 required 管)。
|
|
56
|
+
*/
|
|
57
|
+
declare function evaluateRules(value: string, rules: FieldRule[], ctx?: {
|
|
58
|
+
field?: FieldElement;
|
|
59
|
+
form?: HTMLFormElement | null;
|
|
60
|
+
}): Promise<true | string>;
|
|
61
|
+
/** 收集参与校验的字段:有 name、非 disabled、非提交类/文件类的 input/textarea/select。 */
|
|
62
|
+
declare function collectFormFields(form: HTMLFormElement): FieldElement[];
|
|
63
|
+
/**
|
|
64
|
+
* 为单个表单创建校验 handle(同一 form 单例:重复创建幂等返回既有实例,
|
|
65
|
+
* strategy 以首次创建为准)。提交事件由校验层接管(preventDefault),
|
|
66
|
+
* 通过/未过分别派 icen:form-valid / icen:form-invalid,消费方走事件或 await validate()。
|
|
67
|
+
* SSR 下返回 no-op handle。
|
|
68
|
+
*/
|
|
69
|
+
declare function createFormValidator(form: HTMLFormElement, opts?: FormValidateOptions): FormValidator;
|
|
70
|
+
/**
|
|
71
|
+
* 接线表单校验(document 级委托,页面级一次即可,重复调用幂等)。
|
|
72
|
+
* 现有与后续插入的 form[data-icen-validate] 自动补 novalidate 并挂 handle
|
|
73
|
+
* (submit 捕获阶段 ensure,冒泡阶段 handle 的 submit 监听接管校验)。
|
|
74
|
+
* 返回销毁函数:摘除委托、销毁 scope 内由委托路径建立的 handle 并复位幂等标记,
|
|
75
|
+
* 销毁后可重新 initFormValidate。SSR 下返回 no-op。
|
|
76
|
+
*/
|
|
77
|
+
declare function initFormValidate(root?: ParentNode): () => void;
|
|
78
|
+
/** show_form 字段规格(inputSchema 的运行时形态)。 */
|
|
79
|
+
interface ShowFormFieldSpec {
|
|
80
|
+
name: string;
|
|
81
|
+
label: string;
|
|
82
|
+
type?: 'text' | 'email' | 'number' | 'url' | 'textarea' | 'select' | 'date';
|
|
83
|
+
required?: boolean;
|
|
84
|
+
pattern?: string;
|
|
85
|
+
min?: number;
|
|
86
|
+
max?: number;
|
|
87
|
+
options?: Array<string | {
|
|
88
|
+
label: string;
|
|
89
|
+
value: string;
|
|
90
|
+
}>;
|
|
91
|
+
help?: string;
|
|
92
|
+
}
|
|
93
|
+
interface ShowFormSpec {
|
|
94
|
+
title?: string;
|
|
95
|
+
fields: ShowFormFieldSpec[];
|
|
96
|
+
submitLabel?: string;
|
|
97
|
+
}
|
|
98
|
+
type ShowFormResult = Record<string, unknown> | {
|
|
99
|
+
cancelled: true;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export { type CustomValidatorFn, type FieldElement, type FieldRule, type FormValidateOptions, type FormValidateStrategy, type FormValidator, type ShowFormFieldSpec, type ShowFormResult, type ShowFormSpec, collectFormFields, createFormValidator, evaluateRules, fieldLabel, fieldValue, initFormValidate, registerValidator, resolveFieldRules, setValidateMessages, unregisterValidator };
|