bt-core-app 1.1.9 → 1.2.1

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 (73) hide show
  1. package/dist/bt-core-app.js +25270 -15306
  2. package/dist/components/BT-Btn.vue.d.ts +41 -0
  3. package/dist/components/BT-Col.vue.d.ts +49 -0
  4. package/dist/components/BT-Field-Checkbox.vue.d.ts +56 -0
  5. package/dist/components/BT-Field-Date.vue.d.ts +64 -0
  6. package/dist/components/BT-Field-Entity.vue.d.ts +46 -0
  7. package/dist/components/BT-Field-Select.vue.d.ts +54 -0
  8. package/dist/components/BT-Field-String.vue.d.ts +53 -0
  9. package/dist/components/BT-Field-Switch.vue.d.ts +51 -0
  10. package/dist/components/BT-Field-Tags.vue.d.ts +51 -0
  11. package/dist/components/BT-Field-Textarea.vue.d.ts +52 -0
  12. package/dist/components/BT-Field-Trigger.vue.d.ts +79 -0
  13. package/dist/components/BT-Header-Option.vue.d.ts +18 -0
  14. package/dist/components/BT-Json.vue.d.ts +8 -0
  15. package/dist/components/BT-Select-List-Box.vue.d.ts +108 -0
  16. package/dist/components/BT-Select.vue.d.ts +53 -0
  17. package/dist/components/BT-Snack.vue.d.ts +33 -0
  18. package/dist/components/Dialog-Confirm.vue.d.ts +2 -2
  19. package/dist/components/Dialog-Select-Date.vue.d.ts +2 -2
  20. package/dist/components/Dialog-Select.vue.d.ts +2 -2
  21. package/dist/components/Dialog-Text.vue.d.ts +2 -2
  22. package/dist/composables/actions.d.ts +6 -6
  23. package/dist/composables/api.d.ts +1 -0
  24. package/dist/composables/auth.d.ts +1 -0
  25. package/dist/composables/cosmetics.d.ts +3 -1
  26. package/dist/composables/dates.d.ts +1 -0
  27. package/dist/composables/demo.d.ts +1 -0
  28. package/dist/composables/filters.d.ts +1 -0
  29. package/dist/composables/list.d.ts +11 -2
  30. package/dist/composables/navigation.d.ts +1 -0
  31. package/dist/composables/presets.d.ts +1 -0
  32. package/dist/composables/pwa.d.ts +1 -0
  33. package/dist/composables/stores.d.ts +17 -6
  34. package/dist/index.d.ts +11 -12
  35. package/dist/style.css +1 -1
  36. package/dist/types.d.ts +2 -0
  37. package/dist/useApi.d.ts +0 -30
  38. package/package.json +2 -1
  39. package/src/components/BT-Btn.vue +1 -1
  40. package/src/components/BT-Field-Checkbox.vue +70 -0
  41. package/src/components/BT-Field-Date.vue +108 -0
  42. package/src/components/BT-Field-Entity.vue +48 -0
  43. package/src/components/BT-Field-Select.vue +67 -0
  44. package/src/components/BT-Field-String.vue +78 -0
  45. package/src/components/BT-Field-Switch.vue +68 -0
  46. package/src/components/BT-Field-Tags.vue +66 -0
  47. package/src/components/BT-Field-Textarea.vue +67 -0
  48. package/src/components/BT-Field-Trigger.vue +315 -0
  49. package/src/components/BT-Header-Option.vue +39 -0
  50. package/src/components/BT-Json.vue +67 -0
  51. package/src/components/BT-Select-List-Box.vue +258 -0
  52. package/src/components/BT-Select.vue +46 -0
  53. package/src/components/BT-Snack.vue +31 -0
  54. package/src/components/Dialog-Select-Date.vue +1 -1
  55. package/src/composables/actions.ts +6 -6
  56. package/src/composables/api.ts +9 -1
  57. package/src/composables/auth.ts +15 -21
  58. package/src/composables/cosmetics.ts +27 -28
  59. package/src/composables/dates.ts +9 -1
  60. package/src/composables/demo.ts +9 -1
  61. package/src/composables/filters.ts +9 -1
  62. package/src/composables/list.ts +5 -2
  63. package/src/composables/navigation.ts +9 -1
  64. package/src/composables/presets.ts +9 -1
  65. package/src/composables/pwa.ts +9 -1
  66. package/src/composables/stores.ts +32 -11
  67. package/src/core.ts +49 -16
  68. package/src/index.ts +12 -12
  69. package/src/types.ts +5 -1
  70. package/src/useApi.ts +57 -57
  71. package/test/auth.test.ts +63 -0
  72. package/test/stores-last-update.test.ts +4 -4
  73. package/vite.config.ts +6 -2
package/src/useApi.ts CHANGED
@@ -1,68 +1,68 @@
1
- import { inject } from 'vue'
2
- // import { BTActions } from './composables/actions'
3
- import { BTAuth } from './composables/auth'
4
- import { BTApi } from './composables/api'
5
- import { BTCosmetics } from './composables/cosmetics'
6
- import { BTDates } from './composables/dates'
7
- import { BTDemo } from './composables/demo'
8
- import { BTFilters } from './composables/filters'
9
- import { BTNavigation } from './composables/navigation'
10
- import { BTPresets } from './composables/presets'
11
- import { BTPWA } from './composables/pwa'
12
- import { BTStore, CreateStoreOptions } from './composables/stores'
1
+ // import { inject } from 'vue'
2
+ // // import { BTActions } from './composables/actions'
3
+ // import { BTAuth } from './composables/auth'
4
+ // import { BTApi } from './composables/api'
5
+ // import { BTCosmetics } from './composables/cosmetics'
6
+ // import { BTDates } from './composables/dates'
7
+ // import { BTDemo } from './composables/demo'
8
+ // import { BTFilters } from './composables/filters'
9
+ // import { BTNavigation } from './composables/navigation'
10
+ // import { BTPresets } from './composables/presets'
11
+ // import { BTPWA } from './composables/pwa'
12
+ // import { BTStore, CreateStoreOptions } from './composables/stores'
13
13
 
14
- // /**returns a new instance */
15
- // export function useActions(): BTActions {
16
- // return inject('bt-actions')!
17
- // }
14
+ // // /**returns a new instance */
15
+ // // export function useActions(): BTActions {
16
+ // // return inject('bt-actions')!
17
+ // // }
18
18
 
19
- /**returns a singleton */
20
- export function useApi(): BTApi {
21
- return inject('bt-api')!
22
- }
19
+ // /**returns a singleton */
20
+ // export function useApi(): BTApi {
21
+ // return inject('bt-api')!
22
+ // }
23
23
 
24
- /**returns a singleton */
25
- export function useAuth(): BTAuth {
26
- return inject('bt-auth')!
27
- }
24
+ // /**returns a singleton */
25
+ // export function useAuth(): BTAuth {
26
+ // return inject('bt-auth')!
27
+ // }
28
28
 
29
- /**returns a singleton */
30
- export function useCosmetics(): BTCosmetics {
31
- return inject('bt-cosmetics')!
32
- }
29
+ // /**returns a singleton */
30
+ // export function useCosmetics(): BTCosmetics {
31
+ // return inject('bt-cosmetics')!
32
+ // }
33
33
 
34
- /**returns a singleton */
35
- export function useDates(): BTDates {
36
- return inject('bt-dates')!
37
- }
34
+ // /**returns a singleton */
35
+ // export function useDates(): BTDates {
36
+ // return inject('bt-dates')!
37
+ // }
38
38
 
39
- /**returns a singleton */
40
- export function useDemo(): BTDemo {
41
- return inject('bt-demo')!
42
- }
39
+ // /**returns a singleton */
40
+ // export function useDemo(): BTDemo {
41
+ // return inject('bt-demo')!
42
+ // }
43
43
 
44
- /**returns a singleton */
45
- export function useFilters(): BTFilters {
46
- return inject('bt-filters')!
47
- }
44
+ // /**returns a singleton */
45
+ // export function useFilters(): BTFilters {
46
+ // return inject('bt-filters')!
47
+ // }
48
48
 
49
- /**returns a singleton */
50
- export function useNavigation(): BTNavigation {
51
- return inject('bt-navigation')!
52
- }
49
+ // /**returns a singleton */
50
+ // export function useNavigation(): BTNavigation {
51
+ // return inject('bt-navigation')!
52
+ // }
53
53
 
54
- /**returns a singleton */
55
- export function usePresets(preset?: string): any {
56
- const p = inject('bt-presets')! as BTPresets
57
- return p.usePresets(preset)
58
- }
54
+ // /**returns a singleton */
55
+ // export function usePresets(preset?: string): any {
56
+ // const p = inject('bt-presets')! as BTPresets
57
+ // return p.usePresets(preset)
58
+ // }
59
59
 
60
- /**returns a singleton */
61
- export function usePWA(): BTPWA {
62
- return inject('bt-pwa')!
63
- }
60
+ // /**returns a singleton */
61
+ // export function usePWA(): BTPWA {
62
+ // return inject('bt-pwa')!
63
+ // }
64
64
 
65
- /**returns a new instance */
66
- export function useStore(): (opt: CreateStoreOptions) => BTStore {
67
- return inject('bt-store')!
68
- }
65
+ // /**returns a new instance */
66
+ // export function useStore(): (opt: CreateStoreOptions) => BTStore {
67
+ // return inject('bt-store')!
68
+ // }
@@ -0,0 +1,63 @@
1
+ import { describe, test, expect, afterAll, afterEach, beforeAll } from 'vitest'
2
+ import { createAuth, useAuth } from '../src/composables/auth'
3
+ import { setupServer } from 'msw/node'
4
+ import { http, HttpResponse } from 'msw'
5
+
6
+ const handlers = [
7
+ http.get('https://test-api/get/1', () => {
8
+ return HttpResponse.json({
9
+ data: { test: 'a' },
10
+ count: 0,
11
+ filters: ['test']
12
+ })
13
+ }),
14
+ http.get('https://test-api/get/2', () => {
15
+ return new HttpResponse('not found', {
16
+ status: 304
17
+ })
18
+ }),
19
+ http.get('https://test-api/getAll', () => {
20
+ return HttpResponse.json({
21
+ data: [{ test: 'a' }, { test: 'b' }],
22
+ count: 2,
23
+ filters: ['test', 'test two']
24
+ })
25
+ }),
26
+ http.post('https://test-api/post', () => {
27
+ return HttpResponse.json({ data: { test: 'b' } })
28
+ }),
29
+ http.patch('https://test-api/patch', () => {
30
+ return HttpResponse.json({ data: { test: 'c' } })
31
+ })
32
+ ]
33
+
34
+ const server = setupServer(...handlers)
35
+
36
+ beforeAll(() => server.listen({ onUnhandledRequest: 'error' }))
37
+
38
+ afterAll(() => server.close())
39
+
40
+ afterEach(() => server.resetHandlers())
41
+
42
+ describe('default auth', () => {
43
+ const auth = createAuth({
44
+ defaultTimeZone: 'Aus',
45
+ getAuthItem: () => { return {}},
46
+ getAuthUrl: () => ''
47
+ })
48
+
49
+ test('creates successfully', () => {
50
+ const state = auth.authState
51
+ const creds = auth.credentials
52
+
53
+ expect(state).not.toBeNull()
54
+ expect(auth.credentials).not.toBeNull()
55
+ expect(creds.timeZone).toEqual('Aus')
56
+ })
57
+
58
+ test('use successfully', () => {
59
+ const a = useAuth()
60
+
61
+ expect(a.authState).toEqual(auth.authState)
62
+ })
63
+ })
@@ -1,5 +1,5 @@
1
1
  import { setActivePinia, createPinia } from 'pinia'
2
- import { createSessionStore, createWholeLastUpdateStore } from '../src/composables/stores'
2
+ import { createSessionStoreDefinition, createWholeLastUpdateStoreDefinition } from '../src/composables/stores'
3
3
  import { createApi } from '../src/composables/api'
4
4
  import { describe, test, expect, beforeEach, afterAll, afterEach, beforeAll } from 'vitest'
5
5
  import { setupServer } from 'msw/node'
@@ -49,8 +49,8 @@ describe('use last update store no api no caching', () => {
49
49
 
50
50
  setActivePinia(pinia)
51
51
 
52
- const store = createWholeLastUpdateStore({
53
- api: null,
52
+ const store = createWholeLastUpdateStoreDefinition({
53
+ api: undefined,
54
54
  storageMode: 'session',
55
55
  storeName: 'whole'
56
56
  })()
@@ -95,7 +95,7 @@ describe('use last update store with api no caching', () => {
95
95
  app.use(pinia)
96
96
  setActivePinia(pinia)
97
97
 
98
- const store = createWholeLastUpdateStore({
98
+ const store = createWholeLastUpdateStoreDefinition({
99
99
  storageMode: 'session',
100
100
  api: api,
101
101
  storeName: 'whole-api'
package/vite.config.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  import { defineConfig } from 'vite'
3
3
  import path from 'path'
4
4
  import vue from '@vitejs/plugin-vue'
5
+ import vuetify, { transformAssetUrls } from 'vite-plugin-vuetify'
5
6
  import dts from 'vite-plugin-dts'
6
7
 
7
8
  // https://vitejs.dev/config/
@@ -26,9 +27,12 @@ export default defineConfig({
26
27
  }
27
28
  },
28
29
  plugins: [
30
+ // vue({
31
+ // template: { transformAssetUrls }
32
+ // }),
29
33
  vue(),
30
- dts()
31
- // dts({ rollupTypes: true })
34
+ dts(),
35
+ vuetify()
32
36
  ],
33
37
  resolve: {
34
38
  alias: {