@snksergio/design-system 0.41.0 → 0.42.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.
@@ -8010,6 +8010,38 @@ function measureTextWidth(text, font) {
8010
8010
  if (!ctx) return 0;
8011
8011
  return ctx.measureText(text).width;
8012
8012
  }
8013
+ const ACTIONS_INLINE_MAX = 3;
8014
+ function actionsWidthForSlots(slots) {
8015
+ return 30 * Math.max(1, slots) + 14;
8016
+ }
8017
+ function oculta(a, row) {
8018
+ return typeof a.hidden === "function" ? a.hidden(row) : !!a.hidden;
8019
+ }
8020
+ function splitActionSlots(actions, row) {
8021
+ const visiveis = actions.filter((a) => !oculta(a, row));
8022
+ if (visiveis.length === 0) return { inline: [], menu: [] };
8023
+ if (visiveis.some((a) => a.showInMenu)) {
8024
+ return {
8025
+ inline: visiveis.filter((a) => !a.showInMenu),
8026
+ menu: visiveis.filter((a) => a.showInMenu)
8027
+ };
8028
+ }
8029
+ if (visiveis.length <= ACTIONS_INLINE_MAX) return { inline: visiveis, menu: [] };
8030
+ return { inline: [], menu: visiveis };
8031
+ }
8032
+ function countActionSlots(split) {
8033
+ return split.inline.length + (split.menu.length > 0 ? 1 : 0);
8034
+ }
8035
+ function measureActionsWidth(getActions, rows) {
8036
+ if (!getActions || rows.length === 0) return null;
8037
+ let maxSlots = 0;
8038
+ for (const row of rows) {
8039
+ const slots = countActionSlots(splitActionSlots(getActions({ row }), row));
8040
+ if (slots > maxSlots) maxSlots = slots;
8041
+ }
8042
+ if (maxSlots === 0) return null;
8043
+ return actionsWidthForSlots(maxSlots);
8044
+ }
8013
8045
  function getFieldValue(row, field) {
8014
8046
  if (!field.includes(".")) {
8015
8047
  return row[field];
@@ -8049,7 +8081,7 @@ function calculateColumnWidths(columns, rows, options) {
8049
8081
  for (const col of columns) {
8050
8082
  const field = String(col.field);
8051
8083
  if (col.type === "actions") {
8052
- const w = col.minWidth ?? ACTIONS_COLUMN_WIDTH;
8084
+ const w = col.width ?? col.minWidth ?? measureActionsWidth(col.getActions, rows.slice(0, sampleSize)) ?? ACTIONS_COLUMN_WIDTH;
8053
8085
  widths[field] = w;
8054
8086
  totalContentWidth += w;
8055
8087
  continue;
@@ -9844,13 +9876,8 @@ function DataTableActionsCell({
9844
9876
  row,
9845
9877
  actions
9846
9878
  }) {
9847
- const visible = actions.filter((a) => {
9848
- if (typeof a.hidden === "function") return !a.hidden(row);
9849
- return !a.hidden;
9850
- });
9851
- const inlineActions = visible.filter((a) => !a.showInMenu);
9852
- const menuActions = visible.filter((a) => a.showInMenu);
9853
- if (visible.length === 0) return null;
9879
+ const { inline: inlineActions, menu: menuActions } = splitActionSlots(actions, row);
9880
+ if (inlineActions.length === 0 && menuActions.length === 0) return null;
9854
9881
  const resolveDisabled = (a) => {
9855
9882
  if (typeof a.disabled === "function") return a.disabled(row);
9856
9883
  return !!a.disabled;
@@ -12895,59 +12922,58 @@ function Panel({
12895
12922
  ] });
12896
12923
  }
12897
12924
  export {
12898
- SELECTION_COLUMN_WIDTH as $,
12925
+ SortPanel as $,
12899
12926
  AlertModal as A,
12900
12927
  BulkActionButton as B,
12901
12928
  ColsPanel as C,
12902
12929
  DataTable as D,
12903
- DataTableEditCell as E,
12930
+ DataTableEmpty as E,
12904
12931
  FormFieldInput as F,
12905
- DataTableEmpty as G,
12906
- DataTableFloatingBulkBar as H,
12907
- DataTableLoading as I,
12908
- DataTableNoResults as J,
12909
- DataTableTotalizerRow as K,
12932
+ DataTableFloatingBulkBar as G,
12933
+ DataTableLoading as H,
12934
+ DataTableNoResults as I,
12935
+ DataTableTotalizerRow as J,
12936
+ FLOATING_PANEL_SIZE_PX as K,
12910
12937
  ListItem as L,
12911
- FLOATING_PANEL_SIZE_PX as M,
12912
- FilterPanel as N,
12913
- FloatingPanelField as O,
12938
+ FilterPanel as M,
12939
+ FloatingPanelField as N,
12940
+ FloatingPanelSection as O,
12914
12941
  Panel as P,
12915
- FloatingPanelSection as Q,
12916
- FooterTable as R,
12917
- FooterTableSkeleton as S,
12942
+ FooterTable as Q,
12943
+ FooterTableSkeleton as R,
12944
+ FormFieldCheckbox as S,
12918
12945
  ToolbarToolButton as T,
12919
- FormFieldCheckbox as U,
12920
- FormFieldSwitch as V,
12921
- Kanban as W,
12922
- MoreMenu as X,
12923
- PanelBody as Y,
12924
- PanelFooter as Z,
12925
- PanelHeader as _,
12946
+ FormFieldSwitch as U,
12947
+ Kanban as V,
12948
+ MoreMenu as W,
12949
+ PanelBody as X,
12950
+ PanelFooter as Y,
12951
+ PanelHeader as Z,
12952
+ SELECTION_COLUMN_WIDTH as _,
12926
12953
  FormField as a,
12927
- SortPanel as a0,
12928
- SortPopover as a1,
12929
- TABLE_HEADER_HEIGHT as a2,
12930
- Table as a3,
12931
- TableBody as a4,
12932
- TableCardRow as a5,
12933
- TableCell as a6,
12934
- TableHead as a7,
12935
- TableHeadCell as a8,
12936
- TableRow as a9,
12937
- TableToolbarViews as aa,
12938
- ToolbarDivider as ab,
12939
- ToolbarSaveButton as ac,
12940
- ToolbarSegmented as ad,
12941
- ToolbarSettingsMenu as ae,
12942
- ViewsPopover as af,
12943
- avatarVariants as ag,
12944
- floatingPanelStyles as ah,
12945
- panelContainer as ai,
12946
- savedViewsMockService as aj,
12947
- useColumnResize as ak,
12948
- useColumnWidths as al,
12949
- useDataTableContext as am,
12950
- useFloatingPanelResize as an,
12954
+ SortPopover as a0,
12955
+ TABLE_HEADER_HEIGHT as a1,
12956
+ Table as a2,
12957
+ TableBody as a3,
12958
+ TableCardRow as a4,
12959
+ TableCell as a5,
12960
+ TableHead as a6,
12961
+ TableHeadCell as a7,
12962
+ TableRow as a8,
12963
+ TableToolbarViews as a9,
12964
+ ToolbarDivider as aa,
12965
+ ToolbarSaveButton as ab,
12966
+ ToolbarSegmented as ac,
12967
+ ToolbarSettingsMenu as ad,
12968
+ ViewsPopover as ae,
12969
+ avatarVariants as af,
12970
+ floatingPanelStyles as ag,
12971
+ panelContainer as ah,
12972
+ savedViewsMockService as ai,
12973
+ useColumnResize as aj,
12974
+ useColumnWidths as ak,
12975
+ useDataTableContext as al,
12976
+ useFloatingPanelResize as am,
12951
12977
  FormFieldSelect as b,
12952
12978
  FormFieldTextarea as c,
12953
12979
  FloatingPanel as d,
@@ -12957,21 +12983,21 @@ export {
12957
12983
  ButtonGroup as h,
12958
12984
  isFilterEntryActive as i,
12959
12985
  ToolbarSimpleFilterDrawer as j,
12960
- ACTIONS_COLUMN_WIDTH as k,
12961
- TableToolbar as l,
12962
- ToolbarActions as m,
12963
- ToolbarFilterButton as n,
12964
- ToolbarSearch as o,
12986
+ TableToolbar as k,
12987
+ ToolbarActions as l,
12988
+ ToolbarFilterButton as m,
12989
+ ToolbarSearch as n,
12990
+ ToolbarApplied as o,
12965
12991
  presetView as p,
12966
- ToolbarApplied as q,
12967
- ToolbarTabs as r,
12968
- columnTypeRegistry as s,
12969
- List as t,
12970
- AddViewModal as u,
12971
- BulkActionsBar as v,
12972
- ColsPopover as w,
12973
- Combobox as x,
12974
- DEFAULT_FILTER_OPERATORS as y,
12975
- DataTableActionsCell as z
12992
+ ToolbarTabs as q,
12993
+ columnTypeRegistry as r,
12994
+ List as s,
12995
+ AddViewModal as t,
12996
+ BulkActionsBar as u,
12997
+ ColsPopover as v,
12998
+ Combobox as w,
12999
+ DEFAULT_FILTER_OPERATORS as x,
13000
+ DataTableActionsCell as y,
13001
+ DataTableEditCell as z
12976
13002
  };
12977
- //# sourceMappingURL=panel-Bje0kUTh.mjs.map
13003
+ //# sourceMappingURL=panel-BI52RBEn.mjs.map