rayyy-vue-table-components 1.2.20 → 1.2.22

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,7 +1,6 @@
1
1
  type __VLS_Props = {
2
2
  showFilter?: boolean;
3
3
  showSearch?: boolean;
4
- fullInput?: boolean;
5
4
  badgeValue?: number;
6
5
  };
7
6
  declare function __VLS_template(): {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rayyy-vue-table-components",
3
- "version": "1.2.20",
3
+ "version": "1.2.22",
4
4
  "description": "Vue 3 + Element Plus 表格組件庫",
5
5
  "type": "module",
6
6
  "main": "./dist/index.umd.js",
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts" generic="T extends Record<string, unknown>">
2
- import { computed, ref } from 'vue'
2
+ import { computed, ref, useAttrs } from 'vue'
3
3
  import type { FormInstance, FormRules } from 'element-plus'
4
4
 
5
5
  type Props<T extends object = object> = {
@@ -10,6 +10,9 @@ type Props<T extends object = object> = {
10
10
  }
11
11
  const props = withDefaults(defineProps<Props>(), {})
12
12
 
13
+ // 獲取所有非 props 屬性
14
+ const attrs = useAttrs()
15
+
13
16
  const computedLabelWidth = computed(() => {
14
17
  if (props.labelWidth) return props.labelWidth
15
18
  else return '100px'
@@ -47,6 +50,7 @@ defineExpose({
47
50
 
48
51
  <template>
49
52
  <el-form
53
+ v-bind="attrs"
50
54
  ref="formRef"
51
55
  :model="formData"
52
56
  :label-width="computedLabelWidth"
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" setup>
2
- import { computed } from 'vue'
2
+ import { computed, useAttrs } from 'vue'
3
3
  import { Search } from '@element-plus/icons-vue'
4
4
 
5
5
  const props = defineProps<{
@@ -20,6 +20,9 @@ const emits = defineEmits<{
20
20
  (e: 'update:clearValue'): void
21
21
  }>()
22
22
 
23
+ // 獲取所有非 props 屬性
24
+ const attrs = useAttrs()
25
+
23
26
  const v = computed({
24
27
  get: () => props.modelValue,
25
28
  set: (val: string | number | null | undefined) => emits('update:modelValue', val),
@@ -31,6 +34,7 @@ const handlerClear = () => {
31
34
 
32
35
  <template>
33
36
  <el-input
37
+ v-bind="attrs"
34
38
  v-model="v"
35
39
  :placeholder="props.placeholder"
36
40
  :type="props.type"
@@ -1,6 +1,6 @@
1
1
 
2
2
  <script setup lang="ts">
3
- import { ref } from 'vue'
3
+ import { ref, useAttrs } from 'vue'
4
4
  import type { ElInput } from 'element-plus'
5
5
 
6
6
  const inputValue = ref<string>('')
@@ -18,6 +18,9 @@ const props = withDefaults(
18
18
  }
19
19
  )
20
20
 
21
+ // 獲取所有非 props 屬性
22
+ const attrs = useAttrs()
23
+
21
24
  const emits = defineEmits<{
22
25
  (e: 'update:modelValue', val: string[]): void
23
26
  (e: 'inputError'): void
@@ -60,7 +63,7 @@ const deleteLastTag = () => {
60
63
  </script>
61
64
 
62
65
  <template>
63
- <div class="w-full border border-t rounded" @click="focusInput" >
66
+ <div v-bind="attrs" class="w-full border border-t rounded" @click="focusInput" >
64
67
  <el-tag
65
68
  v-for="(tag, position) in props.modelValue"
66
69
  :key="tag"
@@ -1,5 +1,6 @@
1
1
  <template>
2
2
  <el-select
3
+ v-bind="attrs"
3
4
  :model-value="modelValue"
4
5
  :class="props.class"
5
6
  :placeholder="props.placeholder"
@@ -17,6 +18,7 @@
17
18
  </template>
18
19
 
19
20
  <script lang="ts" setup>
21
+ import { useAttrs } from 'vue'
20
22
  import type { ElOptions } from '@/types/OptionDto.ts'
21
23
 
22
24
  export type Selection = string | string[]
@@ -42,6 +44,9 @@ const props = withDefaults(
42
44
  },
43
45
  )
44
46
 
47
+ // 獲取所有非 props 屬性
48
+ const attrs = useAttrs()
49
+
45
50
  const emits = defineEmits<{
46
51
  (e: 'update:modelValue', data?: Selection): void
47
52
  }>()
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" setup>
2
- import { computed } from 'vue'
2
+ import { computed, useAttrs } from 'vue'
3
3
 
4
4
  const props = defineProps<{
5
5
  text?: string
@@ -19,6 +19,9 @@ const emits = defineEmits<{
19
19
  (e: 'click', evt: MouseEvent): void
20
20
  }>()
21
21
 
22
+ // 獲取所有非 props 屬性
23
+ const attrs = useAttrs()
24
+
22
25
  const click = (evt: MouseEvent) => {
23
26
  emits('click', evt)
24
27
  }
@@ -33,6 +36,7 @@ const buttonClass = computed(() => {
33
36
 
34
37
  <template>
35
38
  <el-button
39
+ v-bind="attrs"
36
40
  :type="props.type"
37
41
  :size="props.size"
38
42
  :plain="props.plain"
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" setup>
2
- import { computed, ref } from 'vue'
2
+ import { computed, ref, useAttrs } from 'vue'
3
3
  import { useWindowSize } from '@vueuse/core'
4
4
  import { BaseBtn } from '@/components'
5
5
  import { Search, Filter } from '@element-plus/icons-vue'
@@ -10,6 +10,9 @@ defineProps<{
10
10
  badgeValue?: number
11
11
  }>()
12
12
 
13
+ // 獲取所有非 props 屬性
14
+ const attrs = useAttrs()
15
+
13
16
  const showDrawer = ref(false)
14
17
 
15
18
  function onClickBtn() {
@@ -40,7 +43,7 @@ const submitFilter = () => {
40
43
  </script>
41
44
 
42
45
  <template>
43
- <base-btn type="primary" class="filter-btn" @click="onClickBtn">
46
+ <base-btn v-bind="attrs" type="primary" class="filter-btn" @click="onClickBtn">
44
47
  <el-badge
45
48
  :value="badgeValue"
46
49
  class="!flex justify-center items-center"
@@ -1,12 +1,11 @@
1
1
  <script lang="ts" setup>
2
- import { ref } from 'vue'
2
+ import { ref, useAttrs } from 'vue'
3
3
  import BaseInput from '../form/BaseInput.vue'
4
4
  import FilterBtn from './FilterBtn.vue'
5
5
 
6
6
  defineProps<{
7
7
  showFilter?: boolean
8
8
  showSearch?: boolean
9
- fullInput?: boolean
10
9
  badgeValue?: number
11
10
  }>()
12
11
 
@@ -16,6 +15,9 @@ const emits = defineEmits<{
16
15
  (e: 'update:resetFilter'): void
17
16
  }>()
18
17
 
18
+ // 獲取所有非 props 屬性
19
+ const attrs = useAttrs()
20
+
19
21
  const keyword = ref('')
20
22
 
21
23
  const doSearch = () => {
@@ -30,13 +32,13 @@ const resetFilter = () => {
30
32
  </script>
31
33
 
32
34
  <template>
33
- <div class="search-bar">
35
+ <div v-bind="attrs" class="search-bar">
34
36
  <div class="search-bar-left">
35
37
  <slot name="button" />
36
38
  </div>
37
39
 
38
40
  <div class="flex items-center justify-end">
39
- <div v-if="showSearch" :class="{ 'w-full': fullInput, 'search-input': !fullInput }">
41
+ <div v-if="showSearch" class="search-input">
40
42
  <base-input
41
43
  v-model="keyword"
42
44
  placeholder="請輸入關鍵字搜尋列表"
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { toRefs } from 'vue'
2
+ import { toRefs, computed } from 'vue'
3
3
  import type { Pager } from '@/types'
4
4
  import { MainPanel, SearchBar } from '@/components'
5
5
 
@@ -22,6 +22,9 @@ const emits = defineEmits<{
22
22
  (e: 'updatePageSize', limit: number): boolean
23
23
  }>()
24
24
 
25
+ const showAllFeatures = computed(() => {
26
+ return props.showDefaultSearch || (props.showSearch && props.showEdit && props.showFilter)
27
+ })
25
28
  const search = (keyword: string) => {
26
29
  emits('search', keyword)
27
30
  }
@@ -43,15 +46,15 @@ const changePageSize = (limit: number) => {
43
46
  <main-panel :title="props.title" :show-back="showBack">
44
47
  <template #searchBar>
45
48
  <search-bar
46
- :show-filter="showFilter"
47
- :show-search="showSearch"
49
+ :show-filter="showAllFeatures || showFilter"
50
+ :show-search="showAllFeatures || showSearch"
48
51
  :badge-value="badgeValue"
49
52
  @keydown:enter="search"
50
53
  @update:clear="clearable"
51
54
  >
52
55
  <template #button>
53
56
  <slot name="firstButton"></slot>
54
- <slot name="customButton"> </slot>
57
+ <slot name="customButton" v-if="showAllFeatures || showEdit"> </slot>
55
58
  <slot name="lastButton"></slot>
56
59
  </template>
57
60
  <template #filterBody>