@globalbrain/sefirot 3.37.0 → 3.38.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.
@@ -44,6 +44,8 @@ const initial = computed(() => props.name?.charAt(0).toUpperCase())
44
44
 
45
45
  .img {
46
46
  object-fit: cover;
47
+ height: 100%;
48
+ width: 100%;
47
49
  }
48
50
 
49
51
  .initial {
@@ -163,7 +163,11 @@ function onClick() {
163
163
  }
164
164
 
165
165
  .SInputCheckbox.disabled {
166
- .box {
166
+ .input {
167
+ cursor: not-allowed;
168
+ }
169
+
170
+ .input .box {
167
171
  border-color: var(--input-disabled-border-color);
168
172
  background-color: var(--input-disabled-bg-color);
169
173
 
@@ -171,6 +175,13 @@ function onClick() {
171
175
  &:focus:not(:focus-visible) { border-color: var(--input-disabled-border-color); }
172
176
  }
173
177
 
174
- .input { cursor: not-allowed; }
178
+ .input.on .box {
179
+ border-color: var(--c-border-info-1);
180
+ background-color: var(--c-blue-8);
181
+ }
182
+
183
+ .check-icon {
184
+ color: var(--c-white-a3);
185
+ }
175
186
  }
176
187
  </style>
@@ -141,7 +141,11 @@ function onClick() {
141
141
  }
142
142
 
143
143
  .SInputRadio.disabled {
144
- .box {
144
+ .input {
145
+ cursor: not-allowed;
146
+ }
147
+
148
+ .input .box {
145
149
  border-color: var(--input-disabled-border-color);
146
150
  background-color: var(--input-disabled-bg-color);
147
151
 
@@ -149,6 +153,12 @@ function onClick() {
149
153
  &:focus:not(:focus-visible) { border-color: var(--input-disabled-border-color); }
150
154
  }
151
155
 
152
- .input { cursor: not-allowed; }
156
+ .input.on .box {
157
+ border-color: var(--c-border-info-1);
158
+ }
159
+
160
+ .check {
161
+ background-color: var(--c-blue-9);
162
+ }
153
163
  }
154
164
  </style>
@@ -136,19 +136,17 @@ const indexes = computed(() => {
136
136
  return records.map((record, i) => indexField ? record[indexField] : i)
137
137
  })
138
138
 
139
- const selectedIndexes = reactive(new Set())
139
+ const selectedIndexes = reactive(new Set(Array.isArray(props.selected) ? props.selected : []))
140
140
 
141
141
  const control = computed({
142
142
  get() {
143
- const selected = indexes.value.filter((index) => {
144
- return selectedIndexes.has(index)
145
- })
146
-
147
- updateSelected(selected)
143
+ if (Array.isArray(props.selected)) {
144
+ return props.selected.length === indexes.value.length
145
+ ? true
146
+ : props.selected.length ? 'indeterminate' : false
147
+ }
148
148
 
149
- return selected.length === indexes.value.length
150
- ? true
151
- : selected.length ? 'indeterminate' : false
149
+ return 'indeterminate' // doesn't matter
152
150
  },
153
151
 
154
152
  set(newValue) {
@@ -170,6 +168,12 @@ watch(indexes, (newValue, oldValue) => {
170
168
  }
171
169
  })
172
170
 
171
+ watch(selectedIndexes, (newValue) => {
172
+ if (Array.isArray(props.selected)) {
173
+ updateSelected(Array.from(newValue))
174
+ }
175
+ })
176
+
173
177
  const virtualizerOptions = computed(() => ({
174
178
  count: recordsWithSummary.value.length,
175
179
  getScrollElement: () => body.value,
@@ -390,7 +394,12 @@ function updateSelected(selected: any) {
390
394
  @resize="(value) => updateColWidth(key, value, true)"
391
395
  >
392
396
  <SInputCheckbox
393
- v-if="Array.isArray(selected) && key === '__select' && unref(options.records)?.length"
397
+ v-if="
398
+ Array.isArray(selected)
399
+ && key === '__select'
400
+ && unref(options.records)?.length
401
+ && options.disableSelection == null
402
+ "
394
403
  v-model="control"
395
404
  />
396
405
  </STableColumn>
@@ -450,11 +459,13 @@ function updateSelected(selected: any) {
450
459
  v-if="Array.isArray(selected)"
451
460
  :model-value="selectedIndexes.has(indexes[index])"
452
461
  @update:model-value="c => selectedIndexes[c ? 'add' : 'delete'](indexes[index])"
462
+ :disabled="options.disableSelection?.(recordsWithSummary[index]) === true"
453
463
  />
454
464
  <SInputRadio
455
465
  v-else
456
466
  :model-value="selected === indexes[index]"
457
467
  @update:model-value="c => updateSelected(c ? indexes[index] : null)"
468
+ :disabled="options.disableSelection?.(recordsWithSummary[index]) === true"
458
469
  />
459
470
  </template>
460
471
  </STableCell>
@@ -131,6 +131,10 @@ const computedCell = computed<TableCell | undefined>(() =>
131
131
  transition: background-color 0.1s;
132
132
  overflow: hidden;
133
133
 
134
+ :where(.row:has(.input.on)) & {
135
+ background-color: var(--c-bg-elv-4);
136
+ }
137
+
134
138
  .row:hover & {
135
139
  background-color: var(--c-bg-elv-4);
136
140
  }
@@ -16,10 +16,11 @@ export interface Table<
16
16
  loading?: MaybeRef<boolean | undefined>
17
17
  rowSize?: MaybeRef<number | undefined>
18
18
  borderless?: MaybeRef<boolean>
19
+ disableSelection?: (record: R) => boolean
19
20
 
20
21
  /**
21
22
  * @deprecated Use `<SControl>` to add equivalent features.
22
- */
23
+ */
23
24
  actions?: MaybeRef<TableHeaderAction[]>
24
25
  menu?: MaybeRef<TableMenu[] | TableMenu[][]>
25
26
  header?: MaybeRef<boolean | undefined>
@@ -5,6 +5,7 @@ import { _required } from './validators'
5
5
 
6
6
  export interface RuleOptions {
7
7
  optional?: boolean
8
+ async?: boolean
8
9
  message(params: MessageProps): string
9
10
  validation(value: unknown): boolean | Promise<boolean>
10
11
  }
@@ -18,14 +19,14 @@ export function createRule(
18
19
  ): ValidationRuleWithParams {
19
20
  const lang = useLang()
20
21
 
22
+ function validation(value: unknown) {
23
+ return options.optional && !_required(value)
24
+ ? true
25
+ : options.validation(value)
26
+ }
27
+
21
28
  return helpers.withMessage(
22
- (params) => {
23
- return options.message({ ...params, lang })
24
- },
25
- (value) => {
26
- return options.optional && !_required(value)
27
- ? true
28
- : options.validation(value)
29
- }
29
+ (params) => options.message({ ...params, lang }),
30
+ options.async ? helpers.withAsync(validation) : validation
30
31
  )
31
32
  }
@@ -11,6 +11,7 @@ export function requiredIf(
11
11
  msg?: string
12
12
  ) {
13
13
  return createRule({
14
+ async: true,
14
15
  message: ({ lang }) => msg ?? message[lang],
15
16
  validation: (value) => baseRequiredIf(value, condition)
16
17
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@globalbrain/sefirot",
3
- "version": "3.37.0",
3
+ "version": "3.38.1",
4
4
  "packageManager": "pnpm@8.15.4",
5
5
  "description": "Vue Components for Global Brain Design System.",
6
6
  "author": "Kia Ishii <ka.ishii@globalbrains.com>",