@bagelink/vue 0.0.276 → 0.0.280
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/components/ComboBox.vue.d.ts +2 -0
- package/dist/components/ComboBox.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/CheckInput.vue.d.ts +9 -4
- package/dist/components/form/inputs/CheckInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
- package/dist/index.cjs +44 -40
- package/dist/index.mjs +44 -40
- package/dist/plugins/modal.d.ts +1 -1
- package/dist/plugins/modal.d.ts.map +1 -1
- package/dist/style.css +444 -469
- package/package.json +1 -1
- package/src/components/ComboBox.vue +75 -69
- package/src/components/form/inputs/CheckInput.vue +55 -53
- package/src/components/form/inputs/SelectInput.vue +272 -284
- package/src/components/formkit/Toggle.vue +85 -100
- package/src/plugins/modal.ts +23 -23
- package/src/styles/buttons.css +38 -40
- package/src/styles/inputs.css +100 -109
- package/src/styles/layout.css +0 -1
- package/src/styles/text.css +0 -21
package/package.json
CHANGED
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
2
|
+
<Dropdown placement="auto-start" class="bagel-input combobox">
|
|
3
|
+
<button class="combobox-btn" @click="toggle">
|
|
4
|
+
{{
|
|
5
|
+
valueToLabel(selectedItem) ||
|
|
6
|
+
placeholder || 'Select' }}
|
|
7
|
+
<MaterialIcon v-bind="{ 'icon': open ? 'unfold_less' : 'unfold_more' }" />
|
|
8
|
+
</button>
|
|
9
|
+
<input type="hidden" v-if="required">
|
|
10
|
+
<template #popper="{ hide }">
|
|
11
|
+
<Card thin class="combobox-options">
|
|
12
|
+
<TextInput v-if="searchable" ref="searchInput" dense :placeholder="'Search'" icon="search" v-model="search" />
|
|
13
|
+
<div class="combobox-option" v-for="(option, i) in filteredOptions" :key="`${option}${i}`" @click="() => {
|
|
14
|
+
select(option)
|
|
15
|
+
hide();
|
|
16
|
+
}" :class="{ selected: option === selectedItem }">
|
|
17
|
+
<span>
|
|
18
|
+
{{ label(option) }}
|
|
19
|
+
</span>
|
|
20
|
+
<Icon v-if="isSelected(option)" icon="check" />
|
|
21
|
+
</div>
|
|
22
|
+
</Card>
|
|
23
|
+
</template>
|
|
24
|
+
</Dropdown>
|
|
24
25
|
</template>
|
|
25
26
|
|
|
26
27
|
<script lang="ts" setup>
|
|
27
28
|
import { Dropdown } from 'floating-vue';
|
|
28
29
|
import 'floating-vue/style.css';
|
|
29
30
|
import {
|
|
30
|
-
|
|
31
|
+
TextInput, Card, Icon, MaterialIcon,
|
|
31
32
|
} from '@bagelink/vue';
|
|
32
33
|
|
|
33
34
|
type Option = string | number | Record<string, any> | { label: string, value: string | number };
|
|
@@ -37,96 +38,101 @@ let selectedItem = $ref<Option>();
|
|
|
37
38
|
const searchInput = $ref<HTMLInputElement | null>(null);
|
|
38
39
|
|
|
39
40
|
const props = defineProps<{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
options: Option[];
|
|
42
|
+
placeholder?: string;
|
|
43
|
+
disabled?: boolean;
|
|
44
|
+
modelValue?: Option;
|
|
45
|
+
searchable?: boolean;
|
|
46
|
+
required?: boolean;
|
|
45
47
|
}>();
|
|
46
48
|
let search = $ref('');
|
|
47
49
|
|
|
48
50
|
const toggle = () => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
open = !open;
|
|
52
|
+
if (!open) search = '';
|
|
53
|
+
if (open) setTimeout(() => (searchInput as any)?.$el?.querySelector('input')?.focus(), 100);
|
|
52
54
|
};
|
|
53
55
|
|
|
54
56
|
const valueToLabel = (value?: Option) => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
if (!value) return '';
|
|
58
|
+
const option = props.options.find((option) => {
|
|
59
|
+
if (typeof option === 'string' || typeof option === 'number') return option === value;
|
|
60
|
+
return option.value === value;
|
|
61
|
+
});
|
|
62
|
+
if (!option) return value;
|
|
63
|
+
return label(option);
|
|
62
64
|
};
|
|
63
65
|
|
|
64
66
|
const emit = defineEmits(['update:modelValue']);
|
|
65
67
|
|
|
66
68
|
const label = (option: Option) => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
if (typeof option === 'string') return option;
|
|
70
|
+
if (typeof option === 'number') return `${option}`;
|
|
71
|
+
return option.label;
|
|
70
72
|
};
|
|
71
73
|
|
|
72
74
|
const isSelected = (option: Option) => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
if (typeof option === 'string' || typeof option === 'number') return option === selectedItem;
|
|
76
|
+
return option.value === selectedItem;
|
|
75
77
|
};
|
|
76
78
|
|
|
77
79
|
const filteredOptions = $computed(() => props.options.filter((option) => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
const searchTerm = new RegExp(search, 'gi');
|
|
81
|
+
if (typeof option === 'string') return option.match(searchTerm);
|
|
82
|
+
if (typeof option === 'number') return `${option}`.match(searchTerm);
|
|
83
|
+
return option.label.match(searchTerm);
|
|
82
84
|
}));
|
|
83
85
|
|
|
84
86
|
const select = (option: Option) => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
if (typeof option === 'string') selectedItem = option;
|
|
88
|
+
else if (typeof option === 'number') selectedItem = option;
|
|
89
|
+
else selectedItem = option.value;
|
|
90
|
+
emit('update:modelValue', selectedItem);
|
|
91
|
+
open = false;
|
|
90
92
|
};
|
|
91
93
|
</script>
|
|
92
94
|
|
|
93
95
|
<style scoped>
|
|
94
96
|
.combobox {
|
|
95
|
-
|
|
97
|
+
width: 100%;
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
.combobox-option {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
padding: 6px 12px;
|
|
102
|
+
cursor: pointer;
|
|
103
|
+
border-radius: 5px;
|
|
104
|
+
transition: all 0.2s;
|
|
105
|
+
display: flex;
|
|
106
|
+
justify-content: space-between;
|
|
107
|
+
width: 100%;
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
.combobox-options {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
max-height: 300px;
|
|
112
|
+
overflow-y: auto;
|
|
111
113
|
}
|
|
112
114
|
|
|
113
115
|
.combobox-option:hover {
|
|
114
|
-
|
|
116
|
+
background: var(--bgl-gray-20);
|
|
115
117
|
}
|
|
116
118
|
</style>
|
|
117
119
|
|
|
118
120
|
<style>
|
|
119
|
-
.combobox-btn
|
|
120
|
-
|
|
121
|
+
.combobox-btn {
|
|
122
|
+
display: flex;
|
|
123
|
+
justify-content: space-between;
|
|
124
|
+
align-items: center;
|
|
125
|
+
height: var(--input-height);
|
|
126
|
+
border-radius: var(--input-border-radius);
|
|
121
127
|
}
|
|
122
128
|
|
|
123
129
|
.v-popper__arrow-container {
|
|
124
|
-
|
|
130
|
+
display: none;
|
|
125
131
|
}
|
|
126
132
|
|
|
127
133
|
.v-popper--theme-dropdown .v-popper__inner {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
134
|
+
border: none;
|
|
135
|
+
background: transparent;
|
|
136
|
+
border-radius: var(--card-border-radius);
|
|
131
137
|
}
|
|
132
138
|
</style>
|
|
@@ -1,95 +1,97 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
<div class="bagel-input bgl-checkbox" :title="title" :class="{ small: small }">
|
|
3
|
+
<div class="check-square" :class="{ checked: checked }" @click="checked = !checked">
|
|
4
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24">
|
|
5
|
+
<path d="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z" />
|
|
6
|
+
</svg>
|
|
7
|
+
</div>
|
|
8
|
+
<label>
|
|
9
|
+
<input :required="required" :id="id" type="checkbox" v-model="checked">
|
|
10
|
+
<slot name="label">
|
|
11
|
+
{{ label }}
|
|
12
|
+
</slot>
|
|
13
|
+
</label>
|
|
14
|
+
</div>
|
|
13
15
|
</template>
|
|
14
16
|
|
|
15
17
|
<script setup lang="ts">
|
|
16
18
|
defineProps<{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
label?: string;
|
|
20
|
+
id?: string;
|
|
21
|
+
title?: string;
|
|
22
|
+
small?: boolean;
|
|
23
|
+
required?: boolean
|
|
22
24
|
}>();
|
|
23
25
|
|
|
24
26
|
const checked = defineModel<boolean>('modelValue', { default: false });
|
|
25
27
|
</script>
|
|
26
28
|
<style>
|
|
27
29
|
:root {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
--bgl-white: #fff;
|
|
31
|
+
--input-height: 40px;
|
|
32
|
+
--input-border-radius: 7px;
|
|
33
|
+
--bgl-transition: all 200ms ease;
|
|
34
|
+
--bgl-primary: #19b8ea;
|
|
33
35
|
|
|
34
36
|
}
|
|
35
37
|
</style>
|
|
36
38
|
<style scoped>
|
|
37
39
|
.bgl-checkbox {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
position: relative;
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-direction: row;
|
|
43
|
+
align-items: center;
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
.bgl-checkbox input[type=checkbox] {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
position: absolute;
|
|
48
|
+
opacity: 0;
|
|
49
|
+
z-index: -1;
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
.bgl-checkbox label {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
padding-inline-start: 0.5rem;
|
|
54
|
+
transition: var(--bgl-transition);
|
|
55
|
+
cursor: pointer;
|
|
56
|
+
user-select: none;
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
.bgl-checkbox:hover {
|
|
58
|
-
|
|
60
|
+
filter: brightness(95%);
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
.bgl-checkbox:active {
|
|
62
|
-
|
|
64
|
+
filter: var(--bgl-active-filter);
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
.bgl-checkbox .check-square {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
width: calc(var(--input-height) / 2.5);
|
|
69
|
+
height: calc(var(--input-height) / 2.5);
|
|
70
|
+
background: var(--bgl-white);
|
|
71
|
+
border-radius: calc(var(--input-border-radius) / 2);
|
|
72
|
+
border: var(--bgl-primary) 1px solid;
|
|
73
|
+
position: relative;
|
|
74
|
+
display: flex;
|
|
75
|
+
align-items: center;
|
|
76
|
+
justify-content: center;
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
.check-square.checked {
|
|
78
|
-
|
|
80
|
+
background: var(--bgl-primary);
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
.bgl-checkbox svg {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
width: calc(var(--input-height) / 2.5);
|
|
85
|
+
height: calc(var(--input-height) / 2.5);
|
|
86
|
+
position: absolute;
|
|
87
|
+
z-index: 2;
|
|
88
|
+
fill: var(--bgl-white);
|
|
89
|
+
pointer-events: none;
|
|
90
|
+
transform: scale(0);
|
|
91
|
+
transition: var(--bgl-transition);
|
|
90
92
|
}
|
|
91
93
|
|
|
92
94
|
.check-square.checked svg {
|
|
93
|
-
|
|
95
|
+
transform: scale(1);
|
|
94
96
|
}
|
|
95
97
|
</style>
|