plmt-constructor-sdk 0.13.38 → 0.13.40

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.
@@ -16,10 +16,16 @@ function isFulfillingCondition(type, cellValue, condition) {
16
16
  : conditionValue;
17
17
  return isFulfillingNumberCondition(method, cellValue, value);
18
18
  case constants_1.ColumnType.Date:
19
- const date = Array.isArray(conditionValue)
20
- ? conditionValue.map((item) => new Date(item))
21
- : new Date(conditionValue);
22
- return isFulfillingDateCondition(method, new Date(cellValue), date);
19
+ const cellDate = new Date(cellValue);
20
+ if (Array.isArray(conditionValue)) {
21
+ if (conditionValue.length < 2)
22
+ return false;
23
+ return isFulfillingDateCondition(method, cellDate, [
24
+ new Date(conditionValue[0]),
25
+ new Date(conditionValue[1]),
26
+ ]);
27
+ }
28
+ return isFulfillingDateCondition(method, cellDate, new Date(conditionValue));
23
29
  default:
24
30
  return false;
25
31
  }
@@ -104,30 +110,58 @@ function isFulfillingNumberCondition(method, cellValue, conditionValue) {
104
110
  function isFulfillingDateCondition(method, cellValue, conditionValue) {
105
111
  if (Array.isArray(conditionValue))
106
112
  switch (method) {
107
- case data_1.FilterMethod.InList:
113
+ case data_1.FilterMethod.InList: {
108
114
  return (cellValue >= conditionValue[0] &&
109
115
  cellValue <= conditionValue[1]);
110
- case data_1.FilterMethod.NotInList:
116
+ }
117
+ case data_1.FilterMethod.NotInList: {
111
118
  return (cellValue < conditionValue[0] ||
112
119
  cellValue > conditionValue[1]);
120
+ }
121
+ case data_1.FilterMethod.Range: {
122
+ const start = startOfDay(conditionValue[0]);
123
+ const end = endOfDay(conditionValue[1]);
124
+ return cellValue >= start && cellValue <= end;
125
+ }
126
+ case data_1.FilterMethod.Range$Not: {
127
+ const start = startOfDay(conditionValue[0]);
128
+ const end = endOfDay(conditionValue[1]);
129
+ return cellValue < start || cellValue > end;
130
+ }
113
131
  default:
114
132
  return false;
115
133
  }
116
134
  else
117
135
  switch (method) {
118
- case data_1.FilterMethod.Equal:
119
- return cellValue.getTime() === conditionValue.getTime();
120
- case data_1.FilterMethod.NotEqual:
121
- return cellValue.getTime() !== conditionValue.getTime();
136
+ case data_1.FilterMethod.Equal: {
137
+ const start = startOfDay(conditionValue);
138
+ const end = endOfDay(conditionValue);
139
+ return cellValue >= start && cellValue <= end;
140
+ }
141
+ case data_1.FilterMethod.NotEqual: {
142
+ const start = startOfDay(conditionValue);
143
+ const end = endOfDay(conditionValue);
144
+ return cellValue < start || cellValue > end;
145
+ }
122
146
  case data_1.FilterMethod.GreaterThen:
123
- return cellValue > conditionValue;
147
+ return cellValue > endOfDay(conditionValue);
124
148
  case data_1.FilterMethod.GreaterThenOrEqual:
125
- return cellValue >= conditionValue;
149
+ return cellValue >= startOfDay(conditionValue);
126
150
  case data_1.FilterMethod.LessThen:
127
- return cellValue < conditionValue;
151
+ return cellValue < startOfDay(conditionValue);
128
152
  case data_1.FilterMethod.LessThenOrEqual:
129
- return cellValue <= conditionValue;
153
+ return cellValue <= endOfDay(conditionValue);
130
154
  default:
131
155
  return false;
132
156
  }
133
157
  }
158
+ function startOfDay(date) {
159
+ const normalizedDate = new Date(date.getTime());
160
+ normalizedDate.setHours(0, 0, 0, 0);
161
+ return normalizedDate;
162
+ }
163
+ function endOfDay(date) {
164
+ const normalizedDate = new Date(date.getTime());
165
+ normalizedDate.setHours(23, 59, 59, 999);
166
+ return normalizedDate;
167
+ }
@@ -1,10 +1,5 @@
1
- import { FilterMethod } from '../data';
2
- export declare enum ColumnType {
3
- String = 0,
4
- Number = 1,
5
- Date = 2,
6
- Boolean = 3
7
- }
1
+ import { ColumnType, FilterMethod } from '../data';
2
+ export { ColumnType };
8
3
  export declare const COLOR_STEPS = 128;
9
4
  export interface Condition {
10
5
  column_id: number;
@@ -1,11 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.COLOR_STEPS = exports.ColumnType = void 0;
4
- var ColumnType;
5
- (function (ColumnType) {
6
- ColumnType[ColumnType["String"] = 0] = "String";
7
- ColumnType[ColumnType["Number"] = 1] = "Number";
8
- ColumnType[ColumnType["Date"] = 2] = "Date";
9
- ColumnType[ColumnType["Boolean"] = 3] = "Boolean";
10
- })(ColumnType = exports.ColumnType || (exports.ColumnType = {}));
4
+ const data_1 = require("../data");
5
+ Object.defineProperty(exports, "ColumnType", { enumerable: true, get: function () { return data_1.ColumnType; } });
11
6
  exports.COLOR_STEPS = 128;
package/declare.d.ts CHANGED
@@ -12,14 +12,6 @@
12
12
  * @packageDocumentation
13
13
  * @module Регистрация виджета
14
14
  */
15
- import { WidgetState } from './widget';
16
- declare global {
17
- interface Window {
18
- getWidgetState: {
19
- [uid: string]: () => WidgetState;
20
- };
21
- }
22
- }
23
15
  /**
24
16
  * Функция-декоратор
25
17
  */
package/declare.js CHANGED
@@ -35,11 +35,6 @@ function Declare(params) {
35
35
  const uid = readFromUrl('uid');
36
36
  if (uid)
37
37
  instance.uid = uid;
38
- if (typeof instance.getWidgetState === 'function' && uid) {
39
- const getState = window.parent['getWidgetState'] || {};
40
- getState[uid] = instance.getWidgetState.bind(instance);
41
- window.parent.getWidgetState = getState;
42
- }
43
38
  Object.assign(instance, {
44
39
  viewSettings: {},
45
40
  ready() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plmt-constructor-sdk",
3
- "version": "0.13.38",
3
+ "version": "0.13.40",
4
4
  "description": "Набор инструментов для создания виджетов.",
5
5
  "dependencies": {
6
6
  "logical-not": "^1.0.9"
package/widget.d.ts CHANGED
@@ -18,11 +18,6 @@ export declare abstract class Widget {
18
18
  ready(): void;
19
19
  onInit(): void;
20
20
  abstract onChange(): void;
21
- /**
22
- * Метод для получения состояния виджета
23
- * @return `WidgetState`
24
- */
25
- abstract getWidgetState(): WidgetState;
26
21
  /**
27
22
  * Обработчик события кастомного запроса
28
23
  * @param customData WidgetCustomProvide
@@ -32,15 +27,6 @@ export declare abstract class Widget {
32
27
  onThemeChange(): void;
33
28
  onLangChange(): void;
34
29
  }
35
- /**
36
- * Состояние виджета
37
- */
38
- export interface WidgetState {
39
- /** Лимит */
40
- limit?: number;
41
- /** Смещение */
42
- offset?: number;
43
- }
44
30
  /**
45
31
  * Интерфейс для виджета с одним источником данных
46
32
  */