@globalbrain/sefirot 3.38.0 → 3.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.
@@ -8,7 +8,6 @@ export type Size =
8
8
  | 'medium'
9
9
  | 'large'
10
10
  | 'jumbo'
11
- | 'mega'
12
11
  | 'fill'
13
12
 
14
13
  const props = defineProps<{
@@ -0,0 +1,71 @@
1
+ <script setup lang="ts">
2
+ import { computed } from 'vue'
3
+ import SAvatar from './SAvatar.vue'
4
+
5
+ export type Size = 'mini' | 'small' | 'medium' | 'large' | 'jumbo'
6
+
7
+ const props = withDefaults(defineProps<{
8
+ size?: Size
9
+ avatars: { image?: string; name?: string }[]
10
+ avatarCount?: number
11
+ }>(), {
12
+ size: 'medium',
13
+ avatarCount: 2
14
+ })
15
+
16
+ const avatars = computed(() => {
17
+ return props.avatarCount < 1 ? props.avatars : props.avatars.slice(0, props.avatarCount)
18
+ })
19
+
20
+ const count = computed(() => {
21
+ return props.avatarCount < 1 ? 0 : Math.max(0, props.avatars.length - props.avatarCount)
22
+ })
23
+ </script>
24
+
25
+ <template>
26
+ <div class="SAvatarStack" :class="size">
27
+ <SAvatar
28
+ v-for="(avatar, index) in avatars"
29
+ :key="index"
30
+ :size="size"
31
+ :avatar="avatar.image"
32
+ :name="avatar.name"
33
+ />
34
+ <div v-if="count" class="more">+{{ count }}</div>
35
+ </div>
36
+ </template>
37
+
38
+ <style scoped lang="postcss">
39
+ .SAvatarStack {
40
+ display: flex;
41
+
42
+ > * {
43
+ border: 2px solid var(--c-bg-elv-2);
44
+ flex-shrink: 0;
45
+ }
46
+
47
+ &.mini > *:not(:last-child) { margin-right: -6px }
48
+ &.small > *:not(:last-child) { margin-right: -8px }
49
+ &.medium > *:not(:last-child) { margin-right: -8px }
50
+ &.large > *:not(:last-child) { margin-right: -12px }
51
+ &.jumbo > *:not(:last-child) { margin-right: -16px }
52
+ }
53
+
54
+ .more {
55
+ aspect-ratio: 1;
56
+ font-feature-settings: 'tnum';
57
+ display: flex;
58
+ justify-content: center;
59
+ align-items: center;
60
+ background-color: var(--c-bg-mute-1);
61
+ border-radius: 50%;
62
+ line-height: 1;
63
+ color: var(--c-text-2);
64
+
65
+ .mini & { font-size: 10px }
66
+ .small & { font-size: 10px }
67
+ .medium & { font-size: 12px }
68
+ .large & { font-size: 12px }
69
+ .jumbo & { font-size: 14px }
70
+ }
71
+ </style>
@@ -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.38.0",
3
+ "version": "3.39.0",
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>",
@@ -21,7 +21,8 @@
21
21
  "lib"
22
22
  ],
23
23
  "scripts": {
24
- "docs": "vitepress dev docs --port 4000",
24
+ "docs": "pnpm docs:dev",
25
+ "docs:dev": "vitepress dev docs --port 4000",
25
26
  "docs:build": "vitepress build docs",
26
27
  "docs:preview": "vitepress serve docs --port 3000",
27
28
  "story": "histoire dev --port 3000",