@blade-flags/react 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 +9 -0
- package/dist/index.cjs +66 -0
- package/dist/index.d.cts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +38 -0
- package/package.json +36 -0
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,66 @@
|
|
|
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.tsx
|
|
29
|
+
var import_react = require("react");
|
|
30
|
+
var import_core = require("@blade-flags/core");
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
var Flag = (0, import_react.forwardRef)(
|
|
33
|
+
({ code, type = "country", flags, ...rest }, ref) => {
|
|
34
|
+
const svg = (0, import_core.resolveFlag)(flags, code, type);
|
|
35
|
+
if (!svg) return null;
|
|
36
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { ref, ...rest, dangerouslySetInnerHTML: { __html: svg } });
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
Flag.displayName = "Flag";
|
|
40
|
+
|
|
41
|
+
// src/AutoFlag.tsx
|
|
42
|
+
var import_react2 = require("react");
|
|
43
|
+
var import_core2 = require("@blade-flags/core");
|
|
44
|
+
var import_default = require("@blade-flags/core/flags/default");
|
|
45
|
+
var import_circle = require("@blade-flags/core/flags/circle");
|
|
46
|
+
var import_flat = require("@blade-flags/core/flags/flat");
|
|
47
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
48
|
+
var variantMap = {
|
|
49
|
+
default: import_default.defaultFlags,
|
|
50
|
+
circle: import_circle.circleFlags,
|
|
51
|
+
flat: import_flat.flatFlags
|
|
52
|
+
};
|
|
53
|
+
var AutoFlag = (0, import_react2.forwardRef)(
|
|
54
|
+
({ code, type = "country", variant = "default", ...rest }, ref) => {
|
|
55
|
+
const flags = variantMap[variant];
|
|
56
|
+
const svg = (0, import_core2.resolveFlag)(flags, code, type);
|
|
57
|
+
if (!svg) return null;
|
|
58
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { ref, ...rest, dangerouslySetInnerHTML: { __html: svg } });
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
AutoFlag.displayName = "AutoFlag";
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
AutoFlag,
|
|
65
|
+
Flag
|
|
66
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { FlagType, FlagMap, FlagVariant } from '@blade-flags/core';
|
|
3
|
+
|
|
4
|
+
interface FlagProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
5
|
+
code: string;
|
|
6
|
+
type?: FlagType;
|
|
7
|
+
flags: FlagMap;
|
|
8
|
+
}
|
|
9
|
+
declare const Flag: react.ForwardRefExoticComponent<FlagProps & react.RefAttributes<HTMLSpanElement>>;
|
|
10
|
+
|
|
11
|
+
interface AutoFlagProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
12
|
+
code: string;
|
|
13
|
+
type?: FlagType;
|
|
14
|
+
variant?: FlagVariant;
|
|
15
|
+
}
|
|
16
|
+
declare const AutoFlag: react.ForwardRefExoticComponent<AutoFlagProps & react.RefAttributes<HTMLSpanElement>>;
|
|
17
|
+
|
|
18
|
+
export { AutoFlag, type AutoFlagProps, Flag, type FlagProps };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { FlagType, FlagMap, FlagVariant } from '@blade-flags/core';
|
|
3
|
+
|
|
4
|
+
interface FlagProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
5
|
+
code: string;
|
|
6
|
+
type?: FlagType;
|
|
7
|
+
flags: FlagMap;
|
|
8
|
+
}
|
|
9
|
+
declare const Flag: react.ForwardRefExoticComponent<FlagProps & react.RefAttributes<HTMLSpanElement>>;
|
|
10
|
+
|
|
11
|
+
interface AutoFlagProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
12
|
+
code: string;
|
|
13
|
+
type?: FlagType;
|
|
14
|
+
variant?: FlagVariant;
|
|
15
|
+
}
|
|
16
|
+
declare const AutoFlag: react.ForwardRefExoticComponent<AutoFlagProps & react.RefAttributes<HTMLSpanElement>>;
|
|
17
|
+
|
|
18
|
+
export { AutoFlag, type AutoFlagProps, Flag, type FlagProps };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// src/Flag.tsx
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { resolveFlag } from "@blade-flags/core";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
var Flag = forwardRef(
|
|
6
|
+
({ code, type = "country", flags, ...rest }, ref) => {
|
|
7
|
+
const svg = resolveFlag(flags, code, type);
|
|
8
|
+
if (!svg) return null;
|
|
9
|
+
return /* @__PURE__ */ jsx("span", { ref, ...rest, dangerouslySetInnerHTML: { __html: svg } });
|
|
10
|
+
}
|
|
11
|
+
);
|
|
12
|
+
Flag.displayName = "Flag";
|
|
13
|
+
|
|
14
|
+
// src/AutoFlag.tsx
|
|
15
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
16
|
+
import { resolveFlag as resolveFlag2 } from "@blade-flags/core";
|
|
17
|
+
import { defaultFlags } from "@blade-flags/core/flags/default";
|
|
18
|
+
import { circleFlags } from "@blade-flags/core/flags/circle";
|
|
19
|
+
import { flatFlags } from "@blade-flags/core/flags/flat";
|
|
20
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
21
|
+
var variantMap = {
|
|
22
|
+
default: defaultFlags,
|
|
23
|
+
circle: circleFlags,
|
|
24
|
+
flat: flatFlags
|
|
25
|
+
};
|
|
26
|
+
var AutoFlag = forwardRef2(
|
|
27
|
+
({ code, type = "country", variant = "default", ...rest }, ref) => {
|
|
28
|
+
const flags = variantMap[variant];
|
|
29
|
+
const svg = resolveFlag2(flags, code, type);
|
|
30
|
+
if (!svg) return null;
|
|
31
|
+
return /* @__PURE__ */ jsx2("span", { ref, ...rest, dangerouslySetInnerHTML: { __html: svg } });
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
AutoFlag.displayName = "AutoFlag";
|
|
35
|
+
export {
|
|
36
|
+
AutoFlag,
|
|
37
|
+
Flag
|
|
38
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@blade-flags/react",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "React 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
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/react": "^19.0.0",
|
|
29
|
+
"react": "^19.0.0",
|
|
30
|
+
"tsup": "^8.2.0",
|
|
31
|
+
"@blade-flags/core": "0.1.0"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsup"
|
|
35
|
+
}
|
|
36
|
+
}
|