pxd 0.1.4 → 0.1.7
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/dist/components/_internal/dismiss-container.d.vue.ts +2 -2
- package/dist/components/_internal/dismiss-container.vue +1 -1
- package/dist/components/_internal/mention-editor.d.vue.ts +3 -4
- package/dist/components/_internal/mention-editor.vue +7 -5
- package/dist/components/_internal/tree-node.d.vue.ts +10 -1
- package/dist/components/_internal/tree-node.vue +32 -12
- package/dist/components/active-graph/index.d.vue.ts +1 -1
- package/dist/components/active-graph/index.vue +4 -18
- package/dist/components/active-graph/types.d.ts +1 -1
- package/dist/components/approval-card/index.d.vue.ts +2 -2
- package/dist/components/approval-card/index.vue +8 -4
- package/dist/components/approval-card/types.d.ts +1 -1
- package/dist/components/avatar/index.d.vue.ts +2 -2
- package/dist/components/avatar/index.vue +1 -1
- package/dist/components/backtop/index.d.vue.ts +1 -1
- package/dist/components/badge/index.vue +4 -2
- package/dist/components/badge/types.d.ts +7 -2
- package/dist/components/browser/index.vue +1 -1
- package/dist/components/bubble/index.d.vue.ts +1 -1
- package/dist/components/bubble/index.vue +35 -14
- package/dist/components/bubble/types.d.ts +2 -1
- package/dist/components/bubble-group/index.d.vue.ts +10 -3
- package/dist/components/bubble-group/index.vue +41 -8
- package/dist/components/bubble-group/types.d.ts +5 -4
- package/dist/components/button/index.d.vue.ts +1 -1
- package/dist/components/button/index.vue +4 -4
- package/dist/components/calendar/index.d.vue.ts +2 -2
- package/dist/components/calendar/index.vue +3 -3
- package/dist/components/calendar/types.d.ts +1 -1
- package/dist/components/checkbox/index.d.vue.ts +2 -2
- package/dist/components/checkbox/index.vue +3 -3
- package/dist/components/checkbox/types.d.ts +1 -1
- package/dist/components/checkbox-group/index.d.vue.ts +2 -2
- package/dist/components/checkbox-group/index.vue +2 -2
- package/dist/components/checkbox-group/types.d.ts +1 -1
- package/dist/components/checkerboard/index.d.vue.ts +3 -1
- package/dist/components/checkerboard/index.vue +13 -2
- package/dist/components/checkerboard/types.d.ts +1 -0
- package/dist/components/choicebox/index.d.vue.ts +2 -2
- package/dist/components/choicebox/index.vue +2 -2
- package/dist/components/choicebox/types.d.ts +1 -1
- package/dist/components/choicebox-item/index.vue +1 -1
- package/dist/components/code-block/index.d.vue.ts +7 -3
- package/dist/components/code-block/index.vue +268 -72
- package/dist/components/code-block/types.d.ts +33 -14
- package/dist/components/collapse/index.d.vue.ts +3 -1
- package/dist/components/collapse/index.vue +37 -41
- package/dist/components/collapse/types.d.ts +3 -1
- package/dist/components/collapse-group/index.vue +3 -3
- package/dist/components/color-selector/index.d.vue.ts +2 -2
- package/dist/components/color-selector/index.vue +2 -2
- package/dist/components/color-selector/types.d.ts +1 -1
- package/dist/components/command-menu/index.d.vue.ts +3 -3
- package/dist/components/command-menu/index.vue +2 -2
- package/dist/components/command-menu/types.d.ts +1 -1
- package/dist/components/confirm-popover/index.d.vue.ts +2 -2
- package/dist/components/confirm-popover/index.vue +10 -15
- package/dist/components/confirm-popover/types.d.ts +6 -7
- package/dist/components/context-usage/index.d.vue.ts +6 -0
- package/dist/components/context-usage/index.vue +120 -0
- package/dist/components/context-usage/types.d.ts +13 -0
- package/dist/components/copy-button/index.vue +17 -9
- package/dist/components/copy-button/types.d.ts +3 -1
- package/dist/components/countdown/index.vue +1 -1
- package/dist/components/date-picker/index.d.vue.ts +13 -3
- package/dist/components/date-picker/index.vue +6 -4
- package/dist/components/date-picker/types.d.ts +1 -1
- package/dist/components/description/index.vue +1 -1
- package/dist/components/description/types.d.ts +3 -1
- package/dist/components/drawer/index.d.vue.ts +5 -5
- package/dist/components/drawer/index.vue +13 -13
- package/dist/components/drawer/types.d.ts +2 -2
- package/dist/components/effort-slider/index.d.vue.ts +2 -2
- package/dist/components/effort-slider/index.vue +63 -17
- package/dist/components/effort-slider/types.d.ts +3 -1
- package/dist/components/ellipsis-text/index.d.vue.ts +3 -3
- package/dist/components/ellipsis-text/index.vue +5 -5
- package/dist/components/ellipsis-text/types.d.ts +4 -2
- package/dist/components/empty-state/index.vue +1 -1
- package/dist/components/empty-state/types.d.ts +3 -1
- package/dist/components/feedback-bar/index.d.vue.ts +4 -4
- package/dist/components/feedback-bar/index.vue +4 -4
- package/dist/components/feedback-bar/types.d.ts +2 -2
- package/dist/components/gauge/index.vue +75 -79
- package/dist/components/gauge/types.d.ts +2 -0
- package/dist/components/hint/index.vue +2 -3
- package/dist/components/hold-button/index.d.vue.ts +4 -4
- package/dist/components/hold-button/index.vue +86 -75
- package/dist/components/hue-text/index.vue +2 -2
- package/dist/components/hue-text/types.d.ts +3 -1
- package/dist/components/image-preview/index.d.vue.ts +2 -0
- package/dist/components/image-preview/index.vue +156 -131
- package/dist/components/image-preview/types.d.ts +18 -18
- package/dist/components/index.d.ts +132 -0
- package/dist/components/index.js +3 -0
- package/dist/components/input/index.d.vue.ts +2 -2
- package/dist/components/input/index.vue +2 -2
- package/dist/components/input/types.d.ts +1 -1
- package/dist/components/kbd/index.vue +1 -1
- package/dist/components/link-button/index.d.vue.ts +1 -1
- package/dist/components/link-button/index.vue +1 -1
- package/dist/components/link-button/types.d.ts +1 -1
- package/dist/components/list/index.d.vue.ts +3 -3
- package/dist/components/list/index.vue +4 -4
- package/dist/components/list/types.d.ts +1 -1
- package/dist/components/list-group/index.vue +1 -1
- package/dist/components/{_internal/loading-mask.d.vue.ts → loading-mask/index.d.vue.ts} +2 -4
- package/dist/components/{_internal/loading-mask.vue → loading-mask/index.vue} +1 -1
- package/dist/components/loading-mask/types.d.ts +3 -0
- package/dist/components/marching-ants/index.d.vue.ts +1 -1
- package/dist/components/marquee/index.d.vue.ts +3 -3
- package/dist/components/marquee/index.vue +1 -1
- package/dist/components/marquee/types.d.ts +2 -2
- package/dist/components/mention/index.d.vue.ts +6 -4
- package/dist/components/mention/index.vue +6 -2
- package/dist/components/mention/types.d.ts +1 -1
- package/dist/components/menu/index.d.vue.ts +5 -3
- package/dist/components/menu/index.vue +6 -2
- package/dist/components/menu/types.d.ts +1 -1
- package/dist/components/message/index.d.vue.ts +1 -1
- package/dist/components/modal/index.d.vue.ts +4 -4
- package/dist/components/modal/index.vue +13 -13
- package/dist/components/modal/types.d.ts +2 -2
- package/dist/components/more-button/index.d.vue.ts +4 -4
- package/dist/components/more-button/index.vue +4 -4
- package/dist/components/more-button/types.d.ts +3 -3
- package/dist/components/note/index.vue +1 -1
- package/dist/components/note/types.d.ts +1 -1
- package/dist/components/number-input/index.d.vue.ts +2 -2
- package/dist/components/number-input/index.vue +2 -2
- package/dist/components/number-input/types.d.ts +1 -1
- package/dist/components/overlay/index.d.vue.ts +2 -2
- package/dist/components/overlay/index.vue +4 -4
- package/dist/components/overlay/types.d.ts +1 -1
- package/dist/components/page-number/index.d.vue.ts +3 -3
- package/dist/components/page-number/index.vue +3 -3
- package/dist/components/page-number/types.d.ts +1 -1
- package/dist/components/pagination/index.vue +2 -2
- package/dist/components/pin-input/index.d.vue.ts +4 -4
- package/dist/components/pin-input/index.vue +3 -3
- package/dist/components/pin-input/types.d.ts +1 -1
- package/dist/components/placeholder/index.vue +3 -3
- package/dist/components/placeholder/types.d.ts +1 -1
- package/dist/components/popover/index.vue +73 -36
- package/dist/components/popover/types.d.ts +1 -2
- package/dist/components/questionnaire/index.d.vue.ts +1 -0
- package/dist/components/questionnaire/index.vue +92 -87
- package/dist/components/questionnaire/types.d.ts +1 -3
- package/dist/components/radio/index.d.vue.ts +2 -2
- package/dist/components/radio/index.vue +3 -3
- package/dist/components/radio/types.d.ts +1 -1
- package/dist/components/radio-group/index.d.vue.ts +2 -2
- package/dist/components/radio-group/index.vue +2 -2
- package/dist/components/radio-group/types.d.ts +1 -1
- package/dist/components/rating/index.d.vue.ts +3 -3
- package/dist/components/rating/index.vue +2 -2
- package/dist/components/rating/types.d.ts +1 -1
- package/dist/components/reactions/index.d.vue.ts +34 -0
- package/dist/components/reactions/index.vue +143 -0
- package/dist/components/reactions/types.d.ts +23 -0
- package/dist/components/reasoning/index.d.vue.ts +2 -0
- package/dist/components/reasoning/index.vue +49 -30
- package/dist/components/reasoning/types.d.ts +9 -0
- package/dist/components/resizable/index.d.vue.ts +2 -2
- package/dist/components/resizable/index.vue +3 -3
- package/dist/components/resizable/types.d.ts +1 -1
- package/dist/components/reveal/index.d.vue.ts +1 -1
- package/dist/components/rolling-number/index.vue +1 -1
- package/dist/components/scroll-text/index.d.vue.ts +1 -1
- package/dist/components/scroll-text/index.vue +2 -2
- package/dist/components/scroll-text/types.d.ts +2 -2
- package/dist/components/scrollable/index.d.vue.ts +3 -2
- package/dist/components/scrollable/types.d.ts +0 -15
- package/dist/components/search-input/index.d.vue.ts +5 -5
- package/dist/components/search-input/index.vue +1 -1
- package/dist/components/select/index.d.vue.ts +10 -6
- package/dist/components/select/index.vue +15 -8
- package/dist/components/select/types.d.ts +1 -1
- package/dist/components/shimmer-text/index.d.vue.ts +1 -1
- package/dist/components/shimmer-text/index.vue +1 -1
- package/dist/components/shimmer-text/types.d.ts +1 -1
- package/dist/components/skeleton/index.d.vue.ts +1 -1
- package/dist/components/slider/index.d.vue.ts +2 -3
- package/dist/components/slider/index.vue +17 -6
- package/dist/components/slider/types.d.ts +2 -1
- package/dist/components/snippet/index.vue +1 -5
- package/dist/components/snippet/types.d.ts +6 -2
- package/dist/components/spinner-dots/types.d.ts +1 -1
- package/dist/components/split-button/index.d.vue.ts +5 -3
- package/dist/components/split-button/index.vue +6 -2
- package/dist/components/split-button/types.d.ts +1 -1
- package/dist/components/steps/index.d.vue.ts +2 -2
- package/dist/components/steps/index.vue +2 -2
- package/dist/components/steps/types.d.ts +1 -1
- package/dist/components/stick-to-bottom/index.vue +3 -6
- package/dist/components/swipe-cell/index.d.vue.ts +2 -2
- package/dist/components/swipe-cell/index.vue +3 -3
- package/dist/components/swipe-cell/types.d.ts +1 -1
- package/dist/components/switch/index.d.vue.ts +2 -2
- package/dist/components/switch/index.vue +2 -2
- package/dist/components/switch/types.d.ts +1 -1
- package/dist/components/switch-item/index.vue +2 -2
- package/dist/components/tabs/index.d.vue.ts +2 -2
- package/dist/components/tabs/index.vue +3 -3
- package/dist/components/tabs/types.d.ts +1 -1
- package/dist/components/text/index.vue +1 -1
- package/dist/components/text/types.d.ts +1 -1
- package/dist/components/textarea/index.d.vue.ts +2 -2
- package/dist/components/textarea/index.vue +2 -2
- package/dist/components/textarea/types.d.ts +1 -1
- package/dist/components/theme-switcher/index.d.vue.ts +2 -3
- package/dist/components/theme-switcher/index.vue +7 -7
- package/dist/components/time-picker/index.d.vue.ts +13 -3
- package/dist/components/time-picker/index.vue +10 -8
- package/dist/components/time-picker/types.d.ts +1 -1
- package/dist/components/timeline-item/index.d.vue.ts +0 -1
- package/dist/components/timeline-item/index.vue +20 -4
- package/dist/components/timeline-item/types.d.ts +2 -2
- package/dist/components/toc/index.d.vue.ts +4 -1
- package/dist/components/toc/index.vue +65 -8
- package/dist/components/toc/types.d.ts +10 -1
- package/dist/components/todo-list/index.d.vue.ts +4 -13
- package/dist/components/todo-list/index.vue +122 -133
- package/dist/components/todo-list/types.d.ts +5 -4
- package/dist/components/toggle/index.d.vue.ts +4 -4
- package/dist/components/toggle/index.vue +4 -4
- package/dist/components/toggle/types.d.ts +6 -6
- package/dist/components/toggle-button/index.d.vue.ts +2 -2
- package/dist/components/toggle-button/index.vue +2 -2
- package/dist/components/toggle-button/types.d.ts +1 -1
- package/dist/components/toggle-button-group/index.d.vue.ts +2 -2
- package/dist/components/toggle-button-group/index.vue +2 -2
- package/dist/components/toggle-button-group/types.d.ts +1 -1
- package/dist/components/tool-call/index.d.vue.ts +2 -0
- package/dist/components/tool-call/index.vue +139 -133
- package/dist/components/tool-call/types.d.ts +6 -1
- package/dist/components/tooltip/index.d.vue.ts +1 -1
- package/dist/components/tooltip/index.vue +1 -0
- package/dist/components/tour/index.d.vue.ts +4 -4
- package/dist/components/tour/index.vue +4 -4
- package/dist/components/tour/types.d.ts +5 -5
- package/dist/components/tree/index.d.vue.ts +27 -18
- package/dist/components/tree/index.vue +95 -27
- package/dist/components/tree/types.d.ts +18 -17
- package/dist/components/virtual-list/index.d.vue.ts +5 -4
- package/dist/components/virtual-list/index.vue +5 -4
- package/dist/components/virtual-list/types.d.ts +10 -8
- package/dist/composables/_internal/use-code-highlight.js +3 -1
- package/dist/composables/_internal/use-details-collapse.d.ts +7 -0
- package/dist/composables/_internal/use-details-collapse.js +68 -0
- package/dist/composables/_internal/use-list-selection.d.ts +1 -1
- package/dist/composables/_internal/use-list-selection.js +2 -2
- package/dist/composables/_internal/use-model-value.d.ts +1 -1
- package/dist/composables/_internal/use-model-value.js +1 -1
- package/dist/composables/_internal/use-tailwind-variant.js +1 -1
- package/dist/composables/_internal/use-tree.d.ts +32 -6
- package/dist/composables/_internal/use-tree.js +89 -54
- package/dist/composables/use-color-scheme.d.ts +1 -1
- package/dist/composables/use-color-scheme.js +7 -3
- package/dist/composables/use-countdown.d.ts +1 -1
- package/dist/composables/use-countdown.js +9 -9
- package/dist/composables/use-loading-bar.js +4 -0
- package/dist/composables/use-stick-to-bottom.d.ts +5 -0
- package/dist/composables/use-stick-to-bottom.js +45 -31
- package/dist/composables/use-virtual-list.d.ts +21 -1
- package/dist/composables/use-virtual-list.js +30 -9
- package/dist/constants/tooltip-variants.d.ts +2 -2
- package/dist/constants/tooltip-variants.js +3 -3
- package/dist/contexts/collapse.d.ts +1 -1
- package/dist/styles/styles.css +1 -1
- package/dist/styles/tw.css +12 -7
- package/package.json +10 -11
- package/volar.d.ts +3 -0
- package/dist/components/bubble-group/types.js +0 -0
- package/dist/components/virtual-list/types.js +0 -0
- package/dist/composables/_internal/use-collapse-motion.d.ts +0 -6
- package/dist/composables/_internal/use-collapse-motion.js +0 -85
- package/dist/utils/_internal/cn-tables.d.ts +0 -27
- package/dist/utils/_internal/cn-tables.js +0 -131
- package/dist/utils/cn.d.ts +0 -1
- package/dist/utils/cn.js +0 -3
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import
|
|
2
|
+
import ChevronDownIcon from "@gdsicon/vue/chevron-down";
|
|
3
|
+
import FileIcon from "@gdsicon/vue/file";
|
|
4
|
+
import { computed, onMounted, onUnmounted, shallowRef, useSlots, watch } from "vue";
|
|
3
5
|
import { MAX_HIGHLIGHT_LENGTH, useCodeHighlight } from "../../composables/_internal/use-code-highlight.js";
|
|
4
6
|
import { useTailwindVariant } from "../../composables/_internal/use-tailwind-variant.js";
|
|
5
7
|
import { useConfigProvider } from "../../contexts/config-provider.js";
|
|
@@ -20,7 +22,7 @@ const props = defineProps({
|
|
|
20
22
|
required: false
|
|
21
23
|
},
|
|
22
24
|
title: {
|
|
23
|
-
type:
|
|
25
|
+
type: null,
|
|
24
26
|
required: false
|
|
25
27
|
},
|
|
26
28
|
size: {
|
|
@@ -31,6 +33,18 @@ const props = defineProps({
|
|
|
31
33
|
type: Boolean,
|
|
32
34
|
required: false
|
|
33
35
|
},
|
|
36
|
+
highlightedLines: {
|
|
37
|
+
type: Array,
|
|
38
|
+
required: false
|
|
39
|
+
},
|
|
40
|
+
addedLines: {
|
|
41
|
+
type: Array,
|
|
42
|
+
required: false
|
|
43
|
+
},
|
|
44
|
+
removedLines: {
|
|
45
|
+
type: Array,
|
|
46
|
+
required: false
|
|
47
|
+
},
|
|
34
48
|
maxHeight: {
|
|
35
49
|
type: [Number, String],
|
|
36
50
|
required: false
|
|
@@ -43,14 +57,31 @@ const props = defineProps({
|
|
|
43
57
|
type: String,
|
|
44
58
|
required: false,
|
|
45
59
|
default: "hover"
|
|
60
|
+
},
|
|
61
|
+
switcher: {
|
|
62
|
+
type: Object,
|
|
63
|
+
required: false
|
|
64
|
+
},
|
|
65
|
+
tabs: {
|
|
66
|
+
type: Object,
|
|
67
|
+
required: false
|
|
46
68
|
}
|
|
47
69
|
});
|
|
48
|
-
const emits = defineEmits([
|
|
70
|
+
const emits = defineEmits([
|
|
71
|
+
"copy",
|
|
72
|
+
"switcher-change",
|
|
73
|
+
"tabs-change"
|
|
74
|
+
]);
|
|
49
75
|
const DEFAULT_MAX_HEIGHT = "20rem";
|
|
50
76
|
const bodyEl = shallowRef(null);
|
|
51
77
|
const expanded = shallowRef(false);
|
|
52
78
|
const isOverflowing = shallowRef(false);
|
|
53
|
-
const
|
|
79
|
+
const activeLine = shallowRef(null);
|
|
80
|
+
const lines = computed(() => props.code.split("\n"));
|
|
81
|
+
const highlightedSet = computed(() => new Set(props.highlightedLines));
|
|
82
|
+
const addedSet = computed(() => new Set(props.addedLines));
|
|
83
|
+
const removedSet = computed(() => new Set(props.removedLines));
|
|
84
|
+
const isLineMode = computed(() => props.lineNumbers || highlightedSet.value.size > 0 || addedSet.value.size > 0 || removedSet.value.size > 0);
|
|
54
85
|
const isOversized = computed(() => props.code.length > MAX_HIGHLIGHT_LENGTH);
|
|
55
86
|
const maxHeight = computed(() => getCssUnitValue(props.maxHeight, DEFAULT_MAX_HEIGHT));
|
|
56
87
|
const isClipped = computed(() => props.collapsible && !expanded.value);
|
|
@@ -59,16 +90,37 @@ const languageClass = computed(() => {
|
|
|
59
90
|
// Oversized blocks drop the language class so the scanner skips them instead of tokenizing.
|
|
60
91
|
return language && !isOversized.value ? `language-${language}` : undefined;
|
|
61
92
|
});
|
|
93
|
+
const lineAnchorPrefix = computed(() => getLineAnchorPrefix(props.code));
|
|
94
|
+
const activeSwitcherValue = computed(() => props.switcher?.value ?? props.switcher?.options[0]?.value);
|
|
95
|
+
const activeSwitcherLabel = computed(() => {
|
|
96
|
+
const option = props.switcher?.options.find((item) => item.value === activeSwitcherValue.value);
|
|
97
|
+
return option?.label ?? option?.value;
|
|
98
|
+
});
|
|
99
|
+
const activeTabValue = computed(() => props.tabs?.value ?? props.tabs?.options[0]?.value);
|
|
62
100
|
const configProvider = useConfigProvider();
|
|
101
|
+
const resolvedSize = computed(() => props.size || configProvider.size);
|
|
102
|
+
const lineRowClass = computed(() => resolvedSize.value === "lg" ? "h-6" : "h-5");
|
|
103
|
+
const lineCodeClass = computed(() => resolvedSize.value === "lg" ? "leading-6" : "leading-5");
|
|
63
104
|
const { scheduleHighlight } = useCodeHighlight();
|
|
105
|
+
const slots = useSlots();
|
|
106
|
+
const hasHeader = computed(() => !!(props.title || props.switcher || slots.header || slots.actions));
|
|
64
107
|
const { attrs, classes } = useTailwindVariant({
|
|
65
|
-
base: "pxd-code-block relative flex flex-col
|
|
108
|
+
base: "pxd-code-block relative flex flex-col text-gray-1000",
|
|
66
109
|
variants: { size: {
|
|
67
|
-
sm: "text-
|
|
68
|
-
md: "text-13px",
|
|
69
|
-
lg: "text-15px"
|
|
110
|
+
sm: "text-[13px]",
|
|
111
|
+
md: "text-[13px]",
|
|
112
|
+
lg: "text-[15px]"
|
|
70
113
|
} }
|
|
71
114
|
}, { selection: () => ({ size: props.size || configProvider.size }) });
|
|
115
|
+
/** FNV-1a over the code: line anchors must stay stable across reloads to be shareable. */
|
|
116
|
+
function getLineAnchorPrefix(code) {
|
|
117
|
+
let hash = 2166136261;
|
|
118
|
+
for (let index = 0; index < code.length; index++) {
|
|
119
|
+
hash ^= code.charCodeAt(index);
|
|
120
|
+
hash = Math.imul(hash, 16777619);
|
|
121
|
+
}
|
|
122
|
+
return `C${(hash >>> 0).toString(16).padStart(8, "0")}`;
|
|
123
|
+
}
|
|
72
124
|
function measureOverflow() {
|
|
73
125
|
const element = bodyEl.value;
|
|
74
126
|
if (!props.collapsible || expanded.value || !element) {
|
|
@@ -82,85 +134,229 @@ function toggleExpanded() {
|
|
|
82
134
|
function onCopy(text) {
|
|
83
135
|
emits("copy", text);
|
|
84
136
|
}
|
|
137
|
+
function getLineAnchor(line) {
|
|
138
|
+
return `${lineAnchorPrefix.value}-L${line}`;
|
|
139
|
+
}
|
|
140
|
+
function toggleLineAnchor(line) {
|
|
141
|
+
const { pathname, search } = window.location;
|
|
142
|
+
if (activeLine.value === line) {
|
|
143
|
+
activeLine.value = null;
|
|
144
|
+
history.replaceState(null, "", `${pathname}${search}`);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
activeLine.value = line;
|
|
148
|
+
history.replaceState(null, "", `#${getLineAnchor(line)}`);
|
|
149
|
+
}
|
|
150
|
+
function syncActiveLineFromHash() {
|
|
151
|
+
const hash = window.location.hash.slice(1);
|
|
152
|
+
const line = Number(hash.slice(`${lineAnchorPrefix.value}-L`.length));
|
|
153
|
+
if (hash.startsWith(`${lineAnchorPrefix.value}-L`) && line >= 1 && line <= lines.value.length) {
|
|
154
|
+
activeLine.value = line;
|
|
155
|
+
document.getElementById(hash)?.scrollIntoView({ block: "nearest" });
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
activeLine.value = null;
|
|
159
|
+
}
|
|
160
|
+
function onHashChange() {
|
|
161
|
+
syncActiveLineFromHash();
|
|
162
|
+
}
|
|
163
|
+
function onSwitcherChange(event) {
|
|
164
|
+
emits("switcher-change", event.target.value);
|
|
165
|
+
}
|
|
166
|
+
function onTabSelect(value) {
|
|
167
|
+
emits("tabs-change", value);
|
|
168
|
+
}
|
|
169
|
+
function onTabsKeydown(event) {
|
|
170
|
+
const keys = [
|
|
171
|
+
"ArrowLeft",
|
|
172
|
+
"ArrowRight",
|
|
173
|
+
"Home",
|
|
174
|
+
"End"
|
|
175
|
+
];
|
|
176
|
+
if (!keys.includes(event.key)) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
event.preventDefault();
|
|
180
|
+
const tabEls = [...event.currentTarget.querySelectorAll("[role=\"tab\"]")];
|
|
181
|
+
const currentIndex = tabEls.findIndex((element) => element === document.activeElement);
|
|
182
|
+
let nextIndex = currentIndex;
|
|
183
|
+
if (event.key === "ArrowRight") {
|
|
184
|
+
nextIndex = (currentIndex + 1) % tabEls.length;
|
|
185
|
+
} else if (event.key === "ArrowLeft") {
|
|
186
|
+
nextIndex = (currentIndex - 1 + tabEls.length) % tabEls.length;
|
|
187
|
+
} else if (event.key === "Home") {
|
|
188
|
+
nextIndex = 0;
|
|
189
|
+
} else {
|
|
190
|
+
nextIndex = tabEls.length - 1;
|
|
191
|
+
}
|
|
192
|
+
tabEls[nextIndex]?.focus();
|
|
193
|
+
tabEls[nextIndex]?.click();
|
|
194
|
+
}
|
|
85
195
|
watch(() => [
|
|
86
196
|
props.code,
|
|
87
197
|
props.language,
|
|
88
198
|
props.size,
|
|
89
199
|
props.maxHeight,
|
|
90
200
|
props.collapsible,
|
|
201
|
+
props.lineNumbers,
|
|
202
|
+
props.highlightedLines,
|
|
203
|
+
props.addedLines,
|
|
204
|
+
props.removedLines,
|
|
91
205
|
expanded.value
|
|
92
206
|
], () => {
|
|
93
207
|
scheduleHighlight();
|
|
94
208
|
measureOverflow();
|
|
95
209
|
}, { flush: "post" });
|
|
96
|
-
|
|
210
|
+
watch(() => props.code, () => {
|
|
211
|
+
activeLine.value = null;
|
|
212
|
+
});
|
|
213
|
+
onMounted(() => {
|
|
214
|
+
measureOverflow();
|
|
215
|
+
syncActiveLineFromHash();
|
|
216
|
+
window.addEventListener("hashchange", onHashChange);
|
|
217
|
+
});
|
|
218
|
+
onUnmounted(() => {
|
|
219
|
+
window.removeEventListener("hashchange", onHashChange);
|
|
220
|
+
});
|
|
97
221
|
</script>
|
|
98
222
|
|
|
99
223
|
<template>
|
|
100
|
-
<div data-code-block :class="classes" v-bind="attrs">
|
|
101
|
-
<div
|
|
102
|
-
v-if="
|
|
103
|
-
class="pxd-code-block--
|
|
104
|
-
>
|
|
105
|
-
<
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
>
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
224
|
+
<div data-code-block :class="classes" v-bind="attrs">
|
|
225
|
+
<div
|
|
226
|
+
v-if="tabs"
|
|
227
|
+
class="pxd-code-block--tabs-bar pt-4 pb-3 scrollbar-none flex items-center overflow-x-auto"
|
|
228
|
+
>
|
|
229
|
+
<div role="tablist" class="min-w-0 flex items-center" @keydown="onTabsKeydown">
|
|
230
|
+
<button
|
|
231
|
+
v-for="option in tabs.options"
|
|
232
|
+
:key="option.value"
|
|
233
|
+
type="button"
|
|
234
|
+
role="tab"
|
|
235
|
+
:tabindex="option.value === activeTabValue ? 0 : -1"
|
|
236
|
+
:aria-selected="option.value === activeTabValue"
|
|
237
|
+
class="h-8 px-3 font-medium cursor-pointer rounded-md text-[13px] text-gray-900 not-aria-selected:hover:text-gray-1000 aria-selected:bg-gray-200 aria-selected:text-gray-1000 motion-safe:transition-colors"
|
|
238
|
+
@click="onTabSelect(option.value)"
|
|
239
|
+
>
|
|
240
|
+
{{ option.label || option.value }}
|
|
241
|
+
</button>
|
|
242
|
+
</div>
|
|
243
|
+
</div>
|
|
244
|
+
|
|
245
|
+
<div
|
|
246
|
+
v-if="hasHeader"
|
|
247
|
+
class="pxd-code-block--header gap-2 ps-3 pe-0.75 h-9 flex items-center rounded-t-lg border bg-background-200"
|
|
248
|
+
>
|
|
249
|
+
<slot name="header">
|
|
250
|
+
<FileIcon class="size-4 shrink-0 text-gray-900" aria-hidden="true" />
|
|
251
|
+
<span class="min-w-0 truncate text-[13px] text-gray-900">{{ title }}</span>
|
|
252
|
+
</slot>
|
|
253
|
+
|
|
254
|
+
<div class="gap-1 min-w-0 ms-auto flex items-center">
|
|
255
|
+
<slot name="actions" />
|
|
256
|
+
|
|
257
|
+
<div v-if="switcher" class="h-7 group/select relative shrink-0">
|
|
258
|
+
<div
|
|
259
|
+
aria-hidden="true"
|
|
260
|
+
class="px-2 gap-1 flex h-full cursor-pointer items-center rounded-md bg-background-200 text-[13px] whitespace-nowrap text-gray-900 group-hover/select:bg-gray-200 has-focus-visible:self-focus-ring motion-safe:transition-colors"
|
|
261
|
+
>
|
|
262
|
+
<span class="truncate">{{ activeSwitcherLabel }}</span>
|
|
263
|
+
<ChevronDownIcon class="size-3 shrink-0" />
|
|
264
|
+
</div>
|
|
265
|
+
|
|
266
|
+
<select
|
|
267
|
+
class="inset-0 absolute cursor-pointer opacity-0 outline-none"
|
|
268
|
+
:value="activeSwitcherValue"
|
|
269
|
+
@change="onSwitcherChange"
|
|
270
|
+
>
|
|
271
|
+
<option v-for="option in switcher.options" :key="option.value" :value="option.value">
|
|
272
|
+
{{ option.label || option.value }}
|
|
273
|
+
</option>
|
|
274
|
+
</select>
|
|
275
|
+
</div>
|
|
276
|
+
|
|
277
|
+
<PCopyButton
|
|
278
|
+
v-if="copyBtn !== 'hidden'"
|
|
279
|
+
icon
|
|
280
|
+
size="xs"
|
|
281
|
+
variant="ghost"
|
|
282
|
+
:text="code"
|
|
283
|
+
@copy="onCopy"
|
|
284
|
+
/>
|
|
285
|
+
</div>
|
|
286
|
+
</div>
|
|
287
|
+
|
|
288
|
+
<div
|
|
289
|
+
class="pxd-code-block--content overflow-hidden border border-gray-alpha-300"
|
|
290
|
+
:class="hasHeader ? 'rounded-b-lg border-t-0' : 'rounded-lg'"
|
|
291
|
+
>
|
|
292
|
+
<div class="group/code-block relative">
|
|
293
|
+
<div
|
|
294
|
+
ref="bodyEl"
|
|
295
|
+
class="pxd-code-block--body overflow-x-hidden overflow-y-auto self-focus-ring"
|
|
296
|
+
tabindex="0"
|
|
297
|
+
:style="{ maxHeight: expanded ? void 0 : maxHeight }"
|
|
298
|
+
>
|
|
299
|
+
<pre
|
|
300
|
+
v-if="isLineMode"
|
|
301
|
+
class="pxd-code-block--pre py-4 notranslate overflow-x-auto font-mono"
|
|
302
|
+
translate="no"
|
|
303
|
+
><div
|
|
304
|
+
v-for="(line, index) in lines"
|
|
305
|
+
:id="getLineAnchor(index + 1)"
|
|
306
|
+
:key="index"
|
|
307
|
+
class="pxd-code-block--line relative ps-4 pe-4 flex items-center data-highlighted:bg-blue-300 data-highlighted:shadow-[inset_2px_0_0_0_var(--color-blue-900)] data-active:bg-amber-300 data-active:shadow-[inset_2px_0_0_0_var(--color-amber-900)] data-added:bg-green-300 data-added:shadow-[inset_2px_0_0_0_var(--color-green-900)] data-removed:bg-red-300 data-removed:shadow-[inset_2px_0_0_0_var(--color-red-900)]"
|
|
308
|
+
:class="lineRowClass"
|
|
309
|
+
:data-highlighted="highlightedSet.has(index + 1) || void 0"
|
|
310
|
+
:data-added="addedSet.has(index + 1) || void 0"
|
|
311
|
+
:data-removed="removedSet.has(index + 1) || void 0"
|
|
312
|
+
:data-active="activeLine === index + 1 || void 0"
|
|
313
|
+
>
|
|
314
|
+
<button
|
|
315
|
+
v-if="lineNumbers"
|
|
316
|
+
type="button"
|
|
317
|
+
tabindex="-1"
|
|
318
|
+
aria-hidden="true"
|
|
319
|
+
class="pxd-code-block--line-number w-8 pe-4 shrink-0 text-right text-gray-600 tabular-nums cursor-pointer select-none hover:text-gray-1000 motion-safe:transition-colors"
|
|
320
|
+
@click="toggleLineAnchor(index + 1)"
|
|
321
|
+
>{{ index + 1 }}</button>
|
|
322
|
+
|
|
323
|
+
<code
|
|
324
|
+
v-text="line"
|
|
325
|
+
class="pxd-code-block--line-code whitespace-pre bg-transparent! border-0! p-0! m-0!"
|
|
326
|
+
:class="[languageClass, lineCodeClass]"
|
|
327
|
+
/>
|
|
328
|
+
</div></pre>
|
|
329
|
+
|
|
330
|
+
<pre
|
|
331
|
+
v-else
|
|
332
|
+
class="pxd-code-block--pre p-3 notranslate min-w-0 flex-1 overflow-x-auto font-mono"
|
|
333
|
+
translate="no"
|
|
334
|
+
><code v-text="code" class="bg-transparent! border-0! p-0! m-0!" :class="languageClass" /></pre>
|
|
335
|
+
</div>
|
|
336
|
+
|
|
337
|
+
<div
|
|
338
|
+
v-if="isClipped"
|
|
339
|
+
class="pxd-code-block--fade inset-x-0 bottom-0 h-16 backdrop-blur-xl pointer-events-none absolute"
|
|
340
|
+
/>
|
|
341
|
+
|
|
342
|
+
<div
|
|
343
|
+
v-if="copyBtn !== 'hidden' && !hasHeader"
|
|
344
|
+
class="end-3.5 top-2 max-sm:opacity-100 absolute focus-within:opacity-100 motion-safe:transition-opacity"
|
|
345
|
+
:class="{ 'opacity-0 group-hover/code-block:opacity-100': copyBtn === 'hover' }"
|
|
346
|
+
>
|
|
347
|
+
<PCopyButton icon size="sm" variant="ghost" :text="code" @copy="onCopy" />
|
|
348
|
+
</div>
|
|
349
|
+
</div>
|
|
350
|
+
|
|
351
|
+
<div v-if="collapsible && isOverflowing" class="border-t border-gray-alpha-300">
|
|
352
|
+
<PButton variant="ghost" size="sm" full-width class="rounded-none" @click="toggleExpanded">
|
|
353
|
+
{{ configProvider.locale.codeBlock[expanded ? "collapse" : "expand"] }}
|
|
354
|
+
</PButton>
|
|
355
|
+
</div>
|
|
356
|
+
</div>
|
|
357
|
+
</div>
|
|
162
358
|
</template>
|
|
163
359
|
|
|
164
360
|
<style>
|
|
165
|
-
.pxd-code-block{--
|
|
361
|
+
.pxd-code-block{--syntax-comment:hsl(var(--color-gray-700-value));--syntax-keyword:hsl(var(--color-purple-900-value));--syntax-operator:hsl(var(--color-gray-800-value));--syntax-string:hsl(var(--color-green-900-value));--syntax-constant:hsl(var(--color-blue-900-value));--syntax-function:hsl(var(--color-teal-900-value));--syntax-type:hsl(var(--color-blue-900-value));--syntax-variable:hsl(var(--color-amber-900-value));--syntax-property:hsl(var(--color-gray-1000-value));--syntax-tag:hsl(var(--color-red-900-value));--syntax-selector:hsl(var(--color-green-900-value));--syntax-inserted:hsl(var(--color-green-900-value));--syntax-deleted:hsl(var(--color-red-900-value))}.pxd-code-block code::highlight(comment),.pxd-code-block code::highlight(quote){color:var(--syntax-comment)}.pxd-code-block code::highlight(at-rule),.pxd-code-block code::highlight(doctype),.pxd-code-block code::highlight(important),.pxd-code-block code::highlight(keyword),.pxd-code-block code::highlight(section),.pxd-code-block code::highlight(storage){color:var(--syntax-keyword)}.pxd-code-block code::highlight(operator),.pxd-code-block code::highlight(punctuation){color:var(--syntax-operator)}.pxd-code-block code::highlight(attribute-value),.pxd-code-block code::highlight(link),.pxd-code-block code::highlight(raw),.pxd-code-block code::highlight(regexp),.pxd-code-block code::highlight(string){color:var(--syntax-string)}.pxd-code-block code::highlight(anchor),.pxd-code-block code::highlight(boolean),.pxd-code-block code::highlight(character-entity),.pxd-code-block code::highlight(constant),.pxd-code-block code::highlight(entity),.pxd-code-block code::highlight(numeric),.pxd-code-block code::highlight(symbol){color:var(--syntax-constant)}.pxd-code-block code::highlight(animation),.pxd-code-block code::highlight(decorator),.pxd-code-block code::highlight(function){color:var(--syntax-function)}.pxd-code-block code::highlight(support),.pxd-code-block code::highlight(type){color:var(--syntax-type)}.pxd-code-block code::highlight(interpolation),.pxd-code-block code::highlight(variable){color:var(--syntax-variable)}.pxd-code-block code::highlight(attribute-name),.pxd-code-block code::highlight(key),.pxd-code-block code::highlight(property){color:var(--syntax-property)}.pxd-code-block code::highlight(tag){color:var(--syntax-tag)}.pxd-code-block code::highlight(selector){color:var(--syntax-selector)}.pxd-code-block code::highlight(inserted){color:var(--syntax-inserted)}.pxd-code-block code::highlight(deleted){color:var(--syntax-deleted)}.pxd-code-block--fade{-webkit-mask-image:linear-gradient(0deg,#000,transparent);mask-image:linear-gradient(0deg,#000,transparent)}.pxd-code-block--line[data-added=true]:after,.pxd-code-block--line[data-removed=true]:after{font-weight:500;inset:0;padding-left:8px;pointer-events:none;position:absolute}.pxd-code-block--line[data-added=true]:after{color:var(--color-green-900);content:"+"}.pxd-code-block--line[data-removed=true]:after{color:var(--color-red-900);content:"-"}@media (max-width:600px){.pxd-code-block--line-number{display:none}}
|
|
166
362
|
</style>
|
|
@@ -1,14 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import type { ComponentLabel } from '../../types/shared/props'
|
|
2
|
+
|
|
3
|
+
export interface CodeBlockSwitcherOption {
|
|
4
|
+
label?: string
|
|
5
|
+
value: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface CodeBlockSwitcherProps {
|
|
9
|
+
options: CodeBlockSwitcherOption[]
|
|
10
|
+
value?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface CodeBlockProps {
|
|
14
|
+
code: string
|
|
15
|
+
language?: string
|
|
16
|
+
title?: ComponentLabel
|
|
17
|
+
size?: 'sm' | 'md' | 'lg'
|
|
18
|
+
lineNumbers?: boolean
|
|
19
|
+
highlightedLines?: number[]
|
|
20
|
+
addedLines?: number[]
|
|
21
|
+
removedLines?: number[]
|
|
22
|
+
maxHeight?: number | string
|
|
23
|
+
collapsible?: boolean
|
|
24
|
+
copyBtn?: 'always' | 'hover' | 'hidden'
|
|
25
|
+
switcher?: CodeBlockSwitcherProps
|
|
26
|
+
tabs?: CodeBlockSwitcherProps
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface CodeBlockEmits {
|
|
30
|
+
copy: [string]
|
|
31
|
+
'switcher-change': [string]
|
|
32
|
+
'tabs-change': [string]
|
|
33
|
+
}
|
|
@@ -9,7 +9,9 @@ declare const __VLS_base: import("vue").DefineComponent<CollapseProps, {}, {}, {
|
|
|
9
9
|
toggle: (args_0: MouseEvent) => any;
|
|
10
10
|
}, string, import("vue").PublicProps, Readonly<CollapseProps> & Readonly<{
|
|
11
11
|
onToggle?: ((args_0: MouseEvent) => any) | undefined;
|
|
12
|
-
}>, {
|
|
12
|
+
}>, {
|
|
13
|
+
expand: boolean;
|
|
14
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
13
15
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
14
16
|
declare const _default: typeof __VLS_export;
|
|
15
17
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import ChevronRightIcon from "@gdsicon/vue/chevron-right";
|
|
3
|
+
import { onBeforeUnmount, shallowRef, watch } from "vue";
|
|
4
|
+
import { useDetailsCollapse } from "../../composables/_internal/use-details-collapse.js";
|
|
5
5
|
import { useCollapseGroupContext } from "../../contexts/collapse.js";
|
|
6
6
|
import { getUniqueId } from "../../utils/helper.js";
|
|
7
7
|
defineOptions({
|
|
@@ -10,49 +10,45 @@ defineOptions({
|
|
|
10
10
|
});
|
|
11
11
|
const props = defineProps({
|
|
12
12
|
title: {
|
|
13
|
-
type:
|
|
13
|
+
type: null,
|
|
14
14
|
required: false
|
|
15
15
|
},
|
|
16
16
|
expand: {
|
|
17
17
|
type: Boolean,
|
|
18
|
-
required: false
|
|
18
|
+
required: false,
|
|
19
|
+
default: false
|
|
19
20
|
}
|
|
20
21
|
});
|
|
21
22
|
const emits = defineEmits(["toggle"]);
|
|
22
23
|
const uid = getUniqueId();
|
|
23
|
-
const internalExpand = shallowRef(props.expand);
|
|
24
24
|
const contentRef = shallowRef();
|
|
25
25
|
const collapseGroup = useCollapseGroupContext();
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
function setExpanded(expanded, exclusive = false) {
|
|
29
|
-
if (collapseGroup) {
|
|
30
|
-
const ids = collapseGroup.expandedIds.value;
|
|
31
|
-
if (exclusive && !collapseGroup.props.multiple) {
|
|
32
|
-
ids.clear();
|
|
33
|
-
}
|
|
34
|
-
if (expanded) {
|
|
35
|
-
ids.add(uid);
|
|
36
|
-
} else {
|
|
37
|
-
ids.delete(uid);
|
|
38
|
-
}
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
internalExpand.value = expanded;
|
|
42
|
-
}
|
|
43
|
-
function onToggleClick(ev) {
|
|
26
|
+
const { isOpen, detailsOpen, onToggleClick, onDetailsToggle } = useDetailsCollapse(contentRef, () => props.expand);
|
|
27
|
+
function onTriggerClick(ev) {
|
|
44
28
|
emits("toggle", ev);
|
|
45
|
-
|
|
29
|
+
onToggleClick();
|
|
46
30
|
}
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
skipEnterMotion();
|
|
52
|
-
setExpanded(true, true);
|
|
31
|
+
watch(() => isOpen.value, (open) => {
|
|
32
|
+
const group = collapseGroup;
|
|
33
|
+
if (!group || group.props.multiple) {
|
|
34
|
+
return;
|
|
53
35
|
}
|
|
54
|
-
|
|
55
|
-
|
|
36
|
+
if (open) {
|
|
37
|
+
group.openUid.value = uid;
|
|
38
|
+
} else if (group.openUid.value === uid) {
|
|
39
|
+
group.openUid.value = "";
|
|
40
|
+
}
|
|
41
|
+
}, { immediate: true });
|
|
42
|
+
watch(() => collapseGroup?.openUid.value, (openUid) => {
|
|
43
|
+
if (openUid && openUid !== uid) {
|
|
44
|
+
isOpen.value = false;
|
|
45
|
+
}
|
|
46
|
+
}, { immediate: true });
|
|
47
|
+
onBeforeUnmount(() => {
|
|
48
|
+
if (collapseGroup?.openUid.value === uid) {
|
|
49
|
+
collapseGroup.openUid.value = "";
|
|
50
|
+
}
|
|
51
|
+
});
|
|
56
52
|
</script>
|
|
57
53
|
|
|
58
54
|
<template>
|
|
@@ -65,7 +61,7 @@ watch(() => props.expand, (expand) => setExpanded(!!expand), { immediate: true }
|
|
|
65
61
|
>
|
|
66
62
|
<summary
|
|
67
63
|
class="pxd-collapse--trigger pe-1 group/collapse flex w-full cursor-pointer touch-manipulation list-none appearance-none items-center justify-between border-none bg-transparent font-inherit self-focus-ring outline-none"
|
|
68
|
-
@click.prevent="
|
|
64
|
+
@click.prevent="onTriggerClick"
|
|
69
65
|
>
|
|
70
66
|
<h3 class="pxd-collapse--title m-0 min-w-0 flex-1 font-inherit text-inherit">
|
|
71
67
|
<slot name="title">
|
|
@@ -73,20 +69,20 @@ watch(() => props.expand, (expand) => setExpanded(!!expand), { immediate: true }
|
|
|
73
69
|
</slot>
|
|
74
70
|
</h3>
|
|
75
71
|
|
|
76
|
-
<
|
|
72
|
+
<ChevronRightIcon
|
|
77
73
|
class="size-4 shrink-0 motion-safe:transition-transform"
|
|
78
|
-
:class="{ '
|
|
74
|
+
:class="{ 'rotate-90': isOpen }"
|
|
79
75
|
/>
|
|
80
76
|
</summary>
|
|
81
77
|
|
|
82
78
|
<div
|
|
83
79
|
ref="contentRef"
|
|
84
|
-
class="
|
|
85
|
-
:class="
|
|
86
|
-
'motion-safe:transition-[height]': isExpanded || isLeaving
|
|
87
|
-
}"
|
|
80
|
+
class="grid-template-cols-1fr grid overflow-hidden motion-safe:transition-[grid-template-rows]"
|
|
81
|
+
:class="isOpen ? 'grid-template-rows-1fr' : 'grid-template-rows-0fr'"
|
|
88
82
|
>
|
|
89
|
-
<
|
|
83
|
+
<div class="pxd-collapse--content">
|
|
84
|
+
<slot />
|
|
85
|
+
</div>
|
|
90
86
|
</div>
|
|
91
87
|
</details>
|
|
92
88
|
</template>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { computed,
|
|
2
|
+
import { computed, shallowRef } from "vue";
|
|
3
3
|
import { provideCollapseGroupContext } from "../../contexts/collapse.js";
|
|
4
4
|
import { useConfigProvider } from "../../contexts/config-provider.js";
|
|
5
5
|
import { getFallbackValue } from "../../utils/helper.js";
|
|
@@ -34,7 +34,7 @@ const SIZES = {
|
|
|
34
34
|
fontWeight: "600"
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
const
|
|
37
|
+
const openUid = shallowRef("");
|
|
38
38
|
const configProvider = useConfigProvider();
|
|
39
39
|
const computedStyle = computed(() => {
|
|
40
40
|
const { padding, fontSize, fontWeight } = getFallbackValue(props.size, SIZES, configProvider.size);
|
|
@@ -45,7 +45,7 @@ const computedStyle = computed(() => {
|
|
|
45
45
|
};
|
|
46
46
|
});
|
|
47
47
|
provideCollapseGroupContext({
|
|
48
|
-
|
|
48
|
+
openUid,
|
|
49
49
|
props
|
|
50
50
|
});
|
|
51
51
|
</script>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ColorSelectorProps } from './types';
|
|
2
2
|
declare const __VLS_export: import("vue").DefineComponent<ColorSelectorProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
3
3
|
change: (args_0: string) => any;
|
|
4
|
-
"update:
|
|
4
|
+
"update:model-value": (args_0: string) => any;
|
|
5
5
|
}, string, import("vue").PublicProps, Readonly<ColorSelectorProps> & Readonly<{
|
|
6
6
|
onChange?: ((args_0: string) => any) | undefined;
|
|
7
|
-
"onUpdate:
|
|
7
|
+
"onUpdate:model-value"?: ((args_0: string) => any) | undefined;
|
|
8
8
|
}>, {
|
|
9
9
|
colors: string[];
|
|
10
10
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -8,7 +8,7 @@ defineOptions({
|
|
|
8
8
|
inheritAttrs: false,
|
|
9
9
|
model: {
|
|
10
10
|
prop: "modelValue",
|
|
11
|
-
event: "update:
|
|
11
|
+
event: "update:model-value"
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
const props = defineProps({
|
|
@@ -32,7 +32,7 @@ const props = defineProps({
|
|
|
32
32
|
required: false
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
|
-
const emits = defineEmits(["change", "update:
|
|
35
|
+
const emits = defineEmits(["change", "update:model-value"]);
|
|
36
36
|
const uniqueName = getUniqueId("color-selector");
|
|
37
37
|
const configProvider = useConfigProvider();
|
|
38
38
|
const modelValue = useModelValue(props, emits);
|