@bagelink/vue 0.0.232-beta.0 → 0.0.233-beta.0

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 (71) hide show
  1. package/dist/components/AccordionItem.vue.d.ts.map +1 -1
  2. package/dist/components/Card.vue.d.ts +2 -0
  3. package/dist/components/Card.vue.d.ts.map +1 -1
  4. package/dist/components/ModalBglForm.vue.d.ts.map +1 -1
  5. package/dist/components/TableSchema.vue.d.ts +3 -39
  6. package/dist/components/TableSchema.vue.d.ts.map +1 -1
  7. package/dist/components/form/BglField.vue.d.ts.map +1 -1
  8. package/dist/components/form/BglForm.vue.d.ts +4 -0
  9. package/dist/components/form/BglForm.vue.d.ts.map +1 -1
  10. package/dist/components/form/inputs/CheckInput.vue.d.ts +9 -22
  11. package/dist/components/form/inputs/CheckInput.vue.d.ts.map +1 -1
  12. package/dist/components/form/inputs/Checkbox.vue.d.ts +4 -10
  13. package/dist/components/form/inputs/Checkbox.vue.d.ts.map +1 -1
  14. package/dist/components/form/inputs/ColorPicker.vue.d.ts +6 -2
  15. package/dist/components/form/inputs/ColorPicker.vue.d.ts.map +1 -1
  16. package/dist/components/form/inputs/DateInput.vue.d.ts +44 -35
  17. package/dist/components/form/inputs/DateInput.vue.d.ts.map +1 -1
  18. package/dist/components/form/inputs/FileUpload.vue.d.ts.map +1 -1
  19. package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
  20. package/dist/components/form/inputs/index.d.ts +0 -10
  21. package/dist/components/form/inputs/index.d.ts.map +1 -1
  22. package/dist/components/formkit/index.d.ts +1 -13
  23. package/dist/components/formkit/index.d.ts.map +1 -1
  24. package/dist/components/index.d.ts +0 -1
  25. package/dist/components/index.d.ts.map +1 -1
  26. package/dist/index.cjs +1101 -3976
  27. package/dist/index.mjs +1102 -3977
  28. package/dist/plugins/bagel.d.ts +1 -1
  29. package/dist/plugins/bagel.d.ts.map +1 -1
  30. package/dist/plugins/modal.d.ts +1 -2
  31. package/dist/plugins/modal.d.ts.map +1 -1
  32. package/dist/style.css +266 -1014
  33. package/dist/types/BagelForm.d.ts +2 -3
  34. package/dist/types/BagelForm.d.ts.map +1 -1
  35. package/package.json +1 -1
  36. package/src/components/AccordionItem.vue +25 -53
  37. package/src/components/Card.vue +2 -1
  38. package/src/components/ModalBglForm.vue +6 -22
  39. package/src/components/TableSchema.vue +1 -3
  40. package/src/components/form/BglField.vue +15 -3
  41. package/src/components/form/BglForm.vue +19 -18
  42. package/src/components/form/inputs/CheckInput.vue +17 -24
  43. package/src/components/form/inputs/Checkbox.vue +3 -24
  44. package/src/components/form/inputs/ColorPicker.vue +8 -19
  45. package/src/components/form/inputs/DateInput.vue +21 -2
  46. package/src/components/form/inputs/FileUpload.vue +11 -23
  47. package/src/components/form/inputs/SelectInput.vue +9 -11
  48. package/src/components/form/inputs/index.ts +0 -10
  49. package/src/components/formkit/index.ts +19 -27
  50. package/src/components/index.ts +0 -1
  51. package/src/plugins/bagel.ts +6 -6
  52. package/src/plugins/modal.ts +1 -2
  53. package/src/styles/modal.css +59 -57
  54. package/src/styles/theme.css +0 -18
  55. package/src/types/BagelForm.ts +7 -11
  56. package/src/components/ContactArray.vue +0 -113
  57. package/src/components/Drop.vue +0 -150
  58. package/src/components/form/inputs/CurrencyInput.vue +0 -137
  59. package/src/components/form/inputs/DatetimeInput.vue +0 -49
  60. package/src/components/form/inputs/DurationInput.vue +0 -55
  61. package/src/components/form/inputs/FloatInput.vue +0 -53
  62. package/src/components/form/inputs/IntInput.vue +0 -52
  63. package/src/components/form/inputs/LinkField.vue +0 -300
  64. package/src/components/form/inputs/Password.vue +0 -90
  65. package/src/components/form/inputs/PasswordInput.vue +0 -85
  66. package/src/components/form/inputs/PlainText.vue +0 -63
  67. package/src/components/form/inputs/ReadOnlyInput.vue +0 -28
  68. package/src/components/form/inputs/SelectField.vue +0 -202
  69. package/src/components/formkit/AddressArray.vue +0 -250
  70. package/src/components/formkit/BankDetailsArray.vue +0 -274
  71. package/src/components/formkit/ContactArrayFormKit.vue +0 -203
@@ -1,10 +1,9 @@
1
- import type { RequireAllOrNone } from 'type-fest';
2
1
  export type AttributeValue = string | number | boolean | null | undefined | Record<string, any>;
3
2
  export type AttributeFn<T = Record<string, any>> = (field: any, row: T) => AttributeValue;
4
3
  export interface Attributes<T = any> {
5
4
  [key: string]: AttributeValue | AttributeFn<T>;
6
5
  }
7
- export type Field<T = Record<string, any>> = RequireAllOrNone<{
6
+ export type Field<T = Record<string, any>> = {
8
7
  $el?: any;
9
8
  id?: string;
10
9
  label?: string;
@@ -22,7 +21,7 @@ export type Field<T = Record<string, any>> = RequireAllOrNone<{
22
21
  transform?: (val?: any, rowData?: Record<string, any>) => any;
23
22
  onUpdate?: (val: any, fieldData?: any, rowData?: Record<string, any>) => void;
24
23
  'v-if'?: string | boolean | ((val: any, row: T) => boolean);
25
- }, 'id' | '$el'>;
24
+ };
26
25
  export interface SelectBagelField {
27
26
  inputType: 'SelectField';
28
27
  options: string | {
@@ -1 +1 @@
1
- {"version":3,"file":"BagelForm.d.ts","sourceRoot":"","sources":["../../src/types/BagelForm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAElD,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAEhG,MAAM,MAAM,WAAW,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,KAAK,cAAc,CAAC;AAE1F,MAAM,WAAW,UAAU,CAAC,CAAC,GAAG,GAAG;IACjC,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;CAC/C;AAED,MAAM,MAAM,KAAK,CAAC,CAAC,GAAG,MAA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AAC,CAAC,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,GAAG,CAAC;IAC9D,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IAC9E,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC;CAC7D,CAAA;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,aAAa,CAAC;IACzB,OAAO,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,EAAE,CAAC;CAC/D;AAED,MAAM,MAAM,cAAc,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/vue",
3
3
  "type": "module",
4
- "version": "0.0.232-beta.0",
4
+ "version": "0.0.233-beta.0",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Neveh Allon",
@@ -1,14 +1,16 @@
1
1
  <template>
2
2
  <div class="accordion-item">
3
- <div class="accordion-title" @click="toggle()">
3
+ <div class="accordion-head" @click="toggle()">
4
4
  {{ label }}
5
5
  <div class="accordion-icon" :class="{open}" >
6
- <MaterialIcon icon="keyboard_arrow_down" />
6
+ <MaterialIcon icon="expand_more" />
7
7
  </div>
8
8
  </div>
9
- <div v-if="open" class="accordion-content" >
10
- <slot />
11
- </div>
9
+ <Transition name="expand">
10
+ <div v-if="open" class="accordion-body">
11
+ <slot />
12
+ </div>
13
+ </Transition>
12
14
  </div>
13
15
  </template>
14
16
 
@@ -29,36 +31,13 @@ function toggle() {
29
31
 
30
32
  <style scoped>
31
33
  .accordion-item {
32
- border-top: 1px solid var(--bgl-gray);
33
- border-bottom: 1px solid var(--bgl-gray);
34
- width: 100%;
35
- max-width: 100%;
36
- margin: -1 auto 0;
37
- border-radius: 0;
38
- background: transparent;
39
- color: #000;
40
- font-size: 1rem;
41
- font-weight: 400;
42
- text-align: left;
34
+ border-bottom: 1px solid var(--border-color);
43
35
  transition: all 0.2s ease;
36
+ cursor: pointer;
44
37
  overflow: hidden;
45
38
  }
46
39
 
47
- .accordion-title {
48
- width: 100%;
49
- max-width: 100%;
50
- margin: 0 auto;
51
- padding: 0;
52
- border: 0;
53
- border-radius: 0;
54
- background: transparent;
55
- color: #000;
56
- font-size: 1rem;
57
- font-weight: 400;
58
- line-height: 1.5;
59
- text-align: left;
60
- transition: all 0.2s ease;
61
- cursor: pointer;
40
+ .accordion-head {
62
41
  height: var( --input-height);
63
42
  display: flex;
64
43
  align-items: center;
@@ -71,30 +50,23 @@ function toggle() {
71
50
  .accordion-icon.open {
72
51
  transform: rotate(180deg);
73
52
  }
53
+ </style>
74
54
 
75
- .accordion-content {
76
- width: 100%;
77
- max-width: 100%;
78
- margin: 0 auto;
79
- padding: 0;
80
- border: 0;
81
- border-radius: 0;
82
- background: transparent;
83
- color: #000;
84
- font-size: 1rem;
85
- font-weight: 400;
86
- line-height: 1.5;
87
- text-align: left;
88
- transition: all 0.2s ease;
55
+ <style>
56
+ .expand-enter-active,
57
+ .expand-leave-active {
58
+ transition: all 0.5s;
59
+ }
60
+
61
+ .expand-enter-from,
62
+ .expand-leave-to {
89
63
  max-height: 0;
90
- animation: expand 1s ease forwards;
64
+ opacity: 0.5;
91
65
  }
92
- @keyframes expand {
93
- 0% {
94
- max-height: 0;
95
- }
96
- 100% {
97
- max-height: 100vh;
98
- }
66
+
67
+ .expand-enter-to,
68
+ .expand-leave-from {
69
+ max-height: 100vh;
70
+ opacity: 1;
99
71
  }
100
72
  </style>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="card" :class="{thin, border, 'h-100':h100}">
2
+ <div class="card" :class="{thin, border, 'h-100':h100, [bg||'']: bg}">
3
3
  <slot/>
4
4
  </div>
5
5
  </template>
@@ -9,5 +9,6 @@ defineProps<{
9
9
  thin?: boolean;
10
10
  border?: boolean;
11
11
  h100?: boolean;
12
+ bg?: 'gray' | 'light' | 'dark' | 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'white' | 'transparent';
12
13
  }>();
13
14
  </script>
@@ -1,32 +1,16 @@
1
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
- >
2
+ <div class="bg-dark" :class="{ 'is-side': side, 'is-active': isActive }"
3
+ @click="() => (dismissable ? closeModal() : '')" @keydown.esc="closeModal">
4
+ <div class="card modal" @click.stop>
12
5
  <header class="tool-bar">
13
6
  <slot name="toolbar" />
14
- <Btn
15
- :style="{ float: side ? 'left' : 'right' }"
16
- flat
17
- icon="close"
18
- @click="closeModal"
19
- />
7
+ <Btn :style="{ float: side ? 'left' : 'right' }" flat icon="close" @click="closeModal" />
20
8
  <h3 class="modal-title">
21
9
  {{ title }}
22
10
  </h3>
23
11
  </header>
24
- <BagelForm
25
- :onDelete="onDelete ? runDelete : undefined"
26
- v-model="formData"
27
- @submit="runSubmit"
28
- :schema="computedFormSchema"
29
- />
12
+ <BagelForm :onDelete="onDelete ? runDelete : undefined" v-model="formData" @submit="runSubmit"
13
+ :schema="computedFormSchema" />
30
14
  </div>
31
15
  </div>
32
16
  </template>
@@ -86,9 +86,7 @@ defineProps<{
86
86
  schema: BglFormSchemaT;
87
87
  }>();
88
88
 
89
- const emit = defineEmits<{
90
- select: [Record<string, any>];
91
- }>();
89
+ const emit = defineEmits(['select']);
92
90
 
93
91
  const selectElement = (data: Record<string, any>) => emit('select', data);
94
92
 
@@ -1,13 +1,16 @@
1
1
  <template>
2
2
  <component :required="field.required" v-bind="bindAttrs(field?.attrs || {}, fieldData, modelValue)"
3
- :class="classify(fieldData, modelValue, field.class, field.attrs?.class)" v-if="vIf" :is="field.$el || 'div'"
4
- :label="field.label" :id="field.id" :placeholder="field.placeholder || field.label" v-model="fieldData">
3
+ :class="classify(fieldData, modelValue, field.class, field.attrs?.class)" v-if="vIf" :is="is" :label="field.label"
4
+ :id="field.id" :placeholder="field.placeholder || field.label" v-model="fieldData"
5
+ :defaultValue="field.defaultValue" :options="field.options" :hint="field.hint">
5
6
  <BglField v-model="formData" v-for="(child, ii) in field.children" :key="child.id || ii" :field="child" />
6
7
  </component>
7
8
  </template>
8
9
 
9
10
  <script lang="ts" setup>
10
- import { type Field, bindAttrs, classify } from '@bagelink/vue';
11
+ import {
12
+ type Field, bindAttrs, classify, SelectInput, TextInput, ToggleInput, CheckInput,
13
+ } from '@bagelink/vue';
11
14
 
12
15
  const props = withDefaults(defineProps<{
13
16
  field: Field
@@ -15,6 +18,15 @@ const props = withDefaults(defineProps<{
15
18
  }>(), {
16
19
  modelValue: () => ({}),
17
20
  });
21
+
22
+ const is = $computed(() => {
23
+ if (props.field.$el === 'text') return TextInput;
24
+ if (props.field.$el === 'select') return SelectInput;
25
+ if (props.field.$el === 'toggle') return ToggleInput;
26
+ if (props.field.$el === 'check') return CheckInput;
27
+ return props.field.$el || 'div';
28
+ });
29
+
18
30
  const emit = defineEmits(['update:modelValue']);
19
31
 
20
32
  const formData = $computed({
@@ -1,32 +1,33 @@
1
1
  <template>
2
- <form ref="form" @submit.prevent="runSubmit">
3
- <BglField
4
- v-for="(field, i) in schema" :key="field.id || `${i}p`" :field="field" v-model="data"
5
- />
6
- <Btn
7
- class="del-top" v-if="data?.id && onDelete" @click="runDelete" value="Delete" flat icon="delete"
8
- color="red" thin
9
- />
2
+ <component :is="id?'div':'form'" ref="form" @submit.prevent="runSubmit">
3
+ <Title tag="h4" :label="label" v-if="label" />
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 />
10
7
  <Btn v-if="!$slots.submit && onSubmit" value="Submit" type="submit" thin />
11
8
  <div v-else>
12
- <slot name="submit"/>
9
+ <slot name="submit" />
13
10
  </div>
14
- </form>
11
+ </component>
15
12
  </template>
16
13
 
17
14
  <script lang="ts" setup>
18
- import { Btn, useModal, BglField } from '@bagelink/vue';
15
+ import {
16
+ Btn, useModal, BglField, Title,
17
+ } from '@bagelink/vue';
19
18
  import { type BglFormSchemaT } from '@bagelink/vue';
20
19
 
21
20
  const { showModal } = useModal();
22
21
 
23
22
  const props = withDefaults(
24
23
  defineProps<{
25
- schema: BglFormSchemaT;
26
- modelValue?: Record<string, any>;
27
- onDelete?: ((id: string) => void);
28
- onSubmit?: ((data: any) => void);
29
- }>(),
24
+ label?: string;
25
+ id?: string;
26
+ schema: BglFormSchemaT;
27
+ modelValue?: Record<string, any>;
28
+ onDelete?: ((id: string) => void);
29
+ onSubmit?: ((data: any) => void);
30
+ }>(),
30
31
  {
31
32
  modelValue: () => ({}),
32
33
  },
@@ -46,11 +47,11 @@ const validateForm = () => form?.reportValidity?.();
46
47
 
47
48
  defineExpose({ validateForm });
48
49
 
49
- const clearForm = () => Object.assign(data.value, {});
50
+ const clearForm = () => Object.assign(data, {});
50
51
 
51
52
  const runSubmit = () => {
52
53
  validateForm();
53
- emit('submit', data.value);
54
+ emit('submit', data);
54
55
  clearForm();
55
56
  };
56
57
 
@@ -2,15 +2,9 @@
2
2
  <div
3
3
  class="bagel-input bgl-checkbox"
4
4
  :title="title"
5
- :class="{ small: small, 'no-edit': !editMode }"
5
+ :class="{ small: small}"
6
6
  >
7
- <input
8
- :id="id"
9
- type="checkbox"
10
- v-model="inputVal"
11
- :class="{ 'no-edit': !editMode }"
12
- >
13
- <div class="check-square">
7
+ <div class="check-square" :class="{checked:checked}" @click="checked = !checked">
14
8
  <svg
15
9
  xmlns="http://www.w3.org/2000/svg"
16
10
  height="24" viewBox="0 -960 960 960"
@@ -18,28 +12,26 @@
18
12
  >
19
13
  <path d="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z"/></svg>
20
14
  </div>
21
- <label :for="id">
15
+ <label>
16
+ <input
17
+ :id="id"
18
+ type="checkbox"
19
+ v-model="checked"
20
+ >
22
21
  {{ label }}
23
22
  </label>
24
23
  </div>
25
24
  </template>
26
25
 
27
26
  <script setup lang="ts">
28
- withDefaults(
29
- defineProps<{
27
+ defineProps<{
30
28
  label: string;
31
29
  id?: string;
32
30
  title?: string;
33
- editMode?: boolean;
34
31
  small?: boolean;
35
- }>(),
36
- {
37
- editMode: true,
38
- id: Math.random().toString(36).substring(7),
39
- },
40
- );
32
+ }>();
41
33
 
42
- const inputVal = defineModel<boolean>('modelValue', { default: false });
34
+ const checked = defineModel<boolean>('modelValue', { default: false });
43
35
  </script>
44
36
  <style>
45
37
  :root {
@@ -68,7 +60,7 @@ const inputVal = defineModel<boolean>('modelValue', { default: false });
68
60
  user-select: none;
69
61
  }
70
62
  .bgl-checkbox:hover{
71
- filter: brightness(90%);
63
+ filter: brightness(95%);
72
64
  }
73
65
  .bgl-checkbox:active{
74
66
  filter: var(--bgl-active-filter);
@@ -85,7 +77,7 @@ const inputVal = defineModel<boolean>('modelValue', { default: false });
85
77
  justify-content: center;
86
78
  }
87
79
 
88
- input:checked ~ .check-square{
80
+ .check-square.checked{
89
81
  background: var(--bgl-primary);
90
82
  }
91
83
  .bgl-checkbox svg{
@@ -94,10 +86,11 @@ input:checked ~ .check-square{
94
86
  position: absolute;
95
87
  z-index: 2;
96
88
  fill: var(--bgl-white);
97
- opacity: 0;
98
89
  pointer-events: none;
90
+ transform: scale(0);
91
+ transition: var(--bgl-transition);
99
92
  }
100
- input:checked ~ .check-square svg{
101
- opacity: 1;
93
+ .check-square.checked svg{
94
+ transform: scale(1);
102
95
  }
103
96
  </style>
@@ -8,33 +8,12 @@
8
8
  </template>
9
9
 
10
10
  <script setup lang="ts">
11
- import { watch } from 'vue';
12
11
  import { MaterialIcon } from '@bagelink/vue';
13
12
 
14
- const props = defineProps({
15
- modelValue: Boolean,
13
+ const val = defineModel('modelValue', {
14
+ type: Boolean,
15
+ default: false,
16
16
  });
17
-
18
- const emits = defineEmits(['update:modelValue']);
19
-
20
- let val = $ref<boolean>();
21
-
22
- watch(
23
- () => props.modelValue,
24
- (v: boolean) => {
25
- if (v === undefined || v === val) return;
26
- console.log('v', v);
27
- val = v;
28
- },
29
- { immediate: true },
30
- );
31
-
32
- watch(
33
- () => val,
34
- (v) => {
35
- if (v !== props.modelValue) emits('update:modelValue', v);
36
- },
37
- );
38
17
  </script>
39
18
 
40
19
  <style scoped>
@@ -1,33 +1,22 @@
1
1
  <template>
2
- <div
3
- class="bagel-input"
4
- :class="{ small }"
5
- :title="field.description"
6
- v-if="field.id"
7
- >
8
- <label :for="field.id">
9
- {{ field.label }}
10
- <input
11
- :id="field.id"
12
- v-model="inputVal"
13
- type="color"
14
- :placeholder="field?.placeholder || field.label"
15
- :class="{ 'no-edit': !editMode }"
16
- :required="required"
17
- v-bind="nativeInputAttrs"
18
- >
2
+ <div class="bagel-input" :class="{ small }" :title="label" v-if="id">
3
+ <label>
4
+ {{ label }}
5
+ <input :id="id" v-model="inputVal" type="color" :placeholder="placeholder || label"
6
+ :class="{ 'no-edit': !editMode }" :required="required" v-bind="nativeInputAttrs">
19
7
  </label>
20
8
  </div>
21
9
  </template>
22
10
 
23
11
  <script setup lang="ts">
24
12
  import { watch } from 'vue';
25
- import { type BagelField } from '@bagelink/vue';
26
13
 
27
14
  const emits = defineEmits(['update:modelValue']);
28
15
  const props = withDefaults(
29
16
  defineProps<{
30
- field: BagelField;
17
+ label?: string;
18
+ id?: string;
19
+ placeholder?: string;
31
20
  modelValue: any;
32
21
  editMode?: boolean;
33
22
  small?: boolean;
@@ -10,15 +10,18 @@
10
10
  <script setup lang="ts">
11
11
  import VDatepicker, { DatePickerInstance } from '@vuepic/vue-datepicker';
12
12
  import '@vuepic/vue-datepicker/dist/main.css';
13
+ import { onMounted } from 'vue';
13
14
 
14
15
  const datePicker = $ref<DatePickerInstance>();
15
16
 
16
- withDefaults(
17
+ const props = withDefaults(
17
18
  defineProps<{
18
19
  label?: string;
19
20
  editMode?: boolean;
20
21
  small?: boolean;
21
22
  enableTime?: boolean;
23
+ modelValue?: string | Date;
24
+ defaultValue?: string | Date;
22
25
  }>(),
23
26
  {
24
27
  enableTime: false,
@@ -27,7 +30,23 @@ withDefaults(
27
30
  },
28
31
  );
29
32
 
30
- const date = defineModel<string | Date>('modelValue', { default: '' });
33
+ const emit = defineEmits(['update:modelValue']);
34
+
35
+ let date = $computed<string | Date>({
36
+ get: () => props.modelValue || '',
37
+ set: (val) => {
38
+ const d = typeof val === 'string' ? new Date(val) : val;
39
+ if (props.enableTime) {
40
+ emit('update:modelValue', d.toISOString());
41
+ } else {
42
+ emit('update:modelValue', d.toISOString().split('T')[0]);
43
+ }
44
+ },
45
+ });
46
+
47
+ onMounted(() => {
48
+ if (props.defaultValue) date = props.defaultValue;
49
+ });
31
50
  </script>
32
51
 
33
52
  <style>
@@ -3,11 +3,9 @@
3
3
  <label>
4
4
  {{ label }}
5
5
  </label>
6
- <div
7
- @click="browse" @dragover="dragover" @drop="drop" @dragleave="dragleave" class="fileUploadWrap"
8
- :class="{ fileDropZone: !storageFiles.length && !fileQueue.length, dragover: isDragOver }"
9
- >
10
- <template v-for="file in storageFiles" :key="file.id">
6
+ <div @click="browse" @dragover="dragover" @drop="drop" @dragleave="dragleave" class="fileUploadWrap"
7
+ :class="{ fileDropZone: !storageFiles.length && !fileQueue.length, dragover: isDragOver }">
8
+ <template v-for="file in storageFiles" :key="file.id">
11
9
  <div class="imagePreviewWrap" v-if="!multiple">
12
10
  <img class="preview" :src="file.url" alt="">
13
11
  </div>
@@ -28,22 +26,12 @@
28
26
  <p class="no-margin">
29
27
  {{ fileQ.name }}
30
28
  </p>
31
- <div
32
- class="pie"
33
- :style="`--p:${fileQ.progress}`"
34
- style="--b: 2px"
35
- :class="{ complete: fileQ.progress === 100 }"
36
- >
37
- <span
38
- class="progress"
39
- v-if="fileQ.progress < 100"
40
- >
41
- {{`${fileQ.progress.toFixed(0)}`}}
29
+ <div class="pie" :style="`--p:${fileQ.progress}`" style="--b: 2px"
30
+ :class="{ complete: fileQ.progress === 100 }">
31
+ <span class="progress" v-if="fileQ.progress < 100">
32
+ {{ `${fileQ.progress.toFixed(0)}` }}
42
33
  </span>
43
- <MaterialIcon
44
- class="success"
45
- icon="check"
46
- />
34
+ <MaterialIcon class="success" icon="check" />
47
35
  </div>
48
36
  </div>
49
37
  </template>
@@ -79,7 +67,7 @@ watch(() => props.files, (newFiles) => {
79
67
  }, { immediate: true });
80
68
 
81
69
  watch(() => storageFiles, (newFiles) => {
82
- let idValue:string[] | string = '';
70
+ let idValue: string[] | string = '';
83
71
  if (props.multiple) idValue = newFiles.map((f) => f.id || '');
84
72
  else idValue = newFiles[0]?.id || '';
85
73
  if (!compareIds(file_ids?.value, idValue)) file_ids.value = idValue;
@@ -116,7 +104,7 @@ const browse = () => {
116
104
  input.onchange = (e: Event) => {
117
105
  const target = e?.target as HTMLInputElement;
118
106
  if (target?.files) {
119
- Array.from(target.files).forEach((file:File) => fileQueue.push({ name: file.name, file, progress: 0 }));
107
+ Array.from(target.files).forEach((file: File) => fileQueue.push({ name: file.name, file, progress: 0 }));
120
108
  }
121
109
  flushQueue();
122
110
  };
@@ -138,7 +126,7 @@ const dragover = (e: DragEvent) => {
138
126
  const drop = (e: DragEvent) => {
139
127
  preventDefault(e);
140
128
  if (e.dataTransfer) {
141
- Array.from(e.dataTransfer.files).forEach((file:File) => fileQueue.push({ name: file.name, file, progress: 0 }));
129
+ Array.from(e.dataTransfer.files).forEach((file: File) => fileQueue.push({ name: file.name, file, progress: 0 }));
142
130
  }
143
131
  isDragOver = false;
144
132
  flushQueue();
@@ -2,10 +2,8 @@
2
2
  <div class="pb-1">
3
3
  <label :for="id">
4
4
  {{ label }}
5
- <Multiselect
6
- ref="multiselect" :closeOnSelect="true" :id="id" label="label" trackBy="value" :options="optionList"
7
- :required="required" :placeholder="placeholder" v-model="seletValue"
8
- />
5
+ <Multiselect ref="multiselect" :id="id" label="label" trackBy="value" :options="optionList" :required="required"
6
+ :placeholder="placeholder" v-model="seletValue" />
9
7
  </label>
10
8
  </div>
11
9
  </template>
@@ -40,7 +38,7 @@ const seletValue = $computed({
40
38
  set: (val?: Option) => {
41
39
  dataValue = val?.value;
42
40
  emit('update:modelValue', dataValue);
43
- multiselect?.deactivate();
41
+ setTimeout(() => multiselect?.deactivate(), 1);
44
42
  },
45
43
  });
46
44
 
@@ -309,12 +307,11 @@ fieldset[disabled] .multiselect {
309
307
 
310
308
  .multiselect__select::before {
311
309
  position: relative;
312
- right: 0;
313
- top: calc(var(--input-height) / 2 - var(--input-font-size));
310
+ background-size: contain;
311
+ transform: scale(0.5);
312
+ top: 4px;
314
313
  color: var(--bgl-black);
315
- content: "expand_more";
316
- font-family: "Material Icons";
317
- font-size: var(--input-font-size);
314
+ content: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' fill='%23b7b7b7' height='24' viewBox='0 -960 960 960' width='24'><path d='M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z'/></svg>")
318
315
  }
319
316
 
320
317
  .multiselect__placeholder {
@@ -387,7 +384,8 @@ fieldset[disabled] .multiselect {
387
384
  right: 0;
388
385
  position: absolute;
389
386
  width: calc(var(--input-height) * 0.8);
390
- height: calc(var(--input-height) * 0.8);;
387
+ height: calc(var(--input-height) * 0.8);
388
+ ;
391
389
  text-align: center;
392
390
  font-size: 13px;
393
391
  }