@isi-ui7/corporate-themes 0.2.0 → 0.2.1

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.
@@ -0,0 +1,8 @@
1
+ import { ReactNode } from 'react';
2
+ import { Ui7Labels } from './labels';
3
+
4
+ export declare function LabelsProvider({ labels, children, }: {
5
+ labels?: Partial<Ui7Labels>;
6
+ children: ReactNode;
7
+ }): import("react/jsx-runtime").JSX.Element;
8
+ export declare function useLabels(): Ui7Labels;
@@ -1,5 +1,6 @@
1
1
  import { ElementType, ReactElement, ReactNode } from 'react';
2
2
  import { CarbonThemeVariant } from '../types';
3
+ import { Ui7Labels } from '../labels';
3
4
 
4
5
  type CorporateThemeProps<T extends ElementType> = {
5
6
  as?: T;
@@ -11,6 +12,7 @@ type CorporateThemeProps<T extends ElementType> = {
11
12
  type GlobalCorporateThemeProps = {
12
13
  corporateId?: string;
13
14
  variant?: CarbonThemeVariant;
15
+ labels?: Partial<Ui7Labels>;
14
16
  children: ReactElement;
15
17
  };
16
18
  /**
@@ -22,5 +24,5 @@ export declare function CorporateTheme<T extends ElementType = "div">({ as, clas
22
24
  * Global theme provider, analogous to Carbon's <GlobalTheme>.
23
25
  * It sets the corporate/variant in context (and root classes via ThemeContextProvider).
24
26
  */
25
- export declare function GlobalCorporateTheme({ corporateId, variant, children }: GlobalCorporateThemeProps): import("react/jsx-runtime").JSX.Element;
27
+ export declare function GlobalCorporateTheme({ corporateId, variant, labels, children }: GlobalCorporateThemeProps): import("react/jsx-runtime").JSX.Element;
26
28
  export {};
package/dist/index.d.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  export * from './types';
2
2
  export * from './tokens';
3
+ export { useLabels, LabelsProvider } from './LabelsContext';
4
+ export type { Ui7Labels } from './labels';
5
+ export { defaultLabels } from './labels';
3
6
  export { ThemeContextProvider, useTheme, corporateThemes } from './context/ThemeContext';
4
7
  export { ThemeProvider } from './components/ThemeProvider';
5
8
  export { CorporateTheme, GlobalCorporateTheme } from './components/CorporateTheme';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { jsx as i, jsxs as k } from "react/jsx-runtime";
2
- import { useMemo as h, useState as b, useEffect as g, createContext as f, useContext as A } from "react";
3
- const E = {
1
+ import { jsx as n, jsxs as P } from "react/jsx-runtime";
2
+ import { useContext as F, createContext as p, useMemo as k, useState as f, useEffect as C } from "react";
3
+ const H = {
4
4
  brandColors: {
5
5
  primary: "#0F62FE",
6
6
  primaryHover: "#0043CE",
@@ -31,7 +31,7 @@ const E = {
31
31
  headerBackground: "#0F62FE",
32
32
  sidebarBackground: "#393939",
33
33
  navigationBackground: "#F4F4F4"
34
- }, H = {
34
+ }, B = {
35
35
  brandColors: {
36
36
  primary: "#0066CC",
37
37
  // BCA Blue
@@ -70,7 +70,7 @@ const E = {
70
70
  headerBackground: "#0066CC",
71
71
  sidebarBackground: "#00A651",
72
72
  navigationBackground: "#F5F5F5"
73
- }, B = {
73
+ }, D = {
74
74
  brandColors: {
75
75
  primary: "#C8102E",
76
76
  // BJB Red (main brand color)
@@ -104,7 +104,7 @@ const E = {
104
104
  headerBackground: "#C8102E",
105
105
  sidebarBackground: "#8B0000",
106
106
  navigationBackground: "#FFF5F5"
107
- }, P = {
107
+ }, S = {
108
108
  brandColors: {
109
109
  primary: "#ED1C24",
110
110
  primaryHover: "#C61018",
@@ -135,7 +135,7 @@ const E = {
135
135
  headerBackground: "#ED1C24",
136
136
  sidebarBackground: "#FF7F00",
137
137
  navigationBackground: "#FFF4E6"
138
- }, D = {
138
+ }, T = {
139
139
  brandColors: {
140
140
  primary: "#0F62FE",
141
141
  primaryHover: "#0043CE",
@@ -171,7 +171,7 @@ const E = {
171
171
  id: "carbon-default",
172
172
  name: "carbon-default",
173
173
  displayName: "ISI",
174
- tokens: E,
174
+ tokens: H,
175
175
  supportedVariants: ["white", "g10", "g90", "g100"],
176
176
  defaultVariant: "g10"
177
177
  },
@@ -179,7 +179,7 @@ const E = {
179
179
  id: "ihsan",
180
180
  name: "ihsan",
181
181
  displayName: "ISI",
182
- tokens: D,
182
+ tokens: T,
183
183
  supportedVariants: ["white", "g10", "g90", "g100"],
184
184
  defaultVariant: "g10"
185
185
  },
@@ -187,7 +187,7 @@ const E = {
187
187
  id: "bca-syariah",
188
188
  name: "bca-syariah",
189
189
  displayName: "BCAS",
190
- tokens: H,
190
+ tokens: B,
191
191
  supportedVariants: ["white", "g10", "g90", "g100"],
192
192
  defaultVariant: "g10"
193
193
  },
@@ -195,7 +195,7 @@ const E = {
195
195
  id: "bjb-syariah",
196
196
  name: "bjb-syariah",
197
197
  displayName: "BJBS",
198
- tokens: B,
198
+ tokens: D,
199
199
  supportedVariants: ["white", "g10", "g90", "g100"],
200
200
  defaultVariant: "g90"
201
201
  },
@@ -203,127 +203,164 @@ const E = {
203
203
  id: "pos-indonesia",
204
204
  name: "pos-indonesia",
205
205
  displayName: "PosInd",
206
- tokens: P,
206
+ tokens: S,
207
207
  supportedVariants: ["white", "g10", "g90", "g100"],
208
208
  defaultVariant: "g10"
209
209
  }
210
- ], F = f(null);
211
- function p(e) {
212
- const t = m.find((a) => a.id === "carbon-default") ?? m.find((a) => a.id === "ihsan") ?? m[0];
213
- return e ? m.find((a) => a.id === e) ?? t : t;
210
+ ], b = {
211
+ rowsPerPage: "Tampil",
212
+ search: "Cari",
213
+ noData: "Tidak ada data",
214
+ loading: "Memuat...",
215
+ nextPage: "Selanjutnya",
216
+ prevPage: "Sebelumnya",
217
+ firstPage: "Halaman pertama",
218
+ lastPage: "Halaman terakhir",
219
+ filterColumns: "Kolom",
220
+ lookupPlaceholder: "Ketik untuk mencari...",
221
+ lookupNoResults: "Tidak ditemukan",
222
+ lookupLoading: "Mencari...",
223
+ addRow: "Tambah Baris",
224
+ deleteRow: "Hapus",
225
+ editableNoData: "Belum ada data",
226
+ modalClose: "Tutup",
227
+ modalCancel: "Batal",
228
+ notifications: "Notifikasi",
229
+ markAllRead: "Tandai Semua Dibaca",
230
+ noNotifications: "Tidak ada notifikasi",
231
+ apps: "Aplikasi",
232
+ required: "Wajib diisi"
233
+ }, A = p(b);
234
+ function V({
235
+ labels: e,
236
+ children: r
237
+ }) {
238
+ const t = e ? { ...b, ...e } : b;
239
+ return /* @__PURE__ */ n(A.Provider, { value: t, children: r });
240
+ }
241
+ function U() {
242
+ return F(A);
214
243
  }
215
- function S({ corporateId: e, variant: t, children: a }) {
216
- const r = h(() => p(e), [e]), [d, v] = b(
217
- t ?? r.defaultVariant
244
+ const h = p(null);
245
+ function E(e) {
246
+ const r = m.find((t) => t.id === "carbon-default") ?? m.find((t) => t.id === "ihsan") ?? m[0];
247
+ return e ? m.find((t) => t.id === e) ?? r : r;
248
+ }
249
+ function w({ corporateId: e, variant: r, children: t }) {
250
+ const a = k(() => E(e), [e]), [d, v] = f(
251
+ r ?? a.defaultVariant
218
252
  );
219
- g(() => {
220
- t && r.supportedVariants.includes(t) && v(t);
221
- }, [t, r]), g(() => {
253
+ C(() => {
254
+ r && a.supportedVariants.includes(r) && v(r);
255
+ }, [r, a]), C(() => {
222
256
  if (typeof document > "u") return;
223
257
  const u = document.documentElement, o = document.body;
224
258
  m.flatMap(
225
- (s) => s.supportedVariants.map((C) => `platform-theme-${s.id}-${C}`)
259
+ (s) => s.supportedVariants.map((g) => `platform-theme-${s.id}-${g}`)
226
260
  ).forEach((s) => {
227
261
  u.classList.remove(s), o.classList.remove(s);
228
262
  });
229
- const n = `platform-theme-${r.id}-${d}`;
230
- return u.classList.add(n), o.classList.add(n), () => {
231
- u.classList.remove(n), o.classList.remove(n);
263
+ const i = `platform-theme-${a.id}-${d}`;
264
+ return u.classList.add(i), o.classList.add(i), () => {
265
+ u.classList.remove(i), o.classList.remove(i);
232
266
  };
233
- }, [r, d]);
267
+ }, [a, d]);
234
268
  const l = {
235
- theme: r,
269
+ theme: a,
236
270
  variant: d,
237
- corporateId: r.id,
271
+ corporateId: a.id,
238
272
  setVariant: v
239
273
  };
240
- return /* @__PURE__ */ i(F.Provider, { value: l, children: a });
274
+ return /* @__PURE__ */ n(h.Provider, { value: l, children: t });
241
275
  }
242
276
  function c() {
243
- const e = A(F);
277
+ const e = F(h);
244
278
  if (!e)
245
279
  throw new Error("useTheme must be used inside ThemeProvider");
246
280
  return e;
247
281
  }
248
- function V({ corporateId: e, variant: t, children: a }) {
249
- return /* @__PURE__ */ i(S, { corporateId: e, variant: t, children: a });
282
+ function x({ corporateId: e, variant: r, children: t }) {
283
+ return /* @__PURE__ */ n(w, { corporateId: e, variant: r, children: t });
250
284
  }
251
- function j({
285
+ function $({
252
286
  as: e,
253
- className: t,
254
- corporateId: a,
255
- variant: r,
287
+ className: r,
288
+ corporateId: t,
289
+ variant: a,
256
290
  children: d,
257
291
  ...v
258
292
  }) {
259
- const l = c(), u = e ?? "div", o = h(
260
- () => a ? p(a) : l.theme,
261
- [a, l.theme]
262
- ), [y, n] = b(
263
- r ?? l.variant ?? o.defaultVariant
293
+ const l = c(), u = e ?? "div", o = k(
294
+ () => t ? E(t) : l.theme,
295
+ [t, l.theme]
296
+ ), [y, i] = f(
297
+ a ?? l.variant ?? o.defaultVariant
264
298
  );
265
- g(() => {
266
- r && o.supportedVariants.includes(r) ? n(r) : r || n(o.defaultVariant);
267
- }, [r, o]);
299
+ C(() => {
300
+ a && o.supportedVariants.includes(a) ? i(a) : a || i(o.defaultVariant);
301
+ }, [a, o]);
268
302
  const s = {
269
303
  theme: o,
270
304
  variant: y,
271
305
  corporateId: o.id,
272
- setVariant: n
273
- }, C = [t, `platform-theme-${o.id}-${y}`].filter(Boolean).join(" ");
274
- return /* @__PURE__ */ i(F.Provider, { value: s, children: /* @__PURE__ */ i(u, { className: C, ...v, children: d }) });
306
+ setVariant: i
307
+ }, g = [r, `platform-theme-${o.id}-${y}`].filter(Boolean).join(" ");
308
+ return /* @__PURE__ */ n(h.Provider, { value: s, children: /* @__PURE__ */ n(u, { className: g, ...v, children: d }) });
275
309
  }
276
- function N({ corporateId: e, variant: t, children: a }) {
277
- return /* @__PURE__ */ i(V, { corporateId: e, variant: t, children: a });
310
+ function M({ corporateId: e, variant: r, labels: t, children: a }) {
311
+ return /* @__PURE__ */ n(V, { labels: t, children: /* @__PURE__ */ n(x, { corporateId: e, variant: r, children: a }) });
278
312
  }
279
- const T = ["white", "g10", "g90", "g100"];
280
- function U() {
281
- const { variant: e, setVariant: t, theme: a } = c();
282
- return /* @__PURE__ */ k("div", { style: { display: "inline-flex", gap: "0.5rem", alignItems: "center" }, children: [
283
- /* @__PURE__ */ i("span", { style: { fontSize: "0.85rem" }, children: a.displayName }),
284
- /* @__PURE__ */ i(
313
+ const I = ["white", "g10", "g90", "g100"];
314
+ function R() {
315
+ const { variant: e, setVariant: r, theme: t } = c();
316
+ return /* @__PURE__ */ P("div", { style: { display: "inline-flex", gap: "0.5rem", alignItems: "center" }, children: [
317
+ /* @__PURE__ */ n("span", { style: { fontSize: "0.85rem" }, children: t.displayName }),
318
+ /* @__PURE__ */ n(
285
319
  "select",
286
320
  {
287
321
  value: e,
288
- onChange: (r) => t(r.target.value),
289
- children: T.map((r) => /* @__PURE__ */ i("option", { value: r, children: r.toUpperCase() }, r))
322
+ onChange: (a) => r(a.target.value),
323
+ children: I.map((a) => /* @__PURE__ */ n("option", { value: a, children: a.toUpperCase() }, a))
290
324
  }
291
325
  )
292
326
  ] });
293
327
  }
294
- function I() {
328
+ function L() {
295
329
  const { theme: e } = c();
296
330
  return e.tokens;
297
331
  }
298
- function L() {
299
- return I().brandColors;
332
+ function K() {
333
+ return L().brandColors;
300
334
  }
301
- function $() {
302
- const { variant: e, setVariant: t } = c();
303
- return { variant: e, setVariant: t };
335
+ function q() {
336
+ const { variant: e, setVariant: r } = c();
337
+ return { variant: e, setVariant: r };
304
338
  }
305
- function M() {
339
+ function z() {
306
340
  const { theme: e } = c();
307
341
  return {
308
342
  logo: e.tokens.logoUrl,
309
343
  brandColors: e.tokens.brandColors
310
344
  };
311
345
  }
312
- function z() {
346
+ function G() {
313
347
  const { theme: e } = c();
314
348
  return e.tokens.density ?? "compact";
315
349
  }
316
350
  export {
317
- j as CorporateTheme,
318
- N as GlobalCorporateTheme,
319
- S as ThemeContextProvider,
320
- V as ThemeProvider,
321
- U as ThemeSwitcher,
351
+ $ as CorporateTheme,
352
+ M as GlobalCorporateTheme,
353
+ V as LabelsProvider,
354
+ w as ThemeContextProvider,
355
+ x as ThemeProvider,
356
+ R as ThemeSwitcher,
322
357
  m as corporateThemes,
323
- L as useBrandColors,
324
- M as useCorporateFeatures,
325
- z as useDensity,
358
+ b as defaultLabels,
359
+ K as useBrandColors,
360
+ z as useCorporateFeatures,
361
+ G as useDensity,
362
+ U as useLabels,
326
363
  c as useTheme,
327
- I as useThemeTokens,
328
- $ as useThemeVariant
364
+ L as useThemeTokens,
365
+ q as useThemeVariant
329
366
  };
@@ -0,0 +1,25 @@
1
+ export interface Ui7Labels {
2
+ rowsPerPage: string;
3
+ search: string;
4
+ noData: string;
5
+ loading: string;
6
+ nextPage: string;
7
+ prevPage: string;
8
+ firstPage: string;
9
+ lastPage: string;
10
+ filterColumns: string;
11
+ lookupPlaceholder: string;
12
+ lookupNoResults: string;
13
+ lookupLoading: string;
14
+ addRow: string;
15
+ deleteRow: string;
16
+ editableNoData: string;
17
+ modalClose: string;
18
+ modalCancel: string;
19
+ notifications: string;
20
+ markAllRead: string;
21
+ noNotifications: string;
22
+ apps: string;
23
+ required: string;
24
+ }
25
+ export declare const defaultLabels: Ui7Labels;