@sankyu/vue-circle-flags 0.0.1 → 0.0.2-beta

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 CHANGED
@@ -1,21 +1,229 @@
1
+ <div align="center">
2
+ <a href="https://react-circle-flags.js.org/">
3
+ <img src="https://raw.githubusercontent.com/SanKyu-Lab/react-circle-flags/main/website/public/favicon.svg" alt="@sankyu/vue-circle-flags" width="120" height="120" />
4
+ </a>
5
+ </div>
6
+
7
+ <div align="center">
8
+
1
9
  # @sankyu/vue-circle-flags
2
10
 
3
- > 🚧 **Working towards Multi-Framework support!** See our [Roadmap Issue](https://github.com/SanKyu-Lab/circle-flags-ui/issues/14) for details.
11
+ [![npm version](https://img.shields.io/npm/v/%40sankyu%2Fvue-circle-flags?style=flat-square&label=%40sankyu%2Fvue-circle-flags)](https://www.npmjs.com/package/@sankyu/vue-circle-flags) [![Bundle Size](https://img.shields.io/bundlephobia/minzip/@sankyu/vue-circle-flags?style=flat-square&label=Bundle%20Size)](https://bundlephobia.com/package/@sankyu/vue-circle-flags) [![npm downloads](https://img.shields.io/npm/dm/@sankyu/vue-circle-flags.svg?style=flat-square&label=NPM%20Downloads)](https://www.npmjs.com/package/@sankyu/vue-circle-flags) [![Last Commit](https://img.shields.io/github/last-commit/SanKyu-Lab/react-circle-flags?style=flat-square&label=Last%20Commit)](https://github.com/SanKyu-Lab/react-circle-flags/commits/main)
12
+
13
+ <!-- CI/CD & Quality -->
14
+
15
+ [![CI](https://github.com/SanKyu-Lab/react-circle-flags/actions/workflows/ci.yml/badge.svg)](https://github.com/SanKyu-Lab/react-circle-flags/actions/workflows/ci.yml) [![Release](https://github.com/SanKyu-Lab/react-circle-flags/actions/workflows/release.yml/badge.svg)](https://github.com/SanKyu-Lab/react-circle-flags/actions/workflows/release.yml) [![codecov](https://codecov.io/gh/SanKyu-Lab/react-circle-flags/branch/main/graph/badge.svg?token=YHZ46T51AG)](https://codecov.io/gh/SanKyu-Lab/react-circle-flags)
16
+
17
+ [![TypeScript supported](https://img.shields.io/badge/TypeScript-supported-blue?style=flat-square&logo=typescript)](https://www.typescriptlang.org/) [![Tree-shakable](https://badgen.net/bundlephobia/tree-shaking/@sankyu/vue-circle-flags)](https://bundlephobia.com/package/@sankyu/vue-circle-flags) [![MIT License](https://img.shields.io/badge/License-MIT-green?style=flat-square&logo=opensourceinitiative)](./LICENSE)
18
+
19
+ ---
20
+
21
+ English Version | [简体中文](./README.zh.md)
22
+
23
+ :star: **Star us on [GitHub](https://github.com/Sankyu-Lab/react-circle-flags)** | :bug: **Report Issues [here](https://github.com/Sankyu-Lab/react-circle-flags/issues)**
24
+
25
+ :rocket: **Explore the [Demo Gallery](https://react-circle-flags.js.org/browse)** | :book: **Read the [Documentation](https://react-circle-flags.js.org/docs/guides/getting-started/)**
26
+
27
+ </div>
28
+
29
+ ---
30
+
31
+ > [!NOTE]
32
+ > 🚧 **Beta Release**
33
+ >
34
+ > This package is currently in beta. APIs may change in future releases. Please report any issues you encounter!
35
+
36
+ ## 📖 Overview
37
+
38
+ This library provides **400+ circular SVG flag components** for Vue 3 with **Full-TypeScript support** & **Tree-shaking Optimization**.
39
+
40
+ Perfect for applications that need fast, crisp country flags without external image requests.
41
+
42
+ ## ✨ Key Features
43
+
44
+ - 🎯 **Tree-shakable** - Only bundle the flags you use
45
+ - 📦 **TypeScript** - Full type definitions included
46
+ - ⚡ **Zero dependencies** - Only requires Vue 3 as peer dependency
47
+ - 🎨 **Inline SVG** - No external requests, works offline
48
+ - 🔧 **Fully customizable** - All standard SVG props supported
49
+ - 📱 **SSR compatible** - Works with `Nuxt.js`, `Quasar`, etc.
50
+ - 🪶 **Lightweight** - Each flag is ~1KB
51
+
52
+ ## 📦 Installation
53
+
54
+ ```bash
55
+ npm install @sankyu/vue-circle-flags
56
+ # or
57
+ pnpm add @sankyu/vue-circle-flags
58
+ # or
59
+ yarn add @sankyu/vue-circle-flags
60
+ # or
61
+ bun add @sankyu/vue-circle-flags
62
+ ```
63
+
64
+ ## 🚀 Usage
65
+
66
+ ### Import individual flags (Recommended)
67
+
68
+ ```vue
69
+ <script setup lang="ts">
70
+ import { FlagUs, FlagCn, FlagGb } from '@sankyu/vue-circle-flags'
71
+ </script>
72
+
73
+ <template>
74
+ <div>
75
+ <FlagUs :width="48" :height="48" />
76
+ <FlagCn :width="48" :height="48" />
77
+ <FlagGb :width="48" :height="48" />
78
+ </div>
79
+ </template>
80
+ ```
81
+
82
+ ### Using with size prop
83
+
84
+ ```vue
85
+ <script setup lang="ts">
86
+ import { FlagJp, FlagDe, FlagFr } from '@sankyu/vue-circle-flags'
87
+ </script>
88
+
89
+ <template>
90
+ <div>
91
+ <FlagJp size="sm" />
92
+ <!-- 16px -->
93
+ <FlagDe size="md" />
94
+ <!-- 24px -->
95
+ <FlagFr size="lg" />
96
+ <!-- 32px -->
97
+ </div>
98
+ </template>
99
+ ```
100
+
101
+ ### Dynamic flag selection
102
+
103
+ ```vue
104
+ <script setup lang="ts">
105
+ import { ref, computed, defineAsyncComponent } from 'vue'
106
+
107
+ const countryCode = ref('us')
108
+
109
+ const FlagComponent = computed(() => {
110
+ const code = countryCode.value.toLowerCase()
111
+ const componentName = `Flag${code.charAt(0).toUpperCase()}${code.slice(1)}`
112
+ return defineAsyncComponent(() =>
113
+ import('@sankyu/vue-circle-flags').then(module => module[componentName])
114
+ )
115
+ })
116
+ </script>
117
+
118
+ <template>
119
+ <component :is="FlagComponent" :width="48" :height="48" />
120
+ </template>
121
+ ```
122
+
123
+ ## 📚 API
124
+
125
+ ### Props
126
+
127
+ | Prop | Type | Default | Description |
128
+ | -------- | ----------------------------------------------- | ------- | ---------------------------- |
129
+ | `width` | `number \| string` | `32` | Width of the flag |
130
+ | `height` | `number \| string` | `32` | Height of the flag |
131
+ | `size` | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl' \| '2xl'` | - | Preset size |
132
+ | `title` | `string` | - | Accessible title for the SVG |
133
+
134
+ ### Size Presets
135
+
136
+ | Size | Pixels |
137
+ | ----- | ------ |
138
+ | `xs` | 12px |
139
+ | `sm` | 16px |
140
+ | `md` | 24px |
141
+ | `lg` | 32px |
142
+ | `xl` | 48px |
143
+ | `2xl` | 64px |
144
+
145
+ ### Build Meta Information
146
+
147
+ You can access the library's build meta information from the `buildMeta` export:
148
+
149
+ ```vue
150
+ <script setup lang="ts">
151
+ import { buildMeta } from '@sankyu/vue-circle-flags'
152
+
153
+ console.log(buildMeta.version) // e.g., "0.0.1"
154
+ console.log(buildMeta.builtTimestamp) // e.g., 1760000000000
155
+ console.log(buildMeta.commitHash) // e.g., <example-sha256-hash>
156
+ console.log(buildMeta.circleFlagsCommitHash) // e.g., <example-sha256-hash>
157
+ </script>
158
+ ```
159
+
160
+ ### Available Flags
161
+
162
+ Each flag is exported with the pattern `Flag{PascalCase ISO_CODE}` (for example, `FlagUs`, `FlagCn`). Convenience aliases are provided for common two-letter codes: `FlagUs`, `FlagCn`, `FlagGb`, `FlagJp`.
163
+
164
+ - `FlagUs` - United States
165
+ - `FlagCn` - China
166
+ - `FlagGb` - United Kingdom
167
+ - `FlagJp` - Japan
168
+ - ... and many more
169
+
170
+ See the [Full list of flags](https://react-circle-flags.js.org/browse) in the gallery.
171
+
172
+ ## 🎨 Styling
173
+
174
+ Flag components accept all standard SVG attributes and can be styled using Vue's class and style bindings.
175
+
176
+ ```vue
177
+ <script setup lang="ts">
178
+ import { FlagUs } from '@sankyu/vue-circle-flags'
179
+ </script>
180
+
181
+ <template>
182
+ <!-- Using class -->
183
+ <FlagUs class="rounded-full shadow-lg hover:scale-110 transition-transform" />
184
+
185
+ <!-- Using inline styles -->
186
+ <FlagUs :style="{ filter: 'grayscale(100%)' }" />
187
+
188
+ <!-- With custom attributes -->
189
+ <FlagUs aria-label="United States flag" role="img" />
190
+ </template>
191
+ ```
192
+
193
+ ## 🔧 TypeScript
194
+
195
+ All flag components are fully typed with TypeScript, providing autocomplete and type safety out of the box.
196
+
197
+ ```typescript
198
+ import type { FlagComponentProps, FlagCode } from '@sankyu/vue-circle-flags'
199
+
200
+ // FlagCode is a union type of all valid flag codes
201
+ const code: FlagCode = 'us' // ✓ Valid
202
+ const invalid: FlagCode = 'xyz' // ✗ Type error
203
+ ```
204
+
205
+ ## 📦 Bundle Size & Tree-shaking
206
+
207
+ `@sankyu/vue-circle-flags` is designed to be tree-shakable.
208
+
209
+ Importing individual flags ensures that only the used flags are included in your bundle.
4
210
 
5
- Vue 3 bindings for circle-flags. Coming soon!
211
+ ```vue
212
+ <script setup lang="ts">
213
+ // ✓ Good - only FlagUs and FlagCn are bundled
214
+ import { FlagUs, FlagCn } from '@sankyu/vue-circle-flags'
215
+ </script>
216
+ ```
6
217
 
7
- ## Status
218
+ ## 🤝 Contributing
8
219
 
9
- This package is currently under development. See [@sankyu/react-circle-flags](https://www.npmjs.com/package/@sankyu/react-circle-flags) for the React version.
220
+ Please see [CONTRIBUTING.md](CONTRIBUTING.md) for contribution guidelines.
10
221
 
11
- ## Planned Features
222
+ ## 📄 License
12
223
 
13
- - 400+ circular SVG flag components
14
- - Tree-shakeable exports
15
- - Full TypeScript support
16
- - SSR compatible (Nuxt.js support)
17
- - Zero runtime dependencies
224
+ `@sankyu/vue-circle-flags` is licensed under the MIT License, © [Sankyu Lab](https://github.com/Sankyu-Lab)
18
225
 
19
- ## Contributing
226
+ ## 🙏 Credits
20
227
 
21
- We welcome contributions! If you're interested in helping build this package, please check out our [contribution guidelines](https://github.com/SanKyu-Lab/circle-flags-ui/blob/main/CONTRIBUTING.md).
228
+ - Flag designs from [HatScripts/circle-flags](https://github.com/HatScripts/circle-flags)
229
+ - Built with [tsup](https://github.com/egoist/tsup)
package/README.zh.md ADDED
@@ -0,0 +1,229 @@
1
+ <div align="center">
2
+ <a href="https://react-circle-flags.js.org/">
3
+ <img src="https://raw.githubusercontent.com/SanKyu-Lab/react-circle-flags/main/website/public/favicon.svg" alt="@sankyu/vue-circle-flags" width="120" height="120" />
4
+ </a>
5
+ </div>
6
+
7
+ <div align="center">
8
+
9
+ # @sankyu/vue-circle-flags
10
+
11
+ [![npm 版本](https://img.shields.io/npm/v/%40sankyu%2Fvue-circle-flags?style=flat-square&label=%40sankyu%2Fvue-circle-flags)](https://www.npmjs.com/package/@sankyu/vue-circle-flags) [![打包大小](https://img.shields.io/bundlephobia/minzip/@sankyu/vue-circle-flags?style=flat-square&label=打包大小)](https://bundlephobia.com/package/@sankyu/vue-circle-flags) [![npm 下载量](https://img.shields.io/npm/dm/@sankyu/vue-circle-flags.svg?style=flat-square&label=NPM%20下载量)](https://www.npmjs.com/package/@sankyu/vue-circle-flags) [![最后提交](https://img.shields.io/github/last-commit/SanKyu-Lab/react-circle-flags?style=flat-square&label=最后提交)](https://github.com/SanKyu-Lab/react-circle-flags/commits/main)
12
+
13
+ <!-- CI/CD 与质量 -->
14
+
15
+ [![CI](https://github.com/SanKyu-Lab/react-circle-flags/actions/workflows/ci.yml/badge.svg)](https://github.com/SanKyu-Lab/react-circle-flags/actions/workflows/ci.yml) [![发布](https://github.com/SanKyu-Lab/react-circle-flags/actions/workflows/release.yml/badge.svg)](https://github.com/SanKyu-Lab/react-circle-flags/actions/workflows/release.yml) [![codecov](https://codecov.io/gh/SanKyu-Lab/react-circle-flags/branch/main/graph/badge.svg?token=YHZ46T51AG)](https://codecov.io/gh/SanKyu-Lab/react-circle-flags)
16
+
17
+ [![支持 TypeScript](https://img.shields.io/badge/TypeScript-支持-blue?style=flat-square&logo=typescript)](https://www.typescriptlang.org/) [![Tree-shakable](https://badgen.net/bundlephobia/tree-shaking/@sankyu/vue-circle-flags)](https://bundlephobia.com/package/@sankyu/vue-circle-flags) [![MIT 许可证](https://img.shields.io/badge/许可证-MIT-green?style=flat-square&logo=opensourceinitiative)](./LICENSE)
18
+
19
+ ---
20
+
21
+ 简体中文 | [English Version](./README.md)
22
+
23
+ :star: **在 [GitHub](https://github.com/Sankyu-Lab/react-circle-flags) 上 Star 我们** | :bug: **在此 [提交问题](https://github.com/Sankyu-Lab/react-circle-flags/issues)**
24
+
25
+ :rocket: **探索 [演示图库](https://react-circle-flags.js.org/browse)** | :book: **[阅读文档](https://react-circle-flags.js.org/docs/guides/getting-started/)**
26
+
27
+ </div>
28
+
29
+ ---
30
+
31
+ > [!NOTE]
32
+ > 🚧 **Beta 版本**
33
+ >
34
+ > 此包目前处于 Beta 阶段。API 可能会在未来版本中发生变化。如遇任何问题,请及时反馈!
35
+
36
+ ## 📖 概述
37
+
38
+ 本库为 Vue 3 提供 **400+ 个圆形 SVG 国旗组件**,具备 **完整的 TypeScript 支持** 以及 **Tree-shaking 优化**。
39
+
40
+ 专为需要快速、清晰显示国旗且无需外部图片请求的应用而设计。
41
+
42
+ ## ✨ 核心特性
43
+
44
+ - 🎯 **支持 Tree-shaking 优化** - 仅打包您使用的国旗
45
+ - 📦 **TypeScript** - 包含完整的类型定义
46
+ - ⚡ **零依赖** - 仅需 Vue 3 作为对等依赖
47
+ - 🎨 **内联 SVG** - 无需外部请求,支持离线使用
48
+ - 🔧 **完全可定制** - 支持所有标准 SVG 属性
49
+ - 📱 **SSR 兼容** - 适用于 `Nuxt.js`、`Quasar` 等框架
50
+ - 🪶 **轻量级** - 每个国旗约 1KB
51
+
52
+ ## 📦 安装
53
+
54
+ ```bash
55
+ npm install @sankyu/vue-circle-flags
56
+ # 或
57
+ pnpm add @sankyu/vue-circle-flags
58
+ # 或
59
+ yarn add @sankyu/vue-circle-flags
60
+ # 或
61
+ bun add @sankyu/vue-circle-flags
62
+ ```
63
+
64
+ ## 🚀 使用
65
+
66
+ ### 导入单个国旗(推荐)
67
+
68
+ ```vue
69
+ <script setup lang="ts">
70
+ import { FlagUs, FlagCn, FlagGb } from '@sankyu/vue-circle-flags'
71
+ </script>
72
+
73
+ <template>
74
+ <div>
75
+ <FlagUs :width="48" :height="48" />
76
+ <FlagCn :width="48" :height="48" />
77
+ <FlagGb :width="48" :height="48" />
78
+ </div>
79
+ </template>
80
+ ```
81
+
82
+ ### 使用 size 属性
83
+
84
+ ```vue
85
+ <script setup lang="ts">
86
+ import { FlagJp, FlagDe, FlagFr } from '@sankyu/vue-circle-flags'
87
+ </script>
88
+
89
+ <template>
90
+ <div>
91
+ <FlagJp size="sm" />
92
+ <!-- 16px -->
93
+ <FlagDe size="md" />
94
+ <!-- 24px -->
95
+ <FlagFr size="lg" />
96
+ <!-- 32px -->
97
+ </div>
98
+ </template>
99
+ ```
100
+
101
+ ### 动态选择国旗
102
+
103
+ ```vue
104
+ <script setup lang="ts">
105
+ import { ref, computed, defineAsyncComponent } from 'vue'
106
+
107
+ const countryCode = ref('us')
108
+
109
+ const FlagComponent = computed(() => {
110
+ const code = countryCode.value.toLowerCase()
111
+ const componentName = `Flag${code.charAt(0).toUpperCase()}${code.slice(1)}`
112
+ return defineAsyncComponent(() =>
113
+ import('@sankyu/vue-circle-flags').then(module => module[componentName])
114
+ )
115
+ })
116
+ </script>
117
+
118
+ <template>
119
+ <component :is="FlagComponent" :width="48" :height="48" />
120
+ </template>
121
+ ```
122
+
123
+ ## 📚 API
124
+
125
+ ### 属性
126
+
127
+ | 属性 | 类型 | 默认值 | 描述 |
128
+ | -------- | ----------------------------------------------- | ------ | ---------------- |
129
+ | `width` | `number \| string` | `32` | 国旗宽度 |
130
+ | `height` | `number \| string` | `32` | 国旗高度 |
131
+ | `size` | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl' \| '2xl'` | - | 预设尺寸 |
132
+ | `title` | `string` | - | SVG 的无障碍标题 |
133
+
134
+ ### 尺寸预设
135
+
136
+ | 尺寸 | 像素 |
137
+ | ----- | ---- |
138
+ | `xs` | 12px |
139
+ | `sm` | 16px |
140
+ | `md` | 24px |
141
+ | `lg` | 32px |
142
+ | `xl` | 48px |
143
+ | `2xl` | 64px |
144
+
145
+ ### 构建元信息
146
+
147
+ 您可以通过 `buildMeta` 导出项访问库的构建元信息:
148
+
149
+ ```vue
150
+ <script setup lang="ts">
151
+ import { buildMeta } from '@sankyu/vue-circle-flags'
152
+
153
+ console.log(buildMeta.version) // 例如:"0.0.1"
154
+ console.log(buildMeta.builtTimestamp) // 例如:1760000000000
155
+ console.log(buildMeta.commitHash) // 例如:<示例-sha256-哈希值>
156
+ console.log(buildMeta.circleFlagsCommitHash) // 例如:<示例-sha256-哈希值>
157
+ </script>
158
+ ```
159
+
160
+ ### 可用的国旗
161
+
162
+ 每个国旗均按 `Flag{帕斯卡命名法 ISO_CODE}` 模式导出(例如 `FlagUs`、`FlagCn`)。为常见的双字母代码提供了便捷别名:`FlagUs`、`FlagCn`、`FlagGb`、`FlagJp`。
163
+
164
+ - `FlagUs` - 美国
165
+ - `FlagCn` - 中国
166
+ - `FlagGb` - 英国
167
+ - `FlagJp` - 日本
168
+ - ... 以及更多
169
+
170
+ 请在图库中查看 [国旗完整列表](https://react-circle-flags.js.org/browse)。
171
+
172
+ ## 🎨 样式
173
+
174
+ 国旗组件接受所有标准 SVG 属性,可使用 Vue 的 class 和 style 绑定轻松设置样式。
175
+
176
+ ```vue
177
+ <script setup lang="ts">
178
+ import { FlagUs } from '@sankyu/vue-circle-flags'
179
+ </script>
180
+
181
+ <template>
182
+ <!-- 使用 class -->
183
+ <FlagUs class="rounded-full shadow-lg hover:scale-110 transition-transform" />
184
+
185
+ <!-- 使用内联样式 -->
186
+ <FlagUs :style="{ filter: 'grayscale(100%)' }" />
187
+
188
+ <!-- 自定义属性 -->
189
+ <FlagUs aria-label="美国国旗" role="img" />
190
+ </template>
191
+ ```
192
+
193
+ ## 🔧 TypeScript
194
+
195
+ 所有国旗组件均使用 TypeScript 完全类型化,开箱即用提供自动完成和类型安全。
196
+
197
+ ```typescript
198
+ import type { FlagComponentProps, FlagCode } from '@sankyu/vue-circle-flags'
199
+
200
+ // FlagCode 是所有有效国旗代码的联合类型
201
+ const code: FlagCode = 'us' // ✓ 有效
202
+ const invalid: FlagCode = 'xyz' // ✗ 类型错误
203
+ ```
204
+
205
+ ## 📦 打包大小与 Tree-shaking 优化
206
+
207
+ `@sankyu/vue-circle-flags` 专为 Tree-shaking 优化而设计。
208
+
209
+ 导入单个国旗可确保只有使用到的国旗被包含在您的打包文件中。
210
+
211
+ ```vue
212
+ <script setup lang="ts">
213
+ // ✓ 推荐 - 仅打包 FlagUs 和 FlagCn
214
+ import { FlagUs, FlagCn } from '@sankyu/vue-circle-flags'
215
+ </script>
216
+ ```
217
+
218
+ ## 🤝 贡献
219
+
220
+ 请参阅 [CONTRIBUTING.md](CONTRIBUTING.md) 了解贡献指南。
221
+
222
+ ## 📄 许可证
223
+
224
+ `@sankyu/vue-circle-flags` 基于 MIT 许可证授权,© [Sankyu Lab](https://github.com/Sankyu-Lab)
225
+
226
+ ## 🙏 致谢
227
+
228
+ - 国旗设计源自 [HatScripts/circle-flags](https://github.com/HatScripts/circle-flags)
229
+ - 使用 [tsup](https://github.com/egoist/tsup) 构建