@shohojdhara/atomix 0.4.2 → 0.4.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shohojdhara/atomix",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Atomix Design System - A modern component library for web applications",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -121,14 +121,13 @@ export const BreadcrumbItem = forwardRef<HTMLLIElement, BreadcrumbItemProps>(
121
121
  ...linkProps,
122
122
  };
123
123
 
124
- const LinkComponent = linkAs;
124
+ const LinkComponent = linkAs as React.ComponentType<any>;
125
125
 
126
126
  return (
127
127
  <li ref={ref} className={itemClasses} style={style} {...props}>
128
128
  {href && !active ? (
129
- LinkComponent ? (
130
- // @ts-ignore - Dynamic components are tricky in TS without stricter types
131
- <LinkComponent href={href} {...commonLinkProps}>
129
+ linkAs && LinkComponent ? (
130
+ <LinkComponent href={href} to={href} {...commonLinkProps}>
132
131
  {linkContent}
133
132
  </LinkComponent>
134
133
  ) : (
@@ -10,7 +10,7 @@ export type ButtonAsProp = {
10
10
  as?: ElementType;
11
11
  to?: string;
12
12
  href?: string;
13
- LinkComponent?: React.ComponentType<any>;
13
+ LinkComponent?: React.ElementType;
14
14
  [key: string]: any;
15
15
  };
16
16
 
@@ -227,6 +227,7 @@ export const Button = React.memo(
227
227
  ...buttonProps,
228
228
  ref: ref as any, // LinkComponent usually forwards ref to anchor
229
229
  href,
230
+ to: href,
230
231
  target,
231
232
  rel: target === '_blank' ? 'noopener noreferrer' : undefined,
232
233
  };
@@ -39,6 +39,8 @@ export const Card = React.memo(
39
39
  onFocus,
40
40
  href,
41
41
  target,
42
+ // Custom Link
43
+ LinkComponent,
42
44
  // Glass
43
45
  glass,
44
46
  // Accessibility
@@ -242,17 +244,35 @@ export const Card = React.memo(
242
244
 
243
245
  // Render as anchor if href is provided
244
246
  if (href && !isDisabled) {
245
- const anchorElement = (
246
- <a
247
- {...commonProps}
248
- ref={ref as React.Ref<HTMLAnchorElement>}
249
- href={href}
250
- target={target}
251
- rel={target === '_blank' ? 'noopener noreferrer' : undefined}
252
- >
253
- {cardContent}
254
- </a>
255
- );
247
+ let anchorElement: React.ReactElement;
248
+
249
+ if (LinkComponent) {
250
+ const LinkComp = LinkComponent as React.ComponentType<any>;
251
+ anchorElement = (
252
+ <LinkComp
253
+ {...commonProps}
254
+ ref={ref as React.Ref<HTMLAnchorElement>}
255
+ href={href}
256
+ to={href}
257
+ target={target}
258
+ rel={target === '_blank' ? 'noopener noreferrer' : undefined}
259
+ >
260
+ {cardContent}
261
+ </LinkComp>
262
+ );
263
+ } else {
264
+ anchorElement = (
265
+ <a
266
+ {...commonProps}
267
+ ref={ref as React.Ref<HTMLAnchorElement>}
268
+ href={href}
269
+ target={target}
270
+ rel={target === '_blank' ? 'noopener noreferrer' : undefined}
271
+ >
272
+ {cardContent}
273
+ </a>
274
+ );
275
+ }
256
276
 
257
277
  if (glass) {
258
278
  const glassProps = glass === true ? {} : glass;