@maz-ui/mcp 5.0.0-beta.3 → 5.0.0-beta.30
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 +1 -1
- package/dist/mcp.d.mts +22 -9
- package/dist/mcp.d.ts +22 -9
- package/dist/mcp.mjs +160 -83
- package/docs/generated-docs/maz-avatar.doc.md +30 -30
- package/docs/generated-docs/maz-btn.doc.md +3 -2
- package/docs/generated-docs/maz-checkbox.doc.md +16 -17
- package/docs/generated-docs/maz-circular-progress-bar.doc.md +1 -1
- package/docs/generated-docs/maz-code-highlight.doc.md +11 -0
- package/docs/generated-docs/maz-container.doc.md +1 -0
- package/docs/generated-docs/maz-date-picker.doc.md +41 -41
- package/docs/generated-docs/maz-drawer.doc.md +7 -8
- package/docs/generated-docs/maz-dropdown.doc.md +3 -0
- package/docs/generated-docs/maz-expand-animation.doc.md +4 -4
- package/docs/generated-docs/maz-fullscreen-loader.doc.md +5 -5
- package/docs/generated-docs/maz-gallery.doc.md +15 -15
- package/docs/generated-docs/maz-input-code.doc.md +16 -16
- package/docs/generated-docs/maz-input-phone-number.doc.md +42 -38
- package/docs/generated-docs/maz-input-price.doc.md +14 -14
- package/docs/generated-docs/maz-input-tags.doc.md +16 -16
- package/docs/generated-docs/maz-input.doc.md +33 -33
- package/docs/generated-docs/maz-lazy-img.doc.md +14 -14
- package/docs/generated-docs/maz-loading-bar.doc.md +4 -4
- package/docs/generated-docs/maz-markdown-editor.doc.md +65 -0
- package/docs/generated-docs/maz-popover.doc.md +1 -1
- package/docs/generated-docs/maz-pull-to-refresh.doc.md +10 -10
- package/docs/generated-docs/maz-radio-buttons.doc.md +17 -17
- package/docs/generated-docs/maz-radio.doc.md +16 -16
- package/docs/generated-docs/maz-reading-progress-bar.doc.md +4 -4
- package/docs/generated-docs/maz-sidebar-content.doc.md +5 -0
- package/docs/generated-docs/maz-sidebar-footer.doc.md +5 -0
- package/docs/generated-docs/maz-sidebar-group.doc.md +11 -0
- package/docs/generated-docs/maz-sidebar-header.doc.md +5 -0
- package/docs/generated-docs/maz-sidebar-menu-button.doc.md +27 -0
- package/docs/generated-docs/maz-sidebar-menu-item.doc.md +5 -0
- package/docs/generated-docs/maz-sidebar-menu-sub.doc.md +16 -0
- package/docs/generated-docs/maz-sidebar-menu.doc.md +5 -0
- package/docs/generated-docs/maz-sidebar-separator.doc.md +0 -0
- package/docs/generated-docs/maz-sidebar-trigger.doc.md +5 -0
- package/docs/generated-docs/maz-sidebar.doc.md +36 -0
- package/docs/generated-docs/maz-slider.doc.md +1 -1
- package/docs/generated-docs/maz-spinner.doc.md +4 -4
- package/docs/generated-docs/maz-switch.doc.md +14 -14
- package/docs/generated-docs/maz-table.doc.md +5 -5
- package/docs/generated-docs/maz-textarea.doc.md +25 -24
- package/docs/generated-docs/maz-ticker.doc.md +1 -1
- package/docs/generated-docs/maz-timeline.doc.md +4 -4
- package/docs/generated-docs/maz-window-mockup.doc.md +23 -0
- package/docs/src/blog/v4.md +1 -1
- package/docs/src/blog/v5.md +5 -7
- package/docs/src/components/maz-avatar.md +29 -0
- package/docs/src/components/maz-btn.md +1 -1
- package/docs/src/components/maz-code-highlight.md +233 -0
- package/docs/src/components/maz-container.md +2 -2
- package/docs/src/components/maz-date-picker.md +1 -1
- package/docs/src/components/maz-dialog.md +46 -0
- package/docs/src/components/maz-dropdown.md +32 -16
- package/docs/src/components/maz-icon.md +2 -2
- package/docs/src/components/maz-input-phone-number.md +106 -103
- package/docs/src/components/maz-markdown-editor.md +369 -0
- package/docs/src/components/maz-sidebar.md +719 -0
- package/docs/src/components/maz-textarea.md +27 -1
- package/docs/src/components/maz-timeline.md +60 -0
- package/docs/src/components/maz-window-mockup.md +249 -0
- package/docs/src/composables/use-form-validator.md +50 -11
- package/docs/src/directives/click-outside.md +8 -15
- package/docs/src/directives/fullscreen-img.md +1 -1
- package/docs/src/directives/lazy-img.md +5 -5
- package/docs/src/directives/tooltip.md +24 -1
- package/docs/src/directives/zoom-img.md +1 -1
- package/docs/src/ecosystem/eslint-config.md +95 -1
- package/docs/src/{guide/icons.md → ecosystem/icons/index.md} +1 -1
- package/docs/src/ecosystem/node/exec-promise.md +87 -0
- package/docs/src/ecosystem/node/index.md +53 -0
- package/docs/src/ecosystem/node/logger.md +146 -0
- package/docs/src/ecosystem/node/print-banner.md +93 -0
- package/docs/src/{guide → ecosystem}/nuxt.md +81 -47
- package/docs/src/{guide → ecosystem}/themes.md +153 -72
- package/docs/src/{guide → ecosystem}/translations.md +1 -1
- package/docs/src/ecosystem/utils/camel-case.md +31 -0
- package/docs/src/{helpers → ecosystem/utils}/capitalize.md +2 -3
- package/docs/src/ecosystem/utils/check-availability.md +79 -0
- package/docs/src/ecosystem/utils/cookie.md +80 -0
- package/docs/src/{helpers → ecosystem/utils}/currency.md +2 -2
- package/docs/src/{helpers → ecosystem/utils}/date.md +2 -2
- package/docs/src/ecosystem/utils/debounce-callback.md +38 -0
- package/docs/src/ecosystem/utils/debounce-id.md +69 -0
- package/docs/src/ecosystem/utils/debounce.md +65 -0
- package/docs/src/ecosystem/utils/fetch-locale-ip.md +33 -0
- package/docs/src/ecosystem/utils/format-json.md +33 -0
- package/docs/src/ecosystem/utils/format-phone-number.md +37 -0
- package/docs/src/ecosystem/utils/get-browser-locale.md +29 -0
- package/docs/src/ecosystem/utils/get-error-message.md +39 -0
- package/docs/src/ecosystem/utils/idle-timeout.md +90 -0
- package/docs/src/ecosystem/utils/index.md +60 -0
- package/docs/src/ecosystem/utils/is-client.md +32 -0
- package/docs/src/ecosystem/utils/is-equal.md +38 -0
- package/docs/src/ecosystem/utils/is-server.md +31 -0
- package/docs/src/ecosystem/utils/is-standalone-mode.md +43 -0
- package/docs/src/ecosystem/utils/kebab-case.md +36 -0
- package/docs/src/ecosystem/utils/normalize-string.md +77 -0
- package/docs/src/{helpers → ecosystem/utils}/number.md +2 -2
- package/docs/src/ecosystem/utils/pascal-case.md +35 -0
- package/docs/src/ecosystem/utils/script-loader.md +77 -0
- package/docs/src/ecosystem/utils/sleep.md +59 -0
- package/docs/src/ecosystem/utils/snake-case.md +36 -0
- package/docs/src/ecosystem/utils/swipe-handler.md +91 -0
- package/docs/src/ecosystem/utils/textarea-autogrow.md +41 -0
- package/docs/src/ecosystem/utils/throttle-id.md +48 -0
- package/docs/src/ecosystem/utils/throttle.md +57 -0
- package/docs/src/ecosystem/utils/truthy-filter.md +31 -0
- package/docs/src/ecosystem/utils/types/deep-key-of.md +48 -0
- package/docs/src/ecosystem/utils/types/deep-partial.md +42 -0
- package/docs/src/ecosystem/utils/types/deep-required.md +39 -0
- package/docs/src/ecosystem/utils/types/flatten-object-keys.md +44 -0
- package/docs/src/ecosystem/utils/types/generic-instance-type.md +42 -0
- package/docs/src/ecosystem/utils/types/infer-maybe-ref.md +35 -0
- package/docs/src/ecosystem/utils/upper-first.md +32 -0
- package/docs/src/ecosystem/utils/user-visibility.md +69 -0
- package/docs/src/guide/getting-started.md +15 -13
- package/docs/src/guide/global-defaults.md +101 -0
- package/docs/src/guide/maz-ui-provider.md +6 -3
- package/docs/src/guide/migration-v4.md +13 -9
- package/docs/src/guide/migration-v5.md +112 -13
- package/docs/src/guide/resolvers.md +7 -7
- package/docs/src/guide/tailwind.md +4 -0
- package/docs/src/guide/vue.md +4 -4
- package/docs/src/index.md +12 -12
- package/docs/src/plugins/aos.md +1 -1
- package/docs/src/plugins/wait.md +1 -1
- package/package.json +8 -7
- package/docs/src/helpers/camel-case.md +0 -14
- package/docs/src/helpers/check-availability.md +0 -14
- package/docs/src/helpers/debounce-callback.md +0 -14
- package/docs/src/helpers/debounce-id.md +0 -14
- package/docs/src/helpers/debounce.md +0 -14
- package/docs/src/helpers/is-client.md +0 -14
- package/docs/src/helpers/is-equal.md +0 -14
- package/docs/src/helpers/is-standalone-mode.md +0 -14
- package/docs/src/helpers/kebab-case.md +0 -14
- package/docs/src/helpers/normalize-string.md +0 -14
- package/docs/src/helpers/pascal-case.md +0 -14
- package/docs/src/helpers/script-loader.md +0 -14
- package/docs/src/helpers/sleep.md +0 -14
- package/docs/src/helpers/snake-case.md +0 -14
- package/docs/src/helpers/throttle-id.md +0 -14
- package/docs/src/helpers/throttle.md +0 -14
- /package/docs/src/{guide → ecosystem/icons}/icon-set.md +0 -0
- /package/docs/src/{guide → ecosystem}/mcp.md +0 -0
- /package/docs/src/{helpers → ecosystem/utils}/country-code-to-unicode-flag.md +0 -0
- /package/docs/src/{helpers → ecosystem/utils}/get-country-flag-url.md +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: '@maz-ui/utils'
|
|
3
|
+
description: Lightweight, tree-shakeable utility functions and TypeScript helpers for Vue, Nuxt and any JavaScript/TypeScript project.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
<NpmBadge package="@maz-ui/utils" />
|
|
11
|
+
|
|
12
|
+
`@maz-ui/utils` ships the runtime helpers and TypeScript type utilities that power maz-ui internally, packaged as a standalone, framework-agnostic library. No Vue dependency, no global side effects — just import what you need.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
::: code-group
|
|
17
|
+
|
|
18
|
+
```bash [pnpm]
|
|
19
|
+
pnpm add @maz-ui/utils
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```bash [npm]
|
|
23
|
+
npm install @maz-ui/utils
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```bash [yarn]
|
|
27
|
+
yarn add @maz-ui/utils
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
:::
|
|
31
|
+
|
|
32
|
+
## Basic usage
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { debounce, formatCurrency, sleep } from '@maz-ui/utils'
|
|
36
|
+
|
|
37
|
+
const debounced = debounce(() => console.log('typed'), 300)
|
|
38
|
+
|
|
39
|
+
const price = formatCurrency(1999.9, 'fr-FR', { currency: 'EUR' })
|
|
40
|
+
|
|
41
|
+
await sleep(500)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## What's inside
|
|
45
|
+
|
|
46
|
+
<UtilsCatalogue />
|
|
47
|
+
|
|
48
|
+
## Tree-shaking
|
|
49
|
+
|
|
50
|
+
The package is published with `"sideEffects": false`. Named imports — `import { sleep } from '@maz-ui/utils'` — are statically analysed by Vite, Rollup, esbuild and webpack: any helper you don't reference is dropped from your bundle.
|
|
51
|
+
|
|
52
|
+
For granular bundling you can also import a single helper through its dedicated subpath:
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
import { sleep } from '@maz-ui/utils/helpers/sleep'
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## TypeScript helpers
|
|
59
|
+
|
|
60
|
+
Beyond runtime utilities, `@maz-ui/utils` also exports a set of generic type helpers (`DeepPartial`, `DeepKeyOf`, `FlattenObjectKeys`, …) under `@maz-ui/utils/ts-helpers`. See the **TypeScript Helpers** section in the sidebar.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: isClient
|
|
3
|
+
description: Check whether the code is running in a browser environment (has a `document`).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { isClient } from '@maz-ui/utils'
|
|
14
|
+
|
|
15
|
+
if (isClient()) {
|
|
16
|
+
document.body.classList.add('hydrated')
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## API
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
function isClient(): boolean
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Returns `true` if `document` is defined, `false` otherwise (e.g. SSR, Node.js, Web Workers).
|
|
27
|
+
|
|
28
|
+
## Notes
|
|
29
|
+
|
|
30
|
+
- The opposite is [`isServer`](./is-server).
|
|
31
|
+
- Implemented as a one-liner: `typeof document !== 'undefined'`.
|
|
32
|
+
- Prefer this over checking `process.client` (Nuxt) or `import.meta.env.SSR` (Vite) when you want a framework-agnostic check.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: isEqual
|
|
3
|
+
description: Deep structural equality check for primitives, arrays, plain objects and Dates.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { isEqual } from '@maz-ui/utils'
|
|
14
|
+
|
|
15
|
+
isEqual({ a: 1, b: [2, 3] }, { a: 1, b: [2, 3] }) // true
|
|
16
|
+
isEqual([1, 2, 3], [1, 2, 3]) // true
|
|
17
|
+
isEqual(new Date('2024-01-01'), new Date('2024-01-01')) // true
|
|
18
|
+
isEqual({ a: 1 }, { a: 1, b: 2 }) // false
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## API
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
function isEqual(a: unknown, b: unknown): boolean
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
| Parameter | Type | Description |
|
|
28
|
+
| --------- | --------- | ----------------- |
|
|
29
|
+
| `a` | `unknown` | First value |
|
|
30
|
+
| `b` | `unknown` | Second value |
|
|
31
|
+
|
|
32
|
+
## Behaviour
|
|
33
|
+
|
|
34
|
+
- **Primitives** (`null`, `undefined`, `string`, `number`, `boolean`, `symbol`, `bigint`) — compared with `===`.
|
|
35
|
+
- **Dates** — compared by `getTime()`.
|
|
36
|
+
- **Arrays** — same length and every element deeply equal.
|
|
37
|
+
- **Plain objects** — same set of keys and every value deeply equal.
|
|
38
|
+
- **Anything else** (Maps, Sets, class instances, functions) is not specifically handled; comparisons fall back to `===`.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: isServer
|
|
3
|
+
description: Check whether the code is running on the server (no `window` or `document`).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { isServer } from '@maz-ui/utils'
|
|
14
|
+
|
|
15
|
+
if (isServer()) {
|
|
16
|
+
return placeholder
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## API
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
function isServer(): boolean
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Returns `true` when either `document` or `window` is undefined — covers Node.js, Bun, Deno, Edge runtimes and Web Workers.
|
|
27
|
+
|
|
28
|
+
## Notes
|
|
29
|
+
|
|
30
|
+
- The opposite is [`isClient`](./is-client).
|
|
31
|
+
- Useful for guarding `window`-dependent code from SSR errors.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: isStandaloneMode
|
|
3
|
+
description: Check whether the app is running as an installed Progressive Web App (PWA) rather than inside a browser tab.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { isStandaloneMode } from '@maz-ui/utils'
|
|
14
|
+
|
|
15
|
+
if (isStandaloneMode()) {
|
|
16
|
+
console.log('Running as installed PWA')
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## API
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
function isStandaloneMode(): boolean
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Returns `true` if the page is rendered in standalone display mode, `false` otherwise (including during SSR).
|
|
27
|
+
|
|
28
|
+
## Detection rules
|
|
29
|
+
|
|
30
|
+
The check returns `true` when **either**:
|
|
31
|
+
|
|
32
|
+
- `window.matchMedia('(display-mode: standalone)').matches` — covers Chrome, Edge, Firefox, etc.
|
|
33
|
+
- `navigator.standalone` is truthy — iOS Safari's legacy property.
|
|
34
|
+
|
|
35
|
+
## Examples
|
|
36
|
+
|
|
37
|
+
Hide install prompts when already installed:
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
if (!isStandaloneMode()) {
|
|
41
|
+
showInstallBanner()
|
|
42
|
+
}
|
|
43
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: kebabCase
|
|
3
|
+
description: Convert any common string casing to kebab-case — handles camelCase, PascalCase, snake_case, spaces and consecutive capitals.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { kebabCase } from '@maz-ui/utils'
|
|
14
|
+
|
|
15
|
+
kebabCase('myComponent') // → 'my-component'
|
|
16
|
+
kebabCase('MyComponent') // → 'my-component'
|
|
17
|
+
kebabCase('XMLParser') // → 'xml-parser'
|
|
18
|
+
kebabCase('hello_world') // → 'hello-world'
|
|
19
|
+
kebabCase('hello world') // → 'hello-world'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## API
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
function kebabCase(str: string): string
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
| Parameter | Type | Description |
|
|
29
|
+
| --------- | -------- | --------------------- |
|
|
30
|
+
| `str` | `string` | The string to convert |
|
|
31
|
+
|
|
32
|
+
## Notes
|
|
33
|
+
|
|
34
|
+
- Consecutive uppercase letters are handled (e.g. `XMLParser` → `xml-parser`).
|
|
35
|
+
- Leading and trailing dashes are stripped.
|
|
36
|
+
- Multiple separators collapse into a single dash.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: normalizeString
|
|
3
|
+
description: Powerful string normalizer — strip accents, normalize whitespace, remove special characters, change case, and apply Unicode normalization forms.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
The Swiss-army knife for turning user input into a safe, comparable, slug-ready string.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { normalizeString } from '@maz-ui/utils'
|
|
16
|
+
|
|
17
|
+
normalizeString(' Crème Brûlée ')
|
|
18
|
+
// → 'creme-brulee'
|
|
19
|
+
|
|
20
|
+
normalizeString('Élégant Café', { case: 'kebab-case' })
|
|
21
|
+
// → 'elegant-cafe'
|
|
22
|
+
|
|
23
|
+
normalizeString('My Article Title!', {
|
|
24
|
+
case: 'kebab-case',
|
|
25
|
+
removeSpecialCharacters: true,
|
|
26
|
+
})
|
|
27
|
+
// → 'my-article-title'
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## API
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
function normalizeString(
|
|
34
|
+
input: string | number | boolean,
|
|
35
|
+
options?: NormalizeStringOptions,
|
|
36
|
+
): string
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Options
|
|
40
|
+
|
|
41
|
+
| Option | Type | Default | Description |
|
|
42
|
+
| -------------------------- | ------------ | ------------------ | -------------------------------------------------------------------------------------------- |
|
|
43
|
+
| `removeAccents` | `boolean` | `true` | Strip diacritics (`é → e`, `ç → c`, …) |
|
|
44
|
+
| `caseSensitive` | `boolean` | `false` | When `false`, lowercases the result unless `case` is set |
|
|
45
|
+
| `replaceSpaces` | `boolean` | `true` | Replace spaces with `-` |
|
|
46
|
+
| `removeSpecialCharacters` | `boolean` | `false` | Strip non-alphanumeric / non-dash characters (Latin alphabet only) |
|
|
47
|
+
| `trim` | `boolean` | `true` | Trim leading/trailing whitespace |
|
|
48
|
+
| `normalizeSpaces` | `boolean` | `true` | Collapse runs of whitespace into a single space |
|
|
49
|
+
| `removeNumbers` | `boolean` | `false` | Strip digits |
|
|
50
|
+
| `case` | `CaseFormat` | `undefined` | Force a target case: `kebab-case`, `camelCase`, `PascalCase`, `snake_case`, `lowercase`, `UPPERCASE` |
|
|
51
|
+
| `customNormalizationForms` | `string[]` | `['NFC', 'NFKD']` | Unicode [normalization forms](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/normalize) applied at the end |
|
|
52
|
+
|
|
53
|
+
## Examples
|
|
54
|
+
|
|
55
|
+
Generate a URL-safe slug:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
const slug = normalizeString(post.title, {
|
|
59
|
+
case: 'kebab-case',
|
|
60
|
+
removeSpecialCharacters: true,
|
|
61
|
+
})
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Build a case-insensitive comparison key:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
const a = normalizeString('Éléphant')
|
|
68
|
+
const b = normalizeString('elephant')
|
|
69
|
+
a === b // true
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Preserve original casing but strip diacritics:
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
normalizeString('Crème Brûlée', { caseSensitive: true, replaceSpaces: false })
|
|
76
|
+
// → 'Creme Brulee'
|
|
77
|
+
```
|
|
@@ -12,7 +12,7 @@ description: The module formatNumber is a function that formats numbers with the
|
|
|
12
12
|
<MazInput v-model="numberValue" type="number" />
|
|
13
13
|
|
|
14
14
|
<div
|
|
15
|
-
style="padding: 16px; margin-top: 16px; background-color: var(--maz-surface-300);"
|
|
15
|
+
style="padding: 16px; margin-top: 16px; background-color: var(--maz-color-surface-300);"
|
|
16
16
|
class="maz:flex maz:flex-center maz:rounded-md maz:gap-0.5"
|
|
17
17
|
>
|
|
18
18
|
formatted value: <strong>{{ numberFormatted }}</strong>
|
|
@@ -34,7 +34,7 @@ const numberFormatted = computed(() =>
|
|
|
34
34
|
<MazInput v-model="numberValue" type="number" />
|
|
35
35
|
|
|
36
36
|
<div
|
|
37
|
-
style="padding: 16px; margin-top: 16px; background-color: var(--maz-surface-300);"
|
|
37
|
+
style="padding: 16px; margin-top: 16px; background-color: var(--maz-color-surface-300);"
|
|
38
38
|
>
|
|
39
39
|
{{ numberFormatted }}
|
|
40
40
|
</div>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: pascalCase
|
|
3
|
+
description: Convert any common string casing — kebab, snake, space-separated, camelCase or UPPERCASE — to PascalCase.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { pascalCase } from '@maz-ui/utils'
|
|
14
|
+
|
|
15
|
+
pascalCase('my-component-name') // → 'MyComponentName'
|
|
16
|
+
pascalCase('hello_world') // → 'HelloWorld'
|
|
17
|
+
pascalCase('hello world') // → 'HelloWorld'
|
|
18
|
+
pascalCase('helloWorld') // → 'HelloWorld'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## API
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
function pascalCase(str: string): string
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
| Parameter | Type | Description |
|
|
28
|
+
| --------- | -------- | --------------------- |
|
|
29
|
+
| `str` | `string` | The string to convert |
|
|
30
|
+
|
|
31
|
+
## Notes
|
|
32
|
+
|
|
33
|
+
- Detects `-`, `_` and space separators automatically.
|
|
34
|
+
- Handles ALL-CAPS inputs by lowercasing before re-capitalizing.
|
|
35
|
+
- For fine-grained control, use [`normalizeString`](./normalize-string) with `{ case: 'PascalCase' }`.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ScriptLoader
|
|
3
|
+
description: Class to inject and cache a <script> tag in document head, with an awaitable load promise — ideal for third-party SDKs.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
`ScriptLoader` handles deduplication (won't inject the same script twice), error reporting, and optional one-time loading semantics.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { ScriptLoader } from '@maz-ui/utils'
|
|
16
|
+
|
|
17
|
+
const loader = new ScriptLoader({
|
|
18
|
+
identifier: 'stripe-js',
|
|
19
|
+
src: 'https://js.stripe.com/v3/',
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
await loader.load()
|
|
23
|
+
// window.Stripe is now available
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## API
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
class ScriptLoader {
|
|
30
|
+
constructor(options: ScriptLoaderOptions)
|
|
31
|
+
load(): Promise<Event | undefined>
|
|
32
|
+
removeTag(tag: Element | string): void
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface ScriptLoaderOptions {
|
|
36
|
+
identifier: string
|
|
37
|
+
src: string
|
|
38
|
+
once?: boolean // default: true
|
|
39
|
+
async?: boolean // default: true
|
|
40
|
+
defer?: boolean // default: true
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
| Option | Type | Default | Description |
|
|
45
|
+
| ------------ | --------- | ------- | ---------------------------------------------------------------------------- |
|
|
46
|
+
| `identifier` | `string` | — | Unique key used to deduplicate the script across calls (set as `data-identifier`) |
|
|
47
|
+
| `src` | `string` | — | Script URL |
|
|
48
|
+
| `once` | `boolean` | `true` | When `true`, skip injection if a script with the same identifier already loaded |
|
|
49
|
+
| `async` | `boolean` | `true` | Sets the `async` attribute on the `<script>` tag |
|
|
50
|
+
| `defer` | `boolean` | `true` | Sets the `defer` attribute on the `<script>` tag |
|
|
51
|
+
|
|
52
|
+
### Methods
|
|
53
|
+
|
|
54
|
+
- **`load()`** — Inject the script (or resolve immediately if cached) and return a promise that resolves to the load `Event` once the script is ready.
|
|
55
|
+
- **`removeTag(tag)`** — Remove an injected `<script>` tag by element reference or identifier string.
|
|
56
|
+
|
|
57
|
+
## Errors
|
|
58
|
+
|
|
59
|
+
`ScriptLoader` throws synchronously in two situations:
|
|
60
|
+
|
|
61
|
+
- `src` or `identifier` is missing.
|
|
62
|
+
- Called in a non-browser environment (no `window` available).
|
|
63
|
+
|
|
64
|
+
## Examples
|
|
65
|
+
|
|
66
|
+
Reload a script on demand by disabling caching:
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
const loader = new ScriptLoader({
|
|
70
|
+
identifier: 'my-widget',
|
|
71
|
+
src: '/widget.js',
|
|
72
|
+
once: false,
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
await loader.load() // first injection
|
|
76
|
+
await loader.load() // previous tag removed, new one injected
|
|
77
|
+
```
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: sleep
|
|
3
|
+
description: Pause execution for a given number of milliseconds. Returns a promise that resolves after the delay.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { sleep } from '@maz-ui/utils'
|
|
14
|
+
|
|
15
|
+
await sleep(500)
|
|
16
|
+
console.log('Half a second later')
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## API
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
function sleep(duration: number): Promise<void>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
| Parameter | Type | Description |
|
|
26
|
+
| ---------- | -------- | --------------------- |
|
|
27
|
+
| `duration` | `number` | Delay in milliseconds |
|
|
28
|
+
|
|
29
|
+
Returns a `Promise<void>` that resolves once the delay elapses.
|
|
30
|
+
|
|
31
|
+
## Examples
|
|
32
|
+
|
|
33
|
+
Chain delays in a sequence:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
async function rampUp() {
|
|
37
|
+
console.log('Starting')
|
|
38
|
+
await sleep(1000)
|
|
39
|
+
console.log('1s later')
|
|
40
|
+
await sleep(2000)
|
|
41
|
+
console.log('3s later')
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Use as a guard between retries with exponential backoff:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
async function withRetry(task: () => Promise<void>, attempts = 3) {
|
|
49
|
+
for (let i = 0; i < attempts; i++) {
|
|
50
|
+
try {
|
|
51
|
+
return await task()
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
await sleep(2 ** i * 100)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
throw new Error('Max retries exceeded')
|
|
58
|
+
}
|
|
59
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: snakeCase
|
|
3
|
+
description: Convert any common string casing to snake_case — handles camelCase, PascalCase, kebab-case, spaces and consecutive capitals.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { snakeCase } from '@maz-ui/utils'
|
|
14
|
+
|
|
15
|
+
snakeCase('myComponent') // → 'my_component'
|
|
16
|
+
snakeCase('MyComponent') // → 'my_component'
|
|
17
|
+
snakeCase('XMLParser') // → 'xml_parser'
|
|
18
|
+
snakeCase('hello-world') // → 'hello_world'
|
|
19
|
+
snakeCase('hello world') // → 'hello_world'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## API
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
function snakeCase(str: string): string
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
| Parameter | Type | Description |
|
|
29
|
+
| --------- | -------- | --------------------- |
|
|
30
|
+
| `str` | `string` | The string to convert |
|
|
31
|
+
|
|
32
|
+
## Notes
|
|
33
|
+
|
|
34
|
+
- Consecutive uppercase letters are handled (e.g. `XMLParser` → `xml_parser`).
|
|
35
|
+
- Leading and trailing underscores are stripped.
|
|
36
|
+
- Multiple separators collapse into a single underscore.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Swipe
|
|
3
|
+
description: Detect directional touch swipes on an element with configurable threshold and optional mouse-wheel guards.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
`Swipe` attaches touch listeners to a DOM element and fires callbacks for left, right, up and down swipes once a configurable distance threshold is crossed.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { Swipe } from '@maz-ui/utils'
|
|
16
|
+
|
|
17
|
+
const swipe = new Swipe({
|
|
18
|
+
element: '#carousel',
|
|
19
|
+
immediate: true,
|
|
20
|
+
onLeft: () => carousel.next(),
|
|
21
|
+
onRight: () => carousel.prev(),
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
// later
|
|
25
|
+
swipe.stop()
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## API
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
class Swipe {
|
|
32
|
+
constructor(options: SwipeOptions)
|
|
33
|
+
|
|
34
|
+
start(element?: HTMLElement | string | null): void
|
|
35
|
+
stop(): void
|
|
36
|
+
|
|
37
|
+
xStart?: number
|
|
38
|
+
yStart?: number
|
|
39
|
+
xEnd?: number
|
|
40
|
+
yEnd?: number
|
|
41
|
+
xDiff?: number
|
|
42
|
+
yDiff?: number
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Options
|
|
47
|
+
|
|
48
|
+
| Option | Type | Default | Description |
|
|
49
|
+
| ---------------------------- | ----------------------------------- | ------- | -------------------------------------------------------------------------- |
|
|
50
|
+
| `element` | `HTMLElement \| string \| null` | `null` | Target element or CSS selector. |
|
|
51
|
+
| `threshold` | `number` | `50` | Minimum distance in px before a swipe is recognised. |
|
|
52
|
+
| `onLeft` / `onRight` / `onUp` / `onDown` | `(event: TouchEvent) => void` | — | Direction callbacks. |
|
|
53
|
+
| `onValuesChanged` | `(values: SwipeValues) => void` | — | Fires whenever start/end/diff values are updated — useful for live tracking. |
|
|
54
|
+
| `preventDefaultOnTouchMove` | `boolean` | `false` | Calls `event.preventDefault()` on `touchmove`. |
|
|
55
|
+
| `preventDefaultOnMouseWheel` | `boolean` | `false` | Calls `event.preventDefault()` on `mousewheel`. |
|
|
56
|
+
| `immediate` | `boolean` | `false` | Attach listeners immediately from the constructor. |
|
|
57
|
+
| `triggerOnEnd` | `boolean` | `false` | Fire direction callbacks on `touchend` instead of on every `touchmove`. |
|
|
58
|
+
|
|
59
|
+
### Methods
|
|
60
|
+
|
|
61
|
+
- **`start(element?)`** — Begin listening. Optionally re-target a new element.
|
|
62
|
+
- **`stop()`** — Detach all listeners. Live values reset.
|
|
63
|
+
|
|
64
|
+
## Examples
|
|
65
|
+
|
|
66
|
+
Slide-based gallery:
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
new Swipe({
|
|
70
|
+
element: '.gallery',
|
|
71
|
+
immediate: true,
|
|
72
|
+
threshold: 80,
|
|
73
|
+
triggerOnEnd: true,
|
|
74
|
+
onLeft: () => gallery.next(),
|
|
75
|
+
onRight: () => gallery.previous(),
|
|
76
|
+
})
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Live progress while dragging:
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
new Swipe({
|
|
83
|
+
element: '.draggable',
|
|
84
|
+
immediate: true,
|
|
85
|
+
onValuesChanged: ({ xDiff }) => {
|
|
86
|
+
if (typeof xDiff === 'number') {
|
|
87
|
+
drawer.style.transform = `translateX(${-xDiff}px)`
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
})
|
|
91
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: TextareaAutogrow
|
|
3
|
+
description: Automatically resize a `<textarea>` element to fit its content as the user types or the window resizes.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
The helper disables manual resize, sets `box-sizing: border-box`, and updates `height` to match `scrollHeight` on input and (debounced) on window resize.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { TextareaAutogrow } from '@maz-ui/utils'
|
|
16
|
+
|
|
17
|
+
const textarea = document.querySelector<HTMLTextAreaElement>('textarea#bio')!
|
|
18
|
+
const autogrow = new TextareaAutogrow(textarea)
|
|
19
|
+
|
|
20
|
+
// later
|
|
21
|
+
autogrow.disconnect()
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## API
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
class TextareaAutogrow {
|
|
28
|
+
constructor(element: HTMLTextAreaElement)
|
|
29
|
+
disconnect(): void
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
| Method | Description |
|
|
34
|
+
| -------------- | ----------------------------------------------------------------- |
|
|
35
|
+
| `disconnect()` | Detach the input and resize listeners. The textarea remains styled. |
|
|
36
|
+
|
|
37
|
+
## Notes
|
|
38
|
+
|
|
39
|
+
- Listeners are attached on first focus — until then, the textarea is fully styled but the height isn't yet computed.
|
|
40
|
+
- Resize updates are debounced by 200 ms.
|
|
41
|
+
- For a Vue-idiomatic API, see the [`v-fullsize-textarea`](/directives/v-fullsize-textarea) directive.
|