pixelon 0.3.82 → 0.3.84

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. */
@@ -6,6 +6,19 @@ export interface ChatCurrency {
6
6
  symbol?: string;
7
7
  }
8
8
  export interface ChatConfig {
9
+ /** SPEC-107 — esta conversación es de OTRO: se lee, no se opera.
10
+ *
11
+ * Las cards del chat llevan acciones que ejecutan de verdad —aceptar una cotización, confirmar
12
+ * un pago, asignar—. Estando dentro de la conversación de otro rol, pulsarlas es actuar en su
13
+ * nombre. `readOnly` no sirve para decidirlo: mezcla «cerrado», «del sistema» y «de otro», y los
14
+ * chats de servicio pertenecen a un usuario sintético, así que hasta el propio panel de la
15
+ * operadora sale como solo lectura.
16
+ *
17
+ * Viaja por config y no por evento porque el bus no guarda el último valor y estas cards nacen
18
+ * después de que se emita: no llegarían a oírlo. Por omisión, operable — una guarda que se cae
19
+ * sola es preferible a un panel que se apaga por una conexión mala; el backend sigue rechazando
20
+ * lo que no toca. */
21
+ chatIsForeign?: boolean;
9
22
  /** IANA timezone identifier (e.g. "America/Bogota") */
10
23
  timezone: string;
11
24
  /** BCP 47 locale string (e.g. "es-CO") */
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) {
@@ -16155,7 +16167,7 @@ function readCreated(messageId) {
16155
16167
  }
16156
16168
  }
16157
16169
  function ReactiveCrudChat({ component, eventBus, assistantMessageId }) {
16158
- const { resolveModuleConfig } = useChatConfig();
16170
+ const { resolveModuleConfig, chatIsForeign } = useChatConfig();
16159
16171
  const [open, setOpen] = useState(false);
16160
16172
  const [created, setCreated] = useState(() => readCreated(assistantMessageId));
16161
16173
  const props = component.props ?? {};
@@ -16194,8 +16206,8 @@ function ReactiveCrudChat({ component, eventBus, assistantMessageId }) {
16194
16206
  type: "button",
16195
16207
  className: `px-chat-reactive-crud-trigger${done ? " px-chat-reactive-crud-trigger--done" : ""}`,
16196
16208
  onClick: () => setOpen(true),
16197
- disabled: done,
16198
- "aria-disabled": done,
16209
+ disabled: done || Boolean(chatIsForeign),
16210
+ "aria-disabled": done || Boolean(chatIsForeign),
16199
16211
  children: [
16200
16212
  /* @__PURE__ */ jsx("span", { className: "px-chat-reactive-crud-trigger__icon", children: done ? /* @__PURE__ */ jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
16201
16213
  /* @__PURE__ */ jsx("path", { d: "M22 11.08V12a10 10 0 1 1-5.93-9.14" }),
@@ -16314,6 +16326,7 @@ function ReactiveCrudItemChat({ component, eventBus }) {
16314
16326
  );
16315
16327
  }
16316
16328
  function ServiceActionsPanel({ config, recordId, recordLabel, allowed, eventBus }) {
16329
+ const { chatIsForeign } = useChatConfig();
16317
16330
  const crud = useReactiveCrud(config, eventBus);
16318
16331
  const [activeAction, setActiveAction] = useState(null);
16319
16332
  const [detailRow, setDetailRow] = useState(null);
@@ -16385,7 +16398,8 @@ function ServiceActionsPanel({ config, recordId, recordLabel, allowed, eventBus
16385
16398
  row && /* @__PURE__ */ jsxs("div", { className: "px-chat-crud-item__actions", children: [
16386
16399
  config.detail && /* @__PURE__ */ jsx("button", { type: "button", className: "px-chat-crud-item__action", onClick: () => setDetailRow(row), children: "Ver" }),
16387
16400
  actions.map((a) => {
16388
- const disabled = matchesDisabledWhen(a, row);
16401
+ const disabled = Boolean(chatIsForeign) || matchesDisabledWhen(a, row);
16402
+ const motivo = chatIsForeign ? "Esta conversaci\xF3n es de otra persona" : disabledReasonFor(a, row);
16389
16403
  const done = matchesDoneWhen(a, row);
16390
16404
  return /* @__PURE__ */ jsxs(
16391
16405
  "button",
@@ -16394,14 +16408,14 @@ function ServiceActionsPanel({ config, recordId, recordLabel, allowed, eventBus
16394
16408
  className: [
16395
16409
  "px-chat-crud-item__action",
16396
16410
  a.intent === "danger" ? "is-danger" : "",
16397
- disabled && a.disabledReason ? "is-con-motivo" : ""
16411
+ disabled && motivo ? "is-con-motivo" : ""
16398
16412
  ].filter(Boolean).join(" "),
16399
16413
  disabled,
16400
16414
  onClick: () => a.form ? setActiveAction({ action: a, row }) : crud.runEndpoints(a.endpoints ?? [a.endpoint], { ...row, id: row[config.idField] }),
16401
16415
  children: [
16402
16416
  /* @__PURE__ */ jsxs("span", { className: "px-chat-crud-item__action-texts", children: [
16403
16417
  /* @__PURE__ */ jsx("span", { children: a.label }),
16404
- disabled && a.disabledReason && /* @__PURE__ */ jsx("span", { className: "px-chat-crud-item__action-reason", children: a.disabledReason })
16418
+ disabled && motivo && /* @__PURE__ */ jsx("span", { className: "px-chat-crud-item__action-reason", children: motivo })
16405
16419
  ] }),
16406
16420
  done && /* @__PURE__ */ jsx(Icon$1, { type: "check-circle", width: 18, height: 18, className: "px-chat-crud-item__done", "aria-label": "Hecho" })
16407
16421
  ]
@@ -16451,6 +16465,7 @@ function PriceNegotiationChat({ component, eventBus }) {
16451
16465
  );
16452
16466
  }
16453
16467
  function NegotiationPanel({ config, recordId, recordLabel, allowed, eventBus }) {
16468
+ const { chatIsForeign } = useChatConfig();
16454
16469
  const crud = useReactiveCrud(config, eventBus);
16455
16470
  const [activeAction, setActiveAction] = useState(null);
16456
16471
  const row = useMemo(
@@ -16496,7 +16511,7 @@ function NegotiationPanel({ config, recordId, recordLabel, allowed, eventBus })
16496
16511
  actions.map((a) => {
16497
16512
  const gated = TURN_GATED.has(a.key) && !myTurn;
16498
16513
  const noOffer = a.key === "accept_price" && !hasOffer;
16499
- const disabled = gated || noOffer;
16514
+ const disabled = gated || noOffer || Boolean(chatIsForeign);
16500
16515
  return /* @__PURE__ */ jsx(
16501
16516
  "button",
16502
16517
  {
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) {
@@ -16176,7 +16188,7 @@ function readCreated(messageId) {
16176
16188
  }
16177
16189
  }
16178
16190
  function ReactiveCrudChat({ component, eventBus, assistantMessageId }) {
16179
- const { resolveModuleConfig } = useChatConfig();
16191
+ const { resolveModuleConfig, chatIsForeign } = useChatConfig();
16180
16192
  const [open, setOpen] = React.useState(false);
16181
16193
  const [created, setCreated] = React.useState(() => readCreated(assistantMessageId));
16182
16194
  const props = component.props ?? {};
@@ -16215,8 +16227,8 @@ function ReactiveCrudChat({ component, eventBus, assistantMessageId }) {
16215
16227
  type: "button",
16216
16228
  className: `px-chat-reactive-crud-trigger${done ? " px-chat-reactive-crud-trigger--done" : ""}`,
16217
16229
  onClick: () => setOpen(true),
16218
- disabled: done,
16219
- "aria-disabled": done,
16230
+ disabled: done || Boolean(chatIsForeign),
16231
+ "aria-disabled": done || Boolean(chatIsForeign),
16220
16232
  children: [
16221
16233
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "px-chat-reactive-crud-trigger__icon", children: done ? /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
16222
16234
  /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M22 11.08V12a10 10 0 1 1-5.93-9.14" }),
@@ -16335,6 +16347,7 @@ function ReactiveCrudItemChat({ component, eventBus }) {
16335
16347
  );
16336
16348
  }
16337
16349
  function ServiceActionsPanel({ config, recordId, recordLabel, allowed, eventBus }) {
16350
+ const { chatIsForeign } = useChatConfig();
16338
16351
  const crud = useReactiveCrud(config, eventBus);
16339
16352
  const [activeAction, setActiveAction] = React.useState(null);
16340
16353
  const [detailRow, setDetailRow] = React.useState(null);
@@ -16406,7 +16419,8 @@ function ServiceActionsPanel({ config, recordId, recordLabel, allowed, eventBus
16406
16419
  row && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-chat-crud-item__actions", children: [
16407
16420
  config.detail && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "px-chat-crud-item__action", onClick: () => setDetailRow(row), children: "Ver" }),
16408
16421
  actions.map((a) => {
16409
- const disabled = matchesDisabledWhen(a, row);
16422
+ const disabled = Boolean(chatIsForeign) || matchesDisabledWhen(a, row);
16423
+ const motivo = chatIsForeign ? "Esta conversaci\xF3n es de otra persona" : disabledReasonFor(a, row);
16410
16424
  const done = matchesDoneWhen(a, row);
16411
16425
  return /* @__PURE__ */ jsxRuntime.jsxs(
16412
16426
  "button",
@@ -16415,14 +16429,14 @@ function ServiceActionsPanel({ config, recordId, recordLabel, allowed, eventBus
16415
16429
  className: [
16416
16430
  "px-chat-crud-item__action",
16417
16431
  a.intent === "danger" ? "is-danger" : "",
16418
- disabled && a.disabledReason ? "is-con-motivo" : ""
16432
+ disabled && motivo ? "is-con-motivo" : ""
16419
16433
  ].filter(Boolean).join(" "),
16420
16434
  disabled,
16421
16435
  onClick: () => a.form ? setActiveAction({ action: a, row }) : crud.runEndpoints(a.endpoints ?? [a.endpoint], { ...row, id: row[config.idField] }),
16422
16436
  children: [
16423
16437
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "px-chat-crud-item__action-texts", children: [
16424
16438
  /* @__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 })
16439
+ disabled && motivo && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "px-chat-crud-item__action-reason", children: motivo })
16426
16440
  ] }),
16427
16441
  done && /* @__PURE__ */ jsxRuntime.jsx(Icon$1, { type: "check-circle", width: 18, height: 18, className: "px-chat-crud-item__done", "aria-label": "Hecho" })
16428
16442
  ]
@@ -16472,6 +16486,7 @@ function PriceNegotiationChat({ component, eventBus }) {
16472
16486
  );
16473
16487
  }
16474
16488
  function NegotiationPanel({ config, recordId, recordLabel, allowed, eventBus }) {
16489
+ const { chatIsForeign } = useChatConfig();
16475
16490
  const crud = useReactiveCrud(config, eventBus);
16476
16491
  const [activeAction, setActiveAction] = React.useState(null);
16477
16492
  const row = React.useMemo(
@@ -16517,7 +16532,7 @@ function NegotiationPanel({ config, recordId, recordLabel, allowed, eventBus })
16517
16532
  actions.map((a) => {
16518
16533
  const gated = TURN_GATED.has(a.key) && !myTurn;
16519
16534
  const noOffer = a.key === "accept_price" && !hasOffer;
16520
- const disabled = gated || noOffer;
16535
+ const disabled = gated || noOffer || Boolean(chatIsForeign);
16521
16536
  return /* @__PURE__ */ jsxRuntime.jsx(
16522
16537
  "button",
16523
16538
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixelon",
3
- "version": "0.3.82",
3
+ "version": "0.3.84",
4
4
  "description": "Design system de la marca goluti",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",