sprintify-ui 0.8.23 → 0.8.25

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.
@@ -61,7 +61,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
61
61
  }>>> & {
62
62
  onClick?: ((...args: any[]) => any) | undefined;
63
63
  }, {
64
- class: string | false | 0 | ClassNameValue[] | null;
64
+ class: string | false | 0 | 0n | ClassNameValue[] | null;
65
65
  type: "button" | "submit" | "reset";
66
66
  size: "xs" | "sm" | "md" | "lg" | "xl";
67
67
  color: string;
@@ -16,7 +16,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
16
16
  }>>> & {
17
17
  onClick?: ((...args: any[]) => any) | undefined;
18
18
  }, {
19
- class: string | false | 0 | ClassNameValue[] | null;
19
+ class: string | false | 0 | 0n | ClassNameValue[] | null;
20
20
  size: "xs" | "sm" | "lg" | "base";
21
21
  }, {}>, {
22
22
  default?(_: {}): any;
@@ -4,7 +4,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
4
4
  size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined;
5
5
  fixedHeader?: boolean | undefined;
6
6
  fixedColumn?: boolean | undefined;
7
- grid?: boolean | undefined;
8
7
  striped?: boolean | undefined;
9
8
  flush?: boolean | undefined;
10
9
  class?: ClassNameValue;
@@ -14,7 +13,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
14
13
  size: string;
15
14
  fixedHeader: boolean;
16
15
  fixedColumn: boolean;
17
- grid: boolean;
18
16
  striped: boolean;
19
17
  flush: boolean;
20
18
  class: undefined;
@@ -26,7 +24,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
26
24
  size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined;
27
25
  fixedHeader?: boolean | undefined;
28
26
  fixedColumn?: boolean | undefined;
29
- grid?: boolean | undefined;
30
27
  striped?: boolean | undefined;
31
28
  flush?: boolean | undefined;
32
29
  class?: ClassNameValue;
@@ -36,20 +33,18 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
36
33
  size: string;
37
34
  fixedHeader: boolean;
38
35
  fixedColumn: boolean;
39
- grid: boolean;
40
36
  striped: boolean;
41
37
  flush: boolean;
42
38
  class: undefined;
43
39
  maxHeight: undefined;
44
40
  loading: boolean;
45
41
  }>>>, {
46
- class: string | false | 0 | ClassNameValue[] | null;
42
+ class: string | false | 0 | 0n | ClassNameValue[] | null;
47
43
  size: "xs" | "sm" | "md" | "lg" | "xl";
48
44
  loading: boolean;
49
45
  maxHeight: number;
50
46
  fixedHeader: boolean;
51
47
  fixedColumn: boolean;
52
- grid: boolean;
53
48
  striped: boolean;
54
49
  flush: boolean;
55
50
  }, {}>, {
@@ -46,7 +46,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
46
46
  onClick: undefined;
47
47
  ignoreRowInteractions: boolean;
48
48
  }>>>, {
49
- class: string | false | 0 | ClassNameValue[] | null;
49
+ class: string | false | 0 | 0n | ClassNameValue[] | null;
50
50
  onClick: (e: MouseEvent) => void;
51
51
  title: string;
52
52
  to: RouteLocationRaw;
@@ -8,7 +8,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
8
8
  }>, {
9
9
  class: undefined;
10
10
  }>>>, {
11
- class: string | false | 0 | ClassNameValue[] | null;
11
+ class: string | false | 0 | 0n | ClassNameValue[] | null;
12
12
  }, {}>, {
13
13
  default?(_: {}): any;
14
14
  }>;
@@ -25,7 +25,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
25
25
  }>>> & {
26
26
  onClick?: ((...args: any[]) => any) | undefined;
27
27
  }, {
28
- class: string | false | 0 | ClassNameValue[] | null;
28
+ class: string | false | 0 | 0n | ClassNameValue[] | null;
29
29
  align: "right" | "left" | "center";
30
30
  style: string | false | import("vue").CSSProperties | StyleValue[] | null;
31
31
  colspan: number;
@@ -6,6 +6,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
6
6
  target?: "_blank" | "_self" | "_parent" | "_top" | undefined;
7
7
  title?: string | undefined;
8
8
  class?: ClassNameValue;
9
+ selected?: boolean | undefined;
9
10
  onClick?: ((e: MouseEvent) => void) | undefined;
10
11
  }>, {
11
12
  href: undefined;
@@ -13,6 +14,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
13
14
  target: undefined;
14
15
  title: undefined;
15
16
  class: undefined;
17
+ selected: boolean;
16
18
  onClick: undefined;
17
19
  }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
18
20
  click: (...args: any[]) => void;
@@ -24,6 +26,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
24
26
  target?: "_blank" | "_self" | "_parent" | "_top" | undefined;
25
27
  title?: string | undefined;
26
28
  class?: ClassNameValue;
29
+ selected?: boolean | undefined;
27
30
  onClick?: ((e: MouseEvent) => void) | undefined;
28
31
  }>, {
29
32
  href: undefined;
@@ -31,18 +34,20 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
31
34
  target: undefined;
32
35
  title: undefined;
33
36
  class: undefined;
37
+ selected: boolean;
34
38
  onClick: undefined;
35
39
  }>>> & {
36
40
  onClick?: ((...args: any[]) => any) | undefined;
37
41
  onMouseenter?: ((...args: any[]) => any) | undefined;
38
42
  onMouseleave?: ((...args: any[]) => any) | undefined;
39
43
  }, {
40
- class: string | false | 0 | ClassNameValue[] | null;
44
+ class: string | false | 0 | 0n | ClassNameValue[] | null;
41
45
  onClick: (e: MouseEvent) => void;
42
46
  title: string;
43
47
  to: RouteLocationRaw;
44
48
  href: string;
45
49
  target: "_blank" | "_self" | "_parent" | "_top";
50
+ selected: boolean;
46
51
  }, {}>, {
47
52
  default?(_: {}): any;
48
53
  }>;
@@ -5,6 +5,7 @@ export interface TableProps {
5
5
  flush?: boolean;
6
6
  fixedHeader?: boolean;
7
7
  fixedColumn?: boolean;
8
+ striped?: boolean;
8
9
  }
9
10
  export type CellConfig = TableProps;
10
11
  export interface CellProps {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprintify-ui",
3
- "version": "0.8.23",
3
+ "version": "0.8.25",
4
4
  "scripts": {
5
5
  "build": "rimraf dist && vue-tsc && vite build",
6
6
  "build-fast": "rimraf dist && vite build",
@@ -48,7 +48,7 @@
48
48
  "@fullcalendar/vue3": "^6.1.11",
49
49
  "@headlessui/vue": "^1.7.19",
50
50
  "color2k": "^2.0.3",
51
- "tailwind-merge": "^1.14.0"
51
+ "tailwind-merge": "^2.4.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@babel/core": "^7.24.0",
@@ -18,6 +18,11 @@ export default {
18
18
  },
19
19
  options: ['none', 'xs', 'sm', 'md', 'lg'],
20
20
  },
21
+ loading: {
22
+ control: {
23
+ type: 'boolean',
24
+ },
25
+ },
21
26
  },
22
27
  };
23
28
 
@@ -72,6 +77,7 @@ const Template = (args) => ({
72
77
  :key="option.value"
73
78
  :href="'https://www.google.com/search?q=' + option.label"
74
79
  target="_blank"
80
+ :selected="option.value === 'darth_maul'"
75
81
  >
76
82
  ${cellsTemplate}
77
83
  </BaseTableRow>
@@ -84,6 +90,16 @@ const Template = (args) => ({
84
90
  export const Demo = Template.bind({});
85
91
  Demo.args = {};
86
92
 
93
+ export const Striped = Template.bind({});
94
+ Striped.args = {
95
+ striped: true,
96
+ };
97
+
98
+ export const Flush = Template.bind({});
99
+ Flush.args = {
100
+ flush: true,
101
+ };
102
+
87
103
  export const FixedHeader = Template.bind({});
88
104
  FixedHeader.args = {
89
105
  fixedHeader: true,
@@ -171,7 +187,7 @@ const TemplateCellClick = (args) => ({
171
187
  {{ option.type ?? 'N/A' }}
172
188
  </BaseTableCell>
173
189
  <BaseTableCell>
174
- ...
190
+ Actions...
175
191
  </BaseTableCell>
176
192
  <BaseTableCell @click="al()">
177
193
  Click me
@@ -49,7 +49,6 @@ const props = withDefaults(defineProps<{
49
49
  size?: Size,
50
50
  fixedHeader?: boolean,
51
51
  fixedColumn?: boolean,
52
- grid?: boolean,
53
52
  striped?: boolean,
54
53
  flush?: boolean,
55
54
  class?: ClassNameValue,
@@ -59,7 +58,6 @@ const props = withDefaults(defineProps<{
59
58
  size: 'md',
60
59
  fixedHeader: false,
61
60
  fixedColumn: false,
62
- grid: false,
63
61
  striped: false,
64
62
  flush: false,
65
63
  class: undefined,
@@ -68,8 +66,15 @@ const props = withDefaults(defineProps<{
68
66
  });
69
67
 
70
68
  const classes = computed(() => {
69
+
70
+ const base = 'border-separate border-spacing-0 text-sm';
71
+
72
+ if (!props.class) {
73
+ return base;
74
+ }
75
+
71
76
  return twMerge(
72
- 'border-separate border-spacing-0 text-sm',
77
+ base,
73
78
  props.class,
74
79
  );
75
80
  });
@@ -34,8 +34,6 @@ import { cellClasses } from '../services/table/classes'
34
34
  import { ClassNameValue, twMerge } from 'tailwind-merge';
35
35
  import { cloneDeep, merge } from 'lodash';
36
36
  import { ComputedRef, StyleValue } from 'vue';
37
- import { useIsFirstColumn } from '../composables/isFirstColumn'
38
- import { useIsLastColumn } from '../composables/isLastColumn'
39
37
 
40
38
  defineOptions({
41
39
  inheritAttrs: false,
@@ -45,9 +43,11 @@ const baseTable = inject('table:props') as ComputedRef<TableProps> | undefined;
45
43
  const baseTableHead = inject('tableHead:props', undefined);
46
44
  const baseTableRow = inject('tableRow:props', undefined) as ComputedRef<CellProps> | undefined;
47
45
  const baseTableRowHover = inject('tableRow:hover', undefined) as ComputedRef<boolean> | undefined;
46
+ const baseTableRowSelected = inject('tableRow:selected', undefined) as ComputedRef<boolean> | undefined;
48
47
  const baseTableHorizontalScrolling = inject('table:horizontalScrolling', undefined) as ComputedRef<boolean> | undefined;
49
48
  const hoverForFullRow = inject('tableRow:hoverForFullRow') as ComputedRef<boolean> | undefined;
50
49
  const setHoverForFullRow = inject('tableRow:setHoverForFullRow') as (active: boolean) => void;
50
+ const baseTableStriped = computed(() => baseTable?.value.striped);
51
51
 
52
52
  if (!baseTableRow) {
53
53
  throw new Error('BaseTableCell must be used within a BaseTableRow.');
@@ -126,33 +126,57 @@ const hoverInternal = computed(() => {
126
126
  });
127
127
 
128
128
  const classes = computed(() => {
129
+
130
+ const hovered = clickable.value && hoverInternal.value;
131
+ const selected = baseTableRowSelected?.value;
132
+
129
133
  const base = cellClasses(cellConfig.value);
130
- const baseTd = 'relative bg-white border-b border-slate-200 group-last/row:border-b-0';
134
+ const baseTd = 'relative border-b group-last/row:border-b-0';
131
135
  const click = clickable.value ? 'cursor-pointer' : '';
132
- const hover = clickable.value && hoverInternal.value ? 'bg-slate-50' : '';
133
- const firstCol = isFirstColumn.value ? 'border-r border-r-transparent' : '';
134
- const horizontalScrolling = baseTable?.value.fixedColumn && baseTableHorizontalScrolling?.value && isFirstColumn.value ? 'sticky z-[1] left-0 border-r-slate-200' : '';
135
- const flushLeft = baseTable?.value.flush && isFirstColumn.value ? 'pl-0' : '';
136
- const flushRight = baseTable?.value.flush && isLastColumn.value ? 'pr-0' : '';
137
136
 
138
- return twMerge(
137
+ let backgroundColor = baseTableStriped.value ? 'group-even/row:bg-slate-100/70' : 'bg-white';
138
+
139
+ if (hovered) {
140
+ backgroundColor = 'bg-slate-100';
141
+ }
142
+
143
+ if (selected) {
144
+ backgroundColor = 'bg-slate-200';
145
+ }
146
+
147
+ let borderColor = 'border-slate-200';
148
+
149
+ if (selected) {
150
+ borderColor = 'border-slate-300';
151
+ }
152
+
153
+ const firstCol = 'first:border-r first:border-r-transparent';
154
+ const horizontalScrolling = baseTable?.value.fixedColumn && baseTableHorizontalScrolling?.value ? 'first:sticky first:z-[1] first:left-0 first:border-r-slate-200' : '';
155
+ const flush = baseTable?.value.flush ? 'first:pl-0 last:pr-0' : '';
156
+
157
+ const internalClasses = [
139
158
  base,
140
159
  baseTd,
141
160
  click,
142
- hover,
161
+ backgroundColor,
162
+ borderColor,
143
163
  firstCol,
144
164
  horizontalScrolling,
145
- flushLeft,
146
- flushRight,
165
+ flush,
166
+ ];
167
+
168
+ if (!props.class) {
169
+ return internalClasses;
170
+ }
171
+
172
+ return twMerge(
173
+ internalClasses,
147
174
  props.class,
148
175
  );
149
176
  });
150
177
 
151
178
  const tdRef = ref<HTMLTableCellElement | null>(null);
152
179
 
153
- const { isFirstColumn } = useIsFirstColumn(tdRef);
154
- const { isLastColumn } = useIsLastColumn(tdRef);
155
-
156
180
  function onClick(event: MouseEvent) {
157
181
  propsInternal.value.onClick?.(event);
158
182
  }
@@ -26,6 +26,10 @@ provide('tableHead:props', computed(() => props));
26
26
  const classes = computed(() => {
27
27
  const base = '';
28
28
 
29
+ if (!props.class) {
30
+ return base;
31
+ }
32
+
29
33
  return twMerge(
30
34
  base,
31
35
  props.class,
@@ -12,8 +12,6 @@
12
12
  </template>
13
13
 
14
14
  <script lang="ts" setup>
15
- import { useIsFirstColumn } from '@/composables/isFirstColumn';
16
- import { useIsLastColumn } from '@/composables/isLastColumn';
17
15
  import { cellClasses } from '@/services/table/classes';
18
16
  import { CellConfig, TableProps } from '@/services/table/types';
19
17
  import { ClassNameValue, twMerge } from 'tailwind-merge';
@@ -59,27 +57,29 @@ const cellConfig = computed<CellConfig>(() => {
59
57
 
60
58
  const thRef = ref<HTMLTableCellElement | null>(null);
61
59
 
62
- const { isFirstColumn } = useIsFirstColumn(thRef);
63
- const { isLastColumn } = useIsLastColumn(thRef);
64
-
65
-
66
60
  const classes = computed(() => {
67
61
  const base = cellClasses(cellConfig.value);
68
62
  const baseTh = 'bg-white text-slate-500 border-b border-slate-300 group';
69
63
  const sticky = baseTable?.value.fixedHeader ? 'sticky top-0 z-[2]' : '';
70
- const firstCol = isFirstColumn.value ? 'border-r border-r-transparent' : '';
71
- const horizontalScrolling = baseTable?.value.fixedColumn && baseTableHorizontalScrolling?.value && isFirstColumn.value ? 'sticky z-[3] left-0 border-r-slate-200' : '';
72
- const flushLeft = baseTable?.value.flush && isFirstColumn.value ? 'pl-0' : '';
73
- const flushRight = baseTable?.value.flush && isLastColumn.value ? 'pr-0' : '';
64
+ const firstCol = 'first:border-r first:border-r-transparent';
65
+ const horizontalScrolling = baseTable?.value.fixedColumn && baseTableHorizontalScrolling?.value ? 'first:sticky first:z-[3] first:left-0 first:border-r-slate-200' : '';
66
+ const flush = baseTable?.value.flush ? 'first:pl-0 last:pr-0' : '';
74
67
 
75
- return twMerge(
68
+ const internalClasses = [
76
69
  base,
77
70
  baseTh,
78
71
  sticky,
79
72
  firstCol,
80
73
  horizontalScrolling,
81
- flushLeft,
82
- flushRight,
74
+ flush,
75
+ ];
76
+
77
+ if (!props.class) {
78
+ return internalClasses;
79
+ }
80
+
81
+ return twMerge(
82
+ internalClasses,
83
83
  props.class,
84
84
  );
85
85
  });
@@ -1,5 +1,6 @@
1
1
  <template>
2
2
  <tr
3
+ ref="trRef"
3
4
  :class="classes"
4
5
  @mouseenter="onMouseEnter"
5
6
  @mouseleave="onMouseLeave"
@@ -30,6 +31,7 @@ const props = withDefaults(defineProps<{
30
31
  target?: '_blank' | '_self' | '_parent' | '_top',
31
32
  title?: string,
32
33
  class?: ClassNameValue,
34
+ selected?: boolean,
33
35
  onClick?: (e: MouseEvent) => void,
34
36
  }>(), {
35
37
  href: undefined,
@@ -37,12 +39,24 @@ const props = withDefaults(defineProps<{
37
39
  target: undefined,
38
40
  title: undefined,
39
41
  class: undefined,
42
+ selected: false,
40
43
  onClick: undefined,
41
44
  });
42
45
 
46
+ const trRef = ref<null | HTMLTableRowElement>(null);
47
+ const parent = ref<null | undefined | HTMLElement>(null);
48
+
49
+ onMounted(() => {
50
+ parent.value = trRef.value?.parentElement;
51
+ });
52
+
43
53
  const classes = computed(() => {
44
54
  const base = 'group/row';
45
55
 
56
+ if (!props.class) {
57
+ return base;
58
+ }
59
+
46
60
  return twMerge(
47
61
  base,
48
62
  props.class,
@@ -68,6 +82,7 @@ function onMouseLeave() {
68
82
 
69
83
  provide('tableRow:props', computed(() => props));
70
84
  provide('tableRow:hover', computed(() => hover.value));
85
+ provide('tableRow:selected', computed(() => props.selected));
71
86
  provide('tableRow:setHoverForFullRow', setHoverForFullRow);
72
87
  provide('tableRow:hoverForFullRow', computed(() => hoverForFullRow.value));
73
88
 
@@ -1,11 +1,10 @@
1
- import { twMerge } from "tailwind-merge";
2
1
  import { CellConfig, CellSize } from "./types";
3
2
 
4
3
  export function cellClasses(config: CellConfig): string {
5
4
  const base = '';
6
5
  const space = size(config.size ?? 'md');
7
6
 
8
- return twMerge([base, space]);
7
+ return [base, space].join(' ');
9
8
  }
10
9
 
11
10
  function size(size: CellSize): string {
@@ -7,6 +7,7 @@ export interface TableProps {
7
7
  flush?: boolean;
8
8
  fixedHeader?: boolean;
9
9
  fixedColumn?: boolean;
10
+ striped?: boolean;
10
11
  }
11
12
 
12
13
  export type CellConfig = TableProps;
@@ -1,4 +0,0 @@
1
- import { MaybeRef } from "vue";
2
- export declare function useIsFirstColumn(tdOrTh: MaybeRef<HTMLTableCellElement | null>): {
3
- isFirstColumn: import("vue").ComputedRef<boolean>;
4
- };
@@ -1,31 +0,0 @@
1
- import { MaybeRef } from "vue";
2
-
3
- export function useIsFirstColumn(tdOrTh: MaybeRef<HTMLTableCellElement | null>) {
4
-
5
- const leftCol = ref<HTMLTableCellElement | null>();
6
-
7
- onMounted(() => {
8
- leftCol.value = unref(tdOrTh)?.previousElementSibling as HTMLTableCellElement | null;
9
- });
10
-
11
- const isFirstColumn = computed(() => {
12
-
13
- if (!leftCol.value) {
14
- return true;
15
- }
16
-
17
- if (leftCol.value.tagName.toLowerCase() === 'th') {
18
- return false;
19
- }
20
-
21
- if (leftCol.value.tagName.toLowerCase() === 'td') {
22
- return false;
23
- }
24
-
25
- return true;
26
- });
27
-
28
- return {
29
- isFirstColumn,
30
- };
31
- }