bt-core-app 1.4.2 → 1.4.4

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 (95) hide show
  1. package/dist/index.d.ts +1273 -41
  2. package/package.json +9 -2
  3. package/dist/composables/actions-tracker.d.ts +0 -19
  4. package/dist/composables/actions.d.ts +0 -79
  5. package/dist/composables/api.d.ts +0 -86
  6. package/dist/composables/auth.d.ts +0 -70
  7. package/dist/composables/cosmetics.d.ts +0 -38
  8. package/dist/composables/csv.d.ts +0 -20
  9. package/dist/composables/dates.d.ts +0 -15
  10. package/dist/composables/demo.d.ts +0 -9
  11. package/dist/composables/dialogs.d.ts +0 -75
  12. package/dist/composables/document-meta.d.ts +0 -11
  13. package/dist/composables/draggable.d.ts +0 -56
  14. package/dist/composables/filters.d.ts +0 -11
  15. package/dist/composables/forage.d.ts +0 -7
  16. package/dist/composables/helpers.d.ts +0 -100
  17. package/dist/composables/id.d.ts +0 -1
  18. package/dist/composables/list.d.ts +0 -211
  19. package/dist/composables/navigation.d.ts +0 -89
  20. package/dist/composables/presets.d.ts +0 -8
  21. package/dist/composables/pwa.d.ts +0 -14
  22. package/dist/composables/resizable.d.ts +0 -35
  23. package/dist/composables/rules.d.ts +0 -7
  24. package/dist/composables/stores.d.ts +0 -111
  25. package/dist/composables/track.d.ts +0 -12
  26. package/dist/composables/urls.d.ts +0 -22
  27. package/dist/core.d.ts +0 -19
  28. package/dist/types.d.ts +0 -13
  29. package/dist/useApi.d.ts +0 -0
  30. package/src/assets/vue.svg +0 -1
  31. package/src/components/BT-Btn.vue +0 -41
  32. package/src/components/BT-Col.vue +0 -36
  33. package/src/components/BT-Field-Checkbox.vue +0 -70
  34. package/src/components/BT-Field-Date.vue +0 -108
  35. package/src/components/BT-Field-Entity.vue +0 -48
  36. package/src/components/BT-Field-Select.vue +0 -67
  37. package/src/components/BT-Field-String.vue +0 -78
  38. package/src/components/BT-Field-Switch.vue +0 -68
  39. package/src/components/BT-Field-Tags.vue +0 -66
  40. package/src/components/BT-Field-Textarea.vue +0 -67
  41. package/src/components/BT-Field-Trigger.vue +0 -315
  42. package/src/components/BT-Header-Option.vue +0 -39
  43. package/src/components/BT-Json.vue +0 -67
  44. package/src/components/BT-Nav-Menu-Item.vue +0 -60
  45. package/src/components/BT-Nav-Sidebar.vue +0 -78
  46. package/src/components/BT-Select-List-Box.vue +0 -258
  47. package/src/components/BT-Select.vue +0 -46
  48. package/src/components/BT-Snack.vue +0 -31
  49. package/src/components/BT-Span.vue +0 -21
  50. package/src/components/Dialog-Confirm.vue +0 -47
  51. package/src/components/Dialog-Select-Date.vue +0 -89
  52. package/src/components/Dialog-Select.vue +0 -140
  53. package/src/components/Dialog-Text.vue +0 -59
  54. package/src/composables/actions-tracker.ts +0 -99
  55. package/src/composables/actions.ts +0 -354
  56. package/src/composables/api.ts +0 -479
  57. package/src/composables/auth.ts +0 -452
  58. package/src/composables/cosmetics.ts +0 -177
  59. package/src/composables/csv.ts +0 -198
  60. package/src/composables/dates.ts +0 -86
  61. package/src/composables/demo.ts +0 -33
  62. package/src/composables/dialogs.ts +0 -114
  63. package/src/composables/document-meta.ts +0 -44
  64. package/src/composables/draggable.ts +0 -189
  65. package/src/composables/filters.ts +0 -264
  66. package/src/composables/forage.ts +0 -49
  67. package/src/composables/helpers.ts +0 -647
  68. package/src/composables/id.ts +0 -20
  69. package/src/composables/list.ts +0 -604
  70. package/src/composables/navigation.ts +0 -222
  71. package/src/composables/presets.ts +0 -28
  72. package/src/composables/pwa.ts +0 -97
  73. package/src/composables/resizable.ts +0 -382
  74. package/src/composables/rules.ts +0 -40
  75. package/src/composables/stores.ts +0 -818
  76. package/src/composables/track.ts +0 -55
  77. package/src/composables/urls.ts +0 -66
  78. package/src/core.ts +0 -113
  79. package/src/index.ts +0 -48
  80. package/src/types.ts +0 -17
  81. package/src/useApi.ts +0 -68
  82. package/src/vite-env.d.ts +0 -1
  83. package/test/api.test.ts +0 -84
  84. package/test/auth.test.ts +0 -74
  85. package/test/forage.test.ts +0 -31
  86. package/test/helpers.test.ts +0 -231
  87. package/test/navigation.test.ts +0 -99
  88. package/test/stores-last-update.test.ts +0 -138
  89. package/test/stores-session.test.ts +0 -118
  90. package/test/track.test.ts +0 -29
  91. package/test/urls.test.ts +0 -42
  92. package/test/utils.ts +0 -15
  93. package/tsconfig.json +0 -28
  94. package/tsconfig.node.json +0 -11
  95. package/vite.config.ts +0 -45
@@ -1,258 +0,0 @@
1
- <template>
2
- <v-col
3
- :class="colClass"
4
- :lg="mLg"
5
- :md="mMd"
6
- :sm="mSm"
7
- :cols="cols">
8
- <v-list-item v-if="!alwaysOpen && mIsSelecting" @click="mIsSelecting = false"
9
- :subtitle="label">
10
- <template #append>
11
- <v-row class="ma-0 pa-0">
12
- <slot name="actions" />
13
- <v-icon>mdi-chevron-up</v-icon>
14
- <slot name="actionsRight" />
15
- <v-menu
16
- v-if="showSettings"
17
- offset-y
18
- :close-on-content-click="false">
19
- <template v-slot:activator="{ props }">
20
- <v-btn
21
- icon="mdi-cog"
22
- :size="mSize"
23
- title="Settings"
24
- v-bind="props" />
25
- </template>
26
- <v-list>
27
- <slot name="settings" />
28
- </v-list>
29
- </v-menu>
30
- </v-row>
31
- </template>
32
- </v-list-item>
33
- <v-slide-y-transition hide-on-leave group>
34
- <v-text-field
35
- v-if="(alwaysOpen || mIsSelecting) && showSearch !== false && isLengthyArray(searchProps)"
36
- @click:prepend-inner="ui.searchString.value = undefined"
37
- hide-details
38
- key="1"
39
- placeholder="Search"
40
- :prepend-inner-icon="ui.searchString.value != null ? 'mdi-close' : undefined"
41
- v-model="ui.searchString.value">
42
- <template #append-inner>
43
- <v-btn
44
- v-if="canRefresh"
45
- @click="ui.refresh({ deepRefresh: true })"
46
- icon="mdi-refresh"
47
- :size="mSize"
48
- variant="text" />
49
- </template>
50
-
51
- </v-text-field>
52
- <v-virtual-scroll
53
- v-if="(alwaysOpen || mIsSelecting) && useVirtualScroller"
54
- :height="height"
55
- :items="ui.filteredItems.value"
56
- key="2">
57
- <template #default="{ item }">
58
- <slot name="item" v-bind:item="item" v-bind:selectItem="selectItem(item)" :active="isActive(item)">
59
- <v-list-item @click="selectItem(item)" :active="isActive(item)" color="primary">
60
- <slot v-bind:item="item">
61
- <v-list-item-title v-if="itemText != null || textFilter != null || textFunction != null">
62
- {{ displayTitle(item) }}
63
- </v-list-item-title>
64
- <v-list-item-subtitle v-if="itemSubtext != null || subtextFilter != null || subtextFunction != null">
65
- {{ displaySubtitle(item) }}
66
- </v-list-item-subtitle>
67
- </slot>
68
-
69
- </v-list-item>
70
- </slot>
71
- </template>
72
- </v-virtual-scroll>
73
- <v-list
74
- v-else-if="alwaysOpen || mIsSelecting"
75
- :bg-color="transparent ? 'transparent' : undefined"
76
- :height="height"
77
- key="3">
78
- <v-list-item
79
- v-if="canSelectNone"
80
- key="-1"
81
- density="compact"
82
- @click="selectItem(null)"
83
- subtitle="(Select None)" />
84
-
85
- <template v-for="(fItem, fInd) in ui.filteredItems.value">
86
- <slot name="item" :items="fItem" :index="fInd" :size="mSize">
87
- <v-list-item
88
- :active="isActive(fItem)"
89
- :key="fInd"
90
- :value="fItem"
91
- @click="selectItem(fItem)">
92
- <slot :item="fItem" :index="fInd" :size="mSize">
93
- <v-list-item-title v-if="itemText != null || textFilter != null || textFunction != null">
94
- {{ displayTitle(fItem) }}
95
- </v-list-item-title>
96
- <v-list-item-subtitle v-if="itemSubtext != null || subtextFilter != null || subtextFunction != null">
97
- {{ displaySubtitle(fItem) }}
98
- </v-list-item-subtitle>
99
- </slot>
100
- </v-list-item>
101
- </slot>
102
- </template>
103
- </v-list>
104
- <slot v-else name="selected" :item="selectedItem" :open="openList">
105
- <v-list-item
106
- @click="openList"
107
- key="4"
108
- :title="label"
109
- :subtitle="displayTitle(selectedItem) ?? placeholder">
110
- <template #append>
111
- <v-row no-gutters>
112
- <slot name="actions" />
113
- <v-icon>mdi-chevron-down</v-icon>
114
- <slot name="actionsRight" />
115
- <v-menu
116
- v-if="showSettings"
117
- offset-y
118
- :close-on-content-click="false">
119
- <template v-slot:activator="{ props }">
120
- <v-btn
121
- icon
122
- v-bind="props"
123
- :size="mSize"
124
- title="Settings" />
125
- </template>
126
- <v-list>
127
- <slot name="settings" />
128
- </v-list>
129
- </v-menu>
130
- </v-row>
131
- </template>
132
- </v-list-item>
133
- </slot>
134
-
135
- </v-slide-y-transition>
136
-
137
- <v-overlay
138
- v-model="ui.isLoading.value"
139
- class="align-center justify-center text-center"
140
- contained
141
- persistent>
142
- <v-progress-circular indeterminate />
143
- <p>{{ ui.loadingMsg.value }}</p>
144
- </v-overlay>
145
- </v-col>
146
-
147
- </template>
148
-
149
- <script setup lang="ts">
150
- import { type ListProps, useList } from '../composables/list'
151
- import { computed, inject, ref } from 'vue'
152
- import { useFilters } from '../composables/filters'
153
- import { isLengthyArray, nestedValue } from '../composables/helpers'
154
-
155
- defineOptions({
156
- inheritAttrs: false
157
- })
158
-
159
- interface SelectProps extends ListProps {
160
- alwaysOpen?: boolean
161
- canRefresh?: boolean
162
- canSearch?: boolean
163
- canSelectNone?: boolean
164
- colClass?: string
165
- cols?: string | boolean
166
- height?: string
167
- isMobile?: boolean
168
- isEditing?: boolean
169
- isSelecting?: boolean
170
- items?: [],
171
- itemSubtext?: string
172
- itemText?: string
173
- itemValue?: string //inherited
174
- label?: string
175
- lg?: string | boolean
176
- modelValue?: any
177
- md?: string | boolean
178
- nav?: string
179
- placeholder?: string
180
- showSettings?: boolean
181
- sm?: string | boolean
182
- subtextFilter?: string
183
- subtextFunction?: Function
184
- textFilter?: string
185
- textFunction?: Function
186
- transparent?: boolean
187
- useVirtualScroller?: boolean
188
- }
189
-
190
- const emit = defineEmits(['update:modelValue', 'change'])
191
-
192
- const props = withDefaults(defineProps<SelectProps>(), {
193
- canRefresh: true,
194
- height: '400',
195
- isEditing: undefined,
196
- sortOrder: 'Ascending',
197
- cols: '12',
198
- lg: false,
199
- md: false,
200
- sm: '6'
201
- })
202
-
203
- const mIsSelecting = ref(props.alwaysOpen ?? props.isSelecting ?? false)
204
- const mSize = inject('size', () => ref('small'), true)
205
- const mIsEditing = inject('isEditing', () => ref(false), true)
206
- const cIsEditing = computed(() => props.isEditing ?? mIsEditing.value)
207
-
208
- const ui = useList(props, undefined, {
209
- useBladeSrc: false,
210
- useRouteSrc: false
211
- })
212
-
213
- const filters = useFilters()
214
-
215
- const displaySubtitle = computed(() => (item: any) => {
216
- let v = props.subtextFunction != null ? props.subtextFunction(item) : item
217
- v = props.itemSubtext != null ? nestedValue(v, props.itemSubtext) : v
218
- return props.subtextFilter != null ? filters.findFilter(props.subtextFilter)(v) : v
219
- })
220
-
221
- const displayTitle = computed(() => (item: any) => {
222
- let v = props.textFunction != null ? props.textFunction(item) : item
223
- v = props.itemText != null ? nestedValue(v, props.itemText) : v
224
- return props.textFilter != null ? filters.findFilter(props.textFilter)(v) : v
225
- })
226
-
227
- const isActive = computed(() => (item: any) => {
228
- return (props.itemValue ? item[props.itemValue] : item) == props.modelValue
229
- })
230
-
231
- function openList() {
232
- if (cIsEditing.value)
233
- mIsSelecting.value = true
234
- }
235
-
236
- function selectItem(item: any) {
237
- mIsSelecting.value = false
238
-
239
- if (item != null || props.canSelectNone) {
240
- let v = item
241
-
242
- if (item != null && props.itemValue != null)
243
- v = item[props.itemValue]
244
-
245
- emit('update:modelValue', v)
246
- emit('change', v)
247
- }
248
- }
249
-
250
- const selectedItem = computed(() => {
251
- return props.modelValue != null ? ui.asyncItems.value.find((x: any) => (x.id == props.modelValue)) : null
252
- })
253
-
254
- const mIsMobile = inject('isMobile', () => ref(false), true)
255
- const mLg = computed(() => (props.isMobile ?? mIsMobile.value) ? false : props.lg)
256
- const mMd = computed(() => (props.isMobile ?? mIsMobile.value) ? false : props.md)
257
- const mSm = computed(() => (props.isMobile ?? mIsMobile.value) ? false : props.sm)
258
- </script>
@@ -1,46 +0,0 @@
1
- <template>
2
- <v-select
3
- :append-icon="canRefresh ? 'mdi-refresh' : undefined"
4
- :clearable="canSelectNone"
5
- @click:append-icon="ui.refresh({ deepRefresh: true })"
6
- hide-details
7
- :items="ui.filteredItems.value"
8
- :item-title="itemText"
9
- :item-value="itemValue"
10
- :variant="fieldVariant" />
11
- </template>
12
-
13
- <script setup lang="ts">
14
- import { type ListProps, type ListEvents, useList } from '../composables/list';
15
- import { type FieldVariant } from '../types'
16
-
17
- interface SelectEvents extends ListEvents {
18
-
19
- }
20
-
21
- interface SelectProps extends ListProps {
22
- additionalUrl?: string
23
- canRefresh?: boolean
24
- canSelectNone?: boolean
25
- fieldVariant?: FieldVariant
26
- items?: [],
27
- itemText?: string
28
- itemValue?: string //inherited
29
- multiple?: boolean
30
- nav?: string
31
- onFilter?: Function
32
- textFilter?: string
33
- }
34
-
35
- const emit = defineEmits<SelectEvents>()
36
-
37
- const props = withDefaults(defineProps<SelectProps>(), {
38
- sortOrder: 'Ascending'
39
- })
40
-
41
- const ui = useList(props, emit, {
42
- useBladeSrc: false,
43
- useRouteSrc: false
44
- })
45
-
46
- </script>
@@ -1,31 +0,0 @@
1
- <template>
2
- <v-snackbar
3
- v-model="showSnack"
4
- :timeout="cTimeout">
5
- {{ modelValue }}
6
- </v-snackbar>
7
- </template>
8
-
9
- <script setup lang="ts">
10
- import { computed, ref, watch } from 'vue';
11
-
12
-
13
- interface SnackProps {
14
- isTimed?: boolean
15
- modelValue?: string
16
- timeout?: string,
17
-
18
- }
19
-
20
- const props = withDefaults(defineProps<SnackProps>(), {
21
- isTimed: true,
22
- timeout: '5000'
23
- })
24
-
25
- const cTimeout = computed(() => { return props.isTimed ? props.timeout : -1 })
26
- const showSnack = ref(false)
27
- watch(() => props.modelValue, () => {
28
- showSnack.value = true
29
- })
30
-
31
- </script>
@@ -1,21 +0,0 @@
1
- <template>
2
- <span>{{ prefix }}{{ displayText }}{{ suffix }}</span>
3
- </template>
4
-
5
- <script setup lang="ts">
6
- import { useFilters } from '../composables/filters'
7
- import { computed } from 'vue'
8
-
9
- interface Props {
10
- filter: string
11
- prefix?: string
12
- suffix?: string
13
- value: any
14
- }
15
-
16
- const props = defineProps<Props>()
17
- const { findFilter } = useFilters()
18
- const displayText = computed(() => {
19
- return props.filter ? findFilter(props.filter)(props.value) : props.value
20
- })
21
- </script>
@@ -1,47 +0,0 @@
1
- <template>
2
- <v-dialog v-model="show">
3
- <div>
4
- <v-card :max-width="maxWidth ?? '400'" :min-width="minWidth" :title="title" class="mx-auto">
5
- <v-card-text>
6
- <div class="text-h6">{{ msg }}</div>
7
- </v-card-text>
8
- <v-card-actions>
9
- <v-btn @click="cancel">{{ cancelText ?? 'No' }}</v-btn>
10
- <v-btn @click="confirm">{{ confirmText ?? 'Yes' }}</v-btn>
11
- </v-card-actions>
12
- </v-card>
13
- </div>
14
- </v-dialog>
15
- </template>
16
-
17
- <script setup lang="ts">
18
- import { onMounted } from 'vue';
19
- import { type ConfirmDialogProps } from '../composables/dialogs'
20
-
21
- const props = withDefaults(defineProps<ConfirmDialogProps>(), {
22
- cancelValue: false,
23
- confirmValue: true,
24
- startIncludeDetails: false
25
- })
26
-
27
- // const props = defineProps(['cancelText', 'confirmText', 'msg', 'minWidth', 'title'])
28
-
29
- const emit = defineEmits(['confirm', 'cancel'])
30
-
31
- let show = false
32
-
33
- function cancel() {
34
- show = false
35
- emit('cancel', props.cancelValue)
36
- }
37
-
38
- function confirm() {
39
- show = false
40
- emit('confirm', props.confirmValue)
41
- }
42
-
43
- onMounted(() => {
44
- show = true
45
- })
46
-
47
- </script>
@@ -1,89 +0,0 @@
1
- <template>
2
- <v-dialog v-model="show">
3
- <div>
4
- <v-card
5
- :max-width="maxWidth ?? '400'"
6
- :min-width="minWidth"
7
- class="mx-auto"
8
- :title="title">
9
- <v-card-text class="pa-0">
10
- <VueDatePicker
11
- auto-apply
12
- dark
13
- :enable-time-picker="useTime"
14
- inline
15
- :is-24="false"
16
- :model-auto="range"
17
- :range="range"
18
- :time-picker-inline="!range && useTime"
19
- :timezone="timeZone"
20
- utc
21
- v-bind="$attrs"
22
- v-model="date" />
23
- </v-card-text>
24
- <v-card-actions>
25
- <v-row no-gutters>
26
- <v-col cols="6">
27
- <v-btn v-if="required !== true" block @click="cancel">{{ cancelText ?? 'Cancel' }}</v-btn>
28
- </v-col>
29
- <v-col cols="6">
30
- <v-btn block @click="accept" :disabled="!canAccept">{{ confirmText ?? 'OK' }}</v-btn>
31
- </v-col>
32
- </v-row>
33
- </v-card-actions>
34
- </v-card>
35
- </div>
36
- </v-dialog>
37
- </template>
38
-
39
- <script setup lang="ts">
40
- import { computed, onMounted, ref } from 'vue'
41
- import VueDatePicker from '@vuepic/vue-datepicker'
42
- import '@vuepic/vue-datepicker/dist/main.css'
43
- import { useAuth } from '../composables/auth'
44
- import { type SelectDateProps } from '../composables/dialogs'
45
-
46
- const props = withDefaults(defineProps<SelectDateProps>(), {
47
- cancelValue: false,
48
- height: '400'
49
- })
50
-
51
- const emit = defineEmits(['confirm', 'cancel'])
52
- const date = ref()
53
- const { timeZone } = useAuth()
54
-
55
- const canAccept = computed(() => {
56
- return !props.required || date.value
57
- })
58
-
59
- let show = false
60
-
61
- function accept() {
62
- if (props.required && !date.value) {
63
- //required
64
- return
65
- }
66
-
67
- show = false
68
- emit('confirm', date.value)
69
- }
70
-
71
- // function maybeAccept(items: any) {
72
- // if (!props.multiple) {
73
- // if (isArrayOfLength(items, 1) || (props.canUnselect && !isLengthyArray(items))) {
74
- // show = false
75
- // emit('confirm', getSelectedValues(items))
76
- // }
77
- // }
78
- // }
79
-
80
- function cancel() {
81
- show = false
82
- emit('cancel', undefined)
83
- }
84
-
85
- onMounted(() => {
86
- show = true
87
- })
88
-
89
- </script>
@@ -1,140 +0,0 @@
1
- <template>
2
- <v-dialog v-model="show">
3
- <div>
4
- <v-card
5
- :max-width="maxWidth ?? '400'"
6
- :min-width="minWidth"
7
- class="mx-auto"
8
- :title="title">
9
- <!-- <v-card-title v-if="title != null">{{ title }}</v-card-title> -->
10
- <v-card-text class="pa-0">
11
- <v-text-field
12
- v-if="ui.showSearch.value"
13
- append-inner-icon="mdi-magnify"
14
- density="compact"
15
- hide-details
16
- placeholder="Search"
17
- v-model="ui.searchString.value" />
18
- <!-- <div v-if="multiple" @click="selectAll" class="text-center my-1">
19
- <v-btn>Select All</v-btn>
20
- </div> -->
21
- <v-list v-if="isLengthyArray(ui.filteredItems.value)"
22
- class="overflow-y-auto"
23
- v-model:selected="selection"
24
- :height="height"
25
- :select-strategy="multiple ? 'independent' : 'single-independent'"
26
- @update:selected="maybeAccept">
27
- <template v-for="(fItem) in ui.filteredItems.value" :key="index">
28
- <v-list-item :value="fItem">
29
- <slot v-bind:item="fItem">
30
- <v-list-item-title v-if="itemText != null || textFilter != null || textFunction != null">
31
- {{ displayTitle(fItem) }}
32
- </v-list-item-title>
33
- <v-list-item-subtitle v-if="itemSubtext != null || subtextFilter != null || subtextFunction != null">
34
- {{ displaySubtitle(fItem) }}
35
- </v-list-item-subtitle>
36
- </slot>
37
- </v-list-item>
38
- </template>
39
- </v-list>
40
- </v-card-text>
41
- <v-card-actions>
42
- <v-row no-gutters>
43
- <v-col :cols="multiple ? 6 : 12">
44
- <v-btn v-if="required !== true" block @click="cancel">{{ cancelText ?? 'Cancel' }}</v-btn>
45
- </v-col>
46
- <v-col v-if="multiple == true" cols="6">
47
- <v-btn block @click="accept" :disabled="!canAccept">{{ confirmText ?? 'OK' }}</v-btn>
48
- </v-col>
49
-
50
- </v-row>
51
- </v-card-actions>
52
- <v-overlay
53
- v-model="ui.isLoading.value"
54
- class="align-center justify-center text-center"
55
- contained
56
- persistent>
57
- <v-progress-circular indeterminate />
58
- <p>{{ ui.loadingMsg }}</p>
59
- </v-overlay>
60
- </v-card>
61
- </div>
62
- </v-dialog>
63
- </template>
64
-
65
- <script setup lang="ts">
66
- import { computed, onMounted, ref } from 'vue';
67
- import { isLengthyArray, isArrayOfLength, nestedValue } from '../composables/helpers'
68
- import { useFilters } from '../composables/filters'
69
- import { useList } from '../composables/list';
70
- import { type SelectDialogProps } from '../composables/dialogs'
71
-
72
- const props = withDefaults(defineProps<SelectDialogProps>(), {
73
- cancelValue: false,
74
- height: '400',
75
- showSearch: true
76
- })
77
-
78
- const emit = defineEmits(['confirm', 'cancel'])
79
-
80
- const ui = useList(props)
81
- const filters = useFilters()
82
- const selection = ref([])
83
-
84
- const displaySubtitle = computed(() => (item: any) => {
85
- let v = props.subtextFunction != null ? props.subtextFunction(item) : item
86
- v = props.itemSubtext != null ? nestedValue(v, props.itemSubtext) : v
87
- return props.subtextFilter != null ? filters.findFilter(props.subtextFilter)(v) : v
88
- })
89
-
90
- const displayTitle = computed(() => (item: any) => {
91
- let v = props.textFunction != null ? props.textFunction(item) : item
92
- v = props.itemText != null ? nestedValue(v, props.itemText) : v
93
- return props.textFilter != null ? filters.findFilter(props.textFilter)(v) : v
94
- })
95
-
96
- const canAccept = computed(() => {
97
- return !props.required || isLengthyArray(selection.value)
98
- })
99
-
100
- let show = false
101
-
102
- function getSelectedValues(items: any) {
103
- const res = props.itemValue != null ? items.map((x: any) => nestedValue(x, props.itemValue)) : items
104
- if (props.multiple) {
105
- return res
106
- }
107
- else {
108
- return res.length > 0 ? res[0] : null
109
- }
110
- }
111
-
112
- function accept() {
113
- if (props.required && !isLengthyArray(selection.value)) {
114
- //required
115
- return
116
- }
117
-
118
- show = false
119
- emit('confirm', getSelectedValues(selection.value))
120
- }
121
-
122
- function maybeAccept(items: any) {
123
- if (!props.multiple) {
124
- if (isArrayOfLength(items, 1) || (props.canUnselect && !isLengthyArray(items))) {
125
- show = false
126
- emit('confirm', getSelectedValues(items))
127
- }
128
- }
129
- }
130
-
131
- function cancel() {
132
- show = false
133
- emit('cancel', undefined)
134
- }
135
-
136
- onMounted(() => {
137
- show = true
138
- })
139
-
140
- </script>