@iyulab/components 0.1.4 → 0.1.5
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/assets/styles/dark.css +40 -36
- package/dist/assets/styles/dark.css.js +1 -1
- package/dist/assets/styles/light.css +41 -38
- package/dist/assets/styles/light.css.js +1 -1
- package/dist/components/BaseElement.styles.js +2 -2
- package/dist/components/alert/Alert.d.ts +8 -4
- package/dist/components/alert/Alert.js +24 -15
- package/dist/components/alert/Alert.styles.js +32 -39
- package/dist/components/alert/index.js +5 -0
- package/dist/components/button/Button.js +4 -2
- package/dist/components/button/Button.styles.js +13 -20
- package/dist/components/button/index.js +5 -0
- package/dist/components/context-menu/index.js +5 -0
- package/dist/components/copy-button/CopyButton.d.ts +7 -3
- package/dist/components/copy-button/CopyButton.js +69 -0
- package/dist/components/copy-button/CopyButton.styles.js +17 -0
- package/dist/components/copy-button/index.js +5 -0
- package/dist/components/dialog/index.js +5 -0
- package/dist/components/divider/Divider.d.ts +5 -5
- package/dist/components/divider/Divider.js +15 -15
- package/dist/components/divider/Divider.styles.js +7 -5
- package/dist/components/divider/index.js +5 -0
- package/dist/components/form/Form.d.ts +3 -1
- package/dist/components/form/Form.js +3 -1
- package/dist/components/form/Form.styles.js +1 -0
- package/dist/components/form/index.js +5 -0
- package/dist/components/icon/Icon.d.ts +6 -12
- package/dist/components/icon/Icon.js +14 -30
- package/dist/components/icon/Icon.styles.js +1 -1
- package/dist/components/icon/index.js +5 -0
- package/dist/components/icon-button/IconButton.d.ts +3 -3
- package/dist/components/icon-button/IconButton.js +6 -6
- package/dist/components/icon-button/IconButton.styles.js +14 -29
- package/dist/components/icon-button/index.js +5 -0
- package/dist/components/index.d.ts +1 -1
- package/dist/components/input/Input.d.ts +14 -13
- package/dist/components/input/Input.js +56 -55
- package/dist/components/input/Input.styles.js +52 -54
- package/dist/components/input/index.js +5 -0
- package/dist/components/menu/index.js +5 -0
- package/dist/components/progress-bar/ProgressBar.d.ts +1 -1
- package/dist/components/progress-bar/ProgressBar.js +2 -2
- package/dist/components/progress-bar/ProgressBar.styles.js +10 -10
- package/dist/components/progress-bar/index.js +5 -0
- package/dist/components/progress-ring/ProgressRing.d.ts +2 -2
- package/dist/components/progress-ring/ProgressRing.js +7 -6
- package/dist/components/progress-ring/ProgressRing.styles.js +8 -9
- package/dist/components/progress-ring/index.js +5 -0
- package/dist/components/spinner/Spinner.styles.js +5 -3
- package/dist/components/spinner/index.js +5 -0
- package/dist/components/split-panel/SplitPanel.d.ts +1 -1
- package/dist/components/split-panel/SplitPanel.js +5 -7
- package/dist/components/split-panel/index.js +5 -0
- package/dist/components/tooltip/Tooltip.styles.js +1 -1
- package/dist/components/tooltip/index.js +5 -0
- package/dist/components/tree/index.js +5 -0
- package/dist/components/tree-item/index.js +5 -0
- package/dist/index.js +24 -5
- package/dist/integrations/react/index.d.ts +0 -1
- package/dist/integrations/react/index.js +0 -1
- package/dist/internals/index.d.ts +0 -1
- package/dist/utilities/decorators.js +2 -0
- package/dist/utilities/icons.d.ts +46 -0
- package/dist/utilities/icons.js +114 -0
- package/dist/utilities/index.d.ts +1 -0
- package/dist/utilities/notifier.d.ts +17 -7
- package/dist/utilities/notifier.js +51 -41
- package/dist/utilities/theme.d.ts +15 -20
- package/dist/utilities/theme.js +24 -20
- package/package.json +7 -6
- package/dist/components/panel/Panel.d.ts +0 -9
- package/dist/components/panel/Panel.js +0 -17
- package/dist/components/panel/Panel.styles.d.ts +0 -1
- package/dist/components/panel/Panel.styles.js +0 -12
- package/dist/components/panel/index.d.ts +0 -7
- package/dist/integrations/react/UPanel.d.ts +0 -8
- package/dist/integrations/react/UPanel.js +0 -10
- package/dist/internals/icon-helpers.d.ts +0 -32
- package/dist/internals/icon-helpers.js +0 -48
|
@@ -3,7 +3,6 @@ import { property } from 'lit/decorators.js';
|
|
|
3
3
|
import { arrayAttributeConverter } from '../../internals/attribute-converters.js';
|
|
4
4
|
import { BaseElement } from '../BaseElement.js';
|
|
5
5
|
import { Divider } from '../divider/Divider.js';
|
|
6
|
-
import { Panel } from '../panel/Panel.js';
|
|
7
6
|
import { styles } from './SplitPanel.styles.js';
|
|
8
7
|
|
|
9
8
|
var __defProp = Object.defineProperty;
|
|
@@ -26,8 +25,8 @@ class SplitPanel extends BaseElement {
|
|
|
26
25
|
this.initialRatio = [];
|
|
27
26
|
this.handleSlotChange = async (e) => {
|
|
28
27
|
const slot = e.target;
|
|
29
|
-
const
|
|
30
|
-
const panels =
|
|
28
|
+
const children = slot.assignedElements({ flatten: true });
|
|
29
|
+
const panels = children.filter((el) => el instanceof HTMLElement);
|
|
31
30
|
if (this.panels.length === panels.length && this.panels.every((p, i) => p === panels[i])) {
|
|
32
31
|
return;
|
|
33
32
|
}
|
|
@@ -52,7 +51,7 @@ class SplitPanel extends BaseElement {
|
|
|
52
51
|
const divider = new Divider();
|
|
53
52
|
divider.orientation = this.orientation;
|
|
54
53
|
divider.draggable = true;
|
|
55
|
-
divider.addEventListener("u-
|
|
54
|
+
divider.addEventListener("u-move", this.handleDividerMove);
|
|
56
55
|
this.dividers.push(divider);
|
|
57
56
|
panel.after(divider);
|
|
58
57
|
});
|
|
@@ -60,7 +59,7 @@ class SplitPanel extends BaseElement {
|
|
|
60
59
|
await this.updateComplete;
|
|
61
60
|
};
|
|
62
61
|
/** 디바이더 드래그 이벤트 핸들러 */
|
|
63
|
-
this.
|
|
62
|
+
this.handleDividerMove = (event) => {
|
|
64
63
|
const divider = event.target;
|
|
65
64
|
const delta = event.detail.delta;
|
|
66
65
|
const index = this.dividers.indexOf(divider);
|
|
@@ -93,8 +92,7 @@ class SplitPanel extends BaseElement {
|
|
|
93
92
|
}
|
|
94
93
|
static {
|
|
95
94
|
this.dependencies = {
|
|
96
|
-
"u-divider": Divider
|
|
97
|
-
"u-panel": Panel
|
|
95
|
+
"u-divider": Divider
|
|
98
96
|
};
|
|
99
97
|
}
|
|
100
98
|
disconnectedCallback() {
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
|
+
import './components/alert/index.js';
|
|
2
|
+
import './components/button/index.js';
|
|
3
|
+
import './components/context-menu/index.js';
|
|
4
|
+
import './components/copy-button/index.js';
|
|
5
|
+
import './components/dialog/index.js';
|
|
6
|
+
import './components/divider/index.js';
|
|
7
|
+
import './components/form/index.js';
|
|
8
|
+
import './components/icon/index.js';
|
|
9
|
+
import './components/icon-button/index.js';
|
|
10
|
+
import './components/input/index.js';
|
|
11
|
+
import './components/menu/index.js';
|
|
12
|
+
import './components/progress-bar/index.js';
|
|
13
|
+
import './components/progress-ring/index.js';
|
|
14
|
+
import './components/spinner/index.js';
|
|
15
|
+
import './components/split-panel/index.js';
|
|
16
|
+
import './components/tooltip/index.js';
|
|
17
|
+
import './components/tree/index.js';
|
|
18
|
+
import './components/tree-item/index.js';
|
|
19
|
+
export { BrowserStorage } from './utilities/BrowserStorage.js';
|
|
20
|
+
export { getPropertyMeta, propertyMeta, setPropertyMeta } from './utilities/decorators.js';
|
|
21
|
+
export { getDefaultBaseUrl, icons, setDefaultBaseUrl } from './utilities/icons.js';
|
|
22
|
+
export { notifier } from './utilities/notifier.js';
|
|
23
|
+
export { theme } from './utilities/theme.js';
|
|
1
24
|
export { Alert } from './components/alert/Alert.js';
|
|
2
25
|
export { Button } from './components/button/Button.js';
|
|
3
26
|
export { ContextMenu } from './components/context-menu/ContextMenu.js';
|
|
27
|
+
export { CopyButton } from './components/copy-button/CopyButton.js';
|
|
4
28
|
export { Dialog } from './components/dialog/Dialog.js';
|
|
5
29
|
export { Divider } from './components/divider/Divider.js';
|
|
6
30
|
export { Form } from './components/form/Form.js';
|
|
@@ -8,7 +32,6 @@ export { Icon } from './components/icon/Icon.js';
|
|
|
8
32
|
export { IconButton } from './components/icon-button/IconButton.js';
|
|
9
33
|
export { Input } from './components/input/Input.js';
|
|
10
34
|
export { Menu } from './components/menu/Menu.js';
|
|
11
|
-
export { Panel } from './components/panel/Panel.js';
|
|
12
35
|
export { ProgressBar } from './components/progress-bar/ProgressBar.js';
|
|
13
36
|
export { ProgressRing } from './components/progress-ring/ProgressRing.js';
|
|
14
37
|
export { Spinner } from './components/spinner/Spinner.js';
|
|
@@ -16,7 +39,3 @@ export { SplitPanel } from './components/split-panel/SplitPanel.js';
|
|
|
16
39
|
export { Tooltip } from './components/tooltip/Tooltip.js';
|
|
17
40
|
export { Tree } from './components/tree/Tree.js';
|
|
18
41
|
export { TreeItem } from './components/tree-item/TreeItem.js';
|
|
19
|
-
export { BrowserStorage } from './utilities/BrowserStorage.js';
|
|
20
|
-
export { getPropertyMeta, propertyMeta, setPropertyMeta } from './utilities/decorators.js';
|
|
21
|
-
export { notifier } from './utilities/notifier.js';
|
|
22
|
-
export { Theme, theme } from './utilities/theme.js';
|
|
@@ -17,7 +17,6 @@ export { UIconButton, UIconButtonProps } from './UIconButton';
|
|
|
17
17
|
export { UInput, UInputProps } from './UInput';
|
|
18
18
|
export { UMenu, UMenuProps } from './UMenu';
|
|
19
19
|
export { UMenuItem, UMenuItemProps } from './UMenuItem';
|
|
20
|
-
export { UPanel, UPanelProps } from './UPanel';
|
|
21
20
|
export { UProgressBar, UProgressBarProps } from './UProgressBar';
|
|
22
21
|
export { UProgressRing, UProgressRingProps } from './UProgressRing';
|
|
23
22
|
export { USpinner, USpinnerProps } from './USpinner';
|
|
@@ -10,7 +10,6 @@ export { UIconButton } from './UIconButton.js';
|
|
|
10
10
|
export { UInput } from './UInput.js';
|
|
11
11
|
export { UMenu } from './UMenu.js';
|
|
12
12
|
export { UMenuItem } from './UMenuItem.js';
|
|
13
|
-
export { UPanel } from './UPanel.js';
|
|
14
13
|
export { UProgressBar } from './UProgressBar.js';
|
|
15
14
|
export { UProgressRing } from './UProgressRing.js';
|
|
16
15
|
export { USpinner } from './USpinner.js';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
type IconResolver = (name: string) => string | undefined | Promise<string | undefined>;
|
|
2
|
+
/**
|
|
3
|
+
* 아이콘 레지스트리 클래스입니다.
|
|
4
|
+
* 아이콘 라이브러리를 등록하고, 아이콘을 조회하는 기능을 제공합니다.
|
|
5
|
+
*/
|
|
6
|
+
declare class IconRegistry {
|
|
7
|
+
private static _instance;
|
|
8
|
+
private libs;
|
|
9
|
+
private constructor();
|
|
10
|
+
static get instance(): IconRegistry;
|
|
11
|
+
/**
|
|
12
|
+
* 지정된 아이콘 라이브러리가 등록되었는지 확인합니다.
|
|
13
|
+
*/
|
|
14
|
+
has(lib: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* 지정된 아이콘 라이브러리를 등록합니다.
|
|
17
|
+
* 이미 등록된 라이브러리 이름인 경우, 경고 메시지를 출력합니다.
|
|
18
|
+
*/
|
|
19
|
+
register(lib: string, resolver: IconResolver): void;
|
|
20
|
+
/**
|
|
21
|
+
* 지정된 아이콘 라이브러리를 등록 해제합니다.
|
|
22
|
+
*/
|
|
23
|
+
unregister(lib: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* 지정된 아이콘 라이브러리의 svg 아이콘 소스를 가져옵니다.
|
|
26
|
+
*/
|
|
27
|
+
resolve(lib: string, name: string): Promise<string | undefined>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 전역 아이콘 레지스트리 인스턴스에 접근합니다.
|
|
31
|
+
* 기본 내장 아이콘 라이브러리가 포함되어 있습니다.
|
|
32
|
+
*/
|
|
33
|
+
export declare const icons: IconRegistry;
|
|
34
|
+
/**
|
|
35
|
+
* `default` 라이브러리에서 아이콘을 로드할 때 사용할 기본 URL을 반환합니다.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getDefaultBaseUrl(): string;
|
|
38
|
+
/**
|
|
39
|
+
* `default` 라이브러리에서 아이콘을 로드할 때 사용할 기본 URL을 설정합니다.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* - `/assets/icons/`
|
|
43
|
+
* - `https://cdn.example.com/icons/`
|
|
44
|
+
*/
|
|
45
|
+
export declare function setDefaultBaseUrl(url: string): void;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import * as arrowClockwise from '../assets/icons/arrow-clockwise.svg.js';
|
|
2
|
+
import * as arrowDown from '../assets/icons/arrow-down.svg.js';
|
|
3
|
+
import * as arrowUp from '../assets/icons/arrow-up.svg.js';
|
|
4
|
+
import * as ban from '../assets/icons/ban.svg.js';
|
|
5
|
+
import * as bellFill from '../assets/icons/bell-fill.svg.js';
|
|
6
|
+
import * as checkCircleFill from '../assets/icons/check-circle-fill.svg.js';
|
|
7
|
+
import * as checkLg from '../assets/icons/check-lg.svg.js';
|
|
8
|
+
import * as chevronDown from '../assets/icons/chevron-down.svg.js';
|
|
9
|
+
import * as chevronLeft from '../assets/icons/chevron-left.svg.js';
|
|
10
|
+
import * as chevronRight from '../assets/icons/chevron-right.svg.js';
|
|
11
|
+
import * as chevronUp from '../assets/icons/chevron-up.svg.js';
|
|
12
|
+
import * as copy from '../assets/icons/copy.svg.js';
|
|
13
|
+
import * as dashLg from '../assets/icons/dash-lg.svg.js';
|
|
14
|
+
import * as exclamationCircleFill from '../assets/icons/exclamation-circle-fill.svg.js';
|
|
15
|
+
import * as exclamationTriangleFill from '../assets/icons/exclamation-triangle-fill.svg.js';
|
|
16
|
+
import * as eyeSlash from '../assets/icons/eye-slash.svg.js';
|
|
17
|
+
import * as eye from '../assets/icons/eye.svg.js';
|
|
18
|
+
import * as infoCircleFill from '../assets/icons/info-circle-fill.svg.js';
|
|
19
|
+
import * as layoutSidebar from '../assets/icons/layout-sidebar.svg.js';
|
|
20
|
+
import * as lightbulbFill from '../assets/icons/lightbulb-fill.svg.js';
|
|
21
|
+
import * as lightbulbOff from '../assets/icons/lightbulb-off.svg.js';
|
|
22
|
+
import * as lightbulb from '../assets/icons/lightbulb.svg.js';
|
|
23
|
+
import * as micFill from '../assets/icons/mic-fill.svg.js';
|
|
24
|
+
import * as micMuteFill from '../assets/icons/mic-mute-fill.svg.js';
|
|
25
|
+
import * as paperclip from '../assets/icons/paperclip.svg.js';
|
|
26
|
+
import * as pencilSquare from '../assets/icons/pencil-square.svg.js';
|
|
27
|
+
import * as plusLg from '../assets/icons/plus-lg.svg.js';
|
|
28
|
+
import * as search from '../assets/icons/search.svg.js';
|
|
29
|
+
import * as speedometer from '../assets/icons/speedometer.svg.js';
|
|
30
|
+
import * as xLg from '../assets/icons/x-lg.svg.js';
|
|
31
|
+
|
|
32
|
+
let defaultIconBaseUrl = "/assets/icons/";
|
|
33
|
+
const defaultIconCache = /* @__PURE__ */ new Map();
|
|
34
|
+
const internalIconBundle = new Map(
|
|
35
|
+
Object.entries(/* #__PURE__ */ Object.assign({"../assets/icons/arrow-clockwise.svg": arrowClockwise,"../assets/icons/arrow-down.svg": arrowDown,"../assets/icons/arrow-up.svg": arrowUp,"../assets/icons/ban.svg": ban,"../assets/icons/bell-fill.svg": bellFill,"../assets/icons/check-circle-fill.svg": checkCircleFill,"../assets/icons/check-lg.svg": checkLg,"../assets/icons/chevron-down.svg": chevronDown,"../assets/icons/chevron-left.svg": chevronLeft,"../assets/icons/chevron-right.svg": chevronRight,"../assets/icons/chevron-up.svg": chevronUp,"../assets/icons/copy.svg": copy,"../assets/icons/dash-lg.svg": dashLg,"../assets/icons/exclamation-circle-fill.svg": exclamationCircleFill,"../assets/icons/exclamation-triangle-fill.svg": exclamationTriangleFill,"../assets/icons/eye-slash.svg": eyeSlash,"../assets/icons/eye.svg": eye,"../assets/icons/info-circle-fill.svg": infoCircleFill,"../assets/icons/layout-sidebar.svg": layoutSidebar,"../assets/icons/lightbulb-fill.svg": lightbulbFill,"../assets/icons/lightbulb-off.svg": lightbulbOff,"../assets/icons/lightbulb.svg": lightbulb,"../assets/icons/mic-fill.svg": micFill,"../assets/icons/mic-mute-fill.svg": micMuteFill,"../assets/icons/paperclip.svg": paperclip,"../assets/icons/pencil-square.svg": pencilSquare,"../assets/icons/plus-lg.svg": plusLg,"../assets/icons/search.svg": search,"../assets/icons/speedometer.svg": speedometer,"../assets/icons/x-lg.svg": xLg
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
})).map(([path, module]) => {
|
|
39
|
+
const name = path.split("/").pop()?.replace(".svg", "") || "";
|
|
40
|
+
return [name, module.default];
|
|
41
|
+
}).filter(([name]) => name !== "")
|
|
42
|
+
);
|
|
43
|
+
class IconRegistry {
|
|
44
|
+
constructor() {
|
|
45
|
+
this.libs = /* @__PURE__ */ new Map();
|
|
46
|
+
}
|
|
47
|
+
static get instance() {
|
|
48
|
+
if (!this._instance) {
|
|
49
|
+
this._instance = new IconRegistry();
|
|
50
|
+
}
|
|
51
|
+
return this._instance;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 지정된 아이콘 라이브러리가 등록되었는지 확인합니다.
|
|
55
|
+
*/
|
|
56
|
+
has(lib) {
|
|
57
|
+
return this.libs.has(lib);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* 지정된 아이콘 라이브러리를 등록합니다.
|
|
61
|
+
* 이미 등록된 라이브러리 이름인 경우, 경고 메시지를 출력합니다.
|
|
62
|
+
*/
|
|
63
|
+
register(lib, resolver) {
|
|
64
|
+
if (this.libs.has(lib)) {
|
|
65
|
+
console.warn(`Icon library "${lib}" is already registered`);
|
|
66
|
+
} else {
|
|
67
|
+
this.libs.set(lib, resolver);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 지정된 아이콘 라이브러리를 등록 해제합니다.
|
|
72
|
+
*/
|
|
73
|
+
unregister(lib) {
|
|
74
|
+
this.libs.delete(lib);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* 지정된 아이콘 라이브러리의 svg 아이콘 소스를 가져옵니다.
|
|
78
|
+
*/
|
|
79
|
+
async resolve(lib, name) {
|
|
80
|
+
const resolver = this.libs.get(lib);
|
|
81
|
+
if (!resolver) return void 0;
|
|
82
|
+
const svg = await resolver(name);
|
|
83
|
+
return svg?.trim();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
IconRegistry.instance.register("internal", (name) => {
|
|
87
|
+
return internalIconBundle.get(name);
|
|
88
|
+
});
|
|
89
|
+
IconRegistry.instance.register("default", async (name) => {
|
|
90
|
+
if (defaultIconCache.has(name)) {
|
|
91
|
+
return defaultIconCache.get(name);
|
|
92
|
+
}
|
|
93
|
+
const baseUrl = getDefaultBaseUrl();
|
|
94
|
+
const remoteUrl = baseUrl.endsWith("/") ? `${baseUrl}${name}.svg` : `${baseUrl}/${name}.svg`;
|
|
95
|
+
try {
|
|
96
|
+
const response = await fetch(remoteUrl);
|
|
97
|
+
if (!response.ok) return void 0;
|
|
98
|
+
const svg = await response.text();
|
|
99
|
+
defaultIconCache.set(name, svg);
|
|
100
|
+
return svg;
|
|
101
|
+
} catch (error) {
|
|
102
|
+
console.error(error);
|
|
103
|
+
return void 0;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
const icons = IconRegistry.instance;
|
|
107
|
+
function getDefaultBaseUrl() {
|
|
108
|
+
return defaultIconBaseUrl;
|
|
109
|
+
}
|
|
110
|
+
function setDefaultBaseUrl(url) {
|
|
111
|
+
defaultIconBaseUrl = url;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export { getDefaultBaseUrl, icons, setDefaultBaseUrl };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AlertType } from '../components/alert/Alert.js';
|
|
2
2
|
export type ScreenPosition = "top-left" | "top-center" | "top-right" | "middle-left" | "middle-center" | "middle-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
3
3
|
/** 토스트 알림 옵션 */
|
|
4
4
|
export interface ToastOptions {
|
|
5
5
|
/** 알림 유형 */
|
|
6
6
|
type: AlertType;
|
|
7
7
|
/** 알림 제목 */
|
|
8
|
-
|
|
8
|
+
heading?: string;
|
|
9
9
|
/** 알림 내용 */
|
|
10
10
|
content?: string;
|
|
11
11
|
/** 알림 표시 시간 (밀리초 단위) */
|
|
@@ -14,13 +14,23 @@ export interface ToastOptions {
|
|
|
14
14
|
position?: ScreenPosition;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Notifier 클래스 — 싱글톤 패턴으로 사용합니다.
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
declare class Notifier {
|
|
20
|
+
private static _instance;
|
|
21
|
+
private containers;
|
|
22
|
+
private toasts;
|
|
23
|
+
private constructor();
|
|
24
|
+
static get instance(): Notifier;
|
|
22
25
|
/**
|
|
23
26
|
* 토스트 알림을 생성합니다.
|
|
24
27
|
*/
|
|
25
28
|
toast(options: ToastOptions): Promise<void>;
|
|
26
|
-
|
|
29
|
+
/** 위치에 맞는 컨테이너 엘리먼트를 가져오거나, 생성합니다. */
|
|
30
|
+
private getOrCreateContainer;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 알림 유틸리티 싱글톤 인스턴스입니다.
|
|
34
|
+
*/
|
|
35
|
+
export declare const notifier: Notifier;
|
|
36
|
+
export {};
|
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
import { Alert } from '../components/alert/Alert.js';
|
|
2
2
|
|
|
3
3
|
Alert.define("u-alert");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
class Notifier {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.containers = /* @__PURE__ */ new Map();
|
|
7
|
+
this.toasts = /* @__PURE__ */ new Set();
|
|
8
|
+
}
|
|
9
|
+
static get instance() {
|
|
10
|
+
if (!this._instance) {
|
|
11
|
+
this._instance = new Notifier();
|
|
12
|
+
}
|
|
13
|
+
return this._instance;
|
|
14
|
+
}
|
|
7
15
|
/**
|
|
8
16
|
* 토스트 알림을 생성합니다.
|
|
9
17
|
*/
|
|
10
18
|
async toast(options) {
|
|
11
19
|
const el = new Alert();
|
|
12
20
|
el.type = options.type;
|
|
13
|
-
el.
|
|
21
|
+
el.heading = options.heading;
|
|
14
22
|
el.content = options.content;
|
|
15
23
|
this.toasts.add(el);
|
|
16
24
|
const position = options.position || "top-right";
|
|
17
|
-
const container = getOrCreateContainer(position);
|
|
25
|
+
const container = this.getOrCreateContainer(position);
|
|
18
26
|
container.appendChild(el);
|
|
19
27
|
await el.updateComplete;
|
|
20
28
|
el.show();
|
|
@@ -26,46 +34,48 @@ const notifier = {
|
|
|
26
34
|
this.toasts.delete(el);
|
|
27
35
|
if (!container.hasChildNodes()) {
|
|
28
36
|
container.remove();
|
|
29
|
-
this.
|
|
37
|
+
this.containers.delete(position);
|
|
30
38
|
}
|
|
31
39
|
}, duration);
|
|
32
40
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
41
|
+
/** 위치에 맞는 컨테이너 엘리먼트를 가져오거나, 생성합니다. */
|
|
42
|
+
getOrCreateContainer(position) {
|
|
43
|
+
let container = this.containers.get(position);
|
|
44
|
+
if (container) return container;
|
|
45
|
+
container = document.createElement("div");
|
|
46
|
+
container.style.position = "fixed";
|
|
47
|
+
container.style.zIndex = "9999";
|
|
48
|
+
container.style.display = "flex";
|
|
49
|
+
container.style.gap = "10px";
|
|
50
|
+
const transformParts = [];
|
|
51
|
+
if (position.startsWith("top")) {
|
|
52
|
+
container.style.top = "20px";
|
|
53
|
+
container.style.flexDirection = "column";
|
|
54
|
+
} else if (position.startsWith("bottom")) {
|
|
55
|
+
container.style.bottom = "20px";
|
|
56
|
+
container.style.flexDirection = "column-reverse";
|
|
57
|
+
} else {
|
|
58
|
+
container.style.top = "50%";
|
|
59
|
+
container.style.flexDirection = "column";
|
|
60
|
+
transformParts.push("translateY(-50%)");
|
|
61
|
+
}
|
|
62
|
+
if (position.endsWith("left")) {
|
|
63
|
+
container.style.left = "20px";
|
|
64
|
+
container.style.alignItems = "flex-start";
|
|
65
|
+
} else if (position.endsWith("right")) {
|
|
66
|
+
container.style.right = "20px";
|
|
67
|
+
container.style.alignItems = "flex-end";
|
|
68
|
+
} else {
|
|
69
|
+
container.style.left = "50%";
|
|
70
|
+
container.style.alignItems = "center";
|
|
71
|
+
transformParts.unshift("translateX(-50%)");
|
|
72
|
+
}
|
|
73
|
+
container.style.transform = transformParts.length ? transformParts.join(" ") : "";
|
|
74
|
+
document.body.appendChild(container);
|
|
75
|
+
this.containers.set(position, container);
|
|
76
|
+
return container;
|
|
64
77
|
}
|
|
65
|
-
container.style.transform = transformParts.length ? transformParts.join(" ") : "";
|
|
66
|
-
document.body.appendChild(container);
|
|
67
|
-
notifier.container.set(position, container);
|
|
68
|
-
return container;
|
|
69
78
|
}
|
|
79
|
+
const notifier = Notifier.instance;
|
|
70
80
|
|
|
71
81
|
export { notifier };
|
|
@@ -8,11 +8,6 @@ export interface ThemeInitOptions {
|
|
|
8
8
|
* @default false
|
|
9
9
|
*/
|
|
10
10
|
debug?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* 내부적으로 제공되는 스타일 시트를 사용할지 여부
|
|
13
|
-
* @default true
|
|
14
|
-
*/
|
|
15
|
-
useBuiltIn?: boolean;
|
|
16
11
|
/**
|
|
17
12
|
* 테마 설정을 브라우저 스토리지에 영구 저장할지 여부 또는 옵션
|
|
18
13
|
* @default false
|
|
@@ -23,24 +18,27 @@ export interface ThemeInitOptions {
|
|
|
23
18
|
* @default 'system'
|
|
24
19
|
*/
|
|
25
20
|
default?: ThemeType;
|
|
21
|
+
/**
|
|
22
|
+
* 내부적으로 제공되는 스타일 시트를 사용할지 여부
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
25
|
+
useBuiltIn?: boolean;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* 현재 문서에 테마를 적용하고 관리하는 유틸리티 클래스입니다.
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
declare class Theme {
|
|
31
31
|
private static _instance;
|
|
32
|
-
private readonly
|
|
32
|
+
private readonly STORAGE_THEME_KEY;
|
|
33
33
|
private storage;
|
|
34
34
|
private _isInitialized;
|
|
35
35
|
private _isDebugMode;
|
|
36
|
-
/** private 생성자 — 외부에서 new Theme()를 할 수 없게 함 */
|
|
37
36
|
private constructor();
|
|
38
|
-
/** 싱글톤 인스턴스 접근자 */
|
|
39
37
|
static get instance(): Theme;
|
|
40
|
-
/** 외부에서 현재 초기화 상태를 확인할 수 있게 getter 제공 */
|
|
41
38
|
get isInitialized(): boolean;
|
|
39
|
+
get isDebugMode(): boolean;
|
|
42
40
|
/**
|
|
43
|
-
* 테마
|
|
41
|
+
* 테마 유틸리티를 초기화합니다.
|
|
44
42
|
*/
|
|
45
43
|
init(options?: ThemeInitOptions): Promise<void>;
|
|
46
44
|
/**
|
|
@@ -48,19 +46,16 @@ export declare class Theme {
|
|
|
48
46
|
*/
|
|
49
47
|
get(): ThemeType | undefined;
|
|
50
48
|
/**
|
|
51
|
-
* 현재
|
|
49
|
+
* 현재 문서에 적용할 테마를 설정합니다.
|
|
52
50
|
*/
|
|
53
51
|
set(theme: ThemeType): void;
|
|
54
|
-
/**
|
|
55
|
-
* 시스템 테마 변경을 처리하는 메서드
|
|
56
|
-
*/
|
|
52
|
+
/** 시스템 테마 변경을 처리하는 메서드 */
|
|
57
53
|
private handleSystemThemeChanged;
|
|
58
|
-
/**
|
|
59
|
-
* 디버그 모드시 로그 출력 함수 (인스턴스 스코프)
|
|
60
|
-
*/
|
|
54
|
+
/** 디버그 모드시 로그 출력 함수 (인스턴스 스코프) */
|
|
61
55
|
private log;
|
|
62
56
|
}
|
|
63
57
|
/**
|
|
64
|
-
* 테마
|
|
58
|
+
* 테마 유틸리티의 싱글톤 인스턴스입니다.
|
|
65
59
|
*/
|
|
66
60
|
export declare const theme: Theme;
|
|
61
|
+
export {};
|