@bagelink/vue 0.0.239 → 0.0.243

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.
Files changed (44) hide show
  1. package/dist/components/Avatar.vue.d.ts +19 -3
  2. package/dist/components/Avatar.vue.d.ts.map +1 -1
  3. package/dist/components/ListItem.vue.d.ts +4 -0
  4. package/dist/components/ListItem.vue.d.ts.map +1 -1
  5. package/dist/components/ListView.vue.d.ts +1 -1
  6. package/dist/components/Modal.vue.d.ts.map +1 -1
  7. package/dist/components/ModalForm.vue.d.ts +6 -0
  8. package/dist/components/ModalForm.vue.d.ts.map +1 -1
  9. package/dist/components/form/ItemRef.vue.d.ts +0 -1
  10. package/dist/components/form/ItemRef.vue.d.ts.map +1 -1
  11. package/dist/components/form/inputs/SelectField.vue.d.ts +4 -1
  12. package/dist/components/form/inputs/SelectField.vue.d.ts.map +1 -1
  13. package/dist/components/form/inputs/TextInput.vue.d.ts +2 -0
  14. package/dist/components/form/inputs/TextInput.vue.d.ts.map +1 -1
  15. package/dist/components/form/inputs/ToggleInput.vue.d.ts +7 -20
  16. package/dist/components/form/inputs/ToggleInput.vue.d.ts.map +1 -1
  17. package/dist/index.cjs +1849 -1860
  18. package/dist/index.mjs +1849 -1860
  19. package/dist/plugins/modal.d.ts +8 -6
  20. package/dist/plugins/modal.d.ts.map +1 -1
  21. package/dist/style.css +246 -87
  22. package/dist/types/BagelForm.d.ts +16 -8
  23. package/dist/types/BagelForm.d.ts.map +1 -1
  24. package/package.json +1 -1
  25. package/src/components/Avatar.vue +14 -17
  26. package/src/components/ListItem.vue +16 -9
  27. package/src/components/Modal.vue +2 -4
  28. package/src/components/ModalForm.vue +7 -3
  29. package/src/components/form/BglField.vue +1 -1
  30. package/src/components/form/BglForm.vue +14 -11
  31. package/src/components/form/inputs/TextInput.vue +27 -60
  32. package/src/components/form/inputs/ToggleInput.vue +29 -40
  33. package/src/plugins/modal.ts +12 -28
  34. package/src/styles/layout.css +197 -30
  35. package/src/styles/modal.css +38 -13
  36. package/src/styles/text.css +12 -0
  37. package/src/styles/theme.css +9 -11
  38. package/src/types/BagelForm.ts +17 -6
  39. package/dist/components/Drop.vue.d.ts +0 -34
  40. package/dist/components/Drop.vue.d.ts.map +0 -1
  41. package/dist/components/FileUploader.vue.d.ts +0 -60
  42. package/dist/components/FileUploader.vue.d.ts.map +0 -1
  43. package/src/types/BagelField.ts +0 -52
  44. package/src/utils/objects.ts +0 -81
@@ -1,11 +1,7 @@
1
1
  <template>
2
- <div class="avatar">
3
- <img
4
- v-if="src"
5
- :src="src"
6
- :alt="name"
7
- >
8
- <p v-else>
2
+ <div class="avatar" :style="{ width: `${size}px`, height: `${size}px` }">
3
+ <img v-if="src" :src="src" :alt="name">
4
+ <p v-else :style="{ 'line-height': `${size * 0.9}px` }">
9
5
  {{ fallback || initials(name || '') }}
10
6
  </p>
11
7
  </div>
@@ -14,22 +10,23 @@
14
10
  <script setup lang="ts">
15
11
  import { initials } from '@bagelink/vue';
16
12
 
17
- defineProps<{
18
- fallback?: string;
19
- src?: string;
20
- name?: string;
21
- }>();
13
+ withDefaults(defineProps<{
14
+ fallback?: string;
15
+ src?: string;
16
+ name?: string;
17
+ size?: number;
18
+ }>(), { size: 50 });
22
19
  </script>
23
20
 
24
21
  <style scoped>
25
- .avatar{
22
+ .avatar {
26
23
  border-radius: 100%;
27
- width: 50px;
28
- height: 50px;
29
- background-color: var(--bgl-primary-tint);
24
+ background-color: var(--bgl-gray-20);
25
+ border: 0.5px solid var(--border-color);
30
26
  overflow: hidden;
31
27
  text-align: center;
32
28
  padding: none;
29
+
33
30
  }
34
31
 
35
32
  .avatar p {
@@ -39,7 +36,7 @@ defineProps<{
39
36
  font-weight: 200;
40
37
  }
41
38
 
42
- .avatar img{
39
+ .avatar img {
43
40
  width: 100%;
44
41
  height: 100%;
45
42
  object-fit: cover;
@@ -1,18 +1,25 @@
1
1
  <template>
2
- <component :is="to ? 'RouterLink' : 'div'" :to="to" class="list-item ellipsis">
3
- <p class="txt16 no-margin">
4
- {{ title }}
5
- <slot />
6
- </p>
7
- <p class="txt14 no-margin txtgray">
8
- {{ subtitle }}
9
- <slot name="subtitle" />
10
- </p>
2
+ <component :is="to ? 'RouterLink' : 'div'" :to="to" class="flex list-item gap-3">
3
+ <Avatar style="flex-basis: 1;" :name="title" :src="src" v-if="src || showAvatar" :size="40" />
4
+ <div>
5
+ <p class="txt16 no-margin ellipsis">
6
+ {{ title }}
7
+ <slot />
8
+ </p>
9
+ <p class="txt14 no-margin txtgray ellipsis">
10
+ {{ subtitle }}
11
+ <slot name="subtitle" />
12
+ </p>
13
+ </div>
11
14
  </component>
12
15
  </template>
13
16
 
14
17
  <script lang="ts" setup>
18
+ import { Avatar } from '@bagelink/vue';
19
+
15
20
  defineProps<{
21
+ src?: string;
22
+ showAvatar?: boolean;
16
23
  to?: string;
17
24
  title?: string;
18
25
  subtitle?: string;
@@ -1,8 +1,6 @@
1
1
  <template>
2
- <div
3
- class="bg-dark" :class="{ 'is-side': side, 'is-active': isActive }"
4
- @click="() => (dismissable ? closeModal() : '')" @keydown.esc="closeModal"
5
- >
2
+ <div class="bg-dark" :class="{ 'is-side': side, 'is-active': isActive, 'bg-lignt': false }"
3
+ @click="() => (dismissable ? closeModal() : '')" @keydown.esc="closeModal">
6
4
  <Card class="modal" @click.stop>
7
5
  <header class="tool-bar">
8
6
  <slot name="toolbar" />
@@ -1,6 +1,7 @@
1
1
  <template>
2
- <Modal :side="side" ref="modal" :dismissable="dismissable" :title="title">
3
- <BagelForm v-model="formData" :schema="computedFormSchema" />
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" />
4
5
  <template #footer v-if="onDelete || onSubmit">
5
6
  <div>
6
7
  <Btn thin flat value="Cancel" @click="closeModal()" />
@@ -28,6 +29,8 @@ const props = defineProps<{
28
29
  onSubmit?: ((formData: any) => Promise<void>);
29
30
  // eslint-disable-next-line no-unused-vars
30
31
  onDelete?: ((id: string) => void);
32
+ // eslint-disable-next-line no-unused-vars
33
+ 'onUpdate:isModalVisible'?: ((visible: boolean) => void);
31
34
  }>();
32
35
 
33
36
  const modal = $ref<InstanceType<typeof Modal>>();
@@ -38,10 +41,11 @@ const computedFormSchema = $computed(() => {
38
41
  });
39
42
 
40
43
  const formData = defineModel<Record<string, any>>('modelValue', { default: {} });
41
-
44
+ const form = $ref<InstanceType<typeof BagelForm>>();
42
45
  const closeModal = () => modal?.closeModal();
43
46
 
44
47
  const runSubmit = async () => {
48
+ if (form?.validateForm?.() === false) return;
45
49
  try {
46
50
  await props.onSubmit?.(formData.value);
47
51
  closeModal();
@@ -2,7 +2,7 @@
2
2
  <component :required="field.required" v-bind="bindAttrs(field?.attrs || {}, fieldData, modelValue)"
3
3
  :class="classify(fieldData, modelValue, field.class, field.attrs?.class)" v-if="iffer(field, fieldData)" :is="is"
4
4
  :label="field.label" :id="field.id" :placeholder="field.placeholder || field.label" v-model="fieldData"
5
- :defaultValue="field.defaultValue" :options="field.options" :hint="field.hint"
5
+ :defaultValue="field.defaultValue" :options="field.options" :helptext="field.helptext"
6
6
  @update:modelValue="($event: any) => field?.onUpdate?.($event, denullify(fieldData, field.id), formData)">
7
7
  {{ field.transform?.(fieldData, modelValue) || fieldData || '' }}
8
8
  <BglField v-model="formData" v-for="(child, ii) in field.children" :key="child.id || ii" :field="child" />
@@ -2,19 +2,15 @@
2
2
  <component :is="id?'div':'form'" ref="form" @submit.prevent="runSubmit">
3
3
  <Title tag="h4" :label="label" v-if="label" />
4
4
  <BglField v-for="(field, i) in schema" :key="field.id || `${i}p`" :field="field" v-model="data" />
5
- <Btn class="del-top" v-if="data?.id && onDelete" @click="runDelete" value="Delete" flat icon="delete" color="red"
6
- thin />
7
- <Btn v-if="!$slots.submit && onSubmit" value="Submit" type="submit" thin />
8
- <div v-else>
9
- <slot name="submit" />
10
- </div>
5
+ <slot name="submit" />
11
6
  </component>
12
7
  </template>
13
8
 
14
9
  <script lang="ts" setup>
15
10
  import {
16
- Btn, useModal, BglField, Title,
11
+ useModal, BglField, Title,
17
12
  } from '@bagelink/vue';
13
+
18
14
  import { type BglFormSchemaT } from '@bagelink/vue';
19
15
 
20
16
  const { showModal } = useModal();
@@ -33,10 +29,17 @@ const props = withDefaults(
33
29
  },
34
30
  );
35
31
 
36
- const emit = defineEmits(['update:modelValue', 'submit']);
32
+ const timeSinceInst = () => new Date().getTime() - instAt.getTime();
37
33
 
34
+ const emit = defineEmits(['update:modelValue', 'submit', 'dirty']);
35
+ const instAt = new Date();
36
+ let isDirty = $ref(false);
38
37
  const data = $computed({
39
38
  set: (val: any) => {
39
+ if (timeSinceInst() > 100) {
40
+ emit('dirty');
41
+ isDirty = true;
42
+ }
40
43
  emit('update:modelValue', val);
41
44
  },
42
45
  get: () => props.modelValue || {},
@@ -45,8 +48,6 @@ const form = $ref<HTMLFormElement>();
45
48
 
46
49
  const validateForm = () => form?.reportValidity?.();
47
50
 
48
- defineExpose({ validateForm });
49
-
50
51
  const clearForm = () => Object.assign(data, {});
51
52
 
52
53
  const runSubmit = () => {
@@ -57,7 +58,7 @@ const runSubmit = () => {
57
58
 
58
59
  const i18nT = (val: string) => val;
59
60
 
60
- const runDelete = () => {
61
+ const deleteItem = () => {
61
62
  showModal(
62
63
  {
63
64
  class: 'small-modal',
@@ -74,6 +75,8 @@ const runDelete = () => {
74
75
  { default: i18nT('form.deleteMessage') },
75
76
  );
76
77
  };
78
+
79
+ defineExpose({ validateForm, deleteItem, isDirty });
77
80
  </script>
78
81
 
79
82
  <style>
@@ -1,59 +1,22 @@
1
1
  <template>
2
- <div
3
- class="bagel-input text-input"
2
+ <div class="bagel-input text-input"
4
3
  :class="{ small, shrink, toggleEdit, editMode, textInputIconWrap: icon, txtInputIconStart: iconStart, code }"
5
- :title="title"
6
- >
4
+ :title="title">
7
5
  <label :for="id">
8
6
  {{ label }}
9
- <input
10
- :autocomplete="autocomplete"
11
- v-if="!multiline && !autoheight && !code"
12
- :id="id"
13
- v-model="inputVal"
14
- :type="type"
15
- :rows="1"
16
- ref="input"
17
- :placeholder="placeholder || label"
18
- :disabled="!editMode"
19
- :required="required"
20
- :pattern="pattern"
21
- v-bind="nativeInputAttrs"
22
- @dblclick="toggleEditAction"
23
- >
24
- <textarea
25
- v-else
26
- :id="id"
27
- v-model="inputVal"
28
- :type="type"
29
- :rows="rows"
30
- ref="input"
31
- :placeholder="placeholder || label"
32
- :disabled="!editMode"
33
- :required="required"
34
- :pattern="pattern"
35
- v-bind="nativeInputAttrs"
36
- @dblclick="toggleEditAction"
37
- />
7
+ <input :autocomplete="autocomplete" v-if="!multiline && !autoheight && !code" :id="id" v-model="inputVal"
8
+ :type="type" :rows="1" ref="input" :placeholder="placeholder || label" :disabled="!editMode"
9
+ :required="required" :pattern="pattern" v-bind="nativeInputAttrs" @dblclick="toggleEditAction">
10
+ <textarea v-else :id="id" v-model="inputVal" :type="type" :rows="rows" ref="input"
11
+ :placeholder="placeholder || label" :disabled="!editMode" :required="required" :pattern="pattern"
12
+ v-bind="nativeInputAttrs" @dblclick="toggleEditAction" />
13
+ <p v-if="helptext">{{ helptext }}</p>
38
14
  </label>
39
15
 
40
- <MaterialIcon
41
- class="iconStart"
42
- v-if="iconStart"
43
- :icon="iconStart"
44
- />
45
- <MaterialIcon
46
- v-if="icon"
47
- :icon="icon"
48
- />
49
- <Btn
50
- class="toggleEditBtn"
51
- v-if="toggleEdit"
52
- thin
53
- @click="toggleEditAction"
54
- :icon="editMode ? 'check' : 'edit'"
55
- flat
56
- />
16
+ <MaterialIcon class="iconStart" v-if="iconStart" :icon="iconStart" />
17
+ <MaterialIcon v-if="icon" :icon="icon" />
18
+ <Btn class="toggleEditBtn" v-if="toggleEdit" thin @click="toggleEditAction" :icon="editMode ? 'check' : 'edit'"
19
+ flat />
57
20
  </div>
58
21
  </template>
59
22
 
@@ -68,6 +31,7 @@ const props = withDefaults(
68
31
  defineProps<{
69
32
  id?: string;
70
33
  title?: string;
34
+ helptext?: string;
71
35
  placeholder?: string;
72
36
  modelValue?: string | number;
73
37
  label?: string;
@@ -80,8 +44,8 @@ const props = withDefaults(
80
44
  nativeInputAttrs?: Record<string, any>;
81
45
  icon?: MaterialIcons;
82
46
  iconStart?: MaterialIcons;
83
- multiline?: boolean;
84
- autoheight?: boolean;
47
+ multiline?: boolean;
48
+ autoheight?: boolean;
85
49
  code?: boolean;
86
50
  lines?: number;
87
51
  autocomplete?: string;
@@ -144,17 +108,20 @@ watch(
144
108
  </style>
145
109
 
146
110
  <style scoped>
147
- .bagel-input textarea{
148
- min-height: unset;
111
+ .bagel-input textarea {
112
+ min-height: unset;
149
113
  }
150
- .bagel-input.text-input textarea{
151
- resize: none;
114
+
115
+ .bagel-input.text-input textarea {
116
+ resize: none;
152
117
  }
153
- .code textarea{
154
- font-family: 'Inconsolata', monospace;
155
- background: var(--bgl-black) !important;
156
- color: var(--bgl-white) !important;
118
+
119
+ .code textarea {
120
+ font-family: 'Inconsolata', monospace;
121
+ background: var(--bgl-black) !important;
122
+ color: var(--bgl-white) !important;
157
123
  }
124
+
158
125
  .bagel-input.toggleEdit:hover {
159
126
  background-color: var(--input-bg);
160
127
  }
@@ -1,59 +1,48 @@
1
1
  <template>
2
- <div
3
- class="bagel-input bgl-checkbox"
4
- :title="title"
5
- :class="{ small: small, 'no-edit': !editMode }"
6
- >
7
- <div class="switch">
8
- <input
9
- :id="id"
10
- type="checkbox"
11
- v-model="inputVal"
12
- :class="{ 'no-edit': !editMode }"
13
- >
14
- <span class="slider round" />
15
- </div>
16
- <label :for="id">
17
- {{ label }}
18
- </label>
19
- </div>
2
+ <div class="bagel-input bgl-checkbox justify-content-center gap-3" :title="title" :class="{ small: small }">
3
+ <div class="switch" :class="{ checked }">
4
+ <span class="slider round" />
5
+ </div>
6
+ <label>
7
+ {{ label }}
8
+ <input :id="id" type="checkbox" v-model="checked">
9
+ </label>
10
+ </div>
20
11
  </template>
21
12
 
22
13
  <script setup lang="ts">
23
- withDefaults(
24
- defineProps<{
25
- label: string;
26
- id?: string;
27
- title?: string;
28
- editMode?: boolean;
29
- small?: boolean;
30
- }>(),
31
- {
32
- editMode: true,
33
- id: Math.random().toString(36).substring(7),
34
- },
35
- );
14
+ defineProps<{
15
+ label: string;
16
+ id?: string;
17
+ title?: string;
18
+ small?: boolean;
19
+ }>();
36
20
 
37
- const inputVal = defineModel<boolean>('modelValue', { default: false });
21
+ const checked = defineModel<boolean>('modelValue', { default: false });
38
22
  </script>
39
23
 
40
24
  <style scoped>
41
- .bgl-checkbox{
25
+ .bgl-checkbox {
42
26
  position: relative;
43
27
  }
44
- .bgl-checkbox input[type=checkbox]{
28
+
29
+ .bgl-checkbox input[type=checkbox] {
45
30
  display: none;
46
31
  }
47
- .bgl-checkbox label{
32
+
33
+ .bgl-checkbox label {
48
34
  padding-inline-start: calc(var(--input-height) + 0.25rem);
49
35
  transition: var(--bgl-transition);
50
36
  cursor: pointer;
51
37
  user-select: none;
38
+ line-height: var(--input-height);
52
39
  }
53
- .bgl-checkbox:hover{
40
+
41
+ .bgl-checkbox:hover {
54
42
  filter: brightness(90%);
55
43
  }
56
- .bgl-checkbox:active{
44
+
45
+ .bgl-checkbox:active {
57
46
  filter: var(--bgl-active-filter);
58
47
  }
59
48
 
@@ -64,7 +53,7 @@ const inputVal = defineModel<boolean>('modelValue', { default: false });
64
53
  width: var(--input-height);
65
54
  border-radius: var(--input-height);
66
55
  background: var(--bgl-gray);
67
- outline: 1px solid var(--bgl-black);
56
+ outline: 1px solid var(--border-color);
68
57
  margin-top: 0.15rem;
69
58
  pointer-events: none;
70
59
  }
@@ -102,11 +91,11 @@ const inputVal = defineModel<boolean>('modelValue', { default: false });
102
91
  transition: 0.4s;
103
92
  }
104
93
 
105
- input:checked + .slider {
94
+ .checked .slider {
106
95
  background: var(--bgl-primary);
107
96
  }
108
97
 
109
- input:checked + .slider:before {
98
+ .checked .slider:before {
110
99
  transform: translateX(calc(var(--input-height) / 2));
111
100
  }
112
101
  </style>
@@ -13,26 +13,20 @@ interface ModalOptions {
13
13
  class?: string;
14
14
  }
15
15
 
16
- interface ModalFormOptions extends ModalOptions {
17
- modelValue?: any;
18
- // eslint-disable-next-line no-unused-vars
19
- 'onUpdate:modelValue'?: (val: any) => void;
20
- // eslint-disable-next-line no-unused-vars
21
- onSubmit: (val: any) => void;
22
- // eslint-disable-next-line no-unused-vars
23
- onDelete?: (id: string) => void;
24
- schema: BglFormSchemaT<any> | (() => BglFormSchemaT<any>);
25
-
16
+ interface ModalFormOptions {
17
+ side?: boolean;
18
+ title?: string;
19
+ dismissable?: boolean;
20
+ schema: BglFormSchemaT<any> | (() => BglFormSchemaT);
21
+ modelValue?: Record<string, any>;
22
+ onSubmit?: (formData: any) => Promise<any>;
23
+ onDelete?: (id: string) => Promise<void>;
26
24
  }
27
25
 
28
26
  interface ModalApi {
29
- // eslint-disable-next-line no-unused-vars
30
27
  showModal: (options: ModalOptions, slots?: Record<string, any>) => void;
31
- // eslint-disable-next-line no-unused-vars
32
28
  showModalForm: (options: ModalFormOptions, slots?: Record<string, any>) => void;
33
- // eslint-disable-next-line no-unused-vars
34
29
  hideModal: (index?: number) => void;
35
- // modalOptions: Ref<ModalOptions | ModalFormOptions>;
36
30
  }
37
31
 
38
32
  export const ModalSymbol: InjectionKey<ModalApi> = Symbol('modal');
@@ -77,22 +71,12 @@ export const ModalPlugin: Plugin = {
77
71
  });
78
72
 
79
73
  const ModalComponent = defineComponent({
80
- data() {
81
- return {
82
- modalStack,
83
- };
84
- },
74
+ data: () => ({ modalStack }),
85
75
  render() {
86
76
  return modalStack.map((modal, index) => {
87
- const renderComponent = modal.modalType === 'modalForm' ? ModalForm : Modal;
88
- return h(
89
- renderComponent as any,
90
- {
91
- ...modal.modalOptions,
92
- 'onUpdate:isModalVisible': () => hideModal(index),
93
- },
94
- modal.componentSlots,
95
- );
77
+ const props = { ...modal.modalOptions, 'onUpdate:isModalVisible': () => hideModal(index) };
78
+ if (modal.modalType === 'modalForm') return h(ModalForm, props as ModalFormOptions, modal.componentSlots);
79
+ return h(Modal, props, modal.componentSlots);
96
80
  });
97
81
  },
98
82
  });