sprintify-ui 0.0.188 → 0.0.190

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 (49) hide show
  1. package/dist/sprintify-ui.es.js +3759 -3749
  2. package/dist/style.css +1 -1
  3. package/dist/types/src/components/BaseActionItem.vue.d.ts +22 -33
  4. package/dist/types/src/components/BaseAlert.vue.d.ts +3 -3
  5. package/dist/types/src/components/BaseAppDialogs.vue.d.ts +1 -1
  6. package/dist/types/src/components/BaseAutocomplete.vue.d.ts +1 -1
  7. package/dist/types/src/components/BaseAutocompleteFetch.vue.d.ts +1 -1
  8. package/dist/types/src/components/BaseBelongsTo.vue.d.ts +1 -1
  9. package/dist/types/src/components/BaseButtonGroup.vue.d.ts +1 -1
  10. package/dist/types/src/components/BaseColor.vue.d.ts +1 -1
  11. package/dist/types/src/components/BaseCounter.vue.d.ts +3 -3
  12. package/dist/types/src/components/BaseDataIteratorSectionColumns.vue.d.ts +4 -8
  13. package/dist/types/src/components/BaseDatePicker.vue.d.ts +1 -1
  14. package/dist/types/src/components/BaseDateSelect.vue.d.ts +1 -1
  15. package/dist/types/src/components/BaseDialog.vue.d.ts +2 -2
  16. package/dist/types/src/components/BaseDropdownAutocomplete.vue.d.ts +1 -1
  17. package/dist/types/src/components/BaseField.vue.d.ts +1 -1
  18. package/dist/types/src/components/BaseFieldI18n.vue.d.ts +1 -1
  19. package/dist/types/src/components/BaseInput.vue.d.ts +3 -3
  20. package/dist/types/src/components/BaseInputPercent.vue.d.ts +1 -1
  21. package/dist/types/src/components/BaseMenu.vue.d.ts +3 -3
  22. package/dist/types/src/components/BaseMenuItem.vue.d.ts +3 -3
  23. package/dist/types/src/components/BaseNavbarItemContent.vue.d.ts +1 -1
  24. package/dist/types/src/components/BaseNavbarSideItemContent.vue.d.ts +1 -1
  25. package/dist/types/src/components/BaseNumber.vue.d.ts +4 -4
  26. package/dist/types/src/components/BasePassword.vue.d.ts +1 -1
  27. package/dist/types/src/components/BaseRadioGroup.vue.d.ts +1 -1
  28. package/dist/types/src/components/BaseRichText.vue.d.ts +4 -4
  29. package/dist/types/src/components/BaseSelect.vue.d.ts +1 -1
  30. package/dist/types/src/components/BaseShortcut.vue.d.ts +23 -4
  31. package/dist/types/src/components/BaseStatistic.vue.d.ts +1 -1
  32. package/dist/types/src/components/BaseSwitch.vue.d.ts +4 -4
  33. package/dist/types/src/components/BaseSystemAlert.vue.d.ts +3 -3
  34. package/dist/types/src/components/BaseTable.vue.d.ts +1 -2
  35. package/dist/types/src/components/BaseTableColumn.vue.d.ts +4 -13
  36. package/dist/types/src/components/BaseTagAutocomplete.vue.d.ts +1 -1
  37. package/dist/types/src/components/BaseTextarea.vue.d.ts +1 -1
  38. package/dist/types/src/types/index.d.ts +1 -2
  39. package/package.json +1 -1
  40. package/src/components/BaseActionItem.vue +21 -28
  41. package/src/components/BaseDataTable.stories.js +49 -17
  42. package/src/components/BaseDataTable.vue +4 -2
  43. package/src/components/BaseNavbarItem.vue +4 -2
  44. package/src/components/BaseNavbarSideItem.vue +8 -5
  45. package/src/components/BaseShortcut.stories.js +20 -1
  46. package/src/components/BaseShortcut.vue +13 -4
  47. package/src/components/BaseTable.vue +1 -1
  48. package/src/components/BaseTableColumn.vue +9 -7
  49. package/src/types/index.ts +1 -2
@@ -5,6 +5,7 @@ import BaseSelect from './BaseSelect.vue';
5
5
  import BaseBadge from './BaseBadge.vue';
6
6
  import BaseAppNotifications from './BaseAppNotifications.vue';
7
7
  import BaseAppDialogs from './BaseAppDialogs.vue';
8
+ import { onBeforeUnmount } from 'vue';
8
9
 
9
10
  export default {
10
11
  title: 'Data/BaseDataTable',
@@ -26,6 +27,16 @@ export default {
26
27
  },
27
28
  };
28
29
 
30
+ const templateComponents = {
31
+ BaseDataTable,
32
+ BaseTableColumn,
33
+ BaseBoolean,
34
+ BaseSelect,
35
+ BaseBadge,
36
+ BaseAppNotifications,
37
+ BaseAppDialogs,
38
+ };
39
+
29
40
  const template = `
30
41
  <BaseDataTable v-bind="args" @cell-click="onCellClick">
31
42
  <BaseTableColumn
@@ -59,6 +70,9 @@ const template = `
59
70
  label="Vote"
60
71
  field="votes_avg_score"
61
72
  sortable
73
+ custom-key="votes_avg_score"
74
+ :toggle="true"
75
+ :toggle-default="false"
62
76
  >
63
77
  <div class="whitespace-pre">
64
78
  {{ Math.round(row.votes_avg_score) }} / 5
@@ -67,8 +81,11 @@ const template = `
67
81
 
68
82
  <BaseTableColumn
69
83
  v-slot="{ row }"
70
- label="Vote"
71
- field="votes_avg_score"
84
+ v-if="ownerIsVisible"
85
+ label="Owner"
86
+ custom-key="owner"
87
+ field="owner_id"
88
+ :toggle="true"
72
89
  sortable
73
90
  >
74
91
  <BaseBadge>
@@ -92,7 +109,6 @@ const template = `
92
109
  label="Access level"
93
110
  field="access_level"
94
111
  sortable
95
- optional
96
112
  >
97
113
  <BaseBadge>
98
114
  {{ row.access_level }}
@@ -160,22 +176,18 @@ const template = `
160
176
  <BaseAppDialogs></BaseAppDialogs>
161
177
  `;
162
178
 
179
+ const templateSetup = (args) => {
180
+ function onCellClick() {
181
+ alert('cell click!');
182
+ }
183
+
184
+ return { args, onCellClick, ownerIsVisible: true };
185
+ };
186
+
163
187
  const Template = (args) => ({
164
- components: {
165
- BaseDataTable,
166
- BaseTableColumn,
167
- BaseBoolean,
168
- BaseSelect,
169
- BaseBadge,
170
- BaseAppNotifications,
171
- BaseAppDialogs,
172
- },
188
+ components: templateComponents,
173
189
  setup() {
174
- function onCellClick() {
175
- alert('cell click!');
176
- }
177
-
178
- return { args, onCellClick };
190
+ return templateSetup(args);
179
191
  },
180
192
  template: template,
181
193
  });
@@ -242,6 +254,26 @@ Demo.args = {
242
254
  ],
243
255
  };
244
256
 
257
+ const VIfOnBaseTableColumn = (args) => ({
258
+ components: templateComponents,
259
+ setup() {
260
+ const ownerIsVisible = ref(true);
261
+
262
+ const intervalId = setInterval(() => {
263
+ ownerIsVisible.value = !ownerIsVisible.value;
264
+ }, 2000);
265
+
266
+ onBeforeUnmount(() => {
267
+ clearInterval(intervalId);
268
+ });
269
+
270
+ return Object.assign(templateSetup(args), { ownerIsVisible });
271
+ },
272
+ template: template,
273
+ });
274
+
275
+ export const VisibleColumns = VIfOnBaseTableColumn.bind({});
276
+
245
277
  const SimpleTemplate = (args) => ({
246
278
  components: {
247
279
  BaseDataTable,
@@ -533,7 +533,7 @@ if (
533
533
  visibleColumns.value = visibleColumnsFromStorage;
534
534
  }
535
535
 
536
- // If nothing is found, set visibleColumns to all non optional columns from table
536
+ // If nothing is found, set visibleColumns to all columns from table
537
537
  const unWatchTable = watch(
538
538
  () => table.value,
539
539
  () => {
@@ -543,8 +543,10 @@ const unWatchTable = watch(
543
543
  visibleColumns.value.length == 0
544
544
  ) {
545
545
  visibleColumns.value = table.value.newColumns
546
- .filter((c) => !c.optional)
546
+ .filter((c) => c.toggle)
547
+ .filter((c) => c.toggleDefault ?? true)
547
548
  .map((c) => c.newKey);
549
+
548
550
  unWatchTable();
549
551
  }
550
552
  }
@@ -1,9 +1,11 @@
1
1
  <template>
2
2
  <div class="flex">
3
3
  <BaseActionItem
4
- :item="item"
4
+ :to="item.to"
5
+ :href="item.href"
6
+ :action="item.action"
5
7
  :dark="dark"
6
- item-class="flex w-full"
8
+ class="flex w-full"
7
9
  @click="onClick"
8
10
  >
9
11
  <template #default="{ active }">
@@ -1,9 +1,11 @@
1
1
  <template>
2
2
  <div>
3
3
  <BaseActionItem
4
- :item="item"
4
+ :to="item.to"
5
+ :href="item.href"
6
+ :action="item.action"
5
7
  :dark="dark"
6
- item-class="flex w-full"
8
+ class="flex w-full"
7
9
  @click="onClick"
8
10
  >
9
11
  <template #default="{ active }">
@@ -23,9 +25,10 @@
23
25
  >
24
26
  <div v-for="subItem in item.actions" :key="subItem.label" class="mb-1">
25
27
  <BaseActionItem
26
- :item="subItem"
27
- :dark="dark"
28
- :item-class="[
28
+ :to="subItem.to"
29
+ :href="subItem.href"
30
+ :action="subItem.action"
31
+ :class="[
29
32
  'flex w-full',
30
33
  dark
31
34
  ? 'text-slate-300 hover:text-white'
@@ -35,7 +35,8 @@ export const Basic = Template.bind({});
35
35
  Basic.args = {
36
36
  to: '/restaurants',
37
37
  title: 'Basic shortcut',
38
- icon: 'heroicons:user',
38
+ icon: 'heroicons:user-solid',
39
+ color: 'blue',
39
40
  };
40
41
 
41
42
  export const Colors = (args) => ({
@@ -81,3 +82,21 @@ Contrast.args = {
81
82
  'Le lorem ipsum est, en imprimerie, une suite de mots sans signification utilisée à titre provisoire pour calibrer une mise en page',
82
83
  linkText: 'Open app',
83
84
  };
85
+
86
+ export const Href = Template.bind({});
87
+ Href.args = {
88
+ href: 'https://www.google.com',
89
+ title: 'Basic shortcut',
90
+ icon: 'heroicons:user-solid',
91
+ color: 'blue',
92
+ };
93
+
94
+ export const Action = Template.bind({});
95
+ Action.args = {
96
+ action() {
97
+ alert(1);
98
+ },
99
+ title: 'Basic shortcut',
100
+ icon: 'heroicons:user-solid',
101
+ color: 'blue',
102
+ };
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <BaseCard class="flex duration-200 hover:bg-slate-50">
3
- <router-link :to="to">
3
+ <BaseActionItem :to="to" :href="href" :action="action" class="block w-full">
4
4
  <section class="whitespace-pre-line p-4">
5
5
  <!-- Icon -->
6
6
  <div
@@ -38,7 +38,7 @@
38
38
  </div>
39
39
  </div>
40
40
  </section>
41
- </router-link>
41
+ </BaseActionItem>
42
42
  </BaseCard>
43
43
  </template>
44
44
 
@@ -48,11 +48,20 @@ import { Icon as BaseIcon } from '@iconify/vue';
48
48
  import BaseCard from './BaseCard.vue';
49
49
  import { RouteLocationRaw } from 'vue-router';
50
50
  import { getColorConfig } from '@/utils/colors';
51
+ import BaseActionItem from './BaseActionItem.vue';
51
52
 
52
53
  const props = defineProps({
53
54
  to: {
54
- required: true,
55
- type: [String, Object] as PropType<RouteLocationRaw>,
55
+ default: undefined,
56
+ type: [String, Object, undefined] as PropType<RouteLocationRaw | undefined>,
57
+ },
58
+ href: {
59
+ default: undefined,
60
+ type: [String, undefined] as PropType<string | undefined>,
61
+ },
62
+ action: {
63
+ default: undefined,
64
+ type: [Function, undefined] as PropType<() => Promise<void> | undefined>,
56
65
  },
57
66
  title: {
58
67
  required: true,
@@ -399,7 +399,7 @@ const visibleColumns = computed(() => {
399
399
 
400
400
  return newColumns.value.filter((column: BaseTableColumn) => {
401
401
  if (column.toggle === false) {
402
- return !!column.visible;
402
+ return true;
403
403
  }
404
404
 
405
405
  if (!isArray(props.visibleColumns)) {
@@ -44,21 +44,17 @@ export default defineComponent({
44
44
  default: false,
45
45
  type: Boolean,
46
46
  },
47
- visible: {
48
- default: true,
49
- type: Boolean,
50
- },
51
47
  clickable: {
52
48
  default: true,
53
49
  type: Boolean,
54
50
  },
55
51
  toggle: {
56
52
  type: Boolean,
57
- default: true,
53
+ default: false,
58
54
  },
59
- optional: {
55
+ toggleDefault: {
60
56
  type: Boolean,
61
- default: false,
57
+ default: true,
62
58
  },
63
59
  customSort: {
64
60
  default: undefined,
@@ -104,6 +100,12 @@ export default defineComponent({
104
100
  },
105
101
  },
106
102
  created() {
103
+ if (this.toggle && !this.customKey) {
104
+ throw new Error(
105
+ 'BaseTableColumn: customKey props is required when toggle props is true'
106
+ );
107
+ }
108
+
107
109
  if (this.customKey) {
108
110
  this.newKey = this.customKey + '';
109
111
  } else {
@@ -109,10 +109,9 @@ export interface BaseTableColumn {
109
109
  position: 'left' | 'right';
110
110
  searchable: boolean;
111
111
  sortable: boolean;
112
- visible: boolean;
113
112
  clickable: boolean;
114
113
  toggle: boolean;
115
- optional: boolean;
114
+ toggleDefault: boolean;
116
115
  width: number;
117
116
  style: {
118
117
  width: undefined | number;