@apia/api 4.0.50 → 4.0.60

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/LICENSE.md ADDED
@@ -0,0 +1,6 @@
1
+ All Rights Reserved.
2
+
3
+ Copyright (c) 2026 Statum
4
+
5
+ This software and associated documentation files are proprietary and confidential.
6
+ Unauthorized copying, distribution, modification, or use is strictly prohibited.
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { jsx, jsxs, Fragment } from '@apia/theme/jsx-runtime';
2
2
  import * as React from 'react';
3
3
  import React__default, { createContext, useState, useCallback, useEffect, useId, useRef, useMemo } from 'react';
4
4
  import { Box, Label, spacing, getVariant, Input as Input$1, Select as Select$1, Spinner } from '@apia/theme';
5
- import { debugDispatcher, parseXmlAsync, arrayOrArray, EventEmitter, useMount, encrypt, noNaN, getIndex, getLabel, StatefulEmitter, focus, focusSelector, useLatest, useIntermediateValue, formatMessage, getDateFormat, Mutex, uniqueId as uniqueId$1 } from '@apia/util';
5
+ import { debugDispatcher, parseXmlAsync, arrayOrArray, EventEmitter, useMount, encrypt, noNaN, getIndex, getLabel, StatefulEmitter, focus, focusSelector, useLatest, useIntermediateValue, formatMessage, uniqueId as uniqueId$1, getDateFormat, Mutex } from '@apia/util';
6
6
  import { notify, getNotificationMessageObj, dispatchNotifications } from '@apia/notifications';
7
7
  import { classToValidate, Checkbox, FileInput, classToValidationFunction, Input, Radio, Select, Textarea, useFormContext, validationsStore, hasSucceedFormValidation, Form } from '@apia/validations';
8
8
  import { Accordion, AccordionItem, useModal, LabelBox, SimpleButton, ApiaUtil, Modal, ProgressBar, RequiredMark, DateInput, AutocompleteController, Autocomplete, IconButton } from '@apia/components';
@@ -3340,12 +3340,54 @@ const RangeFilterRenderer = observer(({ state }) => {
3340
3340
  );
3341
3341
  });
3342
3342
 
3343
+ const FilterLabel = ({
3344
+ state,
3345
+ labelOverride,
3346
+ isDate,
3347
+ className,
3348
+ title
3349
+ }) => {
3350
+ const text = React__default.useMemo(() => {
3351
+ const base = labelOverride ?? state?.title ?? "";
3352
+ if (isDate && state?.filterToId && !state.hideToFilter) {
3353
+ try {
3354
+ return formatMessage(window.LBL_DATE_FILTER_FROM_TXT, { TOK1: base });
3355
+ } catch {
3356
+ return base;
3357
+ }
3358
+ }
3359
+ return base;
3360
+ }, [labelOverride, state, isDate]);
3361
+ const showRequiredBefore = !!(state?.required && window.SHOW_REQUIRED_POSITION !== "0");
3362
+ const showRequiredAfter = !!(state?.required && window.SHOW_REQUIRED_POSITION === "0");
3363
+ return /* @__PURE__ */ jsxs(
3364
+ Box,
3365
+ {
3366
+ className: `filterLabel ${className ?? ""}`,
3367
+ title,
3368
+ sx: { display: "flex", flexDirection: "row" },
3369
+ children: [
3370
+ showRequiredBefore && /* @__PURE__ */ jsx(RequiredMark, { isRequired: true, sx: { zIndex: 1 } }),
3371
+ /* @__PURE__ */ jsx(Box, { as: "span", children: text }),
3372
+ showRequiredAfter && /* @__PURE__ */ jsx(RequiredMark, { isRequired: true, sx: { zIndex: 1 } })
3373
+ ]
3374
+ }
3375
+ );
3376
+ };
3377
+
3343
3378
  const SelectFilterRenderer = observer(({ state }) => {
3344
- return /* @__PURE__ */ jsxs(Box, { sx: { position: "relative" }, children: [
3345
- state.required && /* @__PURE__ */ jsx(RequiredMark, { isRequired: true, sx: { position: "absolute", left: 2 } }),
3379
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
3380
+ /* @__PURE__ */ jsx(FilterLabel, { state, isDate: true }),
3346
3381
  /* @__PURE__ */ jsx(
3347
3382
  Select$1,
3348
3383
  {
3384
+ className: "filter__query",
3385
+ sx: {
3386
+ "&.filter__query.filter__query:not([disabled])": {
3387
+ borderLeft: state.required ? "4px solid" : void 0,
3388
+ borderLeftColor: state.required ? "palette.error.main" : void 0
3389
+ }
3390
+ },
3349
3391
  disabled: state.readonly,
3350
3392
  value: state.value,
3351
3393
  onChange: (ev) => {
@@ -3359,11 +3401,18 @@ const SelectFilterRenderer = observer(({ state }) => {
3359
3401
 
3360
3402
  const InputFilterRenderer = observer(({ state }) => {
3361
3403
  const { onFilterBlur, onFilterPressEnter } = useResponsiveTableContext();
3362
- return /* @__PURE__ */ jsxs(Box, { sx: { position: "relative" }, children: [
3363
- state.required && /* @__PURE__ */ jsx(RequiredMark, { isRequired: true, sx: { position: "absolute", left: 2 } }),
3404
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
3405
+ /* @__PURE__ */ jsx(FilterLabel, { state, isDate: true }),
3364
3406
  /* @__PURE__ */ jsx(
3365
3407
  Input$1,
3366
3408
  {
3409
+ className: "filter__query",
3410
+ sx: {
3411
+ "&.filter__query.filter__query:not([disabled])": {
3412
+ borderLeft: state.required ? "4px solid" : void 0,
3413
+ borderLeftColor: state.required ? "palette.error.main" : void 0
3414
+ }
3415
+ },
3367
3416
  disabled: state.readonly,
3368
3417
  value: state.value,
3369
3418
  onChange: (ev) => {
@@ -3393,47 +3442,70 @@ function controlDatesOrder(first, last) {
3393
3442
  }
3394
3443
  const DateFilterRenderer = observer(({ state }) => {
3395
3444
  const { onFilterBlur, onFilterChange } = useResponsiveTableContext();
3445
+ const idFrom = uniqueId$1("date_from_");
3446
+ const idTo = uniqueId$1("date_to_");
3396
3447
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3397
- /* @__PURE__ */ jsxs(Box, { sx: { position: "relative" }, children: [
3398
- state.required && /* @__PURE__ */ jsx(
3399
- RequiredMark,
3400
- {
3401
- isRequired: true,
3402
- sx: { position: "absolute", left: 2, top: 6, zIndex: 1 }
3403
- }
3404
- ),
3405
- /* @__PURE__ */ jsx(Box, { as: "span", children: state?.filterToId ? formatMessage(window.LBL_DATE_FILTER_FROM_TXT, {
3406
- TOK1: state.title ?? ""
3407
- }) : state.title }),
3408
- /* @__PURE__ */ jsx(
3409
- DateInput,
3410
- {
3411
- disabled: state.readonly,
3412
- value: state.value,
3413
- onChange: (date) => {
3414
- state.value = date;
3448
+ /* @__PURE__ */ jsx(FilterLabel, { state, isDate: true }),
3449
+ /* @__PURE__ */ jsx(
3450
+ DateInput,
3451
+ {
3452
+ id: idFrom,
3453
+ className: "filter__query date_from",
3454
+ sx: {
3455
+ "&.filter__query.filter__query:not([disabled])": {
3456
+ borderLeft: state.required ? "4px solid" : void 0,
3457
+ borderLeftColor: state.required ? "palette.error.main" : void 0
3458
+ }
3459
+ },
3460
+ disabled: state.readonly,
3461
+ value: state.value,
3462
+ onChange: (date) => {
3463
+ const result = controlDatesOrder(
3464
+ date ?? "",
3465
+ state.filterToValue ?? ""
3466
+ );
3467
+ if (result) {
3468
+ state.value = date ?? "";
3415
3469
  onFilterChange?.(state);
3416
- },
3417
- onBlur: () => {
3418
- onFilterBlur?.(state);
3470
+ } else {
3471
+ state.value = void 0;
3472
+ onFilterChange?.({
3473
+ ...state,
3474
+ currentValue: "",
3475
+ deleteFiltersTimestamp: void 0,
3476
+ changeFiltersTimestamp: void 0
3477
+ });
3478
+ const a = document.querySelector(`#${idFrom}`);
3479
+ if (a) {
3480
+ a.click();
3481
+ }
3482
+ ApiaUtil.instance.notifications.notify({
3483
+ message: window.MSG_FEC_FIN_MAY_FEC_INI,
3484
+ type: "warning"
3485
+ });
3419
3486
  }
3487
+ },
3488
+ onBlur: () => {
3489
+ onFilterBlur?.({
3490
+ ...state,
3491
+ currentValue: state.value
3492
+ });
3420
3493
  }
3421
- )
3422
- ] }),
3423
- (state?.isAdditional || state.group) && state?.filterToId && /* @__PURE__ */ jsxs(Box, { sx: { position: "relative" }, children: [
3424
- state.required && /* @__PURE__ */ jsx(
3425
- RequiredMark,
3426
- {
3427
- isRequired: true,
3428
- sx: { position: "absolute", left: 2, top: 6, zIndex: 1 }
3429
- }
3430
- ),
3431
- /* @__PURE__ */ jsx(Box, { as: "span", children: formatMessage(window.LBL_DATE_FILTER_TO_TXT, {
3432
- TOK1: state.title ?? ""
3433
- }) }),
3494
+ }
3495
+ ),
3496
+ (state?.isAdditional || state.group) && state?.filterToId && /* @__PURE__ */ jsxs(Fragment, { children: [
3497
+ /* @__PURE__ */ jsx(FilterLabel, { state, isDate: true }),
3434
3498
  /* @__PURE__ */ jsx(
3435
3499
  DateInput,
3436
3500
  {
3501
+ id: idTo,
3502
+ className: "filter__query date_to",
3503
+ sx: {
3504
+ "&.filter__query.filter__query:not([disabled])": {
3505
+ borderLeft: state.required ? "4px solid" : void 0,
3506
+ borderLeftColor: state.required ? "palette.error.main" : void 0
3507
+ }
3508
+ },
3437
3509
  disabled: state.readonly,
3438
3510
  value: state.filterToValue,
3439
3511
  onChange: (date) => {
@@ -3443,6 +3515,18 @@ const DateFilterRenderer = observer(({ state }) => {
3443
3515
  onFilterChange?.(state);
3444
3516
  } else {
3445
3517
  state.filterToValue = void 0;
3518
+ onFilterChange?.({
3519
+ ...state,
3520
+ currentValue: "",
3521
+ deleteFiltersTimestamp: void 0,
3522
+ changeFiltersTimestamp: void 0
3523
+ });
3524
+ const a = document.querySelector(
3525
+ `#${idTo}`
3526
+ );
3527
+ if (a) {
3528
+ a.click();
3529
+ }
3446
3530
  ApiaUtil.instance.notifications.notify({
3447
3531
  message: window.MSG_FEC_FIN_MAY_FEC_INI,
3448
3532
  type: "warning"
@@ -3450,7 +3534,10 @@ const DateFilterRenderer = observer(({ state }) => {
3450
3534
  }
3451
3535
  },
3452
3536
  onBlur: () => {
3453
- onFilterBlur?.(state);
3537
+ onFilterBlur?.({
3538
+ ...state,
3539
+ currentValue: state.filterToValue
3540
+ });
3454
3541
  }
3455
3542
  }
3456
3543
  )
@@ -3694,6 +3781,7 @@ class TableController {
3694
3781
  ...props,
3695
3782
  columns,
3696
3783
  rows: rows ?? [],
3784
+ sx: { ".filterLabel": { display: "none" } },
3697
3785
  filters: useMemo(() => this.parseFilters(), [this.state.filters]),
3698
3786
  FiltersRenderer: useCallback(
3699
3787
  (filterId) => this.state.filters.get(filterId).Component,
@@ -4114,7 +4202,7 @@ class QueryController {
4114
4202
  filterToId: f?.filterToId ?? f.type == "D" ? `filter${String(i + 1)}i` : void 0,
4115
4203
  // Id generado en APIA
4116
4204
  value: f.currentValue,
4117
- avoidLabel: f.type === "D" || f.type === "date" ? true : false,
4205
+ avoidLabel: f.type === "D" || f.type === "date" || f.type === "S" || arrayOrArray(f?.filterOption).length > 0 || f.type === "N" ? true : false,
4118
4206
  filterToValue: f?.filterToValue,
4119
4207
  column: f.column,
4120
4208
  isAdditional: f.asAdditional,
@@ -4301,90 +4389,101 @@ const AdditionalFiltersComponent = observer(
4301
4389
  );
4302
4390
  return [...byGroup.values()];
4303
4391
  })();
4304
- return /* @__PURE__ */ jsx(Box, { sx: { ".requiredMark": { display: "none" } }, children: /* @__PURE__ */ jsx(
4305
- TableContextReproducer,
4392
+ return /* @__PURE__ */ jsx(
4393
+ Box,
4306
4394
  {
4307
- tableName: queryController.tableController.getTableName(),
4308
- children: /* @__PURE__ */ jsxs(Accordion, { className: "additionalFiltersContent", singleExpand: true, children: [
4309
- hasFilters && /* @__PURE__ */ jsx(
4310
- AccordionItem,
4311
- {
4312
- id: "Responsive",
4313
- defaultExpanded: true,
4314
- buttonProps: { ariaLabel: filterTitle, label: filterTitle },
4315
- children: /* @__PURE__ */ jsx(Responsive, {})
4316
- }
4317
- ),
4318
- hasAdditional && /* @__PURE__ */ jsx(
4319
- AccordionItem,
4320
- {
4321
- id: "Additional",
4322
- buttonProps: {
4323
- ariaLabel: window.ADDITIONAL_FILTERS_LABEL,
4324
- label: window.ADDITIONAL_FILTERS_LABEL
4325
- },
4326
- children: /* @__PURE__ */ jsx(Additional, {})
4327
- }
4328
- ),
4329
- groupFilters.length > 0 && /* @__PURE__ */ jsx(Fragment, { children: groupFilters.map((g) => /* @__PURE__ */ jsx(
4330
- AccordionItem,
4331
- {
4332
- id: `Group_${g.filterState.group}`,
4333
- buttonProps: {
4334
- ariaLabel: getLabel(`${g.filterState.group}`).text,
4335
- label: getLabel(`${g.filterState.group}`).text
4336
- },
4337
- children: /* @__PURE__ */ jsxs(
4338
- Box,
4395
+ sx: {
4396
+ ".requiredMark": { display: "none" },
4397
+ ".filter__query": {
4398
+ border: "1px solid #c6c6c6!important"
4399
+ }
4400
+ },
4401
+ children: /* @__PURE__ */ jsx(
4402
+ TableContextReproducer,
4403
+ {
4404
+ tableName: queryController.tableController.getTableName(),
4405
+ children: /* @__PURE__ */ jsxs(Accordion, { className: "additionalFiltersContent", singleExpand: true, children: [
4406
+ hasFilters && /* @__PURE__ */ jsx(
4407
+ AccordionItem,
4339
4408
  {
4340
- sx: {
4341
- display: "flex",
4342
- flexDirection: "column",
4343
- alignItems: "end",
4344
- gap: 3,
4345
- width: "100%"
4409
+ id: "Responsive",
4410
+ defaultExpanded: true,
4411
+ buttonProps: { ariaLabel: filterTitle, label: filterTitle },
4412
+ children: /* @__PURE__ */ jsx(Responsive, {})
4413
+ }
4414
+ ),
4415
+ hasAdditional && /* @__PURE__ */ jsx(
4416
+ AccordionItem,
4417
+ {
4418
+ id: "Additional",
4419
+ buttonProps: {
4420
+ ariaLabel: window.ADDITIONAL_FILTERS_LABEL,
4421
+ label: window.ADDITIONAL_FILTERS_LABEL
4346
4422
  },
4347
- children: [
4348
- /* @__PURE__ */ jsx(
4349
- Grouped,
4350
- {
4351
- tableName: queryController.tableController.getTableName(),
4352
- group: g.filterState?.group ?? ""
4423
+ children: /* @__PURE__ */ jsx(Additional, {})
4424
+ }
4425
+ ),
4426
+ groupFilters.length > 0 && /* @__PURE__ */ jsx(Fragment, { children: groupFilters.map((g) => /* @__PURE__ */ jsx(
4427
+ AccordionItem,
4428
+ {
4429
+ id: `Group_${g.filterState.group}`,
4430
+ buttonProps: {
4431
+ ariaLabel: getLabel(`${g.filterState.group}`).text,
4432
+ label: getLabel(`${g.filterState.group}`).text
4433
+ },
4434
+ children: /* @__PURE__ */ jsxs(
4435
+ Box,
4436
+ {
4437
+ sx: {
4438
+ display: "flex",
4439
+ flexDirection: "column",
4440
+ alignItems: "end",
4441
+ gap: 3,
4442
+ width: "100%"
4353
4443
  },
4354
- g.filterState.group
4355
- ),
4356
- g.filterState.addFilter && /* @__PURE__ */ jsx(
4357
- SimpleButton,
4358
- {
4359
- variant: "outline-sm",
4360
- onClick: g.filterState.addFilter,
4361
- children: getLabel("lblAddFil").text
4362
- }
4363
- )
4364
- ]
4444
+ children: [
4445
+ /* @__PURE__ */ jsx(
4446
+ Grouped,
4447
+ {
4448
+ tableName: queryController.tableController.getTableName(),
4449
+ group: g.filterState?.group ?? ""
4450
+ },
4451
+ g.filterState.group
4452
+ ),
4453
+ g.filterState.addFilter && /* @__PURE__ */ jsx(
4454
+ SimpleButton,
4455
+ {
4456
+ variant: "outline-sm",
4457
+ onClick: g.filterState.addFilter,
4458
+ children: getLabel("lblAddFil").text
4459
+ }
4460
+ )
4461
+ ]
4462
+ }
4463
+ )
4464
+ }
4465
+ )) }),
4466
+ hasSortable && /* @__PURE__ */ jsx(
4467
+ AccordionItem,
4468
+ {
4469
+ id: "Sort",
4470
+ buttonProps: { ariaLabel: sortTitle, label: sortTitle },
4471
+ children: /* @__PURE__ */ jsx(Sort, {})
4472
+ }
4473
+ ),
4474
+ hasFilters && !queryController.structure?.hideFilterTypes && /* @__PURE__ */ jsx(
4475
+ AccordionItem,
4476
+ {
4477
+ id: "FilterTypes",
4478
+ buttonProps: { ariaLabel: filterTypes, label: filterTypes },
4479
+ children: /* @__PURE__ */ jsx(FilterTypesComponent, { queryController })
4365
4480
  }
4366
4481
  )
4367
- }
4368
- )) }),
4369
- hasSortable && /* @__PURE__ */ jsx(
4370
- AccordionItem,
4371
- {
4372
- id: "Sort",
4373
- buttonProps: { ariaLabel: sortTitle, label: sortTitle },
4374
- children: /* @__PURE__ */ jsx(Sort, {})
4375
- }
4376
- ),
4377
- hasFilters && !queryController.structure?.hideFilterTypes && /* @__PURE__ */ jsx(
4378
- AccordionItem,
4379
- {
4380
- id: "FilterTypes",
4381
- buttonProps: { ariaLabel: filterTypes, label: filterTypes },
4382
- children: /* @__PURE__ */ jsx(FilterTypesComponent, { queryController })
4383
- }
4384
- )
4385
- ] })
4482
+ ] })
4483
+ }
4484
+ )
4386
4485
  }
4387
- ) });
4486
+ );
4388
4487
  }
4389
4488
  );
4390
4489