@bagelink/vue 0.0.260 → 0.0.262

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.
@@ -1,24 +1,52 @@
1
1
  <template>
2
- <Modal @onUpdate:isModalVisible="props['onUpdate:isModalVisible']" :side="side" ref="modal" :dismissable="dismissable"
3
- :title="title">
4
- <BagelForm ref="form" v-model="formData" :schema="computedFormSchema" />
5
- <template #footer v-if="onDelete || onSubmit">
2
+ <Modal
3
+ @onUpdate:isModalVisible="props['onUpdate:isModalVisible']"
4
+ :side="side"
5
+ ref="modal"
6
+ :dismissable="dismissable"
7
+ :title="title"
8
+ >
9
+ <BagelForm
10
+ ref="form"
11
+ v-model="formData"
12
+ :schema="computedFormSchema"
13
+ />
14
+ <template
15
+ #footer
16
+ v-if="onDelete || onSubmit"
17
+ >
6
18
  <div>
7
- <Btn thin flat value="Cancel" @click="closeModal()" />
8
- <Btn thin icon="delete" v-if="onDelete" flat value="Delete" @click="runDelete()" color="red" />
19
+ <Btn
20
+ thin
21
+ flat
22
+ value="Cancel"
23
+ @click="closeModal()"
24
+ />
25
+ <Btn
26
+ thin
27
+ icon="delete"
28
+ v-if="onDelete"
29
+ flat
30
+ value="Delete"
31
+ @click="runDelete()"
32
+ color="red"
33
+ />
9
34
  </div>
10
- <Btn value="Submit" @click="runSubmit()" />
35
+ <Btn
36
+ value="Submit"
37
+ @click="runSubmit()"
38
+ />
11
39
  </template>
12
40
  </Modal>
13
41
  </template>
14
42
 
15
43
  <script lang="ts" setup>
16
44
  import {
17
- Modal,
18
- Btn,
19
- BagelForm, type BglFormSchemaT, type BtnOptions,
45
+ Modal, Btn, BagelForm, type BglFormSchemaT, type BtnOptions, useBagel,
20
46
  } from '@bagelink/vue';
21
47
 
48
+ const bagel = useBagel();
49
+
22
50
  const props = defineProps<{
23
51
  side?: boolean;
24
52
  title?: string;
@@ -31,6 +59,8 @@ const props = defineProps<{
31
59
  onDelete?: ((id: string) => void);
32
60
  // eslint-disable-next-line no-unused-vars
33
61
  'onUpdate:isModalVisible'?: ((visible: boolean) => void);
62
+ // eslint-disable-next-line no-unused-vars
63
+ onError?: ((err: any) => void);
34
64
  }>();
35
65
 
36
66
  const modal = $ref<InstanceType<typeof Modal>>();
@@ -49,8 +79,9 @@ const runSubmit = async () => {
49
79
  try {
50
80
  await props.onSubmit?.(formData.value);
51
81
  closeModal();
52
- } catch (err) {
53
- console.error(err);
82
+ } catch (err: any) {
83
+ if (props.onError) props.onError(err);
84
+ else bagel?.onError?.(err);
54
85
  }
55
86
  };
56
87
 
@@ -2,7 +2,11 @@
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" @click="sort(field?.id || '')"
9
+ >
6
10
  <div class="flex">
7
11
  {{ field.id }}
8
12
  <div class="list-arrows" :class="{ sorted: sortField === field.id }">
@@ -12,7 +16,12 @@
12
16
  </th>
13
17
  </thead>
14
18
  <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">
19
+ <tr
20
+ v-for="row in data"
21
+ :key="row.id"
22
+ @click="selectElement(row)"
23
+ class="row row-item position-relative"
24
+ >
16
25
  <td class="col" v-for="field in computedSchema" :key="`${field.id}-${row.id}`">
17
26
  <slot v-if="field.id && slots[field.id]" :name="field.id" :row="row" :field="field" />
18
27
  <div v-else>
@@ -22,7 +31,6 @@
22
31
  </tr>
23
32
  </tbody>
24
33
  </table>
25
- <!-- </Transition> -->
26
34
  </div>
27
35
  </template>
28
36
 
@@ -11,10 +11,18 @@
11
11
  label="label"
12
12
  trackBy="value"
13
13
  :options="optionList"
14
- :required="required"
15
- :placeholder="placeholder"
14
+ :required
15
+ :placeholder
16
16
  v-model="seletValue"
17
+ v-bind="extraProps"
17
18
  />
19
+ <input
20
+ v-model="seletValue"
21
+ type="hidden"
22
+ :name="id"
23
+ :required
24
+ v-bind="extraProps"
25
+ >
18
26
  </label>
19
27
  </div>
20
28
  </template>
@@ -37,6 +45,7 @@ const props = defineProps<{
37
45
  placeholder?: string,
38
46
  defaultValue?: string | number,
39
47
  options: RawOption[] | string
48
+ extraProps?: Record<string, any>
40
49
  }>();
41
50
 
42
51
  let dataValue = $ref<string | number | undefined>(props.modelValue || props.defaultValue);
@@ -194,7 +203,7 @@ fieldset[disabled] .multiselect {
194
203
  }
195
204
 
196
205
  .multiselect--active .multiselect__input {
197
- margin-top: -0.5rem;
206
+ margin-top: -0.6rem;
198
207
  }
199
208
 
200
209
  .multiselect__input::placeholder {
@@ -19,6 +19,7 @@
19
19
  @input="handleInput"
20
20
  :class="{ 'no-edit': !editMode }"
21
21
  v-bind="nativeInputAttrs"
22
+ :required
22
23
  />
23
24
  </div>
24
25
  </template>
@@ -38,6 +39,7 @@ withDefaults(
38
39
  small?: boolean;
39
40
  nativeInputAttrs?: Record<string, any>;
40
41
  showCharacterLimit?: boolean;
42
+ required?: boolean;
41
43
  }>(),
42
44
  {
43
45
  description: '',
@@ -1,23 +1,63 @@
1
1
  <template>
2
- <div class="bagel-input text-input"
3
- :class="{ dense, small, shrink, toggleEdit, editMode, textInputIconWrap: icon, txtInputIconStart: iconStart, code }"
4
- :title="title">
5
- <label :for="id">
2
+ <div
3
+ class="bagel-input text-input"
4
+ :class="{
5
+ dense, small, shrink, toggleEdit, editMode, code,
6
+ textInputIconWrap: icon,
7
+ txtInputIconStart: iconStart,
8
+ }"
9
+ :title="title"
10
+ >
11
+ <label
12
+ :for="id"
13
+ >
6
14
  {{ label }}
7
- <input :title="title" :autocomplete="autocomplete" v-if="!multiline && !autoheight && !code" :id="id"
8
- v-model="inputVal" :type="type" :rows="1" ref="input" :placeholder="placeholder || label"
9
- :disabled="!editMode" :required="required" :pattern="pattern" v-bind="nativeInputAttrs"
10
- @dblclick="toggleEditAction">
11
- <textarea :title="title" v-else :id="id" v-model="inputVal" :type="type" :rows="rows" ref="input"
12
- :placeholder="placeholder || label" :disabled="!editMode" :required="required" :pattern="pattern"
13
- v-bind="nativeInputAttrs" @dblclick="toggleEditAction" />
15
+ <input
16
+ v-if="!multiline && !autoheight && !code"
17
+ :title="title"
18
+ :autocomplete="autocomplete"
19
+ :id="id"
20
+ v-model="inputVal"
21
+ :type="type"
22
+ :rows="1" ref="input"
23
+ :placeholder="placeholder || label"
24
+ :disabled="!editMode"
25
+ :required="required"
26
+ :pattern="pattern"
27
+ v-bind="nativeInputAttrs"
28
+ @dblclick="toggleEditAction"
29
+ >
30
+ <textarea
31
+ v-else
32
+ :title="title"
33
+ :id="id"
34
+ v-model="inputVal"
35
+ :type="type"
36
+ :rows="rows" ref="input"
37
+ :placeholder="placeholder || label"
38
+ :disabled="!editMode"
39
+ :required="required"
40
+ :pattern="pattern"
41
+ v-bind="nativeInputAttrs"
42
+ @dblclick="toggleEditAction"
43
+ />
14
44
  <p v-if="helptext">{{ helptext }}</p>
15
45
  </label>
16
46
 
17
- <MaterialIcon class="iconStart" v-if="iconStart" :icon="iconStart" />
18
- <MaterialIcon v-if="icon" :icon="icon" />
19
- <Btn class="toggleEditBtn" v-if="toggleEdit" thin @click="toggleEditAction" :icon="editMode ? 'check' : 'edit'"
20
- flat />
47
+ <MaterialIcon
48
+ class="iconStart" v-if="iconStart"
49
+ :icon="iconStart"
50
+ />
51
+ <MaterialIcon
52
+ v-if="icon"
53
+ :icon="icon"
54
+ />
55
+ <Btn
56
+ class="toggleEditBtn" v-if="toggleEdit" thin @click="toggleEditAction"
57
+ :icon="editMode ? 'check'
58
+ : 'edit'"
59
+ flat
60
+ />
21
61
  </div>
22
62
  </template>
23
63
 
@@ -21,6 +21,7 @@ interface ModalFormOptions {
21
21
  modelValue?: Record<string, any>;
22
22
  onSubmit?: (formData: any) => Promise<any>;
23
23
  onDelete?: (id: string) => Promise<void>;
24
+ onError?: ((err: any) => void);
24
25
  }
25
26
 
26
27
  interface ModalApi {