@snksergio/design-system 0.52.0 → 0.53.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.
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
5
- import { forwardRef, createContext, useContext, useId, useRef, useState, useCallback, useEffect, useMemo, Fragment as Fragment$1, useImperativeHandle, memo } from "react";
5
+ import { createContext, forwardRef, useContext, useState, Children, isValidElement, useId, useRef, useCallback, useEffect, useMemo, Fragment as Fragment$1, useImperativeHandle, memo } from "react";
6
6
  import { A as AlertDialog, c as AlertDialogContent, f as AlertDialogHeader, i as AlertDialogTitle, d as AlertDialogDescription, e as AlertDialogFooter, b as AlertDialogCancel, a as AlertDialogAction, T as Textarea, S as Select, D as SelectTrigger, E as SelectValue, u as SelectContent, w as SelectItem, l as Checkbox, Q as Switch, C as Calendar$1, R as getPaginationRange, P as Pagination, o as PaginationFirst, t as PaginationPrevious, m as PaginationContent, p as PaginationItem, n as PaginationEllipsis, r as PaginationLink, s as PaginationNext, q as PaginationLast, N as SheetTitle, I as SheetDescription, G as SheetClose, F as Sheet, O as SheetTrigger, L as SheetOverlay } from "./sheet-DIpYkRYS.mjs";
7
7
  import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, closestCorners, DragOverlay, useDroppable, useDraggable, closestCenter } from "@dnd-kit/core";
8
8
  import { useSortable, sortableKeyboardCoordinates, SortableContext, horizontalListSortingStrategy, arrayMove } from "@dnd-kit/sortable";
@@ -158,6 +158,7 @@ function getContrastTextColor(bgColor) {
158
158
  const blackContrast = contrastRatio(0, bgLum);
159
159
  return whiteContrast >= blackContrast ? "white" : "black";
160
160
  }
161
+ const AvatarGroupContext = createContext(void 0);
161
162
  const avatarVariants = tv({
162
163
  base: [
163
164
  "inline-flex items-center justify-center",
@@ -197,21 +198,59 @@ const avatarVariants = tv({
197
198
  color: "muted"
198
199
  }
199
200
  });
201
+ const avatarGroupRoot = tv({ base: "flex items-center" });
202
+ const avatarGroupItem = tv({
203
+ base: ["relative inline-flex rounded-radius-full ring-2"],
204
+ variants: {
205
+ /** Deslocamento negativo ≈ 25% do diâmetro, em token. Ver o bloco acima. */
206
+ size: {
207
+ xs: "-ml-sp-xs",
208
+ // 20px → 4
209
+ sm: "-ml-sp-sm",
210
+ // 24px → 6
211
+ md: "-ml-sp-sm",
212
+ // 28px → 6
213
+ lg: "-ml-sp-md",
214
+ // 32px → 8
215
+ xl: "-ml-sp-lg"
216
+ // 40px → 10
217
+ },
218
+ /** Cor do anel = superfície de trás. */
219
+ surface: {
220
+ surface: "ring-bg-surface",
221
+ canvas: "ring-bg-canvas",
222
+ subtle: "ring-bg-subtle",
223
+ muted: "ring-bg-muted",
224
+ table: "ring-bg-table"
225
+ },
226
+ /** O primeiro não desloca — senão a pilha inteira sai da margem esquerda. */
227
+ primeiro: { true: "ml-0" }
228
+ },
229
+ defaultVariants: {
230
+ size: "md",
231
+ surface: "surface"
232
+ }
233
+ });
200
234
  const Avatar = forwardRef(
201
235
  function Avatar2({
202
236
  size,
203
237
  color,
204
238
  colorHex,
239
+ src,
205
240
  children,
206
241
  className,
207
242
  style,
208
243
  "aria-label": ariaLabel,
209
244
  ...rest
210
245
  }, ref) {
246
+ const grupo = useContext(AvatarGroupContext);
247
+ const sizeEfetivo = size ?? grupo?.size;
248
+ const [urlQueFalhou, setUrlQueFalhou] = useState(null);
249
+ const mostraFoto = typeof src === "string" && src !== "" && urlQueFalhou !== src;
211
250
  const isHex = typeof colorHex === "string" && colorHex.startsWith("#");
212
251
  const autoTextClass = isHex ? getContrastTextColor(colorHex) === "black" ? "text-black" : "text-white" : null;
213
252
  const computedClassName = avatarVariants({
214
- size,
253
+ size: sizeEfetivo,
215
254
  color: isHex ? "_custom" : color,
216
255
  className: isHex ? [autoTextClass, className].filter(Boolean).join(" ") : className
217
256
  });
@@ -224,12 +263,72 @@ const Avatar = forwardRef(
224
263
  style: computedStyle,
225
264
  ...ariaLabel ? { role: "img", "aria-label": ariaLabel } : { "aria-hidden": true },
226
265
  ...rest,
227
- children
266
+ children: mostraFoto ? /* @__PURE__ */ jsx(
267
+ "img",
268
+ {
269
+ src,
270
+ alt: "",
271
+ className: "size-full object-cover",
272
+ draggable: false,
273
+ onError: () => setUrlQueFalhou(src ?? null)
274
+ }
275
+ ) : children
228
276
  }
229
277
  );
230
278
  }
231
279
  );
232
280
  Avatar.displayName = "Avatar";
281
+ const AvatarGroup = forwardRef(
282
+ function AvatarGroup2({
283
+ size = "md",
284
+ max,
285
+ total,
286
+ surface = "surface",
287
+ children,
288
+ className,
289
+ "aria-label": ariaLabel,
290
+ ...rest
291
+ }, ref) {
292
+ const itens = Children.toArray(children).filter(isValidElement);
293
+ const visiveis = typeof max === "number" ? itens.slice(0, max) : itens;
294
+ const escondidos = (total ?? itens.length) - visiveis.length;
295
+ return /* @__PURE__ */ jsx(AvatarGroupContext.Provider, { value: { size, surface }, children: /* @__PURE__ */ jsxs(
296
+ "div",
297
+ {
298
+ ref,
299
+ className: avatarGroupRoot({ className }),
300
+ role: "group",
301
+ "aria-label": ariaLabel,
302
+ ...rest,
303
+ children: [
304
+ visiveis.map((filho, i) => /* @__PURE__ */ jsx(
305
+ "span",
306
+ {
307
+ className: avatarGroupItem({ size, surface, primeiro: i === 0 }),
308
+ style: { zIndex: visiveis.length - i },
309
+ children: filho
310
+ },
311
+ i
312
+ )),
313
+ escondidos > 0 && /* O `+N` é `aria-hidden`: a contagem real já está no `aria-label` do grupo, e
314
+ anunciar "mais 9" solto não diz de quê. */
315
+ /* @__PURE__ */ jsx(
316
+ "span",
317
+ {
318
+ className: avatarGroupItem({ size, surface, primeiro: false }),
319
+ style: { zIndex: 0 },
320
+ children: /* @__PURE__ */ jsxs(Avatar, { size, color: "muted", "aria-hidden": true, children: [
321
+ "+",
322
+ escondidos
323
+ ] })
324
+ }
325
+ )
326
+ ]
327
+ }
328
+ ) });
329
+ }
330
+ );
331
+ AvatarGroup.displayName = "AvatarGroup";
233
332
  const buttonGroupVariants = tv({
234
333
  base: [
235
334
  "inline-flex items-stretch",
@@ -12987,58 +13086,61 @@ function Panel({
12987
13086
  ] });
12988
13087
  }
12989
13088
  export {
12990
- SortPanel as $,
13089
+ SELECTION_COLUMN_WIDTH as $,
12991
13090
  AlertModal as A,
12992
13091
  BulkActionButton as B,
12993
13092
  ColsPanel as C,
12994
13093
  DataTable as D,
12995
- DataTableEmpty as E,
13094
+ DataTableEditCell as E,
12996
13095
  FormFieldInput as F,
12997
- DataTableFloatingBulkBar as G,
12998
- DataTableLoading as H,
12999
- DataTableNoResults as I,
13000
- DataTableTotalizerRow as J,
13001
- FLOATING_PANEL_SIZE_PX as K,
13096
+ DataTableEmpty as G,
13097
+ DataTableFloatingBulkBar as H,
13098
+ DataTableLoading as I,
13099
+ DataTableNoResults as J,
13100
+ DataTableTotalizerRow as K,
13002
13101
  ListItem as L,
13003
- FilterPanel as M,
13004
- FloatingPanelField as N,
13005
- FloatingPanelSection as O,
13102
+ FLOATING_PANEL_SIZE_PX as M,
13103
+ FilterPanel as N,
13104
+ FloatingPanelField as O,
13006
13105
  Panel as P,
13007
- FooterTable as Q,
13008
- FooterTableSkeleton as R,
13009
- FormFieldCheckbox as S,
13106
+ FloatingPanelSection as Q,
13107
+ FooterTable as R,
13108
+ FooterTableSkeleton as S,
13010
13109
  ToolbarToolButton as T,
13011
- FormFieldSwitch as U,
13012
- Kanban as V,
13013
- MoreMenu as W,
13014
- PanelBody as X,
13015
- PanelFooter as Y,
13016
- PanelHeader as Z,
13017
- SELECTION_COLUMN_WIDTH as _,
13110
+ FormFieldCheckbox as U,
13111
+ FormFieldSwitch as V,
13112
+ Kanban as W,
13113
+ MoreMenu as X,
13114
+ PanelBody as Y,
13115
+ PanelFooter as Z,
13116
+ PanelHeader as _,
13018
13117
  FormField as a,
13019
- SortPopover as a0,
13020
- TABLE_HEADER_HEIGHT as a1,
13021
- Table as a2,
13022
- TableBody as a3,
13023
- TableCardRow as a4,
13024
- TableCell as a5,
13025
- TableHead as a6,
13026
- TableHeadCell as a7,
13027
- TableRow as a8,
13028
- TableToolbarViews as a9,
13029
- ToolbarDivider as aa,
13030
- ToolbarSaveButton as ab,
13031
- ToolbarSegmented as ac,
13032
- ToolbarSettingsMenu as ad,
13033
- ViewsPopover as ae,
13034
- avatarVariants as af,
13035
- floatingPanelStyles as ag,
13036
- panelContainer as ah,
13037
- savedViewsMockService as ai,
13038
- useColumnResize as aj,
13039
- useColumnWidths as ak,
13040
- useDataTableContext as al,
13041
- useFloatingPanelResize as am,
13118
+ SortPanel as a0,
13119
+ SortPopover as a1,
13120
+ TABLE_HEADER_HEIGHT as a2,
13121
+ Table as a3,
13122
+ TableBody as a4,
13123
+ TableCardRow as a5,
13124
+ TableCell as a6,
13125
+ TableHead as a7,
13126
+ TableHeadCell as a8,
13127
+ TableRow as a9,
13128
+ TableToolbarViews as aa,
13129
+ ToolbarDivider as ab,
13130
+ ToolbarSaveButton as ac,
13131
+ ToolbarSegmented as ad,
13132
+ ToolbarSettingsMenu as ae,
13133
+ ViewsPopover as af,
13134
+ avatarGroupItem as ag,
13135
+ avatarGroupRoot as ah,
13136
+ avatarVariants as ai,
13137
+ floatingPanelStyles as aj,
13138
+ panelContainer as ak,
13139
+ savedViewsMockService as al,
13140
+ useColumnResize as am,
13141
+ useColumnWidths as an,
13142
+ useDataTableContext as ao,
13143
+ useFloatingPanelResize as ap,
13042
13144
  FormFieldSelect as b,
13043
13145
  FormFieldTextarea as c,
13044
13146
  FloatingPanel as d,
@@ -13058,11 +13160,11 @@ export {
13058
13160
  columnTypeRegistry as r,
13059
13161
  List as s,
13060
13162
  AddViewModal as t,
13061
- BulkActionsBar as u,
13062
- ColsPopover as v,
13063
- Combobox as w,
13064
- DEFAULT_FILTER_OPERATORS as x,
13065
- DataTableActionsCell as y,
13066
- DataTableEditCell as z
13163
+ AvatarGroup as u,
13164
+ BulkActionsBar as v,
13165
+ ColsPopover as w,
13166
+ Combobox as x,
13167
+ DEFAULT_FILTER_OPERATORS as y,
13168
+ DataTableActionsCell as z
13067
13169
  };
13068
- //# sourceMappingURL=panel-DA6K3a3n.mjs.map
13170
+ //# sourceMappingURL=panel-DsOKm4Im.mjs.map