nuxt-hs-ui 2.0.14 → 2.0.16

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/README.md CHANGED
@@ -1,11 +1,33 @@
1
- <!--
2
- Get your module up and running quickly.
1
+ # nuxt-hs-ui
3
2
 
4
- Find and replace all on all files (CMD+SHIFT+F):
5
- - Name: My Module
6
- - Package name: my-module
7
- - Description: My new Nuxt module
8
- -->
3
+ .......
4
+
9
5
 
10
- # My Module
6
+ ## Installation
11
7
 
8
+ ```sh
9
+ npm i nuxt-hs-ui
10
+ ```
11
+
12
+ ### Nuxt
13
+
14
+ ```ts
15
+ import twConfig from "./tailwind.config";
16
+ export default defineNuxtConfig({
17
+ modules: [
18
+ //
19
+ [
20
+ "nuxt-hs-ui",
21
+ {
22
+ tailwind: twConfig,
23
+ prefix: {
24
+ nuxtUi: "",
25
+ form: "",
26
+ interactive: "",
27
+ layout: "",
28
+ },
29
+ },
30
+ ],
31
+ ],
32
+ });
33
+ ```
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.15.0"
6
6
  },
7
- "version": "2.0.14",
7
+ "version": "2.0.16",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
@@ -0,0 +1,87 @@
1
+ /** --------------------------------------------
2
+ 使用方法
3
+
4
+ import { ModalControl, InitModalControl, InitModals } from '@/lib-front/modal-control';
5
+
6
+ interface Modal {
7
+ test1: ModalControl<{
8
+ isLock: boolean;
9
+ id: number;
10
+ }>;
11
+ //test2子コンポーネント側で閉じる部分の制御する
12
+ test2: ModalControl;
13
+ }
14
+
15
+ const modal = reactive<Modal>({
16
+ test1: InitModalControl<Modal['test1']['state']>({
17
+ state: { isLock: false, id: 1 },
18
+ //asyncもOK
19
+ showBefore: (state) => {
20
+ //ここに制御を入れてtrueを返せば中断できる
21
+ return state.isLock;
22
+ },
23
+ showAfter: (state) => {
24
+ },
25
+ //asyncもOK
26
+ closeBefore: (state) => {
27
+ //ここに制御を入れてtrueを返せば中断できる
28
+ return state.isLock;
29
+ },
30
+ closeAfter: (state) => {
31
+ },
32
+ }),
33
+ test2: InitModalControl(),
34
+ });
35
+
36
+ onMounted(() => {
37
+ InitModals(modal, nextTick);
38
+ });
39
+
40
+ -------------------------------------------- */
41
+ type OptionalFunction<T> = ((state: T) => undefined | boolean) | ((state: T) => Promise<undefined | boolean>) | null;
42
+ export interface ModalControl<T = any> {
43
+ /**
44
+ * showBefre,showAfter がasync付きならasync付き関数になります。
45
+ */
46
+ show: (() => undefined) | (() => Promise<undefined>);
47
+ /**
48
+ * showBefore モーダルが開く前に実行される関数
49
+ * - true をreturnするとモーダルを開く処理は中止される
50
+ */
51
+ showBefore: OptionalFunction<T>;
52
+ showAfter: OptionalFunction<T>;
53
+ /**
54
+ * closeBefore,closeAfter がasync付きならasync付き関数になります。
55
+ */
56
+ close: (() => undefined) | (() => Promise<undefined>);
57
+ /**
58
+ * closeBefore モーダルが閉じる前に実行される関数
59
+ * - true をreturnするとモーダルを閉じる処理は中止される
60
+ */
61
+ closeBefore: OptionalFunction<T>;
62
+ closeAfter: OptionalFunction<T>;
63
+ isShow: boolean;
64
+ state: T;
65
+ }
66
+ export declare const InitModalControl: <T = any>(arg?: {
67
+ state?: T;
68
+ /**
69
+ * showBefore モーダルが開く前に実行される関数
70
+ * - true をreturnするとモーダルを開く処理は中止される
71
+ */
72
+ showBefore?: OptionalFunction<T>;
73
+ showAfter?: OptionalFunction<T>;
74
+ /**
75
+ * closeBefore モーダルが閉じる前に実行される関数
76
+ * - true をreturnするとモーダルを閉じる処理は中止される
77
+ */
78
+ closeBefore?: OptionalFunction<T>;
79
+ closeAfter?: OptionalFunction<T>;
80
+ }) => ModalControl<T>;
81
+ /**
82
+ * modalオブジェクトの初期化
83
+ * @param modal ModalControlが含まれるReactiveオブジェクト
84
+ * @param nextTick Vue の nextTick関数
85
+ */
86
+ export declare const InitModals: (modal: any, nextTick: any) => void;
87
+ export {};
@@ -0,0 +1,72 @@
1
+ export const InitModalControl = (arg) => {
2
+ const noneInitMessage = "\u304C\u521D\u671F\u5316\u3055\u308C\u3066\u3044\u307E\u305B\u3093";
3
+ return {
4
+ show: () => console.log("[show]" + noneInitMessage),
5
+ showBefore: null,
6
+ showAfter: null,
7
+ close: () => console.log("[close]" + noneInitMessage),
8
+ closeBefore: null,
9
+ closeAfter: null,
10
+ isShow: false,
11
+ state: null,
12
+ ...arg
13
+ };
14
+ };
15
+ const isAsync = (func) => {
16
+ try {
17
+ if (func === null) return false;
18
+ if (func === void 0) return false;
19
+ if (!("constructor" in func)) return false;
20
+ return func.constructor.name === "AsyncFunction";
21
+ } catch {
22
+ return false;
23
+ }
24
+ };
25
+ export const InitModals = (modal, nextTick) => {
26
+ Object.keys(modal).forEach((key) => {
27
+ const m = modal[key];
28
+ m.show = async () => {
29
+ if (m.showBefore) {
30
+ if (isAsync(m.showBefore)) {
31
+ if (await m.showBefore(m.state) === true) {
32
+ console.info("\u30E2\u30FC\u30C0\u30EB\u306EShow\u52D5\u4F5C\u306F\u30AD\u30E3\u30F3\u30BB\u30EB\u3055\u308C\u307E\u3057\u305F");
33
+ return;
34
+ }
35
+ } else if (m.showBefore(m.state) === true) {
36
+ console.info("\u30E2\u30FC\u30C0\u30EB\u306EShow\u52D5\u4F5C\u306F\u30AD\u30E3\u30F3\u30BB\u30EB\u3055\u308C\u307E\u3057\u305F");
37
+ return;
38
+ }
39
+ }
40
+ m.isShow = true;
41
+ if (!m.showAfter) return;
42
+ await nextTick();
43
+ if (isAsync(m.showAfter)) {
44
+ await m.showAfter(m.state);
45
+ } else {
46
+ m.showAfter(m.state);
47
+ }
48
+ };
49
+ m.close = async () => {
50
+ if (m.closeBefore) {
51
+ if (isAsync(m.closeBefore)) {
52
+ if (await m.closeBefore(m.state) === true) {
53
+ console.info("\u30E2\u30FC\u30C0\u30EB\u306EClose\u52D5\u4F5C\u306F\u30AD\u30E3\u30F3\u30BB\u30EB\u3055\u308C\u307E\u3057\u305F");
54
+ return;
55
+ }
56
+ } else if (m.closeBefore(m.state) === true) {
57
+ console.info("\u30E2\u30FC\u30C0\u30EB\u306EClose\u52D5\u4F5C\u306F\u30AD\u30E3\u30F3\u30BB\u30EB\u3055\u308C\u307E\u3057\u305F");
58
+ return;
59
+ }
60
+ }
61
+ m.isShow = false;
62
+ await nextTick();
63
+ if (!m.closeAfter) return;
64
+ if (isAsync(m.closeAfter)) {
65
+ await m.closeAfter(m.state);
66
+ } else {
67
+ m.closeAfter(m.state);
68
+ }
69
+ return void 0;
70
+ };
71
+ });
72
+ };
@@ -1,3 +1,4 @@
1
+ export type { TabulatorFull as Tabulator } from "tabulator-tables";
1
2
  import { type Theme } from "../utils/theme.js";
2
3
  /**
3
4
  * セル内部にボタンを配置した時用
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-hs-ui",
3
- "version": "2.0.14",
3
+ "version": "2.0.16",
4
4
  "description": "My new Nuxt module",
5
5
  "repository": "https://github.com/hare-systems-ryo/nuxt-hs-ui",
6
6
  "license": "MIT",
@@ -35,6 +35,11 @@
35
35
  "import": "./dist/runtime/utils/float.js",
36
36
  "require": "./dist/runtime/utils/float.js"
37
37
  },
38
+ "./utils/modal": {
39
+ "types": "./dist/runtime/utils/modal.d.ts",
40
+ "import": "./dist/runtime/utils/modal.js",
41
+ "require": "./dist/runtime/utils/modal.js"
42
+ },
38
43
  "./utils/multi-lang-object": {
39
44
  "types": "./dist/runtime/utils/multi-lang-object.d.ts",
40
45
  "import": "./dist/runtime/utils/multi-lang-object.js",