nuxt-hs-ui 2.1.10 → 2.1.12

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.
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.15.0"
6
6
  },
7
- "version": "2.1.10",
7
+ "version": "2.1.12",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
@@ -10,7 +10,14 @@
10
10
  // [ node_modules ]
11
11
  import { TabulatorFull as Tabulator } from "tabulator-tables";
12
12
  // [ NUXT ]
13
- import { ref, watch, computed, onMounted, onUnmounted } from "#imports";
13
+ import {
14
+ ref,
15
+ watch,
16
+ computed,
17
+ onMounted,
18
+ // onUnmounted,
19
+ onBeforeUnmount,
20
+ } from "#imports";
14
21
  // ----------------------------------------------------------------------------
15
22
  // [ utils ]
16
23
  import { Option } from "../../utils/tabulator";
@@ -175,7 +182,10 @@ const initTabulator = () => {
175
182
  onMounted(() => {
176
183
  initTabulator();
177
184
  });
178
- onUnmounted(() => {
185
+
186
+ onBeforeUnmount(() => {
187
+ // console.log("onBeforeUnmount");
188
+ if (tabulator.value === null) return;
179
189
  tabulator.value.destroy();
180
190
  tabulator.value = null;
181
191
  });
@@ -3,8 +3,6 @@ interface StoreState {
3
3
  isInit: boolean;
4
4
  isReady: boolean;
5
5
  isMobile: boolean;
6
- isBracke: boolean;
7
- spBracke: number;
8
6
  readyDeray: number;
9
7
  window: {
10
8
  h: number;
@@ -14,8 +12,8 @@ interface StoreState {
14
12
  };
15
13
  }
16
14
  export declare const useHsMisc: import("pinia").StoreDefinition<"HsMisc", StoreState, {}, {
15
+ IsMobile(): boolean;
17
16
  Init(arg?: {
18
- spBracke?: number;
19
17
  readyDeray?: number;
20
18
  }): Promise<void>;
21
19
  }>;
@@ -8,9 +8,7 @@ export const useHsMisc = defineStore("HsMisc", {
8
8
  state: {
9
9
  isInit: false,
10
10
  isReady: false,
11
- isMobile: false,
12
- isBracke: false,
13
- spBracke: 768,
11
+ isMobile: IsMobile(),
14
12
  readyDeray: 10,
15
13
  window: {
16
14
  h: 0,
@@ -22,6 +20,9 @@ export const useHsMisc = defineStore("HsMisc", {
22
20
  },
23
21
  // ----------------------------------------------------------------------------
24
22
  actions: {
23
+ IsMobile() {
24
+ return IsMobile();
25
+ },
25
26
  // ---------------------
26
27
  async Init(arg) {
27
28
  await Sleep(0);
@@ -30,21 +31,16 @@ export const useHsMisc = defineStore("HsMisc", {
30
31
  if (arg?.readyDeray) {
31
32
  state.readyDeray = arg.readyDeray;
32
33
  }
33
- if (arg?.spBracke) {
34
- state.spBracke = arg.spBracke;
35
- }
36
34
  state.isInit = true;
37
35
  state.isMobile = IsMobile();
38
36
  const initWindow = () => {
39
37
  useEventListener(window, "resize", () => {
40
- state.isBracke = window.innerWidth < state.spBracke;
41
38
  state.window = {
42
39
  h: window.innerHeight,
43
40
  w: window.innerWidth
44
41
  };
45
42
  state.scrollbarWidth = window.innerWidth - document.body.clientWidth < 0 ? 0 : window.innerWidth - document.body.clientWidth;
46
43
  });
47
- state.isBracke = window.innerWidth < state.spBracke;
48
44
  state.window = {
49
45
  h: window.innerHeight,
50
46
  w: window.innerWidth
@@ -2,6 +2,8 @@
2
2
  export declare const GenerateUniqeKey: (len?: number) => string;
3
3
  /** 一定時間処理を待機 */
4
4
  export declare const Sleep: (time: number) => Promise<unknown>;
5
+ export declare const GetUa: () => string;
6
+ export declare const IsTouchDevice: () => boolean;
5
7
  /** モバイル系デバイスかどうかの判定
6
8
  * - ブラウザ側で実行すること */
7
9
  export declare const IsMobile: () => boolean;
@@ -1,4 +1,5 @@
1
1
  import dayjs from "dayjs/esm/index";
2
+ import { useRequestHeaders } from "#app";
2
3
  export const GenerateUniqeKey = (len = 32) => {
3
4
  const S = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
4
5
  const word = len < 14 ? 14 : len - 15;
@@ -11,10 +12,33 @@ export const Sleep = (time) => {
11
12
  }, time);
12
13
  });
13
14
  };
15
+ export const GetUa = () => {
16
+ try {
17
+ if (import.meta.client) {
18
+ if (navigator === void 0) return "";
19
+ return navigator.userAgent.toLowerCase();
20
+ }
21
+ if (import.meta.server) {
22
+ return useRequestHeaders(["User-Agent"])["user-agent"] || "";
23
+ }
24
+ return "";
25
+ } catch (err) {
26
+ console.error(err);
27
+ return "";
28
+ }
29
+ };
30
+ export const IsTouchDevice = () => {
31
+ try {
32
+ if (import.meta.client) return "ontouchend" in document;
33
+ return false;
34
+ } catch (err) {
35
+ console.error(err);
36
+ return false;
37
+ }
38
+ };
14
39
  export const IsMobile = () => {
15
- if (navigator === void 0) return false;
16
- const userAgent = navigator.userAgent.toLowerCase();
17
- if (/android|ipod|ipad|iphone|macintosh/.test(userAgent) && "ontouchend" in document) {
40
+ const ua = GetUa();
41
+ if (/android|ipod|ipad|iphone|macintosh/.test(ua) || IsTouchDevice()) {
18
42
  return true;
19
43
  } else {
20
44
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-hs-ui",
3
- "version": "2.1.10",
3
+ "version": "2.1.12",
4
4
  "description": "My new Nuxt module",
5
5
  "repository": "https://github.com/hare-systems-ryo/nuxt-hs-ui",
6
6
  "license": "MIT",