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,351 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import ChevronLeftIcon from "@gdsicon/vue/chevron-left";
|
|
3
|
+
import ChevronRightIcon from "@gdsicon/vue/chevron-right";
|
|
4
|
+
import CrossIcon from "@gdsicon/vue/cross";
|
|
5
|
+
import MagnifyingGlassMinusIcon from "@gdsicon/vue/magnifying-glass-minus";
|
|
6
|
+
import MagnifyingGlassPlusIcon from "@gdsicon/vue/magnifying-glass-plus";
|
|
7
|
+
import RefreshCounterClockwiseIcon from "@gdsicon/vue/refresh-counter-clockwise";
|
|
8
|
+
import RotateClockwiseIcon from "@gdsicon/vue/rotate-clockwise";
|
|
9
|
+
import { computed, onBeforeUnmount, shallowRef, watch } from "vue";
|
|
10
|
+
import { useFocusTrap } from "../../composables/_internal/use-focus-trap.js";
|
|
11
|
+
import { useConfigProvider } from "../../contexts/config-provider.js";
|
|
12
|
+
import { isServer } from "../../utils/is.js";
|
|
13
|
+
import POverlay from "../overlay/index.vue";
|
|
14
|
+
defineOptions({
|
|
15
|
+
name: "PImagePreview",
|
|
16
|
+
inheritAttrs: false
|
|
17
|
+
});
|
|
18
|
+
const props = defineProps({
|
|
19
|
+
data: {
|
|
20
|
+
type: Array,
|
|
21
|
+
required: false
|
|
22
|
+
},
|
|
23
|
+
index: {
|
|
24
|
+
type: Number,
|
|
25
|
+
required: false,
|
|
26
|
+
default: 0
|
|
27
|
+
},
|
|
28
|
+
zIndex: {
|
|
29
|
+
type: Number,
|
|
30
|
+
required: false
|
|
31
|
+
},
|
|
32
|
+
closeOnPressEscape: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
required: false,
|
|
35
|
+
default: true
|
|
36
|
+
},
|
|
37
|
+
closeOnClickOverlay: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
required: false,
|
|
40
|
+
default: true
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const emits = defineEmits(["index-change"]);
|
|
44
|
+
const MIN_ZOOM = .25;
|
|
45
|
+
const MAX_ZOOM = 4;
|
|
46
|
+
const ZOOM_STEP = .25;
|
|
47
|
+
const DRAG_THRESHOLD = 3;
|
|
48
|
+
const CONTROL_CLASS = "size-8 inline-flex cursor-pointer appearance-none items-center justify-center rounded-md border-0 bg-transparent p-0 font-inherit text-white outline-none hover:bg-white/15 focus-visible:outline-2 focus-visible:outline-white";
|
|
49
|
+
const ARROW_CLASS = "top-1/2 size-9 -translate-y-1/2 inline-flex cursor-pointer appearance-none items-center justify-center rounded-full border-0 bg-black/50 p-0 font-inherit text-white outline-none hover:bg-black/70 focus-visible:outline-2 focus-visible:outline-white absolute";
|
|
50
|
+
let hasDragged = false;
|
|
51
|
+
let dragStartX = 0;
|
|
52
|
+
let dragStartY = 0;
|
|
53
|
+
let dragOriginX = 0;
|
|
54
|
+
let dragOriginY = 0;
|
|
55
|
+
const dialogRef = shallowRef();
|
|
56
|
+
const isVisible = shallowRef(false);
|
|
57
|
+
const activeIndex = shallowRef(props.index);
|
|
58
|
+
const zoom = shallowRef(1);
|
|
59
|
+
const rotation = shallowRef(0);
|
|
60
|
+
const offsetX = shallowRef(0);
|
|
61
|
+
const offsetY = shallowRef(0);
|
|
62
|
+
const isDragging = shallowRef(false);
|
|
63
|
+
const images = computed(() => (props.data ?? []).map((image) => typeof image === "string" ? { src: image } : image));
|
|
64
|
+
const currentIndex = computed(() => {
|
|
65
|
+
const length = images.value.length;
|
|
66
|
+
if (length === 0) {
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
return Math.min(Math.max(activeIndex.value, 0), length - 1);
|
|
70
|
+
});
|
|
71
|
+
const currentImage = computed(() => images.value[currentIndex.value]);
|
|
72
|
+
const dialogLabel = computed(() => currentImage.value?.alt || "Image preview");
|
|
73
|
+
const zoomPercent = computed(() => `${Math.round(zoom.value * 100)}%`);
|
|
74
|
+
const imageStyle = computed(() => ({ transform: `translate3d(${offsetX.value}px, ${offsetY.value}px, 0) scale(${zoom.value}) rotate(${rotation.value}deg)` }));
|
|
75
|
+
const dialogStyle = computed(() => ({ "--image-preview-index": props.zIndex ?? "calc(var(--modal-index) + 5)" }));
|
|
76
|
+
const configProvider = useConfigProvider();
|
|
77
|
+
useFocusTrap(dialogRef);
|
|
78
|
+
function resetTransform() {
|
|
79
|
+
zoom.value = 1;
|
|
80
|
+
rotation.value = 0;
|
|
81
|
+
offsetX.value = 0;
|
|
82
|
+
offsetY.value = 0;
|
|
83
|
+
}
|
|
84
|
+
function setZoom(value) {
|
|
85
|
+
zoom.value = Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, value));
|
|
86
|
+
}
|
|
87
|
+
function zoomIn() {
|
|
88
|
+
setZoom(zoom.value + ZOOM_STEP);
|
|
89
|
+
}
|
|
90
|
+
function zoomOut() {
|
|
91
|
+
setZoom(zoom.value - ZOOM_STEP);
|
|
92
|
+
}
|
|
93
|
+
function rotate() {
|
|
94
|
+
rotation.value = (rotation.value + 90) % 360;
|
|
95
|
+
}
|
|
96
|
+
function reset() {
|
|
97
|
+
resetTransform();
|
|
98
|
+
}
|
|
99
|
+
function switchTo(index) {
|
|
100
|
+
const length = images.value.length;
|
|
101
|
+
if (length === 0) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const nextIndex = (index % length + length) % length;
|
|
105
|
+
if (nextIndex === currentIndex.value) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
activeIndex.value = nextIndex;
|
|
109
|
+
resetTransform();
|
|
110
|
+
emits("index-change", nextIndex);
|
|
111
|
+
}
|
|
112
|
+
function switchBy(delta) {
|
|
113
|
+
switchTo(currentIndex.value + delta);
|
|
114
|
+
}
|
|
115
|
+
function open(index = currentIndex.value) {
|
|
116
|
+
if (images.value.length === 0) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
isVisible.value = true;
|
|
120
|
+
resetTransform();
|
|
121
|
+
switchTo(index);
|
|
122
|
+
}
|
|
123
|
+
function close() {
|
|
124
|
+
isVisible.value = false;
|
|
125
|
+
}
|
|
126
|
+
function onBackdropClick(ev) {
|
|
127
|
+
if (ev.target !== ev.currentTarget) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (hasDragged) {
|
|
131
|
+
hasDragged = false;
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (props.closeOnClickOverlay) {
|
|
135
|
+
close();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function onPointerDown(ev) {
|
|
139
|
+
if (ev.button !== 0) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
hasDragged = false;
|
|
143
|
+
isDragging.value = true;
|
|
144
|
+
dragStartX = ev.clientX;
|
|
145
|
+
dragStartY = ev.clientY;
|
|
146
|
+
dragOriginX = offsetX.value;
|
|
147
|
+
dragOriginY = offsetY.value;
|
|
148
|
+
window.addEventListener("pointermove", onPointerMove);
|
|
149
|
+
window.addEventListener("pointerup", onPointerUp);
|
|
150
|
+
window.addEventListener("pointercancel", onPointerUp);
|
|
151
|
+
}
|
|
152
|
+
function onPointerMove(ev) {
|
|
153
|
+
if (!isDragging.value) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const deltaX = ev.clientX - dragStartX;
|
|
157
|
+
const deltaY = ev.clientY - dragStartY;
|
|
158
|
+
if (Math.abs(deltaX) + Math.abs(deltaY) > DRAG_THRESHOLD) {
|
|
159
|
+
hasDragged = true;
|
|
160
|
+
}
|
|
161
|
+
offsetX.value = dragOriginX + deltaX;
|
|
162
|
+
offsetY.value = dragOriginY + deltaY;
|
|
163
|
+
}
|
|
164
|
+
function onPointerUp() {
|
|
165
|
+
isDragging.value = false;
|
|
166
|
+
window.removeEventListener("pointermove", onPointerMove);
|
|
167
|
+
window.removeEventListener("pointerup", onPointerUp);
|
|
168
|
+
window.removeEventListener("pointercancel", onPointerUp);
|
|
169
|
+
}
|
|
170
|
+
function onWheel(ev) {
|
|
171
|
+
setZoom(zoom.value + (ev.deltaY < 0 ? ZOOM_STEP : -ZOOM_STEP));
|
|
172
|
+
}
|
|
173
|
+
function onKeydown(ev) {
|
|
174
|
+
if (images.value.length < 2) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (ev.key === "ArrowLeft") {
|
|
178
|
+
ev.preventDefault();
|
|
179
|
+
switchBy(-1);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (ev.key === "ArrowRight") {
|
|
183
|
+
ev.preventDefault();
|
|
184
|
+
switchBy(1);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
watch(() => props.index, (index) => {
|
|
188
|
+
activeIndex.value = index;
|
|
189
|
+
});
|
|
190
|
+
watch(currentIndex, () => {
|
|
191
|
+
resetTransform();
|
|
192
|
+
});
|
|
193
|
+
watch(isVisible, (visible) => {
|
|
194
|
+
if (isServer()) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
if (visible) {
|
|
198
|
+
document.addEventListener("keydown", onKeydown);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
document.removeEventListener("keydown", onKeydown);
|
|
202
|
+
});
|
|
203
|
+
onBeforeUnmount(() => {
|
|
204
|
+
onPointerUp();
|
|
205
|
+
if (isServer()) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
document.removeEventListener("keydown", onKeydown);
|
|
209
|
+
});
|
|
210
|
+
defineExpose({
|
|
211
|
+
open,
|
|
212
|
+
close,
|
|
213
|
+
zoomIn,
|
|
214
|
+
zoomOut,
|
|
215
|
+
rotate,
|
|
216
|
+
reset
|
|
217
|
+
});
|
|
218
|
+
</script>
|
|
219
|
+
|
|
220
|
+
<template>
|
|
221
|
+
<div data-image-preview v-bind="$attrs">
|
|
222
|
+
<div class="gap-2 flex flex-wrap">
|
|
223
|
+
<button
|
|
224
|
+
v-for="(image, index) in images"
|
|
225
|
+
:key="`${image.src}-${index}`"
|
|
226
|
+
type="button"
|
|
227
|
+
:aria-label="image.alt || `Preview image ${index + 1}`"
|
|
228
|
+
class="size-20 p-0 shrink-0 cursor-pointer appearance-none overflow-hidden rounded-md border-0 bg-gray-100 self-focus-ring"
|
|
229
|
+
@click="open(index)"
|
|
230
|
+
>
|
|
231
|
+
<slot name="item" :image="image" :index="index">
|
|
232
|
+
<img
|
|
233
|
+
:src="image.src"
|
|
234
|
+
alt=""
|
|
235
|
+
loading="lazy"
|
|
236
|
+
decoding="async"
|
|
237
|
+
fetchpriority="low"
|
|
238
|
+
crossorigin="anonymous"
|
|
239
|
+
class="size-full object-cover"
|
|
240
|
+
/>
|
|
241
|
+
</slot>
|
|
242
|
+
</button>
|
|
243
|
+
</div>
|
|
244
|
+
|
|
245
|
+
<POverlay
|
|
246
|
+
v-model="isVisible"
|
|
247
|
+
variant="none"
|
|
248
|
+
:z-index="zIndex"
|
|
249
|
+
:close-on-press-escape="closeOnPressEscape"
|
|
250
|
+
>
|
|
251
|
+
<Transition name="pxd-transition--fade" appear>
|
|
252
|
+
<div
|
|
253
|
+
v-if="isVisible"
|
|
254
|
+
ref="dialogRef"
|
|
255
|
+
data-image-preview-dialog
|
|
256
|
+
role="dialog"
|
|
257
|
+
aria-modal="true"
|
|
258
|
+
tabindex="-1"
|
|
259
|
+
:aria-label="dialogLabel"
|
|
260
|
+
class="pxd-image-preview--dialog inset-0 bg-black/90 text-white pointer-events-auto fixed z-(--image-preview-index) flex flex-col outline-none select-none"
|
|
261
|
+
:style="dialogStyle"
|
|
262
|
+
@click="onBackdropClick"
|
|
263
|
+
>
|
|
264
|
+
<div
|
|
265
|
+
data-image-preview-stage
|
|
266
|
+
class="min-h-0 relative flex-1 touch-none overflow-hidden"
|
|
267
|
+
:class="isDragging ? 'cursor-grabbing' : 'cursor-grab'"
|
|
268
|
+
@pointerdown="onPointerDown"
|
|
269
|
+
@wheel.prevent="onWheel"
|
|
270
|
+
@click="onBackdropClick"
|
|
271
|
+
>
|
|
272
|
+
<img
|
|
273
|
+
v-if="currentImage"
|
|
274
|
+
:key="currentImage.src"
|
|
275
|
+
:src="currentImage.src"
|
|
276
|
+
:alt="currentImage.alt || `Image ${currentIndex + 1}`"
|
|
277
|
+
draggable="false"
|
|
278
|
+
class="size-full object-contain"
|
|
279
|
+
:style="imageStyle"
|
|
280
|
+
/>
|
|
281
|
+
</div>
|
|
282
|
+
|
|
283
|
+
<span
|
|
284
|
+
v-if="images.length > 1"
|
|
285
|
+
data-image-preview-counter
|
|
286
|
+
aria-live="polite"
|
|
287
|
+
class="top-4 left-4 text-sm text-white/80 absolute"
|
|
288
|
+
>
|
|
289
|
+
{{ currentIndex + 1 }} / {{ images.length }}
|
|
290
|
+
</span>
|
|
291
|
+
|
|
292
|
+
<button
|
|
293
|
+
type="button"
|
|
294
|
+
:aria-label="configProvider.locale.interaction.close"
|
|
295
|
+
class="top-4 right-4 absolute"
|
|
296
|
+
:class="CONTROL_CLASS"
|
|
297
|
+
@click="close"
|
|
298
|
+
>
|
|
299
|
+
<CrossIcon class="size-4" />
|
|
300
|
+
</button>
|
|
301
|
+
|
|
302
|
+
<button
|
|
303
|
+
v-if="images.length > 1"
|
|
304
|
+
type="button"
|
|
305
|
+
aria-label="Previous image"
|
|
306
|
+
class="left-4"
|
|
307
|
+
:class="ARROW_CLASS"
|
|
308
|
+
@click="switchBy(-1)"
|
|
309
|
+
>
|
|
310
|
+
<ChevronLeftIcon class="size-5" />
|
|
311
|
+
</button>
|
|
312
|
+
|
|
313
|
+
<button
|
|
314
|
+
v-if="images.length > 1"
|
|
315
|
+
type="button"
|
|
316
|
+
aria-label="Next image"
|
|
317
|
+
class="right-4"
|
|
318
|
+
:class="ARROW_CLASS"
|
|
319
|
+
@click="switchBy(1)"
|
|
320
|
+
>
|
|
321
|
+
<ChevronRightIcon class="size-5" />
|
|
322
|
+
</button>
|
|
323
|
+
|
|
324
|
+
<div
|
|
325
|
+
class="bottom-4 p-1 gap-0.5 bg-black/50 backdrop-blur-sm absolute left-1/2 flex -translate-x-1/2 items-center rounded-lg"
|
|
326
|
+
>
|
|
327
|
+
<button type="button" aria-label="Zoom out" :class="CONTROL_CLASS" @click="zoomOut">
|
|
328
|
+
<MagnifyingGlassMinusIcon class="size-4" />
|
|
329
|
+
</button>
|
|
330
|
+
|
|
331
|
+
<span data-image-preview-zoom class="min-w-12 text-sm text-center tabular-nums">
|
|
332
|
+
{{ zoomPercent }}
|
|
333
|
+
</span>
|
|
334
|
+
|
|
335
|
+
<button type="button" aria-label="Zoom in" :class="CONTROL_CLASS" @click="zoomIn">
|
|
336
|
+
<MagnifyingGlassPlusIcon class="size-4" />
|
|
337
|
+
</button>
|
|
338
|
+
|
|
339
|
+
<button type="button" aria-label="Rotate" :class="CONTROL_CLASS" @click="rotate">
|
|
340
|
+
<RotateClockwiseIcon class="size-4" />
|
|
341
|
+
</button>
|
|
342
|
+
|
|
343
|
+
<button type="button" aria-label="Reset" :class="CONTROL_CLASS" @click="reset">
|
|
344
|
+
<RefreshCounterClockwiseIcon class="size-4" />
|
|
345
|
+
</button>
|
|
346
|
+
</div>
|
|
347
|
+
</div>
|
|
348
|
+
</Transition>
|
|
349
|
+
</POverlay>
|
|
350
|
+
</div>
|
|
351
|
+
</template>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface ImagePreviewItem {
|
|
2
|
+
src: string
|
|
3
|
+
alt?: string
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export type ImagePreviewSource = string | ImagePreviewItem
|
|
7
|
+
|
|
8
|
+
export interface ImagePreviewProps {
|
|
9
|
+
data?: ImagePreviewSource[]
|
|
10
|
+
index?: number
|
|
11
|
+
zIndex?: number
|
|
12
|
+
closeOnPressEscape?: boolean
|
|
13
|
+
closeOnClickOverlay?: boolean
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ImagePreviewEmits {
|
|
17
|
+
'index-change': [index: number]
|
|
18
|
+
}
|
|
@@ -22,6 +22,7 @@ export { default as Checkerboard } from './checkerboard/index.vue';
|
|
|
22
22
|
export { default as Chip } from './chip/index.vue';
|
|
23
23
|
export { default as Choicebox } from './choicebox/index.vue';
|
|
24
24
|
export { default as ChoiceboxItem } from './choicebox-item/index.vue';
|
|
25
|
+
export { default as CodeBlock } from './code-block/index.vue';
|
|
25
26
|
export { default as Collapse } from './collapse/index.vue';
|
|
26
27
|
export { default as CollapseGroup } from './collapse-group/index.vue';
|
|
27
28
|
export { default as ColorSelector } from './color-selector/index.vue';
|
|
@@ -46,6 +47,7 @@ export { default as GridItem } from './grid-item/index.vue';
|
|
|
46
47
|
export { default as Hint } from './hint/index.vue';
|
|
47
48
|
export { default as HoldButton } from './hold-button/index.vue';
|
|
48
49
|
export { default as HueText } from './hue-text/index.vue';
|
|
50
|
+
export { default as ImagePreview } from './image-preview/index.vue';
|
|
49
51
|
export { default as Input } from './input/index.vue';
|
|
50
52
|
export { default as IntersectionObserver } from './intersection-observer/index.vue';
|
|
51
53
|
export { default as Kbd } from './kbd/index.vue';
|
package/dist/components/index.js
CHANGED
|
@@ -22,6 +22,7 @@ export { default as Checkerboard } from "./checkerboard/index.vue";
|
|
|
22
22
|
export { default as Chip } from "./chip/index.vue";
|
|
23
23
|
export { default as Choicebox } from "./choicebox/index.vue";
|
|
24
24
|
export { default as ChoiceboxItem } from "./choicebox-item/index.vue";
|
|
25
|
+
export { default as CodeBlock } from "./code-block/index.vue";
|
|
25
26
|
export { default as Collapse } from "./collapse/index.vue";
|
|
26
27
|
export { default as CollapseGroup } from "./collapse-group/index.vue";
|
|
27
28
|
export { default as ColorSelector } from "./color-selector/index.vue";
|
|
@@ -46,6 +47,7 @@ export { default as GridItem } from "./grid-item/index.vue";
|
|
|
46
47
|
export { default as Hint } from "./hint/index.vue";
|
|
47
48
|
export { default as HoldButton } from "./hold-button/index.vue";
|
|
48
49
|
export { default as HueText } from "./hue-text/index.vue";
|
|
50
|
+
export { default as ImagePreview } from "./image-preview/index.vue";
|
|
49
51
|
export { default as Input } from "./input/index.vue";
|
|
50
52
|
export { default as IntersectionObserver } from "./intersection-observer/index.vue";
|
|
51
53
|
export { default as Kbd } from "./kbd/index.vue";
|
|
@@ -307,6 +307,7 @@ defineExpose({
|
|
|
307
307
|
:id="uniqueId"
|
|
308
308
|
ref="inputRef"
|
|
309
309
|
class="px-3 py-0 file:font-medium size-full appearance-none rounded-none border-none bg-transparent [text-align:inherit] font-inherit outline-none select-auto file:border-0 file:bg-transparent placeholder:text-gray-600 placeholder:select-none read-only:cursor-default disabled:cursor-not-allowed disabled:text-gray-700 disabled:placeholder:text-gray-500"
|
|
310
|
+
spellcheck="false"
|
|
310
311
|
autocorrect="off"
|
|
311
312
|
autocomplete="off"
|
|
312
313
|
autocapitalize="off"
|
|
@@ -345,8 +346,8 @@ defineExpose({
|
|
|
345
346
|
class="p-1 cursor-pointer appearance-none rounded-sm font-inherit self-focus-ring outline-none hover:bg-background-hover hover:text-foreground active:bg-background-active motion-safe:transition-colors"
|
|
346
347
|
@click.stop.prevent="toggleType"
|
|
347
348
|
>
|
|
348
|
-
<EyeOffIcon v-if="isPasswordVisible" class="size-3
|
|
349
|
-
<EyeIcon v-else class="size-3
|
|
349
|
+
<EyeOffIcon v-if="isPasswordVisible" class="size-3" />
|
|
350
|
+
<EyeIcon v-else class="size-3" />
|
|
350
351
|
</button>
|
|
351
352
|
<button
|
|
352
353
|
v-if="clearable"
|
|
@@ -354,13 +355,13 @@ defineExpose({
|
|
|
354
355
|
class="p-1 cursor-pointer appearance-none rounded-sm font-inherit self-focus-ring outline-none hover:bg-background-hover hover:text-foreground active:bg-background-active motion-safe:transition-colors"
|
|
355
356
|
@click.stop.prevent="clear"
|
|
356
357
|
>
|
|
357
|
-
<CrossIcon class="size-3
|
|
358
|
+
<CrossIcon class="size-3" />
|
|
358
359
|
</button>
|
|
359
360
|
</div>
|
|
360
361
|
|
|
361
362
|
<span
|
|
362
363
|
v-if="isWordLimitShown"
|
|
363
|
-
class="pxd-input--word-limit text-xs px-1.5 -ms-1.5
|
|
364
|
+
class="pxd-input--word-limit text-xs px-1.5 -ms-1.5 shrink-0 text-nowrap text-foreground-secondary"
|
|
364
365
|
:class="{
|
|
365
366
|
'right-0 pe-0 mbs-1 absolute top-full': isWordLimitOutside,
|
|
366
367
|
'text-red-900': isWordLimitExceeded
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { BASIC_MIN_HEIGHTS } from "../../constants/size.js";
|
|
4
|
+
import { useConfigProvider } from "../../contexts/config-provider.js";
|
|
2
5
|
defineOptions({
|
|
3
6
|
name: "PListGroup",
|
|
4
7
|
inheritAttrs: false
|
|
@@ -7,6 +10,8 @@ defineProps({ label: {
|
|
|
7
10
|
type: String,
|
|
8
11
|
required: false
|
|
9
12
|
} });
|
|
13
|
+
const configProvider = useConfigProvider();
|
|
14
|
+
const minHeightClass = computed(() => BASIC_MIN_HEIGHTS[configProvider.size]);
|
|
10
15
|
</script>
|
|
11
16
|
|
|
12
17
|
<template>
|
|
@@ -14,7 +19,8 @@ defineProps({ label: {
|
|
|
14
19
|
role="group"
|
|
15
20
|
data-list-group
|
|
16
21
|
:aria-label="label"
|
|
17
|
-
class="pxd-list-group
|
|
22
|
+
class="pxd-list-group px-2 py-1 flex items-center text-13px text-foreground-secondary"
|
|
23
|
+
:class="minHeightClass"
|
|
18
24
|
v-bind="$attrs"
|
|
19
25
|
>
|
|
20
26
|
{{ label }}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import CheckIcon from "@gdsicon/vue/check";
|
|
3
3
|
import { computed } from "vue";
|
|
4
4
|
import { useTailwindVariant } from "../../composables/_internal/use-tailwind-variant.js";
|
|
5
|
+
import { BASIC_MIN_HEIGHTS } from "../../constants/size.js";
|
|
6
|
+
import { useConfigProvider } from "../../contexts/config-provider.js";
|
|
5
7
|
import { useListContext } from "../../contexts/list.js";
|
|
6
8
|
import { toArray } from "../../utils/format.js";
|
|
7
9
|
import { isNil } from "../../utils/is.js";
|
|
@@ -67,14 +69,25 @@ const { value: selectedValue, onItemSelect } = useListContext();
|
|
|
67
69
|
const isChecked = computed(() => {
|
|
68
70
|
return !isNil(props.value) && toArray(selectedValue.value).includes(props.value);
|
|
69
71
|
});
|
|
72
|
+
const configProvider = useConfigProvider();
|
|
70
73
|
const { attrs, classes } = useTailwindVariant({
|
|
71
|
-
base: "pxd-list-item
|
|
72
|
-
variants: {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
},
|
|
74
|
+
base: "pxd-list-item p-2 text-sm pe-8 gap-2 flex w-full max-w-full cursor-pointer items-center rounded-md outline-none content-visibility-auto data-[disabled=true]:pointer-events-none data-[disabled=true]:text-gray-700",
|
|
75
|
+
variants: {
|
|
76
|
+
size: {
|
|
77
|
+
sm: BASIC_MIN_HEIGHTS.sm,
|
|
78
|
+
md: BASIC_MIN_HEIGHTS.md,
|
|
79
|
+
lg: BASIC_MIN_HEIGHTS.lg
|
|
80
|
+
},
|
|
81
|
+
variant: {
|
|
82
|
+
error: "text-red-900 active:bg-red-100 pointer-fine:data-[active=true]:bg-red-100",
|
|
83
|
+
warning: "text-amber-900 active:bg-amber-100 pointer-fine:data-[active=true]:bg-amber-100",
|
|
84
|
+
default: "text-foreground active:bg-gray-alpha-100 pointer-fine:data-[active=true]:bg-gray-alpha-100"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}, { selection: () => ({
|
|
88
|
+
size: configProvider.size,
|
|
89
|
+
variant: props.variant
|
|
90
|
+
}) });
|
|
78
91
|
function onItemClick(ev) {
|
|
79
92
|
const value = props.value;
|
|
80
93
|
if (props.disabled || isNil(value)) {
|
|
@@ -112,7 +125,7 @@ function onItemClick(ev) {
|
|
|
112
125
|
|
|
113
126
|
<CheckIcon
|
|
114
127
|
v-if="isChecked"
|
|
115
|
-
class="pxd-list-item--checked right-
|
|
128
|
+
class="pxd-list-item--checked right-3 absolute top-1/2 -translate-y-1/2 text-primary"
|
|
116
129
|
/>
|
|
117
130
|
</Component>
|
|
118
131
|
</template>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed, onBeforeUnmount, onMounted, shallowRef, watch } from "vue";
|
|
3
3
|
import { useResizeObserver } from "../../composables/use-resize-observer.js";
|
|
4
|
+
import { BASIC_MIN_HEIGHTS } from "../../constants/size.js";
|
|
5
|
+
import { useConfigProvider } from "../../contexts/config-provider.js";
|
|
4
6
|
import { caf, raf, throttleByRaf } from "../../utils/event.js";
|
|
5
7
|
import { isServer } from "../../utils/is.js";
|
|
6
8
|
defineOptions({
|
|
@@ -84,6 +86,8 @@ const contentClass = computed(() => {
|
|
|
84
86
|
}
|
|
85
87
|
return "block max-w-full truncate";
|
|
86
88
|
});
|
|
89
|
+
const configProvider = useConfigProvider();
|
|
90
|
+
const minHeightClass = computed(() => BASIC_MIN_HEIGHTS[configProvider.size]);
|
|
87
91
|
useResizeObserver(wrapRef, scheduleSync);
|
|
88
92
|
function toDelay(value) {
|
|
89
93
|
const n = Number(value);
|
|
@@ -206,8 +210,8 @@ defineExpose({ reset });
|
|
|
206
210
|
<Component
|
|
207
211
|
data-marquee
|
|
208
212
|
:is="as"
|
|
209
|
-
class="pxd-marquee text-sm
|
|
210
|
-
:class="isWrapMode ? 'items-start' : 'items-center'"
|
|
213
|
+
class="pxd-marquee text-sm py-2 px-3 gap-2 relative flex w-full max-w-full overflow-hidden bg-(--marquee-background) text-(--marquee-color)"
|
|
214
|
+
:class="[minHeightClass, isWrapMode ? 'items-start' : 'items-center']"
|
|
211
215
|
:data-pause-on-hover="pauseOnHover ? 'true' : 'false'"
|
|
212
216
|
:style="rootStyle"
|
|
213
217
|
v-bind="$attrs"
|
|
@@ -20,11 +20,11 @@ declare const __VLS_base: import("vue").DefineComponent<MentionProps, {}, {}, {}
|
|
|
20
20
|
"onUpdate:modelValue"?: ((args_0: string) => any) | undefined;
|
|
21
21
|
"onMention-click"?: ((args_0: MentionClickPayload) => any) | undefined;
|
|
22
22
|
}>, {
|
|
23
|
+
placeholder: string;
|
|
23
24
|
disabled: boolean;
|
|
24
25
|
modelValue: string;
|
|
25
26
|
options: ListOptions | import("./types").MentionOptionsResolver;
|
|
26
27
|
closeOnPressEscape: boolean;
|
|
27
|
-
placeholder: string;
|
|
28
28
|
triggers: string[];
|
|
29
29
|
searchPlaceholder: string;
|
|
30
30
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -14,16 +14,16 @@ type __VLS_Slots = {} & {
|
|
|
14
14
|
declare const __VLS_base: import("vue").DefineComponent<ModalProps, {}, {}, {}, {}, 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<ModalProps> & 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;
|
|
@@ -109,8 +109,8 @@ const computedStyle = computed(() => {
|
|
|
109
109
|
};
|
|
110
110
|
});
|
|
111
111
|
const defaultStyles = computed(() => ({
|
|
112
|
-
headerClass: props.defaultHeaderStyle ? "pbe-
|
|
113
|
-
footerClass: props.defaultFooterStyle ? "border-t
|
|
112
|
+
headerClass: props.defaultHeaderStyle ? "pbe-5 border-b bg-background-200 dark:bg-background-100" : "",
|
|
113
|
+
footerClass: props.defaultFooterStyle ? "pbs-3 border-t bg-background-200 dark:bg-background-100" : ""
|
|
114
114
|
}));
|
|
115
115
|
const isVisible = useModelValue(props, emits);
|
|
116
116
|
const configProvider = useConfigProvider();
|
|
@@ -157,20 +157,17 @@ watch(() => isVisible.value, (visible) => {
|
|
|
157
157
|
v-bind="$attrs"
|
|
158
158
|
>
|
|
159
159
|
<header
|
|
160
|
-
class="pxd-modal--header px-
|
|
161
|
-
:class="[defaultStyles.headerClass, { 'pe-
|
|
160
|
+
class="pxd-modal--header px-5 pbs-5 relative shrink-0 empty:hidden"
|
|
161
|
+
:class="[defaultStyles.headerClass, { 'pe-13': closeable }]"
|
|
162
162
|
>
|
|
163
163
|
<slot name="header">
|
|
164
|
-
<h3
|
|
165
|
-
v-if="$slots.title || title"
|
|
166
|
-
class="text-lg sm:text-xl font-semibold tracking-tight m-0"
|
|
167
|
-
>
|
|
164
|
+
<h3 v-if="title || $slots.title" class="text-lg font-semibold tracking-tight m-0">
|
|
168
165
|
<slot name="title">
|
|
169
166
|
{{ title }}
|
|
170
167
|
</slot>
|
|
171
168
|
</h3>
|
|
172
169
|
|
|
173
|
-
<div v-if="
|
|
170
|
+
<div v-if="subtitle || $slots.subtitle" class="mbs-1 text-sm text-gray-900">
|
|
174
171
|
<slot name="subtitle">
|
|
175
172
|
{{ subtitle }}
|
|
176
173
|
</slot>
|
|
@@ -182,7 +179,7 @@ watch(() => isVisible.value, (visible) => {
|
|
|
182
179
|
variant="ghost"
|
|
183
180
|
size="sm"
|
|
184
181
|
icon
|
|
185
|
-
class="top-4 right-
|
|
182
|
+
class="top-4 right-5 sm:top-5 size-7 absolute"
|
|
186
183
|
:aria-label="configProvider.locale.interaction.close"
|
|
187
184
|
:title="configProvider.locale.interaction.close"
|
|
188
185
|
@click="closeOverlayIfNeed"
|
|
@@ -191,16 +188,13 @@ watch(() => isVisible.value, (visible) => {
|
|
|
191
188
|
</PButton>
|
|
192
189
|
</header>
|
|
193
190
|
|
|
194
|
-
<div
|
|
195
|
-
class="pxd-modal--content px-6 py-4 sm:py-6 empty:py-3 h-full flex-1 overflow-auto"
|
|
196
|
-
:class="contentClass"
|
|
197
|
-
>
|
|
191
|
+
<div class="pxd-modal--content p-5 h-full flex-1 overflow-auto" :class="contentClass">
|
|
198
192
|
<slot />
|
|
199
193
|
</div>
|
|
200
194
|
|
|
201
195
|
<footer
|
|
202
196
|
v-if="$slots.footer"
|
|
203
|
-
class="pxd-modal--footer px-
|
|
197
|
+
class="pxd-modal--footer px-3 pbe-3 gap-2 relative flex shrink-0 items-center justify-between"
|
|
204
198
|
:class="defaultStyles.footerClass"
|
|
205
199
|
>
|
|
206
200
|
<slot name="footer" />
|
|
@@ -65,7 +65,7 @@ const { attrs, classes } = useTailwindVariant({
|
|
|
65
65
|
base: "pxd-note gap-2 sm:items-center max-sm:flex-col flex max-w-full rounded-md border",
|
|
66
66
|
variants: {
|
|
67
67
|
size: {
|
|
68
|
-
sm: "px-2 py-1.5 text-
|
|
68
|
+
sm: "px-2 py-1.5 text-sm",
|
|
69
69
|
md: "px-3 py-2 text-sm",
|
|
70
70
|
lg: "px-4 py-2.5 text-base"
|
|
71
71
|
},
|