@omit-design/preset-mobile 0.2.2 → 0.2.4

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 CHANGED
@@ -14,12 +14,14 @@
14
14
  - **21 `Om*` components** — the import whitelist for `design/**/*.tsx`
15
15
  - **`--om-*` token system** mapped to Ionic 8 runtime (`--ion-*`)
16
16
  - **8 patterns** with copy-paste `.tmpl.tsx` skeletons (consumed by `omit-design new-page`)
17
+ - **`patterns.config.json`** — pattern → signature components map, consumed by the `require-pattern-components` ESLint rule
17
18
 
18
- ## Three hard rules (enforced by [@omit-design/eslint-plugin](../eslint-plugin/))
19
+ ## Four hard rules (enforced by [@omit-design/eslint-plugin](../eslint-plugin/))
19
20
 
20
21
  1. **Tokens only.** All colors / spacing / font sizes / radii / shadows must go through tokens. Raw literals (`#FF6B00`, `12px`, `16px`, etc.) are forbidden in business code.
21
22
  2. **Whitelist imports.** Business pages (under `design/**`) can only import from `@omit-design/preset-mobile`. Direct `@ionic/react` imports are forbidden — exceptions: `IonList`, `IonBackButton`, `IonIcon` (layout / icon hosts only).
22
23
  3. **Pattern header.** Every business page must start with `// @pattern: <name>`, where `<name>` is registered in [PATTERNS.md](./PATTERNS.md).
24
+ 4. **Pattern-scoped components.** The declared pattern must actually use one of its signature components. `@pattern: list-view` requires `OmListRow` / `OmCouponCard` / `OmSettingRow` / `OmProductCard` / `OmMenuCard` / `OmEmptyState`; `@pattern: form-view` requires `OmInput` / `OmSelect` / `OmNumpad`; etc. Mapping in [`patterns.config.json`](./patterns.config.json).
23
25
 
24
26
  ## Components (21)
25
27
 
@@ -63,6 +65,15 @@ npx omit-design new-page list-view design/orders/list
63
65
  # → design/orders/list.tsx with the list-view skeleton
64
66
  ```
65
67
 
68
+ ### Adding / customizing patterns
69
+
70
+ When adding a pattern via the `add-pattern` skill (or by hand), update three places:
71
+ 1. [`PATTERNS.md`](./PATTERNS.md) — human documentation of the pattern's intent and skeleton.
72
+ 2. [`templates/<name>.tmpl.tsx`](./templates/) — copy-paste skeleton consumed by `omit-design new-page`.
73
+ 3. [`patterns.config.json`](./patterns.config.json) — list of signature components the pattern requires (read by the `require-pattern-components` ESLint rule).
74
+
75
+ The signature components are the bare minimum without which a file cannot meaningfully be that pattern. For `list-view` it's "any list-row / empty-state component"; for `form-view` it's "any input component". Lists are "anyOf" — importing one is enough.
76
+
66
77
  ## Token naming
67
78
 
68
79
  | Family | Examples |
package/README.zh-CN.md CHANGED
@@ -14,12 +14,14 @@
14
14
  - **21 个 `Om*` 组件** — `design/**/*.tsx` 的 import 白名单
15
15
  - **`--om-*` token 体系**,映射到 Ionic 8 运行时(`--ion-*`)
16
16
  - **8 个 pattern** + 对应的 `.tmpl.tsx` 模板(`omit-design new-page` 消费)
17
+ - **`patterns.config.json`** — pattern → 签名组件映射,由 `require-pattern-components` ESLint 规则消费
17
18
 
18
- ## 三条硬规则(由 [@omit-design/eslint-plugin](../eslint-plugin/) 强制)
19
+ ## 四条硬规则(由 [@omit-design/eslint-plugin](../eslint-plugin/) 强制)
19
20
 
20
21
  1. **Token 优先**:所有颜色、间距、字号、圆角、阴影必须走 token,**禁止字面量**(`#FF6B00`、`12px`、`16px` 等都不允许出现在业务代码里)。
21
22
  2. **组件白名单**:业务页面(`design/**`)只能 import `@omit-design/preset-mobile`,**禁止**直接 import `@ionic/react`(例外:`IonList` / `IonBackButton` / `IonIcon`,仅做排版/图标宿主)。
22
23
  3. **模式标注**:每个业务页面文件头第一行必须是 `// @pattern: <name>`,`<name>` 必须在 [PATTERNS.md](./PATTERNS.md) 里登记。
24
+ 4. **Pattern 签名组件强制**:声明的 pattern 必须真用其签名组件。`@pattern: list-view` 必须 import `OmListRow` / `OmCouponCard` / `OmSettingRow` / `OmProductCard` / `OmMenuCard` / `OmEmptyState` 至少一个;`@pattern: form-view` 必须 import `OmInput` / `OmSelect` / `OmNumpad` 至少一个;其它 pattern 同理。映射见 [`patterns.config.json`](./patterns.config.json)。
23
25
 
24
26
  ## 组件清单(21 个)
25
27
 
@@ -64,6 +66,15 @@ npx omit-design new-page list-view design/orders/list
64
66
  # → design/orders/list.tsx 已含 list-view 骨架
65
67
  ```
66
68
 
69
+ ### 加 / 改 pattern
70
+
71
+ 用 `add-pattern` skill(或手工)新增 pattern 时,要同步三处:
72
+ 1. [`PATTERNS.md`](./PATTERNS.md) — pattern 意图和骨架的人类文档
73
+ 2. [`templates/<name>.tmpl.tsx`](./templates/) — 可复制骨架,`omit-design new-page` 消费
74
+ 3. [`patterns.config.json`](./patterns.config.json) — pattern 必须的签名组件清单(被 `require-pattern-components` ESLint 规则读)
75
+
76
+ 签名组件是"没有就不算这个 pattern"的最小集 — `list-view` 是"任一列表行 / 空态组件";`form-view` 是"任一输入组件"。是 anyOf 关系,import 一个就过。
77
+
67
78
  ## Token 命名
68
79
 
69
80
  | 类别 | 例子 |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omit-design/preset-mobile",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "type": "module",
5
5
  "description": "Mobile design preset for omit-design: Om* whitelist components, --om-* / --ion-* token map, Ionic 8 runtime.",
6
6
  "main": "./index.ts",
@@ -26,6 +26,7 @@
26
26
  "preset.manifest.ts",
27
27
  "catalog.tsx",
28
28
  "PATTERNS.md",
29
+ "patterns.config.json",
29
30
  "README.md"
30
31
  ],
31
32
  "license": "MIT",
@@ -0,0 +1,13 @@
1
+ {
2
+ "$schema": "./patterns.schema.json",
3
+ "patterns": {
4
+ "list-view": ["OmListRow", "OmCouponCard", "OmSettingRow", "OmProductCard", "OmMenuCard", "OmEmptyState"],
5
+ "detail-view": ["OmCard"],
6
+ "form-view": ["OmInput", "OmSelect", "OmNumpad"],
7
+ "sheet-action": ["OmSheet"],
8
+ "dialog-view": ["OmDialog"],
9
+ "welcome-view": ["OmButton"],
10
+ "dashboard": ["OmStatCard", "OmMenuCard"],
11
+ "tab-view": ["OmTabBar"]
12
+ }
13
+ }