pxd 0.1.3 → 0.1.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/dist/components/_internal/dismiss-container.vue +1 -1
- package/dist/components/_internal/mention-editor.d.vue.ts +1 -1
- package/dist/components/_internal/mention-editor.vue +2 -2
- package/dist/components/_internal/step-item.vue +1 -1
- package/dist/components/_internal/tree-node.d.vue.ts +3 -0
- package/dist/components/_internal/tree-node.vue +16 -7
- package/dist/components/active-graph/index.vue +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.vue +1 -1
- package/dist/components/badge/index.vue +3 -3
- package/dist/components/browser/index.vue +1 -1
- package/dist/components/bubble/index.vue +5 -5
- package/dist/components/button/index.d.vue.ts +1 -1
- package/dist/components/button/index.vue +6 -5
- package/dist/components/button/types.d.ts +1 -1
- package/dist/components/button-group/types.d.ts +1 -1
- package/dist/components/calendar/index.vue +5 -5
- package/dist/components/card/index.vue +2 -2
- package/dist/components/carousel/index.d.vue.ts +0 -1
- package/dist/components/carousel/index.vue +22 -17
- package/dist/components/carousel/types.d.ts +0 -1
- package/dist/components/checkbox/index.vue +1 -1
- package/dist/components/choicebox-item/index.vue +2 -2
- package/dist/components/code-block/index.d.vue.ts +22 -0
- package/dist/components/code-block/index.vue +166 -0
- package/dist/components/code-block/types.d.ts +14 -0
- package/dist/components/command-menu/index.d.vue.ts +1 -1
- package/dist/components/command-menu/index.vue +1 -2
- package/dist/components/config-provider/index.d.vue.ts +4 -0
- package/dist/components/confirm-popover/index.d.vue.ts +7 -8
- package/dist/components/confirm-popover/index.vue +36 -10
- package/dist/components/confirm-popover/types.d.ts +2 -0
- package/dist/components/copy-button/index.vue +1 -5
- package/dist/components/date-picker/index.vue +1 -1
- package/dist/components/description/index.vue +1 -1
- package/dist/components/drawer/index.d.vue.ts +3 -3
- package/dist/components/drawer/index.vue +9 -15
- package/dist/components/ellipsis-text/index.vue +1 -1
- package/dist/components/error/index.vue +2 -2
- package/dist/components/image-preview/index.d.vue.ts +38 -0
- package/dist/components/image-preview/index.vue +351 -0
- package/dist/components/image-preview/types.d.ts +18 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/input/index.vue +5 -4
- package/dist/components/kbd/index.vue +1 -1
- package/dist/components/list-group/index.vue +7 -1
- package/dist/components/list-item/index.vue +21 -8
- package/dist/components/marquee/index.vue +6 -2
- package/dist/components/mention/index.d.vue.ts +1 -1
- package/dist/components/message/index.vue +1 -1
- package/dist/components/modal/index.d.vue.ts +2 -2
- package/dist/components/modal/index.vue +9 -15
- package/dist/components/note/index.vue +1 -1
- package/dist/components/number-input/index.vue +6 -6
- package/dist/components/overlay/index.d.vue.ts +0 -1
- package/dist/components/overlay/index.vue +2 -8
- package/dist/components/overlay/types.d.ts +1 -2
- package/dist/components/pagination/index.vue +4 -4
- package/dist/components/pin-input/index.d.vue.ts +1 -1
- package/dist/components/pin-input/index.vue +5 -1
- package/dist/components/popover/index.vue +26 -21
- package/dist/components/popover/types.d.ts +1 -0
- package/dist/components/project-banner/index.vue +22 -9
- package/dist/components/questionnaire/index.vue +1 -1
- package/dist/components/resizable/index.d.vue.ts +5 -0
- package/dist/components/resizable/index.vue +256 -107
- package/dist/components/resizable/types.d.ts +6 -0
- package/dist/components/select/index.vue +4 -2
- package/dist/components/skeleton/index.d.vue.ts +1 -1
- package/dist/components/swipe-cell/index.vue +1 -1
- package/dist/components/switch/index.vue +1 -1
- package/dist/components/tabs/index.vue +1 -1
- package/dist/components/teleport/index.vue +20 -22
- package/dist/components/textarea/index.vue +1 -0
- package/dist/components/time-picker/index.vue +4 -4
- package/dist/components/toc/index.vue +1 -1
- package/dist/components/todo-list/index.d.vue.ts +1 -1
- package/dist/components/toggle/index.vue +2 -2
- package/dist/components/toggle-button/index.vue +11 -5
- package/dist/components/toggle-button/types.d.ts +3 -2
- package/dist/components/toggle-button-group/index.vue +1 -0
- package/dist/components/toggle-button-group/types.d.ts +2 -2
- package/dist/components/tour/index.vue +3 -3
- package/dist/components/tree/index.d.vue.ts +18 -15
- package/dist/components/tree/index.vue +102 -77
- package/dist/components/tree/types.d.ts +4 -0
- package/dist/composables/_internal/use-code-highlight.d.ts +12 -0
- package/dist/composables/_internal/use-code-highlight.js +47 -0
- package/dist/composables/_internal/use-lock-scroll.js +5 -22
- package/dist/composables/_internal/use-overlay-manager.d.ts +0 -1
- package/dist/composables/_internal/use-overlay-manager.js +2 -18
- package/dist/composables/_internal/use-popover-responsive.js +9 -12
- package/dist/composables/_internal/use-swipe-gesture.d.ts +1 -1
- package/dist/composables/_internal/use-swipe-gesture.js +5 -4
- package/dist/composables/_internal/use-tailwind-variant.js +1 -1
- package/dist/composables/use-media-query.d.ts +3 -1
- package/dist/composables/use-media-query.js +33 -51
- package/dist/composables/use-outside-click.d.ts +2 -1
- package/dist/composables/use-outside-click.js +3 -7
- package/dist/composables/use-repeat-action.d.ts +1 -1
- package/dist/composables/use-repeat-action.js +3 -3
- package/dist/constants/size.d.ts +1 -0
- package/dist/constants/size.js +7 -6
- package/dist/constants/tooltip-variants.d.ts +1 -1
- package/dist/constants/tooltip-variants.js +1 -1
- package/dist/locales/en-us.d.ts +4 -0
- package/dist/locales/en-us.js +4 -0
- package/dist/locales/zh-cn.d.ts +4 -0
- package/dist/locales/zh-cn.js +4 -0
- package/dist/styles/styles.css +1 -1
- package/dist/styles/tw.css +12 -7
- package/dist/utils/_internal/cn-tables.d.ts +27 -0
- package/dist/utils/_internal/cn-tables.js +131 -0
- package/dist/utils/cn.d.ts +1 -0
- package/dist/utils/cn.js +3 -0
- package/package.json +6 -4
- package/volar.d.ts +2 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, onMounted, shallowRef, watch } from "vue";
|
|
3
|
+
import { MAX_HIGHLIGHT_LENGTH, useCodeHighlight } from "../../composables/_internal/use-code-highlight.js";
|
|
4
|
+
import { useTailwindVariant } from "../../composables/_internal/use-tailwind-variant.js";
|
|
5
|
+
import { useConfigProvider } from "../../contexts/config-provider.js";
|
|
6
|
+
import { getCssUnitValue } from "../../utils/format.js";
|
|
7
|
+
import PButton from "../button/index.vue";
|
|
8
|
+
import PCopyButton from "../copy-button/index.vue";
|
|
9
|
+
defineOptions({
|
|
10
|
+
name: "PCodeBlock",
|
|
11
|
+
inheritAttrs: false
|
|
12
|
+
});
|
|
13
|
+
const props = defineProps({
|
|
14
|
+
code: {
|
|
15
|
+
type: String,
|
|
16
|
+
required: true
|
|
17
|
+
},
|
|
18
|
+
language: {
|
|
19
|
+
type: String,
|
|
20
|
+
required: false
|
|
21
|
+
},
|
|
22
|
+
title: {
|
|
23
|
+
type: String,
|
|
24
|
+
required: false
|
|
25
|
+
},
|
|
26
|
+
size: {
|
|
27
|
+
type: String,
|
|
28
|
+
required: false
|
|
29
|
+
},
|
|
30
|
+
lineNumbers: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
required: false
|
|
33
|
+
},
|
|
34
|
+
maxHeight: {
|
|
35
|
+
type: [Number, String],
|
|
36
|
+
required: false
|
|
37
|
+
},
|
|
38
|
+
collapsible: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
required: false
|
|
41
|
+
},
|
|
42
|
+
copyBtn: {
|
|
43
|
+
type: String,
|
|
44
|
+
required: false,
|
|
45
|
+
default: "hover"
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const emits = defineEmits(["copy"]);
|
|
49
|
+
const DEFAULT_MAX_HEIGHT = "20rem";
|
|
50
|
+
const bodyEl = shallowRef(null);
|
|
51
|
+
const expanded = shallowRef(false);
|
|
52
|
+
const isOverflowing = shallowRef(false);
|
|
53
|
+
const lineCount = computed(() => props.code.split("\n").length);
|
|
54
|
+
const isOversized = computed(() => props.code.length > MAX_HIGHLIGHT_LENGTH);
|
|
55
|
+
const maxHeight = computed(() => getCssUnitValue(props.maxHeight, DEFAULT_MAX_HEIGHT));
|
|
56
|
+
const isClipped = computed(() => props.collapsible && !expanded.value);
|
|
57
|
+
const languageClass = computed(() => {
|
|
58
|
+
const language = props.language?.trim().toLowerCase();
|
|
59
|
+
// Oversized blocks drop the language class so the scanner skips them instead of tokenizing.
|
|
60
|
+
return language && !isOversized.value ? `language-${language}` : undefined;
|
|
61
|
+
});
|
|
62
|
+
const configProvider = useConfigProvider();
|
|
63
|
+
const { scheduleHighlight } = useCodeHighlight();
|
|
64
|
+
const { attrs, classes } = useTailwindVariant({
|
|
65
|
+
base: "pxd-code-block relative flex flex-col overflow-hidden rounded-lg border border-gray-alpha-300 bg-(--code-block-bg) text-gray-1000",
|
|
66
|
+
variants: { size: {
|
|
67
|
+
sm: "text-11px",
|
|
68
|
+
md: "text-13px",
|
|
69
|
+
lg: "text-15px"
|
|
70
|
+
} }
|
|
71
|
+
}, { selection: () => ({ size: props.size || configProvider.size }) });
|
|
72
|
+
function measureOverflow() {
|
|
73
|
+
const element = bodyEl.value;
|
|
74
|
+
if (!props.collapsible || expanded.value || !element) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
isOverflowing.value = element.scrollHeight > element.clientHeight + 1;
|
|
78
|
+
}
|
|
79
|
+
function toggleExpanded() {
|
|
80
|
+
expanded.value = !expanded.value;
|
|
81
|
+
}
|
|
82
|
+
function onCopy(text) {
|
|
83
|
+
emits("copy", text);
|
|
84
|
+
}
|
|
85
|
+
watch(() => [
|
|
86
|
+
props.code,
|
|
87
|
+
props.language,
|
|
88
|
+
props.size,
|
|
89
|
+
props.maxHeight,
|
|
90
|
+
props.collapsible,
|
|
91
|
+
expanded.value
|
|
92
|
+
], () => {
|
|
93
|
+
scheduleHighlight();
|
|
94
|
+
measureOverflow();
|
|
95
|
+
}, { flush: "post" });
|
|
96
|
+
onMounted(measureOverflow);
|
|
97
|
+
</script>
|
|
98
|
+
|
|
99
|
+
<template>
|
|
100
|
+
<div data-code-block :class="classes" v-bind="attrs">
|
|
101
|
+
<div
|
|
102
|
+
v-if="title || $slots.header || $slots.actions"
|
|
103
|
+
class="pxd-code-block--header gap-3 px-3 py-2 text-sm flex items-center border-b border-gray-alpha-300"
|
|
104
|
+
>
|
|
105
|
+
<slot name="header">{{ title }}</slot>
|
|
106
|
+
|
|
107
|
+
<div class="gap-1 ms-auto flex items-center">
|
|
108
|
+
<slot name="actions" />
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
|
|
112
|
+
<div class="group/code-block relative">
|
|
113
|
+
<div
|
|
114
|
+
ref="bodyEl"
|
|
115
|
+
class="pxd-code-block--body overflow-x-hidden overflow-y-auto self-focus-ring"
|
|
116
|
+
tabindex="0"
|
|
117
|
+
:style="{ maxHeight: expanded ? void 0 : maxHeight }"
|
|
118
|
+
>
|
|
119
|
+
<div class="flex font-mono">
|
|
120
|
+
<div
|
|
121
|
+
v-if="lineNumbers"
|
|
122
|
+
aria-hidden="true"
|
|
123
|
+
class="pxd-code-block--gutter p-3 shrink-0 border-e border-gray-alpha-300 text-right text-gray-700 tabular-nums select-none"
|
|
124
|
+
>
|
|
125
|
+
<span v-for="line of lineCount" :key="line" class="block">{{ line }}</span>
|
|
126
|
+
</div>
|
|
127
|
+
|
|
128
|
+
<pre
|
|
129
|
+
class="pxd-code-block--pre p-3 notranslate min-w-0 flex-1 overflow-x-auto"
|
|
130
|
+
translate="no"
|
|
131
|
+
><code v-text="code" :class="languageClass" /></pre>
|
|
132
|
+
</div>
|
|
133
|
+
</div>
|
|
134
|
+
|
|
135
|
+
<div
|
|
136
|
+
v-if="isClipped"
|
|
137
|
+
class="inset-x-0 bottom-0 h-16 pointer-events-none absolute bg-linear-to-t from-(--code-block-bg) to-transparent"
|
|
138
|
+
/>
|
|
139
|
+
|
|
140
|
+
<div
|
|
141
|
+
v-if="copyBtn !== 'hidden'"
|
|
142
|
+
class="end-3 top-3 max-sm:opacity-100 absolute focus-within:opacity-100 motion-safe:transition-opacity"
|
|
143
|
+
:class="{ 'opacity-0 group-hover/code-block:opacity-100': copyBtn === 'hover' }"
|
|
144
|
+
>
|
|
145
|
+
<PCopyButton
|
|
146
|
+
icon
|
|
147
|
+
size="sm"
|
|
148
|
+
variant="ghost"
|
|
149
|
+
class="bg-(--code-block-bg)"
|
|
150
|
+
:text="code"
|
|
151
|
+
@copy="onCopy"
|
|
152
|
+
/>
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
<div v-if="collapsible && isOverflowing" class="border-t border-gray-alpha-300">
|
|
157
|
+
<PButton variant="ghost" size="sm" full-width class="rounded-none" @click="toggleExpanded">
|
|
158
|
+
{{ configProvider.locale.codeBlock[expanded ? "collapse" : "expand"] }}
|
|
159
|
+
</PButton>
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
</template>
|
|
163
|
+
|
|
164
|
+
<style>
|
|
165
|
+
.pxd-code-block{--code-block-bg:var(--color-background-100);--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)}
|
|
166
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface CodeBlockProps {
|
|
2
|
+
code: string
|
|
3
|
+
language?: string
|
|
4
|
+
title?: string
|
|
5
|
+
size?: 'sm' | 'md' | 'lg'
|
|
6
|
+
lineNumbers?: boolean
|
|
7
|
+
maxHeight?: number | string
|
|
8
|
+
collapsible?: boolean
|
|
9
|
+
copyBtn?: 'always' | 'hover' | 'hidden'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface CodeBlockEmits {
|
|
13
|
+
copy: [string]
|
|
14
|
+
}
|
|
@@ -21,10 +21,10 @@ declare const __VLS_base: import("vue").DefineComponent<CommandMenuProps, {}, {}
|
|
|
21
21
|
onShow?: (() => any) | undefined;
|
|
22
22
|
onHide?: (() => any) | undefined;
|
|
23
23
|
}>, {
|
|
24
|
+
placeholder: string;
|
|
24
25
|
width: string | number;
|
|
25
26
|
modelValue: boolean;
|
|
26
27
|
closeOnPressEscape: boolean;
|
|
27
|
-
placeholder: string;
|
|
28
28
|
closeOnClickOverlay: boolean;
|
|
29
29
|
closeOnSelectItem: boolean;
|
|
30
30
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -130,7 +130,7 @@ watch(filteredOptions, async () => {
|
|
|
130
130
|
<template #header>
|
|
131
131
|
<label
|
|
132
132
|
:for="uniqueId"
|
|
133
|
-
class="
|
|
133
|
+
class="px-4 py-3 -mx-5 -mbs-5 gap-2 flex items-center border-b bg-background-100"
|
|
134
134
|
>
|
|
135
135
|
<input
|
|
136
136
|
:id="uniqueId"
|
|
@@ -163,7 +163,6 @@ watch(filteredOptions, async () => {
|
|
|
163
163
|
|
|
164
164
|
<PList
|
|
165
165
|
ref="listRef"
|
|
166
|
-
:loop="false"
|
|
167
166
|
:virtual="virtual"
|
|
168
167
|
:options="filteredOptions"
|
|
169
168
|
:default-active-index="0"
|
|
@@ -116,6 +116,10 @@ declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, i
|
|
|
116
116
|
thumbDown: string;
|
|
117
117
|
close: string;
|
|
118
118
|
};
|
|
119
|
+
codeBlock: {
|
|
120
|
+
expand: string;
|
|
121
|
+
collapse: string;
|
|
122
|
+
};
|
|
119
123
|
}>;
|
|
120
124
|
size: import("../../types/shared/props").ComponentSize;
|
|
121
125
|
enterMotion: boolean;
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import type { ConfirmPopoverProps } from './types';
|
|
2
2
|
declare function onConfirm(): Promise<void>;
|
|
3
3
|
declare function onCancel(): void;
|
|
4
|
-
declare var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}, __VLS_14: {
|
|
4
|
+
declare var __VLS_10: {}, __VLS_13: {
|
|
5
|
+
activeTrigger: HTMLElement | null;
|
|
6
|
+
activeTriggerIndex: number;
|
|
7
|
+
}, __VLS_15: {
|
|
9
8
|
confirm: typeof onConfirm;
|
|
10
9
|
cancel: typeof onCancel;
|
|
11
10
|
pending: boolean;
|
|
12
11
|
};
|
|
13
12
|
type __VLS_Slots = {} & {
|
|
14
|
-
default?: (props: typeof
|
|
13
|
+
default?: (props: typeof __VLS_10) => any;
|
|
15
14
|
} & {
|
|
16
|
-
content?: (props: typeof
|
|
15
|
+
content?: (props: typeof __VLS_13) => any;
|
|
17
16
|
} & {
|
|
18
|
-
actions?: (props: typeof
|
|
17
|
+
actions?: (props: typeof __VLS_15) => any;
|
|
19
18
|
};
|
|
20
19
|
declare const __VLS_base: import("vue").DefineComponent<ConfirmPopoverProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
21
20
|
"update:modelValue": (visible: boolean) => any;
|
|
@@ -48,6 +48,14 @@ const props = defineProps({
|
|
|
48
48
|
type: Boolean,
|
|
49
49
|
required: false
|
|
50
50
|
},
|
|
51
|
+
triggerSelector: {
|
|
52
|
+
type: String,
|
|
53
|
+
required: false
|
|
54
|
+
},
|
|
55
|
+
stopPropagation: {
|
|
56
|
+
type: Boolean,
|
|
57
|
+
required: false
|
|
58
|
+
},
|
|
51
59
|
beforeConfirm: {
|
|
52
60
|
type: Function,
|
|
53
61
|
required: false
|
|
@@ -62,6 +70,8 @@ const titleId = getUniqueId("confirm-popover-title");
|
|
|
62
70
|
// Bumped on every open and close, so a confirm that settles after the popover
|
|
63
71
|
// was dismissed cannot confirm an action the user already abandoned.
|
|
64
72
|
let sessionId = 0;
|
|
73
|
+
// Switching to another matched trigger abandons the row the confirm was started for.
|
|
74
|
+
let activeTriggerElement = null;
|
|
65
75
|
const isPending = shallowRef(false);
|
|
66
76
|
const localVisible = shallowRef(props.modelValue ?? false);
|
|
67
77
|
const configProvider = useConfigProvider();
|
|
@@ -78,6 +88,9 @@ function applyVisible(value) {
|
|
|
78
88
|
}
|
|
79
89
|
sessionId++;
|
|
80
90
|
localVisible.value = value;
|
|
91
|
+
if (!value) {
|
|
92
|
+
isPending.value = false;
|
|
93
|
+
}
|
|
81
94
|
}
|
|
82
95
|
// The popover owns the trigger, so its own state is authoritative: mirror it
|
|
83
96
|
// locally and forward it, otherwise a controlled parent that never writes back
|
|
@@ -90,6 +103,17 @@ function close() {
|
|
|
90
103
|
applyVisible(false);
|
|
91
104
|
emits("update:modelValue", false);
|
|
92
105
|
}
|
|
106
|
+
function onTriggerClick(ev) {
|
|
107
|
+
if (!props.triggerSelector || !(ev.target instanceof Element)) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const trigger = ev.target.closest(props.triggerSelector);
|
|
111
|
+
if (!trigger || trigger === activeTriggerElement) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
activeTriggerElement = trigger;
|
|
115
|
+
sessionId++;
|
|
116
|
+
}
|
|
93
117
|
async function onConfirm() {
|
|
94
118
|
if (isPending.value) {
|
|
95
119
|
return;
|
|
@@ -121,17 +145,13 @@ watch(() => props.modelValue, (value) => {
|
|
|
121
145
|
applyVisible(value);
|
|
122
146
|
}
|
|
123
147
|
});
|
|
124
|
-
watch(() => localVisible.value, (value) => {
|
|
125
|
-
if (!value) {
|
|
126
|
-
isPending.value = false;
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
148
|
</script>
|
|
130
149
|
|
|
131
150
|
<template>
|
|
132
151
|
<PPopover
|
|
133
152
|
data-confirm-popover
|
|
134
153
|
class="pxd-confirm-popover"
|
|
154
|
+
v-bind="$attrs"
|
|
135
155
|
trigger="click"
|
|
136
156
|
:model-value="localVisible"
|
|
137
157
|
:position="position"
|
|
@@ -139,23 +159,29 @@ watch(() => localVisible.value, (value) => {
|
|
|
139
159
|
:adaptive="isAdaptive"
|
|
140
160
|
:fill-trigger-width="false"
|
|
141
161
|
:auto-focus-element="true"
|
|
162
|
+
:trigger-selector="triggerSelector"
|
|
163
|
+
:stop-propagation="stopPropagation"
|
|
142
164
|
:wrapper-class="responsiveClasses.wrapper"
|
|
143
165
|
:content-class="responsiveClasses.content"
|
|
144
166
|
:close-on-press-escape="!isPending"
|
|
145
167
|
:lock-scroll-on-visible="isAdaptive"
|
|
146
|
-
v-bind="$attrs"
|
|
147
168
|
@update:model-value="onVisibleChange"
|
|
169
|
+
@trigger-click="onTriggerClick"
|
|
148
170
|
>
|
|
149
171
|
<slot />
|
|
150
172
|
|
|
151
|
-
<template #content>
|
|
152
|
-
<div class="p-3">
|
|
153
|
-
<slot
|
|
173
|
+
<template #content="{ activeTrigger, activeTriggerIndex }">
|
|
174
|
+
<div class="p-3 max-w-64">
|
|
175
|
+
<slot
|
|
176
|
+
name="content"
|
|
177
|
+
:active-trigger="activeTrigger"
|
|
178
|
+
:active-trigger-index="activeTriggerIndex"
|
|
179
|
+
>
|
|
154
180
|
<h3 v-if="title" :id="titleId" class="m-0 text-sm font-medium">
|
|
155
181
|
{{ title }}
|
|
156
182
|
</h3>
|
|
157
183
|
|
|
158
|
-
<p v-if="description" class="m-0 text-
|
|
184
|
+
<p v-if="description" class="m-0 text-13px text-foreground-secondary">
|
|
159
185
|
{{ description }}
|
|
160
186
|
</p>
|
|
161
187
|
</slot>
|
|
@@ -25,11 +25,7 @@ async function onCopyClick(ev) {
|
|
|
25
25
|
<slot v-if="$slots.default" :copied="isCopied" />
|
|
26
26
|
|
|
27
27
|
<template #suffix>
|
|
28
|
-
<Transition
|
|
29
|
-
name="pxd-transition--fade-scale"
|
|
30
|
-
mode="out-in"
|
|
31
|
-
class="pxd-copy-button--icon pointer-events-none"
|
|
32
|
-
>
|
|
28
|
+
<Transition name="pxd-transition--fade-scale" mode="out-in" class="pxd-copy-button--icon">
|
|
33
29
|
<CheckIcon v-if="isCopied" />
|
|
34
30
|
<CopyIcon v-else />
|
|
35
31
|
</Transition>
|
|
@@ -283,8 +283,8 @@ watch(() => props.modelValue, updateDayjsDateTime, { immediate: true });
|
|
|
283
283
|
|
|
284
284
|
<template #content>
|
|
285
285
|
<PCalendar
|
|
286
|
-
class="sm:p-2 p-4"
|
|
287
286
|
compact
|
|
287
|
+
class="p-3"
|
|
288
288
|
:value-format="valueFormat"
|
|
289
289
|
:model-value="calendarModelValue"
|
|
290
290
|
:is-date-disabled="isDateDisabled"
|
|
@@ -24,7 +24,7 @@ defineProps({
|
|
|
24
24
|
<template>
|
|
25
25
|
<dl data-description class="pxd-description" v-bind="$attrs">
|
|
26
26
|
<dt
|
|
27
|
-
class="pxd-description--title gap-1 text-sm mbe-
|
|
27
|
+
class="pxd-description--title gap-1 text-sm mbe-1.5 flex items-center leading-none text-nowrap text-foreground-secondary capitalize"
|
|
28
28
|
>
|
|
29
29
|
<slot name="title">
|
|
30
30
|
{{ title }}
|
|
@@ -14,26 +14,26 @@ type __VLS_Slots = {} & {
|
|
|
14
14
|
declare const __VLS_base: import("vue").DefineComponent<DrawerProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
15
15
|
change: (args_0: boolean) => any;
|
|
16
16
|
"update:modelValue": (visible: boolean) => any;
|
|
17
|
-
"outside-click": (args_0: PointerEvent) => any;
|
|
18
17
|
show: () => any;
|
|
19
18
|
hide: () => any;
|
|
19
|
+
"outside-click": (args_0: PointerEvent) => any;
|
|
20
20
|
"visible-change": (visible: boolean) => any;
|
|
21
21
|
}, string, import("vue").PublicProps, Readonly<DrawerProps> & Readonly<{
|
|
22
22
|
onChange?: ((args_0: boolean) => any) | undefined;
|
|
23
23
|
"onUpdate:modelValue"?: ((visible: boolean) => any) | undefined;
|
|
24
|
-
"onOutside-click"?: ((args_0: PointerEvent) => any) | undefined;
|
|
25
24
|
onShow?: (() => any) | undefined;
|
|
26
25
|
onHide?: (() => any) | undefined;
|
|
26
|
+
"onOutside-click"?: ((args_0: PointerEvent) => any) | undefined;
|
|
27
27
|
"onVisible-change"?: ((visible: boolean) => any) | undefined;
|
|
28
28
|
}>, {
|
|
29
29
|
closeable: boolean;
|
|
30
30
|
modelValue: boolean;
|
|
31
31
|
closeOnPressEscape: boolean;
|
|
32
32
|
autoFocusElement: string | boolean;
|
|
33
|
+
position: import("../../types/shared/props.js").BasePosition;
|
|
33
34
|
closeOnClickOverlay: boolean;
|
|
34
35
|
defaultHeaderStyle: boolean;
|
|
35
36
|
defaultFooterStyle: boolean;
|
|
36
|
-
position: import("../../types/shared/props.js").BasePosition;
|
|
37
37
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
38
38
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
39
39
|
declare const _default: typeof __VLS_export;
|
|
@@ -120,8 +120,8 @@ const ensurePosition = computed(() => {
|
|
|
120
120
|
return "right";
|
|
121
121
|
});
|
|
122
122
|
const defaultStyles = computed(() => ({
|
|
123
|
-
headerClass: props.defaultHeaderStyle ? "pbe-
|
|
124
|
-
footerClass: props.defaultFooterStyle ? "border-t
|
|
123
|
+
headerClass: props.defaultHeaderStyle ? "pbe-5 border-b bg-background-200 dark:bg-background-100" : "",
|
|
124
|
+
footerClass: props.defaultFooterStyle ? "pbs-3 border-t bg-background-200 dark:bg-background-100" : ""
|
|
125
125
|
}));
|
|
126
126
|
const transitionName = computed(() => `pxd-transition--drawer-${ensurePosition.value}`);
|
|
127
127
|
const computedStyle = computed(() => ({
|
|
@@ -179,20 +179,17 @@ watch(() => isVisible.value, (visible) => {
|
|
|
179
179
|
v-bind="$attrs"
|
|
180
180
|
>
|
|
181
181
|
<header
|
|
182
|
-
class="pxd-drawer--header px-
|
|
183
|
-
:class="[defaultStyles.headerClass, { 'pe-
|
|
182
|
+
class="pxd-drawer--header px-5 pbs-5 relative shrink-0 empty:hidden"
|
|
183
|
+
:class="[defaultStyles.headerClass, { 'pe-13': closeable }]"
|
|
184
184
|
>
|
|
185
185
|
<slot name="header">
|
|
186
|
-
<h3
|
|
187
|
-
v-if="$slots.title || title"
|
|
188
|
-
class="text-lg sm:text-xl font-semibold tracking-tight m-0"
|
|
189
|
-
>
|
|
186
|
+
<h3 v-if="title || $slots.title" class="text-lg font-semibold tracking-tight m-0">
|
|
190
187
|
<slot name="title">
|
|
191
188
|
{{ title }}
|
|
192
189
|
</slot>
|
|
193
190
|
</h3>
|
|
194
191
|
|
|
195
|
-
<div v-if="
|
|
192
|
+
<div v-if="subtitle || $slots.subtitle" class="mbs-1 text-sm text-gray-900">
|
|
196
193
|
<slot name="subtitle">
|
|
197
194
|
{{ subtitle }}
|
|
198
195
|
</slot>
|
|
@@ -204,7 +201,7 @@ watch(() => isVisible.value, (visible) => {
|
|
|
204
201
|
variant="ghost"
|
|
205
202
|
size="sm"
|
|
206
203
|
icon
|
|
207
|
-
class="top-4 right-
|
|
204
|
+
class="top-4 right-5 sm:top-5 size-7 absolute"
|
|
208
205
|
:aria-label="configProvider.locale.interaction.close"
|
|
209
206
|
:title="configProvider.locale.interaction.close"
|
|
210
207
|
@click="closeOverlayIfNeed"
|
|
@@ -213,16 +210,13 @@ watch(() => isVisible.value, (visible) => {
|
|
|
213
210
|
</PButton>
|
|
214
211
|
</header>
|
|
215
212
|
|
|
216
|
-
<div
|
|
217
|
-
class="pxd-drawer--content px-6 py-4 sm:py-6 empty:py-3 h-full flex-1 overflow-auto"
|
|
218
|
-
:class="contentClass"
|
|
219
|
-
>
|
|
213
|
+
<div class="pxd-drawer--content p-5 h-full flex-1 overflow-auto" :class="contentClass">
|
|
220
214
|
<slot />
|
|
221
215
|
</div>
|
|
222
216
|
|
|
223
217
|
<footer
|
|
224
218
|
v-if="$slots.footer"
|
|
225
|
-
class="pxd-drawer--footer px-
|
|
219
|
+
class="pxd-drawer--footer px-3 pbe-3 gap-2 relative flex shrink-0 items-center justify-between"
|
|
226
220
|
:class="defaultStyles.footerClass"
|
|
227
221
|
>
|
|
228
222
|
<slot name="footer" />
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { prepareWithSegments, layoutWithLines } from "@chenglou/pretext";
|
|
3
3
|
import { prepareRichInline, measureRichInlineStats } from "@chenglou/pretext/rich-inline";
|
|
4
|
-
import { cn } from "cn";
|
|
5
4
|
import { shallowRef, computed, nextTick, watch, onBeforeUnmount } from "vue";
|
|
6
5
|
import { useResizeObserver } from "../../composables/use-resize-observer.js";
|
|
6
|
+
import { cn } from "../../utils/cn.js";
|
|
7
7
|
import { getStyle } from "../../utils/dom.js";
|
|
8
8
|
import { scheduleByRaf } from "../../utils/event.js";
|
|
9
9
|
import { isServer } from "../../utils/is.js";
|
|
@@ -33,11 +33,11 @@ const { attrs, classes } = useTailwindVariant({
|
|
|
33
33
|
variants: {
|
|
34
34
|
variant: {
|
|
35
35
|
default: "",
|
|
36
|
-
card: "p-
|
|
36
|
+
card: "p-3 gap-2 w-full max-w-full flex-col items-center rounded-lg border border-red-400 bg-red-200 empty:hidden"
|
|
37
37
|
},
|
|
38
38
|
size: {
|
|
39
39
|
xs: "text-xs [--mt:0.125rem]",
|
|
40
|
-
sm: "text-
|
|
40
|
+
sm: "text-sm [--mt:0.125rem]",
|
|
41
41
|
md: "text-sm [--mt:0.125rem]",
|
|
42
42
|
lg: "text-base [--mt:0.25rem]"
|
|
43
43
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ImagePreviewItem, ImagePreviewProps } from './types';
|
|
2
|
+
declare function zoomIn(): void;
|
|
3
|
+
declare function zoomOut(): void;
|
|
4
|
+
declare function rotate(): void;
|
|
5
|
+
declare function reset(): void;
|
|
6
|
+
declare function open(index?: number): void;
|
|
7
|
+
declare function close(): void;
|
|
8
|
+
declare var __VLS_2: {
|
|
9
|
+
image: ImagePreviewItem;
|
|
10
|
+
index: number;
|
|
11
|
+
};
|
|
12
|
+
type __VLS_Slots = {} & {
|
|
13
|
+
item?: (props: typeof __VLS_2) => any;
|
|
14
|
+
};
|
|
15
|
+
declare const __VLS_base: import("vue").DefineComponent<ImagePreviewProps, {
|
|
16
|
+
open: typeof open;
|
|
17
|
+
close: typeof close;
|
|
18
|
+
zoomIn: typeof zoomIn;
|
|
19
|
+
zoomOut: typeof zoomOut;
|
|
20
|
+
rotate: typeof rotate;
|
|
21
|
+
reset: typeof reset;
|
|
22
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
23
|
+
"index-change": (index: number) => any;
|
|
24
|
+
}, string, import("vue").PublicProps, Readonly<ImagePreviewProps> & Readonly<{
|
|
25
|
+
"onIndex-change"?: ((index: number) => any) | undefined;
|
|
26
|
+
}>, {
|
|
27
|
+
closeOnPressEscape: boolean;
|
|
28
|
+
index: number;
|
|
29
|
+
closeOnClickOverlay: boolean;
|
|
30
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
31
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
32
|
+
declare const _default: typeof __VLS_export;
|
|
33
|
+
export default _default;
|
|
34
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
35
|
+
new (): {
|
|
36
|
+
$slots: S;
|
|
37
|
+
};
|
|
38
|
+
};
|