sprintify-ui 0.0.0

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 (176) hide show
  1. package/README.md +188 -0
  2. package/dist/types/src/components/BaseAlert.vue.d.ts +51 -0
  3. package/dist/types/src/components/BaseAutocomplete.vue.d.ts +268 -0
  4. package/dist/types/src/components/BaseAutocompleteFetch.vue.d.ts +273 -0
  5. package/dist/types/src/components/BaseAvatar.vue.d.ts +126 -0
  6. package/dist/types/src/components/BaseBadge.vue.d.ts +94 -0
  7. package/dist/types/src/components/BaseBelongsTo.vue.d.ts +268 -0
  8. package/dist/types/src/components/BaseBoolean.vue.d.ts +64 -0
  9. package/dist/types/src/components/BaseBreadcrumbs.vue.d.ts +66 -0
  10. package/dist/types/src/components/BaseButton.vue.d.ts +23 -0
  11. package/dist/types/src/components/BaseCard.vue.d.ts +74 -0
  12. package/dist/types/src/components/BaseCardRow.vue.d.ts +16 -0
  13. package/dist/types/src/components/BaseClipboard.vue.d.ts +74 -0
  14. package/dist/types/src/components/BaseContainer.vue.d.ts +34 -0
  15. package/dist/types/src/components/BaseCounter.vue.d.ts +125 -0
  16. package/dist/types/src/components/BaseDataIterator.vue.d.ts +345 -0
  17. package/dist/types/src/components/BaseDataTable.vue.d.ts +657 -0
  18. package/dist/types/src/components/BaseDataTableToggleColumns.vue.d.ts +1281 -0
  19. package/dist/types/src/components/BaseDatePicker.vue.d.ts +190 -0
  20. package/dist/types/src/components/BaseDateSelect.vue.d.ts +171 -0
  21. package/dist/types/src/components/BaseDescriptionList.vue.d.ts +48 -0
  22. package/dist/types/src/components/BaseDescriptionListItem.vue.d.ts +49 -0
  23. package/dist/types/src/components/BaseDialog.vue.d.ts +160 -0
  24. package/dist/types/src/components/BaseFilePicker.vue.d.ts +44 -0
  25. package/dist/types/src/components/BaseFileUploader.vue.d.ts +220 -0
  26. package/dist/types/src/components/BaseInput.vue.d.ts +209 -0
  27. package/dist/types/src/components/BaseInputLabel.vue.d.ts +31 -0
  28. package/dist/types/src/components/BaseLoadingCover.vue.d.ts +166 -0
  29. package/dist/types/src/components/BaseLoadingPage.vue.d.ts +2 -0
  30. package/dist/types/src/components/BaseMediaLibrary.vue.d.ts +269 -0
  31. package/dist/types/src/components/BaseMediaLibraryItem.vue.d.ts +75 -0
  32. package/dist/types/src/components/BaseMenu.vue.d.ts +117 -0
  33. package/dist/types/src/components/BaseMenuItem.vue.d.ts +147 -0
  34. package/dist/types/src/components/BaseModalCenter.vue.d.ts +141 -0
  35. package/dist/types/src/components/BaseModalSide.vue.d.ts +141 -0
  36. package/dist/types/src/components/BaseNavbar.vue.d.ts +79 -0
  37. package/dist/types/src/components/BaseNavbarItem.vue.d.ts +80 -0
  38. package/dist/types/src/components/BaseNavbarItemContent.vue.d.ts +127 -0
  39. package/dist/types/src/components/BasePagination.vue.d.ts +25 -0
  40. package/dist/types/src/components/BasePaginationSimple.vue.d.ts +25 -0
  41. package/dist/types/src/components/BasePanel.vue.d.ts +31 -0
  42. package/dist/types/src/components/BasePassword.vue.d.ts +66 -0
  43. package/dist/types/src/components/BaseProcessRing.vue.d.ts +36 -0
  44. package/dist/types/src/components/BaseReadMore.vue.d.ts +74 -0
  45. package/dist/types/src/components/BaseSelect.vue.d.ts +55 -0
  46. package/dist/types/src/components/BaseSideNavigation.vue.d.ts +48 -0
  47. package/dist/types/src/components/BaseSideNavigationItem.vue.d.ts +92 -0
  48. package/dist/types/src/components/BaseSkeleton.vue.d.ts +93 -0
  49. package/dist/types/src/components/BaseSpinner.vue.d.ts +2 -0
  50. package/dist/types/src/components/BaseSwitch.vue.d.ts +39 -0
  51. package/dist/types/src/components/BaseSystemAlert.vue.d.ts +141 -0
  52. package/dist/types/src/components/BaseTabItem.vue.d.ts +70 -0
  53. package/dist/types/src/components/BaseTable.vue.d.ts +467 -0
  54. package/dist/types/src/components/BaseTableColumn.vue.d.ts +164 -0
  55. package/dist/types/src/components/BaseTabs.vue.d.ts +48 -0
  56. package/dist/types/src/components/BaseTagAutocomplete.vue.d.ts +274 -0
  57. package/dist/types/src/components/BaseTagAutocompleteFetch.vue.d.ts +251 -0
  58. package/dist/types/src/components/BaseTextarea.vue.d.ts +228 -0
  59. package/dist/types/src/components/BaseTextareaAutoresize.vue.d.ts +44 -0
  60. package/dist/types/src/components/BaseTitle.vue.d.ts +45 -0
  61. package/dist/types/src/components/BaseWordCount.vue.d.ts +31 -0
  62. package/dist/types/src/components/SlotComponent.d.ts +43 -0
  63. package/dist/types/src/components/index.d.ts +2 -0
  64. package/dist/types/src/composables/breakpoints.d.ts +12 -0
  65. package/dist/types/src/composables/modal.d.ts +6 -0
  66. package/dist/types/src/constants/MyConstants.d.ts +1 -0
  67. package/dist/types/src/constants/index.d.ts +2 -0
  68. package/dist/types/src/index.d.ts +253 -0
  69. package/dist/types/src/types/Media.d.ts +8 -0
  70. package/dist/types/src/types/UploadedFile.d.ts +9 -0
  71. package/dist/types/src/types/User.d.ts +6 -0
  72. package/dist/types/src/types/types.d.ts +88 -0
  73. package/dist/types/src/utils/fileSizeFormat.d.ts +1 -0
  74. package/dist/types/src/utils/index.d.ts +4 -0
  75. package/dist/types/src/utils/scrollPreventer.d.ts +4 -0
  76. package/dist/types/src/utils/toHumanList.d.ts +1 -0
  77. package/package.json +99 -0
  78. package/src/assets/button.css +80 -0
  79. package/src/assets/form.css +15 -0
  80. package/src/assets/main.css +3 -0
  81. package/src/assets/pikaday.css +134 -0
  82. package/src/assets/tailwind.css +5 -0
  83. package/src/components/BaseAlert.stories.js +52 -0
  84. package/src/components/BaseAlert.vue +152 -0
  85. package/src/components/BaseAutocomplete.stories.js +127 -0
  86. package/src/components/BaseAutocomplete.vue +376 -0
  87. package/src/components/BaseAutocompleteFetch.stories.js +121 -0
  88. package/src/components/BaseAutocompleteFetch.vue +185 -0
  89. package/src/components/BaseAvatar.stories.js +39 -0
  90. package/src/components/BaseAvatar.vue +92 -0
  91. package/src/components/BaseBadge.stories.js +61 -0
  92. package/src/components/BaseBadge.vue +70 -0
  93. package/src/components/BaseBelongsTo.stories.js +130 -0
  94. package/src/components/BaseBelongsTo.vue +122 -0
  95. package/src/components/BaseBoolean.stories.js +35 -0
  96. package/src/components/BaseBoolean.vue +29 -0
  97. package/src/components/BaseBreadcrumbs.stories.js +45 -0
  98. package/src/components/BaseBreadcrumbs.vue +78 -0
  99. package/src/components/BaseButton.stories.js +80 -0
  100. package/src/components/BaseButton.vue +39 -0
  101. package/src/components/BaseCard.stories.js +61 -0
  102. package/src/components/BaseCard.vue +49 -0
  103. package/src/components/BaseCardRow.vue +34 -0
  104. package/src/components/BaseClipboard.stories.js +31 -0
  105. package/src/components/BaseClipboard.vue +96 -0
  106. package/src/components/BaseContainer.stories.js +34 -0
  107. package/src/components/BaseContainer.vue +50 -0
  108. package/src/components/BaseCounter.stories.js +32 -0
  109. package/src/components/BaseCounter.vue +72 -0
  110. package/src/components/BaseDataIterator.stories.js +90 -0
  111. package/src/components/BaseDataIterator.vue +658 -0
  112. package/src/components/BaseDataTable.stories.js +95 -0
  113. package/src/components/BaseDataTable.vue +489 -0
  114. package/src/components/BaseDataTableToggleColumns.vue +69 -0
  115. package/src/components/BaseDatePicker.stories.js +53 -0
  116. package/src/components/BaseDatePicker.vue +166 -0
  117. package/src/components/BaseDateSelect.vue +192 -0
  118. package/src/components/BaseDescriptionList.vue +11 -0
  119. package/src/components/BaseDescriptionListItem.vue +12 -0
  120. package/src/components/BaseDialog.vue +104 -0
  121. package/src/components/BaseFilePicker.vue +101 -0
  122. package/src/components/BaseFileUploader.vue +166 -0
  123. package/src/components/BaseInput.vue +82 -0
  124. package/src/components/BaseInputLabel.vue +26 -0
  125. package/src/components/BaseLoadingCover.vue +84 -0
  126. package/src/components/BaseLoadingPage.vue +19 -0
  127. package/src/components/BaseMediaLibrary.vue +281 -0
  128. package/src/components/BaseMediaLibraryItem.vue +92 -0
  129. package/src/components/BaseMenu.vue +114 -0
  130. package/src/components/BaseMenuItem.vue +93 -0
  131. package/src/components/BaseModalCenter.vue +107 -0
  132. package/src/components/BaseModalSide.vue +112 -0
  133. package/src/components/BaseNavbar.vue +72 -0
  134. package/src/components/BaseNavbarItem.vue +72 -0
  135. package/src/components/BaseNavbarItemContent.vue +57 -0
  136. package/src/components/BasePagination.vue +82 -0
  137. package/src/components/BasePaginationSimple.vue +60 -0
  138. package/src/components/BasePanel.vue +39 -0
  139. package/src/components/BasePassword.vue +73 -0
  140. package/src/components/BaseProcessRing.vue +56 -0
  141. package/src/components/BaseReadMore.vue +72 -0
  142. package/src/components/BaseSelect.vue +59 -0
  143. package/src/components/BaseSideNavigation.vue +7 -0
  144. package/src/components/BaseSideNavigationItem.vue +42 -0
  145. package/src/components/BaseSkeleton.vue +24 -0
  146. package/src/components/BaseSpinner.vue +47 -0
  147. package/src/components/BaseSwitch.vue +87 -0
  148. package/src/components/BaseSystemAlert.vue +86 -0
  149. package/src/components/BaseTabItem.vue +30 -0
  150. package/src/components/BaseTable.vue +781 -0
  151. package/src/components/BaseTableColumn.vue +109 -0
  152. package/src/components/BaseTabs.vue +12 -0
  153. package/src/components/BaseTagAutocomplete.vue +385 -0
  154. package/src/components/BaseTagAutocompleteFetch.vue +154 -0
  155. package/src/components/BaseTextarea.vue +73 -0
  156. package/src/components/BaseTextareaAutoresize.vue +117 -0
  157. package/src/components/BaseTitle.vue +80 -0
  158. package/src/components/BaseWordCount.vue +36 -0
  159. package/src/components/SlotComponent.ts +37 -0
  160. package/src/components/index.ts +5 -0
  161. package/src/composables/breakpoints.ts +6 -0
  162. package/src/composables/modal.ts +77 -0
  163. package/src/constants/MyConstants.ts +1 -0
  164. package/src/constants/index.ts +5 -0
  165. package/src/env.d.ts +15 -0
  166. package/src/index.ts +70 -0
  167. package/src/lang/en.json +56 -0
  168. package/src/lang/fr.json +56 -0
  169. package/src/types/Media.ts +9 -0
  170. package/src/types/UploadedFile.ts +10 -0
  171. package/src/types/User.ts +7 -0
  172. package/src/types/types.ts +112 -0
  173. package/src/utils/fileSizeFormat.ts +15 -0
  174. package/src/utils/index.ts +5 -0
  175. package/src/utils/scrollPreventer.ts +21 -0
  176. package/src/utils/toHumanList.ts +20 -0
@@ -0,0 +1,95 @@
1
+ import BaseDataTable from './BaseDataTable.vue';
2
+ import BaseTableColumn from './BaseTableColumn.vue';
3
+ import BaseBoolean from './BaseBoolean.vue';
4
+
5
+ export default {
6
+ title: 'Data/BaseDataTable',
7
+ component: BaseDataTable,
8
+ argTypes: {},
9
+ args: {
10
+ url: 'https://effettandem.com/api/content/articles',
11
+ resource: 'articles',
12
+ urlQuery: {
13
+ per_page: 5,
14
+ },
15
+ historyMode: false,
16
+ },
17
+ };
18
+
19
+ const template = `
20
+ <BaseDataTable v-bind="args">
21
+ <BaseTableColumn
22
+ v-slot="{ row }"
23
+ label="Titre"
24
+ sortable
25
+ field="title->en"
26
+ >
27
+ <div class="max-w-sm">
28
+ <div class="font-medium text-slate-900">
29
+ {{ row.title }}
30
+ </div>
31
+ <p class="text-xs leading-tight text-slate-500">
32
+ {{ row.subtitle }}
33
+ </p>
34
+ <div>
35
+ </BaseTableColumn>
36
+
37
+ <BaseTableColumn
38
+ v-slot="{ row }"
39
+ label="VIP"
40
+ field="access_level"
41
+ sortable
42
+ >
43
+ <BaseBoolean :model-value="row.access_level == 'vip'" />
44
+ </BaseTableColumn>
45
+
46
+ <BaseTableColumn
47
+ v-slot="{ row }"
48
+ label="Vote"
49
+ field="votes_avg_score"
50
+ sortable
51
+ >
52
+ <div class="">
53
+ {{ Math.round(row.votes_avg_score) }} / 5
54
+ </div>
55
+ </BaseTableColumn>
56
+ </BaseDataTable>
57
+ `;
58
+
59
+ const Template = (args) => ({
60
+ components: { BaseDataTable, BaseTableColumn, BaseBoolean },
61
+ setup() {
62
+ return { args };
63
+ },
64
+ template: template,
65
+ });
66
+
67
+ export const Demo = Template.bind({});
68
+ Demo.args = {
69
+ searchable: true,
70
+ actions: [
71
+ {
72
+ label: 'Open Google',
73
+ icon: 'heroicons:link',
74
+ href: 'https://google.com',
75
+ },
76
+ {
77
+ label: 'Export',
78
+ icon: 'heroicons:table-cells',
79
+ action: () => alert('export!'),
80
+ },
81
+ { line: true },
82
+ {
83
+ label: 'Delete all',
84
+ icon: 'heroicons:trash',
85
+ action: () => alert('Delete All!'),
86
+ color: 'danger',
87
+ },
88
+ ],
89
+ };
90
+
91
+ export const Simple = Template.bind({});
92
+ Simple.args = {
93
+ searchable: false,
94
+ actions: [],
95
+ };
@@ -0,0 +1,489 @@
1
+ <template>
2
+ <BaseDataIterator
3
+ ref="dataIterator"
4
+ :url="url"
5
+ :route-key-name="routeKeyName"
6
+ :url-query="urlQuery"
7
+ :default-query="defaultQuery"
8
+ :searchable="searchable"
9
+ :actions="actions"
10
+ :history-mode="historyMode"
11
+ >
12
+ <template
13
+ #default="{
14
+ items,
15
+ loading,
16
+ sortField,
17
+ sortDirection,
18
+ onSortChange,
19
+ error,
20
+ firstLoad,
21
+ }"
22
+ >
23
+ <BaseCard clipped class="isolate w-full overflow-hidden">
24
+ <BaseTable
25
+ ref="table"
26
+ :data="items"
27
+ :loading="loading"
28
+ :detailed="detailed"
29
+ :has-detailed-visible="hasDetailedVisible"
30
+ :checkable="checkable"
31
+ :checkable-actions="checkableActions"
32
+ :checked-rows="checkedRows"
33
+ :is-row-checkable="isRowCheckable"
34
+ checkbox-position="left"
35
+ :sort-field="sortField"
36
+ :sort-direction="sortDirection"
37
+ :max-height="maxHeight"
38
+ :visible-columns="visibleColumns"
39
+ @sort="onSortChange"
40
+ @check="$emit('check', $event)"
41
+ @update:checked-rows="$emit('update:checked-rows', $event)"
42
+ @check-all="$emit('checkAll', $event)"
43
+ @click="onClick"
44
+ >
45
+ <template #default>
46
+ <slot />
47
+
48
+ <BaseTableColumn
49
+ v-slot="{ row }"
50
+ :visible="editButton || deleteButton || $slots.rowActions != null"
51
+ :always-visible="true"
52
+ >
53
+ <div class="flex justify-end text-right">
54
+ <slot name="rowActions" :row="row" />
55
+
56
+ <router-link
57
+ v-if="editButton && editUrl"
58
+ :to="editUrl(row)"
59
+ :disabled="!canUpdate(row)"
60
+ >
61
+ <button class="btn btn-white p-2">
62
+ <Icon
63
+ icon="heroicons:cog-6-tooth-solid"
64
+ class="text-slate-500"
65
+ />
66
+ </button>
67
+ </router-link>
68
+
69
+ <button
70
+ v-if="deleteButton && deleteUrl"
71
+ type="button"
72
+ class="btn btn-white p-2"
73
+ :disabled="!canDelete(row)"
74
+ @click="onDeleteClick(row)"
75
+ >
76
+ <Icon icon="heroicons:trash-solid" class="text-slate-500" />
77
+ </button>
78
+ </div>
79
+ </BaseTableColumn>
80
+ </template>
81
+
82
+ <template #detail="propsDetail">
83
+ <slot name="detail" v-bind="propsDetail" />
84
+ </template>
85
+
86
+ <template #checkedHeader="propsCheckHeader">
87
+ <slot name="checkedHeader" v-bind="propsCheckHeader" />
88
+ </template>
89
+
90
+ <template #empty>
91
+ <div v-if="error" class="flex items-center justify-center py-16">
92
+ <div class="flex flex-col items-center justify-center">
93
+ <Icon
94
+ icon="heroicons:x-circle"
95
+ class="h-10 w-10 text-red-600"
96
+ />
97
+ <p class="mt-3 text-center text-sm text-slate-600">
98
+ {{ $t('sui.whoops') }}
99
+ </p>
100
+ </div>
101
+ </div>
102
+ <div
103
+ v-else-if="firstLoad"
104
+ class="flex items-center justify-center py-16"
105
+ >
106
+ <div class="flex flex-col items-center">
107
+ <img
108
+ :src="'/img/empty-states/data.svg'"
109
+ alt="No data"
110
+ width="100"
111
+ />
112
+ <p class="mt-3 text-center text-sm text-slate-600">
113
+ {{ $t('sui.nothing_found') }}
114
+ </p>
115
+ </div>
116
+ </div>
117
+ </template>
118
+ </BaseTable>
119
+ </BaseCard>
120
+ </template>
121
+
122
+ <template
123
+ v-if="$slots.filters"
124
+ #filters="{ query, updateQuery, updateQueryValue }"
125
+ >
126
+ <slot
127
+ name="filters"
128
+ :query="query"
129
+ :update-query="updateQuery"
130
+ :update-query-value="updateQueryValue"
131
+ />
132
+ </template>
133
+
134
+ <template #sidebarTop="sidebarProps">
135
+ <slot name="sidebarTop" v-bind="sidebarProps"></slot>
136
+ </template>
137
+
138
+ <template #sidebarBottom>
139
+ <div class="mb-3">
140
+ <h3
141
+ class="mb-1 text-xs font-semibold uppercase tracking-wider text-slate-500"
142
+ >
143
+ {{ $t('sui.columns') }}
144
+ </h3>
145
+ <BaseCard>
146
+ <BaseCardRow size="sm">
147
+ <BaseDataTableToggleColumns
148
+ v-model:visibleColumns="visibleColumns"
149
+ :table="table"
150
+ @update:visible-columns="onUpdateVisibleColumn"
151
+ ></BaseDataTableToggleColumns>
152
+ </BaseCardRow>
153
+ </BaseCard>
154
+ </div>
155
+ </template>
156
+ </BaseDataIterator>
157
+ </template>
158
+
159
+ <script lang="ts" setup>
160
+ import { PropType, Ref } from 'vue';
161
+ import {
162
+ CollectionItem,
163
+ DataTableQuery,
164
+ MenuItemInterface,
165
+ } from '@/types/types';
166
+ import { useDialogsStore } from '../stores/dialogs';
167
+ import { useNotificationsStore } from '../stores/notifications';
168
+ import BaseDataIterator from './BaseDataIterator.vue';
169
+ import { isArray } from 'lodash';
170
+
171
+ import BaseCard from './BaseCard.vue';
172
+ import BaseCardRow from './BaseCardRow.vue';
173
+ import BaseTable from './BaseTable.vue';
174
+ import BaseTableColumn from './BaseTableColumn.vue';
175
+ import BaseDataTableToggleColumns from './BaseDataTableToggleColumns.vue';
176
+ import { config } from 'src';
177
+
178
+ const i18n = useI18n();
179
+
180
+ const http = config.http;
181
+
182
+ const dialogs = useDialogsStore();
183
+ const notifications = useNotificationsStore();
184
+
185
+ const table = ref(null) as Ref<null | InstanceType<typeof BaseTable>>;
186
+
187
+ const props = defineProps({
188
+ /**
189
+ * Base URL from which to make requests
190
+ */
191
+ url: {
192
+ required: true,
193
+ type: String,
194
+ },
195
+
196
+ /**
197
+ * Show/Hide edit button
198
+ */
199
+ editButton: {
200
+ default: true,
201
+ type: Boolean,
202
+ },
203
+
204
+ /**
205
+ * Show/Hide delete button
206
+ */
207
+ deleteButton: {
208
+ default: true,
209
+ type: Boolean,
210
+ },
211
+
212
+ /**
213
+ * Route key name for Laravel route model binding
214
+ */
215
+ routeKeyName: {
216
+ default: 'id',
217
+ type: String,
218
+ },
219
+
220
+ /**
221
+ * Query params that always get applied
222
+ */
223
+ urlQuery: {
224
+ default: undefined,
225
+ type: Object as PropType<Record<string, any>>,
226
+ },
227
+
228
+ /**
229
+ * Query params that gets applied by default
230
+ * These may be overwritten by URL params generated by the data-table or filters
231
+ */
232
+ defaultQuery: {
233
+ default: undefined,
234
+ type: Object as PropType<DataTableQuery>,
235
+ },
236
+
237
+ /**
238
+ * Edit url for router link
239
+ */
240
+ editUrl: {
241
+ default: undefined,
242
+ type: Function as PropType<(row: CollectionItem) => string>,
243
+ },
244
+
245
+ /**
246
+ * Delete endpoint to delete an item
247
+ */
248
+ deleteUrl: {
249
+ default: undefined,
250
+ type: Function as PropType<(row: CollectionItem) => string>,
251
+ },
252
+
253
+ /**
254
+ * Show toggle-able details on each row
255
+ */
256
+ detailed: {
257
+ default: false,
258
+ type: Boolean,
259
+ },
260
+
261
+ /**
262
+ * Has detailed visible
263
+ */
264
+ hasDetailedVisible: {
265
+ default() {
266
+ return true;
267
+ },
268
+ type: Function as PropType<(row: any) => boolean>,
269
+ },
270
+
271
+ /**
272
+ * Makes row checkable
273
+ */
274
+ checkable: {
275
+ default: false,
276
+ type: Boolean,
277
+ },
278
+
279
+ /**
280
+ * Actions on each row
281
+ */
282
+ checkableActions: {
283
+ default: undefined,
284
+ type: Array as PropType<MenuItemInterface[]>,
285
+ },
286
+
287
+ /**
288
+ * Checked rows array
289
+ */
290
+ checkedRows: {
291
+ default() {
292
+ return [];
293
+ },
294
+ type: Array as PropType<Record<string, any>[]>,
295
+ },
296
+
297
+ /**
298
+ * Check is a given row is checkable
299
+ */
300
+ isRowCheckable: {
301
+ default() {
302
+ return () => true;
303
+ },
304
+ type: Function,
305
+ },
306
+
307
+ /**
308
+ * Adds a search bar
309
+ */
310
+ searchable: {
311
+ default: true,
312
+ type: Boolean,
313
+ },
314
+
315
+ /**
316
+ * Actions
317
+ */
318
+ actions: {
319
+ default: undefined,
320
+ type: Array as PropType<MenuItemInterface[]>,
321
+ },
322
+
323
+ /**
324
+ * Save data table state in URL
325
+ */
326
+ historyMode: {
327
+ default: true,
328
+ type: Boolean,
329
+ },
330
+
331
+ /*
332
+ * Max height (in px)
333
+ */
334
+ maxHeight: {
335
+ default: undefined,
336
+ type: Number,
337
+ },
338
+ });
339
+
340
+ const emit = defineEmits([
341
+ 'click',
342
+ 'delete',
343
+ 'checkAll',
344
+ 'update:checked-rows',
345
+ 'check',
346
+ ]);
347
+
348
+ const dataIterator = ref(null) as Ref<null | InstanceType<
349
+ typeof BaseDataIterator
350
+ >>;
351
+
352
+ /*
353
+ |--------------------------------------------------------------------------
354
+ | Handlers
355
+ |--------------------------------------------------------------------------
356
+ */
357
+
358
+ function onClick(payload: CollectionItem) {
359
+ emit('click', payload);
360
+ }
361
+
362
+ /*
363
+ |--------------------------------------------------------------------------
364
+ | Gate helpers
365
+ |--------------------------------------------------------------------------
366
+ */
367
+
368
+ const gate = (row: CollectionItem, action: string): boolean => {
369
+ if (row.can && Object.prototype.hasOwnProperty.call(row.can, action)) {
370
+ return row.can[action];
371
+ }
372
+ return true;
373
+ };
374
+
375
+ const canUpdate = (row: CollectionItem): boolean => {
376
+ return gate(row, 'update');
377
+ };
378
+
379
+ const canDelete = (row: CollectionItem): boolean => {
380
+ return gate(row, 'delete');
381
+ };
382
+
383
+ function onDeleteClick(row: CollectionItem) {
384
+ dialogs.push({
385
+ title: i18n.t('sui.delete_record') + '?',
386
+ message: i18n.t('sui.delete_record_description'),
387
+ color: 'danger',
388
+ closeOnOutsideClick: false,
389
+ confirmText: i18n.t('sui.yes_delete'),
390
+ onConfirm: () => onDelete(row),
391
+ });
392
+ }
393
+
394
+ const onDelete = (row: CollectionItem) => {
395
+ if (!props.deleteUrl) {
396
+ return;
397
+ }
398
+
399
+ http.delete(props.deleteUrl(row)).then((response) => {
400
+ if (response.data && response.data.message) {
401
+ notifications.push({
402
+ title: i18n.t('sui.success'),
403
+ text: response.data.message,
404
+ color: 'success',
405
+ });
406
+ }
407
+ emit('delete', row);
408
+
409
+ // Refetch even if URL is the same
410
+ fetch();
411
+ });
412
+ };
413
+
414
+ /*
415
+ |--------------------------------------------------------------------------
416
+ | Toggle columns
417
+ |--------------------------------------------------------------------------
418
+ */
419
+
420
+ const visibleColumns = ref([]) as Ref<number[]>;
421
+
422
+ // Find visible columns in local storage
423
+ const VISIBLE_COLUMNS_LOCAL_STORAGE = 'sprintify.visible_columns.';
424
+ const VISIBLE_COLUMNS_LOCAL_STORAGE_KEY =
425
+ VISIBLE_COLUMNS_LOCAL_STORAGE + window.location.pathname;
426
+
427
+ const visibleColumnsFromStorage = JSON.parse(
428
+ localStorage.getItem(VISIBLE_COLUMNS_LOCAL_STORAGE_KEY) + ''
429
+ ) as number[];
430
+
431
+ // If found, set visibleColumns
432
+ if (
433
+ visibleColumnsFromStorage &&
434
+ isArray(visibleColumnsFromStorage) &&
435
+ visibleColumnsFromStorage.length > 0
436
+ ) {
437
+ visibleColumns.value = visibleColumnsFromStorage;
438
+ }
439
+
440
+ // If nothing is found, set visibleColumns to all non optional columns from table
441
+ const unWatchTable = watch(
442
+ () => table.value,
443
+ () => {
444
+ if (
445
+ table.value &&
446
+ table.value.newColumns.length &&
447
+ visibleColumns.value.length == 0
448
+ ) {
449
+ visibleColumns.value = table.value.newColumns
450
+ .filter((c) => !c.optional)
451
+ .map((c) => c.newKey);
452
+ unWatchTable();
453
+ }
454
+ }
455
+ );
456
+
457
+ /**
458
+ * Update local storage when check input update
459
+ */
460
+ function onUpdateVisibleColumn() {
461
+ localStorage.setItem(
462
+ VISIBLE_COLUMNS_LOCAL_STORAGE_KEY,
463
+ JSON.stringify(visibleColumns.value)
464
+ );
465
+ }
466
+
467
+ /*
468
+ |--------------------------------------------------------------------------
469
+ | Exposed functions
470
+ |--------------------------------------------------------------------------
471
+ */
472
+
473
+ function fetch() {
474
+ if (!dataIterator.value) {
475
+ return;
476
+ }
477
+ // Refetch even if URL is the same
478
+ dataIterator.value.fetch(true);
479
+ }
480
+
481
+ const dataIteratorQuery = computed((): DataTableQuery | null => {
482
+ return dataIterator.value?.query ?? null;
483
+ });
484
+
485
+ defineExpose({
486
+ fetch,
487
+ query: dataIteratorQuery,
488
+ });
489
+ </script>
@@ -0,0 +1,69 @@
1
+ <template>
2
+ <ul>
3
+ <li v-for="col in toggleableColumns" :key="col.newKey">
4
+ <label>
5
+ <input
6
+ :checked="visibleColumns.includes(col.newKey)"
7
+ type="checkbox"
8
+ class="mr-1.5 h-3.5 w-3.5 rounded focus:ring-1 focus:ring-primary-300 focus:ring-offset-1"
9
+ :value="col.newKey"
10
+ @change="onVisibleColumnChange($event, col.newKey)"
11
+ />
12
+ <span class="text-xs text-slate-600">
13
+ {{ col.label }}
14
+ </span>
15
+ </label>
16
+ </li>
17
+ </ul>
18
+ </template>
19
+
20
+ <script lang="ts" setup>
21
+ import { cloneDeep } from 'lodash';
22
+ import { PropType } from 'vue';
23
+ import BaseTable from './BaseTable.vue';
24
+
25
+ const props = defineProps({
26
+ table: {
27
+ required: true,
28
+ type: Object as PropType<InstanceType<typeof BaseTable> | null>,
29
+ },
30
+ visibleColumns: {
31
+ required: true,
32
+ type: Array as PropType<number[]>,
33
+ },
34
+ });
35
+
36
+ const emit = defineEmits(['update:visibleColumns']);
37
+
38
+ const toggleableColumns = computed(() => {
39
+ const tableVue = props.table;
40
+
41
+ if (tableVue == null) {
42
+ return [];
43
+ }
44
+
45
+ if (!tableVue.newColumns) {
46
+ return [];
47
+ }
48
+
49
+ return tableVue.newColumns.filter((c) => !c.alwaysVisible);
50
+ });
51
+
52
+ function onVisibleColumnChange(event: any, newKey: number) {
53
+ const checked = event.target.checked as boolean;
54
+
55
+ console.log(checked);
56
+
57
+ let newVisibleColumns = cloneDeep(props.visibleColumns);
58
+
59
+ if (checked) {
60
+ if (!newVisibleColumns.includes(newKey)) {
61
+ newVisibleColumns.push(newKey);
62
+ }
63
+ } else {
64
+ newVisibleColumns = newVisibleColumns.filter((c) => c != newKey);
65
+ }
66
+
67
+ emit('update:visibleColumns', newVisibleColumns);
68
+ }
69
+ </script>
@@ -0,0 +1,53 @@
1
+ import BaseDatePicker from './BaseDatePicker.vue';
2
+ import { DateTime } from 'luxon';
3
+
4
+ export default {
5
+ title: 'Form/BaseDatePicker',
6
+ component: BaseDatePicker,
7
+ argTypes: {},
8
+ };
9
+
10
+ const Template = (args) => ({
11
+ components: { BaseDatePicker },
12
+ setup() {
13
+ return { args };
14
+ },
15
+ template: `
16
+ <BaseDatePicker v-bind="args">
17
+ </BaseDatePicker>
18
+ `,
19
+ });
20
+
21
+ export const Demo = Template.bind({});
22
+ Demo.args = {
23
+ modelValue: '2023-01-01',
24
+ inputClass: 'border-slate-300',
25
+ };
26
+
27
+ export const YearRange = Template.bind({});
28
+ YearRange.args = {
29
+ modelValue: '1980-11-16',
30
+ inputClass: 'border-slate-300',
31
+ yearRange: [1920, 2020],
32
+ };
33
+
34
+ export const MinDate = Template.bind({});
35
+ MinDate.args = {
36
+ modelValue: '2022-11-16',
37
+ inputClass: 'border-slate-300',
38
+ minDate: DateTime.fromISO('2022-11-10').toJSDate(),
39
+ };
40
+
41
+ export const MaxDate = Template.bind({});
42
+ MaxDate.args = {
43
+ modelValue: '2022-11-16',
44
+ inputClass: 'border-slate-300',
45
+ maxDate: DateTime.fromISO('2022-11-20').toJSDate(),
46
+ };
47
+
48
+ export const Disabled = Template.bind({});
49
+ Disabled.args = {
50
+ modelValue: '2022-11-16',
51
+ inputClass: 'border-slate-300',
52
+ disabled: true,
53
+ };