@qumra/fanar-native 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/README.md +83 -0
- package/lib/art.d.ts +8 -0
- package/lib/art.js +29 -0
- package/lib/assets/art/avatar.png +0 -0
- package/lib/assets/art/empty.png +0 -0
- package/lib/assets/art/image-placeholder.png +0 -0
- package/lib/assets/art/plan-update.png +0 -0
- package/lib/assets/brand/app-store.png +0 -0
- package/lib/assets/brand/etisalat.png +0 -0
- package/lib/assets/brand/facebook.png +0 -0
- package/lib/assets/brand/google-play.png +0 -0
- package/lib/assets/brand/instagram.png +0 -0
- package/lib/assets/brand/orange.png +0 -0
- package/lib/assets/brand/snapchat.png +0 -0
- package/lib/assets/brand/tiktok.png +0 -0
- package/lib/assets/brand/vodafone.png +0 -0
- package/lib/assets/brand/we.png +0 -0
- package/lib/assets/brand/whatsapp.png +0 -0
- package/lib/assets/brand/x.png +0 -0
- package/lib/assets/brand/youtube.png +0 -0
- package/lib/components/Button.d.ts +28 -0
- package/lib/components/Button.js +75 -0
- package/lib/components/Disclosure.d.ts +41 -0
- package/lib/components/Disclosure.js +98 -0
- package/lib/components/Display.d.ts +88 -0
- package/lib/components/Display.js +157 -0
- package/lib/components/Drawer.d.ts +27 -0
- package/lib/components/Drawer.js +58 -0
- package/lib/components/Feedback.d.ts +43 -0
- package/lib/components/Feedback.js +136 -0
- package/lib/components/Form.d.ts +92 -0
- package/lib/components/Form.js +196 -0
- package/lib/components/Money.d.ts +29 -0
- package/lib/components/Money.js +65 -0
- package/lib/components/Nav.d.ts +29 -0
- package/lib/components/Nav.js +65 -0
- package/lib/components/NumberStepper.d.ts +16 -0
- package/lib/components/NumberStepper.js +79 -0
- package/lib/components/Overlay.d.ts +54 -0
- package/lib/components/Overlay.js +147 -0
- package/lib/components/Rating.d.ts +18 -0
- package/lib/components/Rating.js +32 -0
- package/lib/components/Shell.d.ts +54 -0
- package/lib/components/Shell.js +99 -0
- package/lib/components/Surfaces.d.ts +64 -0
- package/lib/components/Surfaces.js +122 -0
- package/lib/components/Text.d.ts +14 -0
- package/lib/components/Text.js +31 -0
- package/lib/components/currency.d.ts +251 -0
- package/lib/components/currency.js +48 -0
- package/lib/glyphs.d.ts +2 -0
- package/lib/glyphs.js +7 -0
- package/lib/i18n/content.d.ts +1 -0
- package/lib/i18n/content.js +28 -0
- package/lib/i18n/en.d.ts +1 -0
- package/lib/i18n/en.js +124 -0
- package/lib/i18n/index.d.ts +64 -0
- package/lib/i18n/index.js +91 -0
- package/lib/i18n/screens.d.ts +1 -0
- package/lib/i18n/screens.js +2025 -0
- package/lib/icons.d.ts +18 -0
- package/lib/icons.js +400 -0
- package/lib/index.d.ts +25 -0
- package/lib/index.js +25 -0
- package/lib/lib/a11y.d.ts +4 -0
- package/lib/lib/a11y.js +8 -0
- package/lib/lib/digits.d.ts +3 -0
- package/lib/lib/digits.js +22 -0
- package/lib/lib/motion.d.ts +14 -0
- package/lib/lib/motion.js +47 -0
- package/lib/lib/tone.d.ts +9 -0
- package/lib/lib/tone.js +16 -0
- package/lib/qumra/NavIcon.d.ts +14 -0
- package/lib/qumra/NavIcon.js +17 -0
- package/lib/qumra/QumraIcon.d.ts +17 -0
- package/lib/qumra/QumraIcon.js +91 -0
- package/lib/qumra/data.generated.d.ts +3 -0
- package/lib/qumra/data.generated.js +146 -0
- package/lib/qumra/types.d.ts +5 -0
- package/lib/qumra/types.js +1 -0
- package/lib/theme/context.d.ts +31 -0
- package/lib/theme/context.js +46 -0
- package/lib/theme/fonts.d.ts +9 -0
- package/lib/theme/fonts.js +36 -0
- package/lib/theme/index.d.ts +4 -0
- package/lib/theme/index.js +4 -0
- package/lib/theme/shadows.d.ts +2 -0
- package/lib/theme/shadows.js +30 -0
- package/lib/theme/theme.d.ts +52 -0
- package/lib/theme/theme.js +78 -0
- package/lib/tokens/generated.d.ts +180 -0
- package/lib/tokens/generated.js +173 -0
- package/lib/tokens/index.d.ts +1 -0
- package/lib/tokens/index.js +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import Svg, { Circle, ClipPath, Defs, Ellipse, G, LinearGradient, Path, RadialGradient, Rect, Stop, Text as SvgText, } from 'react-native-svg';
|
|
4
|
+
import { QUMRA_ICONS } from './data.generated';
|
|
5
|
+
const TAGS = {
|
|
6
|
+
svg: Svg,
|
|
7
|
+
g: G,
|
|
8
|
+
path: Path,
|
|
9
|
+
rect: Rect,
|
|
10
|
+
circle: Circle,
|
|
11
|
+
ellipse: Ellipse,
|
|
12
|
+
defs: Defs,
|
|
13
|
+
clipPath: ClipPath,
|
|
14
|
+
linearGradient: LinearGradient,
|
|
15
|
+
radialGradient: RadialGradient,
|
|
16
|
+
stop: Stop,
|
|
17
|
+
text: SvgText,
|
|
18
|
+
};
|
|
19
|
+
const uniquify = (value, uid) => value.replace(/url\(#([\w-]+)\)/g, (_m, id) => `url(#${id}-${uid})`);
|
|
20
|
+
const isPaint = (key) => key === 'fill' || key === 'stroke' || key === 'stopColor';
|
|
21
|
+
const HEX = /^#([0-9a-f]{3,8})$/i;
|
|
22
|
+
function grayscale(value) {
|
|
23
|
+
const v = value.trim();
|
|
24
|
+
const m = HEX.exec(v);
|
|
25
|
+
if (!m)
|
|
26
|
+
return v;
|
|
27
|
+
let hex = m[1];
|
|
28
|
+
if (hex.length === 3 || hex.length === 4)
|
|
29
|
+
hex = hex.slice(0, 3).split('').map((c) => c + c).join('');
|
|
30
|
+
else
|
|
31
|
+
hex = hex.slice(0, 6);
|
|
32
|
+
const n = parseInt(hex, 16);
|
|
33
|
+
const l = Math.round(0.2126 * ((n >> 16) & 255) + 0.7152 * ((n >> 8) & 255) + 0.0722 * (n & 255));
|
|
34
|
+
const c = l.toString(16).padStart(2, '0');
|
|
35
|
+
return `#${c}${c}${c}`;
|
|
36
|
+
}
|
|
37
|
+
function build(node, uid, key, tint) {
|
|
38
|
+
const [tag, props, kids] = node;
|
|
39
|
+
const Cmp = TAGS[tag];
|
|
40
|
+
if (!Cmp)
|
|
41
|
+
return null;
|
|
42
|
+
const flat = tint && tint !== 'gray' ? tint : undefined;
|
|
43
|
+
if (flat && (tag === 'defs' || tag === 'linearGradient' || tag === 'radialGradient'))
|
|
44
|
+
return null;
|
|
45
|
+
const p = {};
|
|
46
|
+
for (const k of Object.keys(props)) {
|
|
47
|
+
let v = props[k];
|
|
48
|
+
if (k === 'id')
|
|
49
|
+
v = `${v}-${uid}`;
|
|
50
|
+
else if (typeof v === 'string' && v.indexOf('url(#') !== -1)
|
|
51
|
+
v = uniquify(v, uid);
|
|
52
|
+
if (tint && isPaint(k) && v !== 'none')
|
|
53
|
+
v = flat ?? grayscale(v);
|
|
54
|
+
p[k] = v;
|
|
55
|
+
}
|
|
56
|
+
if (flat) {
|
|
57
|
+
if (p.fillOpacity !== undefined)
|
|
58
|
+
p.fillOpacity = '1';
|
|
59
|
+
if (p.strokeOpacity !== undefined)
|
|
60
|
+
p.strokeOpacity = '1';
|
|
61
|
+
}
|
|
62
|
+
const children = kids?.map((c, i) => build(c, uid, i, tint)).filter(Boolean);
|
|
63
|
+
return React.createElement(Cmp, { key, ...p }, children?.length ? children : undefined);
|
|
64
|
+
}
|
|
65
|
+
function badge(count) {
|
|
66
|
+
const raw = String(count ?? '').trim();
|
|
67
|
+
if (!raw || raw === '0')
|
|
68
|
+
return null;
|
|
69
|
+
const n = Number(raw);
|
|
70
|
+
const s = !isNaN(n) && n > 99 ? '99+' : raw.length > 3 ? raw.slice(0, 3) : raw;
|
|
71
|
+
const w = s.length === 1 ? 12.4 : s.length === 2 ? 15.8 : 19.2;
|
|
72
|
+
const fs = s.length === 1 ? 9 : s.length === 2 ? 8.2 : 7.1;
|
|
73
|
+
const x = 30.4 - w;
|
|
74
|
+
return (_jsxs(G, { children: [_jsx(Rect, { x: x, y: 2.2, width: w, height: 12.4, rx: 6.2, fill: "#E8A94F", stroke: "#F2F7F8", strokeWidth: 1.4 }), _jsx(SvgText, { x: x + w / 2, y: 8.4, dy: fs * 0.35, textAnchor: "middle", fill: "#FFFFFF", fontSize: fs, fontWeight: "700", children: s })] }, "qi-count"));
|
|
75
|
+
}
|
|
76
|
+
export function QumraIcon({ name, size = 32, mono, active, color, count, label, onPress, }) {
|
|
77
|
+
const spec = QUMRA_ICONS[name];
|
|
78
|
+
const uid = React.useId().replace(/[^a-zA-Z0-9]/g, '');
|
|
79
|
+
const dimmed = !!mono && !active;
|
|
80
|
+
const tint = dimmed ? color ?? 'gray' : undefined;
|
|
81
|
+
const children = React.useMemo(() => (spec ? spec.tree.map((n, i) => build(n, uid, i, tint)) : []), [spec, uid, tint]);
|
|
82
|
+
if (!spec) {
|
|
83
|
+
if (__DEV__)
|
|
84
|
+
console.warn(`[qumra-icons] لا توجد أيقونة بالاسم «${name}»`);
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const mark = badge(count);
|
|
88
|
+
return (_jsxs(Svg, { width: size, height: size, viewBox: "0 0 32 32", opacity: dimmed ? 0.62 : 1, onPress: onPress, accessibilityRole: "image", accessibilityLabel: label ?? (mark ? `${spec.label} — ${count}` : spec.label), children: [children, mark] }));
|
|
89
|
+
}
|
|
90
|
+
export const hasQumraIcon = (name) => name in QUMRA_ICONS;
|
|
91
|
+
export { QUMRA_ICONS };
|