classcard-ui 0.2.134 → 0.2.135
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/classcard-ui.common.js +17601 -162
- package/dist/classcard-ui.common.js.map +1 -1
- package/dist/classcard-ui.umd.js +17601 -162
- package/dist/classcard-ui.umd.js.map +1 -1
- package/dist/classcard-ui.umd.min.js +13 -5
- package/dist/classcard-ui.umd.min.js.map +1 -1
- package/package.json +2 -1
- package/src/components/CGroupedSelect/CGroupedSelect.vue +164 -0
- package/src/components/CGroupedSelect/index.js +3 -0
- package/src/components/index.js +1 -0
- package/src/stories/CGroupedSelect.stories.js +69 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "classcard-ui",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.135",
|
|
4
4
|
"main": "dist/classcard-ui.common.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"serve": "vue-cli-service serve",
|
|
@@ -21,6 +21,7 @@
|
|
|
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",
|
|
@@ -0,0 +1,164 @@
|
|
|
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
|
+
@focus="showDropDown = true"
|
|
16
|
+
@blur="closeDropDown()"
|
|
17
|
+
/>
|
|
18
|
+
<span
|
|
19
|
+
class="absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"
|
|
20
|
+
>
|
|
21
|
+
<!-- Heroicon name: solid/selector -->
|
|
22
|
+
<svg
|
|
23
|
+
class="h-5 w-5 text-gray-400"
|
|
24
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
25
|
+
viewBox="0 0 20 20"
|
|
26
|
+
fill="currentColor"
|
|
27
|
+
aria-hidden="true"
|
|
28
|
+
>
|
|
29
|
+
<path
|
|
30
|
+
fill-rule="evenodd"
|
|
31
|
+
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"
|
|
32
|
+
clip-rule="evenodd"
|
|
33
|
+
/>
|
|
34
|
+
</svg>
|
|
35
|
+
</span>
|
|
36
|
+
</div>
|
|
37
|
+
<!--
|
|
38
|
+
Select popover, show/hide based on select state.
|
|
39
|
+
|
|
40
|
+
Entering: ""
|
|
41
|
+
From: ""
|
|
42
|
+
To: ""
|
|
43
|
+
Leaving: "transition ease-in duration-100"
|
|
44
|
+
From: "opacity-100"
|
|
45
|
+
To: "opacity-0"
|
|
46
|
+
-->
|
|
47
|
+
<ul
|
|
48
|
+
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"
|
|
49
|
+
tabindex="-1"
|
|
50
|
+
role="listbox"
|
|
51
|
+
aria-labelledby="listbox-label"
|
|
52
|
+
aria-activedescendant="listbox-option-3"
|
|
53
|
+
v-if="showDropDown"
|
|
54
|
+
>
|
|
55
|
+
<!--
|
|
56
|
+
Select option, manage highlight styles based on mouseenter/mouseleave and keyboard navigation.
|
|
57
|
+
|
|
58
|
+
Highlighted: "text-white bg-indigo-600", Not Highlighted: "text-gray-900"
|
|
59
|
+
-->
|
|
60
|
+
<span v-for="option in options" :key="option.id">
|
|
61
|
+
<li
|
|
62
|
+
class="text-gray-900 cursor-default select-none relative py-2 pl-3 pr-9"
|
|
63
|
+
role="option"
|
|
64
|
+
>
|
|
65
|
+
<span class="font-bold italic block truncate">
|
|
66
|
+
{{ option.label }}
|
|
67
|
+
</span>
|
|
68
|
+
</li>
|
|
69
|
+
<li
|
|
70
|
+
class="text-gray-900 cursor-default select-none relative py-2 pl-3 pr-9 group hover:text-white hover:bg-indigo-600"
|
|
71
|
+
v-for="subOption in option.options"
|
|
72
|
+
:key="subOption.id"
|
|
73
|
+
role="option"
|
|
74
|
+
@click="handleOptionClick(subOption)"
|
|
75
|
+
>
|
|
76
|
+
<!-- Selected: "font-semibold", Not Selected: "font-normal" -->
|
|
77
|
+
<span
|
|
78
|
+
:class="[
|
|
79
|
+
subOption.label === value.label
|
|
80
|
+
? 'font-semibold'
|
|
81
|
+
: 'font-normal',
|
|
82
|
+
' block truncate',
|
|
83
|
+
]"
|
|
84
|
+
>
|
|
85
|
+
{{ subOption.label }}
|
|
86
|
+
</span>
|
|
87
|
+
|
|
88
|
+
<!--
|
|
89
|
+
Checkmark, only display for selected option.
|
|
90
|
+
|
|
91
|
+
Highlighted: "text-white", Not Highlighted: "text-indigo-600"
|
|
92
|
+
-->
|
|
93
|
+
<span
|
|
94
|
+
class="text-indigo-600 absolute inset-y-0 right-0 flex items-center pr-4 group-hover:text-white"
|
|
95
|
+
v-if="subOption.label === value.label"
|
|
96
|
+
>
|
|
97
|
+
<!-- Heroicon name: solid/check -->
|
|
98
|
+
<svg
|
|
99
|
+
class="h-5 w-5"
|
|
100
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
101
|
+
viewBox="0 0 20 20"
|
|
102
|
+
fill="currentColor"
|
|
103
|
+
aria-hidden="true"
|
|
104
|
+
>
|
|
105
|
+
<path
|
|
106
|
+
fill-rule="evenodd"
|
|
107
|
+
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"
|
|
108
|
+
clip-rule="evenodd"
|
|
109
|
+
/>
|
|
110
|
+
</svg>
|
|
111
|
+
</span>
|
|
112
|
+
</li>
|
|
113
|
+
</span>
|
|
114
|
+
|
|
115
|
+
<!-- More items... -->
|
|
116
|
+
</ul>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
</template>
|
|
120
|
+
|
|
121
|
+
<script>
|
|
122
|
+
import { debounce } from "lodash";
|
|
123
|
+
|
|
124
|
+
export default {
|
|
125
|
+
name: "CGroupedSelect",
|
|
126
|
+
props: {
|
|
127
|
+
label: String,
|
|
128
|
+
options: Object,
|
|
129
|
+
value: Object,
|
|
130
|
+
},
|
|
131
|
+
data() {
|
|
132
|
+
return {
|
|
133
|
+
showDropDown: false,
|
|
134
|
+
inputValue: "",
|
|
135
|
+
};
|
|
136
|
+
},
|
|
137
|
+
methods: {
|
|
138
|
+
onInput(e) {
|
|
139
|
+
this.inputValue = e.target.value;
|
|
140
|
+
debounce(function () {
|
|
141
|
+
this.$emit("search", e.target.value);
|
|
142
|
+
}, 500);
|
|
143
|
+
},
|
|
144
|
+
handleOptionClick(option) {
|
|
145
|
+
this.$emit("input", option);
|
|
146
|
+
this.inputValue = option.label;
|
|
147
|
+
},
|
|
148
|
+
closeDropDown() {
|
|
149
|
+
this.inputValue = this.value.label;
|
|
150
|
+
this.showDropDown = false;
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
watch: {
|
|
154
|
+
value(newValue) {
|
|
155
|
+
this.inputValue = newValue.label;
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
mounted() {
|
|
159
|
+
this.inputValue = this.value.label;
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
</script>
|
|
163
|
+
|
|
164
|
+
<style></style>
|
package/src/components/index.js
CHANGED
|
@@ -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
|
+
};
|