@opengeoweb/shared 9.13.0 → 9.15.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/shared",
3
- "version": "9.13.0",
3
+ "version": "9.15.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": {
@@ -18,7 +18,8 @@
18
18
  "axios": "1.5.0",
19
19
  "date-fns": "^3.3.0",
20
20
  "redux-mock-store": "^1.5.4",
21
- "@reduxjs/toolkit": "^1.9.7"
21
+ "@reduxjs/toolkit": "^1.9.7",
22
+ "i18next": "^23.7.19"
22
23
  },
23
24
  "peerDependencies": {
24
25
  "react": "18"
@@ -1,4 +1,8 @@
1
1
  import { SwitchProps } from '@mui/material';
2
2
  import * as React from 'react';
3
- declare const SwitchButton: React.FC<SwitchProps>;
3
+ declare const SwitchButton: React.FC<SwitchProps & {
4
+ activeLabel?: string;
5
+ inActiveLabel?: string;
6
+ tooltip?: string;
7
+ }>;
4
8
  export default SwitchButton;
@@ -1,19 +1,21 @@
1
1
  import * as React from 'react';
2
2
  import { BaseSelectProps, SelectVariants } from '@mui/material';
3
- import { SxProps } from '@mui/material/styles';
4
- interface ListELement {
3
+ import { SxProps, Theme } from '@mui/material/styles';
4
+ interface ListElement {
5
5
  value: string;
6
6
  }
7
7
  type TooltipSelectProps = Omit<BaseSelectProps, 'sx'> & {
8
8
  tooltip: string;
9
- list?: ListELement[];
9
+ list?: ListElement[];
10
10
  currentIndex?: number;
11
- onChangeMouseWheel?: (element: ListELement) => void;
11
+ onChangeMouseWheel?: (element: ListElement) => void;
12
12
  requiresCtrlToChange?: boolean;
13
13
  isEnabled?: boolean;
14
14
  hasBackgroundColor?: boolean;
15
15
  variant?: SelectVariants;
16
16
  additionalStyling?: SxProps;
17
+ skipLocalStyling?: boolean;
17
18
  };
18
19
  export declare const TooltipSelect: React.FC<TooltipSelectProps>;
20
+ export declare const tooltipContainerStyles: (theme: Theme, isEnabled: boolean, hasBackgroundColor?: boolean) => object;
19
21
  export {};
@@ -3,3 +3,4 @@ export * from './usePoller/usePoller';
3
3
  export * from './usePrevious/usePrevious';
4
4
  export * from './useIsMounted/useIsMounted';
5
5
  export * from './useMakeSureContainerStaysInsideWindow/useMakeSureContainerStaysInsideWindow';
6
+ export * from './useDebounce/useDebounce';
@@ -0,0 +1 @@
1
+ export declare const useDebounce: (value: string, timeout: number) => string;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import { parseISO, isEqual, Duration, startOfDay, isWithinInterval } from 'date-fns';
1
+ import { parseISO, isEqual, Duration, startOfDay, isWithinInterval, getDay, getMonth, getYear, getWeek } from 'date-fns';
2
2
  export interface DateValues {
3
3
  year?: number;
4
4
  month?: number;
@@ -268,16 +268,54 @@ export declare const getNowUtc: () => Date;
268
268
  export declare const getCurrentTimeAsString: (strFormat?: string, utc?: boolean) => string;
269
269
  /**
270
270
  * Set date values to a given date (by default it is assumed you are passing the new values in UTC).
271
+ * Note that months start at 0!
271
272
  * @param date - the dater to be changed
272
273
  * @param values - an object with options
273
274
  * @param useLocalTimeZone - boolean true if you are passing the values in local timezone
274
275
  * @returns the new date with options set
275
276
  */
276
277
  export declare const set: (date: Date, values: DateValues, useLocalTimeZone?: boolean) => Date;
278
+ /**
279
+ * Get hours of a passed date in UTC (or local timezone if passed false)
280
+ * @param date - the date of which to extract hours
281
+ * @param utc - boolean true - whether to get UTC hours
282
+ * @returns the hour number
283
+ */
284
+ export declare const getHours: (date: Date, utc?: boolean) => number;
285
+ /**
286
+ * Return the start of hour for the given date. The result will be in UTC.
287
+ * @param date - the date of which to retrieve the start of the hour
288
+ * @returns the new date
289
+ */
290
+ export declare const startOfHourUTC: (date: Date) => Date;
291
+ /**
292
+ * Return the start of a day for the given date. The result will be in UTC.
293
+ * @param date - the date of which to retrieve the start of day
294
+ * @returns the new date
295
+ */
296
+ export declare const startOfDayUTC: (date: Date) => Date;
297
+ /**
298
+ * Return the start of a week for the given date. The result will be in UTC.
299
+ * @param date - the date of which to retrieve the start of the week
300
+ * @returns the new date
301
+ */
302
+ export declare const startOfWeekUTC: (date: Date) => Date;
303
+ /**
304
+ * Return the start of a month for the given date. The result will be in UTC.
305
+ * @param date - the date of which to retrieve the start of the month
306
+ * @returns the new date
307
+ */
308
+ export declare const startOfMonthUTC: (date: Date) => Date;
309
+ /**
310
+ * Return the start of a year for the given date. The result will be in UTC.
311
+ * @param date - the date of which to retrieve the start of the year
312
+ * @returns the new date
313
+ */
314
+ export declare const startOfYearUTC: (date: Date) => Date;
277
315
  /**
278
316
  * Compares two dates if values are the same
279
317
  * @param {Date} date - first date
280
318
  * @param {Date} date - second date
281
319
  * @returns {boolean} - True if dates are equal
282
320
  */
283
- export { isEqual, startOfDay, parseISO, isWithinInterval };
321
+ export { isEqual, startOfDay, parseISO, isWithinInterval, getDay, getMonth, getYear, getWeek, };
@@ -1,4 +1,5 @@
1
1
  export * from './axiosErrorUtils';
2
2
  export * as dateUtils from './dateUtils';
3
3
  export * from './reduxTestUtils';
4
+ export * from './translationUtils';
4
5
  export { renderCounter } from './renderCounter';
@@ -0,0 +1 @@
1
+ export * from './translationUtils';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Update i18next translations on the fly when used outside React components
3
+ * NOTE: If possible pass the `t` function instead of using this
4
+ * Because this doesnt trigger a rerender when using a language select
5
+ * This only works for simple values, no interpolation
6
+ */
7
+ export declare const handleOutsideComponentTranslations: <T extends Record<string, string>>(translationList: Record<string, T>, namespace: string, defaultLanguage?: string) => T;