knowidea-ui 0.9.0 → 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/dist/FeaturedList.d.ts +7 -0
- package/dist/FeaturedList.js +11 -0
- package/dist/Rating.d.ts +15 -0
- package/dist/Rating.js +19 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/package.json +7 -7
|
@@ -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/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";
|
|
@@ -37,6 +38,7 @@ export { Status, statusKinds, type StatusProps, type StatusKind, type StatusTone
|
|
|
37
38
|
export { Stat, Sparkline, type StatProps, type StatDelta, type SparklineProps } from "./Stat.js";
|
|
38
39
|
export { Chart, type ChartProps, type ChartPoint, type ChartBreakdown } from "./Chart.js";
|
|
39
40
|
export { Stack, Grid, Container, type StackProps, type GridProps, type ContainerProps, type Space } from "./Layout.js";
|
|
41
|
+
export { FeaturedList, type FeaturedListProps } from "./FeaturedList.js";
|
|
40
42
|
export { Card, type CardProps, type CardMeta } from "./Card.js";
|
|
41
43
|
export { Accordion, type AccordionProps, type AccordionItem } from "./Accordion.js";
|
|
42
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";
|
|
@@ -37,6 +38,7 @@ export { Status, statusKinds } from "./Status.js";
|
|
|
37
38
|
export { Stat, Sparkline } from "./Stat.js";
|
|
38
39
|
export { Chart } from "./Chart.js";
|
|
39
40
|
export { Stack, Grid, Container } from "./Layout.js";
|
|
41
|
+
export { FeaturedList } from "./FeaturedList.js";
|
|
40
42
|
export { Card } from "./Card.js";
|
|
41
43
|
export { Accordion } from "./Accordion.js";
|
|
42
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-
|
|
44
|
-
"knowidea-
|
|
45
|
-
"knowidea-tokens": "0.
|
|
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",
|