jfs-components 0.0.63 → 0.0.65
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/CHANGELOG.md +31 -0
- package/lib/commonjs/components/Carousel/Carousel.js +12 -9
- package/lib/commonjs/components/Drawer/Drawer.js +116 -50
- package/lib/commonjs/components/IconButton/IconButton.js +42 -6
- package/lib/commonjs/components/IconCapsule/IconCapsule.js +5 -0
- package/lib/commonjs/components/Popup/Popup.js +2 -2
- package/lib/commonjs/components/Section/Section.js +280 -58
- package/lib/commonjs/components/UpiHandle/UpiHandle.js +19 -7
- package/lib/commonjs/icons/Icon.js +72 -75
- package/lib/commonjs/icons/registry.js +1 -1
- package/lib/commonjs/utils/MediaSource.js +181 -0
- package/lib/commonjs/utils/index.js +9 -1
- package/lib/module/components/Carousel/Carousel.js +12 -9
- package/lib/module/components/Drawer/Drawer.js +116 -50
- package/lib/module/components/IconButton/IconButton.js +42 -6
- package/lib/module/components/IconCapsule/IconCapsule.js +5 -0
- package/lib/module/components/Popup/Popup.js +2 -2
- package/lib/module/components/Section/Section.js +280 -58
- package/lib/module/components/UpiHandle/UpiHandle.js +20 -8
- package/lib/module/icons/Icon.js +72 -75
- package/lib/module/icons/registry.js +1 -1
- package/lib/module/utils/MediaSource.js +176 -0
- package/lib/module/utils/index.js +2 -1
- package/lib/typescript/src/components/Drawer/Drawer.d.ts +6 -1
- package/lib/typescript/src/components/IconButton/IconButton.d.ts +25 -14
- package/lib/typescript/src/components/IconCapsule/IconCapsule.d.ts +12 -1
- package/lib/typescript/src/components/Section/Section.d.ts +42 -1
- package/lib/typescript/src/components/UpiHandle/UpiHandle.d.ts +17 -3
- package/lib/typescript/src/icons/Icon.d.ts +35 -16
- package/lib/typescript/src/icons/registry.d.ts +1 -1
- package/lib/typescript/src/utils/MediaSource.d.ts +63 -0
- package/lib/typescript/src/utils/index.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/Carousel/Carousel.tsx +16 -17
- package/src/components/Drawer/Drawer.tsx +136 -60
- package/src/components/IconButton/IconButton.tsx +70 -11
- package/src/components/IconCapsule/IconCapsule.tsx +13 -0
- package/src/components/Popup/Popup.tsx +2 -2
- package/src/components/Section/Section.tsx +411 -71
- package/src/components/UpiHandle/UpiHandle.tsx +37 -11
- package/src/icons/Icon.tsx +91 -76
- package/src/icons/registry.ts +1 -1
- package/src/utils/MediaSource.tsx +220 -0
- package/src/utils/index.ts +2 -0
|
@@ -8,99 +8,96 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
var _reactNativeSvg = _interopRequireWildcard(require("react-native-svg"));
|
|
10
10
|
var _registry = require("./registry");
|
|
11
|
+
var _MediaSource = _interopRequireDefault(require("../utils/MediaSource"));
|
|
11
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
13
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
15
|
/**
|
|
15
|
-
* Generic Icon
|
|
16
|
-
*
|
|
17
|
-
* Renders an icon from the registry by name
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* @param {number} [props.size=24] - Icon size in pixels (width and height)
|
|
23
|
-
* @param {string} [props.color='#141414'] - Icon color (hex, rgb, or named color)
|
|
24
|
-
* @param {Object} [props.style] - Additional styles for the container View
|
|
25
|
-
*
|
|
16
|
+
* Generic Icon component.
|
|
17
|
+
*
|
|
18
|
+
* Renders an icon from the registry by `name`, or falls back to a
|
|
19
|
+
* smart-detected `source` (SVG / PNG / JPG / require / SVG component /
|
|
20
|
+
* remote URI). External sources are tinted with `color` so they participate
|
|
21
|
+
* in the design-token modes just like built-in icons.
|
|
22
|
+
*
|
|
26
23
|
* @example
|
|
27
|
-
* ```
|
|
24
|
+
* ```tsx
|
|
25
|
+
* // Built-in icon from the registry.
|
|
28
26
|
* <Icon name="ic_ccv" size={24} color="#141414" />
|
|
29
|
-
*
|
|
30
|
-
*
|
|
27
|
+
*
|
|
28
|
+
* // Fallback to a remote SVG (auto-detected by the .svg extension).
|
|
29
|
+
* <Icon source="https://cdn.example.com/avatar.svg" size={24} color="#5c00b5" />
|
|
30
|
+
*
|
|
31
|
+
* // Fallback to a local raster asset.
|
|
32
|
+
* <Icon source={require('./brand.png')} size={32} />
|
|
33
|
+
*
|
|
34
|
+
* // Fallback to an SVG React component (e.g. via react-native-svg-transformer).
|
|
35
|
+
* import BrandLogo from './brand.svg';
|
|
36
|
+
* <Icon source={BrandLogo} size={24} color="red" />
|
|
31
37
|
* ```
|
|
32
38
|
*/
|
|
33
39
|
function Icon({
|
|
34
40
|
name,
|
|
41
|
+
source,
|
|
35
42
|
size = 24,
|
|
36
43
|
color = '#141414',
|
|
37
44
|
style,
|
|
38
45
|
...rest
|
|
39
46
|
}) {
|
|
40
|
-
|
|
41
|
-
if (!name) {
|
|
42
|
-
console.warn('Icon: name prop is required');
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
if (!(0, _registry.hasIcon)(name)) {
|
|
46
|
-
const {
|
|
47
|
-
getIconNames
|
|
48
|
-
} = require('./registry');
|
|
49
|
-
console.warn(`Icon: "${name}" not found in registry. Available icons: ${getIconNames().join(', ')}`);
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Get icon data from registry
|
|
54
|
-
const iconData = (0, _registry.getIcon)(name);
|
|
55
|
-
if (!iconData) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Parse viewBox to get width and height for aspect ratio
|
|
60
|
-
const viewBoxParts = iconData.viewBox.split(' ');
|
|
61
|
-
// @ts-ignore
|
|
62
|
-
const viewBoxWidth = parseFloat(viewBoxParts[2]) || size;
|
|
63
|
-
// @ts-ignore
|
|
64
|
-
const viewBoxHeight = parseFloat(viewBoxParts[3]) || size;
|
|
65
|
-
|
|
66
|
-
// Calculate aspect ratio to maintain proper scaling
|
|
67
|
-
const aspectRatio = viewBoxWidth / viewBoxHeight;
|
|
68
|
-
|
|
69
|
-
// Determine actual width and height based on size and aspect ratio
|
|
70
|
-
let width = size;
|
|
71
|
-
let height = size;
|
|
72
|
-
|
|
73
|
-
// If viewBox is not square, adjust dimensions to maintain aspect ratio
|
|
74
|
-
if (Math.abs(aspectRatio - 1) > 0.01) {
|
|
75
|
-
if (aspectRatio > 1) {
|
|
76
|
-
// Wider than tall
|
|
77
|
-
height = size / aspectRatio;
|
|
78
|
-
} else {
|
|
79
|
-
// Taller than wide
|
|
80
|
-
width = size * aspectRatio;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
const containerStyle = {
|
|
47
|
+
const containerStyle = [{
|
|
84
48
|
width: size,
|
|
85
49
|
height: size,
|
|
86
50
|
alignItems: 'center',
|
|
87
|
-
justifyContent: 'center'
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
51
|
+
justifyContent: 'center'
|
|
52
|
+
}, style];
|
|
53
|
+
const iconData = name && (0, _registry.hasIcon)(name) ? (0, _registry.getIcon)(name) : null;
|
|
54
|
+
if (iconData) {
|
|
55
|
+
const viewBoxParts = iconData.viewBox.split(' ');
|
|
56
|
+
const viewBoxWidth = parseFloat(viewBoxParts[2] ?? `${size}`) || size;
|
|
57
|
+
const viewBoxHeight = parseFloat(viewBoxParts[3] ?? `${size}`) || size;
|
|
58
|
+
const aspectRatio = viewBoxWidth / viewBoxHeight;
|
|
59
|
+
let width = size;
|
|
60
|
+
let height = size;
|
|
61
|
+
if (Math.abs(aspectRatio - 1) > 0.01) {
|
|
62
|
+
if (aspectRatio > 1) {
|
|
63
|
+
height = size / aspectRatio;
|
|
64
|
+
} else {
|
|
65
|
+
width = size * aspectRatio;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
69
|
+
style: containerStyle,
|
|
70
|
+
...rest,
|
|
71
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.default, {
|
|
72
|
+
width: width,
|
|
73
|
+
height: height,
|
|
74
|
+
viewBox: iconData.viewBox,
|
|
75
|
+
preserveAspectRatio: "xMidYMid meet",
|
|
76
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Path, {
|
|
77
|
+
d: iconData.path,
|
|
78
|
+
fill: color,
|
|
79
|
+
fillRule: iconData.fillRule || 'nonzero'
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (source !== undefined) {
|
|
85
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
86
|
+
style: containerStyle,
|
|
87
|
+
...rest,
|
|
88
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_MediaSource.default, {
|
|
89
|
+
source: source,
|
|
90
|
+
size: size,
|
|
91
|
+
tintColor: color,
|
|
92
|
+
resizeMode: "contain"
|
|
102
93
|
})
|
|
103
|
-
})
|
|
104
|
-
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
if (!name) {
|
|
97
|
+
console.warn('Icon: either `name` or `source` is required');
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
console.warn(`Icon: "${name}" not found in registry and no \`source\` fallback was provided.`);
|
|
101
|
+
return null;
|
|
105
102
|
}
|
|
106
103
|
var _default = exports.default = Icon;
|