@globalbrain/sefirot 3.12.0 → 3.13.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.
@@ -31,6 +31,7 @@ const normalizedMenu = computed(() => {
31
31
  flex-direction: column;
32
32
  gap: 8px;
33
33
  padding: 16px 24px;
34
+ background-color: var(--c-bg-elv-2);
34
35
 
35
36
  @media (min-width: 768px) {
36
37
  padding: 16px 32px;
@@ -8,6 +8,7 @@ import {
8
8
  reactive,
9
9
  ref,
10
10
  shallowRef,
11
+ toValue,
11
12
  unref,
12
13
  watch
13
14
  } from 'vue'
@@ -37,7 +38,8 @@ const row = shallowRef<HTMLElement | null>(null)
37
38
 
38
39
  const ordersToShow = computed(() => {
39
40
  const orders = unref(props.options.orders).filter((key) => {
40
- return unref(props.options.columns)[key]?.show !== false
41
+ const show = unref(props.options.columns)[key]?.show
42
+ return toValue(show) !== false
41
43
  })
42
44
  if (!props.selected) {
43
45
  return orders
@@ -99,6 +99,8 @@ const computedCell = computed<TableCell | undefined>(() =>
99
99
  :record="record"
100
100
  :avatars="computedCell.avatars"
101
101
  :color="computedCell.color"
102
+ :avatar-count="computedCell.avatarCount"
103
+ :name-count="computedCell.nameCount"
102
104
  />
103
105
  <STableCellActions
104
106
  v-else-if="computedCell.type === 'actions'"
@@ -3,12 +3,17 @@ import { computed } from 'vue'
3
3
  import { type TableCellAvatarsOption } from '../composables/Table'
4
4
  import SAvatar from './SAvatar.vue'
5
5
 
6
- const props = defineProps<{
6
+ const props = withDefaults(defineProps<{
7
7
  value?: any
8
8
  record?: any
9
9
  avatars: TableCellAvatarsOption[] | ((value: any, record: any) => TableCellAvatarsOption[])
10
10
  color?: 'neutral' | 'soft' | 'mute'
11
- }>()
11
+ avatarCount?: number
12
+ nameCount?: number
13
+ }>(), {
14
+ avatarCount: 2,
15
+ nameCount: 2
16
+ })
12
17
 
13
18
  const _avatars = computed(() => {
14
19
  return typeof props.avatars === 'function'
@@ -16,39 +21,57 @@ const _avatars = computed(() => {
16
21
  : props.avatars
17
22
  })
18
23
 
24
+ const avatarDiff = computed(() => {
25
+ return _avatars.value.length - props.avatarCount
26
+ })
27
+
19
28
  const displayAvatars = computed(() => {
20
- return _avatars.value.slice(0, 3)
29
+ return _avatars.value.slice(0, props.avatarCount)
30
+ })
31
+
32
+ const nameDiff = computed(() => {
33
+ return _avatars.value.length - props.nameCount
21
34
  })
22
35
 
23
- const names = computed(() => {
24
- if (_avatars.value.length === 0) {
36
+ const displayNames = computed(() => {
37
+ // If the count is 0, treat it as "disabling" the name display.
38
+ if (props.nameCount === 0) {
25
39
  return null
26
40
  }
27
41
 
28
- if (_avatars.value.length === 1) {
29
- return _avatars.value[0].name
30
- }
42
+ const slicedAvatars = _avatars.value.slice(0, props.nameCount)
43
+
44
+ const names = slicedAvatars.map((avatar) => avatar.name).join(', ')
31
45
 
32
- if (_avatars.value.length === 2) {
33
- return `${_avatars.value[0].name}, ${_avatars.value[1].name}`
46
+ if (nameDiff.value > 0) {
47
+ return `${names}, ...`
34
48
  }
35
49
 
36
- return `${_avatars.value[0].name}, ${_avatars.value[1].name} +${_avatars.value.length - 2}`
50
+ return names
37
51
  })
38
52
  </script>
39
53
 
40
54
  <template>
41
55
  <div class="STableCellAvatars" :class="[color]">
42
56
  <div class="container">
43
- <div class="avatars">
44
- <div v-for="(avatar, index) in displayAvatars" :key="index" class="avatar">
57
+ <div v-if="displayAvatars.length" class="avatars">
58
+ <div
59
+ v-for="(avatar, index) in displayAvatars"
60
+ :key="index"
61
+ class="avatar"
62
+ >
45
63
  <div class="avatar-box">
46
64
  <SAvatar size="mini" :avatar="avatar.image" :name="avatar.name" />
47
65
  </div>
48
66
  </div>
67
+ <div v-if="avatarDiff > 0" class="avatar">
68
+ <div class="avatar-box placeholder" :class="{ small: avatarDiff >= 10 }">
69
+ +{{ avatarDiff }}
70
+ </div>
71
+ </div>
49
72
  </div>
50
- <div class="names">
51
- {{ names }}
73
+ <div v-if="displayNames" class="names">
74
+ {{ displayNames }}
52
75
  </div>
53
76
  </div>
54
77
  </div>
@@ -72,28 +95,44 @@ const names = computed(() => {
72
95
  .avatar {
73
96
  position: relative;
74
97
  width: 20px;
98
+ }
75
99
 
76
- &:nth-child(1) { z-index: 30; }
77
- &:nth-child(2) { z-index: 20; }
78
- &:nth-child(3) { z-index: 10; }
100
+ .avatar.placeholder {
101
+ display: flex;
102
+ justify-content: center;
103
+ align-items: center;
79
104
  }
80
105
 
81
106
  .avatar-box {
107
+ display: flex;
108
+ justify-content: center;
109
+ align-items: center;
82
110
  border: 2px solid var(--c-bg-elv-3);
83
111
  border-radius: 50%;
84
112
  width: 28px;
113
+ height: 28px;
85
114
 
86
115
  .row:hover & {
87
116
  border: 2px solid var(--c-bg-elv-4);
88
117
  }
118
+
119
+ &.placeholder {
120
+ font-size: 10px;
121
+ font-weight: 500;
122
+ color: var(--c-text-2);
123
+ background-color: var(--c-bg-mute-1);
124
+ }
125
+
126
+ &.placeholder.small {
127
+ font-size: 9px;
128
+ }
89
129
  }
90
130
 
91
131
  .names {
92
132
  line-height: 28px;
93
133
  font-size: 12px;
94
- font-weight: 500;
95
-
96
- .STableCellAvatars.soft & { color: var(--c-text-2); }
97
- .STableCellAvatars.mute & { color: var(--c-text-3); }
98
134
  }
135
+
136
+ .STableCellAvatars.soft .names { color: var(--c-text-2); }
137
+ .STableCellAvatars.mute .names { color: var(--c-text-3); }
99
138
  </style>
@@ -1,4 +1,4 @@
1
- import { type Component, type MaybeRef } from 'vue'
1
+ import { type Component, type MaybeRef, type MaybeRefOrGetter } from 'vue'
2
2
  import { type Mode } from '../components/SButton.vue'
3
3
  import { type Day } from '../support/Day'
4
4
  import { type DropdownSection } from './Dropdown'
@@ -48,7 +48,7 @@ export interface TableColumn<V, R, SV, SR> {
48
48
  resizable?: boolean
49
49
  cell?: TableCell<V, R> | TableColumnCellFn<V, R>
50
50
  summaryCell?: TableCell<SV, SR> | TableColumnCellFn<SV, SR>
51
- show?: boolean
51
+ show?: MaybeRefOrGetter<boolean>
52
52
  }
53
53
 
54
54
  export type TableColumnCellFn<V, R> = (value: V, record: R) => TableCell<V, R>
@@ -158,6 +158,8 @@ export interface TableCellAvatars<V = any, R = any> extends TableCellBase {
158
158
  type: 'avatars'
159
159
  avatars: TableCellAvatarsOption[] | ((value: V, record: R) => TableCellAvatarsOption[])
160
160
  color?: 'neutral' | 'soft' | 'mute'
161
+ avatarCount?: number
162
+ nameCount?: number
161
163
  }
162
164
 
163
165
  export interface TableCellAvatarsOption {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@globalbrain/sefirot",
3
- "version": "3.12.0",
3
+ "version": "3.13.1",
4
4
  "packageManager": "pnpm@8.12.1",
5
5
  "description": "Vue Components for Global Brain Design System.",
6
6
  "author": "Kia Ishii <ka.ishii@globalbrains.com>",