@blade-flags/vue 0.1.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/LICENSE.md ADDED
@@ -0,0 +1,9 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) Dries Vints
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/dist/index.cjs ADDED
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ AutoFlag: () => AutoFlag,
24
+ Flag: () => Flag
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+
28
+ // src/Flag.ts
29
+ var import_vue = require("vue");
30
+ var import_core = require("@blade-flags/core");
31
+ var Flag = (0, import_vue.defineComponent)({
32
+ name: "Flag",
33
+ props: {
34
+ code: { type: String, required: true },
35
+ type: { type: String, default: "country" },
36
+ flags: { type: Object, required: true }
37
+ },
38
+ setup(props) {
39
+ return () => {
40
+ const svg = (0, import_core.resolveFlag)(props.flags, props.code, props.type);
41
+ if (!svg) return null;
42
+ return (0, import_vue.h)("span", { innerHTML: svg });
43
+ };
44
+ }
45
+ });
46
+
47
+ // src/AutoFlag.ts
48
+ var import_vue2 = require("vue");
49
+ var import_core2 = require("@blade-flags/core");
50
+ var import_default = require("@blade-flags/core/flags/default");
51
+ var import_circle = require("@blade-flags/core/flags/circle");
52
+ var import_flat = require("@blade-flags/core/flags/flat");
53
+ var variantMap = {
54
+ default: import_default.defaultFlags,
55
+ circle: import_circle.circleFlags,
56
+ flat: import_flat.flatFlags
57
+ };
58
+ var AutoFlag = (0, import_vue2.defineComponent)({
59
+ name: "AutoFlag",
60
+ props: {
61
+ code: { type: String, required: true },
62
+ type: { type: String, default: "country" },
63
+ variant: { type: String, default: "default" }
64
+ },
65
+ setup(props) {
66
+ const flags = (0, import_vue2.computed)(() => variantMap[props.variant]);
67
+ return () => {
68
+ const svg = (0, import_core2.resolveFlag)(flags.value, props.code, props.type);
69
+ if (!svg) return null;
70
+ return (0, import_vue2.h)("span", { innerHTML: svg });
71
+ };
72
+ }
73
+ });
74
+ // Annotate the CommonJS export names for ESM import in node:
75
+ 0 && (module.exports = {
76
+ AutoFlag,
77
+ Flag
78
+ });
@@ -0,0 +1,70 @@
1
+ import * as vue from 'vue';
2
+ import { PropType } from 'vue';
3
+ import { FlagType, FlagMap, FlagVariant } from '@blade-flags/core';
4
+
5
+ declare const Flag: vue.DefineComponent<vue.ExtractPropTypes<{
6
+ code: {
7
+ type: StringConstructor;
8
+ required: true;
9
+ };
10
+ type: {
11
+ type: PropType<FlagType>;
12
+ default: string;
13
+ };
14
+ flags: {
15
+ type: PropType<FlagMap>;
16
+ required: true;
17
+ };
18
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
19
+ [key: string]: any;
20
+ }> | null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
21
+ code: {
22
+ type: StringConstructor;
23
+ required: true;
24
+ };
25
+ type: {
26
+ type: PropType<FlagType>;
27
+ default: string;
28
+ };
29
+ flags: {
30
+ type: PropType<FlagMap>;
31
+ required: true;
32
+ };
33
+ }>> & Readonly<{}>, {
34
+ type: FlagType;
35
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
36
+
37
+ declare const AutoFlag: vue.DefineComponent<vue.ExtractPropTypes<{
38
+ code: {
39
+ type: StringConstructor;
40
+ required: true;
41
+ };
42
+ type: {
43
+ type: PropType<FlagType>;
44
+ default: string;
45
+ };
46
+ variant: {
47
+ type: PropType<FlagVariant>;
48
+ default: string;
49
+ };
50
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
51
+ [key: string]: any;
52
+ }> | null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
53
+ code: {
54
+ type: StringConstructor;
55
+ required: true;
56
+ };
57
+ type: {
58
+ type: PropType<FlagType>;
59
+ default: string;
60
+ };
61
+ variant: {
62
+ type: PropType<FlagVariant>;
63
+ default: string;
64
+ };
65
+ }>> & Readonly<{}>, {
66
+ type: FlagType;
67
+ variant: FlagVariant;
68
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
69
+
70
+ export { AutoFlag, Flag };
@@ -0,0 +1,70 @@
1
+ import * as vue from 'vue';
2
+ import { PropType } from 'vue';
3
+ import { FlagType, FlagMap, FlagVariant } from '@blade-flags/core';
4
+
5
+ declare const Flag: vue.DefineComponent<vue.ExtractPropTypes<{
6
+ code: {
7
+ type: StringConstructor;
8
+ required: true;
9
+ };
10
+ type: {
11
+ type: PropType<FlagType>;
12
+ default: string;
13
+ };
14
+ flags: {
15
+ type: PropType<FlagMap>;
16
+ required: true;
17
+ };
18
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
19
+ [key: string]: any;
20
+ }> | null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
21
+ code: {
22
+ type: StringConstructor;
23
+ required: true;
24
+ };
25
+ type: {
26
+ type: PropType<FlagType>;
27
+ default: string;
28
+ };
29
+ flags: {
30
+ type: PropType<FlagMap>;
31
+ required: true;
32
+ };
33
+ }>> & Readonly<{}>, {
34
+ type: FlagType;
35
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
36
+
37
+ declare const AutoFlag: vue.DefineComponent<vue.ExtractPropTypes<{
38
+ code: {
39
+ type: StringConstructor;
40
+ required: true;
41
+ };
42
+ type: {
43
+ type: PropType<FlagType>;
44
+ default: string;
45
+ };
46
+ variant: {
47
+ type: PropType<FlagVariant>;
48
+ default: string;
49
+ };
50
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
51
+ [key: string]: any;
52
+ }> | null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
53
+ code: {
54
+ type: StringConstructor;
55
+ required: true;
56
+ };
57
+ type: {
58
+ type: PropType<FlagType>;
59
+ default: string;
60
+ };
61
+ variant: {
62
+ type: PropType<FlagVariant>;
63
+ default: string;
64
+ };
65
+ }>> & Readonly<{}>, {
66
+ type: FlagType;
67
+ variant: FlagVariant;
68
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
69
+
70
+ export { AutoFlag, Flag };
package/dist/index.js ADDED
@@ -0,0 +1,50 @@
1
+ // src/Flag.ts
2
+ import { defineComponent, h } from "vue";
3
+ import { resolveFlag } from "@blade-flags/core";
4
+ var Flag = defineComponent({
5
+ name: "Flag",
6
+ props: {
7
+ code: { type: String, required: true },
8
+ type: { type: String, default: "country" },
9
+ flags: { type: Object, required: true }
10
+ },
11
+ setup(props) {
12
+ return () => {
13
+ const svg = resolveFlag(props.flags, props.code, props.type);
14
+ if (!svg) return null;
15
+ return h("span", { innerHTML: svg });
16
+ };
17
+ }
18
+ });
19
+
20
+ // src/AutoFlag.ts
21
+ import { defineComponent as defineComponent2, h as h2, computed } from "vue";
22
+ import { resolveFlag as resolveFlag2 } from "@blade-flags/core";
23
+ import { defaultFlags } from "@blade-flags/core/flags/default";
24
+ import { circleFlags } from "@blade-flags/core/flags/circle";
25
+ import { flatFlags } from "@blade-flags/core/flags/flat";
26
+ var variantMap = {
27
+ default: defaultFlags,
28
+ circle: circleFlags,
29
+ flat: flatFlags
30
+ };
31
+ var AutoFlag = defineComponent2({
32
+ name: "AutoFlag",
33
+ props: {
34
+ code: { type: String, required: true },
35
+ type: { type: String, default: "country" },
36
+ variant: { type: String, default: "default" }
37
+ },
38
+ setup(props) {
39
+ const flags = computed(() => variantMap[props.variant]);
40
+ return () => {
41
+ const svg = resolveFlag2(flags.value, props.code, props.type);
42
+ if (!svg) return null;
43
+ return h2("span", { innerHTML: svg });
44
+ };
45
+ }
46
+ });
47
+ export {
48
+ AutoFlag,
49
+ Flag
50
+ };
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@blade-flags/vue",
3
+ "version": "0.1.0",
4
+ "description": "Vue 3 flag components powered by @blade-flags/core",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.cjs"
12
+ }
13
+ },
14
+ "main": "./dist/index.cjs",
15
+ "module": "./dist/index.js",
16
+ "types": "./dist/index.d.ts",
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "peerDependencies": {
24
+ "@blade-flags/core": ">=0.1.0",
25
+ "vue": "^3.3.0"
26
+ },
27
+ "devDependencies": {
28
+ "tsup": "^8.2.0",
29
+ "vue": "^3.5.0",
30
+ "@blade-flags/core": "0.1.0"
31
+ },
32
+ "scripts": {
33
+ "build": "tsup"
34
+ }
35
+ }