@witchcraft/ui 0.1.0 → 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.
Files changed (138) hide show
  1. package/dist/module.json +2 -2
  2. package/dist/module.mjs +1 -1
  3. package/dist/runtime/components/Aria/Aria.vue +5 -9
  4. package/dist/runtime/components/Aria/Aria.vue.d.ts +5 -0
  5. package/dist/runtime/components/Icon/Icon.vue +10 -31
  6. package/dist/runtime/components/Icon/Icon.vue.d.ts +21 -0
  7. package/dist/runtime/components/LibButton/LibButton.vue +58 -77
  8. package/dist/runtime/components/LibButton/LibButton.vue.d.ts +36 -0
  9. package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +48 -75
  10. package/dist/runtime/components/LibCheckbox/LibCheckbox.vue.d.ts +42 -0
  11. package/dist/runtime/components/LibColorInput/LibColorInput.vue +63 -108
  12. package/dist/runtime/components/LibColorInput/LibColorInput.vue.d.ts +63 -0
  13. package/dist/runtime/components/LibColorPicker/LibColorPicker.vue +271 -352
  14. package/dist/runtime/components/LibColorPicker/LibColorPicker.vue.d.ts +61 -0
  15. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +32 -57
  16. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue.d.ts +22 -0
  17. package/dist/runtime/components/LibDatePicker/LibDatePicker.vue +17 -38
  18. package/dist/runtime/components/LibDatePicker/LibDatePicker.vue.d.ts +40 -0
  19. package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue +53 -82
  20. package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue.d.ts +34 -0
  21. package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue +50 -67
  22. package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue.d.ts +34 -0
  23. package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue +7 -8
  24. package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue.d.ts +22 -0
  25. package/dist/runtime/components/LibDebug/LibDebug.vue +42 -70
  26. package/dist/runtime/components/LibDebug/LibDebug.vue.d.ts +32 -0
  27. package/dist/runtime/components/LibDevOnly/LibDevOnly.vue +18 -31
  28. package/dist/runtime/components/LibDevOnly/LibDevOnly.vue.d.ts +22 -0
  29. package/dist/runtime/components/LibFileInput/LibFileInput.vue +113 -157
  30. package/dist/runtime/components/LibFileInput/LibFileInput.vue.d.ts +43 -0
  31. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +215 -242
  32. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue.d.ts +165 -0
  33. package/dist/runtime/components/LibLabel/LibLabel.vue +30 -46
  34. package/dist/runtime/components/LibLabel/LibLabel.vue.d.ts +27 -0
  35. package/dist/runtime/components/LibMultiValues/LibMultiValues.vue +44 -59
  36. package/dist/runtime/components/LibMultiValues/LibMultiValues.vue.d.ts +29 -0
  37. package/dist/runtime/components/LibNotifications/LibNotification.vue +32 -49
  38. package/dist/runtime/components/LibNotifications/LibNotification.vue.d.ts +17 -0
  39. package/dist/runtime/components/LibNotifications/LibNotifications.vue +63 -84
  40. package/dist/runtime/components/LibNotifications/LibNotifications.vue.d.ts +13 -0
  41. package/dist/runtime/components/LibPagination/LibPagination.vue +67 -112
  42. package/dist/runtime/components/LibPagination/LibPagination.vue.d.ts +104 -0
  43. package/dist/runtime/components/LibPalette/LibPalette.vue +20 -23
  44. package/dist/runtime/components/LibPalette/LibPalette.vue.d.ts +14 -0
  45. package/dist/runtime/components/LibPopup/LibPopup.vue +314 -352
  46. package/dist/runtime/components/LibPopup/LibPopup.vue.d.ts +46 -0
  47. package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +70 -92
  48. package/dist/runtime/components/LibProgressBar/LibProgressBar.vue.d.ts +41 -0
  49. package/dist/runtime/components/LibRecorder/LibRecorder.vue +133 -178
  50. package/dist/runtime/components/LibRecorder/LibRecorder.vue.d.ts +77 -0
  51. package/dist/runtime/components/LibRoot/LibRoot.vue +73 -100
  52. package/dist/runtime/components/LibRoot/LibRoot.vue.d.ts +41 -0
  53. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue +49 -78
  54. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue.d.ts +35 -0
  55. package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +123 -157
  56. package/dist/runtime/components/LibSuggestions/LibSuggestions.vue.d.ts +94 -0
  57. package/dist/runtime/components/LibTable/LibTable.vue +63 -100
  58. package/dist/runtime/components/LibTable/LibTable.vue.d.ts +45 -0
  59. package/dist/runtime/components/Template/NAME.vue +15 -36
  60. package/dist/runtime/components/Template/NAME.vue.d.ts +17 -0
  61. package/dist/runtime/components/TestControls/TestControls.vue +6 -9
  62. package/dist/runtime/components/TestControls/TestControls.vue.d.ts +5 -0
  63. package/dist/runtime/directives/vResizableCols.js +89 -83
  64. package/dist/types.d.mts +2 -6
  65. package/package.json +11 -11
  66. package/src/runtime/components/Focus.stories.ts +3 -2
  67. package/src/runtime/components/Icon/Icon.vue +0 -1
  68. package/src/runtime/components/LibButton/LibButton.vue +0 -1
  69. package/src/runtime/components/LibCheckbox/LibCheckbox.vue +0 -1
  70. package/src/runtime/components/LibColorInput/LibColorInput.vue +0 -1
  71. package/src/runtime/components/LibColorPicker/utils/safeConvertToHsva.ts +0 -1
  72. package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +0 -1
  73. package/src/runtime/components/LibFileInput/LibFileInput.vue +0 -1
  74. package/src/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +0 -1
  75. package/src/runtime/components/LibMultiValues/LibMultiValues.vue +0 -1
  76. package/src/runtime/components/LibNotifications/LibNotification.vue +0 -1
  77. package/src/runtime/components/LibNotifications/LibNotifications.vue +0 -1
  78. package/src/runtime/components/LibPagination/LibPagination.vue +0 -1
  79. package/src/runtime/components/LibPopup/LibPopup.vue +0 -1
  80. package/src/runtime/components/LibProgressBar/LibProgressBar.vue +0 -1
  81. package/src/runtime/components/LibRecorder/LibRecorder.vue +0 -1
  82. package/src/runtime/components/LibSimpleInput/LibSimpleInput.vue +0 -1
  83. package/src/runtime/components/LibSuggestions/LibSuggestions.vue +0 -1
  84. package/src/runtime/components/LibTable/LibTable.vue +0 -1
  85. package/src/runtime/directives/vResizableCols.ts +79 -73
  86. package/dist/module.cjs +0 -5
  87. package/dist/module.d.ts +0 -36
  88. package/dist/runtime/components/Focus.stories.d.ts +0 -11
  89. package/dist/runtime/components/Focus.stories.js +0 -53
  90. package/dist/runtime/components/LibButton/LibButton.stories.d.ts +0 -12
  91. package/dist/runtime/components/LibButton/LibButton.stories.js +0 -94
  92. package/dist/runtime/components/LibCheckbox/LibCheckbox.stories.d.ts +0 -14
  93. package/dist/runtime/components/LibCheckbox/LibCheckbox.stories.js +0 -29
  94. package/dist/runtime/components/LibColorInput/LibColorInput.stories.d.ts +0 -7
  95. package/dist/runtime/components/LibColorInput/LibColorInput.stories.js +0 -58
  96. package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.d.ts +0 -9
  97. package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.js +0 -68
  98. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.d.ts +0 -7
  99. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.js +0 -36
  100. package/dist/runtime/components/LibDatePicker/LibDatePicker.stories.d.ts +0 -11
  101. package/dist/runtime/components/LibDatePicker/LibDatePicker.stories.js +0 -98
  102. package/dist/runtime/components/LibDebug/LibDebug.stories.d.ts +0 -9
  103. package/dist/runtime/components/LibDebug/LibDebug.stories.js +0 -46
  104. package/dist/runtime/components/LibFileInput/LibFileInput.stories.d.ts +0 -10
  105. package/dist/runtime/components/LibFileInput/LibFileInput.stories.js +0 -63
  106. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.stories.d.ts +0 -33
  107. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.stories.js +0 -384
  108. package/dist/runtime/components/LibLabel/LibLabel.stories.d.ts +0 -6
  109. package/dist/runtime/components/LibLabel/LibLabel.stories.js +0 -25
  110. package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.d.ts +0 -23
  111. package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.js +0 -61
  112. package/dist/runtime/components/LibNotifications/LibNotification.stories.d.ts +0 -15
  113. package/dist/runtime/components/LibNotifications/LibNotification.stories.js +0 -126
  114. package/dist/runtime/components/LibNotifications/LibNotifications.stories.d.ts +0 -6
  115. package/dist/runtime/components/LibNotifications/LibNotifications.stories.js +0 -109
  116. package/dist/runtime/components/LibPagination/LibPagination.stories.d.ts +0 -6
  117. package/dist/runtime/components/LibPagination/LibPagination.stories.js +0 -40
  118. package/dist/runtime/components/LibPalette/LibPalette.stories.d.ts +0 -6
  119. package/dist/runtime/components/LibPalette/LibPalette.stories.js +0 -20
  120. package/dist/runtime/components/LibPopup/LibPopup.stories.d.ts +0 -14
  121. package/dist/runtime/components/LibPopup/LibPopup.stories.js +0 -147
  122. package/dist/runtime/components/LibProgressBar/LibProgressBar.stories.d.ts +0 -10
  123. package/dist/runtime/components/LibProgressBar/LibProgressBar.stories.js +0 -81
  124. package/dist/runtime/components/LibRecorder/LibRecorder.stories.d.ts +0 -19
  125. package/dist/runtime/components/LibRecorder/LibRecorder.stories.js +0 -63
  126. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.d.ts +0 -26
  127. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.js +0 -78
  128. package/dist/runtime/components/LibSuggestions/LibSuggestions.stories.d.ts +0 -27
  129. package/dist/runtime/components/LibSuggestions/LibSuggestions.stories.js +0 -112
  130. package/dist/runtime/components/LibTable/LibTable.stories.d.ts +0 -16
  131. package/dist/runtime/components/LibTable/LibTable.stories.js +0 -156
  132. package/dist/runtime/components/Reset.stories.d.ts +0 -5
  133. package/dist/runtime/components/Reset.stories.js +0 -19
  134. package/dist/runtime/components/Scrolling.stories.d.ts +0 -6
  135. package/dist/runtime/components/Scrolling.stories.js +0 -44
  136. package/dist/runtime/composables/useScrollNearContainerEdges.stories.d.ts +0 -7
  137. package/dist/runtime/composables/useScrollNearContainerEdges.stories.js +0 -85
  138. 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
- `, ($attrs as any).class)"
14
- v-bind="{ ...$attrs, class: undefined }"
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`, ($attrs as any).class)"
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
- `, ($attrs as any).class)"
38
+ `, $attrs.class)"
39
39
  ref="dialogEl"
40
40
  @click.self.prevent="topNotifications[0] && NotificationHandler.dismiss(topNotifications[0])"
41
41
  >
@@ -50,93 +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.js";
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
- name: "lib-notifications",
66
- inheritAttrs: false,
67
- })
68
-
69
-
70
- // eslint-disable-next-line no-use-before-define
71
- const props = defineProps<Props>()
72
-
73
- const dialogEl = ref<HTMLDialogElement | null>(null)
74
-
75
- const isOpen = ref(false)
76
- const notifications = shallowReactive<NotificationEntry[]>([])
77
- 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([]);
78
73
  const open = () => {
79
- if (!isOpen.value) {
80
- void nextTick(() => {
81
- dialogEl.value!.showModal()
82
- isOpen.value = true
83
- })
84
- }
85
- }
74
+ if (!isOpen.value) {
75
+ void nextTick(() => {
76
+ dialogEl.value.showModal();
77
+ isOpen.value = true;
78
+ });
79
+ }
80
+ };
86
81
  const close = () => {
87
- if (isOpen.value && topNotifications.length === 0) {
88
- dialogEl.value!.close()
89
- isOpen.value = false
90
- }
91
- }
92
-
93
- const addNotification = (entry: NotificationEntry) => {
94
- if (entry.resolution === undefined) {
95
- if (entry.requiresAction) {
96
- topNotifications.push(entry)
97
- open()
98
- entry.promise.then(() => {
99
- removeIfIn(topNotifications, entry)
100
- close()
101
- })
102
- } else {
103
- notifications.splice(0, 0, entry)
104
- entry.promise.then(() => {
105
- removeIfIn(notifications, entry)
106
- })
107
- }
108
- }
109
- }
110
-
111
- const notificationListener = (entry: NotificationEntry, type: "added" | "resolved" | "deleted"): void => {
112
- if (type === "added") {
113
- addNotification(entry)
114
- }
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);
115
113
  }
116
-
117
- const handler = props.handler ?? useNotificationHandler()
118
-
119
- handler.addNotificationListener(notificationListener)
120
-
121
- for (const entry of handler.queue) { addNotification(entry) }
122
114
  onBeforeUnmount(() => {
123
- handler.removeNotificationListener(notificationListener)
124
- })
125
-
115
+ handler.removeNotificationListener(notificationListener);
116
+ });
126
117
  </script>
127
- <script lang="ts">
128
118
 
129
- type RealProps =
130
- & LinkableByIdProps
131
- & {
132
- /** If not provided, uses the global handler (this requires useNotificationHandler be called and configured). */
133
- handler?: NotificationHandler
134
- }
119
+ <script>
135
120
 
136
- interface Props
137
- extends
138
- /** @vue-ignore */
139
- Partial<Omit<HTMLAttributes,"class"> & TailwindClassProp>,
140
- RealProps
141
- {}
142
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
- `, ($attrs as any).class)"
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=" t('pagination.aria.go-to-previous-page',{count:prevLink.i})"
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=" t('pagination.aria.go-to-previous-page', {count:prevLink.i})"
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,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
- name: "lib-pagination",
170
- inheritAttrs: false,
171
- })
172
-
173
- // eslint-disable-next-line no-use-before-define
174
- const props = withDefaults(defineProps<Props>(), {
175
- customRoute: (route: string, i: number) => {
176
- if (i === 0 || i === 1) {
177
- const num = 1
178
- return { href: route, i: num }
179
- }
180
- return { href: route + i.toString(), i }
181
- },
182
- extraPages: 3,
183
- })
184
- const $attrs = useAttrs()
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
- if (currentIsInvalid.value) {
191
- throw new Error(`Current page is out of range: 0 - ${props.total}`)
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
- const maybeNextLink = props.customRoute(props.route, props.current + 1)
199
- if (maybeNextLink.i === currentLink.value.i) {
200
- return props.customRoute(props.route, props.current + 2)
201
- }
202
- return maybeNextLink
203
- })
204
-
205
- const firstLink = computed(() => props.customRoute(props.route, 0))
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
- const num = currentLink.value.i - (props.extraPages - _i)
211
- if (num <= firstLink.value.i || num >= lastLink.value.i || num >= currentLink.value.i) return undefined
212
- return props.customRoute(props.route, num)
213
- }).filter(entry => entry !== undefined) as HrefInfo[])
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
- const num = currentLink.value.i + i
217
- if (num <= firstLink.value.i || num >= lastLink.value.i || num <= currentLink.value.i) return undefined
218
- return props.customRoute(props.route, num)
219
- }).filter(entry => entry !== undefined).slice(0, props.extraPages) as HrefInfo[])
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
- name: "lib-pagination",
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
+ };
@@ -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) ? 'Text':'' }}
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 lang="ts">
26
- export default { name: "lib-palette" }
25
+ <script>
26
+ export default { name: "lib-palette" };
27
27
  </script>
28
28
 
29
- <script setup lang="ts">
30
- import { keys } from "@alanscodelog/utils/keys.js"
31
- import { type Theme } from "metamorphosis"
32
-
33
- import { type BaseInteractiveProps, baseInteractivePropsDefaults,type LinkableByIdProps } from "../shared/props.js"
34
-
35
-
36
- const props = withDefaults(defineProps<
37
- & LinkableByIdProps
38
- & BaseInteractiveProps
39
- & {
40
- theme: Theme
41
- }>(), {
42
- theme: () => ({} as any),
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.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;