@bagelink/vue 0.0.384 → 0.0.392

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.
@@ -2,21 +2,44 @@
2
2
  <div class="table-list-wrap h-100">
3
3
  <table class="infinite-wrapper">
4
4
  <thead class="row first-row">
5
- <th class="col" v-for="field in computedSchema" :key="field.id" @click="sort(field?.id || '')">
5
+ <th
6
+ class="col"
7
+ v-for="field in computedSchema"
8
+ :key="field.id"
9
+ @click="sort(field?.id || '')">
6
10
  <div class="flex">
7
11
  {{ field.label || keyToLabel(field.id) }}
8
- <div class="list-arrows" :class="{ sorted: sortField === field.id }">
9
- <MaterialIcon :class="{ desc: sortDirection === 'DESC' }" icon="keyboard_arrow_up" />
12
+ <div
13
+ class="list-arrows"
14
+ :class="{ sorted: sortField === field.id }">
15
+ <MaterialIcon
16
+ :class="{ desc: sortDirection === 'DESC' }"
17
+ icon="keyboard_arrow_up" />
10
18
  </div>
11
19
  </div>
12
20
  </th>
13
21
  </thead>
14
22
  <tbody ref="infinite" class="rows infinite" :class="{ loading }">
15
- <tr v-for="row in data" :key="row.id" @click="selectElement(row)" class="row row-item position-relative">
16
- <td class="col" v-for="field in computedSchema" :key="`${field.id}-${row.id}`">
17
- <slot v-if="field.id && slots[field.id]" :name="field.id" :row="row" :field="field" />
23
+ <tr
24
+ v-for="row in data"
25
+ :key="row.id"
26
+ @click="selectElement(row)"
27
+ class="row row-item position-relative">
28
+ <td
29
+ class="col"
30
+ v-for="field in computedSchema"
31
+ :key="`${field.id}-${row.id}`">
32
+ <slot
33
+ v-if="field.id && slots[field.id]"
34
+ :name="field.id"
35
+ :row="row"
36
+ :field="field" />
18
37
  <div v-else>
19
- <BglField :field="field" :modelValue="row" />
38
+ <BglField
39
+ class="embedded-field"
40
+ :field="field"
41
+ :modelValue="row"
42
+ label="" />
20
43
  </div>
21
44
  </td>
22
45
  </tr>
@@ -38,8 +61,8 @@ const slots = useSlots();
38
61
  const loading = $ref(true);
39
62
 
40
63
  const props = defineProps<{
41
- data: any[];
42
- schema: BglFormSchemaT | (() => BglFormSchemaT);
64
+ data: any[];
65
+ schema: BglFormSchemaT | (() => BglFormSchemaT);
43
66
  }>();
44
67
 
45
68
  const computedSchema = $computed(() => {
@@ -70,126 +93,131 @@ const sort = (fieldname: string) => {
70
93
 
71
94
  <style scoped>
72
95
  .list-arrows {
73
- opacity: 0;
96
+ opacity: 0;
74
97
  }
75
98
 
76
99
  .list-arrows .bgl_icon-font {
77
- transition: all ease-in-out 0.2s;
100
+ transition: all ease-in-out 0.2s;
78
101
  }
79
102
 
80
103
  .list-arrows.sorted {
81
- opacity: 1;
104
+ opacity: 1;
82
105
  }
83
106
 
84
107
  .col img {
85
- height: 35px;
86
- margin-top: -14px;
87
- margin-bottom: -14px;
88
- border-radius: 5px;
108
+ height: 35px;
109
+ margin-top: -14px;
110
+ margin-bottom: -14px;
111
+ border-radius: 5px;
89
112
  }
90
113
 
91
114
  .list-arrows.sorted .desc {
92
- transform: rotate(180deg);
115
+ transform: rotate(180deg);
93
116
  }
94
117
 
95
118
  table {
96
- border-collapse: separate;
97
- border-spacing: 0 15px;
98
- border-collapse: collapse;
119
+ border-collapse: separate;
120
+ border-spacing: 0 15px;
121
+ border-collapse: collapse;
99
122
  }
100
123
 
101
124
  th {
102
- font-weight: 400;
125
+ font-weight: 400;
126
+ }
127
+
128
+ .embedded-field {
129
+ margin-bottom: -0.2rem;
130
+ margin-top: -0.2rem;
103
131
  }
104
132
 
105
133
  .row {
106
- border-bottom: 1px solid var(--border-color);
107
- cursor: pointer;
134
+ border-bottom: 1px solid var(--border-color);
135
+ cursor: pointer;
108
136
  }
109
137
 
110
138
  .row.first-row {
111
- font-size: 0.8rem;
112
- color: var(--bgl-black-tint);
113
- position: sticky;
114
- top: 0;
115
- z-index: 2;
116
- background: var(--bgl-white);
117
- height: 50px;
118
- vertical-align: bottom;
139
+ font-size: 0.8rem;
140
+ color: var(--bgl-black-tint);
141
+ position: sticky;
142
+ top: 0;
143
+ z-index: 2;
144
+ background: var(--bgl-white);
145
+ height: 50px;
146
+ vertical-align: bottom;
119
147
  }
120
148
 
121
149
  .row.first-row::after {
122
- content: "";
123
- border-bottom: 1px solid var(--border-color);
124
- position: absolute;
125
- left: 0;
126
- right: 0;
127
- bottom: -1px;
150
+ content: '';
151
+ border-bottom: 1px solid var(--border-color);
152
+ position: absolute;
153
+ left: 0;
154
+ right: 0;
155
+ bottom: -1px;
128
156
  }
129
157
 
130
158
  .first-row .col {
131
- cursor: pointer;
132
- background: var(--bgl-white);
159
+ cursor: pointer;
160
+ background: var(--bgl-white);
133
161
  }
134
162
 
135
163
  .col {
136
- white-space: nowrap;
137
- padding: 0.75rem 0.5rem;
138
- transition: var(--bgl-transition);
139
- line-height: 1;
140
- align-items: center;
164
+ white-space: nowrap;
165
+ padding: 0.75rem 0.5rem;
166
+ transition: var(--bgl-transition);
167
+ line-height: 1;
168
+ align-items: center;
141
169
  }
142
170
 
143
- .col>div {
144
- display: flex;
145
- gap: 0.5rem;
171
+ .col > div {
172
+ display: flex;
173
+ gap: 0.5rem;
146
174
  }
147
175
 
148
176
  .max-col-width {
149
- max-width: 30vw;
150
- overflow: hidden;
151
- text-overflow: ellipsis;
177
+ max-width: 30vw;
178
+ overflow: hidden;
179
+ text-overflow: ellipsis;
152
180
  }
153
181
 
154
182
  .col.check .bgl_icon-font {
155
- border-radius: 100%;
156
- background: var(--bgl-blue-20);
157
- color: var(--bgl-primary);
158
- width: 20px;
159
- height: 20px;
160
- display: flex;
161
- align-items: center;
162
- justify-content: center;
163
- margin-top: -2px;
183
+ border-radius: 100%;
184
+ background: var(--bgl-blue-20);
185
+ color: var(--bgl-primary);
186
+ width: 20px;
187
+ height: 20px;
188
+ display: flex;
189
+ align-items: center;
190
+ justify-content: center;
191
+ margin-top: -2px;
164
192
  }
165
193
 
166
194
  .rows {
167
- font-size: 0.8125em;
195
+ font-size: 0.8125em;
168
196
  }
169
197
 
170
198
  .table-list {
171
- height: 100%;
172
- position: relative;
173
- padding-left: 0 !important;
174
- padding-right: 0 !important;
175
- overflow: auto;
199
+ height: 100%;
200
+ position: relative;
201
+ padding-left: 0 !important;
202
+ padding-right: 0 !important;
203
+ overflow: auto;
176
204
  }
177
205
 
178
206
  .BagelTable .table-list {
179
- overflow: unset;
207
+ overflow: unset;
180
208
  }
181
209
 
182
210
  .row-item {
183
- height: 50px;
184
- transition: all 200ms ease;
211
+ height: 50px;
212
+ transition: all 200ms ease;
185
213
  }
186
214
 
187
215
  .row-item:hover {
188
- background: var(--bgl-gray-light);
216
+ background: var(--bgl-gray-light);
189
217
  }
190
218
 
191
219
  .infinite-wrapper {
192
- overflow-y: auto;
193
- width: 100%;
220
+ overflow-y: auto;
221
+ width: 100%;
194
222
  }
195
223
  </style>
@@ -1,19 +1,18 @@
1
1
  <template>
2
2
  <div class="bagel-input">
3
- <label class="pb-025" >
4
- {{ label }}
3
+ <label class="pb-025">
4
+ {{ label }}
5
5
  </label>
6
6
  <div class="flex gap-05 flex-wrap">
7
- <div class="radio-pill" v-for="({optioId,label,value}, index) in cumputedOptions" :key="index">
7
+ <div class="radio-pill" v-for="(option, index) in options" :key="index">
8
8
  <input
9
9
  type="radio"
10
- :id="optioId"
10
+ :id="getValue(option)"
11
11
  :name="id"
12
- :value="value"
13
- :checked="selectedValue === value"
14
- @change="handleSelect"
15
- >
16
- <label :for="optioId">{{ label }}</label>
12
+ :value="getValue(option)"
13
+ :checked="selectedValue === getValue(option)"
14
+ @change="handleSelect" />
15
+ <label :for="getValue(option)">{{ getLabel(option) }}</label>
17
16
  </div>
18
17
  </div>
19
18
  </div>
@@ -22,27 +21,33 @@
22
21
  <script setup lang="ts">
23
22
  import { onMounted, watch } from 'vue';
24
23
 
25
- interface RadioOption {
26
- optioId: string;
27
- label: string;
28
- value: any;
29
- }
24
+ type Option =
25
+ | string
26
+ | number
27
+ | Record<string, any>
28
+ | { label: string; value: string | number };
29
+
30
30
  const emits = defineEmits(['update:modelValue']);
31
31
 
32
+ const getLabel = (option: Option) => {
33
+ if (typeof option === 'string') return option;
34
+ if (typeof option === 'number') return `${option}`;
35
+ return option.label;
36
+ };
37
+
38
+ const getValue = (option: Option) => {
39
+ if (typeof option === 'string') return option;
40
+ if (typeof option === 'number') return option;
41
+ return option.value;
42
+ };
43
+
32
44
  const props = defineProps<{
33
- options?: RadioOption[],
34
- stringOptions: string[],
35
- modelValue: any,
36
- id?: string,
37
- label?: string,
45
+ options?: Option[];
46
+ modelValue: any;
47
+ id?: string;
48
+ label?: string;
38
49
  }>();
39
50
 
40
- const cumputedOptions = $computed(() => props.options || props.stringOptions.map((v) => ({
41
- optioId: v,
42
- label: v,
43
- value: v,
44
- })));
45
-
46
51
  let selectedValue = $ref('');
47
52
 
48
53
  function handleSelect(e: Event) {
@@ -56,7 +61,7 @@ watch(
56
61
  if (newVal === oldVal || oldVal === undefined) return;
57
62
  if (selectedValue !== newVal) selectedValue = newVal;
58
63
  },
59
- { immediate: true },
64
+ { immediate: true }
60
65
  );
61
66
 
62
67
  onMounted(() => {
@@ -66,30 +71,30 @@ onMounted(() => {
66
71
 
67
72
  <style scoped>
68
73
  .radio-pill label {
69
- color: var(--bgl-primary);
70
- white-space: nowrap;
71
- border-radius: calc(var(--btn-border-radius) * 2);
72
- outline: 1px solid var(--bgl-primary);
73
- padding-left: calc(var(--btn-padding) / 2);
74
- padding-right: calc(var(--btn-padding) / 2);
75
- padding-top: calc(var(--btn-padding) / 6);
76
- padding-bottom: calc(var(--btn-padding) / 6);
77
- cursor: pointer;
78
- transition: var(--bgl-transition);
79
- background: var(--bgl-white);
80
- user-select: none;
74
+ color: var(--bgl-primary);
75
+ white-space: nowrap;
76
+ border-radius: calc(var(--btn-border-radius) * 2);
77
+ outline: 1px solid var(--bgl-primary);
78
+ padding-left: calc(var(--btn-padding) / 2);
79
+ padding-right: calc(var(--btn-padding) / 2);
80
+ padding-top: calc(var(--btn-padding) / 6);
81
+ padding-bottom: calc(var(--btn-padding) / 6);
82
+ cursor: pointer;
83
+ transition: var(--bgl-transition);
84
+ background: var(--bgl-white);
85
+ user-select: none;
81
86
  }
82
87
 
83
88
  .radio-pill label:hover {
84
- filter: var(--bgl-hover-filter);
89
+ filter: var(--bgl-hover-filter);
85
90
  }
86
91
 
87
92
  .radio-pill input {
88
- display: none;
93
+ display: none;
89
94
  }
90
95
 
91
- .radio-pill input:checked~label {
92
- background: var(--bgl-primary);
93
- color: var(--bgl-white);
96
+ .radio-pill input:checked ~ label {
97
+ background: var(--bgl-primary);
98
+ color: var(--bgl-white);
94
99
  }
95
100
  </style>
@@ -173,12 +173,16 @@ watch(
173
173
  (newVal: Option | Option[]) => {
174
174
  if (!newVal) return;
175
175
  if (!props.multiselect) {
176
- if (!isSelected(newVal))
177
- selectedItems.splice(0, selectedItems.length, newVal);
176
+ const newOption =
177
+ props.options.find((o) => getValue(o) === newVal) || newVal;
178
+ if (!isSelected(newOption)) {
179
+ selectedItems.splice(0, selectedItems.length, newOption);
180
+ }
178
181
  } else {
179
182
  const isSame = compareArrays([newVal].flat(), selectedItems);
180
- if (!isSame)
183
+ if (!isSame) {
181
184
  selectedItems.splice(0, selectedItems.length, [newVal].flat());
185
+ }
182
186
  }
183
187
  },
184
188
  { immediate: true }
@@ -187,15 +191,14 @@ watch(
187
191
  watch(
188
192
  () => props.options,
189
193
  () => {
190
- const original = JSON.stringify(selectedItems);
194
+ const original = JSON.stringify(props.options.map(getValue));
191
195
  [...selectedItems].forEach((option, i) => {
192
196
  const exists = props.options.find(
193
197
  (o) => getValue(o) === getValue(option)
194
198
  );
195
- if (!exists) selectedItems.splice(i, 1);
196
- else selectedItems.splice(i, 1, exists);
199
+ selectedItems.splice(i, 1, exists);
197
200
  });
198
- const newSelection = JSON.stringify(selectedItems);
201
+ const newSelection = JSON.stringify(selectedItems.map(getValue));
199
202
  if (original !== newSelection) emitUpdate();
200
203
  }
201
204
  );
@@ -13,7 +13,6 @@
13
13
  overflow: auto;
14
14
  margin: 0 auto;
15
15
  width: 100%;
16
- text-align: center;
17
16
  display: grid;
18
17
  align-items: center;
19
18
  }
@@ -25,9 +24,9 @@
25
24
  .modal {
26
25
  width: 96%;
27
26
  max-width: 720px;
28
- transform: scale(0.5);
29
- opacity: 0;
30
- transition: all ease-in-out 0.15s;
27
+ /* transform: scale(0.5); */
28
+ /* opacity: 0; */
29
+ transition: all ease-in-out 0.18s;
31
30
  margin-left: auto;
32
31
  margin-right: auto;
33
32
  height: fit-content;
@@ -55,7 +54,7 @@
55
54
  }
56
55
 
57
56
  .is-side .modal {
58
- inset-inline-end: -600px;
57
+ inset-inline-end: -1720px;
59
58
  transform: scale(1);
60
59
  opacity: 1;
61
60
  /* position: fixed; */
@@ -87,7 +86,7 @@
87
86
  }
88
87
 
89
88
  .is-active.is-side .modal {
90
- inset-inline-end: 20px;
89
+ inset-inline-end: 0px;
91
90
  transform: translateX(0%);
92
91
  }
93
92