@jtigernova-npm/tiffany-vue 1.2.1 → 1.2.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.
@@ -1,15 +1,18 @@
1
1
  import { type Ref } from "vue";
2
- export interface BaseState {
2
+ export interface BaseLoadable {
3
3
  allowLoad: Ref<boolean>;
4
4
  loading: Ref<boolean>;
5
5
  onLoad: () => Promise<void>;
6
6
  }
7
+ export interface BaseState extends BaseLoadable {
8
+ load: () => void;
9
+ }
7
10
  export declare function getBaseStateOpts(): {
8
11
  allowLoad: Ref<boolean>;
9
12
  loading: Ref<boolean>;
10
13
  onLoad: () => Promise<void>;
11
14
  };
12
- export declare function getBaseStateHelper(baseState: BaseState): {
15
+ export declare function getBaseStateHelper(loadable: BaseLoadable): {
13
16
  load: () => void;
14
17
  };
15
18
  export interface TrackableScroll {
@@ -17,7 +20,10 @@ export interface TrackableScroll {
17
20
  trackScrollTop: (scrollElementID: string, event: any) => void;
18
21
  setScrollTop: (scrollElementID: string) => void;
19
22
  }
20
- export declare function getTrackableScrollHelper(): {
23
+ export declare function getTrackableScrollHelper(opts?: {
24
+ spaceBuffer: 30;
25
+ onReachedBottom: () => void;
26
+ }): {
21
27
  scrollTop: Ref<number>;
22
28
  trackScrollTop: (scrollElementID: string, event: any) => void;
23
29
  setScrollTop: (scrollElementID: string) => void;
@@ -1,10 +1,5 @@
1
1
  import { logDebug, logErrorAlways } from "@jtigernova-npm/tiffany";
2
2
  import { ref } from "vue";
3
- // export interface BaseLoadable {
4
- // allowLoad: boolean;
5
- // loading: Ref<boolean>;
6
- // onLoad: () => Promise<void>;
7
- // }
8
3
  export function getBaseStateOpts() {
9
4
  return {
10
5
  allowLoad: ref(true),
@@ -15,12 +10,12 @@ export function getBaseStateOpts() {
15
10
  },
16
11
  };
17
12
  }
18
- export function getBaseStateHelper(baseState) {
13
+ export function getBaseStateHelper(loadable) {
19
14
  return {
20
15
  load() {
21
- if (!baseState.allowLoad)
16
+ if (!loadable.allowLoad)
22
17
  return;
23
- baseState
18
+ loadable
24
19
  .onLoad()
25
20
  .then(() => {
26
21
  logDebug("BaseState.onLoad() done");
@@ -31,7 +26,7 @@ export function getBaseStateHelper(baseState) {
31
26
  },
32
27
  };
33
28
  }
34
- export function getTrackableScrollHelper() {
29
+ export function getTrackableScrollHelper(opts) {
35
30
  const scrollTop = ref(0);
36
31
  return {
37
32
  scrollTop: scrollTop,
@@ -41,6 +36,11 @@ export function getTrackableScrollHelper() {
41
36
  if (scrollElementID == event.target.id) {
42
37
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
43
38
  scrollTop.value = event.target.scrollTop;
39
+ if (!opts)
40
+ return;
41
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
42
+ if (event.target.scrollTop + event.target.clientHeight + opts.spaceBuffer >= event.target.scrollHeight)
43
+ opts.onReachedBottom();
44
44
  }
45
45
  },
46
46
  setScrollTop: (scrollElementID) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jtigernova-npm/tiffany-vue",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "module": "out/index.js",
5
5
  "type": "module",
6
6
  "typings": "index.d.ts",
@@ -12,8 +12,8 @@
12
12
  "format": "prettier --write src/**",
13
13
  "format-build": "npm run format && npm run build",
14
14
  "test": "echo \"Error: no test specified\" && exit 1",
15
- "tiffany-prepare": "tsc && npm run lint && npm run format && npm pack",
16
- "tiffany-publish": "tsc && npm run lint && npm run format && npm pack && npm publish --access public && rm *.tgz"
15
+ "tiffany-prepare": "npm i && tsc && npm run lint && npm run format && npm pack",
16
+ "tiffany-publish": "npm i && tsc && npm run lint && npm run format && npm pack && npm publish --access public && rm *.tgz"
17
17
  },
18
18
  "keywords": [],
19
19
  "author": "JTiger Nova",