@isi-ui7/corporate-themes 0.1.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,26 @@
1
+ import { ElementType, ReactElement, ReactNode } from 'react';
2
+ import { CarbonThemeVariant } from '../types';
3
+
4
+ type CorporateThemeProps<T extends ElementType> = {
5
+ as?: T;
6
+ className?: string;
7
+ corporateId?: string;
8
+ variant?: CarbonThemeVariant;
9
+ children: ReactNode;
10
+ } & Omit<React.ComponentPropsWithoutRef<T>, "as" | "className" | "children">;
11
+ type GlobalCorporateThemeProps = {
12
+ corporateId?: string;
13
+ variant?: CarbonThemeVariant;
14
+ children: ReactElement;
15
+ };
16
+ /**
17
+ * Scoped theme wrapper, similar to Carbon's <Theme>, that applies the corporate theme
18
+ * class to a container and provides a scoped ThemeContext value.
19
+ */
20
+ export declare function CorporateTheme<T extends ElementType = "div">({ as, className, corporateId, variant, children, ...rest }: CorporateThemeProps<T>): import("react/jsx-runtime").JSX.Element;
21
+ /**
22
+ * Global theme provider, analogous to Carbon's <GlobalTheme>.
23
+ * It sets the corporate/variant in context (and root classes via ThemeContextProvider).
24
+ */
25
+ export declare function GlobalCorporateTheme({ corporateId, variant, children }: GlobalCorporateThemeProps): import("react/jsx-runtime").JSX.Element;
26
+ export {};
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from 'react';
2
+ import { CarbonThemeVariant } from '../types';
3
+
4
+ type Props = {
5
+ corporateId?: string;
6
+ variant?: CarbonThemeVariant;
7
+ children: ReactNode;
8
+ };
9
+ export declare function ThemeProvider({ corporateId, variant, children }: Props): import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1 @@
1
+ export declare function ThemeSwitcher(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import { ReactNode } from 'react';
2
+ import { corporateThemes } from '../tokens';
3
+ import { CarbonThemeVariant, CorporateTheme, ThemeContextValue } from '../types';
4
+
5
+ declare const ThemeContext: import('react').Context<ThemeContextValue | null>;
6
+ type ProviderProps = {
7
+ corporateId?: string;
8
+ variant?: CarbonThemeVariant;
9
+ children: ReactNode;
10
+ };
11
+ export declare function findTheme(id?: string): CorporateTheme;
12
+ export declare function ThemeContextProvider({ corporateId, variant, children }: ProviderProps): import("react/jsx-runtime").JSX.Element;
13
+ export declare function useTheme(): ThemeContextValue;
14
+ export { ThemeContext, corporateThemes };
@@ -0,0 +1,14 @@
1
+ import { bcaSyariahTokens } from './tokens';
2
+
3
+ export declare const bcaSyariah: {
4
+ id: string;
5
+ classNames: {
6
+ white: string;
7
+ g10: string;
8
+ g90: string;
9
+ g100: string;
10
+ };
11
+ tokens: import('../..').ThemeTokens;
12
+ };
13
+ export type BcaSyariahTheme = typeof bcaSyariah;
14
+ export { bcaSyariahTokens };
@@ -0,0 +1,3 @@
1
+ import { ThemeTokens } from '../../types';
2
+
3
+ export declare const bcaSyariahTokens: ThemeTokens;
@@ -0,0 +1,14 @@
1
+ import { bjbSyariahTokens } from './tokens';
2
+
3
+ export declare const bjbSyariah: {
4
+ id: string;
5
+ classNames: {
6
+ white: string;
7
+ g10: string;
8
+ g90: string;
9
+ g100: string;
10
+ };
11
+ tokens: import('../..').ThemeTokens;
12
+ };
13
+ export type BjbsSyariahTheme = typeof bjbSyariah;
14
+ export { bjbSyariahTokens };
@@ -0,0 +1,3 @@
1
+ import { ThemeTokens } from '../../types';
2
+
3
+ export declare const bjbSyariahTokens: ThemeTokens;
@@ -0,0 +1,14 @@
1
+ import { carbonDefaultTokens } from './tokens';
2
+
3
+ export declare const carbonDefault: {
4
+ id: string;
5
+ classNames: {
6
+ white: string;
7
+ g10: string;
8
+ g90: string;
9
+ g100: string;
10
+ };
11
+ tokens: import('../..').ThemeTokens;
12
+ };
13
+ export type CarbonDefaultTheme = typeof carbonDefault;
14
+ export { carbonDefaultTokens };
@@ -0,0 +1,3 @@
1
+ import { ThemeTokens } from '../../types';
2
+
3
+ export declare const carbonDefaultTokens: ThemeTokens;
@@ -0,0 +1,14 @@
1
+ import { ihsanSolusiTokens } from './tokens';
2
+
3
+ export declare const ihsanSolusi: {
4
+ id: string;
5
+ classNames: {
6
+ white: string;
7
+ g10: string;
8
+ g90: string;
9
+ g100: string;
10
+ };
11
+ tokens: import('../..').ThemeTokens;
12
+ };
13
+ export type IhsanSolusiTheme = typeof ihsanSolusi;
14
+ export { ihsanSolusiTokens };
@@ -0,0 +1,3 @@
1
+ import { ThemeTokens } from '../../types';
2
+
3
+ export declare const ihsanSolusiTokens: ThemeTokens;
@@ -0,0 +1,14 @@
1
+ import { posIndonesiaTokens } from './tokens';
2
+
3
+ export declare const posIndonesia: {
4
+ id: string;
5
+ classNames: {
6
+ white: string;
7
+ g10: string;
8
+ g90: string;
9
+ g100: string;
10
+ };
11
+ tokens: import('../..').ThemeTokens;
12
+ };
13
+ export type PosIndonesiaTheme = typeof posIndonesia;
14
+ export { posIndonesiaTokens };
@@ -0,0 +1,3 @@
1
+ import { ThemeTokens } from '../../types';
2
+
3
+ export declare const posIndonesiaTokens: ThemeTokens;
@@ -0,0 +1 @@
1
+ export declare function useBrandColors(): import('..').BrandColors;
@@ -0,0 +1,7 @@
1
+ export declare function useCorporateFeatures(): {
2
+ logo: {
3
+ light: string;
4
+ dark: string;
5
+ };
6
+ brandColors: import('..').BrandColors;
7
+ };
@@ -0,0 +1 @@
1
+ export declare function useThemeTokens(): import('..').ThemeTokens;
@@ -0,0 +1,4 @@
1
+ export declare function useThemeVariant(): {
2
+ variant: import('..').CarbonThemeVariant;
3
+ setVariant: (variant: import('..').CarbonThemeVariant) => void;
4
+ };
@@ -0,0 +1,10 @@
1
+ export * from './types';
2
+ export * from './tokens';
3
+ export { ThemeContextProvider, useTheme, corporateThemes } from './context/ThemeContext';
4
+ export { ThemeProvider } from './components/ThemeProvider';
5
+ export { CorporateTheme, GlobalCorporateTheme } from './components/CorporateTheme';
6
+ export { ThemeSwitcher } from './components/ThemeSwitcher';
7
+ export { useThemeTokens } from './hooks/useThemeTokens';
8
+ export { useBrandColors } from './hooks/useBrandColors';
9
+ export { useThemeVariant } from './hooks/useThemeVariant';
10
+ export { useCorporateFeatures } from './hooks/useCorporateFeatures';
package/dist/index.js ADDED
@@ -0,0 +1,324 @@
1
+ import { jsx as i, jsxs as k } from "react/jsx-runtime";
2
+ import { useMemo as b, useState as h, useEffect as g, createContext as f, useContext as A } from "react";
3
+ const E = {
4
+ brandColors: {
5
+ primary: "#0F62FE",
6
+ primaryHover: "#0043CE",
7
+ primaryActive: "#002D9C",
8
+ secondary: "#393939",
9
+ secondaryHover: "#4C4C4C",
10
+ secondaryActive: "#6F6F6F",
11
+ accent: "#4589FF",
12
+ accentHover: "#1F70FF"
13
+ },
14
+ logoUrl: {
15
+ light: "/assets/logos/carbon-light.svg",
16
+ dark: "/assets/logos/carbon-dark.svg"
17
+ },
18
+ interactive: "#0F62FE",
19
+ interactiveHover: "#0043CE",
20
+ interactiveActive: "#002D9C",
21
+ buttonPrimary: "#0F62FE",
22
+ buttonPrimaryHover: "#0043CE",
23
+ buttonPrimaryActive: "#002D9C",
24
+ buttonSecondary: "#393939",
25
+ buttonSecondaryHover: "#4C4C4C",
26
+ linkPrimary: "#0F62FE",
27
+ linkPrimaryHover: "#002D9C",
28
+ linkSecondary: "#4589FF",
29
+ focus: "#0F62FE",
30
+ borderInteractive: "#0F62FE",
31
+ headerBackground: "#0F62FE",
32
+ sidebarBackground: "#393939",
33
+ navigationBackground: "#F4F4F4"
34
+ }, H = {
35
+ brandColors: {
36
+ primary: "#0066CC",
37
+ // BCA Blue
38
+ primaryHover: "#0052A3",
39
+ primaryActive: "#003D7A",
40
+ secondary: "#00A651",
41
+ // Islamic Green
42
+ secondaryHover: "#008542",
43
+ secondaryActive: "#006633",
44
+ accent: "#FFB81C",
45
+ // Gold accent
46
+ accentHover: "#E6A519"
47
+ },
48
+ logoUrl: {
49
+ light: "/assets/logos/bca-syariah-light.svg",
50
+ dark: "/assets/logos/bca-syariah-dark.svg"
51
+ },
52
+ // Interactive - gunakan primary blue
53
+ interactive: "#0066CC",
54
+ interactiveHover: "#0052A3",
55
+ interactiveActive: "#003D7A",
56
+ // Buttons
57
+ buttonPrimary: "#0066CC",
58
+ buttonPrimaryHover: "#0052A3",
59
+ buttonPrimaryActive: "#003D7A",
60
+ buttonSecondary: "#00A651",
61
+ buttonSecondaryHover: "#008542",
62
+ // Links
63
+ linkPrimary: "#0066CC",
64
+ linkPrimaryHover: "#003D7A",
65
+ linkSecondary: "#00A651",
66
+ // Focus
67
+ focus: "#0066CC",
68
+ borderInteractive: "#0066CC",
69
+ // Custom UI
70
+ headerBackground: "#0066CC",
71
+ sidebarBackground: "#00A651",
72
+ navigationBackground: "#F5F5F5"
73
+ }, B = {
74
+ brandColors: {
75
+ primary: "#C8102E",
76
+ // BJB Red (main brand color)
77
+ primaryHover: "#A00D25",
78
+ primaryActive: "#7A0A1C",
79
+ secondary: "#8B0000",
80
+ // Dark Red
81
+ secondaryHover: "#6B0000",
82
+ secondaryActive: "#4B0000",
83
+ accent: "#E31837",
84
+ // Bright Red accent
85
+ accentHover: "#C8102E"
86
+ },
87
+ logoUrl: {
88
+ light: "/assets/logos/bjb-syariah-light.svg",
89
+ dark: "/assets/logos/bjb-syariah-dark.svg"
90
+ },
91
+ interactive: "#C8102E",
92
+ interactiveHover: "#A00D25",
93
+ interactiveActive: "#7A0A1C",
94
+ buttonPrimary: "#C8102E",
95
+ buttonPrimaryHover: "#A00D25",
96
+ buttonPrimaryActive: "#7A0A1C",
97
+ buttonSecondary: "#8B0000",
98
+ buttonSecondaryHover: "#6B0000",
99
+ linkPrimary: "#C8102E",
100
+ linkPrimaryHover: "#7A0A1C",
101
+ linkSecondary: "#E31837",
102
+ focus: "#C8102E",
103
+ borderInteractive: "#C8102E",
104
+ headerBackground: "#C8102E",
105
+ sidebarBackground: "#8B0000",
106
+ navigationBackground: "#FFF5F5"
107
+ }, P = {
108
+ brandColors: {
109
+ primary: "#ED1C24",
110
+ primaryHover: "#C61018",
111
+ primaryActive: "#A00D14",
112
+ secondary: "#FF7F00",
113
+ secondaryHover: "#E66F00",
114
+ secondaryActive: "#CC6300",
115
+ accent: "#FFD100",
116
+ accentHover: "#E6BC00"
117
+ },
118
+ logoUrl: {
119
+ light: "/assets/logos/pos-indonesia-light.svg",
120
+ dark: "/assets/logos/pos-indonesia-dark.svg"
121
+ },
122
+ interactive: "#ED1C24",
123
+ interactiveHover: "#C61018",
124
+ interactiveActive: "#A00D14",
125
+ buttonPrimary: "#ED1C24",
126
+ buttonPrimaryHover: "#C61018",
127
+ buttonPrimaryActive: "#A00D14",
128
+ buttonSecondary: "#FF7F00",
129
+ buttonSecondaryHover: "#E66F00",
130
+ linkPrimary: "#ED1C24",
131
+ linkPrimaryHover: "#A00D14",
132
+ linkSecondary: "#FF7F00",
133
+ focus: "#ED1C24",
134
+ borderInteractive: "#ED1C24",
135
+ headerBackground: "#ED1C24",
136
+ sidebarBackground: "#FF7F00",
137
+ navigationBackground: "#FFF4E6"
138
+ }, D = {
139
+ brandColors: {
140
+ primary: "#0F62FE",
141
+ primaryHover: "#0043CE",
142
+ primaryActive: "#002D9C",
143
+ secondary: "#1192E8",
144
+ secondaryHover: "#0F7EC8",
145
+ secondaryActive: "#0C6AAA",
146
+ accent: "#08BDBA",
147
+ accentHover: "#07A6A4"
148
+ },
149
+ logoUrl: {
150
+ light: "/assets/logos/ihsan-solusi-light.svg",
151
+ dark: "/assets/logos/ihsan-solusi-dark.svg"
152
+ },
153
+ interactive: "#0F62FE",
154
+ interactiveHover: "#0043CE",
155
+ interactiveActive: "#002D9C",
156
+ buttonPrimary: "#0F62FE",
157
+ buttonPrimaryHover: "#0043CE",
158
+ buttonPrimaryActive: "#002D9C",
159
+ buttonSecondary: "#1192E8",
160
+ buttonSecondaryHover: "#0F7EC8",
161
+ linkPrimary: "#0F62FE",
162
+ linkPrimaryHover: "#002D9C",
163
+ linkSecondary: "#1192E8",
164
+ focus: "#0F62FE",
165
+ borderInteractive: "#0F62FE",
166
+ headerBackground: "#0F62FE",
167
+ sidebarBackground: "#1192E8",
168
+ navigationBackground: "#F4F7FF"
169
+ }, u = [
170
+ {
171
+ id: "carbon-default",
172
+ name: "carbon-default",
173
+ displayName: "Carbon Default",
174
+ tokens: E,
175
+ supportedVariants: ["white", "g10", "g90", "g100"],
176
+ defaultVariant: "g10"
177
+ },
178
+ {
179
+ id: "ihsan",
180
+ name: "ihsan",
181
+ displayName: "ISI",
182
+ tokens: D,
183
+ supportedVariants: ["white", "g10", "g90", "g100"],
184
+ defaultVariant: "g10"
185
+ },
186
+ {
187
+ id: "bca-syariah",
188
+ name: "bca-syariah",
189
+ displayName: "BCAS",
190
+ tokens: H,
191
+ supportedVariants: ["white", "g10", "g90", "g100"],
192
+ defaultVariant: "g10"
193
+ },
194
+ {
195
+ id: "bjb-syariah",
196
+ name: "bjb-syariah",
197
+ displayName: "BJBS",
198
+ tokens: B,
199
+ supportedVariants: ["white", "g10", "g90", "g100"],
200
+ defaultVariant: "g90"
201
+ },
202
+ {
203
+ id: "pos-indonesia",
204
+ name: "pos-indonesia",
205
+ displayName: "PosInd",
206
+ tokens: P,
207
+ supportedVariants: ["white", "g10", "g90", "g100"],
208
+ defaultVariant: "g10"
209
+ }
210
+ ], F = f(null);
211
+ function p(e) {
212
+ const a = u.find((t) => t.id === "carbon-default") ?? u.find((t) => t.id === "ihsan") ?? u[0];
213
+ return e ? u.find((t) => t.id === e) ?? a : a;
214
+ }
215
+ function S({ corporateId: e, variant: a, children: t }) {
216
+ const r = b(() => p(e), [e]), [c, m] = h(
217
+ a ?? r.defaultVariant
218
+ );
219
+ g(() => {
220
+ a && r.supportedVariants.includes(a) && m(a);
221
+ }, [a, r]), g(() => {
222
+ if (typeof document > "u") return;
223
+ const l = document.documentElement, o = document.body;
224
+ u.flatMap(
225
+ (s) => s.supportedVariants.map((C) => `platform-theme-${s.id}-${C}`)
226
+ ).forEach((s) => {
227
+ l.classList.remove(s), o.classList.remove(s);
228
+ });
229
+ const n = `platform-theme-${r.id}-${c}`;
230
+ return l.classList.add(n), o.classList.add(n), () => {
231
+ l.classList.remove(n), o.classList.remove(n);
232
+ };
233
+ }, [r, c]);
234
+ const d = {
235
+ theme: r,
236
+ variant: c,
237
+ corporateId: r.id,
238
+ setVariant: m
239
+ };
240
+ return /* @__PURE__ */ i(F.Provider, { value: d, children: t });
241
+ }
242
+ function v() {
243
+ const e = A(F);
244
+ if (!e)
245
+ throw new Error("useTheme must be used inside ThemeProvider");
246
+ return e;
247
+ }
248
+ function V({ corporateId: e, variant: a, children: t }) {
249
+ return /* @__PURE__ */ i(S, { corporateId: e, variant: a, children: t });
250
+ }
251
+ function j({
252
+ as: e,
253
+ className: a,
254
+ corporateId: t,
255
+ variant: r,
256
+ children: c,
257
+ ...m
258
+ }) {
259
+ const d = v(), l = e ?? "div", o = b(
260
+ () => t ? p(t) : d.theme,
261
+ [t, d.theme]
262
+ ), [y, n] = h(
263
+ r ?? d.variant ?? o.defaultVariant
264
+ );
265
+ g(() => {
266
+ r && o.supportedVariants.includes(r) ? n(r) : r || n(o.defaultVariant);
267
+ }, [r, o]);
268
+ const s = {
269
+ theme: o,
270
+ variant: y,
271
+ corporateId: o.id,
272
+ setVariant: n
273
+ }, C = [a, `platform-theme-${o.id}-${y}`].filter(Boolean).join(" ");
274
+ return /* @__PURE__ */ i(F.Provider, { value: s, children: /* @__PURE__ */ i(l, { className: C, ...m, children: c }) });
275
+ }
276
+ function N({ corporateId: e, variant: a, children: t }) {
277
+ return /* @__PURE__ */ i(V, { corporateId: e, variant: a, children: t });
278
+ }
279
+ const T = ["white", "g10", "g90", "g100"];
280
+ function U() {
281
+ const { variant: e, setVariant: a, theme: t } = v();
282
+ return /* @__PURE__ */ k("div", { style: { display: "inline-flex", gap: "0.5rem", alignItems: "center" }, children: [
283
+ /* @__PURE__ */ i("span", { style: { fontSize: "0.85rem" }, children: t.displayName }),
284
+ /* @__PURE__ */ i(
285
+ "select",
286
+ {
287
+ value: e,
288
+ onChange: (r) => a(r.target.value),
289
+ children: T.map((r) => /* @__PURE__ */ i("option", { value: r, children: r.toUpperCase() }, r))
290
+ }
291
+ )
292
+ ] });
293
+ }
294
+ function w() {
295
+ const { theme: e } = v();
296
+ return e.tokens;
297
+ }
298
+ function L() {
299
+ return w().brandColors;
300
+ }
301
+ function $() {
302
+ const { variant: e, setVariant: a } = v();
303
+ return { variant: e, setVariant: a };
304
+ }
305
+ function M() {
306
+ const { theme: e } = v();
307
+ return {
308
+ logo: e.tokens.logoUrl,
309
+ brandColors: e.tokens.brandColors
310
+ };
311
+ }
312
+ export {
313
+ j as CorporateTheme,
314
+ N as GlobalCorporateTheme,
315
+ S as ThemeContextProvider,
316
+ V as ThemeProvider,
317
+ U as ThemeSwitcher,
318
+ u as corporateThemes,
319
+ L as useBrandColors,
320
+ M as useCorporateFeatures,
321
+ v as useTheme,
322
+ w as useThemeTokens,
323
+ $ as useThemeVariant
324
+ };