@isi-ui7/bos7-shared 0.2.10 → 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 +29 -26
- package/dist/shell/provider.d.ts +1 -0
- package/package.json +4 -4
- package/src/shell/provider.tsx +5 -1
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
|
-
|
|
20224
|
+
defaultLocale: r,
|
|
20225
|
+
dictionaries: n
|
|
20225
20226
|
}) {
|
|
20226
|
-
const [
|
|
20227
|
-
|
|
20228
|
-
|
|
20229
|
-
|
|
20230
|
-
|
|
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:
|
|
20233
|
-
setLocale(
|
|
20234
|
-
|
|
20235
|
+
locale: a,
|
|
20236
|
+
setLocale(f) {
|
|
20237
|
+
i(f), As(f);
|
|
20235
20238
|
},
|
|
20236
|
-
t(
|
|
20237
|
-
return
|
|
20239
|
+
t(f, c) {
|
|
20240
|
+
return l[f] ?? c ?? f;
|
|
20238
20241
|
},
|
|
20239
|
-
dictionary:
|
|
20242
|
+
dictionary: l
|
|
20240
20243
|
};
|
|
20241
|
-
}, [
|
|
20244
|
+
}, [s, a]);
|
|
20242
20245
|
return Vt(() => {
|
|
20243
20246
|
if (t) return;
|
|
20244
|
-
let
|
|
20245
|
-
return fetch("/api/auth/preferences", { cache: "no-store" }).then(async (
|
|
20246
|
-
if (
|
|
20247
|
-
const
|
|
20248
|
-
(
|
|
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
|
-
|
|
20254
|
+
l = !0;
|
|
20252
20255
|
};
|
|
20253
|
-
}, [t]), /* @__PURE__ */ Ee(fc.Provider, { value:
|
|
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:
|
|
20306
|
-
const
|
|
20307
|
-
return t ? /* @__PURE__ */ Ee(Mc, { children:
|
|
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) {
|
package/dist/shell/provider.d.ts
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "0.2.11",
|
|
4
4
|
"description": "Shared auth7 and layout primitives for bos7 applications.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -100,8 +100,8 @@
|
|
|
100
100
|
"next": "16.1.1",
|
|
101
101
|
"@carbon/react": "^1.97.0",
|
|
102
102
|
"@carbon/icons-react": "^11.71.0",
|
|
103
|
+
"@isi-ui7/i18n": "0.2.2",
|
|
103
104
|
"@isi-ui7/corporate-themes": "0.2.4",
|
|
104
|
-
"@isi-ui7/i18n": "0.2.1",
|
|
105
105
|
"@isi-ui7/ui-shell": "0.2.4",
|
|
106
106
|
"@isi-ui7/modal-manager": "0.2.2",
|
|
107
107
|
"@isi-ui7/realtime": "0.2.3",
|
|
@@ -121,8 +121,8 @@
|
|
|
121
121
|
"@opentelemetry/exporter-trace-otlp-http": "^0.57.0",
|
|
122
122
|
"@opentelemetry/auto-instrumentations-node": "^0.57.0",
|
|
123
123
|
"@isi-ui7/data-table": "0.2.3",
|
|
124
|
-
"@isi-ui7/
|
|
125
|
-
"@isi-ui7/
|
|
124
|
+
"@isi-ui7/lookup-input": "0.2.3",
|
|
125
|
+
"@isi-ui7/editable-table": "0.2.3"
|
|
126
126
|
},
|
|
127
127
|
"scripts": {
|
|
128
128
|
"build": "vite build",
|
package/src/shell/provider.tsx
CHANGED
|
@@ -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
|
);
|