sprintify-ui 0.6.53 → 0.6.56

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.
@@ -0,0 +1,15 @@
1
+ <template>
2
+ <tbody>
3
+ <slot />
4
+ </tbody>
5
+ </template>
6
+
7
+ <script lang="ts" setup>
8
+
9
+ const baseTable = inject('BaseTable');
10
+
11
+ if (!baseTable) {
12
+ throw new Error('BaseTableBody must be used within a BaseTable.');
13
+ }
14
+
15
+ </script>
@@ -0,0 +1,87 @@
1
+ <template>
2
+ <td class="p-0 border-b border-slate-200">
3
+ <component
4
+ :is="componentName"
5
+ :class="classes"
6
+ :to="propsInternal.to"
7
+ :href="propsInternal.href"
8
+ :title="propsInternal.title"
9
+ :target="propsInternal.target"
10
+ >
11
+ <slot />
12
+ </component>
13
+ </td>
14
+ </template>
15
+
16
+ <script lang="ts" setup>
17
+ import { RouteLocationRaw } from 'vue-router';
18
+ import { TableProps, CellConfig, CellProps } from '../services/table/types'
19
+ import { cellClasses } from '../services/table/classes'
20
+ import { ClassNameValue, twMerge } from 'tailwind-merge';
21
+ import { cloneDeep, merge } from 'lodash';
22
+ import { ComputedRef } from 'vue';
23
+
24
+ defineOptions({
25
+ inheritAttrs: false,
26
+ })
27
+
28
+ const baseTable = inject('BaseTable') as ComputedRef<TableProps> | undefined;
29
+ const baseTableHead = inject('BaseTableHead', undefined);
30
+ const baseTableRow = inject('BaseTableRow', undefined) as ComputedRef<CellProps> | undefined;
31
+
32
+ if (!baseTableRow) {
33
+ throw new Error('BaseTableCell must be used within a BaseTableRow.');
34
+ }
35
+
36
+ const isHead = computed(() => baseTableHead !== undefined);
37
+
38
+ const props = withDefaults(defineProps<{
39
+ href?: string,
40
+ to?: RouteLocationRaw,
41
+ target?: '_blank' | '_self' | '_parent' | '_top',
42
+ title?: string,
43
+ class?: ClassNameValue,
44
+ }>(), {
45
+ href: undefined,
46
+ to: undefined,
47
+ target: undefined,
48
+ title: undefined,
49
+ class: undefined,
50
+ });
51
+
52
+ const cellConfig = computed<CellConfig>(() => {
53
+ return {
54
+ spacing: baseTable?.value?.spacing,
55
+ flush: baseTable?.value?.flush,
56
+ head: isHead.value,
57
+ }
58
+ });
59
+
60
+ const propsInternal = computed<CellProps>(() => {
61
+ return merge(cloneDeep(baseTableRow.value), props);
62
+ });
63
+
64
+ const componentName = computed(() => {
65
+ if (propsInternal.value.href) {
66
+ return 'a';
67
+ }
68
+
69
+ if (propsInternal.value.to) {
70
+ return 'router-link';
71
+ }
72
+
73
+ return 'div';
74
+ });
75
+
76
+ const classes = computed(() => {
77
+ const base = cellClasses(cellConfig.value);
78
+ const click = propsInternal.value.href || propsInternal.value.to ? 'cursor-pointer' : '';
79
+
80
+ return twMerge(
81
+ base,
82
+ click,
83
+ props.class,
84
+ );
85
+ })
86
+
87
+ </script>
@@ -0,0 +1,23 @@
1
+ <template>
2
+ <thead>
3
+ <slot />
4
+ </thead>
5
+ </template>
6
+
7
+ <script lang="ts" setup>
8
+
9
+ const props = withDefaults(defineProps<{
10
+ sticky?: boolean,
11
+ }>(), {
12
+ sticky: false,
13
+ });
14
+
15
+ const baseTable = inject('BaseTable');
16
+
17
+ if (!baseTable) {
18
+ throw new Error('BaseTableHead must be used within a BaseTable.');
19
+ }
20
+
21
+ provide('BaseTableHead', computed(() => props));
22
+
23
+ </script>
@@ -0,0 +1,51 @@
1
+ <template>
2
+ <th class="p-0 border-b border-slate-200">
3
+ <div :class="classes">
4
+ <slot />
5
+ </div>
6
+ </th>
7
+ </template>
8
+
9
+ <script lang="ts" setup>
10
+ import { cellClasses } from '@/services/table/classes';
11
+ import { CellConfig, TableProps } from '@/services/table/types';
12
+ import { ClassNameValue, twMerge } from 'tailwind-merge';
13
+ import { ComputedRef } from 'vue';
14
+
15
+ const baseTable = inject('BaseTable') as ComputedRef<TableProps> | undefined;
16
+ const baseTableHead = inject('BaseTableHead', undefined);
17
+
18
+ if (!baseTableHead) {
19
+ throw new Error('BaseTableCell must be used within a BaseTableHead.');
20
+ }
21
+
22
+ defineOptions({
23
+ inheritAttrs: false,
24
+ });
25
+
26
+ const props = withDefaults(defineProps<{
27
+ class?: ClassNameValue,
28
+ }>(), {
29
+ class: undefined,
30
+ });
31
+
32
+ const cellConfig = computed<CellConfig>(() => {
33
+ return {
34
+ spacing: baseTable?.value?.spacing,
35
+ flush: baseTable?.value?.flush,
36
+ head: true,
37
+ }
38
+ });
39
+
40
+ const classes = computed(() => {
41
+ const base = cellClasses(cellConfig.value);
42
+
43
+ return twMerge(
44
+ 'text-slate-500 font-normal',
45
+ base,
46
+ props.class,
47
+ );
48
+ })
49
+
50
+
51
+ </script>
@@ -0,0 +1,30 @@
1
+ <template>
2
+ <tr>
3
+ <slot />
4
+ </tr>
5
+ </template>
6
+
7
+ <script lang="ts" setup>
8
+ import { RouteLocationRaw } from 'vue-router';
9
+
10
+ const baseTable = inject('BaseTable');
11
+
12
+ if (!baseTable) {
13
+ throw new Error('baseTable must be used within a BaseTable.');
14
+ }
15
+
16
+ const props = withDefaults(defineProps<{
17
+ href?: string,
18
+ to?: RouteLocationRaw,
19
+ target?: '_blank' | '_self' | '_parent' | '_top',
20
+ title?: string,
21
+ }>(), {
22
+ href: undefined,
23
+ to: undefined,
24
+ target: undefined,
25
+ title: undefined,
26
+ });
27
+
28
+ provide('BaseTableRow', computed(() => props));
29
+
30
+ </script>
@@ -79,11 +79,16 @@ import BaseStepper from './BaseStepper.vue';
79
79
  import BaseStepperItem from './BaseStepperItem.vue';
80
80
  import BaseSwitch from './BaseSwitch.vue';
81
81
  import BaseSystemAlert from './BaseSystemAlert.vue';
82
+ import BaseTable from './BaseTable.vue';
83
+ import BaseTableBody from './BaseTableBody.vue';
84
+ import BaseTableCell from './BaseTableCell.vue';
85
+ import BaseTableHead from './BaseTableHead.vue';
86
+ import BaseTableHeader from './BaseTableHeader.vue';
87
+ import BaseTableRow from './BaseTableRow.vue';
82
88
  import BaseTabs from './BaseTabs.vue';
83
89
  import BaseTabItem from './BaseTabItem.vue';
84
90
  import BaseTagAutocomplete from './BaseTagAutocomplete.vue';
85
91
  import BaseTagAutocompleteFetch from './BaseTagAutocompleteFetch.vue';
86
- import BaseTable from './BaseTable.vue';
87
92
  import BaseTableColumn from './BaseTableColumn.vue';
88
93
  import BaseTextarea from './BaseTextarea.vue';
89
94
  import BaseTextareaAutoresize from './BaseTextareaAutoresize.vue';
@@ -179,11 +184,16 @@ export {
179
184
  BaseStepperItem,
180
185
  BaseSwitch,
181
186
  BaseSystemAlert,
187
+ BaseTable,
188
+ BaseTableBody,
189
+ BaseTableCell,
190
+ BaseTableHead,
191
+ BaseTableHeader,
192
+ BaseTableRow,
182
193
  BaseTabs,
183
194
  BaseTabItem,
184
195
  BaseTagAutocomplete,
185
196
  BaseTagAutocompleteFetch,
186
- BaseTable,
187
197
  BaseTableColumn,
188
198
  BaseTextarea,
189
199
  BaseTextareaAutoresize,
@@ -0,0 +1,26 @@
1
+ import { twMerge } from "tailwind-merge";
2
+ import { CellConfig, CellSpacing } from "./types";
3
+
4
+ export function cellClasses(config: CellConfig): string {
5
+ const base = 'text-left block';
6
+ const space = spacing(config.spacing ?? 'md');
7
+ const flush = config.flush ? 'px-0' : '';
8
+
9
+ return twMerge([base, space, flush]);
10
+ }
11
+
12
+ function spacing(spacing: CellSpacing): string {
13
+ if (spacing == 'sm') {
14
+ return 'px-1 py-0.5';
15
+ }
16
+
17
+ if (spacing == 'md') {
18
+ return 'px-2 py-2';
19
+ }
20
+
21
+ if (spacing == 'lg') {
22
+ return 'px-4 py-3';
23
+ }
24
+
25
+ return '';
26
+ }
@@ -0,0 +1,19 @@
1
+ import { RouteLocationRaw } from "vue-router";
2
+
3
+ export type CellSpacing = 'none' | 'sm' | 'md' | 'lg';
4
+
5
+ export interface TableProps {
6
+ spacing?: CellSpacing;
7
+ flush?: boolean;
8
+ }
9
+
10
+ export type CellConfig = {
11
+ flush?: boolean;
12
+ } & TableProps;
13
+
14
+ export interface CellProps {
15
+ title?: string;
16
+ href?: string;
17
+ to?: RouteLocationRaw;
18
+ target?: string;
19
+ }