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.
Files changed (44) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/lib/commonjs/components/Carousel/Carousel.js +12 -9
  3. package/lib/commonjs/components/Drawer/Drawer.js +116 -50
  4. package/lib/commonjs/components/IconButton/IconButton.js +42 -6
  5. package/lib/commonjs/components/IconCapsule/IconCapsule.js +5 -0
  6. package/lib/commonjs/components/Popup/Popup.js +2 -2
  7. package/lib/commonjs/components/Section/Section.js +280 -58
  8. package/lib/commonjs/components/UpiHandle/UpiHandle.js +19 -7
  9. package/lib/commonjs/icons/Icon.js +72 -75
  10. package/lib/commonjs/icons/registry.js +1 -1
  11. package/lib/commonjs/utils/MediaSource.js +181 -0
  12. package/lib/commonjs/utils/index.js +9 -1
  13. package/lib/module/components/Carousel/Carousel.js +12 -9
  14. package/lib/module/components/Drawer/Drawer.js +116 -50
  15. package/lib/module/components/IconButton/IconButton.js +42 -6
  16. package/lib/module/components/IconCapsule/IconCapsule.js +5 -0
  17. package/lib/module/components/Popup/Popup.js +2 -2
  18. package/lib/module/components/Section/Section.js +280 -58
  19. package/lib/module/components/UpiHandle/UpiHandle.js +20 -8
  20. package/lib/module/icons/Icon.js +72 -75
  21. package/lib/module/icons/registry.js +1 -1
  22. package/lib/module/utils/MediaSource.js +176 -0
  23. package/lib/module/utils/index.js +2 -1
  24. package/lib/typescript/src/components/Drawer/Drawer.d.ts +6 -1
  25. package/lib/typescript/src/components/IconButton/IconButton.d.ts +25 -14
  26. package/lib/typescript/src/components/IconCapsule/IconCapsule.d.ts +12 -1
  27. package/lib/typescript/src/components/Section/Section.d.ts +42 -1
  28. package/lib/typescript/src/components/UpiHandle/UpiHandle.d.ts +17 -3
  29. package/lib/typescript/src/icons/Icon.d.ts +35 -16
  30. package/lib/typescript/src/icons/registry.d.ts +1 -1
  31. package/lib/typescript/src/utils/MediaSource.d.ts +63 -0
  32. package/lib/typescript/src/utils/index.d.ts +2 -0
  33. package/package.json +1 -1
  34. package/src/components/Carousel/Carousel.tsx +16 -17
  35. package/src/components/Drawer/Drawer.tsx +136 -60
  36. package/src/components/IconButton/IconButton.tsx +70 -11
  37. package/src/components/IconCapsule/IconCapsule.tsx +13 -0
  38. package/src/components/Popup/Popup.tsx +2 -2
  39. package/src/components/Section/Section.tsx +411 -71
  40. package/src/components/UpiHandle/UpiHandle.tsx +37 -11
  41. package/src/icons/Icon.tsx +91 -76
  42. package/src/icons/registry.ts +1 -1
  43. package/src/utils/MediaSource.tsx +220 -0
  44. 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 Component
16
- *
17
- * Renders an icon from the registry by name with customizable size and color.
18
- *
19
- * @component
20
- * @param {Object} props - Component props
21
- * @param {string} props.name - Icon name from the registry (e.g., 'ic_ccv', 'ic_card')
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
- * ```jsx
24
+ * ```tsx
25
+ * // Built-in icon from the registry.
28
26
  * <Icon name="ic_ccv" size={24} color="#141414" />
29
- * <Icon name="ic_card" size={32} color="#5c00b5" />
30
- * <Icon name="ic_cart" size={20} color="red" />
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
- // Validate icon name
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
- ...style
89
- };
90
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
91
- style: containerStyle,
92
- ...rest,
93
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.default, {
94
- width: width,
95
- height: height,
96
- viewBox: iconData.viewBox,
97
- preserveAspectRatio: "xMidYMid meet",
98
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Path, {
99
- d: iconData.path,
100
- fill: color,
101
- fillRule: iconData.fillRule || 'nonzero'
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;