ppij-design-system 0.0.0-stage → 0.3.0
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/banners.d.ts +31 -0
- package/dist/banners.js +18 -0
- package/dist/card-themes.d.ts +14 -0
- package/dist/card-themes.js +325 -0
- package/dist/components/account-menu.d.ts +24 -0
- package/dist/components/account-menu.js +13 -0
- package/dist/components/admin-drawer.d.ts +40 -0
- package/dist/components/admin-drawer.js +35 -0
- package/dist/components/alert-dialog.d.ts +16 -0
- package/dist/components/alert-dialog.js +39 -0
- package/dist/components/alert.d.ts +11 -0
- package/dist/components/alert.js +29 -0
- package/dist/components/avatar.d.ts +11 -0
- package/dist/components/avatar.js +22 -0
- package/dist/components/badge.d.ts +9 -0
- package/dist/components/badge.js +27 -0
- package/dist/components/banner-carousel.d.ts +14 -0
- package/dist/components/banner-carousel.js +90 -0
- package/dist/components/bottom-bar.d.ts +22 -0
- package/dist/components/bottom-bar.js +12 -0
- package/dist/components/button.d.ts +10 -0
- package/dist/components/button.js +37 -0
- package/dist/components/card-upload.d.ts +30 -0
- package/dist/components/card-upload.js +19 -0
- package/dist/components/card.d.ts +9 -0
- package/dist/components/card.js +24 -0
- package/dist/components/checkbox.d.ts +4 -0
- package/dist/components/checkbox.js +9 -0
- package/dist/components/data-table.d.ts +26 -0
- package/dist/components/data-table.js +17 -0
- package/dist/components/dialog.d.ts +17 -0
- package/dist/components/dialog.js +37 -0
- package/dist/components/drawer.d.ts +13 -0
- package/dist/components/drawer.js +34 -0
- package/dist/components/dropdown-menu.d.ts +25 -0
- package/dist/components/dropdown-menu.js +50 -0
- package/dist/components/editable-panel.d.ts +25 -0
- package/dist/components/editable-panel.js +18 -0
- package/dist/components/empty.d.ts +12 -0
- package/dist/components/empty.js +33 -0
- package/dist/components/file-upload.d.ts +28 -0
- package/dist/components/file-upload.js +21 -0
- package/dist/components/form-panel.d.ts +15 -0
- package/dist/components/form-panel.js +9 -0
- package/dist/components/funding-picker.d.ts +20 -0
- package/dist/components/funding-picker.js +16 -0
- package/dist/components/input.d.ts +3 -0
- package/dist/components/input.js +6 -0
- package/dist/components/invitation-card.d.ts +14 -0
- package/dist/components/invitation-card.js +13 -0
- package/dist/components/label.d.ts +4 -0
- package/dist/components/label.js +7 -0
- package/dist/components/member-card-block.d.ts +47 -0
- package/dist/components/member-card-block.js +329 -0
- package/dist/components/member-card.css +92 -0
- package/dist/components/member-card.d.ts +29 -0
- package/dist/components/member-card.js +22 -0
- package/dist/components/month-picker.d.ts +16 -0
- package/dist/components/month-picker.js +19 -0
- package/dist/components/offline-banner.d.ts +14 -0
- package/dist/components/offline-banner.js +14 -0
- package/dist/components/page-header.d.ts +14 -0
- package/dist/components/page-header.js +10 -0
- package/dist/components/phone-field.d.ts +25 -0
- package/dist/components/phone-field.js +64 -0
- package/dist/components/pill-radio.d.ts +21 -0
- package/dist/components/pill-radio.js +15 -0
- package/dist/components/portal-shell.d.ts +53 -0
- package/dist/components/portal-shell.js +19 -0
- package/dist/components/postcode-field.d.ts +26 -0
- package/dist/components/postcode-field.js +14 -0
- package/dist/components/progress.d.ts +4 -0
- package/dist/components/progress.js +8 -0
- package/dist/components/radio-group.d.ts +5 -0
- package/dist/components/radio-group.js +11 -0
- package/dist/components/review-panel.d.ts +20 -0
- package/dist/components/review-panel.js +14 -0
- package/dist/components/saving-indicator.d.ts +15 -0
- package/dist/components/saving-indicator.js +19 -0
- package/dist/components/scroll-area.d.ts +5 -0
- package/dist/components/scroll-area.js +13 -0
- package/dist/components/search-filter.d.ts +39 -0
- package/dist/components/search-filter.js +19 -0
- package/dist/components/segmented-progress.d.ts +16 -0
- package/dist/components/segmented-progress.js +12 -0
- package/dist/components/select.d.ts +15 -0
- package/dist/components/select.js +38 -0
- package/dist/components/separator.d.ts +4 -0
- package/dist/components/separator.js +7 -0
- package/dist/components/service-tiles.d.ts +26 -0
- package/dist/components/service-tiles.js +17 -0
- package/dist/components/sheet.d.ts +14 -0
- package/dist/components/sheet.js +40 -0
- package/dist/components/sidebar.d.ts +69 -0
- package/dist/components/sidebar.js +210 -0
- package/dist/components/skeleton.d.ts +11 -0
- package/dist/components/skeleton.js +11 -0
- package/dist/components/sonner.d.ts +9 -0
- package/dist/components/sonner.js +25 -0
- package/dist/components/spinner.d.ts +14 -0
- package/dist/components/spinner.js +22 -0
- package/dist/components/stat-card.d.ts +22 -0
- package/dist/components/stat-card.js +12 -0
- package/dist/components/status-card.d.ts +24 -0
- package/dist/components/status-card.js +26 -0
- package/dist/components/stepper.d.ts +25 -0
- package/dist/components/stepper.js +23 -0
- package/dist/components/submit-overlay.d.ts +16 -0
- package/dist/components/submit-overlay.js +15 -0
- package/dist/components/suggestion-sheet.d.ts +20 -0
- package/dist/components/suggestion-sheet.js +36 -0
- package/dist/components/switch.d.ts +6 -0
- package/dist/components/switch.js +8 -0
- package/dist/components/table.d.ts +10 -0
- package/dist/components/table.js +28 -0
- package/dist/components/tabs.d.ts +11 -0
- package/dist/components/tabs.js +28 -0
- package/dist/components/tag-input.d.ts +15 -0
- package/dist/components/tag-input.js +31 -0
- package/dist/components/textarea.d.ts +3 -0
- package/dist/components/textarea.js +6 -0
- package/dist/components/timeline.d.ts +18 -0
- package/dist/components/timeline.js +11 -0
- package/dist/components/todo-strip.d.ts +14 -0
- package/dist/components/todo-strip.js +11 -0
- package/dist/components/tooltip.d.ts +7 -0
- package/dist/components/tooltip.js +16 -0
- package/dist/components/top-bar.d.ts +23 -0
- package/dist/components/top-bar.js +14 -0
- package/dist/components/type-ahead.d.ts +20 -0
- package/dist/components/type-ahead.js +22 -0
- package/dist/components/unit-card.d.ts +26 -0
- package/dist/components/unit-card.js +18 -0
- package/dist/components/view-toggle.d.ts +20 -0
- package/dist/components/view-toggle.js +15 -0
- package/dist/components/wizard-footer.d.ts +24 -0
- package/dist/components/wizard-footer.js +17 -0
- package/dist/components/wizard-header.d.ts +29 -0
- package/dist/components/wizard-header.js +18 -0
- package/dist/hooks/use-mobile.d.ts +1 -0
- package/dist/hooks/use-mobile.js +11 -0
- package/dist/index.d.ts +70 -0
- package/dist/index.js +70 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.js +5 -0
- package/dist/sample-banners.d.ts +8 -0
- package/dist/sample-banners.js +28 -0
- package/dist/tokens.css +119 -0
- package/dist/tokens.json +50 -0
- package/package.json +60 -4
- package/README.md +0 -3
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useLayoutEffect, useEffect, useRef, useState } from "react";
|
|
3
|
+
import Tilt from "react-parallax-tilt";
|
|
4
|
+
import Barcode from "react-barcode";
|
|
5
|
+
import { IconCheck } from "@tabler/icons-react";
|
|
6
|
+
import { AdminDrawer } from "./admin-drawer";
|
|
7
|
+
import { SavingIndicator } from "./saving-indicator";
|
|
8
|
+
import { cardThemes, resolveCardTheme } from "../card-themes";
|
|
9
|
+
import "./member-card.css";
|
|
10
|
+
const memoryStore = new Map();
|
|
11
|
+
/** Module-level singleton: the load effect keys on this object, so a fresh instance per render would refetch forever. */
|
|
12
|
+
const memoryCardThemePreference = {
|
|
13
|
+
read: (memberId) => Promise.resolve(memoryStore.get(memberId) ?? null),
|
|
14
|
+
save: (memberId, id) => {
|
|
15
|
+
memoryStore.set(memberId, id);
|
|
16
|
+
return Promise.resolve();
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
const LABELS = {
|
|
20
|
+
id: {
|
|
21
|
+
brand: "PPI Jepang",
|
|
22
|
+
chip: "Aktif",
|
|
23
|
+
chipExpiring: "Berakhir {date}",
|
|
24
|
+
chipGrace: "Masa tenggang",
|
|
25
|
+
chipExpired: "Kedaluwarsa",
|
|
26
|
+
chipSuspended: "Ditangguhkan",
|
|
27
|
+
pending: "Perubahan menunggu persetujuan",
|
|
28
|
+
flipToBack: "Balik kartu untuk menampilkan barcode",
|
|
29
|
+
flipToFront: "Kembali ke depan kartu",
|
|
30
|
+
barcode: "Barcode",
|
|
31
|
+
download: "Unduh",
|
|
32
|
+
downloading: "Menyiapkan...",
|
|
33
|
+
downloadDone: "Kartu disimpan sebagai gambar.",
|
|
34
|
+
downloadFailed: "Kartu belum bisa disimpan. Coba lagi.",
|
|
35
|
+
changeTheme: "Ubah tema",
|
|
36
|
+
themeTitle: "Ubah tema kartu",
|
|
37
|
+
themeHint: "Pilih tampilan yang Anda suka. Tersimpan di akun Anda dan berlaku di semua perangkat. Tema tidak mengubah keanggotaan Anda.",
|
|
38
|
+
themeSaveError: "Gagal menyimpan. Pilihan bertahan untuk sesi ini; pilih lagi untuk mencoba ulang.",
|
|
39
|
+
theme: "Tema kartu",
|
|
40
|
+
themeAuto: "Otomatis · sesuai korda",
|
|
41
|
+
themeAutoShort: "Otomatis",
|
|
42
|
+
themeGroup: { korda: "Korda Jepang", ppij: "PPI Jepang", seasons: "Empat musim Jepang", nusantara: "Nusantara" },
|
|
43
|
+
motto: "Membuka Dunia untuk Indonesia dan Membuka Indonesia untuk Dunia",
|
|
44
|
+
barcodeHint: "Tunjukkan ke pengurus untuk dipindai",
|
|
45
|
+
graceBack: "Masa tenggang sampai {date}. Perpanjang untuk memakai barcode.",
|
|
46
|
+
expiredBack: "Keanggotaan telah berakhir. Perpanjang untuk memakai barcode.",
|
|
47
|
+
suspendedBack: "Barcode dinonaktifkan selama keanggotaan ditangguhkan.",
|
|
48
|
+
unitLabel: "Unit",
|
|
49
|
+
validLabel: "Berlaku s.d.",
|
|
50
|
+
endedLabel: "Berakhir",
|
|
51
|
+
},
|
|
52
|
+
en: {
|
|
53
|
+
brand: "PPI Japan",
|
|
54
|
+
chip: "Active",
|
|
55
|
+
chipExpiring: "Ends {date}",
|
|
56
|
+
chipGrace: "Grace period",
|
|
57
|
+
chipExpired: "Expired",
|
|
58
|
+
chipSuspended: "Suspended",
|
|
59
|
+
pending: "Change awaiting approval",
|
|
60
|
+
flipToBack: "Flip the card to show the barcode",
|
|
61
|
+
flipToFront: "Flip the card back to the front",
|
|
62
|
+
barcode: "Barcode",
|
|
63
|
+
download: "Download",
|
|
64
|
+
downloading: "Preparing...",
|
|
65
|
+
downloadDone: "Card saved as an image.",
|
|
66
|
+
downloadFailed: "The card could not be saved. Try again.",
|
|
67
|
+
changeTheme: "Change theme",
|
|
68
|
+
themeTitle: "Change card theme",
|
|
69
|
+
themeHint: "Choose a look you like. Saved to your account and used on every device. Themes do not change your membership.",
|
|
70
|
+
themeSaveError: "Saving failed. Your choice stays for this session; pick again to retry.",
|
|
71
|
+
theme: "Card theme",
|
|
72
|
+
themeAuto: "Automatic · your korda",
|
|
73
|
+
themeAutoShort: "Automatic",
|
|
74
|
+
themeGroup: { korda: "Japan regions", ppij: "PPI Japan", seasons: "Four seasons in Japan", nusantara: "Nusantara" },
|
|
75
|
+
motto: "Membuka Dunia untuk Indonesia dan Membuka Indonesia untuk Dunia",
|
|
76
|
+
barcodeHint: "Show this to pengurus to scan",
|
|
77
|
+
graceBack: "Grace period until {date}. Renew to use the barcode.",
|
|
78
|
+
expiredBack: "Membership has ended. Renew to use the barcode.",
|
|
79
|
+
suspendedBack: "The barcode is off while the membership is suspended.",
|
|
80
|
+
unitLabel: "Unit",
|
|
81
|
+
validLabel: "Valid to",
|
|
82
|
+
endedLabel: "Ended",
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
const MAX_X = 10;
|
|
86
|
+
const MAX_Y = 14;
|
|
87
|
+
const CARD_WIDTH = 350;
|
|
88
|
+
/** The download sheet is 398 px wide (CSS) and is captured at 3x. */
|
|
89
|
+
const SHEET_PIXEL_RATIO = 3;
|
|
90
|
+
const CARD_CLASS = {
|
|
91
|
+
active: "mc-active",
|
|
92
|
+
expiring: "mc-expiring",
|
|
93
|
+
change_pending: "mc-active",
|
|
94
|
+
expired_grace: "mc-grace",
|
|
95
|
+
expired: "mc-expired",
|
|
96
|
+
suspended: "mc-suspended",
|
|
97
|
+
};
|
|
98
|
+
/** Only the states with a valid membership show the barcode. */
|
|
99
|
+
export const hasBarcode = (state) => state === "active" || state === "expiring" || state === "change_pending";
|
|
100
|
+
const INTL_LOCALE = { id: "id-ID", en: "en-GB" };
|
|
101
|
+
/** Day and short month, e.g. "31 Mar" (chip). Year added for the validity line, e.g. "31 Mar 2027". */
|
|
102
|
+
function shortDate(value, locale, withYear) {
|
|
103
|
+
if (!value)
|
|
104
|
+
return "-";
|
|
105
|
+
const date = new Date(`${value}T00:00:00+09:00`);
|
|
106
|
+
if (Number.isNaN(date.getTime()))
|
|
107
|
+
return "-";
|
|
108
|
+
return new Intl.DateTimeFormat(INTL_LOCALE[locale], {
|
|
109
|
+
timeZone: "Asia/Tokyo",
|
|
110
|
+
day: "numeric",
|
|
111
|
+
month: "short",
|
|
112
|
+
...(withYear ? { year: "numeric" } : {}),
|
|
113
|
+
}).format(date);
|
|
114
|
+
}
|
|
115
|
+
/** Unit line: "Sendai · PPI Kanto". The stored unit names carry type prefixes ("Komsat Sendai");
|
|
116
|
+
* the card shows the real names without them. A korda member without komsat shows just the korda. */
|
|
117
|
+
function unitLine(p) {
|
|
118
|
+
const komsat = p.komsat?.replace(/^Komsat\s+/, "") ?? "";
|
|
119
|
+
return p.komsat ? `${komsat} · ${p.korda}` : p.korda;
|
|
120
|
+
}
|
|
121
|
+
function chipText(state, p, l) {
|
|
122
|
+
switch (state) {
|
|
123
|
+
case "active":
|
|
124
|
+
case "change_pending":
|
|
125
|
+
return l.chip;
|
|
126
|
+
case "expiring":
|
|
127
|
+
return l.chipExpiring.replace("{date}", shortDate(p.validUntil, p.locale, false));
|
|
128
|
+
case "expired_grace":
|
|
129
|
+
return l.chipGrace;
|
|
130
|
+
case "expired":
|
|
131
|
+
return l.chipExpired;
|
|
132
|
+
case "suspended":
|
|
133
|
+
return l.chipSuspended;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function backNote(state, p, l) {
|
|
137
|
+
switch (state) {
|
|
138
|
+
case "expired_grace":
|
|
139
|
+
return l.graceBack.replace("{date}", shortDate(p.graceUntil, p.locale, true));
|
|
140
|
+
case "expired":
|
|
141
|
+
return l.expiredBack;
|
|
142
|
+
case "suspended":
|
|
143
|
+
return l.suspendedBack;
|
|
144
|
+
default:
|
|
145
|
+
return "";
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/** Front face: logo, chip, name, number, unit line and validity. */
|
|
149
|
+
function Front(p) {
|
|
150
|
+
const l = LABELS[p.locale];
|
|
151
|
+
const state = p.state;
|
|
152
|
+
const ended = state === "expired" || state === "expired_grace";
|
|
153
|
+
return (_jsxs("div", { className: `mc-face mc-front ${CARD_CLASS[state]}`, "data-theme": p.theme?.id, style: { "--mc-base": p.theme?.base }, children: [p.theme && !p.artworkFailed ? (_jsx("svg", { className: "mc-art", viewBox: p.theme.viewBox, preserveAspectRatio: "xMidYMid meet", "aria-hidden": "true", focusable: "false", children: _jsx("image", { href: p.theme.asset, width: p.theme.width, height: p.theme.height, onError: p.onArtworkError }) })) : null, _jsx("div", { className: "mc-shine", "aria-hidden": "true", style: p.shineStyle }), _jsxs("div", { className: "mc-row", children: [_jsx("img", { className: "mc-logo", src: p.logoSrc, alt: l.brand, width: 92, height: 63 }), _jsx("span", { className: "mc-chip", children: chipText(state, p, l) })] }), _jsxs("div", { className: "mc-id", children: [_jsx("span", { className: "mc-name", children: p.name }), state === "suspended" ? (_jsx("span", { className: "mc-note", children: p.suspendReason ?? "" })) : (_jsx("span", { className: "mc-number", children: p.number })), state === "change_pending" ? _jsx("span", { className: "mc-note", children: l.pending }) : null] }), _jsxs("div", { className: "mc-row mc-foot", children: [_jsxs("div", { className: "mc-col", children: [_jsx("span", { className: "mc-label", children: l.unitLabel }), _jsx("span", { className: "mc-val", children: unitLine(p) })] }), state !== "suspended" && p.validUntil ? (_jsxs("div", { className: "mc-col mc-right", children: [_jsx("span", { className: "mc-label", children: ended ? l.endedLabel : l.validLabel }), _jsx("span", { className: "mc-val", children: shortDate(p.validUntil, p.locale, true) })] })) : null] })] }));
|
|
154
|
+
}
|
|
155
|
+
/** Back face: motto, barcode of the membership number, printed number, hint and decorative map. */
|
|
156
|
+
function Back(p) {
|
|
157
|
+
const l = LABELS[p.locale];
|
|
158
|
+
const state = p.state;
|
|
159
|
+
return (_jsxs("div", { className: `mc-face mc-back ${CARD_CLASS[state]}`, children: [_jsx("div", { className: "mc-shine", "aria-hidden": "true", style: p.shineStyle }), state !== "suspended" ? _jsx("img", { className: "mc-map", src: p.mapSrc, alt: "", "aria-hidden": "true" }) : null, _jsx("div", { className: "mc-stripe", children: _jsx("span", { children: l.motto }) }), _jsx("div", { className: "mc-codewrap", children: hasBarcode(state) ? (_jsxs(_Fragment, { children: [_jsx("div", { className: "mc-quiet", children: _jsx(Barcode, { value: p.number, format: "CODE128", width: 1.25, height: 58, displayValue: false, margin: 0, background: "#ffffff", lineColor: "#000000" }) }), _jsx("span", { className: "mc-number mc-small", children: p.number }), _jsx("span", { className: "mc-hint", children: l.barcodeHint })] })) : (_jsx("span", { className: "mc-hint mc-backnote", children: backNote(state, p, l) })) })] }));
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Phone tilt follows the change in orientation from the pose the phone is held in. Android and desktop
|
|
163
|
+
* browsers deliver the events with no prompt; iOS needs a prompt, so it is skipped by user agent and the
|
|
164
|
+
* touch-drag tilt of the library is the fallback. The permission API is never called.
|
|
165
|
+
*/
|
|
166
|
+
const isIOS = () => typeof navigator !== "undefined" &&
|
|
167
|
+
(/iP(hone|ad|od)/.test(navigator.userAgent) || (navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1));
|
|
168
|
+
const sensorWithoutPrompt = () => typeof window !== "undefined" && "DeviceOrientationEvent" in window && !isIOS();
|
|
169
|
+
const clamp = (n, lo, hi) => Math.min(Math.max(n, lo), hi);
|
|
170
|
+
const reduceMotion = () => typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
171
|
+
/** The tilting, flipping card. One button: click, tap, Enter and Space flip it. */
|
|
172
|
+
function MemberCardFace(props) {
|
|
173
|
+
const { name, flipped, onFlip } = props;
|
|
174
|
+
const l = LABELS[props.locale];
|
|
175
|
+
const still = reduceMotion();
|
|
176
|
+
const [shine, setShine] = useState({ x: 25, y: 15 });
|
|
177
|
+
const [gyro, setGyro] = useState(null);
|
|
178
|
+
const frame = useRef(0);
|
|
179
|
+
const fitRef = useRef(null);
|
|
180
|
+
const [scale, setScale] = useState(1);
|
|
181
|
+
// The card is drawn at 350 px and scaled as a whole on narrow screens, so nothing reflows.
|
|
182
|
+
useLayoutEffect(() => {
|
|
183
|
+
const el = fitRef.current;
|
|
184
|
+
if (!el)
|
|
185
|
+
return;
|
|
186
|
+
const fit = () => setScale(Math.min(1, el.clientWidth / CARD_WIDTH));
|
|
187
|
+
fit();
|
|
188
|
+
const ro = new ResizeObserver(fit);
|
|
189
|
+
ro.observe(el);
|
|
190
|
+
return () => ro.disconnect();
|
|
191
|
+
}, []);
|
|
192
|
+
useEffect(() => {
|
|
193
|
+
if (still || !sensorWithoutPrompt())
|
|
194
|
+
return;
|
|
195
|
+
let base = null;
|
|
196
|
+
const onOrient = (e) => {
|
|
197
|
+
if (e.beta == null || e.gamma == null)
|
|
198
|
+
return;
|
|
199
|
+
base ??= { b: e.beta, g: e.gamma };
|
|
200
|
+
base.b += (e.beta - base.b) * 0.03;
|
|
201
|
+
base.g += (e.gamma - base.g) * 0.03;
|
|
202
|
+
const x = clamp(-(e.beta - base.b) * 0.6, -MAX_X, MAX_X);
|
|
203
|
+
const y = clamp((e.gamma - base.g) * 0.6, -MAX_Y, MAX_Y);
|
|
204
|
+
cancelAnimationFrame(frame.current);
|
|
205
|
+
frame.current = requestAnimationFrame(() => {
|
|
206
|
+
setGyro({ x, y });
|
|
207
|
+
setShine({ x: Math.round(50 + (y / MAX_Y) * 45), y: Math.round(50 - (x / MAX_X) * 45) });
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
window.addEventListener("deviceorientation", onOrient);
|
|
211
|
+
return () => {
|
|
212
|
+
window.removeEventListener("deviceorientation", onOrient);
|
|
213
|
+
cancelAnimationFrame(frame.current);
|
|
214
|
+
};
|
|
215
|
+
}, [still]);
|
|
216
|
+
// Each face carries its own shine so it turns with the card (the library's glare layer does not).
|
|
217
|
+
const shineStyle = still
|
|
218
|
+
? undefined
|
|
219
|
+
: {
|
|
220
|
+
background: `radial-gradient(circle at ${shine.x}% ${shine.y}%, rgba(255,255,255,0.5), rgba(255,255,255,0) 40%), radial-gradient(circle at ${100 - shine.x}% ${100 - shine.y}%, rgba(120,128,138,0.08), rgba(120,128,138,0) 60%)`,
|
|
221
|
+
};
|
|
222
|
+
const flipLabel = flipped ? l.flipToFront : l.flipToBack;
|
|
223
|
+
return (_jsx("div", { ref: fitRef, className: "mc-fit", style: { height: (221 + 28) * scale }, children: _jsxs("button", { type: "button", className: "mc-hit", style: { transform: `scale(${scale})`, transformOrigin: "top left" }, "aria-pressed": flipped, onClick: () => onFlip(!flipped), onPointerMove: (e) => {
|
|
224
|
+
if (still)
|
|
225
|
+
return;
|
|
226
|
+
const r = e.currentTarget.getBoundingClientRect();
|
|
227
|
+
setShine({
|
|
228
|
+
x: Math.round(((e.clientX - r.left) / r.width) * 100),
|
|
229
|
+
y: Math.round(((e.clientY - r.top) / r.height) * 100),
|
|
230
|
+
});
|
|
231
|
+
}, onPointerLeave: () => setShine({ x: 25, y: 15 }), children: [_jsx("span", { className: "mc-sr-only", children: `${name}. ${flipLabel}` }), _jsx(Tilt, { className: "mc-tilt", tiltEnable: !still, tiltMaxAngleX: MAX_X, tiltMaxAngleY: MAX_Y, perspective: 900, glareEnable: false, gyroscope: false, tiltAngleXManual: gyro ? gyro.x : null, tiltAngleYManual: gyro ? gyro.y : null, scale: 1.02, children: _jsxs("div", { className: `mc-flip${flipped ? " is-flipped" : ""}`, children: [_jsx("div", { className: "mc-face-wrap mc-front-wrap", inert: flipped, "aria-hidden": flipped, children: _jsx(Front, { ...props, shineStyle: shineStyle }) }), _jsx("div", { className: "mc-face-wrap mc-back-wrap", inert: !flipped, "aria-hidden": !flipped, children: _jsx(Back, { ...props, shineStyle: shineStyle }) })] }) })] }) }));
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* The member card with its actions. "Barcode" and the tap on the card share one flip state.
|
|
235
|
+
* Buttons appear only while a barcode is available (ACTIVE, expiring, change pending).
|
|
236
|
+
*/
|
|
237
|
+
export function MemberCardBlock(props) {
|
|
238
|
+
return _jsx(MemberCardContent, { ...props }, props.memberId);
|
|
239
|
+
}
|
|
240
|
+
/** One selectable theme preview: the real clipped artwork on its base, with a labelled selected state. */
|
|
241
|
+
function ThemeTile({ locale, theme, selected, onPick }) {
|
|
242
|
+
const l = LABELS[locale];
|
|
243
|
+
return (_jsxs("button", { type: "button", role: "radio", "aria-checked": selected, "data-theme-id": theme?.id ?? null, onClick: onPick, className: `mc-tile${selected ? " mc-tile-on" : ""}`, children: [theme ? (_jsx("span", { className: "mc-thumb", style: { background: theme.base }, "aria-hidden": "true", children: _jsx("svg", { viewBox: theme.viewBox, preserveAspectRatio: "xMidYMid meet", "aria-hidden": "true", focusable: "false", children: _jsx("image", { href: theme.asset, width: theme.width, height: theme.height }) }) })) : (_jsx("span", { className: "mc-thumb mc-thumb-auto", "aria-hidden": "true", children: l.themeAutoShort })), _jsx("span", { className: "mc-tile-label", children: theme ? (locale === "id" ? theme.labelId : theme.labelEn) : l.themeAuto }), selected ? _jsx(IconCheck, { className: "mc-tile-check", "aria-hidden": "true" }) : null] }));
|
|
244
|
+
}
|
|
245
|
+
function MemberCardContent(props) {
|
|
246
|
+
const { locale, state, memberId } = props;
|
|
247
|
+
const l = LABELS[locale];
|
|
248
|
+
// Server preference: korda default renders immediately, the saved choice applies when the
|
|
249
|
+
// read resolves, and saving shows the shared autosave indicator. A failed save keeps the
|
|
250
|
+
// in-session choice with a recoverable error.
|
|
251
|
+
const [pref, setPref] = useState({ value: null, loaded: false });
|
|
252
|
+
const [saveState, setSaveState] = useState("idle");
|
|
253
|
+
const preference = props.themePreference ?? memoryCardThemePreference;
|
|
254
|
+
useEffect(() => {
|
|
255
|
+
let alive = true;
|
|
256
|
+
preference.read(memberId)
|
|
257
|
+
.then((value) => { if (alive)
|
|
258
|
+
setPref({ value, loaded: true }); })
|
|
259
|
+
.catch(() => { if (alive)
|
|
260
|
+
setPref((old) => ({ ...old, loaded: true })); });
|
|
261
|
+
return () => { alive = false; };
|
|
262
|
+
}, [memberId, preference]);
|
|
263
|
+
const selected = pref.loaded ? pref.value : null;
|
|
264
|
+
const [themeOpen, setThemeOpen] = useState(false);
|
|
265
|
+
const pickTheme = (id) => {
|
|
266
|
+
setPref({ value: id, loaded: true });
|
|
267
|
+
setSaveState("saving");
|
|
268
|
+
preference.save(memberId, id)
|
|
269
|
+
.then(() => setSaveState("saved"))
|
|
270
|
+
.catch(() => setSaveState("error"));
|
|
271
|
+
};
|
|
272
|
+
const theme = resolveCardTheme(props.korda, selected);
|
|
273
|
+
const [failedTheme, setFailedTheme] = useState(null);
|
|
274
|
+
const artworkFailed = failedTheme === theme.id;
|
|
275
|
+
const faceProps = { ...props, theme, artworkFailed, onArtworkError: () => setFailedTheme(theme.id) };
|
|
276
|
+
const [flipped, setFlipped] = useState(false);
|
|
277
|
+
const [busy, setBusy] = useState(false);
|
|
278
|
+
const [msg, setMsg] = useState(null);
|
|
279
|
+
const sheet = useRef(null);
|
|
280
|
+
async function download() {
|
|
281
|
+
if (!sheet.current || busy)
|
|
282
|
+
return;
|
|
283
|
+
setBusy(true);
|
|
284
|
+
setMsg(null);
|
|
285
|
+
try {
|
|
286
|
+
// Preload the selected artwork before cloning either face. A failed image becomes a plain card.
|
|
287
|
+
if (!artworkFailed) {
|
|
288
|
+
const loaded = await new Promise((resolve) => {
|
|
289
|
+
const img = new Image();
|
|
290
|
+
const timer = window.setTimeout(() => finish(false), 5000);
|
|
291
|
+
function finish(ok) { window.clearTimeout(timer); img.onload = null; img.onerror = null; resolve(ok); }
|
|
292
|
+
img.onload = () => finish(true);
|
|
293
|
+
img.onerror = () => finish(false);
|
|
294
|
+
img.src = theme.asset;
|
|
295
|
+
});
|
|
296
|
+
if (!loaded) {
|
|
297
|
+
setFailedTheme(theme.id);
|
|
298
|
+
await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(() => resolve())));
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
// Loaded on the first tap only, so the library is not part of the first load of Beranda.
|
|
302
|
+
const { toBlob } = await import("html-to-image");
|
|
303
|
+
const blob = await toBlob(sheet.current, {
|
|
304
|
+
pixelRatio: SHEET_PIXEL_RATIO,
|
|
305
|
+
cacheBust: true,
|
|
306
|
+
imagePlaceholder: `data:image/svg+xml;charset=utf-8,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>')}`,
|
|
307
|
+
backgroundColor: "#f6f6f4",
|
|
308
|
+
});
|
|
309
|
+
if (!blob)
|
|
310
|
+
throw new Error("empty image");
|
|
311
|
+
const url = URL.createObjectURL(blob);
|
|
312
|
+
const a = document.createElement("a");
|
|
313
|
+
a.href = url;
|
|
314
|
+
a.download = "kartu-anggota-ppij.png";
|
|
315
|
+
document.body.appendChild(a);
|
|
316
|
+
a.click();
|
|
317
|
+
a.remove();
|
|
318
|
+
setTimeout(() => URL.revokeObjectURL(url), 10_000);
|
|
319
|
+
setMsg({ ok: true, text: l.downloadDone });
|
|
320
|
+
}
|
|
321
|
+
catch {
|
|
322
|
+
setMsg({ ok: false, text: l.downloadFailed });
|
|
323
|
+
}
|
|
324
|
+
finally {
|
|
325
|
+
setBusy(false);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
return (_jsxs("div", { className: "mc-block", "data-card-state": state, children: [_jsx(MemberCardFace, { ...faceProps, flipped: flipped, onFlip: setFlipped }), hasBarcode(state) ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: "mc-actions", children: [_jsx("button", { type: "button", className: "mc-btn mc-btn-primary", "aria-pressed": flipped, onClick: () => setFlipped(!flipped), children: l.barcode }), _jsx("button", { type: "button", className: "mc-btn", disabled: busy, onClick: download, children: busy ? l.downloading : l.download }), _jsx("button", { type: "button", className: "mc-btn", "aria-haspopup": "dialog", "aria-expanded": themeOpen, onClick: () => setThemeOpen(true), children: l.changeTheme })] }), _jsx("p", { className: `mc-msg${msg && !msg.ok ? " mc-msg-err" : ""}`, role: "status", "aria-live": "polite", children: msg?.text }), _jsx("div", { className: "mc-sheet-wrap", "aria-hidden": "true", children: _jsxs("div", { className: "mc-sheet", ref: sheet, children: [_jsx(Front, { ...faceProps }), _jsx(Back, { ...faceProps })] }) })] })) : null, _jsxs(AdminDrawer, { open: themeOpen, onOpenChange: setThemeOpen, locale: locale, title: l.themeTitle, description: l.themeHint, children: [_jsx("div", { className: "mb-3 flex justify-end", children: _jsx(SavingIndicator, { status: saveState, locale: locale, errorText: l.themeSaveError }) }), _jsxs("div", { role: "radiogroup", "aria-label": l.theme, className: "mc-theme-grid", children: [_jsx(ThemeTile, { locale: locale, theme: null, selected: selected === null, onPick: () => pickTheme(null) }), ["korda", "ppij", "seasons", "nusantara"].map((group) => (_jsxs("div", { className: "mc-theme-group", children: [_jsx("h3", { children: l.themeGroup[group] }), _jsx("div", { className: "mc-theme-tiles", children: cardThemes.filter((item) => item.group === group).map((item) => (_jsx(ThemeTile, { locale: locale, theme: item, selected: selected === item.id, onPick: () => pickTheme(item.id) }, item.id))) })] }, group)))] })] })] }));
|
|
329
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/* Member card (openspec/changes/revamp-member-card). Values follow reference/styles.css; the flip is CSS, not react-card-flip. */
|
|
2
|
+
|
|
3
|
+
.mc-fit { width:100%; max-width:350px; margin:0 auto; }
|
|
4
|
+
.mc-hit { all:unset; display:block; width:350px; height:221px; cursor:pointer; border-radius:16px; margin:14px 0; touch-action:pan-y; -webkit-tap-highlight-color:transparent; }
|
|
5
|
+
.mc-hit:focus-visible { outline:2px solid var(--brand-red, #c8102e); outline-offset:4px; }
|
|
6
|
+
.mc-tilt { width:350px; height:221px; border-radius:16px; }
|
|
7
|
+
.mc-tilt > div, .mc-flip { width:350px; height:221px; }
|
|
8
|
+
.mc-flip { position:relative; border-radius:16px; transform-style:preserve-3d; transition:transform .6s; }
|
|
9
|
+
.mc-flip.is-flipped { transform:rotateY(180deg); }
|
|
10
|
+
.mc-face-wrap { position:absolute; left:0; top:0; width:350px; height:221px; border-radius:16px; backface-visibility:hidden; -webkit-backface-visibility:hidden; }
|
|
11
|
+
.mc-back-wrap { transform:rotateY(180deg); }
|
|
12
|
+
@media (prefers-reduced-motion: reduce) { .mc-flip { transition:none; } }
|
|
13
|
+
|
|
14
|
+
.mc-face { box-shadow:0 26px 30px -14px rgba(28,31,35,.4); position:relative; overflow:hidden; width:350px; height:221px; border-radius:16px; border:1px solid #e3e5e8; padding:20px; display:flex; flex-direction:column; justify-content:space-between; color:#1c1f23;
|
|
15
|
+
background: repeating-linear-gradient(45deg, rgba(28,31,35,.028) 0 1px, transparent 1px 6px), linear-gradient(135deg,#fff 0%,#f1f2f4 100%); }
|
|
16
|
+
/* Artwork has its own clipped viewport; it cannot enter the name column or footer. */
|
|
17
|
+
.mc-front { background:var(--mc-base, #fff); }
|
|
18
|
+
.mc-art { position:absolute; left:64%; top:23%; width:31%; height:47%; overflow:hidden; pointer-events:none; }
|
|
19
|
+
.mc-front .mc-id { position:absolute; left:20px; top:98px; width:calc(64% - 24px); gap:3px; }
|
|
20
|
+
.mc-front .mc-name { height:40px; font-size:17px; line-height:20px; text-wrap:wrap; }
|
|
21
|
+
.mc-front .mc-number { font-size:12px; line-height:15px; }
|
|
22
|
+
.mc-front .mc-note { font-size:11px; line-height:11px; max-height:22px; display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:hidden; overflow-wrap:anywhere; }
|
|
23
|
+
.mc-front .mc-foot { position:absolute; left:20px; right:20px; bottom:14px; height:36px; gap:8px; }
|
|
24
|
+
.mc-front .mc-col:first-child { min-width:0; flex:1; }
|
|
25
|
+
.mc-front .mc-right { flex:0 0 92px; }
|
|
26
|
+
.mc-front .mc-label { font-size:10px; line-height:11px; }
|
|
27
|
+
.mc-front .mc-val { font-size:11.5px; line-height:12px; overflow-wrap:anywhere; display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:hidden; }
|
|
28
|
+
.mc-front.mc-grace, .mc-front.mc-expired { background:#eceded; }
|
|
29
|
+
.mc-grace .mc-art, .mc-expired .mc-art { filter:grayscale(1); opacity:.5; }
|
|
30
|
+
.mc-front.mc-suspended { background:#fef2f2; }
|
|
31
|
+
.mc-suspended .mc-art { display:none; }
|
|
32
|
+
.mc-theme-grid { display:grid; gap:20px; }
|
|
33
|
+
.mc-theme-group h3 { margin:0 0 8px; font-size:13px; font-weight:600; color:#1c1f23; }
|
|
34
|
+
.mc-theme-tiles { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
|
|
35
|
+
@media (min-width:480px) { .mc-theme-tiles { grid-template-columns:repeat(3,minmax(0,1fr)); } }
|
|
36
|
+
.mc-tile { position:relative; display:grid; gap:6px; padding:6px; border:1px solid #e3e5e8; border-radius:10px; background:#fff; cursor:pointer; font:inherit; text-align:left; }
|
|
37
|
+
.mc-tile:hover { border-color:#c9ccd1; }
|
|
38
|
+
.mc-tile:focus-visible { outline:2px solid #c8102e; outline-offset:2px; }
|
|
39
|
+
.mc-tile-on { border-color:#c8102e; box-shadow:0 0 0 1px #c8102e; }
|
|
40
|
+
.mc-thumb { display:block; aspect-ratio:350/221; border-radius:6px; overflow:hidden; }
|
|
41
|
+
.mc-thumb svg { display:block; width:100%; height:100%; }
|
|
42
|
+
.mc-thumb-auto { display:grid; place-items:center; background:#f5f5f4; color:#5b6168; font-size:12px; font-weight:600; }
|
|
43
|
+
.mc-tile-label { font-size:12px; line-height:1.35; color:#1c1f23; overflow-wrap:anywhere; }
|
|
44
|
+
.mc-tile-check { position:absolute; top:12px; right:12px; width:18px; height:18px; color:#c8102e; background:#fff; border-radius:50%; padding:2px; }
|
|
45
|
+
|
|
46
|
+
.mc-row { position:relative; z-index:1; display:flex; justify-content:space-between; align-items:flex-start; }
|
|
47
|
+
.mc-logo { width:92px; height:63px; object-fit:contain; display:block; }
|
|
48
|
+
.mc-chip { margin-top:2px; font-size:12px; font-weight:700; background:#047857; color:#fff; border-radius:6px; padding:4px 10px; }
|
|
49
|
+
.mc-id { position:relative; z-index:1; display:flex; flex-direction:column; gap:4px; margin-top:14px; }
|
|
50
|
+
.mc-name { height:48px; font-size:20px; font-weight:700; line-height:1.2; display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:hidden; overflow-wrap:anywhere; text-wrap:balance; }
|
|
51
|
+
.mc-number { font-family:ui-monospace,Menlo,monospace; font-size:15px; letter-spacing:.08em; }
|
|
52
|
+
.mc-note { font-size:14px; line-height:1.4; }
|
|
53
|
+
.mc-foot { align-items:flex-end; }
|
|
54
|
+
.mc-col { display:flex; flex-direction:column; gap:2px; }
|
|
55
|
+
.mc-right { text-align:right; }
|
|
56
|
+
.mc-label { font-size:11px; letter-spacing:.04em; color:#5b6168; }
|
|
57
|
+
.mc-val { font-size:14px; font-weight:600; }
|
|
58
|
+
|
|
59
|
+
.mc-expiring .mc-chip { background:#fcd34d; color:#451a03; }
|
|
60
|
+
.mc-grace, .mc-expired { background:linear-gradient(135deg,#eceded,#dfe1e3); color:#4a5057; }
|
|
61
|
+
.mc-expired .mc-chip { background:#4a5057; }
|
|
62
|
+
.mc-grace .mc-chip { background:#fcd34d; color:#451a03; }
|
|
63
|
+
.mc-grace .mc-label, .mc-expired .mc-label { color:#4a5057; }
|
|
64
|
+
.mc-grace .mc-logo, .mc-expired .mc-logo { filter:grayscale(1); opacity:.65; }
|
|
65
|
+
.mc-suspended { background:#fef2f2; border-color:#fecaca; color:#7f1d1d; }
|
|
66
|
+
.mc-suspended .mc-chip { background:#7f1d1d; }
|
|
67
|
+
.mc-suspended .mc-label { color:#7f1d1d; }
|
|
68
|
+
.mc-suspended .mc-logo { filter:grayscale(1); opacity:.6; }
|
|
69
|
+
|
|
70
|
+
.mc-back { padding:0; justify-content:flex-start; }
|
|
71
|
+
.mc-map { position:absolute; left:50%; top:66px; width:372px; height:auto; transform:translateX(-50%); opacity:.17; pointer-events:none; user-select:none; }
|
|
72
|
+
.mc-stripe { position:relative; z-index:1; height:40px; margin-top:18px; background:#1c1f23; color:#fff; display:flex; align-items:center; padding:0 20px; font-size:10.5px; font-weight:600; line-height:1.35; letter-spacing:.03em; text-wrap:balance; }
|
|
73
|
+
.mc-codewrap { position:relative; z-index:1; flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:6px; padding:0 16px 12px; text-align:center; }
|
|
74
|
+
.mc-quiet { background:#fff; padding:8px 14px; border-radius:6px; line-height:0; box-shadow:0 1px 0 rgba(28,31,35,.06), 0 6px 14px -8px rgba(28,31,35,.35); }
|
|
75
|
+
.mc-small { font-size:13px; }
|
|
76
|
+
.mc-hint { font-size:12px; color:#5b6168; }
|
|
77
|
+
.mc-suspended .mc-hint { color:#7f1d1d; }
|
|
78
|
+
.mc-shine { position:absolute; left:0; top:0; right:0; bottom:0; z-index:0; pointer-events:none; border-radius:16px; }
|
|
79
|
+
.mc-backnote { max-width:260px; font-size:13px; line-height:1.4; }
|
|
80
|
+
|
|
81
|
+
.mc-sr-only { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); clip-path:inset(50%); white-space:nowrap; }
|
|
82
|
+
.mc-block { width:100%; max-width:350px; margin:0 auto; }
|
|
83
|
+
.mc-actions { display:flex; gap:8px; margin-top:4px; }
|
|
84
|
+
.mc-btn { flex:1; min-height:44px; padding:0 12px; border-radius:8px; border:1px solid #e3e5e8; background:#fff; color:#1c1f23; font:600 14px inherit; cursor:pointer; }
|
|
85
|
+
.mc-btn:disabled { opacity:.6; cursor:progress; }
|
|
86
|
+
.mc-btn-primary { background:#c8102e; border-color:#c8102e; color:#fff; }
|
|
87
|
+
.mc-btn:focus-visible { outline:2px solid #c8102e; outline-offset:2px; }
|
|
88
|
+
.mc-msg { min-height:20px; margin:8px 0 0; font-size:13px; color:#047857; text-align:center; }
|
|
89
|
+
.mc-msg-err { color:#b91c1c; }
|
|
90
|
+
.mc-sheet-wrap { position:fixed; left:-10000px; top:0; pointer-events:none; }
|
|
91
|
+
.mc-sheet { width:398px; padding:24px 24px 44px; box-sizing:border-box; background:#f6f6f4; display:flex; flex-direction:column; gap:36px; }
|
|
92
|
+
@media (min-width:768px) { .mc-block { margin:0; } }
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type MemberCardTheme = "red" | "ink";
|
|
3
|
+
export interface MemberCardProps {
|
|
4
|
+
name: string;
|
|
5
|
+
memberId: string;
|
|
6
|
+
komsat: string;
|
|
7
|
+
affiliation?: string;
|
|
8
|
+
validUntil: string;
|
|
9
|
+
statusLabel: string;
|
|
10
|
+
statusVariant?: "default" | "secondary" | "destructive" | "outline";
|
|
11
|
+
validLabel?: string;
|
|
12
|
+
theme?: MemberCardTheme;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Presentation pattern for the PPIJ member card face.
|
|
17
|
+
* Display data arrives as props; issuing, verification, and card state
|
|
18
|
+
* logic stay in the application. The interactive card in the portal
|
|
19
|
+
* (flip, tilt, live barcode) builds on this face.
|
|
20
|
+
*/
|
|
21
|
+
export declare function MemberCard({ name, memberId, komsat, affiliation, validUntil, statusLabel, statusVariant, validLabel, theme, className, }: MemberCardProps): React.JSX.Element;
|
|
22
|
+
export interface MemberCardBackProps {
|
|
23
|
+
memberId: string;
|
|
24
|
+
note: string;
|
|
25
|
+
barcodeLabel?: string;
|
|
26
|
+
className?: string;
|
|
27
|
+
}
|
|
28
|
+
/** Back face: deterministic presentation bars derived from the member id. */
|
|
29
|
+
export declare function MemberCardBack({ memberId, note, barcodeLabel, className }: MemberCardBackProps): React.JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../lib/utils";
|
|
3
|
+
import { Badge } from "./badge";
|
|
4
|
+
/**
|
|
5
|
+
* Presentation pattern for the PPIJ member card face.
|
|
6
|
+
* Display data arrives as props; issuing, verification, and card state
|
|
7
|
+
* logic stay in the application. The interactive card in the portal
|
|
8
|
+
* (flip, tilt, live barcode) builds on this face.
|
|
9
|
+
*/
|
|
10
|
+
export function MemberCard({ name, memberId, komsat, affiliation, validUntil, statusLabel, statusVariant = "secondary", validLabel = "Berlaku hingga", theme = "red", className, }) {
|
|
11
|
+
return (_jsxs("div", { "data-slot": "member-card", className: cn("relative flex aspect-[1.586] w-full max-w-[420px] flex-col justify-between overflow-hidden rounded-2xl p-5 text-white shadow-md", theme === "red"
|
|
12
|
+
? "bg-gradient-to-br from-[#e11436] via-brand-red to-[#8f0c22]"
|
|
13
|
+
: "bg-gradient-to-br from-[#2a2e33] via-brand-ink to-black", className), children: [_jsxs("div", { className: "flex items-start justify-between gap-3", children: [_jsxs("div", { children: [_jsx("p", { className: "text-[11px] font-bold tracking-[0.18em]", children: "PPI JEPANG" }), _jsx("p", { className: "text-[10px] text-white/75", children: "Kartu Anggota" })] }), _jsx(Badge, { variant: statusVariant, children: statusLabel })] }), _jsxs("div", { className: "grid gap-1", children: [_jsx("p", { className: "truncate text-lg leading-tight font-bold", children: name }), _jsx("p", { className: "font-mono text-sm tracking-widest text-white/90", children: memberId }), _jsxs("div", { className: "mt-1 flex items-end justify-between gap-3 text-[11px] text-white/80", children: [_jsx("span", { className: "min-w-0", children: _jsxs("span", { className: "block truncate", children: [komsat, affiliation ? ` · ${affiliation}` : ""] }) }), _jsxs("span", { className: "shrink-0 text-right", children: [_jsx("span", { className: "block text-[9px] tracking-wider uppercase", children: validLabel }), _jsx("span", { className: "text-xs font-semibold text-white", children: validUntil })] })] })] })] }));
|
|
14
|
+
}
|
|
15
|
+
/** Back face: deterministic presentation bars derived from the member id. */
|
|
16
|
+
export function MemberCardBack({ memberId, note, barcodeLabel = "Nomor anggota", className }) {
|
|
17
|
+
const bars = Array.from(memberId.replace(/\D/g, "") || "0").map((ch, i) => {
|
|
18
|
+
const w = (Number(ch) % 3) + 1;
|
|
19
|
+
return _jsx("span", { style: { width: w }, className: "inline-block h-full bg-brand-ink" }, i);
|
|
20
|
+
});
|
|
21
|
+
return (_jsxs("div", { "data-slot": "member-card-back", className: cn("flex aspect-[1.586] w-full max-w-[420px] flex-col justify-between overflow-hidden rounded-2xl bg-[#f1f1ec] p-5 text-brand-ink shadow-md", className), children: [_jsx("div", { className: "h-8 rounded bg-brand-ink" }), _jsxs("div", { children: [_jsx("p", { className: "mb-1 text-[10px] tracking-wider text-brand-muted uppercase", children: barcodeLabel }), _jsx("div", { className: "flex h-12 items-stretch gap-[2px] bg-white p-1.5", children: bars }), _jsx("p", { className: "mt-1 text-center font-mono text-xs tracking-[0.3em]", children: memberId })] }), _jsx("p", { className: "text-[10px] leading-snug text-brand-muted", children: note })] }));
|
|
22
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface MonthPickerProps {
|
|
2
|
+
/** Group label; the two menus are meaningless apart. */
|
|
3
|
+
label: string;
|
|
4
|
+
/** Wire value "YYYY-MM"; either part may still be empty while the member is choosing. */
|
|
5
|
+
value: string;
|
|
6
|
+
onChange: (value: string) => void;
|
|
7
|
+
locale?: "id" | "en";
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Month and year entry (WIZ106-09), extracted from the wizard: two
|
|
12
|
+
* Selects, named months plus a year, in a 1.35fr / 1fr grid. The
|
|
13
|
+
* native month input is deliberately not used (WebKit-hostile). The
|
|
14
|
+
* composed "YYYY-MM" wire format never changes.
|
|
15
|
+
*/
|
|
16
|
+
export declare function MonthPicker({ label, value, onChange, locale, className }: MonthPickerProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../lib/utils";
|
|
3
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./select";
|
|
4
|
+
const MONTHS_ID = ["Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"];
|
|
5
|
+
const MONTHS_EN = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
6
|
+
/**
|
|
7
|
+
* Month and year entry (WIZ106-09), extracted from the wizard: two
|
|
8
|
+
* Selects, named months plus a year, in a 1.35fr / 1fr grid. The
|
|
9
|
+
* native month input is deliberately not used (WebKit-hostile). The
|
|
10
|
+
* composed "YYYY-MM" wire format never changes.
|
|
11
|
+
*/
|
|
12
|
+
export function MonthPicker({ label, value, onChange, locale = "id", className }) {
|
|
13
|
+
const [year = "", month = ""] = value ? value.split("-") : [];
|
|
14
|
+
const months = locale === "en" ? MONTHS_EN : MONTHS_ID;
|
|
15
|
+
const [monthWord, yearWord] = locale === "en" ? ["Month", "Year"] : ["Bulan", "Tahun"];
|
|
16
|
+
const years = Array.from({ length: new Date().getFullYear() - 1989 + 15 }, (_, i) => String(1990 + i)).reverse();
|
|
17
|
+
const compose = (y, m) => (y || m ? `${y}-${m}` : "");
|
|
18
|
+
return (_jsxs("div", { role: "group", "aria-label": label, className: cn("min-w-0 w-full", className), children: [_jsx("p", { className: "mb-2 text-sm font-medium text-brand-ink", children: label }), _jsxs("div", { className: "grid w-full grid-cols-[minmax(0,1.35fr)_minmax(0,1fr)] gap-2", children: [_jsxs(Select, { value: month || "", onValueChange: (next) => onChange(compose(year, next)), children: [_jsx(SelectTrigger, { "aria-label": `${label}: ${monthWord}`, className: "min-h-11 w-full min-w-0 bg-card", children: _jsx(SelectValue, { placeholder: monthWord }) }), _jsx(SelectContent, { position: "popper", align: "start", avoidCollisions: false, className: "max-h-72", children: months.map((name, i) => (_jsx(SelectItem, { value: String(i + 1).padStart(2, "0"), children: name }, name))) })] }), _jsxs(Select, { value: year || "", onValueChange: (next) => onChange(compose(next, month)), children: [_jsx(SelectTrigger, { "aria-label": `${label}: ${yearWord}`, className: "min-h-11 w-full min-w-0 bg-card", children: _jsx(SelectValue, { placeholder: yearWord }) }), _jsx(SelectContent, { position: "popper", align: "start", avoidCollisions: false, className: "max-h-72", children: years.map((y) => (_jsx(SelectItem, { value: y, children: y }, y))) })] })] })] }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface OfflineBannerProps {
|
|
2
|
+
/** Rendered only when true; the consumer owns the online check (the app uses its useOnline hook). */
|
|
3
|
+
show?: boolean;
|
|
4
|
+
/** Defaults to the app's id string; pass the en string or any label to override. */
|
|
5
|
+
label?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Offline banner, extracted exactly from ppij-identity-sso
|
|
9
|
+
* portal/OfflineBanner.tsx: an amber strip under the header (it sits
|
|
10
|
+
* in PortalShell's banner slot) shown while the browser reports no
|
|
11
|
+
* network. Copy: "Tidak ada koneksi. Data Anda tersimpan." /
|
|
12
|
+
* "No connection. Your data is saved."
|
|
13
|
+
*/
|
|
14
|
+
export declare function OfflineBanner({ show, label }: OfflineBannerProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { IconWifiOff } from "@tabler/icons-react";
|
|
3
|
+
/**
|
|
4
|
+
* Offline banner, extracted exactly from ppij-identity-sso
|
|
5
|
+
* portal/OfflineBanner.tsx: an amber strip under the header (it sits
|
|
6
|
+
* in PortalShell's banner slot) shown while the browser reports no
|
|
7
|
+
* network. Copy: "Tidak ada koneksi. Data Anda tersimpan." /
|
|
8
|
+
* "No connection. Your data is saved."
|
|
9
|
+
*/
|
|
10
|
+
export function OfflineBanner({ show = true, label = "Tidak ada koneksi. Data Anda tersimpan." }) {
|
|
11
|
+
if (!show)
|
|
12
|
+
return null;
|
|
13
|
+
return (_jsx("div", { role: "status", className: "border-b border-amber-300 bg-amber-50 text-amber-900", children: _jsxs("p", { className: "mx-auto flex max-w-2xl items-center gap-2 px-4 py-2 text-sm font-semibold", children: [_jsx(IconWifiOff, { className: "size-4 shrink-0", "aria-hidden": "true" }), label] }) }));
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface PageHeaderProps {
|
|
3
|
+
title: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
eyebrow?: string;
|
|
6
|
+
actions?: React.ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Admin page header pattern, following the portal admin convention:
|
|
11
|
+
* a 2xl bold ink title, a muted description, and actions on the right
|
|
12
|
+
* that wrap under the title on narrow screens.
|
|
13
|
+
*/
|
|
14
|
+
export declare function PageHeader({ title, description, eyebrow, actions, className }: PageHeaderProps): React.JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../lib/utils";
|
|
3
|
+
/**
|
|
4
|
+
* Admin page header pattern, following the portal admin convention:
|
|
5
|
+
* a 2xl bold ink title, a muted description, and actions on the right
|
|
6
|
+
* that wrap under the title on narrow screens.
|
|
7
|
+
*/
|
|
8
|
+
export function PageHeader({ title, description, eyebrow, actions, className }) {
|
|
9
|
+
return (_jsxs("div", { className: cn("flex flex-wrap items-start justify-between gap-3", className), children: [_jsxs("div", { className: "min-w-0", children: [eyebrow ? (_jsx("p", { className: "mb-1 text-[11px] font-bold tracking-[0.14em] text-brand-red uppercase", children: eyebrow })) : null, _jsx("h1", { className: "text-2xl leading-tight font-bold text-brand-ink", children: title }), description ? _jsx("p", { className: "mt-1 max-w-prose text-sm text-brand-muted", children: description }) : null] }), actions ? _jsx("div", { className: "flex shrink-0 flex-wrap items-center gap-2", children: actions }) : null] }));
|
|
10
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* The curated calling codes from the portal PhoneField (WIZ106-14):
|
|
4
|
+
* Japan and Indonesia pinned under "Sering dipakai", the rest under
|
|
5
|
+
* "Negara lain". Entries are [code, ISO, Indonesian name, English name].
|
|
6
|
+
*/
|
|
7
|
+
export declare const PHONE_COUNTRY_CODES: ReadonlyArray<readonly [code: string, iso: string, idName: string, enName: string]>;
|
|
8
|
+
export interface PhoneFieldProps {
|
|
9
|
+
id?: string;
|
|
10
|
+
/** Composed value, for example "+81 90-1234-5678". Empty means no number yet. */
|
|
11
|
+
value: string;
|
|
12
|
+
onChange: (value: string) => void;
|
|
13
|
+
/** Prefix assumed when the stored value carries none: +81 for the member, +62 for the emergency contact. */
|
|
14
|
+
defaultCode?: string;
|
|
15
|
+
locale?: "id" | "en";
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Phone entry, extracted from the wizard PhoneField: a grouped
|
|
20
|
+
* country-code Select (104px, showing "JP +81") paired with the
|
|
21
|
+
* national number input. The pair composes one stored string,
|
|
22
|
+
* "+81 90-1234-5678". Both controls are field height (44px); the
|
|
23
|
+
* label is composed by the parent like every other field.
|
|
24
|
+
*/
|
|
25
|
+
export declare function PhoneField({ id, value, onChange, defaultCode, locale, className }: PhoneFieldProps): React.JSX.Element;
|