knowidea-ui 0.8.1 → 0.10.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 +2 -2
- package/dist/Display.d.ts +10 -0
- package/dist/Display.js +6 -0
- package/dist/FeaturedList.d.ts +7 -0
- package/dist/FeaturedList.js +11 -0
- package/dist/Jacket.d.ts +29 -0
- package/dist/Jacket.js +23 -0
- package/dist/Rating.d.ts +15 -0
- package/dist/Rating.js +19 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# knowidea-ui
|
|
2
2
|
|
|
3
|
-
KNOW IDEA UI の React の部品。
|
|
3
|
+
KNOW IDEA UI の React の部品。56 個。ボタン、入力、表、ダイアログ、トースト、大きな見出しと題字のジャケットなど。ライトとダークの両方に対応し、押せる所はすべて 44px 以上。
|
|
4
4
|
|
|
5
5
|
[ドキュメント](https://takikou347.github.io/knowidea-ui/) / [GitHub](https://github.com/takikou347/knowidea-ui) / MIT
|
|
6
6
|
|
|
@@ -35,4 +35,4 @@ export function App() {
|
|
|
35
35
|
| [knowidea-tokens](https://www.npmjs.com/package/knowidea-tokens) | 色、余白、角丸、書体の CSS 変数と、テーマを作る `createTheme` |
|
|
36
36
|
| [knowidea-css](https://www.npmjs.com/package/knowidea-css) | 部品の見た目(`ki-` のクラス)。素の HTML でも使える |
|
|
37
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 の部品
|
|
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;
|
package/dist/Display.js
ADDED
|
@@ -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,7 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef } from "react";
|
|
2
|
+
export interface FeaturedListProps extends ComponentPropsWithoutRef<"ul"> {
|
|
3
|
+
/** 1 つ目が大きな 1 つ、残りが小さな行。中身(題、添える 1 行、日付、画像)は子で渡す */
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
/** 大きな 1 つと小さな行で並べる。配置だけを持つ。className と style は外側の div.ki-featured、aria-* などは ul に渡る。入れ物の幅が 720 以上なら 2 列、狭ければ縦に積む。0 の時は何も描かない。 */
|
|
7
|
+
export declare function FeaturedList({ children, className, style, ...rest }: FeaturedListProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Children } from "react";
|
|
3
|
+
import { cx } from "./utils.js";
|
|
4
|
+
/** 大きな 1 つと小さな行で並べる。配置だけを持つ。className と style は外側の div.ki-featured、aria-* などは ul に渡る。入れ物の幅が 720 以上なら 2 列、狭ければ縦に積む。0 の時は何も描かない。 */
|
|
5
|
+
export function FeaturedList({ children, className, style, ...rest }) {
|
|
6
|
+
const items = Children.toArray(children);
|
|
7
|
+
if (items.length === 0)
|
|
8
|
+
return null;
|
|
9
|
+
const vars = { "--ki-rows": Math.max(items.length - 1, 1) };
|
|
10
|
+
return (_jsx("div", { className: cx("ki-featured", className), style: style, children: _jsx("ul", { className: "ki-featured__list", style: vars, ...rest, children: items.map((item, i) => _jsx("li", { "data-lead": i === 0 ? "" : undefined, children: item }, i)) }) }));
|
|
11
|
+
}
|
package/dist/Jacket.d.ts
ADDED
|
@@ -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/Rating.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface RatingProps {
|
|
2
|
+
/** 何の評価か。必須(読み上げの名前) */
|
|
3
|
+
label: string;
|
|
4
|
+
/** 段の数。既定は 5 */
|
|
5
|
+
max?: number;
|
|
6
|
+
value?: number;
|
|
7
|
+
defaultValue?: number;
|
|
8
|
+
/** あると選べる評価になる。無ければ見るだけ */
|
|
9
|
+
onValueChange?: (value: number) => void;
|
|
10
|
+
name?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
/** 星の評価。選べる時はラジオのグループ(矢印キーで選び直す)、見るだけの時は 1 枚の画像として読み上げる。押せる所は 44px。 */
|
|
15
|
+
export declare function Rating({ label, max, value, defaultValue, onValueChange, name, disabled, className }: RatingProps): import("react").JSX.Element;
|
package/dist/Rating.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useState } from "react";
|
|
3
|
+
import { cx } from "./utils.js";
|
|
4
|
+
/** 星の形。塗りと線は CSS が決める */
|
|
5
|
+
function Star() {
|
|
6
|
+
return (_jsx("svg", { className: "ki-rating__star", viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: _jsx("polygon", { points: "12,2.8 14.8,8.9 21.4,9.6 16.5,14.1 17.9,20.7 12,17.4 6.1,20.7 7.5,14.1 2.6,9.6 9.2,8.9" }) }));
|
|
7
|
+
}
|
|
8
|
+
/** 星の評価。選べる時はラジオのグループ(矢印キーで選び直す)、見るだけの時は 1 枚の画像として読み上げる。押せる所は 44px。 */
|
|
9
|
+
export function Rating({ label, max = 5, value, defaultValue = 0, onValueChange, name, disabled, className }) {
|
|
10
|
+
const auto = useId();
|
|
11
|
+
const [inner, setInner] = useState(defaultValue);
|
|
12
|
+
const now = value ?? inner;
|
|
13
|
+
const steps = Array.from({ length: max }, (_, i) => i + 1);
|
|
14
|
+
if (!onValueChange) {
|
|
15
|
+
const shown = Math.round(now);
|
|
16
|
+
return (_jsx("span", { className: cx("ki-rating", className), role: "img", "aria-label": `${label}: ${max} 段階中 ${shown}`, "data-readonly": "", children: steps.map((n) => _jsx("span", { className: "ki-rating__item", "data-filled": n <= shown ? "" : undefined, children: _jsx(Star, {}) }, n)) }));
|
|
17
|
+
}
|
|
18
|
+
return (_jsx("div", { className: cx("ki-rating", className), role: "radiogroup", "aria-label": label, "data-disabled": disabled ? "" : undefined, children: steps.map((n) => (_jsxs("label", { className: "ki-rating__item", "data-filled": n <= now ? "" : undefined, children: [_jsx("input", { type: "radio", className: "ki-rating__input", name: name ?? auto, value: n, "aria-label": `${max} 段階中 ${n}`, checked: now === n, disabled: disabled, onChange: () => { setInner(n); onValueChange(n); } }), _jsx(Star, {})] }, n))) }));
|
|
19
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export { Kbd, type KbdProps } from "./Kbd.js";
|
|
|
14
14
|
export { Slider, type SliderProps } from "./Slider.js";
|
|
15
15
|
export { Stepper, type StepperProps } from "./Stepper.js";
|
|
16
16
|
export { SegmentedControl, type SegmentedControlProps, type SegmentedOption } from "./SegmentedControl.js";
|
|
17
|
+
export { Rating, type RatingProps } from "./Rating.js";
|
|
17
18
|
export { Field, type FieldProps } from "./Field.js";
|
|
18
19
|
export { Table, type TableProps, type Column, type SortState, type SortDirection } from "./Table.js";
|
|
19
20
|
export { Tabs, type TabsProps, type TabItem } from "./Tabs.js";
|
|
@@ -27,6 +28,8 @@ export { Alert, type AlertProps, type Tone } from "./Alert.js";
|
|
|
27
28
|
export { Badge, type BadgeProps } from "./Badge.js";
|
|
28
29
|
export { CodeBlock, type CodeBlockProps } from "./CodeBlock.js";
|
|
29
30
|
export { Quote, type QuoteProps } from "./Quote.js";
|
|
31
|
+
export { Display, type DisplayProps } from "./Display.js";
|
|
32
|
+
export { Jacket, jacketFit, type JacketProps, type JacketFit } from "./Jacket.js";
|
|
30
33
|
export { Skeleton, SkeletonText, type SkeletonProps, type SkeletonTextProps } from "./Skeleton.js";
|
|
31
34
|
export { EmptyState, type EmptyStateProps } from "./EmptyState.js";
|
|
32
35
|
export { Divider, type DividerProps } from "./Divider.js";
|
|
@@ -35,6 +38,7 @@ export { Status, statusKinds, type StatusProps, type StatusKind, type StatusTone
|
|
|
35
38
|
export { Stat, Sparkline, type StatProps, type StatDelta, type SparklineProps } from "./Stat.js";
|
|
36
39
|
export { Chart, type ChartProps, type ChartPoint, type ChartBreakdown } from "./Chart.js";
|
|
37
40
|
export { Stack, Grid, Container, type StackProps, type GridProps, type ContainerProps, type Space } from "./Layout.js";
|
|
41
|
+
export { FeaturedList, type FeaturedListProps } from "./FeaturedList.js";
|
|
38
42
|
export { Card, type CardProps, type CardMeta } from "./Card.js";
|
|
39
43
|
export { Accordion, type AccordionProps, type AccordionItem } from "./Accordion.js";
|
|
40
44
|
export { Breadcrumbs, type BreadcrumbsProps, type BreadcrumbItem } from "./Breadcrumbs.js";
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ export { Kbd } from "./Kbd.js";
|
|
|
14
14
|
export { Slider } from "./Slider.js";
|
|
15
15
|
export { Stepper } from "./Stepper.js";
|
|
16
16
|
export { SegmentedControl } from "./SegmentedControl.js";
|
|
17
|
+
export { Rating } from "./Rating.js";
|
|
17
18
|
export { Field } from "./Field.js";
|
|
18
19
|
export { Table } from "./Table.js";
|
|
19
20
|
export { Tabs } from "./Tabs.js";
|
|
@@ -27,6 +28,8 @@ export { Alert } from "./Alert.js";
|
|
|
27
28
|
export { Badge } from "./Badge.js";
|
|
28
29
|
export { CodeBlock } from "./CodeBlock.js";
|
|
29
30
|
export { Quote } from "./Quote.js";
|
|
31
|
+
export { Display } from "./Display.js";
|
|
32
|
+
export { Jacket, jacketFit } from "./Jacket.js";
|
|
30
33
|
export { Skeleton, SkeletonText } from "./Skeleton.js";
|
|
31
34
|
export { EmptyState } from "./EmptyState.js";
|
|
32
35
|
export { Divider } from "./Divider.js";
|
|
@@ -35,6 +38,7 @@ export { Status, statusKinds } from "./Status.js";
|
|
|
35
38
|
export { Stat, Sparkline } from "./Stat.js";
|
|
36
39
|
export { Chart } from "./Chart.js";
|
|
37
40
|
export { Stack, Grid, Container } from "./Layout.js";
|
|
41
|
+
export { FeaturedList } from "./FeaturedList.js";
|
|
38
42
|
export { Card } from "./Card.js";
|
|
39
43
|
export { Accordion } from "./Accordion.js";
|
|
40
44
|
export { Breadcrumbs } from "./Breadcrumbs.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knowidea-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.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.
|
|
34
|
-
"knowidea-icons": "^0.
|
|
35
|
-
"knowidea-tokens": "^0.
|
|
33
|
+
"knowidea-css": "^0.10.0",
|
|
34
|
+
"knowidea-icons": "^0.10.0",
|
|
35
|
+
"knowidea-tokens": "^0.10.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-css": "0.
|
|
44
|
-
"knowidea-
|
|
45
|
-
"knowidea-
|
|
43
|
+
"knowidea-css": "0.10.0",
|
|
44
|
+
"knowidea-icons": "0.10.0",
|
|
45
|
+
"knowidea-tokens": "0.10.0"
|
|
46
46
|
},
|
|
47
47
|
"files": [
|
|
48
48
|
"dist",
|