pixelon 0.3.82 → 0.3.83

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.
@@ -15,6 +15,7 @@ export interface ReactiveCrudProps {
15
15
  }
16
16
  export declare function matchesVisibleWhen(a: RowActionDef, row: Record<string, unknown>): boolean;
17
17
  export declare function matchesDisabledWhen(a: RowActionDef, row: Record<string, unknown>): boolean;
18
+ export declare function disabledReasonFor(a: RowActionDef, row: Record<string, unknown>): string | undefined;
18
19
  export declare function matchesDoneWhen(a: RowActionDef, row: Record<string, unknown>): boolean;
19
20
  export declare function ReactiveCrud({ config, eventBus, autoOpenCreate, prefill, onCreated, onCreateClose, googleMapsApiKey: apiKeyProp }: ReactiveCrudProps): import("react/jsx-runtime").JSX.Element;
20
21
  export default ReactiveCrud;
@@ -84,6 +84,14 @@ export interface RowActionVisibleWhen {
84
84
  field: string;
85
85
  in: string[];
86
86
  }
87
+ /** SPEC-113 — una condición que apaga la acción, con SU motivo.
88
+ *
89
+ * Un botón deshabilitado que no dice cuál de dos motivos lo apaga enseña a ignorarlo. Fundir dos
90
+ * situaciones opuestas —«falta el comprobante del cliente» y «todavía no has llegado»— en un
91
+ * «no puedes todavía» es la validación muda de SPEC-074 con otra cara. */
92
+ export interface RowActionDisabledWhen extends RowActionVisibleWhen {
93
+ reason?: string;
94
+ }
87
95
  export interface RowActionDef {
88
96
  key: string;
89
97
  label: string;
@@ -97,9 +105,13 @@ export interface RowActionDef {
97
105
  * aceptado el precio—, que con condiciones unidas por «y» no se pueden escribir. */
98
106
  hiddenWhen?: RowActionVisibleWhen | RowActionVisibleWhen[];
99
107
  /** SPEC-007: la acción se muestra pero queda DESHABILITADA cuando `String(row[field])` está en
100
- * `in` (ej. "Iniciar" deshabilitado hasta que `has_inspection` sea true). */
101
- disabledWhen?: RowActionVisibleWhen;
102
- /** SPEC-007: tooltip cuando la acción está deshabilitada (ej. "Registra la inspección primero"). */
108
+ * `in` (ej. "Iniciar" deshabilitado hasta que `has_inspection` sea true).
109
+ *
110
+ * SPEC-113: admite VARIAS, cada una con su motivo. Se apaga con la primera que se cumple, y esa
111
+ * es la que habla. Una sola condición sigue valiendo igual que siempre. */
112
+ disabledWhen?: RowActionDisabledWhen | RowActionDisabledWhen[];
113
+ /** SPEC-007: tooltip cuando la acción está deshabilitada (ej. "Registra la inspección primero").
114
+ * SPEC-113: es el respaldo — una condición con `reason` propio manda sobre este. */
103
115
  disabledReason?: string;
104
116
  /** SPEC-007: muestra un ✓ al final cuando `String(row[field])` está en `in` (ej. inspección ya
105
117
  * registrada). Indicador de "hecho"; no bloquea reejecutar la acción. */
package/dist/index.esm.js CHANGED
@@ -15985,9 +15985,20 @@ function matchesVisibleWhen(a, row) {
15985
15985
  if (!a.visibleWhen) return true;
15986
15986
  return cumplenTodas(a.visibleWhen, row);
15987
15987
  }
15988
+ function condicionesDeshabilitado(a) {
15989
+ if (!a.disabledWhen) return [];
15990
+ return Array.isArray(a.disabledWhen) ? a.disabledWhen : [a.disabledWhen];
15991
+ }
15992
+ function primeraQueApaga(a, row) {
15993
+ return condicionesDeshabilitado(a).find((c) => c.in.includes(String(row[c.field])));
15994
+ }
15988
15995
  function matchesDisabledWhen(a, row) {
15989
- if (!a.disabledWhen) return false;
15990
- return a.disabledWhen.in.includes(String(row[a.disabledWhen.field]));
15996
+ return primeraQueApaga(a, row) !== void 0;
15997
+ }
15998
+ function disabledReasonFor(a, row) {
15999
+ const c = primeraQueApaga(a, row);
16000
+ if (!c) return void 0;
16001
+ return c.reason ?? a.disabledReason;
15991
16002
  }
15992
16003
  function matchesDoneWhen(a, row) {
15993
16004
  if (!a.doneWhen) return false;
@@ -16062,7 +16073,8 @@ function ReactiveCrud({ config, eventBus, autoOpenCreate, prefill, onCreated, on
16062
16073
  // SPEC-090 T3 — el `disabledReason` de la config ya existía, pero solo lo pintaba el panel
16063
16074
  // del chat; en la tabla el botón se apagaba mudo. Afecta también al de la inspección
16064
16075
  // («Falta el comprobante de pago del cliente», SPEC-066 T7), que tampoco se veía aquí.
16065
- disabledReason: (row) => matchesDisabledWhen(a, row) ? a.disabledReason : void 0,
16076
+ // SPEC-113 — el motivo sale de la condición que apagó el botón, no de la acción entera.
16077
+ disabledReason: (row) => disabledReasonFor(a, row),
16066
16078
  onClick: (row) => a.form ? setActiveAction({ action: a, row }) : crud.runEndpoints(a.endpoints ?? [a.endpoint], { ...row, id: row[config.idField] })
16067
16079
  }));
16068
16080
  if (config.detail) {
@@ -16386,6 +16398,7 @@ function ServiceActionsPanel({ config, recordId, recordLabel, allowed, eventBus
16386
16398
  config.detail && /* @__PURE__ */ jsx("button", { type: "button", className: "px-chat-crud-item__action", onClick: () => setDetailRow(row), children: "Ver" }),
16387
16399
  actions.map((a) => {
16388
16400
  const disabled = matchesDisabledWhen(a, row);
16401
+ const motivo = disabledReasonFor(a, row);
16389
16402
  const done = matchesDoneWhen(a, row);
16390
16403
  return /* @__PURE__ */ jsxs(
16391
16404
  "button",
@@ -16394,14 +16407,14 @@ function ServiceActionsPanel({ config, recordId, recordLabel, allowed, eventBus
16394
16407
  className: [
16395
16408
  "px-chat-crud-item__action",
16396
16409
  a.intent === "danger" ? "is-danger" : "",
16397
- disabled && a.disabledReason ? "is-con-motivo" : ""
16410
+ disabled && motivo ? "is-con-motivo" : ""
16398
16411
  ].filter(Boolean).join(" "),
16399
16412
  disabled,
16400
16413
  onClick: () => a.form ? setActiveAction({ action: a, row }) : crud.runEndpoints(a.endpoints ?? [a.endpoint], { ...row, id: row[config.idField] }),
16401
16414
  children: [
16402
16415
  /* @__PURE__ */ jsxs("span", { className: "px-chat-crud-item__action-texts", children: [
16403
16416
  /* @__PURE__ */ jsx("span", { children: a.label }),
16404
- disabled && a.disabledReason && /* @__PURE__ */ jsx("span", { className: "px-chat-crud-item__action-reason", children: a.disabledReason })
16417
+ disabled && motivo && /* @__PURE__ */ jsx("span", { className: "px-chat-crud-item__action-reason", children: motivo })
16405
16418
  ] }),
16406
16419
  done && /* @__PURE__ */ jsx(Icon$1, { type: "check-circle", width: 18, height: 18, className: "px-chat-crud-item__done", "aria-label": "Hecho" })
16407
16420
  ]
package/dist/index.js CHANGED
@@ -16006,9 +16006,20 @@ function matchesVisibleWhen(a, row) {
16006
16006
  if (!a.visibleWhen) return true;
16007
16007
  return cumplenTodas(a.visibleWhen, row);
16008
16008
  }
16009
+ function condicionesDeshabilitado(a) {
16010
+ if (!a.disabledWhen) return [];
16011
+ return Array.isArray(a.disabledWhen) ? a.disabledWhen : [a.disabledWhen];
16012
+ }
16013
+ function primeraQueApaga(a, row) {
16014
+ return condicionesDeshabilitado(a).find((c) => c.in.includes(String(row[c.field])));
16015
+ }
16009
16016
  function matchesDisabledWhen(a, row) {
16010
- if (!a.disabledWhen) return false;
16011
- return a.disabledWhen.in.includes(String(row[a.disabledWhen.field]));
16017
+ return primeraQueApaga(a, row) !== void 0;
16018
+ }
16019
+ function disabledReasonFor(a, row) {
16020
+ const c = primeraQueApaga(a, row);
16021
+ if (!c) return void 0;
16022
+ return c.reason ?? a.disabledReason;
16012
16023
  }
16013
16024
  function matchesDoneWhen(a, row) {
16014
16025
  if (!a.doneWhen) return false;
@@ -16083,7 +16094,8 @@ function ReactiveCrud({ config, eventBus, autoOpenCreate, prefill, onCreated, on
16083
16094
  // SPEC-090 T3 — el `disabledReason` de la config ya existía, pero solo lo pintaba el panel
16084
16095
  // del chat; en la tabla el botón se apagaba mudo. Afecta también al de la inspección
16085
16096
  // («Falta el comprobante de pago del cliente», SPEC-066 T7), que tampoco se veía aquí.
16086
- disabledReason: (row) => matchesDisabledWhen(a, row) ? a.disabledReason : void 0,
16097
+ // SPEC-113 — el motivo sale de la condición que apagó el botón, no de la acción entera.
16098
+ disabledReason: (row) => disabledReasonFor(a, row),
16087
16099
  onClick: (row) => a.form ? setActiveAction({ action: a, row }) : crud.runEndpoints(a.endpoints ?? [a.endpoint], { ...row, id: row[config.idField] })
16088
16100
  }));
16089
16101
  if (config.detail) {
@@ -16407,6 +16419,7 @@ function ServiceActionsPanel({ config, recordId, recordLabel, allowed, eventBus
16407
16419
  config.detail && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "px-chat-crud-item__action", onClick: () => setDetailRow(row), children: "Ver" }),
16408
16420
  actions.map((a) => {
16409
16421
  const disabled = matchesDisabledWhen(a, row);
16422
+ const motivo = disabledReasonFor(a, row);
16410
16423
  const done = matchesDoneWhen(a, row);
16411
16424
  return /* @__PURE__ */ jsxRuntime.jsxs(
16412
16425
  "button",
@@ -16415,14 +16428,14 @@ function ServiceActionsPanel({ config, recordId, recordLabel, allowed, eventBus
16415
16428
  className: [
16416
16429
  "px-chat-crud-item__action",
16417
16430
  a.intent === "danger" ? "is-danger" : "",
16418
- disabled && a.disabledReason ? "is-con-motivo" : ""
16431
+ disabled && motivo ? "is-con-motivo" : ""
16419
16432
  ].filter(Boolean).join(" "),
16420
16433
  disabled,
16421
16434
  onClick: () => a.form ? setActiveAction({ action: a, row }) : crud.runEndpoints(a.endpoints ?? [a.endpoint], { ...row, id: row[config.idField] }),
16422
16435
  children: [
16423
16436
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "px-chat-crud-item__action-texts", children: [
16424
16437
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: a.label }),
16425
- disabled && a.disabledReason && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "px-chat-crud-item__action-reason", children: a.disabledReason })
16438
+ disabled && motivo && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "px-chat-crud-item__action-reason", children: motivo })
16426
16439
  ] }),
16427
16440
  done && /* @__PURE__ */ jsxRuntime.jsx(Icon$1, { type: "check-circle", width: 18, height: 18, className: "px-chat-crud-item__done", "aria-label": "Hecho" })
16428
16441
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixelon",
3
- "version": "0.3.82",
3
+ "version": "0.3.83",
4
4
  "description": "Design system de la marca goluti",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",