@goplusvn/core 0.1.84 → 0.1.85

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 CHANGED
@@ -1,3 +1,39 @@
1
+ ## 0.1.85 — Hộp thoại: gỡ bẫy class `sm:` khiến trang không ghi đè được
2
+
3
+ Sửa lỗi giao diện do 0.1.84 gây ra. `DialogContent` đổi mặc định thành
4
+ `p-4 sm:p-6` và `sm:max-w-lg`; `cn()` là `twMerge` mà twMerge **chỉ khử xung đột
5
+ trong cùng một variant**, nên `sm:p-6` / `sm:max-w-lg` sống sót khi trang truyền
6
+ `p-0` / `max-w-2xl`, rồi thắng ở ≥640px vì nằm trong media query.
7
+
8
+ Hậu quả trên app đã nâng (thingtodo): mọi hộp thoại CRUD bị bóp từ 672px xuống
9
+ 512px, cộng thêm 24px padding thừa nên đường kẻ header/footer thụt vào không
10
+ chạm mép, và nút X mặc định của Radix lộ ra (trước đó bị header sticky che).
11
+
12
+ **Đổi**
13
+
14
+ - `ui/primitives/dialog.tsx` — `p-4 sm:p-6` → `p-6`; `sm:max-w-lg` → `max-w-lg`;
15
+ bỏ `max-w-[calc(100%-2rem)]` thừa. Giữ nguyên phần chống tràn của 0.1.84
16
+ (`max-h-[calc(100dvh-2rem)]`, `overscroll-contain`, `w-[calc(100%-2rem)] sm:w-full`)
17
+ vì chúng không xung đột với class trang truyền vào.
18
+ - `ui/feedback/index.tsx` — `AlertDialogContent` dính đúng bẫy đó, sửa y hệt.
19
+ LƯU Ý cho app đang dùng: hộp thoại khai `max-w-sm` / `max-w-md` **không**
20
+ prefix từ nay hẹp đúng như đã khai, thay vì bị `sm:max-w-lg` kéo lên 512px.
21
+ - `crud/components/crud-dialog.tsx` — `formWidth` từng nội suy
22
+ `` max-w-${...} ``: Tailwind quét class TĨNH nên class đó không bao giờ được
23
+ sinh ra. Thay bằng bảng ánh xạ tĩnh. Thêm `w-full` (tràn viền trên điện thoại,
24
+ đi cùng `h-[100vh] rounded-none`) và ẩn tường minh nút X bằng
25
+ `[&>button.absolute]:hidden` — trước đây nó chỉ *vô tình* bị header che.
26
+ Đóng bằng "Huỷ" hoặc Esc; footer sticky nên "Huỷ" luôn thấy.
27
+ - `crud/components/crud-detail-dialog.tsx` — thêm `w-full` cho nhất quán.
28
+
29
+ **Quy tắc rút ra**: class mặc định trong primitive mà trang có thể muốn ghi đè
30
+ thì PHẢI để dạng không prefix. Muốn khác nhau theo bề rộng màn hình thì đặt ở
31
+ phía trang, đừng đặt ở mặc định.
32
+
33
+ Đã dựng thật với `core:link`: vinhhoa (từ 0.1.78) và tanloc-spartronics
34
+ (từ 0.1.83) `type-check` + `next build` đều xanh; không mất API công khai, không
35
+ đòi cột/bảng DB mới.
36
+
1
37
  # Changelog
2
38
 
3
39
  ## 0.1.81 — Cây workspace kiểu explorer, xoá/khôi phục lộ ra, thêm thành viên bằng dialog
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@goplusvn/core",
3
3
  "description": "GoPlusVN Platform Kit - ERP kernel: layout, RBAC, CRUD, multi-tenant, system pages",
4
- "version": "0.1.84",
4
+ "version": "0.1.85",
5
5
  "private": false,
6
6
  "publishConfig": {
7
7
  "registry": "https://registry.npmjs.org",
@@ -269,7 +269,7 @@ export function CrudDetailDialog({
269
269
 
270
270
  return (
271
271
  <Dialog open={open} onOpenChange={onOpenChange} modal={true}>
272
- <DialogContent className="max-w-2xl max-h-[90vh] sm:max-h-[90vh] h-[100vh] sm:h-auto rounded-none sm:rounded-lg overflow-hidden flex flex-col p-0 gap-0">
272
+ <DialogContent className="w-full max-w-2xl max-h-[90vh] sm:max-h-[90vh] h-[100vh] sm:h-auto rounded-none sm:rounded-lg overflow-hidden flex flex-col p-0 gap-0">
273
273
  {/* Header */}
274
274
  <DialogHeader className="bg-background border-b px-4 sm:px-6 pt-4 sm:pt-6 pb-3 sm:pb-4 text-left space-y-0 shrink-0">
275
275
  <div className="flex items-center gap-2 sm:gap-3 min-w-0">
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { useEffect, useRef, useState } from "react";
4
4
  import { CheckCircle2, Loader2 } from "lucide-react";
5
+ import { cn } from "../../utils";
5
6
 
6
7
  import type { EntityConfig } from "../../types";
7
8
 
@@ -16,6 +17,22 @@ import { DynamicIcon } from "../../ui";
16
17
  import { CrudForm } from "./crud-form";
17
18
  import { useCrudConfig } from "./crud-context";
18
19
 
20
+ // Tailwind quét class TĨNH — `max-w-${...}` sẽ KHÔNG được sinh ra, hộp thoại
21
+ // mất luôn giới hạn bề rộng. Phải liệt kê nguyên chuỗi.
22
+ const FORM_WIDTH_CLASS: Record<
23
+ NonNullable<EntityConfig["formWidth"]>,
24
+ string
25
+ > = {
26
+ sm: "max-w-sm",
27
+ md: "max-w-md",
28
+ lg: "max-w-lg",
29
+ xl: "max-w-xl",
30
+ "2xl": "max-w-2xl",
31
+ "3xl": "max-w-3xl",
32
+ "4xl": "max-w-4xl",
33
+ "5xl": "max-w-5xl",
34
+ };
35
+
19
36
  interface CrudDialogProps {
20
37
  open: boolean;
21
38
  onOpenChange: (open: boolean) => void;
@@ -192,7 +209,16 @@ export function CrudDialog({
192
209
  return (
193
210
  <Dialog open={open} onOpenChange={onOpenChange} modal={true}>
194
211
  <DialogContent
195
- className="max-w-2xl max-h-[90vh] sm:max-h-[90vh] h-[100vh] sm:h-auto rounded-none sm:rounded-lg overflow-hidden flex flex-col p-0"
212
+ className={cn(
213
+ // `w-full` là CỐ Ý: ghi đè mặc định `w-[calc(100%-2rem)]` của
214
+ // DialogContent để hộp thoại tràn viền trên điện thoại (đi cùng
215
+ // h-[100vh] + rounded-none), desktop vẫn bị max-w-* chặn lại.
216
+ "w-full max-h-[90vh] sm:max-h-[90vh] h-[100vh] sm:h-auto rounded-none sm:rounded-lg overflow-hidden flex flex-col p-0",
217
+ // Header dính (sticky z-10, nền đục) che mất nút X mặc định của
218
+ // Radix — ẩn hẳn cho tường minh. Đóng bằng "Huỷ" hoặc Esc.
219
+ "[&>button.absolute]:hidden",
220
+ FORM_WIDTH_CLASS[config.formWidth ?? "2xl"],
221
+ )}
196
222
  onInteractOutside={(e) => {
197
223
  // Prevent closing dialog when submitting or clicking on Popover
198
224
  if (isSubmitting || showSuccess) {
@@ -484,9 +484,9 @@ export function CrudFieldRenderer({
484
484
  name={field.name}
485
485
  render={({ field: formField }) => (
486
486
  <FormItem>
487
- {field.label && <FormLabel>{field.label}</FormLabel>}
487
+ {field.label && <FormLabel className="font-semibold">{field.label}</FormLabel>}
488
488
  <FormControl>
489
- <div className="flex items-center gap-2 pt-2">
489
+ <div className="flex items-center h-10">
490
490
  <Switch
491
491
  checked={
492
492
  field.type === "switch"
@@ -336,6 +336,7 @@ export interface EntityConfig {
336
336
  codeGeneration?: CodeGenerationConfig;
337
337
  formSections?: FormSection[];
338
338
  formMode?: FormModeConfig;
339
+ formWidth?: "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl";
339
340
  rowActions?: RowAction[];
340
341
  include?: string[];
341
342
  }
@@ -89,7 +89,10 @@ export function AlertDialogContent({
89
89
  <AlertDialogPrimitive.Content
90
90
  data-slot="alert-dialog-content"
91
91
  className={cn(
92
- "fixed top-[50%] left-[50%] z-50 w-full max-w-[calc(100%_-_2rem)] grid bg-background translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-4 sm:p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:max-w-lg",
92
+ "fixed top-[50%] left-[50%] z-50 w-[calc(100%_-_2rem)] sm:w-full grid bg-background translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 max-w-lg",
93
+ // KHÔNG để `sm:p-6` / `sm:max-w-lg` làm mặc định: twMerge chỉ khử xung
94
+ // đột trong cùng variant, nên trang truyền `p-0` / `max-w-sm` sẽ bị
95
+ // class `sm:` đè ngược ở ≥640px (đúng lỗi 0.1.84 của DialogContent).
93
96
  // Cùng lý do với DialogContent: bị neo giữa màn hình nên phải chặn
94
97
  // chiều cao, không thì mô tả dài sẽ tràn ra ngoài và không cuộn được.
95
98
  "max-h-[calc(100dvh_-_2rem)] overflow-y-auto overscroll-contain",
@@ -40,7 +40,7 @@ const DialogContent = React.forwardRef<
40
40
  <DialogPrimitive.Content
41
41
  ref={ref}
42
42
  className={cn(
43
- "fixed left-[50%] top-[50%] z-50 grid translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-4 sm:p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-lg",
43
+ "fixed left-[50%] top-[50%] z-50 grid translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-lg",
44
44
  // Hộp thoại bị neo `top-1/2 -translate-y-1/2`, nên nếu KHÔNG chặn chiều
45
45
  // cao thì nội dung cao hơn màn hình sẽ tràn ra CẢ trên lẫn dưới và
46
46
  // không cuộn được — hỏng trên điện thoại và trên tablet xoay ngang.
@@ -48,7 +48,12 @@ const DialogContent = React.forwardRef<
48
48
  // class của trang đứng sau trong cn() nên vẫn thắng.
49
49
  "max-h-[calc(100dvh_-_2rem)] overflow-y-auto overscroll-contain",
50
50
  // Bề rộng: chừa 1rem mỗi bên trên màn hẹp thay vì dán sát mép.
51
- "w-[calc(100%_-_2rem)] max-w-[calc(100%_-_2rem)] sm:w-full sm:max-w-lg",
51
+ // CẢNH BÁO (đã dính 0.1.84): mọi class mặc định ở đây mà trang có thể
52
+ // muốn ghi đè PHẢI để dạng KHÔNG prefix. `cn()` = twMerge chỉ khử xung
53
+ // đột trong CÙNG một variant — `sm:max-w-lg`/`sm:p-6` sẽ SỐNG SÓT khi
54
+ // trang truyền `max-w-2xl`/`p-0`, rồi thắng ở ≥640px vì nằm trong media
55
+ // query. Đó chính là lỗi bóp CrudDialog còn 512px + padding kép.
56
+ "w-[calc(100%_-_2rem)] sm:w-full max-w-lg",
52
57
  className,
53
58
  )}
54
59
  {...props}