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,264 +0,0 @@
1
- import { getLocationLine, isMinDate } from '../composables/helpers';
2
- import { BTDates } from './dates';
3
-
4
- export interface BTFilters {
5
- findFilter: (mFilter: string | undefined) => Function
6
- }
7
-
8
- export interface UseFiltersOptions {
9
- dates: BTDates
10
- }
11
-
12
- let current: BTFilters
13
-
14
- export function useFilters(): BTFilters {
15
- return current
16
- }
17
-
18
- export function createFilters(options: UseFiltersOptions): BTFilters {
19
- // const { tzString, tzDate, utcString } = useDates()
20
-
21
- function toTimeZoneFormat(value?: string, format?: string, placeholder?: string): string {
22
- if (!value)
23
- return placeholder ?? value ?? '';
24
-
25
- if (isMinDate(value))
26
- return placeholder ?? '';
27
-
28
- return options.dates.tzString(value, format)
29
- }
30
-
31
- function toCompanyNameAndLocationLine(value: object | null | any): string {
32
- if (!value) {
33
- return '';
34
- }
35
-
36
- if (typeof value !== 'object') {
37
- return value;
38
- }
39
-
40
- var rStr = '';
41
-
42
- if (value.companyAccount != null) {
43
- rStr = value.companyAccount.companyName + ' | ';
44
- }
45
-
46
- if (value.addressLineOne != null) {
47
- rStr = rStr + value.addressLineOne + ' ';
48
- }
49
- if (value.streetNumber != null) {
50
- rStr = rStr + value.streetNumber + ' ';
51
- }
52
- if (value.streetName != null) {
53
- rStr = rStr + value.streetName + ', ';
54
- }
55
- if (value.suburb != null) {
56
- rStr = rStr + value.suburb + ' ';
57
- }
58
- if (value.state != null) {
59
- rStr = rStr + value.state + ' ';
60
- }
61
- if (value.postcode != null) {
62
- rStr = rStr + value.postcode;
63
- }
64
-
65
- return rStr;
66
- }
67
-
68
- function toCurrency(val: any): string {
69
- if (typeof val !== 'number') {
70
- return val;
71
- }
72
-
73
- var formatter = new Intl.NumberFormat('en-US', {
74
- style: 'currency',
75
- currency: 'AUD',
76
- minimumFractionDigits: 2
77
- });
78
-
79
- return formatter.format(val);
80
- }
81
-
82
- function toDayDate(value?: string, placeholder?: string): string {
83
- return toTimeZoneFormat(value, 'ccc | d LLL', placeholder)
84
- }
85
-
86
- function toDayMonth(value?: string, placeholder?: string): string {
87
- return toTimeZoneFormat(value, 'd LLL', placeholder)
88
- }
89
-
90
- function toDayOfWeek(value?: string, placeholder?: string): string {
91
- return toTimeZoneFormat(value, 'ccc', placeholder);
92
- }
93
-
94
- function toDayShortDate(value?: string, placeholder?: string): string {
95
- return toTimeZoneFormat(value, 'ccc dd LLL yyyy', placeholder);
96
- }
97
-
98
- function toDayShortDateAndTime(value?: string, placeholder?: string): string {
99
- return toTimeZoneFormat(value, 'ccc dd LLL @ hh:mm a', placeholder);
100
- }
101
-
102
- function toDisplayNumber(val: number): string {
103
- return new Intl.NumberFormat().format(val);
104
- }
105
-
106
- function toDisplayNumberOver(val: number): string {
107
- if (val == 0) {
108
- return '';
109
- }
110
-
111
- return new Intl.NumberFormat().format(val);
112
- }
113
-
114
- function toDisplayNumberSigned(val: number): string {
115
- if (val == 0) {
116
- return '';
117
- }
118
-
119
- var r = new Intl.NumberFormat().format(val);
120
-
121
- if (val > 0) {
122
- return '+' + r;
123
- }
124
- else {
125
- return r;
126
- }
127
- }
128
-
129
- function toFormat(val?: string, format?: string) {
130
- return options.dates.utcString(val, format);
131
- }
132
-
133
- function toLocationLine(val: any): string {
134
- return getLocationLine(val, false);
135
- }
136
-
137
- function toLocationLineNoCommas(value: any): string {
138
- if (!value) {
139
- return '';
140
- }
141
-
142
- if (typeof value !== 'object') {
143
- return value;
144
- }
145
-
146
- var rStr = '';
147
-
148
- if (value.addressLineOne != null) {
149
- rStr = value.addressLineOne + ' ';
150
- }
151
- if (value.streetNumber != null) {
152
- rStr = rStr + value.streetNumber + ' ';
153
- }
154
- if (value.streetName != null) {
155
- rStr = rStr + value.streetName + ' ';
156
- }
157
- if (value.suburb != null) {
158
- rStr = rStr + value.suburb + ' ';
159
- }
160
- if (value.state != null) {
161
- rStr = rStr + value.state + ' ';
162
- }
163
- if (value.postcode != null) {
164
- rStr = rStr + value.postcode;
165
- }
166
-
167
- rStr = rStr.replaceAll(',', ' ');
168
-
169
- return rStr;
170
- }
171
-
172
- function toLongDate(value?: string, placeholder?: string): string {
173
- return toTimeZoneFormat(value, 'ddd DD MMM YYYY', placeholder);
174
- }
175
-
176
- function toLongDateAndTime(value?: string, placeholder?: string): string {
177
- return toTimeZoneFormat(value, 'ccc dd LLL yyyy hh:mm a', placeholder);
178
- }
179
-
180
- function toPercent(val: number): string {
181
- var formatter = new Intl.NumberFormat('en-US', {
182
- style: 'percent',
183
- minimumFractionDigits: 2
184
- });
185
-
186
- return formatter.format(val);
187
- }
188
-
189
- function toPrettyCSV(val: string): string {
190
- return val.replaceAll(',', ' ');
191
- }
192
-
193
- function toShortDate(value?: string, placeholder?: string): string {
194
- return toTimeZoneFormat(value, 'dd LLL yyyy', placeholder);
195
- }
196
-
197
- function toShortDateAndTime(value?: string, placeholder?: string): string {
198
- return toTimeZoneFormat(value, 'dd LLL yyyy hh:mm a', placeholder);
199
- }
200
-
201
- function toTime(value?: string, placeholder?: string): string {
202
- return toTimeZoneFormat(value, 'hh:mm a', placeholder);
203
- }
204
-
205
- function toTimeOfDay(val?: string | number): string {
206
- if (val == null) {
207
- return '';
208
- }
209
-
210
- if (typeof val == 'number') {
211
- return options.dates.tzDate().startOf('day').plus({ minutes: val }).toFormat('T')
212
- }
213
- else if (typeof val == 'string') {
214
- return options.dates.tzString(val, 't')
215
- }
216
- else {
217
- return 'unknown';
218
- }
219
- }
220
-
221
- const e = {
222
- toCompanyNameAndLocationLine,
223
- toCurrency,
224
- toDayDate,
225
- toDayMonth,
226
- toDayOfWeek,
227
- toDayShortDate,
228
- toDayShortDateAndTime,
229
- toDisplayNumber,
230
- toDisplayNumberOver,
231
- toDisplayNumberSigned,
232
- toFormat,
233
- toLocationLine,
234
- toLocationLineNoCommas,
235
- toLongDate,
236
- toLongDateAndTime,
237
- toPercent,
238
- toPrettyCSV,
239
- toShortDate,
240
- toShortDateAndTime,
241
- toTime,
242
- toTimeOfDay
243
- }
244
-
245
- function findFilter(mFilter: undefined | string): Function {
246
- if (mFilter != null) {
247
- let filter = mFilter as keyof typeof e
248
- if (filter != null && e[filter] != null) {
249
- return e[filter] as Function
250
- }
251
- }
252
-
253
- return (v: any) => v
254
- }
255
-
256
- current = {
257
- findFilter,
258
- ...e
259
- }
260
-
261
- return current
262
- }
263
-
264
- export type Textfilter = 'toLocationLine' | 'toLocationLineNoCommas' | 'toLongDate' | 'toLongDateAndTime' | 'toPercent' | 'toPrettyCSV' | 'toShortDate' | 'toShortDateAndTime' | 'toTime' | 'toTimeOfDay' | 'toCompanyNameAndLocationLine' | 'toCurrency' | 'toDayDate' | 'toDayMonth' | 'toDayOfWeek' | 'toDayShortDate' | 'toDayShortDateAndTime' | 'toDisplayNumber' | 'toDisplayNumberOver' | 'toDisplayNumberSigned' | 'toFormat'
@@ -1,49 +0,0 @@
1
- import localforage from 'localforage';
2
- import { useDbName } from '../composables/urls';
3
-
4
- let localDb: LocalForage | null = null;
5
-
6
- localforage.config({
7
- name: useDbName()
8
- })
9
-
10
- export function useLocalDb(): LocalForage {
11
- const dbName = useDbName()
12
- if (localDb == null || localDb.config.name != dbName) {
13
- localDb = localforage.createInstance({ name: dbName })
14
- }
15
-
16
- return localDb
17
- }
18
-
19
- export function useLocalCache() {
20
-
21
- async function clearAsync(storeName: string) {
22
- const db = useLocalDb()
23
- const keys = await db.keys()
24
- let filteredKeys = keys.filter(key => key.startsWith(storeName))
25
-
26
- filteredKeys.forEach(fKey => {
27
- db.removeItem(fKey)
28
- })
29
- }
30
-
31
- async function getAsync<T>(key: string) {
32
- return await useLocalDb().getItem<T>(key)
33
- }
34
-
35
- async function removeAsync(key: string) {
36
- return await useLocalDb().removeItem(key)
37
- }
38
-
39
- async function saveAsync<T>(data: T, key: string) {
40
- await useLocalDb().setItem(key, data)
41
- }
42
-
43
- return {
44
- clearAsync,
45
- getAsync,
46
- removeAsync,
47
- saveAsync
48
- }
49
- }