@isi-ui7/corporate-themes 0.1.2 → 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.
- package/dist/LabelsContext.d.ts +8 -0
- package/dist/components/CorporateTheme.d.ts +3 -1
- package/dist/hooks/useDensity.d.ts +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +129 -87
- package/dist/labels.d.ts +25 -0
- package/dist/style.css +1 -1
- package/dist/types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -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 {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useDensity(): "compact" | "normal";
|
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';
|
|
@@ -8,3 +11,4 @@ export { useThemeTokens } from './hooks/useThemeTokens';
|
|
|
8
11
|
export { useBrandColors } from './hooks/useBrandColors';
|
|
9
12
|
export { useThemeVariant } from './hooks/useThemeVariant';
|
|
10
13
|
export { useCorporateFeatures } from './hooks/useCorporateFeatures';
|
|
14
|
+
export { useDensity } from './hooks/useDensity';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
138
|
+
}, T = {
|
|
139
139
|
brandColors: {
|
|
140
140
|
primary: "#0F62FE",
|
|
141
141
|
primaryHover: "#0043CE",
|
|
@@ -166,12 +166,12 @@ const E = {
|
|
|
166
166
|
headerBackground: "#0F62FE",
|
|
167
167
|
sidebarBackground: "#1192E8",
|
|
168
168
|
navigationBackground: "#F4F7FF"
|
|
169
|
-
},
|
|
169
|
+
}, m = [
|
|
170
170
|
{
|
|
171
171
|
id: "carbon-default",
|
|
172
172
|
name: "carbon-default",
|
|
173
173
|
displayName: "ISI",
|
|
174
|
-
tokens:
|
|
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:
|
|
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:
|
|
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:
|
|
198
|
+
tokens: D,
|
|
199
199
|
supportedVariants: ["white", "g10", "g90", "g100"],
|
|
200
200
|
defaultVariant: "g90"
|
|
201
201
|
},
|
|
@@ -203,122 +203,164 @@ const E = {
|
|
|
203
203
|
id: "pos-indonesia",
|
|
204
204
|
name: "pos-indonesia",
|
|
205
205
|
displayName: "PosInd",
|
|
206
|
-
tokens:
|
|
206
|
+
tokens: S,
|
|
207
207
|
supportedVariants: ["white", "g10", "g90", "g100"],
|
|
208
208
|
defaultVariant: "g10"
|
|
209
209
|
}
|
|
210
|
-
],
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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);
|
|
243
|
+
}
|
|
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;
|
|
214
248
|
}
|
|
215
|
-
function
|
|
216
|
-
const
|
|
217
|
-
|
|
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
|
-
|
|
220
|
-
|
|
221
|
-
}, [
|
|
253
|
+
C(() => {
|
|
254
|
+
r && a.supportedVariants.includes(r) && v(r);
|
|
255
|
+
}, [r, a]), C(() => {
|
|
222
256
|
if (typeof document > "u") return;
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
(s) => s.supportedVariants.map((
|
|
257
|
+
const u = document.documentElement, o = document.body;
|
|
258
|
+
m.flatMap(
|
|
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
|
|
230
|
-
return
|
|
231
|
-
|
|
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
|
-
}, [
|
|
234
|
-
const
|
|
235
|
-
theme:
|
|
236
|
-
variant:
|
|
237
|
-
corporateId:
|
|
238
|
-
setVariant:
|
|
267
|
+
}, [a, d]);
|
|
268
|
+
const l = {
|
|
269
|
+
theme: a,
|
|
270
|
+
variant: d,
|
|
271
|
+
corporateId: a.id,
|
|
272
|
+
setVariant: v
|
|
239
273
|
};
|
|
240
|
-
return /* @__PURE__ */
|
|
274
|
+
return /* @__PURE__ */ n(h.Provider, { value: l, children: t });
|
|
241
275
|
}
|
|
242
|
-
function
|
|
243
|
-
const e =
|
|
276
|
+
function c() {
|
|
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
|
|
249
|
-
return /* @__PURE__ */
|
|
282
|
+
function x({ corporateId: e, variant: r, children: t }) {
|
|
283
|
+
return /* @__PURE__ */ n(w, { corporateId: e, variant: r, children: t });
|
|
250
284
|
}
|
|
251
|
-
function
|
|
285
|
+
function $({
|
|
252
286
|
as: e,
|
|
253
|
-
className:
|
|
287
|
+
className: r,
|
|
254
288
|
corporateId: t,
|
|
255
|
-
variant:
|
|
256
|
-
children:
|
|
257
|
-
...
|
|
289
|
+
variant: a,
|
|
290
|
+
children: d,
|
|
291
|
+
...v
|
|
258
292
|
}) {
|
|
259
|
-
const
|
|
260
|
-
() => t ?
|
|
261
|
-
[t,
|
|
262
|
-
), [y,
|
|
263
|
-
|
|
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
|
-
|
|
266
|
-
|
|
267
|
-
}, [
|
|
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:
|
|
273
|
-
},
|
|
274
|
-
return /* @__PURE__ */
|
|
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
|
|
277
|
-
return /* @__PURE__ */
|
|
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
|
|
280
|
-
function
|
|
281
|
-
const { variant: e, setVariant:
|
|
282
|
-
return /* @__PURE__ */
|
|
283
|
-
/* @__PURE__ */
|
|
284
|
-
/* @__PURE__ */
|
|
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: (
|
|
289
|
-
children:
|
|
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
|
|
295
|
-
const { theme: e } =
|
|
328
|
+
function L() {
|
|
329
|
+
const { theme: e } = c();
|
|
296
330
|
return e.tokens;
|
|
297
331
|
}
|
|
298
|
-
function
|
|
299
|
-
return
|
|
332
|
+
function K() {
|
|
333
|
+
return L().brandColors;
|
|
300
334
|
}
|
|
301
|
-
function
|
|
302
|
-
const { variant: e, setVariant:
|
|
303
|
-
return { variant: e, setVariant:
|
|
335
|
+
function q() {
|
|
336
|
+
const { variant: e, setVariant: r } = c();
|
|
337
|
+
return { variant: e, setVariant: r };
|
|
304
338
|
}
|
|
305
|
-
function
|
|
306
|
-
const { theme: e } =
|
|
339
|
+
function z() {
|
|
340
|
+
const { theme: e } = c();
|
|
307
341
|
return {
|
|
308
342
|
logo: e.tokens.logoUrl,
|
|
309
343
|
brandColors: e.tokens.brandColors
|
|
310
344
|
};
|
|
311
345
|
}
|
|
346
|
+
function G() {
|
|
347
|
+
const { theme: e } = c();
|
|
348
|
+
return e.tokens.density ?? "compact";
|
|
349
|
+
}
|
|
312
350
|
export {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
351
|
+
$ as CorporateTheme,
|
|
352
|
+
M as GlobalCorporateTheme,
|
|
353
|
+
V as LabelsProvider,
|
|
354
|
+
w as ThemeContextProvider,
|
|
355
|
+
x as ThemeProvider,
|
|
356
|
+
R as ThemeSwitcher,
|
|
357
|
+
m as corporateThemes,
|
|
358
|
+
b as defaultLabels,
|
|
359
|
+
K as useBrandColors,
|
|
360
|
+
z as useCorporateFeatures,
|
|
361
|
+
G as useDensity,
|
|
362
|
+
U as useLabels,
|
|
363
|
+
c as useTheme,
|
|
364
|
+
L as useThemeTokens,
|
|
365
|
+
q as useThemeVariant
|
|
324
366
|
};
|
package/dist/labels.d.ts
ADDED
|
@@ -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;
|