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,382 +0,0 @@
1
- import { toValue, useEventListener, useParentElement } from "@vueuse/core"
2
- import { type ComponentPublicInstance, type Ref, ref } from 'vue'
3
- import type { Position, MaybeRefOrGetter } from "@vueuse/core"
4
- import { copyDeep } from "../composables/helpers"
5
- import { type BladeVariant } from "../types"
6
-
7
- export type ResizeHandle = 't' | 'r' | 'b' | 'l' | 'tr' | 'br' | 'bl' | 'tl'
8
-
9
- export interface PointerOrTouchEvent extends PointerEvent, TouchEvent { }
10
-
11
- const allHandles: ResizeHandle[] = ['t', 'r', 'b', 'l', 'tr', 'br', 'bl', 'tl']
12
-
13
- export interface UseResizeOptions {
14
- preventDefault?: MaybeRefOrGetter<boolean>
15
- stopPropagation?: MaybeRefOrGetter<boolean>
16
- // pointerTypes?: PointerType[]
17
- handles?: ResizeHandle[]
18
-
19
- /**
20
- * Callback when the dragging starts. Return `false` to prevent dragging.
21
- */
22
- onStart?: (position: Position, event: PointerEvent) => void | false
23
-
24
- /**
25
- * Callback during dragging.
26
- */
27
- onMove?: (position: Position, event: PointerEvent) => void
28
-
29
- /**
30
- * Callback when dragging end.
31
- */
32
- onEnd?: (position: Position, event: PointerEvent) => void
33
-
34
- minWidth?: number
35
- maxWidth?: number
36
- minHeight?: number
37
- maxHeight?: number
38
- handleWidth?: number
39
- handleZIndex?: number
40
- }
41
-
42
- interface ElementPosition {
43
- left?: number,
44
- top?: number,
45
- height?: number,
46
- width?: number,
47
- position?: string
48
- }
49
-
50
- export function useResizable(
51
- target: MaybeRefOrGetter<ComponentPublicInstance | null>,
52
- options: UseResizeOptions = {}) {
53
- let currentVariant: string | undefined = undefined
54
- let handleWidth = options.handleWidth ?? 12
55
- let handleZIndex = options.handleZIndex ?? 100
56
- let minWidth = options.minWidth ?? 0
57
- let maxWidth = options.maxWidth ?? Number.MAX_SAFE_INTEGER
58
- let minHeight = options.minHeight ?? 0
59
- let maxHeight = options.maxHeight ?? Number.MAX_SAFE_INTEGER
60
- let preventDefault = options.preventDefault ?? false
61
- let stopPropagation = options.stopPropagation ?? false
62
-
63
- let activeHandle: any
64
- let handleEls: HTMLDivElement[] = []
65
- const isAutoResizing = ref(false)
66
- let listeners: Function[] = []
67
- let moveListeners: Function[] = []
68
- const resizingIsOn: Ref<boolean> = ref(false)
69
- const startingPointerPosition: Ref<Position> = ref<Position>({ x: 0, y: 0 })
70
- let startingElementPosition: ElementPosition = { left: 0, top: 0, height: 0, width: 0, position: 'absolute' }
71
- let currentElementPosition: ElementPosition = { }
72
- // let variantMemory: any = {}
73
-
74
- function handleEvent(e: PointerOrTouchEvent) {
75
- if (toValue(preventDefault))
76
- e.preventDefault()
77
- if (toValue(stopPropagation))
78
- e.stopPropagation()
79
- }
80
-
81
- function addHandles(el: ComponentPublicInstance, handles: ResizeHandle[]) {
82
- handleEls = handles.map(createHandleEl)
83
- handleEls.forEach(handleEl => el.$el.appendChild(handleEl))
84
- }
85
-
86
- function removeHandles(el: ComponentPublicInstance) {
87
- handleEls.forEach(handleEl => el.$el.removeChild(handleEl))
88
- }
89
-
90
- function createHandleEl(handle: string): HTMLDivElement { //ComponentPublicInstance {
91
- const handleWidthPx = handleWidth + 'px'
92
- const handleOffsetPx = -handleWidth / 2 + 'px'
93
- const handleCornerZIndex = handleZIndex + 1
94
-
95
- const handleEl = document.createElement('div')
96
- handleEl.dataset.handle = handle
97
- handleEl.style.position = 'absolute'
98
- handleEl.style.touchAction = 'none'
99
- handleEl.style.userSelect = 'none'
100
- handleEl.style.zIndex = (handle.length === 1 ? handleZIndex : handleCornerZIndex).toString()
101
- handleEl.style.cursor = getCursor(handle)
102
-
103
- if (handle.includes('t')) {
104
- handleEl.style.top = handleOffsetPx
105
- handleEl.style.height = handleWidthPx
106
- if (handle === 't') {
107
- handleEl.style.left = '0'
108
- handleEl.style.width = '100%'
109
- }
110
- }
111
- if (handle.includes('b')) {
112
- handleEl.style.bottom = handleOffsetPx
113
- handleEl.style.height = handleWidthPx
114
- if (handle === 'b') {
115
- handleEl.style.left = '0'
116
- handleEl.style.width = '100%'
117
- }
118
- }
119
- if (handle.includes('r')) {
120
- handleEl.style.right = handleOffsetPx
121
- handleEl.style.width = handleWidthPx
122
- if (handle === 'r') {
123
- handleEl.style.top = '0'
124
- handleEl.style.height = '100%'
125
- }
126
- }
127
- if (handle.includes('l')) {
128
- handleEl.style.left = handleOffsetPx
129
- handleEl.style.width = handleWidthPx
130
- if (handle === 'l') {
131
- handleEl.style.top = '0'
132
- handleEl.style.height = '100%'
133
- }
134
- }
135
- return handleEl
136
- }
137
-
138
- function start(e: PointerOrTouchEvent) {
139
- if (!handleEls.some(x => x == e.target)) return
140
- const t = toValue(target)
141
- if (!t) return
142
- const el = t.$el
143
- const isTouch = e.type === 'touchstart' && e.touches.length > 0
144
- const evtData = isTouch ? e.touches[0] : e
145
-
146
- startingPointerPosition.value.x = evtData.clientX
147
- startingPointerPosition.value.y = evtData.clientY
148
-
149
- startingElementPosition = {
150
- left: el.offsetLeft,
151
- top: el.offsetTop,
152
- height: parseInt(window.getComputedStyle(el).getPropertyValue('height')),
153
- width: parseInt(window.getComputedStyle(el).getPropertyValue('width'))
154
- }
155
-
156
- currentElementPosition = copyDeep(startingElementPosition)
157
-
158
- if (options.onStart?.(startingPointerPosition.value, e) === false) return
159
-
160
- let handle = e.target as HTMLElement
161
-
162
- document.documentElement.style.cursor = getCursor(handle.dataset.handle as string)
163
- activeHandle = handle.dataset.handle as string
164
-
165
- moveListeners.push(useEventListener('mousemove', move))
166
- moveListeners.push(useEventListener('mouseup', end))
167
- moveListeners.push(useEventListener('touchmove', move))
168
- moveListeners.push(useEventListener('touchend', end))
169
-
170
- handleEvent(e)
171
- }
172
-
173
- function move(e: any) {
174
- const t = toValue(target)
175
- if (!t) return
176
- const el = t.$el
177
-
178
- const isTouch = e.type === 'touchmove' && e.touches.length > 0
179
- const evtData = isTouch ? e.touches[0] : e
180
- let dx = evtData.clientX - startingPointerPosition.value.x
181
- let dy = evtData.clientY - startingPointerPosition.value.y
182
- const start = toValue(startingElementPosition)
183
-
184
- if (activeHandle.includes('t')) {
185
- const newHeight = Math.min(maxHeight, Math.max(minHeight, (start.height ?? 0) - dy))
186
- currentElementPosition.height = newHeight
187
- currentElementPosition.top = (start.top ?? 0) + dy
188
- }
189
- if (activeHandle.includes('b')) {
190
- const newHeight = Math.min(maxHeight, Math.max(minHeight, (start.height ?? 0) + dy))
191
- currentElementPosition.height = newHeight
192
- }
193
- if (activeHandle.includes('l')) {
194
- const newWidth = Math.min(maxWidth, Math.max(minWidth, (start.width ?? 0) - dx))
195
- currentElementPosition.width = newWidth
196
- currentElementPosition.left = (start.left ?? 0) + dx
197
- }
198
- if (activeHandle.includes('r')) {
199
- const newWidth = Math.min(maxWidth, Math.max(minWidth, (start.width ?? 0) + dx))
200
- currentElementPosition.width = newWidth
201
- }
202
-
203
- el.dispatchEvent(new CustomEvent('resize'))
204
- handleEvent(e)
205
-
206
- applyToElementStyle(currentElementPosition)
207
- }
208
-
209
- function end() {
210
- document.documentElement.style.cursor = ''
211
- activeHandle = null
212
- moveListeners.forEach(l => { l() })
213
- moveListeners.length = 0
214
- }
215
-
216
- function getCursor(handle: string) {
217
- const cursorDirection: any = {
218
- t: 'n',
219
- r: 'e',
220
- b: 's',
221
- l: 'w'
222
- }
223
- return (handle.split('').map(l => cursorDirection[l]).join('') + '-resize')
224
- }
225
-
226
- function restoreSize(variant?: BladeVariant | undefined) {
227
- const t = toValue(target)
228
- if (!t) return
229
- const el = t.$el as HTMLElement
230
- console.log(currentVariant)
231
-
232
- if (currentVariant !== 'page' && variant == 'page') {
233
- //moving back to default page settings
234
- const parent = useParentElement(el)
235
- const p = (toValue(parent) ?? null) as any
236
- let aimWidth = 0
237
- if (p != null) {
238
- const c = window.getComputedStyle(p)
239
- aimWidth = parseInt(c.getPropertyValue('width')) - p.offsetLeft
240
- }
241
-
242
- el.style.transition = 'width 0.5s, height 0.5s, top 0.5s, left 0.5s'
243
- el.offsetHeight
244
- isAutoResizing.value = true
245
-
246
- applyToElementStyle({
247
- height: undefined,
248
- width: aimWidth,
249
- top: 0,
250
- left: 0,
251
- position: undefined
252
- })
253
-
254
- useEventListener(el, 'transitionend', () => {
255
- el.style.width = 'auto'
256
- el.style.top = ''
257
- el.style.left = ''
258
- el.style.position = ''
259
- el.style.transition = ''
260
- isAutoResizing.value = false
261
- }, { once: true })
262
- }
263
- else if ((currentVariant == 'page' || t.$el.style.position !== 'absolute') && variant !== 'page') {
264
- //move to freestyle or blade
265
- el.style.transition = 'width 0.5s, height 0.5s, top 0.5s, left 0.5s'
266
- isAutoResizing.value = true
267
-
268
- startingElementPosition = {
269
- height: parseInt(window.getComputedStyle(el).getPropertyValue('height')),
270
- width: parseInt(window.getComputedStyle(el).getPropertyValue('width')),
271
- top: el.offsetTop,
272
- left: el.offsetLeft,
273
- position: 'absolute'
274
- }
275
-
276
- applyToElementStyle(startingElementPosition)
277
- el.offsetHeight
278
- const s = startingElementPosition
279
-
280
- if (variant == 'freestyle') {
281
- //half the size to indicate non-page variant
282
- currentElementPosition = {
283
- height: s.height,
284
- width: (s.width ?? 100) / 2,
285
- top: (s.top ?? 0) + 2,
286
- left: (s.left ?? 0) + 2,
287
- position: 'absolute'
288
- }
289
- }
290
- else if (variant == 'blade') {
291
- currentElementPosition = {
292
- height: s.height,
293
- width: (s.width ?? 100) / 2,
294
- top: (s.top ?? 0) + 2,
295
- left: (s.left ?? 0) + 2,
296
- position: 'absolute'
297
- }
298
-
299
- //flex column?
300
- }
301
-
302
- applyToElementStyle(currentElementPosition)
303
-
304
- useEventListener(el, 'transitionend', () => {
305
- el.style.transition = ''
306
- isAutoResizing.value = false
307
- }, { once: true })
308
- }
309
- }
310
-
311
- function applyToElementStyle(s: ElementPosition) {
312
- const t = toValue(target)
313
- if (!t) return
314
- const el = t.$el
315
-
316
- if (s.top) {
317
- el.style.top = `${s.top}px`
318
- }
319
- else {
320
- el.style.top = undefined
321
- }
322
-
323
- if (s.left) {
324
- el.style.left = `${s.left}px`
325
- }
326
- else {
327
- el.style.left = undefined
328
- }
329
-
330
- if (s.height) {
331
- el.style.height = `${s.height}px`
332
- }
333
- else {
334
- el.style.height = undefined
335
- }
336
-
337
- if (s.width) {
338
- el.style.width = `${s.width}px`
339
- }
340
- else {
341
- el.style.width = undefined
342
- }
343
-
344
- if (s.position) {
345
- el.style.position = `${s.position}`
346
- }
347
- else {
348
- el.style.position = undefined
349
- }
350
-
351
- console.log(el.style.position)
352
- }
353
-
354
- function turnResizingOn(handles?: ResizeHandle[], variant?: BladeVariant) {
355
- if (resizingIsOn.value) return
356
- const t = toValue(target)
357
- if (!t) return
358
- addHandles(t, handles ?? allHandles)
359
- restoreSize(variant)
360
- listeners.push(useEventListener(t.$el, 'mousedown', start))
361
- listeners.push(useEventListener(t.$el, 'touchstart', start))
362
- resizingIsOn.value = true
363
- currentVariant = variant
364
- }
365
-
366
- function turnResizingOff(variant?: BladeVariant | undefined) {
367
- if (!resizingIsOn.value) return
368
- const t = toValue(target)
369
- if (!t) return
370
- removeHandles(t)
371
- restoreSize(variant)
372
- listeners.forEach(l => { l() })
373
- listeners.length = 0
374
- resizingIsOn.value = false
375
- }
376
-
377
- return {
378
- resizingIsOn,
379
- turnResizingOn,
380
- turnResizingOff
381
- }
382
- }
@@ -1,40 +0,0 @@
1
- import { validEmail } from '../composables/helpers'
2
-
3
- export interface UseRulesOptions {
4
- forEmail?: boolean
5
- forPassword?: boolean
6
- otherRules?: any
7
- required?: boolean,
8
- }
9
-
10
- export function useRules(options?: UseRulesOptions) {
11
- const rules = []
12
-
13
- if (options?.required == true) {
14
- rules.push((v: any) => !!v || 'Field is required')
15
- }
16
-
17
- if (options?.otherRules != null) {
18
- if (Array.isArray(options?.otherRules)) {
19
- rules.push(...options.otherRules)
20
- }
21
- else {
22
- rules.push(options.otherRules)
23
- }
24
- }
25
-
26
- if (options?.forPassword == true) {
27
- rules.push((x: any) => !!x || 'Password is required')
28
- rules.push((x: any) => x !!= null && x.length > 9 || 'Password must be 10 or more characters')
29
- rules.push((x: any) => /^(.*[a-z].*)$/.test(x) || 'Password must contain a lowercase letter')
30
- rules.push((x: any) => /^(.*[A-Z].*)$/.test(x) || 'Password must contain an uppercase letter')
31
- rules.push((x: any) => /^(.*\d.*)$/.test(x) || 'Password must contain a number')
32
- }
33
-
34
- if (options?.forEmail == true) {
35
- rules.push((v: any) => !!v || 'Email is required')
36
- rules.push((v: any) => validEmail(v) || 'Email must be valid')
37
- }
38
-
39
- return rules
40
- }