@globalbrain/sefirot 3.32.0 → 3.33.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.
@@ -17,7 +17,7 @@ const props = defineProps<{
17
17
  checkIcon?: IconifyIcon | DefineComponent
18
18
  checkText?: string
19
19
  checkColor?: Color
20
- text: string
20
+ text?: string
21
21
  disabled?: boolean
22
22
  modelValue: boolean
23
23
  validation?: Validatable
@@ -68,7 +68,7 @@ function onClick() {
68
68
  <div class="check" />
69
69
  </div>
70
70
 
71
- <p class="text">{{ text }}</p>
71
+ <p class="text" v-if="text">{{ text }}</p>
72
72
  </div>
73
73
  </div>
74
74
  <template v-if="$slots.info" #info><slot name="info" /></template>
@@ -1,4 +1,4 @@
1
- <script setup lang="ts">
1
+ <script setup lang="ts" generic="S extends any[] | any | undefined = undefined">
2
2
  import { useVirtualizer } from '@tanstack/vue-virtual'
3
3
  import { useResizeObserver } from '@vueuse/core'
4
4
  import xor from 'lodash-es/xor'
@@ -15,6 +15,7 @@ import {
15
15
  import { type Table } from '../composables/Table'
16
16
  import { getTextWidth } from '../support/Text'
17
17
  import SInputCheckbox from './SInputCheckbox.vue'
18
+ import SInputRadio from './SInputRadio.vue'
18
19
  import SSpinner from './SSpinner.vue'
19
20
  import STableCell from './STableCell.vue'
20
21
  import STableColumn from './STableColumn.vue'
@@ -24,11 +25,11 @@ import STableItem from './STableItem.vue'
24
25
 
25
26
  const props = defineProps<{
26
27
  options: Table
27
- selected?: unknown[]
28
+ selected?: S
28
29
  }>()
29
30
 
30
31
  const emit = defineEmits<{
31
- (e: 'update:selected', value: unknown[]): void
32
+ (e: 'update:selected', value: S): void
32
33
  }>()
33
34
 
34
35
  const head = shallowRef<HTMLElement | null>(null)
@@ -41,7 +42,7 @@ const ordersToShow = computed(() => {
41
42
  const show = unref(props.options.columns)[key]?.show
42
43
  return toValue(show) !== false
43
44
  })
44
- if (!props.selected) {
45
+ if (props.selected === undefined) {
45
46
  return orders
46
47
  }
47
48
  return ['__select', ...orders]
@@ -126,7 +127,7 @@ const recordsWithSummary = computed(() => {
126
127
  })
127
128
 
128
129
  const indexes = computed(() => {
129
- if (!props.selected) {
130
+ if (props.selected === undefined) {
130
131
  return []
131
132
  }
132
133
  const records = unref(props.options.records) ?? []
@@ -139,9 +140,6 @@ const selectedIndexes = reactive(new Set())
139
140
 
140
141
  const control = computed({
141
142
  get() {
142
- if (!props.selected) {
143
- return false
144
- }
145
143
  const selected = indexes.value.filter((index) => {
146
144
  return selectedIndexes.has(index)
147
145
  })
@@ -165,12 +163,11 @@ const control = computed({
165
163
  })
166
164
 
167
165
  watch(indexes, (newValue, oldValue) => {
168
- if (!props.selected) {
169
- return
166
+ if (Array.isArray(props.selected)) {
167
+ xor(newValue, oldValue).forEach((index) => {
168
+ selectedIndexes.delete(index)
169
+ })
170
170
  }
171
- xor(newValue, oldValue).forEach((index) => {
172
- selectedIndexes.delete(index)
173
- })
174
171
  })
175
172
 
176
173
  const virtualizerOptions = computed(() => ({
@@ -343,8 +340,12 @@ function getCell(key: string, index: number) {
343
340
  return (isSummary(index) && col?.summaryCell) ? col?.summaryCell : col?.cell
344
341
  }
345
342
 
346
- function updateSelected(selected: unknown[]) {
347
- if (xor(selected, props.selected ?? []).length) {
343
+ function updateSelected(selected: any) {
344
+ if (Array.isArray(props.selected)) {
345
+ if (xor(selected, props.selected ?? []).length) {
346
+ emit('update:selected', selected)
347
+ }
348
+ } else {
348
349
  emit('update:selected', selected)
349
350
  }
350
351
  }
@@ -361,7 +362,7 @@ function updateSelected(selected: unknown[]) {
361
362
  :actions="unref(options.actions)"
362
363
  :borderless="unref(options.borderless)"
363
364
  :on-reset="options.onReset"
364
- :selected="selected"
365
+ :selected="Array.isArray(selected) ? selected : undefined"
365
366
  />
366
367
 
367
368
  <div class="table" role="grid">
@@ -389,7 +390,7 @@ function updateSelected(selected: unknown[]) {
389
390
  @resize="(value) => updateColWidth(key, value, true)"
390
391
  >
391
392
  <SInputCheckbox
392
- v-if="key === '__select' && unref(options.records)?.length"
393
+ v-if="Array.isArray(selected) && key === '__select' && unref(options.records)?.length"
393
394
  v-model="control"
394
395
  />
395
396
  </STableColumn>
@@ -444,11 +445,18 @@ function updateSelected(selected: unknown[]) {
444
445
  :record="recordsWithSummary[index]"
445
446
  :records="unref(options.records)!"
446
447
  >
447
- <SInputCheckbox
448
- v-if="key === '__select' && !isSummary(index)"
449
- :value="selectedIndexes.has(indexes[index])"
450
- @change="c => selectedIndexes[c ? 'add' : 'delete'](indexes[index])"
451
- />
448
+ <template v-if="key === '__select' && !isSummary(index)">
449
+ <SInputCheckbox
450
+ v-if="Array.isArray(selected)"
451
+ :model-value="selectedIndexes.has(indexes[index])"
452
+ @update:model-value="c => selectedIndexes[c ? 'add' : 'delete'](indexes[index])"
453
+ />
454
+ <SInputRadio
455
+ v-else
456
+ :model-value="selected === indexes[index]"
457
+ @update:model-value="c => updateSelected(c ? indexes[index] : null)"
458
+ />
459
+ </template>
452
460
  </STableCell>
453
461
  </STableItem>
454
462
  </div>
@@ -598,6 +606,7 @@ function updateSelected(selected: unknown[]) {
598
606
  align-items: center;
599
607
  padding: 0 16px;
600
608
  min-height: 40px;
609
+ user-select: none;
601
610
  }
602
611
 
603
612
  :deep(.container) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@globalbrain/sefirot",
3
- "version": "3.32.0",
3
+ "version": "3.33.0",
4
4
  "packageManager": "pnpm@8.15.3",
5
5
  "description": "Vue Components for Global Brain Design System.",
6
6
  "author": "Kia Ishii <ka.ishii@globalbrains.com>",
@@ -72,7 +72,7 @@
72
72
  },
73
73
  "devDependencies": {
74
74
  "@globalbrain/eslint-config": "^1.5.2",
75
- "@histoire/plugin-vue": "0.17.9",
75
+ "@histoire/plugin-vue": "^0.16.5",
76
76
  "@iconify-icons/ph": "^1.2.5",
77
77
  "@iconify-icons/ri": "^1.2.10",
78
78
  "@iconify/vue": "^4.1.1",
@@ -91,7 +91,7 @@
91
91
  "eslint": "^8.56.0",
92
92
  "fuse.js": "^7.0.0",
93
93
  "happy-dom": "^13.3.8",
94
- "histoire": "0.17.9",
94
+ "histoire": "^0.16.5",
95
95
  "lodash-es": "^4.17.21",
96
96
  "markdown-it": "^14.0.0",
97
97
  "normalize.css": "^8.0.1",