classcard-ui 0.2.129 → 0.2.137

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "classcard-ui",
3
- "version": "0.2.129",
3
+ "version": "0.2.137",
4
4
  "main": "dist/classcard-ui.common.js",
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -15,12 +15,13 @@
15
15
  "src/*"
16
16
  ],
17
17
  "dependencies": {
18
- "@shopify/draggable": "*",
18
+ "@shopify/draggable": "^1.0.0-beta.8",
19
19
  "@tailwindcss/forms": "^0.2.1",
20
20
  "core-js": "^3.18.0",
21
21
  "dayjs": "^1.10.7",
22
22
  "gridjs-selection": "^3.4.0",
23
23
  "gridjs-vue": "^3.4.0",
24
+ "lodash": "^4.17.21",
24
25
  "vue": "^2.6.14",
25
26
  "vue-good-table": "^2.21.8",
26
27
  "vue-multiselect": "^2.1.6",
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div>
3
3
  <div :class="classes" class="border-gray-200">
4
- <div class="flex justify-between">
4
+ <div class="flex justify-between items-center">
5
5
  <div>
6
6
  <h3 class="text-base font-semibold text-gray-900">
7
7
  {{ heading }}
@@ -10,8 +10,13 @@
10
10
  {{ description }}
11
11
  </p>
12
12
  </div>
13
- <c-button v-if="tabAction" :type="tabAction.type" :label="tabAction.label"></c-button>
14
- <c-anchor-tag v-if="tabLink" :label="tabLink.label"></c-anchor-tag>
13
+ <c-button
14
+ v-if="tabAction"
15
+ :type="tabAction.type"
16
+ :label="tabAction.label"
17
+ @action="emitTabAction"
18
+ ></c-button>
19
+ <c-anchor-tag v-if="tabLink" :label="tabLink.label" :action="emitTabLink"></c-anchor-tag>
15
20
  </div>
16
21
  </div>
17
22
  </div>
@@ -28,9 +33,20 @@ export default {
28
33
  divider: { type: Boolean },
29
34
  tabAction: { type: Object },
30
35
  tabLink: { type: Object },
36
+ actionEvent: {
37
+ type: Function,
38
+ },
31
39
  classes: {
32
40
  type: String,
33
41
  },
34
42
  },
43
+ methods: {
44
+ emitTabAction() {
45
+ this.$emit("actionEvent");
46
+ },
47
+ emitTabLink() {
48
+ this.$emit("actionEvent");
49
+ },
50
+ },
35
51
  };
36
52
  </script>
@@ -0,0 +1,166 @@
1
+ <template>
2
+ <div>
3
+ <label v-if="label" class="block text-sm font-medium text-gray-700">
4
+ {{ label }}
5
+ </label>
6
+ <div class="mt-1 relative">
7
+ <div class="relative">
8
+ <input
9
+ type="text"
10
+ class="bg-white relative w-full border border-gray-300 rounded-md shadow-sm pl-3 pr-10 py-2 text-left cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"
11
+ aria-haspopup="listbox"
12
+ aria-expanded="true"
13
+ aria-labelledby="listbox-label"
14
+ :value="inputValue"
15
+ :placeholder="placeholder"
16
+ @focus="showDropDown = true"
17
+ @blur="closeDropDown()"
18
+ />
19
+ <span
20
+ class="absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"
21
+ >
22
+ <!-- Heroicon name: solid/selector -->
23
+ <svg
24
+ class="h-5 w-5 text-gray-400"
25
+ xmlns="http://www.w3.org/2000/svg"
26
+ viewBox="0 0 20 20"
27
+ fill="currentColor"
28
+ aria-hidden="true"
29
+ >
30
+ <path
31
+ fill-rule="evenodd"
32
+ d="M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z"
33
+ clip-rule="evenodd"
34
+ />
35
+ </svg>
36
+ </span>
37
+ </div>
38
+ <!--
39
+ Select popover, show/hide based on select state.
40
+
41
+ Entering: ""
42
+ From: ""
43
+ To: ""
44
+ Leaving: "transition ease-in duration-100"
45
+ From: "opacity-100"
46
+ To: "opacity-0"
47
+ -->
48
+ <ul
49
+ class="absolute z-10 mt-1 w-full bg-white shadow-lg max-h-60 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm"
50
+ tabindex="-1"
51
+ role="listbox"
52
+ aria-labelledby="listbox-label"
53
+ aria-activedescendant="listbox-option-3"
54
+ v-if="showDropDown && options.length > 0"
55
+ >
56
+ <!--
57
+ Select option, manage highlight styles based on mouseenter/mouseleave and keyboard navigation.
58
+
59
+ Highlighted: "text-white bg-indigo-600", Not Highlighted: "text-gray-900"
60
+ -->
61
+ <span v-for="option in options" :key="option.id">
62
+ <li
63
+ class="text-gray-900 cursor-default select-none relative py-2 pl-3 pr-9"
64
+ role="option"
65
+ >
66
+ <span class="font-bold italic block truncate">
67
+ {{ option.label }}
68
+ </span>
69
+ </li>
70
+ <li
71
+ class="text-gray-900 cursor-default select-none relative py-2 pl-3 pr-9 group hover:text-white hover:bg-indigo-600"
72
+ v-for="subOption in option.options"
73
+ :key="subOption.id"
74
+ role="option"
75
+ @click="handleOptionClick(subOption)"
76
+ >
77
+ <!-- Selected: "font-semibold", Not Selected: "font-normal" -->
78
+ <span
79
+ :class="[
80
+ subOption.label === value.label
81
+ ? 'font-semibold'
82
+ : 'font-normal',
83
+ ' block truncate',
84
+ ]"
85
+ >
86
+ {{ subOption.label }}
87
+ </span>
88
+
89
+ <!--
90
+ Checkmark, only display for selected option.
91
+
92
+ Highlighted: "text-white", Not Highlighted: "text-indigo-600"
93
+ -->
94
+ <span
95
+ class="text-indigo-600 absolute inset-y-0 right-0 flex items-center pr-4 group-hover:text-white"
96
+ v-if="subOption.label === value.label"
97
+ >
98
+ <!-- Heroicon name: solid/check -->
99
+ <svg
100
+ class="h-5 w-5"
101
+ xmlns="http://www.w3.org/2000/svg"
102
+ viewBox="0 0 20 20"
103
+ fill="currentColor"
104
+ aria-hidden="true"
105
+ >
106
+ <path
107
+ fill-rule="evenodd"
108
+ d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"
109
+ clip-rule="evenodd"
110
+ />
111
+ </svg>
112
+ </span>
113
+ </li>
114
+ </span>
115
+
116
+ <!-- More items... -->
117
+ </ul>
118
+ </div>
119
+ </div>
120
+ </template>
121
+
122
+ <script>
123
+ import { debounce } from "lodash";
124
+
125
+ export default {
126
+ name: "CGroupedSelect",
127
+ props: {
128
+ label: String,
129
+ options: Array,
130
+ value: Object,
131
+ placeholder: String,
132
+ },
133
+ data() {
134
+ return {
135
+ showDropDown: false,
136
+ inputValue: "",
137
+ };
138
+ },
139
+ methods: {
140
+ onInput(e) {
141
+ this.inputValue = e.target.value;
142
+ debounce(function () {
143
+ this.$emit("search", e.target.value);
144
+ }, 500);
145
+ },
146
+ handleOptionClick(option) {
147
+ this.$emit("input", option);
148
+ this.inputValue = option.label;
149
+ },
150
+ closeDropDown() {
151
+ this.inputValue = this.value.label;
152
+ this.showDropDown = false;
153
+ },
154
+ },
155
+ watch: {
156
+ value(newValue) {
157
+ this.inputValue = newValue.label;
158
+ },
159
+ },
160
+ mounted() {
161
+ this.inputValue = this.value.label;
162
+ },
163
+ };
164
+ </script>
165
+
166
+ <style></style>
@@ -0,0 +1,3 @@
1
+ import CGroupedSelect from "./CGroupedSelect.vue";
2
+
3
+ export default CGroupedSelect;
@@ -4,12 +4,14 @@
4
4
  <v-select
5
5
  class="text-sm mt-1"
6
6
  :placeholder="placeholder"
7
- multiple
8
- taggable
7
+ :multiple="isMultiple"
8
+ :taggable="isTaggable"
9
+ :push-tags="pushTags"
9
10
  :selectable="() => (limitSelection == true ? value.length < 1 : value)"
10
11
  :filterable="false"
11
12
  v-model="value"
12
13
  :options="options"
14
+ @input="setSelectedOptions"
13
15
  @search="fetchOptions"
14
16
  :label="optionLabel"
15
17
  >
@@ -49,28 +51,59 @@ export default {
49
51
  },
50
52
  label: String,
51
53
  placeholder: String,
54
+ // whether multiple fields are allowed or not
55
+ isMultiple: {
56
+ type: Boolean,
57
+ },
58
+ // append newly created tags in options
59
+ pushTags: {
60
+ type: Boolean,
61
+ },
62
+ // whether to allow user to create new options
63
+ isTaggable: {
64
+ type: Boolean,
65
+ },
52
66
  limitSelection: {
53
67
  type: Boolean,
54
68
  },
55
69
  getOptions: {
70
+ // function to emit on search{
56
71
  type: Function,
57
72
  },
58
73
  customiseOption: {
59
74
  type: Boolean,
60
75
  },
76
+ // the name of the option to render in the selectpicker
61
77
  optionLabel: {
62
78
  type: String,
63
79
  },
80
+ // action to trigger after selecting option from dropdown
81
+ onSelectOptions: {
82
+ type: Function,
83
+ },
84
+ optionsSelected: {
85
+ type: Array,
86
+ },
64
87
  },
65
88
  computed: {},
66
89
  data() {
67
90
  return {
68
- value: [],
91
+ loaderSearching: true,
92
+ value: this.optionsSelected && this.optionsSelected.length ? this.optionsSelected : [],
69
93
  };
70
94
  },
71
95
  methods: {
72
- fetchOptions(search, loading) {
73
- this.$emit("getOptions", search, loading);
96
+ fetchOptions(search, loaderSearching) {
97
+ this.$emit("getOptions", search, loaderSearching);
98
+ },
99
+ setSelectedOptions(params) {
100
+ this.value = params;
101
+ this.$emit("onSelectOptions", params);
102
+ },
103
+ },
104
+ watch: {
105
+ optionsSelected() {
106
+ this.value = this.optionsSelected;
74
107
  },
75
108
  },
76
109
  };
@@ -11,7 +11,7 @@
11
11
  </div>
12
12
  <span v-if="hint" class="text-sm text-gray-500">{{ hint }}</span>
13
13
  </div>
14
- <div class="mt-1 relative">
14
+ <div class="relative" :class="label ? 'mt-1' : ''">
15
15
  <button
16
16
  type="button"
17
17
  @click="toggleDropdown = !toggleDropdown"
@@ -20,6 +20,7 @@ export { default as CDualSelect } from "./CEditor";
20
20
  export { default as CEditor } from "./CDualSelect";
21
21
  export { default as CFormSectionHeading } from "./CFormSectionHeading";
22
22
  export { default as CIcon } from "./CIcon";
23
+ export { default as CGroupedSelect } from "./CGroupedSelect";
23
24
  export { default as CIconDropdown } from "./CIconDropdown";
24
25
  export { default as CInput } from "./CInput";
25
26
  export { default as CInputAddon } from "./CInputAddon";
@@ -0,0 +1,69 @@
1
+ import CGroupedSelect from "../components/CGroupedSelect/CGroupedSelect.vue";
2
+ import "./utils.css";
3
+
4
+ export default {
5
+ title: "CGroupedSelect",
6
+ component: CGroupedSelect,
7
+ argTypes: {
8
+ options: Array,
9
+ label: String,
10
+ },
11
+ };
12
+
13
+ const Template = (args, { argTypes }) => ({
14
+ props: Object.keys(argTypes),
15
+ components: { CGroupedSelect },
16
+ template: '<c-grouped-select v-bind="$props" />',
17
+ });
18
+
19
+ export const Default = Template.bind({});
20
+
21
+ Default.args = {
22
+ options: [
23
+ {
24
+ id: 0,
25
+ label: "fees",
26
+ options: [
27
+ {
28
+ id: 11751,
29
+ label: "Activity - Cricket - Flat Rate",
30
+ },
31
+ {
32
+ id: 13344,
33
+ label: "Cricket Kit",
34
+ },
35
+ {
36
+ id: 13407,
37
+ label: "Sports - Cricket - 60 mins",
38
+ },
39
+ {
40
+ id: 15370,
41
+ label: "Sports - Cricket - 60 mins",
42
+ },
43
+ ],
44
+ },
45
+ {
46
+ id: 1,
47
+ label: "packages",
48
+ options: [
49
+ {
50
+ id: 15664,
51
+ label: "Sports Cricket 4 Sessions",
52
+ },
53
+ {
54
+ id: 15663,
55
+ label: "Sports - Cricket 6 Sessions",
56
+ },
57
+ ],
58
+ },
59
+ {
60
+ id: 2,
61
+ label: "others",
62
+ options: [],
63
+ },
64
+ ],
65
+ value: {
66
+ id: 11751,
67
+ label: "Activity - Cricket - Flat Rate",
68
+ },
69
+ };