@nubitio/ui 1.1.1 → 1.1.2

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/index.cjs CHANGED
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
16
16
  }
17
17
  return to;
18
18
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
20
20
  value: mod,
21
21
  enumerable: true
22
22
  }) : target, mod));
@@ -65,12 +65,13 @@ const Avatar = ({ owner = "", size, variant = "md", shape = "circle", alt, class
65
65
  const px = size ?? NAMED_SIZES[variant];
66
66
  const initials = getAvatarInitials(owner);
67
67
  const hue = getAvatarHue(owner);
68
+ const classes = [
69
+ "nb-avatar",
70
+ shape === "square" && "nb-avatar--square",
71
+ className
72
+ ].filter(Boolean).join(" ");
68
73
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
69
- className: [
70
- "nb-avatar",
71
- shape === "square" && "nb-avatar--square",
72
- className
73
- ].filter(Boolean).join(" "),
74
+ className: classes,
74
75
  role: "img",
75
76
  "aria-label": alt ?? (owner || "Avatar"),
76
77
  style: {
@@ -138,7 +139,38 @@ const EN_UI_STRINGS = {
138
139
  view: "View",
139
140
  pages: "Pages",
140
141
  previousPage: "Previous page",
141
- nextPage: "Next page"
142
+ nextPage: "Next page",
143
+ settingsMenu: "Display settings",
144
+ accentColor: "Accent color",
145
+ accentColors: "Accent colors",
146
+ density: "Density",
147
+ interfaceDensity: "Interface density",
148
+ densityNormal: "Normal",
149
+ densityCompact: "Compact",
150
+ mainNavigation: "Main navigation",
151
+ mainMenu: "Main menu",
152
+ closeMenu: "Close menu",
153
+ toggleMenu: "Toggle menu",
154
+ mainToolbar: "Main toolbar",
155
+ mainContent: "Main content",
156
+ userMenu: "User menu",
157
+ loadingSession: "Loading session",
158
+ textFormatting: "Text formatting",
159
+ bold: "Bold (Ctrl+B)",
160
+ italic: "Italic (Ctrl+I)",
161
+ strikethrough: "Strikethrough",
162
+ heading2: "Heading 2",
163
+ heading3: "Heading 3",
164
+ bulletList: "Bullet list",
165
+ orderedList: "Ordered list",
166
+ blockquote: "Blockquote",
167
+ addLink: "Add link",
168
+ removeLink: "Remove link",
169
+ undo: "Undo (Ctrl+Z)",
170
+ redo: "Redo (Ctrl+Y)",
171
+ featureUnavailable: "This feature is not available on your current plan.",
172
+ featureRequiresPlan: "This feature requires the {plan} plan. Upgrade your plan to unlock it.",
173
+ viewPlans: "View plans"
142
174
  };
143
175
  const ES_UI_STRINGS = {
144
176
  close: "Cerrar",
@@ -166,7 +198,38 @@ const ES_UI_STRINGS = {
166
198
  view: "Ver",
167
199
  pages: "Páginas",
168
200
  previousPage: "Página anterior",
169
- nextPage: "Página siguiente"
201
+ nextPage: "Página siguiente",
202
+ settingsMenu: "Ajustes de visualización",
203
+ accentColor: "Color de acento",
204
+ accentColors: "Colores de acento",
205
+ density: "Densidad",
206
+ interfaceDensity: "Densidad de interfaz",
207
+ densityNormal: "Normal",
208
+ densityCompact: "Compacta",
209
+ mainNavigation: "Navegación principal",
210
+ mainMenu: "Menú principal",
211
+ closeMenu: "Cerrar menú",
212
+ toggleMenu: "Alternar menú",
213
+ mainToolbar: "Barra de herramientas principal",
214
+ mainContent: "Contenido principal",
215
+ userMenu: "Menú de usuario",
216
+ loadingSession: "Cargando sesión",
217
+ textFormatting: "Formato de texto",
218
+ bold: "Negrita (Ctrl+B)",
219
+ italic: "Cursiva (Ctrl+I)",
220
+ strikethrough: "Tachado",
221
+ heading2: "Título 2",
222
+ heading3: "Título 3",
223
+ bulletList: "Lista con viñetas",
224
+ orderedList: "Lista numerada",
225
+ blockquote: "Cita",
226
+ addLink: "Añadir enlace",
227
+ removeLink: "Quitar enlace",
228
+ undo: "Deshacer (Ctrl+Z)",
229
+ redo: "Rehacer (Ctrl+Y)",
230
+ featureUnavailable: "Esta función no está disponible en tu plan actual.",
231
+ featureRequiresPlan: "Esta función requiere el plan {plan}. Actualiza tu plan para desbloquearla.",
232
+ viewPlans: "Ver planes"
170
233
  };
171
234
  const UiStringsContext = (0, react.createContext)(EN_UI_STRINGS);
172
235
  const UiStringsProvider = ({ strings, children }) => {
@@ -285,6 +348,7 @@ const AppDialog = ({ visible, open, title, onClose, children, footer, width, max
285
348
  function ConfirmDialog({ open, title, message, onConfirm, onCancel, confirmLabel, cancelLabel, variant = "warning" }) {
286
349
  const strings = useUiStrings();
287
350
  const resolvedConfirmLabel = confirmLabel ?? strings.confirm;
351
+ const resolvedCancelLabel = cancelLabel ?? strings.cancel;
288
352
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AppDialog, {
289
353
  open,
290
354
  title,
@@ -295,7 +359,7 @@ function ConfirmDialog({ open, title, message, onConfirm, onCancel, confirmLabel
295
359
  variant: "secondary",
296
360
  onClick: onCancel,
297
361
  autoFocus: true,
298
- children: cancelLabel ?? strings.cancel
362
+ children: resolvedCancelLabel
299
363
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
300
364
  variant: variant === "danger" ? "danger" : "primary",
301
365
  onClick: onConfirm,
@@ -1174,21 +1238,22 @@ function useAccentColor() {
1174
1238
  //#endregion
1175
1239
  //#region packages/ui/SettingsPanel.tsx
1176
1240
  const SettingsPanel = ({ onClose: _onClose }) => {
1241
+ const strings = useUiStrings();
1177
1242
  const { density, toggleDensity } = useDensity();
1178
1243
  const { accent, changeAccent, presets } = useAccentColor();
1179
1244
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1180
1245
  className: "nb-settings-panel",
1181
1246
  role: "menu",
1182
- "aria-label": "Display settings",
1247
+ "aria-label": strings.settingsMenu,
1183
1248
  children: [
1184
1249
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1185
1250
  className: "nb-settings-panel__heading",
1186
- children: "Color de acento"
1251
+ children: strings.accentColor
1187
1252
  }),
1188
1253
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1189
1254
  className: "nb-settings-panel__swatches",
1190
1255
  role: "group",
1191
- "aria-label": "Colores de acento",
1256
+ "aria-label": strings.accentColors,
1192
1257
  children: presets.map((preset) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1193
1258
  className: "nb-settings-panel__swatch",
1194
1259
  type: "button",
@@ -1205,12 +1270,12 @@ const SettingsPanel = ({ onClose: _onClose }) => {
1205
1270
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("hr", { className: "nb-settings-panel__divider" }),
1206
1271
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1207
1272
  className: "nb-settings-panel__heading",
1208
- children: "Densidad"
1273
+ children: strings.density
1209
1274
  }),
1210
1275
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1211
1276
  className: "nb-settings-panel__density",
1212
1277
  role: "group",
1213
- "aria-label": "Densidad de interfaz",
1278
+ "aria-label": strings.interfaceDensity,
1214
1279
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1215
1280
  className: "nb-settings-panel__density-btn",
1216
1281
  type: "button",
@@ -1219,7 +1284,7 @@ const SettingsPanel = ({ onClose: _onClose }) => {
1219
1284
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
1220
1285
  className: "ph ph-rows",
1221
1286
  "aria-hidden": "true"
1222
- }), "Normal"]
1287
+ }), strings.densityNormal]
1223
1288
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1224
1289
  className: "nb-settings-panel__density-btn",
1225
1290
  type: "button",
@@ -1228,7 +1293,7 @@ const SettingsPanel = ({ onClose: _onClose }) => {
1228
1293
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
1229
1294
  className: "ph ph-rows-plus-bottom",
1230
1295
  "aria-hidden": "true"
1231
- }), "Compact"]
1296
+ }), strings.densityCompact]
1232
1297
  })]
1233
1298
  })
1234
1299
  ]
@@ -1237,22 +1302,25 @@ const SettingsPanel = ({ onClose: _onClose }) => {
1237
1302
  //#endregion
1238
1303
  //#region packages/ui/Badge.tsx
1239
1304
  const Badge = ({ variant = "primary", size = "md", outlined = false, pill = true, dot = false, children, className }) => {
1305
+ const classes = [
1306
+ "nb-badge",
1307
+ `nb-badge--${variant}`,
1308
+ size === "sm" && "nb-badge--sm",
1309
+ outlined && "nb-badge--outlined",
1310
+ pill && "nb-badge--pill",
1311
+ dot && "nb-badge--dot",
1312
+ className
1313
+ ].filter(Boolean).join(" ");
1240
1314
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1241
- className: [
1242
- "nb-badge",
1243
- `nb-badge--${variant}`,
1244
- size === "sm" && "nb-badge--sm",
1245
- outlined && "nb-badge--outlined",
1246
- pill && "nb-badge--pill",
1247
- dot && "nb-badge--dot",
1248
- className
1249
- ].filter(Boolean).join(" "),
1315
+ className: classes,
1250
1316
  children: dot ? null : children
1251
1317
  });
1252
1318
  };
1253
1319
  //#endregion
1254
1320
  //#region packages/ui/FeatureGate.tsx
1255
- function FeatureGate({ featureKey, children, enabled = false, behavior = "lock", planBadge = "Pro", upgradeMessage, upgradeUrl = "/settings", lockTooltip = "Esta función no está disponible en tu plan actual." }) {
1321
+ function FeatureGate({ featureKey, children, enabled = false, behavior = "lock", planBadge = "Pro", upgradeMessage, upgradeUrl = "/settings", lockTooltip }) {
1322
+ const strings = useUiStrings();
1323
+ const tooltip = lockTooltip ?? strings.featureUnavailable;
1256
1324
  if (enabled) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1257
1325
  className: "feature-gate",
1258
1326
  children
@@ -1265,15 +1333,16 @@ function FeatureGate({ featureKey, children, enabled = false, behavior = "lock",
1265
1333
  });
1266
1334
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1267
1335
  className: "feature-gate--locked",
1268
- title: lockTooltip,
1269
- "aria-label": lockTooltip,
1336
+ title: tooltip,
1337
+ "aria-label": tooltip,
1270
1338
  role: "presentation",
1271
1339
  children
1272
1340
  });
1273
1341
  }
1274
1342
  function UpgradeGate({ planBadge, upgradeMessage, upgradeUrl, children }) {
1343
+ const strings = useUiStrings();
1275
1344
  const [open, setOpen] = (0, react.useState)(false);
1276
- const message = upgradeMessage ?? `Esta función requiere el plan ${planBadge}. Actualiza tu plan para desbloquearla.`;
1345
+ const message = upgradeMessage ?? strings.featureRequiresPlan.replace("{plan}", planBadge);
1277
1346
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1278
1347
  className: "feature-gate--upgrade",
1279
1348
  onBlur: (e) => {
@@ -1309,13 +1378,13 @@ function UpgradeGate({ planBadge, upgradeMessage, upgradeUrl, children }) {
1309
1378
  children: [
1310
1379
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconButton, {
1311
1380
  icon: "ph ph-x",
1312
- label: "Cerrar",
1381
+ label: strings.close,
1313
1382
  onClick: () => setOpen(false)
1314
1383
  }),
1315
1384
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: message }),
1316
1385
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
1317
1386
  href: upgradeUrl,
1318
- children: "Ver planes"
1387
+ children: strings.viewPlans
1319
1388
  })
1320
1389
  ]
1321
1390
  })
@@ -1358,14 +1427,15 @@ const DEFAULT_ICONS = {
1358
1427
  };
1359
1428
  const EmptyState = ({ icon, variant = "default", title, description, action, size = "md", fill = false, className }) => {
1360
1429
  const iconName = icon ?? DEFAULT_ICONS[variant];
1430
+ const classes = [
1431
+ "nb-empty-state",
1432
+ `nb-empty-state--${variant}`,
1433
+ `nb-empty-state--${size}`,
1434
+ fill && "nb-empty-state--fill",
1435
+ className
1436
+ ].filter(Boolean).join(" ");
1361
1437
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1362
- className: [
1363
- "nb-empty-state",
1364
- `nb-empty-state--${variant}`,
1365
- `nb-empty-state--${size}`,
1366
- fill && "nb-empty-state--fill",
1367
- className
1368
- ].filter(Boolean).join(" "),
1438
+ className: classes,
1369
1439
  role: "status",
1370
1440
  "aria-live": "polite",
1371
1441
  children: [
@@ -1398,12 +1468,13 @@ const EmptyState = ({ icon, variant = "default", title, description, action, siz
1398
1468
  * Use for category filters, tag lists, and multi-select inputs.
1399
1469
  */
1400
1470
  const Chip = ({ label, active = false, count, icon, size = "md", disabled = false, onClick, className = "" }) => {
1471
+ const sizeClass = size !== "md" ? ` nb-chip--${size}` : "";
1401
1472
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1402
1473
  type: "button",
1403
1474
  role: "checkbox",
1404
1475
  "aria-checked": active,
1405
1476
  disabled,
1406
- className: `nb-chip${size !== "md" ? ` nb-chip--${size}` : ""}${active ? " is-active" : ""}${className ? ` ${className}` : ""}`,
1477
+ className: `nb-chip${sizeClass}${active ? " is-active" : ""}${className ? ` ${className}` : ""}`,
1407
1478
  onClick,
1408
1479
  children: [
1409
1480
  icon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
@@ -2639,8 +2710,10 @@ function DateRangePicker({ startValue, endValue, placeholder = "dd/mm/yyyy", dis
2639
2710
  onChange?.(a, b);
2640
2711
  } else if (field === "start") onChange?.(parsed, endIso ?? "");
2641
2712
  else onChange?.(startIso ?? "", parsed);
2642
- } else if (text === "") if (field === "start") onChange?.("", endIso ?? "");
2643
- else onChange?.(startIso ?? "", "");
2713
+ } else if (text === "") {
2714
+ if (field === "start") onChange?.("", endIso ?? "");
2715
+ else onChange?.(startIso ?? "", "");
2716
+ }
2644
2717
  };
2645
2718
  const handleStartBlur = (e) => {
2646
2719
  const related = e.relatedTarget;
@@ -3022,13 +3095,14 @@ function TimelineMarker({ status, variant, marker }) {
3022
3095
  }
3023
3096
  function TimelineItem({ status, title, marker, timestamp, dateTime, tone = "default", children, className }) {
3024
3097
  const variant = useTimelineVariant();
3098
+ const classes = [
3099
+ "nb-timeline__item",
3100
+ `nb-timeline__item--${status}`,
3101
+ variant === "log" && `nb-timeline__item--tone-${tone}`,
3102
+ className
3103
+ ].filter(Boolean).join(" ");
3025
3104
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
3026
- className: [
3027
- "nb-timeline__item",
3028
- `nb-timeline__item--${status}`,
3029
- variant === "log" && `nb-timeline__item--tone-${tone}`,
3030
- className
3031
- ].filter(Boolean).join(" "),
3105
+ className: classes,
3032
3106
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3033
3107
  className: "nb-timeline__marker-col",
3034
3108
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TimelineMarker, {
@@ -3161,8 +3235,9 @@ function Grid({ children, cols = 12, gap = 4, minColWidth, fill, className, styl
3161
3235
  ...style,
3162
3236
  ...minColWidth ? { "--nb-grid-min-col": minColWidth } : {}
3163
3237
  };
3238
+ const colsClass = cols === 12 ? "nb-grid--cols-12" : cols === "auto" ? "nb-grid--cols-auto" : `nb-grid--cols-${cols}`;
3164
3239
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3165
- className: joinClasses("nb-grid", cols === 12 ? "nb-grid--cols-12" : cols === "auto" ? "nb-grid--cols-auto" : `nb-grid--cols-${cols}`, gapClass("nb-grid", gap), fill && "nb-grid--fill", className),
3240
+ className: joinClasses("nb-grid", colsClass, gapClass("nb-grid", gap), fill && "nb-grid--fill", className),
3166
3241
  style: gridStyle,
3167
3242
  ...props,
3168
3243
  children