@bagelink/vue 0.0.236-beta.0 → 0.0.237

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 (51) hide show
  1. package/dist/components/Btn.vue.d.ts +5 -0
  2. package/dist/components/Btn.vue.d.ts.map +1 -1
  3. package/dist/components/DataPreview.vue.d.ts.map +1 -1
  4. package/dist/components/ListItem.vue.d.ts +4 -0
  5. package/dist/components/ListItem.vue.d.ts.map +1 -1
  6. package/dist/components/Modal.vue.d.ts +3 -1
  7. package/dist/components/Modal.vue.d.ts.map +1 -1
  8. package/dist/components/ModalForm.vue.d.ts +48 -41
  9. package/dist/components/ModalForm.vue.d.ts.map +1 -1
  10. package/dist/components/Title.vue.d.ts +9 -0
  11. package/dist/components/Title.vue.d.ts.map +1 -1
  12. package/dist/components/form/BglField.vue.d.ts.map +1 -1
  13. package/dist/components/form/BglForm.vue.d.ts +2 -2
  14. package/dist/components/form/ItemRef.vue.d.ts +0 -1
  15. package/dist/components/form/ItemRef.vue.d.ts.map +1 -1
  16. package/dist/components/form/inputs/SelectField.vue.d.ts +4 -1
  17. package/dist/components/form/inputs/SelectField.vue.d.ts.map +1 -1
  18. package/dist/components/form/inputs/SelectInput.vue.d.ts +4 -4
  19. package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
  20. package/dist/components/index.d.ts +1 -2
  21. package/dist/components/index.d.ts.map +1 -1
  22. package/dist/components/whatsapp/form/MsgTemplate.vue.d.ts +4 -3
  23. package/dist/components/whatsapp/form/MsgTemplate.vue.d.ts.map +1 -1
  24. package/dist/index.cjs +221 -298
  25. package/dist/index.mjs +222 -299
  26. package/dist/plugins/modal.d.ts.map +1 -1
  27. package/dist/style.css +61 -61
  28. package/dist/utils/index.d.ts.map +1 -1
  29. package/package.json +1 -1
  30. package/src/components/Btn.vue +8 -24
  31. package/src/components/DataPreview.vue +4 -15
  32. package/src/components/ListItem.vue +5 -5
  33. package/src/components/Modal.vue +12 -22
  34. package/src/components/ModalForm.vue +25 -55
  35. package/src/components/Title.vue +5 -1
  36. package/src/components/form/BglField.vue +6 -12
  37. package/src/components/form/BglForm.vue +1 -1
  38. package/src/components/form/inputs/DateInput.vue +6 -2
  39. package/src/components/form/inputs/SelectInput.vue +2 -2
  40. package/src/components/index.ts +1 -2
  41. package/src/components/whatsapp/form/MsgTemplate.vue +6 -12
  42. package/src/plugins/modal.ts +3 -6
  43. package/src/styles/theme.css +1 -0
  44. package/src/utils/index.ts +6 -5
  45. package/dist/components/Drop.vue.d.ts +0 -34
  46. package/dist/components/Drop.vue.d.ts.map +0 -1
  47. package/dist/components/FileUploader.vue.d.ts +0 -60
  48. package/dist/components/FileUploader.vue.d.ts.map +0 -1
  49. package/src/components/FormKitTable.vue +0 -280
  50. package/src/components/FormSchema.vue +0 -76
  51. package/src/components/ModalBglForm.vue +0 -106
@@ -1,15 +1,17 @@
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="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">
3
+ :class="classify(fieldData, modelValue, field.class, field.attrs?.class)" v-if="iffer(field, fieldData)" :is="is"
4
+ :label="field.label" :id="field.id" :placeholder="field.placeholder || field.label" v-model="fieldData"
5
+ :defaultValue="field.defaultValue" :options="field.options" :hint="field.hint"
6
+ @update:modelValue="($event: any) => field?.onUpdate?.($event, denullify(fieldData, field.id), formData)">
7
+ {{ field.transform?.(fieldData, modelValue) || fieldData || '' }}
6
8
  <BglField v-model="formData" v-for="(child, ii) in field.children" :key="child.id || ii" :field="child" />
7
9
  </component>
8
10
  </template>
9
11
 
10
12
  <script lang="ts" setup>
11
13
  import {
12
- type Field, bindAttrs, classify, SelectInput, TextInput, ToggleInput, CheckInput,
14
+ type Field, bindAttrs, classify, SelectInput, TextInput, ToggleInput, CheckInput, iffer, denullify,
13
15
  } from '@bagelink/vue';
14
16
 
15
17
  const props = withDefaults(defineProps<{
@@ -43,12 +45,4 @@ const fieldData = $computed({
43
45
  },
44
46
  get: () => (props.field.id ? props.modelValue[props.field.id] : ''),
45
47
  });
46
-
47
- const vIf = $computed(() => {
48
- if (props.field['v-if'] === undefined) return true;
49
- if (typeof props.field['v-if'] === 'boolean') return props.field['v-if'];
50
- if (typeof props.field['v-if'] === 'string') return !!props.modelValue.value[props.field['v-if']];
51
- if (typeof props.field['v-if'] === 'function') return props.field['v-if']!(fieldData.value, props.modelValue);
52
- return true;
53
- });
54
48
  </script>
@@ -23,7 +23,7 @@ const props = withDefaults(
23
23
  defineProps<{
24
24
  label?: string;
25
25
  id?: string;
26
- schema: BglFormSchemaT;
26
+ schema: BglFormSchemaT<any>;
27
27
  modelValue?: Record<string, any>;
28
28
  onDelete?: ((id: string) => void);
29
29
  onSubmit?: ((data: any) => void);
@@ -3,7 +3,7 @@
3
3
  <label v-if="label">
4
4
  {{ label }}
5
5
  </label>
6
- <VDatepicker ref="datePicker" :auto-apply="true" v-model="date" :enable-time-picker="enableTime"/>
6
+ <VDatepicker ref="datePicker" :auto-apply="true" v-model="date" :enable-time-picker="enableTime" />
7
7
  </div>
8
8
  </template>
9
9
 
@@ -45,7 +45,7 @@ let date = $computed<string | Date>({
45
45
  });
46
46
 
47
47
  onMounted(() => {
48
- if (props.defaultValue) date = props.defaultValue;
48
+ if (props.defaultValue) date = props.defaultValue;
49
49
  });
50
50
  </script>
51
51
 
@@ -53,4 +53,8 @@ onMounted(() => {
53
53
  .dp__input_wrap input {
54
54
  padding-inline-start: 2rem !important;
55
55
  }
56
+
57
+ .dp__calendar_row>div:last-child {
58
+ pointer-events: auto !important;
59
+ }
56
60
  </style>
@@ -20,8 +20,8 @@ type RawOption = Option | string | number;
20
20
 
21
21
  const props = defineProps<{
22
22
  required?: boolean,
23
- label: string,
24
- id: string,
23
+ label?: string,
24
+ id?: string,
25
25
  modelValue?: string | number,
26
26
  placeholder?: string,
27
27
  defaultValue?: string | number,
@@ -4,14 +4,13 @@ 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
+ export { default as ModalForm } from './ModalForm.vue';
8
8
  export { default as AccordionItem } from './AccordionItem.vue';
9
9
  export { default as ListView } from './ListView.vue';
10
10
  export { default as ListItem } from './ListItem.vue';
11
11
  export { default as TabbedLayout } from './TabbedLayout.vue';
12
12
  export { default as Comments } from './Comments.vue';
13
13
  export { default as PageTitle } from './PageTitle.vue';
14
- export { default as FormSchema } from './FormSchema.vue';
15
14
  export { default as TableSchema } from './TableSchema.vue';
16
15
  export { default as TopBar } from './TopBar.vue';
17
16
  export { default as RouterWrapper } from './RouterWrapper.vue';
@@ -4,16 +4,9 @@
4
4
  <div class="view-wrapper card thin">
5
5
  <div class="whatsapp-wrap">
6
6
  <div class="create-template-form">
7
- <FormSchema
8
- :schema="whatsappTemplateSchema()"
9
- v-model="localWhatsappData"
10
- @submit="upsertTemplate"
11
- />
7
+ <BagelForm :schema="whatsappTemplateSchema" v-model="localWhatsappData" @submit="upsertTemplate" />
12
8
  </div>
13
- <div
14
- class="whatsapp-preview"
15
- :class="{ whatsappHebrew: localWhatsappData?.language === 'he' }"
16
- >
9
+ <div class="whatsapp-preview" :class="{ whatsappHebrew: localWhatsappData?.language === 'he' }">
17
10
  {{ previewLabel }}
18
11
  <div class="whatsapp-msg">
19
12
  <b>{{
@@ -35,9 +28,10 @@
35
28
  <script setup lang="ts">
36
29
  import { onMounted } from 'vue';
37
30
 
38
- import type { FormKitSchemaDefinition } from '@formkit/core';
39
31
  import type { RouteLocationNormalizedLoaded, Router } from 'vue-router';
40
- import { useBagel, PageTitle, FormSchema } from '@bagelink/vue';
32
+ import {
33
+ useBagel, PageTitle, BagelForm, BglFormSchemaT,
34
+ } from '@bagelink/vue';
41
35
  import {
42
36
  BodyComponent,
43
37
  HeaderComponent,
@@ -48,7 +42,7 @@ import {
48
42
 
49
43
  const props = withDefaults(
50
44
  defineProps<{
51
- whatsappTemplateSchema: () => FormKitSchemaDefinition;
45
+ whatsappTemplateSchema: BglFormSchemaT<LocalTemplateData>;
52
46
  router: Router;
53
47
  route: RouteLocationNormalizedLoaded;
54
48
  previewLabel?: string;
@@ -3,7 +3,7 @@ import {
3
3
  } from 'vue';
4
4
  import type { Plugin } from 'vue';
5
5
  import type { BglFormSchemaT, BtnOptions } from '@bagelink/vue';
6
- import { Modal, ModalBglForm } from '@bagelink/vue';
6
+ import { Modal, ModalForm } from '@bagelink/vue';
7
7
 
8
8
  interface ModalOptions {
9
9
  title?: string;
@@ -84,12 +84,9 @@ export const ModalPlugin: Plugin = {
84
84
  },
85
85
  render() {
86
86
  return modalStack.map((modal, index) => {
87
- let renderComponent;
88
- if (modal.modalType === 'modalForm') renderComponent = ModalBglForm;
89
- else renderComponent = Modal;
90
-
87
+ const renderComponent = modal.modalType === 'modalForm' ? ModalForm : Modal;
91
88
  return h(
92
- renderComponent,
89
+ renderComponent as any,
93
90
  {
94
91
  ...modal.modalOptions,
95
92
  'onUpdate:isModalVisible': () => hideModal(index),
@@ -97,6 +97,7 @@
97
97
  gap: 1rem;
98
98
  display: flex;
99
99
  justify-content: space-between;
100
+ align-items: center;
100
101
  }
101
102
 
102
103
  * {
@@ -39,7 +39,7 @@ export function classify(fieldVal?: any, row?: any, ...classes: any[]) {
39
39
 
40
40
  export function bindAttrs<T = Record<string, any>>(attrs?: Attributes, fieldVal?: any, row?: T) {
41
41
  if (!attrs) return {};
42
- const exclude = ['class', 'style'];
42
+ const exclude = ['class'];
43
43
  const arr = Object.entries(attrs).filter(([key]) => !exclude.includes(key)).map(([key, value]) => [
44
44
  key,
45
45
  typeof value === 'function' ? value(fieldVal, row) : value,
@@ -49,10 +49,11 @@ export function bindAttrs<T = Record<string, any>>(attrs?: Attributes, fieldVal?
49
49
  }
50
50
 
51
51
  export const iffer = (field: any, itemData: any) => {
52
- if (field['v-if'] && typeof field['v-if'] === 'function') {
53
- return field['v-if'](field.id ? itemData[field.id] : '', itemData);
54
- }
55
- return field['v-if'] || true;
52
+ if (field['v-if'] === undefined) return true;
53
+ if (typeof field['v-if'] === 'boolean') return field['v-if'];
54
+ if (typeof field['v-if'] === 'string') return !!itemData.value[field['v-if']];
55
+ if (typeof field['v-if'] === 'function') return field['v-if']!(itemData?.[field.id], itemData);
56
+ return true;
56
57
  };
57
58
 
58
59
  export const denullify = (itemData?: Record<string, any>, fieldID?: string) => (fieldID && itemData ? itemData[fieldID] : null);
@@ -1,34 +0,0 @@
1
- type Option = {
2
- label: string;
3
- value: string;
4
- } | string | number;
5
- declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{
6
- modelValue: string | number;
7
- options: Option[];
8
- placeholder?: string | undefined;
9
- label?: string | undefined;
10
- id: string;
11
- required: boolean;
12
- }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
13
- "update:modelValue": (...args: any[]) => void;
14
- }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
15
- modelValue: string | number;
16
- options: Option[];
17
- placeholder?: string | undefined;
18
- label?: string | undefined;
19
- id: string;
20
- required: boolean;
21
- }>>> & {
22
- "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
23
- }, {}, {}>;
24
- export default _default;
25
- type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
26
- type __VLS_TypePropsToRuntimeProps<T> = {
27
- [K in keyof T]-?: {} extends Pick<T, K> ? {
28
- type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
29
- } : {
30
- type: import('vue').PropType<T[K]>;
31
- required: true;
32
- };
33
- };
34
- //# sourceMappingURL=Drop.vue.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Drop.vue.d.ts","sourceRoot":"","sources":["../../src/components/Drop.vue"],"names":[],"mappings":"AAcA;AAMA,KAAK,MAAM,GAAG;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,MAAM,GAAG,MAAM,CAAC;;gBA8KN,MAAM,GAAG,MAAM;aAClB,MAAM,EAAE;;;QAGb,MAAM;cACA,OAAO;;;;gBALL,MAAM,GAAG,MAAM;aAClB,MAAM,EAAE;;;QAGb,MAAM;cACA,OAAO;;;;AAXnB,wBAcG;AACH,KAAK,sBAAsB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AACjE,KAAK,6BAA6B,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAE;CAAE,CAAC"}
@@ -1,60 +0,0 @@
1
- declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
2
- id?: string | undefined;
3
- private?: 0 | 1 | undefined;
4
- singleFile?: boolean | undefined;
5
- beforeUpload?: (() => Promise<any>) | undefined;
6
- dragDropLabel?: string | undefined;
7
- browseLabel?: string | undefined;
8
- }>, {
9
- private: number;
10
- entity: string;
11
- id: string;
12
- beforeUpload: () => Promise<void>;
13
- dragDropLabel: string;
14
- browseLabel: string;
15
- }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
16
- done: (...args: any[]) => void;
17
- complete: (...args: any[]) => void;
18
- }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
19
- id?: string | undefined;
20
- private?: 0 | 1 | undefined;
21
- singleFile?: boolean | undefined;
22
- beforeUpload?: (() => Promise<any>) | undefined;
23
- dragDropLabel?: string | undefined;
24
- browseLabel?: string | undefined;
25
- }>, {
26
- private: number;
27
- entity: string;
28
- id: string;
29
- beforeUpload: () => Promise<void>;
30
- dragDropLabel: string;
31
- browseLabel: string;
32
- }>>> & {
33
- onDone?: ((...args: any[]) => any) | undefined;
34
- onComplete?: ((...args: any[]) => any) | undefined;
35
- }, {
36
- id: string;
37
- private: 1 | 0;
38
- beforeUpload: () => Promise<any>;
39
- dragDropLabel: string;
40
- browseLabel: string;
41
- }, {}>;
42
- export default _default;
43
- type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
44
- type __VLS_TypePropsToRuntimeProps<T> = {
45
- [K in keyof T]-?: {} extends Pick<T, K> ? {
46
- type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
47
- } : {
48
- type: import('vue').PropType<T[K]>;
49
- required: true;
50
- };
51
- };
52
- type __VLS_WithDefaults<P, D> = {
53
- [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
54
- default: D[K];
55
- }> : P[K];
56
- };
57
- type __VLS_Prettify<T> = {
58
- [K in keyof T]: T[K];
59
- } & {};
60
- //# sourceMappingURL=FileUploader.vue.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FileUploader.vue.d.ts","sourceRoot":"","sources":["../../src/components/FileUploader.vue"],"names":[],"mappings":"AAiDA;;;;;0BA6YuB,QAAQ,GAAG,CAAC;;;;;;;;;;;;;;;;;0BAAZ,QAAQ,GAAG,CAAC;;;;;;;;;;;;;;QAJ5B,MAAM;aAED,CAAC,GAAG,CAAC;kBAEA,MAAM,QAAQ,GAAG,CAAC;mBACjB,MAAM;iBACR,MAAM;;AARtB,wBAeG;AAGH,KAAK,sBAAsB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AACjE,KAAK,6BAA6B,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAE;CAAE,CAAC;AAC9M,KAAK,kBAAkB,CAAC,CAAC,EAAE,CAAC,IAAI;KAE1B,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;QACxE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;KACb,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACT,CAAC;AACN,KAAK,cAAc,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -1,280 +0,0 @@
1
- <template>
2
- <div class="table-list-wrap h-100">
3
- <!-- <Transition name="fade"> -->
4
- <div class="table-list">
5
- <table class="infinite-wrapper">
6
- <thead class="row first-row">
7
- <th
8
- class="col"
9
- v-for="field in columns"
10
- :key="field.id"
11
- @click="sort(field.id)"
12
- >
13
- <div class="flex">
14
- {{ field?.label || field.id }}
15
- <div
16
- class="list-arrows"
17
- :class="{ sorted: sortField === field.id }"
18
- >
19
- <MaterialIcon
20
- :class="{ desc: sortDirection === 'DESC' }"
21
- icon="keyboard_arrow_up"
22
- />
23
- </div>
24
- </div>
25
- </th>
26
- </thead>
27
- <tbody ref="infinite" class="rows infinite" :class="{ loading }">
28
- <tr
29
- @click="selectElement(row)"
30
- class="row row-item position-relative"
31
- v-for="row in data"
32
- :key="row.id"
33
- >
34
- <td
35
- class="col"
36
- v-for="field in columns"
37
- :key="`${field.id}-${row.id}`"
38
- >
39
- <slot
40
- v-if="slots[field.id]"
41
- :name="field.id"
42
- :row="row"
43
- :field="field"
44
- />
45
- <div v-else>
46
- <div v-if="field.inputType === 'DateInput'">
47
- {{ new Date(row[field.id]).toLocaleDateString() }}
48
- </div>
49
- <div v-else-if="field.inputType === 'CheckInput'">
50
- <MaterialIcon
51
- icon="check"
52
- class="pill green"
53
- v-if="row[field.id]"
54
- />
55
- <MaterialIcon icon="close" class="pill" v-else />
56
- </div>
57
- <div v-else-if="field.inputType === 'ItemRef' && row[field.id]">
58
- <Btn
59
- v-if="field.refCollection"
60
- color="gray"
61
- class="thin"
62
- @click="
63
- $router.push(
64
- `/${field.refCollection}/${row[field.id].id}`
65
- )
66
- "
67
- >
68
- {{
69
- field.refFields?.map((k) => row[field.id][k]).join(" ") ||
70
- row[field.id].id
71
- }}
72
- <MaterialIcon icon="arrow_forward" />
73
- </Btn>
74
- <Btn
75
- icon="receipt"
76
- is="a"
77
- thin
78
- v-else-if="field.link"
79
- :href="row[field.id][field.link]"
80
- target="_blank"
81
- >
82
- {{
83
- field.refFields?.map((k) => row[field.id][k]).join(" ") ||
84
- row[field.id].id
85
- }}
86
- </Btn>
87
- <div class="pill" v-else :class="getPillClass(row, field)">
88
- {{
89
- field.refFields?.map((k) => row[field.id][k]).join(" ") ||
90
- row[field.id].id
91
- }}
92
- </div>
93
- </div>
94
- <div class="max-col-width" v-else>
95
- {{ row[field.id] }}
96
- </div>
97
- </div>
98
- </td>
99
- </tr>
100
- </tbody>
101
- </table>
102
- </div>
103
- <!-- </Transition> -->
104
- </div>
105
- </template>
106
-
107
- <script setup lang="ts">
108
- import { computed, ref, useSlots } from 'vue';
109
- import { BagelField, Btn, MaterialIcon } from '@bagelink/vue';
110
-
111
- const slots = useSlots();
112
- const loading = ref(true);
113
-
114
- const props = defineProps<{
115
- data: any[];
116
- schema?: BagelField[];
117
- }>();
118
-
119
- const emit = defineEmits(['selectElement']);
120
-
121
- const selectElement = (data: Record<string, any>) => {
122
- emit('selectElement', data);
123
- };
124
-
125
- // const sortList = () => {};
126
- const sortDirection = ref('');
127
- const sortField = ref('');
128
-
129
- const sort = (fieldname: string) => {
130
- if (sortField.value === fieldname) {
131
- if (sortDirection.value === 'ASC') sortDirection.value = 'DESC';
132
- else sortField.value = '';
133
- } else {
134
- sortField.value = fieldname;
135
- sortDirection.value = 'ASC';
136
- }
137
- };
138
-
139
- const columns = computed<BagelField[]>(
140
- (): BagelField[] => props.schema ||
141
- Object.keys(props.data[0]).map((k: string) => ({ id: k, inputType: 'PlainText' })),
142
- );
143
-
144
- function getPillClass(row: Record<string, any>, field: BagelField) {
145
- return (
146
- field.refFields?.map((k) => row[field.id][k]).join(' ') || row[field.id].id
147
- );
148
- }
149
- </script>
150
-
151
- <style scoped>
152
- .Paid {
153
- background-color: var(--bgl-green);
154
- color: white;
155
- }
156
-
157
- .Error {
158
- background-color: var(--bgl-red-tint);
159
- color: var(--bgl-red);
160
- }
161
-
162
- .list-arrows {
163
- opacity: 0;
164
- }
165
-
166
- .list-arrows .icon-font {
167
- transition: all ease-in-out 0.2s;
168
- }
169
-
170
- .list-arrows.sorted {
171
- opacity: 1;
172
- }
173
-
174
- .list-arrows.sorted .desc {
175
- transform: rotate(180deg);
176
- }
177
-
178
- table {
179
- border-collapse: separate;
180
- border-spacing: 0 15px;
181
- border-collapse: collapse;
182
- }
183
-
184
- th {
185
- font-weight: 400;
186
- }
187
-
188
- .row {
189
- border-bottom: 1px solid var(--border-color);
190
- cursor: pointer;
191
- }
192
-
193
- .row.first-row {
194
- font-size: 0.8rem;
195
- color: var(--bgl-black-tint);
196
- position: sticky;
197
- top: 0;
198
- z-index: 2;
199
- background: var(--bgl-white);
200
- height: 50px;
201
- vertical-align: bottom;
202
- }
203
-
204
- .row.first-row::after {
205
- content: "";
206
- border-bottom: 1px solid var(--border-color);
207
- position: absolute;
208
- left: 0;
209
- right: 0;
210
- bottom: -1px;
211
- }
212
-
213
- .first-row .col {
214
- cursor: pointer;
215
- background: var(--bgl-white);
216
- }
217
-
218
- .col {
219
- white-space: nowrap;
220
- padding: 14px;
221
- transition: var(--bgl-transition);
222
- line-height: 1;
223
- padding-left: 1rem;
224
- padding-right: 1rem;
225
- align-items: center;
226
- }
227
-
228
- .col > div {
229
- display: flex;
230
- gap: 0.5rem;
231
- }
232
-
233
- .max-col-width {
234
- max-width: 30vw;
235
- overflow: hidden;
236
- text-overflow: ellipsis;
237
- }
238
-
239
- .col.check .icon-font {
240
- border-radius: 100%;
241
- background: var(--bgl-blue-20);
242
- color: var(--bgl-primary);
243
- width: 20px;
244
- height: 20px;
245
- display: flex;
246
- align-items: center;
247
- justify-content: center;
248
- margin-top: -2px;
249
- }
250
-
251
- .rows {
252
- font-size: 0.8125em;
253
- }
254
-
255
- .table-list {
256
- height: 100%;
257
- position: relative;
258
- padding-left: 0 !important;
259
- padding-right: 0 !important;
260
- overflow: auto;
261
- }
262
-
263
- .BagelTable .table-list {
264
- overflow: unset;
265
- }
266
-
267
- .row-item {
268
- height: 50px;
269
- transition: all 200ms ease;
270
- }
271
-
272
- .row-item:hover {
273
- background: var(--bgl-gray-light);
274
- }
275
-
276
- .infinite-wrapper {
277
- overflow-y: auto;
278
- width: 100%;
279
- }
280
- </style>
@@ -1,76 +0,0 @@
1
- <template>
2
- <div>
3
- <FormKit
4
- type="form"
5
- :modelValue="modelValue"
6
- @update:modelValue="handleEmit"
7
- @submit="runSubmit"
8
- :submitLabel="i18nT('save')"
9
- >
10
- <FormKitSchema
11
- :schema="schema"
12
- :data="data"
13
- />
14
- </FormKit>
15
- <Btn
16
- class="del-top"
17
- v-if="modelValue?.id && onDelete"
18
- @click="runDelete"
19
- value="Delete"
20
- flat
21
- icon="delete"
22
- color="red"
23
- thin
24
- />
25
- </div>
26
- </template>
27
-
28
- <script lang="ts" setup>
29
- import { reactive } from 'vue';
30
- import { type FormKitSchemaDefinition } from '@formkit/core';
31
-
32
- import { Btn } from '@bagelink/vue';
33
- import { useModal, useI18nT } from '..';
34
-
35
- const { showModal } = useModal();
36
- const i18nT = useI18nT();
37
- const emits = defineEmits(['update:modelValue', 'submit']);
38
- const handleEmit = (val: any) => emits('update:modelValue', val);
39
- const runSubmit = (val: any) => emits('submit', val);
40
-
41
- const props = defineProps<{
42
- modelValue?: any;
43
- schema: FormKitSchemaDefinition;
44
- // eslint-disable-next-line no-unused-vars
45
- onDelete?: ((id: string) => void);
46
- }>();
47
-
48
- const data = reactive({
49
- ...props.modelValue,
50
- t: (val: string) => i18nT?.(val) || val,
51
- });
52
-
53
- const runDelete = () => {
54
- showModal(
55
- {
56
- class: 'small-modal',
57
- title: i18nT('Are you sure?'),
58
- actions: [
59
- {
60
- value: 'Confirm',
61
- color: 'red',
62
- onClick: () => props.onDelete?.(data.id),
63
- },
64
- { value: 'Cancel', color: 'gray' },
65
- ],
66
- },
67
- { default: i18nT('form.deleteMessage') },
68
- );
69
- };
70
- </script>
71
-
72
- <style>
73
- .del-top {
74
- transform: translateY(-2.6rem);
75
- }
76
- </style>