@community-release/nx-ui 0.0.30 → 0.0.32

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.
package/dist/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "ui",
3
3
  "configKey": "ui",
4
- "version": "0.0.30"
4
+ "version": "0.0.32"
5
5
  }
@@ -23,7 +23,6 @@ const props = defineProps({
23
23
  type: String,
24
24
  default: 'Hide'
25
25
  },
26
-
27
26
  modelValue: {
28
27
  type: [Boolean, null],
29
28
  default: null
@@ -0,0 +1,90 @@
1
+ <template>
2
+ <div class="component-ui-text-spoiler">
3
+ <div class="content">{{ computedText }}</div>
4
+ <div v-if="textTooLong" class="title" @click="handleClick">{{ isShown ? hideText : showText }}</div>
5
+ </div>
6
+ </template>
7
+
8
+ <script setup>
9
+ import { watch, ref, computed } from 'vue';
10
+
11
+ // Data
12
+ const emit = defineEmits(['update:modelValue']);
13
+ const props = defineProps({
14
+ text: {
15
+ type: String,
16
+ default: '...'
17
+ },
18
+ showText: {
19
+ type: String,
20
+ default: 'Show'
21
+ },
22
+ hideText: {
23
+ type: String,
24
+ default: 'Hide'
25
+ },
26
+ length: {
27
+ type: Number,
28
+ default: 0
29
+ },
30
+ modelValue: {
31
+ type: [Boolean, null],
32
+ default: null
33
+ }
34
+ });
35
+
36
+ let isShown = ref(false);
37
+ let hasModel = props.modelValue !== null;
38
+
39
+ if (hasModel) {
40
+ watch(() => props.modelValue, (v) => {
41
+ isShown.value = v;
42
+ }, { immediate: true });
43
+ }
44
+
45
+ let textTooLong = computed(() => {
46
+ return props.text.length > props.length;
47
+ });
48
+
49
+ const computedText = computed(() => {
50
+ if (!isShown.value && textTooLong.value) {
51
+ return props.text.slice(0, props.length) + '...';
52
+ } else {
53
+ return props.text;
54
+ }
55
+ });
56
+
57
+ // Methods
58
+ function handleClick() {
59
+ if (hasModel) {
60
+ emit('update:modelValue', !isShown.value);
61
+ } else {
62
+ isShown.value = !isShown.value;
63
+ }
64
+ }
65
+ </script>
66
+
67
+ <style lang="less">
68
+ .component-ui-text-spoiler {
69
+ @com-space-mini: var(--ui-space-mini);
70
+ @com-ani-ease: var(--ui-ani-ease);
71
+ @com-ani-time: var(--ui-ani-time);
72
+ @com-color-primary-text: var(--ui-color-primary-text);
73
+ @com-font-weight-medium: var(--ui-font-weight-medium);
74
+
75
+ > .title {
76
+ padding-top: @com-space-mini;
77
+
78
+ color: @com-color-primary-text;
79
+ font-weight: @com-font-weight-medium;
80
+ cursor: pointer;
81
+
82
+ -webkit-user-select: none;
83
+ user-select: none;
84
+ }
85
+
86
+ > .content {
87
+ position: relative;
88
+ }
89
+ }
90
+ </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@community-release/nx-ui",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
4
4
  "description": "nx-ui - Nuxt UI library",
5
5
  "repository": {
6
6
  "type": "git",