@witchcraft/ui 0.1.3 → 0.2.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -6
- package/dist/module.json +3 -3
- package/dist/module.mjs +15 -12
- package/dist/runtime/build/generateTheme.js +1 -1
- package/dist/runtime/components/Aria/Aria.vue +5 -9
- package/dist/runtime/components/Aria/Aria.vue.d.ts +5 -0
- package/dist/runtime/components/Icon/Icon.vue +10 -30
- package/dist/runtime/components/Icon/Icon.vue.d.ts +21 -0
- package/dist/runtime/components/LibButton/LibButton.vue +51 -72
- package/dist/runtime/components/LibButton/LibButton.vue.d.ts +36 -0
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +43 -74
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue.d.ts +42 -0
- package/dist/runtime/components/LibColorInput/LibColorInput.vue +63 -107
- package/dist/runtime/components/LibColorInput/LibColorInput.vue.d.ts +63 -0
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue +272 -352
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue.d.ts +61 -0
- package/dist/runtime/components/LibColorPicker/utils/safeConvertToHsva.js +1 -1
- package/dist/runtime/components/LibColorPicker/utils/safeConvertToRgba.js +1 -1
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +35 -69
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue.d.ts +22 -0
- package/dist/runtime/components/LibDatePicker/LibDatePicker.vue +17 -38
- package/dist/runtime/components/LibDatePicker/LibDatePicker.vue.d.ts +40 -0
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue +58 -82
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue.d.ts +34 -0
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue +55 -67
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue.d.ts +34 -0
- package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue +7 -8
- package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue.d.ts +22 -0
- package/dist/runtime/components/LibDebug/LibDebug.vue +43 -70
- package/dist/runtime/components/LibDebug/LibDebug.vue.d.ts +32 -0
- package/dist/runtime/components/LibDevOnly/LibDevOnly.vue +18 -31
- package/dist/runtime/components/LibDevOnly/LibDevOnly.vue.d.ts +22 -0
- package/dist/runtime/components/LibFileInput/LibFileInput.vue +116 -156
- package/dist/runtime/components/LibFileInput/LibFileInput.vue.d.ts +43 -0
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +211 -241
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue.d.ts +165 -0
- package/dist/runtime/components/LibLabel/LibLabel.vue +25 -46
- package/dist/runtime/components/LibLabel/LibLabel.vue.d.ts +26 -0
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue +43 -58
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue.d.ts +29 -0
- package/dist/runtime/components/LibNotifications/LibNotification.vue +34 -48
- package/dist/runtime/components/LibNotifications/LibNotification.vue.d.ts +17 -0
- package/dist/runtime/components/LibNotifications/LibNotifications.vue +63 -83
- package/dist/runtime/components/LibNotifications/LibNotifications.vue.d.ts +13 -0
- package/dist/runtime/components/LibPagination/LibPagination.vue +67 -111
- package/dist/runtime/components/LibPagination/LibPagination.vue.d.ts +104 -0
- package/dist/runtime/components/LibPalette/LibPalette.vue +17 -23
- package/dist/runtime/components/LibPalette/LibPalette.vue.d.ts +14 -0
- package/dist/runtime/components/LibPopup/LibPopup.vue +314 -351
- package/dist/runtime/components/LibPopup/LibPopup.vue.d.ts +46 -0
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +65 -91
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue.d.ts +41 -0
- package/dist/runtime/components/LibRecorder/LibRecorder.vue +127 -177
- package/dist/runtime/components/LibRecorder/LibRecorder.vue.d.ts +77 -0
- package/dist/runtime/components/LibRoot/LibRoot.vue +75 -101
- package/dist/runtime/components/LibRoot/LibRoot.vue.d.ts +41 -0
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue +42 -77
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue.d.ts +35 -0
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +118 -156
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue.d.ts +94 -0
- package/dist/runtime/components/LibTable/LibTable.vue +63 -99
- package/dist/runtime/components/LibTable/LibTable.vue.d.ts +45 -0
- package/dist/runtime/components/Template/NAME.vue +15 -36
- package/dist/runtime/components/Template/NAME.vue.d.ts +17 -0
- package/dist/runtime/components/TestControls/TestControls.vue +6 -9
- package/dist/runtime/components/TestControls/TestControls.vue.d.ts +5 -0
- package/dist/runtime/components/shared/props.d.ts +0 -29
- package/dist/runtime/components/shared/props.js +0 -12
- package/dist/runtime/composables/useAccesibilityOutline.js +1 -1
- package/dist/runtime/composables/useDivideAttrs.js +1 -1
- package/dist/runtime/composables/useSuggestions.js +4 -4
- package/dist/runtime/directives/vDetectFlex.js +4 -4
- package/dist/runtime/directives/vExtractRootEl.d.ts +1 -1
- package/dist/runtime/directives/vResizableCols.d.ts +1 -1
- package/dist/runtime/directives/vResizableCols.js +4 -4
- package/dist/runtime/helpers/NotificationHandler.js +6 -6
- package/dist/runtime/helpers/base64ToImg.js +2 -2
- package/dist/runtime/nuxt/plugins/vue-plugin.js +1 -1
- package/dist/runtime/tailwind/themeConvertionOpts.d.ts +1 -1
- package/dist/runtime/theme.d.ts +1 -1
- package/dist/runtime/theme.js +1 -1
- package/dist/runtime/utils/notifyIfError.js +1 -1
- package/dist/runtime/vue/registerComponents.js +1 -1
- package/dist/types.d.mts +2 -6
- package/package.json +68 -90
- package/src/module.ts +19 -12
- package/src/runtime/build/generateTheme.ts +1 -1
- package/src/runtime/components/LibButton/LibButton.stories.ts +1 -1
- package/src/runtime/components/LibButton/LibButton.vue +3 -3
- package/src/runtime/components/LibCheckbox/LibCheckbox.vue +3 -7
- package/src/runtime/components/LibColorPicker/LibColorPicker.vue +6 -4
- package/src/runtime/components/LibColorPicker/utils/safeConvertToHsva.ts +1 -1
- package/src/runtime/components/LibColorPicker/utils/safeConvertToRgba.ts +1 -1
- package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +8 -15
- package/src/runtime/components/LibDatePicker/LibRangeDatePicker.vue +6 -0
- package/src/runtime/components/LibDatePicker/LibSingleDatePicker.vue +6 -0
- package/src/runtime/components/LibDebug/LibDebug.stories.ts +1 -1
- package/src/runtime/components/LibDebug/LibDebug.vue +2 -0
- package/src/runtime/components/LibFileInput/LibFileInput.vue +4 -0
- package/src/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +7 -5
- package/src/runtime/components/LibLabel/LibLabel.vue +2 -3
- package/src/runtime/components/LibMultiValues/LibMultiValues.vue +5 -3
- package/src/runtime/components/LibNotifications/LibNotification.vue +3 -0
- package/src/runtime/components/LibNotifications/LibNotifications.vue +1 -1
- package/src/runtime/components/LibPalette/LibPalette.vue +3 -3
- package/src/runtime/components/LibPopup/LibPopup.vue +2 -2
- package/src/runtime/components/LibProgressBar/LibProgressBar.vue +2 -2
- package/src/runtime/components/LibRecorder/LibRecorder.vue +3 -3
- package/src/runtime/components/LibRoot/LibRoot.vue +3 -2
- package/src/runtime/components/LibSimpleInput/LibSimpleInput.vue +2 -2
- package/src/runtime/components/LibSuggestions/LibSuggestions.vue +2 -2
- package/src/runtime/components/LibTable/LibTable.vue +1 -1
- package/src/runtime/components/Template/NAME.vue +2 -2
- package/src/runtime/components/shared/props.ts +8 -12
- package/src/runtime/composables/useAccesibilityOutline.ts +1 -1
- package/src/runtime/composables/useDivideAttrs.ts +1 -1
- package/src/runtime/composables/useSuggestions.ts +4 -4
- package/src/runtime/directives/vDetectFlex.ts +4 -4
- package/src/runtime/directives/vExtractRootEl.ts +1 -1
- package/src/runtime/directives/vResizableCols.ts +5 -5
- package/src/runtime/helpers/NotificationHandler.ts +6 -6
- package/src/runtime/nuxt/plugins/vue-plugin.ts +1 -1
- package/src/runtime/tailwind/themeConvertionOpts.ts +1 -1
- package/src/runtime/theme.ts +2 -2
- package/src/runtime/utils/notifyIfError.ts +1 -1
- package/src/runtime/vue/registerComponents.ts +1 -1
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -36
- package/dist/runtime/components/Focus.stories.d.ts +0 -11
- package/dist/runtime/components/Focus.stories.js +0 -53
- package/dist/runtime/components/LibButton/LibButton.stories.d.ts +0 -12
- package/dist/runtime/components/LibButton/LibButton.stories.js +0 -94
- package/dist/runtime/components/LibCheckbox/LibCheckbox.stories.d.ts +0 -14
- package/dist/runtime/components/LibCheckbox/LibCheckbox.stories.js +0 -29
- package/dist/runtime/components/LibColorInput/LibColorInput.stories.d.ts +0 -7
- package/dist/runtime/components/LibColorInput/LibColorInput.stories.js +0 -58
- package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.d.ts +0 -9
- package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.js +0 -68
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.d.ts +0 -7
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.js +0 -36
- package/dist/runtime/components/LibDatePicker/LibDatePicker.stories.d.ts +0 -11
- package/dist/runtime/components/LibDatePicker/LibDatePicker.stories.js +0 -98
- package/dist/runtime/components/LibDebug/LibDebug.stories.d.ts +0 -9
- package/dist/runtime/components/LibDebug/LibDebug.stories.js +0 -46
- package/dist/runtime/components/LibFileInput/LibFileInput.stories.d.ts +0 -10
- package/dist/runtime/components/LibFileInput/LibFileInput.stories.js +0 -63
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.stories.d.ts +0 -33
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.stories.js +0 -384
- package/dist/runtime/components/LibLabel/LibLabel.stories.d.ts +0 -6
- package/dist/runtime/components/LibLabel/LibLabel.stories.js +0 -25
- package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.d.ts +0 -23
- package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.js +0 -61
- package/dist/runtime/components/LibNotifications/LibNotification.stories.d.ts +0 -15
- package/dist/runtime/components/LibNotifications/LibNotification.stories.js +0 -126
- package/dist/runtime/components/LibNotifications/LibNotifications.stories.d.ts +0 -6
- package/dist/runtime/components/LibNotifications/LibNotifications.stories.js +0 -109
- package/dist/runtime/components/LibPagination/LibPagination.stories.d.ts +0 -6
- package/dist/runtime/components/LibPagination/LibPagination.stories.js +0 -40
- package/dist/runtime/components/LibPalette/LibPalette.stories.d.ts +0 -6
- package/dist/runtime/components/LibPalette/LibPalette.stories.js +0 -20
- package/dist/runtime/components/LibPopup/LibPopup.stories.d.ts +0 -14
- package/dist/runtime/components/LibPopup/LibPopup.stories.js +0 -147
- package/dist/runtime/components/LibProgressBar/LibProgressBar.stories.d.ts +0 -10
- package/dist/runtime/components/LibProgressBar/LibProgressBar.stories.js +0 -81
- package/dist/runtime/components/LibRecorder/LibRecorder.stories.d.ts +0 -19
- package/dist/runtime/components/LibRecorder/LibRecorder.stories.js +0 -63
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.d.ts +0 -26
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.js +0 -78
- package/dist/runtime/components/LibSuggestions/LibSuggestions.stories.d.ts +0 -27
- package/dist/runtime/components/LibSuggestions/LibSuggestions.stories.js +0 -112
- package/dist/runtime/components/LibTable/LibTable.stories.d.ts +0 -16
- package/dist/runtime/components/LibTable/LibTable.stories.js +0 -156
- package/dist/runtime/components/Reset.stories.d.ts +0 -5
- package/dist/runtime/components/Reset.stories.js +0 -19
- package/dist/runtime/components/Scrolling.stories.d.ts +0 -6
- package/dist/runtime/components/Scrolling.stories.js +0 -44
- package/dist/runtime/composables/useScrollNearContainerEdges.stories.d.ts +0 -7
- package/dist/runtime/composables/useScrollNearContainerEdges.stories.js +0 -85
- package/dist/types.d.ts +0 -7
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
pointer-events-none
|
|
11
11
|
overflow-hidden
|
|
12
12
|
flex flex-col
|
|
13
|
-
`,
|
|
14
|
-
v-bind="{ ...$attrs, class:
|
|
13
|
+
`, $attrs.class)"
|
|
14
|
+
v-bind="{ ...$attrs, class: void 0 }"
|
|
15
15
|
>
|
|
16
16
|
<lib-notification class="pointer-events-auto"
|
|
17
17
|
:handler="handler"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
<Transition>
|
|
25
25
|
<div
|
|
26
26
|
v-show="topNotifications.length > 0"
|
|
27
|
-
:class="twMerge(`notifications--none`,
|
|
27
|
+
:class="twMerge(`notifications--none`, $attrs.class)"
|
|
28
28
|
/>
|
|
29
29
|
</Transition>
|
|
30
30
|
<Transition>
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
p-0
|
|
36
36
|
backdrop:bg-black/50
|
|
37
37
|
backdrop:p-5
|
|
38
|
-
`,
|
|
38
|
+
`, $attrs.class)"
|
|
39
39
|
ref="dialogEl"
|
|
40
40
|
@click.self.prevent="topNotifications[0] && NotificationHandler.dismiss(topNotifications[0])"
|
|
41
41
|
>
|
|
@@ -50,92 +50,72 @@
|
|
|
50
50
|
</dialog>
|
|
51
51
|
</Transition>
|
|
52
52
|
</template>
|
|
53
|
-
<script setup lang="ts">
|
|
54
|
-
import { removeIfIn } from "@alanscodelog/utils/removeIfIn.js"
|
|
55
|
-
import { type HTMLAttributes,nextTick, onBeforeUnmount, ref,shallowReactive, Transition, TransitionGroup } from "vue"
|
|
56
|
-
|
|
57
|
-
import LibNotification from "./LibNotification.vue"
|
|
58
|
-
|
|
59
|
-
import { useNotificationHandler } from "../../composables/useNotificationHandler.js"
|
|
60
|
-
import { type NotificationEntry, NotificationHandler } from "../../helpers/NotificationHandler.js"
|
|
61
|
-
import { twMerge } from "../../utils/twMerge.js"
|
|
62
|
-
import type { LinkableByIdProps, TailwindClassProp } from "../shared/props.js"
|
|
63
53
|
|
|
54
|
+
<script setup>
|
|
55
|
+
import { removeIfIn } from "@alanscodelog/utils/removeIfIn";
|
|
56
|
+
import { nextTick, onBeforeUnmount, ref, shallowReactive, Transition, TransitionGroup } from "vue";
|
|
57
|
+
import LibNotification from "./LibNotification.vue";
|
|
58
|
+
import { useNotificationHandler } from "../../composables/useNotificationHandler.js";
|
|
59
|
+
import { NotificationHandler } from "../../helpers/NotificationHandler.js";
|
|
60
|
+
import { twMerge } from "../../utils/twMerge.js";
|
|
64
61
|
defineOptions({
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const dialogEl = ref
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
const topNotifications = shallowReactive<NotificationEntry[]>([])
|
|
62
|
+
name: "lib-notifications",
|
|
63
|
+
inheritAttrs: false
|
|
64
|
+
});
|
|
65
|
+
const props = defineProps({
|
|
66
|
+
id: { type: String, required: false },
|
|
67
|
+
handler: { type: Object, required: false }
|
|
68
|
+
});
|
|
69
|
+
const dialogEl = ref(null);
|
|
70
|
+
const isOpen = ref(false);
|
|
71
|
+
const notifications = shallowReactive([]);
|
|
72
|
+
const topNotifications = shallowReactive([]);
|
|
77
73
|
const open = () => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
74
|
+
if (!isOpen.value) {
|
|
75
|
+
void nextTick(() => {
|
|
76
|
+
dialogEl.value.showModal();
|
|
77
|
+
isOpen.value = true;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
};
|
|
85
81
|
const close = () => {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
82
|
+
if (isOpen.value && topNotifications.length === 0) {
|
|
83
|
+
dialogEl.value.close();
|
|
84
|
+
isOpen.value = false;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const addNotification = (entry) => {
|
|
88
|
+
if (entry.resolution === void 0) {
|
|
89
|
+
if (entry.requiresAction) {
|
|
90
|
+
topNotifications.push(entry);
|
|
91
|
+
open();
|
|
92
|
+
entry.promise.then(() => {
|
|
93
|
+
removeIfIn(topNotifications, entry);
|
|
94
|
+
close();
|
|
95
|
+
});
|
|
96
|
+
} else {
|
|
97
|
+
notifications.splice(0, 0, entry);
|
|
98
|
+
entry.promise.then(() => {
|
|
99
|
+
removeIfIn(notifications, entry);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const notificationListener = (entry, type) => {
|
|
105
|
+
if (type === "added") {
|
|
106
|
+
addNotification(entry);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const handler = props.handler ?? useNotificationHandler();
|
|
110
|
+
handler.addNotificationListener(notificationListener);
|
|
111
|
+
for (const entry of handler.queue) {
|
|
112
|
+
addNotification(entry);
|
|
114
113
|
}
|
|
115
|
-
|
|
116
|
-
const handler = props.handler ?? useNotificationHandler()
|
|
117
|
-
|
|
118
|
-
handler.addNotificationListener(notificationListener)
|
|
119
|
-
|
|
120
|
-
for (const entry of handler.queue) { addNotification(entry) }
|
|
121
114
|
onBeforeUnmount(() => {
|
|
122
|
-
|
|
123
|
-
})
|
|
124
|
-
|
|
115
|
+
handler.removeNotificationListener(notificationListener);
|
|
116
|
+
});
|
|
125
117
|
</script>
|
|
126
|
-
<script lang="ts">
|
|
127
118
|
|
|
128
|
-
|
|
129
|
-
& LinkableByIdProps
|
|
130
|
-
& {
|
|
131
|
-
/** If not provided, uses the global handler (this requires useNotificationHandler be called and configured). */
|
|
132
|
-
handler?: NotificationHandler
|
|
133
|
-
}
|
|
119
|
+
<script>
|
|
134
120
|
|
|
135
|
-
interface Props
|
|
136
|
-
extends
|
|
137
|
-
/** @vue-ignore */
|
|
138
|
-
Partial<Omit<HTMLAttributes,"class"> & TailwindClassProp>,
|
|
139
|
-
RealProps
|
|
140
|
-
{}
|
|
141
121
|
</script>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type HTMLAttributes } from "vue";
|
|
2
|
+
import { NotificationHandler } from "../../helpers/NotificationHandler.js.js";
|
|
3
|
+
import type { LinkableByIdProps, TailwindClassProp } from "../shared/props.js.js";
|
|
4
|
+
type RealProps = LinkableByIdProps & {
|
|
5
|
+
/** If not provided, uses the global handler (this requires useNotificationHandler be called and configured). */
|
|
6
|
+
handler?: NotificationHandler;
|
|
7
|
+
};
|
|
8
|
+
interface Props extends
|
|
9
|
+
/** @vue-ignore */
|
|
10
|
+
Partial<Omit<HTMLAttributes, "class"> & TailwindClassProp>, RealProps {
|
|
11
|
+
}
|
|
12
|
+
declare const _default: import("vue").DefineComponent<Props, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
13
|
+
export default _default;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
:class="twMerge(`
|
|
4
4
|
pagination--wrapper
|
|
5
5
|
flex flex-wrap items-center justify-center gap-2
|
|
6
|
-
`,
|
|
6
|
+
`, $attrs.class)"
|
|
7
7
|
role="navigation"
|
|
8
8
|
:aria-label="t('pagination.aria')"
|
|
9
9
|
>
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
:i="prevLink.i"
|
|
13
13
|
:href="prevLink.href"
|
|
14
14
|
:text="t('pagination.previous-page')"
|
|
15
|
-
:aria-label="
|
|
15
|
+
:aria-label="t('pagination.aria.go-to-previous-page', { count: prevLink.i })"
|
|
16
16
|
:class="`pagination--link ${pageClasses}`"
|
|
17
17
|
>
|
|
18
18
|
<a
|
|
19
19
|
:class="`pagination--link ${pageClasses}`"
|
|
20
20
|
:href="prevLink.href"
|
|
21
|
-
:aria-label="
|
|
21
|
+
:aria-label="t('pagination.aria.go-to-previous-page', { count: prevLink.i })"
|
|
22
22
|
/>
|
|
23
23
|
</slot>
|
|
24
24
|
<div class="pagination--spacer flex-1"/>
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
:i="0"
|
|
28
28
|
:href="firstLink.href"
|
|
29
29
|
:text="firstLink.i"
|
|
30
|
-
:aria-label="t('pagination.aria.go-to-page', {count:firstLink.i})"
|
|
30
|
+
:aria-label="t('pagination.aria.go-to-page', { count: firstLink.i })"
|
|
31
31
|
:class="`pagination--link pagination--first-link ${pageClasses}`"
|
|
32
32
|
>
|
|
33
33
|
{{ firstLink.href }}
|
|
34
34
|
<a
|
|
35
35
|
:class="`pagination--link pagination--first-link ${pageClasses}`"
|
|
36
36
|
:href="firstLink.href"
|
|
37
|
-
:aria-label="t('pagination.aria.go-to-page', {count:firstLink.i})"
|
|
37
|
+
:aria-label="t('pagination.aria.go-to-page', { count: firstLink.i })"
|
|
38
38
|
>
|
|
39
39
|
{{ firstLink.i }}
|
|
40
40
|
</a>
|
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
:class="`pagination--link ${pageClasses}`"
|
|
51
51
|
:i="entry.i"
|
|
52
52
|
:href="entry.href"
|
|
53
|
-
:aria-label="t('pagination.aria.go-to-page', {count:entry.i})"
|
|
53
|
+
:aria-label="t('pagination.aria.go-to-page', { count: entry.i })"
|
|
54
54
|
>
|
|
55
55
|
<a
|
|
56
56
|
:class="`pagination--link ${pageClasses}`"
|
|
57
57
|
:href="entry.href"
|
|
58
|
-
:aria-label="t('pagination.aria.go-to-page', {count:entry.i})"
|
|
58
|
+
:aria-label="t('pagination.aria.go-to-page', { count: entry.i })"
|
|
59
59
|
>
|
|
60
60
|
{{ entry.i }}
|
|
61
61
|
</a>
|
|
@@ -65,12 +65,12 @@
|
|
|
65
65
|
:class="`pagination--link ${currentPageClasses}`"
|
|
66
66
|
tabindex="0"
|
|
67
67
|
:i="currentLink.i"
|
|
68
|
-
:aria-label="t('pagination.aria.current-page', {count:currentLink.i})"
|
|
68
|
+
:aria-label="t('pagination.aria.current-page', { count: currentLink.i })"
|
|
69
69
|
:aria_current="true"
|
|
70
70
|
>
|
|
71
71
|
<div :class="`pagination--current-page a ${currentPageClasses}`"
|
|
72
72
|
tabindex="0"
|
|
73
|
-
:aria-label="t('pagination.aria.current-page', {count:currentLink.i})"
|
|
73
|
+
:aria-label="t('pagination.aria.current-page', { count: currentLink.i })"
|
|
74
74
|
aria-current="true"
|
|
75
75
|
@click="$event.preventDefault()"
|
|
76
76
|
>
|
|
@@ -85,12 +85,12 @@
|
|
|
85
85
|
:class="`pagination--link ${pageClasses}`"
|
|
86
86
|
:i="entry.i"
|
|
87
87
|
:href="entry.href"
|
|
88
|
-
:aria-label="t('pagination.aria.go-to-page', {count:entry.i})"
|
|
88
|
+
:aria-label="t('pagination.aria.go-to-page', { count: entry.i })"
|
|
89
89
|
>
|
|
90
90
|
<a
|
|
91
91
|
:class="`pagination--link ${pageClasses}`"
|
|
92
92
|
:href="entry.href"
|
|
93
|
-
:aria-label="t('pagination.aria.go-to-page', {count:entry.i})"
|
|
93
|
+
:aria-label="t('pagination.aria.go-to-page', { count: entry.i })"
|
|
94
94
|
>
|
|
95
95
|
{{ entry.i }}
|
|
96
96
|
</a>
|
|
@@ -105,12 +105,12 @@
|
|
|
105
105
|
:i="lastLink.i"
|
|
106
106
|
:href="lastLink.href"
|
|
107
107
|
:text="total"
|
|
108
|
-
:aria-label="t('pagination.aria.go-to-page', {count:lastLink.i})"
|
|
108
|
+
:aria-label="t('pagination.aria.go-to-page', { count: lastLink.i })"
|
|
109
109
|
>
|
|
110
110
|
<a
|
|
111
111
|
:class="`pagination--link ${pageClasses}`"
|
|
112
112
|
:href="lastLink.href"
|
|
113
|
-
:aria-label="t('pagination.aria.go-to-page', {count:lastLink.i})"
|
|
113
|
+
:aria-label="t('pagination.aria.go-to-page', { count: lastLink.i })"
|
|
114
114
|
>
|
|
115
115
|
{{ total }}
|
|
116
116
|
</a>
|
|
@@ -123,27 +123,25 @@
|
|
|
123
123
|
:i="nextLink.i"
|
|
124
124
|
:href="nextLink.href"
|
|
125
125
|
:text="t('pagination.next-page')"
|
|
126
|
-
:aria-label="t('pagination.aria.go-to-next-page', {count:nextLink.i})"
|
|
126
|
+
:aria-label="t('pagination.aria.go-to-next-page', { count: nextLink.i })"
|
|
127
127
|
>
|
|
128
128
|
<a
|
|
129
129
|
:class="`pagination--link ${pageClasses}`"
|
|
130
130
|
:href="nextLink.href"
|
|
131
|
-
:aria-label="t('pagination.aria.go-to-next-page', {count:nextLink.i})"
|
|
131
|
+
:aria-label="t('pagination.aria.go-to-next-page', { count: nextLink.i })"
|
|
132
132
|
>
|
|
133
133
|
Next
|
|
134
134
|
</a>
|
|
135
135
|
</slot>
|
|
136
136
|
</nav>
|
|
137
137
|
</template>
|
|
138
|
-
<script setup lang="ts">
|
|
139
|
-
import { computed, type HTMLAttributes,useAttrs,watch } from "vue"
|
|
140
|
-
|
|
141
|
-
import { useInjectedI18n } from "../../composables/useInjectedI18n.js"
|
|
142
|
-
import { twMerge } from "../../utils/twMerge.js"
|
|
143
|
-
import { type TailwindClassProp } from "../shared/props.js"
|
|
144
|
-
|
|
145
|
-
const t = useInjectedI18n()
|
|
146
138
|
|
|
139
|
+
<script setup>
|
|
140
|
+
import { computed, useAttrs, watch } from "vue";
|
|
141
|
+
import { useInjectedI18n } from "../../composables/useInjectedI18n.js";
|
|
142
|
+
import { twMerge } from "../../utils/twMerge.js";
|
|
143
|
+
import {} from "../shared/props.js";
|
|
144
|
+
const t = useInjectedI18n();
|
|
147
145
|
const commonClasses = `
|
|
148
146
|
block
|
|
149
147
|
focus-outline
|
|
@@ -151,110 +149,68 @@ const commonClasses = `
|
|
|
151
149
|
border-transparent
|
|
152
150
|
transition-all
|
|
153
151
|
outlined:rounded-sm
|
|
154
|
-
|
|
152
|
+
`;
|
|
155
153
|
const pageClasses = `
|
|
156
154
|
${commonClasses}
|
|
157
155
|
focus-outline
|
|
158
156
|
hover:text-accent-600
|
|
159
157
|
hover:border-b-accent-500
|
|
160
158
|
hover:scale-125
|
|
161
|
-
|
|
162
|
-
|
|
159
|
+
`;
|
|
163
160
|
const currentPageClasses = `
|
|
164
161
|
${commonClasses}
|
|
165
162
|
border-b-accent-500
|
|
166
163
|
scale-125
|
|
167
|
-
|
|
164
|
+
`;
|
|
168
165
|
defineOptions({
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
})
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
const
|
|
186
|
-
const
|
|
187
|
-
|
|
166
|
+
name: "lib-pagination",
|
|
167
|
+
inheritAttrs: false
|
|
168
|
+
});
|
|
169
|
+
const props = defineProps({
|
|
170
|
+
total: { type: Number, required: true },
|
|
171
|
+
current: { type: Number, required: true },
|
|
172
|
+
route: { type: String, required: true },
|
|
173
|
+
customRoute: { type: Function, required: false, default: (route, i) => {
|
|
174
|
+
if (i === 0 || i === 1) {
|
|
175
|
+
const num = 1;
|
|
176
|
+
return { href: route, i: num };
|
|
177
|
+
}
|
|
178
|
+
return { href: route + i.toString(), i };
|
|
179
|
+
} },
|
|
180
|
+
extraPages: { type: Number, required: false, default: 3 }
|
|
181
|
+
});
|
|
182
|
+
const $attrs = useAttrs();
|
|
183
|
+
const currentLink = computed(() => props.customRoute(props.route, props.current));
|
|
184
|
+
const currentIsInvalid = computed(() => currentLink.value.i < 0 || currentLink.value.i > props.total);
|
|
188
185
|
watch(() => currentIsInvalid.value, () => {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
})
|
|
193
|
-
|
|
194
|
-
const prevLink = computed(() => props.customRoute(props.route, props.current - 1))
|
|
195
|
-
|
|
186
|
+
if (currentIsInvalid.value) {
|
|
187
|
+
throw new Error(`Current page is out of range: 0 - ${props.total}`);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
const prevLink = computed(() => props.customRoute(props.route, props.current - 1));
|
|
196
191
|
const nextLink = computed(() => {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
})
|
|
203
|
-
|
|
204
|
-
const
|
|
205
|
-
const lastLink = computed(() => props.customRoute(props.route, props.total))
|
|
206
|
-
|
|
207
|
-
type HrefInfo = { href: string, i: number }
|
|
192
|
+
const maybeNextLink = props.customRoute(props.route, props.current + 1);
|
|
193
|
+
if (maybeNextLink.i === currentLink.value.i) {
|
|
194
|
+
return props.customRoute(props.route, props.current + 2);
|
|
195
|
+
}
|
|
196
|
+
return maybeNextLink;
|
|
197
|
+
});
|
|
198
|
+
const firstLink = computed(() => props.customRoute(props.route, 0));
|
|
199
|
+
const lastLink = computed(() => props.customRoute(props.route, props.total));
|
|
208
200
|
const extraPagesPrev = computed(() => [...Array(props.extraPages)].map((_, _i) => {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}).filter(entry => entry !==
|
|
213
|
-
|
|
201
|
+
const num = currentLink.value.i - (props.extraPages - _i);
|
|
202
|
+
if (num <= firstLink.value.i || num >= lastLink.value.i || num >= currentLink.value.i) return void 0;
|
|
203
|
+
return props.customRoute(props.route, num);
|
|
204
|
+
}).filter((entry) => entry !== void 0));
|
|
214
205
|
const extraPagesNext = computed(() => [...Array(props.extraPages + 1)].map((_, i) => {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}).filter(entry => entry !==
|
|
219
|
-
|
|
206
|
+
const num = currentLink.value.i + i;
|
|
207
|
+
if (num <= firstLink.value.i || num >= lastLink.value.i || num <= currentLink.value.i) return void 0;
|
|
208
|
+
return props.customRoute(props.route, num);
|
|
209
|
+
}).filter((entry) => entry !== void 0).slice(0, props.extraPages));
|
|
220
210
|
</script>
|
|
221
|
-
<script lang="ts">
|
|
222
211
|
|
|
223
|
-
|
|
224
|
-
* Pagination component.
|
|
225
|
-
*
|
|
226
|
-
* Can be passed a slot like so to use a custom link element (like NuxtLink):
|
|
227
|
-
* ```vue
|
|
228
|
-
* <template #link="{ href, i, text, ariaLabel, ariaCurrent}">
|
|
229
|
-
* <NuxtLink :to="href" :aria-label="ariaLabel" :aria-current="ariaCurrent ?? false">{{ text ?? i }}</NuxtLink>
|
|
230
|
-
* </template>
|
|
231
|
-
* ```
|
|
232
|
-
*/
|
|
212
|
+
<script>
|
|
233
213
|
export default {
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
type RealProps = {
|
|
237
|
-
/** The total number of pages. */
|
|
238
|
-
total: number
|
|
239
|
-
/** The number of the current page. It must be valid, between 0 - total or the component will throw an error. */
|
|
240
|
-
current: number
|
|
241
|
-
/** The base route/link path for the page. Should end with a forward slash `/`. */
|
|
242
|
-
route: string
|
|
243
|
-
/**
|
|
244
|
-
* A function to customize the output href and page link number. By default, page 0 is page 1, page 1 is 1, then everything else is normal.
|
|
245
|
-
*
|
|
246
|
-
* This is because usually we have routes like: `/page/1`, `/page/2`, not `/page/0`.
|
|
247
|
-
*
|
|
248
|
-
* You can use this function to customize things further. For example, make `/page/1` just `/`
|
|
249
|
-
*/
|
|
250
|
-
customRoute?: (route: string, i: number) => { i: number, href: string }
|
|
251
|
-
/** How many extra pages to show to each side of the current page. */
|
|
252
|
-
extraPages?: number
|
|
253
|
-
}
|
|
254
|
-
interface Props
|
|
255
|
-
extends
|
|
256
|
-
/** @vue-ignore */
|
|
257
|
-
Partial<Omit<HTMLAttributes,"class"> & TailwindClassProp>,
|
|
258
|
-
RealProps
|
|
259
|
-
{}
|
|
214
|
+
name: "lib-pagination"
|
|
215
|
+
};
|
|
260
216
|
</script>
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { type HTMLAttributes } from "vue";
|
|
2
|
+
import { type TailwindClassProp } from "../shared/props.js.js";
|
|
3
|
+
/**
|
|
4
|
+
* Pagination component.
|
|
5
|
+
*
|
|
6
|
+
* Can be passed a slot like so to use a custom link element (like NuxtLink):
|
|
7
|
+
* ```vue
|
|
8
|
+
* <template #link="{ href, i, text, ariaLabel, ariaCurrent}">
|
|
9
|
+
* <NuxtLink :to="href" :aria-label="ariaLabel" :aria-current="ariaCurrent ?? false">{{ text ?? i }}</NuxtLink>
|
|
10
|
+
* </template>
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
declare const _default: __VLS_WithSlots<import("vue").DefineComponent<Props, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
14
|
+
customRoute: (route: string, i: number) => {
|
|
15
|
+
i: number;
|
|
16
|
+
href: string;
|
|
17
|
+
};
|
|
18
|
+
extraPages: number;
|
|
19
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
20
|
+
link?: (props: {
|
|
21
|
+
class: string;
|
|
22
|
+
i: any;
|
|
23
|
+
href: any;
|
|
24
|
+
text: any;
|
|
25
|
+
ariaLabel: any;
|
|
26
|
+
}) => any;
|
|
27
|
+
} & {
|
|
28
|
+
link?: (props: {
|
|
29
|
+
class: string;
|
|
30
|
+
i: number;
|
|
31
|
+
href: any;
|
|
32
|
+
text: any;
|
|
33
|
+
ariaLabel: any;
|
|
34
|
+
}) => any;
|
|
35
|
+
} & {
|
|
36
|
+
link?: (props: {
|
|
37
|
+
i: any;
|
|
38
|
+
href: any;
|
|
39
|
+
ariaLabel: any;
|
|
40
|
+
class: string;
|
|
41
|
+
}) => any;
|
|
42
|
+
} & {
|
|
43
|
+
current?: (props: {
|
|
44
|
+
tabindex: string;
|
|
45
|
+
i: any;
|
|
46
|
+
ariaLabel: any;
|
|
47
|
+
aria_current: boolean;
|
|
48
|
+
class: string;
|
|
49
|
+
}) => any;
|
|
50
|
+
} & {
|
|
51
|
+
link?: (props: {
|
|
52
|
+
i: any;
|
|
53
|
+
href: any;
|
|
54
|
+
ariaLabel: any;
|
|
55
|
+
class: string;
|
|
56
|
+
}) => any;
|
|
57
|
+
} & {
|
|
58
|
+
link?: (props: {
|
|
59
|
+
i: any;
|
|
60
|
+
href: any;
|
|
61
|
+
text: any;
|
|
62
|
+
ariaLabel: any;
|
|
63
|
+
class: string;
|
|
64
|
+
}) => any;
|
|
65
|
+
} & {
|
|
66
|
+
link?: (props: {
|
|
67
|
+
i: any;
|
|
68
|
+
href: any;
|
|
69
|
+
text: any;
|
|
70
|
+
ariaLabel: any;
|
|
71
|
+
class: string;
|
|
72
|
+
}) => any;
|
|
73
|
+
}>;
|
|
74
|
+
export default _default;
|
|
75
|
+
type RealProps = {
|
|
76
|
+
/** The total number of pages. */
|
|
77
|
+
total: number;
|
|
78
|
+
/** The number of the current page. It must be valid, between 0 - total or the component will throw an error. */
|
|
79
|
+
current: number;
|
|
80
|
+
/** The base route/link path for the page. Should end with a forward slash `/`. */
|
|
81
|
+
route: string;
|
|
82
|
+
/**
|
|
83
|
+
* A function to customize the output href and page link number. By default, page 0 is page 1, page 1 is 1, then everything else is normal.
|
|
84
|
+
*
|
|
85
|
+
* This is because usually we have routes like: `/page/1`, `/page/2`, not `/page/0`.
|
|
86
|
+
*
|
|
87
|
+
* You can use this function to customize things further. For example, make `/page/1` just `/`
|
|
88
|
+
*/
|
|
89
|
+
customRoute?: (route: string, i: number) => {
|
|
90
|
+
i: number;
|
|
91
|
+
href: string;
|
|
92
|
+
};
|
|
93
|
+
/** How many extra pages to show to each side of the current page. */
|
|
94
|
+
extraPages?: number;
|
|
95
|
+
};
|
|
96
|
+
interface Props extends
|
|
97
|
+
/** @vue-ignore */
|
|
98
|
+
Partial<Omit<HTMLAttributes, "class"> & TailwindClassProp>, RealProps {
|
|
99
|
+
}
|
|
100
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
101
|
+
new (): {
|
|
102
|
+
$slots: S;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
:style="`background-color: var(${color});`"
|
|
8
8
|
:class="`theme-palette--item h-10 rounded-sm flex items-center justify-center text-fg dark:text-bg`"
|
|
9
9
|
>
|
|
10
|
-
{{ [5, 16, 27, 38, 49].includes(i) ?
|
|
10
|
+
{{ [5, 16, 27, 38, 49].includes(i) ? "Text" : "" }}
|
|
11
11
|
</div>
|
|
12
12
|
</template>
|
|
13
13
|
</div>
|
|
@@ -22,28 +22,22 @@
|
|
|
22
22
|
</div>
|
|
23
23
|
</template>
|
|
24
24
|
|
|
25
|
-
<script
|
|
26
|
-
export default { name: "lib-palette" }
|
|
25
|
+
<script>
|
|
26
|
+
export default { name: "lib-palette" };
|
|
27
27
|
</script>
|
|
28
28
|
|
|
29
|
-
<script setup
|
|
30
|
-
import { keys } from "@alanscodelog/utils/keys
|
|
31
|
-
import {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
...baseInteractivePropsDefaults
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
const exclude = ["--color-bg", "--color-fg"]
|
|
47
|
-
const colors = keys(props.theme.css).filter(key => key.startsWith("--color") && !exclude.includes(key))
|
|
48
|
-
|
|
29
|
+
<script setup>
|
|
30
|
+
import { keys } from "@alanscodelog/utils/keys";
|
|
31
|
+
import {} from "metamorphosis";
|
|
32
|
+
import {} from "../shared/props.js";
|
|
33
|
+
const props = defineProps({
|
|
34
|
+
id: { type: String, required: false },
|
|
35
|
+
disabled: { type: Boolean, required: false, default: false },
|
|
36
|
+
readonly: { type: Boolean, required: false, default: false },
|
|
37
|
+
border: { type: Boolean, required: false, default: true },
|
|
38
|
+
unstyle: { type: Boolean, required: false, default: false },
|
|
39
|
+
theme: { type: Object, required: true, default: () => ({}) }
|
|
40
|
+
});
|
|
41
|
+
const exclude = ["--color-bg", "--color-fg"];
|
|
42
|
+
const colors = keys(props.theme.css).filter((key) => key.startsWith("--color") && !exclude.includes(key));
|
|
49
43
|
</script>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Theme } from "metamorphosis";
|
|
2
|
+
import { type BaseInteractiveProps, type LinkableByIdProps } from "../shared/props.js.js";
|
|
3
|
+
declare const _default: import("vue").DefineComponent<LinkableByIdProps & BaseInteractiveProps & {
|
|
4
|
+
theme: Theme;
|
|
5
|
+
}, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<LinkableByIdProps & BaseInteractiveProps & {
|
|
6
|
+
theme: Theme;
|
|
7
|
+
}> & Readonly<{}>, {
|
|
8
|
+
theme: Theme;
|
|
9
|
+
disabled: boolean;
|
|
10
|
+
readonly: boolean;
|
|
11
|
+
border: boolean;
|
|
12
|
+
unstyle: boolean;
|
|
13
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
14
|
+
export default _default;
|