v7.0.0-beta.1 release

This commit is contained in:
HeuJung committed 2026-04-01 10:30:52 +09:00
commit 6595fd0eb5
3967 files changed
+1875383

No files matched your search

@@ -0,0 +1,43 @@
# Changelog
이 프로젝트의 모든 주요 변경사항을 기록합니다.
형식은 [Keep a Changelog](https://keepachangelog.com/ko/1.1.0/)를 따르며,
[Semantic Versioning](https://semver.org/lang/ko/)을 준수합니다.
## [1.0.0-beta.1] - 2026-04-01
### Changed
- 오픈 베타 릴리즈
## [0.1.3] - 2026-03-16
### Changed
- 라이선스 프로그램 명칭 정비
## [0.1.2] - 2026-03-13
### Added
- manifest에 license 필드 및 LICENSE 파일 추가
### Changed
- 설정 레이아웃 경로를 `resources/layouts/settings.json` → `resources/layouts/admin/plugin_settings.json`으로 이동 (모듈과 동일한 구조 통일)
## [0.1.1] - 2026-02-24
### Changed
- 버전 체계 조정 (정식 출시 전 0.x 체계로 변경)
## [0.1.0] - 2026-02-23
### Added
- Daum 우편번호 검색 플러그인 초기 구현
- Daum 우편번호 서비스 API 연동 (API 키 불필요)
- 주소 검색 팝업/레이어 표시 모드 설정
- 커스텀 핸들러 (openPostcode, setFieldReadOnly)
- 이커머스 주소 검색 레이아웃 확장 (ecommerce-address-search)
- 플러그인 설정 UI (표시 모드, 테마 설정)
- 다국어 지원 (ko, en)
@@ -0,0 +1,47 @@
프로그램 명칭 : 그누보드7용 Daum 우편번호 플러그인 (sirsoft-daum_postcode)
저작자 : (주)에스아이알소프트
----- MIT 라이선스 (한국어 번역) --------------------------------------------------------
MIT 라이선스
Copyright (c) 2026 (주)에스아이알소프트
이 소프트웨어와 관련 문서 파일(이하 "소프트웨어")의 복사본을 취득하는 모든 사람에게
소프트웨어를 제한 없이 사용, 복사, 수정, 병합, 출판, 배포, 서브라이선스 허여 및/또는
판매할 수 있는 권리를 무상으로 부여합니다. 다만, 소프트웨어를 제공받은 사람은 다음
조건을 따라야 합니다:
위 저작권 고지와 본 허가 고지는 소프트웨어의 모든 복사본 또는 상당 부분에 포함되어야
합니다.
소프트웨어는 "있는 그대로" 제공되며, 명시적이든 묵시적이든 어떠한 종류의 보증도 하지
않습니다. 여기에는 상품성, 특정 목적에의 적합성 및 비침해에 대한 보증이 포함되나 이에
국한되지 않습니다. 어떠한 경우에도 저작자 또는 저작권자는 소프트웨어나 소프트웨어의
사용 또는 기타 거래로 인해 발생하는 계약, 불법행위 또는 기타 청구, 손해 또는 기타
책임에 대해 책임을 지지 않습니다.
----- MIT License (English Original) --------------------------------------------------------
The MIT License (MIT)
Copyright (c) 2026 SIRSOFT
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,20 @@
{
"name": "plugins/sirsoft-daum_postcode",
"description": "Daum Postcode Service Plugin for Gnuboard7 platform",
"type": "library",
"version": "1.0.0-beta.1",
"authors": [
{
"name": "sirsoft",
"email": "contact@sirsoft.com"
}
],
"require": {
"php": "^8.2"
},
"autoload": {
"psr-4": {
"Plugins\\Sirsoft\\DaumPostcode\\": ["src/", "./"]
}
}
}
@@ -0,0 +1,18 @@
{
"_meta": {
"version": "1.0.0",
"description": "Daum 우편번호 플러그인 환경설정"
},
"defaults": {
"display_mode": "layer",
"popup_width": 500,
"popup_height": 600,
"theme_color": "#1D4ED8"
},
"frontend_schema": {
"display_mode": { "expose": true },
"popup_width": { "expose": true },
"popup_height": { "expose": true },
"theme_color": { "expose": true }
}
}
@@ -0,0 +1,37 @@
var SirsoftDaumPostcode=function(m){"use strict";const y=window.G7Core?.createLogger?.("DaumPostcode:SetFieldReadOnly")??{log:(...e)=>console.log("[DaumPostcode:SetFieldReadOnly]",...e),warn:(...e)=>console.warn("[DaumPostcode:SetFieldReadOnly]",...e),error:(...e)=>console.error("[DaumPostcode:SetFieldReadOnly]",...e)};function C(e,c){const o=e.params||{},t=o.fields||[],n=o.readOnly!==!1;if(!t.length){y.warn("[setFieldReadOnly] No fields specified");return}y.log(`[setFieldReadOnly] Setting readOnly=${n} for fields:`,t),t.forEach(r=>{const s=document.querySelectorAll(`input[name="${r}"], textarea[name="${r}"]`);if(s.length===0){y.warn(`[setFieldReadOnly] No input found with name="${r}"`);return}s.forEach(i=>{i.readOnly=n,n?i.classList.add("readonly"):i.classList.remove("readonly"),y.log(`[setFieldReadOnly] Set readOnly=${n} on input[name="${r}"]`)})})}const a=window.G7Core?.createLogger?.("DaumPostcode:OpenPostcode")??{log:(...e)=>console.log("[DaumPostcode:OpenPostcode]",...e),warn:(...e)=>console.warn("[DaumPostcode:OpenPostcode]",...e),error:(...e)=>console.error("[DaumPostcode:OpenPostcode]",...e)};function O(e){return{zipcode:e.zonecode||"",address:e.roadAddress||e.jibunAddress||"",addressDetail:"",region:e.sido||"",city:e.sigungu||"",countryCode:"KR",_raw:e}}function x(e,c){const o=e.params||{},{callbackAction:t,displayMode:n="layer",width:r=500,height:s=600,theme:i,targetFields:l}=o,b=(window.G7Core?.plugin?.getSettings?.("sirsoft-daum_postcode")||{}).target_fields||{zipcode:"shipping.zipcode",address:"shipping.address",region:"shipping.region",city:"shipping.city"};if(a.log("[openPostcode] Starting with params:",{displayMode:n,width:r,height:s,hasCallbackAction:!!t,targetFields:l||b}),!window.daum?.Postcode){a.error("[openPostcode] Daum Postcode API not loaded");return}const g={oncomplete:h=>{a.log("[openPostcode] Address selected (raw):",h);const f=O(h);a.log("[openPostcode] Converted to G7 format:",f),t?(a.log("[openPostcode] Executing callbackAction"),L(t,f,c)):(a.log("[openPostcode] Executing default setState"),S(l||b,f))},width:r,height:s};i&&(g.theme=i);const v=new window.daum.Postcode(g);if(n==="popup")v.open();else{const{layer:h,closeLayer:f}=$(r,s),D=g.oncomplete;g.oncomplete=k=>{f(),D(k)},new window.daum.Postcode(g).embed(h)}}function $(e,c){const o=document.createElement("div");o.id="daum-postcode-overlay",o.style.cssText=`
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
justify-content: center;
z-index: 9999;
`;const t=document.createElement("div");t.id="daum-postcode-layer",t.style.cssText=`
width: ${e}px;
height: ${c}px;
background-color: white;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
`;const n=document.createElement("button");n.type="button",n.innerHTML="×",n.style.cssText=`
position: absolute;
top: -12px;
right: -12px;
width: 32px;
height: 32px;
border-radius: 50%;
background-color: #374151;
color: white;
border: none;
cursor: pointer;
font-size: 20px;
line-height: 1;
display: flex;
align-items: center;
justify-content: center;
z-index: 10;
`;const r=document.createElement("div");r.style.cssText="position: relative;",r.appendChild(n),r.appendChild(t),o.appendChild(r),document.body.appendChild(o);const s=()=>{o.parentNode&&o.parentNode.removeChild(o)};n.addEventListener("click",s),o.addEventListener("click",l=>{l.target===o&&s()});const i=l=>{l.key==="Escape"&&(s(),document.removeEventListener("keydown",i))};return document.addEventListener("keydown",i),a.log("[openPostcode] Layer created with size:",{width:e,height:c}),{overlay:o,layer:t,closeLayer:s}}function L(e,c,o){const t=window.G7Core;if(!t?.dispatch){a.error("[openPostcode] G7Core.dispatch not available");return}const n=o?.state||t?.state?.getLocal?.()||{},r={state:n,setState:o?.setState,data:{...o?.data||{},_local:n,$event:c},isolatedContext:o?.isolatedContext};a.log("[openPostcode] Dispatching with componentContext:",{hasLocalState:!!n,sourceType:o?.state?"handlerContext":"getLocal",localCheckout:n?.checkout,event:c});try{const s=Array.isArray(e)?e:[e];for(const i of s)i&&typeof i=="object"&&(a.log("[openPostcode] Dispatching action:",i),t.dispatch(i,{componentContext:r}))}catch(s){a.error("[openPostcode] callbackAction failed:",s)}}function S(e,c){const o=window.G7Core;if(!o?.state?.setLocal){a.error("[openPostcode] G7Core.state.setLocal not available");return}const t={};e.zipcode&&(t[e.zipcode]=c.zipcode),e.address&&(t[e.address]=c.address),e.region&&(t[e.region]=c.region),e.city&&(t[e.city]=c.city),a.log("[openPostcode] Setting local state:",t),o.state.setLocal(t)}const p={setFieldReadOnly:C,openPostcode:x},d="sirsoft-daum_postcode",u=window.G7Core?.createLogger?.(`Plugin:${d}`)??{log:(...e)=>console.log(`[Plugin:${d}]`,...e),warn:(...e)=>console.warn(`[Plugin:${d}]`,...e),error:(...e)=>console.error(`[Plugin:${d}]`,...e)};function P(e=!1){const c=window.G7Core?.getActionDispatcher?.();if(c)Object.entries(p).forEach(([o,t])=>{const n=`${d}.${o}`;c.registerHandler(n,t,{category:"plugin",source:d})}),u.log(`${Object.keys(p).length} handler(s) registered:`,Object.keys(p).map(o=>`${d}.${o}`));else if(e){let o=0;const t=50,n=()=>{const r=window.G7Core?.getActionDispatcher?.();r?(Object.entries(p).forEach(([s,i])=>{const l=`${d}.${s}`;r.registerHandler(l,i,{category:"plugin",source:d})}),u.log(`${Object.keys(p).length} handler(s) registered:`,Object.keys(p).map(s=>`${d}.${s}`))):(o++,o<=t?(u.warn(`ActionDispatcher not found, retrying... (${o}/${t})`),setTimeout(n,100)):u.error("Failed to register handlers: ActionDispatcher not available after maximum retries"))};n()}else u.warn("ActionDispatcher not found, handlers not registered")}function w(){if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>P(!0));else{const e=!!window.G7Core?.getActionDispatcher?.();P(!e)}}return w(),typeof window<"u"&&(window.__SirsoftDaumPostcode={identifier:d,handlers:Object.keys(p),initPlugin:w}),m.initPlugin=w,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"}),m}({});
//# sourceMappingURL=plugin.iife.js.map
@@ -0,0 +1 @@
{"version":3,"file":"plugin.iife.js","sources":["../../resources/js/handlers/setFieldReadOnly.ts","../../resources/js/handlers/openPostcode.ts","../../resources/js/handlers/index.ts","../../resources/js/index.ts"],"sourcesContent":["/**\n * setFieldReadOnly 핸들러\n *\n * 지정된 필드명의 input 요소를 찾아 readOnly 속성을 설정합니다.\n * 주소 검색 플러그인이 설치된 경우, 우편번호/주소 필드를 readOnly로 설정하여\n * 사용자가 직접 입력하지 못하도록 합니다.\n */\n\nimport type { ActionContext } from '../types';\n\n// Logger 설정 (G7Core 초기화 전에도 동작하도록 폴백 포함)\nconst logger = ((window as any).G7Core?.createLogger?.('DaumPostcode:SetFieldReadOnly')) ?? {\n log: (...args: unknown[]) => console.log('[DaumPostcode:SetFieldReadOnly]', ...args),\n warn: (...args: unknown[]) => console.warn('[DaumPostcode:SetFieldReadOnly]', ...args),\n error: (...args: unknown[]) => console.error('[DaumPostcode:SetFieldReadOnly]', ...args),\n};\n\ninterface ActionWithParams {\n handler: string;\n params?: {\n /** readOnly로 설정할 필드명 배열 */\n fields?: string[];\n /** readOnly 값 (기본값: true) */\n readOnly?: boolean;\n };\n [key: string]: any;\n}\n\n/**\n * 지정된 필드명의 input 요소를 찾아 readOnly 속성을 설정합니다.\n *\n * @param action 액션 객체 (params.fields: 필드명 배열, params.readOnly: boolean)\n * @param _context 액션 컨텍스트\n *\n * @example\n * // 레이아웃 JSON에서 사용\n * {\n * \"handler\": \"sirsoft-daum_postcode.setFieldReadOnly\",\n * \"params\": {\n * \"fields\": [\"zonecode\", \"address\"],\n * \"readOnly\": true\n * }\n * }\n */\nexport function setFieldReadOnlyHandler(\n action: ActionWithParams,\n _context: ActionContext\n): void {\n const params = action.params || {};\n const fields = params.fields || [];\n const readOnly = params.readOnly !== false; // 기본값 true\n\n if (!fields.length) {\n logger.warn('[setFieldReadOnly] No fields specified');\n return;\n }\n\n logger.log(`[setFieldReadOnly] Setting readOnly=${readOnly} for fields:`, fields);\n\n // 각 필드에 대해 DOM에서 input 요소를 찾아 readOnly 설정\n fields.forEach((fieldName) => {\n // name 속성으로 input 요소 찾기\n const inputs = document.querySelectorAll<HTMLInputElement | HTMLTextAreaElement>(\n `input[name=\"${fieldName}\"], textarea[name=\"${fieldName}\"]`\n );\n\n if (inputs.length === 0) {\n logger.warn(`[setFieldReadOnly] No input found with name=\"${fieldName}\"`);\n return;\n }\n\n inputs.forEach((input) => {\n input.readOnly = readOnly;\n\n // readOnly 상태에 따른 시각적 피드백 (선택적)\n if (readOnly) {\n input.classList.add('readonly');\n } else {\n input.classList.remove('readonly');\n }\n\n logger.log(`[setFieldReadOnly] Set readOnly=${readOnly} on input[name=\"${fieldName}\"]`);\n });\n });\n}\n","/**\n * openPostcode 핸들러\n *\n * 다음 우편번호 API를 호출하고 G7 표준 형식으로 변환하여 콜백 실행\n * - callbackAction 있으면: 커스텀 동작 실행 (Extension Point에서 정의한 onAddressSelect)\n * - callbackAction 없으면: 플러그인 기본 동작 (설정 기반 setState)\n *\n * G7 표준 주소 이벤트 형식:\n * - zipcode: 우편번호\n * - address: 기본 주소 (도로명/지번)\n * - addressDetail: 상세 주소 (사용자 입력)\n * - region: 시/도\n * - city: 시/군/구\n * - countryCode: 국가 코드\n * - _raw: 원본 다음 API 응답 (필요 시 접근 가능)\n */\n\nimport type { ActionContext } from '../types';\n\n// Logger 설정 (G7Core 초기화 전에도 동작하도록 폴백 포함)\nconst logger = ((window as any).G7Core?.createLogger?.('DaumPostcode:OpenPostcode')) ?? {\n log: (...args: unknown[]) => console.log('[DaumPostcode:OpenPostcode]', ...args),\n warn: (...args: unknown[]) => console.warn('[DaumPostcode:OpenPostcode]', ...args),\n error: (...args: unknown[]) => console.error('[DaumPostcode:OpenPostcode]', ...args),\n};\n\ninterface ActionWithParams {\n handler: string;\n params?: {\n /** 주소 선택 시 실행할 콜백 액션 (Extension Point props에서 전달) */\n callbackAction?: any;\n /** 표시 모드 (popup | layer) */\n displayMode?: string;\n /** 팝업/레이어 너비 */\n width?: number;\n /** 팝업/레이어 높이 */\n height?: number;\n /** 테마 설정 */\n theme?: {\n searchBgColor?: string;\n queryTextColor?: string;\n };\n /** 대상 필드 매핑 (기본 동작 시 사용) */\n targetFields?: {\n zipcode?: string;\nLine truncated
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,16 @@
{
"name": "@g7/sirsoft-daum_postcode",
"version": "1.0.0-beta.1",
"description": "그누보드7 Daum 우편번호 플러그인 프론트엔드 에셋",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"devDependencies": {
"typescript": "^5.3.3",
"vite": "^5.4.14"
}
}
@@ -0,0 +1,32 @@
{
"identifier": "sirsoft-daum_postcode",
"vendor": "sirsoft",
"name": {
"ko": "Daum 우편번호",
"en": "Daum Postcode"
},
"version": "1.0.0-beta.1",
"license": "MIT",
"description": {
"ko": "Daum 우편번호 서비스를 통한 주소 검색 기능을 제공하는 플러그인입니다. API 키 없이 무료로 사용할 수 있습니다.",
"en": "Plugin that provides address search functionality through Daum Postcode service. Free to use without API key."
},
"g7_version": ">=7.0.0-beta.1",
"dependencies": {
"modules": {},
"plugins": {}
},
"github_url": "https://github.com/gnuboard/g7-plugin-sirsoft-daum_postcode",
"github_changelog_url": "https://github.com/gnuboard/g7-plugin-sirsoft-daum_postcode/blob/main/CHANGELOG.md",
"assets": {
"js": {
"entry": "resources/js/index.ts",
"output": "dist/js/plugin.iife.js"
},
"handlers": true
},
"loading": {
"strategy": "global",
"priority": 100
}
}
@@ -0,0 +1,145 @@
<?php
namespace Plugins\Sirsoft\DaumPostcode;
use App\Extension\AbstractPlugin;
/**
* Daum 우편번호 서비스 플러그인
*
* Daum 우편번호 검색 API를 통한 주소 검색 기능을 제공합니다.
*/
class Plugin extends AbstractPlugin
{
/**
* 플러그인 메타데이터 반환
*
* @return array 메타데이터
*/
public function getMetadata(): array
{
return [
'author' => 'Sirsoft',
'license' => 'MIT',
'homepage' => 'https://sir.kr',
'keywords' => ['postcode', 'address', 'daum', 'korea'],
];
}
/**
* 플러그인 설정 스키마 반환
*
* @return array 설정 스키마
*/
public function getSettingsSchema(): array
{
return [
'display_mode' => [
'type' => 'enum',
'options' => ['popup', 'layer'],
'default' => 'layer',
'label' => [
'ko' => '표시 방식',
'en' => 'Display Mode',
],
'hint' => [
'ko' => '주소 검색 창을 표시하는 방식을 선택합니다.',
'en' => 'Select how to display the address search window.',
],
'required' => false,
],
'popup_width' => [
'type' => 'integer',
'default' => 500,
'label' => [
'ko' => '팝업 너비 (px)',
'en' => 'Popup Width (px)',
],
'hint' => [
'ko' => '팝업 모드에서 사용되는 창 너비입니다.',
'en' => 'Window width used in popup mode.',
],
'required' => false,
],
'popup_height' => [
'type' => 'integer',
'default' => 600,
'label' => [
'ko' => '팝업 높이 (px)',
'en' => 'Popup Height (px)',
],
'hint' => [
'ko' => '팝업 모드에서 사용되는 창 높이입니다.',
'en' => 'Window height used in popup mode.',
],
'required' => false,
],
'theme_color' => [
'type' => 'string',
'default' => '#1D4ED8',
'label' => [
'ko' => '테마 색상',
'en' => 'Theme Color',
],
'hint' => [
'ko' => '우편번호 검색 창의 테마 색상입니다. (예: #1D4ED8)',
'en' => 'Theme color for the postcode search window. (e.g., #1D4ED8)',
],
'required' => false,
],
];
}
/**
* 플러그인 설정 기본값 반환
*
* @return array 기본 설정값
*/
public function getConfigValues(): array
{
return [
'display_mode' => 'layer',
'popup_width' => 500,
'popup_height' => 600,
'theme_color' => '#1D4ED8',
];
}
/**
* 플러그인이 제공하는 훅 정보 반환
*
* @return array 훅 정의 배열
*/
public function getHooks(): array
{
return [
[
'name' => 'sirsoft-daum_postcode.address.selected',
'type' => 'action',
'description' => [
'ko' => '주소 선택 완료 시 실행되는 액션 훅',
'en' => 'Action hook executed when address selection is complete',
],
'parameters' => [
'zonecode' => 'string - 우편번호',
'address' => 'string - 기본 주소',
'roadAddress' => 'string - 도로명 주소',
'jibunAddress' => 'string - 지번 주소',
'buildingName' => 'string - 건물명',
],
],
[
'name' => 'sirsoft-daum_postcode.filter_address_data',
'type' => 'filter',
'description' => [
'ko' => '선택된 주소 데이터를 필터링하는 훅',
'en' => 'Filter hook to modify selected address data',
],
'parameters' => [
'data' => 'array - 주소 데이터',
],
'return' => 'array - 필터링된 주소 데이터',
],
];
}
}
@@ -0,0 +1,62 @@
{
"extension_point": "address_search_slot",
"scripts": [
{
"src": "//t1.daumcdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js",
"id": "daum_postcode_script"
}
],
"components": [
{
"id": "daum_postcode_container",
"type": "basic",
"name": "Div",
"props": {
"className": "inline-flex"
},
"lifecycle": {
"onMount": [
{
"comment": "주소 검색 플러그인 마운트 시 지정된 필드를 readOnly로 설정",
"handler": "sirsoft-daum_postcode.setFieldReadOnly",
"params": {
"fields": "{{extensionPointProps.readOnlyFields ?? ['zipcode', 'address']}}",
"readOnly": true
}
}
]
},
"children": [
{
"id": "btn_search_address",
"type": "basic",
"name": "Button",
"props": {
"type": "button",
"className": "px-3 py-2 bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-600 text-sm font-medium transition-colors"
},
"text": "$t:sirsoft-daum_postcode.search_address",
"actions": [
{
"type": "click",
"comment": "G7 표준 형식으로 변환하여 callbackAction 실행 (하이브리드 방식)",
"handler": "sirsoft-daum_postcode.openPostcode",
"params": {
"displayMode": "{{_global.plugins['sirsoft-daum_postcode']?.display_mode ?? 'layer'}}",
"width": "{{_global.plugins['sirsoft-daum_postcode']?.popup_width ?? 500}}",
"height": "{{_global.plugins['sirsoft-daum_postcode']?.popup_height ?? 600}}",
"theme": {
"searchBgColor": "{{_global.plugins['sirsoft-daum_postcode']?.theme_color ?? '#1D4ED8'}}",
"queryTextColor": "#FFFFFF"
},
"callbackAction": "{{extensionPointProps.onAddressSelect}}",
"targetFields": "{{extensionPointProps.targetFields}}"
}
}
]
}
]
}
],
"priority": 100
}
@@ -0,0 +1,23 @@
/**
* sirsoft-daum_postcode 플러그인 핸들러
*
* 플러그인에서 사용하는 모든 커스텀 핸들러를 정의합니다.
*/
import { setFieldReadOnlyHandler } from './setFieldReadOnly';
import { openPostcodeHandler } from './openPostcode';
/**
* 핸들러 맵
*
* 키: 핸들러 이름 (네임스페이스 없이)
* 값: 핸들러 함수
*
* ActionDispatcher에 등록 시 플러그인 식별자가 네임스페이스로 추가됩니다.
* 예: 'setFieldReadOnly' -> 'sirsoft-daum_postcode.setFieldReadOnly'
* 예: 'openPostcode' -> 'sirsoft-daum_postcode.openPostcode'
*/
export const handlerMap = {
setFieldReadOnly: setFieldReadOnlyHandler,
openPostcode: openPostcodeHandler,
} as const;
@@ -0,0 +1,374 @@
/**
* openPostcode 핸들러
*
* 다음 우편번호 API를 호출하고 G7 표준 형식으로 변환하여 콜백 실행
* - callbackAction 있으면: 커스텀 동작 실행 (Extension Point에서 정의한 onAddressSelect)
* - callbackAction 없으면: 플러그인 기본 동작 (설정 기반 setState)
*
* G7 표준 주소 이벤트 형식:
* - zipcode: 우편번호
* - address: 기본 주소 (도로명/지번)
* - addressDetail: 상세 주소 (사용자 입력)
* - region: 시/도
* - city: 시/군/구
* - countryCode: 국가 코드
* - _raw: 원본 다음 API 응답 (필요 시 접근 가능)
*/
import type { ActionContext } from '../types';
// Logger 설정 (G7Core 초기화 전에도 동작하도록 폴백 포함)
const logger = ((window as any).G7Core?.createLogger?.('DaumPostcode:OpenPostcode')) ?? {
log: (...args: unknown[]) => console.log('[DaumPostcode:OpenPostcode]', ...args),
warn: (...args: unknown[]) => console.warn('[DaumPostcode:OpenPostcode]', ...args),
error: (...args: unknown[]) => console.error('[DaumPostcode:OpenPostcode]', ...args),
};
interface ActionWithParams {
handler: string;
params?: {
/** 주소 선택 시 실행할 콜백 액션 (Extension Point props에서 전달) */
callbackAction?: any;
/** 표시 모드 (popup | layer) */
displayMode?: string;
/** 팝업/레이어 너비 */
width?: number;
/** 팝업/레이어 높이 */
height?: number;
/** 테마 설정 */
theme?: {
searchBgColor?: string;
queryTextColor?: string;
};
/** 대상 필드 매핑 (기본 동작 시 사용) */
targetFields?: {
zipcode?: string;
address?: string;
region?: string;
city?: string;
};
};
[key: string]: any;
}
/**
* G7 표준 주소 이벤트 인터페이스
*/
interface G7AddressEvent {
/** 우편번호 */
zipcode: string;
/** 기본 주소 (도로명/지번) */
address: string;
/** 상세 주소 (사용자 입력) */
addressDetail: string;
/** 시/도 */
region: string;
/** 시/군/구 */
city: string;
/** 국가 코드 */
countryCode: string;
/** 원본 다음 API 응답 */
_raw: any;
}
/**
* 다음 우편번호 API 응답을 G7 표준 형식으로 변환합니다.
*/
function convertToG7AddressEvent(daumData: any): G7AddressEvent {
return {
zipcode: daumData.zonecode || '',
address: daumData.roadAddress || daumData.jibunAddress || '',
addressDetail: '',
region: daumData.sido || '',
city: daumData.sigungu || '',
countryCode: 'KR',
_raw: daumData,
};
}
/**
* 다음 우편번호 API를 호출하고 G7 표준 형식으로 변환하여 콜백 실행
*/
export function openPostcodeHandler(
action: ActionWithParams,
context: ActionContext
): void {
const params = action.params || {};
const {
callbackAction,
displayMode = 'layer',
width = 500,
height = 600,
theme,
targetFields,
} = params;
// 플러그인 설정에서 기본 필드 매핑 조회
const G7Core = (window as any).G7Core;
const pluginSettings = G7Core?.plugin?.getSettings?.('sirsoft-daum_postcode') || {};
const defaultTargetFields = pluginSettings.target_fields || {
zipcode: 'shipping.zipcode',
address: 'shipping.address',
region: 'shipping.region',
city: 'shipping.city',
};
logger.log('[openPostcode] Starting with params:', {
displayMode,
width,
height,
hasCallbackAction: !!callbackAction,
targetFields: targetFields || defaultTargetFields,
});
// 다음 우편번호 API가 로드되었는지 확인
if (!(window as any).daum?.Postcode) {
logger.error('[openPostcode] Daum Postcode API not loaded');
return;
}
const postcodeConfig: any = {
oncomplete: (data: any) => {
logger.log('[openPostcode] Address selected (raw):', data);
// 다음 API 응답 → G7 표준 형식 변환
const g7AddressEvent = convertToG7AddressEvent(data);
logger.log('[openPostcode] Converted to G7 format:', g7AddressEvent);
// 하이브리드 분기: callbackAction 유무에 따라 동작 결정
if (callbackAction) {
// 커스텀 동작: Extension Point에서 정의한 onAddressSelect 실행
// context를 전달하여 비동기 콜백에서도 컴포넌트 상태 참조 가능
logger.log('[openPostcode] Executing callbackAction');
executeCallbackAction(callbackAction, g7AddressEvent, context);
} else {
// 기본 동작: 플러그인 설정 기반 setState
logger.log('[openPostcode] Executing default setState');
executeDefaultSetState(targetFields || defaultTargetFields, g7AddressEvent);
}
},
width,
height,
};
// 테마 설정 적용
if (theme) {
postcodeConfig.theme = theme;
}
// 다음 우편번호 인스턴스 생성
const postcode = new (window as any).daum.Postcode(postcodeConfig);
if (displayMode === 'popup') {
// 팝업 모드: 새 창으로 열기
postcode.open();
} else {
// 레이어 모드: 오버레이에 임베드
const { layer, closeLayer } = createEmbedLayer(width, height);
// oncomplete 콜백 후 레이어 닫기 처리
const originalOncomplete = postcodeConfig.oncomplete;
postcodeConfig.oncomplete = (data: any) => {
closeLayer();
originalOncomplete(data);
};
// 새 config로 인스턴스 재생성 후 임베드
const layerPostcode = new (window as any).daum.Postcode(postcodeConfig);
layerPostcode.embed(layer);
}
}
/**
* 임베드용 레이어(오버레이) 요소를 생성합니다.
* 플러그인 설정에서 전달받은 width, height를 사용합니다.
*/
function createEmbedLayer(width: number, height: number): {
overlay: HTMLElement;
layer: HTMLElement;
closeLayer: () => void;
} {
// 오버레이 배경
const overlay = document.createElement('div');
overlay.id = 'daum-postcode-overlay';
overlay.style.cssText = `
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
justify-content: center;
z-index: 9999;
`;
// 레이어 컨테이너
const layer = document.createElement('div');
layer.id = 'daum-postcode-layer';
layer.style.cssText = `
width: ${width}px;
height: ${height}px;
background-color: white;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
`;
// 닫기 버튼
const closeButton = document.createElement('button');
closeButton.type = 'button';
closeButton.innerHTML = '×';
closeButton.style.cssText = `
position: absolute;
top: -12px;
right: -12px;
width: 32px;
height: 32px;
border-radius: 50%;
background-color: #374151;
color: white;
border: none;
cursor: pointer;
font-size: 20px;
line-height: 1;
display: flex;
align-items: center;
justify-content: center;
z-index: 10;
`;
// 레이어 래퍼 (닫기 버튼 포지셔닝용)
const wrapper = document.createElement('div');
wrapper.style.cssText = 'position: relative;';
wrapper.appendChild(closeButton);
wrapper.appendChild(layer);
overlay.appendChild(wrapper);
document.body.appendChild(overlay);
// 레이어 닫기 함수
const closeLayer = () => {
if (overlay.parentNode) {
overlay.parentNode.removeChild(overlay);
}
};
// 닫기 버튼 클릭 시 레이어 닫기
closeButton.addEventListener('click', closeLayer);
// 오버레이 배경 클릭 시 레이어 닫기
overlay.addEventListener('click', (e) => {
if (e.target === overlay) {
closeLayer();
}
});
// ESC 키로 레이어 닫기
const handleEscKey = (e: KeyboardEvent) => {
if (e.key === 'Escape') {
closeLayer();
document.removeEventListener('keydown', handleEscKey);
}
};
document.addEventListener('keydown', handleEscKey);
logger.log('[openPostcode] Layer created with size:', { width, height });
return { overlay, layer, closeLayer };
}
/**
* callbackAction을 실행합니다.
* G7Core.dispatch의 componentContext 옵션을 활용하여 비동기 콜백에서도
* 버튼 클릭 시점의 컴포넌트 상태를 정확히 전달합니다.
*
* dispatch 내부 우선순위: options.componentContext > __g7ActionContext > global fallback
* 따라서 componentContext를 명시적으로 전달하면 __g7ActionContext 수동 관리가 불필요합니다.
*
* handlerContext.state 우선 사용 이유:
* - handleSetState의 컴포넌트 경로(isRealComponentContext=true)는 React setState만 호출하고
* globalState._local을 업데이트하지 않음
* - React 커밋 후 __g7PendingLocalState가 클리어되면 getLocal()은 stale globalState._local 반환
* - handlerContext.state는 extendedDataContext._local(globalState + localDynamicState 병합)에서
* 캡처되므로 컴포넌트 setState 결과가 반영된 최신 상태임
*/
function executeCallbackAction(callbackAction: any, g7AddressEvent: G7AddressEvent, handlerContext?: ActionContext): void {
const G7Core = (window as any).G7Core;
if (!G7Core?.dispatch) {
logger.error('[openPostcode] G7Core.dispatch not available');
return;
}
// handlerContext.state(버튼 클릭 시점 componentContext.state)를 우선 사용
// getLocal()은 globalState._local만 반환하여 컴포넌트 setState 결과 누락 가능
const currentLocalState = handlerContext?.state || G7Core?.state?.getLocal?.() || {};
// dispatch의 componentContext 옵션으로 전달
// → dispatch 내부에서 __g7ActionContext보다 우선 적용됨
const componentContext = {
state: currentLocalState,
setState: handlerContext?.setState,
data: {
...(handlerContext?.data || {}),
_local: currentLocalState,
$event: g7AddressEvent,
},
isolatedContext: handlerContext?.isolatedContext,
};
logger.log('[openPostcode] Dispatching with componentContext:', {
hasLocalState: !!currentLocalState,
sourceType: handlerContext?.state ? 'handlerContext' : 'getLocal',
localCheckout: currentLocalState?.checkout,
event: g7AddressEvent,
});
try {
const actions = Array.isArray(callbackAction) ? callbackAction : [callbackAction];
for (const cbAction of actions) {
if (cbAction && typeof cbAction === 'object') {
logger.log('[openPostcode] Dispatching action:', cbAction);
G7Core.dispatch(cbAction, { componentContext });
}
}
} catch (error) {
logger.error('[openPostcode] callbackAction failed:', error);
}
}
/**
* 기본 setState 동작을 실행합니다.
*/
function executeDefaultSetState(
targetFields: Record<string, string>,
g7AddressEvent: G7AddressEvent
): void {
const G7Core = (window as any).G7Core;
if (!G7Core?.state?.setLocal) {
logger.error('[openPostcode] G7Core.state.setLocal not available');
return;
}
// targetFields 매핑에 따라 상태 업데이트
const updates: Record<string, string> = {};
if (targetFields.zipcode) {
updates[targetFields.zipcode] = g7AddressEvent.zipcode;
}
if (targetFields.address) {
updates[targetFields.address] = g7AddressEvent.address;
}
if (targetFields.region) {
updates[targetFields.region] = g7AddressEvent.region;
}
if (targetFields.city) {
updates[targetFields.city] = g7AddressEvent.city;
}
logger.log('[openPostcode] Setting local state:', updates);
G7Core.state.setLocal(updates);
}
@@ -0,0 +1,85 @@
/**
* setFieldReadOnly 핸들러
*
* 지정된 필드명의 input 요소를 찾아 readOnly 속성을 설정합니다.
* 주소 검색 플러그인이 설치된 경우, 우편번호/주소 필드를 readOnly로 설정하여
* 사용자가 직접 입력하지 못하도록 합니다.
*/
import type { ActionContext } from '../types';
// Logger 설정 (G7Core 초기화 전에도 동작하도록 폴백 포함)
const logger = ((window as any).G7Core?.createLogger?.('DaumPostcode:SetFieldReadOnly')) ?? {
log: (...args: unknown[]) => console.log('[DaumPostcode:SetFieldReadOnly]', ...args),
warn: (...args: unknown[]) => console.warn('[DaumPostcode:SetFieldReadOnly]', ...args),
error: (...args: unknown[]) => console.error('[DaumPostcode:SetFieldReadOnly]', ...args),
};
interface ActionWithParams {
handler: string;
params?: {
/** readOnly로 설정할 필드명 배열 */
fields?: string[];
/** readOnly 값 (기본값: true) */
readOnly?: boolean;
};
[key: string]: any;
}
/**
* 지정된 필드명의 input 요소를 찾아 readOnly 속성을 설정합니다.
*
* @param action 액션 객체 (params.fields: 필드명 배열, params.readOnly: boolean)
* @param _context 액션 컨텍스트
*
* @example
* // 레이아웃 JSON에서 사용
* {
* "handler": "sirsoft-daum_postcode.setFieldReadOnly",
* "params": {
* "fields": ["zonecode", "address"],
* "readOnly": true
* }
* }
*/
export function setFieldReadOnlyHandler(
action: ActionWithParams,
_context: ActionContext
): void {
const params = action.params || {};
const fields = params.fields || [];
const readOnly = params.readOnly !== false; // 기본값 true
if (!fields.length) {
logger.warn('[setFieldReadOnly] No fields specified');
return;
}
logger.log(`[setFieldReadOnly] Setting readOnly=${readOnly} for fields:`, fields);
// 각 필드에 대해 DOM에서 input 요소를 찾아 readOnly 설정
fields.forEach((fieldName) => {
// name 속성으로 input 요소 찾기
const inputs = document.querySelectorAll<HTMLInputElement | HTMLTextAreaElement>(
`input[name="${fieldName}"], textarea[name="${fieldName}"]`
);
if (inputs.length === 0) {
logger.warn(`[setFieldReadOnly] No input found with name="${fieldName}"`);
return;
}
inputs.forEach((input) => {
input.readOnly = readOnly;
// readOnly 상태에 따른 시각적 피드백 (선택적)
if (readOnly) {
input.classList.add('readonly');
} else {
input.classList.remove('readonly');
}
logger.log(`[setFieldReadOnly] Set readOnly=${readOnly} on input[name="${fieldName}"]`);
});
});
}
@@ -0,0 +1,117 @@
/**
* sirsoft-daum_postcode 플러그인 엔트리포인트
*
* 플러그인 활성화 시 자동으로 로드되어 핸들러를 등록합니다.
*/
// 핸들러 맵 임포트
import { handlerMap } from './handlers';
// 플러그인 식별자
const PLUGIN_IDENTIFIER = 'sirsoft-daum_postcode';
// Logger 설정 (G7Core 초기화 전에도 동작하도록 폴백 포함)
const logger = ((window as any).G7Core?.createLogger?.(`Plugin:${PLUGIN_IDENTIFIER}`)) ?? {
log: (...args: unknown[]) => console.log(`[Plugin:${PLUGIN_IDENTIFIER}]`, ...args),
warn: (...args: unknown[]) => console.warn(`[Plugin:${PLUGIN_IDENTIFIER}]`, ...args),
error: (...args: unknown[]) => console.error(`[Plugin:${PLUGIN_IDENTIFIER}]`, ...args),
};
/**
* 핸들러 등록 함수 (내부용)
*
* ActionDispatcher에 핸들러를 등록합니다.
* retry 옵션으로 ActionDispatcher가 없을 때 재시도 여부를 제어합니다.
*
* @param retry 재시도 여부 (기본: false)
*/
function registerHandlers(retry: boolean = false): void {
const actionDispatcher = (window as any).G7Core?.getActionDispatcher?.();
if (actionDispatcher) {
// handlerMap의 모든 핸들러를 자동으로 등록
// 네임스페이스: {plugin-identifier}.{handler-name}
Object.entries(handlerMap).forEach(([name, handler]) => {
const fullName = `${PLUGIN_IDENTIFIER}.${name}`;
actionDispatcher.registerHandler(fullName, handler, {
category: 'plugin',
source: PLUGIN_IDENTIFIER,
});
});
logger.log(
`${Object.keys(handlerMap).length} handler(s) registered:`,
Object.keys(handlerMap).map(name => `${PLUGIN_IDENTIFIER}.${name}`)
);
} else if (retry) {
// 최초 로드 시에만 재시도 (언어 전환 등 재초기화 시에는 재시도하지 않음)
let retryCount = 0;
const maxRetries = 50; // 최대 5초 대기 (50 * 100ms)
const retryRegister = () => {
const dispatcher = (window as any).G7Core?.getActionDispatcher?.();
if (dispatcher) {
Object.entries(handlerMap).forEach(([name, handler]) => {
const fullName = `${PLUGIN_IDENTIFIER}.${name}`;
dispatcher.registerHandler(fullName, handler, {
category: 'plugin',
source: PLUGIN_IDENTIFIER,
});
});
logger.log(
`${Object.keys(handlerMap).length} handler(s) registered:`,
Object.keys(handlerMap).map(name => `${PLUGIN_IDENTIFIER}.${name}`)
);
} else {
retryCount++;
if (retryCount <= maxRetries) {
logger.warn(
`ActionDispatcher not found, retrying... (${retryCount}/${maxRetries})`
);
setTimeout(retryRegister, 100);
} else {
logger.error(
`Failed to register handlers: ActionDispatcher not available after maximum retries`
);
}
}
};
retryRegister();
} else {
logger.warn(
`ActionDispatcher not found, handlers not registered`
);
}
}
/**
* 플러그인 초기화 함수
*
* ActionDispatcher에 핸들러를 등록합니다.
* 플러그인 식별자를 네임스페이스로 사용하여 다른 플러그인과 충돌을 방지합니다.
*/
export function initPlugin(): void {
// DOMContentLoaded 이벤트 사용 (DOM 파싱 완료 후)
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => registerHandlers(true));
} else {
// DOM이 이미 로드된 경우 즉시 실행
const hasDispatcher = !!(window as any).G7Core?.getActionDispatcher?.();
registerHandlers(hasDispatcher ? false : true);
}
}
// 플러그인 초기화 자동 실행
initPlugin();
// 전역 객체에 플러그인 노출 (디버깅용)
if (typeof window !== 'undefined') {
(window as any).__SirsoftDaumPostcode = {
identifier: PLUGIN_IDENTIFIER,
handlers: Object.keys(handlerMap),
initPlugin,
};
}
@@ -0,0 +1,29 @@
/**
* sirsoft-daum_postcode 플러그인 타입 정의
*/
/**
* 액션 컨텍스트 인터페이스
*
* ActionDispatcher에서 핸들러 실행 시 전달되는 컨텍스트입니다.
*/
export interface ActionContext {
/** 현재 로컬 상태 가져오기 */
getLocalState?: () => Record<string, any>;
/** 로컬 상태 업데이트 */
setLocalState?: (updates: Record<string, any>) => void;
/** 전역 상태 가져오기 */
getGlobalState?: () => Record<string, any>;
/** 전역 상태 업데이트 */
setGlobalState?: (updates: Record<string, any>) => void;
/** 라우트 파라미터 */
route?: Record<string, string>;
/** 쿼리 파라미터 */
query?: Record<string, string>;
/** 네비게이션 함수 */
navigate?: (path: string) => void;
/** 이벤트 객체 */
event?: Event;
/** 데이터 컨텍스트 */
dataContext?: Record<string, any>;
}
@@ -0,0 +1,51 @@
{
"search_address": "Search Address",
"postcode": {
"search": "Search Address",
"search_button": "Find Address",
"placeholder": "Search for an address",
"zonecode": "Postal Code",
"address": "Address",
"road_address": "Road Address",
"jibun_address": "Jibun Address",
"detail_address": "Detail Address",
"detail_placeholder": "Enter detail address",
"building_name": "Building Name",
"selected": "Address has been selected.",
"error": {
"load_failed": "Failed to load postcode service.",
"search_failed": "Address search failed."
}
},
"settings": {
"title": "Daum Postcode Settings",
"description": "Configure the display mode and style of Daum Postcode service.",
"notice": "Daum Postcode service is free to use without API key.",
"guide": {
"title": "Usage Guide",
"step1": "Select display mode. Popup opens in a new window, Layer displays as an overlay on the current page.",
"step2": "If popup mode is selected, set the popup window size.",
"step3": "Customize the postcode search window style by setting the theme color."
},
"fields": {
"display_mode": {
"label": "Display Mode",
"hint": "Select how to display the address search window.",
"popup": "Popup",
"layer": "Layer"
},
"popup_width": {
"label": "Popup Width (px)",
"hint": "Window width used in popup mode."
},
"popup_height": {
"label": "Popup Height (px)",
"hint": "Window height used in popup mode."
},
"theme_color": {
"label": "Theme Color",
"hint": "Theme color for the postcode search window. (e.g., #1D4ED8)"
}
}
}
}
@@ -0,0 +1,51 @@
{
"search_address": "주소 검색",
"postcode": {
"search": "주소 검색",
"search_button": "주소 찾기",
"placeholder": "주소를 검색하세요",
"zonecode": "우편번호",
"address": "기본 주소",
"road_address": "도로명 주소",
"jibun_address": "지번 주소",
"detail_address": "상세 주소",
"detail_placeholder": "상세 주소를 입력하세요",
"building_name": "건물명",
"selected": "주소가 선택되었습니다.",
"error": {
"load_failed": "우편번호 서비스를 불러오는데 실패했습니다.",
"search_failed": "주소 검색에 실패했습니다."
}
},
"settings": {
"title": "Daum 우편번호 설정",
"description": "Daum 우편번호 서비스의 표시 방식과 스타일을 설정합니다.",
"notice": "Daum 우편번호 서비스는 API 키 없이 무료로 사용할 수 있습니다.",
"guide": {
"title": "사용 안내",
"step1": "표시 방식을 선택합니다. 팝업은 새 창으로, 레이어는 현재 페이지 위에 오버레이로 표시됩니다.",
"step2": "팝업 모드를 선택한 경우, 팝업 창의 크기를 설정합니다.",
"step3": "테마 색상을 설정하여 우편번호 검색 창의 스타일을 커스터마이징할 수 있습니다."
},
"fields": {
"display_mode": {
"label": "표시 방식",
"hint": "주소 검색 창을 표시하는 방식을 선택합니다.",
"popup": "팝업",
"layer": "레이어"
},
"popup_width": {
"label": "팝업 너비 (px)",
"hint": "팝업 모드에서 사용되는 창 너비입니다."
},
"popup_height": {
"label": "팝업 높이 (px)",
"hint": "팝업 모드에서 사용되는 창 높이입니다."
},
"theme_color": {
"label": "테마 색상",
"hint": "우편번호 검색 창의 테마 색상입니다. (예: #1D4ED8)"
}
}
}
}
@@ -0,0 +1,624 @@
{
"version": "1.0.0",
"layout_name": "plugin_settings",
"permissions": [
"core.plugins.update"
],
"extends": "_admin_base",
"meta": {
"title": "$t:sirsoft-daum_postcode.settings.title",
"description": "$t:sirsoft-daum_postcode.settings.description"
},
"data_sources": [
{
"id": "settings",
"type": "api",
"endpoint": "/api/admin/plugins/{{route.identifier}}/settings",
"method": "GET",
"auto_fetch": true,
"auth_required": true,
"initLocal": "form",
"refetchOnMount": true
}
],
"slots": {
"content": [
{
"id": "plugin_settings_content",
"type": "basic",
"name": "Div",
"blur_until_loaded": "{{_local.isSaving}}",
"dataKey": "form",
"trackChanges": true,
"props": {
"className": "p-4 sm:p-6 lg:p-8 bg-gray-50 dark:bg-gray-900 min-h-screen"
},
"children": [
{
"id": "page_header",
"type": "composite",
"name": "PageHeader",
"props": {
"title": "$t:sirsoft-daum_postcode.settings.title",
"description": "$t:sirsoft-daum_postcode.settings.description",
"backPath": "/admin/plugins",
"backLabel": "$t:admin.plugins.back_to_list"
}
},
{
"id": "notice_banner",
"type": "basic",
"name": "Div",
"props": {
"className": "mt-4 p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg"
},
"children": [
{
"type": "basic",
"name": "Div",
"props": {
"className": "flex gap-3"
},
"children": [
{
"type": "basic",
"name": "Icon",
"props": {
"name": "circle-info",
"className": "w-5 h-5 text-blue-600 dark:text-blue-400 flex-shrink-0 mt-0.5"
}
},
{
"type": "basic",
"name": "P",
"props": {
"className": "text-sm text-blue-700 dark:text-blue-300"
},
"text": "$t:sirsoft-daum_postcode.settings.notice"
}
]
}
]
},
{
"id": "validation_error",
"type": "basic",
"name": "Div",
"if": "{{_local.errors}}",
"props": {
"className": "bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 mt-6"
},
"children": [
{
"type": "basic",
"name": "Div",
"props": {
"className": "flex gap-3"
},
"children": [
{
"type": "basic",
"name": "Icon",
"props": {
"name": "triangle-exclamation",
"className": "w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"
}
},
{
"type": "basic",
"name": "Div",
"children": [
{
"type": "basic",
"name": "H3",
"props": {
"className": "text-sm font-medium text-red-800 dark:text-red-200"
},
"text": "$t:admin.plugins.settings.validation_error"
},
{
"type": "basic",
"name": "Ul",
"if": "{{typeof _local.errors === 'object' && Object.keys(_local.errors).length > 0}}",
"props": {
"className": "mt-2 list-disc list-inside space-y-1"
},
"iteration": {
"source": "Object.entries(_local.errors ?? {}).flatMap(([field, messages]) => Array.isArray(messages) ? messages : [messages])",
"item_var": "message"
},
"children": [
{
"type": "basic",
"name": "Li",
"props": {
"className": "text-sm text-red-700 dark:text-red-300"
},
"text": "{{message}}"
}
]
}
]
}
]
}
]
},
{
"id": "settings_form",
"type": "basic",
"name": "Div",
"props": {
"className": "mt-6 bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700"
},
"children": [
{
"id": "settings_fields",
"type": "basic",
"name": "Div",
"props": {
"className": "p-6 space-y-6"
},
"children": [
{
"id": "field_display_mode",
"type": "basic",
"name": "Div",
"props": {
"className": "grid grid-cols-1 lg:grid-cols-3 gap-4 items-start"
},
"children": [
{
"type": "basic",
"name": "Div",
"props": {
"className": "lg:col-span-1"
},
"children": [
{
"type": "basic",
"name": "Label",
"props": {
"className": "block text-sm font-medium text-gray-700 dark:text-gray-300"
},
"text": "$t:sirsoft-daum_postcode.settings.fields.display_mode.label"
},
{
"type": "basic",
"name": "P",
"props": {
"className": "mt-1 text-xs text-gray-500 dark:text-gray-400"
},
"text": "$t:sirsoft-daum_postcode.settings.fields.display_mode.hint"
}
]
},
{
"type": "basic",
"name": "Div",
"props": {
"className": "lg:col-span-2"
},
"children": [
{
"type": "basic",
"name": "Select",
"props": {
"name": "display_mode",
"className": "w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"
},
"children": [
{
"type": "basic",
"name": "Option",
"props": {
"value": "popup"
},
"text": "popup"
},
{
"type": "basic",
"name": "Option",
"props": {
"value": "layer"
},
"text": "layer"
}
]
}
]
}
]
},
{
"id": "field_popup_width",
"type": "basic",
"name": "Div",
"props": {
"className": "grid grid-cols-1 lg:grid-cols-3 gap-4 items-start"
},
"children": [
{
"type": "basic",
"name": "Div",
"props": {
"className": "lg:col-span-1"
},
"children": [
{
"type": "basic",
"name": "Label",
"props": {
"className": "block text-sm font-medium text-gray-700 dark:text-gray-300"
},
"text": "$t:sirsoft-daum_postcode.settings.fields.popup_width.label"
},
{
"type": "basic",
"name": "P",
"props": {
"className": "mt-1 text-xs text-gray-500 dark:text-gray-400"
},
"text": "$t:sirsoft-daum_postcode.settings.fields.popup_width.hint"
}
]
},
{
"type": "basic",
"name": "Div",
"props": {
"className": "lg:col-span-2"
},
"children": [
{
"type": "basic",
"name": "Input",
"props": {
"type": "number",
"name": "popup_width",
"className": "w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"
}
}
]
}
]
},
{
"id": "field_popup_height",
"type": "basic",
"name": "Div",
"props": {
"className": "grid grid-cols-1 lg:grid-cols-3 gap-4 items-start"
},
"children": [
{
"type": "basic",
"name": "Div",
"props": {
"className": "lg:col-span-1"
},
"children": [
{
"type": "basic",
"name": "Label",
"props": {
"className": "block text-sm font-medium text-gray-700 dark:text-gray-300"
},
"text": "$t:sirsoft-daum_postcode.settings.fields.popup_height.label"
},
{
"type": "basic",
"name": "P",
"props": {
"className": "mt-1 text-xs text-gray-500 dark:text-gray-400"
},
"text": "$t:sirsoft-daum_postcode.settings.fields.popup_height.hint"
}
]
},
{
"type": "basic",
"name": "Div",
"props": {
"className": "lg:col-span-2"
},
"children": [
{
"type": "basic",
"name": "Input",
"props": {
"type": "number",
"name": "popup_height",
"className": "w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"
}
}
]
}
]
},
{
"id": "field_theme_color",
"type": "basic",
"name": "Div",
"props": {
"className": "grid grid-cols-1 lg:grid-cols-3 gap-4 items-start"
},
"children": [
{
"type": "basic",
"name": "Div",
"props": {
"className": "lg:col-span-1"
},
"children": [
{
"type": "basic",
"name": "Label",
"props": {
"className": "block text-sm font-medium text-gray-700 dark:text-gray-300"
},
"text": "$t:sirsoft-daum_postcode.settings.fields.theme_color.label"
},
{
"type": "basic",
"name": "P",
"props": {
"className": "mt-1 text-xs text-gray-500 dark:text-gray-400"
},
"text": "$t:sirsoft-daum_postcode.settings.fields.theme_color.hint"
}
]
},
{
"type": "basic",
"name": "Div",
"props": {
"className": "lg:col-span-2"
},
"children": [
{
"type": "basic",
"name": "Input",
"props": {
"type": "text",
"name": "theme_color",
"placeholder": "#1D4ED8",
"className": "w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"
}
}
]
}
]
}
]
}
]
},
{
"id": "guide_section",
"type": "basic",
"name": "Div",
"props": {
"className": "mt-6 bg-gray-50 dark:bg-gray-800/50 rounded-lg border border-gray-200 dark:border-gray-700 p-6"
},
"children": [
{
"type": "basic",
"name": "H3",
"props": {
"className": "text-lg font-semibold text-gray-900 dark:text-white mb-4"
},
"text": "$t:sirsoft-daum_postcode.settings.guide.title"
},
{
"type": "basic",
"name": "Ol",
"props": {
"className": "list-decimal list-inside space-y-3"
},
"children": [
{
"type": "basic",
"name": "Li",
"props": {
"className": "text-sm text-gray-600 dark:text-gray-400"
},
"text": "$t:sirsoft-daum_postcode.settings.guide.step1"
},
{
"type": "basic",
"name": "Li",
"props": {
"className": "text-sm text-gray-600 dark:text-gray-400"
},
"text": "$t:sirsoft-daum_postcode.settings.guide.step2"
},
{
"type": "basic",
"name": "Li",
"props": {
"className": "text-sm text-gray-600 dark:text-gray-400"
},
"text": "$t:sirsoft-daum_postcode.settings.guide.step3"
}
]
}
]
},
{
"id": "footer_buttons",
"type": "basic",
"name": "Div",
"props": {
"className": "flex justify-end gap-3 mt-6"
},
"children": [
{
"id": "cancel_button",
"type": "basic",
"name": "Button",
"props": {
"className": "px-4 py-2 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 font-medium transition-colors"
},
"actions": [
{
"type": "click",
"handler": "navigate",
"params": {
"path": "/admin/plugins"
}
}
],
"children": [
{
"type": "basic",
"name": "Span",
"text": "$t:common.cancel"
}
]
},
{
"id": "save_button",
"type": "basic",
"name": "Button",
"props": {
"disabled": "{{!_local.hasChanges || _local.isSaving}}",
"className": "flex items-center gap-1.5 px-4 py-2 bg-gray-900 dark:bg-white text-white dark:text-gray-900 rounded-lg hover:bg-gray-800 dark:hover:bg-gray-100 font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
},
"actions": [
{
"type": "click",
"handler": "sequence",
"actions": [
{
"handler": "setState",
"params": {
"target": "local",
"isSaving": true,
"errors": null
}
},
{
"handler": "apiCall",
"auth_required": true,
"target": "/api/admin/plugins/{{route.identifier}}/settings",
"params": {
"method": "PUT",
"body": "{{_local.form}}"
},
"onSuccess": [
{
"handler": "setState",
"params": {
"target": "local",
"isSaving": false,
"hasChanges": false
}
},
{
"handler": "toast",
"params": {
"type": "success",
"message": "$t:admin.plugins.settings.save_success"
}
},
{
"handler": "refetchDataSource",
"params": {
"dataSourceId": "settings"
}
}
],
"onError": [
{
"handler": "setState",
"params": {
"target": "local",
"isSaving": false,
"errors": "{{$error.errors}}"
}
},
{
"handler": "toast",
"params": {
"type": "error",
"message": "$t:admin.plugins.settings.save_error"
}
}
]
}
]
}
],
"children": [
{
"type": "basic",
"name": "Icon",
"if": "{{_local.isSaving}}",
"props": {
"name": "spinner",
"className": "w-4 h-4 animate-spin"
}
},
{
"type": "basic",
"name": "Span",
"if": "{{!_local.isSaving}}",
"text": "$t:common.save"
},
{
"type": "basic",
"name": "Span",
"if": "{{_local.isSaving}}",
"text": "$t:common.saving"
}
]
}
]
}
]
}
]
},
"pageConfig": {
"notice": "$t:sirsoft-daum_postcode.settings.notice",
"guide": {
"title": "$t:sirsoft-daum_postcode.settings.guide.title",
"steps": [
"$t:sirsoft-daum_postcode.settings.guide.step1",
"$t:sirsoft-daum_postcode.settings.guide.step2",
"$t:sirsoft-daum_postcode.settings.guide.step3"
]
}
},
"schema": {
"display_mode": {
"type": "enum",
"options": [
"popup",
"layer"
],
"default": "layer",
"label": "$t:sirsoft-daum_postcode.settings.fields.display_mode.label",
"hint": "$t:sirsoft-daum_postcode.settings.fields.display_mode.hint"
},
"popup_width": {
"type": "integer",
"default": 500,
"label": "$t:sirsoft-daum_postcode.settings.fields.popup_width.label",
"hint": "$t:sirsoft-daum_postcode.settings.fields.popup_width.hint"
},
"popup_height": {
"type": "integer",
"default": 600,
"label": "$t:sirsoft-daum_postcode.settings.fields.popup_height.label",
"hint": "$t:sirsoft-daum_postcode.settings.fields.popup_height.hint"
},
"theme_color": {
"type": "string",
"default": "#1D4ED8",
"label": "$t:sirsoft-daum_postcode.settings.fields.theme_color.label",
"hint": "$t:sirsoft-daum_postcode.settings.fields.theme_color.hint"
}
}
}
@@ -0,0 +1,4 @@
{
"version": "1.0.0",
"routes": []
}
@@ -0,0 +1,29 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
/* Paths */
"baseUrl": ".",
"paths": {
"@/*": ["resources/js/*"]
}
},
"include": ["resources/js/**/*.ts"]
}
@@ -0,0 +1,47 @@
import { defineConfig } from 'vite';
import path from 'path';
export default defineConfig({
define: {
'process.env.NODE_ENV': JSON.stringify('production'),
},
build: {
// 라이브러리 모드 설정
lib: {
entry: path.resolve(__dirname, 'resources/js/index.ts'),
name: 'SirsoftDaumPostcode', // 전역 변수명 (IIFE 모드용)
fileName: 'plugin',
formats: ['iife'], // IIFE 포맷만 빌드
},
// 빌드 출력 설정
outDir: 'dist',
emptyOutDir: true,
// 소스맵 생성
sourcemap: true,
rollupOptions: {
output: {
// JS 파일명 패턴
entryFileNames: 'js/plugin.iife.js',
chunkFileNames: 'js/[name]-[hash].js',
},
},
// 빌드 최적화
minify: 'esbuild',
target: 'es2020',
// Chunk 크기 경고 임계값
chunkSizeWarningLimit: 500,
},
// 타입스크립트 설정
resolve: {
alias: {
'@': path.resolve(__dirname, 'resources/js'),
},
},
});