Browse code

Add tom select npm package

Benjamin Roth authored on02/02/2023 12:00:30
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,219 @@
1
+/**
2
+ * Tom Select bootstrap 4
3
+ */
4
+
5
+//Import Boostrap 4 functions and variables
6
+
7
+$state-valid: map-get($form-validation-states,'valid') !default;
8
+$state-invalid: map-get($form-validation-states,'invalid') !default;
9
+
10
+$enable-shadows: true !default;
11
+$select-font-family: inherit !default;
12
+$select-font-size: inherit !default;
13
+$select-line-height: $input-btn-line-height !default; //formerly line-height-computed
14
+
15
+$select-color-text: gray("800") !default; //$gray-800
16
+$select-color-highlight: rgba(255,237,40,0.4) !default;
17
+$select-color-input: $input-bg !default;
18
+$select-color-input-full: $input-bg !default;
19
+$select-color-input-error: map-get($state-invalid,'color') !default;
20
+$select-color-input-error-focus: darken($select-color-input-error, 10%) !default;
21
+$select-color-disabled: $input-disabled-bg !default;
22
+$select-color-item: #efefef !default;
23
+$select-color-item-border: $border-color !default;
24
+$select-color-item-active: $component-active-bg !default;
25
+$select-color-item-active-text: #fff !default;
26
+$select-color-item-active-border: rgba(0,0,0,0) !default;
27
+$select-color-optgroup: $dropdown-bg !default;
28
+$select-color-optgroup-text: $dropdown-header-color !default;
29
+$select-color-optgroup-border: $dropdown-divider-bg !default;
30
+$select-color-dropdown: $dropdown-bg !default;
31
+$select-color-dropdown-border-top: mix($input-border-color, $input-bg, 0.8) !default;
32
+$select-color-dropdown-item-active: $dropdown-link-hover-bg !default;
33
+$select-color-dropdown-item-active-text: $dropdown-link-hover-color !default;
34
+$select-color-dropdown-item-create-active-text: $dropdown-link-hover-color !default;
35
+$select-opacity-disabled: 0.5 !default;
36
+
37
+$select-border: 1px solid $input-border-color !default;
38
+$select-border-radius: $input-border-radius !default;
39
+
40
+$select-width-item-border: 0px !default;
41
+$select-padding-x: $input-btn-padding-x !default;
42
+$select-padding-y: $input-btn-padding-y !default;
43
+$select-padding-dropdown-item-x: $input-btn-padding-x !default;
44
+$select-padding-dropdown-item-y: 3px !default;
45
+$select-padding-item-x: 5px !default;
46
+$select-padding-item-y: 1px !default;
47
+$select-margin-item-x: 3px !default;
48
+$select-margin-item-y: 3px !default;
49
+
50
+$select-arrow-size: 5px !default;
51
+$select-arrow-color: $select-color-text !default;
52
+$select-arrow-offset: calc(#{$select-padding-x} + 5px) !default;
53
+
54
+
55
+@import "tom-select";
56
+@include ts-caret();
57
+
58
+.#{$select-ns}-wrapper.form-control,
59
+.#{$select-ns}-wrapper.form-select{
60
+	padding:0 !important;
61
+}
62
+
63
+.#{$select-ns}-dropdown,
64
+.#{$select-ns}-dropdown.form-control {
65
+	height: auto;
66
+	padding: 0;
67
+	z-index: $zindex-dropdown;
68
+	background: $select-color-dropdown;
69
+	border: 1px solid $dropdown-border-color; //$dropdown-fallback-border
70
+	border-radius: $border-radius;
71
+	box-shadow: 0 6px 12px rgba(0,0,0,.175);
72
+}
73
+
74
+.#{$select-ns}-dropdown {
75
+	.optgroup-header {
76
+		font-size: $font-size-sm;
77
+		line-height: $line-height-base;
78
+	}
79
+	.optgroup:first-child:before {
80
+		display: none;
81
+	}
82
+	.optgroup:before {
83
+		content: ' ';
84
+		display: block;
85
+		height: 0;
86
+		margin: $dropdown-divider-margin-y 0;
87
+		overflow: hidden;
88
+		border-top: 1px solid $dropdown-divider-bg;
89
+		margin-left: $select-padding-dropdown-item-x * -1;
90
+		margin-right: $select-padding-dropdown-item-x * -1;
91
+	}
92
+
93
+	.create {
94
+		padding-left: $select-padding-dropdown-item-x;
95
+	}
96
+}
97
+
98
+.#{$select-ns}-dropdown-content {
99
+	padding: 5px 0;
100
+}
101
+
102
+.#{$select-ns}-control {
103
+	min-height: $input-height;
104
+	@include box-shadow($input-box-shadow);
105
+	@include transition($input-transition);
106
+	display:flex;
107
+	align-items: center;
108
+
109
+	.focus & {
110
+		border-color: $input-focus-border-color;
111
+		outline: 0;
112
+		@if $enable-shadows {
113
+			box-shadow: $input-box-shadow, $input-focus-box-shadow;
114
+		} @else {
115
+			box-shadow: $input-focus-box-shadow;
116
+		}
117
+	}
118
+}
119
+
120
+.is-invalid .#{$select-ns}-control,
121
+.was-validated .invalid .#{$select-ns}-control{
122
+	border-color: $select-color-input-error;
123
+
124
+	.focus & {
125
+		border-color: $select-color-input-error-focus;
126
+		box-shadow: 0 0 0 $input-focus-width rgba($select-color-input-error, .25);
127
+	}
128
+}
129
+
130
+.is-valid .#{$select-ns}-control{
131
+	$_color: map-get($state-valid,'color');
132
+	//$_icon: map-get($state-valid,'icon');
133
+
134
+	border-color: $_color;
135
+
136
+	.focus & {
137
+		border-color: $_color;
138
+		box-shadow: 0 0 0 $input-focus-width rgba($_color, .25);
139
+	}
140
+}
141
+
142
+.#{$select-ns}-wrapper {
143
+
144
+	.input-group-sm > &,
145
+	&.form-control-sm{
146
+
147
+		.#{$select-ns}-control{
148
+			min-height: $input-height-sm;
149
+			padding: 0 .75rem;
150
+			//padding: $input-padding-y-sm $input-padding-x-sm;
151
+			@include border-radius($input-border-radius-sm);
152
+			@include font-size($input-font-size-sm);
153
+		}
154
+
155
+		&.has-items .#{$select-ns}-control{
156
+			min-height: $input-height-sm !important;
157
+			font-size: $input-font-size-sm;
158
+			padding-bottom: 0;
159
+		}
160
+	}
161
+
162
+
163
+	.input-group-sm > &.multi.has-items,
164
+	&.form-control-sm.multi.has-items{
165
+		.#{$select-ns}-control{
166
+			// padding-top = ($input-height-sm - border-width - item-height) / 2;
167
+			// item-height = ($select-line-height * $input-font-size-sm) + ($select-padding-item-y * 2)
168
+			$border-and-padding: add($input-border-width,$select-padding-item-y) * 2;
169
+			$ts-select-padding-sm: calc( (#{$input-height-sm} - (#{$select-line-height} * #{$input-font-size-sm}) - #{$border-and-padding})/2);
170
+			padding-top: $ts-select-padding-sm !important;
171
+		}
172
+	}
173
+
174
+
175
+	&.multi {
176
+		&.has-items .#{$select-ns}-control {
177
+			padding-left: calc(#{$select-padding-x} - #{$select-padding-item-x});
178
+			--ts-pr-min: calc(#{$select-padding-x} - #{$select-padding-item-x});
179
+		}
180
+		.#{$select-ns}-control > div {
181
+			border-radius: calc(#{$select-border-radius} - 1px);
182
+		}
183
+	}
184
+
185
+	.input-group-lg > & >,
186
+	&.form-control-lg{
187
+	.#{$select-ns}-control{
188
+			min-height: $input-height-lg;
189
+			@include border-radius($input-border-radius-lg);
190
+			@include font-size($input-font-size-lg);
191
+		}
192
+	}
193
+}
194
+
195
+.form-control.#{$select-ns}-wrapper {
196
+	padding: 0;
197
+	height: auto;
198
+	border: none;
199
+	background: none;
200
+	//box-shadow: none;
201
+	border-radius: 0;
202
+}
203
+
204
+.input-group{
205
+
206
+	& > .#{$select-ns}-wrapper{
207
+		flex-grow: 1;
208
+	}
209
+
210
+	& > .#{$select-ns}-wrapper:not(:nth-child(2)) > .#{$select-ns}-control{
211
+		border-top-left-radius: 0;
212
+		border-bottom-left-radius: 0;
213
+	}
214
+
215
+	& > .#{$select-ns}-wrapper:not(:last-child) > .#{$select-ns}-control{
216
+		border-top-right-radius: 0;
217
+		border-bottom-right-radius: 0;
218
+	}
219
+}