knowidea-ui 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,40 +1,38 @@
1
1
  # knowidea-ui
2
2
 
3
- KNOW IDEA の UI ライブラリの React 19 コンポーネント。特定のアプリに依存しない。見た目は `knowidea-css` のクラスを当てるだけで、挙動が複雑なコンポーネント(Dialog、ConfirmDialog、Tabs、Menu、Tooltip、Select、Checkbox、Radio、Switch、Toast、Field、Input、Accordion、Progress、Avatar、Drawer、Sheet、SegmentedControl、DatePicker、Popover、Combobox、Slider、Stepper)は `@base-ui/react` 1.9.0 をベースに実装している。
3
+ KNOW IDEA UI の React の部品。56 個。ボタン、入力、表、ダイアログ、トースト、大きな見出しと題字のジャケットなど。ライトとダークの両方に対応し、押せる所はすべて 44px 以上。
4
4
 
5
- | コマンド | 中身 |
6
- | --- | --- |
7
- | `pnpm --filter knowidea-ui build` | tsc で `dist/` に JS と型定義を出力する |
8
-
9
- 事前に `knowidea-tokens` と `knowidea-icons` のビルドが必要。`pnpm -r build` は依存順にビルドする。
10
-
11
- ## 入れ方
5
+ [ドキュメント](https://takikou347.github.io/knowidea-ui/) / [GitHub](https://github.com/takikou347/knowidea-ui) / MIT
12
6
 
13
- npm などには出していない(公開先はまだ決まっていない)。リポジトリの `pnpm release:pack` で `release/` に tarball を作り、使う側で 4 つ全部を入れる。`knowidea-css`、`knowidea-icons`、`knowidea-tokens` は `peerDependencies` なので、同じコマンドで入れないと解決できない。手順は `apps/docs` の Installation。`pnpm test:consumer` が、新しいプロジェクトで手順どおりに動くことを確かめる。
14
-
15
- ## Components
16
-
17
- | Category | Components |
18
- | --- | --- |
19
- | Inputs | Button、IconButton、TextField、Input、Textarea、Select、Combobox、DatePicker、Calendar、Checkbox、Radio、SegmentedControl、Slider、Stepper、FileUpload、Switch、Field |
20
- | Data display | Avatar、Badge、Chip、Status、Stat(Sparkline)、Table、List(ListItem)、Timeline、Tooltip、Popover、Kbd、CodeBlock、Quote |
21
- | Feedback | Alert、Toast、Dialog、ConfirmDialog、Sheet、Progress、Skeleton、Spinner、EmptyState |
22
- | Surfaces | Card、Accordion、SelectionBar |
23
- | Navigation | Link、Tabs、Menu、Breadcrumbs、Pagination、AppBar、Drawer、BottomNavigation |
24
- | Layout | Stack、Grid、Container、Divider |
25
- | Charts | Chart(棒グラフと折れ線グラフ。追加の依存なしで、自前の SVG で描画する) |
26
- | Theme | ThemeProvider、createTheme |
7
+ ## 入れる
27
8
 
28
- すべてのコンポーネントが、Empty、Loading、Error、Disabled、Focus の 5 つの状態を備える。Props、CSS のクラスと変数、アクセシビリティは、`apps/docs`(ドキュメントサイト)の各ページに記載している。
29
-
30
- アイコンは `knowidea-icons` を使う。`Icon` は `ki-icon` クラスを付けたラッパーで、`name` には `icons.json` の名前を渡す。`icon` プロパティは ReactNode を受け取るため、`SearchIcon` のような名前ごとのコンポーネントも渡せる。
9
+ ```sh
10
+ npm install knowidea-ui knowidea-css knowidea-tokens knowidea-icons
11
+ ```
31
12
 
32
- ## Theme
13
+ ## 使う
33
14
 
34
15
  ```tsx
35
- <ThemeProvider theme={{ primary: "#016C6C", radius: 8, density: "compact", fontSize: 14 }}>
36
- <App />
37
- </ThemeProvider>
16
+ import "knowidea-tokens/tokens.css";
17
+ import "knowidea-css/index.css";
18
+ import { Button, ThemeProvider } from "knowidea-ui";
19
+
20
+ export function App() {
21
+ return (
22
+ <ThemeProvider theme={{ primary: "#016C6C" }}>
23
+ <Button>保存する</Button>
24
+ </ThemeProvider>
25
+ );
26
+ }
38
27
  ```
39
28
 
40
- 囲んだ範囲にだけ CSS 変数をオーバーライドする(ライトとダークの両方)。コントラスト比が 4.5:1 に届かない組み合わせは `console.warn` に出力される(`onWarn` で受け取れる)。仕組みは `packages/tokens/README.md` を参照。
29
+ 主の色、角丸、密度、字の大きさ、グラデーションの見た目(`look: "gradient"`)を `ThemeProvider` で変えられる。部品ごとの使い方はドキュメントにある。
30
+
31
+ ## 4 つのパッケージ
32
+
33
+ | パッケージ | 中身 |
34
+ | --- | --- |
35
+ | [knowidea-tokens](https://www.npmjs.com/package/knowidea-tokens) | 色、余白、角丸、書体の CSS 変数と、テーマを作る `createTheme` |
36
+ | [knowidea-css](https://www.npmjs.com/package/knowidea-css) | 部品の見た目(`ki-` のクラス)。素の HTML でも使える |
37
+ | [knowidea-icons](https://www.npmjs.com/package/knowidea-icons) | アイコン 133 個(SVG のスプライトと React) |
38
+ | [knowidea-ui](https://www.npmjs.com/package/knowidea-ui) | React 19 の部品 56 個。土台は Base UI |
@@ -0,0 +1,10 @@
1
+ import type { HTMLAttributes, ReactNode } from "react";
2
+ export interface DisplayProps extends HTMLAttributes<HTMLHeadingElement> {
3
+ /** 見出しの段。既定は h1(ページの題) */
4
+ as?: "h1" | "h2" | "h3" | "p";
5
+ /** 1 は画面で一番大きな字(1 画面に 1 か所)、2 は節の頭の大きな見出し */
6
+ size?: 1 | 2;
7
+ children: ReactNode;
8
+ }
9
+ /** 大きな見出し。書体は --font-display。ページの題と大きな見出しだけに使い、1 画面に 1〜2 か所にする。 */
10
+ export declare function Display({ as: Tag, size, className, children, ...rest }: DisplayProps): import("react").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cx } from "./utils.js";
3
+ /** 大きな見出し。書体は --font-display。ページの題と大きな見出しだけに使い、1 画面に 1〜2 か所にする。 */
4
+ export function Display({ as: Tag = "h1", size = 1, className, children, ...rest }) {
5
+ return (_jsx(Tag, { className: cx("ki-display", className), "data-size": size === 2 ? "2" : undefined, ...rest, children: children }));
6
+ }
@@ -0,0 +1,29 @@
1
+ import { type CSSProperties, type ReactNode } from "react";
2
+ export type JacketFit = "xl" | "l" | "m" | "s";
3
+ export interface JacketProps {
4
+ /** 題字。"\n" で行を切れる("夜更けの\n台所ラジオ") */
5
+ title: string;
6
+ /** 題の後ろに添える 1 行(番組名、回の番号など)。題の上には置かない */
7
+ meta?: ReactNode;
8
+ /** 面の色。primary(主の色)、ink(字の色の面)、paper(淡い面) */
9
+ tone?: "primary" | "ink" | "paper";
10
+ /** 番組ごとの面の色。textColor と組で渡し、字との差は 3:1 以上にする(題字は大きな字) */
11
+ color?: string;
12
+ textColor?: string;
13
+ /** 形。square は 1:1、portrait は 4:5、landscape は 16:9 */
14
+ ratio?: "square" | "portrait" | "landscape";
15
+ /** 題を上に置くか(start)、下に寄せるか(end) */
16
+ align?: "start" | "end";
17
+ /** vertical は題を縦書きにする */
18
+ orientation?: "horizontal" | "vertical";
19
+ /** 題字の大きさ。auto は題の長さから選ぶ */
20
+ fit?: "auto" | JacketFit;
21
+ /** 隣に同じ題が文字で出ている時は true。読み上げから外す */
22
+ decorative?: boolean;
23
+ className?: string;
24
+ style?: CSSProperties;
25
+ }
26
+ /** 題の長さから字の大きさの段を選ぶ。漢字とかなは 1、英数字と空白は 0.55 と数える(一番長い行で見る) */
27
+ export declare function jacketFit(title: string): JacketFit;
28
+ /** 題字のジャケット。番組や作品の顔を、アイコンのタイルでなく題字で出す。角丸は持たない。 */
29
+ export declare function Jacket({ title, meta, tone, color, textColor, ratio, align, orientation, fit, decorative, className, style, }: JacketProps): import("react").JSX.Element;
package/dist/Jacket.js ADDED
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Fragment } from "react";
3
+ import { cx } from "./utils.js";
4
+ /** 題の長さから字の大きさの段を選ぶ。漢字とかなは 1、英数字と空白は 0.55 と数える(一番長い行で見る) */
5
+ export function jacketFit(title) {
6
+ const width = Math.max(...title.split("\n").map((line) => [...line].reduce((n, ch) => n + (/[\u0000-ɏ]/.test(ch) ? 0.55 : 1), 0)));
7
+ const lines = title.split("\n").length;
8
+ const total = width * lines;
9
+ if (total <= 4)
10
+ return "xl";
11
+ if (total <= 9)
12
+ return "l";
13
+ if (total <= 18)
14
+ return "m";
15
+ return "s";
16
+ }
17
+ /** 題字のジャケット。番組や作品の顔を、アイコンのタイルでなく題字で出す。角丸は持たない。 */
18
+ export function Jacket({ title, meta, tone = "primary", color, textColor, ratio = "square", align = "start", orientation = "horizontal", fit = "auto", decorative = false, className, style, }) {
19
+ const f = fit === "auto" ? jacketFit(title) : fit;
20
+ const vars = { ...(color ? { "--ki-jacket-bg": color } : {}), ...(textColor ? { "--ki-jacket-fg": textColor } : {}), ...style };
21
+ const lines = title.split("\n");
22
+ return (_jsx("div", { className: cx("ki-jacket", className), "data-tone": tone === "primary" ? undefined : tone, "data-ratio": ratio === "square" ? undefined : ratio, "data-align": align === "end" ? "end" : undefined, "data-orientation": orientation === "vertical" ? "vertical" : undefined, "data-fit": f === "m" ? undefined : f, "aria-hidden": decorative ? true : undefined, style: vars, children: _jsxs("div", { className: "ki-jacket__face", children: [_jsx("p", { className: "ki-jacket__title", children: lines.map((line, i) => _jsxs(Fragment, { children: [i > 0 ? _jsx("br", {}) : null, line] }, i)) }), meta ? _jsx("p", { className: "ki-jacket__meta", children: meta }) : null] }) }));
23
+ }
package/dist/index.d.ts CHANGED
@@ -27,6 +27,8 @@ export { Alert, type AlertProps, type Tone } from "./Alert.js";
27
27
  export { Badge, type BadgeProps } from "./Badge.js";
28
28
  export { CodeBlock, type CodeBlockProps } from "./CodeBlock.js";
29
29
  export { Quote, type QuoteProps } from "./Quote.js";
30
+ export { Display, type DisplayProps } from "./Display.js";
31
+ export { Jacket, jacketFit, type JacketProps, type JacketFit } from "./Jacket.js";
30
32
  export { Skeleton, SkeletonText, type SkeletonProps, type SkeletonTextProps } from "./Skeleton.js";
31
33
  export { EmptyState, type EmptyStateProps } from "./EmptyState.js";
32
34
  export { Divider, type DividerProps } from "./Divider.js";
package/dist/index.js CHANGED
@@ -27,6 +27,8 @@ export { Alert } from "./Alert.js";
27
27
  export { Badge } from "./Badge.js";
28
28
  export { CodeBlock } from "./CodeBlock.js";
29
29
  export { Quote } from "./Quote.js";
30
+ export { Display } from "./Display.js";
31
+ export { Jacket, jacketFit } from "./Jacket.js";
30
32
  export { Skeleton, SkeletonText } from "./Skeleton.js";
31
33
  export { EmptyState } from "./EmptyState.js";
32
34
  export { Divider } from "./Divider.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knowidea-ui",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "KNOW IDEA UI の React の部品(Base UI が土台)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -30,9 +30,9 @@
30
30
  "peerDependencies": {
31
31
  "react": "^19.0.0",
32
32
  "react-dom": "^19.0.0",
33
- "knowidea-css": "^0.8.0",
34
- "knowidea-icons": "^0.8.0",
35
- "knowidea-tokens": "^0.8.0"
33
+ "knowidea-css": "^0.9.0",
34
+ "knowidea-icons": "^0.9.0",
35
+ "knowidea-tokens": "^0.9.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/react": "19.3.0",
@@ -40,9 +40,9 @@
40
40
  "react": "19.3.0",
41
41
  "react-dom": "19.3.0",
42
42
  "typescript": "5.9.3",
43
- "knowidea-icons": "0.8.0",
44
- "knowidea-css": "0.8.0",
45
- "knowidea-tokens": "0.8.0"
43
+ "knowidea-icons": "0.9.0",
44
+ "knowidea-css": "0.9.0",
45
+ "knowidea-tokens": "0.9.0"
46
46
  },
47
47
  "files": [
48
48
  "dist",