@bagelink/vue 0.0.211 → 0.0.214

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,51 +1,53 @@
1
1
  <template>
2
- <div :class="{ open: isOpen, closed: !isOpen }">
3
- <slot name="top" />
4
- <div
5
- class="nav-expend"
6
- @click="isOpen = !isOpen"
7
- @keypress.enter="isOpen = !isOpen"
8
- role="button"
9
- aria-label="Toggle Navigation"
10
- tabindex="0"
11
- >
12
- <div class="icon-font top-arrow">chevron_right</div>
13
- </div>
14
-
15
- <div class="full-nav">
16
- <div class="nav-scroll">
17
- <div class="nav-links-wrapper">
18
- <RouterLink
19
- v-for="link in links?.()"
20
- class="nav-button"
21
- :to="link.to"
22
- :key="link.label"
23
- >
24
- <div class="icon-font">
25
- {{ link.materialIcon }}
26
- </div>
27
- <div class="tooltip">
28
- {{ link.localized ? link.localized : link.label }}
29
- </div>
30
- </RouterLink>
31
- </div>
32
- </div>
33
-
34
- <div class="bot-buttons-wrapper">
35
- <slot name="floor" />
36
- </div>
37
- </div>
38
- </div>
2
+ <div :class="{ open: isOpen, closed: !isOpen }">
3
+ <slot name="top" />
4
+ <div
5
+ class="nav-expend"
6
+ @click="isOpen = !isOpen"
7
+ @keypress.enter="isOpen = !isOpen"
8
+ role="button"
9
+ aria-label="Toggle Navigation"
10
+ tabindex="0"
11
+ >
12
+ <div class="icon-font top-arrow">
13
+ chevron_right
14
+ </div>
15
+ </div>
16
+
17
+ <div class="full-nav">
18
+ <div class="nav-scroll">
19
+ <div class="nav-links-wrapper">
20
+ <RouterLink
21
+ v-for="link in links?.()"
22
+ class="nav-button"
23
+ :to="link.to"
24
+ :key="link.label"
25
+ >
26
+ <div class="icon-font">
27
+ {{ link.materialIcon }}
28
+ </div>
29
+ <div class="tooltip">
30
+ {{ link.localized ? link.localized : link.label }}
31
+ </div>
32
+ </RouterLink>
33
+ </div>
34
+ </div>
35
+
36
+ <div class="bot-buttons-wrapper">
37
+ <slot name="floor" />
38
+ </div>
39
+ </div>
40
+ </div>
39
41
  </template>
40
42
 
41
43
  <script lang="ts" setup>
42
44
  // import LangText from "../translation/LangText.vue"s
43
- import type { MaterialIcons } from "@bagelink/vue";
45
+ import type { MaterialIcons } from '@bagelink/vue';
44
46
 
45
47
  const isOpen = $ref(true);
46
48
 
47
49
  withDefaults(
48
- defineProps<{
50
+ defineProps<{
49
51
  links?: () => {
50
52
  label: string;
51
53
  to: string;
@@ -56,15 +58,15 @@ withDefaults(
56
58
  homeLabel?: string;
57
59
  homeTo?: string;
58
60
  }>(),
59
- {
60
- homeIcon: "home",
61
- homeLabel: "Home",
62
- homeTo: "/",
63
- }
61
+ {
62
+ homeIcon: 'home',
63
+ homeLabel: 'Home',
64
+ homeTo: '/',
65
+ },
64
66
  );
65
67
  </script>
66
68
 
67
- <style>
69
+ <style scoped>
68
70
  [dir="rtl"] .top-arrow {
69
71
  transform: rotate(180deg);
70
72
  }
@@ -2,7 +2,7 @@
2
2
  <form @submit.prevent="runSubmit">
3
3
  <BglField
4
4
  v-for="(field, i) in schema" :key="field.id || `${i }p`" :field="field" :modelValue="data"
5
- @update:modelValue="($event: any) => field.id ? data[field.id] = $event : ''"
5
+ @update:modelValue="($event)=>updateModelValue($event, field?.id || '')"
6
6
  />
7
7
  <Btn
8
8
  class="del-top" v-if="modelValue?.id && onDelete" @click="runDelete" value="Delete" flat icon="delete"
@@ -16,9 +16,9 @@
16
16
  </template>
17
17
 
18
18
  <script lang="ts" setup>
19
- import { watch } from 'vue';
20
19
  import { Btn, useModal, BglField } from '@bagelink/vue';
21
20
  import { type BglFormSchemaT } from '@bagelink/vue';
21
+ import { watch } from 'vue';
22
22
 
23
23
  const { showModal } = useModal();
24
24
 
@@ -29,11 +29,19 @@ const props = defineProps<{
29
29
  onSubmit?: ((data: any) => void);
30
30
  }>();
31
31
 
32
+ let data = $ref<Record<string, any>>({});
33
+
34
+ watch(() => props.modelValue, (val) => {
35
+ data = val;
36
+ }, { immediate: true, deep: true });
37
+
38
+ const updateModelValue = (val: any, fieldID: string) => {
39
+ if (!fieldID) return;
40
+ data[fieldID] = val;
41
+ emits('update:modelValue', data);
42
+ };
43
+
32
44
  const emits = defineEmits(['update:modelValue', 'submit']);
33
- const handleEmit = (val: any) => emits('update:modelValue', val);
34
- let data = $ref({
35
- ...props.modelValue,
36
- });
37
45
  const runSubmit = () => {
38
46
  emits('submit', data);
39
47
  clearForm();
@@ -43,12 +51,6 @@ const clearForm = () => data = {};
43
51
 
44
52
  const i18nT = (val: string) => val;
45
53
 
46
- watch(
47
- () => data,
48
- () => handleEmit,
49
- { immediate: true },
50
- );
51
-
52
54
  const runDelete = () => {
53
55
  showModal(
54
56
  {
@@ -1,143 +1,117 @@
1
1
  <template>
2
- <div
3
- class="bagel-input checkbox"
4
- :title="field.description"
5
- :class="{ small: small, 'no-edit': !editMode }"
6
- >
7
- <label :for="field.id">
8
- {{ field.label }}
9
- </label>
10
- <label class="switch">
11
- <input
12
- :id="field.id"
13
- type="checkbox"
14
- v-model="inputVal"
15
- :class="{ 'no-edit': !editMode }"
16
- />
17
- <span class="slider round" />
18
- </label>
19
- </div>
2
+ <div
3
+ class="bagel-input bgl-checkbox"
4
+ :title="title"
5
+ :class="{ small: small, 'no-edit': !editMode }"
6
+ >
7
+ <input
8
+ :id="id"
9
+ type="checkbox"
10
+ v-model="inputVal"
11
+ :class="{ 'no-edit': !editMode }"
12
+ >
13
+ <svg
14
+ xmlns="http://www.w3.org/2000/svg"
15
+ height="24" viewBox="0 -960 960 960"
16
+ width="24"
17
+ >
18
+ <path d="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z"/></svg>
19
+ <label :for="id">
20
+ {{ label }}
21
+ </label>
22
+ </div>
20
23
  </template>
21
24
 
22
25
  <script setup lang="ts">
23
- import { watch, ref, onMounted } from "vue";
24
- import { BagelField } from "@bagelink/vue";
26
+ import { watch } from 'vue';
25
27
 
26
- const emits = defineEmits(["update:modelValue"]);
28
+ const emits = defineEmits(['update:modelValue']);
27
29
  const props = withDefaults(
28
- defineProps<{
29
- field: BagelField;
30
- modelValue: any;
30
+ defineProps<{
31
+ label: string;
32
+ id?: string;
33
+ title?: string;
34
+ modelValue: boolean;
31
35
  editMode?: boolean;
32
36
  small?: boolean;
33
37
  }>(),
34
- {
35
- editMode: true,
36
- }
38
+ {
39
+ editMode: true,
40
+ id: Math.random().toString(36).substring(7),
41
+ },
37
42
  );
38
43
 
39
- const inputVal = ref(false);
44
+ let inputVal = $ref(false);
40
45
  watch(inputVal, (newVal) => {
41
- if (newVal === undefined) return;
42
- emits("update:modelValue", newVal);
46
+ if (newVal === undefined) return;
47
+ emits('update:modelValue', newVal);
43
48
  });
49
+
44
50
  watch(
45
- () => props.modelValue,
46
- (newVal) => {
47
- if (inputVal.value !== newVal) inputVal.value = newVal;
48
- }
51
+ () => props.modelValue,
52
+ (newVal) => {
53
+ if (inputVal !== newVal) inputVal = newVal;
54
+ },
55
+ { immediate: true },
49
56
  );
50
- onMounted(() => (inputVal.value = !!props.modelValue));
51
57
  </script>
58
+ <style>
59
+ :root {
60
+ --bgl-white: #fff;
61
+ --input-height: 40px;
62
+ --input-border-radius: 7px;
63
+ --bgl-transition: all 200ms ease;
64
+ --bgl-primary: #19b8ea;
52
65
 
66
+ }
67
+ </style>
53
68
  <style scoped>
54
- .no-edit {
55
- pointer-events: none;
69
+ .bgl-checkbox{
70
+ position: relative;
56
71
  }
57
-
58
- .radio-wrap p {
59
- display: inline-block;
60
- color: var(--input-bg);
61
- font-size: var(--input-font-size);
62
- margin-inline-end: 10px;
72
+ .bgl-checkbox input[type=checkbox]{
73
+ display: none;
63
74
  }
64
-
65
- .radio-wrap label {
66
- padding: 3px 5px;
67
- display: inline-block;
68
- border-radius: var(--input-border-radius);
69
- font-size: var(--input-font-size);
70
- background: var(--input-bg);
71
- color: var(--bgl-black);
72
- text-align: center;
73
- margin: 8px 5px;
75
+ .bgl-checkbox label{
76
+ padding-inline-start: calc(var(--input-height) / 2 + 0.25rem);
77
+ transition: var(--bgl-transition);
74
78
  cursor: pointer;
75
79
  user-select: none;
76
80
  }
77
-
78
- .bagel-input .radio-wrap label::after {
79
- background: transparent;
80
- }
81
-
82
- .radio-wrap input {
83
- display: none;
84
- }
85
-
86
- .radio-wrap input:checked:checked + label {
87
- background: var(--bgl-primary);
88
- color: var(--bgl-white);
89
- }
90
-
91
- .checkbox {
92
- position: relative;
93
- }
94
-
95
- .switch {
96
- position: relative;
97
- display: inline-block;
98
- height: calc(var(--input-height) / 2);
99
- width: var(--input-height);
100
- border-radius: var(--input-height);
81
+ .bgl-checkbox:hover{
82
+ filter: brightness(90%);
101
83
  }
102
-
103
- .switch input {
104
- opacity: 0;
105
- width: 0;
106
- height: 0;
107
- }
108
-
109
- .slider {
110
- position: absolute;
111
- cursor: pointer;
112
- top: 0;
113
- left: 0;
114
- right: 0;
115
- bottom: 0;
116
- background: var(--input-bg);
117
- -webkit-transition: 0.4s;
118
- transition: 0.4s;
119
- border-radius: calc(var(--input-height) / 2);
120
- box-shadow: inset 0 0 10px #00000020;
84
+ .bgl-checkbox:active{
85
+ filter: var(--bgl-active-filter);
121
86
  }
122
-
123
- .slider:before {
124
- position: absolute;
87
+ .bgl-checkbox label::before{
125
88
  content: "";
126
- height: calc(var(--input-height) / 2 - 4px);
127
- width: calc(var(--input-height) / 2 - 4px);
128
- left: 2px;
129
- bottom: 2px;
130
- border-radius: 50%;
89
+ width: calc(var(--input-height) / 2.5);
90
+ height: calc(var(--input-height) / 2.5);
131
91
  background: var(--bgl-white);
132
- -webkit-transition: 0.4s;
133
- transition: 0.4s;
92
+ display: inline-block;
93
+ position: absolute;
94
+ margin-top: 0.25rem;
95
+ inset-inline-start: 0;
96
+ border-radius: calc(var(--input-border-radius) / 2) ;
97
+ border: var(--bgl-primary) 1px solid;
134
98
  }
135
99
 
136
- input:checked + .slider {
100
+ input:checked ~ label::before{
137
101
  background: var(--bgl-primary);
138
102
  }
139
-
140
- input:checked + .slider:before {
141
- transform: translateX(calc(var(--input-height) / 2));
103
+ .bgl-checkbox svg{
104
+ width: calc(var(--input-height) / 2.5);
105
+ height: calc(var(--input-height) / 2.5);
106
+ position: absolute;
107
+ inset-inline-start: 0.05rem;
108
+ margin-top: 0.3rem;
109
+ z-index: 2;
110
+ fill: var(--bgl-white);
111
+ opacity: 0;
112
+ pointer-events: none;
113
+ }
114
+ input:checked ~ svg{
115
+ opacity: 1;
142
116
  }
143
117
  </style>
@@ -3,16 +3,17 @@
3
3
  <label>
4
4
  {{ label }}
5
5
  </label>
6
- <div @click="browse" @dragover="dragenter" @drop="drop" @dragleave="dragleave" class="fileUploadWrap" :class="{fileDropZone: !files.length, dragover: isDragOver}">
6
+ <div @click="browse" @dragover="dragover" @drop="drop" @dragleave="dragleave" class="fileUploadWrap"
7
+ :class="{ fileDropZone: !files.length, dragover: isDragOver }">
7
8
  <div v-if="files.length && !multiple">
8
9
  <div class="imagePreviewWrap">
9
- <img class="preview" :src="fileToUrl(files[0])" alt="" >
10
+ <img class="preview" :src="fileToUrl(files[0])" alt="">
10
11
  </div>
11
12
  <div class="previewName">
12
13
  <p class="no-margin">
13
- {{files[0].name}}
14
+ {{ files[0].name }}
14
15
  </p>
15
- <Btn thin @click.stop="removeFile(files[0])" flat icon="delete" color="red"/>
16
+ <Btn thin @click.stop="removeFile(files[0])" flat icon="delete" color="red" />
16
17
  </div>
17
18
  </div>
18
19
  </div>
@@ -22,7 +23,7 @@
22
23
  <script setup lang="ts">
23
24
  import { Btn } from '@bagelink/vue';
24
25
 
25
- const props = defineProps<{label:string, multiple?: boolean}>();
26
+ const props = defineProps<{ label: string, multiple?: boolean }>();
26
27
  const files = $ref<File[]>([]);
27
28
  const fileQueue = $ref<File[]>([]);
28
29
  let isDragOver = $ref(false);
@@ -33,14 +34,13 @@ const preventDefault = (e: Event) => {
33
34
  };
34
35
 
35
36
  const fileToUrl = (file: File) => URL.createObjectURL(file);
36
- const removeFile = (file:File) => {
37
+ const removeFile = (file: File) => {
37
38
  const index = files.indexOf(file);
38
39
  files.splice(index, 1);
39
40
  };
40
41
  const flushQueue = () => {
41
- fileQueue.forEach((file:File, i) => {
42
+ fileQueue.forEach((file: File, i) => {
42
43
  if (props.multiple) { if (!files.includes(file)) files.push(file); } else files.splice(0, 1, file);
43
- console.log(files);
44
44
  fileQueue.splice(i, 1);
45
45
  });
46
46
  };
@@ -63,7 +63,7 @@ const dragleave = (e: DragEvent) => {
63
63
  else isDragOver = false;
64
64
  };
65
65
 
66
- const dragenter = (e: DragEvent) => {
66
+ const dragover = (e: DragEvent) => {
67
67
  preventDefault(e);
68
68
  if (e.dataTransfer) isDragOver = true;
69
69
  else isDragOver = false;
@@ -79,52 +79,59 @@ const drop = (e: DragEvent) => {
79
79
 
80
80
  <style scoped>
81
81
  .bagel-input .fileUploadWrap {
82
- outline: 1px solid var(--border-color);
83
- border-radius: var(--input-border-radius);
84
- text-align: center;
85
- cursor: pointer;
86
- transition: var(--bgl-transition);
87
- position: relative;
88
- height: 132px;
89
- font-size: var(--input-font-size);
82
+ outline: 1px solid var(--border-color);
83
+ border-radius: var(--input-border-radius);
84
+ text-align: center;
85
+ cursor: pointer;
86
+ transition: var(--bgl-transition);
87
+ position: relative;
88
+ height: 132px;
89
+ font-size: var(--input-font-size);
90
90
  }
91
- .previewName{
92
- padding: 0.5rem;
93
- text-align: start;
94
- color: var(--input-color);
95
- display: grid;
96
- grid-template-columns: 1fr 22px;
97
- align-items: center;
91
+
92
+ .previewName {
93
+ padding: 0.5rem;
94
+ text-align: start;
95
+ color: var(--input-color);
96
+ display: grid;
97
+ grid-template-columns: 1fr 22px;
98
+ align-items: center;
98
99
 
99
100
  }
100
- .previewName p{
101
- overflow: hidden;
102
- text-overflow: ellipsis;
103
- white-space: nowrap;
101
+
102
+ .previewName p {
103
+ overflow: hidden;
104
+ text-overflow: ellipsis;
105
+ white-space: nowrap;
104
106
  }
105
- .imagePreviewWrap{
106
- background: var(--input-bg);
107
- border-radius: var(--input-border-radius);
108
- height: 90px;
109
- padding: 5px;
107
+
108
+ .imagePreviewWrap {
109
+ background: var(--input-bg);
110
+ border-radius: var(--input-border-radius);
111
+ height: 90px;
112
+ padding: 5px;
110
113
  }
111
114
 
112
115
  img.preview {
113
- height: 80px;
114
- border-radius: var(--input-border-radius);
115
- object-fit: contain;
116
+ height: 80px;
117
+ border-radius: var(--input-border-radius);
118
+ object-fit: contain;
116
119
  }
117
- .fileUploadWrap.dragover, .fileUploadWrap:hover{
118
- box-shadow: inset 0 0 10px #00000012;
120
+
121
+ .fileUploadWrap.dragover,
122
+ .fileUploadWrap:hover {
123
+ box-shadow: inset 0 0 10px #00000012;
119
124
  }
120
- .bagel-input .fileUploadWrap.fileDropZone{
121
- background: var(--input-bg);
122
- display: flex;
123
- align-items: center;
124
- justify-content: center;
125
- color:var(--bgl-gray);
125
+
126
+ .bagel-input .fileUploadWrap.fileDropZone {
127
+ background: var(--input-bg);
128
+ display: flex;
129
+ align-items: center;
130
+ justify-content: center;
131
+ color: var(--bgl-gray);
126
132
  }
133
+
127
134
  .bagel-input .fileUploadWrap.fileDropZone:after {
128
- content: "Drop files here or click to upload";
135
+ content: "Drop files here or click to upload";
129
136
  }
130
137
  </style>
@@ -0,0 +1,127 @@
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>
20
+ </template>
21
+
22
+ <script setup lang="ts">
23
+ import { watch, ref, onMounted } from 'vue';
24
+
25
+ const emits = defineEmits(['update:modelValue']);
26
+ const props = withDefaults(
27
+ defineProps<{
28
+ label: string;
29
+ id?: string;
30
+ title?: string;
31
+ modelValue: boolean;
32
+ editMode?: boolean;
33
+ small?: boolean;
34
+ }>(),
35
+ {
36
+ editMode: true,
37
+ id: Math.random().toString(36).substring(7),
38
+ },
39
+ );
40
+
41
+ const inputVal = ref(false);
42
+ watch(inputVal, (newVal) => {
43
+ if (newVal === undefined) return;
44
+ emits('update:modelValue', newVal);
45
+ });
46
+ watch(
47
+ () => props.modelValue,
48
+ (newVal) => {
49
+ if (inputVal.value !== newVal) inputVal.value = newVal;
50
+ },
51
+ );
52
+ onMounted(() => (inputVal.value = !!props.modelValue));
53
+ </script>
54
+
55
+ <style scoped>
56
+ .bgl-checkbox{
57
+ position: relative;
58
+ }
59
+ .bgl-checkbox input[type=checkbox]{
60
+ display: none;
61
+ }
62
+ .bgl-checkbox label{
63
+ padding-inline-start: calc(var(--input-height) + 0.25rem);
64
+ transition: var(--bgl-transition);
65
+ cursor: pointer;
66
+ user-select: none;
67
+ }
68
+ .bgl-checkbox:hover{
69
+ filter: brightness(90%);
70
+ }
71
+ .bgl-checkbox:active{
72
+ filter: var(--bgl-active-filter);
73
+ }
74
+
75
+ .switch {
76
+ position: absolute;
77
+ display: inline-block;
78
+ height: calc(var(--input-height) / 2);
79
+ width: var(--input-height);
80
+ border-radius: var(--input-height);
81
+ background: var(--bgl-gray);
82
+ outline: 1px solid var(--bgl-black);
83
+ margin-top: 0.15rem;
84
+ pointer-events: none;
85
+ }
86
+
87
+ .switch input {
88
+ opacity: 0;
89
+ width: 0;
90
+ height: 0;
91
+ }
92
+
93
+ .slider {
94
+ position: absolute;
95
+ cursor: pointer;
96
+ top: 0;
97
+ left: 0;
98
+ right: 0;
99
+ bottom: 0;
100
+ background: var(--input-bg);
101
+ -webkit-transition: 0.4s;
102
+ transition: 0.4s;
103
+ border-radius: calc(var(--input-height) / 2);
104
+ box-shadow: inset 0 0 10px #00000020;
105
+ }
106
+
107
+ .slider:before {
108
+ position: absolute;
109
+ content: "";
110
+ height: calc(var(--input-height) / 2 - 4px);
111
+ width: calc(var(--input-height) / 2 - 4px);
112
+ left: 2px;
113
+ bottom: 2px;
114
+ border-radius: 50%;
115
+ background: var(--bgl-white);
116
+ -webkit-transition: 0.4s;
117
+ transition: 0.4s;
118
+ }
119
+
120
+ input:checked + .slider {
121
+ background: var(--bgl-primary);
122
+ }
123
+
124
+ input:checked + .slider:before {
125
+ transform: translateX(calc(var(--input-height) / 2));
126
+ }
127
+ </style>