pxd 0.1.2 → 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/calendar-day.vue +19 -19
- package/dist/components/_internal/dismiss-container.d.vue.ts +1 -1
- package/dist/components/_internal/dismiss-container.vue +20 -20
- package/dist/components/_internal/loading-mask.vue +9 -1
- package/dist/components/_internal/mention-editor.vue +3 -3
- package/dist/components/_internal/popover-arrow.d.vue.ts +1 -1
- package/dist/components/_internal/popover-arrow.vue +1 -1
- package/dist/components/{steps → _internal}/step-item.d.vue.ts +1 -1
- package/dist/components/{steps → _internal}/step-item.vue +2 -2
- package/dist/components/_internal/tree-node.d.vue.ts +23 -20
- package/dist/components/_internal/tree-node.vue +68 -51
- package/dist/components/active-graph/index.d.vue.ts +2 -2
- package/dist/components/active-graph/index.vue +1 -1
- package/dist/components/approval-card/index.d.vue.ts +1 -1
- package/dist/components/approval-card/index.vue +34 -17
- package/dist/components/approval-card/types.d.ts +1 -1
- package/dist/components/avatar/index.vue +2 -2
- package/dist/components/backtop/index.d.vue.ts +3 -3
- package/dist/components/backtop/index.vue +17 -17
- package/dist/components/backtop/types.d.ts +1 -1
- package/dist/components/badge/index.d.vue.ts +3 -3
- package/dist/components/badge/index.vue +45 -45
- package/dist/components/badge/types.d.ts +1 -1
- package/dist/components/book/types.d.ts +1 -1
- package/dist/components/border-beam/index.vue +1 -1
- package/dist/components/border-beam/types.d.ts +1 -1
- package/dist/components/browser/index.vue +1 -1
- package/dist/components/bubble/index.vue +6 -6
- package/dist/components/bubble-group/index.d.vue.ts +4 -4
- package/dist/components/button/index.d.vue.ts +4 -4
- package/dist/components/button/index.vue +18 -17
- package/dist/components/button/types.d.ts +2 -2
- package/dist/components/button-group/types.d.ts +2 -2
- package/dist/components/calendar/index.d.vue.ts +2 -2
- package/dist/components/calendar/index.vue +10 -10
- package/dist/components/calendar/types.d.ts +1 -1
- package/dist/components/card/index.vue +2 -2
- package/dist/components/card/types.d.ts +1 -1
- package/dist/components/carousel/index.d.vue.ts +6 -7
- package/dist/components/carousel/index.vue +23 -18
- package/dist/components/carousel/types.d.ts +1 -2
- package/dist/components/checkbox/index.vue +2 -2
- 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/types.d.ts +1 -1
- package/dist/components/chip/index.d.vue.ts +1 -1
- package/dist/components/chip/types.d.ts +1 -1
- package/dist/components/choicebox/index.d.vue.ts +3 -3
- package/dist/components/choicebox/types.d.ts +1 -1
- package/dist/components/choicebox-item/index.vue +10 -10
- package/dist/components/choicebox-item/types.d.ts +1 -1
- 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/collapse/index.vue +2 -2
- package/dist/components/collapse-group/index.vue +1 -1
- package/dist/components/collapse-group/types.d.ts +1 -1
- package/dist/components/command-menu/index.d.vue.ts +4 -4
- package/dist/components/command-menu/index.vue +11 -5
- package/dist/components/config-provider/index.d.vue.ts +44 -5
- package/dist/components/config-provider/types.d.ts +2 -1
- package/dist/components/confirm-popover/index.d.vue.ts +38 -0
- package/dist/components/confirm-popover/index.vue +203 -0
- package/dist/components/confirm-popover/types.d.ts +25 -0
- package/dist/components/copy-button/index.d.vue.ts +2 -6
- package/dist/components/copy-button/index.vue +4 -10
- package/dist/components/dash-line/index.d.vue.ts +1 -1
- package/dist/components/dash-line/index.vue +8 -8
- package/dist/components/dash-line/types.d.ts +1 -1
- package/dist/components/date-picker/index.d.vue.ts +1 -1
- package/dist/components/date-picker/index.vue +4 -4
- package/dist/components/date-picker/types.d.ts +1 -1
- package/dist/components/description/index.vue +1 -1
- package/dist/components/drawer/index.d.vue.ts +10 -10
- package/dist/components/drawer/index.vue +36 -27
- package/dist/components/drawer/types.d.ts +2 -2
- package/dist/components/effort-slider/index.vue +12 -18
- package/dist/components/effort-slider/types.d.ts +1 -1
- package/dist/components/ellipsis-text/index.d.vue.ts +2 -2
- package/dist/components/ellipsis-text/index.vue +76 -76
- package/dist/components/error/index.vue +2 -2
- package/dist/components/error/types.d.ts +1 -1
- package/dist/components/fader/index.vue +2 -2
- package/dist/components/fader/types.d.ts +1 -1
- package/dist/components/gauge/index.vue +2 -2
- package/dist/components/gauge/types.d.ts +1 -1
- package/dist/components/grid/types.d.ts +1 -1
- package/dist/components/grid-item/types.d.ts +1 -1
- package/dist/components/hint/index.d.vue.ts +32 -0
- package/dist/components/hint/index.vue +239 -0
- package/dist/components/hint/types.d.ts +17 -0
- package/dist/components/hold-button/index.d.vue.ts +4 -4
- package/dist/components/hold-button/index.vue +10 -10
- 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 +6 -0
- package/dist/components/index.js +6 -0
- package/dist/components/input/index.d.vue.ts +1 -1
- package/dist/components/input/index.vue +19 -11
- package/dist/components/input/types.d.ts +1 -1
- package/dist/components/intersection-observer/index.vue +3 -3
- package/dist/components/kbd/index.vue +3 -3
- package/dist/components/kbd/types.d.ts +1 -1
- package/dist/components/link-button/index.d.vue.ts +5 -5
- package/dist/components/list/index.d.vue.ts +4 -4
- package/dist/components/list/index.vue +126 -47
- package/dist/components/list/types.d.ts +1 -1
- package/dist/components/list-group/index.vue +7 -1
- package/dist/components/list-group/types.d.ts +1 -1
- package/dist/components/list-item/index.d.vue.ts +2 -2
- package/dist/components/list-item/index.vue +42 -11
- package/dist/components/loading-bar/index.vue +5 -5
- package/dist/components/marching-ants/index.d.vue.ts +2 -2
- package/dist/components/marching-ants/index.vue +56 -56
- package/dist/components/marching-ants/types.d.ts +1 -1
- package/dist/components/marquee/index.d.vue.ts +6 -6
- package/dist/components/marquee/index.vue +22 -18
- package/dist/components/marquee/types.d.ts +1 -1
- package/dist/components/material/index.d.vue.ts +3 -3
- package/dist/components/mention/index.d.vue.ts +4 -4
- package/dist/components/mention/index.vue +68 -68
- package/dist/components/menu/index.d.vue.ts +4 -4
- package/dist/components/menu/index.vue +10 -10
- package/dist/components/menu/types.d.ts +1 -1
- package/dist/components/message/index.d.vue.ts +1 -1
- package/dist/components/message/index.vue +20 -26
- package/dist/components/message/types.d.ts +1 -1
- package/dist/components/message-item/index.vue +2 -6
- package/dist/components/modal/index.d.vue.ts +9 -9
- package/dist/components/modal/index.vue +32 -23
- package/dist/components/modal/types.d.ts +2 -2
- package/dist/components/noise-background/types.d.ts +1 -1
- package/dist/components/note/index.vue +7 -3
- package/dist/components/note/types.d.ts +2 -1
- package/dist/components/number-input/index.d.vue.ts +11 -6
- package/dist/components/number-input/index.vue +61 -20
- package/dist/components/number-input/types.d.ts +2 -1
- package/dist/components/overlay/index.d.vue.ts +2 -4
- package/dist/components/overlay/index.vue +12 -70
- package/dist/components/overlay/types.d.ts +1 -4
- package/dist/components/page-number/index.vue +30 -29
- package/dist/components/page-number/types.d.ts +1 -1
- package/dist/components/pagination/index.vue +4 -4
- package/dist/components/pin-input/index.vue +11 -7
- package/dist/components/pin-input/types.d.ts +1 -1
- package/dist/components/popover/index.vue +72 -39
- package/dist/components/popover/types.d.ts +4 -1
- package/dist/components/progress/index.d.vue.ts +2 -2
- package/dist/components/progress/index.vue +12 -12
- package/dist/components/progress/types.d.ts +1 -1
- package/dist/components/project-banner/index.vue +22 -9
- package/dist/components/project-banner/types.d.ts +1 -1
- package/dist/components/questionnaire/index.vue +15 -15
- package/dist/components/radio/index.vue +1 -1
- 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/types.d.ts +1 -1
- package/dist/components/rating/index.vue +28 -28
- package/dist/components/rating/types.d.ts +1 -1
- package/dist/components/resizable/index.d.vue.ts +6 -0
- package/dist/components/resizable/index.vue +320 -236
- package/dist/components/resizable/types.d.ts +8 -10
- package/dist/components/reveal/index.d.vue.ts +3 -3
- package/dist/components/reveal/index.vue +4 -4
- package/dist/components/reveal/types.d.ts +1 -1
- package/dist/components/rolling-number/index.d.vue.ts +2 -2
- package/dist/components/rolling-number/index.vue +15 -15
- package/dist/components/scalable-text/index.vue +9 -9
- package/dist/components/scroll-text/index.d.vue.ts +3 -3
- package/dist/components/scroll-text/index.vue +6 -6
- package/dist/components/scroll-text/types.d.ts +1 -1
- package/dist/components/scrollable/types.d.ts +2 -1
- package/dist/components/search-input/index.d.vue.ts +5 -5
- package/dist/components/search-input/index.vue +2 -1
- package/dist/components/select/index.d.vue.ts +12 -9
- package/dist/components/select/index.vue +167 -42
- package/dist/components/select/types.d.ts +3 -1
- package/dist/components/separator/index.d.vue.ts +1 -1
- package/dist/components/separator/types.d.ts +1 -1
- package/dist/components/skeleton/index.vue +11 -11
- package/dist/components/skeleton/types.d.ts +1 -1
- package/dist/components/slider/index.d.vue.ts +1 -1
- package/dist/components/slider/index.vue +1 -1
- package/dist/components/slider/types.d.ts +1 -1
- package/dist/components/snippet/index.d.vue.ts +3 -3
- package/dist/components/snippet/index.vue +7 -5
- package/dist/components/snippet/types.d.ts +1 -1
- package/dist/components/spinner/index.vue +5 -1
- package/dist/components/spinner-dots/index.d.vue.ts +1 -1
- package/dist/components/split-button/index.d.vue.ts +5 -5
- package/dist/components/split-button/types.d.ts +1 -1
- package/dist/components/stack/index.d.vue.ts +3 -3
- package/dist/components/stack/index.vue +28 -29
- package/dist/components/stack/types.d.ts +1 -1
- package/dist/components/status-dot/types.d.ts +1 -1
- package/dist/components/steps/index.d.vue.ts +2 -2
- package/dist/components/steps/index.vue +6 -6
- package/dist/components/steps/types.d.ts +1 -1
- package/dist/components/stick-to-bottom/types.d.ts +1 -1
- package/dist/components/swipe-cell/index.d.vue.ts +6 -6
- package/dist/components/swipe-cell/index.vue +64 -64
- package/dist/components/swipe-cell/types.d.ts +2 -1
- package/dist/components/switch/index.vue +2 -2
- package/dist/components/switch/types.d.ts +1 -1
- package/dist/components/switch-item/index.vue +1 -1
- package/dist/components/switch-item/types.d.ts +1 -1
- package/dist/components/tabs/index.d.vue.ts +1 -1
- package/dist/components/tabs/index.vue +49 -52
- package/dist/components/tabs/types.d.ts +1 -1
- package/dist/components/teleport/index.vue +22 -24
- package/dist/components/text/index.d.vue.ts +3 -3
- package/dist/components/text/index.vue +11 -11
- package/dist/components/text/types.d.ts +1 -1
- package/dist/components/textarea/index.vue +2 -1
- package/dist/components/textarea/types.d.ts +1 -1
- package/dist/components/theme-switcher/index.d.vue.ts +3 -2
- package/dist/components/theme-switcher/index.vue +15 -7
- package/dist/components/theme-switcher/types.d.ts +2 -2
- package/dist/components/time-ago/index.d.vue.ts +6 -0
- package/dist/components/time-ago/index.vue +143 -0
- package/dist/components/time-ago/types.d.ts +4 -0
- package/dist/components/time-picker/index.d.vue.ts +1 -1
- package/dist/components/time-picker/index.vue +11 -11
- package/dist/components/time-picker/types.d.ts +1 -1
- package/dist/components/toc/index.d.vue.ts +2 -2
- package/dist/components/toc/index.vue +1 -1
- package/dist/components/todo-list/index.d.vue.ts +5 -5
- package/dist/components/todo-list/index.vue +15 -15
- package/dist/components/todo-list/types.d.ts +1 -1
- package/dist/components/toggle/index.vue +4 -4
- package/dist/components/toggle/types.d.ts +1 -1
- package/dist/components/toggle-button/index.vue +24 -15
- package/dist/components/toggle-button/types.d.ts +4 -3
- package/dist/components/toggle-button-group/index.d.vue.ts +3 -3
- package/dist/components/toggle-button-group/index.vue +3 -2
- package/dist/components/toggle-button-group/types.d.ts +4 -4
- package/dist/components/tool-call/index.vue +5 -5
- package/dist/components/tooltip/index.d.vue.ts +4 -5
- package/dist/components/tooltip/index.vue +4 -49
- package/dist/components/tooltip/types.d.ts +3 -7
- package/dist/components/tour/index.d.vue.ts +33 -0
- package/dist/components/tour/index.vue +302 -0
- package/dist/components/tour/types.d.ts +29 -0
- package/dist/components/tree/index.d.vue.ts +33 -34
- package/dist/components/tree/index.vue +385 -293
- package/dist/components/tree/types.d.ts +42 -13
- package/dist/components/virtual-list/index.d.vue.ts +4 -4
- 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-list-keyboard-controller.js +9 -10
- package/dist/composables/_internal/use-list-rows.d.ts +4 -0
- package/dist/composables/_internal/use-list-rows.js +12 -4
- package/dist/composables/_internal/use-list-selection.d.ts +1 -1
- package/dist/composables/_internal/use-lock-scroll.d.ts +8 -1
- package/dist/composables/_internal/use-lock-scroll.js +39 -35
- package/dist/composables/_internal/use-mention-editor.js +1 -1
- package/dist/composables/_internal/use-message-group.d.ts +22 -0
- package/dist/composables/_internal/use-message-group.js +143 -0
- package/dist/composables/_internal/use-overlay-dialog.js +1 -3
- package/dist/composables/_internal/use-overlay-manager.d.ts +4 -2
- package/dist/composables/_internal/use-overlay-manager.js +53 -10
- package/dist/composables/_internal/use-popover-responsive.js +9 -12
- package/dist/composables/_internal/use-swipe-gesture.d.ts +2 -2
- package/dist/composables/_internal/use-swipe-gesture.js +5 -4
- package/dist/composables/_internal/use-tailwind-variant.js +1 -1
- package/dist/composables/_internal/use-tour-target.d.ts +29 -0
- package/dist/composables/_internal/use-tour-target.js +201 -0
- package/dist/composables/_internal/use-tree.d.ts +103 -0
- package/dist/composables/_internal/use-tree.js +676 -0
- package/dist/composables/_internal/use-word-limit.d.ts +1 -1
- package/dist/composables/index.d.ts +1 -0
- package/dist/composables/index.js +1 -0
- package/dist/composables/use-color-scheme.d.ts +1 -1
- package/dist/composables/use-color-scheme.js +7 -6
- package/dist/composables/use-delay-destroy.d.ts +1 -1
- package/dist/composables/use-document-hidden.d.ts +1 -1
- package/dist/composables/use-intersection-observer.d.ts +1 -1
- package/dist/composables/use-intersection-observer.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/{_internal/use-motion-reduce.js → use-motion-reduce.js} +2 -2
- package/dist/composables/use-mutation-observer.d.ts +1 -1
- package/dist/composables/use-mutation-observer.js +1 -1
- 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/composables/use-resize-observer.d.ts +1 -1
- package/dist/composables/use-resize-observer.js +1 -1
- package/dist/composables/use-view-transition.js +1 -0
- package/dist/composables/use-virtual-list.d.ts +1 -1
- package/dist/constants/size.d.ts +1 -0
- package/dist/constants/size.js +7 -6
- package/dist/constants/tooltip-variants.d.ts +28 -0
- package/dist/constants/tooltip-variants.js +27 -0
- package/dist/contexts/avatar.js +1 -1
- package/dist/contexts/breadcrumb.js +1 -1
- package/dist/contexts/button.js +1 -1
- package/dist/contexts/checkbox.js +1 -1
- package/dist/contexts/choicebox.js +1 -1
- package/dist/contexts/collapse.js +1 -1
- package/dist/contexts/config-provider.js +1 -1
- package/dist/contexts/list.js +1 -1
- package/dist/contexts/radio.js +1 -1
- package/dist/contexts/switch.js +1 -1
- package/dist/contexts/toggle-button.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/locales/en-us.d.ts +39 -0
- package/dist/locales/en-us.js +24 -0
- package/dist/locales/zh-cn.d.ts +39 -0
- package/dist/locales/zh-cn.js +24 -0
- package/dist/styles/styles.css +1 -1
- package/dist/styles/tw.css +55 -37
- package/dist/utils/_internal/cn-tables.d.ts +27 -0
- package/dist/utils/_internal/cn-tables.js +131 -0
- package/dist/utils/{context.js → _internal/context.js} +1 -1
- package/dist/utils/{observer.d.ts → _internal/observer.d.ts} +1 -1
- package/dist/utils/{observer.js → _internal/observer.js} +4 -4
- package/dist/{components/swipe-cell/instances.d.ts → utils/_internal/swipe-cell-instances.d.ts} +1 -1
- package/dist/utils/cn.d.ts +1 -0
- package/dist/utils/cn.js +3 -0
- package/dist/utils/event.d.ts +2 -1
- package/dist/utils/event.js +3 -0
- package/package.json +29 -51
- package/volar.d.ts +6 -0
- package/dist/components/message/composables/use-group-expand.d.ts +0 -13
- package/dist/components/message/composables/use-group-expand.js +0 -50
- package/dist/components/message/composables/use-message-timer.d.ts +0 -9
- package/dist/components/message/composables/use-message-timer.js +0 -62
- package/dist/components/message/composables/use-promise-message.d.ts +0 -4
- package/dist/components/message/composables/use-promise-message.js +0 -49
- package/dist/components/resizable/utils.d.ts +0 -4
- package/dist/components/resizable/utils.js +0 -10
- package/dist/composables/_internal/use-tree-drag.d.ts +0 -23
- package/dist/composables/_internal/use-tree-drag.js +0 -196
- package/dist/composables/_internal/use-tree-move.d.ts +0 -20
- package/dist/composables/_internal/use-tree-move.js +0 -96
- package/dist/composables/_internal/use-tree-rows.d.ts +0 -46
- package/dist/composables/_internal/use-tree-rows.js +0 -101
- package/dist/composables/_internal/use-tree-selection.d.ts +0 -22
- package/dist/composables/_internal/use-tree-selection.js +0 -87
- package/dist/styles/source.css +0 -675
- package/dist/types/shared/index.d.ts +0 -2
- /package/dist/composables/{_internal/use-motion-reduce.d.ts → use-motion-reduce.d.ts} +0 -0
- /package/dist/utils/{context.d.ts → _internal/context.d.ts} +0 -0
- /package/dist/utils/{mention-html.d.ts → _internal/mention-html.d.ts} +0 -0
- /package/dist/utils/{mention-html.js → _internal/mention-html.js} +0 -0
- /package/dist/{components/swipe-cell/instances.js → utils/_internal/swipe-cell-instances.js} +0 -0
|
@@ -56,7 +56,6 @@ const emits = defineEmits([
|
|
|
56
56
|
"change",
|
|
57
57
|
"update:modelValue"
|
|
58
58
|
]);
|
|
59
|
-
const configProvider = useConfigProvider();
|
|
60
59
|
const today = dayjs();
|
|
61
60
|
const todayKey = today.format("YYYY-MM-DD");
|
|
62
61
|
const uncontrolledValue = shallowRef(props.defaultValue);
|
|
@@ -67,10 +66,6 @@ const selectedValue = computed(() => {
|
|
|
67
66
|
const selectedDateKey = computed(() => {
|
|
68
67
|
return isNil(selectedValue.value) ? null : dayjs(selectedValue.value).format("YYYY-MM-DD");
|
|
69
68
|
});
|
|
70
|
-
const weekDays = computed(() => {
|
|
71
|
-
const days = configProvider.locale.date.day;
|
|
72
|
-
return [...days.slice(1), days[0]];
|
|
73
|
-
});
|
|
74
69
|
const calendarDays = computed(() => {
|
|
75
70
|
const firstDayOfMonth = panelDate.value.startOf("month");
|
|
76
71
|
const startOffset = (firstDayOfMonth.day() + 6) % 7;
|
|
@@ -96,6 +91,11 @@ const panelInfo = computed(() => ({
|
|
|
96
91
|
year: panelDate.value.year(),
|
|
97
92
|
month: panelDate.value.month() + 1
|
|
98
93
|
}));
|
|
94
|
+
const configProvider = useConfigProvider();
|
|
95
|
+
const weekDays = computed(() => {
|
|
96
|
+
const days = configProvider.locale.date.day;
|
|
97
|
+
return [...days.slice(1), days[0]];
|
|
98
|
+
});
|
|
99
99
|
function emitPanelChange() {
|
|
100
100
|
emits("panel-change", panelInfo.value);
|
|
101
101
|
}
|
|
@@ -168,7 +168,7 @@ watch(() => props.modelValue, (value) => {
|
|
|
168
168
|
</PButton>
|
|
169
169
|
<PButton
|
|
170
170
|
icon
|
|
171
|
-
size="
|
|
171
|
+
size="xs"
|
|
172
172
|
variant="ghost"
|
|
173
173
|
class="text-foreground-secondary"
|
|
174
174
|
aria-label="Previous month"
|
|
@@ -177,13 +177,13 @@ watch(() => props.modelValue, (value) => {
|
|
|
177
177
|
<ChevronRightIcon class="size-4 rotate-180" aria-hidden="true" />
|
|
178
178
|
</PButton>
|
|
179
179
|
|
|
180
|
-
<PButton size="
|
|
180
|
+
<PButton size="xs" class="px-0" @click="selectToday">
|
|
181
181
|
{{ configProvider.locale.date.today }}
|
|
182
182
|
</PButton>
|
|
183
183
|
|
|
184
184
|
<PButton
|
|
185
185
|
icon
|
|
186
|
-
size="
|
|
186
|
+
size="xs"
|
|
187
187
|
variant="ghost"
|
|
188
188
|
class="text-foreground-secondary"
|
|
189
189
|
aria-label="Next month"
|
|
@@ -193,7 +193,7 @@ watch(() => props.modelValue, (value) => {
|
|
|
193
193
|
</PButton>
|
|
194
194
|
<PButton
|
|
195
195
|
icon
|
|
196
|
-
size="
|
|
196
|
+
size="xs"
|
|
197
197
|
variant="ghost"
|
|
198
198
|
class="text-foreground-secondary"
|
|
199
199
|
aria-label="Next year"
|
|
@@ -212,7 +212,7 @@ watch(() => props.modelValue, (value) => {
|
|
|
212
212
|
v-for="weekDay in weekDays"
|
|
213
213
|
:key="weekDay"
|
|
214
214
|
class="pxd-calendar--grid-head text-xs font-medium text-gray-800"
|
|
215
|
-
:class="compact ? '
|
|
215
|
+
:class="compact ? 'py-1 text-center' : 'p-2 border-r border-b text-right'"
|
|
216
216
|
role="columnheader"
|
|
217
217
|
>
|
|
218
218
|
{{ weekDay }}
|
|
@@ -20,7 +20,7 @@ const { attrs, classes } = useTailwindVariant({
|
|
|
20
20
|
base: "pxd-card border bg-background-100",
|
|
21
21
|
variants: {
|
|
22
22
|
shape: {
|
|
23
|
-
default: "rounded-
|
|
23
|
+
default: "rounded-lg",
|
|
24
24
|
square: "rounded-none",
|
|
25
25
|
rounded: "rounded-xl"
|
|
26
26
|
},
|
|
@@ -37,7 +37,7 @@ const { attrs, classes } = useTailwindVariant({
|
|
|
37
37
|
<div v-if="$slots.header" class="pxd-card--header text-trim-both">
|
|
38
38
|
<slot name="header" />
|
|
39
39
|
</div>
|
|
40
|
-
<div class="pxd-card--content p-
|
|
40
|
+
<div class="pxd-card--content p-3 text-trim-both">
|
|
41
41
|
<slot />
|
|
42
42
|
</div>
|
|
43
43
|
<div v-if="$slots.footer" class="pxd-card--footer text-trim-both">
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import type { CarouselProps } from './types';
|
|
2
|
-
declare var
|
|
2
|
+
declare var __VLS_2: {
|
|
3
3
|
item: import("./types").CarouselOption;
|
|
4
4
|
index: number;
|
|
5
|
-
},
|
|
5
|
+
}, __VLS_4: {
|
|
6
6
|
current: number;
|
|
7
7
|
total: number;
|
|
8
8
|
};
|
|
9
9
|
type __VLS_Slots = {} & {
|
|
10
|
-
item?: (props: typeof
|
|
10
|
+
item?: (props: typeof __VLS_2) => any;
|
|
11
11
|
} & {
|
|
12
|
-
indicator?: (props: typeof
|
|
12
|
+
indicator?: (props: typeof __VLS_4) => any;
|
|
13
13
|
};
|
|
14
14
|
declare const __VLS_base: import("vue").DefineComponent<CarouselProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
15
15
|
change: (index: number) => any;
|
|
16
16
|
}, string, import("vue").PublicProps, Readonly<CarouselProps> & Readonly<{
|
|
17
17
|
onChange?: ((index: number) => any) | undefined;
|
|
18
18
|
}>, {
|
|
19
|
-
height:
|
|
19
|
+
height: string | number;
|
|
20
20
|
options: import("./types").CarouselOption[];
|
|
21
21
|
index: number;
|
|
22
22
|
loop: boolean;
|
|
@@ -25,8 +25,7 @@ declare const __VLS_base: import("vue").DefineComponent<CarouselProps, {}, {}, {
|
|
|
25
25
|
interval: number;
|
|
26
26
|
indicator: boolean;
|
|
27
27
|
direction: import("../../types/shared/props.js").ComponentDirection;
|
|
28
|
-
|
|
29
|
-
indicatorPosition: import("../../types/shared/props.js").BasePosition | "center";
|
|
28
|
+
indicatorPosition: "center" | import("../../types/shared/props.js").BasePosition;
|
|
30
29
|
pauseOnHover: boolean;
|
|
31
30
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
32
31
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -49,11 +49,6 @@ const props = defineProps({
|
|
|
49
49
|
required: false,
|
|
50
50
|
default: "horizontal"
|
|
51
51
|
},
|
|
52
|
-
indicatorType: {
|
|
53
|
-
type: String,
|
|
54
|
-
required: false,
|
|
55
|
-
default: "dot"
|
|
56
|
-
},
|
|
57
52
|
indicatorPosition: {
|
|
58
53
|
type: String,
|
|
59
54
|
required: false,
|
|
@@ -78,12 +73,12 @@ const emits = defineEmits(["change"]);
|
|
|
78
73
|
let isToggling = false;
|
|
79
74
|
let pendingDelta = null;
|
|
80
75
|
let autoPlayTimerId = null;
|
|
81
|
-
let isPointerEntering = false;
|
|
82
76
|
let maxDrag = 0;
|
|
83
|
-
const slots = useSlots();
|
|
84
77
|
const sliderRef = shallowRef();
|
|
85
78
|
const virtualIndex = shallowRef(props.index);
|
|
86
79
|
const gestureMoveOffset = shallowRef(0);
|
|
80
|
+
const isAutoPlayPaused = shallowRef(false);
|
|
81
|
+
const progressKey = shallowRef(0);
|
|
87
82
|
const slideCount = computed(() => props.options.length);
|
|
88
83
|
const displayIndex = computed(() => {
|
|
89
84
|
const length = slideCount.value;
|
|
@@ -103,7 +98,8 @@ const computedStyle = computed(() => {
|
|
|
103
98
|
const rootStyle = computed(() => {
|
|
104
99
|
return {
|
|
105
100
|
height: getCssUnitValue(props.height),
|
|
106
|
-
"--carousel-item-count": slideCount.value
|
|
101
|
+
"--carousel-item-count": slideCount.value,
|
|
102
|
+
"--carousel-progress-duration": `${props.interval}ms`
|
|
107
103
|
};
|
|
108
104
|
});
|
|
109
105
|
const loopPlacement = computed(() => {
|
|
@@ -120,6 +116,7 @@ const loopPlacement = computed(() => {
|
|
|
120
116
|
}
|
|
121
117
|
return "none";
|
|
122
118
|
});
|
|
119
|
+
const slots = useSlots();
|
|
123
120
|
useSwipeGesture(sliderRef, {
|
|
124
121
|
axis: () => props.direction,
|
|
125
122
|
onPress: ({ size }) => {
|
|
@@ -224,21 +221,22 @@ function clearAutoPlayTimer() {
|
|
|
224
221
|
}
|
|
225
222
|
function restartAutoPlay() {
|
|
226
223
|
clearAutoPlayTimer();
|
|
227
|
-
if (!props.autoplay ||
|
|
224
|
+
if (!props.autoplay || isAutoPlayPaused.value) {
|
|
228
225
|
return;
|
|
229
226
|
}
|
|
227
|
+
progressKey.value++;
|
|
230
228
|
autoPlayTimerId = setTimeout(() => {
|
|
231
229
|
onToggleClick(1);
|
|
232
230
|
}, props.interval);
|
|
233
231
|
}
|
|
234
232
|
function onPointerEnter() {
|
|
235
233
|
if (props.pauseOnHover) {
|
|
236
|
-
|
|
234
|
+
isAutoPlayPaused.value = true;
|
|
237
235
|
clearAutoPlayTimer();
|
|
238
236
|
}
|
|
239
237
|
}
|
|
240
238
|
function onPointerLeave() {
|
|
241
|
-
|
|
239
|
+
isAutoPlayPaused.value = false;
|
|
242
240
|
restartAutoPlay();
|
|
243
241
|
}
|
|
244
242
|
function onIndicatorClick(ev) {
|
|
@@ -267,7 +265,8 @@ onBeforeUnmount(() => {
|
|
|
267
265
|
data-carousel
|
|
268
266
|
v-bind="$attrs"
|
|
269
267
|
:data-orientation="direction"
|
|
270
|
-
:data-
|
|
268
|
+
:data-autoplay="autoplay"
|
|
269
|
+
:data-autoplay-paused="isAutoPlayPaused || void 0"
|
|
271
270
|
:data-indicator-position="indicatorPosition"
|
|
272
271
|
:data-loop-placement="loopPlacement"
|
|
273
272
|
class="pxd-carousel group relative w-full touch-none overflow-hidden"
|
|
@@ -303,9 +302,15 @@ onBeforeUnmount(() => {
|
|
|
303
302
|
v-for="(_, i) in slideCount"
|
|
304
303
|
:key="i"
|
|
305
304
|
:data-index="i"
|
|
306
|
-
class="pxd-carousel--indicator-item
|
|
307
|
-
:class="
|
|
308
|
-
|
|
305
|
+
class="pxd-carousel--indicator-item h-2 relative cursor-pointer appearance-none rounded-full bg-gray-alpha-200 font-inherit self-focus-ring outline-none hover:bg-gray-alpha-400 motion-safe:transition-[width,background-color]"
|
|
306
|
+
:class="i === displayIndex ? 'w-8' : 'w-2'"
|
|
307
|
+
>
|
|
308
|
+
<span
|
|
309
|
+
v-if="i === displayIndex"
|
|
310
|
+
:key="progressKey"
|
|
311
|
+
class="pxd-carousel--indicator-progress block h-full rounded-full bg-primary"
|
|
312
|
+
/>
|
|
313
|
+
</button>
|
|
309
314
|
</slot>
|
|
310
315
|
</div>
|
|
311
316
|
|
|
@@ -317,7 +322,7 @@ onBeforeUnmount(() => {
|
|
|
317
322
|
class="pxd-carousel--prev-btn p-1.5 pointer-events-auto cursor-pointer appearance-none rounded-md bg-gray-alpha-100 font-inherit text-foreground-secondary self-focus-ring outline-none enabled:hover:bg-background-hover enabled:active:bg-background-active disabled:cursor-not-allowed disabled:opacity-50 motion-safe:transition-colors"
|
|
318
323
|
@click="onToggleClick(-1)"
|
|
319
324
|
>
|
|
320
|
-
<ChevronRightIcon class="
|
|
325
|
+
<ChevronRightIcon class="rotate-180" />
|
|
321
326
|
</button>
|
|
322
327
|
|
|
323
328
|
<button
|
|
@@ -327,12 +332,12 @@ onBeforeUnmount(() => {
|
|
|
327
332
|
class="pxd-carousel--next-btn p-1.5 pointer-events-auto cursor-pointer appearance-none rounded-md bg-gray-alpha-100 font-inherit text-foreground-secondary self-focus-ring outline-none enabled:hover:bg-background-hover enabled:active:bg-background-active disabled:cursor-not-allowed disabled:opacity-50 motion-safe:transition-colors"
|
|
328
333
|
@click="onToggleClick(1)"
|
|
329
334
|
>
|
|
330
|
-
<ChevronRightIcon
|
|
335
|
+
<ChevronRightIcon />
|
|
331
336
|
</button>
|
|
332
337
|
</div>
|
|
333
338
|
</div>
|
|
334
339
|
</template>
|
|
335
340
|
|
|
336
341
|
<style>
|
|
337
|
-
.pxd-carousel[data-indicator-
|
|
342
|
+
.pxd-carousel[data-indicator-position=top] .pxd-carousel--indicator{left:.75rem;top:.5rem}.pxd-carousel[data-indicator-position=top] .pxd-carousel--toggler{right:.5rem;top:.5rem}.pxd-carousel[data-indicator-position=bottom] .pxd-carousel--indicator{bottom:.5rem;left:.75rem}.pxd-carousel[data-indicator-position=bottom] .pxd-carousel--toggler{bottom:.5rem;right:.5rem}.pxd-carousel[data-indicator-position=left] .pxd-carousel--indicator{left:.5rem;top:.75rem}.pxd-carousel[data-indicator-position=left] .pxd-carousel--toggler{bottom:.5rem;left:.5rem}.pxd-carousel[data-indicator-position=right] .pxd-carousel--indicator{right:.5rem;top:.75rem}.pxd-carousel[data-indicator-position=right] .pxd-carousel--toggler{bottom:.5rem;right:.5rem}.pxd-carousel[data-indicator-position=center] .pxd-carousel--indicator{bottom:.5rem;left:50%;transform:translateX(-50%)}.pxd-carousel[data-indicator-position=center] .pxd-carousel--toggler{justify-content:space-between;left:0;padding-inline:1rem;top:50%;transform:translateY(-50%);width:100%}.pxd-carousel[data-indicator-position=left] .pxd-carousel--indicator,.pxd-carousel[data-indicator-position=left] .pxd-carousel--toggler,.pxd-carousel[data-indicator-position=right] .pxd-carousel--indicator,.pxd-carousel[data-indicator-position=right] .pxd-carousel--toggler{flex-direction:column}.pxd-carousel[data-orientation=horizontal] .pxd-carousel--slider{display:flex}.pxd-carousel[data-loop-placement=end] .pxd-carousel-item:first-child{transform:translateX(calc(var(--carousel-item-count)*100%))}.pxd-carousel[data-loop-placement=start] .pxd-carousel-item:last-child{transform:translateX(calc(var(--carousel-item-count)*-100%))}.pxd-carousel[data-orientation=vertical][data-loop-placement=end] .pxd-carousel-item:first-child{transform:translateY(calc(var(--carousel-item-count)*100%))}.pxd-carousel[data-orientation=vertical][data-loop-placement=start] .pxd-carousel-item:last-child{transform:translateY(calc(var(--carousel-item-count)*-100%))}.pxd-carousel[data-orientation=vertical] .pxd-carousel--next-btn,.pxd-carousel[data-orientation=vertical] .pxd-carousel--prev-btn{transform:rotate(90deg)}.pxd-carousel[data-autoplay=false] .pxd-carousel--indicator-progress{animation:none;width:100%}.pxd-carousel[data-autoplay-paused] .pxd-carousel--indicator-progress,.pxd-carousel[data-autoplay=false] .pxd-carousel--indicator-progress{animation-play-state:paused}.pxd-carousel--indicator-item:before{content:"";inset:-.25rem;position:absolute}.pxd-carousel--indicator-progress{animation:pxd-carousel-indicator-progress var(--carousel-progress-duration) linear forwards;width:0}@keyframes pxd-carousel-indicator-progress{0%{width:0}to{width:100%}}
|
|
338
343
|
</style>
|
|
@@ -3,7 +3,7 @@ import type {
|
|
|
3
3
|
ComponentDirection,
|
|
4
4
|
ComponentLabel,
|
|
5
5
|
ComponentValue,
|
|
6
|
-
} from '../../types/shared'
|
|
6
|
+
} from '../../types/shared/props'
|
|
7
7
|
|
|
8
8
|
export interface CarouselOption {
|
|
9
9
|
/** Rendered as the slide content when no `item` slot is provided. */
|
|
@@ -22,7 +22,6 @@ export interface CarouselProps {
|
|
|
22
22
|
interval?: number
|
|
23
23
|
indicator?: boolean
|
|
24
24
|
direction?: ComponentDirection
|
|
25
|
-
indicatorType?: 'dot' | 'line'
|
|
26
25
|
indicatorPosition?: BasePosition | 'center'
|
|
27
26
|
pauseOnHover?: boolean
|
|
28
27
|
toggleOnWheel?: boolean
|
|
@@ -54,6 +54,7 @@ const props = defineProps({
|
|
|
54
54
|
const emits = defineEmits(["change", "update:modelValue"]);
|
|
55
55
|
const uniqueId = getUniqueId();
|
|
56
56
|
const checkboxGroupContext = useCheckboxGroupContext();
|
|
57
|
+
const isDisabled = computed(() => props.disabled || checkboxGroupContext?.props.disabled || false);
|
|
57
58
|
const modelValue = useModelValue(checkboxGroupContext?.props ?? props, checkboxGroupContext?.emits ?? emits);
|
|
58
59
|
const isSelected = computed(() => {
|
|
59
60
|
if (Array.isArray(modelValue.value)) {
|
|
@@ -64,9 +65,8 @@ const isSelected = computed(() => {
|
|
|
64
65
|
}
|
|
65
66
|
return modelValue.value === props.value;
|
|
66
67
|
});
|
|
67
|
-
const isDisabled = computed(() => props.disabled || checkboxGroupContext?.props.disabled || false);
|
|
68
68
|
const { classes } = useTailwindVariant({
|
|
69
|
-
base: "pxd-checkbox--inner size-4 p-0.5
|
|
69
|
+
base: "pxd-checkbox--inner size-4 p-0.5 inline-flex shrink-0 transform-gpu items-center justify-center overflow-hidden border text-primary-foreground peer-focus-ring motion-safe:transition-colors",
|
|
70
70
|
variants: {
|
|
71
71
|
checked: {},
|
|
72
72
|
disabled: {},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CheckboxGroupProps } from './types';
|
|
2
|
-
declare var
|
|
2
|
+
declare var __VLS_7: {};
|
|
3
3
|
type __VLS_Slots = {} & {
|
|
4
|
-
default?: (props: typeof
|
|
4
|
+
default?: (props: typeof __VLS_7) => any;
|
|
5
5
|
};
|
|
6
6
|
declare const __VLS_base: import("vue").DefineComponent<CheckboxGroupProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
7
7
|
change: (args_0: import("./types").CheckboxGroupModelValue[]) => any;
|
|
@@ -4,7 +4,7 @@ type __VLS_Slots = {} & {
|
|
|
4
4
|
default?: (props: typeof __VLS_1) => any;
|
|
5
5
|
};
|
|
6
6
|
declare const __VLS_base: import("vue").DefineComponent<ChipProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ChipProps> & Readonly<{}>, {
|
|
7
|
-
variant: import("../../types/shared/props.js").ComponentVariant
|
|
7
|
+
variant: "secondary" | import("../../types/shared/props.js").ComponentVariant;
|
|
8
8
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
9
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
10
10
|
declare const _default: typeof __VLS_export;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ChoiceboxProps } from './types';
|
|
2
|
-
declare var
|
|
2
|
+
declare var __VLS_7: {};
|
|
3
3
|
type __VLS_Slots = {} & {
|
|
4
|
-
default?: (props: typeof
|
|
4
|
+
default?: (props: typeof __VLS_7) => any;
|
|
5
5
|
};
|
|
6
6
|
declare const __VLS_base: import("vue").DefineComponent<ChoiceboxProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
7
7
|
change: (args_0: NonNullable<import("../../types/shared/props.js").ComponentValue | import("../../types/shared/props.js").ComponentValue[] | undefined>) => any;
|
|
@@ -10,7 +10,7 @@ declare const __VLS_base: import("vue").DefineComponent<ChoiceboxProps, {}, {},
|
|
|
10
10
|
onChange?: ((args_0: NonNullable<import("../../types/shared/props.js").ComponentValue | import("../../types/shared/props.js").ComponentValue[] | undefined>) => any) | undefined;
|
|
11
11
|
"onUpdate:modelValue"?: ((args_0: NonNullable<import("../../types/shared/props.js").ComponentValue | import("../../types/shared/props.js").ComponentValue[] | undefined>) => any) | undefined;
|
|
12
12
|
}>, {
|
|
13
|
-
gap: import("../../types/shared/props.js").ResponsiveValue<
|
|
13
|
+
gap: import("../../types/shared/props.js").ResponsiveValue<string | number>;
|
|
14
14
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
15
15
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
16
16
|
declare const _default: typeof __VLS_export;
|
|
@@ -28,16 +28,22 @@ const props = defineProps({
|
|
|
28
28
|
required: false
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
|
-
const choiceboxGroupContext = useChoiceboxContext();
|
|
32
31
|
const inputId = getUniqueId();
|
|
33
32
|
const internalId = getUniqueId();
|
|
34
|
-
const
|
|
33
|
+
const choiceboxGroupContext = useChoiceboxContext();
|
|
35
34
|
const isMultiple = computed(() => {
|
|
36
35
|
return !!choiceboxGroupContext?.props.multiple;
|
|
37
36
|
});
|
|
38
37
|
const isDisabled = computed(() => {
|
|
39
38
|
return props.disabled || !!choiceboxGroupContext?.props.disabled || false;
|
|
40
39
|
});
|
|
40
|
+
const inputName = computed(() => {
|
|
41
|
+
if (isMultiple.value) {
|
|
42
|
+
return internalId;
|
|
43
|
+
}
|
|
44
|
+
return choiceboxGroupContext?.name || internalId;
|
|
45
|
+
});
|
|
46
|
+
const modelValue = useModelValue(choiceboxGroupContext?.props, choiceboxGroupContext?.emits);
|
|
41
47
|
const isSelected = computed(() => {
|
|
42
48
|
if (isMultiple.value) {
|
|
43
49
|
return toArray(modelValue.value).includes(props.value);
|
|
@@ -63,7 +69,7 @@ const { attrs, classes } = useTailwindVariant({
|
|
|
63
69
|
selected: isSelected.value
|
|
64
70
|
}) });
|
|
65
71
|
const { classes: innerClasses } = useTailwindVariant({
|
|
66
|
-
base: "pxd-choicebox-item--inner size-4 p-0.5
|
|
72
|
+
base: "pxd-choicebox-item--inner size-4 p-0.5 order-2 inline-flex shrink-0 transform-gpu items-center justify-center overflow-hidden border text-primary-foreground peer-focus-ring motion-safe:transition-colors",
|
|
67
73
|
variants: {
|
|
68
74
|
disabled: {},
|
|
69
75
|
multiple: {
|
|
@@ -105,12 +111,6 @@ const { classes: innerClasses } = useTailwindVariant({
|
|
|
105
111
|
selected: isSelected.value
|
|
106
112
|
})
|
|
107
113
|
});
|
|
108
|
-
const inputName = computed(() => {
|
|
109
|
-
if (isMultiple.value) {
|
|
110
|
-
return internalId;
|
|
111
|
-
}
|
|
112
|
-
return choiceboxGroupContext?.name || internalId;
|
|
113
|
-
});
|
|
114
114
|
function onInputChange(event) {
|
|
115
115
|
if (isDisabled.value) {
|
|
116
116
|
return;
|
|
@@ -182,5 +182,5 @@ function onInputChange(event) {
|
|
|
182
182
|
</template>
|
|
183
183
|
|
|
184
184
|
<style>
|
|
185
|
-
.pxd-choicebox-item[aria-selected=true] .pxd-choicebox-item--option{background-color:hsla(var(--primary),.
|
|
185
|
+
.pxd-choicebox-item[aria-selected=true] .pxd-choicebox-item--option{background-color:hsla(var(--primary),.1)}.pxd-choicebox-item[aria-selected=true] .pxd-choicebox-item--description,.pxd-choicebox-item[aria-selected=true] .pxd-choicebox-item--label{color:var(--color-primary)}
|
|
186
186
|
</style>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CodeBlockProps } from './types';
|
|
2
|
+
declare var __VLS_1: {}, __VLS_3: {};
|
|
3
|
+
type __VLS_Slots = {} & {
|
|
4
|
+
header?: (props: typeof __VLS_1) => any;
|
|
5
|
+
} & {
|
|
6
|
+
actions?: (props: typeof __VLS_3) => any;
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_base: import("vue").DefineComponent<CodeBlockProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
9
|
+
copy: (args_0: string) => any;
|
|
10
|
+
}, string, import("vue").PublicProps, Readonly<CodeBlockProps> & Readonly<{
|
|
11
|
+
onCopy?: ((args_0: string) => any) | undefined;
|
|
12
|
+
}>, {
|
|
13
|
+
copyBtn: "hidden" | "always" | "hover";
|
|
14
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
15
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
16
|
+
declare const _default: typeof __VLS_export;
|
|
17
|
+
export default _default;
|
|
18
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
19
|
+
new (): {
|
|
20
|
+
$slots: S;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -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
|
+
}
|