@mw-kit/mw-ui 1.7.7 → 1.7.8
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/dist/components/Calendar/functions.d.ts +1 -1
- package/dist/components/Input/components/DateIntervalPicker/functions.d.ts +3 -2
- package/dist/components/Input/components/DateIntervalPicker/interfaces.d.ts +5 -3
- package/dist/functions/common.d.ts +1 -0
- package/dist/functions/formatters.d.ts +1 -2
- package/dist/functions/validators.d.ts +6 -1
- package/dist/index.js +35 -24
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +35 -24
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { CalendarInterface } from './components/Basic/interfaces';
|
|
|
2
2
|
export declare const getCalendar: (d: Date) => CalendarInterface;
|
|
3
3
|
export declare const getMiddle: (min?: Date | undefined, max?: Date | undefined) => Date;
|
|
4
4
|
export declare const getFullDate: (date: Date, time: string, end?: true | undefined) => Date;
|
|
5
|
-
export declare const isDateBetween: (date: Date, min?: Date | undefined, max?: Date | undefined
|
|
5
|
+
export declare const isDateBetween: (date: Date, min?: Date | undefined, max?: Date | undefined) => boolean;
|
|
6
6
|
export declare const getTimeFromDate: (date: Date | null) => string;
|
|
7
7
|
export declare const isInvalid: (value: Date | null, time: string, timeOptions?: {
|
|
8
8
|
required?: boolean | undefined;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { Value } from '../../../Calendar/components/Interval/interfaces';
|
|
1
2
|
import { IntervalType, IntervalTypes } from './interfaces';
|
|
2
|
-
export declare const validate: (value:
|
|
3
|
+
export declare const validate: (value: Value, min?: Date, max?: Date) => boolean;
|
|
3
4
|
export declare const intervalTypes: IntervalTypes;
|
|
4
|
-
export declare const identify: (value:
|
|
5
|
+
export declare const identify: (value: Value) => IntervalType;
|
|
5
6
|
export declare const parse: (value: [string, string]) => [Date | null, Date | null];
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { IntervalCalendarProps } from '../../../Calendar/interfaces';
|
|
3
3
|
import { InputProps } from '../Input/interfaces';
|
|
4
|
+
declare type Value = [string, string];
|
|
4
5
|
export declare type IntervalType = 'day' | 'week' | 'month' | 'custom';
|
|
5
6
|
export interface DateIntervalPickerProps extends React.HTMLAttributes<HTMLInputElement>, Pick<InputProps, 'label' | 'invalid' | 'required' | 'disabled' | 'width' | 'borderless' | 'paddingless'> {
|
|
6
7
|
type: 'date-interval-picker';
|
|
7
|
-
value:
|
|
8
|
-
setValue: (value:
|
|
9
|
-
getLabel?: (value:
|
|
8
|
+
value: Value;
|
|
9
|
+
setValue: (value: Value) => void;
|
|
10
|
+
getLabel?: (value: Value) => string;
|
|
10
11
|
max?: Date;
|
|
11
12
|
min?: Date;
|
|
12
13
|
only?: IntervalType;
|
|
@@ -25,3 +26,4 @@ export interface Variation {
|
|
|
25
26
|
export declare type IntervalTypes = {
|
|
26
27
|
[key in IntervalType]: Variation;
|
|
27
28
|
};
|
|
29
|
+
export {};
|
|
@@ -2,3 +2,4 @@ export declare const stripAccents: (value: string) => string;
|
|
|
2
2
|
export declare const isKeyOf: <T>(object: T, key: string | number | symbol) => key is keyof T;
|
|
3
3
|
export declare const isObject: <T = unknown>(value: unknown) => value is T;
|
|
4
4
|
export declare const dateToIsoString: (date: Date, time?: boolean, fullYear?: boolean, pattern?: 'us' | 'br') => string;
|
|
5
|
+
export declare const keys: <T extends Record<string | number | symbol, any>>(value: T) => (keyof T)[];
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { SpacingOrZero, Spacings } from '../interfaces';
|
|
2
|
-
export declare const keys: <T extends Record<string | number | symbol, any>>(value: T) => (keyof T)[];
|
|
3
2
|
export declare const filterObject: <T extends Record<string | number | symbol, any>, R extends Record<string | number | symbol, any>>(object: T, remove: (keyof T)[], inital?: Partial<R>) => R;
|
|
4
3
|
export declare const phone: (value: string) => string;
|
|
5
4
|
export declare const cnpj: (value: string) => string;
|
|
@@ -24,7 +23,7 @@ export declare const getWeekNumber: (value: Date) => [number, number];
|
|
|
24
23
|
export declare const getMonthName: (value: Date) => string;
|
|
25
24
|
export declare const getFirstWeek: (year?: number | undefined) => Date;
|
|
26
25
|
export declare const getLastWeek: (year?: number | undefined) => Date;
|
|
27
|
-
export { stripAccents, dateToIsoString } from './common';
|
|
26
|
+
export { stripAccents, dateToIsoString, keys } from './common';
|
|
28
27
|
export declare const getSpacings: (value: SpacingOrZero | Spacings, defaults?: "s1" | "s2" | "s3" | "s4" | "s5" | "s6" | "0" | Spacings | undefined) => string;
|
|
29
28
|
export declare const clone: <T>(value: T) => T;
|
|
30
29
|
export declare const unique: <T>(value: T[], callback?: (item: T, arr: T[]) => boolean) => T[];
|
|
@@ -8,7 +8,12 @@ export declare const isString: (value: unknown) => value is string;
|
|
|
8
8
|
export declare const isDateInstance: (value: unknown) => value is Date;
|
|
9
9
|
export declare const isDate: (value: unknown) => boolean;
|
|
10
10
|
declare type Operations = 'eq' | 'gt' | 'gte' | 'lt' | 'lte';
|
|
11
|
-
export declare const dateCompare: (a: Date, b: Date, operation: Operations, time?: boolean
|
|
11
|
+
export declare const dateCompare: (a: Date, b: Date, operation: Operations, time?: boolean | Partial<{
|
|
12
|
+
s: true;
|
|
13
|
+
h: true;
|
|
14
|
+
m: true;
|
|
15
|
+
ms: true;
|
|
16
|
+
}>) => boolean;
|
|
12
17
|
declare type Formats = 'h' | 'm' | 's';
|
|
13
18
|
declare type Mode = 'required' | 'optional';
|
|
14
19
|
export declare const isValidTime: (time: string, format?: Partial<{
|
package/dist/index.js
CHANGED
|
@@ -195,6 +195,9 @@ var dateToIsoString = function dateToIsoString(date, time, fullYear, pattern) {
|
|
|
195
195
|
var timeStr = [date.getHours().toString().padStart(2, '0'), date.getMinutes().toString().padStart(2, '0'), date.getSeconds().toString().padStart(2, '0')].join(':');
|
|
196
196
|
return [dateStr, timeStr].join(' ');
|
|
197
197
|
};
|
|
198
|
+
var keys = function keys(value) {
|
|
199
|
+
return Object.keys(value);
|
|
200
|
+
};
|
|
198
201
|
|
|
199
202
|
var notEmptyString = function notEmptyString(value) {
|
|
200
203
|
return typeof value === 'string' && value.trim() !== '';
|
|
@@ -210,7 +213,11 @@ var isDateInstance = function isDateInstance(value) {
|
|
|
210
213
|
};
|
|
211
214
|
var dateCompare = function dateCompare(a, b, operation, time) {
|
|
212
215
|
if (time === void 0) {
|
|
213
|
-
time =
|
|
216
|
+
time = {
|
|
217
|
+
h: true,
|
|
218
|
+
m: true,
|
|
219
|
+
s: true
|
|
220
|
+
};
|
|
214
221
|
}
|
|
215
222
|
|
|
216
223
|
var operations = {
|
|
@@ -230,12 +237,25 @@ var dateCompare = function dateCompare(a, b, operation, time) {
|
|
|
230
237
|
return this.lt(a, b) || this.eq(a, b);
|
|
231
238
|
}
|
|
232
239
|
};
|
|
240
|
+
a = new Date(a);
|
|
241
|
+
b = new Date(b);
|
|
233
242
|
|
|
234
243
|
if (time === false) {
|
|
235
|
-
a = new Date(a);
|
|
236
244
|
a.setHours(0, 0, 0, 0);
|
|
237
|
-
b = new Date(b);
|
|
238
245
|
b.setHours(0, 0, 0, 0);
|
|
246
|
+
} else if (time !== true) {
|
|
247
|
+
var methods = {
|
|
248
|
+
h: 'setHours',
|
|
249
|
+
m: 'setMinutes',
|
|
250
|
+
s: 'setSeconds',
|
|
251
|
+
ms: 'setMilliseconds'
|
|
252
|
+
};
|
|
253
|
+
keys(methods).forEach(function (k) {
|
|
254
|
+
if (time[k]) return;
|
|
255
|
+
var method = methods[k];
|
|
256
|
+
a[method](0);
|
|
257
|
+
b[method](0);
|
|
258
|
+
});
|
|
239
259
|
}
|
|
240
260
|
|
|
241
261
|
return operations[operation](a, b);
|
|
@@ -292,9 +312,6 @@ var strCmp = function strCmp(x, y, options) {
|
|
|
292
312
|
return options.contain ? x.includes(y) : x === y;
|
|
293
313
|
};
|
|
294
314
|
|
|
295
|
-
var keys = function keys(value) {
|
|
296
|
-
return Object.keys(value);
|
|
297
|
-
};
|
|
298
315
|
var filterObject = function filterObject(object, remove, inital) {
|
|
299
316
|
if (inital === void 0) {
|
|
300
317
|
inital = {};
|
|
@@ -13311,22 +13328,18 @@ var getFullDate = function getFullDate(date, time, end) {
|
|
|
13311
13328
|
v.setHours.apply(v, hours);
|
|
13312
13329
|
return v;
|
|
13313
13330
|
};
|
|
13314
|
-
var isDateBetween = function isDateBetween(date, min, max
|
|
13315
|
-
if (time === void 0) {
|
|
13316
|
-
time = false;
|
|
13317
|
-
}
|
|
13318
|
-
|
|
13331
|
+
var isDateBetween = function isDateBetween(date, min, max) {
|
|
13319
13332
|
if (!max) {
|
|
13320
13333
|
if (!min) return true;
|
|
13321
|
-
return dateCompare(date, min, 'gte'
|
|
13334
|
+
return dateCompare(date, min, 'gte');
|
|
13322
13335
|
}
|
|
13323
13336
|
|
|
13324
13337
|
if (!min) {
|
|
13325
13338
|
if (!max) return true;
|
|
13326
|
-
return dateCompare(date, max, 'lte'
|
|
13339
|
+
return dateCompare(date, max, 'lte');
|
|
13327
13340
|
}
|
|
13328
13341
|
|
|
13329
|
-
return dateCompare(date, min, 'gte'
|
|
13342
|
+
return dateCompare(date, min, 'gte') && dateCompare(date, max, 'lte');
|
|
13330
13343
|
};
|
|
13331
13344
|
var getTimeFromDate = function getTimeFromDate(date) {
|
|
13332
13345
|
if (!date) return '';
|
|
@@ -15551,8 +15564,8 @@ var validate = function validate(_ref, min, max) {
|
|
|
15551
15564
|
var start = _ref[0],
|
|
15552
15565
|
end = _ref[1];
|
|
15553
15566
|
if (start === null || end === null) return true;
|
|
15554
|
-
if (min && start
|
|
15555
|
-
if (max && end
|
|
15567
|
+
if (min && dateCompare(start, min, 'lt')) return false;
|
|
15568
|
+
if (max && dateCompare(end, max, 'gt')) return false;
|
|
15556
15569
|
return true;
|
|
15557
15570
|
};
|
|
15558
15571
|
var intervalTypes = {
|
|
@@ -15560,7 +15573,7 @@ var intervalTypes = {
|
|
|
15560
15573
|
label: function label(prev) {
|
|
15561
15574
|
var today = new Date();
|
|
15562
15575
|
today.setHours(0, 0, 0, 0);
|
|
15563
|
-
if (dateCompare(today, prev[0], 'eq')) return 'Hoje';
|
|
15576
|
+
if (dateCompare(today, prev[0], 'eq', false)) return 'Hoje';
|
|
15564
15577
|
return dateToIsoString(prev[0], false, false);
|
|
15565
15578
|
},
|
|
15566
15579
|
initial: function initial(base) {
|
|
@@ -15600,7 +15613,7 @@ var intervalTypes = {
|
|
|
15600
15613
|
start.setHours(0, 0, 0, 0);
|
|
15601
15614
|
var end = new Date(start);
|
|
15602
15615
|
end.setDate(start.getDate() + 6);
|
|
15603
|
-
end.setHours(23, 59, 59,
|
|
15616
|
+
end.setHours(23, 59, 59, 999);
|
|
15604
15617
|
return [start, end];
|
|
15605
15618
|
},
|
|
15606
15619
|
increment: function increment(prev) {
|
|
@@ -15642,7 +15655,7 @@ var intervalTypes = {
|
|
|
15642
15655
|
var end = new Date(start);
|
|
15643
15656
|
end.setMonth(end.getMonth() + 1);
|
|
15644
15657
|
end.setDate(0);
|
|
15645
|
-
end.setHours(23, 59, 59,
|
|
15658
|
+
end.setHours(23, 59, 59, 999);
|
|
15646
15659
|
return [start, end];
|
|
15647
15660
|
},
|
|
15648
15661
|
increment: function increment(prev) {
|
|
@@ -15652,7 +15665,7 @@ var intervalTypes = {
|
|
|
15652
15665
|
var end = new Date(start);
|
|
15653
15666
|
end.setMonth(end.getMonth() + 1);
|
|
15654
15667
|
end.setDate(0);
|
|
15655
|
-
end.setHours(23, 59, 59,
|
|
15668
|
+
end.setHours(23, 59, 59, 999);
|
|
15656
15669
|
return [start, end];
|
|
15657
15670
|
},
|
|
15658
15671
|
decrement: function decrement(prev) {
|
|
@@ -15662,7 +15675,7 @@ var intervalTypes = {
|
|
|
15662
15675
|
var end = new Date(start);
|
|
15663
15676
|
end.setMonth(end.getMonth() + 1);
|
|
15664
15677
|
end.setDate(0);
|
|
15665
|
-
end.setHours(23, 59, 59,
|
|
15678
|
+
end.setHours(23, 59, 59, 999);
|
|
15666
15679
|
return [start, end];
|
|
15667
15680
|
}
|
|
15668
15681
|
},
|
|
@@ -15691,10 +15704,8 @@ var identify = function identify(value) {
|
|
|
15691
15704
|
var start = value[0],
|
|
15692
15705
|
end = value[1];
|
|
15693
15706
|
if (start === null || end === null) return 'custom';
|
|
15694
|
-
var isoStart = dateToIsoString(start);
|
|
15695
|
-
var isoEnd = dateToIsoString(end);
|
|
15696
15707
|
|
|
15697
|
-
if (
|
|
15708
|
+
if (dateCompare(start, end, 'eq', false)) {
|
|
15698
15709
|
var _intervalTypes$day$in = intervalTypes.day.initial(start),
|
|
15699
15710
|
expectedStart = _intervalTypes$day$in[0],
|
|
15700
15711
|
expectedEnd = _intervalTypes$day$in[1];
|