@hostlink/nuxt-light 1.22.2 → 1.22.3

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.22.2",
4
+ "version": "1.22.3",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
7
7
  "unbuild": "2.0.0"
@@ -53,4 +53,9 @@ const LABLES = [
53
53
  </q-item-section>
54
54
  <q-item-section> {{ $t(label.label) }} </q-item-section>
55
55
  </q-item>
56
- </template>
56
+ </template>
57
+
58
+
59
+ <style scoped>
60
+ .q-item--active{background-color:#e0e0e0}
61
+ </style>
@@ -880,7 +880,3 @@ selectedNodePath.value = drives[0].index.toString();
880
880
  </q-page-container>
881
881
  </q-layout>
882
882
  </template>
883
-
884
- <style>
885
- .q-item--active{background-color:#e0e0e0}
886
- </style>
@@ -0,0 +1,115 @@
1
+ <script setup>
2
+ import collect from "collect.js";
3
+
4
+ import { computed, onMounted, useAttrs, ref } from "vue";
5
+
6
+ const props = defineProps({
7
+ options: {
8
+ type: Array,
9
+ required: true,
10
+ },
11
+ emitValue: {
12
+ type: Boolean,
13
+ default: true,
14
+ },
15
+ mapOptions: {
16
+ type: Boolean,
17
+ default: true,
18
+ },
19
+ });
20
+
21
+ const userString = ref("");
22
+ const items = computed(() => {
23
+
24
+ //filter out items based on user input
25
+
26
+ const filteredItems = collect(props.options)
27
+ .filter((item) => {
28
+ if (userString.value === "") {
29
+ return true;
30
+ }
31
+ return item.label.toLowerCase().includes(userString.value);
32
+ })
33
+ .toArray();
34
+
35
+ const groups = collect(filteredItems).unique("group").pluck("group").sort();
36
+
37
+ const options = collect();
38
+ groups.each((group) => {
39
+ const items = collect(filteredItems).where("group", group).toArray();
40
+ options
41
+ .push({ label: group, is_group: true, disable: true })
42
+ .push(...items);
43
+ });
44
+
45
+ return options.toArray();
46
+ });
47
+
48
+ const model = defineModel();
49
+
50
+ const attrs = useAttrs();
51
+ const handleItemUniqueByGroup = (items) => {
52
+ return;
53
+ if (!attrs.hasOwnProperty("multiple") || attrs.multiple === false) {
54
+ return;
55
+ }
56
+ /*
57
+ model.value = collect(items)
58
+ .unique((item) => {
59
+ // Allow selecting multiple items that are not grouped
60
+ if (item.group === null) {
61
+ return item.value;
62
+ }
63
+
64
+ return item.group;
65
+ })
66
+ .toArray(); */
67
+ };
68
+
69
+ onMounted(() => {
70
+ //這個功能是為了避免在多選的情況下,選擇同一個group的item
71
+ // handleItemUniqueByGroup(model.value);
72
+
73
+ });
74
+
75
+ const filterFn = (val, update, abort) => {
76
+ if (val === "") {
77
+ update(() => {
78
+ userString.value = "";
79
+ });
80
+ return;
81
+ }
82
+
83
+ const needle = val.toLowerCase();
84
+ update(() => {
85
+ userString.value = needle;
86
+ });
87
+ };
88
+
89
+ </script>
90
+
91
+ <template>
92
+
93
+
94
+ <q-select v-model="model" v-bind="$light.getInputProps($props)" :options="items" @update:model-value="handleItemUniqueByGroup"
95
+ input-debounce="0" @filter="filterFn" :color="$light.color" :style="$light.styles.input"
96
+ :emit-value="emitValue" :map-options="mapOptions">
97
+ <template v-slot:option="scope">
98
+ <q-item v-if="scope.opt.is_group" v-bind="{ ...scope.itemProps }" class="text-xs bg-grey-4" :key="scope.opt.label">
99
+ <q-item-section class="!cursor-default">
100
+ {{ scope.opt.label || "Ungroup" }}
101
+ </q-item-section>
102
+ </q-item>
103
+ <q-item v-else v-bind="{ ...scope.itemProps }" :key="scope.opt.value">
104
+ <q-item-section class="q-pl-md">{{ scope.opt.label }}</q-item-section>
105
+ </q-item>
106
+ </template>
107
+ <template v-slot:no-option>
108
+ <q-item>
109
+ <q-item-section class="text-grey">
110
+ No results
111
+ </q-item-section>
112
+ </q-item>
113
+ </template>
114
+ </q-select>
115
+ </template>
@@ -0,0 +1,34 @@
1
+ <script setup>
2
+ import { getErrorMessage } from 'formkit-quasar';
3
+ import { computed } from 'vue'
4
+ const props = defineProps({
5
+ context: Object
6
+ });
7
+
8
+ const { error, errorMessage } = getErrorMessage(props.context.node);
9
+
10
+
11
+
12
+ const value = computed({
13
+ get: () => props.context.value,
14
+ set: (val) => props.context.node.input(val)
15
+ })
16
+
17
+
18
+ let clearable = false;
19
+ if (props.context.state.required) { //no clearable
20
+ clearable = false;
21
+ } else {
22
+ clearable = true;
23
+ }
24
+
25
+ </script>
26
+ <template>
27
+ <l-group-select v-model="value" :label="context.label" v-bind="context.attrs" :error="error"
28
+ :error-message="errorMessage" :required="context.state.required"
29
+ :disable="context.disabled">
30
+ <template v-for="(s, name) in $slots" v-slot:[name]="props" :key="name">
31
+ <slot :name="name" v-bind="props ?? {}"></slot>
32
+ </template>
33
+ </l-group-select>
34
+ </template>
@@ -14,6 +14,7 @@ import InputXlsxVue from "./InputXlsx.vue";
14
14
  import FileUploadVue from "./FileUpload.vue";
15
15
  import EditorVue from "./Editor.vue";
16
16
  import ToggleVue from "./Toggle.vue";
17
+ import GroupSelect from "./GroupSelect.vue";
17
18
  export const createLightPlugin = () => {
18
19
  return (node) => {
19
20
  let type = node.props.type + "";
@@ -79,6 +80,11 @@ export const createLightPlugin = () => {
79
80
  type: "input",
80
81
  component: SelectVue
81
82
  });
83
+ case "l-group-select":
84
+ return node.define({
85
+ type: "input",
86
+ component: GroupSelect
87
+ });
82
88
  case "l-repeater":
83
89
  return node.define({
84
90
  type: "input",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "1.22.2",
3
+ "version": "1.22.3",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": {
6
6
  "type": "git",