bt-core-app 1.4.2 → 1.4.3

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 (68) hide show
  1. package/package.json +8 -2
  2. package/dist/useApi.d.ts +0 -0
  3. package/src/assets/vue.svg +0 -1
  4. package/src/components/BT-Btn.vue +0 -41
  5. package/src/components/BT-Col.vue +0 -36
  6. package/src/components/BT-Field-Checkbox.vue +0 -70
  7. package/src/components/BT-Field-Date.vue +0 -108
  8. package/src/components/BT-Field-Entity.vue +0 -48
  9. package/src/components/BT-Field-Select.vue +0 -67
  10. package/src/components/BT-Field-String.vue +0 -78
  11. package/src/components/BT-Field-Switch.vue +0 -68
  12. package/src/components/BT-Field-Tags.vue +0 -66
  13. package/src/components/BT-Field-Textarea.vue +0 -67
  14. package/src/components/BT-Field-Trigger.vue +0 -315
  15. package/src/components/BT-Header-Option.vue +0 -39
  16. package/src/components/BT-Json.vue +0 -67
  17. package/src/components/BT-Nav-Menu-Item.vue +0 -60
  18. package/src/components/BT-Nav-Sidebar.vue +0 -78
  19. package/src/components/BT-Select-List-Box.vue +0 -258
  20. package/src/components/BT-Select.vue +0 -46
  21. package/src/components/BT-Snack.vue +0 -31
  22. package/src/components/BT-Span.vue +0 -21
  23. package/src/components/Dialog-Confirm.vue +0 -47
  24. package/src/components/Dialog-Select-Date.vue +0 -89
  25. package/src/components/Dialog-Select.vue +0 -140
  26. package/src/components/Dialog-Text.vue +0 -59
  27. package/src/composables/actions-tracker.ts +0 -99
  28. package/src/composables/actions.ts +0 -354
  29. package/src/composables/api.ts +0 -479
  30. package/src/composables/auth.ts +0 -452
  31. package/src/composables/cosmetics.ts +0 -177
  32. package/src/composables/csv.ts +0 -198
  33. package/src/composables/dates.ts +0 -86
  34. package/src/composables/demo.ts +0 -33
  35. package/src/composables/dialogs.ts +0 -114
  36. package/src/composables/document-meta.ts +0 -44
  37. package/src/composables/draggable.ts +0 -189
  38. package/src/composables/filters.ts +0 -264
  39. package/src/composables/forage.ts +0 -49
  40. package/src/composables/helpers.ts +0 -647
  41. package/src/composables/id.ts +0 -20
  42. package/src/composables/list.ts +0 -604
  43. package/src/composables/navigation.ts +0 -222
  44. package/src/composables/presets.ts +0 -28
  45. package/src/composables/pwa.ts +0 -97
  46. package/src/composables/resizable.ts +0 -382
  47. package/src/composables/rules.ts +0 -40
  48. package/src/composables/stores.ts +0 -818
  49. package/src/composables/track.ts +0 -55
  50. package/src/composables/urls.ts +0 -66
  51. package/src/core.ts +0 -113
  52. package/src/index.ts +0 -48
  53. package/src/types.ts +0 -17
  54. package/src/useApi.ts +0 -68
  55. package/src/vite-env.d.ts +0 -1
  56. package/test/api.test.ts +0 -84
  57. package/test/auth.test.ts +0 -74
  58. package/test/forage.test.ts +0 -31
  59. package/test/helpers.test.ts +0 -231
  60. package/test/navigation.test.ts +0 -99
  61. package/test/stores-last-update.test.ts +0 -138
  62. package/test/stores-session.test.ts +0 -118
  63. package/test/track.test.ts +0 -29
  64. package/test/urls.test.ts +0 -42
  65. package/test/utils.ts +0 -15
  66. package/tsconfig.json +0 -28
  67. package/tsconfig.node.json +0 -11
  68. package/vite.config.ts +0 -45
@@ -1,222 +0,0 @@
1
- //nav item needs to have a 'ignore Suspension' prop
2
- import { useDataUrl } from '../composables/urls'
3
- import { appendUrl, deepSelect } from '../composables/helpers'
4
- import { ref, type Ref } from 'vue'
5
- import { type AuthItem } from './auth'
6
-
7
- export interface ExternalParty {
8
- party?: string
9
- property?: string
10
- }
11
-
12
- export interface ExternalNavigation {
13
- canPull?: boolean
14
- canPush?: boolean
15
- convertFunc?: Function
16
- name?: string
17
- localNavigation?: string
18
- localDisplayPath?: string
19
- localComparePath?: string
20
- syncComparePath?: string
21
- syncDisplayPath?: string
22
- syncIDPath?: string
23
- }
24
-
25
- export interface NavigationItem extends AuthItem {
26
- /**aliases are other names that could use this navigation item's set of permissions, etc.*/
27
- aliases?: string[]
28
- /**potentially the nav that leads to the archive */
29
- archiveName?: string
30
- /**the name of the background img to show when the route opens this nav */
31
- background?: string
32
- /**how long until locally cached data is refreshed */
33
- cacheExpiryHours?: number
34
- /**any children of this nav item */
35
- children?: NavigationItem[]
36
- /**the name that will be displayed in the navigation menu */
37
- displayName?: string
38
- /**where credentials can be found for external parties*/
39
- externalPartyCredentialNavigation?: string
40
- /**possible external parties to connect to and sync with */
41
- externalParties?: ExternalParty[]
42
- /**possible external party navigation items and how to connect/sync */
43
- externalNavigations?: ExternalNavigation[]
44
- /**will hide app bar if set to true when the route opens this nav */
45
- hideAppBar?: boolean
46
- /**will hide the nav sidebar if set to true when the route opens this nav */
47
- hideNavigation?: boolean
48
- /**will open a dialog box to confirm navigating away from this route */
49
- hesitate?: boolean
50
- /**the mdi icon that goes with this nav item. Will show in places like the nav menu */
51
- icon?: string
52
- /**default to false. True will mean that even is account is suspended, this will still allow navigation */
53
- ignoreSuspension?: boolean
54
- /**default to true. When false will hide from nav menu */
55
- isInNavMenu?: boolean
56
- /**the microservice the leads to the default url to obtain data from. Defaults to 'default'. */
57
- microservice?: string
58
- /**the name of this nav item. */
59
- name?: string
60
- /**the url path on top of the base microservice url */
61
- path?: string
62
- /**permissions that are required for this navItem. All these permissions must be met. */
63
- permissions?: string[]
64
- /**default to true. When false will allow universal access regardless of permission */
65
- requiresAuth?: boolean
66
- /**the name of the route to access individual items */
67
- singleName?: string
68
- /**this nav item is restricted to these subscriptions. So the user needs to have at least one of these subscription codes. */
69
- subscriptions?: string[]
70
- /**this nav item is preferred in this subscription codes. */
71
- subFilters?: string[]
72
- }
73
-
74
- const appBar = ref(true)
75
- const appNavigation = ref(false)
76
- const backgroundName: Ref<string | undefined> = ref()
77
- const hesitate = ref(false)
78
- let removeHesitateListener: any = null
79
-
80
- export interface BTNavigation {
81
- showAppBar: Ref<boolean>
82
- showAppNavigation: Ref<boolean>
83
- backgroundName: Ref<string | undefined>
84
- hesitate: Ref<boolean>
85
- navigationItems: NavigationItem[],
86
- findArchiveName: (navName?: string) => string | undefined
87
- findCacheHours: (navName?: string) => number
88
- findDisplay: (navName?: string) => string | undefined
89
- findIcon: (navName?: string) => string | undefined
90
- findItem: (navName?: string | NavigationItem) => NavigationItem | null
91
- findStoreName: (navName?: string) => string
92
- findPath: (navName?: string) => string | undefined
93
- findSingleDisplay: (navName?: string) => string | undefined
94
- updateNavigationProperties: (navName?: string | NavigationItem) => void
95
- }
96
-
97
- export interface UseNavigationOptions {
98
- defaultCacheExpiryHours?: number
99
- navItems?: NavigationItem[]
100
- }
101
-
102
- let current: BTNavigation
103
-
104
- export function useNavigation(): BTNavigation {
105
- return current
106
- }
107
-
108
- export function createNavigation(options: UseNavigationOptions): BTNavigation {
109
- const cacheExpiryHours = options.defaultCacheExpiryHours ?? 7
110
- const navigationList = options.navItems ?? []
111
-
112
- function findArchiveName(navName?: string): string | undefined {
113
- return findItem(navName)?.archiveName
114
- }
115
-
116
- function findCacheHours(navName?: string): number {
117
- return findItem(navName)?.cacheExpiryHours ?? cacheExpiryHours
118
- }
119
-
120
- function findDisplay(navName?: string): string | undefined {
121
- return findItem(navName)?.displayName
122
- }
123
-
124
- function findIcon(navName?: string): string | undefined {
125
- return findItem(navName)?.icon
126
- }
127
-
128
- function findItem(navName?: string | NavigationItem) {
129
- if (navName == null) return null
130
- if (typeof navName != 'string') return navName
131
-
132
- const items = deepSelect(navigationList, (x: NavigationItem) => x.children) as NavigationItem[]
133
-
134
- return items.find(navItem => navItem.name == navName ||
135
- navItem.singleName == navName ||
136
- navItem.aliases?.some(y => y == navName)) ?? null
137
- }
138
-
139
- /**defaults to microservice of default */
140
- function findPath(navName?: string) {
141
- const navItem = findItem(navName)
142
- if (navItem == null) return undefined
143
-
144
- let vPath = useDataUrl(navItem.microservice ?? 'default') ?? ''
145
-
146
- if (navItem.path != null)
147
- vPath = appendUrl(vPath, navItem.path)
148
-
149
- if (vPath?.endsWith('/'))
150
- vPath = vPath.slice(0, vPath.length - 1)
151
-
152
- return vPath
153
- }
154
-
155
- /**finds display name and attempts to remove plural suffixes */
156
- function findSingleDisplay(navName?: string): string | undefined {
157
- const item = findItem(navName)
158
-
159
- if (item?.singleName != null)
160
- return item.singleName
161
-
162
- const displayName = item?.displayName
163
-
164
- if (displayName == null) return undefined
165
-
166
- if (displayName.endsWith('ies'))
167
- return displayName.slice(0, displayName.length - 3)
168
-
169
- if (displayName.endsWith('es'))
170
- return displayName.slice(0, displayName.length - 2)
171
-
172
- if (displayName.endsWith('s'))
173
- return displayName.slice(0, displayName.length - 1)
174
-
175
- return displayName
176
- }
177
-
178
- function findStoreName(navName?: string) {
179
- const navItem = findItem(navName)
180
- return navItem?.name ?? navItem?.singleName ?? 'store'
181
- }
182
-
183
- /**updates background, navigation sidebar, and app bar settings */
184
- function updateNavigationProperties(navName?: string | NavigationItem) {
185
- if (navName == null) return
186
-
187
- const item = typeof navName == 'string' ? findItem(navName) : navName
188
-
189
- backgroundName.value = item?.background
190
- appNavigation.value = item?.hideNavigation !== true
191
- appBar.value = item?.hideAppBar !== true
192
-
193
- if (removeHesitateListener != null)
194
- removeHesitateListener()
195
-
196
- hesitate.value = item?.hesitate === true
197
-
198
- if (hesitate.value)
199
- removeHesitateListener = window.addEventListener('beforeunload', e => {
200
- e.preventDefault()
201
- })
202
- }
203
-
204
- current = {
205
- showAppBar: appBar,
206
- showAppNavigation: appNavigation,
207
- backgroundName,
208
- hesitate,
209
- navigationItems: navigationList,
210
- findArchiveName,
211
- findCacheHours,
212
- findDisplay,
213
- findIcon,
214
- findItem,
215
- findStoreName,
216
- findPath,
217
- findSingleDisplay,
218
- updateNavigationProperties
219
- }
220
-
221
- return current
222
- }
@@ -1,28 +0,0 @@
1
- export interface BTPresets {
2
- usePresets(preset?: string): any
3
- }
4
-
5
- export interface CreatePresetsOptions {
6
- presets: any
7
- }
8
-
9
- let current: BTPresets
10
-
11
- export function usePresets(preset?: string): any {
12
- return current.usePresets(preset)
13
- }
14
-
15
- export function createPresets(options: CreatePresetsOptions): BTPresets {
16
-
17
- function usePresets(preset?: string): any {
18
- if (!preset) return {}
19
- let mPreset = preset as keyof typeof options.presets
20
- return options.presets[mPreset] ?? {}
21
- }
22
-
23
- current = {
24
- usePresets
25
- }
26
-
27
- return current
28
- }
@@ -1,97 +0,0 @@
1
- import { tryOnMounted } from '@vueuse/core'
2
- import { ref, type Ref } from 'vue'
3
-
4
- export interface SWEvent extends Event {
5
- detail: any
6
- }
7
-
8
- let updateListener: void | undefined
9
- let controllerChangeListener: void | undefined
10
- let promptListener: void | undefined
11
- let isUpdating = false
12
-
13
- const canInstallApp = ref(false)
14
- const canUpdateApp = ref(false)
15
- const prompt: Ref<any> = ref()
16
- const sWorker: Ref<any> = ref()
17
-
18
- export interface BTPWA {
19
- canInstallApp: Ref<boolean>
20
- canUpdateApp: Ref<boolean>
21
- installApp: () => void
22
- isInstalled: () => boolean
23
- updateApp: () => void
24
- }
25
-
26
- let current: BTPWA
27
-
28
- export function usePWA(): BTPWA {
29
- return current
30
- }
31
-
32
- export function createPWA(): BTPWA {
33
-
34
- function notifyUpdateAvailable(e: any) {
35
- sWorker.value = e.detail
36
- canUpdateApp.value = true
37
- }
38
-
39
- function controllerChanged() {
40
- if (isUpdating) return
41
- isUpdating = true
42
- window.location.reload()
43
- }
44
-
45
- function installApp() {
46
- prompt.value?.prompt()
47
- canInstallApp.value = false
48
- }
49
-
50
- function isInstalled() {
51
- // For iOS
52
- // if (window.navigator.standalone) return true
53
-
54
- // For Android
55
- if (window.matchMedia('(display-mode: standalone)').matches) return true
56
-
57
- // If neither is true, it's not installed
58
- return false
59
- }
60
-
61
- function storePrompt(e: Event) {
62
- e.preventDefault()
63
- canInstallApp.value = true
64
- prompt.value = e
65
- }
66
-
67
- function updateApp() {
68
- canUpdateApp.value = false
69
-
70
- if (!sWorker.value || !sWorker.value.waiting)
71
- return
72
-
73
- sWorker.value.waiting.postMessage({ type: 'SKIP_WAITING' })
74
- }
75
-
76
- tryOnMounted(() => {
77
- if (updateListener == null) {
78
- updateListener = document.addEventListener('swUpdated', notifyUpdateAvailable, { once: true })
79
- }
80
-
81
- if (controllerChangeListener == null)
82
- controllerChangeListener = navigator.serviceWorker.addEventListener('controllerchange', controllerChanged)
83
-
84
- if (promptListener == null)
85
- promptListener = window.addEventListener('beforeinstallprompt', storePrompt)
86
- })
87
-
88
- current = {
89
- canInstallApp,
90
- canUpdateApp,
91
- installApp,
92
- isInstalled,
93
- updateApp
94
- }
95
-
96
- return current
97
- }