@mrshmllw/smores-react 2.1.22 → 2.1.25
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/README.md +2 -1
- package/dist/ActionDropdown/ActionDropdown.d.ts +1 -3
- package/dist/ActionDropdown/ActionDropdown.js.map +1 -1
- package/dist/Button/Button.js +12 -4
- package/dist/Button/Button.js.map +1 -1
- package/dist/CheckBox/CheckBox.d.ts +1 -1
- package/dist/CheckBox/CheckBox.js +10 -6
- package/dist/CheckBox/CheckBox.js.map +1 -1
- package/dist/CheckBox/index.d.ts +1 -1
- package/dist/CheckBox/index.js.map +1 -1
- package/dist/CheckBoxGroup/CheckBox.js +1 -1
- package/dist/ConfirmationRadioButtons/Confirmation.d.ts +2 -1
- package/dist/ConfirmationRadioButtons/Confirmation.js +9 -2
- package/dist/ConfirmationRadioButtons/Confirmation.js.map +1 -1
- package/dist/ConfirmationRadioButtons/Confirmation.stories.d.ts +1 -0
- package/dist/ConfirmationRadioButtons/Confirmation.stories.js +8 -0
- package/dist/ConfirmationRadioButtons/Confirmation.stories.js.map +1 -1
- package/dist/Datepicker/Datepicker.js +29 -57
- package/dist/Datepicker/Datepicker.js.map +1 -1
- package/dist/Datepicker/DatesList.d.ts +1 -0
- package/dist/Datepicker/DatesList.js +13 -1
- package/dist/Datepicker/DatesList.js.map +1 -1
- package/dist/Datepicker/types.d.ts +0 -4
- package/dist/Dropdown/Dropdown.d.ts +13 -5
- package/dist/Dropdown/Dropdown.js +7 -4
- package/dist/Dropdown/Dropdown.js.map +1 -1
- package/dist/Dropdown/Dropdown.stories.d.ts +44 -2
- package/dist/Dropdown/Dropdown.stories.js +9 -0
- package/dist/Dropdown/Dropdown.stories.js.map +1 -1
- package/dist/Message/Message.d.ts +3 -0
- package/dist/Message/Message.js +14 -5
- package/dist/Message/Message.js.map +1 -1
- package/dist/Message/Message.stories.js +1 -1
- package/dist/Message/Message.stories.js.map +1 -1
- package/dist/NumberInput/NumberInput.d.ts +1 -3
- package/dist/NumberInput/NumberInput.js +3 -1
- package/dist/NumberInput/NumberInput.js.map +1 -1
- package/dist/Pagination/Pagination.js +1 -2
- package/dist/Pagination/Pagination.js.map +1 -1
- package/dist/RadioButton/RadioButton.d.ts +1 -1
- package/dist/RadioButton/RadioButton.js +9 -5
- package/dist/RadioButton/RadioButton.js.map +1 -1
- package/dist/SearchInput/SearchInput.d.ts +1 -2
- package/dist/SearchInput/SearchInput.js +5 -1
- package/dist/SearchInput/SearchInput.js.map +1 -1
- package/dist/SupportMessage/Collection.d.ts +2 -0
- package/dist/SupportMessage/Collection.js +40 -0
- package/dist/SupportMessage/Collection.js.map +1 -0
- package/dist/SupportMessage/SupportMessage.d.ts +10 -0
- package/dist/SupportMessage/SupportMessage.js +59 -0
- package/dist/SupportMessage/SupportMessage.js.map +1 -0
- package/dist/SupportMessage/SupportMessage.stories.d.ts +9 -0
- package/dist/SupportMessage/SupportMessage.stories.js +17 -0
- package/dist/SupportMessage/SupportMessage.stories.js.map +1 -0
- package/dist/SupportMessage/SupportMessage.test.d.ts +1 -0
- package/dist/SupportMessage/SupportMessage.test.js +30 -0
- package/dist/SupportMessage/SupportMessage.test.js.map +1 -0
- package/dist/SupportMessage/index.d.ts +1 -0
- package/dist/SupportMessage/index.js +2 -0
- package/dist/SupportMessage/index.js.map +1 -0
- package/dist/Text/Text.stories.d.ts +1 -0
- package/dist/Text/Text.stories.js +35 -0
- package/dist/Text/Text.stories.js.map +1 -1
- package/dist/TextInput/TextInput.d.ts +5 -7
- package/dist/TextInput/TextInput.js +18 -13
- package/dist/TextInput/TextInput.js.map +1 -1
- package/dist/TextInput/TextInput.stories.d.ts +2 -1
- package/dist/TextInput/TextInput.stories.js +12 -0
- package/dist/TextInput/TextInput.stories.js.map +1 -1
- package/dist/Textarea/Textarea.d.ts +5 -7
- package/dist/Textarea/Textarea.js +17 -12
- package/dist/Textarea/Textarea.js.map +1 -1
- package/dist/Textarea/Textarea.stories.d.ts +2 -1
- package/dist/Textarea/Textarea.stories.js +10 -0
- package/dist/Textarea/Textarea.stories.js.map +1 -1
- package/dist/Toggle/Toggle.d.ts +1 -1
- package/dist/Toggle/Toggle.stories.d.ts +1 -1
- package/dist/setupTests.d.ts +1 -0
- package/dist/setupTests.js +2 -0
- package/dist/setupTests.js.map +1 -0
- package/dist/utils/date.d.ts +1 -0
- package/dist/utils/date.js +9 -0
- package/dist/utils/date.js.map +1 -0
- package/dist/utils/deprecated.d.ts +9 -0
- package/dist/utils/deprecated.js +30 -0
- package/dist/utils/deprecated.js.map +1 -0
- package/dist/utils/id.d.ts +2 -0
- package/dist/utils/id.js +13 -0
- package/dist/utils/id.js.map +1 -0
- package/dist/utils/id.test.d.ts +1 -0
- package/dist/utils/id.test.js +30 -0
- package/dist/utils/id.test.js.map +1 -0
- package/package.json +10 -7
package/README.md
CHANGED
@@ -135,12 +135,13 @@ yalc remove --all
|
|
135
135
|
* [IconWrapper](https://github.com/marshmallow-insurance/smores-react/tree/master/src/IconWrapper)
|
136
136
|
* [LabelledText](https://github.com/marshmallow-insurance/smores-react/tree/master/src/LabelledText)
|
137
137
|
* [Loader](https://github.com/marshmallow-insurance/smores-react/tree/master/src/Loader)
|
138
|
-
* [Message](https://github.com/marshmallow-insurance/smores-react/tree/master/src/Message)
|
138
|
+
* [Message](https://github.com/marshmallow-insurance/smores-react/tree/master/src/Message) (deprecated - use Support Message instead)
|
139
139
|
* [Modal](https://github.com/marshmallow-insurance/smores-react/tree/master/src/Modal)
|
140
140
|
* [NumberInput](https://github.com/marshmallow-insurance/smores-react/tree/master/src/NumberInput)
|
141
141
|
* [RadioButton](https://github.com/marshmallow-insurance/smores-react/tree/master/src/RadioButton)
|
142
142
|
* [Row](https://github.com/marshmallow-insurance/smores-react/tree/master/src/Row)
|
143
143
|
* [SearchInput](https://github.com/marshmallow-insurance/smores-react/tree/master/src/SearchInput)
|
144
|
+
* [SupportMessage](https://github.com/marshmallow-insurance/smores-react/tree/master/src/SupportMessage)
|
144
145
|
* [Tag](https://github.com/marshmallow-insurance/smores-react/tree/master/src/Tag)
|
145
146
|
* [Text](https://github.com/marshmallow-insurance/smores-react/tree/master/src/Text)
|
146
147
|
* [Textarea](https://github.com/marshmallow-insurance/smores-react/tree/master/src/Textarea)
|
@@ -1,9 +1,7 @@
|
|
1
1
|
import { FC } from 'react';
|
2
2
|
import { ActionListItem } from './List';
|
3
3
|
export declare type ActionDropdownProps = {
|
4
|
-
|
5
|
-
id: string;
|
6
|
-
/** className attribute to apply classes from props */
|
4
|
+
id?: string;
|
7
5
|
className?: string;
|
8
6
|
/** label displayed above the dropdown */
|
9
7
|
label?: string;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ActionDropdown.js","sourceRoot":"","sources":["../../src/ActionDropdown/ActionDropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAM,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAE/C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAkB,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAS,KAAK,EAAE,MAAM,UAAU,CAAA;
|
1
|
+
{"version":3,"file":"ActionDropdown.js","sourceRoot":"","sources":["../../src/ActionDropdown/ActionDropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAM,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAE/C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAkB,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAS,KAAK,E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AAI,CAAC;wBACP,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;;;;;;;;;;;;GAYrC,CACF,CAAA;AAED,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAA;;;;;CAKjC,CAAA;AAED,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;CAS3B,CAAA;AAMD,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAC/B,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,GAAG,CAAA;;;;;eAKJ,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;kBACpB,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;wBACjB,KAAK,CAAC,MAAM,CAAC,KAAK;wBAClB,KAAK,CAAC,MAAM,CAAC,OAAO;kBAC1B,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ;;;GAGvC,CACF,CAAA"}
|
package/dist/Button/Button.js
CHANGED
@@ -14,19 +14,27 @@ import styled, { css } from 'styled-components';
|
|
14
14
|
import { darken } from 'polished';
|
15
15
|
import { theme } from '../theme';
|
16
16
|
import { focusOutline } from '../utils/focusOutline';
|
17
|
+
import { useDeprecatedWarning } from '../utils/deprecated';
|
17
18
|
import { LegacyButton } from './LegacyButton';
|
18
19
|
import { Loader } from '../Loader';
|
19
20
|
import { Icon as IconComponent } from '../Icon';
|
20
|
-
export const Button = forwardRef((
|
21
|
-
|
22
|
-
|
21
|
+
export const Button = forwardRef((props, ref) => {
|
22
|
+
const { children, id, className = '', color = 'secondary', block = false, inverted = false, disabled = false, outlined = false, handleClick, loading = false, primary = false, secondary = false, tertiary = false, icon = '', forcedWidth = '', form, type } = props, otherProps = __rest(props, ["children", "id", "className", "color", "block", "inverted", "disabled", "outlined", "handleClick", "loading", "primary", "secondary", "tertiary", "icon", "forcedWidth", "form", "type"]);
|
23
|
+
const isLegacyButton = !primary && !secondary && !tertiary;
|
24
|
+
useDeprecatedWarning({
|
25
|
+
enabled: isLegacyButton,
|
26
|
+
title: 'Legacy Button',
|
27
|
+
message: "You're using the legacy Button component. Please use the new Button by providing one of the following props: 'primary', 'secondary', 'tertiary'.",
|
28
|
+
componentProps: props,
|
29
|
+
});
|
30
|
+
if (isLegacyButton) {
|
23
31
|
return (React.createElement(LegacyButton, { id: id, className: className, color: color, block: block, inverted: inverted, disabled: disabled, outlined: outlined, handleClick: (e) => {
|
24
32
|
handleClick && handleClick(e);
|
25
33
|
} }, children));
|
26
34
|
}
|
27
35
|
return (React.createElement(Container, Object.assign({ id: id, className: className, disabled: disabled || loading, onClick: (e) => {
|
28
36
|
handleClick && handleClick(e);
|
29
|
-
}, isLoading: loading, primary: primary, secondary: secondary, tertiary: tertiary, icon: icon, forcedWidth: forcedWidth }, (form ? { form } : {}), { type: type },
|
37
|
+
}, isLoading: loading, primary: primary, secondary: secondary, tertiary: tertiary, icon: icon, forcedWidth: forcedWidth }, (form ? { form } : {}), { type: type }, otherProps, { ref: ref }),
|
30
38
|
loading && (React.createElement(LoaderContainer, null,
|
31
39
|
React.createElement(Loader, { color: primary ? 'white' : 'secondary', height: "16" }))),
|
32
40
|
React.createElement(ContentContainer, { icon: icon, "$loading": loading },
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src/Button/Button.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAuC,UAAU,EAAE,MAAM,OAAO,CAAA;AAC9E,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,OAAO,EAAS,KAAK,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,MAAM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,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;CACpD,CAAA;AAED,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC,CAAA;;CAE1C,CAAA;AAED,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAA;;;CAGnC,CAAA"}
|
@@ -3,12 +3,16 @@ import styled from 'styled-components';
|
|
3
3
|
import { focusOutline } from '../utils/focusOutline';
|
4
4
|
import { Text } from '../Text';
|
5
5
|
import { theme } from '../theme';
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
React.createElement(
|
11
|
-
|
6
|
+
import { useUniqueId } from '../utils/id';
|
7
|
+
export const CheckBox = ({ id: idProp, checked, children, toggle, error, errorMsg, }) => {
|
8
|
+
const id = useUniqueId(idProp);
|
9
|
+
return (React.createElement(React.Fragment, null,
|
10
|
+
React.createElement(BoxContainer, { id: id },
|
11
|
+
React.createElement(Text, { tag: "span", typo: "base", color: error ? 'error' : 'secondary' }, children),
|
12
|
+
React.createElement("input", { type: "checkbox", checked: checked, onChange: toggle }),
|
13
|
+
React.createElement(Checkmark, { error: error })),
|
14
|
+
error && errorMsg && React.createElement(ErrorBox, null, errorMsg)));
|
15
|
+
};
|
12
16
|
const Checkmark = styled.span `
|
13
17
|
position: absolute;
|
14
18
|
left: 0;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CheckBox.js","sourceRoot":"","sources":["../../src/CheckBox/CheckBox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAA;AAC5C,OAAO,MAAM,MAAM,mBAAmB,CAAA;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEpD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;
|
1
|
+
{"version":3,"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;;;;;;;;;;;;;CAkB5C,CAAA;AAED,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAA;;;;;;;;;;;;;kBAaf,SAAS;0BACD,KAAK,CAAC,MAAM,CAAC,SAAS;0BACtB,KAAK,CAAC,MAAM,CAAC,SAAS;;;kBAG9B,SAAS;;;;MAIrB,YAAY,CAAC,EAAE,QAAQ,EAAE,qBAAqB,SAAS,EAAE,EAAE,CAAC;;;;MAI5D,SAAS;0BACW,KAAK,CAAC,MAAM,CAAC,UAAU;0BACvB,KAAK,CAAC,MAAM,CAAC,SAAS;;;;;;;CAO/C,CAAA;AAED,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAA;;;WAGjB,KAAK,CAAC,MAAM,CAAC,KAAK;CAC5B,CAAA"}
|
package/dist/CheckBox/index.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export { CheckBox } from './CheckBox';
|
1
|
+
export { CheckBox, CheckBoxProps } from './CheckBox';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/CheckBox/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/CheckBox/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAiB,MAAM,YAAY,CAAA"}
|
@@ -2,7 +2,7 @@ import { FC, FormEvent, ReactElement } from 'react';
|
|
2
2
|
export declare type ConfirmationProps = {
|
3
3
|
onChange(value?: boolean): void;
|
4
4
|
checked?: boolean;
|
5
|
-
id
|
5
|
+
id?: string;
|
6
6
|
error?: boolean;
|
7
7
|
errorMsg?: string;
|
8
8
|
label?: string;
|
@@ -10,5 +10,6 @@ export declare type ConfirmationProps = {
|
|
10
10
|
sublabel?: string | ReactElement;
|
11
11
|
yesLabel?: string | ReactElement;
|
12
12
|
noLabel?: string | ReactElement;
|
13
|
+
required?: boolean;
|
13
14
|
};
|
14
15
|
export declare const Confirmation: FC<ConfirmationProps>;
|
@@ -4,10 +4,14 @@ import { theme } from '../theme';
|
|
4
4
|
import { Box } from '../Box';
|
5
5
|
import { Text } from '../Text';
|
6
6
|
import { RadioButton } from './RadioButtonStyled';
|
7
|
-
|
7
|
+
import { useUniqueId } from '../utils/id';
|
8
|
+
export const Confirmation = ({ checked, onChange, id: idProp, error = false, errorMsg = '', label, onBlur, sublabel, yesLabel = 'Yes', noLabel = 'No', required = false, }) => {
|
9
|
+
const id = useUniqueId(idProp);
|
8
10
|
return (React.createElement(ConfirmationWrapper, null,
|
9
11
|
(label || sublabel) && (React.createElement(TextWrapper, null,
|
10
|
-
|
12
|
+
React.createElement(LabelWrapper, null,
|
13
|
+
label && React.createElement(SectionHeadingText, { tag: "h3" }, label),
|
14
|
+
required && (React.createElement(Text, { tag: "p", typo: "base-small", color: "error" }, "*"))),
|
11
15
|
sublabel && (React.createElement(Text, { tag: "p", typo: "base-small", color: "subtext" }, sublabel)))),
|
12
16
|
React.createElement(RadioButtonGroupWrapper, null,
|
13
17
|
React.createElement(RadioButtonGroup, null,
|
@@ -66,4 +70,7 @@ const TextWrapper = styled.div `
|
|
66
70
|
display: flex;
|
67
71
|
flex-direction: column;
|
68
72
|
`;
|
73
|
+
const LabelWrapper = styled.div `
|
74
|
+
display: flex;
|
75
|
+
`;
|
69
76
|
//# sourceMappingURL=Confirmation.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Confirmation.js","sourceRoot":"","sources":["../../src/ConfirmationRadioButtons/Confirmation.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAA;AAC1D,OAAO,MAAM,MAAM,mBAAmB,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAChC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,WAAW,EAAa,MA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W;sBAC1B,CAAC,EAAE,OAAO,EAAa,EAAE,EAAE,CAC7C,CAAC,OAAO,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE;YAChC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAa,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC;;;;;;;;;CAStE,CAAA;AAED,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAA;;;;WAIjB,KAAK,CAAC,MAAM,CAAC,KAAK;CAC5B,CAAA;AAED,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;;;;CAItC,CAAA;AAED,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;CAEtC,CAAA;AAED,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAA;;;CAG7B,CAAA;AAED,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAA;;CAE9B,CAAA"}
|
@@ -49,4 +49,12 @@ WithNoLabel.args = {
|
|
49
49
|
checked: undefined,
|
50
50
|
yesLabel: 'Yes',
|
51
51
|
};
|
52
|
+
export const Required = Template.bind({});
|
53
|
+
Required.args = {
|
54
|
+
id: 'radioButton',
|
55
|
+
label: 'Do you like ice cream?',
|
56
|
+
onChange: noop,
|
57
|
+
checked: undefined,
|
58
|
+
required: true,
|
59
|
+
};
|
52
60
|
//# sourceMappingURL=Confirmation.stories.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Confirmation.stories.js","sourceRoot":"","sources":["../../src/ConfirmationRadioButtons/Confirmation.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACpC,OAAO,EAAE,YAAY,EAAqB,MAAM,gBAAgB,CAAA;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,eAAe;IACb,KAAK,EAAE,2B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"}
|
@@ -1,88 +1,60 @@
|
|
1
|
-
import React, { useState
|
1
|
+
import React, { useState } from 'react';
|
2
2
|
import styled from 'styled-components';
|
3
|
-
import { format, addDays,
|
3
|
+
import { format, addDays, getMonth, getYear, eachMonthOfInterval, isSameDay, isWithinInterval, getDaysInMonth, isWeekend, } from 'date-fns';
|
4
4
|
import { Box } from '../Box';
|
5
5
|
import { Text } from '../Text';
|
6
6
|
import { Icon } from '../Icon';
|
7
7
|
import { theme } from '../theme';
|
8
8
|
import { DatesList } from './DatesList';
|
9
|
+
import { convertToUkDate } from '../utils/date';
|
10
|
+
const getAvailableMonths = (startDate, endDate) => {
|
11
|
+
const monthList = eachMonthOfInterval({
|
12
|
+
start: startDate,
|
13
|
+
end: endDate,
|
14
|
+
});
|
15
|
+
return monthList.map((monthDate) => ({
|
16
|
+
date: monthDate,
|
17
|
+
label: format(monthDate, 'MMMM'),
|
18
|
+
}));
|
19
|
+
};
|
9
20
|
export const Datepicker = ({ disableWeekend = true, firstDayShift = false, range = 14, fromDate = new Date(), onDateSelect, }) => {
|
21
|
+
// We want to make sure that the date is in the UK timezone,
|
22
|
+
// this might need to be revisit when opening up to new countries
|
23
|
+
const startDate = convertToUkDate(fromDate);
|
24
|
+
const endDate = addDays(startDate, range);
|
25
|
+
const availableMonths = getAvailableMonths(startDate, endDate);
|
10
26
|
const [activeDay, setActiveDay] = useState();
|
11
|
-
const [
|
12
|
-
const [listDays, setListDays] = useState([
|
13
|
-
{
|
14
|
-
monthName: '',
|
15
|
-
filteredDays: [],
|
16
|
-
},
|
17
|
-
]);
|
27
|
+
const [activeMonthIndex, setActiveMonth] = useState(0);
|
18
28
|
const handleSelectEvent = (date) => {
|
19
29
|
setActiveDay(date);
|
20
30
|
onDateSelect(format(date, 'yyyy-MM-dd'));
|
21
31
|
};
|
22
|
-
const generateDaysForMonth = (
|
23
|
-
const
|
24
|
-
const
|
25
|
-
const
|
26
|
-
const year = getYear(startDay);
|
32
|
+
const generateDaysForMonth = (monthDate) => {
|
33
|
+
const daysInMonth = getDaysInMonth(monthDate);
|
34
|
+
const month = getMonth(monthDate);
|
35
|
+
const year = getYear(monthDate);
|
27
36
|
const filteredDays = [];
|
28
|
-
if (firstDayShift) {
|
29
|
-
const date = new Date(year, month, 1);
|
30
|
-
const dayOfTheWeek = getISODay(date);
|
31
|
-
const blankDays = dayOfTheWeek - 1;
|
32
|
-
for (let i = 0; i < blankDays; i += 1) {
|
33
|
-
filteredDays.push({
|
34
|
-
date,
|
35
|
-
label: '',
|
36
|
-
active: false,
|
37
|
-
disabled: true,
|
38
|
-
});
|
39
|
-
}
|
40
|
-
}
|
41
37
|
for (let i = 1; i <= daysInMonth; i += 1) {
|
42
38
|
const date = new Date(year, month, i);
|
43
39
|
filteredDays.push({
|
44
40
|
date,
|
45
41
|
label: format(date, 'dd'),
|
46
42
|
active: activeDay ? isSameDay(date, activeDay) : false,
|
47
|
-
disabled:
|
48
|
-
!isWithinInterval(date, { start: startDay, end: endDay })) ||
|
43
|
+
disabled: !isWithinInterval(date, { start: startDate, end: endDate }) ||
|
49
44
|
(disableWeekend && isWeekend(date)),
|
50
45
|
});
|
51
46
|
}
|
52
|
-
return
|
53
|
-
monthName,
|
54
|
-
filteredDays,
|
55
|
-
};
|
56
|
-
};
|
57
|
-
const combineAvailableDays = () => {
|
58
|
-
const today = fromDate;
|
59
|
-
const endDay = addDays(today, range);
|
60
|
-
const sameMonth = isSameMonth(today, endDay);
|
61
|
-
let availableDays = [];
|
62
|
-
// Check if we should generate dates from current for next month
|
63
|
-
if (!sameMonth) {
|
64
|
-
const thisMonth = generateDaysForMonth(today, endDay);
|
65
|
-
const nextMonth = generateDaysForMonth(startOfMonth(addMonths(today, 1)), endDay);
|
66
|
-
availableDays = [thisMonth, nextMonth];
|
67
|
-
}
|
68
|
-
else {
|
69
|
-
availableDays = [generateDaysForMonth(today, endDay)];
|
70
|
-
}
|
71
|
-
setListDays(availableDays);
|
47
|
+
return filteredDays;
|
72
48
|
};
|
73
|
-
useLayoutEffect(() => {
|
74
|
-
combineAvailableDays();
|
75
|
-
}, [activeDay, activeMonth]);
|
76
49
|
return (React.createElement(Container, { id: "datepicker" },
|
77
50
|
React.createElement(Header, { flex: true, alignItems: "center", justifyContent: "space-between", direction: "row" },
|
78
|
-
React.createElement(Circle, { disabled:
|
51
|
+
React.createElement(Circle, { disabled: activeMonthIndex === 0, onClick: () => setActiveMonth(activeMonthIndex - 1) },
|
79
52
|
React.createElement(Caret, { render: "caret", color: "white", size: 24, rotate: 90 })),
|
80
|
-
React.createElement(Heading, { tag: "h4", typo: "desc-base" },
|
81
|
-
React.createElement(Circle, { disabled:
|
82
|
-
listDays[listDays.length - 1].monthName, onClick: () => setActiveMonth(activeMonth + 1) },
|
53
|
+
React.createElement(Heading, { tag: "h4", typo: "desc-base" }, availableMonths[activeMonthIndex].label),
|
54
|
+
React.createElement(Circle, { disabled: activeMonthIndex === availableMonths.length - 1, onClick: () => setActiveMonth(activeMonthIndex + 1) },
|
83
55
|
React.createElement(Caret, { render: "caret", color: "white", size: 24, rotate: -90 }))),
|
84
56
|
React.createElement(Box, { flex: true, alignItems: "center", justifyContent: "center" },
|
85
|
-
React.createElement(DatesList, { items:
|
57
|
+
React.createElement(DatesList, { items: generateDaysForMonth(availableMonths[activeMonthIndex].date), handleDateSelect: handleSelectEvent, firstDayShift: firstDayShift }))));
|
86
58
|
};
|
87
59
|
const Container = styled(Box) `
|
88
60
|
font-family: ${theme.font.system};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Datepicker.js","sourceRoot":"","sources":["../../src/Datepicker/Datepicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAM,QAAQ,EAAE,
|
1
|
+
{"version":3,"file":"Datepicker.js","sourceRoot":"","sources":["../../src/Datepicker/Datepicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAM,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,MAAM,MAAM,mBA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,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;WACf,KAAK,CAAC,MAAM,CAAC,SAAS;;;6BAGJ,KAAK,CAAC,MAAM,CAAC,OAAO;;;;;;CAMhD,CAAA;AAED,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;;iBAGX,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM;CACxC,CAAA;AAED,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;;;CAIzB,CAAA;AAED,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;sBACN,KAAK,CAAC,MAAM,CAAC,SAAS;;;;;;;;;;;;CAY3C,CAAA"}
|
@@ -1,7 +1,19 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import styled from 'styled-components';
|
3
|
+
import { getISODay } from 'date-fns';
|
3
4
|
import { theme } from '../theme';
|
4
|
-
|
5
|
+
const getBlankDaysCount = (firstDayOfTheMonth) => {
|
6
|
+
const dayOfTheWeek = getISODay(firstDayOfTheMonth);
|
7
|
+
return dayOfTheWeek - 1;
|
8
|
+
};
|
9
|
+
export const DatesList = ({ items, handleDateSelect, firstDayShift, }) => {
|
10
|
+
return (React.createElement(Container, null,
|
11
|
+
firstDayShift &&
|
12
|
+
Array(getBlankDaysCount(items[0].date))
|
13
|
+
.fill(null)
|
14
|
+
.map((_, index) => React.createElement(ListItem, { key: `blankItem-${index}`, disabled: true })),
|
15
|
+
items.map((item, i) => (React.createElement(ListItem, { key: i, disabled: item.disabled, className: `ListItem ${item.active ? 'active' : ''}`, onClick: () => handleDateSelect(item.date) }, item.label)))));
|
16
|
+
};
|
5
17
|
const Container = styled.ul `
|
6
18
|
display: grid;
|
7
19
|
grid-column-gap: 4px;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"DatesList.js","sourceRoot":"","sources":["../../src/Datepicker/DatesList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAa,MAAM,OAAO,CAAA;AACj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C,CAAA;AAED,MAAM,SAAS,GAAG,MAAM,CAAC,EAAE,CAAA;;;;;;;;;;;;;;;;CAgB1B,CAAA;AAMD,MAAM,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAW;;;;;;;;iBAQpB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM;;;WAG9B,KAAK,CAAC,MAAM,CAAC,SAAS;;oBAEb,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;aACjD,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;;;;wBAI/B,KAAK,CAAC,MAAM,CAAC,UAAU;;;;aAIlC,KAAK,CAAC,MAAM,CAAC,KAAK;wBACP,KAAK,CAAC,MAAM,CAAC,SAAS;;;CAG7C,CAAA"}
|
@@ -1,13 +1,11 @@
|
|
1
|
-
import {
|
1
|
+
import React, { FormEvent, RefObject } from 'react';
|
2
2
|
export declare type DropdownItem = {
|
3
3
|
optionGroupLabel?: string;
|
4
4
|
label: string;
|
5
5
|
value: string;
|
6
6
|
};
|
7
7
|
declare type DefaultProps = {
|
8
|
-
|
9
|
-
id: string;
|
10
|
-
/** className attribute to apply classes from props */
|
8
|
+
id?: string;
|
11
9
|
className?: string;
|
12
10
|
/** ref attribute for select input */
|
13
11
|
ref?: RefObject<HTMLSelectElement>;
|
@@ -37,6 +35,8 @@ declare type DefaultProps = {
|
|
37
35
|
onBlur?: (e: FormEvent<HTMLSelectElement>) => void;
|
38
36
|
/** required item */
|
39
37
|
required?: boolean;
|
38
|
+
/** set required asterisk */
|
39
|
+
showRequiredAsterisk?: boolean;
|
40
40
|
};
|
41
41
|
/** on change or on input required */
|
42
42
|
declare type TruncateProps = {
|
@@ -49,5 +49,13 @@ declare type TruncateProps = {
|
|
49
49
|
onInputChange: (e: FormEvent<HTMLSelectElement>) => void;
|
50
50
|
};
|
51
51
|
export declare type DropdownProps = DefaultProps & TruncateProps;
|
52
|
-
export declare const Dropdown:
|
52
|
+
export declare const Dropdown: React.ForwardRefExoticComponent<(Pick<DefaultProps & {
|
53
|
+
/** on change is required and on input optional */
|
54
|
+
onSelect: (e: string) => void;
|
55
|
+
onInputChange?: ((e: FormEvent<HTMLSelectElement>) => void) | undefined;
|
56
|
+
}, "required" | "error" | "id" | "name" | "value" | "label" | "className" | "disabled" | "list" | "defaultValue" | "placeholder" | "onBlur" | "onSelect" | "outlined" | "errorMsg" | "onInputChange" | "showRequiredAsterisk"> | Pick<DefaultProps & {
|
57
|
+
/** on input is required and on change optional */
|
58
|
+
onSelect?: ((e: string) => void) | undefined;
|
59
|
+
onInputChange: (e: FormEvent<HTMLSelectElement>) => void;
|
60
|
+
}, "required" | "error" | "id" | "name" | "value" | "label" | "className" | "disabled" | "list" | "defaultValue" | "placeholder" | "onBlur" | "onSelect" | "outlined" | "errorMsg" | "onInputChange" | "showRequiredAsterisk">) & React.RefAttributes<HTMLSelectElement>>;
|
53
61
|
export {};
|
@@ -1,11 +1,13 @@
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
1
|
+
import React, { useEffect, useState, forwardRef, } from 'react';
|
2
2
|
import styled from 'styled-components';
|
3
3
|
import { darken } from 'polished';
|
4
4
|
import { Text } from '../Text';
|
5
5
|
import { Icon } from '../Icon';
|
6
6
|
import { Box } from '../Box';
|
7
7
|
import { theme } from '../theme';
|
8
|
-
|
8
|
+
import { useUniqueId } from '../utils/id';
|
9
|
+
export const Dropdown = forwardRef(function Dropdown({ id: idProp, className = '', label, placeholder, name, value, defaultValue, disabled = false, list, onSelect, outlined = false, error = false, errorMsg = '', onInputChange, onBlur, required = true, showRequiredAsterisk = false, }, ref) {
|
10
|
+
const id = useUniqueId(idProp);
|
9
11
|
const [key, setKey] = useState('');
|
10
12
|
const [hasOptGroups, setHasOptGroups] = useState(false);
|
11
13
|
const [dropdownItemsGroups, setDropdownItemsGroups] = useState([]);
|
@@ -28,7 +30,8 @@ export const Dropdown = ({ id, className = '', ref, label, placeholder, name, va
|
|
28
30
|
}, [list]);
|
29
31
|
return (React.createElement(Container, { className: className },
|
30
32
|
label && (React.createElement(Box, { mb: outlined ? '4px' : '0px' },
|
31
|
-
React.createElement(Text, { tag: "label", color: "subtext", typo: "label", htmlFor: id }, label)
|
33
|
+
React.createElement(Text, { tag: "label", color: "subtext", typo: "label", htmlFor: id }, label),
|
34
|
+
showRequiredAsterisk && (React.createElement(Text, { tag: "label", color: "error", typo: "label" }, "*")))),
|
32
35
|
React.createElement(Content, { outlined: outlined, key: key },
|
33
36
|
React.createElement(Select, { id: id, defaultValue: list.length === 1
|
34
37
|
? String(list[0].value)
|
@@ -49,7 +52,7 @@ export const Dropdown = ({ id, className = '', ref, label, placeholder, name, va
|
|
49
52
|
React.createElement(Caret, { outlined: outlined },
|
50
53
|
React.createElement(Icon, { render: "caret", color: "subtext", size: 24 }))),
|
51
54
|
error && React.createElement(ErrorBox, null, errorMsg)));
|
52
|
-
};
|
55
|
+
});
|
53
56
|
const Container = styled.div `
|
54
57
|
display: flex;
|
55
58
|
flex-direction: column;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Dropdown.js","sourceRoot":"","sources":["../../src/Dropdown/Dropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
1
|
+
{"version":3,"file":"Dropdown.js","sourceRoot":"","sources":["../../src/Dropdown/Dropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,SAAS,EACT,QAAQ,EAGR,UAAU,GAEX,MAAM,OAAO,CAAA;AACd,OAAO,MAAM,MAAM,mBAAmB,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAA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,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC;;;IAGjD,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CACjB,QAAQ;IACR;sBACkB,KAAK,CAAC,MAAM,CAAC,OAAO;;;;;;;wBAOlB,KAAK,CAAC,MAAM,CAAC,OAAO;;CAE3C;;IAEG,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CACd,KAAK;IACL,KAAK,IAAI,EAAE;IACX;wBACoB,KAAK,CAAC,MAAM,CAAC,OAAO;CAC3C;;EAEC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,eAAe,CAAC,QAAQ,EAAE,KAAK,CAAC;CAC1D,CAAA;AAED,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAc;;;;WAI3B,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC;;;CAGrD,CAAA;AAED,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAA;;;WAGjB,KAAK,CAAC,MAAM,CAAC,KAAK;CAC5B,CAAA"}
|
@@ -1,8 +1,49 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import { DropdownProps } from './Dropdown';
|
3
2
|
declare const _default: {
|
4
3
|
title: string;
|
5
|
-
component: React.
|
4
|
+
component: React.ForwardRefExoticComponent<(Pick<{
|
5
|
+
id?: string | undefined;
|
6
|
+
className?: string | undefined;
|
7
|
+
ref?: React.RefObject<HTMLSelectElement> | undefined;
|
8
|
+
placeholder?: string | undefined;
|
9
|
+
label?: string | undefined;
|
10
|
+
name?: string | undefined;
|
11
|
+
value?: string | undefined;
|
12
|
+
defaultValue?: string | undefined;
|
13
|
+
error?: boolean | undefined;
|
14
|
+
errorMsg?: string | undefined;
|
15
|
+
disabled?: boolean | undefined;
|
16
|
+
list: import("./Dropdown").DropdownItem[];
|
17
|
+
onSelect: (element: string) => void;
|
18
|
+
outlined?: boolean | undefined;
|
19
|
+
onBlur?: ((e: React.FormEvent<HTMLSelectElement>) => void) | undefined;
|
20
|
+
required?: boolean | undefined;
|
21
|
+
showRequiredAsterisk?: boolean | undefined;
|
22
|
+
} & {
|
23
|
+
onSelect: (e: string) => void;
|
24
|
+
onInputChange?: ((e: React.FormEvent<HTMLSelectElement>) => void) | undefined;
|
25
|
+
}, "required" | "error" | "id" | "name" | "value" | "label" | "className" | "disabled" | "list" | "defaultValue" | "placeholder" | "onBlur" | "onSelect" | "outlined" | "errorMsg" | "onInputChange" | "showRequiredAsterisk"> | Pick<{
|
26
|
+
id?: string | undefined;
|
27
|
+
className?: string | undefined;
|
28
|
+
ref?: React.RefObject<HTMLSelectElement> | undefined;
|
29
|
+
placeholder?: string | undefined;
|
30
|
+
label?: string | undefined;
|
31
|
+
name?: string | undefined;
|
32
|
+
value?: string | undefined;
|
33
|
+
defaultValue?: string | undefined;
|
34
|
+
error?: boolean | undefined;
|
35
|
+
errorMsg?: string | undefined;
|
36
|
+
disabled?: boolean | undefined;
|
37
|
+
list: import("./Dropdown").DropdownItem[];
|
38
|
+
onSelect: (element: string) => void;
|
39
|
+
outlined?: boolean | undefined;
|
40
|
+
onBlur?: ((e: React.FormEvent<HTMLSelectElement>) => void) | undefined;
|
41
|
+
required?: boolean | undefined;
|
42
|
+
showRequiredAsterisk?: boolean | undefined;
|
43
|
+
} & {
|
44
|
+
onSelect?: ((e: string) => void) | undefined;
|
45
|
+
onInputChange: (e: React.FormEvent<HTMLSelectElement>) => void;
|
46
|
+
}, "required" | "error" | "id" | "name" | "value" | "label" | "className" | "disabled" | "list" | "defaultValue" | "placeholder" | "onBlur" | "onSelect" | "outlined" | "errorMsg" | "onInputChange" | "showRequiredAsterisk">) & React.RefAttributes<HTMLSelectElement>>;
|
6
47
|
argTypes: {
|
7
48
|
onSelect: {
|
8
49
|
action: string;
|
@@ -26,3 +67,4 @@ export declare const OutlineWithErrorWithGroups: any;
|
|
26
67
|
export declare const WithError: any;
|
27
68
|
export declare const WithErrorWithGroups: any;
|
28
69
|
export declare const DateSelectorExample: any;
|
70
|
+
export declare const WithRequiredAsterisk: any;
|