@cp949/japanpost-react 1.0.2 → 1.0.3

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/README.ko.md CHANGED
@@ -18,6 +18,28 @@ pnpm add @cp949/japanpost-react
18
18
 
19
19
  - 지원 React 버전: React 18, React 19
20
20
 
21
+ 이 패키지는 ESM으로 배포됩니다. 서버 유틸리티와 공용 타입은
22
+ `@cp949/japanpost-react`에서 가져오고, Next.js App Router에서 훅이나
23
+ headless 입력 컴포넌트는 `@cp949/japanpost-react/client`를 사용하세요.
24
+ `require("@cp949/japanpost-react")`,
25
+ `require("@cp949/japanpost-react/client")`는 지원되지 않으며, CommonJS
26
+ 소비자는 `const pkg = await import("@cp949/japanpost-react");` 같은 ESM
27
+ interop을 사용해야 합니다.
28
+
29
+ ## Next.js
30
+
31
+ Next.js App Router에서 훅이나 headless 입력 컴포넌트를 쓸 때는
32
+ 클라이언트 컴포넌트 안에서 `@cp949/japanpost-react/client` 경로를
33
+ 사용하는 것을 권장합니다. 유틸리티 함수와 공용 타입은 루트 엔트리에서
34
+ 가져오면 됩니다.
35
+
36
+ ```tsx
37
+ "use client";
38
+
39
+ import { PostalCodeInput, useJapanPostalCode } from "@cp949/japanpost-react/client";
40
+ import { normalizeJapanPostalCode, type JapanAddressDataSource } from "@cp949/japanpost-react";
41
+ ```
42
+
21
43
  ## 빠른 시작
22
44
 
23
45
  ```tsx
@@ -157,6 +179,9 @@ export function PostalForm() {
157
179
  성공할 수 있고, `404 -> not_found`는 miss를 오류로 노출하는 백엔드에서만
158
180
  선택적으로 쓰면 됩니다.
159
181
 
182
+ Next.js에서도 `dataSource`는 자체 서버 API를 바라보도록 두고, Japan Post
183
+ 업스트림 자격 증명과 토큰 교환은 브라우저가 아니라 서버에서 처리하세요.
184
+
160
185
  ## Exports
161
186
 
162
187
  - `normalizeJapanPostalCode`
@@ -345,5 +370,6 @@ timeout 메시지는 토큰 발급 단계와 실제 조회 단계 중 어느 쪽
345
370
  ## SSR
346
371
 
347
372
  `dataSource` 구현에서는 서버 측 API를 사용하고, 토큰 교환과 업스트림 서명은
348
- 서버에서만 처리하세요. React 훅과 UI 컴포넌트는 클라이언트 컴포넌트에서
373
+ 서버에서만 처리하세요. Next.js App Router에서는 React 훅과 UI 컴포넌트를
374
+ `@cp949/japanpost-react/client`에서 import해 클라이언트 컴포넌트에서
349
375
  사용하는 것이 안전합니다.
package/README.md CHANGED
@@ -21,6 +21,26 @@ pnpm add @cp949/japanpost-react
21
21
  `packages/japanpost-react`
22
22
  - Demo app in this repository: `apps/demo`
23
23
 
24
+ This package is published as ESM. Keep server utilities and shared types on
25
+ `@cp949/japanpost-react`, and import hooks or headless input components for the
26
+ Next.js App Router from `@cp949/japanpost-react/client`. CommonJS consumers
27
+ must use ESM interop. `require("@cp949/japanpost-react")` and
28
+ `require("@cp949/japanpost-react/client")` are not supported. In CommonJS, use
29
+ ESM interop such as `const pkg = await import("@cp949/japanpost-react");`.
30
+
31
+ ## Next.js
32
+
33
+ When you use hooks or headless input components in the Next.js App Router,
34
+ import them from `@cp949/japanpost-react/client` inside a Client Component.
35
+ Keep utility functions and shared types on the root entry.
36
+
37
+ ```tsx
38
+ "use client";
39
+
40
+ import { PostalCodeInput, useJapanPostalCode } from "@cp949/japanpost-react/client";
41
+ import { normalizeJapanPostalCode, type JapanAddressDataSource } from "@cp949/japanpost-react";
42
+ ```
43
+
24
44
  ## What The Package Provides
25
45
 
26
46
  - Hooks for postal-code lookup and address search:
@@ -163,6 +183,10 @@ The example paths above match this repository's reference backend. In your own
163
183
  app, the backend routes can be different as long as your `dataSource`
164
184
  implementation returns the same public types.
165
185
 
186
+ In Next.js, keep the `dataSource` implementation pointed at your own server-side
187
+ API routes. Do not expose Japan Post credentials or token exchange logic to the
188
+ browser.
189
+
166
190
  ## Core Contract
167
191
 
168
192
  `Page<T>` is the result shape shared by the hooks and the reference backend:
@@ -0,0 +1 @@
1
+ export * from "./index";
@@ -0,0 +1,3 @@
1
+ "use client";
2
+
3
+ export * from "./index.es.js";
package/dist/index.es.js CHANGED
@@ -1,255 +1,77 @@
1
1
  import { useCallback as e, useEffect as t, useMemo as n, useRef as r, useState as i } from "react";
2
- //#region \0rolldown/runtime.js
3
- var a = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), o = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
4
- if (typeof require < "u") return require.apply(this, arguments);
5
- throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
6
- }), s = /* @__PURE__ */ a(((e) => {
7
- var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
8
- function r(e, n, r) {
9
- var i = null;
10
- if (r !== void 0 && (i = "" + r), n.key !== void 0 && (i = "" + n.key), "key" in n) for (var a in r = {}, n) a !== "key" && (r[a] = n[a]);
11
- else r = n;
12
- return n = r.ref, {
13
- $$typeof: t,
14
- type: e,
15
- key: i,
16
- ref: n === void 0 ? null : n,
17
- props: r
18
- };
19
- }
20
- e.Fragment = n, e.jsx = r, e.jsxs = r;
21
- })), c = /* @__PURE__ */ a(((e) => {
22
- process.env.NODE_ENV !== "production" && (function() {
23
- function t(e) {
24
- if (e == null) return null;
25
- if (typeof e == "function") return e.$$typeof === k ? null : e.displayName || e.name || null;
26
- if (typeof e == "string") return e;
27
- switch (e) {
28
- case v: return "Fragment";
29
- case b: return "Profiler";
30
- case y: return "StrictMode";
31
- case w: return "Suspense";
32
- case T: return "SuspenseList";
33
- case O: return "Activity";
34
- }
35
- if (typeof e == "object") switch (typeof e.tag == "number" && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), e.$$typeof) {
36
- case _: return "Portal";
37
- case S: return e.displayName || "Context";
38
- case x: return (e._context.displayName || "Context") + ".Consumer";
39
- case C:
40
- var n = e.render;
41
- return e = e.displayName, e ||= (e = n.displayName || n.name || "", e === "" ? "ForwardRef" : "ForwardRef(" + e + ")"), e;
42
- case E: return n = e.displayName || null, n === null ? t(e.type) || "Memo" : n;
43
- case D:
44
- n = e._payload, e = e._init;
45
- try {
46
- return t(e(n));
47
- } catch {}
48
- }
49
- return null;
50
- }
51
- function n(e) {
52
- return "" + e;
53
- }
54
- function r(e) {
55
- try {
56
- n(e);
57
- var t = !1;
58
- } catch {
59
- t = !0;
60
- }
61
- if (t) {
62
- t = console;
63
- var r = t.error, i = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
64
- return r.call(t, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", i), n(e);
65
- }
66
- }
67
- function i(e) {
68
- if (e === v) return "<>";
69
- if (typeof e == "object" && e && e.$$typeof === D) return "<...>";
70
- try {
71
- var n = t(e);
72
- return n ? "<" + n + ">" : "<...>";
73
- } catch {
74
- return "<...>";
75
- }
76
- }
77
- function a() {
78
- var e = A.A;
79
- return e === null ? null : e.getOwner();
80
- }
81
- function s() {
82
- return Error("react-stack-top-frame");
83
- }
84
- function c(e) {
85
- if (j.call(e, "key")) {
86
- var t = Object.getOwnPropertyDescriptor(e, "key").get;
87
- if (t && t.isReactWarning) return !1;
88
- }
89
- return e.key !== void 0;
90
- }
91
- function l(e, t) {
92
- function n() {
93
- P || (P = !0, console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", t));
94
- }
95
- n.isReactWarning = !0, Object.defineProperty(e, "key", {
96
- get: n,
97
- configurable: !0
98
- });
99
- }
100
- function u() {
101
- var e = t(this.type);
102
- return F[e] || (F[e] = !0, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")), e = this.props.ref, e === void 0 ? null : e;
103
- }
104
- function d(e, t, n, r, i, a) {
105
- var o = n.ref;
106
- return e = {
107
- $$typeof: g,
108
- type: e,
109
- key: t,
110
- props: n,
111
- _owner: r
112
- }, (o === void 0 ? null : o) === null ? Object.defineProperty(e, "ref", {
113
- enumerable: !1,
114
- value: null
115
- }) : Object.defineProperty(e, "ref", {
116
- enumerable: !1,
117
- get: u
118
- }), e._store = {}, Object.defineProperty(e._store, "validated", {
119
- configurable: !1,
120
- enumerable: !1,
121
- writable: !0,
122
- value: 0
123
- }), Object.defineProperty(e, "_debugInfo", {
124
- configurable: !1,
125
- enumerable: !1,
126
- writable: !0,
127
- value: null
128
- }), Object.defineProperty(e, "_debugStack", {
129
- configurable: !1,
130
- enumerable: !1,
131
- writable: !0,
132
- value: i
133
- }), Object.defineProperty(e, "_debugTask", {
134
- configurable: !1,
135
- enumerable: !1,
136
- writable: !0,
137
- value: a
138
- }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
139
- }
140
- function f(e, n, i, o, s, u) {
141
- var f = n.children;
142
- if (f !== void 0) if (o) if (M(f)) {
143
- for (o = 0; o < f.length; o++) p(f[o]);
144
- Object.freeze && Object.freeze(f);
145
- } else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
146
- else p(f);
147
- if (j.call(n, "key")) {
148
- f = t(e);
149
- var m = Object.keys(n).filter(function(e) {
150
- return e !== "key";
151
- });
152
- o = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", R[f + o] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", o, f, m, f), R[f + o] = !0);
153
- }
154
- if (f = null, i !== void 0 && (r(i), f = "" + i), c(n) && (r(n.key), f = "" + n.key), "key" in n) for (var h in i = {}, n) h !== "key" && (i[h] = n[h]);
155
- else i = n;
156
- return f && l(i, typeof e == "function" ? e.displayName || e.name || "Unknown" : e), d(e, f, i, a(), s, u);
157
- }
158
- function p(e) {
159
- m(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e && e.$$typeof === D && (e._payload.status === "fulfilled" ? m(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
160
- }
161
- function m(e) {
162
- return typeof e == "object" && !!e && e.$$typeof === g;
163
- }
164
- var h = o("react"), g = Symbol.for("react.transitional.element"), _ = Symbol.for("react.portal"), v = Symbol.for("react.fragment"), y = Symbol.for("react.strict_mode"), b = Symbol.for("react.profiler"), x = Symbol.for("react.consumer"), S = Symbol.for("react.context"), C = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), T = Symbol.for("react.suspense_list"), E = Symbol.for("react.memo"), D = Symbol.for("react.lazy"), O = Symbol.for("react.activity"), k = Symbol.for("react.client.reference"), A = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, j = Object.prototype.hasOwnProperty, M = Array.isArray, N = console.createTask ? console.createTask : function() {
165
- return null;
166
- };
167
- h = { react_stack_bottom_frame: function(e) {
168
- return e();
169
- } };
170
- var P, F = {}, I = h.react_stack_bottom_frame.bind(h, s)(), L = N(i(s)), R = {};
171
- e.Fragment = v, e.jsx = function(e, t, n) {
172
- var r = 1e4 > A.recentlyCreatedOwnerStacks++;
173
- return f(e, t, n, !1, r ? Error("react-stack-top-frame") : I, r ? N(i(e)) : L);
174
- }, e.jsxs = function(e, t, n) {
175
- var r = 1e4 > A.recentlyCreatedOwnerStacks++;
176
- return f(e, t, n, !0, r ? Error("react-stack-top-frame") : I, r ? N(i(e)) : L);
177
- };
178
- })();
179
- })), l = (/* @__PURE__ */ a(((e, t) => {
180
- process.env.NODE_ENV === "production" ? t.exports = s() : t.exports = c();
181
- })))();
182
- function u({ defaultValue: e = "", value: t, disabled: n, label: r = "Address keyword", buttonLabel: a = "Search", inputProps: o, buttonProps: s, onChange: c, onSearch: u }) {
183
- let [d, f] = i(e), p = t ?? d;
184
- function m(e) {
185
- e.preventDefault(), u(p.trim());
186
- }
2
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
3
+ //#region src/components/AddressSearchInput.tsx
4
+ function s({ defaultValue: e = "", value: t, disabled: n, label: r = "Address keyword", buttonLabel: s = "Search", inputProps: c, buttonProps: l, onChange: u, onSearch: d }) {
5
+ let [f, p] = i(e), m = t ?? f;
187
6
  function h(e) {
188
- t === void 0 && f(e), c?.(e);
7
+ e.preventDefault(), d(m.trim());
8
+ }
9
+ function g(e) {
10
+ t === void 0 && p(e), u?.(e);
189
11
  }
190
- return /* @__PURE__ */ (0, l.jsxs)("form", {
191
- onSubmit: m,
192
- children: [/* @__PURE__ */ (0, l.jsxs)("label", { children: [r, /* @__PURE__ */ (0, l.jsx)("input", {
193
- ...o,
12
+ return /* @__PURE__ */ o("form", {
13
+ onSubmit: h,
14
+ children: [/* @__PURE__ */ o("label", { children: [r, /* @__PURE__ */ a("input", {
15
+ ...c,
194
16
  disabled: n,
195
- value: p,
196
- onChange: (e) => h(e.target.value)
197
- })] }), /* @__PURE__ */ (0, l.jsx)("button", {
198
- ...s,
17
+ value: m,
18
+ onChange: (e) => g(e.target.value)
19
+ })] }), /* @__PURE__ */ a("button", {
20
+ ...l,
199
21
  disabled: n,
200
22
  type: "submit",
201
- children: a
23
+ children: s
202
24
  })]
203
25
  });
204
26
  }
205
27
  //#endregion
206
28
  //#region src/core/formatters.ts
207
- function d(e) {
29
+ function c(e) {
208
30
  return e.replace(/[^\d]/g, "");
209
31
  }
210
- function f(e) {
211
- let t = d(e);
32
+ function l(e) {
33
+ let t = c(e);
212
34
  return t.length === 7 ? `${t.slice(0, 3)}-${t.slice(3)}` : t;
213
35
  }
214
36
  //#endregion
215
37
  //#region src/components/PostalCodeInput.tsx
216
- function p({ defaultValue: e = "", value: t, disabled: n, label: r = "Postal code", buttonLabel: a = "Search", inputProps: o, buttonProps: s, onChange: c, onSearch: u }) {
217
- let [f, p] = i(e), m = t ?? f;
218
- function h(e) {
219
- e.preventDefault(), u(d(m));
220
- }
38
+ function u({ defaultValue: e = "", value: t, disabled: n, label: r = "Postal code", buttonLabel: s = "Search", inputProps: l, buttonProps: u, onChange: d, onSearch: f }) {
39
+ let [p, m] = i(e), h = t ?? p;
221
40
  function g(e) {
222
- t === void 0 && p(e), c?.(e);
41
+ e.preventDefault(), f(c(h));
223
42
  }
224
- return /* @__PURE__ */ (0, l.jsxs)("form", {
225
- onSubmit: h,
226
- children: [/* @__PURE__ */ (0, l.jsxs)("label", { children: [r, /* @__PURE__ */ (0, l.jsx)("input", {
227
- ...o,
43
+ function _(e) {
44
+ t === void 0 && m(e), d?.(e);
45
+ }
46
+ return /* @__PURE__ */ o("form", {
47
+ onSubmit: g,
48
+ children: [/* @__PURE__ */ o("label", { children: [r, /* @__PURE__ */ a("input", {
49
+ ...l,
228
50
  disabled: n,
229
- inputMode: o?.inputMode ?? "numeric",
230
- value: m,
231
- onChange: (e) => g(e.target.value)
232
- })] }), /* @__PURE__ */ (0, l.jsx)("button", {
233
- ...s,
51
+ inputMode: l?.inputMode ?? "numeric",
52
+ value: h,
53
+ onChange: (e) => _(e.target.value)
54
+ })] }), /* @__PURE__ */ a("button", {
55
+ ...u,
234
56
  disabled: n,
235
57
  type: "submit",
236
- children: a
58
+ children: s
237
59
  })]
238
60
  });
239
61
  }
240
62
  //#endregion
241
63
  //#region src/core/errors.ts
242
- function m(e, t, n) {
64
+ function d(e, t, n) {
243
65
  let r = Error(t);
244
66
  return r.name = "JapanAddressError", r.code = e, r.cause = n?.cause, r.status = n?.status, r;
245
67
  }
246
68
  //#endregion
247
69
  //#region src/core/normalizers.ts
248
- function h(e) {
70
+ function f(e) {
249
71
  return e.filter(Boolean).join(" ").trim();
250
72
  }
251
- function g(e) {
252
- let t = h([
73
+ function p(e) {
74
+ let t = f([
253
75
  e.prefecture,
254
76
  e.city,
255
77
  e.town,
@@ -269,17 +91,17 @@ function g(e) {
269
91
  }
270
92
  //#endregion
271
93
  //#region src/core/validators.ts
272
- function _(e) {
273
- return /^\d{7}$/.test(d(e));
94
+ function m(e) {
95
+ return /^\d{7}$/.test(c(e));
274
96
  }
275
97
  //#endregion
276
98
  //#region src/react/toJapanAddressError.ts
277
- function v(e) {
278
- return typeof e == "object" && e && "code" in e && typeof e.code == "string" ? e : m("data_source_error", e instanceof Error ? e.message : "Unknown error", { cause: e });
99
+ function h(e) {
100
+ return typeof e == "object" && e && "code" in e && typeof e.code == "string" ? e : d("data_source_error", e instanceof Error ? e.message : "Unknown error", { cause: e });
279
101
  }
280
102
  //#endregion
281
103
  //#region src/react/useLatestRequestState.ts
282
- function y() {
104
+ function g() {
283
105
  let n = r(0), a = r(!0), o = r(null), [s, c] = i(!1), [l, u] = i(null), [d, f] = i(null), p = e((e) => a.current && e === n.current, []), m = e(() => {
284
106
  n.current += 1, o.current?.abort(), o.current = null;
285
107
  }, []);
@@ -317,15 +139,15 @@ function y() {
317
139
  }
318
140
  //#endregion
319
141
  //#region src/react/useJapanAddressSearch.ts
320
- function b(e) {
142
+ function _(e) {
321
143
  if (e) return e;
322
144
  throw Error("useJapanAddressSearch requires options.dataSource");
323
145
  }
324
- function x(e) {
146
+ function v(e) {
325
147
  return e?.trim() || void 0;
326
148
  }
327
- function S(e) {
328
- let t = typeof e == "string" ? { addressQuery: e } : e, n = x(t.addressQuery), r = x(t.prefCode), i = x(t.prefName), a = x(t.prefKana), o = x(t.prefRoma), s = x(t.cityCode), c = x(t.cityName), l = x(t.cityKana), u = x(t.cityRoma), d = x(t.townName), f = x(t.townKana), p = x(t.townRoma);
149
+ function y(e) {
150
+ let t = typeof e == "string" ? { addressQuery: e } : e, n = v(t.addressQuery), r = v(t.prefCode), i = v(t.prefName), a = v(t.prefKana), o = v(t.prefRoma), s = v(t.cityCode), c = v(t.cityName), l = v(t.cityKana), u = v(t.cityRoma), d = v(t.townName), f = v(t.townKana), p = v(t.townRoma);
329
151
  return n === void 0 && r === void 0 && i === void 0 && a === void 0 && o === void 0 && s === void 0 && c === void 0 && l === void 0 && u === void 0 && d === void 0 && f === void 0 && p === void 0 ? null : {
330
152
  ...n === void 0 ? {} : { addressQuery: n },
331
153
  ...r === void 0 ? {} : { prefCode: r },
@@ -345,7 +167,7 @@ function S(e) {
345
167
  ...t.includePrefectureDetails === void 0 ? {} : { includePrefectureDetails: t.includePrefectureDetails }
346
168
  };
347
169
  }
348
- function C(e) {
170
+ function b(e) {
349
171
  return e.aborted ? Promise.resolve(null) : new Promise((t) => {
350
172
  let n = () => {
351
173
  e.removeEventListener("abort", n), t(null);
@@ -353,43 +175,43 @@ function C(e) {
353
175
  e.addEventListener("abort", n, { once: !0 });
354
176
  });
355
177
  }
356
- function w(i) {
357
- let a = n(() => b(i.dataSource), [i.dataSource]), o = i.debounceMs ?? 0, s = r(null), c = r(null), { loading: l, data: u, error: d, beginRequest: f, setSuccess: p, setFailure: h, finishRequest: g, cancel: _, reset: x } = y(), w = e((e) => {
178
+ function x(i) {
179
+ let a = n(() => _(i.dataSource), [i.dataSource]), o = i.debounceMs ?? 0, s = r(null), c = r(null), { loading: l, data: u, error: f, beginRequest: p, setSuccess: m, setFailure: v, finishRequest: x, cancel: S, reset: C } = g(), w = e((e) => {
358
180
  s.current !== null && (globalThis.clearTimeout(s.current), s.current = null), c.current?.(e), c.current = null;
359
181
  }, []);
360
182
  t(() => () => {
361
183
  w(null);
362
184
  }, [w]);
363
185
  let T = e(() => {
364
- w(null), x();
365
- }, [w, x]), E = e(() => {
366
- w(null), _();
367
- }, [w, _]), D = e(async (e, t, n) => {
186
+ w(null), C();
187
+ }, [w, C]), E = e(() => {
188
+ w(null), S();
189
+ }, [w, S]), D = e(async (e, t, n) => {
368
190
  try {
369
- let r = { signal: t }, i = a.searchAddress(n, r), o = await Promise.race([i, C(t)]);
370
- return t.aborted || o === null ? null : (p(e, o), o);
191
+ let r = { signal: t }, i = a.searchAddress(n, r), o = await Promise.race([i, b(t)]);
192
+ return t.aborted || o === null ? null : (m(e, o), o);
371
193
  } catch (n) {
372
- return t.aborted ? null : h(e, v(n));
194
+ return t.aborted ? null : v(e, h(n));
373
195
  } finally {
374
- g(e);
196
+ x(e);
375
197
  }
376
198
  }, [
377
199
  a,
378
- g,
379
- h,
380
- p
200
+ x,
201
+ v,
202
+ m
381
203
  ]);
382
204
  return {
383
205
  loading: l,
384
206
  data: u,
385
- error: d,
207
+ error: f,
386
208
  cancel: E,
387
209
  reset: T,
388
210
  search: e((e) => {
389
- let t = S(e), { requestId: n, signal: r } = f();
211
+ let t = y(e), { requestId: n, signal: r } = p();
390
212
  if (w(null), t === null) {
391
- let e = h(n, m("invalid_query", "Address query is required"));
392
- return g(n), Promise.resolve(e);
213
+ let e = v(n, d("invalid_query", "Address query is required"));
214
+ return x(n), Promise.resolve(e);
393
215
  }
394
216
  return o <= 0 ? new Promise((e) => {
395
217
  c.current = e, D(n, r, t).then((t) => {
@@ -405,7 +227,7 @@ function w(i) {
405
227
  }, o);
406
228
  });
407
229
  }, [
408
- f,
230
+ p,
409
231
  w,
410
232
  o,
411
233
  D
@@ -414,51 +236,51 @@ function w(i) {
414
236
  }
415
237
  //#endregion
416
238
  //#region src/react/useJapanPostalCode.ts
417
- function T(e) {
239
+ function S(e) {
418
240
  if (e) return e;
419
241
  throw Error("useJapanPostalCode requires options.dataSource");
420
242
  }
421
- function E(t) {
422
- let r = n(() => T(t.dataSource), [t.dataSource]), { loading: i, data: a, error: o, beginRequest: s, setSuccess: c, setFailure: l, finishRequest: u, cancel: f, reset: p } = y();
243
+ function C(t) {
244
+ let r = n(() => S(t.dataSource), [t.dataSource]), { loading: i, data: a, error: o, beginRequest: s, setSuccess: l, setFailure: u, finishRequest: f, cancel: p, reset: m } = g();
423
245
  return {
424
246
  loading: i,
425
247
  data: a,
426
248
  error: o,
427
- cancel: f,
428
- reset: p,
249
+ cancel: p,
250
+ reset: m,
429
251
  search: e(async (e) => {
430
252
  let { requestId: t, signal: n } = s();
431
253
  try {
432
- let i = typeof e == "string" ? { postalCode: e } : e, a = d(i.postalCode);
433
- if (!/^\d{3,7}$/.test(a)) throw m("invalid_postal_code", "Postal code must contain between 3 and 7 digits");
254
+ let i = typeof e == "string" ? { postalCode: e } : e, a = c(i.postalCode);
255
+ if (!/^\d{3,7}$/.test(a)) throw d("invalid_postal_code", "Postal code must contain between 3 and 7 digits");
434
256
  let o = { signal: n }, s = {
435
257
  postalCode: a,
436
258
  pageNumber: i.pageNumber ?? 0,
437
259
  rowsPerPage: i.rowsPerPage ?? 100,
438
260
  ...i.includeParenthesesTown === void 0 ? {} : { includeParenthesesTown: i.includeParenthesesTown }
439
- }, l = await r.lookupPostalCode(s, o);
440
- return n.aborted ? null : (c(t, l), l);
261
+ }, u = await r.lookupPostalCode(s, o);
262
+ return n.aborted ? null : (l(t, u), u);
441
263
  } catch (e) {
442
- return n.aborted ? null : l(t, v(e));
264
+ return n.aborted ? null : u(t, h(e));
443
265
  } finally {
444
- u(t);
266
+ f(t);
445
267
  }
446
268
  }, [
447
269
  s,
448
270
  r,
271
+ f,
449
272
  u,
450
- l,
451
- c
273
+ l
452
274
  ])
453
275
  };
454
276
  }
455
277
  //#endregion
456
278
  //#region src/react/useJapanAddress.ts
457
- function D(t) {
279
+ function w(t) {
458
280
  let r = n(() => {
459
281
  if (t.dataSource) return t.dataSource;
460
282
  throw Error("useJapanAddress requires options.dataSource");
461
- }, [t.dataSource]), a = E({ dataSource: r }), o = w({
283
+ }, [t.dataSource]), a = C({ dataSource: r }), o = x({
462
284
  dataSource: r,
463
285
  debounceMs: t.debounceMs
464
286
  }), s = a.reset, c = a.search, l = o.reset, u = o.search, [d, f] = i(null), p = e(async (e) => (l(), f("postalCode"), c(e)), [l, c]), m = e(async (e) => (s(), f("addressQuery"), u(e)), [s, u]), h = e(() => {
@@ -474,4 +296,4 @@ function D(t) {
474
296
  };
475
297
  }
476
298
  //#endregion
477
- export { u as AddressSearchInput, p as PostalCodeInput, m as createJapanAddressError, f as formatJapanPostalCode, _ as isValidJapanPostalCode, g as normalizeJapanPostAddressRecord, d as normalizeJapanPostalCode, D as useJapanAddress, w as useJapanAddressSearch, E as useJapanPostalCode };
299
+ export { s as AddressSearchInput, u as PostalCodeInput, d as createJapanAddressError, l as formatJapanPostalCode, m as isValidJapanPostalCode, p as normalizeJapanPostAddressRecord, c as normalizeJapanPostalCode, w as useJapanAddress, x as useJapanAddressSearch, C as useJapanPostalCode };
@@ -0,0 +1,7 @@
1
+ export { AddressSearchInput } from './components/AddressSearchInput';
2
+ export { PostalCodeInput } from './components/PostalCodeInput';
3
+ export { useJapanAddress } from './react/useJapanAddress';
4
+ export { useJapanAddressSearch } from './react/useJapanAddressSearch';
5
+ export { useJapanPostalCode } from './react/useJapanPostalCode';
6
+ export type * from './core/types';
7
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,mBAAmB,cAAc,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cp949/japanpost-react",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Headless React hooks and optional components for Japan Post postcode and address search",
5
5
  "type": "module",
6
6
  "author": "cp949",
@@ -13,7 +13,7 @@
13
13
  "bugs": {
14
14
  "url": "https://github.com/cp949/japanpost-react/issues"
15
15
  },
16
- "main": "dist/index.umd.cjs",
16
+ "main": "dist/index.es.js",
17
17
  "module": "dist/index.es.js",
18
18
  "types": "dist/index.d.ts",
19
19
  "sideEffects": false,
@@ -31,8 +31,11 @@
31
31
  "exports": {
32
32
  ".": {
33
33
  "types": "./dist/index.d.ts",
34
- "import": "./dist/index.es.js",
35
- "require": "./dist/index.umd.cjs"
34
+ "import": "./dist/index.es.js"
35
+ },
36
+ "./client": {
37
+ "types": "./dist/client.d.ts",
38
+ "import": "./dist/client.es.js"
36
39
  }
37
40
  },
38
41
  "keywords": [
@@ -64,7 +67,7 @@
64
67
  },
65
68
  "scripts": {
66
69
  "dev": "vite build --watch",
67
- "build": "tsc && vite build",
70
+ "build": "tsc && vite build && node scripts/postbuild-client.mjs",
68
71
  "release": "pnpm --dir ../.. readme:package && pnpm --dir ../.. test && pnpm build && pnpm publish --access public --no-git-checks",
69
72
  "preview": "vite preview",
70
73
  "lint": "biome lint .",
@@ -1,6 +0,0 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`react`)):typeof define==`function`&&define.amd?define([`exports`,`react`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.JapanPostcodeReact={},e.React))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var n=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),r=n((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),i=n((e=>{process.env.NODE_ENV!==`production`&&(function(){function t(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===O?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case D:return`Activity`}if(typeof e==`object`)switch(typeof e.tag==`number`&&console.error(`Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.`),e.$$typeof){case g:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var n=e.render;return e=e.displayName,e||=(e=n.displayName||n.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case T:return n=e.displayName||null,n===null?t(e.type)||`Memo`:n;case E:n=e._payload,e=e._init;try{return t(e(n))}catch{}}return null}function n(e){return``+e}function r(e){try{n(e);var t=!1}catch{t=!0}if(t){t=console;var r=t.error,i=typeof Symbol==`function`&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||`Object`;return r.call(t,`The provided key is an unsupported type %s. This value must be coerced to a string before using it here.`,i),n(e)}}function i(e){if(e===_)return`<>`;if(typeof e==`object`&&e&&e.$$typeof===E)return`<...>`;try{var n=t(e);return n?`<`+n+`>`:`<...>`}catch{return`<...>`}}function a(){var e=k.A;return e===null?null:e.getOwner()}function o(){return Error(`react-stack-top-frame`)}function s(e){if(A.call(e,`key`)){var t=Object.getOwnPropertyDescriptor(e,`key`).get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function c(e,t){function n(){N||(N=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",t))}n.isReactWarning=!0,Object.defineProperty(e,`key`,{get:n,configurable:!0})}function l(){var e=t(this.type);return P[e]||(P[e]=!0,console.error(`Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.`)),e=this.props.ref,e===void 0?null:e}function u(e,t,n,r,i,a){var o=n.ref;return e={$$typeof:h,type:e,key:t,props:n,_owner:r},(o===void 0?null:o)===null?Object.defineProperty(e,`ref`,{enumerable:!1,value:null}):Object.defineProperty(e,`ref`,{enumerable:!1,get:l}),e._store={},Object.defineProperty(e._store,`validated`,{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,`_debugInfo`,{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,`_debugStack`,{configurable:!1,enumerable:!1,writable:!0,value:i}),Object.defineProperty(e,`_debugTask`,{configurable:!1,enumerable:!1,writable:!0,value:a}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function d(e,n,i,o,l,d){var p=n.children;if(p!==void 0)if(o)if(j(p)){for(o=0;o<p.length;o++)f(p[o]);Object.freeze&&Object.freeze(p)}else console.error(`React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.`);else f(p);if(A.call(n,`key`)){p=t(e);var m=Object.keys(n).filter(function(e){return e!==`key`});o=0<m.length?`{key: someKey, `+m.join(`: ..., `)+`: ...}`:`{key: someKey}`,L[p+o]||(m=0<m.length?`{`+m.join(`: ..., `)+`: ...}`:`{}`,console.error(`A props object containing a "key" prop is being spread into JSX:
2
- let props = %s;
3
- <%s {...props} />
4
- React keys must be passed directly to JSX without using spread:
5
- let props = %s;
6
- <%s key={someKey} {...props} />`,o,p,m,p),L[p+o]=!0)}if(p=null,i!==void 0&&(r(i),p=``+i),s(n)&&(r(n.key),p=``+n.key),`key`in n)for(var h in i={},n)h!==`key`&&(i[h]=n[h]);else i=n;return p&&c(i,typeof e==`function`?e.displayName||e.name||`Unknown`:e),u(e,p,i,a(),l,d)}function f(e){p(e)?e._store&&(e._store.validated=1):typeof e==`object`&&e&&e.$$typeof===E&&(e._payload.status===`fulfilled`?p(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function p(e){return typeof e==`object`&&!!e&&e.$$typeof===h}var m=require(`react`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.client.reference`),k=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A=Object.prototype.hasOwnProperty,j=Array.isArray,M=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(e){return e()}};var N,P={},F=m.react_stack_bottom_frame.bind(m,o)(),I=M(i(o)),L={};e.Fragment=_,e.jsx=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!1,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)},e.jsxs=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!0,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)}})()})),a=n(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=r():t.exports=i()}))();function o({defaultValue:e=``,value:n,disabled:r,label:i=`Address keyword`,buttonLabel:o=`Search`,inputProps:s,buttonProps:c,onChange:l,onSearch:u}){let[d,f]=(0,t.useState)(e),p=n??d;function m(e){e.preventDefault(),u(p.trim())}function h(e){n===void 0&&f(e),l?.(e)}return(0,a.jsxs)(`form`,{onSubmit:m,children:[(0,a.jsxs)(`label`,{children:[i,(0,a.jsx)(`input`,{...s,disabled:r,value:p,onChange:e=>h(e.target.value)})]}),(0,a.jsx)(`button`,{...c,disabled:r,type:`submit`,children:o})]})}function s(e){return e.replace(/[^\d]/g,``)}function c(e){let t=s(e);return t.length===7?`${t.slice(0,3)}-${t.slice(3)}`:t}function l({defaultValue:e=``,value:n,disabled:r,label:i=`Postal code`,buttonLabel:o=`Search`,inputProps:c,buttonProps:l,onChange:u,onSearch:d}){let[f,p]=(0,t.useState)(e),m=n??f;function h(e){e.preventDefault(),d(s(m))}function g(e){n===void 0&&p(e),u?.(e)}return(0,a.jsxs)(`form`,{onSubmit:h,children:[(0,a.jsxs)(`label`,{children:[i,(0,a.jsx)(`input`,{...c,disabled:r,inputMode:c?.inputMode??`numeric`,value:m,onChange:e=>g(e.target.value)})]}),(0,a.jsx)(`button`,{...l,disabled:r,type:`submit`,children:o})]})}function u(e,t,n){let r=Error(t);return r.name=`JapanAddressError`,r.code=e,r.cause=n?.cause,r.status=n?.status,r}function d(e){return e.filter(Boolean).join(` `).trim()}function f(e){let t=d([e.prefecture,e.city,e.town,e.detail??``]);return{postalCode:e.postalCode,prefecture:e.prefecture,prefectureKana:e.prefectureKana,city:e.city,cityKana:e.cityKana,town:e.town,townKana:e.townKana,address:t,provider:`japan-post`}}function p(e){return/^\d{7}$/.test(s(e))}function m(e){return typeof e==`object`&&e&&`code`in e&&typeof e.code==`string`?e:u(`data_source_error`,e instanceof Error?e.message:`Unknown error`,{cause:e})}function h(){let e=(0,t.useRef)(0),n=(0,t.useRef)(!0),r=(0,t.useRef)(null),[i,a]=(0,t.useState)(!1),[o,s]=(0,t.useState)(null),[c,l]=(0,t.useState)(null),u=(0,t.useCallback)(t=>n.current&&t===e.current,[]),d=(0,t.useCallback)(()=>{e.current+=1,r.current?.abort(),r.current=null},[]);(0,t.useEffect)(()=>(n.current=!0,()=>{n.current=!1,d()}),[d]);let f=(0,t.useCallback)(()=>{let t=e.current+1;e.current=t,r.current?.abort();let n=new AbortController;return r.current=n,a(!0),l(null),{requestId:t,signal:n.signal}},[]),p=(0,t.useCallback)((e,t)=>{u(e)&&s(t)},[u]),m=(0,t.useCallback)((e,t)=>(u(e)&&(l(t),s(null)),null),[u]),h=(0,t.useCallback)(()=>{d(),a(!1)},[d]);return{loading:i,data:o,error:c,beginRequest:f,setSuccess:p,setFailure:m,finishRequest:(0,t.useCallback)(e=>{u(e)&&(a(!1),r.current=null)},[u]),cancel:h,reset:(0,t.useCallback)(()=>{h(),s(null),l(null)},[h])}}function g(e){if(e)return e;throw Error(`useJapanAddressSearch requires options.dataSource`)}function _(e){return e?.trim()||void 0}function v(e){let t=typeof e==`string`?{addressQuery:e}:e,n=_(t.addressQuery),r=_(t.prefCode),i=_(t.prefName),a=_(t.prefKana),o=_(t.prefRoma),s=_(t.cityCode),c=_(t.cityName),l=_(t.cityKana),u=_(t.cityRoma),d=_(t.townName),f=_(t.townKana),p=_(t.townRoma);return n===void 0&&r===void 0&&i===void 0&&a===void 0&&o===void 0&&s===void 0&&c===void 0&&l===void 0&&u===void 0&&d===void 0&&f===void 0&&p===void 0?null:{...n===void 0?{}:{addressQuery:n},...r===void 0?{}:{prefCode:r},...i===void 0?{}:{prefName:i},...a===void 0?{}:{prefKana:a},...o===void 0?{}:{prefRoma:o},...s===void 0?{}:{cityCode:s},...c===void 0?{}:{cityName:c},...l===void 0?{}:{cityKana:l},...u===void 0?{}:{cityRoma:u},...d===void 0?{}:{townName:d},...f===void 0?{}:{townKana:f},...p===void 0?{}:{townRoma:p},pageNumber:t.pageNumber??0,rowsPerPage:t.rowsPerPage??100,...t.includeCityDetails===void 0?{}:{includeCityDetails:t.includeCityDetails},...t.includePrefectureDetails===void 0?{}:{includePrefectureDetails:t.includePrefectureDetails}}}function y(e){return e.aborted?Promise.resolve(null):new Promise(t=>{let n=()=>{e.removeEventListener(`abort`,n),t(null)};e.addEventListener(`abort`,n,{once:!0})})}function b(e){let n=(0,t.useMemo)(()=>g(e.dataSource),[e.dataSource]),r=e.debounceMs??0,i=(0,t.useRef)(null),a=(0,t.useRef)(null),{loading:o,data:s,error:c,beginRequest:l,setSuccess:d,setFailure:f,finishRequest:p,cancel:_,reset:b}=h(),x=(0,t.useCallback)(e=>{i.current!==null&&(globalThis.clearTimeout(i.current),i.current=null),a.current?.(e),a.current=null},[]);(0,t.useEffect)(()=>()=>{x(null)},[x]);let S=(0,t.useCallback)(()=>{x(null),b()},[x,b]),C=(0,t.useCallback)(()=>{x(null),_()},[x,_]),w=(0,t.useCallback)(async(e,t,r)=>{try{let i={signal:t},a=n.searchAddress(r,i),o=await Promise.race([a,y(t)]);return t.aborted||o===null?null:(d(e,o),o)}catch(n){return t.aborted?null:f(e,m(n))}finally{p(e)}},[n,p,f,d]);return{loading:o,data:s,error:c,cancel:C,reset:S,search:(0,t.useCallback)(e=>{let t=v(e),{requestId:n,signal:o}=l();if(x(null),t===null){let e=f(n,u(`invalid_query`,`Address query is required`));return p(n),Promise.resolve(e)}return r<=0?new Promise(e=>{a.current=e,w(n,o,t).then(t=>{e(t),a.current===e&&(a.current=null)})}):new Promise(e=>{a.current=e,i.current=globalThis.setTimeout(()=>{i.current=null;let e=a.current;a.current=null,w(n,o,t).then(t=>{e?.(t)})},r)})},[l,x,r,w])}}function x(e){if(e)return e;throw Error(`useJapanPostalCode requires options.dataSource`)}function S(e){let n=(0,t.useMemo)(()=>x(e.dataSource),[e.dataSource]),{loading:r,data:i,error:a,beginRequest:o,setSuccess:c,setFailure:l,finishRequest:d,cancel:f,reset:p}=h();return{loading:r,data:i,error:a,cancel:f,reset:p,search:(0,t.useCallback)(async e=>{let{requestId:t,signal:r}=o();try{let i=typeof e==`string`?{postalCode:e}:e,a=s(i.postalCode);if(!/^\d{3,7}$/.test(a))throw u(`invalid_postal_code`,`Postal code must contain between 3 and 7 digits`);let o={signal:r},l={postalCode:a,pageNumber:i.pageNumber??0,rowsPerPage:i.rowsPerPage??100,...i.includeParenthesesTown===void 0?{}:{includeParenthesesTown:i.includeParenthesesTown}},d=await n.lookupPostalCode(l,o);return r.aborted?null:(c(t,d),d)}catch(e){return r.aborted?null:l(t,m(e))}finally{d(t)}},[o,n,d,l,c])}}function C(e){let n=(0,t.useMemo)(()=>{if(e.dataSource)return e.dataSource;throw Error(`useJapanAddress requires options.dataSource`)},[e.dataSource]),r=S({dataSource:n}),i=b({dataSource:n,debounceMs:e.debounceMs}),a=r.reset,o=r.search,s=i.reset,c=i.search,[l,u]=(0,t.useState)(null),d=(0,t.useCallback)(async e=>(s(),u(`postalCode`),o(e)),[s,o]),f=(0,t.useCallback)(async e=>(a(),u(`addressQuery`),c(e)),[a,c]),p=(0,t.useCallback)(()=>{a(),s(),u(null)},[s,a]),m=l===`postalCode`?r.data:l===`addressQuery`?i.data:null,h=l===`postalCode`?r.error:l===`addressQuery`?i.error:null;return{loading:r.loading||i.loading,data:m,error:h,reset:p,searchByPostalCode:d,searchByAddressQuery:f}}e.AddressSearchInput=o,e.PostalCodeInput=l,e.createJapanAddressError=u,e.formatJapanPostalCode=c,e.isValidJapanPostalCode=p,e.normalizeJapanPostAddressRecord=f,e.normalizeJapanPostalCode=s,e.useJapanAddress=C,e.useJapanAddressSearch=b,e.useJapanPostalCode=S});