@witchcraft/ui 0.0.1 → 0.1.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 +18 -28
- package/dist/module.d.mts +3 -1
- package/dist/module.json +3 -3
- package/dist/module.mjs +21 -12
- package/dist/runtime/assets/base.css +1 -1
- package/dist/runtime/assets/locales/en.json +2 -2
- package/dist/runtime/assets/tailwind.css +1 -1
- package/dist/runtime/assets/utils.css +1 -0
- package/dist/runtime/build/WitchcraftUiResolver.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 +12 -28
- package/dist/runtime/components/Icon/Icon.vue.d.ts +21 -0
- package/dist/runtime/components/LibButton/LibButton.vue +93 -117
- package/dist/runtime/components/LibButton/LibButton.vue.d.ts +36 -0
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +53 -76
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue.d.ts +42 -0
- package/dist/runtime/components/LibColorInput/LibColorInput.vue +131 -101
- package/dist/runtime/components/LibColorInput/LibColorInput.vue.d.ts +63 -0
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue +326 -296
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue.d.ts +61 -0
- package/dist/runtime/components/LibColorPicker/utils/safeConvertToHsva.d.ts +2 -0
- package/dist/runtime/components/LibColorPicker/utils/safeConvertToHsva.js +18 -0
- package/dist/runtime/components/LibColorPicker/utils/safeConvertToRgba.d.ts +2 -0
- package/dist/runtime/components/LibColorPicker/utils/safeConvertToRgba.js +17 -0
- package/dist/runtime/components/LibColorPicker/utils/toLowPrecisionRgbaString.d.ts +2 -0
- package/dist/runtime/components/LibColorPicker/utils/toLowPrecisionRgbaString.js +8 -0
- package/dist/runtime/components/LibColorPicker/utils/truncate.d.ts +1 -0
- package/dist/runtime/components/LibColorPicker/utils/truncate.js +5 -0
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +42 -64
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue.d.ts +22 -0
- package/dist/runtime/components/LibDatePicker/LibDatePicker.vue +20 -54
- package/dist/runtime/components/LibDatePicker/LibDatePicker.vue.d.ts +40 -0
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue +205 -173
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue.d.ts +34 -0
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue +215 -164
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue.d.ts +34 -0
- package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue +9 -10
- package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue.d.ts +22 -0
- package/dist/runtime/components/LibDebug/LibDebug.vue +47 -65
- package/dist/runtime/components/LibDebug/LibDebug.vue.d.ts +32 -0
- package/dist/runtime/components/LibDevOnly/LibDevOnly.vue +19 -34
- package/dist/runtime/components/LibDevOnly/LibDevOnly.vue.d.ts +22 -0
- package/dist/runtime/components/LibFileInput/LibFileInput.vue +155 -173
- package/dist/runtime/components/LibFileInput/LibFileInput.vue.d.ts +43 -0
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +352 -0
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue.d.ts +165 -0
- package/dist/runtime/components/LibLabel/LibLabel.vue +30 -46
- package/dist/runtime/components/LibLabel/LibLabel.vue.d.ts +27 -0
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue +50 -66
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue.d.ts +29 -0
- package/dist/runtime/components/LibNotifications/LibNotification.vue +48 -56
- package/dist/runtime/components/LibNotifications/LibNotification.vue.d.ts +17 -0
- package/dist/runtime/components/LibNotifications/LibNotifications.vue +71 -83
- package/dist/runtime/components/LibNotifications/LibNotifications.vue.d.ts +13 -0
- package/dist/runtime/components/LibPagination/LibPagination.vue +86 -131
- package/dist/runtime/components/LibPagination/LibPagination.vue.d.ts +104 -0
- package/dist/runtime/components/LibPalette/LibPalette.vue +23 -26
- package/dist/runtime/components/LibPalette/LibPalette.vue.d.ts +14 -0
- package/dist/runtime/components/LibPopup/LibPopup.vue +326 -400
- package/dist/runtime/components/LibPopup/LibPopup.vue.d.ts +46 -0
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +73 -93
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue.d.ts +41 -0
- package/dist/runtime/components/LibRecorder/LibRecorder.vue +134 -179
- package/dist/runtime/components/LibRecorder/LibRecorder.vue.d.ts +77 -0
- package/dist/runtime/components/LibRoot/LibRoot.vue +75 -89
- package/dist/runtime/components/LibRoot/LibRoot.vue.d.ts +41 -0
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue +51 -82
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue.d.ts +35 -0
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +147 -164
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue.d.ts +94 -0
- package/dist/runtime/components/LibTable/LibTable.vue +69 -106
- 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 +7 -10
- package/dist/runtime/components/TestControls/TestControls.vue.d.ts +5 -0
- package/dist/runtime/components/index.d.ts +12 -11
- package/dist/runtime/components/index.js +12 -11
- package/dist/runtime/components/shared/props.d.ts +81 -16
- package/dist/runtime/components/shared/storyHelpers/playInput.js +5 -5
- package/dist/runtime/components/shared/storyHelpers/playSuggestions.js +15 -11
- package/dist/runtime/composables/index.d.ts +5 -0
- package/dist/runtime/composables/index.js +5 -0
- package/dist/runtime/composables/useDivideAttrs.js +1 -0
- package/dist/runtime/composables/useDragWithThreshold.d.ts +71 -0
- package/dist/runtime/composables/useDragWithThreshold.js +40 -0
- package/dist/runtime/composables/usePreHydrationValue.d.ts +12 -0
- package/dist/runtime/composables/usePreHydrationValue.js +15 -0
- package/dist/runtime/composables/useSetupI18n.d.ts +2 -0
- package/dist/runtime/composables/useSetupI18n.js +5 -1
- package/dist/runtime/composables/useSuggestions.d.ts +7 -5
- package/dist/runtime/composables/useSuggestions.js +94 -57
- package/dist/runtime/directives/vResizableCols.js +92 -84
- package/dist/runtime/helpers/NotificationHandler.d.ts +5 -0
- package/dist/runtime/helpers/index.d.ts +3 -1
- package/dist/runtime/helpers/index.js +3 -1
- package/dist/runtime/types/index.d.ts +6 -0
- package/dist/runtime/utils/notifyIfError.d.ts +14 -0
- package/dist/runtime/utils/notifyIfError.js +29 -0
- package/dist/types.d.mts +2 -6
- package/package.json +27 -29
- package/src/module.ts +31 -12
- package/src/runtime/assets/base.css +10 -1
- package/src/runtime/assets/locales/en.json +2 -2
- package/src/runtime/assets/tailwind.css +1 -1
- package/src/runtime/assets/{style.css → utils.css} +86 -4
- package/src/runtime/build/WitchcraftUiResolver.ts +1 -1
- package/src/runtime/components/Focus.stories.ts +3 -2
- package/src/runtime/components/Icon/Icon.vue +10 -6
- package/src/runtime/components/LibButton/LibButton.vue +41 -47
- package/src/runtime/components/LibCheckbox/LibCheckbox.vue +7 -4
- package/src/runtime/components/LibColorInput/LibColorInput.vue +111 -37
- package/src/runtime/components/LibColorPicker/LibColorPicker.stories.ts +25 -4
- package/src/runtime/components/LibColorPicker/LibColorPicker.vue +242 -131
- package/src/runtime/components/LibColorPicker/utils/safeConvertToHsva.ts +24 -0
- package/src/runtime/components/LibColorPicker/utils/safeConvertToRgba.ts +23 -0
- package/src/runtime/components/LibColorPicker/utils/toLowPrecisionRgbaString.ts +13 -0
- package/src/runtime/components/LibColorPicker/utils/truncate.ts +6 -0
- package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.ts +1 -1
- package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +11 -9
- package/src/runtime/components/LibDatePicker/LibDatePicker.vue +4 -17
- package/src/runtime/components/LibDatePicker/LibRangeDatePicker.vue +192 -131
- package/src/runtime/components/LibDatePicker/LibSingleDatePicker.vue +183 -115
- package/src/runtime/components/LibDatePicker/LibTimeZonePicker.vue +3 -3
- package/src/runtime/components/LibDebug/LibDebug.vue +15 -5
- package/src/runtime/components/LibDevOnly/LibDevOnly.vue +1 -3
- package/src/runtime/components/LibFileInput/LibFileInput.vue +54 -29
- package/src/runtime/components/{LibInput/LibInput.stories.ts → LibInputDeprecated/LibInputDeprecated.stories.ts} +64 -19
- package/{dist/runtime/components/LibInput/LibInput.vue → src/runtime/components/LibInputDeprecated/LibInputDeprecated.vue} +40 -34
- package/src/runtime/components/LibLabel/LibLabel.vue +2 -2
- package/src/runtime/components/LibMultiValues/LibMultiValues.stories.ts +5 -4
- package/src/runtime/components/LibMultiValues/LibMultiValues.vue +11 -13
- package/src/runtime/components/LibNotifications/LibNotification.vue +19 -11
- package/src/runtime/components/LibNotifications/LibNotifications.stories.ts +2 -2
- package/src/runtime/components/LibNotifications/LibNotifications.vue +20 -12
- package/src/runtime/components/LibPagination/LibPagination.stories.ts +2 -2
- package/src/runtime/components/LibPagination/LibPagination.vue +19 -20
- package/src/runtime/components/LibPalette/LibPalette.vue +3 -3
- package/src/runtime/components/LibPopup/LibPopup.stories.ts +2 -2
- package/src/runtime/components/LibPopup/LibPopup.vue +30 -67
- package/src/runtime/components/LibProgressBar/LibProgressBar.vue +3 -2
- package/src/runtime/components/LibRecorder/LibRecorder.vue +2 -3
- package/src/runtime/components/LibRoot/LibRoot.vue +14 -1
- package/src/runtime/components/LibSimpleInput/LibSimpleInput.stories.ts +1 -1
- package/src/runtime/components/LibSimpleInput/LibSimpleInput.vue +5 -8
- package/src/runtime/components/LibSuggestions/LibSuggestions.vue +42 -26
- package/src/runtime/components/LibTable/LibTable.vue +8 -9
- package/src/runtime/components/Scrolling.stories.ts +58 -0
- package/src/runtime/components/Template/NAME.vue +1 -1
- package/src/runtime/components/TestControls/TestControls.vue +1 -1
- package/src/runtime/components/index.ts +12 -12
- package/src/runtime/components/shared/props.ts +82 -19
- package/src/runtime/components/shared/storyHelpers/playInput.ts +6 -5
- package/src/runtime/components/shared/storyHelpers/playSuggestions.ts +25 -11
- package/src/runtime/composables/index.ts +5 -0
- package/src/runtime/composables/useDarkMode.ts +2 -2
- package/src/runtime/composables/useDivideAttrs.ts +1 -0
- package/src/runtime/composables/useDragWithThreshold.ts +108 -0
- package/src/runtime/composables/usePreHydrationValue.ts +30 -0
- package/src/runtime/composables/useSetupI18n.ts +8 -2
- package/src/runtime/composables/useSuggestions.ts +92 -45
- package/src/runtime/directives/vResizableCols.ts +82 -74
- package/src/runtime/helpers/NotificationHandler.ts +5 -0
- package/src/runtime/helpers/index.ts +3 -1
- package/src/runtime/types/index.ts +5 -0
- package/src/runtime/utils/notifyIfError.ts +45 -0
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -34
- package/dist/runtime/assets/style.css +0 -1
- 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 -7
- package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.js +0 -51
- 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/LibInput/LibInput.stories.d.ts +0 -33
- package/dist/runtime/components/LibInput/LibInput.stories.js +0 -339
- 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 -60
- 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/composables/useScrollNearContainerEdges.stories.d.ts +0 -7
- package/dist/runtime/composables/useScrollNearContainerEdges.stories.js +0 -85
- package/dist/runtime/helpers/addValue.d.ts +0 -1
- package/dist/runtime/helpers/addValue.js +0 -8
- package/dist/types.d.ts +0 -7
- package/src/runtime/components/LibInput/LibInput.vue +0 -372
- package/src/runtime/helpers/addValue.ts +0 -10
- /package/src/runtime/components/{reset.stories.ts → Reset.stories.ts} +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<nav
|
|
3
3
|
:class="twMerge(`
|
|
4
|
+
pagination--wrapper
|
|
4
5
|
flex flex-wrap items-center justify-center gap-2
|
|
5
|
-
`,
|
|
6
|
+
`, $attrs.class)"
|
|
6
7
|
role="navigation"
|
|
7
8
|
:aria-label="t('pagination.aria')"
|
|
8
9
|
>
|
|
@@ -11,34 +12,34 @@
|
|
|
11
12
|
:i="prevLink.i"
|
|
12
13
|
:href="prevLink.href"
|
|
13
14
|
:text="t('pagination.previous-page')"
|
|
14
|
-
:aria-label="
|
|
15
|
-
:class="pageClasses"
|
|
15
|
+
:aria-label="t('pagination.aria.go-to-previous-page', { count: prevLink.i })"
|
|
16
|
+
:class="`pagination--link ${pageClasses}`"
|
|
16
17
|
>
|
|
17
18
|
<a
|
|
18
|
-
:class="pageClasses"
|
|
19
|
+
:class="`pagination--link ${pageClasses}`"
|
|
19
20
|
:href="prevLink.href"
|
|
20
|
-
:aria-label="
|
|
21
|
+
:aria-label="t('pagination.aria.go-to-previous-page', { count: prevLink.i })"
|
|
21
22
|
/>
|
|
22
23
|
</slot>
|
|
23
|
-
<div class="flex-1"/>
|
|
24
|
+
<div class="pagination--spacer flex-1"/>
|
|
24
25
|
<slot v-if="firstLink.i !== currentLink.i"
|
|
25
26
|
name="link"
|
|
26
27
|
:i="0"
|
|
27
28
|
:href="firstLink.href"
|
|
28
29
|
:text="firstLink.i"
|
|
29
|
-
:aria-label="t('pagination.aria.go-to-page', {count:firstLink.i})"
|
|
30
|
-
:class="pageClasses"
|
|
30
|
+
:aria-label="t('pagination.aria.go-to-page', { count: firstLink.i })"
|
|
31
|
+
:class="`pagination--link pagination--first-link ${pageClasses}`"
|
|
31
32
|
>
|
|
32
33
|
{{ firstLink.href }}
|
|
33
34
|
<a
|
|
34
|
-
:class="pageClasses"
|
|
35
|
+
:class="`pagination--link pagination--first-link ${pageClasses}`"
|
|
35
36
|
:href="firstLink.href"
|
|
36
|
-
:aria-label="t('pagination.aria.go-to-page', {count:firstLink.i})"
|
|
37
|
+
:aria-label="t('pagination.aria.go-to-page', { count: firstLink.i })"
|
|
37
38
|
>
|
|
38
39
|
{{ firstLink.i }}
|
|
39
40
|
</a>
|
|
40
41
|
</slot>
|
|
41
|
-
<div v-if="prevLink.i - extraPages > firstLink.i" class="page-fill">
|
|
42
|
+
<div v-if="prevLink.i - extraPages > firstLink.i" class="pagination--page-fill">
|
|
42
43
|
...
|
|
43
44
|
</div>
|
|
44
45
|
<template
|
|
@@ -46,31 +47,30 @@
|
|
|
46
47
|
:key="entry.i"
|
|
47
48
|
>
|
|
48
49
|
<slot name="link"
|
|
49
|
-
:class="pageClasses"
|
|
50
|
+
:class="`pagination--link ${pageClasses}`"
|
|
50
51
|
:i="entry.i"
|
|
51
52
|
:href="entry.href"
|
|
52
|
-
:aria-label="t('pagination.aria.go-to-page', {count:entry.i})"
|
|
53
|
+
:aria-label="t('pagination.aria.go-to-page', { count: entry.i })"
|
|
53
54
|
>
|
|
54
55
|
<a
|
|
55
|
-
:class="pageClasses"
|
|
56
|
+
:class="`pagination--link ${pageClasses}`"
|
|
56
57
|
:href="entry.href"
|
|
57
|
-
:aria-label="t('pagination.aria.go-to-page', {count:entry.i})"
|
|
58
|
+
:aria-label="t('pagination.aria.go-to-page', { count: entry.i })"
|
|
58
59
|
>
|
|
59
60
|
{{ entry.i }}
|
|
60
61
|
</a>
|
|
61
62
|
</slot>
|
|
62
63
|
</template>
|
|
63
64
|
<slot name="current"
|
|
64
|
-
:class="currentPageClasses"
|
|
65
|
+
:class="`pagination--link ${currentPageClasses}`"
|
|
65
66
|
tabindex="0"
|
|
66
67
|
:i="currentLink.i"
|
|
67
|
-
:aria-label="t('pagination.aria.current-page', {count:currentLink.i})"
|
|
68
|
+
:aria-label="t('pagination.aria.current-page', { count: currentLink.i })"
|
|
68
69
|
:aria_current="true"
|
|
69
70
|
>
|
|
70
|
-
<div class="a"
|
|
71
|
+
<div :class="`pagination--current-page a ${currentPageClasses}`"
|
|
71
72
|
tabindex="0"
|
|
72
|
-
:
|
|
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
|
>
|
|
@@ -82,68 +82,66 @@
|
|
|
82
82
|
:key="entry.i"
|
|
83
83
|
>
|
|
84
84
|
<slot name="link"
|
|
85
|
-
:class="pageClasses"
|
|
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
|
-
:class="pageClasses"
|
|
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>
|
|
97
97
|
</slot>
|
|
98
98
|
</template>
|
|
99
|
-
<div v-if="nextLink.i + extraPages < total" class="page-fill" aria-hidden="true">
|
|
99
|
+
<div v-if="nextLink.i + extraPages < total" class="pagination--page-fill" aria-hidden="true">
|
|
100
100
|
...
|
|
101
101
|
</div>
|
|
102
102
|
<slot v-if="lastLink.i !== currentLink.i"
|
|
103
103
|
name="link"
|
|
104
|
-
:class="pageClasses"
|
|
104
|
+
:class="`pagination--link ${pageClasses}`"
|
|
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
|
-
:class="pageClasses"
|
|
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>
|
|
117
117
|
</slot>
|
|
118
|
-
<div class="flex-1"/>
|
|
118
|
+
<div class="pagination--spacer flex-1"/>
|
|
119
119
|
<slot
|
|
120
120
|
v-if="nextLink.i <= total && nextLink.i !== currentLink.i"
|
|
121
|
-
:class="pageClasses"
|
|
121
|
+
:class="`pagination--link ${pageClasses}`"
|
|
122
122
|
name="link"
|
|
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
|
-
:class="pageClasses"
|
|
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,111 +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
|
-
|
|
186
|
-
const currentLink = computed(() => props.customRoute(props.route, props.current))
|
|
187
|
-
const currentIsInvalid = computed(() => currentLink.value.i < 0 || currentLink.value.i > props.total)
|
|
188
|
-
|
|
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);
|
|
189
185
|
watch(() => currentIsInvalid.value, () => {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
})
|
|
194
|
-
|
|
195
|
-
const prevLink = computed(() => props.customRoute(props.route, props.current - 1))
|
|
196
|
-
|
|
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));
|
|
197
191
|
const nextLink = computed(() => {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
})
|
|
204
|
-
|
|
205
|
-
const
|
|
206
|
-
const lastLink = computed(() => props.customRoute(props.route, props.total))
|
|
207
|
-
|
|
208
|
-
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));
|
|
209
200
|
const extraPagesPrev = computed(() => [...Array(props.extraPages)].map((_, _i) => {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}).filter(entry => entry !==
|
|
214
|
-
|
|
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));
|
|
215
205
|
const extraPagesNext = computed(() => [...Array(props.extraPages + 1)].map((_, i) => {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}).filter(entry => entry !==
|
|
220
|
-
|
|
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));
|
|
221
210
|
</script>
|
|
222
|
-
<script lang="ts">
|
|
223
211
|
|
|
224
|
-
|
|
225
|
-
* Pagination component.
|
|
226
|
-
*
|
|
227
|
-
* Can be passed a slot like so to use a custom link element (like NuxtLink):
|
|
228
|
-
* ```vue
|
|
229
|
-
* <template #link="{ href, i, text, ariaLabel, ariaCurrent}">
|
|
230
|
-
* <NuxtLink :to="href" :aria-label="ariaLabel" :aria-current="ariaCurrent ?? false">{{ text ?? i }}</NuxtLink>
|
|
231
|
-
* </template>
|
|
232
|
-
* ```
|
|
233
|
-
*/
|
|
212
|
+
<script>
|
|
234
213
|
export default {
|
|
235
|
-
|
|
236
|
-
}
|
|
237
|
-
type RealProps = {
|
|
238
|
-
/** The total number of pages. */
|
|
239
|
-
total: number
|
|
240
|
-
/** The number of the current page. It must be valid, between 0 - total or the component will throw an error. */
|
|
241
|
-
current: number
|
|
242
|
-
/** The base route/link path for the page. Should end with a forward slash `/`. */
|
|
243
|
-
route: string
|
|
244
|
-
/**
|
|
245
|
-
* 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.
|
|
246
|
-
*
|
|
247
|
-
* This is because usually we have routes like: `/page/1`, `/page/2`, not `/page/0`.
|
|
248
|
-
*
|
|
249
|
-
* You can use this function to customize things further. For example, make `/page/1` just `/`
|
|
250
|
-
*/
|
|
251
|
-
customRoute?: (route: string, i: number) => { i: number, href: string }
|
|
252
|
-
/** How many extra pages to show to each side of the current page. */
|
|
253
|
-
extraPages?: number
|
|
254
|
-
}
|
|
255
|
-
interface Props
|
|
256
|
-
extends
|
|
257
|
-
/** @vue-ignore */
|
|
258
|
-
Partial<Omit<HTMLAttributes,"class"> & TailwindClassProp>,
|
|
259
|
-
RealProps
|
|
260
|
-
{}
|
|
214
|
+
name: "lib-pagination"
|
|
215
|
+
};
|
|
261
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
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="flex h-full flex-col items-center justify-center ">
|
|
3
|
-
<div class="container mx-auto ">
|
|
2
|
+
<div class="theme-palette flex h-full flex-col items-center justify-center ">
|
|
3
|
+
<div class="theme-palette--container mx-auto ">
|
|
4
4
|
<div class="grid grid-cols-11 gap-2 gap-y-10 px-10">
|
|
5
5
|
<template v-for="color, i in colors" :key="color">
|
|
6
6
|
<div
|
|
7
7
|
:style="`background-color: var(${color});`"
|
|
8
|
-
:class="`h-10 rounded-sm flex items-center justify-center text-fg dark:text-bg`"
|
|
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,25 @@
|
|
|
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.js"
|
|
31
|
-
import {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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.js";
|
|
31
|
+
import {} from "metamorphosis";
|
|
32
|
+
import { baseInteractivePropsDefaults } from "../shared/props.js";
|
|
33
|
+
const props = defineProps(/* @__PURE__ */ _mergeDefaults({
|
|
34
|
+
id: { type: String, required: false },
|
|
35
|
+
disabled: { type: Boolean, required: false },
|
|
36
|
+
readonly: { type: Boolean, required: false },
|
|
37
|
+
border: { type: Boolean, required: false },
|
|
38
|
+
unstyle: { type: Boolean, required: false },
|
|
39
|
+
theme: { type: Object, required: true }
|
|
40
|
+
}, {
|
|
41
|
+
theme: () => ({}),
|
|
42
|
+
...baseInteractivePropsDefaults
|
|
43
|
+
}));
|
|
44
|
+
const exclude = ["--color-bg", "--color-fg"];
|
|
45
|
+
const colors = keys(props.theme.css).filter((key) => key.startsWith("--color") && !exclude.includes(key));
|
|
49
46
|
</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;
|