@nagiyu/ui 0.0.0-stage → 0.1.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/src/components/Button/Button.d.ts +82 -0
- package/dist/src/components/Button/Button.d.ts.map +1 -0
- package/dist/src/components/Button/Button.jsx +68 -0
- package/dist/src/components/Button/Button.jsx.map +1 -0
- package/dist/src/components/Button/Button.module.css +238 -0
- package/dist/src/components/Button/index.d.ts +3 -0
- package/dist/src/components/Button/index.d.ts.map +1 -0
- package/dist/src/components/Button/index.js +2 -0
- package/dist/src/components/Button/index.js.map +1 -0
- package/dist/src/components/Checkbox/Checkbox.d.ts +59 -0
- package/dist/src/components/Checkbox/Checkbox.d.ts.map +1 -0
- package/dist/src/components/Checkbox/Checkbox.jsx +75 -0
- package/dist/src/components/Checkbox/Checkbox.jsx.map +1 -0
- package/dist/src/components/Checkbox/Checkbox.module.css +166 -0
- package/dist/src/components/Checkbox/index.d.ts +3 -0
- package/dist/src/components/Checkbox/index.d.ts.map +1 -0
- package/dist/src/components/Checkbox/index.js +2 -0
- package/dist/src/components/Checkbox/index.js.map +1 -0
- package/dist/src/components/Chip/Chip.d.ts +60 -0
- package/dist/src/components/Chip/Chip.d.ts.map +1 -0
- package/dist/src/components/Chip/Chip.jsx +39 -0
- package/dist/src/components/Chip/Chip.jsx.map +1 -0
- package/dist/src/components/Chip/Chip.module.css +144 -0
- package/dist/src/components/Chip/index.d.ts +3 -0
- package/dist/src/components/Chip/index.d.ts.map +1 -0
- package/dist/src/components/Chip/index.js +2 -0
- package/dist/src/components/Chip/index.js.map +1 -0
- package/dist/src/components/Link/Link.d.ts +52 -0
- package/dist/src/components/Link/Link.d.ts.map +1 -0
- package/dist/src/components/Link/Link.jsx +29 -0
- package/dist/src/components/Link/Link.jsx.map +1 -0
- package/dist/src/components/Link/Link.module.css +100 -0
- package/dist/src/components/Link/index.d.ts +3 -0
- package/dist/src/components/Link/index.d.ts.map +1 -0
- package/dist/src/components/Link/index.js +2 -0
- package/dist/src/components/Link/index.js.map +1 -0
- package/dist/src/components/Select/Select.d.ts +71 -0
- package/dist/src/components/Select/Select.d.ts.map +1 -0
- package/dist/src/components/Select/Select.jsx +55 -0
- package/dist/src/components/Select/Select.jsx.map +1 -0
- package/dist/src/components/Select/Select.module.css +150 -0
- package/dist/src/components/Select/index.d.ts +3 -0
- package/dist/src/components/Select/index.d.ts.map +1 -0
- package/dist/src/components/Select/index.js +2 -0
- package/dist/src/components/Select/index.js.map +1 -0
- package/dist/src/components/TextField/TextField.d.ts +96 -0
- package/dist/src/components/TextField/TextField.d.ts.map +1 -0
- package/dist/src/components/TextField/TextField.jsx +68 -0
- package/dist/src/components/TextField/TextField.jsx.map +1 -0
- package/dist/src/components/TextField/TextField.module.css +139 -0
- package/dist/src/components/TextField/index.d.ts +3 -0
- package/dist/src/components/TextField/index.d.ts.map +1 -0
- package/dist/src/components/TextField/index.js +2 -0
- package/dist/src/components/TextField/index.js.map +1 -0
- package/dist/src/components/dialogs/ConfirmDialog.d.ts +29 -0
- package/dist/src/components/dialogs/ConfirmDialog.d.ts.map +1 -0
- package/dist/src/components/dialogs/ConfirmDialog.jsx +34 -0
- package/dist/src/components/dialogs/ConfirmDialog.jsx.map +1 -0
- package/dist/src/components/dialogs/LegalDialog.d.ts +14 -0
- package/dist/src/components/dialogs/LegalDialog.d.ts.map +1 -0
- package/dist/src/components/dialogs/LegalDialog.jsx +34 -0
- package/dist/src/components/dialogs/LegalDialog.jsx.map +1 -0
- package/dist/src/components/dialogs/PrivacyPolicyDialog.d.ts +17 -0
- package/dist/src/components/dialogs/PrivacyPolicyDialog.d.ts.map +1 -0
- package/dist/src/components/dialogs/PrivacyPolicyDialog.jsx +7 -0
- package/dist/src/components/dialogs/PrivacyPolicyDialog.jsx.map +1 -0
- package/dist/src/components/dialogs/TermsOfServiceDialog.d.ts +17 -0
- package/dist/src/components/dialogs/TermsOfServiceDialog.d.ts.map +1 -0
- package/dist/src/components/dialogs/TermsOfServiceDialog.jsx +7 -0
- package/dist/src/components/dialogs/TermsOfServiceDialog.jsx.map +1 -0
- package/dist/src/components/error/ErrorAlert.d.ts +58 -0
- package/dist/src/components/error/ErrorAlert.d.ts.map +1 -0
- package/dist/src/components/error/ErrorAlert.jsx +68 -0
- package/dist/src/components/error/ErrorAlert.jsx.map +1 -0
- package/dist/src/components/feedback/AccessDeniedView.d.ts +59 -0
- package/dist/src/components/feedback/AccessDeniedView.d.ts.map +1 -0
- package/dist/src/components/feedback/AccessDeniedView.jsx +83 -0
- package/dist/src/components/feedback/AccessDeniedView.jsx.map +1 -0
- package/dist/src/components/feedback/ErrorView.d.ts +47 -0
- package/dist/src/components/feedback/ErrorView.d.ts.map +1 -0
- package/dist/src/components/feedback/ErrorView.jsx +63 -0
- package/dist/src/components/feedback/ErrorView.jsx.map +1 -0
- package/dist/src/components/feedback/GlobalErrorView.d.ts +18 -0
- package/dist/src/components/feedback/GlobalErrorView.d.ts.map +1 -0
- package/dist/src/components/feedback/GlobalErrorView.jsx +27 -0
- package/dist/src/components/feedback/GlobalErrorView.jsx.map +1 -0
- package/dist/src/components/feedback/NotFoundView.d.ts +37 -0
- package/dist/src/components/feedback/NotFoundView.d.ts.map +1 -0
- package/dist/src/components/feedback/NotFoundView.jsx +54 -0
- package/dist/src/components/feedback/NotFoundView.jsx.map +1 -0
- package/dist/src/components/layout/AppLayout.d.ts +8 -0
- package/dist/src/components/layout/AppLayout.d.ts.map +1 -0
- package/dist/src/components/layout/AppLayout.jsx +14 -0
- package/dist/src/components/layout/AppLayout.jsx.map +1 -0
- package/dist/src/components/layout/Footer.d.ts +66 -0
- package/dist/src/components/layout/Footer.d.ts.map +1 -0
- package/dist/src/components/layout/Footer.jsx +107 -0
- package/dist/src/components/layout/Footer.jsx.map +1 -0
- package/dist/src/components/layout/Header.d.ts +89 -0
- package/dist/src/components/layout/Header.d.ts.map +1 -0
- package/dist/src/components/layout/Header.jsx +227 -0
- package/dist/src/components/layout/Header.jsx.map +1 -0
- package/dist/src/components/layout/ServiceLayout.d.ts +20 -0
- package/dist/src/components/layout/ServiceLayout.d.ts.map +1 -0
- package/dist/src/components/layout/ServiceLayout.jsx +17 -0
- package/dist/src/components/layout/ServiceLayout.jsx.map +1 -0
- package/dist/src/components/layout/SessionHeader.d.ts +25 -0
- package/dist/src/components/layout/SessionHeader.d.ts.map +1 -0
- package/dist/src/components/layout/SessionHeader.jsx +46 -0
- package/dist/src/components/layout/SessionHeader.jsx.map +1 -0
- package/dist/src/components/legal/CommercialTransactionsTable.d.ts +13 -0
- package/dist/src/components/legal/CommercialTransactionsTable.d.ts.map +1 -0
- package/dist/src/components/legal/CommercialTransactionsTable.jsx +56 -0
- package/dist/src/components/legal/CommercialTransactionsTable.jsx.map +1 -0
- package/dist/src/components/legal/LegalSections.d.ts +13 -0
- package/dist/src/components/legal/LegalSections.d.ts.map +1 -0
- package/dist/src/components/legal/LegalSections.jsx +38 -0
- package/dist/src/components/legal/LegalSections.jsx.map +1 -0
- package/dist/src/components/legal/index.d.ts +5 -0
- package/dist/src/components/legal/index.d.ts.map +1 -0
- package/dist/src/components/legal/index.js +3 -0
- package/dist/src/components/legal/index.js.map +1 -0
- package/dist/src/components/loading/LoadingState.d.ts +41 -0
- package/dist/src/components/loading/LoadingState.d.ts.map +1 -0
- package/dist/src/components/loading/LoadingState.jsx +29 -0
- package/dist/src/components/loading/LoadingState.jsx.map +1 -0
- package/dist/src/components/providers/AppThemeProvider.d.ts +6 -0
- package/dist/src/components/providers/AppThemeProvider.d.ts.map +1 -0
- package/dist/src/components/providers/AppThemeProvider.jsx +14 -0
- package/dist/src/components/providers/AppThemeProvider.jsx.map +1 -0
- package/dist/src/components/providers/SessionProviderWrapper.d.ts +11 -0
- package/dist/src/components/providers/SessionProviderWrapper.d.ts.map +1 -0
- package/dist/src/components/providers/SessionProviderWrapper.jsx +11 -0
- package/dist/src/components/providers/SessionProviderWrapper.jsx.map +1 -0
- package/dist/src/data/commercialTransactionsData.d.ts +9 -0
- package/dist/src/data/commercialTransactionsData.d.ts.map +1 -0
- package/dist/src/data/commercialTransactionsData.js +46 -0
- package/dist/src/data/commercialTransactionsData.js.map +1 -0
- package/dist/src/data/privacyPolicyData.d.ts +7 -0
- package/dist/src/data/privacyPolicyData.d.ts.map +1 -0
- package/dist/src/data/privacyPolicyData.js +247 -0
- package/dist/src/data/privacyPolicyData.js.map +1 -0
- package/dist/src/data/termsOfServiceData.d.ts +7 -0
- package/dist/src/data/termsOfServiceData.d.ts.map +1 -0
- package/dist/src/data/termsOfServiceData.js +227 -0
- package/dist/src/data/termsOfServiceData.js.map +1 -0
- package/dist/src/index.d.ts +52 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +35 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/session-provider.d.ts +5 -0
- package/dist/src/session-provider.d.ts.map +1 -0
- package/dist/src/session-provider.js +7 -0
- package/dist/src/session-provider.js.map +1 -0
- package/dist/src/styles/base.css +14 -0
- package/dist/src/styles/theme.d.ts +22 -0
- package/dist/src/styles/theme.d.ts.map +1 -0
- package/dist/src/styles/theme.js +169 -0
- package/dist/src/styles/theme.js.map +1 -0
- package/dist/src/styles/tokens.css +361 -0
- package/dist/src/styles/tokens.d.ts +167 -0
- package/dist/src/styles/tokens.d.ts.map +1 -0
- package/dist/src/styles/tokens.js +151 -0
- package/dist/src/styles/tokens.js.map +1 -0
- package/dist/src/types/legal.d.ts +36 -0
- package/dist/src/types/legal.d.ts.map +1 -0
- package/dist/src/types/legal.js +7 -0
- package/dist/src/types/legal.js.map +1 -0
- package/dist/src/utils/auth.d.ts +53 -0
- package/dist/src/utils/auth.d.ts.map +1 -0
- package/dist/src/utils/auth.js +78 -0
- package/dist/src/utils/auth.js.map +1 -0
- package/dist/src/utils/navigation.d.ts +16 -0
- package/dist/src/utils/navigation.d.ts.map +1 -0
- package/dist/src/utils/navigation.js +54 -0
- package/dist/src/utils/navigation.js.map +1 -0
- package/package.json +64 -4
- package/README.md +0 -3
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Button のバリアント。
|
|
4
|
+
*
|
|
5
|
+
* - `solid`: 塗りつぶし(強調アクション)
|
|
6
|
+
* - `outline`: 枠線のみ(中位アクション)
|
|
7
|
+
* - `ghost`: 背景なし(弱い・補助アクション)
|
|
8
|
+
*/
|
|
9
|
+
export type ButtonVariant = 'solid' | 'outline' | 'ghost';
|
|
10
|
+
/**
|
|
11
|
+
* Button の色(意味)。視覚的な色名(blue 等)ではなく必ず意味で指定する。
|
|
12
|
+
*/
|
|
13
|
+
export type ButtonColor = 'primary' | 'secondary' | 'danger' | 'success' | 'warning' | 'neutral';
|
|
14
|
+
/**
|
|
15
|
+
* Button のサイズ。
|
|
16
|
+
*/
|
|
17
|
+
export type ButtonSize = 'sm' | 'md' | 'lg';
|
|
18
|
+
/**
|
|
19
|
+
* Button の共通プロパティ(asChild の有無に依らず使えるもの)。
|
|
20
|
+
*/
|
|
21
|
+
type ButtonOwnPropsBase = {
|
|
22
|
+
/**
|
|
23
|
+
* バリアント。既定: `solid`
|
|
24
|
+
*/
|
|
25
|
+
variant?: ButtonVariant;
|
|
26
|
+
/**
|
|
27
|
+
* 色(意味)。既定: `primary`
|
|
28
|
+
*/
|
|
29
|
+
color?: ButtonColor;
|
|
30
|
+
/**
|
|
31
|
+
* サイズ。既定: `md`
|
|
32
|
+
*/
|
|
33
|
+
size?: ButtonSize;
|
|
34
|
+
/**
|
|
35
|
+
* ローディング中はスピナーを表示し、操作を抑止する。
|
|
36
|
+
*/
|
|
37
|
+
loading?: boolean;
|
|
38
|
+
};
|
|
39
|
+
type ButtonHtmlProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'color'>;
|
|
40
|
+
/**
|
|
41
|
+
* 通常モード(`asChild` 未指定または `false`)の Props。
|
|
42
|
+
* `startIcon` を受け付ける。
|
|
43
|
+
*/
|
|
44
|
+
type ButtonRegularProps = ButtonHtmlProps & ButtonOwnPropsBase & {
|
|
45
|
+
asChild?: false;
|
|
46
|
+
/**
|
|
47
|
+
* ボタン左側に表示する装飾アイコン。`aria-hidden="true"` が自動付与される。
|
|
48
|
+
* `loading` 中は内部で非表示になり、スピナーに置き換わる。
|
|
49
|
+
*/
|
|
50
|
+
startIcon?: React.ReactNode;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* `asChild` モードの Props。
|
|
54
|
+
* Radix `Slot` は単一子要素しか許容しないため、`startIcon` の同時指定は型エラーにする。
|
|
55
|
+
*/
|
|
56
|
+
type ButtonAsChildProps = ButtonHtmlProps & ButtonOwnPropsBase & {
|
|
57
|
+
asChild: true;
|
|
58
|
+
/**
|
|
59
|
+
* `asChild` モードでは利用不可。子要素自身で構造を組み立てること。
|
|
60
|
+
*/
|
|
61
|
+
startIcon?: never;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Button のプロパティ。
|
|
65
|
+
*
|
|
66
|
+
* 100% ライブラリ非依存の独自定義。MUI / Radix 等の Props 型は extends しない。
|
|
67
|
+
* エスケープハッチは `className` のみ(`sx` / `style` は提供しない)。
|
|
68
|
+
*/
|
|
69
|
+
export type ButtonProps = ButtonRegularProps | ButtonAsChildProps;
|
|
70
|
+
/**
|
|
71
|
+
* 汎用ボタンコンポーネント。
|
|
72
|
+
*
|
|
73
|
+
* - `variant` × `color` × `size` の直交した API
|
|
74
|
+
* - `loading` でスピナー表示(`aria-busy` 自動設定)
|
|
75
|
+
* - `startIcon` で左側装飾アイコン(`aria-hidden` 自動付与)
|
|
76
|
+
* - `asChild` でリンク等への変身に対応(Radix Slot パターン、`startIcon` とは排他)
|
|
77
|
+
*
|
|
78
|
+
* @see docs/development/shared-ui-components.md
|
|
79
|
+
*/
|
|
80
|
+
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
81
|
+
export default Button;
|
|
82
|
+
//# sourceMappingURL=Button.d.ts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M,uFA6EV,CAAC;AAEH,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
4
|
+
import styles from './Button.module.css';
|
|
5
|
+
/**
|
|
6
|
+
* 汎用ボタンコンポーネント。
|
|
7
|
+
*
|
|
8
|
+
* - `variant` × `color` × `size` の直交した API
|
|
9
|
+
* - `loading` でスピナー表示(`aria-busy` 自動設定)
|
|
10
|
+
* - `startIcon` で左側装飾アイコン(`aria-hidden` 自動付与)
|
|
11
|
+
* - `asChild` でリンク等への変身に対応(Radix Slot パターン、`startIcon` とは排他)
|
|
12
|
+
*
|
|
13
|
+
* @see docs/development/shared-ui-components.md
|
|
14
|
+
*/
|
|
15
|
+
const Button = React.forwardRef(function Button(props, ref) {
|
|
16
|
+
const { variant = 'solid', color = 'primary', size = 'md', loading = false, asChild = false, disabled, className, children, type, 'aria-busy': ariaBusy, 'aria-disabled': ariaDisabled, ...rest } = props;
|
|
17
|
+
// startIcon は asChild と排他のため、通常モード側でのみ取り出す。
|
|
18
|
+
const startIcon = asChild ? undefined : props.startIcon;
|
|
19
|
+
// asChild と startIcon は型で排他にしているが、実際の rest からも除外する。
|
|
20
|
+
if ('startIcon' in rest) {
|
|
21
|
+
delete rest.startIcon;
|
|
22
|
+
}
|
|
23
|
+
const Comp = asChild ? Slot : 'button';
|
|
24
|
+
const isDisabled = disabled || loading;
|
|
25
|
+
const classes = [
|
|
26
|
+
styles.button,
|
|
27
|
+
styles[`variant-${variant}`],
|
|
28
|
+
styles[`color-${color}`],
|
|
29
|
+
styles[`size-${size}`],
|
|
30
|
+
loading ? styles.loading : null,
|
|
31
|
+
isDisabled ? styles.disabled : null,
|
|
32
|
+
className,
|
|
33
|
+
]
|
|
34
|
+
.filter(Boolean)
|
|
35
|
+
.join(' ');
|
|
36
|
+
// asChild の場合、子要素は <button> とは限らないため `disabled` 属性は付与しない。
|
|
37
|
+
// 代わりに `aria-disabled` と CSS で操作抑止する。
|
|
38
|
+
const buttonProps = asChild
|
|
39
|
+
? {
|
|
40
|
+
'aria-disabled': ariaDisabled ?? (isDisabled || undefined),
|
|
41
|
+
'aria-busy': ariaBusy ?? (loading || undefined),
|
|
42
|
+
}
|
|
43
|
+
: {
|
|
44
|
+
type: type ?? 'button',
|
|
45
|
+
disabled: isDisabled,
|
|
46
|
+
'aria-busy': ariaBusy ?? (loading || undefined),
|
|
47
|
+
'aria-disabled': ariaDisabled,
|
|
48
|
+
};
|
|
49
|
+
// asChild の場合、Radix Slot は単一の React 要素しか受け付けないため、
|
|
50
|
+
// 子要素をそのまま渡す。スピナー描画は通常モードに限定し、asChild + loading は
|
|
51
|
+
// `aria-busy` と `[aria-disabled]` 経由の視覚的減光(opacity)で表現する。
|
|
52
|
+
if (asChild) {
|
|
53
|
+
return (<Comp ref={ref} className={classes} {...buttonProps} {...rest}>
|
|
54
|
+
{children}
|
|
55
|
+
</Comp>);
|
|
56
|
+
}
|
|
57
|
+
return (<Comp ref={ref} className={classes} {...buttonProps} {...rest}>
|
|
58
|
+
{loading ? (<span className={styles.spinner} aria-hidden="true" data-testid="button-spinner"/>) : null}
|
|
59
|
+
<span className={loading ? styles.contentHidden : styles.content}>
|
|
60
|
+
{startIcon ? (<span className={styles.startIcon} aria-hidden="true" data-testid="button-start-icon">
|
|
61
|
+
{startIcon}
|
|
62
|
+
</span>) : null}
|
|
63
|
+
{children}
|
|
64
|
+
</span>
|
|
65
|
+
</Comp>);
|
|
66
|
+
});
|
|
67
|
+
export default Button;
|
|
68
|
+
//# sourceMappingURL=Button.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.jsx","sourceRoot":"","sources":["../../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,s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,CAAC,MAAM,CAAC,WAAW,CAAC,mBAAmB,CACnF;YAAA,CAAC,SAAS,CACZ;UAAA,EAAE,IAAI,CAAC,CACR,CAAC,CAAC,CAAC,IAAI,CACR;QAAA,CAAC,QAAQ,CACX;MAAA,EAAE,IAAI,CACR;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Button コンポーネントのスタイル定義。
|
|
3
|
+
*
|
|
4
|
+
* - すべての色・余白・角丸は tokens.css の Semantic 変数を参照する。
|
|
5
|
+
* - MUI 等の特定ライブラリへの依存は持たない(@nagiyu/ui の独立性を保つ)。
|
|
6
|
+
* - 状態は `:hover` / `:focus-visible` / `:active` / `[aria-disabled]` で表現。
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
.button {
|
|
10
|
+
/* Layout */
|
|
11
|
+
position: relative;
|
|
12
|
+
display: inline-flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
gap: var(--spacing-xs);
|
|
16
|
+
|
|
17
|
+
/* Typography */
|
|
18
|
+
font-family: var(--font-family-sans);
|
|
19
|
+
font-weight: var(--font-weight-medium);
|
|
20
|
+
line-height: var(--line-height-tight);
|
|
21
|
+
text-decoration: none;
|
|
22
|
+
white-space: nowrap;
|
|
23
|
+
|
|
24
|
+
/* Box */
|
|
25
|
+
border-radius: var(--radius-md);
|
|
26
|
+
border: 1px solid transparent;
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
user-select: none;
|
|
29
|
+
transition:
|
|
30
|
+
background-color var(--duration-fast) var(--easing-out),
|
|
31
|
+
border-color var(--duration-fast) var(--easing-out),
|
|
32
|
+
color var(--duration-fast) var(--easing-out),
|
|
33
|
+
box-shadow var(--duration-fast) var(--easing-out);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.button:focus-visible {
|
|
37
|
+
outline: 2px solid var(--color-action-primary);
|
|
38
|
+
outline-offset: 2px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* =========================================================================
|
|
42
|
+
* Size
|
|
43
|
+
* ========================================================================= */
|
|
44
|
+
|
|
45
|
+
.size-sm {
|
|
46
|
+
padding: var(--spacing-xs) var(--spacing-sm);
|
|
47
|
+
font-size: var(--font-size-sm);
|
|
48
|
+
min-height: 32px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.size-md {
|
|
52
|
+
padding: var(--spacing-sm) var(--spacing-md);
|
|
53
|
+
font-size: var(--font-size-md);
|
|
54
|
+
min-height: 40px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.size-lg {
|
|
58
|
+
padding: var(--spacing-sm) var(--spacing-lg);
|
|
59
|
+
font-size: var(--font-size-lg);
|
|
60
|
+
min-height: 48px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* =========================================================================
|
|
64
|
+
* Variant × Color
|
|
65
|
+
*
|
|
66
|
+
* 色は CSS カスタムプロパティ `--btn-*` に解決し、各 variant でその値を使う。
|
|
67
|
+
* これにより色追加時は `.color-*` を 1 つ書けばよい構成にする。
|
|
68
|
+
* `--btn-text` / `--btn-text-active` は背景を塗らない outline / ghost の文字色。
|
|
69
|
+
* ========================================================================= */
|
|
70
|
+
|
|
71
|
+
.color-primary {
|
|
72
|
+
--btn-bg: var(--color-action-primary);
|
|
73
|
+
--btn-bg-hover: var(--color-action-primary-hover);
|
|
74
|
+
--btn-bg-active: var(--color-action-primary-active);
|
|
75
|
+
--btn-fg: var(--color-action-primary-fg);
|
|
76
|
+
--btn-border: var(--color-action-primary);
|
|
77
|
+
--btn-text: var(--btn-bg);
|
|
78
|
+
--btn-text-active: var(--btn-bg-active);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.color-secondary {
|
|
82
|
+
--btn-bg: var(--color-action-secondary);
|
|
83
|
+
--btn-bg-hover: var(--color-action-secondary-hover);
|
|
84
|
+
--btn-bg-active: var(--color-action-secondary-active);
|
|
85
|
+
--btn-fg: var(--color-action-secondary-fg);
|
|
86
|
+
--btn-border: var(--color-action-secondary);
|
|
87
|
+
--btn-text: var(--btn-bg);
|
|
88
|
+
--btn-text-active: var(--btn-bg-active);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.color-danger {
|
|
92
|
+
--btn-bg: var(--color-action-danger);
|
|
93
|
+
--btn-bg-hover: var(--color-action-danger-hover);
|
|
94
|
+
--btn-bg-active: var(--color-action-danger-active);
|
|
95
|
+
--btn-fg: var(--color-action-danger-fg);
|
|
96
|
+
--btn-border: var(--color-action-danger);
|
|
97
|
+
--btn-text: var(--btn-bg);
|
|
98
|
+
--btn-text-active: var(--btn-bg-active);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.color-success {
|
|
102
|
+
--btn-bg: var(--color-action-success);
|
|
103
|
+
--btn-bg-hover: var(--color-action-success-hover);
|
|
104
|
+
--btn-bg-active: var(--color-action-success-active);
|
|
105
|
+
--btn-fg: var(--color-action-success-fg);
|
|
106
|
+
--btn-border: var(--color-action-success);
|
|
107
|
+
--btn-text: var(--btn-bg);
|
|
108
|
+
--btn-text-active: var(--btn-bg-active);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.color-warning {
|
|
112
|
+
--btn-bg: var(--color-action-warning);
|
|
113
|
+
--btn-bg-hover: var(--color-action-warning-hover);
|
|
114
|
+
--btn-bg-active: var(--color-action-warning-active);
|
|
115
|
+
--btn-fg: var(--color-action-warning-fg);
|
|
116
|
+
--btn-border: var(--color-action-warning);
|
|
117
|
+
--btn-text: var(--btn-bg);
|
|
118
|
+
--btn-text-active: var(--btn-bg-active);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.color-neutral {
|
|
122
|
+
--btn-bg: var(--color-action-neutral);
|
|
123
|
+
--btn-bg-hover: var(--color-action-neutral-hover);
|
|
124
|
+
--btn-bg-active: var(--color-action-neutral-active);
|
|
125
|
+
--btn-fg: var(--color-action-neutral-fg);
|
|
126
|
+
--btn-border: var(--color-border-default);
|
|
127
|
+
/* neutral の --btn-bg は背景に近い淡色のため、outline / ghost の文字には使えない */
|
|
128
|
+
--btn-text: var(--color-action-neutral-fg);
|
|
129
|
+
--btn-text-active: var(--color-action-neutral-fg);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/* solid: 塗りつぶし */
|
|
133
|
+
.variant-solid {
|
|
134
|
+
background-color: var(--btn-bg);
|
|
135
|
+
color: var(--btn-fg);
|
|
136
|
+
border-color: var(--btn-border);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.variant-solid:hover:not([aria-disabled='true']):not(:disabled) {
|
|
140
|
+
background-color: var(--btn-bg-hover);
|
|
141
|
+
border-color: var(--btn-bg-hover);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.variant-solid:active:not([aria-disabled='true']):not(:disabled) {
|
|
145
|
+
background-color: var(--btn-bg-active);
|
|
146
|
+
border-color: var(--btn-bg-active);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/* outline: 枠線のみ */
|
|
150
|
+
.variant-outline {
|
|
151
|
+
background-color: transparent;
|
|
152
|
+
color: var(--btn-text);
|
|
153
|
+
border-color: var(--btn-border);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.variant-outline:hover:not([aria-disabled='true']):not(:disabled) {
|
|
157
|
+
background-color: var(--btn-bg);
|
|
158
|
+
color: var(--btn-fg);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.variant-outline:active:not([aria-disabled='true']):not(:disabled) {
|
|
162
|
+
background-color: var(--btn-bg-active);
|
|
163
|
+
border-color: var(--btn-bg-active);
|
|
164
|
+
color: var(--btn-fg);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/* ghost: 背景なし */
|
|
168
|
+
.variant-ghost {
|
|
169
|
+
background-color: transparent;
|
|
170
|
+
color: var(--btn-text);
|
|
171
|
+
border-color: transparent;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.variant-ghost:hover:not([aria-disabled='true']):not(:disabled) {
|
|
175
|
+
background-color: var(--color-bg-subtle);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.variant-ghost:active:not([aria-disabled='true']):not(:disabled) {
|
|
179
|
+
background-color: var(--color-bg-subtle);
|
|
180
|
+
color: var(--btn-text-active);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/* =========================================================================
|
|
184
|
+
* Disabled / Loading
|
|
185
|
+
* ========================================================================= */
|
|
186
|
+
|
|
187
|
+
.disabled,
|
|
188
|
+
.button:disabled,
|
|
189
|
+
.button[aria-disabled='true'] {
|
|
190
|
+
cursor: not-allowed;
|
|
191
|
+
opacity: 0.5;
|
|
192
|
+
pointer-events: none;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.loading {
|
|
196
|
+
cursor: wait;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.content {
|
|
200
|
+
display: inline-flex;
|
|
201
|
+
align-items: center;
|
|
202
|
+
gap: var(--spacing-xs);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.contentHidden {
|
|
206
|
+
visibility: hidden;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/* startIcon: ラベル左側のアイコン。currentColor 継承で variant の文字色に追従する */
|
|
210
|
+
.startIcon {
|
|
211
|
+
display: inline-flex;
|
|
212
|
+
align-items: center;
|
|
213
|
+
flex-shrink: 0;
|
|
214
|
+
color: currentColor;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/* スピナー(CSS のみで実装し、SVG / 追加依存を避ける) */
|
|
218
|
+
.spinner {
|
|
219
|
+
position: absolute;
|
|
220
|
+
width: 1em;
|
|
221
|
+
height: 1em;
|
|
222
|
+
border: 2px solid currentColor;
|
|
223
|
+
border-top-color: transparent;
|
|
224
|
+
border-radius: var(--radius-full);
|
|
225
|
+
animation: button-spin 0.8s linear infinite;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
@keyframes button-spin {
|
|
229
|
+
to {
|
|
230
|
+
transform: rotate(360deg);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
@media (prefers-reduced-motion: reduce) {
|
|
235
|
+
.spinner {
|
|
236
|
+
animation-duration: 2s;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Button/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Button/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Checkbox のサイズ。
|
|
4
|
+
*/
|
|
5
|
+
export type CheckboxSize = 'sm' | 'md' | 'lg';
|
|
6
|
+
/**
|
|
7
|
+
* Checkbox のプロパティ。
|
|
8
|
+
*
|
|
9
|
+
* 100% ライブラリ非依存の独自定義。MUI / Radix 等の Props 型は extends しない。
|
|
10
|
+
* エスケープハッチは `className` のみ。
|
|
11
|
+
*/
|
|
12
|
+
export interface CheckboxProps {
|
|
13
|
+
checked?: boolean;
|
|
14
|
+
defaultChecked?: boolean;
|
|
15
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
16
|
+
/**
|
|
17
|
+
* チェックボックス右側に表示するラベル。
|
|
18
|
+
* 渡すと `<label>` で input と関連付けて 1 コンポーネントで完結する
|
|
19
|
+
* (MUI の `<FormControlLabel control={<Checkbox/>} label="..."/>` 相当)。
|
|
20
|
+
*/
|
|
21
|
+
label?: React.ReactNode;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
required?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* 部分選択状態。`true` のとき、HTML の `indeterminate` DOM プロパティを設定し、
|
|
26
|
+
* 視覚的にも横棒(ダッシュ)アイコンを表示する。
|
|
27
|
+
*/
|
|
28
|
+
indeterminate?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* サイズ。既定: `md`
|
|
31
|
+
*/
|
|
32
|
+
size?: CheckboxSize;
|
|
33
|
+
id?: string;
|
|
34
|
+
name?: string;
|
|
35
|
+
value?: string;
|
|
36
|
+
autoFocus?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* `label` 以外で名前を提供する場合に使用する。`label` が指定されている場合は不要。
|
|
39
|
+
*/
|
|
40
|
+
'aria-label'?: string;
|
|
41
|
+
'aria-labelledby'?: string;
|
|
42
|
+
className?: string;
|
|
43
|
+
/**
|
|
44
|
+
* 内部の `<input type="checkbox">` 要素への ref。
|
|
45
|
+
*/
|
|
46
|
+
inputRef?: React.Ref<HTMLInputElement>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* チェックボックスコンポーネント。
|
|
50
|
+
*
|
|
51
|
+
* - `label` を渡せば `<label>` で input と自動関連付け(a11y 必須対応)
|
|
52
|
+
* - `indeterminate` で DOM プロパティと視覚(横棒アイコン)を同期
|
|
53
|
+
* - 視覚的に隠した native `<input type="checkbox">` を CSS で再描画
|
|
54
|
+
*
|
|
55
|
+
* @see docs/development/shared-ui-components.md
|
|
56
|
+
*/
|
|
57
|
+
declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLInputElement>>;
|
|
58
|
+
export default Checkbox;
|
|
59
|
+
//# sourceMappingURL=Checkbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../../../src/components/Checkbox/Checkbox.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAE5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAGhE;;;;OAIG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAGxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAGxB;;OAEG;IACH,IAAI,CAAC,EAAE,YAAY,CAAC;IAGpB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IAGpB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAG3B,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;CACxC;AAED;;;;;;;;GAQG;AACH,QAAA,MAAM,QAAQ,wFA4GZ,CAAC;AAEH,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import styles from './Checkbox.module.css';
|
|
4
|
+
/**
|
|
5
|
+
* チェックボックスコンポーネント。
|
|
6
|
+
*
|
|
7
|
+
* - `label` を渡せば `<label>` で input と自動関連付け(a11y 必須対応)
|
|
8
|
+
* - `indeterminate` で DOM プロパティと視覚(横棒アイコン)を同期
|
|
9
|
+
* - 視覚的に隠した native `<input type="checkbox">` を CSS で再描画
|
|
10
|
+
*
|
|
11
|
+
* @see docs/development/shared-ui-components.md
|
|
12
|
+
*/
|
|
13
|
+
const Checkbox = React.forwardRef(function Checkbox({ checked, defaultChecked, onChange, label, disabled = false, required = false, indeterminate = false, size = 'md', id, name, value, autoFocus, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, className, inputRef, }, ref) {
|
|
14
|
+
const generatedId = React.useId();
|
|
15
|
+
const inputId = id ?? generatedId;
|
|
16
|
+
// 内部 ref を作り、外部から渡された ref とマージする。
|
|
17
|
+
// indeterminate は HTML 属性ではなく DOM プロパティなので useEffect で同期。
|
|
18
|
+
const internalRef = React.useRef(null);
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
if (internalRef.current) {
|
|
21
|
+
internalRef.current.indeterminate = indeterminate;
|
|
22
|
+
}
|
|
23
|
+
}, [indeterminate]);
|
|
24
|
+
const setRefs = React.useCallback((node) => {
|
|
25
|
+
internalRef.current = node;
|
|
26
|
+
if (typeof ref === 'function') {
|
|
27
|
+
ref(node);
|
|
28
|
+
}
|
|
29
|
+
else if (ref) {
|
|
30
|
+
ref.current = node;
|
|
31
|
+
}
|
|
32
|
+
if (typeof inputRef === 'function') {
|
|
33
|
+
inputRef(node);
|
|
34
|
+
}
|
|
35
|
+
else if (inputRef) {
|
|
36
|
+
inputRef.current = node;
|
|
37
|
+
}
|
|
38
|
+
}, [ref, inputRef]);
|
|
39
|
+
const wrapperClasses = [
|
|
40
|
+
styles.wrapper,
|
|
41
|
+
disabled ? styles.disabled : null,
|
|
42
|
+
styles[`size-${size}`],
|
|
43
|
+
className,
|
|
44
|
+
]
|
|
45
|
+
.filter(Boolean)
|
|
46
|
+
.join(' ');
|
|
47
|
+
const inputElement = (<span className={styles.root}>
|
|
48
|
+
<input ref={setRefs} id={inputId} type="checkbox" name={name} value={value} checked={checked} defaultChecked={defaultChecked} onChange={onChange} disabled={disabled} required={required} autoFocus={autoFocus} aria-label={ariaLabel} aria-labelledby={ariaLabelledBy} className={styles.input}/>
|
|
49
|
+
<span className={styles.box} aria-hidden="true">
|
|
50
|
+
{/* チェックマーク(checked 時に表示) */}
|
|
51
|
+
<svg className={styles.checkIcon} viewBox="0 0 24 24" focusable="false">
|
|
52
|
+
<path d="M9 16.17 4.83 12l-1.41 1.41L9 19 21 7l-1.41-1.41z"/>
|
|
53
|
+
</svg>
|
|
54
|
+
{/* 横棒(indeterminate 時に表示) */}
|
|
55
|
+
<svg className={styles.dashIcon} viewBox="0 0 24 24" focusable="false">
|
|
56
|
+
<path d="M19 13H5v-2h14v2z"/>
|
|
57
|
+
</svg>
|
|
58
|
+
</span>
|
|
59
|
+
</span>);
|
|
60
|
+
if (label) {
|
|
61
|
+
return (<label htmlFor={inputId} className={wrapperClasses}>
|
|
62
|
+
{inputElement}
|
|
63
|
+
<span className={styles.labelText}>
|
|
64
|
+
{label}
|
|
65
|
+
{required ? (<span aria-hidden="true" className={styles.requiredMark}>
|
|
66
|
+
{' '}
|
|
67
|
+
*
|
|
68
|
+
</span>) : null}
|
|
69
|
+
</span>
|
|
70
|
+
</label>);
|
|
71
|
+
}
|
|
72
|
+
return <span className={wrapperClasses}>{inputElement}</span>;
|
|
73
|
+
});
|
|
74
|
+
export default Checkbox;
|
|
75
|
+
//# sourceMappingURL=Checkbox.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.jsx","sourceRoot":"","sources":["../../../../src/components/Checkbox/Checkbox.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAiE3C;;;;;;;;GAQG;AACH,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAkC,SAAS,Q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