@14ch/svelte-ui 0.0.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/README.md +359 -0
- package/dist/assets/styles/README.md +144 -0
- package/dist/assets/styles/core.scss +61 -0
- package/dist/assets/styles/import.scss +11 -0
- package/dist/assets/styles/optional/fonts.scss +23 -0
- package/dist/assets/styles/optional/reset.scss +230 -0
- package/dist/assets/styles/variables.scss +805 -0
- package/dist/components/Button.svelte +574 -0
- package/dist/components/Button.svelte.d.ts +56 -0
- package/dist/components/COMPONENT_DESIGN_GUIDELINES.md +127 -0
- package/dist/components/Checkbox.svelte +523 -0
- package/dist/components/Checkbox.svelte.d.ts +42 -0
- package/dist/components/CheckboxGroup.svelte +82 -0
- package/dist/components/CheckboxGroup.svelte.d.ts +13 -0
- package/dist/components/ColorPicker.svelte +496 -0
- package/dist/components/ColorPicker.svelte.d.ts +45 -0
- package/dist/components/Combobox.svelte +576 -0
- package/dist/components/Combobox.svelte.d.ts +52 -0
- package/dist/components/ConfirmDialog.svelte +116 -0
- package/dist/components/ConfirmDialog.svelte.d.ts +20 -0
- package/dist/components/Datepicker.svelte +578 -0
- package/dist/components/Datepicker.svelte.d.ts +72 -0
- package/dist/components/DatepickerCalendar.svelte +925 -0
- package/dist/components/DatepickerCalendar.svelte.d.ts +31 -0
- package/dist/components/Dialog.svelte +245 -0
- package/dist/components/Dialog.svelte.d.ts +38 -0
- package/dist/components/Drawer.svelte +383 -0
- package/dist/components/Drawer.svelte.d.ts +39 -0
- package/dist/components/Fab.svelte +486 -0
- package/dist/components/Fab.svelte.d.ts +51 -0
- package/dist/components/FileUploader.svelte +456 -0
- package/dist/components/FileUploader.svelte.d.ts +36 -0
- package/dist/components/Icon.svelte +167 -0
- package/dist/components/Icon.svelte.d.ts +21 -0
- package/dist/components/IconButton.svelte +557 -0
- package/dist/components/IconButton.svelte.d.ts +60 -0
- package/dist/components/ImageUploader.svelte +516 -0
- package/dist/components/ImageUploader.svelte.d.ts +37 -0
- package/dist/components/ImageUploaderPreview.svelte +157 -0
- package/dist/components/ImageUploaderPreview.svelte.d.ts +13 -0
- package/dist/components/Input.svelte +885 -0
- package/dist/components/Input.svelte.d.ts +75 -0
- package/dist/components/LoadingSpinner.svelte +116 -0
- package/dist/components/LoadingSpinner.svelte.d.ts +10 -0
- package/dist/components/Modal.svelte +313 -0
- package/dist/components/Modal.svelte.d.ts +34 -0
- package/dist/components/Pagination.svelte +276 -0
- package/dist/components/Pagination.svelte.d.ts +14 -0
- package/dist/components/Popup.svelte +676 -0
- package/dist/components/Popup.svelte.d.ts +40 -0
- package/dist/components/PopupMenu.svelte +421 -0
- package/dist/components/PopupMenu.svelte.d.ts +24 -0
- package/dist/components/PopupMenuButton.svelte +365 -0
- package/dist/components/PopupMenuButton.svelte.d.ts +42 -0
- package/dist/components/Radio.svelte +548 -0
- package/dist/components/Radio.svelte.d.ts +42 -0
- package/dist/components/RadioGroup.svelte +74 -0
- package/dist/components/RadioGroup.svelte.d.ts +14 -0
- package/dist/components/Select.svelte +479 -0
- package/dist/components/Select.svelte.d.ts +47 -0
- package/dist/components/Slider.svelte +473 -0
- package/dist/components/Slider.svelte.d.ts +46 -0
- package/dist/components/Snackbar.svelte +124 -0
- package/dist/components/Snackbar.svelte.d.ts +9 -0
- package/dist/components/SnackbarItem.svelte +423 -0
- package/dist/components/SnackbarItem.svelte.d.ts +21 -0
- package/dist/components/Switch.svelte +454 -0
- package/dist/components/Switch.svelte.d.ts +40 -0
- package/dist/components/Tab.svelte +193 -0
- package/dist/components/Tab.svelte.d.ts +14 -0
- package/dist/components/TabItem.svelte +140 -0
- package/dist/components/TabItem.svelte.d.ts +17 -0
- package/dist/components/Textarea.svelte +702 -0
- package/dist/components/Textarea.svelte.d.ts +64 -0
- package/dist/components/skeleton/Skeleton.svelte +235 -0
- package/dist/components/skeleton/Skeleton.svelte.d.ts +13 -0
- package/dist/components/skeleton/SkeletonAvatar.svelte +97 -0
- package/dist/components/skeleton/SkeletonAvatar.svelte.d.ts +8 -0
- package/dist/components/skeleton/SkeletonBox.svelte +105 -0
- package/dist/components/skeleton/SkeletonBox.svelte.d.ts +12 -0
- package/dist/components/skeleton/SkeletonButton.svelte +71 -0
- package/dist/components/skeleton/SkeletonButton.svelte.d.ts +8 -0
- package/dist/components/skeleton/SkeletonHeading.svelte +49 -0
- package/dist/components/skeleton/SkeletonHeading.svelte.d.ts +8 -0
- package/dist/components/skeleton/SkeletonMedia.svelte +115 -0
- package/dist/components/skeleton/SkeletonMedia.svelte.d.ts +9 -0
- package/dist/components/skeleton/SkeletonText.svelte +75 -0
- package/dist/components/skeleton/SkeletonText.svelte.d.ts +8 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +43 -0
- package/dist/types/icon.d.ts +4 -0
- package/dist/types/icon.js +2 -0
- package/dist/types/menuItem.d.ts +8 -0
- package/dist/types/menuItem.js +1 -0
- package/dist/types/options.d.ts +6 -0
- package/dist/types/options.js +4 -0
- package/dist/types/skeleton.d.ts +77 -0
- package/dist/types/skeleton.js +19 -0
- package/dist/utils/accessibility.d.ts +48 -0
- package/dist/utils/accessibility.js +87 -0
- package/dist/utils/formatText.d.ts +4 -0
- package/dist/utils/formatText.js +44 -0
- package/dist/utils/mobile.d.ts +9 -0
- package/dist/utils/mobile.js +47 -0
- package/dist/utils/snackbar.svelte.d.ts +51 -0
- package/dist/utils/snackbar.svelte.js +107 -0
- package/dist/utils/style.d.ts +17 -0
- package/dist/utils/style.js +22 -0
- package/package.json +102 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Option, OptionValue } from '../types/options';
|
|
3
|
+
import Checkbox from './Checkbox.svelte';
|
|
4
|
+
import { onMount } from 'svelte';
|
|
5
|
+
import { getStyleFromNumber } from '../utils/style';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
// 基本プロパティ
|
|
9
|
+
options,
|
|
10
|
+
value = $bindable(),
|
|
11
|
+
|
|
12
|
+
// スタイル/レイアウト
|
|
13
|
+
direction = 'vertical',
|
|
14
|
+
gap = '0',
|
|
15
|
+
wrap = false,
|
|
16
|
+
minOptionWidth,
|
|
17
|
+
|
|
18
|
+
// 入力イベント
|
|
19
|
+
onchange = () => {} // No params for type inference
|
|
20
|
+
}: {
|
|
21
|
+
// 基本プロパティ
|
|
22
|
+
options: Option[];
|
|
23
|
+
value: OptionValue[];
|
|
24
|
+
|
|
25
|
+
// スタイル/レイアウト
|
|
26
|
+
direction?: 'vertical' | 'horizontal';
|
|
27
|
+
gap?: string | number;
|
|
28
|
+
wrap?: boolean;
|
|
29
|
+
minOptionWidth?: string | number;
|
|
30
|
+
|
|
31
|
+
// 入力イベント
|
|
32
|
+
onchange?: (value: OptionValue[]) => void;
|
|
33
|
+
} = $props();
|
|
34
|
+
let localValues: Record<string, boolean> = $state({});
|
|
35
|
+
|
|
36
|
+
onMount(() => {
|
|
37
|
+
options.forEach((option) => {
|
|
38
|
+
localValues[option.value] = false;
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const handleChange = () => {
|
|
43
|
+
value = options.filter((option) => localValues[option.value]).map((option) => option.value);
|
|
44
|
+
onchange(value);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const gapStyle = getStyleFromNumber(gap);
|
|
48
|
+
|
|
49
|
+
const minOptionWidthStyle = getStyleFromNumber(minOptionWidth);
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<ul
|
|
53
|
+
class="checkbox-group"
|
|
54
|
+
style="--flex-direction: {direction === 'vertical' ? 'column' : 'row'};
|
|
55
|
+
--gap: {gapStyle};
|
|
56
|
+
--wrap: {wrap ? 'wrap' : 'none'};
|
|
57
|
+
--min-option-width: {minOptionWidthStyle}
|
|
58
|
+
"
|
|
59
|
+
>
|
|
60
|
+
{#each options as option (option.value)}
|
|
61
|
+
{#if localValues[option.value] !== undefined}
|
|
62
|
+
<li class="checkbox-group__option">
|
|
63
|
+
<Checkbox bind:value={localValues[option.value]} onchange={handleChange}>
|
|
64
|
+
{option.label}
|
|
65
|
+
</Checkbox>
|
|
66
|
+
</li>
|
|
67
|
+
{/if}
|
|
68
|
+
{/each}
|
|
69
|
+
</ul>
|
|
70
|
+
|
|
71
|
+
<style>
|
|
72
|
+
.checkbox-group {
|
|
73
|
+
display: flex;
|
|
74
|
+
flex-direction: var(--flex-direction);
|
|
75
|
+
gap: var(--gap);
|
|
76
|
+
flex-wrap: var(--wrap);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.checkbox-group__option {
|
|
80
|
+
min-width: var(--min-option-width);
|
|
81
|
+
}
|
|
82
|
+
</style>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Option, OptionValue } from '../types/options';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
options: Option[];
|
|
4
|
+
value: OptionValue[];
|
|
5
|
+
direction?: 'vertical' | 'horizontal';
|
|
6
|
+
gap?: string | number;
|
|
7
|
+
wrap?: boolean;
|
|
8
|
+
minOptionWidth?: string | number;
|
|
9
|
+
onchange?: (value: OptionValue[]) => void;
|
|
10
|
+
};
|
|
11
|
+
declare const CheckboxGroup: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
12
|
+
type CheckboxGroup = ReturnType<typeof CheckboxGroup>;
|
|
13
|
+
export default CheckboxGroup;
|
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
<!-- ColorPicker.svelte -->
|
|
2
|
+
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import { untrack } from 'svelte';
|
|
5
|
+
import Input from './Input.svelte';
|
|
6
|
+
import { t } from '../i18n';
|
|
7
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
8
|
+
import type { IconVariant } from '../types/icon';
|
|
9
|
+
|
|
10
|
+
// =========================================================================
|
|
11
|
+
// Props, States & Constants
|
|
12
|
+
// =========================================================================
|
|
13
|
+
let {
|
|
14
|
+
// 基本プロパティ
|
|
15
|
+
value = $bindable(''),
|
|
16
|
+
|
|
17
|
+
// HTML属性系
|
|
18
|
+
id = `colorpicker-${Math.random().toString(36).substring(2, 15)}`,
|
|
19
|
+
inputAttributes,
|
|
20
|
+
|
|
21
|
+
// スタイル/レイアウト
|
|
22
|
+
customStyle = '',
|
|
23
|
+
focusStyle = 'outline',
|
|
24
|
+
fullWidth = false,
|
|
25
|
+
rounded = false,
|
|
26
|
+
|
|
27
|
+
// 状態/動作
|
|
28
|
+
disabled = false,
|
|
29
|
+
readonly = false,
|
|
30
|
+
clearable = false,
|
|
31
|
+
clearButtonAriaLabel = t('input.clear'),
|
|
32
|
+
iconVariant = 'outlined',
|
|
33
|
+
|
|
34
|
+
// 入力イベント
|
|
35
|
+
onchange = () => {}, // No params for type inference
|
|
36
|
+
oninput = () => {}, // No params for type inference
|
|
37
|
+
|
|
38
|
+
// フォーカスイベント
|
|
39
|
+
onfocus = () => {}, // No params for type inference
|
|
40
|
+
onblur = () => {}, // No params for type inference
|
|
41
|
+
|
|
42
|
+
// キーボードイベント
|
|
43
|
+
onkeydown = () => {}, // No params for type inference
|
|
44
|
+
onkeyup = () => {}, // No params for type inference
|
|
45
|
+
|
|
46
|
+
// マウスイベント
|
|
47
|
+
onclick = () => {}, // No params for type inference
|
|
48
|
+
onmousedown = () => {}, // No params for type inference
|
|
49
|
+
onmouseup = () => {}, // No params for type inference
|
|
50
|
+
onmouseenter = () => {}, // No params for type inference
|
|
51
|
+
onmouseleave = () => {}, // No params for type inference
|
|
52
|
+
onmouseover = () => {}, // No params for type inference
|
|
53
|
+
onmouseout = () => {}, // No params for type inference
|
|
54
|
+
oncontextmenu = () => {}, // No params for type inference
|
|
55
|
+
onauxclick = () => {}, // No params for type inference
|
|
56
|
+
|
|
57
|
+
// タッチイベント
|
|
58
|
+
ontouchstart = () => {}, // No params for type inference
|
|
59
|
+
ontouchend = () => {}, // No params for type inference
|
|
60
|
+
ontouchmove = () => {}, // No params for type inference
|
|
61
|
+
ontouchcancel = () => {}, // No params for type inference
|
|
62
|
+
|
|
63
|
+
// ポインターイベント
|
|
64
|
+
onpointerdown = () => {}, // No params for type inference
|
|
65
|
+
onpointerup = () => {}, // No params for type inference
|
|
66
|
+
onpointerenter = () => {}, // No params for type inference
|
|
67
|
+
onpointerleave = () => {}, // No params for type inference
|
|
68
|
+
onpointermove = () => {}, // No params for type inference
|
|
69
|
+
onpointercancel = () => {}, // No params for type inference
|
|
70
|
+
|
|
71
|
+
// その他
|
|
72
|
+
...restProps
|
|
73
|
+
}: {
|
|
74
|
+
// 基本プロパティ
|
|
75
|
+
value?: string;
|
|
76
|
+
|
|
77
|
+
// HTML属性系
|
|
78
|
+
id?: string;
|
|
79
|
+
inputAttributes?: HTMLInputAttributes | undefined;
|
|
80
|
+
|
|
81
|
+
// スタイル/レイアウト
|
|
82
|
+
customStyle?: string;
|
|
83
|
+
focusStyle?: 'background' | 'outline' | 'none';
|
|
84
|
+
fullWidth?: boolean;
|
|
85
|
+
rounded?: boolean;
|
|
86
|
+
|
|
87
|
+
// 状態/動作
|
|
88
|
+
disabled?: boolean;
|
|
89
|
+
readonly?: boolean;
|
|
90
|
+
clearable?: boolean;
|
|
91
|
+
clearButtonAriaLabel?: string;
|
|
92
|
+
iconVariant?: IconVariant;
|
|
93
|
+
|
|
94
|
+
// 入力イベント
|
|
95
|
+
onchange?: (value: any) => void;
|
|
96
|
+
oninput?: (value: any) => void;
|
|
97
|
+
|
|
98
|
+
// フォーカスイベント
|
|
99
|
+
onfocus?: Function; // No params for type inference
|
|
100
|
+
onblur?: Function; // No params for type inference
|
|
101
|
+
|
|
102
|
+
// キーボードイベント
|
|
103
|
+
onkeydown?: Function; // No params for type inference
|
|
104
|
+
onkeyup?: Function; // No params for type inference
|
|
105
|
+
|
|
106
|
+
// マウスイベント
|
|
107
|
+
onclick?: Function; // No params for type inference
|
|
108
|
+
onmousedown?: Function; // No params for type inference
|
|
109
|
+
onmouseup?: Function; // No params for type inference
|
|
110
|
+
onmouseenter?: Function; // No params for type inference
|
|
111
|
+
onmouseleave?: Function; // No params for type inference
|
|
112
|
+
onmouseover?: Function; // No params for type inference
|
|
113
|
+
onmouseout?: Function; // No params for type inference
|
|
114
|
+
oncontextmenu?: Function; // No params for type inference
|
|
115
|
+
onauxclick?: Function; // No params for type inference
|
|
116
|
+
|
|
117
|
+
// タッチイベント
|
|
118
|
+
ontouchstart?: Function; // No params for type inference
|
|
119
|
+
ontouchend?: Function; // No params for type inference
|
|
120
|
+
ontouchmove?: Function; // No params for type inference
|
|
121
|
+
ontouchcancel?: Function; // No params for type inference
|
|
122
|
+
|
|
123
|
+
// ポインターイベント
|
|
124
|
+
onpointerdown?: Function; // No params for type inference
|
|
125
|
+
onpointerup?: Function; // No params for type inference
|
|
126
|
+
onpointerenter?: Function; // No params for type inference
|
|
127
|
+
onpointerleave?: Function; // No params for type inference
|
|
128
|
+
onpointermove?: Function; // No params for type inference
|
|
129
|
+
onpointercancel?: Function; // No params for type inference
|
|
130
|
+
|
|
131
|
+
// その他
|
|
132
|
+
[key: string]: any;
|
|
133
|
+
} = $props();
|
|
134
|
+
|
|
135
|
+
let localValue: string | undefined = $state(value);
|
|
136
|
+
let prevValue: string = $state('');
|
|
137
|
+
let isFocused: boolean = $state(false);
|
|
138
|
+
|
|
139
|
+
// =========================================================================
|
|
140
|
+
|
|
141
|
+
// $effect
|
|
142
|
+
// =========================================================================
|
|
143
|
+
|
|
144
|
+
$effect(() => {
|
|
145
|
+
value;
|
|
146
|
+
untrack(() => {
|
|
147
|
+
/* value を localValue に反映 */
|
|
148
|
+
localValue = value;
|
|
149
|
+
|
|
150
|
+
/* value が更新されたらonchangeを実行 */
|
|
151
|
+
handleChange();
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
$effect(() => {
|
|
156
|
+
localValue;
|
|
157
|
+
untrack(() => {
|
|
158
|
+
/* localValue がクリアされた時に value もクリア */
|
|
159
|
+
if (localValue === '' || localValue === undefined) {
|
|
160
|
+
value = '';
|
|
161
|
+
prevValue = '';
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// =========================================================================
|
|
167
|
+
// Methods
|
|
168
|
+
// =========================================================================
|
|
169
|
+
|
|
170
|
+
const handleSubmit = (event: SubmitEvent) => {
|
|
171
|
+
event?.preventDefault?.();
|
|
172
|
+
handleChange();
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const handleChange = (event?: Event): void => {
|
|
176
|
+
// 空文字列の場合はそのまま処理
|
|
177
|
+
if (localValue && !localValue.startsWith('#')) {
|
|
178
|
+
localValue = '#' + localValue;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (value !== prevValue || localValue !== prevValue) {
|
|
182
|
+
value = localValue;
|
|
183
|
+
prevValue = value;
|
|
184
|
+
onchange(value);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
const handleInput = (event?: Event): void => {
|
|
189
|
+
if (disabled) return;
|
|
190
|
+
oninput?.(localValue);
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const handleFocus = (event: FocusEvent): void => {
|
|
194
|
+
if (disabled) return;
|
|
195
|
+
isFocused = true;
|
|
196
|
+
onfocus(event);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const handleBlur = (event: FocusEvent): void => {
|
|
200
|
+
if (disabled) return;
|
|
201
|
+
isFocused = false;
|
|
202
|
+
onblur(event);
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const handleClick = (event: MouseEvent) => {
|
|
206
|
+
if (disabled) return;
|
|
207
|
+
onclick?.(event);
|
|
208
|
+
};
|
|
209
|
+
const handleKeydown = (event: KeyboardEvent) => {
|
|
210
|
+
if (disabled) return;
|
|
211
|
+
onkeydown(event);
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
const handleKeyup = (event: KeyboardEvent) => {
|
|
215
|
+
if (disabled) return;
|
|
216
|
+
onkeyup(event);
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
// マウスイベント
|
|
220
|
+
const handleMouseDown = (event: MouseEvent) => {
|
|
221
|
+
if (disabled) return;
|
|
222
|
+
onmousedown?.(event);
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
const handleMouseUp = (event: MouseEvent) => {
|
|
226
|
+
if (disabled) return;
|
|
227
|
+
onmouseup?.(event);
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
const handleMouseEnter = (event: MouseEvent) => {
|
|
231
|
+
if (disabled) return;
|
|
232
|
+
onmouseenter?.(event);
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
const handleMouseLeave = (event: MouseEvent) => {
|
|
236
|
+
if (disabled) return;
|
|
237
|
+
onmouseleave?.(event);
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
const handleMouseOver = (event: MouseEvent) => {
|
|
241
|
+
if (disabled) return;
|
|
242
|
+
onmouseover?.(event);
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
const handleMouseOut = (event: MouseEvent) => {
|
|
246
|
+
if (disabled) return;
|
|
247
|
+
onmouseout?.(event);
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const handleContextMenu = (event: MouseEvent) => {
|
|
251
|
+
if (disabled) return;
|
|
252
|
+
oncontextmenu?.(event);
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
const handleAuxClick = (event: MouseEvent) => {
|
|
256
|
+
if (disabled) return;
|
|
257
|
+
onauxclick?.(event);
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
// タッチイベント
|
|
261
|
+
const handleTouchStart = (event: TouchEvent) => {
|
|
262
|
+
if (disabled) return;
|
|
263
|
+
ontouchstart?.(event);
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
const handleTouchEnd = (event: TouchEvent) => {
|
|
267
|
+
if (disabled) return;
|
|
268
|
+
ontouchend?.(event);
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
const handleTouchMove = (event: TouchEvent) => {
|
|
272
|
+
if (disabled) return;
|
|
273
|
+
ontouchmove?.(event);
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
const handleTouchCancel = (event: TouchEvent) => {
|
|
277
|
+
if (disabled) return;
|
|
278
|
+
ontouchcancel?.(event);
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
// ポインターイベント
|
|
282
|
+
const handlePointerDown = (event: PointerEvent) => {
|
|
283
|
+
if (disabled) return;
|
|
284
|
+
onpointerdown?.(event);
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
const handlePointerUp = (event: PointerEvent) => {
|
|
288
|
+
if (disabled) return;
|
|
289
|
+
onpointerup?.(event);
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
const handlePointerEnter = (event: PointerEvent) => {
|
|
293
|
+
if (disabled) return;
|
|
294
|
+
onpointerenter?.(event);
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
const handlePointerLeave = (event: PointerEvent) => {
|
|
298
|
+
if (disabled) return;
|
|
299
|
+
onpointerleave?.(event);
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
const handlePointerMove = (event: PointerEvent) => {
|
|
303
|
+
if (disabled) return;
|
|
304
|
+
onpointermove?.(event);
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
const handlePointerCancel = (event: PointerEvent) => {
|
|
308
|
+
if (disabled) return;
|
|
309
|
+
onpointercancel?.(event);
|
|
310
|
+
};
|
|
311
|
+
</script>
|
|
312
|
+
|
|
313
|
+
<div
|
|
314
|
+
class="color-picker
|
|
315
|
+
focus-style-{focusStyle}"
|
|
316
|
+
class:color-picker--full-width={fullWidth}
|
|
317
|
+
class:color-picker--rounded={rounded}
|
|
318
|
+
class:color-picker--clearable={clearable}
|
|
319
|
+
class:color-picker--disabled={disabled}
|
|
320
|
+
class:color-picker--readonly={readonly}
|
|
321
|
+
class:color-picker--focused={isFocused}
|
|
322
|
+
data-testid="color-picker"
|
|
323
|
+
style={customStyle}
|
|
324
|
+
>
|
|
325
|
+
<Input
|
|
326
|
+
id={id ? `${id}-input` : undefined}
|
|
327
|
+
bind:value={localValue}
|
|
328
|
+
type="text"
|
|
329
|
+
placeholder=""
|
|
330
|
+
{disabled}
|
|
331
|
+
{readonly}
|
|
332
|
+
{clearable}
|
|
333
|
+
{clearButtonAriaLabel}
|
|
334
|
+
{focusStyle}
|
|
335
|
+
{fullWidth}
|
|
336
|
+
{rounded}
|
|
337
|
+
customStyle={`padding-left: var(--svelte-ui-colorpicker-text-padding-left); ${customStyle}`}
|
|
338
|
+
{inputAttributes}
|
|
339
|
+
onchange={handleChange}
|
|
340
|
+
oninput={handleInput}
|
|
341
|
+
onfocus={handleFocus}
|
|
342
|
+
onblur={handleBlur}
|
|
343
|
+
onclick={handleClick}
|
|
344
|
+
onkeydown={handleKeydown}
|
|
345
|
+
onkeyup={handleKeyup}
|
|
346
|
+
onmousedown={handleMouseDown}
|
|
347
|
+
onmouseup={handleMouseUp}
|
|
348
|
+
onmouseenter={handleMouseEnter}
|
|
349
|
+
onmouseleave={handleMouseLeave}
|
|
350
|
+
onmouseover={handleMouseOver}
|
|
351
|
+
onmouseout={handleMouseOut}
|
|
352
|
+
oncontextmenu={handleContextMenu}
|
|
353
|
+
onauxclick={handleAuxClick}
|
|
354
|
+
ontouchstart={handleTouchStart}
|
|
355
|
+
ontouchend={handleTouchEnd}
|
|
356
|
+
ontouchmove={handleTouchMove}
|
|
357
|
+
ontouchcancel={handleTouchCancel}
|
|
358
|
+
onpointerdown={handlePointerDown}
|
|
359
|
+
onpointerup={handlePointerUp}
|
|
360
|
+
onpointerenter={handlePointerEnter}
|
|
361
|
+
onpointerleave={handlePointerLeave}
|
|
362
|
+
onpointermove={handlePointerMove}
|
|
363
|
+
onpointercancel={handlePointerCancel}
|
|
364
|
+
onsubmit={handleSubmit}
|
|
365
|
+
{...restProps}
|
|
366
|
+
/>
|
|
367
|
+
|
|
368
|
+
<div class="color-picker__trigger">
|
|
369
|
+
<input
|
|
370
|
+
type="color"
|
|
371
|
+
bind:value
|
|
372
|
+
onchange={handleChange}
|
|
373
|
+
onfocus={handleFocus}
|
|
374
|
+
onblur={handleBlur}
|
|
375
|
+
onclick={handleClick}
|
|
376
|
+
onkeydown={handleKeydown}
|
|
377
|
+
{disabled}
|
|
378
|
+
class="color-picker__color-input"
|
|
379
|
+
{...inputAttributes}
|
|
380
|
+
{...restProps}
|
|
381
|
+
/>
|
|
382
|
+
<div class="color-picker__color-display" style="background-color: {value};"></div>
|
|
383
|
+
</div>
|
|
384
|
+
</div>
|
|
385
|
+
|
|
386
|
+
<style>
|
|
387
|
+
/* =============================================
|
|
388
|
+
* 基本構造・レイアウト
|
|
389
|
+
* ============================================= */
|
|
390
|
+
.color-picker {
|
|
391
|
+
display: inline-flex;
|
|
392
|
+
justify-content: stretch;
|
|
393
|
+
align-items: center;
|
|
394
|
+
position: relative;
|
|
395
|
+
width: auto;
|
|
396
|
+
max-width: 100%;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/* =============================================
|
|
400
|
+
* 基本コンポーネント
|
|
401
|
+
* ============================================= */
|
|
402
|
+
|
|
403
|
+
.color-picker__trigger {
|
|
404
|
+
position: absolute;
|
|
405
|
+
left: var(--svelte-ui-colorpicker-trigger-offset);
|
|
406
|
+
display: inline-block;
|
|
407
|
+
width: var(--svelte-ui-colorpicker-trigger-size);
|
|
408
|
+
height: var(--svelte-ui-colorpicker-trigger-size);
|
|
409
|
+
padding: 0;
|
|
410
|
+
|
|
411
|
+
&::before {
|
|
412
|
+
content: '';
|
|
413
|
+
display: block;
|
|
414
|
+
position: absolute;
|
|
415
|
+
width: 100%;
|
|
416
|
+
height: 100%;
|
|
417
|
+
border: var(--svelte-ui-colorpicker-trigger-border-style)
|
|
418
|
+
var(--svelte-ui-colorpicker-trigger-border-width)
|
|
419
|
+
var(--svelte-ui-colorpicker-trigger-border-color);
|
|
420
|
+
border-radius: var(--svelte-ui-colorpicker-trigger-border-radius);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
.color-picker__color-input {
|
|
425
|
+
opacity: 0;
|
|
426
|
+
position: absolute;
|
|
427
|
+
width: 100%;
|
|
428
|
+
height: 100%;
|
|
429
|
+
padding: 0;
|
|
430
|
+
z-index: 2;
|
|
431
|
+
pointer-events: auto;
|
|
432
|
+
cursor: pointer;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
.color-picker__color-display {
|
|
436
|
+
display: block;
|
|
437
|
+
width: 100%;
|
|
438
|
+
height: 100%;
|
|
439
|
+
cursor: pointer;
|
|
440
|
+
position: relative;
|
|
441
|
+
border-radius: var(--svelte-ui-colorpicker-trigger-border-radius);
|
|
442
|
+
z-index: 1;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/* =============================================
|
|
446
|
+
* レイアウトバリエーション
|
|
447
|
+
* ============================================= */
|
|
448
|
+
.color-picker--full-width {
|
|
449
|
+
width: 100%;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/* =============================================
|
|
453
|
+
* 状態管理(disabled, focused等)
|
|
454
|
+
* ============================================= */
|
|
455
|
+
.color-picker--disabled {
|
|
456
|
+
opacity: var(--svelte-ui-input-disabled-opacity);
|
|
457
|
+
pointer-events: none;
|
|
458
|
+
|
|
459
|
+
.color-picker__color-input {
|
|
460
|
+
cursor: not-allowed;
|
|
461
|
+
pointer-events: none;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/* =============================================
|
|
466
|
+
* 状態管理(readonly等)
|
|
467
|
+
* ============================================= */
|
|
468
|
+
.color-picker--readonly {
|
|
469
|
+
.color-picker__color-input,
|
|
470
|
+
.color-picker__trigger {
|
|
471
|
+
pointer-events: none;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/* =============================================
|
|
476
|
+
* デザインバリアント:default
|
|
477
|
+
* ============================================= */
|
|
478
|
+
.color-picker {
|
|
479
|
+
.color-picker__trigger::before {
|
|
480
|
+
border-color: var(--svelte-ui-colorpicker-trigger-border-color);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/* =============================================
|
|
485
|
+
* デザインバリアント:rounded
|
|
486
|
+
* ============================================= */
|
|
487
|
+
.color-picker--rounded {
|
|
488
|
+
.color-picker__color-display {
|
|
489
|
+
border-radius: var(--svelte-ui-border-radius-rounded);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
.color-picker__trigger::before {
|
|
493
|
+
border-radius: var(--svelte-ui-border-radius-rounded);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
</style>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
2
|
+
import type { IconVariant } from '../types/icon';
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
value?: string;
|
|
5
|
+
id?: string;
|
|
6
|
+
inputAttributes?: HTMLInputAttributes | undefined;
|
|
7
|
+
customStyle?: string;
|
|
8
|
+
focusStyle?: 'background' | 'outline' | 'none';
|
|
9
|
+
fullWidth?: boolean;
|
|
10
|
+
rounded?: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
readonly?: boolean;
|
|
13
|
+
clearable?: boolean;
|
|
14
|
+
clearButtonAriaLabel?: string;
|
|
15
|
+
iconVariant?: IconVariant;
|
|
16
|
+
onchange?: (value: any) => void;
|
|
17
|
+
oninput?: (value: any) => void;
|
|
18
|
+
onfocus?: Function;
|
|
19
|
+
onblur?: Function;
|
|
20
|
+
onkeydown?: Function;
|
|
21
|
+
onkeyup?: Function;
|
|
22
|
+
onclick?: Function;
|
|
23
|
+
onmousedown?: Function;
|
|
24
|
+
onmouseup?: Function;
|
|
25
|
+
onmouseenter?: Function;
|
|
26
|
+
onmouseleave?: Function;
|
|
27
|
+
onmouseover?: Function;
|
|
28
|
+
onmouseout?: Function;
|
|
29
|
+
oncontextmenu?: Function;
|
|
30
|
+
onauxclick?: Function;
|
|
31
|
+
ontouchstart?: Function;
|
|
32
|
+
ontouchend?: Function;
|
|
33
|
+
ontouchmove?: Function;
|
|
34
|
+
ontouchcancel?: Function;
|
|
35
|
+
onpointerdown?: Function;
|
|
36
|
+
onpointerup?: Function;
|
|
37
|
+
onpointerenter?: Function;
|
|
38
|
+
onpointerleave?: Function;
|
|
39
|
+
onpointermove?: Function;
|
|
40
|
+
onpointercancel?: Function;
|
|
41
|
+
[key: string]: any;
|
|
42
|
+
};
|
|
43
|
+
declare const ColorPicker: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
44
|
+
type ColorPicker = ReturnType<typeof ColorPicker>;
|
|
45
|
+
export default ColorPicker;
|