@celestia-island/hikari 0.4.4
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/README.md +54 -0
- package/package.json +63 -0
- package/src/DemoApp.vue +400 -0
- package/src/components/HkActionBar.tsx +15 -0
- package/src/components/HkAlert.scss +121 -0
- package/src/components/HkAlert.tsx +85 -0
- package/src/components/HkAvatar.tsx +29 -0
- package/src/components/HkBadge.scss +117 -0
- package/src/components/HkBadge.tsx +50 -0
- package/src/components/HkBreadcrumb.tsx +39 -0
- package/src/components/HkButton.scss +128 -0
- package/src/components/HkButton.tsx +74 -0
- package/src/components/HkCard.scss +49 -0
- package/src/components/HkCard.tsx +38 -0
- package/src/components/HkCheckbox.scss +102 -0
- package/src/components/HkCheckbox.tsx +85 -0
- package/src/components/HkCollapse.tsx +48 -0
- package/src/components/HkColorPicker.scss +148 -0
- package/src/components/HkColorPicker.tsx +204 -0
- package/src/components/HkConfirmDialog.scss +12 -0
- package/src/components/HkConfirmDialog.tsx +75 -0
- package/src/components/HkDateTimePicker.scss +361 -0
- package/src/components/HkDateTimePicker.tsx +424 -0
- package/src/components/HkDivider.scss +85 -0
- package/src/components/HkDivider.tsx +51 -0
- package/src/components/HkDraggableGrid.scss +132 -0
- package/src/components/HkDraggableGrid.tsx +291 -0
- package/src/components/HkDraggableList.scss +110 -0
- package/src/components/HkDraggableList.tsx +238 -0
- package/src/components/HkDrawer.scss +175 -0
- package/src/components/HkDrawer.tsx +171 -0
- package/src/components/HkEmptyState.scss +42 -0
- package/src/components/HkEmptyState.tsx +41 -0
- package/src/components/HkErrorBoundary.scss +64 -0
- package/src/components/HkErrorBoundary.tsx +82 -0
- package/src/components/HkGaugeRing.scss +4 -0
- package/src/components/HkGaugeRing.tsx +130 -0
- package/src/components/HkHoverRevealAction.scss +66 -0
- package/src/components/HkHoverRevealAction.tsx +77 -0
- package/src/components/HkIcon.tsx +43 -0
- package/src/components/HkIconButton.tsx +42 -0
- package/src/components/HkImageViewer.scss +33 -0
- package/src/components/HkImageViewer.tsx +250 -0
- package/src/components/HkInput.scss +172 -0
- package/src/components/HkInput.tsx +175 -0
- package/src/components/HkKbd.tsx +26 -0
- package/src/components/HkKeywordSearchModal.scss +148 -0
- package/src/components/HkKeywordSearchModal.tsx +308 -0
- package/src/components/HkListTransition.scss +131 -0
- package/src/components/HkListTransition.tsx +29 -0
- package/src/components/HkLocalePickerPopup.tsx +42 -0
- package/src/components/HkLogo.scss +36 -0
- package/src/components/HkLogo.tsx +93 -0
- package/src/components/HkMarkdownRenderer.scss +141 -0
- package/src/components/HkMarkdownRenderer.tsx +123 -0
- package/src/components/HkMediaControlBar.scss +65 -0
- package/src/components/HkMediaControlBar.tsx +115 -0
- package/src/components/HkMediaPlayer.scss +29 -0
- package/src/components/HkMediaPlayer.tsx +210 -0
- package/src/components/HkMediaSlider.scss +54 -0
- package/src/components/HkMediaSlider.tsx +81 -0
- package/src/components/HkMediaVisualizer.scss +7 -0
- package/src/components/HkMediaVisualizer.tsx +119 -0
- package/src/components/HkMinimap.scss +76 -0
- package/src/components/HkMinimap.tsx +255 -0
- package/src/components/HkModal.scss +318 -0
- package/src/components/HkModal.tsx +481 -0
- package/src/components/HkModalBreadcrumb.scss +55 -0
- package/src/components/HkModalBreadcrumb.tsx +113 -0
- package/src/components/HkMorphingTabs.scss +141 -0
- package/src/components/HkMorphingTabs.tsx +113 -0
- package/src/components/HkNavItem.scss +81 -0
- package/src/components/HkNavItem.tsx +157 -0
- package/src/components/HkNumberInput.scss +154 -0
- package/src/components/HkNumberInput.tsx +161 -0
- package/src/components/HkPasswordInput.scss +289 -0
- package/src/components/HkPasswordInput.tsx +533 -0
- package/src/components/HkPhaseTransition.scss +25 -0
- package/src/components/HkPhaseTransition.tsx +40 -0
- package/src/components/HkPopover.scss +82 -0
- package/src/components/HkPopover.tsx +410 -0
- package/src/components/HkPopupSelect.scss +136 -0
- package/src/components/HkPopupSelect.tsx +199 -0
- package/src/components/HkProgressBar.scss +106 -0
- package/src/components/HkProgressBar.tsx +61 -0
- package/src/components/HkProgressDialog.tsx +67 -0
- package/src/components/HkProgressRing.scss +56 -0
- package/src/components/HkProgressRing.tsx +82 -0
- package/src/components/HkRadio.scss +119 -0
- package/src/components/HkRadio.tsx +75 -0
- package/src/components/HkRollingNumber.scss +37 -0
- package/src/components/HkRollingNumber.tsx +97 -0
- package/src/components/HkScrollContainer.scss +101 -0
- package/src/components/HkScrollContainer.tsx +362 -0
- package/src/components/HkSearchInput.scss +132 -0
- package/src/components/HkSearchInput.tsx +117 -0
- package/src/components/HkSelect.scss +143 -0
- package/src/components/HkSelect.tsx +230 -0
- package/src/components/HkSelectionGrid.scss +177 -0
- package/src/components/HkSelectionGrid.tsx +99 -0
- package/src/components/HkSelectionWaterfall.scss +93 -0
- package/src/components/HkSelectionWaterfall.tsx +90 -0
- package/src/components/HkSidebar.scss +81 -0
- package/src/components/HkSidebar.tsx +45 -0
- package/src/components/HkSkeleton.scss +44 -0
- package/src/components/HkSkeleton.tsx +30 -0
- package/src/components/HkSkeletonList.tsx +35 -0
- package/src/components/HkSpinner.scss +67 -0
- package/src/components/HkSpinner.tsx +41 -0
- package/src/components/HkSplash.scss +60 -0
- package/src/components/HkSplash.tsx +40 -0
- package/src/components/HkSwitch.scss +157 -0
- package/src/components/HkSwitch.tsx +72 -0
- package/src/components/HkTable.scss +198 -0
- package/src/components/HkTable.tsx +246 -0
- package/src/components/HkTabs.scss +109 -0
- package/src/components/HkTabs.tsx +111 -0
- package/src/components/HkTag.scss +88 -0
- package/src/components/HkTag.tsx +44 -0
- package/src/components/HkTextarea.scss +72 -0
- package/src/components/HkTextarea.tsx +104 -0
- package/src/components/HkTimeline.scss +139 -0
- package/src/components/HkTimeline.tsx +95 -0
- package/src/components/HkToast.scss +168 -0
- package/src/components/HkToast.tsx +175 -0
- package/src/components/HkTooltip.scss +47 -0
- package/src/components/HkTooltip.tsx +108 -0
- package/src/components/HkTree.scss +188 -0
- package/src/components/HkTree.tsx +217 -0
- package/src/components/HkTrendChart.tsx +180 -0
- package/src/components/HkWindowedItem.scss +17 -0
- package/src/components/HkWindowedItem.tsx +107 -0
- package/src/components/HkZoomToolbar.scss +35 -0
- package/src/components/HkZoomToolbar.tsx +69 -0
- package/src/composables/useBreakpoint.ts +41 -0
- package/src/composables/useClipboard.ts +37 -0
- package/src/composables/useConfirm.ts +35 -0
- package/src/composables/useProgressDialog.ts +52 -0
- package/src/composables/useReportedTransition.ts +69 -0
- package/src/composables/useScrollWindow.ts +21 -0
- package/src/composables/useToast.ts +2 -0
- package/src/demo.scss +24 -0
- package/src/demo.ts +22 -0
- package/src/env.d.ts +6 -0
- package/src/i18n/context.ts +89 -0
- package/src/i18n/locales/ar/components.json +43 -0
- package/src/i18n/locales/ar/components.toml +40 -0
- package/src/i18n/locales/de/components.json +43 -0
- package/src/i18n/locales/de/components.toml +40 -0
- package/src/i18n/locales/en/components.json +43 -0
- package/src/i18n/locales/en/components.toml +40 -0
- package/src/i18n/locales/es/components.json +43 -0
- package/src/i18n/locales/es/components.toml +40 -0
- package/src/i18n/locales/fr/components.json +43 -0
- package/src/i18n/locales/fr/components.toml +40 -0
- package/src/i18n/locales/ja/components.json +43 -0
- package/src/i18n/locales/ja/components.toml +40 -0
- package/src/i18n/locales/ko/components.json +43 -0
- package/src/i18n/locales/ko/components.toml +40 -0
- package/src/i18n/locales/pt/components.json +43 -0
- package/src/i18n/locales/pt/components.toml +40 -0
- package/src/i18n/locales/ru/components.json +43 -0
- package/src/i18n/locales/ru/components.toml +40 -0
- package/src/i18n/locales/zh-Hans/components.json +43 -0
- package/src/i18n/locales/zh-Hans/components.toml +40 -0
- package/src/i18n/locales/zh-Hant/components.json +43 -0
- package/src/i18n/locales/zh-Hant/components.toml +40 -0
- package/src/index.ts +137 -0
- package/src/render.ts +18 -0
- package/src/runtime/animationBus.ts +278 -0
- package/src/runtime/cronBus.ts +25 -0
- package/src/runtime/index.ts +12 -0
- package/src/runtime/useAsyncData.ts +30 -0
- package/src/runtime/useBreakpoint.ts +62 -0
- package/src/runtime/useClipboard.ts +37 -0
- package/src/runtime/useConfirm.ts +35 -0
- package/src/runtime/useOverlay.ts +82 -0
- package/src/runtime/usePopupManager.ts +89 -0
- package/src/runtime/useToast.ts +140 -0
- package/src/styles/index.scss +10 -0
- package/src/theme/index.ts +5 -0
- package/src/theme/presets.ts +307 -0
- package/src/theme/theme.scss +17 -0
- package/src/theme/useBackgroundLuminance.ts +145 -0
- package/src/theme/useSolarTime.ts +101 -0
- package/src/theme/useTheme.ts +141 -0
- package/src/tokens.scss +26 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/* HkTooltip — lightweight tooltip. Colours are intentionally decoupled from
|
|
2
|
+
theme tokens so the tooltip stays legible on any wallpaper. */
|
|
3
|
+
.hk-tooltip-wrapper {
|
|
4
|
+
position: relative;
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
max-width: 100%;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.hk-tooltip-trigger {
|
|
10
|
+
display: inline-flex;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.hk-tooltip-popup {
|
|
14
|
+
position: fixed;
|
|
15
|
+
z-index: var(--z-tooltip);
|
|
16
|
+
padding: var(--space-4) var(--space-8);
|
|
17
|
+
border: none;
|
|
18
|
+
border-radius: var(--radius-sm);
|
|
19
|
+
font-size: var(--text-xs);
|
|
20
|
+
line-height: 1.4;
|
|
21
|
+
white-space: normal;
|
|
22
|
+
word-break: break-word;
|
|
23
|
+
pointer-events: none;
|
|
24
|
+
opacity: 0;
|
|
25
|
+
transition: opacity var(--duration-short) ease;
|
|
26
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
|
|
27
|
+
background: #ffffff;
|
|
28
|
+
color: #000000;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.hk-tooltip-popup.hk-tooltip-visible {
|
|
32
|
+
opacity: 1;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.hk-tooltip-content {
|
|
36
|
+
max-width: 280px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
[data-mode="light"] .hk-tooltip-popup {
|
|
40
|
+
background: #ffffff;
|
|
41
|
+
color: #000000;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
[data-mode="dark"] .hk-tooltip-popup {
|
|
45
|
+
background: #4b4b4b;
|
|
46
|
+
color: #ffffff;
|
|
47
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { computed, defineComponent, onBeforeUnmount, ref, Teleport, type CSSProperties, type PropType } from "vue";
|
|
2
|
+
import "./HkTooltip.scss";
|
|
3
|
+
|
|
4
|
+
export default defineComponent({
|
|
5
|
+
name: "HkTooltip",
|
|
6
|
+
props: {
|
|
7
|
+
text: { type: String, required: true },
|
|
8
|
+
placement: { type: String as PropType<"top" | "bottom" | "left" | "right">, default: "top" },
|
|
9
|
+
delay: { type: Number, default: 300 },
|
|
10
|
+
maxWidth: { type: String, default: undefined },
|
|
11
|
+
},
|
|
12
|
+
setup(props, { slots }) {
|
|
13
|
+
const visible = ref(false);
|
|
14
|
+
const wrapperRef = ref<HTMLElement | null>(null);
|
|
15
|
+
const tooltipStyle = ref<CSSProperties>({});
|
|
16
|
+
let showTimer: ReturnType<typeof setTimeout> | null = null;
|
|
17
|
+
|
|
18
|
+
function updatePosition() {
|
|
19
|
+
if (!wrapperRef.value) return;
|
|
20
|
+
const rect = wrapperRef.value.getBoundingClientRect();
|
|
21
|
+
const gap = 8;
|
|
22
|
+
const style: CSSProperties = {};
|
|
23
|
+
|
|
24
|
+
if (props.maxWidth) {
|
|
25
|
+
style.maxWidth = props.maxWidth;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
switch (props.placement) {
|
|
29
|
+
case "top":
|
|
30
|
+
style.top = `${rect.top - gap}px`;
|
|
31
|
+
style.left = `${rect.left + rect.width / 2}px`;
|
|
32
|
+
style.transform = "translate(-50%, -100%)";
|
|
33
|
+
break;
|
|
34
|
+
case "bottom":
|
|
35
|
+
style.top = `${rect.bottom + gap}px`;
|
|
36
|
+
style.left = `${rect.left + rect.width / 2}px`;
|
|
37
|
+
style.transform = "translate(-50%, 0)";
|
|
38
|
+
break;
|
|
39
|
+
case "left":
|
|
40
|
+
style.top = `${rect.top + rect.height / 2}px`;
|
|
41
|
+
style.left = `${rect.left - gap}px`;
|
|
42
|
+
style.transform = "translate(-100%, -50%)";
|
|
43
|
+
break;
|
|
44
|
+
case "right":
|
|
45
|
+
style.top = `${rect.top + rect.height / 2}px`;
|
|
46
|
+
style.left = `${rect.right + gap}px`;
|
|
47
|
+
style.transform = "translate(0, -50%)";
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
tooltipStyle.value = style;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function show() {
|
|
55
|
+
clearShowTimer();
|
|
56
|
+
showTimer = setTimeout(() => {
|
|
57
|
+
visible.value = true;
|
|
58
|
+
requestAnimationFrame(updatePosition);
|
|
59
|
+
}, props.delay);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function hide() {
|
|
63
|
+
clearShowTimer();
|
|
64
|
+
visible.value = false;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function clearShowTimer() {
|
|
68
|
+
if (showTimer !== null) {
|
|
69
|
+
clearTimeout(showTimer);
|
|
70
|
+
showTimer = null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
onBeforeUnmount(() => {
|
|
75
|
+
clearShowTimer();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const tooltipCls = computed(() => [
|
|
79
|
+
"hk-tooltip-popup",
|
|
80
|
+
`hk-tooltip-${props.placement}`,
|
|
81
|
+
visible.value ? "hk-tooltip-visible" : "",
|
|
82
|
+
]);
|
|
83
|
+
|
|
84
|
+
return () => (
|
|
85
|
+
<span
|
|
86
|
+
ref={wrapperRef}
|
|
87
|
+
class="hk-tooltip-wrapper"
|
|
88
|
+
data-position={props.placement}
|
|
89
|
+
onMouseenter={show}
|
|
90
|
+
onMouseleave={hide}
|
|
91
|
+
onFocusin={show}
|
|
92
|
+
onFocusout={hide}
|
|
93
|
+
>
|
|
94
|
+
<span class="hk-tooltip-trigger">
|
|
95
|
+
{slots.default?.()}
|
|
96
|
+
</span>
|
|
97
|
+
<Teleport to="body">
|
|
98
|
+
<div
|
|
99
|
+
class={tooltipCls.value}
|
|
100
|
+
style={tooltipStyle.value}
|
|
101
|
+
>
|
|
102
|
+
<div class="hk-tooltip-content">{props.text}</div>
|
|
103
|
+
</div>
|
|
104
|
+
</Teleport>
|
|
105
|
+
</span>
|
|
106
|
+
);
|
|
107
|
+
},
|
|
108
|
+
});
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
.hk-tree {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.hk-tree-node {
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.hk-tree-indent {
|
|
12
|
+
flex-shrink: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.hk-tree-children {
|
|
16
|
+
position: relative;
|
|
17
|
+
|
|
18
|
+
&::before {
|
|
19
|
+
content: "";
|
|
20
|
+
position: absolute;
|
|
21
|
+
left: var(--guide-left, 8px);
|
|
22
|
+
top: 0;
|
|
23
|
+
bottom: 6px;
|
|
24
|
+
width: 1px;
|
|
25
|
+
background: color-mix(in srgb, var(--hi-color-border) 30%, transparent);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.hk-tree-row {
|
|
30
|
+
display: flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
padding: 0 8px;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
transition: background var(--hi-duration-fast, 0.15s) ease;
|
|
35
|
+
color: var(--hi-color-text-primary);
|
|
36
|
+
position: relative;
|
|
37
|
+
|
|
38
|
+
&:hover {
|
|
39
|
+
background: color-mix(in srgb, var(--hi-color-primary) 5%, transparent);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.hk-tree-row[data-status="completed"] {
|
|
44
|
+
opacity: 0.55;
|
|
45
|
+
|
|
46
|
+
.hk-tree-label {
|
|
47
|
+
text-decoration: line-through;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.hk-tree-row[data-status="failed"] .hk-tree-label {
|
|
52
|
+
color: var(--hi-color-danger);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.hk-tree-row[data-status="in_progress"],
|
|
56
|
+
.hk-tree-row[data-status="running"] {
|
|
57
|
+
.hk-tree-label {
|
|
58
|
+
font-weight: 500;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.hk-tree-row[data-status="warning"] .hk-tree-label {
|
|
63
|
+
color: var(--hi-color-warning);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.hk-tree-row[data-status="muted"] {
|
|
67
|
+
opacity: 0.45;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* ── Row heights by size ───────────────────────── */
|
|
71
|
+
|
|
72
|
+
.hk-tree[data-size="xs"] > .hk-tree-node > .hk-tree-row,
|
|
73
|
+
.hk-tree[data-size="xs"] .hk-tree-children > .hk-tree-node > .hk-tree-row {
|
|
74
|
+
min-height: 22px;
|
|
75
|
+
|
|
76
|
+
.hk-tree-label { font-size: var(--hi-text-xs, 0.75rem); }
|
|
77
|
+
.hk-tree-icon { width: 14px; height: 14px; }
|
|
78
|
+
.hk-tree-leaf { width: 4px; height: 4px; }
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.hk-tree[data-size="sm"] > .hk-tree-node > .hk-tree-row,
|
|
82
|
+
.hk-tree[data-size="sm"] .hk-tree-children > .hk-tree-node > .hk-tree-row {
|
|
83
|
+
min-height: 28px;
|
|
84
|
+
|
|
85
|
+
.hk-tree-label { font-size: var(--hi-text-xs, 0.75rem); }
|
|
86
|
+
.hk-tree-icon { width: 16px; height: 16px; }
|
|
87
|
+
.hk-tree-leaf { width: 5px; height: 5px; }
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.hk-tree[data-size="md"] > .hk-tree-node > .hk-tree-row,
|
|
91
|
+
.hk-tree[data-size="md"] .hk-tree-children > .hk-tree-node > .hk-tree-row {
|
|
92
|
+
min-height: 34px;
|
|
93
|
+
|
|
94
|
+
.hk-tree-label { font-size: var(--hi-text-sm, 0.875rem); }
|
|
95
|
+
.hk-tree-icon { width: 18px; height: 18px; }
|
|
96
|
+
.hk-tree-leaf { width: 6px; height: 6px; }
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/* ── Toggle chevron ────────────────────────────── */
|
|
100
|
+
|
|
101
|
+
.hk-tree-toggle {
|
|
102
|
+
display: flex;
|
|
103
|
+
align-items: center;
|
|
104
|
+
justify-content: center;
|
|
105
|
+
width: 16px;
|
|
106
|
+
height: 16px;
|
|
107
|
+
flex-shrink: 0;
|
|
108
|
+
color: var(--hi-color-muted);
|
|
109
|
+
border-radius: var(--hi-radius-sm, 4px);
|
|
110
|
+
transition: color var(--hi-duration-fast, 0.15s), background var(--hi-duration-fast, 0.15s);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.hk-tree-toggle[data-parent] {
|
|
114
|
+
cursor: pointer;
|
|
115
|
+
|
|
116
|
+
&:hover {
|
|
117
|
+
background: color-mix(in srgb, var(--hi-color-surface) 40%, transparent);
|
|
118
|
+
color: var(--hi-color-text-primary);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.hk-tree-chevron {
|
|
123
|
+
transition: transform var(--hi-duration-normal, 0.3s) ease;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.hk-tree-chevron[data-open] {
|
|
127
|
+
transform: rotate(90deg);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.hk-tree-leaf {
|
|
131
|
+
display: block;
|
|
132
|
+
border-radius: 50%;
|
|
133
|
+
background: color-mix(in srgb, var(--hi-color-muted) 25%, transparent);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* ── Icon slot ─────────────────────────────────── */
|
|
137
|
+
|
|
138
|
+
.hk-tree-icon {
|
|
139
|
+
display: flex;
|
|
140
|
+
align-items: center;
|
|
141
|
+
justify-content: center;
|
|
142
|
+
flex-shrink: 0;
|
|
143
|
+
margin-left: 4px;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* ── Label ─────────────────────────────────────── */
|
|
147
|
+
|
|
148
|
+
.hk-tree-label {
|
|
149
|
+
flex: 1;
|
|
150
|
+
min-width: 0;
|
|
151
|
+
white-space: nowrap;
|
|
152
|
+
overflow: hidden;
|
|
153
|
+
text-overflow: ellipsis;
|
|
154
|
+
line-height: 1.4;
|
|
155
|
+
font-weight: 400;
|
|
156
|
+
margin-left: 4px;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/* ── Label rich-text parts (agent::skill) ───────── */
|
|
160
|
+
|
|
161
|
+
.hk-tree-label-agent {
|
|
162
|
+
font-weight: 600;
|
|
163
|
+
color: var(--hi-color-primary);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.hk-tree-label-sep {
|
|
167
|
+
color: var(--hi-color-muted);
|
|
168
|
+
font-weight: 400;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.hk-tree-label-skill {
|
|
172
|
+
font-weight: 500;
|
|
173
|
+
color: var(--hi-color-text-primary);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.hk-tree-label-tag {
|
|
177
|
+
display: inline-block;
|
|
178
|
+
vertical-align: middle;
|
|
179
|
+
padding: 0 0.375em;
|
|
180
|
+
font-size: 0.85em;
|
|
181
|
+
font-weight: 600;
|
|
182
|
+
color: var(--hi-color-primary);
|
|
183
|
+
background: color-mix(in srgb, var(--hi-color-primary) 8%, transparent);
|
|
184
|
+
border: 1px solid color-mix(in srgb, var(--hi-color-primary) 18%, transparent);
|
|
185
|
+
border-radius: var(--hi-radius-sm, 4px);
|
|
186
|
+
line-height: 1.5;
|
|
187
|
+
letter-spacing: 0.02em;
|
|
188
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { defineComponent, ref, watch, h, type Component, type PropType, type VNodeChild } from "vue";
|
|
2
|
+
|
|
3
|
+
import "./HkTree.scss";
|
|
4
|
+
|
|
5
|
+
export type TreeSize = "xs" | "sm" | "md";
|
|
6
|
+
|
|
7
|
+
export interface TreeNode {
|
|
8
|
+
id: string;
|
|
9
|
+
label: string;
|
|
10
|
+
icon?: Component;
|
|
11
|
+
iconClass?: string;
|
|
12
|
+
status?: string;
|
|
13
|
+
tag?: boolean;
|
|
14
|
+
tagLabel?: string;
|
|
15
|
+
children?: TreeNode[];
|
|
16
|
+
data?: unknown;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface TreeRowScope {
|
|
20
|
+
node: TreeNode;
|
|
21
|
+
depth: number;
|
|
22
|
+
indent: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
type RowRenderer = (scope: TreeRowScope) => VNodeChild;
|
|
26
|
+
|
|
27
|
+
export default defineComponent({
|
|
28
|
+
name: "HkTree",
|
|
29
|
+
props: {
|
|
30
|
+
nodes: { type: Array as PropType<TreeNode[]>, default: () => [] },
|
|
31
|
+
size: { type: String as PropType<TreeSize>, default: "sm" },
|
|
32
|
+
defaultExpandAll: { type: Boolean, default: false },
|
|
33
|
+
indent: { type: Number, default: 16 },
|
|
34
|
+
expandOnClick: { type: Boolean, default: false },
|
|
35
|
+
},
|
|
36
|
+
emits: {
|
|
37
|
+
select: (_node: TreeNode) => true,
|
|
38
|
+
toggle: (_node: TreeNode) => true,
|
|
39
|
+
},
|
|
40
|
+
setup(props, { slots, emit }) {
|
|
41
|
+
const expanded = ref<Set<string>>(new Set());
|
|
42
|
+
|
|
43
|
+
function ensureExpanded() {
|
|
44
|
+
if (expanded.value.size > 0) return;
|
|
45
|
+
if (!props.defaultExpandAll) return;
|
|
46
|
+
const ids = new Set<string>();
|
|
47
|
+
function walk(list: TreeNode[]) {
|
|
48
|
+
for (const n of list) {
|
|
49
|
+
if (n.children?.length) {
|
|
50
|
+
ids.add(n.id);
|
|
51
|
+
walk(n.children);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
walk(props.nodes);
|
|
56
|
+
expanded.value = ids;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
watch(
|
|
60
|
+
() => props.nodes,
|
|
61
|
+
() => { if (props.defaultExpandAll) ensureExpanded(); },
|
|
62
|
+
{ immediate: true },
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
function findNode(id: string): TreeNode | undefined {
|
|
66
|
+
let found: TreeNode | undefined;
|
|
67
|
+
function walk(list: TreeNode[]) {
|
|
68
|
+
for (const n of list) {
|
|
69
|
+
if (n.id === id) { found = n; return; }
|
|
70
|
+
if (n.children?.length) walk(n.children);
|
|
71
|
+
if (found) return;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
walk(props.nodes);
|
|
75
|
+
return found;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function toggle(id: string) {
|
|
79
|
+
const next = new Set(expanded.value);
|
|
80
|
+
if (next.has(id)) next.delete(id);
|
|
81
|
+
else next.add(id);
|
|
82
|
+
expanded.value = next;
|
|
83
|
+
const node = findNode(id);
|
|
84
|
+
if (node) emit("toggle", node);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const renderRow: RowRenderer | undefined = slots.row
|
|
88
|
+
? (scope) => slots.row!(scope)
|
|
89
|
+
: undefined;
|
|
90
|
+
|
|
91
|
+
return () => (
|
|
92
|
+
<div class="hk-tree" data-size={props.size}>
|
|
93
|
+
{props.nodes.map((node) => (
|
|
94
|
+
<TreeNodeRow
|
|
95
|
+
key={node.id}
|
|
96
|
+
node={node}
|
|
97
|
+
depth={0}
|
|
98
|
+
indent={props.indent}
|
|
99
|
+
expanded={expanded.value}
|
|
100
|
+
expandOnClick={props.expandOnClick}
|
|
101
|
+
renderRow={renderRow}
|
|
102
|
+
onToggle={toggle}
|
|
103
|
+
onSelect={(n) => emit("select", n)}
|
|
104
|
+
/>
|
|
105
|
+
))}
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
interface TreeNodeRowProps {
|
|
112
|
+
node: TreeNode;
|
|
113
|
+
depth: number;
|
|
114
|
+
indent: number;
|
|
115
|
+
expanded: Set<string>;
|
|
116
|
+
expandOnClick: boolean;
|
|
117
|
+
renderRow?: RowRenderer;
|
|
118
|
+
onToggle: (id: string) => void;
|
|
119
|
+
onSelect: (node: TreeNode) => void;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const TreeNodeRow = ({
|
|
123
|
+
node,
|
|
124
|
+
depth,
|
|
125
|
+
indent,
|
|
126
|
+
expanded,
|
|
127
|
+
expandOnClick,
|
|
128
|
+
renderRow,
|
|
129
|
+
onToggle,
|
|
130
|
+
onSelect,
|
|
131
|
+
}: TreeNodeRowProps) => {
|
|
132
|
+
const hasChildren = (node.children?.length ?? 0) > 0;
|
|
133
|
+
const isExpanded = hasChildren && expanded.has(node.id);
|
|
134
|
+
const IconComp = node.icon;
|
|
135
|
+
|
|
136
|
+
const guideLeft = depth * indent + 16;
|
|
137
|
+
|
|
138
|
+
function handleRowClick() {
|
|
139
|
+
onSelect(node);
|
|
140
|
+
if (expandOnClick && hasChildren) onToggle(node.id);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return (
|
|
144
|
+
<div class="hk-tree-node">
|
|
145
|
+
<div
|
|
146
|
+
class="hk-tree-row"
|
|
147
|
+
data-status={node.status || undefined}
|
|
148
|
+
onClick={handleRowClick}
|
|
149
|
+
>
|
|
150
|
+
{depth > 0 && (
|
|
151
|
+
<span class="hk-tree-indent" style={{ width: `${depth * indent}px` }} />
|
|
152
|
+
)}
|
|
153
|
+
|
|
154
|
+
<span
|
|
155
|
+
class="hk-tree-toggle"
|
|
156
|
+
data-parent={hasChildren || undefined}
|
|
157
|
+
data-open={isExpanded || undefined}
|
|
158
|
+
onClick={(e: MouseEvent) => { e.stopPropagation(); if (hasChildren) onToggle(node.id); }}
|
|
159
|
+
>
|
|
160
|
+
{hasChildren ? (
|
|
161
|
+
<svg viewBox="0 0 16 16" width="12" height="12" class="hk-tree-chevron" data-open={isExpanded || undefined}>
|
|
162
|
+
<path d="M6 4l4 4-4 4" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
|
|
163
|
+
</svg>
|
|
164
|
+
) : (
|
|
165
|
+
<span class="hk-tree-leaf" />
|
|
166
|
+
)}
|
|
167
|
+
</span>
|
|
168
|
+
|
|
169
|
+
{renderRow
|
|
170
|
+
? renderRow({ node, depth, indent })
|
|
171
|
+
: (
|
|
172
|
+
<>
|
|
173
|
+
{IconComp ? (
|
|
174
|
+
<span class={["hk-tree-icon", node.iconClass ?? ""]}>
|
|
175
|
+
{h(IconComp as Component, { size: 13 })}
|
|
176
|
+
</span>
|
|
177
|
+
) : null}
|
|
178
|
+
|
|
179
|
+
<span class="hk-tree-label">
|
|
180
|
+
{node.tagLabel
|
|
181
|
+
? [renderTagLabel(node.tagLabel), " ", renderLabel(node.label)]
|
|
182
|
+
: node.tag
|
|
183
|
+
? renderTagLabel(node.label)
|
|
184
|
+
: renderLabel(node.label)}
|
|
185
|
+
</span>
|
|
186
|
+
</>
|
|
187
|
+
)}
|
|
188
|
+
</div>
|
|
189
|
+
|
|
190
|
+
{hasChildren && isExpanded && (
|
|
191
|
+
<div class="hk-tree-children" style={{ "--guide-left": `${guideLeft}px` } as Record<string, string>}>
|
|
192
|
+
{node.children?.map((child) => (
|
|
193
|
+
<TreeNodeRow
|
|
194
|
+
key={child.id}
|
|
195
|
+
node={child}
|
|
196
|
+
depth={depth + 1}
|
|
197
|
+
indent={indent}
|
|
198
|
+
expanded={expanded}
|
|
199
|
+
expandOnClick={expandOnClick}
|
|
200
|
+
renderRow={renderRow}
|
|
201
|
+
onToggle={onToggle}
|
|
202
|
+
onSelect={onSelect}
|
|
203
|
+
/>
|
|
204
|
+
))}
|
|
205
|
+
</div>
|
|
206
|
+
)}
|
|
207
|
+
</div>
|
|
208
|
+
);
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
function renderLabel(label: string) {
|
|
212
|
+
return label;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function renderTagLabel(label: string) {
|
|
216
|
+
return <span class="hk-tree-label-tag">{label}</span>;
|
|
217
|
+
}
|