@bagelink/vue 0.0.342 → 0.0.348

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 (43) hide show
  1. package/dist/components/Card.vue.d.ts +2 -2
  2. package/dist/components/Modal.vue.d.ts +1 -0
  3. package/dist/components/RouterWrapper.vue.d.ts.map +1 -1
  4. package/dist/components/form/BglForm.vue.d.ts +7 -1
  5. package/dist/components/form/BglForm.vue.d.ts.map +1 -1
  6. package/dist/components/form/inputs/DateInput.vue.d.ts +1 -0
  7. package/dist/components/form/inputs/RichText.vue.d.ts +20 -0
  8. package/dist/components/form/inputs/RichText.vue.d.ts.map +1 -0
  9. package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
  10. package/dist/components/form/inputs/index.d.ts +1 -1
  11. package/dist/components/form/inputs/index.d.ts.map +1 -1
  12. package/dist/components/index.d.ts +0 -2
  13. package/dist/components/index.d.ts.map +1 -1
  14. package/dist/components/layout/BottomMenu.vue.d.ts +24 -0
  15. package/dist/components/layout/BottomMenu.vue.d.ts.map +1 -0
  16. package/dist/components/layout/TabsNav.vue.d.ts.map +1 -1
  17. package/dist/components/layout/index.d.ts +1 -0
  18. package/dist/components/layout/index.d.ts.map +1 -1
  19. package/dist/index.cjs +32865 -24539
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.mjs +32866 -24540
  22. package/dist/style.css +166 -225
  23. package/dist/types/materialIcons.d.ts +1 -1
  24. package/dist/types/materialIcons.d.ts.map +1 -1
  25. package/package.json +4 -8
  26. package/src/components/RouterWrapper.vue +6 -4
  27. package/src/components/form/inputs/RichText.vue +219 -0
  28. package/src/components/form/inputs/SelectInput.vue +123 -122
  29. package/src/components/form/inputs/index.ts +1 -1
  30. package/src/components/index.ts +0 -2
  31. package/src/components/layout/BottomMenu.vue +64 -0
  32. package/src/components/layout/SidebarMenu.vue +2 -1
  33. package/src/components/layout/Tabs.vue +4 -4
  34. package/src/components/layout/TabsNav.vue +36 -14
  35. package/src/components/layout/index.ts +1 -0
  36. package/src/styles/layout.css +11 -0
  37. package/src/styles/mobilLayout.css +10 -0
  38. package/src/styles/theme.css +0 -1
  39. package/src/styles/transitions.css +4 -0
  40. package/src/types/materialIcons.ts +2069 -6
  41. package/src/components/Comments.vue +0 -268
  42. package/src/components/RTXEditor.vue +0 -151
  43. package/src/components/form/inputs/RichTextEditor.vue +0 -56
@@ -1,268 +0,0 @@
1
- <template>
2
- <div class="comments-wrap">
3
- <div class="comment-list">
4
- <div
5
- :class="{
6
- editable: editComment?.id === comment.id,
7
- me: comment.sender.id === bagel.auth.user?.id,
8
- }"
9
- class="comment"
10
- v-for="comment in comments"
11
- :key="comment.id"
12
- >
13
- <div class="comment-top">
14
- <div class="comment-owner">
15
- {{ comment.sender.first_name }} {{ comment.sender.last_name }}
16
- </div>
17
- <div class="comment-time">
18
- {{ comment.updated_at.split("T")[0] }}
19
- </div>
20
- <div class="comment-actions">
21
- <MaterialIcon
22
- :size="1"
23
- class="edit"
24
- icon="edit"
25
- @click="editComment = comment"
26
- />
27
- <MaterialIcon
28
- :size="1.2"
29
- class="delete"
30
- icon="delete"
31
- @click="deleteComment(comment.id)"
32
- />
33
- <MaterialIcon :size="1.2" class="save" icon="save" @click="save" />
34
- </div>
35
- </div>
36
- <RTXEditor
37
- v-model="editComment.body_html"
38
- @keydown.meta.enter="save"
39
- v-if="editComment !== null && editComment?.id === comment.id"
40
- />
41
- <div class="editor-wrapper" v-html="comment.body_html" v-else />
42
- </div>
43
- </div>
44
- <div class="new-comment">
45
- <RTXEditor
46
- class="comment-input"
47
- v-model="bodyHtml"
48
- @keydown.meta.enter="newComment"
49
- />
50
- <Btn icon="send" @click="newComment">
51
- {{ sendBtnLabel }}
52
- </Btn>
53
- </div>
54
- </div>
55
- </template>
56
-
57
- <script lang="ts" setup>
58
- import { onMounted, watch } from 'vue';
59
- import { Btn, MaterialIcon, RTXEditor } from '@bagelink/vue';
60
- import { useBagel } from '..';
61
-
62
- const bagel = useBagel();
63
- let comments = $ref<Record<string, any>>([]);
64
-
65
- interface Comment {
66
- id: string;
67
- ref_table: string;
68
- ref_id: string;
69
- body_html: string;
70
- type: 'Comment';
71
- created_at: string;
72
- updated_at: string;
73
- }
74
- let editComment = $ref<Comment | null>(null);
75
-
76
- const props = defineProps<{
77
- ref_table: string;
78
- ref_id: string;
79
- sendBtnLabel: string;
80
- }>();
81
-
82
- const fetchData = async () => {
83
- comments = [];
84
- comments = await bagel.get(`comments/${props.ref_table}/${props.ref_id}`);
85
- };
86
-
87
- onMounted(fetchData);
88
- watch(() => props.ref_id, fetchData);
89
-
90
- const save = async () => {
91
- if (!editComment) return;
92
- await bagel.put(`comments/${editComment.id}`, editComment);
93
- void fetchData(); // TODO: Nati: should be awaited?
94
- editComment = null;
95
- };
96
-
97
- let bodyHtml = $ref('');
98
-
99
- const deleteComment = async (id: string) => {
100
- await bagel.delete(`comments/${id}`);
101
- void fetchData(); // TODO: Nati: should be awaited?
102
- };
103
-
104
- const newComment = async () => {
105
- if (!bodyHtml) return;
106
- await bagel.post('comments', {
107
- ref_table: props.ref_table,
108
- ref_id: props.ref_id,
109
- body_html: bodyHtml,
110
- type: 'Comment',
111
- });
112
- bodyHtml = '';
113
- void fetchData(); // TODO: Nati: should be awaited?
114
- };
115
- </script>
116
-
117
- <style scoped>
118
- .comments-wrap {
119
- display: grid;
120
- grid-template-rows: 1fr 40px;
121
- height: 100%;
122
- position: relative;
123
- gap: 0.5rem;
124
- }
125
-
126
- .comments-wrap p {
127
- margin: 0;
128
- }
129
-
130
- .comments-wrap::before {
131
- content: "";
132
- inset-inline-start: 10px;
133
- top: 0px;
134
- width: 1px;
135
- background: var(--border-color);
136
- position: absolute;
137
- bottom: 10px;
138
- }
139
-
140
- .comment-top {
141
- display: flex;
142
- align-items: baseline;
143
- flex-wrap: wrap;
144
- position: relative;
145
- margin-inline-start: 1rem;
146
- }
147
-
148
- .comment-list {
149
- padding: 0.5rem;
150
- height: 100%;
151
- overflow: auto;
152
- }
153
-
154
- .comment {
155
- margin-bottom: 1rem;
156
- }
157
-
158
- .comment-owner {
159
- font-size: 14px;
160
- margin-inline-end: 0.5rem;
161
- color: var(--bgl-gray);
162
- }
163
-
164
- .comment-owner::before {
165
- content: "";
166
- height: 12px;
167
- width: 12px;
168
- border-radius: 100%;
169
- position: absolute;
170
- background: var(--bgl-gray);
171
- inset-inline-start: -1.2rem;
172
- top: 0.2rem;
173
- }
174
-
175
- .me .comment-owner {
176
- color: var(--bgl-primary);
177
- }
178
-
179
- .me .comment-owner::before {
180
- background: var(--bgl-primary);
181
- }
182
-
183
- .comment-time {
184
- color: var(--bgl-gray);
185
- font-size: 10px;
186
- white-space: nowrap;
187
- }
188
-
189
- .comment-actions {
190
- background: red;
191
- line-height: 0;
192
- display: flex;
193
- padding: 0 0.5rem;
194
- flex-grow: 1;
195
- gap: 0.25rem;
196
- }
197
-
198
- .comment .comment-actions .edit {
199
- opacity: 0;
200
- }
201
-
202
- .comment-actions .edit {
203
- margin-inline-end: auto;
204
- }
205
-
206
- .comment.me:hover .comment-actions .edit {
207
- opacity: 0.4;
208
- }
209
-
210
- .comment-actions > div {
211
- transition: all 200ms ease;
212
- cursor: pointer;
213
- opacity: 0.6;
214
- }
215
-
216
- .comment-actions > div:hover {
217
- color: var(--bgl-primary);
218
- }
219
-
220
- .comment-actions .delete:hover {
221
- color: var(--bgl-red);
222
- }
223
-
224
- .comment-actions > div:active {
225
- filter: brightness(70%);
226
- }
227
-
228
- .bgl_icon-font.delete,
229
- .bgl_icon-font.save {
230
- display: none;
231
- }
232
-
233
- .editable .bgl_icon-font.delete,
234
- .editable .bgl_icon-font.save {
235
- display: block;
236
- }
237
-
238
- /* .editor-wrapper { */
239
- /* margin-inline-start: 0.5rem; */
240
- /* margin-top: 0.05em; */
241
- /* margin-bottom: 0.05em; */
242
- /* height: 100%; */
243
- /* padding: 0.05em 0.5em; */
244
- /* overflow: hidden; */
245
- /* border-radius: 10px; */
246
- /* } */
247
- .editable .editor-wrapper {
248
- background-color: var(--input-bg);
249
- }
250
-
251
- .new-comment {
252
- display: flex;
253
- align-items: flex-end;
254
- position: relative;
255
- z-index: 2;
256
- gap: 0.5rem;
257
- font-size: 12px;
258
- color: var(--input-color);
259
- line-height: 1.6;
260
- }
261
-
262
- .comment-input {
263
- max-height: 100px;
264
- overflow: auto;
265
- flex-grow: 1;
266
- border-radius: var(--btn-border-radius);
267
- }
268
- </style>
@@ -1,151 +0,0 @@
1
- <template>
2
- <!-- :class="{ editable: editable }" -->
3
- <div
4
- @click="focusEditor"
5
- :id="`canvas-${elementId}`"
6
- @keydown.meta.enter="$emit('keydown.meta.enter')"
7
- />
8
- </template>
9
-
10
- <script setup lang="ts">
11
- import { ref, onMounted, watch } from 'vue';
12
- import { DOMParser, DOMSerializer } from 'prosemirror-model';
13
- import { EditorState } from 'prosemirror-state';
14
- import { EditorView } from 'prosemirror-view';
15
- import { keymap } from 'prosemirror-keymap';
16
- import { baseKeymap } from 'prosemirror-commands';
17
- import { undo, redo, history } from 'prosemirror-history';
18
- import { schema } from 'prosemirror-schema-basic';
19
-
20
- const props = withDefaults(
21
- defineProps<{
22
- elementId?: string;
23
- modelValue: string;
24
- }>(),
25
- {
26
- elementId: Math.random().toString(36).substr(2, 9),
27
- modelValue: '',
28
- },
29
- );
30
-
31
- const emit = defineEmits(['update:modelValue', 'keydown.meta.enter']);
32
-
33
- const html = ref<string>(props.modelValue);
34
- let view: EditorView;
35
-
36
- const createEditorStateFromHTML = (htmlContent: string) => {
37
- let content = { type: 'doc', content: [] };
38
- try {
39
- const dom = document.createElement('div');
40
- dom.innerHTML = htmlContent || '';
41
- content = DOMParser.fromSchema(schema)
42
- .parse(dom, { preserveWhitespace: true })
43
- .toJSON();
44
- } catch (err) {
45
- content = { type: 'doc', content: [] };
46
- }
47
-
48
- const state = EditorState.create({
49
- doc: DOMParser.fromSchema(schema).schema.nodeFromJSON(content),
50
- plugins: [
51
- history(),
52
- keymap({ 'Mod-z': undo, 'Mod-y': redo }),
53
- keymap(baseKeymap),
54
- ],
55
- });
56
-
57
- return state;
58
- };
59
-
60
- function handleChange(newState: any) {
61
- const dom = document.createElement('div');
62
- const node = DOMSerializer.fromSchema(schema).serializeFragment(newState);
63
- dom.appendChild(node);
64
- html.value = dom?.innerHTML || '';
65
- emit('update:modelValue', html.value);
66
- }
67
-
68
- const createEditorView = (state: EditorState) => {
69
- const editorDiv = document.getElementById(`canvas-${props.elementId}`);
70
- view = new EditorView(editorDiv, {
71
- state,
72
- // editable: () => props.editable,
73
- dispatchTransaction(transaction) {
74
- const newState = view.state.apply(transaction);
75
- handleChange(newState.doc);
76
- view.updateState(newState);
77
- },
78
- });
79
- view.setProps({
80
- // editable: () => props.editable,
81
- });
82
- };
83
-
84
- function loadContent() {
85
- const state = createEditorStateFromHTML(props.modelValue);
86
- createEditorView(state);
87
- }
88
-
89
- watch(
90
- () => props.modelValue,
91
- (val: string) => {
92
- if (val === html.value) return;
93
- const el = document.getElementById(`canvas-${props.elementId}`);
94
- if (el) el.innerHTML = '';
95
- loadContent();
96
- },
97
- );
98
-
99
- onMounted(loadContent);
100
-
101
- function focusEditor() {
102
- view.focus();
103
- }
104
- </script>
105
-
106
- <style>
107
- .new-comment .ProseMirror {
108
- width: 100%;
109
- height: 100%;
110
- border-radius: 3px;
111
- padding: 0.55rem;
112
- min-height: 40px;
113
- }
114
-
115
- .new-comment .ProseMirror p {
116
- margin: 0;
117
- }
118
-
119
- .comment-input .ProseMirror {
120
- background-color: var(--input-bg);
121
- margin-inline-start: 0;
122
- }
123
-
124
- .new-comment .editable {
125
- background-color: var(--input-bg);
126
- }
127
-
128
- .ProseMirror-focused {
129
- outline: none;
130
- border: none;
131
- box-shadow: inset 0 0 10px #00000012;
132
- }
133
-
134
- .ProseMirror,
135
- .editor-wrapper {
136
- height: 100%;
137
- border-radius: 3px;
138
- padding: 0.55rem;
139
- border-radius: var(--btn-border-radius);
140
- margin-inline-start: 1rem;
141
- }
142
-
143
- .ProseMirror p,
144
- .editor-wrapper p {
145
- margin: 0;
146
- }
147
-
148
- .editable .ProseMirror {
149
- background-color: var(--bgl-bg);
150
- }
151
- </style>
@@ -1,56 +0,0 @@
1
- <template>
2
- <div
3
- class="bagel-input"
4
- :title="description"
5
- :class="{ small: small }"
6
- >
7
- <label v-if="label">
8
- <LangText :input="label" />
9
- </label>
10
- <textarea
11
- :value="modelValue"
12
- @input="handleInput"
13
- :placeholder="placeholder"
14
- :class="{ 'no-edit': !editMode }"
15
- />
16
- </div>
17
- </template>
18
-
19
- <script setup lang="ts">
20
- const emits = defineEmits(['update:modelValue']);
21
-
22
- // const props =
23
- withDefaults(
24
- defineProps<{
25
- description?: string;
26
- label?: string;
27
- modelValue: any;
28
- placeholder?: string;
29
- editMode?: boolean;
30
- small?: boolean;
31
- }>(),
32
- {
33
- description: '',
34
- editMode: true,
35
- placeholder: '',
36
- label: '',
37
- },
38
- );
39
- const handleInput = (e: Event) => {
40
- const el = e.target as HTMLInputElement;
41
- emits('update:modelValue', el.value);
42
- };
43
- </script>
44
-
45
- <style scoped>
46
- .bagel-input {
47
- height: 100%;
48
- margin: 0;
49
- }
50
-
51
- .bagel-input textarea {
52
- height: 100%;
53
- resize: none;
54
- background: transparent;
55
- }
56
- </style>