Skip to content

feat: Korean amount reading + hidden canonical sync (0.2.0)#5

Merged
jlc488 merged 1 commit into
mainfrom
feature/korean-reading-hidden-sync
Jul 17, 2026
Merged

feat: Korean amount reading + hidden canonical sync (0.2.0)#5
jlc488 merged 1 commit into
mainfrom
feature/korean-reading-hidden-sync

Conversation

@jlc488

@jlc488 jlc488 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

What / 무엇

v0.2의 한국 특화 차별화 기능 2종 + 버전 0.2.0 bump.

한글 금액 병기 — toKorean / data-numkey-korean

toKorean('1500000')      // "150만"
toKorean('927483041001') // "9,274억 8,304만 1,001"
toKorean('100000001')    // "1억 1" — 0 그룹 생략
  • 은행·핀테크 UI의 "150만" 병기를 함수 하나 + 마크업 속성으로. 빈 속성이면 인풋 뒤에 무스타일 span.numkey-korean 생성 ("원"은 호출자 CSS 몫), 값을 주면 기존 요소 셀렉터
  • 만 단위 4자리 그룹핑, 그룹별 3자리 콤마, 부호 유지, 소수부 무시, 양(10^28)까지 — 초과 시 콤마 포맷 폴백
  • unbind 시 생성한 span 제거

폼 전송 해결 — data-numkey-name

<input data-numkey data-numkey-name="amount" value="1234567">
<!-- 화면: 1,234,567 · POST: amount=1234567 -->
  • 정리된 정식 값을 항상 담는 hidden 인풋 생성 — 입력 중간 상태에서도 (1,234. 표시 중에 제출돼도 1234 전송). JSP/PHP 서버측 콤마 제거 코드가 사라집니다
  • unbind 시 제거

Verification / 검증

  • typecheck ✓ · 61 tests ✓ (12 new: 읽기 케이스·0그룹 생략·조/경, span/셀렉터 타깃, hidden 동기화·중간 상태 정리, unbind 클린업) · build ✓
  • 실브라우저 (데모): 서버 값 1500000 로드 즉시 병기 "150만", 타이핑 중 "9,274억 8,304만 1,001" 실시간 갱신, hidden amount=55000 동기화 확인. 데모 readout은 리스너 순서 이슈를 피해 getValue로 계산 (처음 구현은 hidden을 읽어 한 키 늦게 표시되는 버그 — 수정 완료)

Docs

README en/ko: 병기·hidden 섹션 + 예제, 속성 테이블 갱신, 로드맵에서 출시 항목 제거. CHANGELOG 0.2.0 (이중언어). 데모 사이트 카드 2개 추가.

머지 후 gh workflow run publish.yml 디스패치로 첫 자동 릴리스를 검증합니다.

…canonical sync (data-numkey-name)

The two v0.2 differentiators for the Korean market:

- toKorean(canonical): mixed digits-plus-units reading ('1500000' → 150만,
  '927483041001' → 9,274억 8,304만 1,001). Zero groups omitted, per-group
  3-digit comma grouping, sign kept, fraction ignored, units up to 양;
  beyond that falls back to plain comma formatting
- data-numkey-korean: live reading beside the input — empty value generates
  an unstyled span.numkey-korean after the field (원 suffix belongs to the
  caller's CSS), a value is a selector for an existing element. Generated
  spans are removed on unbind
- data-numkey-name: generated hidden input that always carries the SETTLED
  canonical value (typing '1,234.' posts '1234'), so classic JSP/PHP form
  POSTs need no server-side comma stripping. Removed on unbind
- version 0.2.0 + bilingual CHANGELOG; README en/ko sections with examples;
  demo site cards for both features (readout computed via getValue, not the
  hidden element, to avoid listener-ordering staleness)
- tests: 61 (12 new — reading cases incl. zero-group omission and 조/경,
  span/selector targets, hidden sync incl. transient settling, unbind
  cleanup)
@jlc488
jlc488 merged commit ce7a62d into main Jul 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant