colibri-ui 0.8.83 → 0.8.86
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/Accordion/Accordion.module.css +4 -0
- package/Accordion/index.js +15 -23
- package/Autocomplete/Autocomplete.js +101 -132
- package/Avatar/Avatar.module.css +6 -0
- package/Avatar/index.js +102 -89
- package/Badge/Badge.module.css +2 -1
- package/Badge/Control/index.js +5 -3
- package/Badge/index.js +16 -16
- package/Button/index.js +23 -20
- package/Button/tokens.js +2 -2
- package/Calendar/Calendar.js +171 -269
- package/Card/Card.js +26 -32
- package/Checkbox/index.js +46 -43
- package/Chip/Chip.module.css +2 -1
- package/Chip/index.js +15 -15
- package/ClickOutside/index.js +10 -13
- package/CodeField/CodeField.js +113 -170
- package/Counter/Counter.module.css +2 -1
- package/Counter/index.js +21 -20
- package/Datepicker/components/DatePicker/index.js +81 -102
- package/Datepicker/index.js +17 -16
- package/DotsLoader/index.js +23 -15
- package/Drawer/Drawer.js +75 -97
- package/Drawer/Drawer.module.css +2 -1
- package/Dropdown/index.js +55 -68
- package/Dropzone/Dropzone.js +78 -168
- package/Dropzone/Dropzone.module.css +2 -1
- package/Editable/Editable.js +44 -57
- package/Grid/Item/index.js +11 -13
- package/Grid/index.js +15 -21
- package/Icons/ArrowNext.js +7 -8
- package/Icons/Cart.js +7 -8
- package/Icons/Check.js +7 -8
- package/Icons/Chevron.js +7 -8
- package/Icons/Close.js +6 -6
- package/Icons/Copy.js +7 -8
- package/Icons/Cross.js +6 -6
- package/Icons/CrossFill.js +7 -8
- package/Icons/Edit.js +7 -8
- package/Icons/Exit.js +7 -8
- package/Icons/EyeClosed.js +7 -8
- package/Icons/EyeOpen.js +7 -8
- package/Icons/Help.js +6 -6
- package/Icons/Info.js +7 -8
- package/Icons/Minus.js +7 -8
- package/Icons/More.js +7 -8
- package/Icons/Plus.js +7 -8
- package/Icons/Setting.js +7 -8
- package/Icons/Shield.js +7 -8
- package/Icons/Trash.js +7 -8
- package/Icons/User.js +7 -8
- package/Image/Image.module.css +4 -0
- package/Image/index.d.ts +1 -1
- package/Image/index.js +44 -37
- package/Input/index.d.ts +1 -1
- package/Input/index.js +38 -25
- package/Input/index.props.d.ts +1 -1
- package/InputRadio/index.js +32 -24
- package/List/List.js +81 -76
- package/Menu/Menu.module.css +2 -1
- package/Menu/components/MenuItem/index.js +17 -14
- package/Menu/index.js +22 -23
- package/Modal/components/Body/index.js +9 -8
- package/Modal/components/Close/Close.module.css +4 -0
- package/Modal/components/Close/index.js +13 -14
- package/Modal/components/Content/index.js +5 -6
- package/Modal/components/Footer/index.js +5 -3
- package/Modal/components/Header/index.js +13 -12
- package/Modal/components/Title/index.js +10 -9
- package/Modal/context.js +3 -3
- package/Modal/index.js +46 -68
- package/MultiSelect/components/MenuOverlay/index.js +48 -61
- package/MultiSelect/components/MenuOverlayItem/index.js +13 -14
- package/MultiSelect/index.js +72 -100
- package/MultiSelect/index.module.css +2 -1
- package/MultiSelect/utils/index.js +8 -18
- package/NumberInput/NumberInput.js +80 -112
- package/Portal/index.js +6 -10
- package/Progress/Progress.js +45 -58
- package/RadioGroup/Radio.js +29 -32
- package/RadioGroup/index.js +43 -46
- package/Rating/Rating.js +50 -63
- package/Select/components/MenuOverlay/index.js +16 -25
- package/Select/components/MenuOverlayItem/index.js +13 -11
- package/Select/index.js +39 -48
- package/Select/index.module.css +2 -1
- package/Separator/index.js +5 -6
- package/Sheet/Sheet.js +89 -121
- package/Sheet/Sheet.module.css +4 -2
- package/Skeleton/index.js +25 -30
- package/Slider/Slider.js +83 -119
- package/Status/index.js +17 -18
- package/Switch/Switch.module.css +2 -1
- package/Switch/index.js +22 -15
- package/TabsMenu/Tab/Tab.js +14 -10
- package/TabsMenu/Tab/Tab.module.css +2 -1
- package/TabsMenu/index.js +25 -26
- package/TabsPanels/Panel/index.js +6 -4
- package/TabsPanels/index.js +13 -10
- package/TextArea/index.d.ts +1 -1
- package/TextArea/index.js +31 -19
- package/Theme/breakpoints.js +5 -11
- package/Theme/colors/theme_buenos_aires.js +14 -14
- package/Theme/colors/theme_jaipur.js +14 -14
- package/Theme/global.css +0 -1
- package/Theme/index.js +1 -1
- package/TimeSelect/Label/index.js +11 -13
- package/TimeSelect/helpers.js +23 -42
- package/TimeSelect/index.js +32 -38
- package/Tooltip/index.js +36 -42
- package/Typography/index.js +17 -13
- package/Typography/index.props.d.ts +3 -0
- package/base/BaseInput/index.js +10 -8
- package/base/FormField/index.d.ts +1 -1
- package/base/FormField/index.js +27 -22
- package/base/FormField/index.props.d.ts +4 -0
- package/base/InputRoot/index.js +27 -27
- package/esm/Accordion/Accordion.module.css +4 -0
- package/esm/Accordion/index.js +15 -21
- package/esm/Autocomplete/Autocomplete.js +101 -130
- package/esm/Avatar/Avatar.module.css +6 -0
- package/esm/Avatar/index.js +102 -88
- package/esm/Badge/Badge.module.css +2 -1
- package/esm/Badge/Control/index.js +5 -3
- package/esm/Badge/index.js +16 -15
- package/esm/Button/index.js +23 -19
- package/esm/Button/tokens.js +2 -2
- package/esm/Calendar/Calendar.js +171 -267
- package/esm/Card/Card.js +26 -32
- package/esm/Checkbox/index.js +46 -42
- package/esm/Chip/Chip.module.css +2 -1
- package/esm/Chip/index.js +15 -14
- package/esm/ClickOutside/index.js +10 -13
- package/esm/CodeField/CodeField.js +113 -169
- package/esm/Counter/Counter.module.css +2 -1
- package/esm/Counter/index.js +21 -19
- package/esm/Datepicker/components/DatePicker/index.js +81 -101
- package/esm/Datepicker/index.js +17 -16
- package/esm/DotsLoader/index.js +23 -14
- package/esm/Drawer/Drawer.js +75 -96
- package/esm/Drawer/Drawer.module.css +2 -1
- package/esm/Dropdown/index.js +55 -66
- package/esm/Dropzone/Dropzone.js +78 -165
- package/esm/Dropzone/Dropzone.module.css +2 -1
- package/esm/Editable/Editable.js +44 -56
- package/esm/Grid/Item/index.js +11 -12
- package/esm/Grid/index.js +15 -21
- package/esm/Icons/ArrowNext.js +7 -8
- package/esm/Icons/Cart.js +7 -8
- package/esm/Icons/Check.js +7 -8
- package/esm/Icons/Chevron.js +7 -8
- package/esm/Icons/Close.js +6 -6
- package/esm/Icons/Copy.js +7 -8
- package/esm/Icons/Cross.js +6 -6
- package/esm/Icons/CrossFill.js +7 -8
- package/esm/Icons/Edit.js +7 -8
- package/esm/Icons/Exit.js +7 -8
- package/esm/Icons/EyeClosed.js +7 -8
- package/esm/Icons/EyeOpen.js +7 -8
- package/esm/Icons/Help.js +6 -6
- package/esm/Icons/Info.js +7 -8
- package/esm/Icons/Minus.js +7 -8
- package/esm/Icons/More.js +7 -8
- package/esm/Icons/Plus.js +7 -8
- package/esm/Icons/Setting.js +7 -8
- package/esm/Icons/Shield.js +7 -8
- package/esm/Icons/Trash.js +7 -8
- package/esm/Icons/User.js +7 -8
- package/esm/Image/Image.module.css +4 -0
- package/esm/Image/index.d.ts +1 -1
- package/esm/Image/index.js +44 -36
- package/esm/Input/index.d.ts +1 -1
- package/esm/Input/index.js +39 -26
- package/esm/Input/index.props.d.ts +1 -1
- package/esm/InputRadio/index.js +32 -23
- package/esm/List/List.js +81 -75
- package/esm/Menu/Menu.module.css +2 -1
- package/esm/Menu/components/MenuItem/index.js +17 -13
- package/esm/Menu/index.js +22 -23
- package/esm/Modal/components/Body/index.js +9 -7
- package/esm/Modal/components/Close/Close.module.css +4 -0
- package/esm/Modal/components/Close/index.js +13 -14
- package/esm/Modal/components/Content/index.js +5 -6
- package/esm/Modal/components/Footer/index.js +5 -3
- package/esm/Modal/components/Header/index.js +13 -11
- package/esm/Modal/components/Title/index.js +10 -9
- package/esm/Modal/context.js +3 -3
- package/esm/Modal/index.js +50 -70
- package/esm/MultiSelect/components/MenuOverlay/index.js +48 -60
- package/esm/MultiSelect/components/MenuOverlayItem/index.js +13 -14
- package/esm/MultiSelect/index.js +72 -97
- package/esm/MultiSelect/index.module.css +2 -1
- package/esm/MultiSelect/utils/index.js +8 -14
- package/esm/NumberInput/NumberInput.js +80 -111
- package/esm/Portal/index.js +6 -9
- package/esm/Progress/Progress.js +45 -58
- package/esm/RadioGroup/Radio.js +29 -32
- package/esm/RadioGroup/index.js +43 -45
- package/esm/Rating/Rating.js +50 -63
- package/esm/Select/components/MenuOverlay/index.js +16 -24
- package/esm/Select/components/MenuOverlayItem/index.js +13 -11
- package/esm/Select/index.js +39 -46
- package/esm/Select/index.module.css +2 -1
- package/esm/Separator/index.js +5 -6
- package/esm/Sheet/Sheet.js +89 -119
- package/esm/Sheet/Sheet.module.css +4 -2
- package/esm/Skeleton/index.js +25 -30
- package/esm/Slider/Slider.js +83 -119
- package/esm/Status/index.js +17 -17
- package/esm/Switch/Switch.module.css +2 -1
- package/esm/Switch/index.js +22 -14
- package/esm/TabsMenu/Tab/Tab.js +14 -9
- package/esm/TabsMenu/Tab/Tab.module.css +2 -1
- package/esm/TabsMenu/index.js +25 -26
- package/esm/TabsPanels/Panel/index.js +6 -4
- package/esm/TabsPanels/index.js +13 -10
- package/esm/TextArea/index.d.ts +1 -1
- package/esm/TextArea/index.js +32 -20
- package/esm/Theme/breakpoints.js +5 -11
- package/esm/Theme/colors/theme_buenos_aires.js +14 -14
- package/esm/Theme/colors/theme_jaipur.js +14 -14
- package/esm/Theme/global.css +0 -1
- package/esm/Theme/index.js +1 -1
- package/esm/TimeSelect/Label/index.js +11 -13
- package/esm/TimeSelect/helpers.js +22 -37
- package/esm/TimeSelect/index.js +32 -38
- package/esm/Tooltip/index.js +36 -41
- package/esm/Typography/index.js +17 -12
- package/esm/Typography/index.props.d.ts +3 -0
- package/esm/base/BaseInput/index.js +10 -8
- package/esm/base/FormField/index.d.ts +1 -1
- package/esm/base/FormField/index.js +27 -21
- package/esm/base/FormField/index.props.d.ts +4 -0
- package/esm/base/InputRoot/index.js +27 -26
- package/esm/helpers/date/index.js +4 -8
- package/esm/hooks/useMediaSizes/index.js +9 -15
- package/esm/hooks/useModalStack/index.js +6 -9
- package/esm/hooks/useOnClickOutside/index.js +6 -6
- package/esm/hooks/useScrollLock/index.js +10 -9
- package/esm/hooks/useTrapFocus/index.js +8 -10
- package/esm/lib/keyboard.js +2 -4
- package/helpers/date/index.js +21 -32
- package/hooks/useMediaSizes/index.js +9 -15
- package/hooks/useModalStack/index.js +6 -9
- package/hooks/useOnClickOutside/index.js +6 -6
- package/hooks/useScrollLock/index.js +10 -9
- package/hooks/useTrapFocus/index.js +8 -10
- package/lib/keyboard.js +2 -4
- package/package.json +5 -1
package/esm/Typography/index.js
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
1
|
import { __rest } from 'tslib';
|
|
3
2
|
import React from 'react';
|
|
4
3
|
import clsx from 'clsx';
|
|
5
4
|
import styles from './Typography.module.css';
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
const Typography = _a => {
|
|
7
|
+
var {
|
|
8
|
+
tag: Component = "span",
|
|
9
|
+
children,
|
|
10
|
+
variant,
|
|
11
|
+
size,
|
|
12
|
+
style,
|
|
13
|
+
fontWeight,
|
|
14
|
+
lines,
|
|
15
|
+
className
|
|
16
|
+
} = _a,
|
|
17
17
|
props = __rest(_a, ["tag", "children", "variant", "size", "style", "fontWeight", "lines", "className"]);
|
|
18
18
|
return /*#__PURE__*/React.createElement(Component, Object.assign({}, props, {
|
|
19
19
|
style: lines ? Object.assign(Object.assign({}, style), {
|
|
20
20
|
"--typography-lines": lines
|
|
21
21
|
}) : Object.assign({}, style),
|
|
22
|
-
className: clsx(
|
|
22
|
+
className: clsx({
|
|
23
|
+
[styles[`size_${size}`]]: Boolean(size),
|
|
24
|
+
[styles[`font-weight_${fontWeight}`]]: Boolean(fontWeight),
|
|
25
|
+
[styles[`variant_${variant}`]]: Boolean(variant),
|
|
26
|
+
[styles.clamp]: Boolean(lines)
|
|
27
|
+
}, className)
|
|
23
28
|
}), children);
|
|
24
29
|
};
|
|
25
30
|
|
|
@@ -5,6 +5,9 @@ export type TypographySize = "xs" | "s" | "m" | "l" | "text-xs" | "text-sm" | "t
|
|
|
5
5
|
export type TypographyTag = "span" | "label" | "legend" | "p" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "s";
|
|
6
6
|
export type TypographyProps = {
|
|
7
7
|
className?: string;
|
|
8
|
+
/** Associates the text with a form control when `tag` is `label`. */
|
|
9
|
+
htmlFor?: string;
|
|
10
|
+
id?: string;
|
|
8
11
|
tag?: TypographyTag;
|
|
9
12
|
variant?: TypographyVariant;
|
|
10
13
|
size?: TypographySize;
|
|
@@ -3,15 +3,17 @@ import React from 'react';
|
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import styles from './BaseInput.module.css';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
const BaseInput = _a => {
|
|
7
|
+
var {
|
|
8
|
+
className,
|
|
9
|
+
onFocus,
|
|
10
|
+
onChange,
|
|
11
|
+
onBlur,
|
|
12
|
+
onKeyDown,
|
|
13
|
+
ref
|
|
14
|
+
} = _a,
|
|
13
15
|
props = __rest(_a, ["className", "onFocus", "onChange", "onBlur", "onKeyDown", "ref"]);
|
|
14
|
-
|
|
16
|
+
const onChangeHandler = e => {
|
|
15
17
|
if (onChange) onChange(e, e.target.value);
|
|
16
18
|
};
|
|
17
19
|
return /*#__PURE__*/React.createElement("input", Object.assign({
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { FormFieldProps } from "./index.props";
|
|
3
|
-
export declare const FormField: ({ label, hint, children, hasError, required, className, ref, }: FormFieldProps) => React.JSX.Element;
|
|
3
|
+
export declare const FormField: ({ label, hint, children, hasError, hintId, htmlFor, required, className, ref, }: FormFieldProps) => React.JSX.Element;
|
|
@@ -1,28 +1,34 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import clsx from 'clsx';
|
|
4
3
|
import { Typography } from '../../Typography/index.js';
|
|
5
4
|
import styles from './FormField.module.css';
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
6
|
+
const FormField = ({
|
|
7
|
+
label,
|
|
8
|
+
hint,
|
|
9
|
+
children,
|
|
10
|
+
hasError,
|
|
11
|
+
hintId,
|
|
12
|
+
htmlFor,
|
|
13
|
+
required,
|
|
14
|
+
className,
|
|
15
|
+
ref
|
|
16
|
+
}) => (/*#__PURE__*/React.createElement("div", {
|
|
17
|
+
className: clsx(styles.container, className),
|
|
18
|
+
ref: ref
|
|
19
|
+
}, label && (/*#__PURE__*/React.createElement(Typography, {
|
|
20
|
+
className: clsx(styles.label, {
|
|
21
|
+
[styles.label_required]: Boolean(required)
|
|
22
|
+
}),
|
|
23
|
+
tag: "label",
|
|
24
|
+
htmlFor: htmlFor
|
|
25
|
+
}, label)), children, hint && (/*#__PURE__*/React.createElement(Typography, {
|
|
26
|
+
id: hintId,
|
|
27
|
+
className: clsx({
|
|
28
|
+
[styles.hint_error]: hasError
|
|
29
|
+
}),
|
|
30
|
+
variant: hasError ? "alert" : "secondary",
|
|
31
|
+
tag: "span"
|
|
32
|
+
}, hint))));
|
|
27
33
|
|
|
28
34
|
export { FormField };
|
|
@@ -4,6 +4,10 @@ export type FormFieldProps = PropsWithChildren<{
|
|
|
4
4
|
className?: string;
|
|
5
5
|
hasError?: boolean;
|
|
6
6
|
hint?: ReactNode;
|
|
7
|
+
/** Id of the hint, referenced by the control's `aria-describedby`. */
|
|
8
|
+
hintId?: string;
|
|
9
|
+
/** Id of the control the label belongs to. */
|
|
10
|
+
htmlFor?: string;
|
|
7
11
|
label?: ReactNode;
|
|
8
12
|
ref?: React.Ref<HTMLDivElement>;
|
|
9
13
|
required?: boolean;
|
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import clsx from 'clsx';
|
|
4
3
|
import styles from './InputRoot.module.css';
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
5
|
+
const InputRoot = ({
|
|
6
|
+
active,
|
|
7
|
+
className,
|
|
8
|
+
startIcon,
|
|
9
|
+
endIcon,
|
|
10
|
+
children,
|
|
11
|
+
variant = "primary",
|
|
12
|
+
disabled,
|
|
13
|
+
hasError,
|
|
14
|
+
style,
|
|
15
|
+
size,
|
|
16
|
+
ref
|
|
17
|
+
}) => (/*#__PURE__*/React.createElement("div", {
|
|
18
|
+
ref: ref,
|
|
19
|
+
style: style,
|
|
20
|
+
className: clsx(styles.root, styles[`variant_${variant}`], size && styles[`size_${size}`], {
|
|
21
|
+
[styles[`variant_${variant}_active`]]: active,
|
|
22
|
+
[styles[`variant_${variant}_disabled`]]: disabled,
|
|
23
|
+
[styles[`variant_${variant}_error`]]: hasError
|
|
24
|
+
}, className)
|
|
25
|
+
}, startIcon && /*#__PURE__*/React.createElement("div", {
|
|
26
|
+
className: styles["base-icon"]
|
|
27
|
+
}, startIcon), children, endIcon && /*#__PURE__*/React.createElement("div", {
|
|
28
|
+
className: styles["base-icon"]
|
|
29
|
+
}, endIcon), disabled && /*#__PURE__*/React.createElement("div", {
|
|
30
|
+
className: styles["base-disable-wrapper"]
|
|
31
|
+
})));
|
|
31
32
|
|
|
32
33
|
export { InputRoot };
|
|
@@ -2,20 +2,16 @@ import { parseISO, isValid, format } from 'date-fns';
|
|
|
2
2
|
import 'date-fns/locale';
|
|
3
3
|
|
|
4
4
|
// Helper to parse date strings with fallback
|
|
5
|
-
|
|
5
|
+
const parse = dateInput => {
|
|
6
6
|
if (!dateInput) {
|
|
7
7
|
return new Date();
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
const date = typeof dateInput === "string" ? parseISO(dateInput) : dateInput;
|
|
10
10
|
return isValid(date) ? date : new Date(dateInput);
|
|
11
11
|
};
|
|
12
12
|
// Convert date to ISO format (YYYY-MM-DD)
|
|
13
|
-
|
|
14
|
-
return format(date, "yyyy-MM-dd");
|
|
15
|
-
};
|
|
13
|
+
const toISODate = date => format(date, "yyyy-MM-dd");
|
|
16
14
|
// Convert date to DMY format (dd.MM.yyyy)
|
|
17
|
-
|
|
18
|
-
return dateISO ? format(new Date(dateISO), "dd.MM.yyyy") : "";
|
|
19
|
-
};
|
|
15
|
+
const toDMYDate = dateISO => dateISO ? format(new Date(dateISO), "dd.MM.yyyy") : "";
|
|
20
16
|
|
|
21
17
|
export { parse, toDMYDate, toISODate };
|
|
@@ -1,28 +1,22 @@
|
|
|
1
1
|
import { useCallback, useSyncExternalStore } from 'react';
|
|
2
2
|
import { media } from '../../Theme/breakpoints.js';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
var getMediaQueryList = function getMediaQueryList(query) {
|
|
8
|
-
return typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia(query) : null;
|
|
9
|
-
};
|
|
4
|
+
const getServerSnapshot = () => false;
|
|
5
|
+
const getMediaQueryList = query => typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia(query) : null;
|
|
10
6
|
/**
|
|
11
7
|
* Returns whether the media query matches.
|
|
12
8
|
* Returns `false` on the server and during hydration, the real value right after.
|
|
13
9
|
*/
|
|
14
|
-
|
|
10
|
+
const useMediaSizes = queryInput => {
|
|
15
11
|
// A function input is a new function every render: memoize on the query string.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (!queryList) return
|
|
12
|
+
const query = (typeof queryInput === "function" ? queryInput(media) : queryInput).replace(/^\s*@media\s*/, "");
|
|
13
|
+
const subscribe = useCallback(onChange => {
|
|
14
|
+
const queryList = getMediaQueryList(query);
|
|
15
|
+
if (!queryList) return () => {};
|
|
20
16
|
queryList.addEventListener("change", onChange);
|
|
21
|
-
return
|
|
22
|
-
return queryList.removeEventListener("change", onChange);
|
|
23
|
-
};
|
|
17
|
+
return () => queryList.removeEventListener("change", onChange);
|
|
24
18
|
}, [query]);
|
|
25
|
-
|
|
19
|
+
const getSnapshot = useCallback(() => {
|
|
26
20
|
var _a, _b;
|
|
27
21
|
return (_b = (_a = getMediaQueryList(query)) === null || _a === void 0 ? void 0 : _a.matches) !== null && _b !== void 0 ? _b : false;
|
|
28
22
|
}, [query]);
|
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
import { useEffect, useCallback } from 'react';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const stack = [];
|
|
4
4
|
/**
|
|
5
5
|
* Tracks open modals so only the topmost one reacts to Escape and Tab.
|
|
6
6
|
* An inactive entry is not registered and counts as topmost only while no
|
|
7
7
|
* modal is open.
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
useEffect(function () {
|
|
9
|
+
const useModalStack = (id, active = true) => {
|
|
10
|
+
useEffect(() => {
|
|
12
11
|
if (!active) return;
|
|
13
12
|
stack.push(id);
|
|
14
|
-
return
|
|
15
|
-
|
|
13
|
+
return () => {
|
|
14
|
+
const index = stack.lastIndexOf(id);
|
|
16
15
|
if (index !== -1) stack.splice(index, 1);
|
|
17
16
|
};
|
|
18
17
|
}, [id, active]);
|
|
19
|
-
return useCallback(
|
|
20
|
-
return stack.length ? stack[stack.length - 1] === id : !active;
|
|
21
|
-
}, [id, active]);
|
|
18
|
+
return useCallback(() => stack.length ? stack[stack.length - 1] === id : !active, [id, active]);
|
|
22
19
|
};
|
|
23
20
|
|
|
24
21
|
export { useModalStack };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
let element = {
|
|
4
4
|
current: undefined
|
|
5
5
|
};
|
|
6
6
|
function useOnClickOutside(ref, handler) {
|
|
7
|
-
useEffect(
|
|
8
|
-
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const previous = element;
|
|
9
9
|
element = ref;
|
|
10
|
-
|
|
10
|
+
const listener = event => {
|
|
11
11
|
// Ensure this hook belongs to the current element.
|
|
12
12
|
if ((ref === null || ref === void 0 ? void 0 : ref.current) !== (element === null || element === void 0 ? void 0 : element.current)) return;
|
|
13
|
-
|
|
13
|
+
const el = element.current;
|
|
14
14
|
if (!el) return;
|
|
15
15
|
// Ignore clicks inside the element.
|
|
16
16
|
if (el.contains(event.target)) return;
|
|
@@ -18,7 +18,7 @@ function useOnClickOutside(ref, handler) {
|
|
|
18
18
|
};
|
|
19
19
|
document.addEventListener("mousedown", listener, false);
|
|
20
20
|
document.addEventListener("touchstart", listener, false);
|
|
21
|
-
return
|
|
21
|
+
return () => {
|
|
22
22
|
document.removeEventListener("mousedown", listener, false);
|
|
23
23
|
document.removeEventListener("touchstart", listener, false);
|
|
24
24
|
element = previous;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
useEffect(
|
|
5
|
-
|
|
3
|
+
const useScrollLock = () => {
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
const body = document.querySelector("body");
|
|
6
6
|
if (!body) return undefined;
|
|
7
|
-
|
|
8
|
-
overflow
|
|
9
|
-
width
|
|
10
|
-
|
|
7
|
+
const {
|
|
8
|
+
overflow,
|
|
9
|
+
width
|
|
10
|
+
} = body.style;
|
|
11
|
+
const scrollBarWidth = window.innerWidth - document.documentElement.clientWidth;
|
|
11
12
|
body.style.overflow = "hidden";
|
|
12
13
|
if (scrollBarWidth > 0) {
|
|
13
|
-
body.style.width =
|
|
14
|
+
body.style.width = `calc(100% - ${scrollBarWidth}px)`;
|
|
14
15
|
}
|
|
15
|
-
return
|
|
16
|
+
return () => {
|
|
16
17
|
body.style.overflow = overflow;
|
|
17
18
|
body.style.width = width;
|
|
18
19
|
};
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
return element.querySelectorAll('a[href], button, textarea, input[type="text"], input[type="password"], input[type="radio"], input[type="checkbox"], select');
|
|
5
|
-
};
|
|
3
|
+
const getFocusableModalElements = element => element.querySelectorAll('a[href], button, textarea, input[type="text"], input[type="password"], input[type="radio"], input[type="checkbox"], select');
|
|
6
4
|
function useTrapFocus(refObject, isActive) {
|
|
7
|
-
useEffect(
|
|
8
|
-
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const handler = event => {
|
|
9
7
|
if (!refObject.current || event.code !== "Tab") return;
|
|
10
8
|
if (isActive && !isActive()) return;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
const focusable = Array.from(getFocusableModalElements(refObject.current));
|
|
10
|
+
const firstElement = focusable[0];
|
|
11
|
+
const lastElement = focusable[focusable.length - 1];
|
|
14
12
|
if (!lastElement || !firstElement) return;
|
|
15
|
-
|
|
13
|
+
const focusOutside = document.activeElement ? !focusable.includes(document.activeElement) : true;
|
|
16
14
|
if (event.shiftKey && (document.activeElement === firstElement || focusOutside)) {
|
|
17
15
|
lastElement.focus();
|
|
18
16
|
event.preventDefault();
|
|
@@ -22,7 +20,7 @@ function useTrapFocus(refObject, isActive) {
|
|
|
22
20
|
}
|
|
23
21
|
};
|
|
24
22
|
document.addEventListener("keydown", handler);
|
|
25
|
-
return
|
|
23
|
+
return () => {
|
|
26
24
|
document.removeEventListener("keydown", handler);
|
|
27
25
|
};
|
|
28
26
|
}, [refObject, isActive]);
|
package/esm/lib/keyboard.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const Keys = {
|
|
2
2
|
BACKSPACE: "Backspace",
|
|
3
3
|
TAB: "Tab",
|
|
4
4
|
ENTER: "Enter",
|
|
@@ -17,9 +17,7 @@ var Keys = {
|
|
|
17
17
|
DELETE: "Delete"
|
|
18
18
|
};
|
|
19
19
|
function isKey(eventKey, keys) {
|
|
20
|
-
return keys.some(
|
|
21
|
-
return Keys[value] === eventKey || value === eventKey;
|
|
22
|
-
});
|
|
20
|
+
return keys.some(value => Keys[value] === eventKey || value === eventKey);
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
export { Keys, isKey };
|
package/helpers/date/index.js
CHANGED
|
@@ -4,69 +4,58 @@ var dateFns = require('date-fns');
|
|
|
4
4
|
var locale = require('date-fns/locale');
|
|
5
5
|
|
|
6
6
|
// Helper to parse date strings with fallback
|
|
7
|
-
|
|
7
|
+
const parse = dateInput => {
|
|
8
8
|
if (!dateInput) {
|
|
9
9
|
return new Date();
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
const date = typeof dateInput === "string" ? dateFns.parseISO(dateInput) : dateInput;
|
|
12
12
|
return dateFns.isValid(date) ? date : new Date(dateInput);
|
|
13
13
|
};
|
|
14
14
|
// Get full month name with the first letter capitalized
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const getUpperMonthName = date => {
|
|
16
|
+
const parsedDate = parse(date);
|
|
17
17
|
return dateFns.format(parsedDate, "LLLL", {
|
|
18
18
|
locale: locale.enGB
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
21
|
// Get short weekday name by index (e.g., Mo, Tu, etc.)
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
const getShortWeekDayNameByIndex = index => {
|
|
23
|
+
const firstDayOfWeek = dateFns.startOfWeek(new Date());
|
|
24
24
|
return dateFns.format(dateFns.addDays(firstDayOfWeek, index), "EEEEEE", {
|
|
25
25
|
locale: locale.enGB
|
|
26
26
|
});
|
|
27
27
|
};
|
|
28
28
|
// Get formatted date string with month and day
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
const getDateMonth = date => {
|
|
30
|
+
const parsedDate = parse(date);
|
|
31
31
|
return dateFns.format(parsedDate, "MMMM d", {
|
|
32
32
|
locale: locale.enGB
|
|
33
33
|
});
|
|
34
34
|
};
|
|
35
35
|
// Shift the date by a number of days
|
|
36
|
-
|
|
37
|
-
return dateFns.addDays(date, days);
|
|
38
|
-
};
|
|
36
|
+
const shiftDate = (date, days) => dateFns.addDays(date, days);
|
|
39
37
|
// Check if two dates are in the same month and year
|
|
40
|
-
|
|
41
|
-
return date.getFullYear() === otherDate.getFullYear() && date.getMonth() === otherDate.getMonth();
|
|
42
|
-
};
|
|
38
|
+
const isSameMonthAndYear = (date, otherDate) => date.getFullYear() === otherDate.getFullYear() && date.getMonth() === otherDate.getMonth();
|
|
43
39
|
// Convert date to ISO format (YYYY-MM-DD)
|
|
44
|
-
|
|
45
|
-
return dateFns.format(date, "yyyy-MM-dd");
|
|
46
|
-
};
|
|
40
|
+
const toISODate = date => dateFns.format(date, "yyyy-MM-dd");
|
|
47
41
|
// Convert date to DMY format (dd.MM.yyyy)
|
|
48
|
-
|
|
49
|
-
return dateISO ? dateFns.format(new Date(dateISO), "dd.MM.yyyy") : "";
|
|
50
|
-
};
|
|
42
|
+
const toDMYDate = dateISO => dateISO ? dateFns.format(new Date(dateISO), "dd.MM.yyyy") : "";
|
|
51
43
|
// Get the period dates as a formatted string
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
var start = parse(startDate);
|
|
44
|
+
const getPeriodDates = (startDate, period = 1) => {
|
|
45
|
+
const start = parse(startDate);
|
|
55
46
|
if (period === 1) {
|
|
56
47
|
return getDateMonth(start);
|
|
57
48
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return
|
|
49
|
+
const end = shiftDate(start, period - 1);
|
|
50
|
+
const startDateFormat = isSameMonthAndYear(start, end) ? dateFns.format(start, "d") : getDateMonth(start);
|
|
51
|
+
return `${startDateFormat} – ${getDateMonth(end)}`;
|
|
61
52
|
};
|
|
62
53
|
// Clear time from a date
|
|
63
|
-
|
|
64
|
-
return new Date(date.setHours(0, 0, 0, 0));
|
|
65
|
-
};
|
|
54
|
+
const clearTime = date => new Date(date.setHours(0, 0, 0, 0));
|
|
66
55
|
// Get the difference in days between two dates
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
56
|
+
const getDaysDiff = (dateStart, dateEnd) => {
|
|
57
|
+
const start = clearTime(dateStart).getTime();
|
|
58
|
+
const end = clearTime(dateEnd).getTime();
|
|
70
59
|
return Math.round((end - start) / (1000 * 60 * 60 * 24)); // Convert milliseconds to days
|
|
71
60
|
};
|
|
72
61
|
|
|
@@ -3,28 +3,22 @@
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var breakpoints = require('../../Theme/breakpoints.js');
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
var getMediaQueryList = function getMediaQueryList(query) {
|
|
10
|
-
return typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia(query) : null;
|
|
11
|
-
};
|
|
6
|
+
const getServerSnapshot = () => false;
|
|
7
|
+
const getMediaQueryList = query => typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia(query) : null;
|
|
12
8
|
/**
|
|
13
9
|
* Returns whether the media query matches.
|
|
14
10
|
* Returns `false` on the server and during hydration, the real value right after.
|
|
15
11
|
*/
|
|
16
|
-
|
|
12
|
+
const useMediaSizes = queryInput => {
|
|
17
13
|
// A function input is a new function every render: memoize on the query string.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (!queryList) return
|
|
14
|
+
const query = (typeof queryInput === "function" ? queryInput(breakpoints.media) : queryInput).replace(/^\s*@media\s*/, "");
|
|
15
|
+
const subscribe = React.useCallback(onChange => {
|
|
16
|
+
const queryList = getMediaQueryList(query);
|
|
17
|
+
if (!queryList) return () => {};
|
|
22
18
|
queryList.addEventListener("change", onChange);
|
|
23
|
-
return
|
|
24
|
-
return queryList.removeEventListener("change", onChange);
|
|
25
|
-
};
|
|
19
|
+
return () => queryList.removeEventListener("change", onChange);
|
|
26
20
|
}, [query]);
|
|
27
|
-
|
|
21
|
+
const getSnapshot = React.useCallback(() => {
|
|
28
22
|
var _a, _b;
|
|
29
23
|
return (_b = (_a = getMediaQueryList(query)) === null || _a === void 0 ? void 0 : _a.matches) !== null && _b !== void 0 ? _b : false;
|
|
30
24
|
}, [query]);
|
|
@@ -2,25 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const stack = [];
|
|
6
6
|
/**
|
|
7
7
|
* Tracks open modals so only the topmost one reacts to Escape and Tab.
|
|
8
8
|
* An inactive entry is not registered and counts as topmost only while no
|
|
9
9
|
* modal is open.
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
React.useEffect(function () {
|
|
11
|
+
const useModalStack = (id, active = true) => {
|
|
12
|
+
React.useEffect(() => {
|
|
14
13
|
if (!active) return;
|
|
15
14
|
stack.push(id);
|
|
16
|
-
return
|
|
17
|
-
|
|
15
|
+
return () => {
|
|
16
|
+
const index = stack.lastIndexOf(id);
|
|
18
17
|
if (index !== -1) stack.splice(index, 1);
|
|
19
18
|
};
|
|
20
19
|
}, [id, active]);
|
|
21
|
-
return React.useCallback(
|
|
22
|
-
return stack.length ? stack[stack.length - 1] === id : !active;
|
|
23
|
-
}, [id, active]);
|
|
20
|
+
return React.useCallback(() => stack.length ? stack[stack.length - 1] === id : !active, [id, active]);
|
|
24
21
|
};
|
|
25
22
|
|
|
26
23
|
exports.useModalStack = useModalStack;
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
let element = {
|
|
6
6
|
current: undefined
|
|
7
7
|
};
|
|
8
8
|
function useOnClickOutside(ref, handler) {
|
|
9
|
-
React.useEffect(
|
|
10
|
-
|
|
9
|
+
React.useEffect(() => {
|
|
10
|
+
const previous = element;
|
|
11
11
|
element = ref;
|
|
12
|
-
|
|
12
|
+
const listener = event => {
|
|
13
13
|
// Ensure this hook belongs to the current element.
|
|
14
14
|
if ((ref === null || ref === void 0 ? void 0 : ref.current) !== (element === null || element === void 0 ? void 0 : element.current)) return;
|
|
15
|
-
|
|
15
|
+
const el = element.current;
|
|
16
16
|
if (!el) return;
|
|
17
17
|
// Ignore clicks inside the element.
|
|
18
18
|
if (el.contains(event.target)) return;
|
|
@@ -20,7 +20,7 @@ function useOnClickOutside(ref, handler) {
|
|
|
20
20
|
};
|
|
21
21
|
document.addEventListener("mousedown", listener, false);
|
|
22
22
|
document.addEventListener("touchstart", listener, false);
|
|
23
|
-
return
|
|
23
|
+
return () => {
|
|
24
24
|
document.removeEventListener("mousedown", listener, false);
|
|
25
25
|
document.removeEventListener("touchstart", listener, false);
|
|
26
26
|
element = previous;
|