@globalbrain/sefirot 2.37.1 → 2.39.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.
@@ -29,5 +29,6 @@ defineProps<{
29
29
  <SDropdownSectionComponent
30
30
  v-else-if="section.type === 'component'"
31
31
  :comp="section.component"
32
+ :props="section.props"
32
33
  />
33
34
  </template>
@@ -1,11 +1,12 @@
1
1
  <script setup lang="ts">
2
- import { type DefineComponent } from 'vue'
2
+ import { type Component } from 'vue'
3
3
 
4
4
  defineProps<{
5
- comp: DefineComponent
5
+ comp: Component
6
+ props?: Record<string, any>
6
7
  }>()
7
8
  </script>
8
9
 
9
10
  <template>
10
- <Component :is="comp" />
11
+ <component :is="comp" v-bind="props" />
11
12
  </template>
@@ -9,7 +9,11 @@ defineProps<{
9
9
  <template>
10
10
  <ul class="SDropdownSectionMenu">
11
11
  <li v-for="option in options" :key="option.label" class="item">
12
- <button class="button" @click="option.onClick">
12
+ <button
13
+ class="button"
14
+ @click="option.onClick"
15
+ :disabled="option.disabled"
16
+ >
13
17
  {{ option.label }}
14
18
  </button>
15
19
  </li>
@@ -33,8 +37,13 @@ defineProps<{
33
37
  font-weight: 400;
34
38
  transition: color 0.25s, background-color 0.25s;
35
39
 
36
- &:hover {
40
+ &:hover:not(:disabled) {
37
41
  background-color: var(--c-mute);
38
42
  }
43
+
44
+ &:disabled {
45
+ color: var(--c-text-3);
46
+ cursor: not-allowed;
47
+ }
39
48
  }
40
49
  </style>
@@ -27,6 +27,14 @@ const body = shallowRef<HTMLElement | null>(null)
27
27
  const block = shallowRef<HTMLElement | null>(null)
28
28
  const row = shallowRef<HTMLElement | null>(null)
29
29
 
30
+ const ordersToShow = computed(() => {
31
+ return unref(props.options.orders).filter((key) => {
32
+ return unref(props.options.columns)[key]?.show !== false
33
+ })
34
+ })
35
+
36
+ watch(() => ordersToShow.value, handleResize)
37
+
30
38
  const colToGrowAdjusted = ref(false)
31
39
 
32
40
  const colToGrow = computed(() => {
@@ -34,13 +42,13 @@ const colToGrow = computed(() => {
34
42
  return -1
35
43
  }
36
44
 
37
- return unref(props.options.orders).findIndex((key) => {
45
+ return ordersToShow.value.findIndex((key) => {
38
46
  return unref(props.options.columns)[key]?.grow
39
47
  }) ?? -1
40
48
  })
41
49
 
42
50
  const nameOfColToGrow = computed(() => {
43
- return unref(props.options.orders)[colToGrow.value]
51
+ return ordersToShow.value[colToGrow.value]
44
52
  })
45
53
 
46
54
  const cellOfColToGrow = computed(() => {
@@ -130,7 +138,7 @@ useResizeObserver(block, ([entry]) => {
130
138
  const resizeObserver = useResizeObserver(head, handleResize)
131
139
 
132
140
  function stopObserving() {
133
- const orders = unref(props.options.orders)
141
+ const orders = ordersToShow.value
134
142
  colWidths[orders[orders.length - 1]] = 'auto'
135
143
  resizeObserver.stop()
136
144
  }
@@ -236,7 +244,7 @@ function getCell(key: string, index: number) {
236
244
  <div class="block" ref="block">
237
245
  <div class="row" ref="row">
238
246
  <STableItem
239
- v-for="key in unref(options.orders)"
247
+ v-for="key in ordersToShow"
240
248
  :key="key"
241
249
  :name="key"
242
250
  :class-name="unref(options.columns)[key].className"
@@ -281,7 +289,7 @@ function getCell(key: string, index: number) {
281
289
  >
282
290
  <div class="row" :class="isSummaryOrLastClass(rIndex)">
283
291
  <STableItem
284
- v-for="key in unref(options.orders)"
292
+ v-for="key in ordersToShow"
285
293
  :key="key"
286
294
  :name="key"
287
295
  :class-name="unref(options.columns)[key].className"
@@ -313,7 +321,7 @@ function getCell(key: string, index: number) {
313
321
  >
314
322
  <div class="row" :class="isSummaryOrLastClass(rIndex)">
315
323
  <STableItem
316
- v-for="key in unref(options.orders)"
324
+ v-for="key in ordersToShow"
317
325
  :key="key"
318
326
  :name="key"
319
327
  :class-name="unref(options.columns)[key].className"
@@ -20,7 +20,7 @@ const props = defineProps<{
20
20
  getter?: string | null | ((value: any, record: any) => string | null)
21
21
  color?: Color | ((value: any, record: any) => Color)
22
22
  iconColor?: Color | ((value: any, record: any) => Color)
23
- link?(value: any, record: any): string
23
+ link?: string | null | ((value: any, record: any) => string)
24
24
  onClick?(value: any, record: any): void
25
25
  }>()
26
26
 
@@ -34,6 +34,12 @@ const _value = computed(() => {
34
34
  : props.getter
35
35
  })
36
36
 
37
+ const _link = computed(() => {
38
+ return typeof props.link === 'function'
39
+ ? props.link(props.value, props.record)
40
+ : props.link
41
+ })
42
+
37
43
  const _color = computed(() => {
38
44
  return typeof props.color === 'function'
39
45
  ? props.color(props.value, props.record)
@@ -52,7 +58,7 @@ const _iconColor = computed(() => {
52
58
  <SLink
53
59
  v-if="_value"
54
60
  class="container"
55
- :href="link?.(value, record)"
61
+ :href="_link"
56
62
  :role="onClick ? 'button' : null"
57
63
  @click="() => onClick?.(value, record)"
58
64
  >
@@ -1,5 +1,5 @@
1
1
  import { type MaybeRef, useElementBounding, useWindowSize } from '@vueuse/core'
2
- import { type Ref } from 'vue'
2
+ import { type Component, type Ref } from 'vue'
3
3
  import { ref, unref } from 'vue'
4
4
 
5
5
  export type DropdownSection =
@@ -21,6 +21,7 @@ export interface DropdownSectionMenu extends DropdownSectionBase {
21
21
 
22
22
  export interface DropdownSectionMenuOption {
23
23
  label: string
24
+ disabled?: boolean
24
25
  onClick(): void
25
26
  }
26
27
 
@@ -73,7 +74,8 @@ export interface DropdownSectionActionsOption {
73
74
 
74
75
  export interface DropdownSectionComponent extends DropdownSectionBase {
75
76
  type: 'component'
76
- component: any
77
+ component: Component
78
+ props?: Record<string, any>
77
79
  }
78
80
 
79
81
  export interface ManualDropdownPosition {
@@ -43,6 +43,7 @@ export interface TableColumn<V, R, SV, SR> {
43
43
  resizable?: boolean
44
44
  cell?: TableCell | TableColumnCellFn<V, R>
45
45
  summaryCell?: TableCell | TableColumnCellFn<SV, SR>
46
+ show?: boolean
46
47
  }
47
48
 
48
49
  export type TableColumnCellFn<V, R> = (value: V, record: R) => TableCell
@@ -80,7 +81,7 @@ export interface TableCellText extends TableCellBase {
80
81
  align?: 'left' | 'center' | 'right'
81
82
  icon?: any
82
83
  value?: string | null | ((value: any, record: any) => string | null)
83
- link?(value: any, record: any): string
84
+ link?: string | null | ((value: any, record: any) => string)
84
85
  color?: TableCellValueColor | ((value: any, record: any) => TableCellValueColor)
85
86
  iconColor?: TableCellValueColor | ((value: any, record: any) => TableCellValueColor)
86
87
  onClick?(value: any, record: any): void
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@globalbrain/sefirot",
3
- "version": "2.37.1",
4
- "packageManager": "pnpm@8.5.0",
3
+ "version": "2.39.0",
4
+ "packageManager": "pnpm@8.6.2",
5
5
  "description": "Vue Components for Global Brain Design System.",
6
6
  "author": "Kia Ishii <ka.ishii@globalbrains.com>",
7
7
  "license": "MIT",