@isi-ui7/bos7-shared 0.2.9 → 0.2.11

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/dist/index.js CHANGED
@@ -20205,8 +20205,8 @@ function lx() {
20205
20205
  const e = (navigator.language || "").toLowerCase();
20206
20206
  return e.startsWith("en") ? "en" : e.startsWith("id") ? "id" : null;
20207
20207
  }
20208
- function ux() {
20209
- return fx() ?? lx() ?? Ka;
20208
+ function ux(e) {
20209
+ return fx() ?? e ?? lx() ?? Ka;
20210
20210
  }
20211
20211
  function As(e) {
20212
20212
  typeof document > "u" || (document.cookie = `${cc}=${e}; path=/; max-age=31536000; samesite=lax`);
@@ -20221,36 +20221,39 @@ const fc = bs({
20221
20221
  function hx({
20222
20222
  children: e,
20223
20223
  locale: t,
20224
- dictionaries: r
20224
+ defaultLocale: r,
20225
+ dictionaries: n
20225
20226
  }) {
20226
- const [n, a] = qt(t ?? ux()), i = ka(() => ({
20227
- id: { ...za.id, ...(r == null ? void 0 : r.id) ?? {} },
20228
- en: { ...za.en, ...(r == null ? void 0 : r.en) ?? {} }
20229
- }), [r]), s = ka(() => {
20230
- const o = i[n];
20227
+ const [a, i] = qt(
20228
+ t ?? ux(r)
20229
+ ), s = ka(() => ({
20230
+ id: { ...za.id, ...(n == null ? void 0 : n.id) ?? {} },
20231
+ en: { ...za.en, ...(n == null ? void 0 : n.en) ?? {} }
20232
+ }), [n]), o = ka(() => {
20233
+ const l = s[a];
20231
20234
  return {
20232
- locale: n,
20233
- setLocale(l) {
20234
- a(l), As(l);
20235
+ locale: a,
20236
+ setLocale(f) {
20237
+ i(f), As(f);
20235
20238
  },
20236
- t(l, f) {
20237
- return o[l] ?? f ?? l;
20239
+ t(f, c) {
20240
+ return l[f] ?? c ?? f;
20238
20241
  },
20239
- dictionary: o
20242
+ dictionary: l
20240
20243
  };
20241
- }, [i, n]);
20244
+ }, [s, a]);
20242
20245
  return Vt(() => {
20243
20246
  if (t) return;
20244
- let o = !1;
20245
- return fetch("/api/auth/preferences", { cache: "no-store" }).then(async (l) => l.ok ? await l.json() : null).then((l) => {
20246
- if (o) return;
20247
- const f = l == null ? void 0 : l.locale;
20248
- (f === "id" || f === "en") && (a(f), As(f));
20247
+ let l = !1;
20248
+ return fetch("/api/auth/preferences", { cache: "no-store" }).then(async (f) => f.ok ? await f.json() : null).then((f) => {
20249
+ if (l) return;
20250
+ const c = f == null ? void 0 : f.locale;
20251
+ (c === "id" || c === "en") && (i(c), As(c));
20249
20252
  }).catch(() => {
20250
20253
  }), () => {
20251
- o = !0;
20254
+ l = !0;
20252
20255
  };
20253
- }, [t]), /* @__PURE__ */ Ee(fc.Provider, { value: s, children: e });
20256
+ }, [t]), /* @__PURE__ */ Ee(fc.Provider, { value: o, children: e });
20254
20257
  }
20255
20258
  function Ii() {
20256
20259
  return Cs(fc);
@@ -20301,10 +20304,10 @@ function dx() {
20301
20304
  };
20302
20305
  }
20303
20306
  function C_(e) {
20304
- const t = (e == null ? void 0 : e.withAuth) ?? !0, r = e == null ? void 0 : e.dictionaries;
20305
- return function({ children: a, Layout: i }) {
20306
- const s = /* @__PURE__ */ Ee(hx, { dictionaries: r, children: /* @__PURE__ */ Ee(i, { children: a }) });
20307
- return t ? /* @__PURE__ */ Ee(Mc, { children: s }) : s;
20307
+ const t = (e == null ? void 0 : e.withAuth) ?? !0, r = e == null ? void 0 : e.dictionaries, n = (e == null ? void 0 : e.defaultLocale) ?? "en";
20308
+ return function({ children: i, Layout: s }) {
20309
+ const o = /* @__PURE__ */ Ee(hx, { defaultLocale: n, dictionaries: r, children: /* @__PURE__ */ Ee(s, { children: i }) });
20310
+ return t ? /* @__PURE__ */ Ee(Mc, { children: o }) : o;
20308
20311
  };
20309
20312
  }
20310
20313
  function px(e, t, r) {
@@ -10,6 +10,7 @@ type SharedShellProviderProps = {
10
10
  type SharedShellProviderOptions = {
11
11
  withAuth?: boolean;
12
12
  dictionaries?: Partial<Record<"id" | "en", Record<string, string>>>;
13
+ defaultLocale?: "id" | "en";
13
14
  };
14
15
  export declare function createShellProvider(options?: SharedShellProviderOptions): ({ children, Layout }: SharedShellProviderProps) => import("react/jsx-runtime").JSX.Element;
15
16
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isi-ui7/bos7-shared",
3
- "version": "0.2.9",
3
+ "version": "0.2.11",
4
4
  "description": "Shared auth7 and layout primitives for bos7 applications.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -50,7 +50,8 @@
50
50
  "./form-rules": "./src/form-rules.ts",
51
51
  "./i18n": "./src/i18n.tsx",
52
52
  "./workflow/use-crud-form": "./src/workflow/use-crud-form.ts",
53
- "./styles": "./src/form-contract.css"
53
+ "./styles": "./src/form-contract.css",
54
+ "./form-value-schema": "./src/form-value-schema.ts"
54
55
  },
55
56
  "publishConfig": {
56
57
  "registry": "https://registry.npmjs.org",
@@ -99,8 +100,8 @@
99
100
  "next": "16.1.1",
100
101
  "@carbon/react": "^1.97.0",
101
102
  "@carbon/icons-react": "^11.71.0",
103
+ "@isi-ui7/i18n": "0.2.2",
102
104
  "@isi-ui7/corporate-themes": "0.2.4",
103
- "@isi-ui7/i18n": "0.2.1",
104
105
  "@isi-ui7/ui-shell": "0.2.4",
105
106
  "@isi-ui7/modal-manager": "0.2.2",
106
107
  "@isi-ui7/realtime": "0.2.3",
@@ -16,15 +16,19 @@ type SharedShellProviderProps = {
16
16
  type SharedShellProviderOptions = {
17
17
  withAuth?: boolean;
18
18
  dictionaries?: Partial<Record<"id" | "en", Record<string, string>>>;
19
+ // Default bahasa untuk pengunjung baru; pilihan user (cookie) tetap menang.
20
+ // Standar platform: English.
21
+ defaultLocale?: "id" | "en";
19
22
  };
20
23
 
21
24
  export function createShellProvider(options?: SharedShellProviderOptions) {
22
25
  const withAuth = options?.withAuth ?? true;
23
26
  const dictionaries = options?.dictionaries;
27
+ const defaultLocale = options?.defaultLocale ?? "en";
24
28
 
25
29
  return function SharedShellProvider({ children, Layout }: SharedShellProviderProps) {
26
30
  const content = (
27
- <I18nProvider dictionaries={dictionaries}>
31
+ <I18nProvider defaultLocale={defaultLocale} dictionaries={dictionaries}>
28
32
  <Layout>{children}</Layout>
29
33
  </I18nProvider>
30
34
  );