@maz-ui/mcp 4.1.1 → 4.1.3
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/mcp.mjs +2 -2
- package/docs/generated-docs/maz-radio-buttons.doc.md +1 -0
- package/docs/src/blog/v4.md +276 -0
- package/docs/src/components/maz-popover.md +1 -1
- package/docs/src/components/maz-select-country.md +1 -1
- package/docs/src/components/maz-slider.md +3 -2
- package/docs/src/composables/use-display-names.md +3 -3
- package/docs/src/composables/use-form-validator.md +2 -2
- package/docs/src/composables/use-idle-timeout.md +1 -1
- package/docs/src/composables/use-swipe.md +1 -1
- package/docs/src/composables/use-timer.md +1 -1
- package/docs/src/demo/ColorPicker.vue +167 -0
- package/docs/src/demo/DemoDashboardPage.vue +2 -9
- package/docs/src/demo/ThemeEditorPage.vue +396 -0
- package/docs/src/directives/click-outside.md +1 -1
- package/docs/src/directives/lazy-img.md +1 -1
- package/docs/src/directives/tooltip.md +1 -1
- package/docs/src/directives/zoom-img.md +1 -1
- package/docs/src/guide/getting-started.md +3 -3
- package/docs/src/guide/icon-set.md +46 -12
- package/docs/src/guide/icons.md +3 -3
- package/docs/src/guide/migration-v4.md +68 -63
- package/docs/src/guide/themes.md +4 -0
- package/docs/src/index.md +4 -4
- package/docs/src/theme-editor.md +21 -0
- package/package.json +5 -5
package/dist/mcp.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { existsSync, readFileSync, readdirSync } from 'node:fs';
|
|
|
7
7
|
import { resolve, dirname, join } from 'node:path';
|
|
8
8
|
import { fileURLToPath } from 'node:url';
|
|
9
9
|
|
|
10
|
-
const version = "4.1.
|
|
10
|
+
const version = "4.1.2";
|
|
11
11
|
|
|
12
12
|
const _dirname = dirname(fileURLToPath(import.meta.url));
|
|
13
13
|
class DocumentationService {
|
|
@@ -404,7 +404,7 @@ class MazUiMcpServer {
|
|
|
404
404
|
},
|
|
405
405
|
{
|
|
406
406
|
name: "list_composables",
|
|
407
|
-
description: "List all Vue
|
|
407
|
+
description: "List all Vue or Nuxt composables (useToast, useDialog, etc.)",
|
|
408
408
|
inputSchema: {
|
|
409
409
|
type: "object",
|
|
410
410
|
properties: {}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
| **success** | Whether the input is successful. | `boolean` | No | `undefined` | - |
|
|
17
17
|
| **warning** | Whether there is a warning with the input. | `boolean` | No | `undefined` | - |
|
|
18
18
|
| **hint** | The hint text to display below the input. | `string` | No | `undefined` | - |
|
|
19
|
+
| **size** | The size of the radio buttons | `MazSize` | No | `'md'` | - |
|
|
19
20
|
|
|
20
21
|
## Events
|
|
21
22
|
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Maz-UI v4.0.0 - The Complete Rebuild
|
|
3
|
+
description: Discover the complete rebuild of Maz-UI - now with modular architecture, advanced tree-shaking, comprehensive theming system, and performance optimizations that will transform your Vue & Nuxt development experience.
|
|
4
|
+
date: 2024-12-15
|
|
5
|
+
author: Louis Mazel
|
|
6
|
+
layout: doc
|
|
7
|
+
head:
|
|
8
|
+
- - meta
|
|
9
|
+
- name: keywords
|
|
10
|
+
content: vue ui library, vue components, nuxt ui, maz-ui v4, tree-shaking, theming, typescript, performance
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
<img src="./../public/img/post-layer.png" alt="Maz-UI v4.0.0" class="maz-rounded maz-w-full maz-mb-12" />
|
|
14
|
+
|
|
15
|
+
# Maz-UI v4.0.0 - The Complete Rebuild
|
|
16
|
+
|
|
17
|
+
After months of development, I'm announcing **Maz-UI v4.0.0** — a complete architectural rebuild focused on performance, modularity, and developer experience.
|
|
18
|
+
|
|
19
|
+
## Why I Built v4.0.0
|
|
20
|
+
|
|
21
|
+
Modern applications require better performance, smaller bundle sizes, and improved developer tooling. Maz-UI v3 served its purpose, but I wanted to address these requirements with a ground-up rebuild.
|
|
22
|
+
|
|
23
|
+
**The goals were:** Better tree-shaking, modular architecture, and enhanced TypeScript support.
|
|
24
|
+
|
|
25
|
+
## What's New
|
|
26
|
+
|
|
27
|
+
### Modular Architecture
|
|
28
|
+
|
|
29
|
+
Maz-UI v4 uses a monorepo structure where every component, composable, directive, and utility can be imported independently. This gives you better control over your bundle size.
|
|
30
|
+
|
|
31
|
+
### Bundle Size Improvements
|
|
32
|
+
|
|
33
|
+
Optimal tree-shaking implementation results in **60-90% bundle size reductions** compared to v3. You can now import exactly what you need.
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
// Before v4: Large bundle with unused code
|
|
37
|
+
import * as MazUI from 'maz-ui'
|
|
38
|
+
|
|
39
|
+
// v4: Surgical imports for minimal bundles
|
|
40
|
+
import MazBtn from 'maz-ui/components/MazBtn'
|
|
41
|
+
import { useToast } from 'maz-ui/composables'
|
|
42
|
+
import { formatCurrency } from 'maz-ui/utils'
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Theme System
|
|
46
|
+
|
|
47
|
+
#### Four Theme Presets
|
|
48
|
+
|
|
49
|
+
Choose from four pre-built themes:
|
|
50
|
+
|
|
51
|
+
- **Maz-UI**: Vibrant and modern with signature Maz-UI aesthetics
|
|
52
|
+
- **Pristine**: Minimalist elegance
|
|
53
|
+
- **Ocean**: Fresh aquatic theme with deep blues and coral accents
|
|
54
|
+
- **Obsidian**: Sophisticated dark theme focused on readability
|
|
55
|
+
|
|
56
|
+
#### HSL CSS Variables & Smart Dark Mode
|
|
57
|
+
|
|
58
|
+
The theming system uses HSL variables for flexibility, with automatic color scale generation (50-950) and dark mode support.
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { MazUi } from 'maz-ui/plugins/maz-ui'
|
|
62
|
+
import { ocean } from '@maz-ui/themes/presets'
|
|
63
|
+
|
|
64
|
+
app.use(MazUi, {
|
|
65
|
+
theme: {
|
|
66
|
+
preset: ocean,
|
|
67
|
+
strategy: 'hybrid', // Optimal performance
|
|
68
|
+
darkModeStrategy: 'class'
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Internationalization
|
|
74
|
+
|
|
75
|
+
#### Multi-language Support
|
|
76
|
+
|
|
77
|
+
Support for 9 languages: English, French, German, Spanish, Italian, Portuguese, Japanese, and Chinese, with custom language integration.
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
import { MazUi } from 'maz-ui/plugins/maz-ui'
|
|
81
|
+
import { fr, en } from '@maz-ui/translations'
|
|
82
|
+
|
|
83
|
+
app.use(MazUi, {
|
|
84
|
+
translations: {
|
|
85
|
+
locale: 'fr',
|
|
86
|
+
fallbackLocale: 'en',
|
|
87
|
+
messages: { fr, en }
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Specialized Ecosystem Packages
|
|
93
|
+
|
|
94
|
+
- **@maz-ui/icons** - 840+ Icons
|
|
95
|
+
SVG icon library with Vue components, direct SVG files, and auto-import support.
|
|
96
|
+
|
|
97
|
+
- **@maz-ui/nuxt** - Nuxt Integration
|
|
98
|
+
Nuxt module with auto-imports and SSR support.
|
|
99
|
+
|
|
100
|
+
- **@maz-ui/themes** - Theming System
|
|
101
|
+
Pre-built theme collections and design tokens.
|
|
102
|
+
|
|
103
|
+
- **@maz-ui/translations** - Internationalization
|
|
104
|
+
Lightweight i18n system for Maz-UI components.
|
|
105
|
+
|
|
106
|
+
- **@maz-ui/mcp** - MCP Server
|
|
107
|
+
Model Context Protocol server that connects AI agents to Maz-UI documentation.
|
|
108
|
+
|
|
109
|
+
### New & Enhanced Components
|
|
110
|
+
|
|
111
|
+
- **MazPopover** - Overlay Component
|
|
112
|
+
Popover with positioning, trigger modes, and accessibility features.
|
|
113
|
+
|
|
114
|
+
- **MazSelectCountry** - Country Selector
|
|
115
|
+
Country/language selector with i18n support and flag display.
|
|
116
|
+
|
|
117
|
+
- **MazLink** - Link Component
|
|
118
|
+
Replaces `MazBtn variant="link"` with auto-external detection and icons.
|
|
119
|
+
|
|
120
|
+
- **MazExpandAnimation** - CSS Grid Animations
|
|
121
|
+
Replaces `MazTransitionExpand` with v-model control and timing functions.
|
|
122
|
+
|
|
123
|
+
- **MazDropzone** - File Upload
|
|
124
|
+
Rewritten without external dependencies, featuring auto-upload and event handling.
|
|
125
|
+
|
|
126
|
+
## Performance Improvements
|
|
127
|
+
|
|
128
|
+
| Metric | v3.x | v4.0.0 | Improvement |
|
|
129
|
+
|--------|------|--------|-------------|
|
|
130
|
+
| **Bundle Size** | ~500KB | ~50-200KB | **60-90%** reduction |
|
|
131
|
+
| **Tree-shaking** | Limited | Optimal | Perfect granular imports |
|
|
132
|
+
| **TypeScript** | Good | Excellent | Strict types with auto-completion |
|
|
133
|
+
| **Build Speed** | Standard | Enhanced | Faster compilation |
|
|
134
|
+
|
|
135
|
+
## Developer Experience
|
|
136
|
+
|
|
137
|
+
### TypeScript-First Architecture
|
|
138
|
+
|
|
139
|
+
All components, composables, and utilities include TypeScript definitions with IDE auto-completion. Types are prefixed with `Maz` for consistency.
|
|
140
|
+
|
|
141
|
+
### Auto-Import Resolvers
|
|
142
|
+
|
|
143
|
+
Integration with `unplugin-vue-components` and `unplugin-auto-import` for auto-imports.
|
|
144
|
+
|
|
145
|
+
### Composable-Based Architecture
|
|
146
|
+
|
|
147
|
+
Several utilities are now Vue composables:
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
// Before: Utility function
|
|
151
|
+
import { idleTimeout } from 'maz-ui'
|
|
152
|
+
|
|
153
|
+
// v4: Vue composable with reactive state
|
|
154
|
+
import { useIdleTimeout } from 'maz-ui/composables'
|
|
155
|
+
const { isIdle } = useIdleTimeout({ timeout: 5000 })
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Enhanced Development Tools
|
|
159
|
+
|
|
160
|
+
- Nuxt DevTools integration
|
|
161
|
+
- Interactive documentation with live examples
|
|
162
|
+
- Comprehensive migration guides
|
|
163
|
+
- MCP server for AI-assisted development
|
|
164
|
+
|
|
165
|
+
## Key Features
|
|
166
|
+
|
|
167
|
+
### Modular
|
|
168
|
+
|
|
169
|
+
Import individual components without the entire library. Tree-shaking ensures minimal bundle size.
|
|
170
|
+
|
|
171
|
+
### SSR Compatible
|
|
172
|
+
|
|
173
|
+
Compatible with Nuxt and server-side rendering.
|
|
174
|
+
|
|
175
|
+
### TypeScript Support
|
|
176
|
+
|
|
177
|
+
Built with TypeScript with auto-completion and type safety.
|
|
178
|
+
|
|
179
|
+
### Theming System
|
|
180
|
+
|
|
181
|
+
HSL-based theming with CSS custom properties and multiple rendering strategies.
|
|
182
|
+
|
|
183
|
+
### Dark Mode
|
|
184
|
+
|
|
185
|
+
Components support light and dark themes with system preference detection.
|
|
186
|
+
|
|
187
|
+
### Complete Ecosystem
|
|
188
|
+
|
|
189
|
+
Components, plugins, directives, composables, and utilities.
|
|
190
|
+
|
|
191
|
+
## Getting Started
|
|
192
|
+
|
|
193
|
+
### For Vue Projects
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
npm install maz-ui@4.0.0
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
// main.ts
|
|
201
|
+
import { createApp } from 'vue'
|
|
202
|
+
import { MazUi } from 'maz-ui/plugins/maz-ui'
|
|
203
|
+
import { mazUi } from '@maz-ui/themes/presets'
|
|
204
|
+
import { fr } from '@maz-ui/translations'
|
|
205
|
+
import 'maz-ui/styles'
|
|
206
|
+
|
|
207
|
+
const app = createApp(App)
|
|
208
|
+
|
|
209
|
+
app.use(MazUi, {
|
|
210
|
+
theme: { preset: mazUi },
|
|
211
|
+
translations: {
|
|
212
|
+
locale: 'fr',
|
|
213
|
+
fallbackLocale: 'en',
|
|
214
|
+
messages: { fr }
|
|
215
|
+
}
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
app.mount('#app')
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### For Nuxt Projects
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
npm install @maz-ui/nuxt
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
// nuxt.config.ts
|
|
229
|
+
export default defineNuxtConfig({
|
|
230
|
+
modules: ['@maz-ui/nuxt'],
|
|
231
|
+
})
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Migration Resources
|
|
235
|
+
|
|
236
|
+
To help with migration from v3 to v4:
|
|
237
|
+
|
|
238
|
+
- **[Complete Migration Guide](../guide/migration-v4.md)** - Step-by-step migration instructions
|
|
239
|
+
- **[MCP Integration](../guide/mcp.md)** - Connect AI agents for migration assistance
|
|
240
|
+
- **[Interactive Examples](../index.md)** - Live demonstrations of new features
|
|
241
|
+
- **[Community Support](https://github.com/LouisMazel/maz-ui/discussions)** - Get help from the community
|
|
242
|
+
|
|
243
|
+
## Summary
|
|
244
|
+
|
|
245
|
+
Maz-UI v4.0.0 is a complete rebuild focusing on performance, modularity, and developer experience. The new architecture provides better tree-shaking, smaller bundles, and improved TypeScript support.
|
|
246
|
+
|
|
247
|
+
Whether you're building a small project or large application, v4 offers the components and tools you need with better performance characteristics.
|
|
248
|
+
|
|
249
|
+
## Essential Links
|
|
250
|
+
|
|
251
|
+
- **[Get Started](/guide/getting-started)** - Installation and setup
|
|
252
|
+
- **[View Components](/components/maz-btn)** - Explore 50+ components
|
|
253
|
+
- **[Migration Guide](/guide/migration-v4)** - Upgrade from v3.x
|
|
254
|
+
- **[GitHub Repository](https://github.com/LouisMazel/maz-ui)** - Source code & issues
|
|
255
|
+
- **[Changelog](https://github.com/LouisMazel/maz-ui/blob/master/CHANGELOG.md)** - Detailed release notes
|
|
256
|
+
- **[v3 Documentation](https://v3.maz-ui.com)** - Legacy version support
|
|
257
|
+
|
|
258
|
+
## Get Started
|
|
259
|
+
|
|
260
|
+
**Ready to try Maz-UI v4.0.0?**
|
|
261
|
+
|
|
262
|
+
<div class="maz-flex maz-gap-4 maz-mt-8 maz-flex-wrap">
|
|
263
|
+
<MazBtn href="https://maz-ui.com/guide/getting-started" size="lg">
|
|
264
|
+
Get Started Now
|
|
265
|
+
</MazBtn>
|
|
266
|
+
<MazBtn href="https://maz-ui.com/guide/migration-v4" color="background" outlined size="lg">
|
|
267
|
+
Migration Guide
|
|
268
|
+
</MazBtn>
|
|
269
|
+
<MazBtn href="https://github.com/LouisMazel/maz-ui" color="background" outlined size="lg" target="blank">
|
|
270
|
+
View on GitHub
|
|
271
|
+
</MazBtn>
|
|
272
|
+
</div>
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
*Feel free to share your feedback and contribute to the project on GitHub.*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: MazPopover
|
|
3
|
-
description: MazPopover is a versatile Vue
|
|
3
|
+
description: MazPopover is a versatile Vue component for displaying content in overlays that bypass overflow constraints of parent elements
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# {{ $frontmatter.title }}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: MazSelectCountry
|
|
3
|
-
description: MazSelectCountry is a versatile Vue
|
|
3
|
+
description: MazSelectCountry is a versatile Vue component for selecting countries or languages with built-in internationalization support and customizable display options
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# {{ $frontmatter.title }}
|
|
@@ -29,10 +29,10 @@ const sliderValue = ref(50)
|
|
|
29
29
|
|
|
30
30
|
### Step
|
|
31
31
|
|
|
32
|
-
<MazSlider v-model="
|
|
32
|
+
<MazSlider v-model="sliderStepValue" :step="10" class="vp-raw" />
|
|
33
33
|
|
|
34
34
|
```html
|
|
35
|
-
<MazSlider v-model="
|
|
35
|
+
<MazSlider v-model="value" :step="10" class="vp-raw" />
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
### Multiple sliders & labels
|
|
@@ -181,6 +181,7 @@ const multipleSilders = ref([25, 50, 75])
|
|
|
181
181
|
<script lang="ts" setup>
|
|
182
182
|
import { ref } from 'vue'
|
|
183
183
|
const sliderValue = ref(50)
|
|
184
|
+
const sliderStepValue = ref(50)
|
|
184
185
|
const multipleSilders = ref([25, 50, 75])
|
|
185
186
|
const multipleSildersLabels = ['Small', 'Middle', 'Big']
|
|
186
187
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: useDisplayNames
|
|
3
|
-
description: useDisplayNames is a Vue
|
|
3
|
+
description: useDisplayNames is a Vue composable specialized in displaying localized country names (regions) and language names. It supports various code formats including ISO 639-1 (language codes), ISO 3166-1 (country codes), and BCP 47 (language tags), using the Intl.DisplayNames API for internationalization.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# {{ $frontmatter.title }}
|
|
@@ -20,7 +20,7 @@ Depending on your environment (client or node server) and the browser you are us
|
|
|
20
20
|
## Key Features
|
|
21
21
|
|
|
22
22
|
- Displays localized country names (regions) and language names
|
|
23
|
-
- Supports multiple code formats: ISO 639-1 (language codes), ISO 3166-1 (country codes), and BCP 47 (language tags)
|
|
23
|
+
- Supports multiple code formats: ISO 639-1 (language codes), ISO 3166-1 (country codes), and BCP 47 (language tags)
|
|
24
24
|
- Works with any locale supported by the browser's Intl.DisplayNames API
|
|
25
25
|
- Provides functions to get individual names or bulk retrieve all available names
|
|
26
26
|
- Handles errors gracefully with fallback values
|
|
@@ -154,7 +154,7 @@ function getAllDisplayNames(options: {
|
|
|
154
154
|
|
|
155
155
|
## Notes
|
|
156
156
|
|
|
157
|
-
- The `useDisplayNames` composable is designed to be used with Vue
|
|
157
|
+
- The `useDisplayNames` composable is designed to be used with Vue.
|
|
158
158
|
- The composable functions return `ComputedRef` values, which are reactive and will update automatically when their dependencies change.
|
|
159
159
|
- Handle errors gracefully by providing fallback values when the display name cannot be fetched.
|
|
160
160
|
- The `Intl.DisplayNames` API is used internally to fetch and format the display names based on the provided locale and code.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: useFormValidator
|
|
3
|
-
description: useFormValidator and useFormField are two Vue
|
|
3
|
+
description: useFormValidator and useFormField are two Vue composables designed to simplify form validation using Valibot as the validation library. These composables offer a flexible and typed approach to handle form validation in your Vue applications.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# {{ $frontmatter.title }}
|
|
7
7
|
|
|
8
|
-
`useFormValidator` and `useFormField` are two Vue
|
|
8
|
+
`useFormValidator` and `useFormField` are two Vue composables designed to simplify form validation using [Valibot](https://valibot.dev/guides/introduction/) as the validation library. These composables offer a flexible and typed approach to handle form validation in your Vue applications.
|
|
9
9
|
|
|
10
10
|
## Introduction
|
|
11
11
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: useIdleTimeout
|
|
3
|
-
description: A Vue
|
|
3
|
+
description: A Vue composable that provides an easy way to track user inactivity on your website and execute a callback function when the user becomes idle.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# {{ $frontmatter.title }}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: useSwipe
|
|
3
|
-
description: useSwipe is a Vue
|
|
3
|
+
description: useSwipe is a Vue composable that simplifies the management of "swipe" interactions on HTML elements.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# {{ $frontmatter.title }}
|
|
@@ -19,7 +19,7 @@ The composable provides the following functionality:
|
|
|
19
19
|
|
|
20
20
|
The composable also includes cleanup logic using onBeforeUnmount to ensure that the timer is stopped when the component is unmounted.
|
|
21
21
|
|
|
22
|
-
This composable can be used in Vue
|
|
22
|
+
This composable can be used in Vue components to handle timeouts in a flexible and reactive manner.
|
|
23
23
|
|
|
24
24
|
## Usage
|
|
25
25
|
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/* eslint-disable style/max-statements-per-line */
|
|
3
|
+
|
|
4
|
+
import type { HSL } from '@maz-ui/themes'
|
|
5
|
+
import { computed, ref, watch } from 'vue'
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
modelValue: HSL
|
|
9
|
+
label?: string
|
|
10
|
+
disabled?: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
14
|
+
disabled: false,
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const emit = defineEmits<{
|
|
18
|
+
'update:modelValue': [value: HSL]
|
|
19
|
+
}>()
|
|
20
|
+
|
|
21
|
+
const colorInput = ref<HTMLInputElement>()
|
|
22
|
+
|
|
23
|
+
function hslToHex(hsl: HSL): string {
|
|
24
|
+
const match = hsl.match(/(\d+(?:\.\d+)?)\s+(\d+(?:\.\d+)?)%\s+(\d+(?:\.\d+)?)%/)
|
|
25
|
+
if (!match)
|
|
26
|
+
return '#000000'
|
|
27
|
+
|
|
28
|
+
const h = Number.parseFloat(match[1]) / 360
|
|
29
|
+
const s = Number.parseFloat(match[2]) / 100
|
|
30
|
+
const l = Number.parseFloat(match[3]) / 100
|
|
31
|
+
|
|
32
|
+
const hue2rgb = (p: number, q: number, t: number) => {
|
|
33
|
+
if (t < 0)
|
|
34
|
+
t += 1
|
|
35
|
+
if (t > 1)
|
|
36
|
+
t -= 1
|
|
37
|
+
if (t < 1 / 6)
|
|
38
|
+
return p + (q - p) * 6 * t
|
|
39
|
+
if (t < 1 / 2)
|
|
40
|
+
return q
|
|
41
|
+
if (t < 2 / 3)
|
|
42
|
+
return p + (q - p) * (2 / 3 - t) * 6
|
|
43
|
+
return p
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let r: number
|
|
47
|
+
let g: number
|
|
48
|
+
let b: number
|
|
49
|
+
|
|
50
|
+
if (s === 0) {
|
|
51
|
+
r = g = b = l
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const q = l < 0.5 ? l * (1 + s) : l + s - l * s
|
|
55
|
+
const p = 2 * l - q
|
|
56
|
+
r = hue2rgb(p, q, h + 1 / 3)
|
|
57
|
+
g = hue2rgb(p, q, h)
|
|
58
|
+
b = hue2rgb(p, q, h - 1 / 3)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const toHex = (c: number) => {
|
|
62
|
+
const hex = Math.round(c * 255).toString(16)
|
|
63
|
+
return hex.length === 1 ? `0${hex}` : hex
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return `#${toHex(r)}${toHex(g)}${toHex(b)}`
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function hexToHsl(hex: string): HSL {
|
|
70
|
+
const r = Number.parseInt(hex.slice(1, 3), 16) / 255
|
|
71
|
+
const g = Number.parseInt(hex.slice(3, 5), 16) / 255
|
|
72
|
+
const b = Number.parseInt(hex.slice(5, 7), 16) / 255
|
|
73
|
+
|
|
74
|
+
const max = Math.max(r, g, b)
|
|
75
|
+
const min = Math.min(r, g, b)
|
|
76
|
+
let h: number
|
|
77
|
+
let s: number
|
|
78
|
+
const l = (max + min) / 2
|
|
79
|
+
|
|
80
|
+
if (max === min) {
|
|
81
|
+
h = s = 0
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const d = max - min
|
|
85
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min)
|
|
86
|
+
|
|
87
|
+
switch (max) {
|
|
88
|
+
case r: h = (g - b) / d + (g < b ? 6 : 0); break
|
|
89
|
+
case g: h = (b - r) / d + 2; break
|
|
90
|
+
case b: h = (r - g) / d + 4; break
|
|
91
|
+
default: h = 0
|
|
92
|
+
}
|
|
93
|
+
h /= 6
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const hue = Math.round(h * 360)
|
|
97
|
+
const saturation = Math.round(s * 100)
|
|
98
|
+
const lightness = Math.round(l * 100)
|
|
99
|
+
|
|
100
|
+
return `${hue} ${saturation}% ${lightness}%` as HSL
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const hexValue = computed(() => hslToHex(props.modelValue))
|
|
104
|
+
|
|
105
|
+
function handleColorChange(event: Event) {
|
|
106
|
+
const target = event.target as HTMLInputElement
|
|
107
|
+
const hslValue = hexToHsl(target.value)
|
|
108
|
+
emit('update:modelValue', hslValue)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
watch(() => props.modelValue, () => {
|
|
112
|
+
if (colorInput.value) {
|
|
113
|
+
colorInput.value.value = hexValue.value
|
|
114
|
+
}
|
|
115
|
+
}, { immediate: true })
|
|
116
|
+
</script>
|
|
117
|
+
|
|
118
|
+
<template>
|
|
119
|
+
<div class="color-picker">
|
|
120
|
+
<label v-if="label" for="input-color">
|
|
121
|
+
{{ label }}
|
|
122
|
+
</label>
|
|
123
|
+
|
|
124
|
+
<input
|
|
125
|
+
id="input-color"
|
|
126
|
+
ref="colorInput"
|
|
127
|
+
type="color"
|
|
128
|
+
:value="hexValue"
|
|
129
|
+
:disabled="disabled"
|
|
130
|
+
@change="handleColorChange"
|
|
131
|
+
>
|
|
132
|
+
</div>
|
|
133
|
+
</template>
|
|
134
|
+
|
|
135
|
+
<style lang="postcss" scoped>
|
|
136
|
+
.color-picker {
|
|
137
|
+
@apply maz-inline-flex maz-flex-col maz-gap-1;
|
|
138
|
+
|
|
139
|
+
label {
|
|
140
|
+
@apply maz-text-sm maz-font-medium maz-text-foreground maz-truncate;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
input[type='color'] {
|
|
144
|
+
-webkit-appearance: none;
|
|
145
|
+
appearance: none;
|
|
146
|
+
background: none;
|
|
147
|
+
cursor: pointer;
|
|
148
|
+
|
|
149
|
+
@apply maz-h-10 maz-w-full maz-cursor-pointer maz-overflow-hidden maz-rounded maz-border maz-border-solid maz-border-divider disabled:maz-cursor-not-allowed disabled:maz-opacity-50;
|
|
150
|
+
|
|
151
|
+
&::-webkit-color-swatch-wrapper {
|
|
152
|
+
padding: 0;
|
|
153
|
+
@apply maz-rounded;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
&::-webkit-color-swatch {
|
|
157
|
+
border: none;
|
|
158
|
+
@apply maz-rounded;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
&::-moz-color-swatch {
|
|
162
|
+
border: none;
|
|
163
|
+
@apply maz-rounded;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
</style>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import dataLabels from 'chartjs-plugin-datalabels'
|
|
3
3
|
import { ref } from 'vue'
|
|
4
4
|
|
|
5
|
-
const { delay =
|
|
5
|
+
const { delay = 0 } = defineProps<{
|
|
6
6
|
delay?: number
|
|
7
7
|
}>()
|
|
8
8
|
|
|
@@ -117,7 +117,6 @@ const tableHeaders = [
|
|
|
117
117
|
color="success"
|
|
118
118
|
size="3rem"
|
|
119
119
|
:delay
|
|
120
|
-
:once="false"
|
|
121
120
|
/>
|
|
122
121
|
<div class="maz-truncate">
|
|
123
122
|
<div class="maz-text-xl maz-font-bold">
|
|
@@ -126,7 +125,6 @@ const tableHeaders = [
|
|
|
126
125
|
:count="28945"
|
|
127
126
|
prefix="$"
|
|
128
127
|
separator=","
|
|
129
|
-
:once="false"
|
|
130
128
|
/>
|
|
131
129
|
</div>
|
|
132
130
|
<div class="maz-truncate maz-text-sm maz-text-muted">
|
|
@@ -143,7 +141,6 @@ const tableHeaders = [
|
|
|
143
141
|
color="info"
|
|
144
142
|
size="3rem"
|
|
145
143
|
:delay
|
|
146
|
-
:once="false"
|
|
147
144
|
/>
|
|
148
145
|
<div class="maz-truncate">
|
|
149
146
|
<div class="maz-text-xl maz-font-bold">
|
|
@@ -151,7 +148,6 @@ const tableHeaders = [
|
|
|
151
148
|
:delay
|
|
152
149
|
:count="384"
|
|
153
150
|
separator=","
|
|
154
|
-
:once="false"
|
|
155
151
|
/>
|
|
156
152
|
</div>
|
|
157
153
|
<div class="maz-truncate maz-text-sm maz-text-muted">
|
|
@@ -168,7 +164,6 @@ const tableHeaders = [
|
|
|
168
164
|
color="warning"
|
|
169
165
|
size="3rem"
|
|
170
166
|
:delay
|
|
171
|
-
:once="false"
|
|
172
167
|
/>
|
|
173
168
|
<div class="maz-truncate">
|
|
174
169
|
<div class="maz-text-xl maz-font-bold">
|
|
@@ -176,7 +171,6 @@ const tableHeaders = [
|
|
|
176
171
|
:delay
|
|
177
172
|
:count="1482"
|
|
178
173
|
separator=","
|
|
179
|
-
:once="false"
|
|
180
174
|
/>
|
|
181
175
|
</div>
|
|
182
176
|
<div class="maz-truncate maz-text-sm maz-text-muted">
|
|
@@ -193,7 +187,6 @@ const tableHeaders = [
|
|
|
193
187
|
color="destructive"
|
|
194
188
|
size="3rem"
|
|
195
189
|
:delay
|
|
196
|
-
:once="false"
|
|
197
190
|
/>
|
|
198
191
|
<div class="maz-truncate">
|
|
199
192
|
<div class="maz-text-xl maz-font-bold">
|
|
@@ -201,7 +194,6 @@ const tableHeaders = [
|
|
|
201
194
|
:delay
|
|
202
195
|
:count="94"
|
|
203
196
|
suffix="%"
|
|
204
|
-
:once="false"
|
|
205
197
|
/>
|
|
206
198
|
</div>
|
|
207
199
|
<div class="maz-truncate maz-text-sm maz-text-muted">
|
|
@@ -223,6 +215,7 @@ const tableHeaders = [
|
|
|
223
215
|
input-size="sm"
|
|
224
216
|
pagination
|
|
225
217
|
selectable
|
|
218
|
+
scrollable
|
|
226
219
|
>
|
|
227
220
|
<template #cell-amount="{ value }">
|
|
228
221
|
<span class="maz-font-semibold">
|