@opengeoweb/shared 4.6.0 → 4.7.0
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/index.esm.js +258 -9
- package/index.umd.js +299 -26
- package/lib/components/ToolContainer/ToolContainerDraggable.d.ts +0 -1
- package/lib/utils/dateUtils/dateUtils.d.ts +133 -0
- package/lib/utils/dateUtils/dateUtils.spec.d.ts +1 -0
- package/lib/utils/dateUtils/index.d.ts +1 -0
- package/lib/utils/index.d.ts +1 -0
- package/package.json +5 -4
package/index.esm.js
CHANGED
|
@@ -8,6 +8,7 @@ import { throttle } from 'lodash';
|
|
|
8
8
|
import Draggable from 'react-draggable';
|
|
9
9
|
import { Resizable } from 're-resizable';
|
|
10
10
|
import { useStore } from 'react-redux';
|
|
11
|
+
import { parseISO, parse, format, isEqual, isBefore, isAfter } from 'date-fns';
|
|
11
12
|
|
|
12
13
|
/*! *****************************************************************************
|
|
13
14
|
Copyright (c) Microsoft Corporation.
|
|
@@ -581,7 +582,9 @@ var useDraftFormHelpers = function useDraftFormHelpers() {
|
|
|
581
582
|
register = _useFormContext.register;
|
|
582
583
|
|
|
583
584
|
React.useEffect(function () {
|
|
584
|
-
setValue(HIDDEN_INPUT_HELPER_IS_DRAFT, isDefaultDraft
|
|
585
|
+
setValue(HIDDEN_INPUT_HELPER_IS_DRAFT, isDefaultDraft, {
|
|
586
|
+
shouldDirty: false
|
|
587
|
+
}); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
585
588
|
}, []);
|
|
586
589
|
|
|
587
590
|
var isDraft = function isDraft() {
|
|
@@ -597,7 +600,9 @@ var useDraftFormHelpers = function useDraftFormHelpers() {
|
|
|
597
600
|
};
|
|
598
601
|
|
|
599
602
|
var toggleIsDraft = function toggleIsDraft(isDraft) {
|
|
600
|
-
return setValue(HIDDEN_INPUT_HELPER_IS_DRAFT, isDraft
|
|
603
|
+
return setValue(HIDDEN_INPUT_HELPER_IS_DRAFT, isDraft, {
|
|
604
|
+
shouldDirty: false
|
|
605
|
+
});
|
|
601
606
|
};
|
|
602
607
|
|
|
603
608
|
var DraftFieldHelper = function DraftFieldHelper() {
|
|
@@ -1918,15 +1923,13 @@ var DraggableComponent = function DraggableComponent(_a) {
|
|
|
1918
1923
|
leftHeaderComponent = _a$leftHeaderComponen === void 0 ? null : _a$leftHeaderComponen,
|
|
1919
1924
|
_a$rightHeaderCompone = _a.rightHeaderComponent,
|
|
1920
1925
|
rightHeaderComponent = _a$rightHeaderCompone === void 0 ? null : _a$rightHeaderCompone,
|
|
1921
|
-
_a$hasElevation = _a.hasElevation,
|
|
1922
|
-
hasElevation = _a$hasElevation === void 0 ? true : _a$hasElevation,
|
|
1923
1926
|
className = _a.className,
|
|
1924
1927
|
_a$sx = _a.sx,
|
|
1925
1928
|
sx = _a$sx === void 0 ? {} : _a$sx,
|
|
1926
|
-
props = __rest(_a, ["title", "bounds", "headerSize", "startSize", "startPosition", "children", "isOpen", "onClose", "initialMaxHeight", "onChangeSize", "onMouseDown", "onResizeStop", "onDragEnd", "order", "source", "leftHeaderComponent", "rightHeaderComponent", "
|
|
1929
|
+
props = __rest(_a, ["title", "bounds", "headerSize", "startSize", "startPosition", "children", "isOpen", "onClose", "initialMaxHeight", "onChangeSize", "onMouseDown", "onResizeStop", "onDragEnd", "order", "source", "leftHeaderComponent", "rightHeaderComponent", "className", "sx"]);
|
|
1927
1930
|
|
|
1928
1931
|
var zIndex = (source === 'app' ? BASE_Z_INDEX : 1000) + order;
|
|
1929
|
-
var elevation =
|
|
1932
|
+
var elevation = BASE_ELEVATION + order;
|
|
1930
1933
|
var nodeRef = React__default.useRef(null);
|
|
1931
1934
|
|
|
1932
1935
|
var _React$useState = React__default.useState({
|
|
@@ -3070,8 +3073,13 @@ var TooltipSelect = function TooltipSelect(_a) {
|
|
|
3070
3073
|
if (requiresCtrlToChange && (event.ctrlKey || event.metaKey) || !requiresCtrlToChange) {
|
|
3071
3074
|
if (selectOpen) return;
|
|
3072
3075
|
var direction = event.deltaY < 0 ? 1 : -1;
|
|
3073
|
-
var
|
|
3074
|
-
|
|
3076
|
+
var newIndex = currentIndex - direction;
|
|
3077
|
+
|
|
3078
|
+
if (newIndex < 0 || newIndex >= list.length) {
|
|
3079
|
+
return;
|
|
3080
|
+
}
|
|
3081
|
+
|
|
3082
|
+
onChangeMouseWheel(list[newIndex]);
|
|
3075
3083
|
}
|
|
3076
3084
|
}, [selectOpen, currentIndex, list, onChangeMouseWheel, requiresCtrlToChange]);
|
|
3077
3085
|
var onOpen = React.useCallback(function () {
|
|
@@ -3294,4 +3302,245 @@ var getWarningMessage = function getWarningMessage(error) {
|
|
|
3294
3302
|
// temporary check until we get the unit test passing with container queries
|
|
3295
3303
|
var IS_JEST = typeof jest !== 'undefined';
|
|
3296
3304
|
|
|
3297
|
-
|
|
3305
|
+
/* *
|
|
3306
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3307
|
+
* you may not use this file except in compliance with the License.
|
|
3308
|
+
* You may obtain a copy of the License at
|
|
3309
|
+
*
|
|
3310
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3311
|
+
*
|
|
3312
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3313
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3314
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3315
|
+
* See the License for the specific language governing permissions and
|
|
3316
|
+
* limitations under the License.
|
|
3317
|
+
*
|
|
3318
|
+
* Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
3319
|
+
* Copyright 2022 - Finnish Meteorological Institute (FMI)
|
|
3320
|
+
* */
|
|
3321
|
+
/**
|
|
3322
|
+
* Parsing date strings with geoweb dateUtils:
|
|
3323
|
+
*
|
|
3324
|
+
* An ISO String *with timezone* can safely be parsed directly to a date:
|
|
3325
|
+
*
|
|
3326
|
+
* date = new Date('2022-10-10T15:30:00Z')
|
|
3327
|
+
* date = new Date('2022-10-10T15:30:00+00:00')
|
|
3328
|
+
* date = new Date('2022-10-10T15:30:00+02:00')
|
|
3329
|
+
*
|
|
3330
|
+
* or using the dateUtils isoStringToDate function *with utc=false*
|
|
3331
|
+
*
|
|
3332
|
+
* date = isoStringToDate('2022-10-10T15:30:00Z', false)
|
|
3333
|
+
*
|
|
3334
|
+
* An ISO String *without a timezone* can be parsed with isoStringToDate
|
|
3335
|
+
*
|
|
3336
|
+
* date = isoStringToDate('2022-10-10T15:30:00')
|
|
3337
|
+
*
|
|
3338
|
+
* *Do not parse ISO without timezone using `new Date()` unless you correct for the local timezone*
|
|
3339
|
+
*
|
|
3340
|
+
* To parse an arbitrary date string with timezone use:
|
|
3341
|
+
*
|
|
3342
|
+
* date = stringToDate('2022.11.10, 11:15 +01:00', 'yyyy.MM.dd, HH:mm xxx', false)
|
|
3343
|
+
*
|
|
3344
|
+
* To parse an arbitrary date string without timezone use:
|
|
3345
|
+
*
|
|
3346
|
+
* date = stringToDate('2022.11.10, 11:15', 'yyyy.MM.dd, HH:mm')
|
|
3347
|
+
*
|
|
3348
|
+
*
|
|
3349
|
+
* To safely convert dates to utc strings use:
|
|
3350
|
+
*
|
|
3351
|
+
* date.toISOString()
|
|
3352
|
+
*
|
|
3353
|
+
* To get parts of UTC time use
|
|
3354
|
+
*
|
|
3355
|
+
* date.getUTCHours()
|
|
3356
|
+
* date.getUTCMins()
|
|
3357
|
+
*
|
|
3358
|
+
* To parse an arbitrary date string to a UTC string use:
|
|
3359
|
+
*
|
|
3360
|
+
* dateToString(new Date('2022-10-10T15:30:00Z', 'HH:ss dd MMM yyyy')
|
|
3361
|
+
*
|
|
3362
|
+
*/
|
|
3363
|
+
|
|
3364
|
+
/**
|
|
3365
|
+
* Parse an ISO string to a date
|
|
3366
|
+
*
|
|
3367
|
+
* Expects the following props:
|
|
3368
|
+
* @param {string} input - string containing date
|
|
3369
|
+
*
|
|
3370
|
+
* @returns {Date} Date
|
|
3371
|
+
* @example
|
|
3372
|
+
* ``` isoStringToDate("2022-5-10T20:32:00+00:00")) ```
|
|
3373
|
+
*/
|
|
3374
|
+
|
|
3375
|
+
var isoStringToDate = function isoStringToDate(input) {
|
|
3376
|
+
var utc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
3377
|
+
var parsed = parseISO(input);
|
|
3378
|
+
|
|
3379
|
+
if (utc) {
|
|
3380
|
+
return setUTCDate(parsed);
|
|
3381
|
+
}
|
|
3382
|
+
|
|
3383
|
+
return parsed;
|
|
3384
|
+
};
|
|
3385
|
+
/**
|
|
3386
|
+
* Parse a string to a date
|
|
3387
|
+
*
|
|
3388
|
+
* ***NOTE: String will be parsed in local time if utc is set to false***
|
|
3389
|
+
*
|
|
3390
|
+
* Expects the following props:
|
|
3391
|
+
* @param {string} input - string containing date
|
|
3392
|
+
* @param {string} strFormat - format of the string, see: https://date-fns.org/v2.29.3/docs/parse
|
|
3393
|
+
* @param {boolean} utc [ default = true ] - boolean indicating whether to parse as UTC
|
|
3394
|
+
* @param {Date} referenceDate [ default = new Date() ] - defines values missing from the parsed dateString
|
|
3395
|
+
*
|
|
3396
|
+
* @returns {Date} Date
|
|
3397
|
+
* @example
|
|
3398
|
+
* ``` stringToDate("2022 5 10 20:32", 'yyyy M d HH:mm')) ```
|
|
3399
|
+
*/
|
|
3400
|
+
|
|
3401
|
+
var stringToDate = function stringToDate(input, strFormat) {
|
|
3402
|
+
var utc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
3403
|
+
var referenceDate = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new Date();
|
|
3404
|
+
var parsed = parse(input, strFormat, referenceDate);
|
|
3405
|
+
|
|
3406
|
+
if (utc) {
|
|
3407
|
+
return setUTCDate(parsed);
|
|
3408
|
+
}
|
|
3409
|
+
|
|
3410
|
+
return parsed;
|
|
3411
|
+
};
|
|
3412
|
+
/**
|
|
3413
|
+
* Use this if you initialise a date without a timezone to set it to utc correctly
|
|
3414
|
+
* eg.
|
|
3415
|
+
* new Date(2022, 10, 12, 15, 30)
|
|
3416
|
+
* should be:
|
|
3417
|
+
* setUTCDate(new Date(2022, 10, 12, 15, 30))
|
|
3418
|
+
*
|
|
3419
|
+
* Expects the following props:
|
|
3420
|
+
* @param {Date} inDate - date to be set to UTC
|
|
3421
|
+
*
|
|
3422
|
+
* @returns {Date} - Date in UTC
|
|
3423
|
+
* @example
|
|
3424
|
+
* ``` setUTCDate(new Date(2022, 10, 12, 15, 30)) ```
|
|
3425
|
+
*/
|
|
3426
|
+
|
|
3427
|
+
var setUTCDate = function setUTCDate(inDate) {
|
|
3428
|
+
var utcDate = new Date(inDate);
|
|
3429
|
+
utcDate.setUTCFullYear(inDate.getFullYear(), inDate.getMonth(), inDate.getDate());
|
|
3430
|
+
utcDate.setUTCHours(inDate.getHours(), inDate.getMinutes(), inDate.getSeconds(), inDate.getMilliseconds());
|
|
3431
|
+
return utcDate;
|
|
3432
|
+
};
|
|
3433
|
+
/**
|
|
3434
|
+
* Format a date to a string
|
|
3435
|
+
*
|
|
3436
|
+
* Expects the following props:
|
|
3437
|
+
* @param {Date} inDate - date to be formatted
|
|
3438
|
+
* @param {string} strFormat - format of string
|
|
3439
|
+
* @param {boolean} utc - [default: true] true to return in utc otherwise return in local timezone
|
|
3440
|
+
*
|
|
3441
|
+
* @returns {string} - formatted date string
|
|
3442
|
+
* @example
|
|
3443
|
+
* ``` dateToString(new Date(2022, 10, 12, 15, 30), 'dd MMM yyyy') ```
|
|
3444
|
+
*/
|
|
3445
|
+
|
|
3446
|
+
var dateToString = function dateToString(inDate, strFormat) {
|
|
3447
|
+
var utc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
3448
|
+
|
|
3449
|
+
if (utc) {
|
|
3450
|
+
return format(new Date(inDate.getUTCFullYear(), inDate.getUTCMonth(), inDate.getUTCDate(), inDate.getUTCHours(), inDate.getUTCMinutes(), inDate.getUTCSeconds()), strFormat);
|
|
3451
|
+
}
|
|
3452
|
+
|
|
3453
|
+
return format(inDate, strFormat);
|
|
3454
|
+
};
|
|
3455
|
+
/**
|
|
3456
|
+
* Find out if a date is between two other dates.
|
|
3457
|
+
*
|
|
3458
|
+
* Inclusivity parameter matches that used in momentjs where '[' indicates inclusion and '(' indicates exclusion.
|
|
3459
|
+
*
|
|
3460
|
+
* Expects the following props:
|
|
3461
|
+
* @param {Date} date - date to be tested
|
|
3462
|
+
* @param {Date} from - first date
|
|
3463
|
+
* @param {Date} to - last date
|
|
3464
|
+
* @param {string} inclusivity - [default: '()'] Must be one of : '()', '[]', '(]', '[)'
|
|
3465
|
+
*
|
|
3466
|
+
* @returns {boolen} - true if date is between, otherwise false
|
|
3467
|
+
*
|
|
3468
|
+
*/
|
|
3469
|
+
|
|
3470
|
+
var isBetween = function isBetween(date, from, to) {
|
|
3471
|
+
var inclusivity = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '()';
|
|
3472
|
+
|
|
3473
|
+
if (!['()', '[]', '(]', '[)'].includes(inclusivity)) {
|
|
3474
|
+
throw new Error('Inclusivity parameter must be one of (), [], (], [)');
|
|
3475
|
+
}
|
|
3476
|
+
|
|
3477
|
+
var isBeforeEqual = inclusivity[0] === '[';
|
|
3478
|
+
var isAfterEqual = inclusivity[1] === ']';
|
|
3479
|
+
return (isBeforeEqual ? isEqual(from, date) || isBefore(from, date) : isBefore(from, date)) && (isAfterEqual ? isEqual(to, date) || isAfter(to, date) : isAfter(to, date));
|
|
3480
|
+
};
|
|
3481
|
+
/**
|
|
3482
|
+
* Creates a new Date object with the specified date and time, or the current date and time if no arguments are provided.
|
|
3483
|
+
*
|
|
3484
|
+
* @param yearOrIsoString The year for the new Date object, or an ISO-formatted string representing the date and time.
|
|
3485
|
+
* @param month The month for the new Date object (0-11).
|
|
3486
|
+
* @param day The day for the new Date object (1-31).
|
|
3487
|
+
* @param hours The hour for the new Date object (0-23).
|
|
3488
|
+
* @param minutes The minute for the new Date object (0-59).
|
|
3489
|
+
* @param seconds The second for the new Date object (0-59).
|
|
3490
|
+
* @param milliseconds The millisecond for the new Date object (0-999).
|
|
3491
|
+
* @returns A new Date object with the specified date and time, or the current date and time if no arguments are provided.
|
|
3492
|
+
*
|
|
3493
|
+
* @example
|
|
3494
|
+
* createDate(2022, 11, 13);
|
|
3495
|
+
* // => 2022-12-13T00:00:00.000Z
|
|
3496
|
+
*
|
|
3497
|
+
* @example
|
|
3498
|
+
* createDate('2022-12-13T00:00:00.000Z');
|
|
3499
|
+
* // => 2022-12-13T00:00:00.000Z
|
|
3500
|
+
*/
|
|
3501
|
+
|
|
3502
|
+
var createDate = function createDate(yearOrIsoString, month, day) {
|
|
3503
|
+
var hours = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
3504
|
+
var minutes = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
3505
|
+
var seconds = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
|
|
3506
|
+
var milliseconds = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0;
|
|
3507
|
+
|
|
3508
|
+
if (yearOrIsoString === undefined) {
|
|
3509
|
+
return new Date();
|
|
3510
|
+
}
|
|
3511
|
+
|
|
3512
|
+
if (typeof yearOrIsoString === 'string') {
|
|
3513
|
+
return new Date(yearOrIsoString);
|
|
3514
|
+
}
|
|
3515
|
+
|
|
3516
|
+
return new Date(yearOrIsoString, month, day, hours, minutes, seconds, milliseconds);
|
|
3517
|
+
};
|
|
3518
|
+
|
|
3519
|
+
/* *
|
|
3520
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3521
|
+
* you may not use this file except in compliance with the License.
|
|
3522
|
+
* You may obtain a copy of the License at
|
|
3523
|
+
*
|
|
3524
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3525
|
+
*
|
|
3526
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3527
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3528
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3529
|
+
* See the License for the specific language governing permissions and
|
|
3530
|
+
* limitations under the License.
|
|
3531
|
+
*
|
|
3532
|
+
* Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
3533
|
+
* Copyright 2022 - Finnish Meteorological Institute (FMI)
|
|
3534
|
+
* */
|
|
3535
|
+
|
|
3536
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
3537
|
+
__proto__: null,
|
|
3538
|
+
isoStringToDate: isoStringToDate,
|
|
3539
|
+
stringToDate: stringToDate,
|
|
3540
|
+
setUTCDate: setUTCDate,
|
|
3541
|
+
dateToString: dateToString,
|
|
3542
|
+
isBetween: isBetween,
|
|
3543
|
+
createDate: createDate
|
|
3544
|
+
});
|
|
3545
|
+
|
|
3546
|
+
export { AlertBanner, AlertIcon, AppHeader, AppLayout, Avatar, ConfirmationDialog, ConfirmationServiceProvider, CustomAccordion, CustomSlider, CustomToggleButton, CustomTooltip, DEFAULT_ERROR_MESSAGE, DraggableComponent$1 as Draggable, EnableButton, ErrorBoundary, HIDDEN_INPUT_HELPER_IS_DRAFT, IS_JEST, ManagerButton, ManagerDeleteButton, ResizeComponent as Resizable, StatusTag, ToggleMenu, ToolButton, ToolContainer, DraggableComponent as ToolContainerDraggable, ToolFooter, ToolHeader, TooltipSelect, UserMenu, UserMenuItemCheatSheet, MenuItemTheme as UserMenuItemTheme, adjustPosition, calculateDialogSizeAndPosition, index as dateUtils, defaultDelay, getAxiosErrorMessage, getAxiosWarningMessage, getErrorMessage, getInitials, getPosition, getWarningMessage, isAxiosError, showPrompt, sliderHeaderStyle, tooltipContainerStyles, useConfirmationDialog, useControlledTooltip, useDialogActions, useDraftFormHelpers, useIsMounted, useMakeSureContainerStaysInsideWindow, usePoller, usePreventBrowserClose, usePrevious, useUserMenu, withEggs };
|
package/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@mui/material'), require('@opengeoweb/theme'), require('react-hook-form'), require('@opengeoweb/form-fields'), require('lodash'), require('react-draggable'), require('re-resizable'), require('react-redux')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react', '@mui/material', '@opengeoweb/theme', 'react-hook-form', '@opengeoweb/form-fields', 'lodash', 'react-draggable', 're-resizable', 'react-redux'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Shared = {}, global.React, global.material, global.theme, global.reactHookForm, global.formFields, global.lodash, global.Draggable, global.reResizable, global.reactRedux));
|
|
5
|
-
})(this, (function (exports, React, material, theme, reactHookForm, formFields, lodash, Draggable, reResizable, reactRedux) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@mui/material'), require('@opengeoweb/theme'), require('react-hook-form'), require('@opengeoweb/form-fields'), require('lodash'), require('react-draggable'), require('re-resizable'), require('react-redux'), require('date-fns')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react', '@mui/material', '@opengeoweb/theme', 'react-hook-form', '@opengeoweb/form-fields', 'lodash', 'react-draggable', 're-resizable', 'react-redux', 'date-fns'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Shared = {}, global.React, global.material, global.theme, global.reactHookForm, global.formFields, global.lodash, global.Draggable, global.reResizable, global.reactRedux, global.dateFns));
|
|
5
|
+
})(this, (function (exports, React, material, theme, reactHookForm, formFields, lodash, Draggable, reResizable, reactRedux, dateFns) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -450,7 +450,9 @@
|
|
|
450
450
|
register = _a.register;
|
|
451
451
|
|
|
452
452
|
React__namespace.useEffect(function () {
|
|
453
|
-
setValue(HIDDEN_INPUT_HELPER_IS_DRAFT, isDefaultDraft
|
|
453
|
+
setValue(HIDDEN_INPUT_HELPER_IS_DRAFT, isDefaultDraft, {
|
|
454
|
+
shouldDirty: false
|
|
455
|
+
}); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
454
456
|
}, []);
|
|
455
457
|
|
|
456
458
|
var isDraft = function isDraft() {
|
|
@@ -466,7 +468,9 @@
|
|
|
466
468
|
};
|
|
467
469
|
|
|
468
470
|
var toggleIsDraft = function toggleIsDraft(isDraft) {
|
|
469
|
-
return setValue(HIDDEN_INPUT_HELPER_IS_DRAFT, isDraft
|
|
471
|
+
return setValue(HIDDEN_INPUT_HELPER_IS_DRAFT, isDraft, {
|
|
472
|
+
shouldDirty: false
|
|
473
|
+
});
|
|
470
474
|
};
|
|
471
475
|
|
|
472
476
|
var DraftFieldHelper = function DraftFieldHelper() {
|
|
@@ -1776,27 +1780,25 @@
|
|
|
1776
1780
|
leftHeaderComponent = _q === void 0 ? null : _q,
|
|
1777
1781
|
_r = _a.rightHeaderComponent,
|
|
1778
1782
|
rightHeaderComponent = _r === void 0 ? null : _r,
|
|
1779
|
-
_s = _a.hasElevation,
|
|
1780
|
-
hasElevation = _s === void 0 ? true : _s,
|
|
1781
1783
|
className = _a.className,
|
|
1782
|
-
|
|
1783
|
-
sx =
|
|
1784
|
-
props = __rest(_a, ["title", "bounds", "headerSize", "startSize", "startPosition", "children", "isOpen", "onClose", "initialMaxHeight", "onChangeSize", "onMouseDown", "onResizeStop", "onDragEnd", "order", "source", "leftHeaderComponent", "rightHeaderComponent", "
|
|
1784
|
+
_s = _a.sx,
|
|
1785
|
+
sx = _s === void 0 ? {} : _s,
|
|
1786
|
+
props = __rest(_a, ["title", "bounds", "headerSize", "startSize", "startPosition", "children", "isOpen", "onClose", "initialMaxHeight", "onChangeSize", "onMouseDown", "onResizeStop", "onDragEnd", "order", "source", "leftHeaderComponent", "rightHeaderComponent", "className", "sx"]);
|
|
1785
1787
|
|
|
1786
1788
|
var zIndex = (source === 'app' ? BASE_Z_INDEX : 1000) + order;
|
|
1787
|
-
var elevation =
|
|
1789
|
+
var elevation = BASE_ELEVATION + order;
|
|
1788
1790
|
var nodeRef = React__default["default"].useRef(null);
|
|
1789
1791
|
|
|
1790
|
-
var
|
|
1792
|
+
var _t = __read(React__default["default"].useState({
|
|
1791
1793
|
x: 0,
|
|
1792
1794
|
y: 0
|
|
1793
1795
|
}), 2),
|
|
1794
|
-
position =
|
|
1795
|
-
setPosition =
|
|
1796
|
+
position = _t[0],
|
|
1797
|
+
setPosition = _t[1];
|
|
1796
1798
|
|
|
1797
|
-
var
|
|
1798
|
-
size =
|
|
1799
|
-
setSize =
|
|
1799
|
+
var _u = __read(React__default["default"].useState(startSize), 2),
|
|
1800
|
+
size = _u[0],
|
|
1801
|
+
setSize = _u[1];
|
|
1800
1802
|
|
|
1801
1803
|
var isRightAligned = startPosition && startPosition.right !== null && startPosition.right !== undefined;
|
|
1802
1804
|
var onStopDrag = React__default["default"].useCallback(function (_event, position) {
|
|
@@ -1804,13 +1806,13 @@
|
|
|
1804
1806
|
onDragEnd(position, size);
|
|
1805
1807
|
}, [setPosition, onDragEnd, size]);
|
|
1806
1808
|
|
|
1807
|
-
var
|
|
1808
|
-
initialMaxHeight =
|
|
1809
|
-
setInitialMaxHeight =
|
|
1809
|
+
var _v = __read(React__default["default"].useState(defaultInitialMaxHeight), 2),
|
|
1810
|
+
initialMaxHeight = _v[0],
|
|
1811
|
+
setInitialMaxHeight = _v[1];
|
|
1810
1812
|
|
|
1811
|
-
var
|
|
1812
|
-
initialDragPositionX =
|
|
1813
|
-
setInitialDragPositionX =
|
|
1813
|
+
var _w = __read(React__default["default"].useState(0), 2),
|
|
1814
|
+
initialDragPositionX = _w[0],
|
|
1815
|
+
setInitialDragPositionX = _w[1];
|
|
1814
1816
|
|
|
1815
1817
|
var onStartResize = function onStartResize() {
|
|
1816
1818
|
setInitialMaxHeight('initial');
|
|
@@ -2940,8 +2942,13 @@
|
|
|
2940
2942
|
if (requiresCtrlToChange && (event.ctrlKey || event.metaKey) || !requiresCtrlToChange) {
|
|
2941
2943
|
if (selectOpen) return;
|
|
2942
2944
|
var direction = event.deltaY < 0 ? 1 : -1;
|
|
2943
|
-
var
|
|
2944
|
-
|
|
2945
|
+
var newIndex = currentIndex - direction;
|
|
2946
|
+
|
|
2947
|
+
if (newIndex < 0 || newIndex >= list.length) {
|
|
2948
|
+
return;
|
|
2949
|
+
}
|
|
2950
|
+
|
|
2951
|
+
onChangeMouseWheel(list[newIndex]);
|
|
2945
2952
|
}
|
|
2946
2953
|
}, [selectOpen, currentIndex, list, onChangeMouseWheel, requiresCtrlToChange]);
|
|
2947
2954
|
var onOpen = React__namespace.useCallback(function () {
|
|
@@ -3162,6 +3169,271 @@
|
|
|
3162
3169
|
// temporary check until we get the unit test passing with container queries
|
|
3163
3170
|
var IS_JEST = typeof jest !== 'undefined';
|
|
3164
3171
|
|
|
3172
|
+
/* *
|
|
3173
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3174
|
+
* you may not use this file except in compliance with the License.
|
|
3175
|
+
* You may obtain a copy of the License at
|
|
3176
|
+
*
|
|
3177
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3178
|
+
*
|
|
3179
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3180
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3181
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3182
|
+
* See the License for the specific language governing permissions and
|
|
3183
|
+
* limitations under the License.
|
|
3184
|
+
*
|
|
3185
|
+
* Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
3186
|
+
* Copyright 2022 - Finnish Meteorological Institute (FMI)
|
|
3187
|
+
* */
|
|
3188
|
+
/**
|
|
3189
|
+
* Parsing date strings with geoweb dateUtils:
|
|
3190
|
+
*
|
|
3191
|
+
* An ISO String *with timezone* can safely be parsed directly to a date:
|
|
3192
|
+
*
|
|
3193
|
+
* date = new Date('2022-10-10T15:30:00Z')
|
|
3194
|
+
* date = new Date('2022-10-10T15:30:00+00:00')
|
|
3195
|
+
* date = new Date('2022-10-10T15:30:00+02:00')
|
|
3196
|
+
*
|
|
3197
|
+
* or using the dateUtils isoStringToDate function *with utc=false*
|
|
3198
|
+
*
|
|
3199
|
+
* date = isoStringToDate('2022-10-10T15:30:00Z', false)
|
|
3200
|
+
*
|
|
3201
|
+
* An ISO String *without a timezone* can be parsed with isoStringToDate
|
|
3202
|
+
*
|
|
3203
|
+
* date = isoStringToDate('2022-10-10T15:30:00')
|
|
3204
|
+
*
|
|
3205
|
+
* *Do not parse ISO without timezone using `new Date()` unless you correct for the local timezone*
|
|
3206
|
+
*
|
|
3207
|
+
* To parse an arbitrary date string with timezone use:
|
|
3208
|
+
*
|
|
3209
|
+
* date = stringToDate('2022.11.10, 11:15 +01:00', 'yyyy.MM.dd, HH:mm xxx', false)
|
|
3210
|
+
*
|
|
3211
|
+
* To parse an arbitrary date string without timezone use:
|
|
3212
|
+
*
|
|
3213
|
+
* date = stringToDate('2022.11.10, 11:15', 'yyyy.MM.dd, HH:mm')
|
|
3214
|
+
*
|
|
3215
|
+
*
|
|
3216
|
+
* To safely convert dates to utc strings use:
|
|
3217
|
+
*
|
|
3218
|
+
* date.toISOString()
|
|
3219
|
+
*
|
|
3220
|
+
* To get parts of UTC time use
|
|
3221
|
+
*
|
|
3222
|
+
* date.getUTCHours()
|
|
3223
|
+
* date.getUTCMins()
|
|
3224
|
+
*
|
|
3225
|
+
* To parse an arbitrary date string to a UTC string use:
|
|
3226
|
+
*
|
|
3227
|
+
* dateToString(new Date('2022-10-10T15:30:00Z', 'HH:ss dd MMM yyyy')
|
|
3228
|
+
*
|
|
3229
|
+
*/
|
|
3230
|
+
|
|
3231
|
+
/**
|
|
3232
|
+
* Parse an ISO string to a date
|
|
3233
|
+
*
|
|
3234
|
+
* Expects the following props:
|
|
3235
|
+
* @param {string} input - string containing date
|
|
3236
|
+
*
|
|
3237
|
+
* @returns {Date} Date
|
|
3238
|
+
* @example
|
|
3239
|
+
* ``` isoStringToDate("2022-5-10T20:32:00+00:00")) ```
|
|
3240
|
+
*/
|
|
3241
|
+
|
|
3242
|
+
var isoStringToDate = function isoStringToDate(input, utc) {
|
|
3243
|
+
if (utc === void 0) {
|
|
3244
|
+
utc = true;
|
|
3245
|
+
}
|
|
3246
|
+
|
|
3247
|
+
var parsed = dateFns.parseISO(input);
|
|
3248
|
+
|
|
3249
|
+
if (utc) {
|
|
3250
|
+
return setUTCDate(parsed);
|
|
3251
|
+
}
|
|
3252
|
+
|
|
3253
|
+
return parsed;
|
|
3254
|
+
};
|
|
3255
|
+
/**
|
|
3256
|
+
* Parse a string to a date
|
|
3257
|
+
*
|
|
3258
|
+
* ***NOTE: String will be parsed in local time if utc is set to false***
|
|
3259
|
+
*
|
|
3260
|
+
* Expects the following props:
|
|
3261
|
+
* @param {string} input - string containing date
|
|
3262
|
+
* @param {string} strFormat - format of the string, see: https://date-fns.org/v2.29.3/docs/parse
|
|
3263
|
+
* @param {boolean} utc [ default = true ] - boolean indicating whether to parse as UTC
|
|
3264
|
+
* @param {Date} referenceDate [ default = new Date() ] - defines values missing from the parsed dateString
|
|
3265
|
+
*
|
|
3266
|
+
* @returns {Date} Date
|
|
3267
|
+
* @example
|
|
3268
|
+
* ``` stringToDate("2022 5 10 20:32", 'yyyy M d HH:mm')) ```
|
|
3269
|
+
*/
|
|
3270
|
+
|
|
3271
|
+
var stringToDate = function stringToDate(input, strFormat, utc, referenceDate) {
|
|
3272
|
+
if (utc === void 0) {
|
|
3273
|
+
utc = true;
|
|
3274
|
+
}
|
|
3275
|
+
|
|
3276
|
+
if (referenceDate === void 0) {
|
|
3277
|
+
referenceDate = new Date();
|
|
3278
|
+
}
|
|
3279
|
+
|
|
3280
|
+
var parsed = dateFns.parse(input, strFormat, referenceDate);
|
|
3281
|
+
|
|
3282
|
+
if (utc) {
|
|
3283
|
+
return setUTCDate(parsed);
|
|
3284
|
+
}
|
|
3285
|
+
|
|
3286
|
+
return parsed;
|
|
3287
|
+
};
|
|
3288
|
+
/**
|
|
3289
|
+
* Use this if you initialise a date without a timezone to set it to utc correctly
|
|
3290
|
+
* eg.
|
|
3291
|
+
* new Date(2022, 10, 12, 15, 30)
|
|
3292
|
+
* should be:
|
|
3293
|
+
* setUTCDate(new Date(2022, 10, 12, 15, 30))
|
|
3294
|
+
*
|
|
3295
|
+
* Expects the following props:
|
|
3296
|
+
* @param {Date} inDate - date to be set to UTC
|
|
3297
|
+
*
|
|
3298
|
+
* @returns {Date} - Date in UTC
|
|
3299
|
+
* @example
|
|
3300
|
+
* ``` setUTCDate(new Date(2022, 10, 12, 15, 30)) ```
|
|
3301
|
+
*/
|
|
3302
|
+
|
|
3303
|
+
var setUTCDate = function setUTCDate(inDate) {
|
|
3304
|
+
var utcDate = new Date(inDate);
|
|
3305
|
+
utcDate.setUTCFullYear(inDate.getFullYear(), inDate.getMonth(), inDate.getDate());
|
|
3306
|
+
utcDate.setUTCHours(inDate.getHours(), inDate.getMinutes(), inDate.getSeconds(), inDate.getMilliseconds());
|
|
3307
|
+
return utcDate;
|
|
3308
|
+
};
|
|
3309
|
+
/**
|
|
3310
|
+
* Format a date to a string
|
|
3311
|
+
*
|
|
3312
|
+
* Expects the following props:
|
|
3313
|
+
* @param {Date} inDate - date to be formatted
|
|
3314
|
+
* @param {string} strFormat - format of string
|
|
3315
|
+
* @param {boolean} utc - [default: true] true to return in utc otherwise return in local timezone
|
|
3316
|
+
*
|
|
3317
|
+
* @returns {string} - formatted date string
|
|
3318
|
+
* @example
|
|
3319
|
+
* ``` dateToString(new Date(2022, 10, 12, 15, 30), 'dd MMM yyyy') ```
|
|
3320
|
+
*/
|
|
3321
|
+
|
|
3322
|
+
var dateToString = function dateToString(inDate, strFormat, utc) {
|
|
3323
|
+
if (utc === void 0) {
|
|
3324
|
+
utc = true;
|
|
3325
|
+
}
|
|
3326
|
+
|
|
3327
|
+
if (utc) {
|
|
3328
|
+
return dateFns.format(new Date(inDate.getUTCFullYear(), inDate.getUTCMonth(), inDate.getUTCDate(), inDate.getUTCHours(), inDate.getUTCMinutes(), inDate.getUTCSeconds()), strFormat);
|
|
3329
|
+
}
|
|
3330
|
+
|
|
3331
|
+
return dateFns.format(inDate, strFormat);
|
|
3332
|
+
};
|
|
3333
|
+
/**
|
|
3334
|
+
* Find out if a date is between two other dates.
|
|
3335
|
+
*
|
|
3336
|
+
* Inclusivity parameter matches that used in momentjs where '[' indicates inclusion and '(' indicates exclusion.
|
|
3337
|
+
*
|
|
3338
|
+
* Expects the following props:
|
|
3339
|
+
* @param {Date} date - date to be tested
|
|
3340
|
+
* @param {Date} from - first date
|
|
3341
|
+
* @param {Date} to - last date
|
|
3342
|
+
* @param {string} inclusivity - [default: '()'] Must be one of : '()', '[]', '(]', '[)'
|
|
3343
|
+
*
|
|
3344
|
+
* @returns {boolen} - true if date is between, otherwise false
|
|
3345
|
+
*
|
|
3346
|
+
*/
|
|
3347
|
+
|
|
3348
|
+
var isBetween = function isBetween(date, from, to, inclusivity) {
|
|
3349
|
+
if (inclusivity === void 0) {
|
|
3350
|
+
inclusivity = '()';
|
|
3351
|
+
}
|
|
3352
|
+
|
|
3353
|
+
if (!['()', '[]', '(]', '[)'].includes(inclusivity)) {
|
|
3354
|
+
throw new Error('Inclusivity parameter must be one of (), [], (], [)');
|
|
3355
|
+
}
|
|
3356
|
+
|
|
3357
|
+
var isBeforeEqual = inclusivity[0] === '[';
|
|
3358
|
+
var isAfterEqual = inclusivity[1] === ']';
|
|
3359
|
+
return (isBeforeEqual ? dateFns.isEqual(from, date) || dateFns.isBefore(from, date) : dateFns.isBefore(from, date)) && (isAfterEqual ? dateFns.isEqual(to, date) || dateFns.isAfter(to, date) : dateFns.isAfter(to, date));
|
|
3360
|
+
};
|
|
3361
|
+
/**
|
|
3362
|
+
* Creates a new Date object with the specified date and time, or the current date and time if no arguments are provided.
|
|
3363
|
+
*
|
|
3364
|
+
* @param yearOrIsoString The year for the new Date object, or an ISO-formatted string representing the date and time.
|
|
3365
|
+
* @param month The month for the new Date object (0-11).
|
|
3366
|
+
* @param day The day for the new Date object (1-31).
|
|
3367
|
+
* @param hours The hour for the new Date object (0-23).
|
|
3368
|
+
* @param minutes The minute for the new Date object (0-59).
|
|
3369
|
+
* @param seconds The second for the new Date object (0-59).
|
|
3370
|
+
* @param milliseconds The millisecond for the new Date object (0-999).
|
|
3371
|
+
* @returns A new Date object with the specified date and time, or the current date and time if no arguments are provided.
|
|
3372
|
+
*
|
|
3373
|
+
* @example
|
|
3374
|
+
* createDate(2022, 11, 13);
|
|
3375
|
+
* // => 2022-12-13T00:00:00.000Z
|
|
3376
|
+
*
|
|
3377
|
+
* @example
|
|
3378
|
+
* createDate('2022-12-13T00:00:00.000Z');
|
|
3379
|
+
* // => 2022-12-13T00:00:00.000Z
|
|
3380
|
+
*/
|
|
3381
|
+
|
|
3382
|
+
var createDate = function createDate(yearOrIsoString, month, day, hours, minutes, seconds, milliseconds) {
|
|
3383
|
+
if (hours === void 0) {
|
|
3384
|
+
hours = 0;
|
|
3385
|
+
}
|
|
3386
|
+
|
|
3387
|
+
if (minutes === void 0) {
|
|
3388
|
+
minutes = 0;
|
|
3389
|
+
}
|
|
3390
|
+
|
|
3391
|
+
if (seconds === void 0) {
|
|
3392
|
+
seconds = 0;
|
|
3393
|
+
}
|
|
3394
|
+
|
|
3395
|
+
if (milliseconds === void 0) {
|
|
3396
|
+
milliseconds = 0;
|
|
3397
|
+
}
|
|
3398
|
+
|
|
3399
|
+
if (yearOrIsoString === undefined) {
|
|
3400
|
+
return new Date();
|
|
3401
|
+
}
|
|
3402
|
+
|
|
3403
|
+
if (typeof yearOrIsoString === 'string') {
|
|
3404
|
+
return new Date(yearOrIsoString);
|
|
3405
|
+
}
|
|
3406
|
+
|
|
3407
|
+
return new Date(yearOrIsoString, month, day, hours, minutes, seconds, milliseconds);
|
|
3408
|
+
};
|
|
3409
|
+
|
|
3410
|
+
/* *
|
|
3411
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3412
|
+
* you may not use this file except in compliance with the License.
|
|
3413
|
+
* You may obtain a copy of the License at
|
|
3414
|
+
*
|
|
3415
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3416
|
+
*
|
|
3417
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3418
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3419
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3420
|
+
* See the License for the specific language governing permissions and
|
|
3421
|
+
* limitations under the License.
|
|
3422
|
+
*
|
|
3423
|
+
* Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
3424
|
+
* Copyright 2022 - Finnish Meteorological Institute (FMI)
|
|
3425
|
+
* */
|
|
3426
|
+
|
|
3427
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
3428
|
+
__proto__: null,
|
|
3429
|
+
isoStringToDate: isoStringToDate,
|
|
3430
|
+
stringToDate: stringToDate,
|
|
3431
|
+
setUTCDate: setUTCDate,
|
|
3432
|
+
dateToString: dateToString,
|
|
3433
|
+
isBetween: isBetween,
|
|
3434
|
+
createDate: createDate
|
|
3435
|
+
});
|
|
3436
|
+
|
|
3165
3437
|
exports.AlertBanner = AlertBanner;
|
|
3166
3438
|
exports.AlertIcon = AlertIcon;
|
|
3167
3439
|
exports.AppHeader = AppHeader;
|
|
@@ -3195,6 +3467,7 @@
|
|
|
3195
3467
|
exports.UserMenuItemTheme = MenuItemTheme;
|
|
3196
3468
|
exports.adjustPosition = adjustPosition;
|
|
3197
3469
|
exports.calculateDialogSizeAndPosition = calculateDialogSizeAndPosition;
|
|
3470
|
+
exports.dateUtils = index;
|
|
3198
3471
|
exports.defaultDelay = defaultDelay;
|
|
3199
3472
|
exports.getAxiosErrorMessage = getAxiosErrorMessage;
|
|
3200
3473
|
exports.getAxiosWarningMessage = getAxiosWarningMessage;
|
|
@@ -25,7 +25,6 @@ interface DraggableComponentProps extends Omit<ResizableComponentProps, 'bounds'
|
|
|
25
25
|
source?: 'app' | 'module';
|
|
26
26
|
leftHeaderComponent?: React.ReactNode;
|
|
27
27
|
rightHeaderComponent?: React.ReactNode;
|
|
28
|
-
hasElevation?: boolean;
|
|
29
28
|
sx?: SxProps;
|
|
30
29
|
}
|
|
31
30
|
declare const DraggableComponent: React.FC<DraggableComponentProps>;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parsing date strings with geoweb dateUtils:
|
|
3
|
+
*
|
|
4
|
+
* An ISO String *with timezone* can safely be parsed directly to a date:
|
|
5
|
+
*
|
|
6
|
+
* date = new Date('2022-10-10T15:30:00Z')
|
|
7
|
+
* date = new Date('2022-10-10T15:30:00+00:00')
|
|
8
|
+
* date = new Date('2022-10-10T15:30:00+02:00')
|
|
9
|
+
*
|
|
10
|
+
* or using the dateUtils isoStringToDate function *with utc=false*
|
|
11
|
+
*
|
|
12
|
+
* date = isoStringToDate('2022-10-10T15:30:00Z', false)
|
|
13
|
+
*
|
|
14
|
+
* An ISO String *without a timezone* can be parsed with isoStringToDate
|
|
15
|
+
*
|
|
16
|
+
* date = isoStringToDate('2022-10-10T15:30:00')
|
|
17
|
+
*
|
|
18
|
+
* *Do not parse ISO without timezone using `new Date()` unless you correct for the local timezone*
|
|
19
|
+
*
|
|
20
|
+
* To parse an arbitrary date string with timezone use:
|
|
21
|
+
*
|
|
22
|
+
* date = stringToDate('2022.11.10, 11:15 +01:00', 'yyyy.MM.dd, HH:mm xxx', false)
|
|
23
|
+
*
|
|
24
|
+
* To parse an arbitrary date string without timezone use:
|
|
25
|
+
*
|
|
26
|
+
* date = stringToDate('2022.11.10, 11:15', 'yyyy.MM.dd, HH:mm')
|
|
27
|
+
*
|
|
28
|
+
*
|
|
29
|
+
* To safely convert dates to utc strings use:
|
|
30
|
+
*
|
|
31
|
+
* date.toISOString()
|
|
32
|
+
*
|
|
33
|
+
* To get parts of UTC time use
|
|
34
|
+
*
|
|
35
|
+
* date.getUTCHours()
|
|
36
|
+
* date.getUTCMins()
|
|
37
|
+
*
|
|
38
|
+
* To parse an arbitrary date string to a UTC string use:
|
|
39
|
+
*
|
|
40
|
+
* dateToString(new Date('2022-10-10T15:30:00Z', 'HH:ss dd MMM yyyy')
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
43
|
+
/**
|
|
44
|
+
* Parse an ISO string to a date
|
|
45
|
+
*
|
|
46
|
+
* Expects the following props:
|
|
47
|
+
* @param {string} input - string containing date
|
|
48
|
+
*
|
|
49
|
+
* @returns {Date} Date
|
|
50
|
+
* @example
|
|
51
|
+
* ``` isoStringToDate("2022-5-10T20:32:00+00:00")) ```
|
|
52
|
+
*/
|
|
53
|
+
export declare const isoStringToDate: (input: string, utc?: boolean) => Date;
|
|
54
|
+
/**
|
|
55
|
+
* Parse a string to a date
|
|
56
|
+
*
|
|
57
|
+
* ***NOTE: String will be parsed in local time if utc is set to false***
|
|
58
|
+
*
|
|
59
|
+
* Expects the following props:
|
|
60
|
+
* @param {string} input - string containing date
|
|
61
|
+
* @param {string} strFormat - format of the string, see: https://date-fns.org/v2.29.3/docs/parse
|
|
62
|
+
* @param {boolean} utc [ default = true ] - boolean indicating whether to parse as UTC
|
|
63
|
+
* @param {Date} referenceDate [ default = new Date() ] - defines values missing from the parsed dateString
|
|
64
|
+
*
|
|
65
|
+
* @returns {Date} Date
|
|
66
|
+
* @example
|
|
67
|
+
* ``` stringToDate("2022 5 10 20:32", 'yyyy M d HH:mm')) ```
|
|
68
|
+
*/
|
|
69
|
+
export declare const stringToDate: (input: string, strFormat: string, utc?: boolean, referenceDate?: Date | number) => Date;
|
|
70
|
+
/**
|
|
71
|
+
* Use this if you initialise a date without a timezone to set it to utc correctly
|
|
72
|
+
* eg.
|
|
73
|
+
* new Date(2022, 10, 12, 15, 30)
|
|
74
|
+
* should be:
|
|
75
|
+
* setUTCDate(new Date(2022, 10, 12, 15, 30))
|
|
76
|
+
*
|
|
77
|
+
* Expects the following props:
|
|
78
|
+
* @param {Date} inDate - date to be set to UTC
|
|
79
|
+
*
|
|
80
|
+
* @returns {Date} - Date in UTC
|
|
81
|
+
* @example
|
|
82
|
+
* ``` setUTCDate(new Date(2022, 10, 12, 15, 30)) ```
|
|
83
|
+
*/
|
|
84
|
+
export declare const setUTCDate: (inDate: Date) => Date;
|
|
85
|
+
/**
|
|
86
|
+
* Format a date to a string
|
|
87
|
+
*
|
|
88
|
+
* Expects the following props:
|
|
89
|
+
* @param {Date} inDate - date to be formatted
|
|
90
|
+
* @param {string} strFormat - format of string
|
|
91
|
+
* @param {boolean} utc - [default: true] true to return in utc otherwise return in local timezone
|
|
92
|
+
*
|
|
93
|
+
* @returns {string} - formatted date string
|
|
94
|
+
* @example
|
|
95
|
+
* ``` dateToString(new Date(2022, 10, 12, 15, 30), 'dd MMM yyyy') ```
|
|
96
|
+
*/
|
|
97
|
+
export declare const dateToString: (inDate: Date, strFormat: string, utc?: boolean) => string;
|
|
98
|
+
/**
|
|
99
|
+
* Find out if a date is between two other dates.
|
|
100
|
+
*
|
|
101
|
+
* Inclusivity parameter matches that used in momentjs where '[' indicates inclusion and '(' indicates exclusion.
|
|
102
|
+
*
|
|
103
|
+
* Expects the following props:
|
|
104
|
+
* @param {Date} date - date to be tested
|
|
105
|
+
* @param {Date} from - first date
|
|
106
|
+
* @param {Date} to - last date
|
|
107
|
+
* @param {string} inclusivity - [default: '()'] Must be one of : '()', '[]', '(]', '[)'
|
|
108
|
+
*
|
|
109
|
+
* @returns {boolen} - true if date is between, otherwise false
|
|
110
|
+
*
|
|
111
|
+
*/
|
|
112
|
+
export declare const isBetween: (date: Date, from: Date, to: Date, inclusivity?: string) => boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Creates a new Date object with the specified date and time, or the current date and time if no arguments are provided.
|
|
115
|
+
*
|
|
116
|
+
* @param yearOrIsoString The year for the new Date object, or an ISO-formatted string representing the date and time.
|
|
117
|
+
* @param month The month for the new Date object (0-11).
|
|
118
|
+
* @param day The day for the new Date object (1-31).
|
|
119
|
+
* @param hours The hour for the new Date object (0-23).
|
|
120
|
+
* @param minutes The minute for the new Date object (0-59).
|
|
121
|
+
* @param seconds The second for the new Date object (0-59).
|
|
122
|
+
* @param milliseconds The millisecond for the new Date object (0-999).
|
|
123
|
+
* @returns A new Date object with the specified date and time, or the current date and time if no arguments are provided.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* createDate(2022, 11, 13);
|
|
127
|
+
* // => 2022-12-13T00:00:00.000Z
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* createDate('2022-12-13T00:00:00.000Z');
|
|
131
|
+
* // => 2022-12-13T00:00:00.000Z
|
|
132
|
+
*/
|
|
133
|
+
export declare const createDate: (yearOrIsoString?: string | number | undefined, month?: number | undefined, day?: number | undefined, hours?: number, minutes?: number, seconds?: number, milliseconds?: number) => Date;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dateUtils';
|
package/lib/utils/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeoweb/shared",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"description": "GeoWeb shared library with shared components and utils for the opengeoweb project",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -14,17 +14,18 @@
|
|
|
14
14
|
"peerDependencies": {
|
|
15
15
|
"react": "^17.0.2",
|
|
16
16
|
"@mui/material": "^5.10.8",
|
|
17
|
-
"@opengeoweb/theme": "4.
|
|
17
|
+
"@opengeoweb/theme": "4.7.0",
|
|
18
18
|
"react-draggable": "^4.4.5",
|
|
19
19
|
"re-resizable": "^6.9.0",
|
|
20
20
|
"@redux-eggs/core": "^2.2.0",
|
|
21
21
|
"react-redux": "^8.0.4",
|
|
22
|
-
"@opengeoweb/form-fields": "4.
|
|
22
|
+
"@opengeoweb/form-fields": "4.7.0",
|
|
23
23
|
"react-hook-form": "^6.12.1",
|
|
24
24
|
"moment": "^2.29.0",
|
|
25
25
|
"moment-timezone": "^0.5.31",
|
|
26
26
|
"@mui/x-date-pickers": "^5.0.4",
|
|
27
27
|
"lodash": "^4.17.20",
|
|
28
|
-
"axios": "^0.25.0"
|
|
28
|
+
"axios": "^0.25.0",
|
|
29
|
+
"date-fns": "^2.29.3"
|
|
29
30
|
}
|
|
30
31
|
}
|