knowidea-ui 0.0.0-stage → 0.8.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/LICENSE +21 -0
- package/README.md +37 -2
- package/dist/Accordion.d.ts +21 -0
- package/dist/Accordion.js +8 -0
- package/dist/Alert.d.ts +17 -0
- package/dist/Alert.js +9 -0
- package/dist/AppBar.d.ts +18 -0
- package/dist/AppBar.js +7 -0
- package/dist/Avatar.d.ts +11 -0
- package/dist/Avatar.js +17 -0
- package/dist/Badge.d.ts +10 -0
- package/dist/Badge.js +5 -0
- package/dist/BottomNavigation.d.ts +13 -0
- package/dist/BottomNavigation.js +7 -0
- package/dist/Breadcrumbs.d.ts +14 -0
- package/dist/Breadcrumbs.js +9 -0
- package/dist/Button.d.ts +14 -0
- package/dist/Button.js +13 -0
- package/dist/Calendar.d.ts +28 -0
- package/dist/Calendar.js +131 -0
- package/dist/Card.d.ts +34 -0
- package/dist/Card.js +13 -0
- package/dist/Chart.d.ts +41 -0
- package/dist/Chart.js +93 -0
- package/dist/Chip.d.ts +19 -0
- package/dist/Chip.js +19 -0
- package/dist/Choice.d.ts +49 -0
- package/dist/Choice.js +20 -0
- package/dist/CodeBlock.d.ts +12 -0
- package/dist/CodeBlock.js +25 -0
- package/dist/Combobox.d.ts +30 -0
- package/dist/Combobox.js +21 -0
- package/dist/DatePicker.d.ts +19 -0
- package/dist/DatePicker.js +29 -0
- package/dist/Dialog.d.ts +35 -0
- package/dist/Dialog.js +19 -0
- package/dist/Divider.d.ts +8 -0
- package/dist/Divider.js +8 -0
- package/dist/Drawer.d.ts +33 -0
- package/dist/Drawer.js +19 -0
- package/dist/EmptyState.d.ts +12 -0
- package/dist/EmptyState.js +5 -0
- package/dist/Field.d.ts +14 -0
- package/dist/Field.js +7 -0
- package/dist/FileUpload.d.ts +23 -0
- package/dist/FileUpload.js +116 -0
- package/dist/Icon.d.ts +9 -0
- package/dist/Icon.js +7 -0
- package/dist/IconButton.d.ts +8 -0
- package/dist/IconButton.js +13 -0
- package/dist/Input.d.ts +14 -0
- package/dist/Input.js +14 -0
- package/dist/Kbd.d.ts +7 -0
- package/dist/Kbd.js +13 -0
- package/dist/Layout.d.ts +39 -0
- package/dist/Layout.js +24 -0
- package/dist/Link.d.ts +11 -0
- package/dist/Link.js +5 -0
- package/dist/List.d.ts +45 -0
- package/dist/List.js +28 -0
- package/dist/Menu.d.ts +22 -0
- package/dist/Menu.js +16 -0
- package/dist/NavItems.d.ts +10 -0
- package/dist/NavItems.js +1 -0
- package/dist/Pagination.d.ts +16 -0
- package/dist/Pagination.js +32 -0
- package/dist/Popover.d.ts +22 -0
- package/dist/Popover.js +10 -0
- package/dist/Progress.d.ts +16 -0
- package/dist/Progress.js +9 -0
- package/dist/Quote.d.ts +8 -0
- package/dist/Quote.js +5 -0
- package/dist/SegmentedControl.d.ts +24 -0
- package/dist/SegmentedControl.js +8 -0
- package/dist/Select.d.ts +20 -0
- package/dist/Select.js +10 -0
- package/dist/SelectionBar.d.ts +27 -0
- package/dist/SelectionBar.js +12 -0
- package/dist/Sheet.d.ts +22 -0
- package/dist/Sheet.js +16 -0
- package/dist/Skeleton.d.ts +13 -0
- package/dist/Skeleton.js +9 -0
- package/dist/Slider.d.ts +27 -0
- package/dist/Slider.js +10 -0
- package/dist/Spinner.d.ts +6 -0
- package/dist/Spinner.js +5 -0
- package/dist/Stat.d.ts +44 -0
- package/dist/Stat.js +21 -0
- package/dist/Status.d.ts +26 -0
- package/dist/Status.js +21 -0
- package/dist/Stepper.d.ts +23 -0
- package/dist/Stepper.js +8 -0
- package/dist/Table.d.ts +45 -0
- package/dist/Table.js +177 -0
- package/dist/Tabs.d.ts +17 -0
- package/dist/Tabs.js +6 -0
- package/dist/TextField.d.ts +20 -0
- package/dist/TextField.js +7 -0
- package/dist/ThemeProvider.d.ts +18 -0
- package/dist/ThemeProvider.js +26 -0
- package/dist/ThemeScope.d.ts +11 -0
- package/dist/ThemeScope.js +13 -0
- package/dist/Timeline.d.ts +28 -0
- package/dist/Timeline.js +16 -0
- package/dist/Toast.d.ts +21 -0
- package/dist/Toast.js +29 -0
- package/dist/Tooltip.d.ts +9 -0
- package/dist/Tooltip.js +7 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.js +52 -0
- package/dist/motion.d.ts +6 -0
- package/dist/motion.js +39 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +11 -0
- package/package.json +53 -3
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
type InputAttrs = Omit<ComponentPropsWithoutRef<"input">, "children" | "size">;
|
|
3
|
+
export interface TextFieldProps extends InputAttrs {
|
|
4
|
+
/** ラベル。必須 */
|
|
5
|
+
label: ReactNode;
|
|
6
|
+
/** 補足。入力の前に知っておくこと */
|
|
7
|
+
hint?: ReactNode;
|
|
8
|
+
/** 誤り。あると失敗になり、理由が欄の下に出る */
|
|
9
|
+
error?: ReactNode;
|
|
10
|
+
/** 複数行にする */
|
|
11
|
+
multiline?: boolean;
|
|
12
|
+
rows?: number;
|
|
13
|
+
/** 読み込み中。右端に回転を出す(1 行のみ) */
|
|
14
|
+
loading?: boolean;
|
|
15
|
+
/** 等幅の数字 */
|
|
16
|
+
numeric?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** ラベル、入力、補足、誤りを 1 つにした欄。 */
|
|
19
|
+
export declare function TextField({ label, hint, error, required, disabled, multiline, rows, loading, numeric, className, ...rest }: TextFieldProps): import("react").JSX.Element;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Field } from "./Field.js";
|
|
3
|
+
import { Input, Textarea } from "./Input.js";
|
|
4
|
+
/** ラベル、入力、補足、誤りを 1 つにした欄。 */
|
|
5
|
+
export function TextField({ label, hint, error, required, disabled, multiline, rows, loading, numeric, className, ...rest }) {
|
|
6
|
+
return (_jsx(Field, { label: label, hint: hint, error: error, required: required, disabled: disabled, className: className, children: multiline ? (_jsx(Textarea, { invalid: !!error, rows: rows, disabled: disabled, required: required, ...rest })) : (_jsx(Input, { invalid: !!error, loading: loading, numeric: numeric, disabled: disabled, required: required, ...rest })) }));
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ElementType, type ReactNode } from "react";
|
|
2
|
+
import { createTheme, type ThemeOptions, type ThemeWarning } from "knowidea-tokens/create-theme";
|
|
3
|
+
export interface ThemeProviderProps {
|
|
4
|
+
/** 主の色、角丸、密度、字の大きさ、見た目(look)。無い項目は基本のまま */
|
|
5
|
+
theme: ThemeOptions;
|
|
6
|
+
/** 描画する要素。既定は div(display: contents なので、見た目の箱は作らない) */
|
|
7
|
+
as?: ElementType;
|
|
8
|
+
/** コントラストが足りないとき呼ばれる。既定は console.warn */
|
|
9
|
+
onWarn?: (warnings: ThemeWarning[]) => void;
|
|
10
|
+
className?: string;
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 子の下の CSS 変数を上書きする。<style> を子の前に出すので、SSR でもちらつかない。
|
|
15
|
+
* ライトとダークの両方を作る(ダークは同じ色相で明るくした別の値)。
|
|
16
|
+
*/
|
|
17
|
+
export declare function ThemeProvider({ theme, as: Tag, onWarn, className, children }: ThemeProviderProps): import("react").JSX.Element;
|
|
18
|
+
export { createTheme, type ThemeOptions, type ThemeWarning };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useContext, useId, useMemo } from "react";
|
|
3
|
+
import { createTheme } from "knowidea-tokens/create-theme";
|
|
4
|
+
import { cx } from "./utils.js";
|
|
5
|
+
import { ThemeLookContext, ThemeScopeContext } from "./ThemeScope.js";
|
|
6
|
+
/**
|
|
7
|
+
* 子の下の CSS 変数を上書きする。<style> を子の前に出すので、SSR でもちらつかない。
|
|
8
|
+
* ライトとダークの両方を作る(ダークは同じ色相で明るくした別の値)。
|
|
9
|
+
*/
|
|
10
|
+
export function ThemeProvider({ theme, as: Tag = "div", onWarn, className, children }) {
|
|
11
|
+
const id = "ki" + useId().replace(/[^a-zA-Z0-9]/g, "");
|
|
12
|
+
const key = JSON.stringify(theme);
|
|
13
|
+
const built = useMemo(() => createTheme(theme), [key]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
14
|
+
if (built.warnings.length > 0) {
|
|
15
|
+
if (onWarn)
|
|
16
|
+
onWarn(built.warnings);
|
|
17
|
+
else if (typeof console !== "undefined")
|
|
18
|
+
for (const w of built.warnings)
|
|
19
|
+
console.warn("[knowidea-ui] ThemeProvider: " + w.message);
|
|
20
|
+
}
|
|
21
|
+
// look を書かなければ外の ThemeProvider の見た目を受け継ぐ。"flat" と書けば、その下はグラデーションを外す
|
|
22
|
+
const outer = useContext(ThemeLookContext);
|
|
23
|
+
const look = theme.look === undefined ? outer : theme.look === "gradient" ? "gradient" : outer ? "flat" : null;
|
|
24
|
+
return (_jsxs(Tag, { className: cx(className), "data-ki-theme": id, "data-ki-look": look ?? undefined, style: { display: "contents" }, children: [_jsx("style", { children: built.css(`[data-ki-theme="${id}"]`) }), _jsx(ThemeScopeContext.Provider, { value: id, children: _jsx(ThemeLookContext.Provider, { value: look, children: children }) })] }));
|
|
25
|
+
}
|
|
26
|
+
export { createTheme };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ThemeProvider の id。ポータルに出る物(Dialog、Menu、Select、Tooltip、Toast、Drawer)は、
|
|
3
|
+
* ThemeProvider の外(body の直下)に描かれるため、この id を属性で付けて、テーマの変数を届ける。
|
|
4
|
+
*/
|
|
5
|
+
export declare const ThemeScopeContext: import("react").Context<string | null>;
|
|
6
|
+
/** ThemeProvider の見た目(look)。ポータルにも data-ki-look で届ける。外に gradient が無ければ null */
|
|
7
|
+
export declare const ThemeLookContext: import("react").Context<"flat" | "gradient" | null>;
|
|
8
|
+
export declare function useThemeScope(): {
|
|
9
|
+
"data-ki-theme"?: string;
|
|
10
|
+
"data-ki-look"?: string;
|
|
11
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* ThemeProvider の id。ポータルに出る物(Dialog、Menu、Select、Tooltip、Toast、Drawer)は、
|
|
4
|
+
* ThemeProvider の外(body の直下)に描かれるため、この id を属性で付けて、テーマの変数を届ける。
|
|
5
|
+
*/
|
|
6
|
+
export const ThemeScopeContext = createContext(null);
|
|
7
|
+
/** ThemeProvider の見た目(look)。ポータルにも data-ki-look で届ける。外に gradient が無ければ null */
|
|
8
|
+
export const ThemeLookContext = createContext(null);
|
|
9
|
+
export function useThemeScope() {
|
|
10
|
+
const id = useContext(ThemeScopeContext);
|
|
11
|
+
const look = useContext(ThemeLookContext);
|
|
12
|
+
return { ...(id ? { "data-ki-theme": id } : null), ...(look ? { "data-ki-look": look } : null) };
|
|
13
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { type IconName } from "./Icon.js";
|
|
3
|
+
export interface TimelineEntry {
|
|
4
|
+
id: string;
|
|
5
|
+
/** 時刻の文(例: 10/13 09:28)。等幅で出る */
|
|
6
|
+
time: string;
|
|
7
|
+
/** 太字の短い題(例: 公開) */
|
|
8
|
+
title: string;
|
|
9
|
+
/** 1 行の中身 */
|
|
10
|
+
text: ReactNode;
|
|
11
|
+
icon?: IconName;
|
|
12
|
+
/** 印の色 */
|
|
13
|
+
tone?: "success" | "warn" | "error" | "info";
|
|
14
|
+
/** あると中身がリンクになり、行全体が押せる */
|
|
15
|
+
href?: string;
|
|
16
|
+
/** 時刻の隣に出す補足(誰が、どこで) */
|
|
17
|
+
meta?: ReactNode;
|
|
18
|
+
}
|
|
19
|
+
export interface TimelineProps {
|
|
20
|
+
items: TimelineEntry[];
|
|
21
|
+
state?: "ready" | "loading" | "empty" | "error";
|
|
22
|
+
emptyText?: string;
|
|
23
|
+
errorText?: string;
|
|
24
|
+
loadingText?: string;
|
|
25
|
+
className?: string;
|
|
26
|
+
}
|
|
27
|
+
/** 新しい順のイベントの一覧。 */
|
|
28
|
+
export declare function Timeline({ items, state, emptyText, errorText, loadingText, className }: TimelineProps): import("react").JSX.Element;
|
package/dist/Timeline.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { EmptyState } from "./EmptyState.js";
|
|
3
|
+
import { Icon } from "./Icon.js";
|
|
4
|
+
import { Skeleton } from "./Skeleton.js";
|
|
5
|
+
import { cx } from "./utils.js";
|
|
6
|
+
/** 新しい順のイベントの一覧。 */
|
|
7
|
+
export function Timeline({ items, state = "ready", emptyText = "まだイベントはない", errorText = "イベントを取得できなかった。", loadingText = "読み込み中", className }) {
|
|
8
|
+
if (state === "empty")
|
|
9
|
+
return _jsx(EmptyState, { title: emptyText, icon: _jsx(Icon, { name: "pulse" }) });
|
|
10
|
+
if (state === "error")
|
|
11
|
+
return _jsx(EmptyState, { title: errorText, icon: _jsx(Icon, { name: "warning" }) });
|
|
12
|
+
if (state === "loading") {
|
|
13
|
+
return (_jsxs("ul", { className: cx("ki-timeline", className), "aria-busy": "true", children: [_jsxs("li", { className: "ki-timeline__item", style: { gridTemplateColumns: "1fr" }, children: [_jsx("span", { className: "ki-sr-only", role: "status", children: loadingText }), _jsx(Skeleton, { size: "long" }), _jsx(Skeleton, { size: "medium" })] }), _jsxs("li", { className: "ki-timeline__item", style: { gridTemplateColumns: "1fr" }, children: [_jsx(Skeleton, { size: "long" }), _jsx(Skeleton, { size: "short" })] })] }));
|
|
14
|
+
}
|
|
15
|
+
return (_jsx("ul", { className: cx("ki-timeline", className), children: items.map((it) => (_jsxs("li", { className: "ki-timeline__item", "data-tone": it.tone, children: [_jsx("span", { className: "ki-timeline__icon", children: _jsx(Icon, { name: it.icon ?? "note" }) }), _jsxs("div", { className: "ki-timeline__body", children: [_jsxs("p", { className: "ki-timeline__text", children: [_jsx("span", { className: "ki-timeline__title", children: it.title }), " ", it.href ? _jsx("a", { href: it.href, children: it.text }) : it.text] }), _jsxs("p", { className: "ki-timeline__meta", children: [it.meta ? _jsx("span", { children: it.meta }) : null, _jsx("time", { children: it.time })] })] })] }, it.id))) }));
|
|
16
|
+
}
|
package/dist/Toast.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export type ToastTone = "info" | "success" | "warn" | "error";
|
|
3
|
+
export interface ToastProviderProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
/** 自動で消えるまでの ms。0 で消えない。既定 5000 */
|
|
6
|
+
timeout?: number;
|
|
7
|
+
/** 同時に出す数 */
|
|
8
|
+
limit?: number;
|
|
9
|
+
}
|
|
10
|
+
/** アプリの根に 1 つ置く。中から useToast() で出す。ThemeProvider の内でも外でもよい(テーマは useToast を呼んだ所のものが当たる) */
|
|
11
|
+
export declare function ToastProvider({ children, timeout, limit }: ToastProviderProps): import("react").JSX.Element;
|
|
12
|
+
export interface ToastOptions {
|
|
13
|
+
title: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
tone?: ToastTone;
|
|
16
|
+
timeout?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare function useToast(): {
|
|
19
|
+
show: (o: ToastOptions) => string;
|
|
20
|
+
close: (id?: string) => void;
|
|
21
|
+
};
|
package/dist/Toast.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { ThemeLookContext, ThemeScopeContext, useThemeScope } from "./ThemeScope.js";
|
|
3
|
+
import { useContext } from "react";
|
|
4
|
+
import { Toast as BaseToast } from "@base-ui/react/toast";
|
|
5
|
+
import { Icon } from "./Icon.js";
|
|
6
|
+
const toneIcon = { info: "info", success: "success", warn: "warning", error: "error" };
|
|
7
|
+
function ToastList() {
|
|
8
|
+
const { toasts } = BaseToast.useToastManager();
|
|
9
|
+
return (_jsx(_Fragment, { children: toasts.map((t) => {
|
|
10
|
+
const tone = t.type ?? "info";
|
|
11
|
+
// useToast を呼んだ所の ThemeProvider を、1 件ずつに付ける。ToastProvider が ThemeProvider の外にあっても色が当たる
|
|
12
|
+
const { theme, look } = t.data ?? {};
|
|
13
|
+
return (_jsx(BaseToast.Root, { toast: t, className: "ki-toast", "data-type": tone, "data-ki-theme": theme, "data-ki-look": look, swipeDirection: ["right", "down"], children: _jsxs(BaseToast.Content, { className: "ki-toast__body", children: [_jsx("span", { className: "ki-toast__icon", children: _jsx(Icon, { name: toneIcon[tone] }) }), _jsxs("div", { className: "ki-toast__content", children: [_jsx(BaseToast.Title, { className: "ki-toast__title" }), _jsx(BaseToast.Description, { className: "ki-toast__description" })] }), _jsx(BaseToast.Close, { className: "ki-button ki-icon-button ki-toast__close", "data-variant": "quiet", "aria-label": "\u9589\u3058\u308B", children: _jsx(Icon, { name: "close" }) })] }) }, t.id));
|
|
14
|
+
}) }));
|
|
15
|
+
}
|
|
16
|
+
/** アプリの根に 1 つ置く。中から useToast() で出す。ThemeProvider の内でも外でもよい(テーマは useToast を呼んだ所のものが当たる) */
|
|
17
|
+
export function ToastProvider({ children, timeout = 5000, limit = 3 }) {
|
|
18
|
+
const scope = useThemeScope();
|
|
19
|
+
return (_jsxs(BaseToast.Provider, { timeout: timeout, limit: limit, children: [children, _jsx(BaseToast.Portal, { children: _jsx(BaseToast.Viewport, { className: "ki-toast-viewport", "data-stack": "", ...scope, children: _jsx(ToastList, {}) }) })] }));
|
|
20
|
+
}
|
|
21
|
+
export function useToast() {
|
|
22
|
+
const m = BaseToast.useToastManager();
|
|
23
|
+
const theme = useContext(ThemeScopeContext) ?? undefined;
|
|
24
|
+
const look = useContext(ThemeLookContext) ?? undefined;
|
|
25
|
+
return {
|
|
26
|
+
show: (o) => m.add({ title: o.title, description: o.description, type: o.tone ?? "info", timeout: o.timeout, data: { theme, look } }),
|
|
27
|
+
close: (id) => m.close(id),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from "react";
|
|
2
|
+
export interface TooltipProps {
|
|
3
|
+
/** 補足の文。短く */
|
|
4
|
+
content: ReactNode;
|
|
5
|
+
/** 触れる要素 1 つ。アイコンだけなら aria-label を付ける */
|
|
6
|
+
children: ReactElement;
|
|
7
|
+
side?: "top" | "bottom" | "left" | "right";
|
|
8
|
+
}
|
|
9
|
+
export declare function Tooltip({ content, children, side }: TooltipProps): import("react").JSX.Element;
|
package/dist/Tooltip.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useThemeScope } from "./ThemeScope.js";
|
|
3
|
+
import { Tooltip as BaseTooltip } from "@base-ui/react/tooltip";
|
|
4
|
+
export function Tooltip({ content, children, side = "top" }) {
|
|
5
|
+
const scope = useThemeScope();
|
|
6
|
+
return (_jsx(BaseTooltip.Provider, { children: _jsxs(BaseTooltip.Root, { children: [_jsx(BaseTooltip.Trigger, { render: children }), _jsx(BaseTooltip.Portal, { children: _jsx(BaseTooltip.Positioner, { className: "ki-tooltip__positioner", side: side, sideOffset: 6, ...scope, children: _jsx(BaseTooltip.Popup, { className: "ki-tooltip", children: content }) }) })] }) }));
|
|
7
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export { Icon, type IconProps, type IconName } from "./Icon.js";
|
|
2
|
+
export { Spinner, type SpinnerProps } from "./Spinner.js";
|
|
3
|
+
export { Button, type ButtonProps, type ButtonVariant } from "./Button.js";
|
|
4
|
+
export { IconButton, type IconButtonProps } from "./IconButton.js";
|
|
5
|
+
export { Link, type LinkProps } from "./Link.js";
|
|
6
|
+
export { Input, Textarea, type InputProps, type TextareaProps } from "./Input.js";
|
|
7
|
+
export { Select, type SelectProps, type SelectOption } from "./Select.js";
|
|
8
|
+
export { Checkbox, Switch, RadioGroup, type CheckboxProps, type SwitchProps, type RadioGroupProps, type RadioOption } from "./Choice.js";
|
|
9
|
+
export { Calendar, sameDay, type CalendarProps } from "./Calendar.js";
|
|
10
|
+
export { DatePicker, type DatePickerProps } from "./DatePicker.js";
|
|
11
|
+
export { Combobox, normalizeForSearch, type ComboboxProps, type ComboboxOption } from "./Combobox.js";
|
|
12
|
+
export { FileUpload, formatBytes, type FileUploadProps } from "./FileUpload.js";
|
|
13
|
+
export { Kbd, type KbdProps } from "./Kbd.js";
|
|
14
|
+
export { Slider, type SliderProps } from "./Slider.js";
|
|
15
|
+
export { Stepper, type StepperProps } from "./Stepper.js";
|
|
16
|
+
export { SegmentedControl, type SegmentedControlProps, type SegmentedOption } from "./SegmentedControl.js";
|
|
17
|
+
export { Field, type FieldProps } from "./Field.js";
|
|
18
|
+
export { Table, type TableProps, type Column, type SortState, type SortDirection } from "./Table.js";
|
|
19
|
+
export { Tabs, type TabsProps, type TabItem } from "./Tabs.js";
|
|
20
|
+
export { Dialog, DialogClose, ConfirmDialog, type DialogProps, type ConfirmDialogProps } from "./Dialog.js";
|
|
21
|
+
export { Sheet, SheetClose, type SheetProps } from "./Sheet.js";
|
|
22
|
+
export { Popover, type PopoverProps } from "./Popover.js";
|
|
23
|
+
export { Menu, type MenuProps, type MenuEntry } from "./Menu.js";
|
|
24
|
+
export { Tooltip, type TooltipProps } from "./Tooltip.js";
|
|
25
|
+
export { ToastProvider, useToast, type ToastProviderProps, type ToastOptions, type ToastTone } from "./Toast.js";
|
|
26
|
+
export { Alert, type AlertProps, type Tone } from "./Alert.js";
|
|
27
|
+
export { Badge, type BadgeProps } from "./Badge.js";
|
|
28
|
+
export { CodeBlock, type CodeBlockProps } from "./CodeBlock.js";
|
|
29
|
+
export { Quote, type QuoteProps } from "./Quote.js";
|
|
30
|
+
export { Skeleton, SkeletonText, type SkeletonProps, type SkeletonTextProps } from "./Skeleton.js";
|
|
31
|
+
export { EmptyState, type EmptyStateProps } from "./EmptyState.js";
|
|
32
|
+
export { Divider, type DividerProps } from "./Divider.js";
|
|
33
|
+
export { Pagination, pageItems, type PaginationProps } from "./Pagination.js";
|
|
34
|
+
export { Status, statusKinds, type StatusProps, type StatusKind, type StatusTone } from "./Status.js";
|
|
35
|
+
export { Stat, Sparkline, type StatProps, type StatDelta, type SparklineProps } from "./Stat.js";
|
|
36
|
+
export { Chart, type ChartProps, type ChartPoint, type ChartBreakdown } from "./Chart.js";
|
|
37
|
+
export { Stack, Grid, Container, type StackProps, type GridProps, type ContainerProps, type Space } from "./Layout.js";
|
|
38
|
+
export { Card, type CardProps, type CardMeta } from "./Card.js";
|
|
39
|
+
export { Accordion, type AccordionProps, type AccordionItem } from "./Accordion.js";
|
|
40
|
+
export { Breadcrumbs, type BreadcrumbsProps, type BreadcrumbItem } from "./Breadcrumbs.js";
|
|
41
|
+
export { Avatar, type AvatarProps } from "./Avatar.js";
|
|
42
|
+
export { Chip, type ChipProps } from "./Chip.js";
|
|
43
|
+
export { Progress, type ProgressProps } from "./Progress.js";
|
|
44
|
+
export { TextField, type TextFieldProps } from "./TextField.js";
|
|
45
|
+
export { List, ListItem, type ListProps, type ListEntry, type ListItemProps } from "./List.js";
|
|
46
|
+
export { Timeline, type TimelineProps, type TimelineEntry } from "./Timeline.js";
|
|
47
|
+
export { SelectionBar, type SelectionBarProps } from "./SelectionBar.js";
|
|
48
|
+
export { AppBar, type AppBarProps } from "./AppBar.js";
|
|
49
|
+
export { Drawer, type DrawerProps, type DrawerGroup } from "./Drawer.js";
|
|
50
|
+
export { BottomNavigation, type BottomNavigationProps } from "./BottomNavigation.js";
|
|
51
|
+
export type { NavItem } from "./NavItems.js";
|
|
52
|
+
export { ThemeProvider, createTheme, type ThemeProviderProps, type ThemeOptions, type ThemeWarning } from "./ThemeProvider.js";
|
|
53
|
+
export { formatNumber } from "./utils.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export { Icon } from "./Icon.js";
|
|
2
|
+
export { Spinner } from "./Spinner.js";
|
|
3
|
+
export { Button } from "./Button.js";
|
|
4
|
+
export { IconButton } from "./IconButton.js";
|
|
5
|
+
export { Link } from "./Link.js";
|
|
6
|
+
export { Input, Textarea } from "./Input.js";
|
|
7
|
+
export { Select } from "./Select.js";
|
|
8
|
+
export { Checkbox, Switch, RadioGroup } from "./Choice.js";
|
|
9
|
+
export { Calendar, sameDay } from "./Calendar.js";
|
|
10
|
+
export { DatePicker } from "./DatePicker.js";
|
|
11
|
+
export { Combobox, normalizeForSearch } from "./Combobox.js";
|
|
12
|
+
export { FileUpload, formatBytes } from "./FileUpload.js";
|
|
13
|
+
export { Kbd } from "./Kbd.js";
|
|
14
|
+
export { Slider } from "./Slider.js";
|
|
15
|
+
export { Stepper } from "./Stepper.js";
|
|
16
|
+
export { SegmentedControl } from "./SegmentedControl.js";
|
|
17
|
+
export { Field } from "./Field.js";
|
|
18
|
+
export { Table } from "./Table.js";
|
|
19
|
+
export { Tabs } from "./Tabs.js";
|
|
20
|
+
export { Dialog, DialogClose, ConfirmDialog } from "./Dialog.js";
|
|
21
|
+
export { Sheet, SheetClose } from "./Sheet.js";
|
|
22
|
+
export { Popover } from "./Popover.js";
|
|
23
|
+
export { Menu } from "./Menu.js";
|
|
24
|
+
export { Tooltip } from "./Tooltip.js";
|
|
25
|
+
export { ToastProvider, useToast } from "./Toast.js";
|
|
26
|
+
export { Alert } from "./Alert.js";
|
|
27
|
+
export { Badge } from "./Badge.js";
|
|
28
|
+
export { CodeBlock } from "./CodeBlock.js";
|
|
29
|
+
export { Quote } from "./Quote.js";
|
|
30
|
+
export { Skeleton, SkeletonText } from "./Skeleton.js";
|
|
31
|
+
export { EmptyState } from "./EmptyState.js";
|
|
32
|
+
export { Divider } from "./Divider.js";
|
|
33
|
+
export { Pagination, pageItems } from "./Pagination.js";
|
|
34
|
+
export { Status, statusKinds } from "./Status.js";
|
|
35
|
+
export { Stat, Sparkline } from "./Stat.js";
|
|
36
|
+
export { Chart } from "./Chart.js";
|
|
37
|
+
export { Stack, Grid, Container } from "./Layout.js";
|
|
38
|
+
export { Card } from "./Card.js";
|
|
39
|
+
export { Accordion } from "./Accordion.js";
|
|
40
|
+
export { Breadcrumbs } from "./Breadcrumbs.js";
|
|
41
|
+
export { Avatar } from "./Avatar.js";
|
|
42
|
+
export { Chip } from "./Chip.js";
|
|
43
|
+
export { Progress } from "./Progress.js";
|
|
44
|
+
export { TextField } from "./TextField.js";
|
|
45
|
+
export { List, ListItem } from "./List.js";
|
|
46
|
+
export { Timeline } from "./Timeline.js";
|
|
47
|
+
export { SelectionBar } from "./SelectionBar.js";
|
|
48
|
+
export { AppBar } from "./AppBar.js";
|
|
49
|
+
export { Drawer } from "./Drawer.js";
|
|
50
|
+
export { BottomNavigation } from "./BottomNavigation.js";
|
|
51
|
+
export { ThemeProvider, createTheme } from "./ThemeProvider.js";
|
|
52
|
+
export { formatNumber } from "./utils.js";
|
package/dist/motion.d.ts
ADDED
package/dist/motion.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useLayoutEffect, useRef } from "react";
|
|
2
|
+
/** トークンの時間("160ms")を数に。動きを減らす設定ではトークンが 0ms になる */
|
|
3
|
+
function duration(el, name) {
|
|
4
|
+
const v = getComputedStyle(el).getPropertyValue(name).trim();
|
|
5
|
+
return v.endsWith("ms") ? parseFloat(v) : v.endsWith("s") ? parseFloat(v) * 1000 : 0;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* 一覧の行を、足した時は上から少し滑って出し、消した時と並べ替えた時は新しい位置へ滑らせる。
|
|
9
|
+
* 行には data-id を付ける。初めて出た時は動かさない(状態が変わる時だけ動かす)。
|
|
10
|
+
*/
|
|
11
|
+
export function useListMotion(ref, key) {
|
|
12
|
+
const tops = useRef(null);
|
|
13
|
+
useLayoutEffect(() => {
|
|
14
|
+
const box = ref.current;
|
|
15
|
+
if (!box)
|
|
16
|
+
return;
|
|
17
|
+
const rows = Array.from(box.querySelectorAll(":scope > [data-id]"));
|
|
18
|
+
// 動いている途中の行は止めてから測る(続けて押した時に、途中の位置を覚えないように)
|
|
19
|
+
rows.forEach((el) => el.getAnimations().forEach((a) => a.cancel()));
|
|
20
|
+
// 一覧の中のスクロールの分を足し、スクロールしただけで動いたと見ないようにする
|
|
21
|
+
const base = box.getBoundingClientRect().top - box.scrollTop;
|
|
22
|
+
const next = new Map(rows.map((el) => [el.dataset.id, el.getBoundingClientRect().top - base]));
|
|
23
|
+
const prev = tops.current;
|
|
24
|
+
tops.current = next;
|
|
25
|
+
const ms = duration(box, "--motion-duration-state");
|
|
26
|
+
// 行が無かった所(初め、読み込み中、空)から出た時は動かさない
|
|
27
|
+
if (!prev || prev.size === 0 || ms === 0 || typeof box.animate !== "function")
|
|
28
|
+
return;
|
|
29
|
+
const easing = getComputedStyle(box).getPropertyValue("--motion-ease").trim() || "ease";
|
|
30
|
+
for (const el of rows) {
|
|
31
|
+
const was = prev.get(el.dataset.id);
|
|
32
|
+
const now = next.get(el.dataset.id);
|
|
33
|
+
if (was === undefined)
|
|
34
|
+
el.animate([{ opacity: 0, transform: "translateY(-4px)" }, { opacity: 1, transform: "none" }], { duration: ms, easing });
|
|
35
|
+
else if (Math.abs(was - now) > 1)
|
|
36
|
+
el.animate([{ transform: `translateY(${was - now}px)` }, { transform: "none" }], { duration: ms, easing });
|
|
37
|
+
}
|
|
38
|
+
}, [ref, key]);
|
|
39
|
+
}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function cx(...parts: Array<string | false | null | undefined>): string;
|
|
2
|
+
/** 3 桁区切り(日本語) */
|
|
3
|
+
export declare function formatNumber(n: number): string;
|
|
4
|
+
/** 軸の目盛り用。1,000 以上は 万 や k にせず、短く「18万」と出す */
|
|
5
|
+
export declare function formatCompact(n: number): string;
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function cx(...parts) {
|
|
2
|
+
return parts.filter(Boolean).join(" ");
|
|
3
|
+
}
|
|
4
|
+
/** 3 桁区切り(日本語) */
|
|
5
|
+
export function formatNumber(n) {
|
|
6
|
+
return n.toLocaleString("ja-JP");
|
|
7
|
+
}
|
|
8
|
+
/** 軸の目盛り用。1,000 以上は 万 や k にせず、短く「18万」と出す */
|
|
9
|
+
export function formatCompact(n) {
|
|
10
|
+
return new Intl.NumberFormat("ja-JP", { notation: "compact", maximumFractionDigits: 1 }).format(n);
|
|
11
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knowidea-ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.8.1",
|
|
4
|
+
"description": "KNOW IDEA UI の React の部品(Base UI が土台)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/takikou347/knowidea-ui.git",
|
|
9
|
+
"directory": "packages/ui"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://takikou347.github.io/knowidea-ui/",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/takikou347/knowidea-ui/issues"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public",
|
|
17
|
+
"provenance": true
|
|
18
|
+
},
|
|
19
|
+
"type": "module",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"default": "./dist/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@base-ui/react": "1.9.0"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"react": "^19.0.0",
|
|
32
|
+
"react-dom": "^19.0.0",
|
|
33
|
+
"knowidea-css": "^0.8.1",
|
|
34
|
+
"knowidea-icons": "^0.8.1",
|
|
35
|
+
"knowidea-tokens": "^0.8.1"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/react": "19.3.0",
|
|
39
|
+
"@types/react-dom": "19.3.0",
|
|
40
|
+
"react": "19.3.0",
|
|
41
|
+
"react-dom": "19.3.0",
|
|
42
|
+
"typescript": "5.9.3",
|
|
43
|
+
"knowidea-css": "0.8.1",
|
|
44
|
+
"knowidea-tokens": "0.8.1",
|
|
45
|
+
"knowidea-icons": "0.8.1"
|
|
46
|
+
},
|
|
47
|
+
"files": [
|
|
48
|
+
"dist",
|
|
49
|
+
"README.md",
|
|
50
|
+
"LICENSE"
|
|
51
|
+
],
|
|
52
|
+
"sideEffects": false,
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.json"
|
|
55
|
+
}
|
|
6
56
|
}
|