@d0rich/esprit-design 0.3.3 → 0.3.5

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.
@@ -1,27 +1,69 @@
1
- <script lang="ts">
2
- import { type StyleValue } from 'vue'
1
+ <script setup lang="ts">
2
+ import { type StyleValue, computed } from 'vue'
3
3
 
4
- export default {
4
+ defineOptions({
5
5
  name: 'DWrapShape'
6
- }
7
- </script>
8
-
9
- <script setup lang="ts">
10
- defineProps<{
6
+ })
7
+ const props = defineProps<{
11
8
  shapeClass?: string | Record<string, boolean>
12
9
  shapeStyle?: StyleValue
13
10
  filterClass?: string | Record<string, boolean>
14
11
  filterStyle?: StyleValue
15
12
  tag?: string
16
13
  }>()
14
+
15
+ const slots = defineSlots<{
16
+ 'shape-content'?: () => {}
17
+ 'bg-overlay'?: () => {}
18
+ default?: () => {}
19
+ }>()
20
+
21
+ function isClassEmpty(
22
+ cls: string | Record<string, boolean> | undefined
23
+ ): boolean {
24
+ if (!cls) return true
25
+ if (typeof cls === 'string') return !cls.trim()
26
+ return Object.keys(cls).length === 0
27
+ }
28
+
29
+ function isStyleEmpty(style: StyleValue): boolean {
30
+ if (typeof style === 'string') return !style.trim()
31
+ if (Array.isArray(style)) return style.length === 0
32
+ if (style === null) return true
33
+ if (style === undefined) return true
34
+ return Object.keys(style).length === 0
35
+ }
36
+
37
+ const isShapeCustomized = computed(() => {
38
+ if (slots['shape-content']) return true
39
+ if (!isClassEmpty(props.shapeClass)) return true
40
+ return !isStyleEmpty(props.shapeStyle)
41
+ })
42
+ const isFilterCustomized = computed(() => {
43
+ if (!isClassEmpty(props.filterClass)) return true
44
+ return !isStyleEmpty(props.filterStyle)
45
+ })
17
46
  </script>
18
47
 
19
48
  <template>
20
49
  <Component :is="tag ?? 'div'">
21
50
  <div class="d-shape">
22
- <div class="d-shape__bg-filter" :class="filterClass" :style="filterStyle">
23
- <div class="d-shape__bg-wrapper">
24
- <div class="d-shape__bg" :class="shapeClass" :style="shapeStyle">
51
+ <div
52
+ v-if="isShapeCustomized || slots['bg-overlay'] || isFilterCustomized"
53
+ class="d-shape__bg-filter"
54
+ :class="filterClass"
55
+ :style="filterStyle"
56
+ >
57
+ <div
58
+ v-if="isShapeCustomized || slots['bg-overlay']"
59
+ class="d-shape__bg-wrapper"
60
+ >
61
+ <div
62
+ v-if="isShapeCustomized"
63
+ class="d-shape__bg"
64
+ :class="shapeClass"
65
+ :style="shapeStyle"
66
+ >
25
67
  <slot name="shape-content" />
26
68
  </div>
27
69
  <slot name="bg-overlay" />