@hostlink/nuxt-light 1.27.2 → 1.27.4

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,7 +1,7 @@
1
1
  {
2
2
  "name": "light",
3
3
  "configKey": "light",
4
- "version": "1.27.2",
4
+ "version": "1.27.4",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
7
7
  "unbuild": "2.0.0"
@@ -34,6 +34,7 @@ export default {
34
34
 
35
35
  const root = h(QBtn, {
36
36
  ...this.$props, // 傳遞 props
37
+ ...this.$light.getButtonProps(this.$props), // 傳遞按鈕屬性
37
38
  ...filteredAttrs, // 傳遞過濾後的 attrs
38
39
  onClick: handleClick, // 明確綁定 handleClick
39
40
  }, this.$slots);
@@ -1,9 +1,9 @@
1
1
  declare namespace _default {
2
2
  let name: string;
3
3
  let props: any;
4
- function data(): {
5
- normalizedOptions: any[];
6
- filteredOptions: any[];
4
+ function setup(props: any): {
5
+ filteredOptions: import("vue").Ref<any, any>;
6
+ normalizedOptions: import("vue").ComputedRef<any[]>;
7
7
  };
8
8
  namespace methods {
9
9
  function filterOptions(inputValue: any, update: any, abort: any): void;
@@ -1,36 +1,31 @@
1
- import { h } from 'vue';
1
+ import { computed, h, ref } from 'vue';
2
2
  import { QSelect } from 'quasar';
3
3
 
4
+ // 將 normalizeOptions 拆分為更小的函數
5
+ const normalizeOption = (option, i) => {
6
+ if (typeof option === 'string' || typeof option === 'number') {
7
+ return { label: String(option), value: String(option) };
8
+ }
9
+ if (typeof option === 'object') {
10
+ if ('group' in option) {
11
+ option.options = normalizeOptions(option.options || [], i);
12
+ return option;
13
+ } else if ('value' in option && typeof option.value !== 'string') {
14
+ Object.assign(option, { value: option.value });
15
+ }
16
+ }
17
+ return option;
18
+ };
19
+
4
20
  const normalizeOptions = (options, i = { count: 1 }) => {
5
21
  if (Array.isArray(options)) {
6
- return options.map((option) => {
7
- if (typeof option === 'string' || typeof option === 'number') {
8
- return {
9
- label: String(option),
10
- value: String(option),
11
- }
12
- }
13
- if (typeof option == 'object') {
14
- if ('group' in option) {
15
- option.options = normalizeOptions(option.options || [], i)
16
- return option
17
- } else if ('value' in option && typeof option.value !== 'string') {
18
- Object.assign(option, {
19
- value: option.value,
20
- })
21
- }
22
- }
23
- return option
24
- }
25
- )
22
+ return options.map(option => normalizeOption(option, i));
26
23
  }
27
- return Object.keys(options).map((value) => {
28
- return {
29
- label: options[value],
30
- value,
31
- }
32
- })
33
- }
24
+ return Object.keys(options).map(value => ({
25
+ label: options[value],
26
+ value,
27
+ }));
28
+ };
34
29
 
35
30
  export default {
36
31
  name: 'LSelect',
@@ -39,7 +34,7 @@ export default {
39
34
  emitValue: { type: Boolean, default: true },
40
35
  mapOptions: { type: Boolean, default: true },
41
36
  hideBottomSpace: { type: Boolean, default: true },
42
- required: { type: Boolean, default: false },
37
+ required: Boolean,
43
38
  filled: { type: Boolean, default: undefined },
44
39
  outlined: { type: Boolean, default: undefined },
45
40
  standout: { type: Boolean, default: undefined },
@@ -50,13 +45,15 @@ export default {
50
45
  optionLabel: { type: [String, Function], default: 'label' },
51
46
  optionValue: { type: String, default: 'value' },
52
47
  inputDebounce: { type: [Number, String], default: 0 },
53
-
54
48
  },
55
- data() {
56
- const normalizedOptions = normalizeOptions(this.options); // 將選項標準化
49
+ setup(props) {
50
+ // 使用 computed 來緩存 normalizedOptions
51
+ const normalizedOptions = computed(() => normalizeOptions(props.options));
52
+ const filteredOptions = ref(props.options);
53
+
57
54
  return {
58
- normalizedOptions: normalizedOptions, // 用於存儲標準化的選項
59
- filteredOptions: normalizedOptions // 用於存儲過濾後的選項
55
+ filteredOptions,
56
+ normalizedOptions,
60
57
  };
61
58
  },
62
59
  methods: {
@@ -67,22 +64,27 @@ export default {
67
64
  }
68
65
 
69
66
  update(() => {
70
- this.filteredOptions = this.normalizedOptions.filter(option => {
71
-
72
- const label = typeof this.optionLabel === 'function' ? this.optionLabel(option) : option[this.optionLabel];
67
+ this.filteredOptions.value = this.normalizedOptions.filter(option => {
68
+ const label =
69
+ typeof this.optionLabel === 'function'
70
+ ? this.optionLabel(option)
71
+ : option[this.optionLabel];
73
72
  return label && label.toLowerCase().includes(inputValue.toLowerCase());
74
73
  });
75
74
  });
76
75
  },
77
76
  },
78
77
  render() {
79
- return h(QSelect, {
80
- ...this.$light.getInputProps(this.$props), // 使用主題樣式的輸入屬性
81
- 'onUpdate:modelValue': this.$emit.bind(this, 'update:modelValue'),
82
- onFilter: this.$props.useInput ? this.filterOptions : undefined, // 僅在 filterable 為 true 時使用 filterOptions
83
- options: this.$props.useInput ? this.filteredOptions : this.$props.options,
84
- }, {
85
- ...this.$slots,
86
- });
78
+ return h(
79
+ QSelect,
80
+ {
81
+ ...this.$props,
82
+ ...this.$light.getInputProps(this.$props), // 使用主題樣式的輸入屬性
83
+ 'onUpdate:modelValue': this.$emit.bind(this, 'update:modelValue'),
84
+ onFilter: this.$props.useInput ? this.filterOptions : undefined, // 僅在 filterable 為 true 時使用 filterOptions
85
+ options: this.$props.useInput ? this.filteredOptions.value : this.$props.options,
86
+ },
87
+ this.$slots
88
+ );
87
89
  },
88
90
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "1.27.2",
3
+ "version": "1.27.4",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": {
6
6
  "type": "git",