@finhay-pro/leaf-design-system 0.2.1 → 0.2.3
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/README.md +398 -207
- package/dist/cdn/leaf-0.2.3.min.css +8 -0
- package/dist/cdn/leaf-0.2.3.min.js +204 -0
- package/dist/components/Button/Button.d.ts +2 -2
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/Button/Button.js +17 -15
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Calendar/Calendar.d.ts +2 -2
- package/dist/components/Calendar/Calendar.d.ts.map +1 -1
- package/dist/components/Calendar/Calendar.js +41 -23
- package/dist/components/Calendar/Calendar.js.map +1 -1
- package/dist/components/Carousel/Carousel.d.ts +35 -0
- package/dist/components/Carousel/Carousel.d.ts.map +1 -0
- package/dist/components/Carousel/Carousel.js +193 -0
- package/dist/components/Carousel/Carousel.js.map +1 -0
- package/dist/components/Carousel/index.d.ts +2 -0
- package/dist/components/Carousel/index.d.ts.map +1 -0
- package/dist/components/Carousel/index.js +2 -0
- package/dist/components/Carousel/index.js.map +1 -0
- package/dist/components/Checkbox/Checkbox.d.ts +2 -2
- package/dist/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/components/Checkbox/Checkbox.js +6 -3
- package/dist/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/Date/Date.d.ts +26 -0
- package/dist/components/Date/Date.d.ts.map +1 -0
- package/dist/components/Date/Date.js +26 -0
- package/dist/components/Date/Date.js.map +1 -0
- package/dist/components/Date/index.d.ts +2 -0
- package/dist/components/Date/index.d.ts.map +1 -0
- package/dist/components/Date/index.js +2 -0
- package/dist/components/Date/index.js.map +1 -0
- package/dist/components/Dialog/Dialog.d.ts +1 -2
- package/dist/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/components/Dialog/Dialog.js +2 -3
- package/dist/components/Dialog/Dialog.js.map +1 -1
- package/dist/components/Dropdown/Dropdown.d.ts +24 -10
- package/dist/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/dist/components/Dropdown/Dropdown.js +244 -37
- package/dist/components/Dropdown/Dropdown.js.map +1 -1
- package/dist/components/Empty/Empty.d.ts +27 -0
- package/dist/components/Empty/Empty.d.ts.map +1 -0
- package/dist/components/Empty/Empty.js +22 -0
- package/dist/components/Empty/Empty.js.map +1 -0
- package/dist/components/Empty/index.d.ts +2 -0
- package/dist/components/Empty/index.d.ts.map +1 -0
- package/dist/components/Empty/index.js +2 -0
- package/dist/components/Empty/index.js.map +1 -0
- package/dist/components/FileViewer/FileViewer.d.ts +63 -0
- package/dist/components/FileViewer/FileViewer.d.ts.map +1 -0
- package/dist/components/FileViewer/FileViewer.js +73 -0
- package/dist/components/FileViewer/FileViewer.js.map +1 -0
- package/dist/components/FileViewer/FileViewerDialog.d.ts +27 -0
- package/dist/components/FileViewer/FileViewerDialog.d.ts.map +1 -0
- package/dist/components/FileViewer/FileViewerDialog.js +13 -0
- package/dist/components/FileViewer/FileViewerDialog.js.map +1 -0
- package/dist/components/FileViewer/index.d.ts +4 -0
- package/dist/components/FileViewer/index.d.ts.map +1 -0
- package/dist/components/FileViewer/index.js +4 -0
- package/dist/components/FileViewer/index.js.map +1 -0
- package/dist/components/Form/DynamicForm.d.ts +52 -0
- package/dist/components/Form/DynamicForm.d.ts.map +1 -0
- package/dist/components/Form/DynamicForm.js +135 -0
- package/dist/components/Form/DynamicForm.js.map +1 -0
- package/dist/components/Form/Form.d.ts +54 -0
- package/dist/components/Form/Form.d.ts.map +1 -0
- package/dist/components/Form/Form.js +127 -0
- package/dist/components/Form/Form.js.map +1 -0
- package/dist/components/Form/adapters.d.ts +66 -0
- package/dist/components/Form/adapters.d.ts.map +1 -0
- package/dist/components/Form/adapters.js +113 -0
- package/dist/components/Form/adapters.js.map +1 -0
- package/dist/components/Form/index.d.ts +24 -0
- package/dist/components/Form/index.d.ts.map +1 -0
- package/dist/components/Form/index.js +23 -0
- package/dist/components/Form/index.js.map +1 -0
- package/dist/components/Form/useForm.d.ts +25 -0
- package/dist/components/Form/useForm.d.ts.map +1 -0
- package/dist/components/Form/useForm.js +46 -0
- package/dist/components/Form/useForm.js.map +1 -0
- package/dist/components/Input/Input.d.ts +1 -2
- package/dist/components/Input/Input.d.ts.map +1 -1
- package/dist/components/Input/Input.js +3 -4
- package/dist/components/Input/Input.js.map +1 -1
- package/dist/components/Input/InputDate.d.ts +3 -4
- package/dist/components/Input/InputDate.d.ts.map +1 -1
- package/dist/components/Input/InputDate.js +13 -6
- package/dist/components/Input/InputDate.js.map +1 -1
- package/dist/components/Input/InputOtp.d.ts +2 -2
- package/dist/components/Input/InputOtp.d.ts.map +1 -1
- package/dist/components/Input/InputOtp.js +2 -3
- package/dist/components/Input/InputOtp.js.map +1 -1
- package/dist/components/Input/InputStepper.d.ts +3 -4
- package/dist/components/Input/InputStepper.d.ts.map +1 -1
- package/dist/components/Input/InputStepper.js +4 -5
- package/dist/components/Input/InputStepper.js.map +1 -1
- package/dist/components/Logo/Logo.d.ts +2 -2
- package/dist/components/Logo/Logo.d.ts.map +1 -1
- package/dist/components/Logo/Logo.js +3 -4
- package/dist/components/Logo/Logo.js.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.d.ts +49 -0
- package/dist/components/MultiSelect/MultiSelect.d.ts.map +1 -0
- package/dist/components/MultiSelect/MultiSelect.js +285 -0
- package/dist/components/MultiSelect/MultiSelect.js.map +1 -0
- package/dist/components/MultiSelect/index.d.ts +2 -0
- package/dist/components/MultiSelect/index.d.ts.map +1 -0
- package/dist/components/MultiSelect/index.js +2 -0
- package/dist/components/MultiSelect/index.js.map +1 -0
- package/dist/components/Number/Number.d.ts +32 -0
- package/dist/components/Number/Number.d.ts.map +1 -0
- package/dist/components/Number/Number.js +43 -0
- package/dist/components/Number/Number.js.map +1 -0
- package/dist/components/Number/index.d.ts +2 -0
- package/dist/components/Number/index.d.ts.map +1 -0
- package/dist/components/Number/index.js +2 -0
- package/dist/components/Number/index.js.map +1 -0
- package/dist/components/QrCode/QrCode.d.ts +27 -0
- package/dist/components/QrCode/QrCode.d.ts.map +1 -0
- package/dist/components/QrCode/QrCode.js +44 -0
- package/dist/components/QrCode/QrCode.js.map +1 -0
- package/dist/components/QrCode/index.d.ts +3 -0
- package/dist/components/QrCode/index.d.ts.map +1 -0
- package/dist/components/QrCode/index.js +3 -0
- package/dist/components/QrCode/index.js.map +1 -0
- package/dist/components/Radio/Radio.d.ts +4 -4
- package/dist/components/Radio/Radio.d.ts.map +1 -1
- package/dist/components/Radio/Radio.js +4 -5
- package/dist/components/Radio/Radio.js.map +1 -1
- package/dist/components/Skeleton/Skeleton.d.ts +2 -2
- package/dist/components/Skeleton/Skeleton.d.ts.map +1 -1
- package/dist/components/Skeleton/Skeleton.js +2 -3
- package/dist/components/Skeleton/Skeleton.js.map +1 -1
- package/dist/components/Slider/Slider.d.ts +8 -6
- package/dist/components/Slider/Slider.d.ts.map +1 -1
- package/dist/components/Slider/Slider.js +12 -8
- package/dist/components/Slider/Slider.js.map +1 -1
- package/dist/components/Spinner/Spinner.d.ts +5 -2
- package/dist/components/Spinner/Spinner.d.ts.map +1 -1
- package/dist/components/Spinner/Spinner.js +5 -4
- package/dist/components/Spinner/Spinner.js.map +1 -1
- package/dist/components/Table/Table.d.ts +59 -0
- package/dist/components/Table/Table.d.ts.map +1 -0
- package/dist/components/Table/Table.js +274 -0
- package/dist/components/Table/Table.js.map +1 -0
- package/dist/components/Table/TableHeader.d.ts +19 -0
- package/dist/components/Table/TableHeader.d.ts.map +1 -0
- package/dist/components/Table/TableHeader.js +16 -0
- package/dist/components/Table/TableHeader.js.map +1 -0
- package/dist/components/Table/TableRow.d.ts +27 -0
- package/dist/components/Table/TableRow.d.ts.map +1 -0
- package/dist/components/Table/TableRow.js +30 -0
- package/dist/components/Table/TableRow.js.map +1 -0
- package/dist/components/Table/dom.d.ts +9 -0
- package/dist/components/Table/dom.d.ts.map +1 -0
- package/dist/components/Table/dom.js +17 -0
- package/dist/components/Table/dom.js.map +1 -0
- package/dist/components/Table/index.d.ts +2 -0
- package/dist/components/Table/index.d.ts.map +1 -0
- package/dist/components/Table/index.js +2 -0
- package/dist/components/Table/index.js.map +1 -0
- package/dist/components/Tabs/Tabs.d.ts +2 -3
- package/dist/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/components/Tabs/Tabs.js +4 -5
- package/dist/components/Tabs/Tabs.js.map +1 -1
- package/dist/components/Textarea/Textarea.d.ts +18 -0
- package/dist/components/Textarea/Textarea.d.ts.map +1 -0
- package/dist/components/Textarea/Textarea.js +41 -0
- package/dist/components/Textarea/Textarea.js.map +1 -0
- package/dist/components/Textarea/index.d.ts +2 -0
- package/dist/components/Textarea/index.d.ts.map +1 -0
- package/dist/components/Textarea/index.js +2 -0
- package/dist/components/Textarea/index.js.map +1 -0
- package/dist/components/Toast/Toast.d.ts +4 -3
- package/dist/components/Toast/Toast.d.ts.map +1 -1
- package/dist/components/Toast/Toast.js +7 -6
- package/dist/components/Toast/Toast.js.map +1 -1
- package/dist/components/Toggle/Toggle.d.ts +3 -3
- package/dist/components/Toggle/Toggle.d.ts.map +1 -1
- package/dist/components/Toggle/Toggle.js +5 -3
- package/dist/components/Toggle/Toggle.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +4 -5
- package/dist/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/components/Tooltip/Tooltip.js +10 -8
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/components/Upload/Upload.d.ts +89 -0
- package/dist/components/Upload/Upload.d.ts.map +1 -0
- package/dist/components/Upload/Upload.js +196 -0
- package/dist/components/Upload/Upload.js.map +1 -0
- package/dist/components/Upload/index.d.ts +2 -0
- package/dist/components/Upload/index.d.ts.map +1 -0
- package/dist/components/Upload/index.js +2 -0
- package/dist/components/Upload/index.js.map +1 -0
- package/dist/core/calendar.d.ts +5 -0
- package/dist/core/calendar.d.ts.map +1 -1
- package/dist/core/calendar.js +11 -0
- package/dist/core/calendar.js.map +1 -1
- package/dist/core/carousel.d.ts +42 -0
- package/dist/core/carousel.d.ts.map +1 -0
- package/dist/core/carousel.js +126 -0
- package/dist/core/carousel.js.map +1 -0
- package/dist/core/date.d.ts +46 -0
- package/dist/core/date.d.ts.map +1 -0
- package/dist/core/date.js +117 -0
- package/dist/core/date.js.map +1 -0
- package/dist/core/dialog.d.ts.map +1 -1
- package/dist/core/dialog.js +28 -2
- package/dist/core/dialog.js.map +1 -1
- package/dist/core/dropdown.d.ts +15 -2
- package/dist/core/dropdown.d.ts.map +1 -1
- package/dist/core/dropdown.js +29 -4
- package/dist/core/dropdown.js.map +1 -1
- package/dist/core/file/csv.d.ts +42 -0
- package/dist/core/file/csv.d.ts.map +1 -0
- package/dist/core/file/csv.js +159 -0
- package/dist/core/file/csv.js.map +1 -0
- package/dist/core/file/detect.d.ts +38 -0
- package/dist/core/file/detect.d.ts.map +1 -0
- package/dist/core/file/detect.js +218 -0
- package/dist/core/file/detect.js.map +1 -0
- package/dist/core/file/docx-render.d.ts +14 -0
- package/dist/core/file/docx-render.d.ts.map +1 -0
- package/dist/core/file/docx-render.js +173 -0
- package/dist/core/file/docx-render.js.map +1 -0
- package/dist/core/file/docx.d.ts +110 -0
- package/dist/core/file/docx.d.ts.map +1 -0
- package/dist/core/file/docx.js +632 -0
- package/dist/core/file/docx.js.map +1 -0
- package/dist/core/file/dom.d.ts +18 -0
- package/dist/core/file/dom.d.ts.map +1 -0
- package/dist/core/file/dom.js +57 -0
- package/dist/core/file/dom.js.map +1 -0
- package/dist/core/file/download.d.ts +26 -0
- package/dist/core/file/download.d.ts.map +1 -0
- package/dist/core/file/download.js +57 -0
- package/dist/core/file/download.js.map +1 -0
- package/dist/core/file/error.d.ts +34 -0
- package/dist/core/file/error.d.ts.map +1 -0
- package/dist/core/file/error.js +19 -0
- package/dist/core/file/error.js.map +1 -0
- package/dist/core/file/mime.d.ts +11 -0
- package/dist/core/file/mime.d.ts.map +1 -0
- package/dist/core/file/mime.js +61 -0
- package/dist/core/file/mime.js.map +1 -0
- package/dist/core/file/render.d.ts +45 -0
- package/dist/core/file/render.d.ts.map +1 -0
- package/dist/core/file/render.js +133 -0
- package/dist/core/file/render.js.map +1 -0
- package/dist/core/file/sheet-render.d.ts +30 -0
- package/dist/core/file/sheet-render.d.ts.map +1 -0
- package/dist/core/file/sheet-render.js +152 -0
- package/dist/core/file/sheet-render.js.map +1 -0
- package/dist/core/file/source.d.ts +56 -0
- package/dist/core/file/source.d.ts.map +1 -0
- package/dist/core/file/source.js +188 -0
- package/dist/core/file/source.js.map +1 -0
- package/dist/core/file/text.d.ts +9 -0
- package/dist/core/file/text.d.ts.map +1 -0
- package/dist/core/file/text.js +21 -0
- package/dist/core/file/text.js.map +1 -0
- package/dist/core/file/viewer.d.ts +160 -0
- package/dist/core/file/viewer.d.ts.map +1 -0
- package/dist/core/file/viewer.js +623 -0
- package/dist/core/file/viewer.js.map +1 -0
- package/dist/core/file/xlsx-format.d.ts +55 -0
- package/dist/core/file/xlsx-format.d.ts.map +1 -0
- package/dist/core/file/xlsx-format.js +476 -0
- package/dist/core/file/xlsx-format.js.map +1 -0
- package/dist/core/file/xlsx-write.d.ts +48 -0
- package/dist/core/file/xlsx-write.d.ts.map +1 -0
- package/dist/core/file/xlsx-write.js +219 -0
- package/dist/core/file/xlsx-write.js.map +1 -0
- package/dist/core/file/xlsx.d.ts +115 -0
- package/dist/core/file/xlsx.d.ts.map +1 -0
- package/dist/core/file/xlsx.js +402 -0
- package/dist/core/file/xlsx.js.map +1 -0
- package/dist/core/file/xml.d.ts +34 -0
- package/dist/core/file/xml.d.ts.map +1 -0
- package/dist/core/file/xml.js +102 -0
- package/dist/core/file/xml.js.map +1 -0
- package/dist/core/file/zip-write.d.ts +24 -0
- package/dist/core/file/zip-write.d.ts.map +1 -0
- package/dist/core/file/zip-write.js +131 -0
- package/dist/core/file/zip-write.js.map +1 -0
- package/dist/core/file/zip.d.ts +37 -0
- package/dist/core/file/zip.d.ts.map +1 -0
- package/dist/core/file/zip.js +195 -0
- package/dist/core/file/zip.js.map +1 -0
- package/dist/core/form.d.ts +88 -0
- package/dist/core/form.d.ts.map +1 -0
- package/dist/core/form.js +353 -0
- package/dist/core/form.js.map +1 -0
- package/dist/core/icons.d.ts +16 -0
- package/dist/core/icons.d.ts.map +1 -1
- package/dist/core/icons.js +16 -0
- package/dist/core/icons.js.map +1 -1
- package/dist/core/number.d.ts +45 -0
- package/dist/core/number.d.ts.map +1 -0
- package/dist/core/number.js +74 -0
- package/dist/core/number.js.map +1 -0
- package/dist/core/qr-code.d.ts +18 -0
- package/dist/core/qr-code.d.ts.map +1 -0
- package/dist/core/qr-code.js +702 -0
- package/dist/core/qr-code.js.map +1 -0
- package/dist/core/stepper.d.ts +6 -2
- package/dist/core/stepper.d.ts.map +1 -1
- package/dist/core/stepper.js +12 -9
- package/dist/core/stepper.js.map +1 -1
- package/dist/core/table/attrs.d.ts +65 -0
- package/dist/core/table/attrs.d.ts.map +1 -0
- package/dist/core/table/attrs.js +202 -0
- package/dist/core/table/attrs.js.map +1 -0
- package/dist/core/table/columns.d.ts +156 -0
- package/dist/core/table/columns.d.ts.map +1 -0
- package/dist/core/table/columns.js +147 -0
- package/dist/core/table/columns.js.map +1 -0
- package/dist/core/table/flash.d.ts +26 -0
- package/dist/core/table/flash.d.ts.map +1 -0
- package/dist/core/table/flash.js +84 -0
- package/dist/core/table/flash.js.map +1 -0
- package/dist/core/table/index.d.ts +10 -0
- package/dist/core/table/index.d.ts.map +1 -0
- package/dist/core/table/index.js +10 -0
- package/dist/core/table/index.js.map +1 -0
- package/dist/core/table/measure.d.ts +23 -0
- package/dist/core/table/measure.d.ts.map +1 -0
- package/dist/core/table/measure.js +54 -0
- package/dist/core/table/measure.js.map +1 -0
- package/dist/core/table/resize.d.ts +13 -0
- package/dist/core/table/resize.d.ts.map +1 -0
- package/dist/core/table/resize.js +34 -0
- package/dist/core/table/resize.js.map +1 -0
- package/dist/core/table/sort.d.ts +23 -0
- package/dist/core/table/sort.d.ts.map +1 -0
- package/dist/core/table/sort.js +71 -0
- package/dist/core/table/sort.js.map +1 -0
- package/dist/core/table/span.d.ts +31 -0
- package/dist/core/table/span.d.ts.map +1 -0
- package/dist/core/table/span.js +84 -0
- package/dist/core/table/span.js.map +1 -0
- package/dist/core/table/virtual.d.ts +29 -0
- package/dist/core/table/virtual.d.ts.map +1 -0
- package/dist/core/table/virtual.js +24 -0
- package/dist/core/table/virtual.js.map +1 -0
- package/dist/core/upload.d.ts +51 -0
- package/dist/core/upload.d.ts.map +1 -0
- package/dist/core/upload.js +114 -0
- package/dist/core/upload.js.map +1 -0
- package/dist/engine/assets.json +1 -0
- package/dist/engine/chunk-X2H56OKG.js +4854 -0
- package/dist/engine/cli.js +8 -0
- package/dist/engine/postcss.d.ts +3 -0
- package/dist/engine/postcss.js +7 -0
- package/dist/engine/vite.d.ts +3 -0
- package/dist/engine/vite.js +7 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -1
- package/dist/{styles.css → leaf.css} +2146 -153
- package/dist/skill/leaf-design-system-0.2.3.zip +0 -0
- package/dist/utils/colorClass.d.ts +24 -0
- package/dist/utils/colorClass.d.ts.map +1 -0
- package/dist/utils/colorClass.js +107 -0
- package/dist/utils/colorClass.js.map +1 -0
- package/package.json +18 -29
- package/dist/button.css +0 -214
- package/dist/calendar.css +0 -336
- package/dist/cdn/leaf-0.2.1.min.css +0 -2
- package/dist/cdn/leaf-0.2.1.min.js +0 -9
- package/dist/checkbox.css +0 -132
- package/dist/classes.css +0 -3464
- package/dist/color.css +0 -260
- package/dist/dialog.css +0 -176
- package/dist/dropdown.css +0 -303
- package/dist/input-date.css +0 -49
- package/dist/input-otp.css +0 -76
- package/dist/input-stepper.css +0 -179
- package/dist/input.css +0 -218
- package/dist/logo-assets.css +0 -81
- package/dist/logo.css +0 -52
- package/dist/radio.css +0 -124
- package/dist/skeleton.css +0 -49
- package/dist/skill/leaf-design-system-0.2.1.zip +0 -0
- package/dist/slider.css +0 -249
- package/dist/spinner.css +0 -117
- package/dist/tabs.css +0 -253
- package/dist/toast.css +0 -236
- package/dist/toggle.css +0 -116
- package/dist/tokens.css +0 -264
- package/dist/tooltip.css +0 -213
- package/dist/typography.css +0 -150
package/README.md
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
# @finhay-pro/leaf-design-system
|
|
2
2
|
|
|
3
3
|
Design system của Finhay: **2 bộ token — Color và Typography** (CSS variables trong
|
|
4
|
-
[`@finhay/leaf-tokens`](../tokens)), **class typography / màu dùng sẵn
|
|
5
|
-
HTML tĩnh dùng chung markup)
|
|
6
|
-
|
|
4
|
+
[`@finhay/leaf-tokens`](../tokens)), **class typography / màu dùng sẵn**, **component** (React +
|
|
5
|
+
HTML tĩnh dùng chung markup) và **utility layout** do engine CSS riêng của Leaf sinh ra (không
|
|
6
|
+
dependency, không cần Tailwind). Màu và chữ luôn đọc từ token; spacing / radius / độ dày viền không
|
|
7
|
+
phải token — component tự khai báo trong CSS của nó, app dùng utility px (`p-[16px]`,
|
|
8
|
+
`rounded-xl`, `border-[0.5px]`).
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
| Loại project | Cách dùng |
|
|
11
|
+
| -------------------------- | ---------------------------------------------------------------------------------------- |
|
|
12
|
+
| Next.js / Vite (có bundle) | Plugin Leaf (PostCSS / Vite) + một dòng `@import` |
|
|
13
|
+
| HTML tĩnh có bước build | CLI `leaf-css` sinh một file CSS |
|
|
14
|
+
| Landing page (CDN) | 1 `<link>` + 1 `<script>` — script sinh utility từ class trên DOM ngay trong trình duyệt |
|
|
9
15
|
|
|
10
|
-
|
|
11
|
-
| ------------------- | ------------------------------------------ | ------------------------------------- |
|
|
12
|
-
| Next.js (có bundle) | Token + class typography / màu + component | **Tailwind CSS v4** |
|
|
13
|
-
| Landing page tĩnh | Bản CDN (1 `<link>` + 1 `<script>`) | **CSS riêng của page** |
|
|
14
|
-
|
|
15
|
-
Xem [Dùng với Next.js + Tailwind](#dùng-với-nextjs--tailwind) và [HTML tĩnh (CDN)](#html-tĩnh-cdn).
|
|
16
|
+
Xem [Cài đặt](#cài-đặt), [Utility layout](#utility-layout) và [HTML tĩnh (CDN)](#html-tĩnh-cdn).
|
|
16
17
|
|
|
17
18
|
## Cài đặt
|
|
18
19
|
|
|
@@ -20,119 +21,100 @@ Xem [Dùng với Next.js + Tailwind](#dùng-với-nextjs--tailwind) và [HTML t
|
|
|
20
21
|
pnpm add @finhay-pro/leaf-design-system
|
|
21
22
|
```
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
| Import | Nội dung |
|
|
29
|
-
| -------------------------------------------------- | ---------------------------------------------------------------------------------------- |
|
|
30
|
-
| `@finhay-pro/leaf-design-system/tokens.css` | Chỉ token (primitive + semantic màu + typography), không class. |
|
|
31
|
-
| `@finhay-pro/leaf-design-system/typography.css` | Chỉ class typography. |
|
|
32
|
-
| `@finhay-pro/leaf-design-system/color.css` | Chỉ class color. |
|
|
33
|
-
| `@finhay-pro/leaf-design-system/button.css` | Style của component `Button`. |
|
|
34
|
-
| `@finhay-pro/leaf-design-system/tabs.css` | Style của component `Tabs`. |
|
|
35
|
-
| `@finhay-pro/leaf-design-system/dialog.css` | Style của component `Dialog`. |
|
|
36
|
-
| `@finhay-pro/leaf-design-system/logo.css` | Style của component `Logo`. |
|
|
37
|
-
| `@finhay-pro/leaf-design-system/logo-assets.css` | SVG data-URI cho Logo HTML tĩnh — không nằm trong `classes.css` / `styles.css`. |
|
|
38
|
-
| `@finhay-pro/leaf-design-system/skeleton.css` | Style của component `Skeleton`. |
|
|
39
|
-
| `@finhay-pro/leaf-design-system/spinner.css` | Style của component `Spinner`. |
|
|
40
|
-
| `@finhay-pro/leaf-design-system/toggle.css` | Style của component `Toggle`. |
|
|
41
|
-
| `@finhay-pro/leaf-design-system/slider.css` | Style của component `Slider`. |
|
|
42
|
-
| `@finhay-pro/leaf-design-system/tooltip.css` | Style của component `Tooltip`. |
|
|
43
|
-
| `@finhay-pro/leaf-design-system/radio.css` | Style của component `Radio` / `RadioGroup`. |
|
|
44
|
-
| `@finhay-pro/leaf-design-system/checkbox.css` | Style của component `Checkbox`. |
|
|
45
|
-
| `@finhay-pro/leaf-design-system/input.css` | Style của component `Input` (field / inline, dùng chung cho `InputDate`). |
|
|
46
|
-
| `@finhay-pro/leaf-design-system/input-otp.css` | Style của component `InputOtp`. |
|
|
47
|
-
| `@finhay-pro/leaf-design-system/input-stepper.css` | Style của component `InputStepper`. |
|
|
48
|
-
| `@finhay-pro/leaf-design-system/calendar.css` | Style của component `Calendar` (cần kèm `button.css` + `color.css`). |
|
|
49
|
-
| `@finhay-pro/leaf-design-system/input-date.css` | Popover của `InputDate` (kèm `input.css` + `calendar.css` + `button.css` + `color.css`). |
|
|
50
|
-
| `@finhay-pro/leaf-design-system/toast.css` | Style của `Toaster` / `ToastContent`. |
|
|
51
|
-
| `@finhay-pro/leaf-design-system/dropdown.css` | Style của component `Dropdown`. |
|
|
52
|
-
| `@finhay-pro/leaf-design-system/classes.css` | Tất cả class + component, không token. |
|
|
53
|
-
| `@finhay-pro/leaf-design-system/styles.css` | Token + tất cả class + component. Một dòng là đủ. |
|
|
54
|
-
|
|
55
|
-
Import bằng CSS:
|
|
24
|
+
Khai báo plugin, rồi đặt **đúng một dòng** `@import` ở file CSS gốc. Plugin thay dòng đó bằng
|
|
25
|
+
stylesheet đã tree-shake: token + reset + class typography / màu + CSS của component đang dùng
|
|
26
|
+
(nhận diện qua named import từ package hoặc class `leaf-*` trong markup) + utility layout có trong
|
|
27
|
+
source. Không còn file CSS lẻ nào khác để import.
|
|
56
28
|
|
|
57
29
|
```css
|
|
58
|
-
/*
|
|
59
|
-
@import "@finhay-pro/leaf-design-system/
|
|
60
|
-
|
|
61
|
-
/* 2. Class typography + màu */
|
|
62
|
-
@import "@finhay-pro/leaf-design-system/typography.css";
|
|
63
|
-
@import "@finhay-pro/leaf-design-system/color.css";
|
|
64
|
-
|
|
65
|
-
/* 3. Component nào dùng thì import cái đó */
|
|
66
|
-
@import "@finhay-pro/leaf-design-system/button.css";
|
|
67
|
-
@import "@finhay-pro/leaf-design-system/tabs.css";
|
|
68
|
-
@import "@finhay-pro/leaf-design-system/dialog.css";
|
|
69
|
-
@import "@finhay-pro/leaf-design-system/logo.css";
|
|
70
|
-
@import "@finhay-pro/leaf-design-system/skeleton.css";
|
|
71
|
-
@import "@finhay-pro/leaf-design-system/spinner.css";
|
|
72
|
-
@import "@finhay-pro/leaf-design-system/toggle.css";
|
|
73
|
-
@import "@finhay-pro/leaf-design-system/slider.css";
|
|
74
|
-
@import "@finhay-pro/leaf-design-system/tooltip.css";
|
|
75
|
-
@import "@finhay-pro/leaf-design-system/radio.css";
|
|
76
|
-
@import "@finhay-pro/leaf-design-system/checkbox.css";
|
|
77
|
-
@import "@finhay-pro/leaf-design-system/input.css";
|
|
78
|
-
@import "@finhay-pro/leaf-design-system/input-otp.css";
|
|
79
|
-
@import "@finhay-pro/leaf-design-system/input-stepper.css";
|
|
80
|
-
@import "@finhay-pro/leaf-design-system/calendar.css";
|
|
81
|
-
@import "@finhay-pro/leaf-design-system/input-date.css";
|
|
82
|
-
@import "@finhay-pro/leaf-design-system/toast.css";
|
|
83
|
-
@import "@finhay-pro/leaf-design-system/dropdown.css";
|
|
30
|
+
/* app/globals.css (Next.js) · src/index.css (Vite) */
|
|
31
|
+
@import "@finhay-pro/leaf-design-system/css";
|
|
84
32
|
```
|
|
85
33
|
|
|
86
|
-
|
|
34
|
+
Next.js — `postcss.config.mjs`:
|
|
87
35
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
36
|
+
```js
|
|
37
|
+
export default {
|
|
38
|
+
plugins: { "@finhay-pro/leaf-design-system/postcss": {} },
|
|
39
|
+
};
|
|
40
|
+
```
|
|
92
41
|
|
|
93
|
-
|
|
42
|
+
Vite — `vite.config.ts` (file CSS chứa `@import` được import từ `src/main.tsx`):
|
|
94
43
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
44
|
+
```ts
|
|
45
|
+
import leaf from "@finhay-pro/leaf-design-system/vite";
|
|
46
|
+
import react from "@vitejs/plugin-react";
|
|
47
|
+
import { defineConfig } from "vite";
|
|
98
48
|
|
|
99
|
-
|
|
100
|
-
|
|
49
|
+
export default defineConfig({ plugins: [react(), leaf()] });
|
|
50
|
+
```
|
|
101
51
|
|
|
102
|
-
|
|
103
|
-
@import "@finhay-pro/leaf-design-system/styles.css";
|
|
104
|
-
@import "tailwindcss";
|
|
52
|
+
HTML tĩnh không bundler — file input chứa cùng dòng `@import`:
|
|
105
53
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
54
|
+
```bash
|
|
55
|
+
npx leaf-css -i src/input.css -o dist/leaf.css [--watch] [--minify]
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Engine tự quét source từ gốc project (CLI: thư mục chạy lệnh), bỏ qua file trong `.gitignore`.
|
|
59
|
+
**Không có cấu hình**: `@theme`, `@utility`, `@variant`, `@custom-variant`, `@plugin`, `@config`,
|
|
60
|
+
`@apply`, `@source`, `@import "tailwindcss"` trong CSS của app → build báo lỗi.
|
|
61
|
+
|
|
62
|
+
## Utility layout
|
|
63
|
+
|
|
64
|
+
Cú pháp kiểu Tailwind v4, luật của Leaf (trang docs **Layout utilities** có đủ chi tiết):
|
|
65
|
+
|
|
66
|
+
- **Đơn vị luôn là px.** `rem` / `em` trong giá trị tuỳ ý bị chặn.
|
|
67
|
+
- **Không có thang số** cho padding, margin, gap, space, w / h / size, min / max, basis, inset /
|
|
68
|
+
top / left…, translate, indent, scroll-m / p, border-spacing — chỉ nhận px tuỳ ý: `p-[16px]`,
|
|
69
|
+
`gap-[24px]`, `-mt-[4px]`, `w-[300px]`, `max-w-[448px]`. Từ khoá vẫn dùng: `0`, `px`, `auto`,
|
|
70
|
+
`full`, `screen`, `dvh` / `svh` / `lvh`, `min` / `max` / `fit`, phân số `w-1/2`.
|
|
71
|
+
- **Thang có tên giữ lại (quy ra px):** `rounded-sm` (4px) / `md` (6) / `lg` (8) / `xl` (12) /
|
|
72
|
+
`2xl` (16) / `full`, `border` / `border-2`, `shadow-*`, `blur-*`, `opacity-N`, `z-N`,
|
|
73
|
+
`duration-N`, `grid-cols-N`, `order-N`, `line-clamp-N`, `aspect-*`.
|
|
74
|
+
- **Breakpoint:** `xs:` ≤ 767px (max-width), `sm:` ≥ 768, `md:` ≥ 1024, `lg:` ≥ 1280, `xl:` ≥ 1600,
|
|
75
|
+
`2xl:` ≥ 1920; kèm `max-sm:`…, `min-[640px]:`, `max-[..]:`, container query `@container` +
|
|
76
|
+
`@sm:`….
|
|
77
|
+
- **Variant:** `hover:` (`:hover` thuần), `focus:`, `focus-visible:`, `active:`, `disabled:`,
|
|
78
|
+
`group-*`, `peer-*`, `has-*`, `not-*`, `in-*`, `aria-*`, `data-*`, `first:` / `last:` / `odd:` /
|
|
79
|
+
`even:`, `before:` / `after:`, `placeholder:`, `*:`, selector tuỳ ý `[&>svg]:`, `!` important.
|
|
80
|
+
Không có `dark:` / `light:` — theme đi theo token + `data-theme`.
|
|
81
|
+
- **Chữ và màu chỉ từ class Leaf** (`display-*`, `heading-*`, `body-*`, `body-*-highlight`,
|
|
82
|
+
`text-*`, `bg-*`, `border-*`). Không có `font-*`, `text-sm`, `leading-*`, `tracking-*`,
|
|
83
|
+
`italic`, palette (`bg-red-500`, `text-white`), màu tuỳ ý (`bg-[#fff]`), cú pháp `(--biến)`,
|
|
84
|
+
utility SVG `fill-*` / `stroke-*`. Class Leaf nhận variant và độ mờ: `md:heading-1`,
|
|
85
|
+
`hover:bg-tertiary`, `bg-primary/50`, `placeholder:text-tertiary`. Utility khác cần màu nhận hậu
|
|
86
|
+
tố Leaf: `ring-*` / `outline-*` / `divide-*` / `shadow-*` / `from-*` / `via-*` / `to-*` theo
|
|
87
|
+
thang nền, `decoration-*` / `accent-*` / `caret-*` theo thang chữ.
|
|
88
|
+
|
|
89
|
+
Class không hợp luật không sinh CSS; plugin / CLI in cảnh báo kèm gợi ý:
|
|
90
|
+
|
|
91
|
+
```text
|
|
92
|
+
[leaf-css] `m-4`: Leaf không có thang số cho `m-*` — ghi giá trị px: `m-[16px]`
|
|
111
93
|
```
|
|
112
94
|
|
|
113
95
|
```tsx
|
|
114
96
|
import { Button } from "@finhay-pro/leaf-design-system";
|
|
115
97
|
|
|
116
|
-
<section className="bg-secondary border-quaternary flex flex-col gap-
|
|
117
|
-
<h3 className="heading-3 text-primary">Tích luỹ</h3>
|
|
118
|
-
<p className="body-4 text-secondary hover:text-
|
|
119
|
-
<
|
|
98
|
+
<section className="bg-secondary border-quaternary flex flex-col gap-[12px] rounded-xl border p-[16px] md:p-[24px]">
|
|
99
|
+
<h3 className="heading-3 md:heading-2 text-primary">Tích luỹ</h3>
|
|
100
|
+
<p className="body-4 text-secondary hover:text-highlight">Lợi nhuận 8.5%/năm</p>
|
|
101
|
+
<div className="w-full md:w-auto">
|
|
102
|
+
<Button width="100%">Đầu tư</Button>
|
|
103
|
+
</div>
|
|
120
104
|
</section>;
|
|
121
105
|
```
|
|
122
106
|
|
|
123
|
-
|
|
124
|
-
`border-quaternary`…). Giá trị lẻ dùng token qua cú pháp biến của Tailwind:
|
|
125
|
-
`bg-(--base-tertiary)`, `text-(color:--text-highlight)`.
|
|
126
|
-
- Spacing / radius / độ dày viền dùng thang của Tailwind (base 4px). Thang px theo Figma:
|
|
107
|
+
Thang Figma quy ra utility:
|
|
127
108
|
|
|
128
|
-
| Figma | px |
|
|
129
|
-
| ----------------- | -------------------------------------------------------- |
|
|
130
|
-
| Spacing 2XS…7XL | 2 · 4 · 8 · 12 · 16 · 24 · 36 · 48 · 60 · 84 · 120 · 240 | `
|
|
131
|
-
| Radius S/M/L/Full | 4 · 8 · 12 · full | `rounded-sm` / `rounded-lg` / `rounded-xl` / `rounded-full`
|
|
132
|
-
| Border S/M/L/XL | 0.5 · 1 · 1.5 · 2 | `border-[0.5px]` / `border` / `border-[1.5px]` / `border-2`
|
|
109
|
+
| Figma | px | Utility |
|
|
110
|
+
| ----------------- | -------------------------------------------------------- | ----------------------------------------------------------- |
|
|
111
|
+
| Spacing 2XS…7XL | 2 · 4 · 8 · 12 · 16 · 24 · 36 · 48 · 60 · 84 · 120 · 240 | `p-[2px]` … `p-[240px]` (`gap-[12px]`, `mt-[8px]`…) |
|
|
112
|
+
| Radius S/M/L/Full | 4 · 8 · 12 · full | `rounded-sm` / `rounded-lg` / `rounded-xl` / `rounded-full` |
|
|
113
|
+
| Border S/M/L/XL | 0.5 · 1 · 1.5 · 2 | `border-[0.5px]` / `border` / `border-[1.5px]` / `border-2` |
|
|
133
114
|
|
|
134
|
-
-
|
|
135
|
-
|
|
115
|
+
- Component React **không nhận `className`**. Layout / spacing: bọc `div` dùng utility. Màu / chữ:
|
|
116
|
+
prop token (`color`, `background`, `typography`). Size: prop `width` / `height` nếu component
|
|
117
|
+
có. HTML tĩnh gắn class Leaf (`text-*`, `bg-*`) trên markup `.leaf-*`.
|
|
136
118
|
|
|
137
119
|
## Typography class
|
|
138
120
|
|
|
@@ -174,13 +156,14 @@ nhau, nên một `h1` hoàn toàn có thể hiển thị bằng style `display-3
|
|
|
174
156
|
<h1 class="display-3">Finhay</h1>
|
|
175
157
|
```
|
|
176
158
|
|
|
177
|
-
Trong React / Next.js, class
|
|
159
|
+
Trong React / Next.js, class typography / màu gắn vào `className` của element HTML — **không**
|
|
160
|
+
truyền `className` vào component Leaf (dùng prop token / bọc `div`):
|
|
178
161
|
|
|
179
162
|
```tsx
|
|
180
163
|
<h2 className="heading-2">Tài sản của bạn</h2>
|
|
181
164
|
|
|
182
|
-
// Class typography lo cỡ chữ, color lo màu; khoảng cách là
|
|
183
|
-
<p className="body-3 text-secondary mt-
|
|
165
|
+
// Class typography lo cỡ chữ, color lo màu; khoảng cách là utility (`mt-[8px]`)
|
|
166
|
+
<p className="body-3 text-secondary mt-[8px]">Lợi nhuận kỳ vọng 8.5%/năm</p>
|
|
184
167
|
|
|
185
168
|
// Gắn vào component của thư viện khác cũng chỉ là một chuỗi class
|
|
186
169
|
<Link href="/tai-khoan" className="body-3-highlight">
|
|
@@ -205,8 +188,8 @@ viết thêm gì cho light mode.
|
|
|
205
188
|
| System (đủ 3 bộ) | `text-*`, `bg-*`, `border-*` với `red`, `green`, `yellow`, `orange`, `blue`, `purple` (+ `-secondary`) |
|
|
206
189
|
|
|
207
190
|
```html
|
|
208
|
-
<!-- Viền: class màu chỉ set border-color — độ dày / padding
|
|
209
|
-
<div class="bg-secondary border-quaternary
|
|
191
|
+
<!-- Viền: class màu chỉ set border-color — độ dày / padding là utility -->
|
|
192
|
+
<div class="bg-secondary border-quaternary rounded-xl border p-[16px]">
|
|
210
193
|
<h3 class="heading-3 text-primary">Tích luỹ</h3>
|
|
211
194
|
<p class="body-4 text-secondary">Lợi nhuận kỳ vọng 8.5%/năm</p>
|
|
212
195
|
<p class="body-4 text-red">Số dư không đủ</p>
|
|
@@ -248,46 +231,44 @@ Không dùng thư viện icon khác hay tự vẽ SVG icon. Icons by [Remix Icon
|
|
|
248
231
|
## Cần biết
|
|
249
232
|
|
|
250
233
|
- **Class typography chỉ set đúng 3 thuộc tính** (`font-size`, `line-height`, `font-weight`);
|
|
251
|
-
**class color chỉ set đúng 1** (`color` / `background-color` / `border-color`). Font family
|
|
252
|
-
|
|
253
|
-
(
|
|
254
|
-
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
`@layer utilities
|
|
259
|
-
|
|
260
|
-
`!important`.
|
|
261
|
-
- **Mỗi file CSS mở đầu bằng `@layer theme, base, components, utilities;`** — trùng thứ tự layer của
|
|
262
|
-
Tailwind v4, nên import file theo thứ tự nào thì class màu vẫn đứng trên CSS component. Component
|
|
263
|
-
không trông vào CSS reset: tự reset `button`, tự xử lý `[hidden]`.
|
|
264
|
-
- **Class không có biến thể `hover:` / `focus:` / opacity** — nó là CSS thuần. Cần state thì dùng
|
|
265
|
-
Tailwind (`hover:text-(color:--text-highlight)`) hoặc CSS của page với cùng token.
|
|
234
|
+
**class color chỉ set đúng 1** (`color` / `background-color` / `border-color`). Font family nằm
|
|
235
|
+
ngoài phạm vi — app tự set `body { font-family: var(--font-sans) }`. Reset tối thiểu
|
|
236
|
+
(box-sizing, margin, list, form control) có sẵn trong `@layer base`.
|
|
237
|
+
- Leaf **không** có token spacing / radius / độ dày viền — chỉ có token màu và typography; layout
|
|
238
|
+
dùng utility px.
|
|
239
|
+
- **Thứ tự layer cố định:** stylesheet sinh ra mở đầu bằng
|
|
240
|
+
`@layer properties, theme, base, components, utilities;`. Typography và CSS component nằm trong
|
|
241
|
+
`@layer components`; class màu và utility nằm trong `@layer utilities` (đè được CSS component, vd.
|
|
242
|
+
`leaf-spinner text-highlight`). CSS không layer của app override được tất cả, không cần
|
|
243
|
+
`!important`. Component không trông vào CSS reset: tự reset `button`, tự xử lý `[hidden]`.
|
|
266
244
|
- **Chỉ semantic token mới có class màu.** Primitive (`--neutral-500`, `--brand-300`…) là nguồn nội
|
|
267
|
-
bộ, dùng thẳng trong UI là mất khả năng đổi theme.
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
màu của Leaf.
|
|
273
|
-
- Typography token hiện chỉ có **bộ Desktop**. Chưa có responsive type set, nên các style Display
|
|
274
|
-
cần app tự xử lý ở breakpoint nhỏ.
|
|
245
|
+
bộ, dùng thẳng trong UI là mất khả năng đổi theme.
|
|
246
|
+
- **Tên class không có prefix.** App dùng Leaf cần cân nhắc kỹ nếu load kèm CSS framework khác
|
|
247
|
+
(Bootstrap cũng định nghĩa `.display-1`–`.display-6`).
|
|
248
|
+
- Typography token hiện chỉ có **bộ Desktop**. Display / heading lớn trên mobile: đặt class nhỏ
|
|
249
|
+
làm mặc định rồi đổi theo breakpoint (`heading-2 md:display-3`).
|
|
275
250
|
|
|
276
251
|
## Phát triển
|
|
277
252
|
|
|
278
253
|
```bash
|
|
279
|
-
pnpm --filter @finhay-pro/leaf-design-system build # tsc → dist/ + gom CSS +
|
|
280
|
-
pnpm --filter @finhay-pro/leaf-design-system dev # gom CSS + tsc --watch
|
|
254
|
+
pnpm --filter @finhay-pro/leaf-design-system build # tsc → dist/ + gom CSS + engine + CDN + skill
|
|
255
|
+
pnpm --filter @finhay-pro/leaf-design-system dev # gom CSS + engine + tsc --watch
|
|
281
256
|
pnpm --filter @finhay-pro/leaf-design-system typecheck
|
|
282
257
|
```
|
|
283
258
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
259
|
+
- `scripts/build-css.mjs` — gom token + reset + class Leaf + CSS từng component thành
|
|
260
|
+
`dist/engine/assets.json` (kèm bảng export → CSS component) và `dist/leaf.css` (đích của
|
|
261
|
+
`@finhay-pro/leaf-design-system/css`; bản dự phòng không utility).
|
|
262
|
+
- `scripts/build-engine.mjs` — bundle engine (`packages/css` = `@finhay/leaf-css`, chỉ `node:*`)
|
|
263
|
+
thành `dist/engine/vite.js`, `postcss.js`, `cli.js` (bin `leaf-css`).
|
|
264
|
+
- `scripts/build-cdn.mjs` — `dist/cdn/leaf-<version>.min.{css,js}`, minify bằng minifier của engine;
|
|
265
|
+
JS = `window.Leaf` + runtime sinh utility từ class trên DOM.
|
|
266
|
+
|
|
267
|
+
Không sửa file trong `dist`. Engine có test riêng ở `packages/css/test`.
|
|
287
268
|
|
|
288
269
|
`build` ghi đè `dist` tại chỗ, **không xoá `dist` trước** (chỉ `prepublishOnly` mới `clean`):
|
|
289
270
|
`turbo run dev` luôn build package trước docs, và nếu `dist` biến mất dù chỉ một lúc thì dev server
|
|
290
|
-
của docs lỗi resolve `@finhay-pro/leaf-design-system
|
|
271
|
+
của docs lỗi resolve `@finhay-pro/leaf-design-system/css`. Gặp lỗi đó: chạy lại `pnpm dev` (vẫn lỗi
|
|
291
272
|
thì xoá `apps/docs/node_modules/.vite`).
|
|
292
273
|
|
|
293
274
|
**Mọi hình thức nằm trong CSS** và chỉ đọc attribute (`data-*`, `aria-*`, `:disabled`), kể cả
|
|
@@ -298,14 +279,12 @@ tĩnh viết cùng markup là ra cùng kết quả. Attribute thiếu → CSS l
|
|
|
298
279
|
`<tên>.css` của component; markup chỉ gắn class `leaf-*` (+ class typography / màu khi cần). Phần tử
|
|
299
280
|
nào CSS set `display` thì kèm rule `[hidden] { display: none }`.
|
|
300
281
|
|
|
301
|
-
Thêm bộ class mới (typography / màu): tạo `src/styles/<tên>.css` — script tự sinh `dist/<tên>.css`
|
|
302
|
-
và gom vào `classes.css` + `styles.css`; chỉ cần thêm một dòng `"./<tên>.css"` vào `exports` của
|
|
303
|
-
`package.json`.
|
|
304
282
|
Thêm component React (khi thật sự cần state/behavior, không phải để bọc style): tạo
|
|
305
283
|
`src/components/<Tên>/` (kèm `<tên>.css` nếu cần) rồi re-export trong `src/index.ts`. CSS của
|
|
306
|
-
component
|
|
307
|
-
|
|
308
|
-
|
|
284
|
+
component được `build-css.mjs` tự gom vào `assets.json` và engine tự thêm khi app import component
|
|
285
|
+
— không khai báo gì trong `exports`. Tên file CSS phải duy nhất trong cả `src/` (script báo lỗi nếu
|
|
286
|
+
trùng).
|
|
287
|
+
Component có hành vi (Button loading · Tabs · Toggle · Dialog · Slider · Tooltip · InputOtp · InputStepper · Toast · Dropdown · Carousel · QrCode · Upload · Calendar · InputDate · MultiSelect · Form) cần thêm bản vanilla cho HTML
|
|
309
288
|
tĩnh trong `src/vanilla/` và gắn vào `window.Leaf` qua `src/vanilla/index.ts`. `src/vanilla` chỉ
|
|
310
289
|
vào bản CDN, không vào bản npm.
|
|
311
290
|
|
|
@@ -318,6 +297,7 @@ vào bản CDN, không vào bản npm.
|
|
|
318
297
|
| `Dialog` | Panel + backdrop blur — `open` (controlled), `title` / `onBack` / `onClose(reason)`, `dismissible`, `closeLabel` / `backLabel`, `theme`, `maxWidth` / `height` / `maxHeight` |
|
|
319
298
|
| `Logo` | Wordmark FHSC · Finhay · FHC — `brand` / `mode` / `side` / `size` |
|
|
320
299
|
| `Skeleton` | Placeholder shimmer — `width` / `height` / `border` (radius), nền `--base-tertiary` |
|
|
300
|
+
| `Empty` | Trạng thái không có dữ liệu — `image` (string URL; không truyền = ẩn, `""` = CDN mặc định) · `size` sm/md · `description` (mặc định “Không có dữ liệu”) |
|
|
321
301
|
| `Spinner` | Indicator 8 nan — `animation` (`spin` · `fade` · `pulse` · `breathe`), `size` |
|
|
322
302
|
| `Toggle` | Công tắc On/Off — `size` md/sm, `checked`, `disabled` (Figma Active Off); `name` / `value` → input ẩn cho form |
|
|
323
303
|
| `Slider` | Kéo từng `step` trong `min`–`max` (mặc định 0–100, bước 1) · mốc `steps` · `labels`; `name` → input ẩn |
|
|
@@ -331,20 +311,11 @@ vào bản CDN, không vào bản npm.
|
|
|
331
311
|
| `InputDate` | `Input` trigger + popover `Calendar` — `value` chốt khi bấm "Chọn" (hoặc `confirmOnSelect`), `formatDisplay`, `align`, `monthOnly` (MM/YYYY); `name` → input ẩn ISO |
|
|
332
312
|
| `Toaster` / `toast` | Toast success / error / warning — `toast.success(title, { description, duration })`, `duration: -1` không tự đóng, dừng khi hover / focus, `toast.dismiss(id)`; `<Toaster position closeLabel theme />` đặt một lần; kèm `ToastContent` |
|
|
333
313
|
| `Dropdown` | Chọn một giá trị — `variant` list / radio, `trigger` field / text, `appearance` filled / outlined, `size` md / sm, `openOn` click / hover, `align`, `readOnly`, `maxHeight`; option `leading` / `disabled`; phím ↑ ↓ Home End + typeahead |
|
|
314
|
+
| `FileViewer` | Xem file (PDF native, XLSX / CSV, DOCX, ảnh, video / audio, text) không thư viện ngoài — `source` URL (+`fetchInit`) / Blob / base64, toolbar, `ref`; kèm `FileViewerDialog` |
|
|
334
315
|
| `LanguageDropdown` | Chọn ngôn ngữ Tiếng Việt / English kèm cờ (CDN Finhay) — danh sách ở `LEAF_LANGUAGES`, `value` kiểu `LeafLanguageCode`; mặc định `size="sm"`, `openOn="hover"`, `align="end"` |
|
|
335
316
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
(bảng đầy đủ ở mục Import CSS) — hoặc một dòng styles.css cho tất cả */
|
|
339
|
-
@import "@finhay-pro/leaf-design-system/button.css";
|
|
340
|
-
@import "@finhay-pro/leaf-design-system/tabs.css";
|
|
341
|
-
@import "@finhay-pro/leaf-design-system/dialog.css";
|
|
342
|
-
@import "@finhay-pro/leaf-design-system/toast.css";
|
|
343
|
-
@import "@finhay-pro/leaf-design-system/input.css";
|
|
344
|
-
@import "@finhay-pro/leaf-design-system/dropdown.css";
|
|
345
|
-
/* … skeleton / spinner / toggle / slider / tooltip / radio / checkbox / input-otp /
|
|
346
|
-
input-stepper / calendar / input-date / logo */
|
|
347
|
-
```
|
|
317
|
+
CSS của component không cần import riêng: plugin Leaf tự thêm CSS của component được import (kèm
|
|
318
|
+
component nó dùng bên trong, vd. `InputDate` → `Input` + `Calendar` + `Button`).
|
|
348
319
|
|
|
349
320
|
```tsx
|
|
350
321
|
import {
|
|
@@ -353,6 +324,7 @@ import {
|
|
|
353
324
|
Dialog,
|
|
354
325
|
Logo,
|
|
355
326
|
Skeleton,
|
|
327
|
+
Empty,
|
|
356
328
|
Spinner,
|
|
357
329
|
Toggle,
|
|
358
330
|
Slider,
|
|
@@ -384,6 +356,9 @@ import { RiAddLine, RiArrowRightLine } from "@remixicon/react";
|
|
|
384
356
|
</Button>
|
|
385
357
|
|
|
386
358
|
<Skeleton height={48} border={12} />
|
|
359
|
+
<Empty image="" />
|
|
360
|
+
<Empty image="" size="sm" description="Chưa có giao dịch" />
|
|
361
|
+
<Empty image="https://cdn.example.com/empty.png" />
|
|
387
362
|
|
|
388
363
|
<Tabs
|
|
389
364
|
variant="buy"
|
|
@@ -399,61 +374,107 @@ import { RiAddLine, RiArrowRightLine } from "@remixicon/react";
|
|
|
399
374
|
toast.success("Đặt lệnh thành công", { description: "Mua 100 AAA" });
|
|
400
375
|
```
|
|
401
376
|
|
|
377
|
+
## Đọc & ghi file (không UI)
|
|
378
|
+
|
|
379
|
+
Đọc / ghi Excel / CSV / text ngay trên trình duyệt, **không thư viện ngoài** (ZIP giải bằng
|
|
380
|
+
`DecompressionStream("deflate-raw")`, XML bằng `DOMParser`). Source nhận URL (kèm `fetchInit` để
|
|
381
|
+
gửi header đăng nhập), `Blob` / `File`, `ArrayBuffer` / typed array, hoặc `{ base64, mimeType }`.
|
|
382
|
+
|
|
383
|
+
| Export | Mô tả |
|
|
384
|
+
| ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
385
|
+
| `readSpreadsheet(source, opt)` | XLSX / CSV → `{ sheets: [{ name, hidden, rows, merges, colWidths }] }`; ô `{ v, t, w }` — `w` là chuỗi hiển thị như Excel (numFmt + locale) |
|
|
386
|
+
| `spreadsheetToCsv(sheet, opt)` | Một sheet → CSV; `values: "raw"` (mặc định, cho import dữ liệu) hoặc `"formatted"`, `delimiter`, `blankRows` |
|
|
387
|
+
| `readText(source)` | Text theo BOM (UTF-8 / UTF-16) |
|
|
388
|
+
| `readFileSource(source, opt)` | Chuẩn hoá source → `{ blob, name, mime, size }`; `maxSize` (mặc định 20 MB), `signal` |
|
|
389
|
+
| `detectFileType(file)` | `pdf` · `image` · `video` · `audio` · `text` · `csv` · `xlsx` · `docx` · `unsupported` (MIME → đuôi → magic bytes) |
|
|
390
|
+
| `readSpreadsheetRecords` / `sheetToRecords` | Sheet → mảng object theo dòng header (`headerRow`, `values: "raw" \| "formatted"`) — thay `XLSX.utils.sheet_to_json` |
|
|
391
|
+
| `parseCsv` / `toCsv` | CSV RFC 4180, tự nhận `,` `;` `\t` `\|` |
|
|
392
|
+
| `parseCsvRecords` | CSV → `Record<string, string>[]` (trim, bỏ dòng trống, `transformHeader`) — thay `papaparse` `header: true` |
|
|
393
|
+
| `writeXlsx(sheets, opt)` | → `Blob` XLSX: nhiều sheet, chuỗi / số / boolean / `Date`, header đậm + cố định, độ rộng cột (tự tính), ô gộp — thay `XLSX.write` |
|
|
394
|
+
| `jsonToSheetRows(objs, cols)` | Mảng object → dòng có header (`key` / hàm + `header`) — thay `XLSX.utils.json_to_sheet` |
|
|
395
|
+
| `downloadXlsx` / `downloadCsv` / `downloadBlob` / `csvBlob` | Tải file qua `<a download>`; CSV có BOM UTF-8 cho Excel — thay `XLSX.writeFile`, `react-csv`, `file-saver` |
|
|
396
|
+
| `FileReadError` | Lỗi có `code`: `invalid-source` · `fetch-failed` · `too-large` · `corrupt` · `encrypted` · `unsupported` · `legacy-format` · `unsupported-browser` · `aborted` |
|
|
397
|
+
|
|
398
|
+
```ts
|
|
399
|
+
import { readSpreadsheet, spreadsheetToCsv, FileReadError } from "@finhay-pro/leaf-design-system";
|
|
400
|
+
|
|
401
|
+
try {
|
|
402
|
+
const { sheets } = await readSpreadsheet(file); // File từ <Upload> / <input type="file">
|
|
403
|
+
const csv = spreadsheetToCsv(sheets[0]); // "FPT,1200,98500,…" — số / ngày (YYYY-MM-DD) giá trị gốc
|
|
404
|
+
} catch (error) {
|
|
405
|
+
if (error instanceof FileReadError && error.code === "legacy-format") {
|
|
406
|
+
// .xls (Excel 97–2003) — yêu cầu lưu lại dạng .xlsx; file có mật khẩu → "encrypted"
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// Import → mảng object; xuất báo cáo
|
|
411
|
+
const rows = await readSpreadsheetRecords(file); // [{ "Mã CK": "VNM", "KL": 1000 }]
|
|
412
|
+
await downloadXlsx("bao-cao.xlsx", [{ name: "Lệnh", header: true, rows: jsonToSheetRows(orders) }]);
|
|
413
|
+
downloadCsv("lenh.csv", [
|
|
414
|
+
["Mã", "KL"],
|
|
415
|
+
["VNM", 1000],
|
|
416
|
+
]);
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
Giới hạn: không đọc `.xls` cũ (BIFF) → `legacy-format`, ZIP64, file có mật khẩu → `encrypted`;
|
|
420
|
+
`writeXlsx` không ghi công thức / màu / viền; trình duyệt tối thiểu Chrome 103+, Safari 16.4+,
|
|
421
|
+
Firefox 113+ (thiếu API → `unsupported-browser`; ghi XLSX thiếu `CompressionStream` thì lưu không
|
|
422
|
+
nén, file vẫn hợp lệ).
|
|
423
|
+
|
|
424
|
+
### Thay thư viện nào bằng gì
|
|
425
|
+
|
|
426
|
+
| Đang dùng | Leaf |
|
|
427
|
+
| -------------------------------------------------------- | --------------------------------------------------------------------- |
|
|
428
|
+
| `react-dropzone` | `Upload` (`accept`, `maxSize`, `minSize`, `maxFiles`, `onReject`) |
|
|
429
|
+
| `react-medium-image-zoom`, `react-image-pan-zoom-rotate` | `FileViewer` ảnh (zoom 25–400%, xoay, kéo) / `Upload preview` |
|
|
430
|
+
| `<object>` / `<iframe>` PDF base64 | `FileViewer` / `FileViewerDialog` với `source={{ base64, mimeType }}` |
|
|
431
|
+
| `react-pdf` (desktop web) | `FileViewer` PDF (trình xem của trình duyệt) |
|
|
432
|
+
| `xlsx` đọc (`read`, `sheet_to_json`) | `readSpreadsheet`, `readSpreadsheetRecords`, `spreadsheetToCsv` |
|
|
433
|
+
| `xlsx` ghi (`json_to_sheet`, `writeFile`) | `jsonToSheetRows`, `writeXlsx`, `downloadXlsx` |
|
|
434
|
+
| `papaparse` | `parseCsv`, `parseCsvRecords` |
|
|
435
|
+
| `react-csv`, `file-saver` | `downloadCsv`, `downloadBlob` |
|
|
436
|
+
|
|
437
|
+
Chưa thay được: đọc `.xls` cũ (BIFF), xem PDF inline trên Chrome Android / WebView (Leaf hiện nút
|
|
438
|
+
Mở tab mới / Tải xuống).
|
|
439
|
+
|
|
402
440
|
## HTML tĩnh (CDN)
|
|
403
441
|
|
|
404
|
-
Cho landing page / trang dựng tay không có bundler:
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
Calendar
|
|
408
|
-
|
|
442
|
+
Cho landing page / trang dựng tay không có bundler: 1 `<link>` + 1 `<script>`. CSS gồm token +
|
|
443
|
+
reset + class typography / color + CSS của mọi component. Script gồm hành vi Button loading · Tabs ·
|
|
444
|
+
Toggle · Dialog · Slider · Tooltip · InputOtp · InputStepper · Toast · Dropdown · Carousel · QrCode ·
|
|
445
|
+
Upload · Calendar · InputDate · MultiSelect · Form (`data-leaf-*` / `window.Leaf`) **và runtime sinh
|
|
446
|
+
utility layout** từ class trên DOM (theo dõi DOM thay đổi) — trang dùng cùng utility như app
|
|
447
|
+
(`flex`, `gap-[16px]`, `md:grid-cols-3`), không cần CSS riêng cho layout.
|
|
409
448
|
|
|
410
449
|
```html
|
|
411
|
-
<link rel="stylesheet" href="https://<cdn>/leaf-0.2.
|
|
412
|
-
<script src="https://<cdn>/leaf-0.2.
|
|
450
|
+
<link rel="stylesheet" href="https://<cdn>/leaf-0.2.3.min.css" />
|
|
451
|
+
<script src="https://<cdn>/leaf-0.2.3.min.js" defer></script>
|
|
413
452
|
<!-- Icon: Remix Icon (xem mục Icon) -->
|
|
414
453
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/remixicon@4.9.1/fonts/remixicon.css" />
|
|
415
454
|
|
|
416
455
|
<style>
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
body {
|
|
420
|
-
margin: 0;
|
|
421
|
-
font-family: var(--font-sans);
|
|
422
|
-
background: var(--base-primary);
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
@layer page {
|
|
427
|
-
.hero {
|
|
428
|
-
display: flex;
|
|
429
|
-
flex-direction: column;
|
|
430
|
-
gap: 16px;
|
|
431
|
-
padding: 48px 16px;
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
@media (min-width: 768px) {
|
|
435
|
-
.hero {
|
|
436
|
-
flex-direction: row;
|
|
437
|
-
}
|
|
438
|
-
}
|
|
456
|
+
body {
|
|
457
|
+
font-family: var(--font-sans);
|
|
439
458
|
}
|
|
440
459
|
</style>
|
|
441
460
|
|
|
442
|
-
<
|
|
443
|
-
<
|
|
444
|
-
|
|
445
|
-
</
|
|
461
|
+
<body class="bg-primary">
|
|
462
|
+
<section class="flex flex-col gap-[16px] px-[16px] py-[48px] sm:flex-row">
|
|
463
|
+
<h1 class="display-3 text-primary">Finhay</h1>
|
|
464
|
+
<button class="leaf-button" data-size="md">Mở tài khoản</button>
|
|
465
|
+
</section>
|
|
466
|
+
</body>
|
|
446
467
|
```
|
|
447
468
|
|
|
448
|
-
| File | Nội dung
|
|
449
|
-
| ------------------------ |
|
|
450
|
-
| `leaf-<version>.min.css` |
|
|
451
|
-
| `leaf-<version>.min.js` | Hành vi Button loading · Tabs · Toggle · Dialog · Slider · Tooltip · InputOtp · InputStepper · Toast · Dropdown → `window.Leaf
|
|
469
|
+
| File | Nội dung |
|
|
470
|
+
| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
471
|
+
| `leaf-<version>.min.css` | Đã minify: token + reset + typography + color + CSS của mọi component. |
|
|
472
|
+
| `leaf-<version>.min.js` | Hành vi Button loading · Tabs · Toggle · Dialog · Slider · Tooltip · InputOtp · InputStepper · Toast · Dropdown · Carousel · QrCode · Upload · Calendar · InputDate · MultiSelect · Form → `window.Leaf` + runtime utility layout. |
|
|
452
473
|
|
|
453
474
|
Bản CDN nằm trong package npm (`dist/cdn/`), nên jsDelivr phục vụ trực tiếp theo version:
|
|
454
475
|
`https://cdn.jsdelivr.net/npm/@finhay-pro/leaf-design-system@<version>/dist/cdn/leaf-<version>.min.css`
|
|
455
476
|
(và `.min.js`) — cũng là link trên trang docs
|
|
456
|
-
[**
|
|
477
|
+
[**Installation**](http://leaf-design-system.finhay.local/installation) (`apps/docs/config/shared.ts` →
|
|
457
478
|
`leafCdn`). Trang demo đủ mọi component có bản HTML tĩnh:
|
|
458
479
|
[`examples/static.html`](examples/static.html) (mở bằng `file://` sau khi build).
|
|
459
480
|
|
|
@@ -529,8 +550,8 @@ thì đọc lại mỗi lần đặt vị trí). Bubble `pointer-events: none`
|
|
|
529
550
|
Span rỗng `.leaf-logo` + `data-brand` / `data-mode` / `data-side` + `--leaf-logo-size`. CSS gắn
|
|
530
551
|
SVG data-URI — không cần JS. Khác React, HTML tĩnh **không có mặc định**: wordmark phải đủ cả ba
|
|
531
552
|
attribute, và span phải rỗng tuyệt đối (`:empty` — không có khoảng trắng bên trong), thiếu là ra ô
|
|
532
|
-
trống. `data-mode` theo nền phía sau (`dark` = nền tối), không tự đổi theo `data-theme`. Bản CDN đã gộp sẵn data-URI; dùng qua npm thì
|
|
533
|
-
`logo
|
|
553
|
+
trống. `data-mode` theo nền phía sau (`dark` = nền tối), không tự đổi theo `data-theme`. Bản CDN đã gộp sẵn data-URI; dùng qua npm thì plugin Leaf tự thêm data-URI khi thấy class
|
|
554
|
+
`leaf-logo` trong markup (component React render `<img>` nên không cần).
|
|
534
555
|
|
|
535
556
|
### Radio / Checkbox / Input
|
|
536
557
|
|
|
@@ -571,26 +592,48 @@ giống React. Trigger `filled` có nền `--base-secondary` — đặt trên ca
|
|
|
571
592
|
`leaf:dropdown-change`. Có `input.leaf-dropdown__input` thì leaf.js ghi value vào đó. Panel nằm ngay
|
|
572
593
|
dưới trigger (không portal) — tránh đặt trong khung `overflow: hidden / auto` thấp hơn panel.
|
|
573
594
|
|
|
574
|
-
###
|
|
595
|
+
### FileViewer
|
|
575
596
|
|
|
576
|
-
|
|
577
|
-
`
|
|
597
|
+
`<div class="leaf-file-viewer" data-leaf-file-viewer data-src="…">` tự tải khi DOM sẵn sàng; hoặc
|
|
598
|
+
`Leaf.fileViewer.open(el, source, options)` / `clear(el)` / `get(el)` / `zoom(el, n)`, event
|
|
599
|
+
`leaf:file-viewer-load` · `-error` · `-change`. Markup do controller dùng chung với React dựng nên
|
|
600
|
+
giống hệt. Dùng được trong app React 18 qua `useEffect`.
|
|
601
|
+
|
|
602
|
+
### Đọc file
|
|
603
|
+
|
|
604
|
+
`Leaf.file` — cùng API phần [Đọc & ghi file](#đọc--ghi-file-không-ui), không cần markup:
|
|
605
|
+
|
|
606
|
+
```js
|
|
607
|
+
input.addEventListener("change", async () => {
|
|
608
|
+
const { sheets } = await Leaf.file.readSpreadsheet(input.files[0]);
|
|
609
|
+
console.log(Leaf.file.spreadsheetToCsv(sheets[0]));
|
|
610
|
+
});
|
|
611
|
+
// Leaf.file.read(source) · Leaf.file.detectType(file) · Leaf.file.readText(source)
|
|
612
|
+
// Leaf.file.readSpreadsheetRecords(file) · Leaf.file.parseCsvRecords(text)
|
|
613
|
+
// Leaf.file.downloadXlsx(name, sheets) · Leaf.file.downloadCsv(name, rows) · Leaf.file.download(name, blob)
|
|
614
|
+
```
|
|
615
|
+
|
|
616
|
+
### Skeleton / Empty / Spinner
|
|
617
|
+
|
|
618
|
+
Chỉ CSS. Skeleton: `--leaf-skeleton-width` / `height` / `radius`. Empty: `.leaf-empty` +
|
|
619
|
+
`data-size` sm/md (ảnh CDN + description). Spinner: `data-animation` / `data-size` + SVG path;
|
|
620
|
+
overlay = `.leaf-spinner-overlay` (app tự `hidden`/mount).
|
|
578
621
|
|
|
579
622
|
### Cần biết
|
|
580
623
|
|
|
581
624
|
- **Link gắn theo version.** Mỗi bản phát hành là một link mới; trang cũ giữ link cũ nên không tự
|
|
582
625
|
vỡ. Muốn lên bản mới thì đổi cả link CSS lẫn JS cùng một version, đọc [Changelog](#changelog)
|
|
583
626
|
trước.
|
|
584
|
-
- **Không kèm font
|
|
585
|
-
`body { font-family: var(--font-sans) }`.
|
|
627
|
+
- **Không kèm font.** Tự load Inter (Google Fonts hoặc self-host) và set
|
|
628
|
+
`body { font-family: var(--font-sans) }`. Reset tối thiểu đã có trong `@layer base`.
|
|
586
629
|
- **CSS của trang phải nằm trong `@layer` nếu đụng vào element của component.** Style component
|
|
587
630
|
nằm trong `@layer components`, mà CSS không layer luôn thắng CSS có layer bất kể specificity —
|
|
588
631
|
reset kiểu `* { padding: 0 }` hay `button { background: none }` đặt trần sẽ xoá padding / nền
|
|
589
632
|
của `.leaf-button`. Bọc reset trong `@layer base { … }`, layout của page trong một layer riêng
|
|
590
633
|
(vd. `@layer page`, khai báo sau `utilities` nếu muốn đè cả class màu).
|
|
591
|
-
- **
|
|
592
|
-
|
|
593
|
-
|
|
634
|
+
- **Utility layout cần `leaf.js`.** Runtime trong script sinh CSS cho `flex`, `gap-[16px]`,
|
|
635
|
+
`md:grid-cols-3`… từ class trên trang; thiếu script thì chỉ còn token, class Leaf và CSS
|
|
636
|
+
component. Luật utility giống bản npm (px, không thang số, chữ / màu chỉ từ class Leaf).
|
|
594
637
|
- **Trình duyệt tối thiểu** (CSS dùng `@layer`): Chrome / Edge 99+, Safari 15.4+, Firefox 97+.
|
|
595
638
|
- Dark là mặc định; `data-theme="light"` trên `<html>` để chuyển light.
|
|
596
639
|
- z-index của lớp phủ đọc `--leaf-z-dropdown` (30) / `--leaf-z-dialog` (50) /
|
|
@@ -609,6 +652,153 @@ Chỉ CSS. Skeleton: `--leaf-skeleton-width` / `height` / `radius`. Spinner: `da
|
|
|
609
652
|
|
|
610
653
|
## Changelog
|
|
611
654
|
|
|
655
|
+
### 0.2.3
|
|
656
|
+
|
|
657
|
+
> ⚠️ **Breaking** — Leaf tự sinh utility layout, không còn dùng Tailwind. Xem **Nâng cấp từ 0.2.2**
|
|
658
|
+
> bên dưới trước khi nâng.
|
|
659
|
+
|
|
660
|
+
**Engine CSS của Leaf thay Tailwind (không third party)**
|
|
661
|
+
|
|
662
|
+
- Một dòng `@import "@finhay-pro/leaf-design-system/css";` + plugin `@finhay-pro/leaf-design-system/vite`
|
|
663
|
+
hoặc `/postcss`; HTML tĩnh có build dùng CLI `npx leaf-css -i input.css -o leaf.css [--watch]
|
|
664
|
+
[--minify]`. Engine bundle trong `dist/engine`, chỉ import `node:*`; package không có
|
|
665
|
+
`dependencies`.
|
|
666
|
+
- Thứ tự output: token (`@layer theme`) + reset (`@layer base`) → **CSS của component đang dùng**
|
|
667
|
+
(nhận qua named import, kể cả phụ thuộc bắc cầu, hoặc class `leaf-*` trong markup) → class typo /
|
|
668
|
+
màu Leaf → **utility có trong source** (tree-shaking, quét gốc project theo `.gitignore`).
|
|
669
|
+
- Utility cú pháp kiểu Tailwind v4: layout, flex / grid, spacing, sizing, background (trừ màu),
|
|
670
|
+
border (trừ màu), effect, filter, transform, transition, interactivity…; variant state,
|
|
671
|
+
`group-*` / `peer-*` / `has-*` / `not-*`, `aria-*` / `data-*`, arbitrary `[&>svg]:`, `!`, container
|
|
672
|
+
query. Class màu / typo Leaf nhận variant và opacity (`md:heading-1`, `hover:bg-tertiary`,
|
|
673
|
+
`bg-primary/50`).
|
|
674
|
+
- Luật Leaf: chỉ px (từ chối `rem` / `em`); spacing / size / inset không có thang số
|
|
675
|
+
(`p-[16px]`, không `p-4`); không font / cỡ chữ / `leading-*` / palette / màu tuỳ ý / `dark:`;
|
|
676
|
+
không cấu hình (`@theme`, `@utility`, `@apply`, `@source`, `@import "tailwindcss"`… → lỗi
|
|
677
|
+
build). Class bị từ chối có cảnh báo kèm gợi ý.
|
|
678
|
+
- Breakpoint mới: `xs` ≤ 767 · `sm` ≥ 768 · `md` ≥ 1024 · `lg` ≥ 1280 · `xl` ≥ 1600 · `2xl` ≥ 1920;
|
|
679
|
+
thêm `max-*`, `min-[..]`, `max-[..]`.
|
|
680
|
+
- CDN: `leaf-<ver>.min.js` kèm runtime sinh utility từ class trên DOM (thay `@tailwindcss/browser`);
|
|
681
|
+
`leaf-<ver>.min.css` minify bằng minifier của engine.
|
|
682
|
+
- Hiệu năng (docs, 276 file): build lần đầu ~37ms, HMR ~2ms, runtime CDN ~0,6ms / 500 class.
|
|
683
|
+
|
|
684
|
+
**Table — bảng dữ liệu (React + leaf.js)**
|
|
685
|
+
|
|
686
|
+
- `Table` + `Leaf.table.create(root, options)` (data mode) và `data-leaf-table` (static mode: sort +
|
|
687
|
+
resize trên markup render sẵn) — cùng markup, logic dùng chung `core/table/`.
|
|
688
|
+
- Header luôn sticky, group header nhiều tầng (`children`); pin cột (`stickyColumns`,
|
|
689
|
+
`pin: "left" | "right"`), mép vùng pin có đường kẻ; nền theo cột `background` (`LeafBgColor`).
|
|
690
|
+
- Sort 3 trạng thái (none → asc → desc), `sortDescFirst`, `sortFn`, `manualSort`; width / `minWidth`
|
|
691
|
+
/ `maxWidth` / `grow`, resize bằng kéo (Pointer Events), phím ← → (Shift ×5), double-click về mặc
|
|
692
|
+
định; text không bao giờ bị cắt.
|
|
693
|
+
- Rowspan / colspan (`span`, `mergeRows`), virtual theo hàng (`rowHeight`, `overscan`), realtime
|
|
694
|
+
`column.flash` (một timer cho cả bảng, dòng memo), `bordered`, `striped`, `size`, loading, rỗng,
|
|
695
|
+
`onRowClick`; ref `TableHandle` (`scrollToRow`, `scrollToTop`).
|
|
696
|
+
- leaf.js: `setOptions`, `setRows`, `update({ [rowId]: patch })` (gộp theo frame), `getSort` /
|
|
697
|
+
`setSort`, `getColumnWidths` / `setColumnWidths`, `scrollToRow`, `destroy`; event
|
|
698
|
+
`leaf:table-sort-change`, `leaf:table-resize`.
|
|
699
|
+
- Icon mới `arrow-up-line` / `arrow-down-line`; `bgColorToken` trong `utils/colorClass.ts`.
|
|
700
|
+
|
|
701
|
+
**Bảo mật**
|
|
702
|
+
|
|
703
|
+
- leaf.js MultiSelect: chip dựng bằng DOM API (`createElement` / `textContent`), `leading` dùng
|
|
704
|
+
`cloneNode` — label chứa HTML (kể cả đã escape từ server) không còn thành thẻ thật. DOM output
|
|
705
|
+
không đổi.
|
|
706
|
+
- Ghi rõ `data-tooltip` (Tooltip) và mẫu `renderTabs` chỉ nhận markup tin cậy.
|
|
707
|
+
- Dev / CI (không vào bản publish): vitest 5.0.5 (vá `@vitest/mocker`), override `undici` ^8.12.2,
|
|
708
|
+
GitHub Actions chạy Node 24, CI chạy `format:check`; site docs thêm header bảo mật nginx.
|
|
709
|
+
|
|
710
|
+
**Nâng cấp từ 0.2.2**
|
|
711
|
+
|
|
712
|
+
| 0.2.2 | 0.2.3 |
|
|
713
|
+
| ------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- |
|
|
714
|
+
| `@import ".../styles.css"` / `tokens.css` / `typography.css` / `color.css` / `classes.css` | `@import "@finhay-pro/leaf-design-system/css";` + plugin Vite / PostCSS |
|
|
715
|
+
| CSS lẻ từng component (`button.css`, `tabs.css`, `logo-assets.css`…) | Đã xoá — engine tự lấy CSS của component đang dùng |
|
|
716
|
+
| `tailwindcss`, `@tailwindcss/vite` / `postcss` / `browser` | `leaf()` / plugin PostCSS / CLI `leaf-css` / JS CDN — gỡ Tailwind khỏi app |
|
|
717
|
+
| `p-4`, `gap-6`, `w-40`, `max-w-md` | `p-[16px]`, `gap-[24px]`, `w-[160px]`, `max-w-[448px]` |
|
|
718
|
+
| `sm:` 640 · `md:` 768 · `lg:` 1024 · `xl:` 1280 | `sm:` 768 · `md:` 1024 · `lg:` 1280 · `xl:` 1600 (`xs:` ≤ 767) |
|
|
719
|
+
| `bg-(--base-tertiary)`, `text-(color:--x)` | `bg-tertiary`, `text-*` (có variant: `hover:bg-tertiary`) |
|
|
720
|
+
| `font-*`, `text-[24px]`, `leading-*`, `rem` / `em` | class typo Leaf (`md:heading-1`), px |
|
|
721
|
+
| Token không layer | Token trong `@layer theme` — CSS không layer của app luôn đè được |
|
|
722
|
+
|
|
723
|
+
`exports` chỉ còn `.`, `./css`, `./vite`, `./postcss`; thêm bin `leaf-css`. Giữ nguyên điểm gãy
|
|
724
|
+
cũ khi migrate: `md:` → `sm:`, `lg:` → `md:`, `sm:` → `min-[640px]:`. API React / `window.Leaf`
|
|
725
|
+
của component có sẵn không đổi.
|
|
726
|
+
|
|
727
|
+
### 0.2.2
|
|
728
|
+
|
|
729
|
+
**Đọc file — không thư viện ngoài**
|
|
730
|
+
|
|
731
|
+
- `readSpreadsheet` đọc XLSX / CSV thành `{ sheets }`: ô gộp, sheet ẩn, độ rộng cột, shared string /
|
|
732
|
+
rich text / inline string, công thức (giá trị cache), boolean, lỗi, ngày (hệ 1900 và 1904); chuỗi
|
|
733
|
+
hiển thị `w` theo numFmt của Excel (`#,##0`, `0.00%`, `dd/mm/yyyy`, `[h]:mm`, `"đ"`…) và locale
|
|
734
|
+
(mặc định `vi-VN`). Thay được `xlsx` (SheetJS) khi import dữ liệu.
|
|
735
|
+
- `spreadsheetToCsv`, `readText`, `readFileSource` (URL + `fetchInit`, Blob, base64, `maxSize`),
|
|
736
|
+
`detectFileType`, `parseCsv` / `toCsv`, `FileReadError` (`code`).
|
|
737
|
+
- Chống zip bomb (giới hạn entry / dung lượng giải nén, đếm byte thực), từ chối ZIP64 / mã hoá.
|
|
738
|
+
- `readDocxText` (plain text của DOCX), ô bảng tính có style `s` (đậm / nghiêng / màu / nền / căn lề).
|
|
739
|
+
- leaf.js: `Leaf.file.{read, detectType, readText, readSpreadsheet, spreadsheetToCsv, readDocxText}`.
|
|
740
|
+
|
|
741
|
+
**FileViewer — xem file trong app (React + leaf.js)**
|
|
742
|
+
|
|
743
|
+
- `FileViewer` / `FileViewerDialog` + `Leaf.fileViewer` (`data-leaf-file-viewer`) — một controller
|
|
744
|
+
dùng chung (`core/file/viewer.ts`) nên markup React và HTML tĩnh trùng nhau.
|
|
745
|
+
- PDF: trình xem có sẵn của trình duyệt; `navigator.pdfViewerEnabled === false` (Chrome Android) →
|
|
746
|
+
"Mở tab mới" / "Tải xuống" (`pdfMode`). XLSX / CSV: bảng có header dính, ô gộp, style ô, tab sheet,
|
|
747
|
+
ảo hoá > 200 dòng. DOCX: heading, list nhiều cấp, bảng gộp ô, ảnh, link, ngắt trang. Ảnh: zoom /
|
|
748
|
+
xoay / kéo. Video / audio / text.
|
|
749
|
+
- Trạng thái idle / loading / lỗi (Thử lại) / không hỗ trợ (PPTX, Office cũ — Tải xuống); nhãn
|
|
750
|
+
tiếng Việt mặc định + `FILE_VIEWER_LABELS_EN`; `ref` (`FileViewerHandle`) điều khiển từ ngoài.
|
|
751
|
+
- An toàn: không `innerHTML` với nội dung file, link DOCX chỉ http(s) / mailto / tel, object URL
|
|
752
|
+
luôn được thu hồi. CSS `file-viewer.css`; icon Remix mới trong `core/icons.ts`.
|
|
753
|
+
- Docs `/components/file-viewer` (13 ví dụ React + 8 snippet HTML) — người dùng tự chọn / kéo thả
|
|
754
|
+
file để xem; skill `references/components/file-viewer.md`.
|
|
755
|
+
- leaf.js tăng ~60 KB minified (~56 KB gzip toàn bộ) do parser ZIP / XML / XLSX / DOCX.
|
|
756
|
+
- Fixture test trong `test/fixtures/`: `example1.xlsx` (3 sheet) · `example2.docx` · `example3.pdf`
|
|
757
|
+
(2 trang) · `example4.png`; CSV `;` / PPTX dựng trong bộ nhớ (`csvSample` / `pptxSample`), edge
|
|
758
|
+
case dựng bằng `test/helpers/zip.ts`.
|
|
759
|
+
|
|
760
|
+
**Ghi file — không thư viện ngoài**
|
|
761
|
+
|
|
762
|
+
- `writeXlsx(sheets)` → `Blob` XLSX hợp lệ (shared strings, numFmt ngày `dd/mm/yyyy` /
|
|
763
|
+
`dd/mm/yyyy hh:mm:ss`, header đậm + cố định, độ rộng cột tự tính, ô gộp, tên sheet tự làm sạch /
|
|
764
|
+
chống trùng); ZIP nén bằng `CompressionStream("deflate-raw")`, thiếu API thì lưu không nén.
|
|
765
|
+
- `jsonToSheetRows`, `downloadBlob`, `downloadCsv` (BOM UTF-8 mặc định), `downloadXlsx`, `csvBlob`.
|
|
766
|
+
- `readSpreadsheetRecords` / `sheetToRecords` / `parseCsvRecords`: dữ liệu import thành mảng object
|
|
767
|
+
(header trim, rỗng → `Cột N`, trùng → `_2`).
|
|
768
|
+
- leaf.js: `Leaf.file` thêm `readSpreadsheetRecords`, `sheetToRecords`, `parseCsv`,
|
|
769
|
+
`parseCsvRecords`, `toCsv`, `writeXlsx`, `jsonToSheetRows`, `csvBlob`, `download`, `downloadCsv`,
|
|
770
|
+
`downloadXlsx`.
|
|
771
|
+
|
|
772
|
+
**Upload**
|
|
773
|
+
|
|
774
|
+
- `maxSize` / `minSize`, `onReject(rejections)` với lý do `accept` · `max-size` · `min-size` ·
|
|
775
|
+
`max-files` · `multiple` — trước đây file bị loại biến mất im lặng. Thả file khi đã đủ `maxFiles`
|
|
776
|
+
cũng báo `max-files`.
|
|
777
|
+
- `preview`: thumbnail ảnh (icon file với loại khác), dung lượng (`formatFileSize`), nút xem mở
|
|
778
|
+
`FileViewerDialog`; `viewLabel`, `viewerLabels`.
|
|
779
|
+
- `accept` khớp cả MIME suy từ đuôi khi `File.type` rỗng (`.heic` trên Chrome) hoặc sai (`.csv` từ
|
|
780
|
+
Excel Windows).
|
|
781
|
+
- `DynamicForm` field `upload` nhận `upload: { accept, maxSize, minSize, multiple, maxFiles, preview,
|
|
782
|
+
formats, dropLabel, onReject }`.
|
|
783
|
+
- leaf.js: `data-max-size` / `data-min-size`, `data-preview` / `data-view-label`, event
|
|
784
|
+
`leaf:upload-reject` · `leaf:upload-view` (`Leaf.upload.REJECT_EVENT` / `VIEW_EVENT`).
|
|
785
|
+
- Sửa: leaf.js nội suy tên file vào `innerHTML` (tên file chứa HTML chạy được script) — nay dựng DOM
|
|
786
|
+
bằng `textContent`. `countLabel` dạng chuỗi thay mọi chữ `N` (vd. "Nhận" → "1hận") — nay chỉ
|
|
787
|
+
`{count}` hoặc `N` đứng riêng.
|
|
788
|
+
|
|
789
|
+
**FileViewer — sửa / bổ sung**
|
|
790
|
+
|
|
791
|
+
- An toàn: object URL luôn bọc lại với MIME cố định theo loại thay vì `Content-Type` của server; PDF
|
|
792
|
+
bắt buộc chữ ký `%PDF-` kể cả khi app ép `type` / `mimeType` (server trả nhầm HTML không còn chạy
|
|
793
|
+
trong iframe dưới origin app); "Mở tab mới" chỉ cho PDF; "Tải xuống" luôn
|
|
794
|
+
`application/octet-stream`.
|
|
795
|
+
- `FileReadError` code mới `legacy-format` cho `.xls` / `.doc` / `.ppt` (Office 97–2003); OOXML có mật
|
|
796
|
+
khẩu báo `encrypted` — cả viewer lẫn `readSpreadsheet` / `readDocxText`.
|
|
797
|
+
- HEIC / HEIF / TIFF: trình duyệt không decode được (Chrome, Firefox) → "không hỗ trợ" + Tải xuống
|
|
798
|
+
thay vì "file hỏng". Nhận `.tif` / `.tiff` / `image/tiff` là ảnh.
|
|
799
|
+
- DOCX: đọc bookmark; link `#bookmark` cuộn trong viewer thay vì đổi hash / route của app.
|
|
800
|
+
- `FileViewerDialog` thêm `footer` (hàng nút dưới viewer).
|
|
801
|
+
|
|
612
802
|
### 0.2.1
|
|
613
803
|
|
|
614
804
|
**InputDate / Calendar — chọn theo tháng**
|
|
@@ -624,7 +814,7 @@ Chỉ CSS. Skeleton: `--leaf-skeleton-width` / `height` / `radius`. Spinner: `da
|
|
|
624
814
|
- `calendar.css`: ô tháng (`.leaf-calendar__option`) có trạng thái `data-today` / `:disabled`;
|
|
625
815
|
root `data-month-only="true"` cho ô cao 40px.
|
|
626
816
|
- Docs (Input, Calendar) và Claude skill (`input-date.md`, `calendar.md`) cập nhật ví dụ / prop.
|
|
627
|
-
- `monthOnly`
|
|
817
|
+
- `monthOnly` trên React và leaf.js (`data-month-only` trên `data-leaf-calendar` / `data-leaf-input-date`).
|
|
628
818
|
|
|
629
819
|
**Sửa lỗi**
|
|
630
820
|
|
|
@@ -702,8 +892,7 @@ Chỉ CSS. Skeleton: `--leaf-skeleton-width` / `height` / `radius`. Spinner: `da
|
|
|
702
892
|
|
|
703
893
|
- Bỏ class layout / spacing / border width / radius khỏi Leaf: xoá `spacing.css`, `border.css`,
|
|
704
894
|
`flex.css`, `grid.css`, `sizing.css`, `overflow.css`, `position.css`, `text-layout.css` (cả
|
|
705
|
-
export npm lẫn trong `classes.css` / `styles.css` / CDN). Next.js dùng Tailwind
|
|
706
|
-
[Dùng với Next.js + Tailwind](#dùng-với-nextjs--tailwind)), landing page dùng CSS của page. Trang
|
|
895
|
+
export npm lẫn trong `classes.css` / `styles.css` / CDN). Next.js dùng Tailwind, landing page dùng CSS của page. Trang
|
|
707
896
|
dựng layout bằng các class này (`flex`, `gap-m`, `p-l`, `radius-l`…) phải giữ link CDN 0.1.7 hoặc
|
|
708
897
|
chuyển sang CSS riêng trước khi lên 0.1.8.
|
|
709
898
|
- Bỏ token `--spacing-*`, `--border-width-*`, `--radius-*` (file `spacing.css` / `border.css` của
|
|
@@ -885,10 +1074,12 @@ Chỉ CSS. Skeleton: `--leaf-skeleton-width` / `height` / `radius`. Spinner: `da
|
|
|
885
1074
|
Logo CSS data-URI theo `data-brand` / `data-mode` / `data-side`; docs `htmlSection` +
|
|
886
1075
|
`examples/static.html` cover đủ component.
|
|
887
1076
|
- Skeleton: placeholder shimmer (`width` / `height` / `border`), nền `--base-tertiary`.
|
|
1077
|
+
- Empty: trạng thái không dữ liệu — `image` (string URL; `""` = CDN mặc định) · `size`
|
|
1078
|
+
sm/md · `description` (mặc định “Không có dữ liệu”).
|
|
888
1079
|
- Spinner: indicator 8 nan (loader-line), animation `spin` · `fade` · `pulse` · `breathe`; màu
|
|
889
1080
|
mặc định trắng (dark) / đen (light) qua `--base-quinary`, overlay cũng vậy — không dùng highlight.
|
|
890
1081
|
- Toggle: công tắc On/Off (Figma 730:12438) — size md/sm, checked, disabled.
|
|
891
|
-
- Slider: bước rời (Figma 730:12646) — title/unit, labels,
|
|
1082
|
+
- Slider: bước rời (Figma 730:12646) — title/unit, labels, color (LeafTextColor → data-color).
|
|
892
1083
|
- Tooltip: hover/focus (Figma 891:4983) — size/position/align + TooltipContent.
|
|
893
1084
|
- Dialog / Logo: React component + CSS (Logo asset generate qua `embed-logo-assets.mjs`).
|
|
894
1085
|
- Thêm bản CDN cho HTML tĩnh: `leaf-<version>.min.css` + `leaf-<version>.min.js` (`window.Leaf`).
|