plmt-constructor-sdk 0.16.0 → 0.17.1

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.
Files changed (3) hide show
  1. package/README.md +23 -19
  2. package/config.d.ts +6 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -244,7 +244,7 @@ background: var(--background-bright);
244
244
  в блоке с ключом `blocke-key`:
245
245
 
246
246
  ```ts
247
- import { DataSettings } from 'plmt-constructor-sdk';
247
+ import { DataSettings, ViewSettings } from 'plmt-constructor-sdk';
248
248
  import {
249
249
  CreateViewSettings,
250
250
  input,
@@ -269,23 +269,27 @@ export const createViewSettings: CreateViewSettings<DataSettings> = ({
269
269
  ];
270
270
  };
271
271
 
272
- export const validation: ViewSettingsValidation = {
273
- ['number-key']: (value: any) => {
274
- const number = parseInt(value);
275
-
276
- if (isNaN(number))
277
- return {
278
- ru: 'Значение должно быть числом',
279
- en: 'Not a number',
280
- };
281
-
282
- if (number < 1 || number > max)
283
- return {
284
- ru: `Значение должно быть в диапозоне от 1 до ${max}`,
285
- en: `Not in range 1 до ${max}`,
286
- };
287
-
288
- return null;
289
- },
272
+ export const validation: ViewSettingsValidation = (
273
+ viewSettings: ViewSettings,
274
+ ) => {
275
+ return {
276
+ ['number-key']: (value: any) => {
277
+ const number = parseInt(value);
278
+
279
+ if (isNaN(number))
280
+ return {
281
+ ru: 'Значение должно быть числом',
282
+ en: 'Not a number',
283
+ };
284
+
285
+ if (number < 1 || number > max)
286
+ return {
287
+ ru: `Значение должно быть в диапозоне от 1 до ${max}`,
288
+ en: `Not in range 1 до ${max}`,
289
+ };
290
+
291
+ return null;
292
+ },
293
+ };
290
294
  };
291
295
  ```
package/config.d.ts CHANGED
@@ -137,9 +137,15 @@ export interface CreateViewSettings<DataSettings extends WidgetDataSettings | Wi
137
137
  }
138
138
  export declare type ViewSettingsValidator = (value: any) => Text | null;
139
139
  declare type ViewSettingsLabel = Text | string;
140
+ /**
141
+ * @deprecated Используйте ViewSettingsValidationFn
142
+ */
140
143
  export interface ViewSettingsValidation {
141
144
  [key: string]: ViewSettingsValidator;
142
145
  }
146
+ export declare type ViewSettingsValidationFn = (viewSettings: ViewSettings) => {
147
+ [key: string]: ViewSettingsValidator;
148
+ };
143
149
  export declare class ViewSettingsItem {
144
150
  private [viewSettingsItemValue];
145
151
  constructor(_: symbol);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plmt-constructor-sdk",
3
- "version": "0.16.0",
3
+ "version": "0.17.1",
4
4
  "description": "Набор инструментов для создания виджетов.",
5
5
  "dependencies": {
6
6
  "logical-not": "^1.0.9"