@suphark/ui 0.21.0 → 0.22.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/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/components/shared/auth-parts.tsx +19 -8
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
รูปแบบตาม [Keep a Changelog](https://keepachangelog.com/) · semver: patch = หน้าตา/บั๊ก, minor = component/prop ใหม่, major = เปลี่ยน/ลบ props
|
|
4
4
|
|
|
5
|
+
## [0.22.0] — 2026-10-02
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `ProviderButtons`: prop `text` ต่อ provider (ข้อความเต็มของปุ่มแทน "ดำเนินการต่อด้วย {label}" เช่น ชื่อ SSO ยาว "Estar (Microsoft 365)"); ปุ่มเต็มกว้าง (1 ตัว / `layout="list"`) **ขึ้นบรรทัดใหม่แทนตัดเป็น …** (badge ไม่หด); ตาราง 2 คอลัมน์ยังตัด แต่ `aria-label`/`title` เป็นข้อความเต็ม — ขอจาก Pi Auth
|
|
10
|
+
- showcase: demo `/components/auth-layout` ปุ่ม SSO ใช้ `text` ยาว
|
|
11
|
+
|
|
5
12
|
## [0.21.0] — 2026-10-02
|
|
6
13
|
|
|
7
14
|
ตัวสำเร็จรูปของ primitive ใหม่จาก shadcn (0.20.0) — เพิ่มอย่างเดียว
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suphark/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Design system กลางของ Suphark apps: shadcn/ui (base-nova, Base UI, Tailwind v4) + shared components + token/ฟอนต์ Noto Sans Thai Looped — ส่งเป็น source ให้แอป Next transpile เอง",
|
|
@@ -31,6 +31,8 @@ export interface AuthProvider {
|
|
|
31
31
|
id: string;
|
|
32
32
|
/** ชื่อ provider เช่น "Google" — ปุ่มแสดง "ดำเนินการต่อด้วย Google" (UiText.auth.continueWith) */
|
|
33
33
|
label: string;
|
|
34
|
+
/** ข้อความเต็มของปุ่มแทน "ดำเนินการต่อด้วย {label}" (ทุก layout) เช่น "Estar (Microsoft 365)" */
|
|
35
|
+
text?: ReactNode;
|
|
34
36
|
/** โลโก้ของ provider (svg) */
|
|
35
37
|
icon?: ReactNode;
|
|
36
38
|
onClick?: () => void;
|
|
@@ -45,6 +47,7 @@ export interface AuthProvider {
|
|
|
45
47
|
* ปุ่มเข้าสู่ระบบด้วย provider (Google / Microsoft / SSO ขององค์กร)
|
|
46
48
|
* 1 ตัว = ปุ่มเต็มกว้างพร้อมข้อความ · 2 ตัวขึ้นไป = ตาราง 2 คอลัมน์ (`layout="list"` บังคับเรียงลงพร้อมข้อความเต็ม)
|
|
47
49
|
* `pendingId` = ตัวที่กำลังพาไป (ปุ่มนั้นหมุน ตัวอื่นปิด กันกดซ้ำ)
|
|
50
|
+
* ปุ่มเต็มกว้าง (1 ตัว / list) ข้อความยาวขึ้นบรรทัดใหม่ได้ ไม่ตัดทิ้ง · ตาราง 2 คอลัมน์ตัดด้วย … (ชื่อเต็มอยู่ใน aria-label/title)
|
|
48
51
|
*/
|
|
49
52
|
export function ProviderButtons({
|
|
50
53
|
providers,
|
|
@@ -62,26 +65,33 @@ export function ProviderButtons({
|
|
|
62
65
|
return (
|
|
63
66
|
<div className={cn("grid gap-2", grid ? "grid-cols-2" : "grid-cols-1", className)}>
|
|
64
67
|
{providers.map((p) => {
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
const full = (text?.continueWith ?? "ดำเนินการต่อด้วย {provider}").replace(
|
|
69
|
+
"{provider}",
|
|
70
|
+
p.label,
|
|
71
|
+
);
|
|
72
|
+
const label = p.text ?? (grid ? p.label : full);
|
|
68
73
|
const content = (
|
|
69
74
|
<>
|
|
70
75
|
{p.icon}
|
|
71
|
-
<span className="truncate">{label}</span>
|
|
72
|
-
{p.badge &&
|
|
76
|
+
<span className={grid ? "truncate" : "min-w-0 text-balance"}>{label}</span>
|
|
77
|
+
{p.badge && (
|
|
78
|
+
<span className="ml-auto shrink-0 text-label text-muted-foreground">{p.badge}</span>
|
|
79
|
+
)}
|
|
73
80
|
</>
|
|
74
81
|
);
|
|
82
|
+
// ปุ่มเต็มกว้าง: ให้ข้อความยาวขึ้นบรรทัดใหม่ได้ (Button ตั้ง whitespace-nowrap + h-8)
|
|
83
|
+
const buttonClass = grid ? "w-full" : "h-auto min-h-8 w-full py-1.5 whitespace-normal";
|
|
84
|
+
const a11y = grid ? { "aria-label": full, title: full } : {};
|
|
75
85
|
const busy = pendingId === p.id;
|
|
76
86
|
const disabled = p.disabled || (pendingId != null && !busy);
|
|
77
87
|
return p.href ? (
|
|
78
88
|
<Button
|
|
79
89
|
key={p.id}
|
|
80
90
|
variant="outline"
|
|
81
|
-
className=
|
|
91
|
+
className={buttonClass}
|
|
82
92
|
disabled={disabled}
|
|
83
93
|
nativeButton={false}
|
|
84
|
-
render={<a href={p.href}
|
|
94
|
+
render={<a href={p.href} {...a11y} />}
|
|
85
95
|
>
|
|
86
96
|
{content}
|
|
87
97
|
</Button>
|
|
@@ -90,8 +100,9 @@ export function ProviderButtons({
|
|
|
90
100
|
key={p.id}
|
|
91
101
|
type="button"
|
|
92
102
|
variant="outline"
|
|
93
|
-
className=
|
|
103
|
+
className={buttonClass}
|
|
94
104
|
disabled={disabled || busy}
|
|
105
|
+
{...a11y}
|
|
95
106
|
onClick={p.onClick}
|
|
96
107
|
>
|
|
97
108
|
{content}
|