@nonfx/vue-flagpack 2.0.3 → 2.0.7
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 +35 -13
- package/dist/vue-flag-rollup.cjs.js +1 -1
- package/dist/vue-flag-rollup.esm.js +1 -1
- package/dist/vue-flag-rollup.iife.js +1 -1
- package/package.json +3 -2
- package/src/Flag.vue +7 -4
- package/src/utils.ts +5 -2
package/README.md
CHANGED
|
@@ -133,27 +133,49 @@ app.mount('#app')
|
|
|
133
133
|
|
|
134
134
|
|
|
135
135
|
|
|
136
|
-
## How
|
|
136
|
+
## How Dynamic Loading Works
|
|
137
137
|
|
|
138
|
-
Vue-flagpack uses **dynamic imports
|
|
138
|
+
Vue-flagpack uses **dynamic imports with code-splitting** for efficient flag loading:
|
|
139
139
|
|
|
140
|
-
- **
|
|
141
|
-
- **
|
|
142
|
-
- **
|
|
143
|
-
- **
|
|
140
|
+
- **Dynamic Imports**: The `Flag` component dynamically imports SVG files based on the `code` prop
|
|
141
|
+
- **Code-Splitting**: Modern bundlers (Vite, Webpack 5, Nuxt 3) split flags into separate chunks
|
|
142
|
+
- **Lazy Loading**: Flags are loaded on-demand when the component renders
|
|
143
|
+
- **Cache-Friendly**: Once loaded, flags are cached by the browser
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
### Static vs Dynamic Usage
|
|
146
|
+
|
|
147
|
+
**Static usage (known at build time):**
|
|
148
|
+
```vue
|
|
149
|
+
<Flag code="NL" size="m" />
|
|
150
|
+
<Flag code="US" size="m" />
|
|
151
|
+
```
|
|
152
|
+
Result: Only NL.svg and US.svg might be bundled (depending on bundler optimization)
|
|
153
|
+
|
|
154
|
+
**Dynamic usage (refs/computed/props):**
|
|
155
|
+
```vue
|
|
156
|
+
<Flag :code="selectedCountry" size="m" />
|
|
157
|
+
```
|
|
158
|
+
Result: All flags in the `m` size directory (~750 flags) are included as separate chunks, loaded on-demand
|
|
159
|
+
|
|
160
|
+
**Note:** Because the flag code is determined at runtime, bundlers cannot tree-shake unused flags. However, they are lazy-loaded, so only the flags actually displayed are fetched by the browser.
|
|
146
161
|
|
|
147
162
|
### Bundle Size Comparison
|
|
148
163
|
|
|
149
|
-
- **v1.x
|
|
150
|
-
- **v2.x
|
|
164
|
+
- **v1.x**: ~16MB (all flags bundled together)
|
|
165
|
+
- **v2.x**: ~5KB base + flags as separate chunks
|
|
166
|
+
|
|
167
|
+
**With static usage (code known at build time):**
|
|
168
|
+
- Your bundle = ~5KB base + ~10KB (5 flags) = **~15KB total**
|
|
151
169
|
|
|
152
|
-
|
|
153
|
-
- Your bundle
|
|
154
|
-
-
|
|
170
|
+
**With dynamic usage (code determined at runtime):**
|
|
171
|
+
- Your bundle = ~5KB base + ~17MB (all flags as separate chunks)
|
|
172
|
+
- But only the flags you actually display are loaded by the browser
|
|
173
|
+
- Each flag is ~2-4KB and loaded on-demand
|
|
155
174
|
|
|
156
|
-
|
|
175
|
+
**Recommendation:** For dynamic country selectors with many possible flags, this is optimal because:
|
|
176
|
+
- Users only download the flags they actually see
|
|
177
|
+
- Flags are cached after first load
|
|
178
|
+
- No large initial bundle
|
|
157
179
|
|
|
158
180
|
## Available component configurations — Props
|
|
159
181
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue"),a=require("flagpack-core");const n=["src"];var o=e.defineComponent({__name:"Flag",props:{size:{default:"m"},code:{default:"528"},hasDropShadow:{type:Boolean,default:!1},hasBorder:{type:Boolean,default:!0},hasBorderRadius:{type:Boolean,default:!0},gradient:{default:void 0},className:{default:""}},setup(o){const r=o,t=e.ref(""),d=async()=>{try{const e=(a.isoToCountryCode(r.code)||r.code).toUpperCase(),n=r.size.toLowerCase(),o=await import(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue"),a=require("flagpack-core");const n=["src"];var o=e.defineComponent({__name:"Flag",props:{size:{default:"m"},code:{default:"528"},hasDropShadow:{type:Boolean,default:!1},hasBorder:{type:Boolean,default:!0},hasBorderRadius:{type:Boolean,default:!0},gradient:{default:void 0},className:{default:""}},setup(o){const r=o,t=e.ref(""),d=async()=>{try{const e=(a.isoToCountryCode(r.code)||r.code).toUpperCase(),n=r.size.toLowerCase(),o=(await import(`@nonfx/vue-flagpack/src/flags/${n}/${e}.svg?raw`)).default,d=new Blob([o],{type:"image/svg+xml"});t.value=URL.createObjectURL(d)}catch(e){console.warn(`Flag not found for code: ${r.code}`,e),t.value=""}};return e.onMounted(()=>{d()}),e.watch(()=>[r.code,r.size],()=>{d()}),(a,r)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flag",`size-${o.size}`,{"border-radius":o.hasBorderRadius},{border:o.hasBorder},{"drop-shadow":o.hasDropShadow},o.gradient,o.className])},[t.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:t.value,alt:"flag"},null,8,n)):e.createCommentVNode("",!0)],2))}});async function r(e,n="m"){try{const o=(a.isoToCountryCode(e)||e).toUpperCase(),r=n.toLowerCase(),t=(await import(`@nonfx/vue-flagpack/src/flags/${r}/${o}.svg?raw`)).default,d=new Blob([t],{type:"image/svg+xml"});return URL.createObjectURL(d)}catch(a){return console.warn(`Flag not found for code: ${e}`,a),""}}!function(e,a){void 0===a&&(a={});var n=a.insertAt;if("undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===n&&o.firstChild?o.insertBefore(r,o.firstChild):o.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}('.flag[data-v-c3ae00cc] {\n display: inline-block;\n overflow: hidden;\n position: relative;\n box-sizing: border-box;\n}\n.flag.size-s[data-v-c3ae00cc] {\n width: 16px;\n height: 12px;\n}\n.flag.size-s.drop-shadow[data-v-c3ae00cc] {\n box-shadow: 0 0 1px 0.5px rgba(0, 0, 0, 0.1);\n}\n.flag.size-s.border-radius[data-v-c3ae00cc] {\n border-radius: 1px;\n}\n.flag.size-m[data-v-c3ae00cc] {\n width: 20px;\n height: 15px;\n}\n.flag.size-m.drop-shadow[data-v-c3ae00cc] {\n box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1);\n}\n.flag.size-m.border-radius[data-v-c3ae00cc] {\n border-radius: 1.5px;\n}\n.flag.size-l[data-v-c3ae00cc] {\n width: 32px;\n height: 24px;\n}\n.flag.size-l.drop-shadow[data-v-c3ae00cc] {\n box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.1);\n}\n.flag.size-l.border-radius[data-v-c3ae00cc] {\n border-radius: 2px;\n}\n.flag.border[data-v-c3ae00cc]::before {\n content: "";\n width: 100%;\n height: 100%;\n position: absolute;\n display: block;\n mix-blend-mode: overlay;\n box-sizing: border-box;\n border: 1px solid rgba(0, 0, 0, 0.5);\n mix-blend-mode: overlay;\n}\n.flag.border-radius[data-v-c3ae00cc]::before {\n content: "";\n width: 100%;\n height: 100%;\n position: absolute;\n display: block;\n mix-blend-mode: overlay;\n box-sizing: border-box;\n border-radius: 1px;\n}\n.flag.top-down[data-v-c3ae00cc]::before {\n content: "";\n width: 100%;\n height: 100%;\n position: absolute;\n display: block;\n mix-blend-mode: overlay;\n box-sizing: border-box;\n background-image: linear-gradient(0deg, rgba(0, 0, 0, 0.3) 2%, rgba(255, 255, 255, 0.7) 100%);\n}\n.flag.real-linear[data-v-c3ae00cc]::before {\n content: "";\n width: 100%;\n height: 100%;\n position: absolute;\n display: block;\n mix-blend-mode: overlay;\n box-sizing: border-box;\n background-image: linear-gradient(45deg, rgba(0, 0, 0, 0.2) 0%, rgba(39, 39, 39, 0.22) 11%, rgba(255, 255, 255, 0.3) 27%, rgba(0, 0, 0, 0.24) 41%, rgba(0, 0, 0, 0.55) 52%, rgba(255, 255, 255, 0.26) 63%, rgba(0, 0, 0, 0.27) 74%, rgba(255, 255, 255, 0.3) 100%);\n}\n.flag.real-circular[data-v-c3ae00cc]::before {\n content: "";\n width: 100%;\n height: 100%;\n position: absolute;\n display: block;\n mix-blend-mode: overlay;\n box-sizing: border-box;\n background: radial-gradient(50% 36%, rgba(255, 255, 255, 0.3) 0%, rgba(0, 0, 0, 0.24) 11%, rgba(0, 0, 0, 0.55) 17%, rgba(255, 255, 255, 0.26) 22%, rgba(0, 0, 0, 0.17) 27%, rgba(255, 255, 255, 0.28) 31%, rgba(255, 255, 255, 0) 37%) center calc(50% - 8px)/600% 600%, radial-gradient(50% 123%, rgba(255, 255, 255, 0.3) 25%, rgba(0, 0, 0, 0.24) 48%, rgba(0, 0, 0, 0.55) 61%, rgba(255, 255, 255, 0.26) 72%, rgba(0, 0, 0, 0.17) 80%, rgba(255, 255, 255, 0.28) 88%, rgba(255, 255, 255, 0.3) 100%) center calc(50% - 8px)/600% 600%;\n}\n.flag img[data-v-c3ae00cc] {\n display: block;\n width: 100%;\n height: 100%;\n object-fit: cover;\n}'),o.__scopeId="data-v-c3ae00cc";var t={install:(e,a={})=>{e.component(a.name||"Flag",o)}};Object.defineProperty(exports,"isoToCountryCode",{enumerable:!0,get:function(){return a.isoToCountryCode}}),exports.Flag=o,exports.default=t,exports.getFlagUrl=r,exports.importFlag=async function(e,a="m"){return r(e,a)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineComponent as
|
|
1
|
+
import{defineComponent as a,ref as e,onMounted as n,watch as o,createElementBlock as r,openBlock as d,normalizeClass as t,createCommentVNode as i}from"vue";import{isoToCountryCode as c}from"flagpack-core";export{isoToCountryCode}from"flagpack-core";const l=["src"];var s=a({__name:"Flag",props:{size:{default:"m"},code:{default:"528"},hasDropShadow:{type:Boolean,default:!1},hasBorder:{type:Boolean,default:!0},hasBorderRadius:{type:Boolean,default:!0},gradient:{default:void 0},className:{default:""}},setup(a){const s=a,g=e(""),b=async()=>{try{const a=(c(s.code)||s.code).toUpperCase(),e=s.size.toLowerCase(),n=(await import(`@nonfx/vue-flagpack/src/flags/${e}/${a}.svg?raw`)).default,o=new Blob([n],{type:"image/svg+xml"});g.value=URL.createObjectURL(o)}catch(a){console.warn(`Flag not found for code: ${s.code}`,a),g.value=""}};return n(()=>{b()}),o(()=>[s.code,s.size],()=>{b()}),(e,n)=>(d(),r("div",{class:t(["flag",`size-${a.size}`,{"border-radius":a.hasBorderRadius},{border:a.hasBorder},{"drop-shadow":a.hasDropShadow},a.gradient,a.className])},[g.value?(d(),r("img",{key:0,src:g.value,alt:"flag"},null,8,l)):i("",!0)],2))}});async function g(a,e="m"){try{const n=(c(a)||a).toUpperCase(),o=e.toLowerCase(),r=(await import(`@nonfx/vue-flagpack/src/flags/${o}/${n}.svg?raw`)).default,d=new Blob([r],{type:"image/svg+xml"});return URL.createObjectURL(d)}catch(e){return console.warn(`Flag not found for code: ${a}`,e),""}}async function b(a,e="m"){return g(a,e)}!function(a,e){void 0===e&&(e={});var n=e.insertAt;if("undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===n&&o.firstChild?o.insertBefore(r,o.firstChild):o.appendChild(r),r.styleSheet?r.styleSheet.cssText=a:r.appendChild(document.createTextNode(a))}}('.flag[data-v-c3ae00cc] {\n display: inline-block;\n overflow: hidden;\n position: relative;\n box-sizing: border-box;\n}\n.flag.size-s[data-v-c3ae00cc] {\n width: 16px;\n height: 12px;\n}\n.flag.size-s.drop-shadow[data-v-c3ae00cc] {\n box-shadow: 0 0 1px 0.5px rgba(0, 0, 0, 0.1);\n}\n.flag.size-s.border-radius[data-v-c3ae00cc] {\n border-radius: 1px;\n}\n.flag.size-m[data-v-c3ae00cc] {\n width: 20px;\n height: 15px;\n}\n.flag.size-m.drop-shadow[data-v-c3ae00cc] {\n box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1);\n}\n.flag.size-m.border-radius[data-v-c3ae00cc] {\n border-radius: 1.5px;\n}\n.flag.size-l[data-v-c3ae00cc] {\n width: 32px;\n height: 24px;\n}\n.flag.size-l.drop-shadow[data-v-c3ae00cc] {\n box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.1);\n}\n.flag.size-l.border-radius[data-v-c3ae00cc] {\n border-radius: 2px;\n}\n.flag.border[data-v-c3ae00cc]::before {\n content: "";\n width: 100%;\n height: 100%;\n position: absolute;\n display: block;\n mix-blend-mode: overlay;\n box-sizing: border-box;\n border: 1px solid rgba(0, 0, 0, 0.5);\n mix-blend-mode: overlay;\n}\n.flag.border-radius[data-v-c3ae00cc]::before {\n content: "";\n width: 100%;\n height: 100%;\n position: absolute;\n display: block;\n mix-blend-mode: overlay;\n box-sizing: border-box;\n border-radius: 1px;\n}\n.flag.top-down[data-v-c3ae00cc]::before {\n content: "";\n width: 100%;\n height: 100%;\n position: absolute;\n display: block;\n mix-blend-mode: overlay;\n box-sizing: border-box;\n background-image: linear-gradient(0deg, rgba(0, 0, 0, 0.3) 2%, rgba(255, 255, 255, 0.7) 100%);\n}\n.flag.real-linear[data-v-c3ae00cc]::before {\n content: "";\n width: 100%;\n height: 100%;\n position: absolute;\n display: block;\n mix-blend-mode: overlay;\n box-sizing: border-box;\n background-image: linear-gradient(45deg, rgba(0, 0, 0, 0.2) 0%, rgba(39, 39, 39, 0.22) 11%, rgba(255, 255, 255, 0.3) 27%, rgba(0, 0, 0, 0.24) 41%, rgba(0, 0, 0, 0.55) 52%, rgba(255, 255, 255, 0.26) 63%, rgba(0, 0, 0, 0.27) 74%, rgba(255, 255, 255, 0.3) 100%);\n}\n.flag.real-circular[data-v-c3ae00cc]::before {\n content: "";\n width: 100%;\n height: 100%;\n position: absolute;\n display: block;\n mix-blend-mode: overlay;\n box-sizing: border-box;\n background: radial-gradient(50% 36%, rgba(255, 255, 255, 0.3) 0%, rgba(0, 0, 0, 0.24) 11%, rgba(0, 0, 0, 0.55) 17%, rgba(255, 255, 255, 0.26) 22%, rgba(0, 0, 0, 0.17) 27%, rgba(255, 255, 255, 0.28) 31%, rgba(255, 255, 255, 0) 37%) center calc(50% - 8px)/600% 600%, radial-gradient(50% 123%, rgba(255, 255, 255, 0.3) 25%, rgba(0, 0, 0, 0.24) 48%, rgba(0, 0, 0, 0.55) 61%, rgba(255, 255, 255, 0.26) 72%, rgba(0, 0, 0, 0.17) 80%, rgba(255, 255, 255, 0.28) 88%, rgba(255, 255, 255, 0.3) 100%) center calc(50% - 8px)/600% 600%;\n}\n.flag img[data-v-c3ae00cc] {\n display: block;\n width: 100%;\n height: 100%;\n object-fit: cover;\n}'),s.__scopeId="data-v-c3ae00cc";var p={install:(a,e={})=>{a.component(e.name||"Flag",s)}};export{s as Flag,p as default,g as getFlagUrl,b as importFlag};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var VueFlagpack=function(e,a,n){"use strict";const o=["src"];var r=a.defineComponent({__name:"Flag",props:{size:{default:"m"},code:{default:"528"},hasDropShadow:{type:Boolean,default:!1},hasBorder:{type:Boolean,default:!0},hasBorderRadius:{type:Boolean,default:!0},gradient:{default:void 0},className:{default:""}},setup(e){const r=e,t=a.ref(""),d=async()=>{try{const e=(n.isoToCountryCode(r.code)||r.code).toUpperCase(),a=r.size.toLowerCase(),o=await import(
|
|
1
|
+
var VueFlagpack=function(e,a,n){"use strict";const o=["src"];var r=a.defineComponent({__name:"Flag",props:{size:{default:"m"},code:{default:"528"},hasDropShadow:{type:Boolean,default:!1},hasBorder:{type:Boolean,default:!0},hasBorderRadius:{type:Boolean,default:!0},gradient:{default:void 0},className:{default:""}},setup(e){const r=e,t=a.ref(""),d=async()=>{try{const e=(n.isoToCountryCode(r.code)||r.code).toUpperCase(),a=r.size.toLowerCase(),o=(await import(`@nonfx/vue-flagpack/src/flags/${a}/${e}.svg?raw`)).default,d=new Blob([o],{type:"image/svg+xml"});t.value=URL.createObjectURL(d)}catch(e){console.warn(`Flag not found for code: ${r.code}`,e),t.value=""}};return a.onMounted(()=>{d()}),a.watch(()=>[r.code,r.size],()=>{d()}),(n,r)=>(a.openBlock(),a.createElementBlock("div",{class:a.normalizeClass(["flag",`size-${e.size}`,{"border-radius":e.hasBorderRadius},{border:e.hasBorder},{"drop-shadow":e.hasDropShadow},e.gradient,e.className])},[t.value?(a.openBlock(),a.createElementBlock("img",{key:0,src:t.value,alt:"flag"},null,8,o)):a.createCommentVNode("",!0)],2))}});async function t(e,a="m"){try{const o=(n.isoToCountryCode(e)||e).toUpperCase(),r=a.toLowerCase(),t=(await import(`@nonfx/vue-flagpack/src/flags/${r}/${o}.svg?raw`)).default,d=new Blob([t],{type:"image/svg+xml"});return URL.createObjectURL(d)}catch(a){return console.warn(`Flag not found for code: ${e}`,a),""}}!function(e,a){void 0===a&&(a={});var n=a.insertAt;if("undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===n&&o.firstChild?o.insertBefore(r,o.firstChild):o.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}('.flag[data-v-c3ae00cc] {\n display: inline-block;\n overflow: hidden;\n position: relative;\n box-sizing: border-box;\n}\n.flag.size-s[data-v-c3ae00cc] {\n width: 16px;\n height: 12px;\n}\n.flag.size-s.drop-shadow[data-v-c3ae00cc] {\n box-shadow: 0 0 1px 0.5px rgba(0, 0, 0, 0.1);\n}\n.flag.size-s.border-radius[data-v-c3ae00cc] {\n border-radius: 1px;\n}\n.flag.size-m[data-v-c3ae00cc] {\n width: 20px;\n height: 15px;\n}\n.flag.size-m.drop-shadow[data-v-c3ae00cc] {\n box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1);\n}\n.flag.size-m.border-radius[data-v-c3ae00cc] {\n border-radius: 1.5px;\n}\n.flag.size-l[data-v-c3ae00cc] {\n width: 32px;\n height: 24px;\n}\n.flag.size-l.drop-shadow[data-v-c3ae00cc] {\n box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.1);\n}\n.flag.size-l.border-radius[data-v-c3ae00cc] {\n border-radius: 2px;\n}\n.flag.border[data-v-c3ae00cc]::before {\n content: "";\n width: 100%;\n height: 100%;\n position: absolute;\n display: block;\n mix-blend-mode: overlay;\n box-sizing: border-box;\n border: 1px solid rgba(0, 0, 0, 0.5);\n mix-blend-mode: overlay;\n}\n.flag.border-radius[data-v-c3ae00cc]::before {\n content: "";\n width: 100%;\n height: 100%;\n position: absolute;\n display: block;\n mix-blend-mode: overlay;\n box-sizing: border-box;\n border-radius: 1px;\n}\n.flag.top-down[data-v-c3ae00cc]::before {\n content: "";\n width: 100%;\n height: 100%;\n position: absolute;\n display: block;\n mix-blend-mode: overlay;\n box-sizing: border-box;\n background-image: linear-gradient(0deg, rgba(0, 0, 0, 0.3) 2%, rgba(255, 255, 255, 0.7) 100%);\n}\n.flag.real-linear[data-v-c3ae00cc]::before {\n content: "";\n width: 100%;\n height: 100%;\n position: absolute;\n display: block;\n mix-blend-mode: overlay;\n box-sizing: border-box;\n background-image: linear-gradient(45deg, rgba(0, 0, 0, 0.2) 0%, rgba(39, 39, 39, 0.22) 11%, rgba(255, 255, 255, 0.3) 27%, rgba(0, 0, 0, 0.24) 41%, rgba(0, 0, 0, 0.55) 52%, rgba(255, 255, 255, 0.26) 63%, rgba(0, 0, 0, 0.27) 74%, rgba(255, 255, 255, 0.3) 100%);\n}\n.flag.real-circular[data-v-c3ae00cc]::before {\n content: "";\n width: 100%;\n height: 100%;\n position: absolute;\n display: block;\n mix-blend-mode: overlay;\n box-sizing: border-box;\n background: radial-gradient(50% 36%, rgba(255, 255, 255, 0.3) 0%, rgba(0, 0, 0, 0.24) 11%, rgba(0, 0, 0, 0.55) 17%, rgba(255, 255, 255, 0.26) 22%, rgba(0, 0, 0, 0.17) 27%, rgba(255, 255, 255, 0.28) 31%, rgba(255, 255, 255, 0) 37%) center calc(50% - 8px)/600% 600%, radial-gradient(50% 123%, rgba(255, 255, 255, 0.3) 25%, rgba(0, 0, 0, 0.24) 48%, rgba(0, 0, 0, 0.55) 61%, rgba(255, 255, 255, 0.26) 72%, rgba(0, 0, 0, 0.17) 80%, rgba(255, 255, 255, 0.28) 88%, rgba(255, 255, 255, 0.3) 100%) center calc(50% - 8px)/600% 600%;\n}\n.flag img[data-v-c3ae00cc] {\n display: block;\n width: 100%;\n height: 100%;\n object-fit: cover;\n}'),r.__scopeId="data-v-c3ae00cc";var d={install:(e,a={})=>{e.component(a.name||"Flag",r)}};return Object.defineProperty(e,"isoToCountryCode",{enumerable:!0,get:function(){return n.isoToCountryCode}}),e.Flag=r,e.default=d,e.getFlagUrl=t,e.importFlag=async function(e,a="m"){return t(e,a)},Object.defineProperty(e,"__esModule",{value:!0}),e}({},Vue,flagpackCore);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nonfx/vue-flagpack",
|
|
3
3
|
"description": "Gorgeous flag components for your Vue 3 and Nuxt 3 project with tree-shaking support.",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.7",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Yummygum <info@yummygum.com> (https://yummygum.com)",
|
|
7
7
|
"repository": {
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
},
|
|
35
35
|
"./nuxt": {
|
|
36
36
|
"import": "./dist/nuxt.mjs"
|
|
37
|
-
}
|
|
37
|
+
},
|
|
38
|
+
"./src/flags/*": "./src/flags/*"
|
|
38
39
|
},
|
|
39
40
|
"license": "MIT",
|
|
40
41
|
"bugs": {
|
package/src/Flag.vue
CHANGED
|
@@ -44,14 +44,17 @@ const loadFlag = async () => {
|
|
|
44
44
|
const countryCode = (isoToCountryCode(props.code) || props.code).toUpperCase()
|
|
45
45
|
const sizeKey = props.size.toLowerCase()
|
|
46
46
|
|
|
47
|
-
// Dynamic import from
|
|
48
|
-
//
|
|
47
|
+
// Dynamic import from package root
|
|
48
|
+
// Using absolute path from package root for proper resolution
|
|
49
49
|
const svgModule = await import(
|
|
50
50
|
/* @vite-ignore */
|
|
51
|
-
|
|
51
|
+
`@nonfx/vue-flagpack/src/flags/${sizeKey}/${countryCode}.svg?raw`
|
|
52
52
|
)
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
// Convert SVG string to data URL
|
|
55
|
+
const svgString = svgModule.default
|
|
56
|
+
const blob = new Blob([svgString], { type: 'image/svg+xml' })
|
|
57
|
+
flagSvg.value = URL.createObjectURL(blob)
|
|
55
58
|
} catch (error) {
|
|
56
59
|
console.warn(`Flag not found for code: ${props.code}`, error)
|
|
57
60
|
flagSvg.value = ''
|
package/src/utils.ts
CHANGED
|
@@ -14,10 +14,13 @@ export async function getFlagUrl(
|
|
|
14
14
|
|
|
15
15
|
const svgModule = await import(
|
|
16
16
|
/* @vite-ignore */
|
|
17
|
-
|
|
17
|
+
`@nonfx/vue-flagpack/src/flags/${sizeKey}/${countryCode}.svg?raw`
|
|
18
18
|
)
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
// Convert SVG string to data URL
|
|
21
|
+
const svgString = svgModule.default
|
|
22
|
+
const blob = new Blob([svgString], { type: 'image/svg+xml' })
|
|
23
|
+
return URL.createObjectURL(blob)
|
|
21
24
|
} catch (error) {
|
|
22
25
|
console.warn(`Flag not found for code: ${code}`, error)
|
|
23
26
|
return ''
|