@14ch/svelte-ui 0.0.11 → 0.0.13
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/assets/styles/variables.scss +0 -6
- package/dist/components/Button.svelte +82 -73
- package/dist/components/Button.svelte.d.ts +26 -25
- package/dist/components/Checkbox.svelte +86 -77
- package/dist/components/Checkbox.svelte.d.ts +26 -25
- package/dist/components/CheckboxGroup.svelte +43 -26
- package/dist/components/CheckboxGroup.svelte.d.ts +4 -3
- package/dist/components/ColorPicker.svelte +71 -61
- package/dist/components/ColorPicker.svelte.d.ts +28 -27
- package/dist/components/Combobox.svelte +79 -76
- package/dist/components/Combobox.svelte.d.ts +28 -27
- package/dist/components/ConfirmDialog.svelte +24 -22
- package/dist/components/ConfirmDialog.svelte.d.ts +2 -2
- package/dist/components/Datepicker.svelte +131 -84
- package/dist/components/Datepicker.svelte.d.ts +33 -30
- package/dist/components/DatepickerCalendar.svelte +24 -18
- package/dist/components/DatepickerCalendar.svelte.d.ts +7 -6
- package/dist/components/Dialog.svelte +30 -28
- package/dist/components/Dialog.svelte.d.ts +2 -2
- package/dist/components/Drawer.svelte +31 -29
- package/dist/components/Drawer.svelte.d.ts +2 -2
- package/dist/components/Fab.svelte +63 -54
- package/dist/components/Fab.svelte.d.ts +26 -25
- package/dist/components/FileUploader.svelte +59 -49
- package/dist/components/FileUploader.svelte.d.ts +14 -13
- package/dist/components/Icon.svelte +29 -27
- package/dist/components/Icon.svelte.d.ts +2 -2
- package/dist/components/IconButton.svelte +88 -79
- package/dist/components/IconButton.svelte.d.ts +26 -25
- package/dist/components/ImageUploader.svelte +61 -51
- package/dist/components/ImageUploader.svelte.d.ts +14 -13
- package/dist/components/ImageUploaderPreview.svelte +33 -20
- package/dist/components/ImageUploaderPreview.svelte.d.ts +2 -2
- package/dist/components/Input.svelte +105 -93
- package/dist/components/Input.svelte.d.ts +30 -29
- package/dist/components/LoadingSpinner.svelte +14 -13
- package/dist/components/LoadingSpinner.svelte.d.ts +2 -2
- package/dist/components/Modal.svelte +26 -24
- package/dist/components/Modal.svelte.d.ts +2 -2
- package/dist/components/Pagination.svelte +20 -28
- package/dist/components/Pagination.svelte.d.ts +2 -2
- package/dist/components/Popup.svelte +48 -49
- package/dist/components/Popup.svelte.d.ts +3 -3
- package/dist/components/PopupMenu.svelte +90 -90
- package/dist/components/PopupMenu.svelte.d.ts +2 -2
- package/dist/components/PopupMenuButton.svelte +83 -76
- package/dist/components/PopupMenuButton.svelte.d.ts +26 -25
- package/dist/components/Radio.svelte +73 -63
- package/dist/components/Radio.svelte.d.ts +30 -28
- package/dist/components/RadioGroup.svelte +39 -26
- package/dist/components/RadioGroup.svelte.d.ts +4 -3
- package/dist/components/SegmentedControl.svelte +79 -69
- package/dist/components/SegmentedControl.svelte.d.ts +26 -25
- package/dist/components/Select.svelte +73 -65
- package/dist/components/Select.svelte.d.ts +27 -26
- package/dist/components/Slider.svelte +73 -64
- package/dist/components/Slider.svelte.d.ts +26 -25
- package/dist/components/Snackbar.svelte +10 -9
- package/dist/components/Snackbar.svelte.d.ts +2 -2
- package/dist/components/SnackbarItem.svelte +28 -28
- package/dist/components/SnackbarItem.svelte.d.ts +2 -2
- package/dist/components/Switch.svelte +70 -62
- package/dist/components/Switch.svelte.d.ts +26 -25
- package/dist/components/Tab.svelte +31 -20
- package/dist/components/Tab.svelte.d.ts +3 -2
- package/dist/components/TabItem.svelte +20 -19
- package/dist/components/TabItem.svelte.d.ts +2 -2
- package/dist/components/Textarea.svelte +96 -95
- package/dist/components/Textarea.svelte.d.ts +27 -26
- package/dist/components/skeleton/Skeleton.svelte +16 -14
- package/dist/components/skeleton/Skeleton.svelte.d.ts +2 -2
- package/dist/components/skeleton/SkeletonAvatar.svelte +9 -5
- package/dist/components/skeleton/SkeletonAvatar.svelte.d.ts +2 -2
- package/dist/components/skeleton/SkeletonBox.svelte +11 -11
- package/dist/components/skeleton/SkeletonBox.svelte.d.ts +2 -2
- package/dist/components/skeleton/SkeletonButton.svelte +10 -5
- package/dist/components/skeleton/SkeletonButton.svelte.d.ts +2 -2
- package/dist/components/skeleton/SkeletonHeading.svelte +8 -11
- package/dist/components/skeleton/SkeletonHeading.svelte.d.ts +2 -2
- package/dist/components/skeleton/SkeletonMedia.svelte +10 -6
- package/dist/components/skeleton/SkeletonMedia.svelte.d.ts +2 -2
- package/dist/components/skeleton/SkeletonText.svelte +9 -13
- package/dist/components/skeleton/SkeletonText.svelte.d.ts +2 -2
- package/dist/index.d.ts +41 -0
- package/dist/types/eventHandlers.d.ts +9 -0
- package/dist/types/eventHandlers.js +2 -0
- package/dist/types/options.d.ts +1 -1
- package/dist/utils/formatText.js +4 -1
- package/package.json +5 -2
|
@@ -8,6 +8,15 @@
|
|
|
8
8
|
// =========================================================================
|
|
9
9
|
// Props, States & Constants
|
|
10
10
|
// =========================================================================
|
|
11
|
+
export type SnackbarProps = {
|
|
12
|
+
// スタイル/レイアウト
|
|
13
|
+
position?: 'top' | 'bottom';
|
|
14
|
+
maxVisible?: number;
|
|
15
|
+
variant?: 'filled' | 'outlined';
|
|
16
|
+
|
|
17
|
+
// 状態/動作
|
|
18
|
+
duration?: number;
|
|
19
|
+
};
|
|
11
20
|
|
|
12
21
|
let {
|
|
13
22
|
// スタイル/レイアウト
|
|
@@ -17,15 +26,7 @@
|
|
|
17
26
|
|
|
18
27
|
// 状態/動作
|
|
19
28
|
duration = 3000
|
|
20
|
-
}:
|
|
21
|
-
// スタイル/レイアウト
|
|
22
|
-
position?: 'top' | 'bottom';
|
|
23
|
-
maxVisible?: number;
|
|
24
|
-
variant?: 'filled' | 'outlined';
|
|
25
|
-
|
|
26
|
-
// 状態/動作
|
|
27
|
-
duration?: number;
|
|
28
|
-
} = $props();
|
|
29
|
+
}: SnackbarProps = $props();
|
|
29
30
|
|
|
30
31
|
// =========================================================================
|
|
31
32
|
// Lifecycle
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
type
|
|
1
|
+
export type SnackbarProps = {
|
|
2
2
|
position?: 'top' | 'bottom';
|
|
3
3
|
maxVisible?: number;
|
|
4
4
|
variant?: 'filled' | 'outlined';
|
|
5
5
|
duration?: number;
|
|
6
6
|
};
|
|
7
|
-
declare const Snackbar: import("svelte").Component
|
|
7
|
+
declare const Snackbar: import("svelte").Component<SnackbarProps, {}, "">;
|
|
8
8
|
type Snackbar = ReturnType<typeof Snackbar>;
|
|
9
9
|
export default Snackbar;
|
|
@@ -12,6 +12,33 @@
|
|
|
12
12
|
// =========================================================================
|
|
13
13
|
// Props, States & Constants
|
|
14
14
|
// =========================================================================
|
|
15
|
+
export type SnackbarItemProps = {
|
|
16
|
+
// Snippet
|
|
17
|
+
children?: Snippet;
|
|
18
|
+
|
|
19
|
+
// 基本プロパティ
|
|
20
|
+
message?: string;
|
|
21
|
+
type?: 'info' | 'success' | 'warning' | 'error' | 'default';
|
|
22
|
+
actionLabel?: string;
|
|
23
|
+
|
|
24
|
+
// HTML属性系
|
|
25
|
+
id: string;
|
|
26
|
+
|
|
27
|
+
// スタイル/レイアウト
|
|
28
|
+
variant?: 'filled' | 'outlined';
|
|
29
|
+
position?: 'top' | 'bottom';
|
|
30
|
+
color?: string;
|
|
31
|
+
textColor?: string;
|
|
32
|
+
|
|
33
|
+
// 状態/動作
|
|
34
|
+
duration?: number;
|
|
35
|
+
closable?: boolean;
|
|
36
|
+
closeButtonAriaLabel?: string;
|
|
37
|
+
iconVariant?: IconVariant;
|
|
38
|
+
|
|
39
|
+
// イベントハンドラー
|
|
40
|
+
onAction?: () => void;
|
|
41
|
+
};
|
|
15
42
|
|
|
16
43
|
let {
|
|
17
44
|
// Snippet
|
|
@@ -39,33 +66,7 @@
|
|
|
39
66
|
|
|
40
67
|
// イベントハンドラー
|
|
41
68
|
onAction
|
|
42
|
-
}:
|
|
43
|
-
// Snippet
|
|
44
|
-
children?: Snippet;
|
|
45
|
-
|
|
46
|
-
// 基本プロパティ
|
|
47
|
-
message?: string;
|
|
48
|
-
type?: 'info' | 'success' | 'warning' | 'error' | 'default';
|
|
49
|
-
actionLabel?: string;
|
|
50
|
-
|
|
51
|
-
// HTML属性系
|
|
52
|
-
id: string;
|
|
53
|
-
|
|
54
|
-
// スタイル/レイアウト
|
|
55
|
-
variant?: 'filled' | 'outlined';
|
|
56
|
-
position?: 'top' | 'bottom';
|
|
57
|
-
color?: string;
|
|
58
|
-
textColor?: string;
|
|
59
|
-
|
|
60
|
-
// 状態/動作
|
|
61
|
-
duration?: number;
|
|
62
|
-
closable?: boolean;
|
|
63
|
-
closeButtonAriaLabel?: string;
|
|
64
|
-
iconVariant?: IconVariant;
|
|
65
|
-
|
|
66
|
-
// イベントハンドラー
|
|
67
|
-
onAction?: () => void;
|
|
68
|
-
} = $props();
|
|
69
|
+
}: SnackbarItemProps = $props();
|
|
69
70
|
|
|
70
71
|
let visible = $state(true);
|
|
71
72
|
let timeoutId: ReturnType<typeof setTimeout> | null = null;
|
|
@@ -95,7 +96,6 @@
|
|
|
95
96
|
// =========================================================================
|
|
96
97
|
// Methods
|
|
97
98
|
// =========================================================================
|
|
98
|
-
|
|
99
99
|
const handleClose = () => {
|
|
100
100
|
// アニメーション開始前に、他のSnackbarの位置を測定
|
|
101
101
|
if (snackbarRef) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { IconVariant } from '../types/icon';
|
|
3
|
-
type
|
|
3
|
+
export type SnackbarItemProps = {
|
|
4
4
|
children?: Snippet;
|
|
5
5
|
message?: string;
|
|
6
6
|
type?: 'info' | 'success' | 'warning' | 'error' | 'default';
|
|
@@ -16,6 +16,6 @@ type $$ComponentProps = {
|
|
|
16
16
|
iconVariant?: IconVariant;
|
|
17
17
|
onAction?: () => void;
|
|
18
18
|
};
|
|
19
|
-
declare const SnackbarItem: import("svelte").Component
|
|
19
|
+
declare const SnackbarItem: import("svelte").Component<SnackbarItemProps, {}, "">;
|
|
20
20
|
type SnackbarItem = ReturnType<typeof SnackbarItem>;
|
|
21
21
|
export default SnackbarItem;
|
|
@@ -3,10 +3,79 @@
|
|
|
3
3
|
<script lang="ts">
|
|
4
4
|
import type { Snippet } from 'svelte';
|
|
5
5
|
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
6
|
+
import type {
|
|
7
|
+
FocusHandler,
|
|
8
|
+
KeyboardHandler,
|
|
9
|
+
MouseHandler,
|
|
10
|
+
TouchHandler,
|
|
11
|
+
PointerHandler,
|
|
12
|
+
BivariantValueHandler
|
|
13
|
+
} from '../types/eventHandlers';
|
|
6
14
|
|
|
7
15
|
// =========================================================================
|
|
8
16
|
// Props, States & Constants
|
|
9
17
|
// =========================================================================
|
|
18
|
+
export type SwitchProps = {
|
|
19
|
+
// Snippet
|
|
20
|
+
children?: Snippet;
|
|
21
|
+
|
|
22
|
+
// 基本プロパティ
|
|
23
|
+
value: boolean;
|
|
24
|
+
|
|
25
|
+
// HTML属性系
|
|
26
|
+
id?: string;
|
|
27
|
+
inputAttributes?: HTMLInputAttributes | undefined;
|
|
28
|
+
|
|
29
|
+
// スタイル/レイアウト
|
|
30
|
+
size?: 'small' | 'medium' | 'large';
|
|
31
|
+
|
|
32
|
+
// 状態/動作
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
required?: boolean;
|
|
35
|
+
|
|
36
|
+
// ARIA/アクセシビリティ
|
|
37
|
+
reducedMotion?: boolean;
|
|
38
|
+
|
|
39
|
+
// フォーカスイベント
|
|
40
|
+
onfocus?: FocusHandler;
|
|
41
|
+
onblur?: FocusHandler;
|
|
42
|
+
|
|
43
|
+
// キーボードイベント
|
|
44
|
+
onkeydown?: KeyboardHandler;
|
|
45
|
+
onkeyup?: KeyboardHandler;
|
|
46
|
+
|
|
47
|
+
// マウスイベント
|
|
48
|
+
onclick?: MouseHandler;
|
|
49
|
+
onmousedown?: MouseHandler;
|
|
50
|
+
onmouseup?: MouseHandler;
|
|
51
|
+
onmouseenter?: MouseHandler;
|
|
52
|
+
onmouseleave?: MouseHandler;
|
|
53
|
+
onmouseover?: MouseHandler;
|
|
54
|
+
onmouseout?: MouseHandler;
|
|
55
|
+
oncontextmenu?: MouseHandler;
|
|
56
|
+
onauxclick?: MouseHandler;
|
|
57
|
+
|
|
58
|
+
// タッチイベント
|
|
59
|
+
ontouchstart?: TouchHandler;
|
|
60
|
+
ontouchend?: TouchHandler;
|
|
61
|
+
ontouchmove?: TouchHandler;
|
|
62
|
+
ontouchcancel?: TouchHandler;
|
|
63
|
+
|
|
64
|
+
// ポインターイベント
|
|
65
|
+
onpointerdown?: PointerHandler;
|
|
66
|
+
onpointerup?: PointerHandler;
|
|
67
|
+
onpointerenter?: PointerHandler;
|
|
68
|
+
onpointerleave?: PointerHandler;
|
|
69
|
+
onpointermove?: PointerHandler;
|
|
70
|
+
onpointercancel?: PointerHandler;
|
|
71
|
+
|
|
72
|
+
// 入力イベント
|
|
73
|
+
onchange?: (value: boolean) => void;
|
|
74
|
+
|
|
75
|
+
// その他
|
|
76
|
+
[key: string]: any;
|
|
77
|
+
};
|
|
78
|
+
|
|
10
79
|
let {
|
|
11
80
|
// Snippet
|
|
12
81
|
children,
|
|
@@ -66,72 +135,11 @@
|
|
|
66
135
|
|
|
67
136
|
// その他
|
|
68
137
|
...restProps
|
|
69
|
-
}:
|
|
70
|
-
// Snippet
|
|
71
|
-
children?: Snippet;
|
|
72
|
-
|
|
73
|
-
// 基本プロパティ
|
|
74
|
-
value: boolean;
|
|
75
|
-
|
|
76
|
-
// HTML属性系
|
|
77
|
-
id?: string;
|
|
78
|
-
inputAttributes?: HTMLInputAttributes | undefined;
|
|
79
|
-
|
|
80
|
-
// スタイル/レイアウト
|
|
81
|
-
size?: 'small' | 'medium' | 'large';
|
|
82
|
-
|
|
83
|
-
// 状態/動作
|
|
84
|
-
disabled?: boolean;
|
|
85
|
-
required?: boolean;
|
|
86
|
-
|
|
87
|
-
// ARIA/アクセシビリティ
|
|
88
|
-
reducedMotion?: boolean;
|
|
89
|
-
|
|
90
|
-
// フォーカスイベント
|
|
91
|
-
onfocus?: Function; // No params for type inference
|
|
92
|
-
onblur?: Function; // No params for type inference
|
|
93
|
-
|
|
94
|
-
// キーボードイベント
|
|
95
|
-
onkeydown?: Function; // No params for type inference
|
|
96
|
-
onkeyup?: Function; // No params for type inference
|
|
97
|
-
|
|
98
|
-
// マウスイベント
|
|
99
|
-
onclick?: Function; // No params for type inference
|
|
100
|
-
onmousedown?: Function; // No params for type inference
|
|
101
|
-
onmouseup?: Function; // No params for type inference
|
|
102
|
-
onmouseenter?: Function; // No params for type inference
|
|
103
|
-
onmouseleave?: Function; // No params for type inference
|
|
104
|
-
onmouseover?: Function; // No params for type inference
|
|
105
|
-
onmouseout?: Function; // No params for type inference
|
|
106
|
-
oncontextmenu?: Function; // No params for type inference
|
|
107
|
-
onauxclick?: Function; // No params for type inference
|
|
108
|
-
|
|
109
|
-
// タッチイベント
|
|
110
|
-
ontouchstart?: Function; // No params for type inference
|
|
111
|
-
ontouchend?: Function; // No params for type inference
|
|
112
|
-
ontouchmove?: Function; // No params for type inference
|
|
113
|
-
ontouchcancel?: Function; // No params for type inference
|
|
114
|
-
|
|
115
|
-
// ポインターイベント
|
|
116
|
-
onpointerdown?: Function; // No params for type inference
|
|
117
|
-
onpointerup?: Function; // No params for type inference
|
|
118
|
-
onpointerenter?: Function; // No params for type inference
|
|
119
|
-
onpointerleave?: Function; // No params for type inference
|
|
120
|
-
onpointermove?: Function; // No params for type inference
|
|
121
|
-
onpointercancel?: Function; // No params for type inference
|
|
122
|
-
|
|
123
|
-
// 入力イベント
|
|
124
|
-
onchange?: (value: boolean) => void;
|
|
125
|
-
|
|
126
|
-
// その他
|
|
127
|
-
[key: string]: any;
|
|
128
|
-
} = $props();
|
|
138
|
+
}: SwitchProps = $props();
|
|
129
139
|
|
|
130
140
|
let inputRef: HTMLInputElement | undefined = $state();
|
|
131
141
|
let errorId = `switch-error-${Math.random().toString(36).substring(2, 15)}`;
|
|
132
142
|
|
|
133
|
-
// =========================================================================
|
|
134
|
-
|
|
135
143
|
// =========================================================================
|
|
136
144
|
// Methods
|
|
137
145
|
// =========================================================================
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
3
|
-
type
|
|
3
|
+
import type { FocusHandler, KeyboardHandler, MouseHandler, TouchHandler, PointerHandler } from '../types/eventHandlers';
|
|
4
|
+
export type SwitchProps = {
|
|
4
5
|
children?: Snippet;
|
|
5
6
|
value: boolean;
|
|
6
7
|
id?: string;
|
|
@@ -9,32 +10,32 @@ type $$ComponentProps = {
|
|
|
9
10
|
disabled?: boolean;
|
|
10
11
|
required?: boolean;
|
|
11
12
|
reducedMotion?: boolean;
|
|
12
|
-
onfocus?:
|
|
13
|
-
onblur?:
|
|
14
|
-
onkeydown?:
|
|
15
|
-
onkeyup?:
|
|
16
|
-
onclick?:
|
|
17
|
-
onmousedown?:
|
|
18
|
-
onmouseup?:
|
|
19
|
-
onmouseenter?:
|
|
20
|
-
onmouseleave?:
|
|
21
|
-
onmouseover?:
|
|
22
|
-
onmouseout?:
|
|
23
|
-
oncontextmenu?:
|
|
24
|
-
onauxclick?:
|
|
25
|
-
ontouchstart?:
|
|
26
|
-
ontouchend?:
|
|
27
|
-
ontouchmove?:
|
|
28
|
-
ontouchcancel?:
|
|
29
|
-
onpointerdown?:
|
|
30
|
-
onpointerup?:
|
|
31
|
-
onpointerenter?:
|
|
32
|
-
onpointerleave?:
|
|
33
|
-
onpointermove?:
|
|
34
|
-
onpointercancel?:
|
|
13
|
+
onfocus?: FocusHandler;
|
|
14
|
+
onblur?: FocusHandler;
|
|
15
|
+
onkeydown?: KeyboardHandler;
|
|
16
|
+
onkeyup?: KeyboardHandler;
|
|
17
|
+
onclick?: MouseHandler;
|
|
18
|
+
onmousedown?: MouseHandler;
|
|
19
|
+
onmouseup?: MouseHandler;
|
|
20
|
+
onmouseenter?: MouseHandler;
|
|
21
|
+
onmouseleave?: MouseHandler;
|
|
22
|
+
onmouseover?: MouseHandler;
|
|
23
|
+
onmouseout?: MouseHandler;
|
|
24
|
+
oncontextmenu?: MouseHandler;
|
|
25
|
+
onauxclick?: MouseHandler;
|
|
26
|
+
ontouchstart?: TouchHandler;
|
|
27
|
+
ontouchend?: TouchHandler;
|
|
28
|
+
ontouchmove?: TouchHandler;
|
|
29
|
+
ontouchcancel?: TouchHandler;
|
|
30
|
+
onpointerdown?: PointerHandler;
|
|
31
|
+
onpointerup?: PointerHandler;
|
|
32
|
+
onpointerenter?: PointerHandler;
|
|
33
|
+
onpointerleave?: PointerHandler;
|
|
34
|
+
onpointermove?: PointerHandler;
|
|
35
|
+
onpointercancel?: PointerHandler;
|
|
35
36
|
onchange?: (value: boolean) => void;
|
|
36
37
|
[key: string]: any;
|
|
37
38
|
};
|
|
38
|
-
declare const Switch: import("svelte").Component
|
|
39
|
+
declare const Switch: import("svelte").Component<SwitchProps, {}, "value">;
|
|
39
40
|
type Switch = ReturnType<typeof Switch>;
|
|
40
41
|
export default Switch;
|
|
@@ -3,16 +3,34 @@
|
|
|
3
3
|
<script lang="ts">
|
|
4
4
|
import TabItem from './TabItem.svelte';
|
|
5
5
|
import type { MenuItem } from '../types/menuItem';
|
|
6
|
+
import { afterNavigate } from '$app/navigation';
|
|
6
7
|
|
|
7
8
|
// =========================================================================
|
|
8
9
|
// Props, States & Constants
|
|
9
10
|
// =========================================================================
|
|
11
|
+
export type TabProps = {
|
|
12
|
+
// 基本プロパティ
|
|
13
|
+
tabItems: MenuItem[];
|
|
14
|
+
pathPrefix?: string;
|
|
15
|
+
customPathMatcher?: (currentPath: string, itemHref: string, item: MenuItem) => boolean;
|
|
16
|
+
currentPath?: string;
|
|
17
|
+
|
|
18
|
+
// スタイル/レイアウト
|
|
19
|
+
textColor?: string;
|
|
20
|
+
selectedTextColor?: string;
|
|
21
|
+
selectedBarColor?: string;
|
|
22
|
+
|
|
23
|
+
// ARIA/アクセシビリティ
|
|
24
|
+
ariaLabel?: string;
|
|
25
|
+
ariaLabelledby?: string;
|
|
26
|
+
};
|
|
10
27
|
|
|
11
28
|
let {
|
|
12
29
|
// 基本プロパティ
|
|
13
30
|
tabItems = [],
|
|
14
31
|
pathPrefix = '',
|
|
15
32
|
customPathMatcher,
|
|
33
|
+
currentPath,
|
|
16
34
|
|
|
17
35
|
// スタイル/レイアウト
|
|
18
36
|
textColor = 'var(--svelte-ui-text-subtle-color)',
|
|
@@ -22,34 +40,30 @@
|
|
|
22
40
|
// ARIA/アクセシビリティ
|
|
23
41
|
ariaLabel = 'Tabs',
|
|
24
42
|
ariaLabelledby
|
|
25
|
-
}:
|
|
26
|
-
// 基本プロパティ
|
|
27
|
-
tabItems: MenuItem[];
|
|
28
|
-
pathPrefix?: string;
|
|
29
|
-
customPathMatcher?: (currentPath: string, itemHref: string, item: MenuItem) => boolean;
|
|
30
|
-
|
|
31
|
-
// スタイル/レイアウト
|
|
32
|
-
textColor?: string;
|
|
33
|
-
selectedTextColor?: string;
|
|
34
|
-
selectedBarColor?: string;
|
|
43
|
+
}: TabProps = $props();
|
|
35
44
|
|
|
36
|
-
|
|
37
|
-
ariaLabel?: string;
|
|
38
|
-
ariaLabelledby?: string;
|
|
39
|
-
} = $props();
|
|
45
|
+
let resolvedCurrentPath = $state('');
|
|
40
46
|
|
|
41
47
|
// =========================================================================
|
|
42
48
|
// Methods
|
|
43
49
|
// =========================================================================
|
|
44
|
-
|
|
45
|
-
// ブラウザ標準APIを使用した現在パス取得
|
|
46
50
|
const getCurrentPath = () => {
|
|
51
|
+
// アプリ側から現在パスが明示的に渡されていればそれを優先(SSR対応)
|
|
52
|
+
if (currentPath && currentPath !== '') {
|
|
53
|
+
return currentPath;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// それ以外の場合はクライアント実行時のみ window.location から取得
|
|
47
57
|
if (typeof window !== 'undefined') {
|
|
48
58
|
return window.location.pathname;
|
|
49
59
|
}
|
|
50
60
|
return '';
|
|
51
61
|
};
|
|
52
62
|
|
|
63
|
+
afterNavigate(() => {
|
|
64
|
+
resolvedCurrentPath = getCurrentPath();
|
|
65
|
+
});
|
|
66
|
+
|
|
53
67
|
// パスの正規化処理
|
|
54
68
|
const normalizePath = (path: string): string => {
|
|
55
69
|
if (!pathPrefix) return path;
|
|
@@ -131,16 +145,13 @@
|
|
|
131
145
|
// $derived
|
|
132
146
|
// =========================================================================
|
|
133
147
|
|
|
134
|
-
// 現在のパスを取得
|
|
135
|
-
const currentPath = $derived(getCurrentPath());
|
|
136
|
-
|
|
137
148
|
// アクティブなタブのインデックスを現在のパスに基づいて計算
|
|
138
149
|
const selectedTabIndex = $derived.by(() => {
|
|
139
150
|
for (let i = 0; i < tabItems.length; i++) {
|
|
140
151
|
const item = tabItems[i];
|
|
141
152
|
if (!item.href) continue;
|
|
142
153
|
|
|
143
|
-
if (matchPath(
|
|
154
|
+
if (matchPath(resolvedCurrentPath, item.href, item)) {
|
|
144
155
|
return i;
|
|
145
156
|
}
|
|
146
157
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { MenuItem } from '../types/menuItem';
|
|
2
|
-
type
|
|
2
|
+
export type TabProps = {
|
|
3
3
|
tabItems: MenuItem[];
|
|
4
4
|
pathPrefix?: string;
|
|
5
5
|
customPathMatcher?: (currentPath: string, itemHref: string, item: MenuItem) => boolean;
|
|
6
|
+
currentPath?: string;
|
|
6
7
|
textColor?: string;
|
|
7
8
|
selectedTextColor?: string;
|
|
8
9
|
selectedBarColor?: string;
|
|
9
10
|
ariaLabel?: string;
|
|
10
11
|
ariaLabelledby?: string;
|
|
11
12
|
};
|
|
12
|
-
declare const Tab: import("svelte").Component
|
|
13
|
+
declare const Tab: import("svelte").Component<TabProps, {}, "">;
|
|
13
14
|
type Tab = ReturnType<typeof Tab>;
|
|
14
15
|
export default Tab;
|
|
@@ -8,6 +8,25 @@
|
|
|
8
8
|
// =========================================================================
|
|
9
9
|
// Props, States & Constants
|
|
10
10
|
// =========================================================================
|
|
11
|
+
export type TabItemProps = {
|
|
12
|
+
// 基本プロパティ
|
|
13
|
+
tabItem: MenuItem;
|
|
14
|
+
|
|
15
|
+
// スタイル/レイアウト
|
|
16
|
+
textColor: string;
|
|
17
|
+
selectedTextColor: string;
|
|
18
|
+
selectedBarColor: string;
|
|
19
|
+
|
|
20
|
+
// アイコン関連
|
|
21
|
+
iconFilled?: boolean;
|
|
22
|
+
iconWeight?: IconWeight;
|
|
23
|
+
iconGrade?: IconGrade;
|
|
24
|
+
iconOpticalSize?: IconOpticalSize;
|
|
25
|
+
iconVariant?: IconVariant;
|
|
26
|
+
|
|
27
|
+
// 状態/動作
|
|
28
|
+
isSelected?: boolean;
|
|
29
|
+
};
|
|
11
30
|
|
|
12
31
|
let {
|
|
13
32
|
// 基本プロパティ
|
|
@@ -27,25 +46,7 @@
|
|
|
27
46
|
|
|
28
47
|
// 状態/動作
|
|
29
48
|
isSelected = false
|
|
30
|
-
}:
|
|
31
|
-
// 基本プロパティ
|
|
32
|
-
tabItem: MenuItem;
|
|
33
|
-
|
|
34
|
-
// スタイル/レイアウト
|
|
35
|
-
textColor: string;
|
|
36
|
-
selectedTextColor: string;
|
|
37
|
-
selectedBarColor: string;
|
|
38
|
-
|
|
39
|
-
// アイコン関連
|
|
40
|
-
iconFilled?: boolean;
|
|
41
|
-
iconWeight?: IconWeight;
|
|
42
|
-
iconGrade?: IconGrade;
|
|
43
|
-
iconOpticalSize?: IconOpticalSize;
|
|
44
|
-
iconVariant?: IconVariant;
|
|
45
|
-
|
|
46
|
-
// 状態/動作
|
|
47
|
-
isSelected?: boolean;
|
|
48
|
-
} = $props();
|
|
49
|
+
}: TabItemProps = $props();
|
|
49
50
|
</script>
|
|
50
51
|
|
|
51
52
|
<a
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MenuItem } from '../types/menuItem';
|
|
2
2
|
import type { IconVariant, IconWeight, IconGrade, IconOpticalSize } from '../types/icon';
|
|
3
|
-
type
|
|
3
|
+
export type TabItemProps = {
|
|
4
4
|
tabItem: MenuItem;
|
|
5
5
|
textColor: string;
|
|
6
6
|
selectedTextColor: string;
|
|
@@ -12,6 +12,6 @@ type $$ComponentProps = {
|
|
|
12
12
|
iconVariant?: IconVariant;
|
|
13
13
|
isSelected?: boolean;
|
|
14
14
|
};
|
|
15
|
-
declare const TabItem: import("svelte").Component
|
|
15
|
+
declare const TabItem: import("svelte").Component<TabItemProps, {}, "">;
|
|
16
16
|
type TabItem = ReturnType<typeof TabItem>;
|
|
17
17
|
export default TabItem;
|