classcard-ui 0.2.242 → 0.2.251

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.242",
3
+ "version": "0.2.251",
4
4
  "main": "dist/classcard-ui.common.js",
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -25,6 +25,7 @@
25
25
  "gridjs-selection": "^3.4.0",
26
26
  "gridjs-vue": "^3.4.0",
27
27
  "lodash-es": "^4.17.21",
28
+ "uppload": "^3.2.1",
28
29
  "v-calendar": "^2.3.2",
29
30
  "vue": "^2.6.14",
30
31
  "vue-good-table": "^2.21.8",
@@ -3,10 +3,13 @@
3
3
  <div
4
4
  :class="divider || showSection ? 'border-b border-gray-200 pb-2' : ''"
5
5
  class="flex flex-row items-center justify-between cursor-pointer"
6
- @click="collapse"
6
+ @click.self="collapse"
7
7
  >
8
8
  <!-- left and right arrow icon as per opening and closing of collapsible -->
9
- <div class="flex flex-row items-center">
9
+ <div
10
+ class="flex flex-row items-center"
11
+ @click="collapse"
12
+ >
10
13
  <c-icon
11
14
  :name="showSection ? 'chevron-down' : 'chevron-right'"
12
15
  class="text-gray-900 h-5 w-5"
@@ -81,6 +84,7 @@ export default {
81
84
  },
82
85
  methods: {
83
86
  collapse() {
87
+ console.log("collapsing")
84
88
  this.showSection = !this.showSection;
85
89
  },
86
90
  },
@@ -11,39 +11,53 @@
11
11
  </div>
12
12
  <span v-if="hint" class="text-sm text-gray-500">{{ hint }}</span>
13
13
  </div>
14
+
14
15
  <div class="relative" :class="label ? 'mt-1' : ''">
15
- <button
16
- type="button"
16
+ <input
17
+ type="text"
18
+ v-model="selectSearch"
17
19
  @click="toggleDropdown = !toggleDropdown"
18
20
  @focus="type == 'tertiary' ? (showFocus = true) : ''"
19
21
  @blur="close()"
22
+ @keyup="search()"
20
23
  aria-haspopup="listbox"
21
24
  aria-expanded="true"
22
25
  aria-labelledby="listbox-label"
23
26
  :class="classes"
24
- class="relative w-full rounded-md pl-2 pr-10 py-2 text-left cursor-pointer focus:outline-none sm:text-sm disabled:opacity-50"
27
+ class="relative w-full rounded-md pl-3 pr-10 py-2 text-left cursor-pointer focus:outline-none sm:text-sm disabled:opacity-50"
25
28
  :disabled="isDisabled"
26
- >
29
+ />
30
+
31
+ <div class="absolute top-2 left-3 flex pointer-events-none">
27
32
  <span class="flex items-center">
28
33
  <c-avatar
29
- v-if="showImage"
34
+ v-if="showImage && !selectSearch"
30
35
  size="extraextrasmall"
31
36
  image="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80"
32
37
  :rounded="true"
33
38
  ></c-avatar>
34
- <c-icon v-if="icon" :class="icon.class" :name="icon.name" :type="icon.type"></c-icon>
39
+ <c-icon
40
+ v-if="icon && !selectSearch"
41
+ :class="icon.class"
42
+ :name="icon.name"
43
+ :type="icon.type"
44
+ >
45
+ </c-icon>
35
46
  <span :class="showImage ? 'ml-3' : ''" class="block truncate">
36
- {{ selectedValue ? selectedValue : placeholder }}
47
+ {{ selectedValue ? selectedValue :
48
+ selectSearch && selectSearch.length > 0 ? null : placeholder
49
+ }}
37
50
  </span>
38
51
  </span>
39
-
40
- <span
52
+ </div>
53
+ <div class="absolute top-2.5 right-3 flex pointer-events-none">
54
+ <div
41
55
  v-if="type == 'tertiary' ? showFocus : true"
42
- class="absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"
43
- >
56
+ class="right-0 flex items-center pointer-events-none"
57
+ >
44
58
  <c-icon name="selector" type="solid" class="h-5 w-5"></c-icon>
45
- </span>
46
- </button>
59
+ </div>
60
+ </div>
47
61
  <transition
48
62
  enter-active-class="transition ease-out duration-100"
49
63
  enter-class="transform opacity-0 scale-95"
@@ -75,7 +89,7 @@
75
89
  {{ addAction.label }}
76
90
  </li>
77
91
  <li
78
- v-for="(option, index) in options"
92
+ v-for="(option, index) in renderOptions"
79
93
  :key="index"
80
94
  id="listbox-option-0"
81
95
  role="option"
@@ -184,6 +198,8 @@ export default {
184
198
  selectedValue: this.value !== null && this.value.option ? this.value.option : this.value,
185
199
  showSelectedValue: false,
186
200
  showFocus: false,
201
+ selectSearch: null,
202
+ renderOptions: this.options
187
203
  };
188
204
  },
189
205
  computed: {
@@ -200,7 +216,7 @@ export default {
200
216
  },
201
217
  methods: {
202
218
  handleSelect(event, option) {
203
- this.selectedValue = option.option;
219
+ this.selectedValue = option[this.renderOptionName];
204
220
  this.$emit("onChangeValue", option);
205
221
  this.toggleDropdown = false;
206
222
  },
@@ -211,6 +227,16 @@ export default {
211
227
  this.toggleDropdown = false;
212
228
  this.type === "tertiary" ? (this.showFocus = false) : "";
213
229
  },
230
+ search() {
231
+ if(!this.selectSearch && this.selectSearch == '') {
232
+ this.renderOptions = this.options;
233
+ }
234
+ let options = [...this.options];
235
+ this.renderOptions = options.filter((option) => {
236
+ return option[this.renderOptionName].toLowerCase().includes(this.selectSearch.toLowerCase());
237
+ });
238
+ console.log(this.renderOptions);
239
+ }
214
240
  },
215
241
  watch: {
216
242
  value() {
@@ -2,31 +2,15 @@
2
2
  <div>
3
3
  <div v-if="type === 'default'">
4
4
  <slot></slot>
5
- <div class="flex justify-between">
6
- <label class="block text-sm font-medium text-gray-900">
7
- {{ label }}
8
- </label>
9
- <span v-if="hint" class="text-sm text-gray-500">{{ hint }}</span>
10
- </div>
11
5
  <div
12
6
  :class="errorClasses"
13
- class="w-full mt-2 flex justify-center px-6 py-14 border-2 rounded-md"
7
+ class=""
8
+ id="c-file-area"
9
+ @click="uploader.open()"
14
10
  >
15
- <div class="space-y-1 text-center">
16
- <div class="flex text-sm text-gray-600">
17
- <c-icon
18
- type="solid"
19
- class="h-5 w-5 text-indigo-600"
20
- name="arrow-up"
21
- ></c-icon>
22
- <label
23
- class="relative cursor-pointer bg-white rounded-md font-medium text-indigo-600 hover:text-indigo-500 focus-within:outline-none focus-within:ring-2 focus-within:ring-offset-2 focus-within:ring-indigo-500 ml-1"
24
- >
25
- <span>Upload</span>
26
- <input type="file" class="sr-only" />
27
- </label>
28
- </div>
29
- </div>
11
+ <button type="white" class="inline-flex items-center px-4 py-2 shadow-sm text-sm font-medium rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 text-gray-700 border bg-white border-gray-300 hover:bg-gray-50 focus:ring-indigo-600 ">
12
+ {{buttonText}}
13
+ </button>
30
14
  </div>
31
15
  </div>
32
16
  <div
@@ -41,14 +25,14 @@
41
25
  </template>
42
26
 
43
27
  <script>
44
- import CIcon from "../CIcon/CIcon.vue";
45
28
  import * as filestack from "filestack-js";
29
+ import { Uppload, Local, xhrUploader, en, Crop, Unsplash } from "uppload";
46
30
 
47
31
  export default {
48
32
  name: "CUpload",
49
- components: { CIcon },
33
+ components: { },
50
34
  props: {
51
- label: {
35
+ buttonText: {
52
36
  type: String,
53
37
  },
54
38
  fileSize: {
@@ -78,6 +62,11 @@ export default {
78
62
  default: 1,
79
63
  },
80
64
  },
65
+ data() {
66
+ return {
67
+ uploader: null
68
+ }
69
+ },
81
70
  methods: {
82
71
  initFilestack() {
83
72
  const client = filestack.init(this.filestackApiKey);
@@ -91,6 +80,36 @@ export default {
91
80
  const picker = client.picker(options);
92
81
  picker.open();
93
82
  },
83
+ initUppload() {
84
+ // Uppload library
85
+ this.uploader = new Uppload({
86
+ lang: en,
87
+ compression: 0.4,
88
+ compressionToMime: "image/jpeg",
89
+ maxSize: [500, 1000],
90
+ uploader: xhrUploader({
91
+ endpoint: `https://reportcard.tech/api/saveImage/`,
92
+ fileKeyName: "image",
93
+ // settingsFunction: (xmlHttp) => {
94
+ // xmlHttp.setRequestHeader("Authorization", `Bearer ${token}`);
95
+ // },
96
+ responseFunction: (response) => {
97
+ console.log(response);
98
+ },
99
+ }),
100
+ // bind: document.querySelector("#imagePreview"),
101
+ });
102
+ this.uploader.use([
103
+ new Local(),
104
+ new Unsplash("hXfo-C0svXV4IDCncBo7s-ySQpVJVeZrGuWxwwgC7qw"),
105
+ new Crop({ aspectRatio: 23 / 45 }),
106
+ ]);
107
+
108
+ // Uppload Error Handle
109
+ this.uploader.on("error", (error) => {
110
+ console.log("The error message is", error);
111
+ });
112
+ }
94
113
  },
95
114
  computed: {
96
115
  errorClasses() {
@@ -104,6 +123,8 @@ export default {
104
123
  mounted() {
105
124
  if (this.type === "filestack") {
106
125
  this.initFilestack();
126
+ } else if(this.type == "default") {
127
+ this.initUppload();
107
128
  }
108
129
  },
109
130
  };
@@ -32,7 +32,7 @@ Default.args = {
32
32
  helpText: "This information is displayed on booking page",
33
33
  hint: "Optional",
34
34
  showImage: true,
35
- value: {},
35
+ value: null,
36
36
  renderOptionName: "code",
37
37
  options: [
38
38
  { code: "one", value: "onee" },
@@ -26,7 +26,7 @@ const Template = (args, { argTypes }) => ({
26
26
 
27
27
  export const Default = Template.bind({});
28
28
  Default.args = {
29
- label: "Name",
29
+ buttonText: "Select File",
30
30
  hint: "Optional",
31
31
  fileSize: "10",
32
32
  isValidate: true,