@bagelink/vue 0.0.204 → 0.0.211

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 (36) hide show
  1. package/dist/components/Btn.vue.d.ts +3 -0
  2. package/dist/components/Btn.vue.d.ts.map +1 -1
  3. package/dist/components/ModalBglForm.vue.d.ts +45 -0
  4. package/dist/components/ModalBglForm.vue.d.ts.map +1 -0
  5. package/dist/components/TabbedLayout.vue.d.ts +5 -3
  6. package/dist/components/TabbedLayout.vue.d.ts.map +1 -1
  7. package/dist/components/form/BglField.vue.d.ts.map +1 -1
  8. package/dist/components/form/index.d.ts +1 -0
  9. package/dist/components/form/index.d.ts.map +1 -1
  10. package/dist/components/form/inputs/RadioPillsInput.vue.d.ts +5 -3
  11. package/dist/components/form/inputs/RadioPillsInput.vue.d.ts.map +1 -1
  12. package/dist/components/index.d.ts +1 -0
  13. package/dist/components/index.d.ts.map +1 -1
  14. package/dist/index.cjs +303 -183
  15. package/dist/index.mjs +303 -183
  16. package/dist/plugins/modal.d.ts +3 -1
  17. package/dist/plugins/modal.d.ts.map +1 -1
  18. package/dist/style.css +68 -47
  19. package/dist/types/BagelForm.d.ts +2 -0
  20. package/dist/types/BagelForm.d.ts.map +1 -1
  21. package/dist/types/BtnOptions.d.ts +1 -0
  22. package/dist/types/BtnOptions.d.ts.map +1 -1
  23. package/dist/types/materialIcons.d.ts +1 -1
  24. package/dist/types/materialIcons.d.ts.map +1 -1
  25. package/package.json +1 -1
  26. package/src/components/Btn.vue +1 -0
  27. package/src/components/ModalBglForm.vue +121 -0
  28. package/src/components/TabbedLayout.vue +58 -45
  29. package/src/components/form/BglField.vue +1 -0
  30. package/src/components/form/index.ts +1 -0
  31. package/src/components/form/inputs/RadioPillsInput.vue +20 -14
  32. package/src/components/index.ts +1 -0
  33. package/src/plugins/modal.ts +16 -8
  34. package/src/types/BagelForm.ts +2 -0
  35. package/src/types/BtnOptions.ts +1 -1
  36. package/src/types/materialIcons.ts +1 -0
@@ -0,0 +1,121 @@
1
+ <template>
2
+ <div
3
+ class="bg-dark"
4
+ :class="{ 'is-side': side, 'is-active': isActive }"
5
+ @click="() => (dismissable ? closeModal() : '')"
6
+ @keydown.esc="closeModal"
7
+ >
8
+ <div
9
+ class="card modal"
10
+ @click.stop
11
+ >
12
+ <header class="tool-bar">
13
+ <slot name="toolbar" />
14
+ <Btn
15
+ :style="{ float: side ? 'left' : 'right' }"
16
+ flat
17
+ icon="close"
18
+ @click="closeModal"
19
+ />
20
+ <h3 class="modal-title">
21
+ {{ title }}
22
+ </h3>
23
+ </header>
24
+ <BagelForm
25
+ :onDelete="onDelete ? runDelete : undefined"
26
+ :modelValue="modelValue"
27
+ @update:modelValue="handleEmit"
28
+ @submit="runSubmit"
29
+ :schema="computedFormSchema"
30
+ />
31
+ </div>
32
+ </div>
33
+ </template>
34
+
35
+ <script lang="ts" setup>
36
+ import { onMounted, onUnmounted } from 'vue';
37
+ import {
38
+ Btn, BtnOptions, useEscape, BagelForm,
39
+ } from '@bagelink/vue';
40
+ import '../styles/modal.css';
41
+ import { BglFormSchemaT } from 'dist';
42
+
43
+ const props = defineProps<{
44
+ side?: boolean;
45
+ title?: string;
46
+ dismissable?: boolean;
47
+ actions?: BtnOptions[];
48
+ schema: BglFormSchemaT | (() => BglFormSchemaT);
49
+ modelValue?: Record<string, any>;
50
+ // eslint-disable-next-line no-unused-vars
51
+ onSubmit?: ((formData: any) => Promise<void>);
52
+ // eslint-disable-next-line no-unused-vars
53
+ onDelete?: ((id: string) => void);
54
+ }>();
55
+
56
+ const computedFormSchema = $computed(() => {
57
+ if (typeof props.schema === 'function') {
58
+ return props.schema();
59
+ }
60
+ return props.schema;
61
+ });
62
+
63
+ let isActive = $ref<boolean>(false);
64
+
65
+ const emit = defineEmits(['update:isModalVisible', 'update:modelValue']);
66
+ const handleEmit = (value: any) => {
67
+ emit('update:modelValue', value);
68
+ };
69
+
70
+ const closeModal = () => {
71
+ isActive = false;
72
+ setTimeout(() => {
73
+ emit('update:isModalVisible', false);
74
+ }, 200);
75
+ };
76
+
77
+ const runSubmit = async (formData: any) => {
78
+ try {
79
+ await props.onSubmit?.(formData);
80
+ closeModal();
81
+ } catch (err) {
82
+ console.error(err);
83
+ }
84
+ };
85
+
86
+ const runDelete = () => {
87
+ props.onDelete?.(props.modelValue?.id);
88
+ closeModal();
89
+ };
90
+
91
+ const escapeKeyClose = (e: KeyboardEvent) => props?.dismissable && useEscape(e, () => closeModal());
92
+
93
+ onMounted(() => {
94
+ setTimeout(() => {
95
+ isActive = true;
96
+ }, 1);
97
+
98
+ document.addEventListener(
99
+ 'keydown',
100
+ escapeKeyClose,
101
+ );
102
+ });
103
+ onUnmounted(() => {
104
+ document.removeEventListener(
105
+ 'keydown',
106
+ escapeKeyClose,
107
+ );
108
+ });
109
+ </script>
110
+
111
+ <style scoped>
112
+ .modal-title {
113
+ margin-top: 0.5rem;
114
+ }
115
+
116
+ @media screen and (max-width: 910px) {
117
+ .modal-title {
118
+ margin-top: 1rem;
119
+ }
120
+ }
121
+ </style>
@@ -1,65 +1,65 @@
1
1
  <template>
2
- <div class="h-100 grid list-view gap-3">
3
- <div class="card tabs-top">
4
- <slot name="top-section" />
5
- <div class="tabs grid auto-flow-columns fit-content">
6
- <div
7
- v-for="tab in tabs"
8
- :class="{
9
- active:
10
- tab === activeTab ||
11
- tab === router.currentRoute.value.path.split('/').slice(-1)[0],
12
- }"
13
- class="tab"
14
- :key="tab"
15
- @click="changeTab(tab)"
16
- >
17
- {{ tab }}
18
- </div>
19
- </div>
20
- </div>
21
- <!-- <TransitionRouterView v-if="baseRoute" /> -->
22
- <div
23
- class="list-content"
24
- v-for="tab in tabs.filter((item) => item === activeTab)"
25
- :key="tab"
26
- >
27
- <slot :name="tab" :key="tab" />
28
- </div>
29
- </div>
2
+ <div class="h-100 grid list-view gap-3" :class="{'side-tabs': sideTabs}">
3
+ <div class="card tabs-top">
4
+ <slot name="top-section" />
5
+ <div class="tabs grid auto-flow-columns fit-content">
6
+ <div
7
+ v-for="tab in tabs"
8
+ :class="{
9
+ active:
10
+ tab === activeTab ||
11
+ tab === router?.currentRoute.value.path.split('/').slice(-1)[0],
12
+ }"
13
+ class="tab"
14
+ :key="tab"
15
+ @click="changeTab(tab)"
16
+ >
17
+ {{ tab }}
18
+ </div>
19
+ </div>
20
+ </div>
21
+ <div
22
+ class="list-content"
23
+ v-for="tab in tabs.filter((item) => item === activeTab)"
24
+ :key="tab"
25
+ >
26
+ <slot :name="tab" :key="tab" />
27
+ </div>
28
+ </div>
30
29
  </template>
31
30
 
32
31
  <script setup lang="ts">
33
- import { onMounted } from "vue";
34
- import type { Router } from "vue-router";
32
+ import { onMounted } from 'vue';
33
+ import type { Router } from 'vue-router';
35
34
 
36
- const emit = defineEmits(["update:modelValue"]);
35
+ const emit = defineEmits(['update:modelValue']);
37
36
 
38
37
  let activeTab = $ref<string>();
39
38
  const props = defineProps<{
40
39
  title?: string;
41
40
  tabs: string[];
42
41
  modelValue?: string;
43
- router: Router;
42
+ router?: Router;
43
+ sideTabs?: boolean;
44
44
  }>();
45
45
 
46
46
  function changeTab(tab: string) {
47
- const { router } = props;
48
- activeTab = tab;
49
- void router.push({
50
- path: router.currentRoute.value.path,
51
- query: { ...router.currentRoute.value.query, t: tab },
52
- hash: router.currentRoute.value.hash,
53
- });
54
- emit("update:modelValue", activeTab);
47
+ activeTab = tab;
48
+ emit('update:modelValue', activeTab);
49
+ if (!props.router) return;
50
+ void props.router?.push({
51
+ path: props.router.currentRoute.value.path,
52
+ query: { ...props.router.currentRoute.value.query, t: tab },
53
+ hash: props.router.currentRoute.value.hash,
54
+ });
55
55
  }
56
56
 
57
57
  onMounted(() => {
58
- const firstTab =
58
+ const firstTab =
59
59
  props.modelValue ||
60
- props.router.currentRoute.value.query.t ||
60
+ props.router?.currentRoute.value.query.t ||
61
61
  props.tabs[0];
62
- activeTab = firstTab as string;
62
+ activeTab = firstTab as string;
63
63
  });
64
64
  </script>
65
65
 
@@ -68,7 +68,20 @@ onMounted(() => {
68
68
  text-transform: capitalize;
69
69
  }
70
70
 
71
- .card.tabs-top {
72
- /* width: 99%; */
71
+ .side-tabs{
72
+ display: flex;
73
+ }
74
+ .side-tabs .tabs-top{
75
+ margin-inline-end: 1rem;
76
+ }
77
+ .side-tabs .tabs{
78
+ display: block;
79
+ padding: 0;
80
+ margin: 0;
81
+ border: none;
82
+ }
83
+
84
+ .side-tabs .tab{
85
+ border: none;
73
86
  }
74
87
  </style>
@@ -4,6 +4,7 @@
4
4
  v-bind="bindAttrs(field?.attrs||{}, props.modelValue[field.id || ''], props.modelValue,)"
5
5
  :is="field.$el || 'div'"
6
6
  :label="field.label"
7
+ :id="field.id"
7
8
  :placeholder="field.placeholder || field.label"
8
9
  :modelValue="props.modelValue[field.id || '']"
9
10
  @update:modelValue="($event:any)=>emits('update:modelValue', $event)"
@@ -2,5 +2,6 @@ export { default as ItemRef } from './ItemRef.vue';
2
2
  export { default as MaterialIcon } from './MaterialIcon.vue';
3
3
  export { default as PlainInputField } from './PlainInputField.vue';
4
4
  export { default as BglForm } from './BglForm.vue';
5
+ export { default as BagelForm } from './BglForm.vue';
5
6
  export { default as BglField } from './BglField.vue';
6
7
  export * from './inputs';
@@ -1,15 +1,20 @@
1
1
  <template>
2
- <div class="flex gap-2 flex-wrap">
3
- <div class="radio-pill" v-for="({id,label,value}, index) in cumputedOptions" :key="index">
4
- <input
5
- type="radio"
6
- :id="id"
7
- :name="name"
8
- :value="value"
9
- :checked="selectedValue === value"
10
- @change="handleSelect"
11
- >
12
- <label :for="id">{{ label }}</label>
2
+ <div class="bagel-input">
3
+ <label class="pb-025" >
4
+ {{ label }}
5
+ </label>
6
+ <div class="flex gap-2 flex-wrap">
7
+ <div class="radio-pill" v-for="({optioId,label,value}, index) in cumputedOptions" :key="index">
8
+ <input
9
+ type="radio"
10
+ :id="optioId"
11
+ :name="id"
12
+ :value="value"
13
+ :checked="selectedValue === value"
14
+ @change="handleSelect"
15
+ >
16
+ <label :for="optioId">{{ label }}</label>
17
+ </div>
13
18
  </div>
14
19
  </div>
15
20
  </template>
@@ -18,7 +23,7 @@
18
23
  import { onMounted, watch } from 'vue';
19
24
 
20
25
  interface RadioOption {
21
- id: string;
26
+ optioId: string;
22
27
  label: string;
23
28
  value: any;
24
29
  }
@@ -28,11 +33,12 @@ const props = defineProps<{
28
33
  options?: RadioOption[],
29
34
  stringOptions: string[],
30
35
  modelValue: any,
31
- name: string,
36
+ id?: string,
37
+ label?: string,
32
38
  }>();
33
39
 
34
40
  const cumputedOptions = $computed(() => props.options || props.stringOptions.map((v) => ({
35
- id: v,
41
+ optioId: v,
36
42
  label: v,
37
43
  value: v,
38
44
  })));
@@ -4,6 +4,7 @@ export { default as MaterialIcon } from './MaterialIcon.vue';
4
4
  export { default as NavBar } from './NavBar.vue';
5
5
  export { default as Btn } from './Btn.vue';
6
6
  export { default as Modal } from './Modal.vue';
7
+ export { default as ModalBglForm } from './ModalBglForm.vue';
7
8
  export { default as DropDown } from './DropDown.vue';
8
9
  export { default as ListView } from './ListView.vue';
9
10
  export { default as ListItem } from './ListItem.vue';
@@ -3,8 +3,9 @@ import {
3
3
  } from 'vue';
4
4
  import type { Plugin } from 'vue';
5
5
  import type { BtnOptions } from '@bagelink/vue';
6
- import { Modal, ModalForm } from '@bagelink/vue';
6
+ import { Modal, ModalForm, ModalBglForm } from '@bagelink/vue';
7
7
  import type { FormKitSchemaDefinition } from '@formkit/core';
8
+ import { BglFormSchemaT } from 'dist/types';
8
9
 
9
10
  interface ModalOptions {
10
11
  title?: string;
@@ -22,13 +23,15 @@ interface ModalFormOptions extends ModalOptions {
22
23
  onSubmit: (val: any) => void;
23
24
  // eslint-disable-next-line no-unused-vars
24
25
  onDelete?: (id: string) => void;
25
- schema: FormKitSchemaDefinition;
26
+ schema: FormKitSchemaDefinition | BglFormSchemaT;
26
27
  }
27
28
 
28
29
  interface ModalApi {
29
30
  // eslint-disable-next-line no-unused-vars
30
31
  showModal: (options: ModalOptions, slots?: Record<string, any>) => void;
31
32
  // eslint-disable-next-line no-unused-vars
33
+ showModalForm: (options: ModalFormOptions, slots?: Record<string, any>) => void;
34
+ // eslint-disable-next-line no-unused-vars
32
35
  modalForm: (options: ModalFormOptions, slots?: Record<string, any>) => void;
33
36
  // eslint-disable-next-line no-unused-vars
34
37
  hideModal: (index?: number) => void;
@@ -45,7 +48,7 @@ export const useModal = (): ModalApi => {
45
48
 
46
49
  interface ModalComponentProps {
47
50
  componentSlots: Record<string, any>,
48
- isModalForm: boolean,
51
+ modalType: 0 | 1 | 2,
49
52
  modalOptions: ModalOptions | ModalFormOptions
50
53
  }
51
54
 
@@ -59,20 +62,21 @@ export const ModalPlugin: Plugin = {
59
62
  };
60
63
 
61
64
  const showModal = (
62
- isForm: boolean,
65
+ modalType: 0 | 1 | 2,
63
66
  options: ModalOptions | ModalFormOptions,
64
67
  slots: Record<string, any> = {},
65
68
  ) => {
66
69
  modalStack.push({
67
70
  modalOptions: options,
68
- isModalForm: isForm,
71
+ modalType,
69
72
  componentSlots: slots,
70
73
  });
71
74
  };
72
75
 
73
76
  app.provide(ModalSymbol, {
74
- modalForm: (options: ModalFormOptions, slots?: Record<string, any>) => showModal(true, options, slots),
75
- showModal: (options: ModalOptions, slots?: Record<string, any>) => showModal(false, options, slots),
77
+ modalForm: (options: ModalFormOptions, slots?: Record<string, any>) => showModal(1, options, slots),
78
+ showModal: (options: ModalOptions, slots?: Record<string, any>) => showModal(0, options, slots),
79
+ showModalForm: (options: ModalFormOptions, slots?: Record<string, any>) => showModal(2, options, slots),
76
80
  hideModal: (index = modalStack.length - 1) => hideModal(index),
77
81
  // modalOptions,
78
82
  });
@@ -85,7 +89,11 @@ export const ModalPlugin: Plugin = {
85
89
  },
86
90
  render() {
87
91
  return modalStack.map((modal, index) => {
88
- const renderComponent = modal.isModalForm ? ModalForm : Modal;
92
+ let renderComponent;
93
+ if (modal.modalType === 1) renderComponent = ModalForm;
94
+ else if (modal.modalType === 2) renderComponent = ModalBglForm;
95
+ else renderComponent = Modal;
96
+
89
97
  return h(
90
98
  renderComponent,
91
99
  {
@@ -14,6 +14,8 @@ export type Field<T = Record<string, any>> = {
14
14
  children?: Field<T>[];
15
15
  attrs?: Attributes<T>;
16
16
  required?: boolean;
17
+ hint?: string;
18
+ 'v-if'?: string | boolean | ((val: any, row: T) => boolean);
17
19
  }
18
20
 
19
21
  export interface SelectBagelField {
@@ -12,5 +12,5 @@ export interface BtnOptions {
12
12
  loading?: boolean;
13
13
  role?: string;
14
14
  value?: string;
15
-
15
+ border?: boolean;
16
16
  }
@@ -528,6 +528,7 @@ export type MaterialIcons =
528
528
  | 'check_in_out'
529
529
  | 'check_indeterminate_small'
530
530
  | 'check_small'
531
+ | 'checkbook'
531
532
  | 'checklist'
532
533
  | 'checklist_rtl'
533
534
  | 'checkroom'