prometeo-design-system 7.1.3 → 7.1.4

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/dist/Chip.es.js CHANGED
@@ -1,37 +1,37 @@
1
1
  import { j as o } from "./jsx-runtime-GkKLlHH4.js";
2
- import { memo as x, forwardRef as U, useMemo as N, useCallback as v } from "react";
3
- import { c as m } from "./index-BOQuZ0gG.js";
4
- import { c as h } from "./cn-B6yFEsav.js";
5
- import { i as R } from "./iconUtils-rTOfKDxE.js";
6
- import { Close as B } from "./Icons/Close.es.js";
7
- import { A as F } from "./AvatarBase-sKVPLn_O.js";
8
- const K = {
2
+ import { memo as C, forwardRef as B, useMemo as N, useCallback as p } from "react";
3
+ import { c as h } from "./index-BOQuZ0gG.js";
4
+ import { c as v } from "./cn-B6yFEsav.js";
5
+ import { i as V } from "./iconUtils-rTOfKDxE.js";
6
+ import { Close as F } from "./Icons/Close.es.js";
7
+ import { A as K } from "./AvatarBase-sKVPLn_O.js";
8
+ const q = {
9
9
  small: "h-5 px-2 text-xs prometeo-fonts-body-small",
10
10
  medium: "h-8 px-3 text-sm prometeo-fonts-body-medium",
11
11
  large: "h-9 px-3 text-sm prometeo-fonts-body-medium"
12
- }, q = {
12
+ }, Q = {
13
13
  default: "text-neutral-default-default border-neutral-default-default bg-inherit rounded-lg font-semibold",
14
14
  error: "",
15
15
  success: ""
16
- }, Q = "border-neutral-strong-default text-neutral-default-disabled", Z = "text-neutral-default-disabled", $ = ["leading", "avatar"], J = ["default", "error", "success"];
17
- function W(e) {
18
- return $.includes(e);
19
- }
20
- function V(e) {
16
+ }, Z = "border-neutral-strong-default text-neutral-default-disabled", $ = "text-neutral-default-disabled", J = ["leading", "avatar"], W = ["default", "error", "success"];
17
+ function X(e) {
21
18
  return J.includes(e);
22
19
  }
23
- function X(e) {
24
- const a = e.layout ?? (W(e.variant) ? e.variant : void 0), s = e.semanticVariant ?? (V(e.variant) ? e.variant : void 0), i = a ?? (e.avatar ? "avatar" : "leading"), f = !!e.onRemove || !!e.size || !!s || !!e.semanticVariant || V(e.variant);
20
+ function H(e) {
21
+ return W.includes(e);
22
+ }
23
+ function ee(e) {
24
+ const a = e.layout ?? (X(e.variant) ? e.variant : void 0), s = e.semanticVariant ?? (H(e.variant) ? e.variant : void 0), i = a ?? (e.avatar ? "avatar" : "leading"), m = !!e.onRemove || !!e.size || !!s || !!e.semanticVariant || H(e.variant);
25
25
  return {
26
26
  layout: i,
27
27
  legacySemanticVariant: s,
28
- legacySizeClass: e.size ? K[e.size] : void 0,
29
- legacySemanticContainerClass: s ? q[s] : void 0,
28
+ legacySizeClass: e.size ? q[e.size] : void 0,
29
+ legacySemanticContainerClass: s ? Q[s] : void 0,
30
30
  useLegacyRemoveHandler: !!e.onRemove,
31
- isLegacyMode: f
31
+ isLegacyMode: m
32
32
  };
33
33
  }
34
- const ee = m(
34
+ const ae = h(
35
35
  "group/chip flex items-center gap-1 p-2 w-max h-8 radius-medium border transition-all duration-300 ease-in-out",
36
36
  {
37
37
  variants: {
@@ -118,7 +118,7 @@ const ee = m(
118
118
  }
119
119
  ]
120
120
  }
121
- ), ae = m(
121
+ ), re = h(
122
122
  "pyrion-fonts-label-medium transition-all duration-300 ease-in-out select-none",
123
123
  {
124
124
  variants: {
@@ -211,7 +211,7 @@ const ee = m(
211
211
  }
212
212
  ]
213
213
  }
214
- ), re = m("transition-all duration-300 ease-in-out", {
214
+ ), te = h("transition-all duration-300 ease-in-out", {
215
215
  variants: {
216
216
  isSelected: {
217
217
  true: "",
@@ -295,7 +295,7 @@ const ee = m(
295
295
  className: "icon-disabled-ondisabled group-hover/chip:icon-disabled-ondisabled group-active/chip:icon-disabled-ondisabled"
296
296
  }
297
297
  ]
298
- }), te = m(
298
+ }), se = h(
299
299
  "transition-all duration-300 ease-in-out border-neutral-default-default border",
300
300
  {
301
301
  variants: {
@@ -349,145 +349,146 @@ const ee = m(
349
349
  }
350
350
  ]
351
351
  }
352
- ), se = {
352
+ ), de = {
353
353
  size: "xsmall",
354
354
  name: "A B"
355
355
  };
356
- function de(e, a, s) {
356
+ function oe(e, a, s) {
357
357
  return {
358
358
  isSelected: !!e,
359
359
  disabled: !!a,
360
360
  forcedStatus: s
361
361
  };
362
362
  }
363
- function oe(e) {
363
+ function ne(e) {
364
364
  return N(
365
365
  () => ({
366
- container: ee(e),
367
- label: ae(e),
368
- icon: re(e),
369
- avatar: te(e)
366
+ container: ae(e),
367
+ label: re(e),
368
+ icon: te(e),
369
+ avatar: se(e)
370
370
  }),
371
371
  [e.isSelected, e.disabled, e.forcedStatus]
372
372
  );
373
373
  }
374
- const H = x(function({
374
+ const D = C(function({
375
375
  icon: a,
376
376
  className: s,
377
377
  size: i = 16
378
378
  }) {
379
379
  return /* @__PURE__ */ o.jsx(a, { size: i, className: s });
380
- }), ne = x(function({
380
+ }), ie = C(function({
381
381
  avatar: a,
382
382
  className: s
383
383
  }) {
384
- return /* @__PURE__ */ o.jsx(F, { ...a, className: s });
384
+ return /* @__PURE__ */ o.jsx(K, { ...a, className: s });
385
385
  });
386
- function ie(e, a) {
387
- return e.label === a.label && e.isSelected === a.isSelected && e.disabled === a.disabled && e.forcedStatus === a.forcedStatus && e.layout === a.layout && e.variant === a.variant && e.semanticVariant === a.semanticVariant && e.className === a.className && e.onRemove === a.onRemove && e.id === a.id && e.size === a.size && e.tabIndex === a.tabIndex && e.leadingIcon === a.leadingIcon && e.trailingIcon === a.trailingIcon && e.onClick === a.onClick && e.onTrailingIconClick === a.onTrailingIconClick && e.avatar?.imageUrl === a.avatar?.imageUrl && e.avatar?.name === a.avatar?.name;
386
+ function le(e, a) {
387
+ return e.label === a.label && e.isSelected === a.isSelected && e.disabled === a.disabled && e.forcedStatus === a.forcedStatus && e.layout === a.layout && e.variant === a.variant && e.semanticVariant === a.semanticVariant && e.className === a.className && e.onRemove === a.onRemove && e.id === a.id && e.size === a.size && e.tabIndex === a.tabIndex && e.leadingIcon === a.leadingIcon && e.leadingSlot === a.leadingSlot && e.trailingIcon === a.trailingIcon && e.onClick === a.onClick && e.onTrailingIconClick === a.onTrailingIconClick && e.avatar?.imageUrl === a.avatar?.imageUrl && e.avatar?.name === a.avatar?.name;
388
388
  }
389
- const le = x(
390
- U(function({
389
+ const ce = C(
390
+ B(function({
391
391
  isSelected: a = !1,
392
392
  label: s,
393
393
  leadingIcon: i,
394
- trailingIcon: f,
395
- forcedStatus: D,
396
- onTrailingIconClick: p,
394
+ leadingSlot: m,
395
+ trailingIcon: x,
396
+ forcedStatus: P,
397
+ onTrailingIconClick: f,
397
398
  onClick: l,
398
399
  disabled: r = !1,
399
400
  avatar: c,
400
- variant: C,
401
- layout: L,
402
- semanticVariant: A,
401
+ variant: L,
402
+ layout: A,
403
+ semanticVariant: I,
403
404
  onRemove: u,
404
405
  id: g,
405
- size: I,
406
+ size: _,
406
407
  tabIndex: y,
407
- className: P
408
- }, j) {
408
+ className: j
409
+ }, T) {
409
410
  const t = N(
410
- () => X({
411
- layout: L,
412
- variant: C,
413
- semanticVariant: A,
411
+ () => ee({
412
+ layout: A,
413
+ variant: L,
414
+ semanticVariant: I,
414
415
  avatar: c,
415
416
  onRemove: u,
416
- size: I
417
+ size: _
417
418
  }),
418
- [L, C, A, c, u, I]
419
- ), T = de(a, r, D), b = oe(T), _ = R(i) ? i : null, S = R(f) ? f : t.useLegacyRemoveHandler ? B : null, z = N(
420
- () => ({ ...se, ...c }),
419
+ [A, L, I, c, u, _]
420
+ ), z = oe(a, r, P), b = ne(z), E = V(i) ? i : null, S = V(x) ? x : t.useLegacyRemoveHandler ? F : null, M = N(
421
+ () => ({ ...de, ...c }),
421
422
  [c?.imageUrl, c?.name]
422
- ), n = !r && !!l, E = t.layout === "avatar", M = y !== void 0 ? y : n ? 0 : void 0, w = v(
423
+ ), n = !r && !!l, R = t.layout === "avatar", w = y !== void 0 ? y : n ? 0 : void 0, Y = p(
423
424
  (d) => {
424
- r || (d.preventDefault(), d.stopPropagation(), p?.(d));
425
+ r || (d.preventDefault(), d.stopPropagation(), f?.(d));
425
426
  },
426
- [r, p]
427
- ), Y = v(
427
+ [r, f]
428
+ ), k = p(
428
429
  (d) => {
429
430
  r || (d.stopPropagation(), d.preventDefault(), g != null && u?.(g));
430
431
  },
431
432
  [r, g, u]
432
- ), k = v(
433
+ ), G = p(
433
434
  (d) => {
434
435
  r || l?.(d);
435
436
  },
436
437
  [r, l]
437
- ), G = v(
438
+ ), O = p(
438
439
  (d) => {
439
440
  !n || r || d.key !== "Enter" && d.key !== " " || (d.preventDefault(), l?.(d));
440
441
  },
441
442
  [r, n, l]
442
- ), O = !!S && (!!p || t.useLegacyRemoveHandler);
443
+ ), U = !!S && (!!f || t.useLegacyRemoveHandler);
443
444
  return /* @__PURE__ */ o.jsxs(
444
445
  "div",
445
446
  {
446
- ref: j,
447
- className: h(
447
+ ref: T,
448
+ className: v(
448
449
  b.container,
449
450
  !t.legacySizeClass && "h-8",
450
451
  t.legacySizeClass,
451
452
  t.legacySemanticContainerClass,
452
453
  t.isLegacyMode && "inline-flex font-semibold",
453
454
  n && "cursor-pointer",
454
- r && t.isLegacyMode && Q,
455
+ r && t.isLegacyMode && Z,
455
456
  r && "pointer-events-none",
456
- P
457
+ j
457
458
  ),
458
- onClick: n ? k : void 0,
459
- onKeyDown: n ? G : void 0,
459
+ onClick: n ? G : void 0,
460
+ onKeyDown: n ? O : void 0,
460
461
  "aria-disabled": r || void 0,
461
462
  role: n ? "button" : void 0,
462
- tabIndex: M,
463
+ tabIndex: w,
463
464
  children: [
464
465
  /* @__PURE__ */ o.jsxs("div", { className: "flex items-center gap-1 min-w-0", children: [
465
- _ && !E && /* @__PURE__ */ o.jsx(H, { icon: _, className: b.icon }),
466
- E && /* @__PURE__ */ o.jsx(ne, { avatar: z, className: b.avatar }),
467
- /* @__PURE__ */ o.jsx("span", { className: h(b.label, "truncate"), children: s })
466
+ !R && (m ?? (E && /* @__PURE__ */ o.jsx(D, { icon: E, className: b.icon }))),
467
+ R && /* @__PURE__ */ o.jsx(ie, { avatar: M, className: b.avatar }),
468
+ /* @__PURE__ */ o.jsx("span", { className: v(b.label, "truncate"), children: s })
468
469
  ] }),
469
- O && S && /* @__PURE__ */ o.jsx(
470
+ U && S && /* @__PURE__ */ o.jsx(
470
471
  "button",
471
472
  {
472
473
  type: "button",
473
474
  disabled: r,
474
475
  tabIndex: y,
475
- onMouseDown: t.useLegacyRemoveHandler ? Y : void 0,
476
- onClick: t.useLegacyRemoveHandler ? void 0 : w,
477
- className: h(
476
+ onMouseDown: t.useLegacyRemoveHandler ? k : void 0,
477
+ onClick: t.useLegacyRemoveHandler ? void 0 : Y,
478
+ className: v(
478
479
  "shrink-0",
479
- (p || u) && !r && "cursor-pointer",
480
+ (f || u) && !r && "cursor-pointer",
480
481
  t.useLegacyRemoveHandler && "p-0.5 z-10 transition-all duration-200 hover:scale-105",
481
482
  t.useLegacyRemoveHandler && r && "cursor-default hover:scale-100"
482
483
  ),
483
484
  "aria-label": `Quitar ${s}`,
484
485
  children: /* @__PURE__ */ o.jsx(
485
- H,
486
+ D,
486
487
  {
487
488
  icon: S,
488
- className: h(
489
+ className: v(
489
490
  b.icon,
490
- r && t.isLegacyMode && Z
491
+ r && t.isLegacyMode && $
491
492
  ),
492
493
  size: t.useLegacyRemoveHandler ? 18 : 16
493
494
  }
@@ -498,9 +499,9 @@ const le = x(
498
499
  }
499
500
  );
500
501
  }),
501
- ie
502
+ le
502
503
  );
503
- le.displayName = "Chip";
504
+ ce.displayName = "Chip";
504
505
  export {
505
- le as default
506
+ ce as default
506
507
  };
@@ -1,3 +1,4 @@
1
+ import { default as React } from 'react';
1
2
  import { IconComponent } from '../../Icons';
2
3
  import { ComponentVariant, SizeVariant } from '../Shared/types';
3
4
  import { AvatarBaseProps } from '../Avatar/AvatarBase';
@@ -6,7 +7,7 @@ export type ChipAvatarProps = Pick<AvatarBaseProps, "imageUrl" | "name">;
6
7
  export type ChipForcedStatus = "default" | "hovered" | "pressed" | "disabled";
7
8
  /** Layout del chip o variante semántica legacy. */
8
9
  export type ChipVariantProp = ChipLayout | ComponentVariant;
9
- export interface ChipProps {
10
+ interface ChipBaseProps {
10
11
  label: string;
11
12
  layout?: ChipLayout;
12
13
  /**
@@ -19,7 +20,6 @@ export interface ChipProps {
19
20
  */
20
21
  semanticVariant?: ComponentVariant;
21
22
  isSelected?: boolean;
22
- leadingIcon?: IconComponent;
23
23
  trailingIcon?: IconComponent;
24
24
  onTrailingIconClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
25
25
  onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
@@ -41,6 +41,15 @@ export interface ChipProps {
41
41
  /** @deprecated Evitá overridear estilos del sistema. */
42
42
  className?: string;
43
43
  }
44
+ type ChipPropsWithLeadingIcon = ChipBaseProps & {
45
+ leadingIcon?: IconComponent;
46
+ leadingSlot?: never;
47
+ };
48
+ type ChipPropsWithLeadingSlot = ChipBaseProps & {
49
+ leadingSlot?: React.ReactNode;
50
+ leadingIcon?: never;
51
+ };
52
+ export type ChipProps = ChipPropsWithLeadingIcon | ChipPropsWithLeadingSlot;
44
53
  export type ResolvedChipConfig = {
45
54
  layout: ChipLayout;
46
55
  legacySemanticVariant?: ComponentVariant;
@@ -53,3 +62,4 @@ export declare function isChipLayout(value?: string): value is ChipLayout;
53
62
  export declare function isLegacySemanticVariant(value?: string): value is ComponentVariant;
54
63
  export type ChipConfigInput = Pick<ChipProps, "layout" | "variant" | "semanticVariant" | "avatar" | "onRemove" | "size">;
55
64
  export declare function resolveChipConfig(props: ChipConfigInput): ResolvedChipConfig;
65
+ export {};