@coopdigital/react 1.4.0 → 1.5.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/dist/components/AlertBanner/AlertBanner.d.ts +12 -2
- package/dist/components/AlertBanner/AlertBanner.js +3 -2
- package/dist/components/Author/Author.d.ts +7 -1
- package/dist/components/Author/Author.js +1 -0
- package/dist/components/Button/Button.d.ts +7 -1
- package/dist/components/Button/Button.js +1 -0
- package/dist/components/Card/Card.d.ts +40 -6
- package/dist/components/Card/Card.js +7 -6
- package/dist/components/Checkbox/Checkbox.d.ts +6 -4
- package/dist/components/Checkbox/Checkbox.js +9 -6
- package/dist/components/DatePicker/DatePicker.d.ts +8 -3
- package/dist/components/DatePicker/DatePicker.js +11 -11
- package/dist/components/Expandable/Expandable.d.ts +19 -3
- package/dist/components/Expandable/Expandable.js +4 -3
- package/dist/components/Field/Field.context.d.ts +14 -0
- package/dist/components/Field/Field.context.js +14 -0
- package/dist/components/Field/Field.d.ts +26 -4
- package/dist/components/Field/Field.js +33 -34
- package/dist/components/Field/index.js +1 -0
- package/dist/components/FieldMarkers/Label.js +4 -0
- package/dist/components/Fieldset/Fieldset.d.ts +33 -5
- package/dist/components/Fieldset/Fieldset.js +6 -5
- package/dist/components/Flourish/Flourish.d.ts +7 -1
- package/dist/components/Flourish/Flourish.js +1 -0
- package/dist/components/Form/Form.d.ts +7 -1
- package/dist/components/Form/Form.js +1 -0
- package/dist/components/Image/Image.d.ts +7 -1
- package/dist/components/Image/Image.js +1 -0
- package/dist/components/Pill/Pill.d.ts +12 -2
- package/dist/components/Pill/Pill.js +3 -2
- package/dist/components/Popover/Popover.d.ts +33 -5
- package/dist/components/Popover/Popover.js +6 -5
- package/dist/components/Popover/index.js +1 -0
- package/dist/components/Radio/Radio.d.ts +6 -4
- package/dist/components/Radio/Radio.js +9 -6
- package/dist/components/RootSVG/RootSVG.d.ts +7 -1
- package/dist/components/RootSVG/RootSVG.js +1 -0
- package/dist/components/Searchbox/Searchbox.context.d.ts +13 -0
- package/dist/components/Searchbox/Searchbox.context.js +11 -0
- package/dist/components/Searchbox/Searchbox.d.ts +15 -11
- package/dist/components/Searchbox/Searchbox.js +25 -28
- package/dist/components/Select/Select.d.ts +18 -5
- package/dist/components/Select/Select.js +9 -9
- package/dist/components/Signpost/Signpost.d.ts +7 -1
- package/dist/components/Signpost/Signpost.js +1 -0
- package/dist/components/SkipNav/SkipNav.d.ts +7 -1
- package/dist/components/SkipNav/SkipNav.js +1 -0
- package/dist/components/Squircle/Squircle.d.ts +7 -1
- package/dist/components/Squircle/Squircle.js +1 -0
- package/dist/components/Tag/Tag.d.ts +7 -1
- package/dist/components/Tag/Tag.js +1 -0
- package/dist/components/TextInput/TextInput.d.ts +4 -3
- package/dist/components/TextInput/TextInput.js +6 -6
- package/dist/components/Textarea/Textarea.d.ts +4 -3
- package/dist/components/Textarea/Textarea.js +4 -6
- package/dist/components/ValidationSummary/ValidationSummary.d.ts +26 -4
- package/dist/components/ValidationSummary/ValidationSummary.js +8 -6
- package/dist/hooks/useSlots.d.ts +4 -2
- package/dist/hooks/useSlots.js +33 -7
- package/dist/index.js +10 -10
- package/dist/types/index.d.ts +14 -14
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +9 -7
- package/package.json +9 -8
- package/src/components/AlertBanner/AlertBanner.tsx +5 -2
- package/src/components/Author/Author.tsx +4 -1
- package/src/components/Button/Button.tsx +5 -1
- package/src/components/Card/Card.tsx +8 -6
- package/src/components/Checkbox/Checkbox.tsx +13 -9
- package/src/components/DatePicker/DatePicker.tsx +15 -15
- package/src/components/Expandable/Expandable.tsx +5 -8
- package/src/components/Field/Field.context.ts +29 -0
- package/src/components/Field/Field.tsx +61 -56
- package/src/components/FieldMarkers/Label.tsx +4 -0
- package/src/components/Fieldset/Fieldset.tsx +7 -5
- package/src/components/Flourish/Flourish.tsx +4 -1
- package/src/components/Form/Form.tsx +4 -1
- package/src/components/Image/Image.tsx +4 -1
- package/src/components/Pill/Pill.tsx +4 -2
- package/src/components/Popover/Popover.tsx +7 -5
- package/src/components/Radio/Radio.tsx +12 -9
- package/src/components/RootSVG/RootSVG.tsx +4 -1
- package/src/components/Searchbox/Searchbox.context.tsx +20 -0
- package/src/components/Searchbox/Searchbox.tsx +55 -44
- package/src/components/Select/Select.tsx +11 -11
- package/src/components/Signpost/Signpost.tsx +4 -1
- package/src/components/SkipNav/SkipNav.tsx +4 -1
- package/src/components/Squircle/Squircle.tsx +4 -1
- package/src/components/Tag/Tag.tsx +4 -1
- package/src/components/TextInput/TextInput.tsx +8 -8
- package/src/components/Textarea/Textarea.tsx +7 -8
- package/src/components/ValidationSummary/ValidationSummary.tsx +12 -5
- package/src/hooks/useSlots.ts +37 -9
- package/src/types/index.ts +18 -14
- package/src/utils/index.ts +8 -6
- package/dist/node_modules/merge-refs/dist/index.js +0 -36
|
@@ -15,13 +15,23 @@ interface AlertBannerHeadingProps extends HTMLAttributes<HTMLHeadingElement> {
|
|
|
15
15
|
/** **(Optional)** Specify additional CSS classes to be applied to the Heading. */
|
|
16
16
|
className?: string;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
declare const AlertBanner: {
|
|
19
19
|
({ children, className, ref, variant, ...props }: AlertBannerProps): JSX.Element;
|
|
20
|
+
slot: {
|
|
21
|
+
name: string;
|
|
22
|
+
};
|
|
20
23
|
Heading: {
|
|
21
24
|
({ children, className }: AlertBannerHeadingProps): JSX.Element;
|
|
22
|
-
|
|
25
|
+
slot: {
|
|
23
26
|
name: string;
|
|
24
27
|
};
|
|
25
28
|
};
|
|
26
29
|
};
|
|
30
|
+
declare const AlertBannerHeading: {
|
|
31
|
+
({ children, className }: AlertBannerHeadingProps): JSX.Element;
|
|
32
|
+
slot: {
|
|
33
|
+
name: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
27
36
|
export default AlertBanner;
|
|
37
|
+
export { AlertBanner, AlertBannerHeading };
|
|
@@ -12,7 +12,8 @@ const AlertBanner = ({ children, className, ref, variant = "default", ...props }
|
|
|
12
12
|
const AlertBannerHeading = ({ children, className }) => {
|
|
13
13
|
return jsx("h2", { className: className, children: children });
|
|
14
14
|
};
|
|
15
|
-
|
|
15
|
+
AlertBanner.slot = { name: "AlertBanner" };
|
|
16
|
+
AlertBannerHeading.slot = { name: "AlertBannerHeading" };
|
|
16
17
|
AlertBanner.Heading = AlertBannerHeading;
|
|
17
18
|
|
|
18
|
-
export { AlertBanner, AlertBanner as default };
|
|
19
|
+
export { AlertBanner, AlertBannerHeading, AlertBanner as default };
|
|
@@ -16,5 +16,11 @@ export interface AuthorProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
16
16
|
/** **(Optional)** Specify the Author size. */
|
|
17
17
|
size?: "sm" | "md";
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
declare const Author: {
|
|
20
|
+
({ author, className, date, datePrefix, image, ref, size, ...props }: AuthorProps): JSX.Element;
|
|
21
|
+
slot: {
|
|
22
|
+
name: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
20
25
|
export default Author;
|
|
26
|
+
export { Author };
|
|
@@ -17,5 +17,6 @@ const Author = ({ author = "Co-op team", className, date, datePrefix = "", image
|
|
|
17
17
|
};
|
|
18
18
|
return (jsxs("div", { ...componentProps, ref: ref, children: [image && jsx(Image, { ...imageProps }), jsxs("div", { className: "coop-author--content", children: [jsxs("span", { children: [jsx("span", { children: datePrefix ? datePrefix + " " : "" }), jsx("span", { className: "coop-author--date", children: date })] }), jsxs("span", { children: ["by ", author] })] })] }));
|
|
19
19
|
};
|
|
20
|
+
Author.slot = { name: "Author" };
|
|
20
21
|
|
|
21
22
|
export { Author, Author as default };
|
|
@@ -26,5 +26,11 @@ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
26
26
|
/** **(Optional)** Specify the Button variant. */
|
|
27
27
|
variant?: "solid" | "ghost" | "text";
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
declare const Button: {
|
|
30
|
+
({ as, children, className, href, isDisabled, isFullWidth, isLoading, loadingText, onClick, ref, size, variant, ...props }: ButtonProps): JSX.Element;
|
|
31
|
+
slot: {
|
|
32
|
+
name: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
30
35
|
export default Button;
|
|
36
|
+
export { Button };
|
|
@@ -34,5 +34,6 @@ const Button = ({ as, children, className, href, isDisabled = false, isFullWidth
|
|
|
34
34
|
const finalChildren = isPending || isLoading ? (jsxs(Fragment, { children: [loadingText, jsx(LoadingIcon, { stroke: "currentColor", strokeWidth: "1px" })] })) : (children);
|
|
35
35
|
return React.createElement(element, { ...componentProps, ref }, finalChildren);
|
|
36
36
|
};
|
|
37
|
+
Button.slot = { name: "Button" };
|
|
37
38
|
|
|
38
39
|
export { Button, Button as default };
|
|
@@ -48,37 +48,71 @@ interface CardBadgeProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
48
48
|
position?: "inset" | "popout";
|
|
49
49
|
}
|
|
50
50
|
type CardImageProps = ImageProps;
|
|
51
|
-
|
|
51
|
+
declare const Card: {
|
|
52
52
|
({ chevron, children, className, href, hrefAs, imagePosition, orientation, ref, ...props }: CardProps): JSX.Element;
|
|
53
|
+
slot: {
|
|
54
|
+
name: string;
|
|
55
|
+
};
|
|
53
56
|
Label: {
|
|
54
57
|
({ children, className }: CardLabelProps): JSX.Element;
|
|
55
|
-
|
|
58
|
+
slot: {
|
|
56
59
|
name: string;
|
|
57
60
|
};
|
|
58
61
|
};
|
|
59
62
|
Heading: {
|
|
60
63
|
({ as, children, className }: CardHeadingProps): JSX.Element;
|
|
61
|
-
|
|
64
|
+
slot: {
|
|
62
65
|
name: string;
|
|
63
66
|
};
|
|
64
67
|
};
|
|
65
68
|
Badge: {
|
|
66
69
|
({ align, children, position, ...props }: CardBadgeProps): JSX.Element;
|
|
67
|
-
|
|
70
|
+
slot: {
|
|
68
71
|
name: string;
|
|
69
72
|
};
|
|
70
73
|
};
|
|
71
74
|
Body: {
|
|
72
75
|
({ children }: CardBodyProps): JSX.Element;
|
|
73
|
-
|
|
76
|
+
slot: {
|
|
74
77
|
name: string;
|
|
75
78
|
};
|
|
76
79
|
};
|
|
77
80
|
Image: {
|
|
78
81
|
(props: CardImageProps): import("react/jsx-runtime").JSX.Element;
|
|
79
|
-
|
|
82
|
+
slot: {
|
|
80
83
|
name: string;
|
|
81
84
|
};
|
|
82
85
|
};
|
|
83
86
|
};
|
|
87
|
+
declare const CardHeading: {
|
|
88
|
+
({ as, children, className }: CardHeadingProps): JSX.Element;
|
|
89
|
+
slot: {
|
|
90
|
+
name: string;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
declare const CardLabel: {
|
|
94
|
+
({ children, className }: CardLabelProps): JSX.Element;
|
|
95
|
+
slot: {
|
|
96
|
+
name: string;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
declare const CardBadge: {
|
|
100
|
+
({ align, children, position, ...props }: CardBadgeProps): JSX.Element;
|
|
101
|
+
slot: {
|
|
102
|
+
name: string;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
declare const CardBody: {
|
|
106
|
+
({ children }: CardBodyProps): JSX.Element;
|
|
107
|
+
slot: {
|
|
108
|
+
name: string;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
declare const CardImage: {
|
|
112
|
+
(props: CardImageProps): import("react/jsx-runtime").JSX.Element;
|
|
113
|
+
slot: {
|
|
114
|
+
name: string;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
84
117
|
export default Card;
|
|
118
|
+
export { Card, CardBadge, CardBody, CardHeading, CardImage, CardLabel };
|
|
@@ -55,15 +55,16 @@ const CardImage = (props) => {
|
|
|
55
55
|
var _a;
|
|
56
56
|
return jsx(Image, { ...props, crop: (_a = props.crop) !== null && _a !== void 0 ? _a : "wide" });
|
|
57
57
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
Card.slot = { name: "Card" };
|
|
59
|
+
CardLabel.slot = { name: "CardLabel" };
|
|
60
|
+
CardHeading.slot = { name: "CardHeading" };
|
|
61
|
+
CardBadge.slot = { name: "CardBadge" };
|
|
62
|
+
CardBody.slot = { name: "CardBody" };
|
|
63
|
+
CardImage.slot = { name: "CardImage" };
|
|
63
64
|
Card.Label = CardLabel;
|
|
64
65
|
Card.Heading = CardHeading;
|
|
65
66
|
Card.Badge = CardBadge;
|
|
66
67
|
Card.Body = CardBody;
|
|
67
68
|
Card.Image = CardImage;
|
|
68
69
|
|
|
69
|
-
export { Card, Card as default };
|
|
70
|
+
export { Card, CardBadge, CardBody, CardHeading, CardImage, CardLabel, Card as default };
|
|
@@ -16,11 +16,13 @@ export interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement
|
|
|
16
16
|
/** **(Optional)** Specify the Checkbox size. */
|
|
17
17
|
size?: StandardSizes;
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
declare const Checkbox: {
|
|
20
20
|
({ className, disabled, error, id, name, ref, size, ...props }: CheckboxProps): JSX.Element;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
slot: {
|
|
22
|
+
field: boolean;
|
|
23
|
+
inline: boolean;
|
|
24
|
+
name: string;
|
|
24
25
|
};
|
|
25
26
|
};
|
|
26
27
|
export default Checkbox;
|
|
28
|
+
export { Checkbox };
|
|
@@ -1,24 +1,27 @@
|
|
|
1
|
+
|
|
2
|
+
"use client";
|
|
1
3
|
import { jsx } from 'react/jsx-runtime';
|
|
2
4
|
import clsx from 'clsx';
|
|
3
|
-
import {
|
|
5
|
+
import { useField } from '../Field/Field.context.js';
|
|
4
6
|
|
|
5
7
|
const Checkbox = ({ className, disabled, error = false, id, name, ref, size, ...props }) => {
|
|
6
|
-
const
|
|
8
|
+
const field = useField();
|
|
7
9
|
const componentProps = {
|
|
8
10
|
className: clsx("coop-checkbox", "coop-field-element", className),
|
|
9
11
|
"data-error": error || undefined,
|
|
10
12
|
"data-size": size !== null && size !== void 0 ? size : undefined,
|
|
11
13
|
disabled,
|
|
12
|
-
id:
|
|
14
|
+
id: id !== null && id !== void 0 ? id : field === null || field === void 0 ? void 0 : field.id,
|
|
13
15
|
name,
|
|
14
16
|
type: "checkbox",
|
|
15
17
|
...props,
|
|
16
18
|
};
|
|
17
19
|
return jsx("input", { ...componentProps, ref: ref });
|
|
18
20
|
};
|
|
19
|
-
Checkbox.
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
Checkbox.slot = {
|
|
22
|
+
field: true,
|
|
23
|
+
inline: true,
|
|
24
|
+
name: "Checkbox",
|
|
22
25
|
};
|
|
23
26
|
|
|
24
27
|
export { Checkbox, Checkbox as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { InputHTMLAttributes, JSX, Ref } from "react";
|
|
2
2
|
import type { DayPickerProps, Mode } from "react-day-picker";
|
|
3
|
-
import type {
|
|
3
|
+
import type { StandardSizes } from "../../types";
|
|
4
4
|
import type { DateRange } from "./datepicker-utils";
|
|
5
5
|
type OnDateSelectHandler = (selected: string | string[] | {
|
|
6
6
|
from?: string;
|
|
@@ -55,8 +55,13 @@ export interface DatePickerProps extends Omit<InputHTMLAttributes<HTMLInputEleme
|
|
|
55
55
|
*/
|
|
56
56
|
startDate?: Date;
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
declare const DatePicker: {
|
|
59
59
|
({ className, closeOnSelect, dateFormat, disabled, disabledDates, endDate, error, id, initialDate, initialSelected, mode, name, onChange, onSelect, ref, required, size, startDate, ...props }: DatePickerProps): JSX.Element;
|
|
60
|
-
|
|
60
|
+
slot: {
|
|
61
|
+
field: boolean;
|
|
62
|
+
name: string;
|
|
63
|
+
suffix: string;
|
|
64
|
+
};
|
|
61
65
|
};
|
|
62
66
|
export default DatePicker;
|
|
67
|
+
export { DatePicker };
|
|
@@ -4,8 +4,8 @@ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { useMemo, useReducer, useCallback } from 'react';
|
|
6
6
|
import { DayPicker } from 'react-day-picker';
|
|
7
|
-
import { useId } from '../../hooks/useId.js';
|
|
8
7
|
import { Button } from '../Button/Button.js';
|
|
8
|
+
import { useField } from '../Field/Field.context.js';
|
|
9
9
|
import { CalendarIcon } from '../icons/CalendarIcon.js';
|
|
10
10
|
import { CrossIcon } from '../icons/CrossIcon.js';
|
|
11
11
|
import { TickIcon } from '../icons/TickIcon.js';
|
|
@@ -14,10 +14,6 @@ import { TextInput } from '../TextInput/TextInput.js';
|
|
|
14
14
|
import { getInitialDate, getStartDate, getEndDate, getDefaultMonth, getDateValues, shouldClose, shouldSkipParsing } from './datepicker-utils.js';
|
|
15
15
|
|
|
16
16
|
const now = new Date();
|
|
17
|
-
const componentConfig = {
|
|
18
|
-
fieldSuffix: "_display",
|
|
19
|
-
isField: true,
|
|
20
|
-
};
|
|
21
17
|
const baseValueProps = {
|
|
22
18
|
readOnly: true,
|
|
23
19
|
type: "hidden",
|
|
@@ -42,7 +38,7 @@ const Calendar = ({ captionLayout = "label", className, disabled, endMonth, form
|
|
|
42
38
|
};
|
|
43
39
|
const DatePicker = ({ className, closeOnSelect = true, dateFormat = "dd/MM/yyyy", disabled, disabledDates, endDate, error = false, id, initialDate = now, initialSelected = false, mode = "single", name, onChange, onSelect, ref, required = false, size, startDate, ...props }) => {
|
|
44
40
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
45
|
-
const
|
|
41
|
+
const field = useField();
|
|
46
42
|
initialDate = getInitialDate(mode, initialDate);
|
|
47
43
|
const startDateProp = startDate;
|
|
48
44
|
const endDateProp = endDate;
|
|
@@ -113,7 +109,7 @@ const DatePicker = ({ className, closeOnSelect = true, dateFormat = "dd/MM/yyyy"
|
|
|
113
109
|
};
|
|
114
110
|
const valueProps = {
|
|
115
111
|
...baseValueProps,
|
|
116
|
-
id:
|
|
112
|
+
id: id !== null && id !== void 0 ? id : field === null || field === void 0 ? void 0 : field.id,
|
|
117
113
|
name: name,
|
|
118
114
|
};
|
|
119
115
|
const getPlaceholder = () => {
|
|
@@ -127,9 +123,9 @@ const DatePicker = ({ className, closeOnSelect = true, dateFormat = "dd/MM/yyyy"
|
|
|
127
123
|
return lowerCaseDateFormat;
|
|
128
124
|
}
|
|
129
125
|
};
|
|
130
|
-
return (jsxs("div", { ...componentProps, children: [jsxs(Popover, { onOpenChange: setOpen, open: state.open, children: [jsx(Popover.Anchor, { className: "coop-datepicker-inner", children: jsx(TextInput, { autoComplete: "off", className: "coop-datepicker-input", disabled: disabled, id:
|
|
126
|
+
return (jsxs("div", { ...componentProps, children: [jsxs(Popover, { onOpenChange: setOpen, open: state.open, children: [jsx(Popover.Anchor, { className: "coop-datepicker-inner", children: jsx(TextInput, { autoComplete: "off", className: "coop-datepicker-input", disabled: disabled, id: valueProps.id + "_display",
|
|
131
127
|
//maxLength={dateFormat.length}
|
|
132
|
-
name: name +
|
|
128
|
+
name: name + "_display", onChange: updateFromInput, placeholder: getPlaceholder(), ref: ref, required: required, size: size, suffix: disabled ? (jsx("span", { className: "coop-datepicker-trigger", children: jsx(CalendarIcon, { width: 24 }) })) : (jsx(Popover.Trigger, { "aria-label": "Choose date", className: "coop-datepicker-trigger", children: jsx(CalendarIcon, { width: 24 }) })), suffixInline: true, value: (_f = (_e = state === null || state === void 0 ? void 0 : state[mode]) === null || _e === void 0 ? void 0 : _e.input) !== null && _f !== void 0 ? _f : "" }) }), jsxs(Popover.Content, { "aria-label": "Date picker", className: "coop-datepicker-calendar bg-white", collisionPadding: 16, sideOffset: 4, children: [jsx(Calendar
|
|
133
129
|
// jsx-ally throws here because we set autoFocus, but this
|
|
134
130
|
// is not a standard element. Daypicker uses this value to
|
|
135
131
|
// focus the day rather than the nav when it renders.
|
|
@@ -141,8 +137,12 @@ const DatePicker = ({ className, closeOnSelect = true, dateFormat = "dd/MM/yyyy"
|
|
|
141
137
|
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
142
138
|
autoFocus: true, captionLayout: "dropdown",
|
|
143
139
|
//defaultMonth={defaultMonth}
|
|
144
|
-
disabled: disabledDates, endMonth: endDate, month: state.view, onMonthChange: setView, onSelect: updateValues, startMonth: startDate, ...calendarProps[mode] }), jsxs("div", { className: "coop-datepicker-actions", children: [jsxs(Button, { "aria-label": "Cancel", className: "bg-tint-grey", onClick: resetState, size: "sm", children: ["Clear ", jsx(CrossIcon, { stroke: "black", strokeWidth: 1 })] }), jsx(Popover.Close, { asChild: true, children: jsxs(Button, { "aria-label": "Accept", size: "sm", children: ["OK ", jsx(TickIcon, { stroke: "white", strokeWidth: 1 })] }) })] })] })] }), jsx("div", { "aria-live": "assertive", className: "sr-only coop-datepicker-status", role: "status", children: (_g = state.message) !== null && _g !== void 0 ? _g : footerMessage[mode] }), mode === "single" && (jsx("input", { ...valueProps, value: (_l = (_j = (_h = state.single) === null || _h === void 0 ? void 0 : _h.field) !== null && _j !== void 0 ? _j : (_k = state.single) === null || _k === void 0 ? void 0 : _k.input) !== null && _l !== void 0 ? _l : "" })), mode === "multiple" && (jsx("input", { ...valueProps, value: (_q = (_o = (_m = state.multiple) === null || _m === void 0 ? void 0 : _m.field) !== null && _o !== void 0 ? _o : (_p = state.multiple) === null || _p === void 0 ? void 0 : _p.input) !== null && _q !== void 0 ? _q : "" })), mode === "range" && (jsxs(Fragment, { children: [jsx("input", { ...baseValueProps, id: `${
|
|
140
|
+
disabled: disabledDates, endMonth: endDate, month: state.view, onMonthChange: setView, onSelect: updateValues, startMonth: startDate, ...calendarProps[mode] }), jsxs("div", { className: "coop-datepicker-actions", children: [jsxs(Button, { "aria-label": "Cancel", className: "bg-tint-grey", onClick: resetState, size: "sm", children: ["Clear ", jsx(CrossIcon, { stroke: "black", strokeWidth: 1 })] }), jsx(Popover.Close, { asChild: true, children: jsxs(Button, { "aria-label": "Accept", size: "sm", children: ["OK ", jsx(TickIcon, { stroke: "white", strokeWidth: 1 })] }) })] })] })] }), jsx("div", { "aria-live": "assertive", className: "sr-only coop-datepicker-status", role: "status", children: (_g = state.message) !== null && _g !== void 0 ? _g : footerMessage[mode] }), mode === "single" && (jsx("input", { ...valueProps, value: (_l = (_j = (_h = state.single) === null || _h === void 0 ? void 0 : _h.field) !== null && _j !== void 0 ? _j : (_k = state.single) === null || _k === void 0 ? void 0 : _k.input) !== null && _l !== void 0 ? _l : "" })), mode === "multiple" && (jsx("input", { ...valueProps, value: (_q = (_o = (_m = state.multiple) === null || _m === void 0 ? void 0 : _m.field) !== null && _o !== void 0 ? _o : (_p = state.multiple) === null || _p === void 0 ? void 0 : _p.input) !== null && _q !== void 0 ? _q : "" })), mode === "range" && (jsxs(Fragment, { children: [jsx("input", { ...baseValueProps, id: `${valueProps.id}_start`, name: `${name}_start`, value: (_v = (_t = (_s = (_r = state.range) === null || _r === void 0 ? void 0 : _r.field) === null || _s === void 0 ? void 0 : _s.from) !== null && _t !== void 0 ? _t : (_u = state.range) === null || _u === void 0 ? void 0 : _u.input) !== null && _v !== void 0 ? _v : "" }), jsx("input", { ...baseValueProps, id: `${valueProps.id}_end`, name: `${name}_end`, value: (_0 = (_y = (_x = (_w = state.range) === null || _w === void 0 ? void 0 : _w.field) === null || _x === void 0 ? void 0 : _x.to) !== null && _y !== void 0 ? _y : (_z = state.range) === null || _z === void 0 ? void 0 : _z.input) !== null && _0 !== void 0 ? _0 : "" })] }))] }));
|
|
141
|
+
};
|
|
142
|
+
DatePicker.slot = {
|
|
143
|
+
field: true,
|
|
144
|
+
name: "DatePicker",
|
|
145
|
+
suffix: "_display",
|
|
145
146
|
};
|
|
146
|
-
DatePicker.config = componentConfig;
|
|
147
147
|
|
|
148
148
|
export { DatePicker, DatePicker as default };
|
|
@@ -19,19 +19,35 @@ interface ExpandableContentProps extends HTMLAttributes<HTMLElement> {
|
|
|
19
19
|
/** **(Optional)** Specify additional CSS classes to be applied to the content wrapper. */
|
|
20
20
|
className?: string;
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
declare const Expandable: {
|
|
23
23
|
({ children, className, ref, ...props }: ExpandableProps): JSX.Element;
|
|
24
|
+
slot: {
|
|
25
|
+
name: string;
|
|
26
|
+
};
|
|
24
27
|
Summary: {
|
|
25
28
|
({ children, className, ...props }: ExpandableSummaryProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
-
|
|
29
|
+
slot: {
|
|
27
30
|
name: string;
|
|
28
31
|
};
|
|
29
32
|
};
|
|
30
33
|
Content: {
|
|
31
34
|
({ children, className, ...props }: ExpandableContentProps): import("react/jsx-runtime").JSX.Element;
|
|
32
|
-
|
|
35
|
+
slot: {
|
|
33
36
|
name: string;
|
|
34
37
|
};
|
|
35
38
|
};
|
|
36
39
|
};
|
|
40
|
+
declare const ExpandableSummary: {
|
|
41
|
+
({ children, className, ...props }: ExpandableSummaryProps): import("react/jsx-runtime").JSX.Element;
|
|
42
|
+
slot: {
|
|
43
|
+
name: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
declare const ExpandableContent: {
|
|
47
|
+
({ children, className, ...props }: ExpandableContentProps): import("react/jsx-runtime").JSX.Element;
|
|
48
|
+
slot: {
|
|
49
|
+
name: string;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
37
52
|
export default Expandable;
|
|
53
|
+
export { Expandable, ExpandableContent, ExpandableSummary };
|
|
@@ -26,9 +26,10 @@ const ExpandableSummary = ({ children, className, ...props }) => {
|
|
|
26
26
|
const ExpandableContent = ({ children, className, ...props }) => {
|
|
27
27
|
return (jsx("div", { className: clsx("coop-expandable--content", className), ...props, children: children }));
|
|
28
28
|
};
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
Expandable.slot = { name: "Expandable" };
|
|
30
|
+
ExpandableSummary.slot = { name: "ExpandableSummary" };
|
|
31
|
+
ExpandableContent.slot = { name: "ExpandableContent" };
|
|
31
32
|
Expandable.Summary = ExpandableSummary;
|
|
32
33
|
Expandable.Content = ExpandableContent;
|
|
33
34
|
|
|
34
|
-
export { Expandable, Expandable as default };
|
|
35
|
+
export { Expandable, ExpandableContent, ExpandableSummary, Expandable as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface FieldConfig {
|
|
2
|
+
disabled: boolean;
|
|
3
|
+
id: string;
|
|
4
|
+
inline?: boolean;
|
|
5
|
+
suffix?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface FieldContextValue {
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
id?: string;
|
|
10
|
+
inline?: boolean;
|
|
11
|
+
suffix?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const FieldContext: import("react").Context<FieldContextValue | null>;
|
|
14
|
+
export declare const useField: () => FieldContextValue | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
"use client";
|
|
3
|
+
import { createContext, useContext } from 'react';
|
|
4
|
+
|
|
5
|
+
const FieldContext = createContext(null);
|
|
6
|
+
const useField = () => {
|
|
7
|
+
const context = useContext(FieldContext);
|
|
8
|
+
if (!context) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
return context;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { FieldContext, useField };
|
|
@@ -19,25 +19,47 @@ interface FieldProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
19
19
|
/** **(Optional)** Specify a custom React ref for this component. */
|
|
20
20
|
ref?: Ref<HTMLDivElement>;
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
declare const Field: {
|
|
23
23
|
({ boxed, children, className, error, hideErrorBar, ref, ...props }: FieldProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
slot: {
|
|
25
|
+
name: string;
|
|
26
|
+
};
|
|
24
27
|
Label: {
|
|
25
28
|
(props: LabelProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
-
|
|
29
|
+
slot: {
|
|
27
30
|
name: string;
|
|
28
31
|
};
|
|
29
32
|
};
|
|
30
33
|
Hint: {
|
|
31
34
|
(props: HintProps): import("react/jsx-runtime").JSX.Element;
|
|
32
|
-
|
|
35
|
+
slot: {
|
|
33
36
|
name: string;
|
|
34
37
|
};
|
|
35
38
|
};
|
|
36
39
|
Error: {
|
|
37
40
|
(props: ErrorProps): import("react/jsx-runtime").JSX.Element;
|
|
38
|
-
|
|
41
|
+
slot: {
|
|
39
42
|
name: string;
|
|
40
43
|
};
|
|
41
44
|
};
|
|
42
45
|
};
|
|
46
|
+
declare const FieldLabel: {
|
|
47
|
+
(props: LabelProps): import("react/jsx-runtime").JSX.Element;
|
|
48
|
+
slot: {
|
|
49
|
+
name: string;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
declare const FieldHint: {
|
|
53
|
+
(props: HintProps): import("react/jsx-runtime").JSX.Element;
|
|
54
|
+
slot: {
|
|
55
|
+
name: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
declare const FieldError: {
|
|
59
|
+
(props: ErrorProps): import("react/jsx-runtime").JSX.Element;
|
|
60
|
+
slot: {
|
|
61
|
+
name: string;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
43
64
|
export default Field;
|
|
65
|
+
export { Field, FieldError, FieldHint, FieldLabel };
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
"use client";
|
|
3
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
4
|
import clsx from 'clsx';
|
|
3
|
-
import React from 'react';
|
|
4
5
|
import { useId } from '../../hooks/useId.js';
|
|
5
6
|
import { useSlots } from '../../hooks/useSlots.js';
|
|
7
|
+
import { getSlotProp } from '../../utils/index.js';
|
|
6
8
|
import { Error } from '../FieldMarkers/Error.js';
|
|
7
9
|
import { Hint } from '../FieldMarkers/Hint.js';
|
|
8
10
|
import { Label } from '../FieldMarkers/Label.js';
|
|
11
|
+
import { FieldContext } from './Field.context.js';
|
|
9
12
|
|
|
10
13
|
const componentSlots = {
|
|
11
14
|
Children: null,
|
|
@@ -15,57 +18,53 @@ const componentSlots = {
|
|
|
15
18
|
FieldLabel: null,
|
|
16
19
|
};
|
|
17
20
|
const Field = ({ boxed = false, children, className, error = false, hideErrorBar = false, ref, ...props }) => {
|
|
18
|
-
var _a, _b
|
|
21
|
+
var _a, _b;
|
|
19
22
|
const slots = { ...useSlots(componentSlots, children) };
|
|
20
23
|
const hasMarkers = !!((_b = (_a = slots.FieldLabel) !== null && _a !== void 0 ? _a : slots.FieldError) !== null && _b !== void 0 ? _b : slots.FieldHint);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
const internalId = useId();
|
|
25
|
+
const controlProps = {
|
|
26
|
+
disabled: false,
|
|
27
|
+
id: internalId,
|
|
28
|
+
};
|
|
26
29
|
if (Array.isArray(slots.Children)) {
|
|
27
30
|
slots.Children = slots.Children.filter((child) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
//resolveComponentName(child)
|
|
32
|
+
var _a, _b, _c, _d;
|
|
33
|
+
if (child && typeof child === "object" && "type" in child) {
|
|
34
|
+
if (typeof (child === null || child === void 0 ? void 0 : child.type) === "function" && "slot" in child.type) {
|
|
35
|
+
const { slot } = child === null || child === void 0 ? void 0 : child.type;
|
|
36
|
+
slots.Control = child;
|
|
37
|
+
if (slots.Control.props) {
|
|
38
|
+
controlProps.inline = (_a = slot.inline) !== null && _a !== void 0 ? _a : false;
|
|
39
|
+
controlProps.disabled = (_b = getSlotProp(slots.Control, "disabled")) !== null && _b !== void 0 ? _b : false;
|
|
40
|
+
controlProps.id = (_c = getSlotProp(slots.Control, "id")) !== null && _c !== void 0 ? _c : controlProps.id;
|
|
41
|
+
controlProps.suffix = (_d = slot.suffix) !== null && _d !== void 0 ? _d : undefined;
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
32
45
|
}
|
|
33
46
|
return true;
|
|
34
47
|
});
|
|
35
48
|
}
|
|
36
|
-
if (React.isValidElement(control)) {
|
|
37
|
-
const controlProps = control.props;
|
|
38
|
-
controlId = (_c = controlProps.id) !== null && _c !== void 0 ? _c : controlId;
|
|
39
|
-
controlDisabled = (_d = controlProps.disabled) !== null && _d !== void 0 ? _d : false;
|
|
40
|
-
controlSuffix = (_g = (_f = (_e = control === null || control === void 0 ? void 0 : control.type) === null || _e === void 0 ? void 0 : _e.config) === null || _f === void 0 ? void 0 : _f.fieldSuffix) !== null && _g !== void 0 ? _g : "";
|
|
41
|
-
isInline = (_k = (_j = (_h = control === null || control === void 0 ? void 0 : control.type) === null || _h === void 0 ? void 0 : _h.config) === null || _j === void 0 ? void 0 : _j.isInline) !== null && _k !== void 0 ? _k : false;
|
|
42
|
-
slots.Control = controlProps.id
|
|
43
|
-
? control
|
|
44
|
-
: React.cloneElement(control, { id: controlId });
|
|
45
|
-
}
|
|
46
|
-
if (React.isValidElement(slots.FieldLabel) && !slots.FieldLabel.props.htmlFor) {
|
|
47
|
-
slots.FieldLabel = React.cloneElement(slots.FieldLabel, {
|
|
48
|
-
htmlFor: controlId + controlSuffix,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
49
|
const componentProps = {
|
|
52
50
|
...props,
|
|
53
|
-
"aria-disabled":
|
|
54
|
-
className: clsx("coop-field",
|
|
51
|
+
"aria-disabled": controlProps.disabled || undefined,
|
|
52
|
+
className: clsx("coop-field", controlProps.inline && "coop-field-inline", className),
|
|
55
53
|
"data-boxed": boxed || undefined,
|
|
56
54
|
"data-error": error || undefined,
|
|
57
55
|
"data-hide-error": hideErrorBar || undefined,
|
|
58
56
|
};
|
|
59
|
-
return (jsxs("div", { ...componentProps, ref: ref, children: [!
|
|
57
|
+
return (jsx(FieldContext.Provider, { value: { ...controlProps }, children: jsxs("div", { ...componentProps, ref: ref, children: [!(controlProps === null || controlProps === void 0 ? void 0 : controlProps.inline) && hasMarkers && (jsxs("div", { className: "coop-field-markers", children: [slots.FieldLabel, slots.FieldHint, slots.FieldError] })), slots.Control && (jsxs("div", { className: "coop-field-control", children: [slots.Control, (controlProps === null || controlProps === void 0 ? void 0 : controlProps.inline) && hasMarkers && (jsxs("div", { className: "coop-field-markers", children: [slots.FieldLabel, slots.FieldHint, slots.FieldError] }))] })), slots.Children] }) }));
|
|
60
58
|
};
|
|
61
59
|
const FieldLabel = (props) => jsx(Label, { ...props });
|
|
62
60
|
const FieldHint = (props) => jsx(Hint, { ...props });
|
|
63
61
|
const FieldError = (props) => jsx(Error, { ...props });
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
Field.slot = { name: "Field" };
|
|
63
|
+
FieldLabel.slot = { name: "FieldLabel" };
|
|
64
|
+
FieldHint.slot = { name: "FieldHint" };
|
|
65
|
+
FieldError.slot = { name: "FieldError" };
|
|
67
66
|
Field.Label = FieldLabel;
|
|
68
67
|
Field.Hint = FieldHint;
|
|
69
68
|
Field.Error = FieldError;
|
|
70
69
|
|
|
71
|
-
export { Field, Field as default };
|
|
70
|
+
export { Field, FieldError, FieldHint, FieldLabel, Field as default };
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
+
import { useField } from '../Field/Field.context.js';
|
|
3
4
|
|
|
4
5
|
const Label = ({ children, className, isVisible = true, ref, ...props }) => {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
const field = useField();
|
|
5
8
|
const componentProps = {
|
|
6
9
|
className: clsx("coop-field-label", !isVisible && "sr-only", className),
|
|
10
|
+
htmlFor: (_a = props.htmlFor) !== null && _a !== void 0 ? _a : ((field === null || field === void 0 ? void 0 : field.id) ? field.id + ((_b = field === null || field === void 0 ? void 0 : field.suffix) !== null && _b !== void 0 ? _b : "") : undefined),
|
|
7
11
|
...props,
|
|
8
12
|
};
|
|
9
13
|
return (jsx("label", { ...componentProps, ref: ref, children: jsx("span", { children: children }) }));
|