@yosgo/swap-ui 1.0.142 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -36
- package/build/index.cjs +3693 -0
- package/build/index.cjs.map +1 -0
- package/build/index.d.cts +710 -0
- package/build/index.d.ts +710 -50
- package/build/index.js +3553 -13927
- package/build/index.js.map +1 -1
- package/package.json +63 -63
- package/build/AppBar/AppBar.d.ts +0 -4
- package/build/AppBar/AppBar.types.d.ts +0 -2
- package/build/AutoComplete/AutoComplete.d.ts +0 -6
- package/build/AutoComplete/AutoComplete.types.d.ts +0 -23
- package/build/AutoComplete/BankCodes.d.ts +0 -5
- package/build/Banner/Banner.d.ts +0 -4
- package/build/Banner/Banner.types.d.ts +0 -10
- package/build/Breadcrumb/Breadcrumb.d.ts +0 -4
- package/build/Breadcrumb/Breadcrumb.types.d.ts +0 -7
- package/build/BreadcrumbItem/BreadcrumbItem.d.ts +0 -4
- package/build/BreadcrumbItem/BreadcrumbItem.types.d.ts +0 -4
- package/build/Button/Button.d.ts +0 -4
- package/build/Button/Button.types.d.ts +0 -13
- package/build/Card/Card.d.ts +0 -4
- package/build/Card/Card.types.d.ts +0 -17
- package/build/CheckBox/CheckBox.d.ts +0 -4
- package/build/CheckBox/CheckBox.types.d.ts +0 -7
- package/build/CheckBox/CheckBoxList.d.ts +0 -4
- package/build/CheckBox/CheckBoxList.types.d.ts +0 -9
- package/build/CheckBox/RadioButton.d.ts +0 -4
- package/build/CheckBox/RadioButton.types.d.ts +0 -7
- package/build/CheckBox/RadioList.d.ts +0 -4
- package/build/CheckBox/RadioList.types.d.ts +0 -9
- package/build/Chip/Chip.d.ts +0 -4
- package/build/Chip/Chip.types.d.ts +0 -11
- package/build/CircularProgress/CircularProgress.d.ts +0 -4
- package/build/CircularProgress/CircularProgress.types.d.ts +0 -5
- package/build/Container/Container.d.ts +0 -4
- package/build/Container/Container.types.d.ts +0 -7
- package/build/DatePicker/DatePicker.d.ts +0 -4
- package/build/DatePicker/DatePicker.types.d.ts +0 -14
- package/build/Dropdown/Dropdown.d.ts +0 -4
- package/build/Dropdown/Dropdown.types.d.ts +0 -9
- package/build/IconButton/IconButton.d.ts +0 -4
- package/build/IconButton/IconButton.types.d.ts +0 -7
- package/build/LandingPage/LandingPage.d.ts +0 -4
- package/build/LandingPage/LandingPage.types.d.ts +0 -14
- package/build/LandingPage/LandingPageMobile.d.ts +0 -4
- package/build/LandingPage/LandingPageMobile.types.d.ts +0 -14
- package/build/Link/Link.d.ts +0 -4
- package/build/Link/Link.types.d.ts +0 -4
- package/build/Menu/Menu.d.ts +0 -4
- package/build/Menu/Menu.types.d.ts +0 -3
- package/build/Menu/MenuItem.d.ts +0 -4
- package/build/Menu/MenuItem.types.d.ts +0 -12
- package/build/Menu/Select.d.ts +0 -4
- package/build/Menu/Select.types.d.ts +0 -41
- package/build/Modal/Modal.d.ts +0 -4
- package/build/Modal/Modal.types.d.ts +0 -55
- package/build/Pagination/Pagination.d.ts +0 -4
- package/build/Pagination/Pagination.types.d.ts +0 -3
- package/build/Paper/Paper.d.ts +0 -4
- package/build/Paper/Paper.types.d.ts +0 -5
- package/build/Progress/Progress.d.ts +0 -4
- package/build/Progress/Progress.types.d.ts +0 -8
- package/build/SWAPAppBar/SWAPAppBar.d.ts +0 -4
- package/build/SWAPAppBar/SWAPAppBar.types.d.ts +0 -19
- package/build/SWAPBanner/SWAPBanner.d.ts +0 -4
- package/build/SWAPBanner/SWAPBanner.types.d.ts +0 -16
- package/build/SWAPCopyField/SWAPCopyField.d.ts +0 -4
- package/build/SWAPCopyField/SWAPCopyField.types.d.ts +0 -8
- package/build/SWAPDialog/SWAPDialog.d.ts +0 -4
- package/build/SWAPDialog/SWAPDialog.types.d.ts +0 -18
- package/build/SWAPLogo/SWAPLogo.d.ts +0 -4
- package/build/SWAPLogo/SWAPLogo.types.d.ts +0 -10
- package/build/SWAPModal/SWAPModal.d.ts +0 -4
- package/build/SWAPModal/SWAPModal.types.d.ts +0 -29
- package/build/SWAPShare/SWAPShare.d.ts +0 -4
- package/build/SWAPShare/SWAPShare.types.d.ts +0 -6
- package/build/SWAPSpace/SWAPSpace.d.ts +0 -4
- package/build/SWAPSpace/SWAPSpace.types.d.ts +0 -3
- package/build/SWAPTaxField/SWAPTaxField.d.ts +0 -24
- package/build/SWAPTaxField/SWAPTaxField.types.d.ts +0 -13
- package/build/SWAPTheme/SWAPTheme.d.ts +0 -7
- package/build/SWAPTheme/SWAPTheme.types.d.ts +0 -166
- package/build/Skeleton/Skeleton.d.ts +0 -4
- package/build/Skeleton/Skeleton.types.d.ts +0 -3
- package/build/Snackbar/Snackbar.d.ts +0 -4
- package/build/Snackbar/Snackbar.types.d.ts +0 -20
- package/build/Styles/Styles.d.ts +0 -4
- package/build/Styles/Styles.types.d.ts +0 -8
- package/build/Switch/Switch.d.ts +0 -4
- package/build/Switch/Switch.types.d.ts +0 -3
- package/build/Tab/SegmentedTab.d.ts +0 -4
- package/build/Tab/SegmentedTab.types.d.ts +0 -7
- package/build/Tab/SegmentedTabs.d.ts +0 -4
- package/build/Tab/SegmentedTabs.types.d.ts +0 -5
- package/build/Tab/Tab.d.ts +0 -4
- package/build/Tab/Tab.types.d.ts +0 -10
- package/build/Tab/TabPanel.d.ts +0 -10
- package/build/Tab/Tabs.d.ts +0 -4
- package/build/Tab/Tabs.types.d.ts +0 -3
- package/build/Table/Table.d.ts +0 -4
- package/build/Table/Table.types.d.ts +0 -2
- package/build/TaxTextField/TaxTextField.d.ts +0 -24
- package/build/TaxTextField/TaxTextField.types.d.ts +0 -26
- package/build/TextField/TextField.d.ts +0 -4
- package/build/TextField/TextField.types.d.ts +0 -7
- package/build/Tooltip/Tooltip.d.ts +0 -4
- package/build/Tooltip/Tooltip.types.d.ts +0 -15
- package/build/Typography/Typography.d.ts +0 -4
- package/build/Typography/Typography.types.d.ts +0 -8
- package/build/index.esm.js +0 -13931
- package/build/index.esm.js.map +0 -1
- package/build/utils/useBreakpoints.d.ts +0 -2
package/README.md
CHANGED
|
@@ -1,61 +1,75 @@
|
|
|
1
1
|
<img src="https://blog.swap.work/wp-content/uploads/2021/02/cropped-SWAP_web-logo-01-2.png" width="150" />
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
# SWAP UI(v2)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
SWAP([www.swap.work](https://www.swap.work))的品牌 UI 套件,基於 [MUI v9](https://mui.com/) 全面重構。
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
2. 易於使用。儘量不需要再寫額外的輔助函式或是過於多層的元件包裝就能使用,避免 Material-ui 多層包裝的缺點
|
|
7
|
+
**v2 的核心理念是 theme-first**:品牌視覺(色彩、圓角、陰影、字體、各元件外觀)全部定義在一份 SWAP theme 裡——
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
1. **原生 MUI 元件自動長成品牌樣式**。`import Button from "@mui/material/Button"` 掛上 theme 後就是 SWAP 的六種按鈕,同時擁有 MUI 完整的元件庫與文件。
|
|
10
|
+
2. **swap-ui 只提供 MUI 沒有的東西**。品牌資產(SWAPLogo)、組合元件(Modal、Card、Snackbar…)、業務元件(TaxTextField)與 design tokens。
|
|
11
|
+
3. **效能**。v1(MUI v4 + JSS)的 runtime 樣式爆量問題在 v2(Emotion + theme 靜態化 + CSS variables)根治。
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
2. 瀏覽 <a href="https://yosgo-open-source.github.io/swap-ui/?path=/docs/swaplogo--%E8%AA%8D%E8%AD%98" target="_blank">Storybook</a>
|
|
13
|
+
元件預覽與使用手冊:`npm run storybook` 或瀏覽 <a href="https://yosgo-open-source.github.io/swap-ui/v2/" target="_blank">Storybook</a>(v1 手冊仍在 <a href="https://yosgo-open-source.github.io/swap-ui/" target="_blank">根路徑</a>)(每個元件都有「Docs」使用指南與可互動的 Playground)。
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
# 安裝
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
1. SWAPIncomeAndExpenseTypeField:依據工作內容提供所得類型的建議
|
|
21
|
-
1. SWAPPage: 讓用戶在完整的頁面中完成某件事情
|
|
22
|
-
1. SWAPAnnotatedLayout: 用於帳戶設定頁面中,解釋各類型設定
|
|
17
|
+
```bash
|
|
18
|
+
# peerDependencies(emotion 是 @mui/material 的 optional peer,必須明確安裝)
|
|
19
|
+
npm i react react-dom @mui/material @emotion/react @emotion/styled
|
|
23
20
|
|
|
24
|
-
#
|
|
21
|
+
# swap-ui
|
|
22
|
+
npm i @yosgo/swap-ui
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
# 快速開始
|
|
26
|
+
|
|
27
|
+
App 最外層包一次 `SWAPThemeProvider`(含品牌 theme、CssBaseline 與自托管字體):
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import { SWAPThemeProvider } from "@yosgo/swap-ui";
|
|
25
31
|
|
|
32
|
+
<SWAPThemeProvider>
|
|
33
|
+
<App />
|
|
34
|
+
</SWAPThemeProvider>
|
|
26
35
|
```
|
|
27
|
-
# peerDependencies
|
|
28
|
-
$ yarn add react react-dom styled-components @material-ui/core @material-ui/icons
|
|
29
36
|
|
|
30
|
-
|
|
31
|
-
|
|
37
|
+
之後:
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
// 一般元件直接用 MUI,樣式由 theme 自動套用
|
|
41
|
+
import Button from "@mui/material/Button";
|
|
42
|
+
<Button variant="primary" size="large">送出</Button>
|
|
43
|
+
|
|
44
|
+
// SWAP 專屬元件與 tokens 由 swap-ui 匯出
|
|
45
|
+
import { Typography, Modal, SWAPLogo, swapColors } from "@yosgo/swap-ui";
|
|
32
46
|
```
|
|
33
47
|
|
|
34
48
|
# 開發
|
|
35
49
|
|
|
50
|
+
```bash
|
|
51
|
+
npm run storybook # 元件預覽與手冊(localhost:6006)
|
|
52
|
+
npm test # 兩層測試:jsdom 單元 + Storybook 瀏覽器互動測試
|
|
53
|
+
npm run typecheck # TypeScript 檢查
|
|
54
|
+
npm run build # 打包(ESM + CJS + d.ts)
|
|
36
55
|
```
|
|
37
|
-
# 產生一個元件範本
|
|
38
|
-
$ yarn generate NewComponentName
|
|
39
56
|
|
|
40
|
-
|
|
41
|
-
$ yarn storybook
|
|
42
|
-
```
|
|
57
|
+
新元件慣例:實作(`src/components/X.tsx` + `X.types.ts`)+ story(含 Playground、controls 白名單)+ 手冊(`X.mdx`)+ 測試,並於 `src/index.ts` 匯出。詳見 `docs/superpowers/` 內的設計文件與各計劃。
|
|
43
58
|
|
|
44
|
-
#
|
|
59
|
+
# 發佈(⚠️ 安全規則)
|
|
45
60
|
|
|
46
|
-
|
|
47
|
-
# 發佈套件到 NPM 上
|
|
48
|
-
$ npm publish
|
|
61
|
+
現役產品鎖定 `^1.x`,v2 發佈**不可**推上 `latest`,一律:
|
|
49
62
|
|
|
50
|
-
|
|
51
|
-
|
|
63
|
+
```bash
|
|
64
|
+
# 預發佈(beta/alpha)一律指定 next tag
|
|
65
|
+
npm publish --tag next
|
|
52
66
|
|
|
53
|
-
#
|
|
54
|
-
|
|
67
|
+
# 發佈前後確認 dist-tags(latest 必須仍指向 1.x,直到正式切換)
|
|
68
|
+
npm dist-tag ls @yosgo/swap-ui
|
|
55
69
|
```
|
|
56
70
|
|
|
57
|
-
|
|
71
|
+
正式 `2.0.0` 需待產品端遷移驗收完成後,才發佈至 `latest`。完整規則見 `docs/superpowers/specs/2026-07-14-mui-v9-theme-first-migration-design.md` §6.1。
|
|
72
|
+
|
|
73
|
+
# v1 → v2
|
|
58
74
|
|
|
59
|
-
|
|
60
|
-
- [Material-ui and Typescript error when bundling #29](https://github.com/transitive-bullshit/react-modern-library-boilerplate/issues/29#issuecomment-635883117)
|
|
61
|
-
- [Shopify Polaris](https://5d559397bae39100201eedc1-jyzwfelqxv.chromatic.com/)
|
|
75
|
+
v1 原始碼封存於 `legacy/v1-src/`(master 分支保持 v1 原樣)。**遷移指南見 [MIGRATION.md](https://github.com/yosgo-open-source/swap-ui/blob/v2/MIGRATION.md)**(import 對照表、breaking 清單、Next.js / React Router 接入、常見錯誤對照),Storybook 手冊側欄最上方亦有同步的「遷移指南」頁。
|