@konomi-app/ui 3.0.0 → 4.1.0

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/index.d.ts CHANGED
@@ -1,128 +1,162 @@
1
- declare class Overlay {
2
- #private;
3
- /**
4
- * オーバーレイをレンダリングするルート要素の`dataset`。
5
- */
6
- protected readonly _rootDataset: DOMStringMap;
7
- /**
8
- * オーバーレイが表示されているかどうか。
9
- */
10
- protected _shown: boolean;
11
- /**
12
- * オーバーレイを表示中にページを離れようとした場合にアラートを表示するかどうかを設定します。
13
- */
14
- protected _disableBeforeUnload: boolean;
15
- constructor();
16
- show(): void;
17
- hide(): void;
18
- protected render(): void;
19
- /** JavaScript中にページを離れようとした場合にアラートを表示します */
20
- private beforeunload;
21
- protected get root(): HTMLDivElement;
22
- /** @deprecated このメソッドは非推奨です。代わりに`show`メソッドを使用してください。 */
23
- start(): void;
24
- /** @deprecated このメソッドは非推奨です。代わりに`hide`メソッドを使用してください。 */
25
- stop(): void;
1
+ import * as lit from 'lit';
2
+ import { LitElement, TemplateResult } from 'lit';
3
+
4
+ type DialogType = 'loading' | 'alert' | 'confirm' | 'queue' | 'steps';
5
+ type AlertIcon = 'success' | 'error' | 'warning' | 'info';
6
+ type QueueItemStatus = 'pending' | 'active' | 'done' | 'skipped' | 'error';
7
+ type StepItemStatus = 'pending' | 'active' | 'done' | 'skipped' | 'error';
8
+ interface QueueItem {
9
+ label: string;
10
+ status: QueueItemStatus;
11
+ }
12
+ interface StepItem {
13
+ label: string;
14
+ status: StepItemStatus;
15
+ }
16
+ interface ShowOptions {
17
+ type: DialogType;
18
+ label?: string;
19
+ description?: string;
20
+ icon?: AlertIcon;
21
+ progress?: number;
22
+ allowOutsideClick?: boolean;
23
+ }
24
+ interface AlertOptions {
25
+ type?: AlertIcon;
26
+ label?: string;
27
+ description?: string;
28
+ html?: string;
29
+ showCancelButton?: boolean;
30
+ confirmButtonText?: string;
31
+ cancelButtonText?: string;
32
+ allowOutsideClick?: boolean;
33
+ allowEscapeKey?: boolean;
34
+ timer?: number;
35
+ }
36
+ interface ConfirmOptions {
37
+ label?: string;
38
+ description?: string;
39
+ type?: AlertIcon;
40
+ confirmButtonText?: string;
41
+ cancelButtonText?: string;
42
+ allowOutsideClick?: boolean;
43
+ allowEscapeKey?: boolean;
44
+ }
45
+ interface DialogResult {
46
+ isConfirmed: boolean;
47
+ isCanceled: boolean;
48
+ isDismissed: boolean;
49
+ }
50
+ interface DialogState {
51
+ open: boolean;
52
+ dialogType: DialogType;
53
+ icon: AlertIcon | null;
54
+ label: string;
55
+ description: string;
56
+ html: string;
57
+ progress: number | null;
58
+ showConfirmButton: boolean;
59
+ showCancelButton: boolean;
60
+ confirmButtonText: string;
61
+ cancelButtonText: string;
62
+ allowOutsideClick: boolean;
63
+ allowEscapeKey: boolean;
64
+ queues: QueueItem[];
65
+ steps: StepItem[];
66
+ timer: number | null;
67
+ title: string;
26
68
  }
27
69
 
28
- type Label$2 = string | string[];
29
- type ConstructorProps$2 = Readonly<Partial<{
30
- label: Label$2;
31
- progress: number;
32
- }>>;
33
- declare const ATTRIBUTE_ANIMATION = "data-animation";
34
- declare class LoadingOverlay extends Overlay {
70
+ type Listener = (state: DialogState) => void;
71
+ declare class DialogController {
35
72
  #private;
36
- protected readonly _loaderElement: HTMLDivElement;
37
- protected readonly _progressElement: HTMLDivElement;
38
- protected readonly _contentElement: HTMLDivElement;
39
- constructor(props?: ConstructorProps$2);
40
- show(): void;
73
+ constructor();
74
+ get state(): Readonly<DialogState>;
75
+ subscribe(fn: Listener): () => void;
76
+ show(options?: ShowOptions): void;
41
77
  hide(): void;
42
- set label(label: Label$2);
43
- set html(html: string);
44
- /**
45
- * 進捗状況を設定します。
46
- * @param percent 進捗のパーセンテージ(0-100)
47
- */
48
- set progress(percent: number);
49
- render(): void;
78
+ alert(optionsOrLabel: string | AlertOptions): Promise<DialogResult>;
79
+ confirm(optionsOrLabel: string | ConfirmOptions): Promise<boolean>;
80
+ loading(label?: string): void;
81
+ progress(percent: number): void;
82
+ label(label: string): void;
83
+ description(description: string): void;
84
+ setQueues(labels: string[]): void;
85
+ queue(labels: string[], title?: string): void;
86
+ queueTitle(title: string): void;
87
+ startQueue(label: string): void;
88
+ finishQueue(label: string): void;
89
+ skipQueue(label: string): void;
90
+ errorQueue(label: string): void;
91
+ clearQueues(): void;
92
+ setSteps(labels: string[]): void;
93
+ steps(labels: string[]): void;
94
+ startStep(label: string): void;
95
+ finishStep(label: string): void;
96
+ skipStep(label: string): void;
97
+ errorStep(label: string): void;
98
+ clearSteps(): void;
99
+ onConfirm(): void;
100
+ onCancel(): void;
101
+ onOutsideClick(): void;
102
+ onEscapeKey(): void;
50
103
  }
51
104
 
52
- type Label$1 = string | string[];
53
- type TaskStatus = 'new' | 'in-progress' | 'done' | 'error';
54
- type Task = {
55
- key: string;
56
- label: Label$1;
57
- status: TaskStatus;
58
- };
59
- type ConstructorProps$1 = Readonly<Partial<{
60
- taskList: Task[];
61
- }>>;
62
- declare class TaskListOverlay extends Overlay {
63
- #private;
64
- protected readonly _contentElement: HTMLDivElement;
65
- constructor(props?: ConstructorProps$1);
66
- hide(): void;
67
- done(key: string): void;
68
- error(key: string): void;
69
- inProgress(key: string): void;
70
- addTask(...tasks: {
71
- key: string;
72
- label: Label$1;
73
- }[]): void;
74
- render(): void;
75
- private renderTask;
76
- private getTaskStatusElement;
77
- private containerStyle;
78
- private contentStyle;
79
- private taskListContainerStyle;
80
- private taskContainerStyle;
81
- private taskLabelStyle;
82
- private taskStatusStyle;
105
+ declare class OverlayDialog extends LitElement {
106
+ static styles: lit.CSSResult;
107
+ controller: DialogController;
108
+ private _state;
109
+ private _unsubscribe?;
110
+ private _beforeUnloadHandler;
111
+ connectedCallback(): void;
112
+ disconnectedCallback(): void;
113
+ private _syncBodyScroll;
114
+ private _onBackdropClick;
115
+ private _onKeyDown;
116
+ private _renderIcon;
117
+ private _renderSpinner;
118
+ private _renderTaskIcon;
119
+ private _getQueueWindow;
120
+ private _renderQueueList;
121
+ private _renderStepsHeader;
122
+ private _renderStepsList;
123
+ private _renderButtons;
124
+ private _renderBody;
125
+ render(): TemplateResult;
126
+ }
127
+ declare global {
128
+ interface HTMLElementTagNameMap {
129
+ 'overlay-dialog': OverlayDialog;
130
+ }
83
131
  }
84
132
 
85
- type Label = string | string[];
86
- type ConstructorProps = Readonly<Partial<{
87
- label: Label;
88
- progress: number;
89
- }>>;
90
- declare class Modal extends Overlay {
133
+ declare class DialogSingleton {
91
134
  #private;
92
- protected readonly _containerElement: HTMLDivElement;
93
- protected readonly _iconElement: HTMLDivElement;
94
- protected readonly _titleElement: HTMLDivElement;
95
- protected readonly _loaderElement: HTMLDivElement;
96
- protected readonly _progressElement: HTMLDivElement;
97
- protected readonly _contentElement: HTMLDivElement;
98
- protected readonly _actionsElement: HTMLDivElement;
99
- protected readonly _okButtonElement: HTMLButtonElement;
100
- protected readonly _cancelButtonElement: HTMLButtonElement;
101
- constructor(props?: ConstructorProps);
102
- alert(params: {
103
- title?: string;
104
- text?: string;
105
- icon?: string;
106
- disableClose?: boolean;
107
- disableEscape?: boolean;
108
- }): Promise<any>;
109
- loading(): void;
135
+ show(options?: ShowOptions): void;
110
136
  hide(): void;
111
- set label(label: Label);
112
- set html(html: string);
113
- set progress(progress: number);
114
- private changeState;
115
- render(): void;
137
+ alert(optionsOrLabel: string | AlertOptions): Promise<DialogResult>;
138
+ confirm(optionsOrLabel: string | ConfirmOptions): Promise<boolean>;
139
+ loading(label?: string): void;
140
+ progress(percent: number): void;
141
+ label(label: string): void;
142
+ description(description: string): void;
143
+ setQueues(labels: string[]): void;
144
+ queue(labels: string[], title?: string): void;
145
+ startQueue(label: string): void;
146
+ finishQueue(label: string): void;
147
+ skipQueue(label: string): void;
148
+ errorQueue(label: string): void;
149
+ queueTitle(title: string): void;
150
+ clearQueues(): void;
151
+ setSteps(labels: string[]): void;
152
+ steps(labels: string[]): void;
153
+ startStep(label: string): void;
154
+ finishStep(label: string): void;
155
+ skipStep(label: string): void;
156
+ errorStep(label: string): void;
157
+ clearSteps(): void;
158
+ get controller(): DialogController;
116
159
  }
160
+ declare const dialog: DialogSingleton;
117
161
 
118
- /**
119
- * 指定された関数をラップし、実行中にローディングオーバーレイを表示する高階関数。
120
- *
121
- * @template T - 任意の引数を取り、任意の値を返す関数の型。
122
- * @param {T} fn - 実行する関数。
123
- * @param {string} [label='Loading...'] - ローディングオーバーレイに表示するラベル。デフォルトは 'Loading...'。
124
- * @returns {(...args: Parameters<T>) => Promise<ReturnType<T>>} - ラップされた関数。実行中にローディングオーバーレイを表示し、完了後に非表示にする。
125
- */
126
- declare const withLoading: <T extends (...args: any[]) => any>(fn: T, label?: string) => (...args: Parameters<T>) => Promise<ReturnType<T>>;
127
-
128
- export { ATTRIBUTE_ANIMATION, LoadingOverlay, Modal, TaskListOverlay, withLoading };
162
+ export { type AlertIcon, type AlertOptions, type ConfirmOptions, DialogController, type DialogResult, type DialogState, type DialogType, OverlayDialog, type QueueItem, type QueueItemStatus, type ShowOptions, type StepItem, type StepItemStatus, dialog };