@digitalwalletcorp/vue-core 1.2.1 → 1.3.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 +79 -3
- package/lib/accordion-fieldset.d.cts +14 -4
- package/lib/accordion-fieldset.d.ts +14 -4
- package/lib/accordion-section.d.cts +20 -10
- package/lib/accordion-section.d.ts +20 -10
- package/lib/components-BuTJ1wX8.js +26 -0
- package/lib/components-CKql5lWg.cjs +1 -0
- package/lib/components.d.cts +10 -0
- package/lib/components.d.ts +10 -0
- package/lib/copy-button.d.cts +34 -0
- package/lib/copy-button.d.ts +34 -0
- package/lib/dark-mode-selector.d.cts +32 -0
- package/lib/dark-mode-selector.d.ts +32 -0
- package/lib/data-table.d.cts +29 -0
- package/lib/data-table.d.ts +29 -0
- package/lib/help-button.d.cts +39 -0
- package/lib/help-button.d.ts +39 -0
- package/lib/help-popper.d.cts +39 -0
- package/lib/help-popper.d.ts +39 -0
- package/lib/helpers/data-table-csv.d.cts +17 -0
- package/lib/helpers/data-table-csv.d.ts +17 -0
- package/lib/helpers/show-floating-component.d.cts +86 -0
- package/lib/helpers/show-floating-component.d.ts +86 -0
- package/lib/helpers/show-modal-dialog.d.cts +73 -0
- package/lib/helpers/show-modal-dialog.d.ts +73 -0
- package/lib/helpers/show-overlay-box.d.cts +53 -0
- package/lib/helpers/show-overlay-box.d.ts +53 -0
- package/lib/helpers/show-screen-loading.d.cts +20 -0
- package/lib/helpers/show-screen-loading.d.ts +20 -0
- package/lib/helpers/show-snackbar.d.cts +47 -0
- package/lib/helpers/show-snackbar.d.ts +47 -0
- package/lib/hourglass-loading.d.cts +1 -1
- package/lib/hourglass-loading.d.ts +1 -1
- package/lib/index.cjs +1 -1
- package/lib/index.d.cts +34 -0
- package/lib/index.d.ts +34 -0
- package/lib/index.js +445 -18
- package/lib/internal/anchored-popover.d.cts +35 -0
- package/lib/internal/anchored-popover.d.ts +35 -0
- package/lib/internal/anchored-position.d.cts +50 -0
- package/lib/internal/anchored-position.d.ts +50 -0
- package/lib/internal/data-table-controls.d.cts +42 -0
- package/lib/internal/data-table-controls.d.ts +42 -0
- package/lib/internal/data-table-value.d.cts +32 -0
- package/lib/internal/data-table-value.d.ts +32 -0
- package/lib/internal/floating-component.d.cts +52 -0
- package/lib/internal/floating-component.d.ts +52 -0
- package/lib/internal/icon-popper.d.cts +32 -0
- package/lib/internal/icon-popper.d.ts +32 -0
- package/lib/internal/mount-window.d.cts +39 -0
- package/lib/internal/mount-window.d.ts +39 -0
- package/lib/internal/movable-window.d.cts +55 -0
- package/lib/internal/movable-window.d.ts +55 -0
- package/lib/internal/opened-overlay-boxes.d.cts +2 -0
- package/lib/internal/opened-overlay-boxes.d.ts +2 -0
- package/lib/internal/pagination.d.cts +22 -0
- package/lib/internal/pagination.d.ts +22 -0
- package/lib/internal/snackbar-container.d.cts +20 -0
- package/lib/internal/snackbar-container.d.ts +20 -0
- package/lib/internal/snackbar-item.d.cts +17 -0
- package/lib/internal/snackbar-item.d.ts +17 -0
- package/lib/internal/tab-group-context.d.cts +4 -2
- package/lib/internal/tab-group-context.d.ts +4 -2
- package/lib/internal/use-movable-window.d.cts +44 -0
- package/lib/internal/use-movable-window.d.ts +44 -0
- package/lib/internal/window-order.d.cts +6 -0
- package/lib/internal/window-order.d.ts +6 -0
- package/lib/intersection-lazy-component.d.cts +32 -0
- package/lib/intersection-lazy-component.d.ts +32 -0
- package/lib/label-button.d.cts +2 -2
- package/lib/label-button.d.ts +2 -2
- package/lib/label-icon.d.cts +2 -2
- package/lib/label-icon.d.ts +2 -2
- package/lib/modal-dialog.d.cts +67 -0
- package/lib/modal-dialog.d.ts +67 -0
- package/lib/nuxt.cjs +1 -1
- package/lib/nuxt.js +1 -1
- package/lib/overlay-box.d.cts +52 -0
- package/lib/overlay-box.d.ts +52 -0
- package/lib/page-section.d.cts +2 -2
- package/lib/page-section.d.ts +2 -2
- package/lib/page-title.d.cts +2 -2
- package/lib/page-title.d.ts +2 -2
- package/lib/register.cjs +1 -1
- package/lib/register.js +1 -1
- package/lib/screen-loading.d.cts +7 -0
- package/lib/screen-loading.d.ts +7 -0
- package/lib/style.css +1 -1
- package/lib/tab-content.d.cts +5 -5
- package/lib/tab-content.d.ts +5 -5
- package/lib/tab-group.d.cts +7 -10
- package/lib/tab-group.d.ts +7 -10
- package/lib/types/data-table.d.cts +185 -0
- package/lib/types/data-table.d.ts +185 -0
- package/lib/types/modal-dialog.d.cts +13 -0
- package/lib/types/modal-dialog.d.ts +13 -0
- package/lib/types/movable-window.d.cts +16 -0
- package/lib/types/movable-window.d.ts +16 -0
- package/lib/warning-popper.d.cts +39 -0
- package/lib/warning-popper.d.ts +39 -0
- package/lib/warning-popper.vue_vue_type_style_index_0_lang-BKV_FX6k.js +1837 -0
- package/lib/warning-popper.vue_vue_type_style_index_0_lang-CHmkjVCO.cjs +1 -0
- package/package.json +40 -14
- package/src/accordion-fieldset.vue +24 -19
- package/src/accordion-section.vue +33 -28
- package/src/components.ts +10 -0
- package/src/copy-button.vue +89 -0
- package/src/dark-mode-selector.vue +212 -0
- package/src/data-table.vue +648 -0
- package/src/help-button.vue +128 -0
- package/src/help-popper.vue +70 -0
- package/src/helpers/data-table-csv.ts +55 -0
- package/src/helpers/show-floating-component.ts +177 -0
- package/src/helpers/show-modal-dialog.ts +121 -0
- package/src/helpers/show-overlay-box.ts +106 -0
- package/src/helpers/show-screen-loading.ts +37 -0
- package/src/helpers/show-snackbar.ts +153 -0
- package/src/hourglass-loading.vue +1 -1
- package/src/index.ts +34 -0
- package/src/internal/anchored-popover.vue +192 -0
- package/src/internal/anchored-position.ts +135 -0
- package/src/internal/data-table-controls.vue +203 -0
- package/src/internal/data-table-value.ts +99 -0
- package/src/internal/floating-component.vue +202 -0
- package/src/internal/icon-popper.vue +185 -0
- package/src/internal/mount-window.ts +110 -0
- package/src/internal/movable-window.vue +315 -0
- package/src/internal/opened-overlay-boxes.ts +2 -0
- package/src/internal/pagination.vue +325 -0
- package/src/internal/snackbar-container.vue +258 -0
- package/src/internal/snackbar-item.ts +20 -0
- package/src/internal/tab-group-context.ts +4 -2
- package/src/internal/use-movable-window.ts +208 -0
- package/src/internal/window-order.ts +11 -0
- package/src/intersection-lazy-component.vue +84 -0
- package/src/label-button.vue +9 -6
- package/src/label-icon.vue +2 -2
- package/src/modal-dialog.vue +287 -0
- package/src/overlay-box.vue +218 -0
- package/src/page-section.vue +7 -7
- package/src/page-title.vue +4 -4
- package/src/screen-loading.vue +90 -0
- package/src/tab-content.vue +16 -15
- package/src/tab-group.vue +34 -36
- package/src/types/data-table.ts +196 -0
- package/src/types/modal-dialog.ts +16 -0
- package/src/types/movable-window.ts +18 -0
- package/src/warning-popper.vue +70 -0
- package/lib/accordion-fieldset.cjs +0 -1
- package/lib/accordion-fieldset.js +0 -4
- package/lib/accordion-fieldset.vue_vue_type_style_index_0_lang-Cf4czDXz.js +0 -66
- package/lib/accordion-fieldset.vue_vue_type_style_index_0_lang-DoM5QjpJ.cjs +0 -1
- package/lib/accordion-section.cjs +0 -1
- package/lib/accordion-section.js +0 -4
- package/lib/accordion-section.vue_vue_type_style_index_0_lang-CFDdUEnn.cjs +0 -1
- package/lib/accordion-section.vue_vue_type_style_index_0_lang-Gvjjx02P.js +0 -78
- package/lib/components-C63HJoCn.cjs +0 -1
- package/lib/components-q4Cf97bO.js +0 -24
- package/lib/hourglass-loading.cjs +0 -1
- package/lib/hourglass-loading.js +0 -4
- package/lib/hourglass-loading.vue_vue_type_style_index_0_lang-C72UVA9W.cjs +0 -1
- package/lib/hourglass-loading.vue_vue_type_style_index_0_lang-DkUGIxQ2.js +0 -22
- package/lib/label-button.cjs +0 -1
- package/lib/label-button.js +0 -4
- package/lib/label-button.vue_vue_type_style_index_0_lang-D7ZgfZOL.cjs +0 -1
- package/lib/label-button.vue_vue_type_style_index_0_lang-DqRYddVt.js +0 -44
- package/lib/label-icon.cjs +0 -1
- package/lib/label-icon.js +0 -4
- package/lib/label-icon.vue_vue_type_style_index_0_lang-D9Cimu20.cjs +0 -1
- package/lib/label-icon.vue_vue_type_style_index_0_lang-me52HE2V.js +0 -38
- package/lib/page-section.cjs +0 -1
- package/lib/page-section.js +0 -4
- package/lib/page-section.vue_vue_type_style_index_0_lang-DEAkTLxd.cjs +0 -1
- package/lib/page-section.vue_vue_type_style_index_0_lang-DpVQe_rV.js +0 -54
- package/lib/page-title.cjs +0 -1
- package/lib/page-title.js +0 -4
- package/lib/page-title.vue_vue_type_style_index_0_lang-BqIsIks5.cjs +0 -1
- package/lib/page-title.vue_vue_type_style_index_0_lang-ChZot85K.js +0 -36
- package/lib/tab-content.cjs +0 -1
- package/lib/tab-content.js +0 -4
- package/lib/tab-content.vue_vue_type_style_index_0_lang-BeCi7Xkp.cjs +0 -1
- package/lib/tab-content.vue_vue_type_style_index_0_lang-CcQLHmIF.js +0 -44
- package/lib/tab-group.cjs +0 -1
- package/lib/tab-group.js +0 -4
- package/lib/tab-group.vue_vue_type_style_index_0_lang-C84mDEOC.js +0 -103
- package/lib/tab-group.vue_vue_type_style_index_0_lang-CMaufRJV.cjs +0 -1
- package/lib/use-shrinkable-CS2bmsJJ.js +0 -17
- package/lib/use-shrinkable-Cu9JQZll.cjs +0 -1
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
ライトモードとダークモードを切り替えるスイッチ
|
|
3
|
+
選んだモードを <html> の class(light / dark)に反映し、localStorage に保存する。
|
|
4
|
+
保存値が無ければ OS の設定に従う。OS の設定が変わったとき、およびモードを切り替えたときは同一サイトのすべてのタブ、ウィンドウが追随する。
|
|
5
|
+
SSRではライトの状態で描画されるため、一瞬ちらつきが発生することがある。
|
|
6
|
+
これを回避するには dark-mode-selector.md に記載されている回避ロジックを実装する。
|
|
7
|
+
-->
|
|
8
|
+
<template>
|
|
9
|
+
<button
|
|
10
|
+
type="button"
|
|
11
|
+
role="switch"
|
|
12
|
+
class="dwui-dark-mode-selector"
|
|
13
|
+
:aria-label="props.label"
|
|
14
|
+
:aria-checked="isDark"
|
|
15
|
+
@click="onClickToggle"
|
|
16
|
+
>
|
|
17
|
+
<span class="dwui-dark-mode-selector-track">
|
|
18
|
+
<span class="dwui-dark-mode-selector-icon-light"><slot name="icon-light"><SvgHighBrightness /></slot></span>
|
|
19
|
+
<span class="dwui-dark-mode-selector-icon-dark"><slot name="icon-dark"><SvgMoonPhases :moon-age="3.85" /></slot></span>
|
|
20
|
+
</span>
|
|
21
|
+
<span class="dwui-dark-mode-selector-handle" />
|
|
22
|
+
</button>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<script setup lang="ts">
|
|
26
|
+
import { onBeforeUnmount, onMounted, ref } from 'vue';
|
|
27
|
+
import { SvgHighBrightness, SvgMoonPhases } from '@digitalwalletcorp/vue-svg-icons';
|
|
28
|
+
|
|
29
|
+
type ColorScheme = 'light' | 'dark';
|
|
30
|
+
|
|
31
|
+
export interface Props {
|
|
32
|
+
/** 選んだモードを保存する localStorage のキー */
|
|
33
|
+
storageKey?: string;
|
|
34
|
+
/** スイッチの読み上げ名 */
|
|
35
|
+
label?: string;
|
|
36
|
+
}
|
|
37
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
38
|
+
storageKey: 'dwui-color-scheme',
|
|
39
|
+
label: 'Dark mode'
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export interface Emits {
|
|
43
|
+
/** マウント時に決まったモードと、その後モードが変わるたびに、新しいモードを発行する */
|
|
44
|
+
(e: 'emit:change', value: ColorScheme): void;
|
|
45
|
+
}
|
|
46
|
+
const emit = defineEmits<Emits>();
|
|
47
|
+
|
|
48
|
+
export interface Slots {
|
|
49
|
+
'icon-light'?(): unknown;
|
|
50
|
+
'icon-dark'?(): unknown;
|
|
51
|
+
}
|
|
52
|
+
defineSlots<Slots>();
|
|
53
|
+
|
|
54
|
+
const isDark = ref<boolean>(false);
|
|
55
|
+
|
|
56
|
+
let applied: ColorScheme | null = null;
|
|
57
|
+
let mediaQuery: MediaQueryList | null = null;
|
|
58
|
+
|
|
59
|
+
const isColorScheme = (value: unknown): value is ColorScheme => value === 'light' || value === 'dark';
|
|
60
|
+
|
|
61
|
+
/** OS の設定から得られるモード */
|
|
62
|
+
const osScheme = (): ColorScheme => mediaQuery?.matches ? 'dark' : 'light';
|
|
63
|
+
|
|
64
|
+
/** 保存されているモード。無い場合や localStorage が使えない場合は null */
|
|
65
|
+
const storedScheme = (): ColorScheme | null => {
|
|
66
|
+
try {
|
|
67
|
+
const value = localStorage.getItem(props.storageKey);
|
|
68
|
+
return isColorScheme(value) ? value : null;
|
|
69
|
+
} catch {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/** モードを <html> の class に反映する。変わったときだけ change を発行する */
|
|
75
|
+
const applyScheme = (scheme: ColorScheme): void => {
|
|
76
|
+
const classList = document.documentElement.classList;
|
|
77
|
+
classList.remove(scheme === 'dark' ? 'light' : 'dark');
|
|
78
|
+
classList.add(scheme);
|
|
79
|
+
isDark.value = scheme === 'dark';
|
|
80
|
+
if (applied !== scheme) {
|
|
81
|
+
applied = scheme;
|
|
82
|
+
emit('emit:change', scheme);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/** モードを保存して反映する */
|
|
87
|
+
const selectScheme = (scheme: ColorScheme): void => {
|
|
88
|
+
try {
|
|
89
|
+
localStorage.setItem(props.storageKey, scheme);
|
|
90
|
+
} catch {
|
|
91
|
+
// 保存できなくても表示の切り替えは行う
|
|
92
|
+
}
|
|
93
|
+
applyScheme(scheme);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const onClickToggle = (): void => {
|
|
97
|
+
selectScheme(isDark.value ? 'light' : 'dark');
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const onChangeOsScheme = (event: MediaQueryListEvent): void => {
|
|
101
|
+
selectScheme(event.matches ? 'dark' : 'light');
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// 別のタブで切り替えたとき。保存値が消されたときは OS の設定に戻る
|
|
105
|
+
const onStorage = (event: StorageEvent): void => {
|
|
106
|
+
if (event.key !== props.storageKey) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
applyScheme(isColorScheme(event.newValue) ? event.newValue : osScheme());
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
onMounted(() => {
|
|
113
|
+
mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
|
114
|
+
applyScheme(storedScheme() ?? osScheme());
|
|
115
|
+
mediaQuery.addEventListener('change', onChangeOsScheme);
|
|
116
|
+
window.addEventListener('storage', onStorage);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
onBeforeUnmount(() => {
|
|
120
|
+
mediaQuery?.removeEventListener('change', onChangeOsScheme);
|
|
121
|
+
window.removeEventListener('storage', onStorage);
|
|
122
|
+
});
|
|
123
|
+
</script>
|
|
124
|
+
|
|
125
|
+
<style>
|
|
126
|
+
:where(.dwui-dark-mode-selector) {
|
|
127
|
+
position: relative;
|
|
128
|
+
display: inline-block;
|
|
129
|
+
vertical-align: top;
|
|
130
|
+
width: 3.85em;
|
|
131
|
+
height: 1.65em;
|
|
132
|
+
padding: 0;
|
|
133
|
+
border: none;
|
|
134
|
+
border-radius: 0.85em;
|
|
135
|
+
background-color: transparent;
|
|
136
|
+
background-image: none;
|
|
137
|
+
color: inherit;
|
|
138
|
+
font: inherit;
|
|
139
|
+
line-height: 0;
|
|
140
|
+
cursor: pointer;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
:where(.dwui-dark-mode-selector-track) {
|
|
144
|
+
position: relative;
|
|
145
|
+
display: block;
|
|
146
|
+
height: inherit;
|
|
147
|
+
border-radius: inherit;
|
|
148
|
+
background: var(--dwui-background-dark-mode-selector, azure);
|
|
149
|
+
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12), inset 0 0 2px rgba(0, 0, 0, 0.15);
|
|
150
|
+
font-size: 0.85em;
|
|
151
|
+
transition: background 0.15s ease-out;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
:where(.dwui-dark-mode-selector[aria-checked='true'] > .dwui-dark-mode-selector-track) {
|
|
155
|
+
background: var(--dwui-background-dark-mode-selector-checked, darkslategray);
|
|
156
|
+
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15), inset 0 0 3px rgba(0, 0, 0, 0.2);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
:where(.dwui-dark-mode-selector-icon-light, .dwui-dark-mode-selector-icon-dark) {
|
|
160
|
+
position: absolute;
|
|
161
|
+
top: 50%;
|
|
162
|
+
transform: translateY(-50%);
|
|
163
|
+
display: inline-flex;
|
|
164
|
+
align-items: center;
|
|
165
|
+
line-height: 1;
|
|
166
|
+
transition: opacity 0.15s ease-out;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
:where(.dwui-dark-mode-selector-icon-light) {
|
|
170
|
+
right: 0.6em;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
:where(.dwui-dark-mode-selector-icon-dark) {
|
|
174
|
+
left: 0.6em;
|
|
175
|
+
opacity: 0;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
:where(.dwui-dark-mode-selector[aria-checked='true'] .dwui-dark-mode-selector-icon-light) {
|
|
179
|
+
opacity: 0;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
:where(.dwui-dark-mode-selector[aria-checked='true'] .dwui-dark-mode-selector-icon-dark) {
|
|
183
|
+
opacity: 1;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
:where(.dwui-dark-mode-selector-handle) {
|
|
187
|
+
position: absolute;
|
|
188
|
+
top: 0.075em;
|
|
189
|
+
left: 0;
|
|
190
|
+
width: 1.5em;
|
|
191
|
+
height: 1.5em;
|
|
192
|
+
border-radius: 0.75em;
|
|
193
|
+
background: var(--dwui-background-dark-mode-selector-handle, linear-gradient(0.25turn, #888484 0%, #b4abab 50%, #888484 100%));
|
|
194
|
+
box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.2);
|
|
195
|
+
transition: left 0.15s ease-out;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
:where(.dwui-dark-mode-selector[aria-checked='true'] > .dwui-dark-mode-selector-handle) {
|
|
199
|
+
left: calc(3.85em - 1.5em - 0.075em);
|
|
200
|
+
box-shadow: -1px 1px 5px rgba(0, 0, 0, 0.2);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
:where(.dwui-dark-mode-selector:disabled) {
|
|
204
|
+
opacity: 0.5;
|
|
205
|
+
cursor: not-allowed;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
:where(.dwui-dark-mode-selector:focus-visible) {
|
|
209
|
+
outline: var(--dwui-outline-width-focus-ring, 2px) solid var(--dwui-outline-color-focus-ring, Highlight);
|
|
210
|
+
outline-offset: var(--dwui-outline-offset-focus-ring, 2px);
|
|
211
|
+
}
|
|
212
|
+
</style>
|