@sonhoseong/mfa-lib 1.2.4 → 1.2.6

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,32 @@
1
+ import React from 'react';
2
+ export interface AppNavbarProps {
3
+ /** 앱 이름/타이틀 */
4
+ appName?: string;
5
+ /** 로고 클릭 시 이동할 경로 */
6
+ homePath?: string;
7
+ /** 관리 페이지 경로 */
8
+ adminPath?: string;
9
+ /** 로그인 페이지 경로 */
10
+ loginPath?: string;
11
+ /** 인증 상태 */
12
+ isAuthenticated: boolean;
13
+ /** 사용자 이름 */
14
+ userName?: string;
15
+ /** 로그아웃 핸들러 */
16
+ onLogout: () => void;
17
+ /** 네비게이션 함수 */
18
+ onNavigate: (path: string) => void;
19
+ /** 추가 네비게이션 링크 */
20
+ extraLinks?: Array<{
21
+ label: string;
22
+ path: string;
23
+ isActive?: boolean;
24
+ }>;
25
+ }
26
+ /**
27
+ * 공통 네비게이션 바 - KOMCA 패턴
28
+ * Remote 앱 단독 실행 시 사용
29
+ */
30
+ export declare const AppNavbar: React.FC<AppNavbarProps>;
31
+ export default AppNavbar;
32
+ //# sourceMappingURL=AppNavbar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppNavbar.d.ts","sourceRoot":"","sources":["../../../src/components/navigation/AppNavbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,cAAc;IAC7B,eAAe;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY;IACZ,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe;IACf,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,eAAe;IACf,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,kBAAkB;IAClB,UAAU,CAAC,EAAE,KAAK,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC,CAAC;CACJ;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAkJ9C,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -0,0 +1,72 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * 공통 네비게이션 바 - KOMCA 패턴
4
+ * Remote 앱 단독 실행 시 사용
5
+ */
6
+ export const AppNavbar = ({ appName = '앱', homePath = '/', adminPath = '/admin', loginPath = '/login', isAuthenticated, userName, onLogout, onNavigate, extraLinks = [] }) => {
7
+ const styles = {
8
+ navbar: {
9
+ position: 'fixed',
10
+ top: 0,
11
+ left: 0,
12
+ right: 0,
13
+ zIndex: 1000,
14
+ background: 'rgba(255, 255, 255, 0.95)',
15
+ backdropFilter: 'blur(12px)',
16
+ WebkitBackdropFilter: 'blur(12px)',
17
+ borderBottom: '1px solid #E2E8F0',
18
+ },
19
+ inner: {
20
+ maxWidth: '1100px',
21
+ margin: '0 auto',
22
+ padding: '16px 24px',
23
+ display: 'flex',
24
+ alignItems: 'center',
25
+ justifyContent: 'space-between',
26
+ },
27
+ logoLink: {
28
+ display: 'flex',
29
+ alignItems: 'center',
30
+ gap: '8px',
31
+ textDecoration: 'none',
32
+ color: '#1E3A5F',
33
+ fontWeight: 600,
34
+ fontSize: '16px',
35
+ cursor: 'pointer',
36
+ background: 'none',
37
+ border: 'none',
38
+ padding: 0,
39
+ },
40
+ links: {
41
+ display: 'flex',
42
+ alignItems: 'center',
43
+ gap: '8px',
44
+ },
45
+ link: {
46
+ padding: '8px 16px',
47
+ color: '#64748B',
48
+ textDecoration: 'none',
49
+ fontSize: '14px',
50
+ fontWeight: 500,
51
+ borderRadius: '8px',
52
+ transition: 'all 0.2s ease',
53
+ background: 'transparent',
54
+ border: 'none',
55
+ cursor: 'pointer',
56
+ fontFamily: 'inherit',
57
+ },
58
+ linkActive: {
59
+ color: '#0EA5E9',
60
+ background: 'rgba(14, 165, 233, 0.1)',
61
+ },
62
+ };
63
+ return (_jsx("nav", { style: styles.navbar, children: _jsxs("div", { style: styles.inner, children: [_jsxs("button", { style: styles.logoLink, onClick: () => onNavigate(homePath), children: [_jsx("svg", { viewBox: "0 0 48 48", width: "24", height: "24", fill: "none", children: _jsx("path", { d: "M 8 40 L 24 8 L 40 40", stroke: "#1E3A5F", strokeWidth: "8", strokeLinecap: "round", strokeLinejoin: "round", fill: "none" }) }), _jsx("span", { children: appName })] }), _jsxs("div", { style: styles.links, children: [_jsx("button", { style: styles.link, onClick: () => onNavigate(homePath), onMouseOver: (e) => (e.currentTarget.style.background = '#F8FAFC'), onMouseOut: (e) => (e.currentTarget.style.background = 'transparent'), children: "\uD648" }), extraLinks.map((link) => (_jsx("button", { style: {
64
+ ...styles.link,
65
+ ...(link.isActive ? styles.linkActive : {}),
66
+ }, onClick: () => onNavigate(link.path), children: link.label }, link.path))), isAuthenticated && (_jsx("button", { style: styles.link, onClick: () => onNavigate(adminPath), onMouseOver: (e) => (e.currentTarget.style.background = '#F8FAFC'), onMouseOut: (e) => (e.currentTarget.style.background = 'transparent'), children: "\uAD00\uB9AC" })), !isAuthenticated ? (_jsx("button", { style: {
67
+ ...styles.link,
68
+ background: '#1E3A5F',
69
+ color: 'white',
70
+ }, onClick: () => onNavigate(loginPath), onMouseOver: (e) => (e.currentTarget.style.background = '#0EA5E9'), onMouseOut: (e) => (e.currentTarget.style.background = '#1E3A5F'), children: "\uB85C\uADF8\uC778" })) : (_jsxs("button", { style: styles.link, onClick: onLogout, onMouseOver: (e) => (e.currentTarget.style.background = '#F8FAFC'), onMouseOut: (e) => (e.currentTarget.style.background = 'transparent'), children: ["\uB85C\uADF8\uC544\uC6C3 ", userName && `(${userName})`] }))] })] }) }));
71
+ };
72
+ export default AppNavbar;
@@ -18,6 +18,8 @@ export interface StickyNavProps {
18
18
  showLogo?: boolean;
19
19
  /** 커스텀 클래스 */
20
20
  className?: string;
21
+ /** URL hash 업데이트 여부 (기본 true) */
22
+ updateHash?: boolean;
21
23
  }
22
24
  export declare const StickyNav: React.FC<StickyNavProps>;
23
25
  export default StickyNav;
@@ -1 +1 @@
1
- {"version":3,"file":"StickyNav.d.ts","sourceRoot":"","sources":["../../../src/components/navigation/StickyNav.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAEhE,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,+BAA+B;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sBAAsB;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uBAAuB;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB;IACjB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,eAAe;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAmK9C,CAAC;AAEF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"StickyNav.d.ts","sourceRoot":"","sources":["../../../src/components/navigation/StickyNav.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAEhE,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,+BAA+B;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sBAAsB;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uBAAuB;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB;IACjB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,eAAe;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAwM9C,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -1,9 +1,32 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState, useEffect, useCallback } from 'react';
3
- export const StickyNav = ({ sections, triggerPoint = 0.2, scrollOffset = 80, topPosition = 20, onLogoClick, showLogo = true, className = '' }) => {
3
+ export const StickyNav = ({ sections, triggerPoint = 0.2, scrollOffset = 80, topPosition = 20, onLogoClick, showLogo = true, className = '', updateHash = true }) => {
4
4
  const [activeSection, setActiveSection] = useState('');
5
5
  const [hoveredSection, setHoveredSection] = useState(null);
6
- // Scroll spy
6
+ // 초기 로드 시 hash가 있으면 해당 섹션으로 스크롤 + hashchange 이벤트 처리
7
+ useEffect(() => {
8
+ const scrollToHash = () => {
9
+ if (window.location.hash) {
10
+ const id = window.location.hash.slice(1);
11
+ const element = document.getElementById(id);
12
+ if (element) {
13
+ const elementPosition = element.getBoundingClientRect().top;
14
+ const offsetPosition = elementPosition + window.pageYOffset - scrollOffset;
15
+ window.scrollTo({ top: offsetPosition, behavior: 'smooth' });
16
+ }
17
+ }
18
+ };
19
+ // 초기 로드
20
+ if (updateHash && window.location.hash) {
21
+ setTimeout(scrollToHash, 100);
22
+ }
23
+ // 브라우저 뒤로/앞으로 버튼 처리
24
+ if (updateHash) {
25
+ window.addEventListener('hashchange', scrollToHash);
26
+ return () => window.removeEventListener('hashchange', scrollToHash);
27
+ }
28
+ }, [updateHash, scrollOffset]);
29
+ // Scroll spy - 스크롤 시 active section 업데이트 + hash 업데이트
7
30
  useEffect(() => {
8
31
  const handleScroll = () => {
9
32
  const viewportHeight = window.innerHeight;
@@ -13,7 +36,13 @@ export const StickyNav = ({ sections, triggerPoint = 0.2, scrollOffset = 80, top
13
36
  if (element) {
14
37
  const rect = element.getBoundingClientRect();
15
38
  if (rect.top <= trigger && rect.bottom > trigger) {
16
- setActiveSection(section.id);
39
+ if (activeSection !== section.id) {
40
+ setActiveSection(section.id);
41
+ // 스크롤 시에도 hash 업데이트 (pushState로 히스토리 쌓지 않음)
42
+ if (updateHash) {
43
+ window.history.replaceState(null, '', `#${section.id}`);
44
+ }
45
+ }
17
46
  break;
18
47
  }
19
48
  }
@@ -22,15 +51,19 @@ export const StickyNav = ({ sections, triggerPoint = 0.2, scrollOffset = 80, top
22
51
  window.addEventListener('scroll', handleScroll, { passive: true });
23
52
  handleScroll();
24
53
  return () => window.removeEventListener('scroll', handleScroll);
25
- }, [sections, triggerPoint]);
54
+ }, [sections, triggerPoint, activeSection, updateHash]);
26
55
  const scrollToSection = useCallback((id) => {
27
56
  const element = document.getElementById(id);
28
57
  if (element) {
58
+ // URL hash 업데이트 (pushState로 히스토리에 추가)
59
+ if (updateHash) {
60
+ window.history.pushState(null, '', `#${id}`);
61
+ }
29
62
  const elementPosition = element.getBoundingClientRect().top;
30
63
  const offsetPosition = elementPosition + window.pageYOffset - scrollOffset;
31
64
  window.scrollTo({ top: offsetPosition, behavior: 'smooth' });
32
65
  }
33
- }, [scrollOffset]);
66
+ }, [scrollOffset, updateHash]);
34
67
  const handleLogoClick = useCallback(() => {
35
68
  if (onLogoClick) {
36
69
  onLogoClick();
@@ -1,2 +1,3 @@
1
1
  export * from './StickyNav';
2
+ export * from './AppNavbar';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/navigation/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/navigation/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
@@ -1 +1,2 @@
1
1
  export * from './StickyNav';
2
+ export * from './AppNavbar';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonhoseong/mfa-lib",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
4
4
  "description": "MFA 공통 라이브러리 - KOMCA 패턴",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",