@bagelink/vue 0.0.206 → 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.
Files changed (34) hide show
  1. package/dist/components/ModalBglForm.vue.d.ts +44 -0
  2. package/dist/components/ModalBglForm.vue.d.ts.map +1 -0
  3. package/dist/components/NavBar.vue.d.ts.map +1 -1
  4. package/dist/components/form/BglForm.vue.d.ts.map +1 -1
  5. package/dist/components/form/index.d.ts +1 -0
  6. package/dist/components/form/index.d.ts.map +1 -1
  7. package/dist/components/form/inputs/CheckInput.vue.d.ts +11 -4
  8. package/dist/components/form/inputs/CheckInput.vue.d.ts.map +1 -1
  9. package/dist/components/form/inputs/FileUpload.vue.d.ts.map +1 -1
  10. package/dist/components/index.d.ts +1 -0
  11. package/dist/components/index.d.ts.map +1 -1
  12. package/dist/index.cjs +252 -139
  13. package/dist/index.mjs +253 -140
  14. package/dist/plugins/modal.d.ts +3 -1
  15. package/dist/plugins/modal.d.ts.map +1 -1
  16. package/dist/style.css +153 -172
  17. package/dist/types/BagelForm.d.ts +2 -0
  18. package/dist/types/BagelForm.d.ts.map +1 -1
  19. package/dist/types/BtnOptions.d.ts +1 -0
  20. package/dist/types/BtnOptions.d.ts.map +1 -1
  21. package/package.json +1 -1
  22. package/src/components/ModalBglForm.vue +120 -0
  23. package/src/components/NavBar.vue +47 -45
  24. package/src/components/form/BglForm.vue +14 -12
  25. package/src/components/form/index.ts +1 -0
  26. package/src/components/form/inputs/CheckInput.vue +84 -110
  27. package/src/components/form/inputs/FileUpload.vue +52 -45
  28. package/src/components/form/inputs/ToggleInput.vue +127 -0
  29. package/src/components/formkit/Toggle.vue +22 -22
  30. package/src/components/index.ts +1 -0
  31. package/src/plugins/modal.ts +16 -8
  32. package/src/styles/theme.css +0 -8
  33. package/src/types/BagelForm.ts +2 -0
  34. package/src/types/BtnOptions.ts +1 -1
@@ -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>
@@ -1,36 +1,36 @@
1
1
  <template>
2
- <div
3
- class="bagel-input checkbox"
4
- :class="{ check: context?.attrs.isCheckbox }"
5
- :title="context?.help"
6
- >
7
- <label class="switch">
8
- <input
9
- @change="() => props.context?.node.input(inputVal)"
10
- type="checkbox"
11
- v-model="inputVal"
12
- :id="context?.id"
13
- />
14
- <span class="slider round" />
15
- </label>
16
- </div>
2
+ <div
3
+ class="bagel-input checkbox"
4
+ :class="{ check: context?.attrs.isCheckbox }"
5
+ :title="context?.help"
6
+ >
7
+ <label class="switch">
8
+ <input
9
+ @change="() => props.context?.node.input(inputVal)"
10
+ type="checkbox"
11
+ v-model="inputVal"
12
+ :id="context?.id"
13
+ >
14
+ <span class="slider round" />
15
+ </label>
16
+ </div>
17
17
  </template>
18
18
 
19
19
  <script setup lang="ts">
20
- import { watch } from "vue";
20
+ import { watch } from 'vue';
21
21
 
22
22
  const props = defineProps({
23
- context: Object,
23
+ context: Object,
24
24
  });
25
25
 
26
26
  let inputVal = $ref(false);
27
27
 
28
28
  watch(
29
- () => props.context?.value,
30
- (newVal) => {
31
- inputVal = newVal;
32
- },
33
- { immediate: true }
29
+ () => props.context?.value,
30
+ (newVal) => {
31
+ inputVal = newVal;
32
+ },
33
+ { immediate: true },
34
34
  );
35
35
  </script>
36
36
 
@@ -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
  {
@@ -8,7 +8,6 @@
8
8
  --bgl-primary: #2E5BFF;
9
9
  --bgl-primary-tint: #2E5BFF80;
10
10
  --bgl-primary-light: #eef6ff;
11
-
12
11
  --bgl-blue-20: rgba(46, 91, 255, 20%);
13
12
  --bgl-blue-dark: #191c30;
14
13
  --bgl-blue-light: #eef6ff;
@@ -107,13 +106,6 @@
107
106
  justify-content: flex-end;
108
107
  }
109
108
 
110
- body {
111
- background-color: var(--bgl-bg);
112
- color: var(--bgl-black);
113
- font-family: var(--bgl-font);
114
- overflow: hidden;
115
- }
116
-
117
109
  * {
118
110
  box-sizing: border-box;
119
111
  }
@@ -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
  }