@at-pocket/js-sdk 0.0.1 → 0.0.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.
package/package.json CHANGED
@@ -1,12 +1,19 @@
1
1
  {
2
2
  "name": "@at-pocket/js-sdk",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "TypeScript definitions for the atPocket JS SDK",
5
- "keywords": ["typescript", "types", "atPocket", "js-sdk"],
5
+ "keywords": [
6
+ "typescript",
7
+ "types",
8
+ "atPocket",
9
+ "js-sdk"
10
+ ],
6
11
  "author": "iii@oec",
7
12
  "license": "MIT",
8
13
  "types": "src/index.d.ts",
9
- "files": ["src"],
14
+ "files": [
15
+ "src"
16
+ ],
10
17
  "publishConfig": {
11
18
  "access": "public"
12
19
  }
@@ -3,6 +3,7 @@ import { ApiInterface } from "./lib/api";
3
3
  import { EventsInterface } from "./lib/events";
4
4
  import { PortalInterface } from "./lib/portal";
5
5
  import { ProxyInterface } from './lib/proxy';
6
+ import { PluginInterface } from './lib/plugin';
6
7
 
7
8
  // atPocket インターフェースに `app` を追加
8
9
  export interface atPocket {
@@ -13,4 +14,12 @@ export interface atPocket {
13
14
  app: AppInterface;
14
15
  portal: PortalInterface;
15
16
  proxy: ProxyInterface;
17
+ plugin: PluginInterface;
18
+
19
+ /**
20
+ * デバイスタイプを取得
21
+ *
22
+ * @returns desktop | mobile
23
+ */
24
+ deviceType: 'desktop' | 'mobile';
16
25
  }
package/src/lib/app.d.ts CHANGED
@@ -46,6 +46,16 @@ export interface AppInterface {
46
46
  */
47
47
  getQueryCondition(): Record<string, any>;
48
48
 
49
+ /**
50
+ * アプリ上部の要素を取得
51
+ */
52
+ getTopSpaceElement(): HTMLElement | null;
53
+
54
+ /**
55
+ * アプリ下部の要素を取得
56
+ */
57
+ getBottomSpaceElement(): HTMLElement | null;
58
+
49
59
  /**
50
60
  * レコード
51
61
  */
@@ -1,11 +1,42 @@
1
+ type ListEvent = {
2
+ appId: number,
3
+ fields: any,
4
+ record: any,
5
+ sort: any,
6
+ order: any,
7
+ }
8
+
9
+ type DetailEvent = {
10
+ appId: number,
11
+ fields: any,
12
+ record: any[]
13
+ }
14
+
15
+ export type Event = ListEvent & DetailEvent;
16
+
1
17
  // イベントハンドラーの型
2
- export type EventHandler = (event: CustomEvent) => any;
18
+ export type EventHandler = (event: Event) => any;
3
19
 
4
20
  // トリガーイベントのオプションの型
5
21
  export type IOptions = Record<string, any>;
6
22
 
7
23
  // コールバック関数の型
8
- export type ICallback = (event: CustomEvent) => void;
24
+ export type ICallback = (event: Event) => void;
25
+
26
+ // イベントタイプ
27
+ export type EventType = 'app.record.index.show'
28
+ | 'app.record.detail.show'
29
+ | 'app.record.detail.delete.submit'
30
+ | 'app.record.detail.delete.submit.success'
31
+ | 'app.record.create.show'
32
+ | 'app.record.create.change'
33
+ | 'app.record.create.submit'
34
+ | 'app.record.create.submit.success'
35
+ | 'app.record.edit.show'
36
+ | 'app.record.edit.change'
37
+ | 'app.record.edit.submit'
38
+ | 'app.record.edit.submit.success'
39
+ | 'portal.index.show';
9
40
 
10
41
  // Events インターフェースの定義
11
42
  export interface EventsInterface {
@@ -14,13 +45,13 @@ export interface EventsInterface {
14
45
  * @param types - イベントの種類(文字列 or 文字列配列)
15
46
  * @param handler - イベント発火時に実行する関数
16
47
  */
17
- on(types: string | string[], handler: EventHandler): void;
48
+ on(types: EventType | EventType[], handler: EventHandler): void;
18
49
 
19
50
  /**
20
51
  * イベントハンドラーを削除
21
52
  * @param types - 削除するイベントの種類(省略可)
22
53
  */
23
- off(types?: string | string[]): void;
54
+ off(types?: EventType | EventType[]): void;
24
55
 
25
56
  /**
26
57
  * イベントを発火
@@ -28,7 +59,7 @@ export interface EventsInterface {
28
59
  * @param options - イベントのオプション(デフォルト `{}`)
29
60
  * @param callback - イベント完了後に実行する関数(オプション)
30
61
  */
31
- trigger(type: string, options?: IOptions, callback?: ICallback): CustomEvent | void;
62
+ trigger(type: EventType, options?: IOptions, callback?: ICallback): Event | void;
32
63
 
33
64
  /**
34
65
  * すべてのイベントを削除
@@ -1,3 +1,25 @@
1
1
  export interface PluginInterface {
2
-
2
+ app: {
3
+ /**
4
+ * プラグインIDを取得
5
+ */
6
+ getPluginId(): string | null;
7
+
8
+ /**
9
+ * プラグイン設定取得
10
+ *
11
+ * @returns プラグイン設定
12
+ */
13
+ getConfig(): Record<string, any>;
14
+
15
+ /**
16
+ * プラグイン設定をセット
17
+ *
18
+ * @param values プラグイン設定
19
+ * @returns {void}
20
+ */
21
+ setConfig(values: Record<string, any>): void
22
+ };
23
+ getConfigFormData(): any;
24
+ setConfigFormData(): void;
3
25
  }
@@ -5,83 +5,91 @@ export interface RecordInterface {
5
5
  * @returns {HTMLElement | null}
6
6
  */
7
7
  getAppBarSpaceElement(): HTMLElement | null;
8
- }
9
8
 
9
+ /**
10
+ * レコードIDを取得
11
+ * @returns {number | null} レコードID
12
+ */
13
+ getId(): number | null;
10
14
 
11
- /**
12
- * AppBarのカスタマイズ領域を取得
13
- * @returns {HTMLElement | null}
14
- */
15
- export function getAppBarSpaceElement(): HTMLElement | null;
15
+ /**
16
+ * レコードのデータを取得
17
+ * @returns {Record<string, any>}
18
+ */
19
+ get(): Record<string, any>;
16
20
 
17
- /**
18
- * レコードIDを取得
19
- * @returns {number | null} レコードID
20
- */
21
- export function getId(): number | null;
21
+ /**
22
+ * レコードに値をセット
23
+ * @param {object} record セットするレコードデータ
24
+ */
25
+ set(record: { record: any }): void;
22
26
 
23
- /**
24
- * レコードのデータを取得
25
- * @returns {Record<string, any>}
26
- */
27
- export function get(): Record<string, any>;
27
+ /**
28
+ * 詳細画面でフィールド要素を取得
29
+ * @param fieldId フィールドのID
30
+ * @returns HTMLElement | null
31
+ */
32
+ getFieldElement(fieldId: string): HTMLElement | null;
28
33
 
29
- /**
30
- * レコードに値をセット
31
- * @param {object} record セットするレコードデータ
32
- */
33
- export function set(record: { record: any }): void;
34
+ /**
35
+ * 新規作成、編集画面でフィールドの入力要素を取得
36
+ * @param fieldId フィールドのID
37
+ * @returns HTMLElement | null;
38
+ */
39
+ getFieldInputElement(fieldId: string): HTMLElement | null;
34
40
 
35
- /**
36
- * フィールド要素を取得
37
- * @param fieldId - フィールドのID
38
- * @returns HTMLElement | null
39
- */
40
- export function getFieldElement(fieldId: string): HTMLElement | null;
41
+ /**
42
+ * フィールドのラベル要素を取得
43
+ * @param fieldId フィールドのID
44
+ * @returns HTMLElement | null
45
+ */
46
+ getFieldLabelElement(fieldId: string): HTMLElement | null;
41
47
 
42
- /**
43
- * フィールドのラベル要素を取得
44
- * @param fieldId - フィールドのID
45
- * @returns HTMLElement | null
46
- */
47
- export function getFieldLabelElement(fieldId: string): HTMLElement | null;
48
+ /**
49
+ * フィールドのデータ要素を取得
50
+ * @param fieldId フィールドのID
51
+ * @returns HTMLElement | null
52
+ */
53
+ getFieldValueElement(fieldId: string): HTMLElement | null;
48
54
 
49
- /**
50
- * フィールドのデータ要素を取得
51
- * @param fieldId - フィールドのID
52
- * @returns HTMLElement | null
53
- */
54
- export function getFieldDataElement(fieldId: string): HTMLElement | null;
55
+ /**
56
+ * フィールドのデータ要素を取得
57
+ * @deprecated getFieldValueElementを使用
58
+ * @param fieldId フィールドのID
59
+ * @returns HTMLElement | null
60
+ */
61
+ getFieldDataElement(fieldId: string): HTMLElement | null;
55
62
 
56
- /**
57
- * スペースフィールドの要素を取得
58
- * @param fieldId - フィールドのID
59
- * @returns HTMLElement | null
60
- */
61
- export function getSpaceElement(fieldId: string): HTMLElement | null;
63
+ /**
64
+ * スペースフィールドの要素を取得
65
+ * @param fieldId フィールドのID
66
+ * @returns HTMLElement | null
67
+ */
68
+ getSpaceElement(fieldId: string): HTMLElement | null;
62
69
 
63
- /**
64
- * フィールドの表示/非表示を切り替える
65
- * @param fieldId - フィールドのID
66
- * @param isShown - 表示するかどうか
67
- */
68
- export function setFieldShown(fieldId: string, isShown: boolean): void;
70
+ /**
71
+ * フィールドの表示/非表示を切り替える
72
+ * @param fieldId フィールドのID
73
+ * @param isShown 表示するかどうか
74
+ */
75
+ setFieldShown(fieldId: string, isShown?: boolean): void;
69
76
 
70
- /**
71
- * フィールドの編集可/不可を切り替える
72
- * @param fieldId - フィールドのID
73
- * @param isDisabled - 編集不可にするかどうか
74
- */
75
- export function setFieldDisabled(fieldId: string, isDisabled: boolean): void;
77
+ /**
78
+ * フィールドが表示中かどうか
79
+ * @param fieldId フィールドのID
80
+ */
81
+ isFieldShown(fieldId: string): boolean;
76
82
 
77
- /**
78
- * レコードのヘッダーの要素を取得
79
- * @returns HTMLElement | null
80
- */
81
- export function getRecordHeaderSpaceElement(): HTMLElement | null;
83
+ /**
84
+ * フィールドの編集可/不可を切り替える
85
+ * @param fieldId フィールドのID
86
+ * @param isDisabled 編集不可にするかどうか
87
+ */
88
+ setFieldDisabled(fieldId: string, isDisabled?: boolean): void;
82
89
 
83
- /**
84
- * レコードのフッターの要素を取得
85
- * @returns HTMLElement | null
86
- */
87
- export function getRecordFooterSpaceElement(): HTMLElement | null;
90
+ /**
91
+ * フィールドが編集不可かどうか
92
+ * @param fieldId フィールドのID
93
+ */
94
+ isFieldDisabled(fieldId: string): boolean;
95
+ }
File without changes