@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
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: country-code-to-unicode-flag
|
|
3
|
-
description: Convert country code in unicode flag
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# {{ $frontmatter.title }}
|
|
7
|
-
|
|
8
|
-
{{ $frontmatter.description }}
|
|
9
|
-
|
|
10
|
-
::: warning
|
|
11
|
-
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)
|
|
12
|
-
|
|
13
|
-
Use can also use [get-country-flag-url](./get-country-flag-url.md) instead.
|
|
14
|
-
:::
|
|
15
|
-
|
|
16
|
-
## Basic usage
|
|
17
|
-
|
|
18
|
-
<span style="font-size: 2rem;">
|
|
19
|
-
{{ unicodeFlag }}
|
|
20
|
-
</span>
|
|
21
|
-
|
|
22
|
-
```vue
|
|
23
|
-
<template>
|
|
24
|
-
<span style="font-size: 2rem;">
|
|
25
|
-
{{ unicodeFlag }}
|
|
26
|
-
</span>
|
|
27
|
-
</template>
|
|
28
|
-
|
|
29
|
-
<script lang="ts" setup >
|
|
30
|
-
import { countryCodeToUnicodeFlag } from '@maz-ui/utils'
|
|
31
|
-
|
|
32
|
-
const unicodeFlag = countryCodeToUnicodeFlag('FR')
|
|
33
|
-
</script>
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## Example
|
|
37
|
-
|
|
38
|
-
<div class="maz:gap-2 maz:flex maz:flex-wrap maz:items-center">
|
|
39
|
-
<span class="maz:text-xs">{{ flag }}</span>
|
|
40
|
-
<span class="maz:text-sm">{{ flag }}</span>
|
|
41
|
-
<span class="maz:text-base">{{ flag }}</span>
|
|
42
|
-
<span class="maz:text-lg">{{ flag }}</span>
|
|
43
|
-
<span class="maz:text-xl">{{ flag }}</span>
|
|
44
|
-
<span class="maz:text-2xl">{{ flag }}</span>
|
|
45
|
-
<span class="maz:text-3xl">{{ flag }}</span>
|
|
46
|
-
<span class="maz:text-4xl">{{ flag }}</span>
|
|
47
|
-
<span class="maz:text-5xl">{{ flag }}</span>
|
|
48
|
-
<span class="maz:text-6xl">{{ flag }}</span>
|
|
49
|
-
<span class="maz:text-7xl">{{ flag }}</span>
|
|
50
|
-
</div>
|
|
51
|
-
|
|
52
|
-
<MazSelect
|
|
53
|
-
v-model="countryCode"
|
|
54
|
-
:options="countryOptions"
|
|
55
|
-
label="Select country"
|
|
56
|
-
search
|
|
57
|
-
search-placeholder="Search country"
|
|
58
|
-
@selected-option="(option) => console.log('option', option)"
|
|
59
|
-
>
|
|
60
|
-
<template #default="{ option, isSelected }">
|
|
61
|
-
<div
|
|
62
|
-
class="maz:flex maz:items-center maz:gap-3"
|
|
63
|
-
>
|
|
64
|
-
<span class="maz:text-lg">
|
|
65
|
-
{{ option.unicodeFlag }}
|
|
66
|
-
</span>
|
|
67
|
-
<MazBadge
|
|
68
|
-
pastel
|
|
69
|
-
size="0.7rem"
|
|
70
|
-
class="maz:w-9"
|
|
71
|
-
:class="{ 'maz:text-muted': !isSelected }"
|
|
72
|
-
>
|
|
73
|
-
{{ option.value }}
|
|
74
|
-
</MazBadge>
|
|
75
|
-
<span :class="{ 'maz:font-semibold': isSelected }">
|
|
76
|
-
{{ option.label }}
|
|
77
|
-
</span>
|
|
78
|
-
</div>
|
|
79
|
-
</template>
|
|
80
|
-
</MazSelect>
|
|
81
|
-
|
|
82
|
-
<script lang="ts" setup>
|
|
83
|
-
import { computed, ref, onMounted } from 'vue'
|
|
84
|
-
import { countryCodeToUnicodeFlag } from '@maz-ui/utils'
|
|
85
|
-
import { getCountries } from 'libphonenumber-js'
|
|
86
|
-
|
|
87
|
-
const unicodeFlag = countryCodeToUnicodeFlag('FR')
|
|
88
|
-
|
|
89
|
-
const countryCode = ref('FR')
|
|
90
|
-
const flag = computed(() => countryCodeToUnicodeFlag(countryCode.value))
|
|
91
|
-
|
|
92
|
-
const countryOptions = ref(getCountriesList())
|
|
93
|
-
|
|
94
|
-
onMounted(() => {
|
|
95
|
-
const listOfCountries = getCountriesList(window.navigator.language)
|
|
96
|
-
if (listOfCountries.length > 1) {
|
|
97
|
-
countryOptions.value = listOfCountries
|
|
98
|
-
}
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
function getCountriesList(
|
|
102
|
-
locale?: string,
|
|
103
|
-
) {
|
|
104
|
-
const countriesList = []
|
|
105
|
-
const isoList = getCountries()
|
|
106
|
-
|
|
107
|
-
for (const iso2 of isoList) {
|
|
108
|
-
const name = new Intl.DisplayNames([locale ?? 'en-US'], { type: 'region' }).of(iso2)
|
|
109
|
-
|
|
110
|
-
if (name) {
|
|
111
|
-
countriesList.push({
|
|
112
|
-
value: iso2,
|
|
113
|
-
label: name,
|
|
114
|
-
unicodeFlag: countryCodeToUnicodeFlag(iso2)
|
|
115
|
-
})
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return countriesList
|
|
120
|
-
}
|
|
121
|
-
</script>
|
|
122
|
-
|
|
123
|
-
::: details Show full code
|
|
124
|
-
|
|
125
|
-
```vue
|
|
126
|
-
|
|
127
|
-
<template>
|
|
128
|
-
<div class="maz:gap-2 maz:flex maz:flex-wrap maz:items-center">
|
|
129
|
-
<span class="maz:text-xs">{{ flag }}</span>
|
|
130
|
-
<span class="maz:text-sm">{{ flag }}</span>
|
|
131
|
-
<span class="maz:text-base">{{ flag }}</span>
|
|
132
|
-
<span class="maz:text-lg">{{ flag }}</span>
|
|
133
|
-
<span class="maz:text-xl">{{ flag }}</span>
|
|
134
|
-
<span class="maz:text-2xl">{{ flag }}</span>
|
|
135
|
-
<span class="maz:text-3xl">{{ flag }}</span>
|
|
136
|
-
<span class="maz:text-4xl">{{ flag }}</span>
|
|
137
|
-
<span class="maz:text-5xl">{{ flag }}</span>
|
|
138
|
-
<span class="maz:text-6xl">{{ flag }}</span>
|
|
139
|
-
<span class="maz:text-7xl">{{ flag }}</span>
|
|
140
|
-
</div>
|
|
141
|
-
|
|
142
|
-
<MazSelect
|
|
143
|
-
v-model="countryCode"
|
|
144
|
-
:options="countryOptions"
|
|
145
|
-
label="Select country"
|
|
146
|
-
search
|
|
147
|
-
search-placeholder="Search country"
|
|
148
|
-
@selected-option="(option) => console.log('option', option)"
|
|
149
|
-
>
|
|
150
|
-
<template #default="{ option, isSelected }">
|
|
151
|
-
<div
|
|
152
|
-
class="maz:flex maz:items-center maz:gap-3"
|
|
153
|
-
>
|
|
154
|
-
<span class="maz:text-lg">
|
|
155
|
-
{{ option.unicodeFlag }}
|
|
156
|
-
</span>
|
|
157
|
-
<MazBadge
|
|
158
|
-
pastel
|
|
159
|
-
size="0.7rem"
|
|
160
|
-
class="maz:w-9"
|
|
161
|
-
:class="{ 'maz:text-muted': !isSelected }"
|
|
162
|
-
>
|
|
163
|
-
{{ option.value }}
|
|
164
|
-
</MazBadge>
|
|
165
|
-
<span :class="{ 'maz:font-semibold': isSelected }">
|
|
166
|
-
{{ option.label }}
|
|
167
|
-
</span>
|
|
168
|
-
</div>
|
|
169
|
-
</template>
|
|
170
|
-
</MazSelect>
|
|
171
|
-
</template>
|
|
172
|
-
|
|
173
|
-
<script lang="ts" setup>
|
|
174
|
-
import { computed, ref, onMounted } from 'vue'
|
|
175
|
-
import { countryCodeToUnicodeFlag } from '@maz-ui/utils'
|
|
176
|
-
import { getCountries } from 'libphonenumber-js'
|
|
177
|
-
|
|
178
|
-
const countryCode = ref('FR')
|
|
179
|
-
const flag = computed(() => countryCodeToUnicodeFlag(countryCode.value))
|
|
180
|
-
|
|
181
|
-
const countryOptions = ref(getCountriesList())
|
|
182
|
-
|
|
183
|
-
onMounted(() => {
|
|
184
|
-
const listOfCountries = getCountriesList(window.navigator.language)
|
|
185
|
-
if (listOfCountries.length > 1) {
|
|
186
|
-
countryOptions.value = listOfCountries
|
|
187
|
-
}
|
|
188
|
-
})
|
|
189
|
-
|
|
190
|
-
function getCountriesList(
|
|
191
|
-
locale?: string,
|
|
192
|
-
) {
|
|
193
|
-
const countriesList = []
|
|
194
|
-
const isoList = getCountries()
|
|
195
|
-
|
|
196
|
-
for (const iso2 of isoList) {
|
|
197
|
-
const name = new Intl.DisplayNames([locale ?? 'en-US'], { type: 'region' }).of(iso2)
|
|
198
|
-
|
|
199
|
-
if (name) {
|
|
200
|
-
countriesList.push({
|
|
201
|
-
value: iso2,
|
|
202
|
-
label: name,
|
|
203
|
-
unicodeFlag: countryCodeToUnicodeFlag(iso2)
|
|
204
|
-
})
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
return countriesList
|
|
209
|
-
}
|
|
210
|
-
</script>
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
:::
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: debounceCallback
|
|
3
|
-
description: Module-scoped one-shot debounce — schedule a callback that gets reset on each new call.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# {{ $frontmatter.title }}
|
|
7
|
-
|
|
8
|
-
{{ $frontmatter.description }}
|
|
9
|
-
|
|
10
|
-
Unlike [`debounce`](./debounce), 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.
|
|
11
|
-
|
|
12
|
-
::: warning Shared module state
|
|
13
|
-
`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) for isolated debounces.
|
|
14
|
-
:::
|
|
15
|
-
|
|
16
|
-
## Usage
|
|
17
|
-
|
|
18
|
-
```ts
|
|
19
|
-
import { debounceCallback } from '@maz-ui/utils'
|
|
20
|
-
|
|
21
|
-
debounceCallback(() => {
|
|
22
|
-
console.log('runs only if no other call happens in the next 300 ms')
|
|
23
|
-
}, 300)
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## API
|
|
27
|
-
|
|
28
|
-
```ts
|
|
29
|
-
function debounceCallback(
|
|
30
|
-
callback: (...args: unknown[]) => unknown,
|
|
31
|
-
delay: number,
|
|
32
|
-
): void
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
| Parameter | Type | Description |
|
|
36
|
-
| ---------- | ---------- | ------------------------------------------ |
|
|
37
|
-
| `callback` | `Function` | Function to run after the quiet window |
|
|
38
|
-
| `delay` | `number` | Quiet window before firing, in milliseconds |
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: fetchLocaleIp
|
|
3
|
-
description: Resolve the visitor's ISO country code from their IP address using the free `ipwho.is` service.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# {{ $frontmatter.title }}
|
|
7
|
-
|
|
8
|
-
{{ $frontmatter.description }}
|
|
9
|
-
|
|
10
|
-
Useful for pre-filling locale-aware UI — phone-number country selectors, currency hints, default language — before the user has interacted with the page.
|
|
11
|
-
|
|
12
|
-
## Usage
|
|
13
|
-
|
|
14
|
-
```ts
|
|
15
|
-
import { fetchLocaleIp } from '@maz-ui/utils'
|
|
16
|
-
|
|
17
|
-
const countryCode = await fetchLocaleIp()
|
|
18
|
-
// 'FR' | 'US' | … or undefined if the request fails
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## API
|
|
22
|
-
|
|
23
|
-
```ts
|
|
24
|
-
function fetchLocaleIp(): Promise<string | undefined>
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
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.
|
|
28
|
-
|
|
29
|
-
## Notes
|
|
30
|
-
|
|
31
|
-
- Hits `https://ipwho.is` — a public, no-key service. Consider rate limits and privacy for production usage.
|
|
32
|
-
- Returns `undefined` rather than throwing so a fallback path (default locale, manual selection) can be wired without `try/catch`.
|
|
33
|
-
- For a static locale source, see [`getBrowserLocale`](./get-browser-locale).
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: getBrowserLocale
|
|
3
|
-
description: Read the user's browser language tag (e.g. `'fr-FR'`, `'en-US'`) — returns `undefined` on the server.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# {{ $frontmatter.title }}
|
|
7
|
-
|
|
8
|
-
{{ $frontmatter.description }}
|
|
9
|
-
|
|
10
|
-
## Usage
|
|
11
|
-
|
|
12
|
-
```ts
|
|
13
|
-
import { getBrowserLocale } from '@maz-ui/utils'
|
|
14
|
-
|
|
15
|
-
const locale = getBrowserLocale() // 'fr-FR' | 'en-US' | … | undefined
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## API
|
|
19
|
-
|
|
20
|
-
```ts
|
|
21
|
-
function getBrowserLocale(): string | undefined
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Returns `navigator.language` on the client. On the server (no `navigator`), returns `undefined`.
|
|
25
|
-
|
|
26
|
-
## Notes
|
|
27
|
-
|
|
28
|
-
- For IP-based country detection instead of the browser-declared locale, see [`fetchLocaleIp`](./fetch-locale-ip).
|
|
29
|
-
- The returned tag follows [BCP 47](https://www.rfc-editor.org/info/bcp47).
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: getCountryFlagUrl
|
|
3
|
-
description: Get country flag from flagcdn.com with a simple function call
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# {{ $frontmatter.title }}
|
|
7
|
-
|
|
8
|
-
{{ $frontmatter.description }}
|
|
9
|
-
|
|
10
|
-
<MazSelect
|
|
11
|
-
v-model="countryCode"
|
|
12
|
-
:options="countryOptions"
|
|
13
|
-
label="Select country"
|
|
14
|
-
search
|
|
15
|
-
search-placeholder="Search country"
|
|
16
|
-
@selected-option="(option) => console.log('option', option)"
|
|
17
|
-
>
|
|
18
|
-
<template #default="{ option, isSelected }">
|
|
19
|
-
<div
|
|
20
|
-
class="maz:flex maz:items-center maz:gap-3"
|
|
21
|
-
>
|
|
22
|
-
<img :src="option.flagSrc" class="maz:text-lg" :alt="`Flag of ${option.label}`" />
|
|
23
|
-
<MazBadge
|
|
24
|
-
pastel
|
|
25
|
-
size="0.7rem"
|
|
26
|
-
class="maz:w-9"
|
|
27
|
-
:class="{ 'maz:text-muted': !isSelected }"
|
|
28
|
-
>
|
|
29
|
-
{{ option.value }}
|
|
30
|
-
</MazBadge>
|
|
31
|
-
<span :class="{ 'maz:font-semibold': isSelected }">
|
|
32
|
-
{{ option.label }}
|
|
33
|
-
</span>
|
|
34
|
-
</div>
|
|
35
|
-
</template>
|
|
36
|
-
</MazSelect>
|
|
37
|
-
|
|
38
|
-
## Basic usage
|
|
39
|
-
|
|
40
|
-
<img :src="flagSrc" alt="Flag of France" />
|
|
41
|
-
|
|
42
|
-
```vue
|
|
43
|
-
<template>
|
|
44
|
-
<img :src="flagSrc" alt="Flag of France" />
|
|
45
|
-
</template>
|
|
46
|
-
|
|
47
|
-
<script lang="ts" setup >
|
|
48
|
-
import { getCountryFlagUrl } from '@maz-ui/utils'
|
|
49
|
-
|
|
50
|
-
const flagSrc = getCountryFlagUrl('FR')
|
|
51
|
-
</script>
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## Sizing
|
|
55
|
-
|
|
56
|
-
<div class="maz:gap-2 maz:flex maz:flex-wrap maz:items-center">
|
|
57
|
-
<img
|
|
58
|
-
v-for="{ src, size, countryCode } in sizedFlags"
|
|
59
|
-
:key="src"
|
|
60
|
-
:src="src"
|
|
61
|
-
:alt="`${countryCode} Flag`"
|
|
62
|
-
/>
|
|
63
|
-
</div>
|
|
64
|
-
|
|
65
|
-
::: details Show full code
|
|
66
|
-
|
|
67
|
-
```vue
|
|
68
|
-
<template>
|
|
69
|
-
<img
|
|
70
|
-
v-for="{ src, size, countryCode } in sizedFlags"
|
|
71
|
-
:key="src"
|
|
72
|
-
:src="src"
|
|
73
|
-
:alt="`${countryCode} Flag`"
|
|
74
|
-
/>
|
|
75
|
-
</template>
|
|
76
|
-
|
|
77
|
-
<script lang="ts" setup>
|
|
78
|
-
import { computed } from 'vue'
|
|
79
|
-
import { getCountryFlagUrl } from '@maz-ui/utils'
|
|
80
|
-
|
|
81
|
-
const countryCode = ref('FR')
|
|
82
|
-
|
|
83
|
-
const sizedFlags = computed(() => {
|
|
84
|
-
const sizes: Size[] = [
|
|
85
|
-
'16x12',
|
|
86
|
-
'20x15',
|
|
87
|
-
'24x18',
|
|
88
|
-
'80x60',
|
|
89
|
-
'h80',
|
|
90
|
-
'w160',
|
|
91
|
-
]
|
|
92
|
-
|
|
93
|
-
return sizes.map(size => ({
|
|
94
|
-
src: getCountryFlagUrl(countryCode.value, size),
|
|
95
|
-
size: size,
|
|
96
|
-
countryCode: countryCode.value
|
|
97
|
-
}))
|
|
98
|
-
})
|
|
99
|
-
</script>
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
:::
|
|
103
|
-
|
|
104
|
-
<script lang="ts" setup>
|
|
105
|
-
import { computed, ref, onMounted } from 'vue'
|
|
106
|
-
import { getCountryFlagUrl } from '@maz-ui/utils'
|
|
107
|
-
import { getCountries } from 'libphonenumber-js'
|
|
108
|
-
|
|
109
|
-
const countryCode = ref('FR')
|
|
110
|
-
const flagSrc = computed(() => getCountryFlagUrl(countryCode.value))
|
|
111
|
-
|
|
112
|
-
const sizedFlags = computed(() => {
|
|
113
|
-
const sizes: Size[] = [
|
|
114
|
-
'16x12',
|
|
115
|
-
'20x15',
|
|
116
|
-
'24x18',
|
|
117
|
-
'80x60',
|
|
118
|
-
'h80',
|
|
119
|
-
'w160',
|
|
120
|
-
]
|
|
121
|
-
|
|
122
|
-
return sizes.map(size => ({
|
|
123
|
-
src: getCountryFlagUrl(countryCode.value, size),
|
|
124
|
-
size: size,
|
|
125
|
-
countryCode: countryCode.value
|
|
126
|
-
}))
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
const countryOptions = ref(getCountriesList())
|
|
130
|
-
|
|
131
|
-
onMounted(() => {
|
|
132
|
-
const listOfCountries = getCountriesList(window.navigator.language)
|
|
133
|
-
if (listOfCountries.length > 1) {
|
|
134
|
-
countryOptions.value = listOfCountries
|
|
135
|
-
}
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
function getCountriesList(locale?: string) {
|
|
139
|
-
const countriesList = []
|
|
140
|
-
const isoList = getCountries()
|
|
141
|
-
|
|
142
|
-
for (const iso2 of isoList) {
|
|
143
|
-
const name = new Intl.DisplayNames([locale ?? 'en-US'], { type: 'region' }).of(iso2)
|
|
144
|
-
|
|
145
|
-
if (name) {
|
|
146
|
-
countriesList.push({
|
|
147
|
-
value: iso2,
|
|
148
|
-
label: name,
|
|
149
|
-
flagSrc: getCountryFlagUrl(iso2)
|
|
150
|
-
})
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return countriesList
|
|
155
|
-
}
|
|
156
|
-
</script>
|
|
@@ -1,31 +0,0 @@
|
|
|
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.
|
|
@@ -1,43 +0,0 @@
|
|
|
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
|
-
```
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: truthyFilter
|
|
3
|
-
description: Type guard that filters out falsy values (`false`, `''`, `0`, `null`, `undefined`) while narrowing the TypeScript type.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# {{ $frontmatter.title }}
|
|
7
|
-
|
|
8
|
-
{{ $frontmatter.description }}
|
|
9
|
-
|
|
10
|
-
Pass it directly to `Array.prototype.filter` to drop nullish/empty entries while telling TypeScript the result no longer contains those types.
|
|
11
|
-
|
|
12
|
-
## Usage
|
|
13
|
-
|
|
14
|
-
```ts
|
|
15
|
-
import { truthyFilter } from '@maz-ui/utils'
|
|
16
|
-
|
|
17
|
-
const items: (string | null | undefined)[] = ['a', null, 'b', undefined, '']
|
|
18
|
-
const cleaned = items.filter(truthyFilter)
|
|
19
|
-
// cleaned has type string[]
|
|
20
|
-
// cleaned = ['a', 'b']
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## API
|
|
24
|
-
|
|
25
|
-
```ts
|
|
26
|
-
type Truthy<T> = T extends false | '' | 0 | null | undefined ? never : T
|
|
27
|
-
|
|
28
|
-
function truthyFilter<T>(value: T): value is Truthy<T>
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
The function returns `Boolean(value)` — its real value is in the type predicate, which narrows away the falsy variants for downstream type-checking.
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: DeepRequired
|
|
3
|
-
description: Recursive variant of TypeScript's `Required<T>` — strips `?` from every property at every depth.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# {{ $frontmatter.title }}
|
|
7
|
-
|
|
8
|
-
{{ $frontmatter.description }}
|
|
9
|
-
|
|
10
|
-
The mirror image of [`DeepPartial`](./deep-partial). Useful when you want a fully-resolved internal type derived from a public options interface.
|
|
11
|
-
|
|
12
|
-
## Usage
|
|
13
|
-
|
|
14
|
-
```ts
|
|
15
|
-
import type { DeepRequired } from '@maz-ui/utils'
|
|
16
|
-
|
|
17
|
-
interface Options {
|
|
18
|
-
cache?: {
|
|
19
|
-
ttl?: number
|
|
20
|
-
strategy?: 'memory' | 'disk'
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
type ResolvedOptions = DeepRequired<Options>
|
|
25
|
-
// {
|
|
26
|
-
// cache: {
|
|
27
|
-
// ttl: number
|
|
28
|
-
// strategy: 'memory' | 'disk'
|
|
29
|
-
// }
|
|
30
|
-
// }
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## API
|
|
34
|
-
|
|
35
|
-
```ts
|
|
36
|
-
type DeepRequired<T> = Required<{
|
|
37
|
-
[K in keyof T]: T[K] extends Required<T[K]> ? T[K] : DeepRequired<T[K]>
|
|
38
|
-
}>
|
|
39
|
-
```
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: FlattenObjectKeys
|
|
3
|
-
description: Build a union of dot-separated leaf paths for a nested object, with an optional prefix.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# {{ $frontmatter.title }}
|
|
7
|
-
|
|
8
|
-
{{ $frontmatter.description }}
|
|
9
|
-
|
|
10
|
-
Similar to [`DeepKeyOf`](./deep-key-of) but only yields **leaf** paths (skips intermediate object keys), and accepts a `Prefix` parameter for namespacing.
|
|
11
|
-
|
|
12
|
-
## Usage
|
|
13
|
-
|
|
14
|
-
```ts
|
|
15
|
-
import type { FlattenObjectKeys } from '@maz-ui/utils'
|
|
16
|
-
|
|
17
|
-
interface Config {
|
|
18
|
-
app: {
|
|
19
|
-
name: string
|
|
20
|
-
version: number
|
|
21
|
-
}
|
|
22
|
-
debug: boolean
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
type Leaves = FlattenObjectKeys<Config>
|
|
26
|
-
// → 'app.name' | 'app.version' | 'debug'
|
|
27
|
-
|
|
28
|
-
type Namespaced = FlattenObjectKeys<Config, 'config.'>
|
|
29
|
-
// → 'config.app.name' | 'config.app.version' | 'config.debug'
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## API
|
|
33
|
-
|
|
34
|
-
```ts
|
|
35
|
-
type FlattenObjectKeys<T extends Record<string, any>, Prefix extends string = ''> = {
|
|
36
|
-
[K in keyof T]: T[K] extends Record<string, any>
|
|
37
|
-
? FlattenObjectKeys<T[K], `${Prefix}${K extends string ? K : ''}.`>
|
|
38
|
-
: `${Prefix}${K extends string ? K : ''}`
|
|
39
|
-
}[keyof T]
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Notes
|
|
43
|
-
|
|
44
|
-
- Unlike `DeepKeyOf`, intermediate object keys (e.g. `'app'` in the example) are not included — only the paths that resolve to non-object leaves.
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: upperFirst
|
|
3
|
-
description: Uppercase the first character of a string and leave the rest unchanged.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# {{ $frontmatter.title }}
|
|
7
|
-
|
|
8
|
-
{{ $frontmatter.description }}
|
|
9
|
-
|
|
10
|
-
## Usage
|
|
11
|
-
|
|
12
|
-
```ts
|
|
13
|
-
import { upperFirst } from '@maz-ui/utils'
|
|
14
|
-
|
|
15
|
-
upperFirst('hello') // → 'Hello'
|
|
16
|
-
upperFirst('hELLO') // → 'HELLO'
|
|
17
|
-
upperFirst('') // → ''
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## API
|
|
21
|
-
|
|
22
|
-
```ts
|
|
23
|
-
function upperFirst(value: string): string
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
| Parameter | Type | Description |
|
|
27
|
-
| --------- | -------- | --------------------- |
|
|
28
|
-
| `value` | `string` | The string to process |
|
|
29
|
-
|
|
30
|
-
## Notes
|
|
31
|
-
|
|
32
|
-
- Does **not** lowercase the remaining characters — use [`capitalize`](./capitalize) for the same behaviour when you control the input shape.
|