@hostlink/nuxt-light 1.26.12 → 1.27.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.
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "light",
3
3
  "configKey": "light",
4
- "version": "1.26.12",
4
+ "version": "1.27.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
7
7
  "unbuild": "2.0.0"
@@ -0,0 +1,6 @@
1
+ declare namespace _default {
2
+ let name: string;
3
+ let props: any;
4
+ function render(): any;
5
+ }
6
+ export default _default;
@@ -0,0 +1,38 @@
1
+ import { h } from "vue";
2
+ import { useQuasar, QBtn } from "quasar";
3
+
4
+ export default {
5
+ name: "LBtn",
6
+ props: {
7
+ ...QBtn.props,
8
+ permission: { type: String, default: "" },
9
+ confirmTitle: { type: String, default: "Confirm" },
10
+ confirmMessage: { type: String, default: undefined },
11
+ },
12
+ render() {
13
+ const $q = useQuasar();
14
+
15
+ const root = h(QBtn, {
16
+ ...this.$props,
17
+ ...this.$light.getButtonProps(this.$props),
18
+ onClick: () => {
19
+ const args = arguments;
20
+ if (this.$props.confirmMessage) {
21
+ $q.dialog({
22
+ color: this.$light.color,
23
+ title: this.$props.confirmTitle,
24
+ message: this.$props.confirmMessage,
25
+ ok: "Yes",
26
+ cancel: "No",
27
+ }).onOk(() => {
28
+ this.$props.onClick?.apply(null, args);
29
+ });
30
+ } else {
31
+ this.$props.onClick?.apply(null, args);
32
+ }
33
+ },
34
+ }, this.$slots);
35
+
36
+ return this.$light.isGranted(this.permission) ? root : null;
37
+ },
38
+ }
@@ -0,0 +1,13 @@
1
+ declare namespace _default {
2
+ let name: string;
3
+ let props: any;
4
+ function data(): {
5
+ normalizedOptions: any[];
6
+ filteredOptions: any[];
7
+ };
8
+ namespace methods {
9
+ function filterOptions(inputValue: any, update: any, abort: any): void;
10
+ }
11
+ function render(): any;
12
+ }
13
+ export default _default;
@@ -0,0 +1,85 @@
1
+ import { h } from 'vue';
2
+ import { QSelect } from 'quasar';
3
+
4
+ const normalizeOptions = (options, i = { count: 1 }) => {
5
+ 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
+ )
26
+ }
27
+ return Object.keys(options).map((value) => {
28
+ return {
29
+ label: options[value],
30
+ value,
31
+ }
32
+ })
33
+ }
34
+
35
+ export default {
36
+ name: 'LSelect',
37
+ props: {
38
+ ...QSelect.props,
39
+ emitValue: { type: Boolean, default: true },
40
+ mapOptions: { type: Boolean, default: true },
41
+ hideBottomSpace: { type: Boolean, default: true },
42
+ required: { type: Boolean, default: false },
43
+ filled: { type: Boolean, default: undefined },
44
+ outlined: { type: Boolean, default: undefined },
45
+ standout: { type: Boolean, default: undefined },
46
+ rounded: { type: Boolean, default: undefined },
47
+ dense: { type: Boolean, default: undefined },
48
+ square: { type: Boolean, default: undefined },
49
+ stackLabel: { type: Boolean, default: undefined },
50
+ optionLabel: { type: String, default: 'label' },
51
+ optionValue: { type: String, default: 'value' },
52
+ },
53
+ data() {
54
+ const normalizedOptions = normalizeOptions(this.options); // 將選項標準化
55
+ return {
56
+ normalizedOptions: normalizedOptions, // 用於存儲標準化的選項
57
+ filteredOptions: normalizedOptions // 用於存儲過濾後的選項
58
+ };
59
+ },
60
+ methods: {
61
+ filterOptions(inputValue, update, abort) {
62
+ if (this.onFilter) {
63
+ this.onFilter(inputValue, update, abort);
64
+ return;
65
+ }
66
+
67
+ update(() => {
68
+ this.filteredOptions = this.normalizedOptions.filter(option => {
69
+ const label = option[this.optionLabel];
70
+ return label && label.toLowerCase().includes(inputValue.toLowerCase());
71
+ });
72
+ });
73
+ },
74
+ },
75
+ render() {
76
+ return h(QSelect, {
77
+ ...this.$light.getInputProps(this.$props), // 使用主題樣式的輸入屬性
78
+ 'onUpdate:modelValue': this.$emit.bind(this, 'update:modelValue'),
79
+ onFilter: this.$props.useInput ? this.filterOptions : undefined, // 僅在 filterable 為 true 時使用 filterOptions
80
+ options: this.$props.useInput ? this.filteredOptions : this.$props.options,
81
+ }, {
82
+ ...this.$slots,
83
+ });
84
+ },
85
+ };
@@ -11,6 +11,7 @@ const node = props.context.node;
11
11
  const min = props.context.node.props.min ?? 1;
12
12
  const max = props.context.node.props.max ?? Infinity;
13
13
  const sortable = (props.context.node.props.sortable !== undefined) ? props.context.node.props.sortable : true;
14
+ const addLabel=props.context.node.props.addLabel ?? 'Add';
14
15
 
15
16
  const [parent, localValue] = useDragAndDrop(props.context.value, {
16
17
  dragHandle: ".l-repeater-handle",
@@ -104,6 +105,6 @@ const cursor = ref('cursor-grab');
104
105
  </q-item>
105
106
  </FormKit>
106
107
  </q-list>
107
- <q-btn @click="onAdd" label="Add" icon="sym_o_add" :color="$light.color" outline />
108
+ <q-btn @click="onAdd" :label="addLabel" icon="sym_o_add" :color="$light.color" outline />
108
109
  </FormKit>
109
110
  </template>
@@ -22,8 +22,10 @@ if (props.context.state.required) { //no clearable
22
22
  clearable = true;
23
23
  }
24
24
 
25
+
25
26
  </script>
26
27
  <template>
28
+
27
29
  <l-select v-model="value" :label="context.label" v-bind="context.attrs" :error="error" :error-message="errorMessage"
28
30
  :clearable="clearable" :required="context.state.required" :disable="context.disabled">
29
31
  <template v-for="(s, name) in $slots" v-slot:[name]="props" :key="name">
@@ -88,7 +88,7 @@ export const createLightPlugin = () => {
88
88
  case "l-repeater":
89
89
  return node.define({
90
90
  type: "input",
91
- props: ["min", "max", "sortable"],
91
+ props: ["min", "max", "sortable", "addLabel"],
92
92
  component: RepeaterVue
93
93
  });
94
94
  case "l-form":
@@ -58,6 +58,7 @@ const languages = tt.app.languages.map((lang) => {
58
58
  </script>
59
59
  <template>
60
60
  <l-page>
61
+
61
62
  <FormKit type="l-form" :value="obj">
62
63
  <l-row>
63
64
  <l-col md="6">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "1.26.12",
3
+ "version": "1.27.0",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": {
6
6
  "type": "git",