@m3ui-vue/m3ui-vue 0.6.1 → 0.6.2
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 +3 -0
- package/dist/MIcon-CaEooCmZ.js.map +1 -1
- package/dist/{MMenuItem-DbbrJhFE.js → MMenuItem-C7jKU-Qh.js} +13 -13
- package/dist/{MMenuItem-DbbrJhFE.js.map → MMenuItem-C7jKU-Qh.js.map} +1 -1
- package/dist/barcode.js.map +1 -1
- package/dist/chart.js +1 -1
- package/dist/chart.js.map +1 -1
- package/dist/code-editor.js +1 -1
- package/dist/code-editor.js.map +1 -1
- package/dist/{common-VrOaLkjh.js → common-0dgrgaPL.js} +287 -213
- package/dist/common-0dgrgaPL.js.map +1 -0
- package/dist/components/MBar.vue.d.ts +58 -0
- package/dist/components/MPageProgress.vue.d.ts +15 -0
- package/dist/components/MSlider.vue.d.ts +6 -0
- package/dist/components/MWindow.vue.d.ts +1 -1
- package/dist/composables/usePageProgress.d.ts +19 -0
- package/dist/{dist-Dsrzt6J5.js → dist-CrjSW5DN.js} +248 -241
- package/dist/{dist-Dsrzt6J5.js.map → dist-CrjSW5DN.js.map} +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +2918 -2639
- package/dist/m3ui.js.map +1 -1
- package/dist/markdown.js +1 -1
- package/dist/markdown.js.map +1 -1
- package/dist/qrcode.js.map +1 -1
- package/dist/rich-text-editor.js +1 -1
- package/dist/rich-text-editor.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/terminal.js.map +1 -1
- package/package.json +26 -26
- package/src/__tests__/usePageProgress.test.ts +52 -0
- package/src/components/MBar.vue +158 -0
- package/src/components/MPageProgress.vue +62 -0
- package/src/components/MSlider.vue +174 -52
- package/src/composables/usePageProgress.ts +49 -0
- package/src/index.ts +3 -0
- package/dist/common-VrOaLkjh.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m3ui-vue/m3ui-vue",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Material 3 component library for Vue 3 + Tailwind CSS v4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -176,48 +176,48 @@
|
|
|
176
176
|
}
|
|
177
177
|
},
|
|
178
178
|
"devDependencies": {
|
|
179
|
-
"@codemirror/commands": "^6.
|
|
179
|
+
"@codemirror/commands": "^6.11.0",
|
|
180
180
|
"@codemirror/lang-css": "^6.3.1",
|
|
181
|
-
"@codemirror/lang-html": "^6.4.
|
|
181
|
+
"@codemirror/lang-html": "^6.4.12",
|
|
182
182
|
"@codemirror/lang-javascript": "^6.2.5",
|
|
183
183
|
"@codemirror/lang-json": "^6.0.2",
|
|
184
184
|
"@codemirror/lang-python": "^6.2.1",
|
|
185
185
|
"@codemirror/lang-vue": "^0.1.3",
|
|
186
|
-
"@codemirror/language": "^6.12.
|
|
187
|
-
"@codemirror/state": "^6.
|
|
186
|
+
"@codemirror/language": "^6.12.4",
|
|
187
|
+
"@codemirror/state": "^6.7.4",
|
|
188
188
|
"@codemirror/theme-one-dark": "^6.1.3",
|
|
189
|
-
"@codemirror/view": "^6.43.
|
|
189
|
+
"@codemirror/view": "^6.43.11",
|
|
190
190
|
"@lezer/highlight": "^1.2.3",
|
|
191
|
-
"@tiptap/extension-color": "^3.
|
|
192
|
-
"@tiptap/extension-highlight": "^3.
|
|
193
|
-
"@tiptap/extension-image": "^3.
|
|
194
|
-
"@tiptap/extension-link": "^3.
|
|
195
|
-
"@tiptap/extension-placeholder": "^3.
|
|
196
|
-
"@tiptap/extension-text-align": "^3.
|
|
197
|
-
"@tiptap/extension-text-style": "^3.
|
|
198
|
-
"@tiptap/extension-underline": "^3.
|
|
199
|
-
"@tiptap/starter-kit": "^3.
|
|
200
|
-
"@tiptap/vue-3": "^3.
|
|
191
|
+
"@tiptap/extension-color": "^3.31.3",
|
|
192
|
+
"@tiptap/extension-highlight": "^3.31.3",
|
|
193
|
+
"@tiptap/extension-image": "^3.31.3",
|
|
194
|
+
"@tiptap/extension-link": "^3.31.3",
|
|
195
|
+
"@tiptap/extension-placeholder": "^3.31.3",
|
|
196
|
+
"@tiptap/extension-text-align": "^3.31.3",
|
|
197
|
+
"@tiptap/extension-text-style": "^3.31.3",
|
|
198
|
+
"@tiptap/extension-underline": "^3.31.3",
|
|
199
|
+
"@tiptap/starter-kit": "^3.31.3",
|
|
200
|
+
"@tiptap/vue-3": "^3.31.3",
|
|
201
201
|
"@types/jsbarcode": "^3.11.4",
|
|
202
|
-
"@types/markdown-it": "^14.
|
|
203
|
-
"@vitejs/plugin-vue": "^6.0.
|
|
204
|
-
"@vue/test-utils": "^2.
|
|
202
|
+
"@types/markdown-it": "^14.2.0",
|
|
203
|
+
"@vitejs/plugin-vue": "^6.0.8",
|
|
204
|
+
"@vue/test-utils": "^2.5.0",
|
|
205
205
|
"@vue/tsconfig": "^0.9.1",
|
|
206
|
-
"@webgpu/types": "^0.1.
|
|
206
|
+
"@webgpu/types": "^0.1.72",
|
|
207
207
|
"@xterm/addon-fit": "^0.11.0",
|
|
208
208
|
"@xterm/xterm": "^6.0.0",
|
|
209
209
|
"chart.js": "^4.5.1",
|
|
210
210
|
"codemirror": "^6.0.2",
|
|
211
|
-
"happy-dom": "^20.
|
|
212
|
-
"highlight.js": "^11.
|
|
211
|
+
"happy-dom": "^20.14.5",
|
|
212
|
+
"highlight.js": "^11.12.0",
|
|
213
213
|
"jsbarcode": "^3.12.3",
|
|
214
|
-
"markdown-it": "^
|
|
214
|
+
"markdown-it": "^15.0.2",
|
|
215
215
|
"qrcode-generator": "^2.0.4",
|
|
216
216
|
"typescript": "~6.0.3",
|
|
217
|
-
"vite": "^8.0
|
|
218
|
-
"vitest": "^
|
|
217
|
+
"vite": "^8.3.0",
|
|
218
|
+
"vitest": "^5.0.0",
|
|
219
219
|
"vue": "^3.5.42",
|
|
220
|
-
"vue-chartjs": "^5.3.
|
|
220
|
+
"vue-chartjs": "^5.3.4",
|
|
221
221
|
"vue-tsc": "^3.3.11"
|
|
222
222
|
},
|
|
223
223
|
"publishConfig": {
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, vi } from 'vitest'
|
|
2
|
+
import { usePageProgress } from '../composables/usePageProgress'
|
|
3
|
+
|
|
4
|
+
describe('usePageProgress', () => {
|
|
5
|
+
beforeEach(() => {
|
|
6
|
+
const { done } = usePageProgress()
|
|
7
|
+
done()
|
|
8
|
+
vi.useRealTimers()
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it('start() activates the bar with an initial value', () => {
|
|
12
|
+
const { progress, isActive, start } = usePageProgress()
|
|
13
|
+
start()
|
|
14
|
+
expect(isActive.value).toBe(true)
|
|
15
|
+
expect(progress.value).toBeGreaterThan(0)
|
|
16
|
+
expect(progress.value).toBeLessThan(100)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('start() trickles progress toward 90% over time without reaching it', () => {
|
|
20
|
+
vi.useFakeTimers()
|
|
21
|
+
const { progress, start } = usePageProgress()
|
|
22
|
+
start()
|
|
23
|
+
vi.advanceTimersByTime(2000)
|
|
24
|
+
expect(progress.value).toBeGreaterThan(50)
|
|
25
|
+
expect(progress.value).toBeLessThan(90)
|
|
26
|
+
vi.useRealTimers()
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('set() jumps straight to the given percentage, clamped to [0, 100]', () => {
|
|
30
|
+
const { progress, isActive, set } = usePageProgress()
|
|
31
|
+
set(150)
|
|
32
|
+
expect(progress.value).toBe(100)
|
|
33
|
+
expect(isActive.value).toBe(true)
|
|
34
|
+
|
|
35
|
+
set(-10)
|
|
36
|
+
expect(progress.value).toBe(0)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('done() completes the bar then fades it out and resets', () => {
|
|
40
|
+
vi.useFakeTimers()
|
|
41
|
+
const { progress, isActive, start, done } = usePageProgress()
|
|
42
|
+
start()
|
|
43
|
+
done()
|
|
44
|
+
expect(progress.value).toBe(100)
|
|
45
|
+
expect(isActive.value).toBe(true)
|
|
46
|
+
|
|
47
|
+
vi.advanceTimersByTime(200)
|
|
48
|
+
expect(isActive.value).toBe(false)
|
|
49
|
+
expect(progress.value).toBe(0)
|
|
50
|
+
vi.useRealTimers()
|
|
51
|
+
})
|
|
52
|
+
})
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import MIcon from './MIcon.vue'
|
|
4
|
+
|
|
5
|
+
const props = withDefaults(
|
|
6
|
+
defineProps<{
|
|
7
|
+
title?: string
|
|
8
|
+
/** Material Symbol name, or an image src (URL, data URI, or a path with a file extension) — detected automatically. */
|
|
9
|
+
icon?: string
|
|
10
|
+
titleAlign?: 'start' | 'center'
|
|
11
|
+
/** Show the minimize/maximize/close buttons as a group. Defaults to `true`, except on `platform="macos"` where the OS draws native traffic lights instead. */
|
|
12
|
+
controls?: boolean
|
|
13
|
+
/** Individually hide one control while keeping the others — e.g. a fixed-size window with no maximize button. */
|
|
14
|
+
minimizable?: boolean
|
|
15
|
+
maximizable?: boolean
|
|
16
|
+
closable?: boolean
|
|
17
|
+
/** Reflects the real window state — the bar has no way to know it itself, the host app must read it from its Electron main process and pass it down. */
|
|
18
|
+
maximized?: boolean
|
|
19
|
+
platform?: 'windows' | 'macos'
|
|
20
|
+
/** Bar height in px. */
|
|
21
|
+
height?: number
|
|
22
|
+
/** Double-clicking empty drag space toggles maximize, matching native title bar behavior. */
|
|
23
|
+
doubleClickMaximize?: boolean
|
|
24
|
+
}>(),
|
|
25
|
+
{
|
|
26
|
+
titleAlign: 'start',
|
|
27
|
+
// Explicit `undefined` defaults, not omitted — an omitted optional boolean
|
|
28
|
+
// prop gets auto-cast to `false` by Vue (not left `undefined`), which would
|
|
29
|
+
// permanently break the `props.x ?? smartDefault` fallbacks below.
|
|
30
|
+
controls: undefined,
|
|
31
|
+
minimizable: undefined,
|
|
32
|
+
maximizable: undefined,
|
|
33
|
+
closable: undefined,
|
|
34
|
+
maximized: false,
|
|
35
|
+
platform: 'windows',
|
|
36
|
+
height: 36,
|
|
37
|
+
doubleClickMaximize: true,
|
|
38
|
+
},
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
const emit = defineEmits<{ minimize: []; maximize: []; close: [] }>()
|
|
42
|
+
|
|
43
|
+
// A plain Material Symbol name never has a scheme/path/extension, so this is
|
|
44
|
+
// enough to tell an image src apart from an icon name without needing a
|
|
45
|
+
// separate prop.
|
|
46
|
+
const iconIsImage = computed(() => {
|
|
47
|
+
if (!props.icon) return false
|
|
48
|
+
return /^(data:|https?:\/\/|\.{0,2}\/)/.test(props.icon) || /\.(png|jpe?g|svg|gif|webp|ico|avif)$/i.test(props.icon)
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
const showControls = computed(() => props.controls ?? props.platform !== 'macos')
|
|
52
|
+
const showMinimize = computed(() => showControls.value && (props.minimizable ?? true))
|
|
53
|
+
const showMaximize = computed(() => showControls.value && (props.maximizable ?? true))
|
|
54
|
+
const showClose = computed(() => showControls.value && (props.closable ?? true))
|
|
55
|
+
const hasAnyControl = computed(() => showMinimize.value || showMaximize.value || showClose.value)
|
|
56
|
+
|
|
57
|
+
function onDblclick() {
|
|
58
|
+
if (props.doubleClickMaximize) emit('maximize')
|
|
59
|
+
}
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<template>
|
|
63
|
+
<div
|
|
64
|
+
class="relative flex w-full shrink-0 select-none items-center bg-surface-container text-on-surface"
|
|
65
|
+
style="-webkit-app-region: drag"
|
|
66
|
+
:style="{ height: `${height}px` }"
|
|
67
|
+
@dblclick="onDblclick"
|
|
68
|
+
>
|
|
69
|
+
<!-- Reserves space for native macOS traffic lights, drawn by the OS outside the web content -->
|
|
70
|
+
<div v-if="platform === 'macos'" class="h-full shrink-0" style="width: 78px" />
|
|
71
|
+
|
|
72
|
+
<div
|
|
73
|
+
v-if="icon || $slots.icon"
|
|
74
|
+
class="flex h-full shrink-0 items-center pl-3"
|
|
75
|
+
style="-webkit-app-region: no-drag"
|
|
76
|
+
>
|
|
77
|
+
<slot name="icon">
|
|
78
|
+
<img v-if="iconIsImage" :src="icon" alt="" class="h-4 w-4 object-contain" />
|
|
79
|
+
<MIcon v-else :name="icon!" :size="16" />
|
|
80
|
+
</slot>
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
<!-- Start-aligned title sits inline; centered title floats over the whole bar so it's
|
|
84
|
+
centered regardless of how wide the icon/controls on either side are. -->
|
|
85
|
+
<div
|
|
86
|
+
v-if="titleAlign === 'start'"
|
|
87
|
+
class="flex h-full flex-1 items-center truncate px-2 text-label-medium text-on-surface-variant"
|
|
88
|
+
>
|
|
89
|
+
<slot name="title">{{ title }}</slot>
|
|
90
|
+
</div>
|
|
91
|
+
<div v-else class="h-full flex-1" />
|
|
92
|
+
<div
|
|
93
|
+
v-if="titleAlign === 'center'"
|
|
94
|
+
class="pointer-events-none absolute inset-x-0 flex h-full items-center justify-center truncate px-20 text-label-medium text-on-surface-variant"
|
|
95
|
+
>
|
|
96
|
+
<slot name="title">{{ title }}</slot>
|
|
97
|
+
</div>
|
|
98
|
+
|
|
99
|
+
<div v-if="$slots.default" class="flex h-full items-center" style="-webkit-app-region: no-drag">
|
|
100
|
+
<slot />
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
<div v-if="$slots.trailing" class="flex h-full shrink-0 items-center" style="-webkit-app-region: no-drag">
|
|
104
|
+
<slot name="trailing" />
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
<div v-if="hasAnyControl" class="flex h-full shrink-0" style="-webkit-app-region: no-drag">
|
|
108
|
+
<button
|
|
109
|
+
v-if="showMinimize"
|
|
110
|
+
type="button"
|
|
111
|
+
class="m3-bar-btn"
|
|
112
|
+
aria-label="Minimize"
|
|
113
|
+
@click="emit('minimize')"
|
|
114
|
+
>
|
|
115
|
+
<MIcon name="horizontal_rule" :size="16" />
|
|
116
|
+
</button>
|
|
117
|
+
<button
|
|
118
|
+
v-if="showMaximize"
|
|
119
|
+
type="button"
|
|
120
|
+
class="m3-bar-btn"
|
|
121
|
+
:aria-label="maximized ? 'Restore' : 'Maximize'"
|
|
122
|
+
@click="emit('maximize')"
|
|
123
|
+
>
|
|
124
|
+
<MIcon :name="maximized ? 'filter_none' : 'crop_square'" :size="14" />
|
|
125
|
+
</button>
|
|
126
|
+
<button
|
|
127
|
+
v-if="showClose"
|
|
128
|
+
type="button"
|
|
129
|
+
class="m3-bar-btn m3-bar-btn-close"
|
|
130
|
+
aria-label="Close"
|
|
131
|
+
@click="emit('close')"
|
|
132
|
+
>
|
|
133
|
+
<MIcon name="close" :size="16" />
|
|
134
|
+
</button>
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
</template>
|
|
138
|
+
|
|
139
|
+
<style>
|
|
140
|
+
.m3-bar-btn {
|
|
141
|
+
display: inline-flex;
|
|
142
|
+
height: 100%;
|
|
143
|
+
width: 46px;
|
|
144
|
+
align-items: center;
|
|
145
|
+
justify-content: center;
|
|
146
|
+
color: var(--color-on-surface-variant);
|
|
147
|
+
transition: background-color 100ms ease, color 100ms ease;
|
|
148
|
+
cursor: pointer;
|
|
149
|
+
}
|
|
150
|
+
.m3-bar-btn:hover {
|
|
151
|
+
background-color: var(--color-surface-container-highest);
|
|
152
|
+
color: var(--color-on-surface);
|
|
153
|
+
}
|
|
154
|
+
.m3-bar-btn-close:hover {
|
|
155
|
+
background-color: var(--color-error);
|
|
156
|
+
color: var(--color-on-error);
|
|
157
|
+
}
|
|
158
|
+
</style>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { getCurrentInstance, onMounted, onUnmounted } from "vue";
|
|
3
|
+
import { usePageProgress } from "../composables/usePageProgress";
|
|
4
|
+
|
|
5
|
+
const props = withDefaults(
|
|
6
|
+
defineProps<{
|
|
7
|
+
color?: "primary" | "secondary" | "tertiary" | "error";
|
|
8
|
+
thickness?: number;
|
|
9
|
+
/** Auto-wire to vue-router's navigation guards when a router is detected. Set to `false` to drive it entirely by hand via `usePageProgress()`. */
|
|
10
|
+
auto?: boolean;
|
|
11
|
+
position?: "top" | "bottom";
|
|
12
|
+
}>(),
|
|
13
|
+
{ color: "primary", thickness: 3, auto: true, position: "top" },
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const { progress, isActive, start, done } = usePageProgress();
|
|
17
|
+
|
|
18
|
+
const colorMap: Record<"primary" | "secondary" | "tertiary" | "error", string> = {
|
|
19
|
+
primary: "bg-primary",
|
|
20
|
+
secondary: "bg-secondary",
|
|
21
|
+
tertiary: "bg-tertiary",
|
|
22
|
+
error: "bg-error",
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const unregister: Array<() => void> = [];
|
|
26
|
+
|
|
27
|
+
onMounted(() => {
|
|
28
|
+
if (!props.auto) return;
|
|
29
|
+
|
|
30
|
+
// Duck-typed vue-router detection — avoids a hard dependency on the package.
|
|
31
|
+
const router = getCurrentInstance()?.appContext.config.globalProperties.$router;
|
|
32
|
+
if (!router) return;
|
|
33
|
+
|
|
34
|
+
unregister.push(router.beforeEach(() => { start(); }));
|
|
35
|
+
unregister.push(router.afterEach(() => { done(); }));
|
|
36
|
+
unregister.push(router.onError(() => { done(); }));
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
onUnmounted(() => {
|
|
40
|
+
unregister.forEach((fn) => fn());
|
|
41
|
+
unregister.length = 0;
|
|
42
|
+
});
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<template>
|
|
46
|
+
<div
|
|
47
|
+
class="pointer-events-none fixed inset-x-0 z-[9999] overflow-hidden transition-opacity duration-300"
|
|
48
|
+
:class="[position === 'top' ? 'top-0' : 'bottom-0', isActive ? 'opacity-100' : 'opacity-0']"
|
|
49
|
+
:style="{ height: `${thickness}px` }"
|
|
50
|
+
role="progressbar"
|
|
51
|
+
aria-hidden="true"
|
|
52
|
+
:aria-valuenow="isActive ? Math.round(progress) : undefined"
|
|
53
|
+
aria-valuemin="0"
|
|
54
|
+
aria-valuemax="100"
|
|
55
|
+
>
|
|
56
|
+
<div
|
|
57
|
+
class="h-full rounded-r-full transition-[width] duration-200 ease-out"
|
|
58
|
+
:class="colorMap[color]"
|
|
59
|
+
:style="{ width: `${progress}%` }"
|
|
60
|
+
/>
|
|
61
|
+
</div>
|
|
62
|
+
</template>
|