@maz-ui/mcp 5.0.0 → 5.1.0-beta.0
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 +61 -228
- package/bin/maz-ui-mcp.mjs +2 -5
- package/dist/cli.d.mts +7 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.mjs +14 -0
- package/dist/index.d.mts +340 -0
- package/dist/index.d.ts +340 -0
- package/dist/index.mjs +14 -0
- package/dist/shared/mcp.DzqVbCaL.mjs +2346 -0
- package/docs/README.md +207 -0
- package/docs/agents/agents-md.md +52 -0
- package/docs/agents/claude-rule.md +52 -0
- package/docs/components/maz-accordion.md +76 -0
- package/docs/{src/components → components}/maz-alert.md +31 -164
- package/docs/components/maz-animated-counter.md +87 -0
- package/docs/components/maz-animated-element.md +46 -0
- package/docs/components/maz-animated-text.md +53 -0
- package/docs/components/maz-avatar.md +193 -0
- package/docs/components/maz-backdrop.md +178 -0
- package/docs/{src/components → components}/maz-badge.md +26 -67
- package/docs/components/maz-bottom-sheet.md +257 -0
- package/docs/{src/components → components}/maz-btn-group.md +26 -189
- package/docs/{src/components → components}/maz-btn.md +60 -245
- package/docs/components/maz-card-spotlight.md +84 -0
- package/docs/{src/components → components}/maz-card.md +67 -192
- package/docs/components/maz-carousel.md +153 -0
- package/docs/{src/components → components}/maz-chart.md +17 -161
- package/docs/components/maz-checkbox.md +138 -0
- package/docs/components/maz-checklist.md +251 -0
- package/docs/components/maz-circular-progress-bar.md +109 -0
- package/docs/{src/components → components}/maz-code-highlight.md +15 -93
- package/docs/components/maz-container.md +241 -0
- package/docs/{src/components → components}/maz-date-picker.md +85 -454
- package/docs/components/maz-dialog-confirm.md +215 -0
- package/docs/components/maz-dialog.md +143 -0
- package/docs/components/maz-drawer.md +106 -0
- package/docs/components/maz-dropdown.md +419 -0
- package/docs/{src/components → components}/maz-dropzone.md +80 -221
- package/docs/components/maz-expand-animation.md +82 -0
- package/docs/components/maz-fullscreen-loader.md +58 -0
- package/docs/components/maz-gallery.md +79 -0
- package/docs/{src/components → components}/maz-icon.md +32 -83
- package/docs/components/maz-input-code.md +73 -0
- package/docs/components/maz-input-number.md +79 -0
- package/docs/components/maz-input-phone-number.md +536 -0
- package/docs/components/maz-input-price.md +68 -0
- package/docs/components/maz-input-tags.md +112 -0
- package/docs/{src/components → components}/maz-input.md +74 -221
- package/docs/components/maz-lazy-img.md +113 -0
- package/docs/components/maz-link.md +146 -0
- package/docs/components/maz-loading-bar.md +38 -0
- package/docs/{src/components → components}/maz-markdown-editor.md +72 -125
- package/docs/components/maz-pagination.md +82 -0
- package/docs/components/maz-popover.md +794 -0
- package/docs/{src/components → components}/maz-pull-to-refresh.md +59 -45
- package/docs/components/maz-radio-buttons.md +313 -0
- package/docs/components/maz-radio.md +119 -0
- package/docs/{src/components → components}/maz-read-more.md +31 -122
- package/docs/components/maz-reading-progress-bar.md +96 -0
- package/docs/{src/components → components}/maz-select-country.md +80 -340
- package/docs/{src/components → components}/maz-select.md +76 -206
- package/docs/components/maz-sidebar-content.md +25 -0
- package/docs/components/maz-sidebar-footer.md +25 -0
- package/docs/components/maz-sidebar-group.md +27 -0
- package/docs/components/maz-sidebar-header.md +25 -0
- package/docs/components/maz-sidebar-menu-button.md +41 -0
- package/docs/components/maz-sidebar-menu-item.md +25 -0
- package/docs/components/maz-sidebar-menu-sub.md +32 -0
- package/docs/components/maz-sidebar-menu.md +25 -0
- package/docs/components/maz-sidebar-separator.md +21 -0
- package/docs/components/maz-sidebar-trigger.md +25 -0
- package/docs/{src/components → components}/maz-sidebar.md +117 -329
- package/docs/{src/components → components}/maz-skeleton.md +27 -156
- package/docs/{src/components → components}/maz-slider.md +33 -66
- package/docs/components/maz-spinner.md +84 -0
- package/docs/{src/components → components}/maz-stepper.md +43 -185
- package/docs/components/maz-switch.md +86 -0
- package/docs/components/maz-table-cell.md +27 -0
- package/docs/components/maz-table-row.md +28 -0
- package/docs/components/maz-table-title.md +27 -0
- package/docs/components/maz-table-virtualizer.md +31 -0
- package/docs/components/maz-table.md +426 -0
- package/docs/components/maz-tabs-bar.md +43 -0
- package/docs/components/maz-tabs-content-item.md +27 -0
- package/docs/components/maz-tabs-content.md +27 -0
- package/docs/{src/components → components}/maz-tabs.md +89 -126
- package/docs/components/maz-textarea.md +255 -0
- package/docs/components/maz-ticker.md +427 -0
- package/docs/components/maz-timeline.md +304 -0
- package/docs/components/maz-ui-provider.md +26 -0
- package/docs/{src/components → components}/maz-window-mockup.md +38 -105
- package/docs/composables/use-aos.md +41 -0
- package/docs/composables/use-breakpoints.md +42 -0
- package/docs/composables/use-dialog.md +58 -0
- package/docs/{src/composables → composables}/use-display-names.md +12 -59
- package/docs/{src/composables → composables}/use-drag.md +14 -68
- package/docs/{src/composables → composables}/use-form-validator.md +22 -696
- package/docs/{src/composables → composables}/use-idle-timeout.md +13 -97
- package/docs/{src/composables → composables}/use-pull-to-refresh.md +14 -7
- package/docs/{src/composables → composables}/use-reading-time.md +20 -56
- package/docs/composables/use-string-matching.md +41 -0
- package/docs/{src/composables → composables}/use-swipe.md +14 -81
- package/docs/{src/composables → composables}/use-timer.md +12 -38
- package/docs/composables/use-toast.md +50 -0
- package/docs/{src/composables → composables}/use-user-visibility.md +14 -56
- package/docs/composables/use-wait.md +50 -0
- package/docs/composables/use-window-size.md +25 -0
- package/docs/{src/directives → directives}/click-outside.md +13 -99
- package/docs/{src/directives → directives}/fullscreen-img.md +10 -28
- package/docs/{src/directives → directives}/lazy-img.md +14 -49
- package/docs/{src/directives → directives}/tooltip.md +12 -217
- package/docs/{src/directives → directives}/zoom-img.md +11 -38
- package/docs/{src/ecosystem → ecosystem}/eslint-config.md +37 -29
- package/docs/ecosystem/icons/icon-set.md +25 -0
- package/docs/{src/ecosystem → ecosystem}/icons/index.md +22 -16
- package/docs/ecosystem/mcp.md +165 -0
- package/docs/{src/ecosystem → ecosystem}/node/exec-promise.md +12 -6
- package/docs/ecosystem/node/index.md +53 -0
- package/docs/{src/ecosystem → ecosystem}/node/logger.md +12 -6
- package/docs/{src/ecosystem → ecosystem}/node/print-banner.md +12 -4
- package/docs/ecosystem/node/setup-agents.md +102 -0
- package/docs/{src/ecosystem → ecosystem}/nuxt.md +46 -19
- package/docs/{src/ecosystem → ecosystem}/stylelint-config.md +33 -25
- package/docs/{src/ecosystem → ecosystem}/themes.md +72 -235
- package/docs/{src/ecosystem → ecosystem}/translations.md +25 -23
- package/docs/ecosystem/utils/camel-case.md +37 -0
- package/docs/ecosystem/utils/capitalize.md +37 -0
- package/docs/{src/ecosystem → ecosystem}/utils/check-availability.md +14 -8
- package/docs/{src/ecosystem → ecosystem}/utils/cookie.md +18 -12
- package/docs/ecosystem/utils/country-code-to-unicode-flag.md +128 -0
- package/docs/{src/ecosystem → ecosystem}/utils/currency.md +12 -26
- package/docs/{src/ecosystem → ecosystem}/utils/date.md +10 -24
- package/docs/ecosystem/utils/debounce-callback.md +44 -0
- package/docs/{src/ecosystem → ecosystem}/utils/debounce-id.md +14 -8
- package/docs/{src/ecosystem → ecosystem}/utils/debounce.md +14 -8
- package/docs/ecosystem/utils/fetch-locale-ip.md +39 -0
- package/docs/{src/ecosystem → ecosystem}/utils/format-json.md +11 -5
- package/docs/{src/ecosystem → ecosystem}/utils/format-phone-number.md +12 -6
- package/docs/ecosystem/utils/get-browser-locale.md +35 -0
- package/docs/ecosystem/utils/get-country-flag-url.md +67 -0
- package/docs/{src/ecosystem → ecosystem}/utils/get-error-message.md +10 -4
- package/docs/{src/ecosystem → ecosystem}/utils/idle-timeout.md +15 -9
- package/docs/{src/ecosystem → ecosystem}/utils/index.md +10 -13
- package/docs/{src/ecosystem → ecosystem}/utils/is-client.md +11 -5
- package/docs/{src/ecosystem → ecosystem}/utils/is-equal.md +14 -8
- package/docs/{src/ecosystem → ecosystem}/utils/is-ios.md +12 -6
- package/docs/ecosystem/utils/is-server.md +37 -0
- package/docs/ecosystem/utils/is-standalone-mode.md +49 -0
- package/docs/{src/ecosystem → ecosystem}/utils/kebab-case.md +10 -4
- package/docs/{src/ecosystem → ecosystem}/utils/normalize-string.md +10 -4
- package/docs/{src/ecosystem → ecosystem}/utils/number.md +10 -24
- package/docs/{src/ecosystem → ecosystem}/utils/pascal-case.md +11 -5
- package/docs/{src/ecosystem → ecosystem}/utils/prevent-ios-input-zoom.md +14 -8
- package/docs/{src/ecosystem → ecosystem}/utils/script-loader.md +16 -8
- package/docs/{src/ecosystem → ecosystem}/utils/sleep.md +10 -4
- package/docs/{src/ecosystem → ecosystem}/utils/snake-case.md +10 -4
- package/docs/{src/ecosystem → ecosystem}/utils/swipe-handler.md +14 -8
- package/docs/{src/ecosystem → ecosystem}/utils/textarea-autogrow.md +12 -6
- package/docs/{src/ecosystem → ecosystem}/utils/throttle-id.md +13 -7
- package/docs/{src/ecosystem → ecosystem}/utils/throttle.md +14 -8
- package/docs/ecosystem/utils/truthy-filter.md +37 -0
- package/docs/{src/ecosystem → ecosystem}/utils/types/deep-key-of.md +11 -5
- package/docs/{src/ecosystem → ecosystem}/utils/types/deep-partial.md +10 -4
- package/docs/ecosystem/utils/types/deep-required.md +45 -0
- package/docs/ecosystem/utils/types/flatten-object-keys.md +50 -0
- package/docs/{src/ecosystem → ecosystem}/utils/types/generic-instance-type.md +10 -4
- package/docs/{src/ecosystem → ecosystem}/utils/types/infer-maybe-ref.md +10 -4
- package/docs/ecosystem/utils/upper-first.md +38 -0
- package/docs/{src/ecosystem → ecosystem}/utils/user-visibility.md +12 -6
- package/docs/guide/ai-agents.md +237 -0
- package/docs/{src/guide → guide}/browser-support.md +22 -15
- package/docs/{src/guide → guide}/getting-started.md +34 -139
- package/docs/{src/guide → guide}/global-defaults.md +12 -11
- package/docs/{src/guide → guide}/maz-ui-provider.md +17 -16
- package/docs/{src/guide → guide}/migration-v5.md +95 -88
- package/docs/{src/guide → guide}/resolvers.md +33 -100
- package/docs/guide/tailwind.md +483 -0
- package/docs/{src/guide → guide}/vue.md +33 -39
- package/docs/manifest.json +1 -0
- package/docs/{src/plugins → plugins}/aos.md +20 -55
- package/docs/{src/plugins → plugins}/dialog.md +14 -161
- package/docs/plugins/toast.md +221 -0
- package/docs/plugins/wait.md +78 -0
- package/docs/reference/icons.md +46 -0
- package/docs/reference/tailwind-tokens.md +191 -0
- package/docs/rules.md +57 -0
- package/package.json +84 -22
- package/dist/mcp.d.mts +0 -153
- package/dist/mcp.d.ts +0 -153
- package/dist/mcp.mjs +0 -1511
- package/docs/generated-docs/maz-accordion.doc.md +0 -21
- package/docs/generated-docs/maz-alert.doc.md +0 -20
- package/docs/generated-docs/maz-animated-counter.doc.md +0 -17
- package/docs/generated-docs/maz-animated-element.doc.md +0 -14
- package/docs/generated-docs/maz-animated-text.doc.md +0 -17
- package/docs/generated-docs/maz-avatar.doc.md +0 -45
- package/docs/generated-docs/maz-backdrop.doc.md +0 -55
- package/docs/generated-docs/maz-badge.doc.md +0 -16
- package/docs/generated-docs/maz-bottom-sheet.doc.md +0 -24
- package/docs/generated-docs/maz-btn-group.doc.md +0 -20
- package/docs/generated-docs/maz-btn.doc.md +0 -33
- package/docs/generated-docs/maz-card-spotlight.doc.md +0 -16
- package/docs/generated-docs/maz-card.doc.md +0 -39
- package/docs/generated-docs/maz-carousel.doc.md +0 -17
- package/docs/generated-docs/maz-chart.doc.md +0 -10
- package/docs/generated-docs/maz-checkbox.doc.md +0 -33
- package/docs/generated-docs/maz-checklist.doc.md +0 -30
- package/docs/generated-docs/maz-circular-progress-bar.doc.md +0 -27
- package/docs/generated-docs/maz-code-highlight.doc.md +0 -11
- package/docs/generated-docs/maz-container.doc.md +0 -26
- package/docs/generated-docs/maz-date-picker.doc.md +0 -56
- package/docs/generated-docs/maz-dialog-confirm.doc.md +0 -24
- package/docs/generated-docs/maz-dialog.doc.md +0 -22
- package/docs/generated-docs/maz-drawer.doc.md +0 -25
- package/docs/generated-docs/maz-dropdown.doc.md +0 -45
- package/docs/generated-docs/maz-dropzone.doc.md +0 -82
- package/docs/generated-docs/maz-expand-animation.doc.md +0 -12
- package/docs/generated-docs/maz-fullscreen-loader.doc.md +0 -13
- package/docs/generated-docs/maz-gallery.doc.md +0 -17
- package/docs/generated-docs/maz-icon.doc.md +0 -16
- package/docs/generated-docs/maz-input-code.doc.md +0 -25
- package/docs/generated-docs/maz-input-number.doc.md +0 -33
- package/docs/generated-docs/maz-input-phone-number.doc.md +0 -62
- package/docs/generated-docs/maz-input-price.doc.md +0 -26
- package/docs/generated-docs/maz-input-tags.doc.md +0 -24
- package/docs/generated-docs/maz-input.doc.md +0 -54
- package/docs/generated-docs/maz-lazy-img.doc.md +0 -49
- package/docs/generated-docs/maz-link.doc.md +0 -31
- package/docs/generated-docs/maz-loading-bar.doc.md +0 -6
- package/docs/generated-docs/maz-markdown-editor.doc.md +0 -65
- package/docs/generated-docs/maz-pagination.doc.md +0 -21
- package/docs/generated-docs/maz-popover.doc.md +0 -79
- package/docs/generated-docs/maz-pull-to-refresh.doc.md +0 -50
- package/docs/generated-docs/maz-radio-buttons.doc.md +0 -34
- package/docs/generated-docs/maz-radio.doc.md +0 -33
- package/docs/generated-docs/maz-read-more.doc.md +0 -18
- package/docs/generated-docs/maz-reading-progress-bar.doc.md +0 -18
- package/docs/generated-docs/maz-select-country.doc.md +0 -45
- package/docs/generated-docs/maz-select.doc.md +0 -32
- package/docs/generated-docs/maz-sidebar-content.doc.md +0 -5
- package/docs/generated-docs/maz-sidebar-footer.doc.md +0 -5
- package/docs/generated-docs/maz-sidebar-group.doc.md +0 -11
- package/docs/generated-docs/maz-sidebar-header.doc.md +0 -5
- package/docs/generated-docs/maz-sidebar-menu-button.doc.md +0 -27
- package/docs/generated-docs/maz-sidebar-menu-item.doc.md +0 -5
- package/docs/generated-docs/maz-sidebar-menu-sub.doc.md +0 -16
- package/docs/generated-docs/maz-sidebar-menu.doc.md +0 -5
- package/docs/generated-docs/maz-sidebar-separator.doc.md +0 -0
- package/docs/generated-docs/maz-sidebar-trigger.doc.md +0 -5
- package/docs/generated-docs/maz-sidebar.doc.md +0 -36
- package/docs/generated-docs/maz-skeleton.doc.md +0 -12
- package/docs/generated-docs/maz-slider.doc.md +0 -20
- package/docs/generated-docs/maz-spinner.doc.md +0 -6
- package/docs/generated-docs/maz-stepper.doc.md +0 -30
- package/docs/generated-docs/maz-switch.doc.md +0 -31
- package/docs/generated-docs/maz-table-cell.doc.md +0 -5
- package/docs/generated-docs/maz-table-row.doc.md +0 -12
- package/docs/generated-docs/maz-table-title.doc.md +0 -5
- package/docs/generated-docs/maz-table-virtualizer.doc.md +0 -20
- package/docs/generated-docs/maz-table.doc.md +0 -72
- package/docs/generated-docs/maz-tabs-bar.doc.md +0 -29
- package/docs/generated-docs/maz-tabs-content-item.doc.md +0 -11
- package/docs/generated-docs/maz-tabs-content.doc.md +0 -5
- package/docs/generated-docs/maz-tabs.doc.md +0 -20
- package/docs/generated-docs/maz-textarea.doc.md +0 -46
- package/docs/generated-docs/maz-ticker.doc.md +0 -25
- package/docs/generated-docs/maz-timeline.doc.md +0 -32
- package/docs/generated-docs/maz-ui-provider.doc.md +0 -12
- package/docs/generated-docs/maz-window-mockup.doc.md +0 -23
- package/docs/src/blog/v4.md +0 -276
- package/docs/src/blog/v5.md +0 -184
- package/docs/src/changelog.md +0 -7
- package/docs/src/components/index.md +0 -8
- package/docs/src/components/maz-accordion.md +0 -80
- package/docs/src/components/maz-animated-counter.md +0 -124
- package/docs/src/components/maz-animated-element.md +0 -36
- package/docs/src/components/maz-animated-text.md +0 -36
- package/docs/src/components/maz-avatar.md +0 -227
- package/docs/src/components/maz-backdrop.md +0 -250
- package/docs/src/components/maz-bottom-sheet.md +0 -533
- package/docs/src/components/maz-card-spotlight.md +0 -163
- package/docs/src/components/maz-carousel.md +0 -231
- package/docs/src/components/maz-checkbox.md +0 -168
- package/docs/src/components/maz-checklist.md +0 -414
- package/docs/src/components/maz-circular-progress-bar.md +0 -145
- package/docs/src/components/maz-container.md +0 -363
- package/docs/src/components/maz-dialog-confirm.md +0 -240
- package/docs/src/components/maz-dialog.md +0 -164
- package/docs/src/components/maz-drawer.md +0 -181
- package/docs/src/components/maz-dropdown.md +0 -691
- package/docs/src/components/maz-expand-animation.md +0 -99
- package/docs/src/components/maz-fullscreen-loader.md +0 -58
- package/docs/src/components/maz-gallery.md +0 -85
- package/docs/src/components/maz-input-code.md +0 -61
- package/docs/src/components/maz-input-number.md +0 -81
- package/docs/src/components/maz-input-phone-number.md +0 -942
- package/docs/src/components/maz-input-price.md +0 -67
- package/docs/src/components/maz-input-tags.md +0 -114
- package/docs/src/components/maz-lazy-img.md +0 -88
- package/docs/src/components/maz-link.md +0 -178
- package/docs/src/components/maz-loading-bar.md +0 -26
- package/docs/src/components/maz-pagination.md +0 -79
- package/docs/src/components/maz-popover.md +0 -1416
- package/docs/src/components/maz-radio-buttons.md +0 -462
- package/docs/src/components/maz-radio.md +0 -142
- package/docs/src/components/maz-reading-progress-bar.md +0 -74
- package/docs/src/components/maz-spinner.md +0 -93
- package/docs/src/components/maz-switch.md +0 -92
- package/docs/src/components/maz-table.md +0 -732
- package/docs/src/components/maz-textarea.md +0 -400
- package/docs/src/components/maz-ticker.md +0 -692
- package/docs/src/components/maz-timeline.md +0 -478
- package/docs/src/composables/use-aos.md +0 -34
- package/docs/src/composables/use-breakpoints.md +0 -35
- package/docs/src/composables/use-dialog.md +0 -88
- package/docs/src/composables/use-string-matching.md +0 -63
- package/docs/src/composables/use-toast.md +0 -71
- package/docs/src/composables/use-wait.md +0 -62
- package/docs/src/composables/use-window-size.md +0 -18
- package/docs/src/ecosystem/icons/icon-set.md +0 -123
- package/docs/src/ecosystem/mcp.md +0 -210
- package/docs/src/ecosystem/node/index.md +0 -53
- package/docs/src/ecosystem/utils/camel-case.md +0 -31
- package/docs/src/ecosystem/utils/capitalize.md +0 -50
- package/docs/src/ecosystem/utils/country-code-to-unicode-flag.md +0 -213
- package/docs/src/ecosystem/utils/debounce-callback.md +0 -38
- package/docs/src/ecosystem/utils/fetch-locale-ip.md +0 -33
- package/docs/src/ecosystem/utils/get-browser-locale.md +0 -29
- package/docs/src/ecosystem/utils/get-country-flag-url.md +0 -156
- package/docs/src/ecosystem/utils/is-server.md +0 -31
- package/docs/src/ecosystem/utils/is-standalone-mode.md +0 -43
- package/docs/src/ecosystem/utils/truthy-filter.md +0 -31
- package/docs/src/ecosystem/utils/types/deep-required.md +0 -39
- package/docs/src/ecosystem/utils/types/flatten-object-keys.md +0 -44
- package/docs/src/ecosystem/utils/upper-first.md +0 -32
- package/docs/src/guide/cli.md +0 -144
- package/docs/src/guide/migration-v4.md +0 -925
- package/docs/src/guide/tailwind.md +0 -158
- package/docs/src/index.md +0 -603
- package/docs/src/made-with-maz-ui.md +0 -58
- package/docs/src/plugins/toast.md +0 -349
- package/docs/src/plugins/wait.md +0 -109
- package/docs/src/theme-editor.md +0 -21
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "camelCase"
|
|
3
|
+
description: "Convert a kebab-case string to camelCase by stripping dashes and uppercasing the following letter."
|
|
4
|
+
package: "@maz-ui/utils"
|
|
5
|
+
url: "https://maz-ui.com/ecosystem/utils/camel-case"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# camelCase
|
|
9
|
+
|
|
10
|
+
> Convert a kebab-case string to camelCase by stripping dashes and uppercasing the following letter.
|
|
11
|
+
|
|
12
|
+
- Package: `@maz-ui/utils`
|
|
13
|
+
- Import: `import { camelCase } from '@maz-ui/utils/helpers/camelCase'`
|
|
14
|
+
- Web: https://maz-ui.com/ecosystem/utils/camel-case
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { camelCase } from '@maz-ui/utils'
|
|
20
|
+
|
|
21
|
+
camelCase('my-component-name') // → 'myComponentName'
|
|
22
|
+
camelCase('hello-world') // → 'helloWorld'
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## API
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
function camelCase(str: string): string
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
| Parameter | Type | Description |
|
|
32
|
+
| --------- | -------- | --------------------- |
|
|
33
|
+
| `str` | `string` | The string to convert |
|
|
34
|
+
|
|
35
|
+
## Notes
|
|
36
|
+
|
|
37
|
+
`camelCase` is intentionally minimal - it only handles `kebab-case` input. For more general normalization (snake_case, spaces, PascalCase), use [`normalizeString`](./normalize-string.md) with the `case: 'camelCase'` option.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "capitalize"
|
|
3
|
+
description: "The module capitalize is a function that adds a capital letter to a string"
|
|
4
|
+
package: "@maz-ui/utils"
|
|
5
|
+
url: "https://maz-ui.com/ecosystem/utils/capitalize"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# capitalize
|
|
9
|
+
|
|
10
|
+
> The module capitalize is a function that adds a capital letter to a string
|
|
11
|
+
|
|
12
|
+
- Package: `@maz-ui/utils`
|
|
13
|
+
- Import: `import { capitalize } from '@maz-ui/utils/helpers/capitalize'`
|
|
14
|
+
- Web: https://maz-ui.com/ecosystem/utils/capitalize
|
|
15
|
+
|
|
16
|
+
```vue
|
|
17
|
+
<script lang="ts" setup>
|
|
18
|
+
import { capitalize } from '@maz-ui/utils'
|
|
19
|
+
import { computed, ref } from 'vue'
|
|
20
|
+
|
|
21
|
+
const stringValue = ref('string value')
|
|
22
|
+
|
|
23
|
+
const stringFormatted = computed(() =>
|
|
24
|
+
capitalize(stringValue.value),
|
|
25
|
+
)
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<template>
|
|
29
|
+
<MazInput v-model="stringValue" />
|
|
30
|
+
|
|
31
|
+
<div
|
|
32
|
+
class="flex flex-center rounded-md gap-0.5 p-4 mt-16 bg-surface-300"
|
|
33
|
+
>
|
|
34
|
+
{{ stringFormatted }}
|
|
35
|
+
</div>
|
|
36
|
+
</template>
|
|
37
|
+
```
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: checkAvailability
|
|
3
|
-
description: Poll a getter until a value is available (or matches an expected value), then run a callback
|
|
2
|
+
title: "checkAvailability"
|
|
3
|
+
description: "Poll a getter until a value is available (or matches an expected value), then run a callback - with timeout and configurable retry interval."
|
|
4
|
+
package: "@maz-ui/utils"
|
|
5
|
+
url: "https://maz-ui.com/ecosystem/utils/check-availability"
|
|
4
6
|
---
|
|
5
7
|
|
|
6
|
-
#
|
|
8
|
+
# checkAvailability
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
> Poll a getter until a value is available (or matches an expected value), then run a callback - with timeout and configurable retry interval.
|
|
11
|
+
|
|
12
|
+
- Package: `@maz-ui/utils`
|
|
13
|
+
- Import: `import { checkAvailability } from '@maz-ui/utils/helpers/checkAvailability'`
|
|
14
|
+
- Web: https://maz-ui.com/ecosystem/utils/check-availability
|
|
9
15
|
|
|
10
16
|
Useful for waiting on a third-party SDK to attach itself to `window`, on a Vue ref to be populated after mount, or on any asynchronously-available value.
|
|
11
17
|
|
|
@@ -42,11 +48,11 @@ function checkAvailability<T>(
|
|
|
42
48
|
| --------------- | ---------- | ------- | ---------------------------------------------------------------------- |
|
|
43
49
|
| `maxAttempts` | `number` | `20` | Number of polls before giving up |
|
|
44
50
|
| `interval` | `number` | `100` | Delay between polls, in milliseconds |
|
|
45
|
-
| `expectedValue` | `T` |
|
|
46
|
-
| `errorMessage` | `string` |
|
|
47
|
-
| `onError` | `Function` |
|
|
51
|
+
| `expectedValue` | `T` | - | When set, callback fires only when `getRef()` strictly equals this value |
|
|
52
|
+
| `errorMessage` | `string` | - | Custom error message when `maxAttempts` is exceeded |
|
|
53
|
+
| `onError` | `Function` | - | Called with the timeout `Error` instead of throwing |
|
|
48
54
|
|
|
49
|
-
With default options, the helper polls every 100 ms up to 20 times
|
|
55
|
+
With default options, the helper polls every 100 ms up to 20 times - a 2 second timeout in total.
|
|
50
56
|
|
|
51
57
|
## Examples
|
|
52
58
|
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: cookie
|
|
3
|
-
description: Read, write and delete browser cookies with full attribute support
|
|
2
|
+
title: "cookie"
|
|
3
|
+
description: "Read, write and delete browser cookies with full attribute support - `path`, `domain`, `maxAge`, `expires`, `secure`, `sameSite`, `partitioned`."
|
|
4
|
+
package: "@maz-ui/utils"
|
|
5
|
+
url: "https://maz-ui.com/ecosystem/utils/cookie"
|
|
4
6
|
---
|
|
5
7
|
|
|
6
|
-
#
|
|
8
|
+
# cookie
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
> Read, write and delete browser cookies with full attribute support - `path`, `domain`, `maxAge`, `expires`, `secure`, `sameSite`, `partitioned`.
|
|
11
|
+
|
|
12
|
+
- Package: `@maz-ui/utils`
|
|
13
|
+
- Import: `import { getCookie, setCookie, deleteCookie } from '@maz-ui/utils/helpers/cookie'`
|
|
14
|
+
- Web: https://maz-ui.com/ecosystem/utils/cookie
|
|
9
15
|
|
|
10
16
|
The module exports three functions: `getCookie`, `setCookie`, `deleteCookie`. Reads work both on the client (via `document.cookie`) and on the server (when you pass the raw `Cookie` header).
|
|
11
17
|
|
|
@@ -24,7 +30,7 @@ function getCookie(key: string, cookieHeader?: string): string | null
|
|
|
24
30
|
| Parameter | Type | Description |
|
|
25
31
|
| -------------- | -------- | -------------------------------------------------------------------------------------------- |
|
|
26
32
|
| `key` | `string` | Cookie name |
|
|
27
|
-
| `cookieHeader` | `string` | (Optional) Raw `Cookie` request header
|
|
33
|
+
| `cookieHeader` | `string` | (Optional) Raw `Cookie` request header - pass during SSR (e.g. from `useSSRContext()` in Nuxt) |
|
|
28
34
|
|
|
29
35
|
Returns the URL-decoded value, or `null` when the cookie is absent.
|
|
30
36
|
|
|
@@ -53,16 +59,16 @@ No-op on the server.
|
|
|
53
59
|
| Option | Type | Default | Description |
|
|
54
60
|
| ------------- | --------- | ---------------- | --------------------------------------------------------------------------------- |
|
|
55
61
|
| `path` | `string` | `'/'` | Path attribute. Pass `null` to omit. |
|
|
56
|
-
| `domain` | `string` |
|
|
62
|
+
| `domain` | `string` | - | Domain attribute. |
|
|
57
63
|
| `maxAge` | `number` | `31_536_000` (1y) | Lifetime in seconds. Pass `null` for a session cookie. |
|
|
58
|
-
| `expires` | `Date` |
|
|
59
|
-
| `secure` | `boolean` |
|
|
64
|
+
| `expires` | `Date` | - | Explicit expiration date. Takes precedence over `maxAge`. |
|
|
65
|
+
| `secure` | `boolean` | - | Restrict to HTTPS. |
|
|
60
66
|
| `sameSite` | `'Lax' \| 'Strict' \| 'None'` | `'Lax'` | Same-site policy. Pass `null` to omit. |
|
|
61
|
-
| `partitioned` | `boolean` |
|
|
67
|
+
| `partitioned` | `boolean` | - | Mark the cookie as partitioned (CHIPS). |
|
|
68
|
+
|
|
69
|
+
**Warning: `HttpOnly`**
|
|
62
70
|
|
|
63
|
-
|
|
64
|
-
`HttpOnly` cannot be set from `document.cookie` — browsers reject it. Use a server-set cookie for that.
|
|
65
|
-
:::
|
|
71
|
+
`HttpOnly` cannot be set from `document.cookie` - browsers reject it. Use a server-set cookie for that.
|
|
66
72
|
|
|
67
73
|
## deleteCookie
|
|
68
74
|
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "country-code-to-unicode-flag"
|
|
3
|
+
description: "Convert country code in unicode flag"
|
|
4
|
+
package: "@maz-ui/utils"
|
|
5
|
+
url: "https://maz-ui.com/ecosystem/utils/country-code-to-unicode-flag"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# country-code-to-unicode-flag
|
|
9
|
+
|
|
10
|
+
> Convert country code in unicode flag
|
|
11
|
+
|
|
12
|
+
- Package: `@maz-ui/utils`
|
|
13
|
+
- Import: `import { countryCodeToUnicodeFlag } from '@maz-ui/utils/helpers/countryCodeToUnicodeFlag'`
|
|
14
|
+
- Web: https://maz-ui.com/ecosystem/utils/country-code-to-unicode-flag
|
|
15
|
+
|
|
16
|
+
**Warning:**
|
|
17
|
+
|
|
18
|
+
This feature does not work with Windows but you can use this polyfill: [https://www.npmjs.com/package/country-flag-emoji-polyfill](https://www.npmjs.com/package/country-flag-emoji-polyfill)
|
|
19
|
+
|
|
20
|
+
Use can also use [get-country-flag-url](./get-country-flag-url.md) instead.
|
|
21
|
+
|
|
22
|
+
## Basic usage
|
|
23
|
+
|
|
24
|
+
```vue
|
|
25
|
+
<template>
|
|
26
|
+
<span style="font-size: 2rem;">
|
|
27
|
+
{{ unicodeFlag }}
|
|
28
|
+
</span>
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<script lang="ts" setup >
|
|
32
|
+
import { countryCodeToUnicodeFlag } from '@maz-ui/utils'
|
|
33
|
+
|
|
34
|
+
const unicodeFlag = countryCodeToUnicodeFlag('FR')
|
|
35
|
+
</script>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Example
|
|
39
|
+
|
|
40
|
+
**Details: Show full code**
|
|
41
|
+
|
|
42
|
+
```vue
|
|
43
|
+
|
|
44
|
+
<template>
|
|
45
|
+
<div class="gap-2 flex flex-wrap items-center">
|
|
46
|
+
<span class="text-xs">{{ flag }}</span>
|
|
47
|
+
<span class="text-sm">{{ flag }}</span>
|
|
48
|
+
<span class="text-base">{{ flag }}</span>
|
|
49
|
+
<span class="text-lg">{{ flag }}</span>
|
|
50
|
+
<span class="text-xl">{{ flag }}</span>
|
|
51
|
+
<span class="text-2xl">{{ flag }}</span>
|
|
52
|
+
<span class="text-3xl">{{ flag }}</span>
|
|
53
|
+
<span class="text-4xl">{{ flag }}</span>
|
|
54
|
+
<span class="text-5xl">{{ flag }}</span>
|
|
55
|
+
<span class="text-6xl">{{ flag }}</span>
|
|
56
|
+
<span class="text-7xl">{{ flag }}</span>
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
<MazSelect
|
|
60
|
+
v-model="countryCode"
|
|
61
|
+
:options="countryOptions"
|
|
62
|
+
label="Select country"
|
|
63
|
+
search
|
|
64
|
+
search-placeholder="Search country"
|
|
65
|
+
@selected-option="(option) => console.log('option', option)"
|
|
66
|
+
>
|
|
67
|
+
<template #default="{ option, isSelected }">
|
|
68
|
+
<div
|
|
69
|
+
class="flex items-center gap-3"
|
|
70
|
+
>
|
|
71
|
+
<span class="text-lg">
|
|
72
|
+
{{ option.unicodeFlag }}
|
|
73
|
+
</span>
|
|
74
|
+
<MazBadge
|
|
75
|
+
pastel
|
|
76
|
+
size="0.7rem"
|
|
77
|
+
class="w-9"
|
|
78
|
+
:class="{ 'text-muted': !isSelected }"
|
|
79
|
+
>
|
|
80
|
+
{{ option.value }}
|
|
81
|
+
</MazBadge>
|
|
82
|
+
<span :class="{ 'font-semibold': isSelected }">
|
|
83
|
+
{{ option.label }}
|
|
84
|
+
</span>
|
|
85
|
+
</div>
|
|
86
|
+
</template>
|
|
87
|
+
</MazSelect>
|
|
88
|
+
</template>
|
|
89
|
+
|
|
90
|
+
<script lang="ts" setup>
|
|
91
|
+
import { computed, ref, onMounted } from 'vue'
|
|
92
|
+
import { countryCodeToUnicodeFlag } from '@maz-ui/utils'
|
|
93
|
+
import { getCountries } from 'libphonenumber-js'
|
|
94
|
+
|
|
95
|
+
const countryCode = ref('FR')
|
|
96
|
+
const flag = computed(() => countryCodeToUnicodeFlag(countryCode.value))
|
|
97
|
+
|
|
98
|
+
const countryOptions = ref(getCountriesList())
|
|
99
|
+
|
|
100
|
+
onMounted(() => {
|
|
101
|
+
const listOfCountries = getCountriesList(window.navigator.language)
|
|
102
|
+
if (listOfCountries.length > 1) {
|
|
103
|
+
countryOptions.value = listOfCountries
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
function getCountriesList(
|
|
108
|
+
locale?: string,
|
|
109
|
+
) {
|
|
110
|
+
const countriesList = []
|
|
111
|
+
const isoList = getCountries()
|
|
112
|
+
|
|
113
|
+
for (const iso2 of isoList) {
|
|
114
|
+
const name = new Intl.DisplayNames([locale ?? 'en-US'], { type: 'region' }).of(iso2)
|
|
115
|
+
|
|
116
|
+
if (name) {
|
|
117
|
+
countriesList.push({
|
|
118
|
+
value: iso2,
|
|
119
|
+
label: name,
|
|
120
|
+
unicodeFlag: countryCodeToUnicodeFlag(iso2)
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return countriesList
|
|
126
|
+
}
|
|
127
|
+
</script>
|
|
128
|
+
```
|
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: formatCurrency
|
|
3
|
-
description: The module formatCurrency is a function that formats numbers to currency with the native api [Intl.NumberFormat](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat) from browsers and Node.js
|
|
2
|
+
title: "formatCurrency"
|
|
3
|
+
description: "The module formatCurrency is a function that formats numbers to currency with the native api [Intl.NumberFormat](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat) from browsers and Node.js"
|
|
4
|
+
package: "@maz-ui/utils"
|
|
5
|
+
url: "https://maz-ui.com/ecosystem/utils/currency"
|
|
4
6
|
---
|
|
5
7
|
|
|
6
|
-
#
|
|
8
|
+
# formatCurrency
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
> The module formatCurrency is a function that formats numbers to currency with the native api [Intl.NumberFormat](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat) from browsers and Node.js
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
- Package: `@maz-ui/utils`
|
|
13
|
+
- Import: `import { formatCurrency } from '@maz-ui/utils/helpers/formatCurrency'`
|
|
14
|
+
- Web: https://maz-ui.com/ecosystem/utils/currency
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
**Tip:**
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
This module uses the native api [Intl.NumberFormat](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat) from browsers
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
style="padding: 16px; margin-top: 16px; background-color: var(--maz-surface-300);"
|
|
20
|
-
class="flex flex-center rounded gap-05"
|
|
21
|
-
>
|
|
22
|
-
formatted value: <strong>{{ priceFormatted }}</strong>
|
|
23
|
-
</div>
|
|
20
|
+
Enter only numbers
|
|
24
21
|
|
|
25
22
|
```vue
|
|
26
23
|
<script lang="ts" setup>
|
|
@@ -45,17 +42,6 @@ const priceFormatted = computed(() =>
|
|
|
45
42
|
</template>
|
|
46
43
|
```
|
|
47
44
|
|
|
48
|
-
<script lang="ts" setup>
|
|
49
|
-
import { formatCurrency } from '@maz-ui/utils'
|
|
50
|
-
import { ref, computed } from 'vue'
|
|
51
|
-
|
|
52
|
-
const numberValue = ref(69)
|
|
53
|
-
|
|
54
|
-
const priceFormatted = computed(() =>
|
|
55
|
-
formatCurrency(numberValue.value, 'fr-FR', { currency: 'EUR' }),
|
|
56
|
-
)
|
|
57
|
-
</script>
|
|
58
|
-
|
|
59
45
|
## Options
|
|
60
46
|
|
|
61
47
|
> All options from [Intl.NumberFormat](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat) are availables
|
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: formatDate
|
|
3
|
-
description: The module formatDate is a function that formats dates with the native api [Intl.DateTimeFormat](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat) from browsers and Node.js
|
|
2
|
+
title: "formatDate"
|
|
3
|
+
description: "The module formatDate is a function that formats dates with the native api [Intl.DateTimeFormat](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat) from browsers and Node.js"
|
|
4
|
+
package: "@maz-ui/utils"
|
|
5
|
+
url: "https://maz-ui.com/ecosystem/utils/date"
|
|
4
6
|
---
|
|
5
7
|
|
|
6
|
-
#
|
|
8
|
+
# formatDate
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
> The module formatDate is a function that formats dates with the native api [Intl.DateTimeFormat](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat) from browsers and Node.js
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
- Package: `@maz-ui/utils`
|
|
13
|
+
- Import: `import { formatDate } from '@maz-ui/utils/helpers/formatDate'`
|
|
14
|
+
- Web: https://maz-ui.com/ecosystem/utils/date
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
style="padding: 16px; margin-top: 16px; background-color: var(--maz-surface-300);"
|
|
16
|
-
class="flex flex-center rounded gap-05"
|
|
17
|
-
>
|
|
18
|
-
formatted value: <strong>{{ dateFormatted }}</strong>
|
|
19
|
-
</div>
|
|
16
|
+
> This module use the native api [Intl.DateTimeFormat](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat) from browsers
|
|
20
17
|
|
|
21
18
|
```vue
|
|
22
19
|
<script lang="ts" setup>
|
|
@@ -54,14 +51,3 @@ const DEFAULT_OPTIONS: Intl.DateTimeFormatOptions = {
|
|
|
54
51
|
year: 'numeric',
|
|
55
52
|
}
|
|
56
53
|
```
|
|
57
|
-
|
|
58
|
-
<script lang="ts" setup>
|
|
59
|
-
import { formatDate } from '@maz-ui/utils'
|
|
60
|
-
import { ref, computed } from 'vue'
|
|
61
|
-
|
|
62
|
-
const dateValue = ref('2022-02-01')
|
|
63
|
-
|
|
64
|
-
const dateFormatted = computed(() =>
|
|
65
|
-
dateValue.value ? formatDate(dateValue.value, 'en-US') : undefined,
|
|
66
|
-
)
|
|
67
|
-
</script>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "debounceCallback"
|
|
3
|
+
description: "Module-scoped one-shot debounce - schedule a callback that gets reset on each new call."
|
|
4
|
+
package: "@maz-ui/utils"
|
|
5
|
+
url: "https://maz-ui.com/ecosystem/utils/debounce-callback"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# debounceCallback
|
|
9
|
+
|
|
10
|
+
> Module-scoped one-shot debounce - schedule a callback that gets reset on each new call.
|
|
11
|
+
|
|
12
|
+
- Package: `@maz-ui/utils`
|
|
13
|
+
- Import: `import { debounceCallback } from '@maz-ui/utils/helpers/debounceCallback'`
|
|
14
|
+
- Web: https://maz-ui.com/ecosystem/utils/debounce-callback
|
|
15
|
+
|
|
16
|
+
Unlike [`debounce`](./debounce.md), which builds a debounced wrapper around a function, `debounceCallback` is a procedural helper: each call schedules a callback after `delay` ms, cancelling any previous pending callback.
|
|
17
|
+
|
|
18
|
+
**Warning: Shared module state**
|
|
19
|
+
|
|
20
|
+
`debounceCallback` uses a single module-level timer. All consumers of this function share the same timer slot, so calling it from two unrelated places will cancel each other. Use [`debounceId`](./debounce-id.md) for isolated debounces.
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { debounceCallback } from '@maz-ui/utils'
|
|
26
|
+
|
|
27
|
+
debounceCallback(() => {
|
|
28
|
+
console.log('runs only if no other call happens in the next 300 ms')
|
|
29
|
+
}, 300)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## API
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
function debounceCallback(
|
|
36
|
+
callback: (...args: unknown[]) => unknown,
|
|
37
|
+
delay: number,
|
|
38
|
+
): void
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
| Parameter | Type | Description |
|
|
42
|
+
| ---------- | ---------- | ------------------------------------------ |
|
|
43
|
+
| `callback` | `Function` | Function to run after the quiet window |
|
|
44
|
+
| `delay` | `number` | Quiet window before firing, in milliseconds |
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: debounceId
|
|
3
|
-
description: Debounce an async function with isolated state per identifier
|
|
2
|
+
title: "debounceId"
|
|
3
|
+
description: "Debounce an async function with isolated state per identifier - only the last call resolves, others are cancelled."
|
|
4
|
+
package: "@maz-ui/utils"
|
|
5
|
+
url: "https://maz-ui.com/ecosystem/utils/debounce-id"
|
|
4
6
|
---
|
|
5
7
|
|
|
6
|
-
#
|
|
8
|
+
# debounceId
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
> Debounce an async function with isolated state per identifier - only the last call resolves, others are cancelled.
|
|
11
|
+
|
|
12
|
+
- Package: `@maz-ui/utils`
|
|
13
|
+
- Import: `import { debounceId } from '@maz-ui/utils/helpers/debounceId'`
|
|
14
|
+
- Web: https://maz-ui.com/ecosystem/utils/debounce-id
|
|
9
15
|
|
|
10
16
|
`debounceId` is the right tool when:
|
|
11
17
|
|
|
12
18
|
- You need to debounce **async** work and `await` the result.
|
|
13
|
-
- You want **per-key isolation**
|
|
19
|
+
- You want **per-key isolation** - debounces for `'search'` shouldn't interfere with debounces for `'autosave'`.
|
|
14
20
|
|
|
15
21
|
## Usage
|
|
16
22
|
|
|
@@ -41,11 +47,11 @@ function debounceId<T, Args extends unknown[]>(
|
|
|
41
47
|
|
|
42
48
|
| Parameter | Type | Description |
|
|
43
49
|
| ------------ | --------------- | ------------------------------------------------------------ |
|
|
44
|
-
| `identifier` | `string` | Unique key
|
|
50
|
+
| `identifier` | `string` | Unique key - calls with the same key share a debounce timer |
|
|
45
51
|
| `func` | `Function` | The async (or sync) function to debounce |
|
|
46
52
|
| `delay` | `number` | Quiet window before the call resolves, in ms |
|
|
47
53
|
|
|
48
|
-
Returns a function that always returns a `Promise<T>`. Earlier pending promises are cancelled
|
|
54
|
+
Returns a function that always returns a `Promise<T>`. Earlier pending promises are cancelled - only the last invocation resolves.
|
|
49
55
|
|
|
50
56
|
## Examples
|
|
51
57
|
|
|
@@ -66,4 +72,4 @@ async function saveDocument(id: string, payload: unknown) {
|
|
|
66
72
|
|
|
67
73
|
## Related
|
|
68
74
|
|
|
69
|
-
- [`throttleId`](./throttle-id)
|
|
75
|
+
- [`throttleId`](./throttle-id.md) - same shape, but throttles instead of debounces.
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: debounce
|
|
3
|
-
description: Wrap a function so it only runs after a quiet period
|
|
2
|
+
title: "debounce"
|
|
3
|
+
description: "Wrap a function so it only runs after a quiet period - every new call resets the timer."
|
|
4
|
+
package: "@maz-ui/utils"
|
|
5
|
+
url: "https://maz-ui.com/ecosystem/utils/debounce"
|
|
4
6
|
---
|
|
5
7
|
|
|
6
|
-
#
|
|
8
|
+
# debounce
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
> Wrap a function so it only runs after a quiet period - every new call resets the timer.
|
|
11
|
+
|
|
12
|
+
- Package: `@maz-ui/utils`
|
|
13
|
+
- Import: `import { debounce } from '@maz-ui/utils/helpers/debounce'`
|
|
14
|
+
- Web: https://maz-ui.com/ecosystem/utils/debounce
|
|
9
15
|
|
|
10
16
|
Useful for input handlers, resize listeners, search-as-you-type and any callback that should not fire on every event.
|
|
11
17
|
|
|
@@ -38,7 +44,7 @@ function debounce<F extends (...args: any[]) => any>(
|
|
|
38
44
|
| `fn` | `Function` | The function to debounce |
|
|
39
45
|
| `delay` | `number` | Quiet window in milliseconds before `fn` runs |
|
|
40
46
|
|
|
41
|
-
The returned function shares no state with other debounced wrappers
|
|
47
|
+
The returned function shares no state with other debounced wrappers - each call to `debounce()` creates a fresh timer.
|
|
42
48
|
|
|
43
49
|
## Examples
|
|
44
50
|
|
|
@@ -60,6 +66,6 @@ const onInput = debounce((event: Event) => {
|
|
|
60
66
|
|
|
61
67
|
## Related
|
|
62
68
|
|
|
63
|
-
- [`debounceId`](./debounce-id)
|
|
64
|
-
- [`debounceCallback`](./debounce-callback)
|
|
65
|
-
- [`throttle`](./throttle)
|
|
69
|
+
- [`debounceId`](./debounce-id.md) - debounce an async function, keyed by an identifier, returning a promise.
|
|
70
|
+
- [`debounceCallback`](./debounce-callback.md) - module-scoped one-shot debounce.
|
|
71
|
+
- [`throttle`](./throttle.md) - rate-limits instead of waiting for silence.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "fetchLocaleIp"
|
|
3
|
+
description: "Resolve the visitor's ISO country code from their IP address using the free `ipwho.is` service."
|
|
4
|
+
package: "@maz-ui/utils"
|
|
5
|
+
url: "https://maz-ui.com/ecosystem/utils/fetch-locale-ip"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# fetchLocaleIp
|
|
9
|
+
|
|
10
|
+
> Resolve the visitor's ISO country code from their IP address using the free `ipwho.is` service.
|
|
11
|
+
|
|
12
|
+
- Package: `@maz-ui/utils`
|
|
13
|
+
- Import: `import { fetchLocaleIp } from '@maz-ui/utils/helpers/fetchLocaleIp'`
|
|
14
|
+
- Web: https://maz-ui.com/ecosystem/utils/fetch-locale-ip
|
|
15
|
+
|
|
16
|
+
Useful for pre-filling locale-aware UI - phone-number country selectors, currency hints, default language - before the user has interacted with the page.
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { fetchLocaleIp } from '@maz-ui/utils'
|
|
22
|
+
|
|
23
|
+
const countryCode = await fetchLocaleIp()
|
|
24
|
+
// 'FR' | 'US' | … or undefined if the request fails
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
function fetchLocaleIp(): Promise<string | undefined>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Returns the ISO 3166-1 alpha-2 country code (e.g. `'FR'`), or `undefined` if the request fails. Errors are caught and logged via `console.error` - the call never throws.
|
|
34
|
+
|
|
35
|
+
## Notes
|
|
36
|
+
|
|
37
|
+
- Hits `https://ipwho.is` - a public, no-key service. Consider rate limits and privacy for production usage.
|
|
38
|
+
- Returns `undefined` rather than throwing so a fallback path (default locale, manual selection) can be wired without `try/catch`.
|
|
39
|
+
- For a static locale source, see [`getBrowserLocale`](./get-browser-locale.md).
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: formatJson
|
|
3
|
-
description: Tiny wrapper around `JSON.stringify` with sensible default indentation.
|
|
2
|
+
title: "formatJson"
|
|
3
|
+
description: "Tiny wrapper around `JSON.stringify` with sensible default indentation."
|
|
4
|
+
package: "@maz-ui/utils"
|
|
5
|
+
url: "https://maz-ui.com/ecosystem/utils/format-json"
|
|
4
6
|
---
|
|
5
7
|
|
|
6
|
-
#
|
|
8
|
+
# formatJson
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
> Tiny wrapper around `JSON.stringify` with sensible default indentation.
|
|
11
|
+
|
|
12
|
+
- Package: `@maz-ui/utils`
|
|
13
|
+
- Import: `import { formatJson } from '@maz-ui/utils/helpers/formatJson'`
|
|
14
|
+
- Web: https://maz-ui.com/ecosystem/utils/format-json
|
|
9
15
|
|
|
10
16
|
## Usage
|
|
11
17
|
|
|
@@ -29,5 +35,5 @@ function formatJson(json: unknown, indent?: number): string
|
|
|
29
35
|
|
|
30
36
|
| Parameter | Type | Default | Description |
|
|
31
37
|
| --------- | --------- | ------- | ---------------------------------------- |
|
|
32
|
-
| `json` | `unknown` |
|
|
38
|
+
| `json` | `unknown` | - | Any JSON-serialisable value |
|
|
33
39
|
| `indent` | `number` | `2` | Number of spaces per indentation level |
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: formatPhoneNumber
|
|
3
|
-
description: Format an arbitrary phone-number string into its international representation using `libphonenumber-js`.
|
|
2
|
+
title: "formatPhoneNumber"
|
|
3
|
+
description: "Format an arbitrary phone-number string into its international representation using `libphonenumber-js`."
|
|
4
|
+
package: "@maz-ui/utils"
|
|
5
|
+
url: "https://maz-ui.com/ecosystem/utils/format-phone-number"
|
|
4
6
|
---
|
|
5
7
|
|
|
6
|
-
#
|
|
8
|
+
# formatPhoneNumber
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
> Format an arbitrary phone-number string into its international representation using `libphonenumber-js`.
|
|
11
|
+
|
|
12
|
+
- Package: `@maz-ui/utils`
|
|
13
|
+
- Import: `import { formatPhoneNumber } from '@maz-ui/utils/helpers/formatPhoneNumber'`
|
|
14
|
+
- Web: https://maz-ui.com/ecosystem/utils/format-phone-number
|
|
9
15
|
|
|
10
16
|
If the input can't be parsed, the original string is returned unchanged.
|
|
11
17
|
|
|
@@ -15,7 +21,7 @@ If the input can't be parsed, the original string is returned unchanged.
|
|
|
15
21
|
import { formatPhoneNumber } from '@maz-ui/utils'
|
|
16
22
|
|
|
17
23
|
formatPhoneNumber('+33612345678') // → '+33 6 12 34 56 78'
|
|
18
|
-
formatPhoneNumber('0612345678') // → '0612345678' (unparseable without country context
|
|
24
|
+
formatPhoneNumber('0612345678') // → '0612345678' (unparseable without country context - returned as-is)
|
|
19
25
|
```
|
|
20
26
|
|
|
21
27
|
## API
|
|
@@ -33,5 +39,5 @@ Throws a `TypeError` when `phoneNumber` is empty.
|
|
|
33
39
|
## Notes
|
|
34
40
|
|
|
35
41
|
- For maximum portability, supply the input in E.164 (`+CCXXXXXXXXX`). Otherwise, parsing falls back to passing the input through unchanged.
|
|
36
|
-
- For interactive phone-number input with country selection, see the [`MazInputPhoneNumber`](
|
|
42
|
+
- For interactive phone-number input with country selection, see the [`MazInputPhoneNumber`](../../components/maz-input-phone-number.md) component.
|
|
37
43
|
- Built on [`libphonenumber-js`](https://github.com/catamphetamine/libphonenumber-js).
|