@loafacto/ui 0.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.
@@ -0,0 +1,20 @@
1
+ /** 전역 로딩 상태. API 호출 시 start/stop 하면 오버레이 표시 */
2
+ export declare const useLoadingStore: import("pinia").StoreDefinition<"loading", Pick<{
3
+ loading: import("vue").ComputedRef<boolean>;
4
+ count: import("vue").Ref<number, number>;
5
+ start: () => void;
6
+ stop: () => void;
7
+ withLoading: <T>(fn: () => Promise<T>) => Promise<T>;
8
+ }, "count">, Pick<{
9
+ loading: import("vue").ComputedRef<boolean>;
10
+ count: import("vue").Ref<number, number>;
11
+ start: () => void;
12
+ stop: () => void;
13
+ withLoading: <T>(fn: () => Promise<T>) => Promise<T>;
14
+ }, "loading">, Pick<{
15
+ loading: import("vue").ComputedRef<boolean>;
16
+ count: import("vue").Ref<number, number>;
17
+ start: () => void;
18
+ stop: () => void;
19
+ withLoading: <T>(fn: () => Promise<T>) => Promise<T>;
20
+ }, "stop" | "start" | "withLoading">>;
@@ -0,0 +1,69 @@
1
+ export type ToastType = 'success' | 'error' | 'info' | 'warning';
2
+ export interface ToastItem {
3
+ id: string;
4
+ type: ToastType;
5
+ message: string;
6
+ duration: number;
7
+ createdAt: number;
8
+ }
9
+ export declare const useToastStore: import("pinia").StoreDefinition<"toast", Pick<{
10
+ items: import("vue").Ref<{
11
+ id: string;
12
+ type: ToastType;
13
+ message: string;
14
+ duration: number;
15
+ createdAt: number;
16
+ }[], ToastItem[] | {
17
+ id: string;
18
+ type: ToastType;
19
+ message: string;
20
+ duration: number;
21
+ createdAt: number;
22
+ }[]>;
23
+ add: (message: string, type?: ToastType, duration?: number) => string;
24
+ remove: (id: string) => void;
25
+ success: (message: string, duration?: number) => string;
26
+ error: (message: string, duration?: number) => string;
27
+ info: (message: string, duration?: number) => string;
28
+ warning: (message: string, duration?: number) => string;
29
+ }, "items">, Pick<{
30
+ items: import("vue").Ref<{
31
+ id: string;
32
+ type: ToastType;
33
+ message: string;
34
+ duration: number;
35
+ createdAt: number;
36
+ }[], ToastItem[] | {
37
+ id: string;
38
+ type: ToastType;
39
+ message: string;
40
+ duration: number;
41
+ createdAt: number;
42
+ }[]>;
43
+ add: (message: string, type?: ToastType, duration?: number) => string;
44
+ remove: (id: string) => void;
45
+ success: (message: string, duration?: number) => string;
46
+ error: (message: string, duration?: number) => string;
47
+ info: (message: string, duration?: number) => string;
48
+ warning: (message: string, duration?: number) => string;
49
+ }, never>, Pick<{
50
+ items: import("vue").Ref<{
51
+ id: string;
52
+ type: ToastType;
53
+ message: string;
54
+ duration: number;
55
+ createdAt: number;
56
+ }[], ToastItem[] | {
57
+ id: string;
58
+ type: ToastType;
59
+ message: string;
60
+ duration: number;
61
+ createdAt: number;
62
+ }[]>;
63
+ add: (message: string, type?: ToastType, duration?: number) => string;
64
+ remove: (id: string) => void;
65
+ success: (message: string, duration?: number) => string;
66
+ error: (message: string, duration?: number) => string;
67
+ info: (message: string, duration?: number) => string;
68
+ warning: (message: string, duration?: number) => string;
69
+ }, "error" | "success" | "info" | "warning" | "add" | "remove">>;
@@ -0,0 +1,31 @@
1
+ import { type SemanticPalette } from './themeColors';
2
+ /**
3
+ * 사용자가 실제로 고르는 색은 5개뿐이다. 나머지 시맨틱 색상(텍스트·경계·상태·버튼…)은
4
+ * 전부 이 5개에서 파생된다 — deriveSemanticPalette() 참고.
5
+ *
6
+ * 값의 출처는 서비스마다 다르다. hub 는 백엔드 site_settings 에서 받아오고,
7
+ * 서비스 앱은 그냥 기본값을 쓰거나 자체 설정을 넣으면 된다.
8
+ */
9
+ export interface ThemeConfig {
10
+ /** 앱 전체 배경 */
11
+ bg: string;
12
+ /** 사이드바 배경 */
13
+ sidebar: string;
14
+ /** 헤더/상단바 배경 */
15
+ header: string;
16
+ /** 카드/패널 배경 */
17
+ card: string;
18
+ /** 강조색 — 버튼·링크·활성 상태의 기준 */
19
+ accent: string;
20
+ /** 스킨 식별자. CSS 에서 `[style*="--admin-ui-skin"]` 분기용 훅으로만 쓴다. */
21
+ skin?: string;
22
+ }
23
+ export declare const DEFAULT_THEME: ThemeConfig;
24
+ /**
25
+ * 테마를 CSS 변수로 문서 루트에 적용한다.
26
+ *
27
+ * CSS 변수를 쓰는 이유는 이 값들이 라이브러리 경계를 넘어가야 하기 때문이다.
28
+ * 플랫폼 셸이 한 번 적용하면 같은 문서 안의 모든 서비스 화면이 —
29
+ * 리모트로 붙든 iframe 이든 — 같은 색을 본다. JS 로 전파할 필요가 없다.
30
+ */
31
+ export declare function applyTheme(config?: Partial<ThemeConfig>): SemanticPalette;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * 시맨틱 색상 자동 파생 시스템
3
+ *
4
+ * 사용자가 정의하는 색상: bg, sidebar, header, card, accent (5개)
5
+ * 이 5개로부터 나머지 모든 UI 색상을 자동으로 파생한다.
6
+ */
7
+ /** hex → [r, g, b] (0-255) */
8
+ export declare function hexToRgb(hex: string): [number, number, number];
9
+ /** 색상 문자열(hex 또는 rgba)에서 RGB 추출 */
10
+ export declare function colorToRgb(color: string): [number, number, number];
11
+ /** 상대 휘도 (WCAG 2.1) — 0(검정)~1(흰색) */
12
+ export declare function luminance(r: number, g: number, b: number): number;
13
+ /** WCAG 대비율 */
14
+ export declare function contrastRatio(l1: number, l2: number): number;
15
+ export declare function isLightBackground(color: string): boolean;
16
+ export interface SemanticPalette {
17
+ textHeading: string;
18
+ textBody: string;
19
+ textMuted: string;
20
+ border: string;
21
+ hover: string;
22
+ overlay: string;
23
+ surface: string;
24
+ surfaceAlt: string;
25
+ accent: string;
26
+ accentRgb: string;
27
+ accentText: string;
28
+ accentHover: string;
29
+ accentMuted: string;
30
+ accentMutedText: string;
31
+ btnPrimaryBg: string;
32
+ btnPrimaryText: string;
33
+ btnPrimaryHover: string;
34
+ inputBg: string;
35
+ inputBorder: string;
36
+ inputFocusBorder: string;
37
+ inputFocusShadow: string;
38
+ statusSuccess: string;
39
+ statusError: string;
40
+ statusWarning: string;
41
+ statusInfo: string;
42
+ statusNeutral: string;
43
+ statusPurple: string;
44
+ statusTeal: string;
45
+ sidebarText: string;
46
+ sidebarTextMuted: string;
47
+ sidebarActive: string;
48
+ headerText: string;
49
+ footerBg: string;
50
+ footerText: string;
51
+ footerBorder: string;
52
+ }
53
+ /** 5개 기본색으로부터 전체 시맨틱 팔레트 파생 */
54
+ export declare function deriveSemanticPalette(bg: string, sidebar: string, header: string, _card: string, accent: string): SemanticPalette;
55
+ /** CSS 변수로 일괄 적용 */
56
+ export declare function applySemanticPalette(palette: SemanticPalette): void;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * 플랫폼에 편입된 서비스 하나를 기술한다.
3
+ *
4
+ * 이 목록은 두 곳에서 동시에 쓰인다 — 홈의 서비스 런처와 상단바의 서비스 전환 메뉴.
5
+ * 그래서 목록의 출처는 반드시 한 군데여야 한다(현재는 apps/web/src/services.ts).
6
+ * 서비스가 늘어나면 이 목록을 별도 패키지(@loafacto/registry)로 승격시켜
7
+ * 각 서비스 저장소도 같은 정의를 읽게 만든다.
8
+ */
9
+ export interface ServiceDescriptor {
10
+ /** 안정적인 식별자. 경로와 별개로 유지된다. */
11
+ id: string;
12
+ /** 사용자에게 보이는 이름 */
13
+ name: string;
14
+ /**
15
+ * 진입 경로. 같은 오리진의 절대 경로다 — 예: '/macro'.
16
+ * 이 값이 곧 Caddy 가 이 서비스의 정적 파일로 보내는 접두사이며,
17
+ * 동시에 플랫폼 라우터가 건드리면 안 되는 예약 경로다.
18
+ *
19
+ * 끝 슬래시를 붙이지 않는다. 대신 Caddy 에 `redir /macro /macro/ permanent` 가
20
+ * 있어야 한다 — `handle /macro/*` 는 끝 슬래시 없는 경로를 매칭하지 않는다.
21
+ *
22
+ * 별도 사이트로 나가는 외부 링크는 서비스가 아니다. ShortcutLink 를 쓴다.
23
+ */
24
+ path: string;
25
+ /** 런처 카드에 들어가는 한 줄 설명 */
26
+ description?: string;
27
+ /** 24x24 viewBox 기준 SVG path 데이터 */
28
+ iconPath?: string;
29
+ /** 아직 준비 중이면 true — 런처에 보이되 진입은 막는다 */
30
+ comingSoon?: boolean;
31
+ /** 로그인해야 쓸 수 있는 서비스인지 */
32
+ requiresAuth?: boolean;
33
+ }
34
+ /**
35
+ * 상단바에 아이콘으로 놓이는 바로가기.
36
+ *
37
+ * 서비스(ServiceDescriptor)와 구분한다. 서비스는 loafacto.com 경로 아래로 편입돼
38
+ * 플랫폼이 라우팅까지 책임지는 대상이고, 바로가기는 그냥 다른 사이트로 나가는 링크다.
39
+ * 홈 런처에 섞어두면 "플랫폼에 편입된 서비스"라는 의미가 흐려져서 분리했다.
40
+ *
41
+ * 항상 새 탭에서 열린다 — 나가는 링크이므로 지금 보던 화면을 잃지 않는 편이 낫다.
42
+ */
43
+ export interface ShortcutLink {
44
+ id: string;
45
+ /** 툴팁과 스크린리더에 쓰이는 이름 */
46
+ label: string;
47
+ /** 전체 URL */
48
+ href: string;
49
+ /** 24x24 viewBox 기준 SVG path 데이터 */
50
+ iconPath: string;
51
+ }
52
+ /** 상단바에 표시할 현재 사용자 요약 */
53
+ export interface ShellUser {
54
+ displayName: string;
55
+ email?: string;
56
+ avatarUrl?: string;
57
+ }
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@loafacto/ui",
3
+ "version": "0.1.0",
4
+ "description": "Loafacto 공용 UI — 테마(시맨틱 팔레트 파생), 애플리케이션 셸, 공통 오버레이 컴포넌트",
5
+ "type": "module",
6
+ "files": ["dist"],
7
+ "main": "./dist/index.js",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js"
14
+ },
15
+ "./styles.css": "./dist/loafacto-ui.css",
16
+ "./package.json": "./package.json"
17
+ },
18
+ "sideEffects": ["**/*.css"],
19
+ "publishConfig": {
20
+ "registry": "https://registry.npmjs.org",
21
+ "//access": "스코프 패키지는 기본이 restricted 다. public 을 명시하지 않으면 유료 플랜을 요구하며 거부된다.",
22
+ "access": "public"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/Qpang/loafacto-platform.git",
27
+ "directory": "packages/ui"
28
+ },
29
+ "scripts": {
30
+ "build": "vite build && vue-tsc -p tsconfig.build.json",
31
+ "typecheck": "vue-tsc --noEmit -p tsconfig.json",
32
+
33
+ "//prepare": "npm 이 설치 직후 자동으로 실행한다. apps/web 은 @loafacto/ui 의 타입을 dist/index.d.ts 에서 읽는데 dist 는 gitignore 대상이라 갓 클론한 트리에는 없다. 이게 없으면 빌드보다 타입체크가 먼저 도는 순간(CI 가 정확히 그렇다) 모듈을 못 찾는다.",
34
+ "prepare": "npm run build"
35
+ },
36
+ "peerDependencies": {
37
+ "pinia": "^3.0.0",
38
+ "vue": "^3.5.0"
39
+ },
40
+ "devDependencies": {
41
+ "@types/node": "^22.10.2",
42
+ "@vitejs/plugin-vue": "^6.0.2",
43
+ "pinia": "^3.0.4",
44
+ "typescript": "~5.9.3",
45
+ "vite": "^6.0.3",
46
+ "vue": "^3.5.13",
47
+ "vue-tsc": "^3.1.5"
48
+ }
49
+ }