@chotot/clad-ui 2.0.0 → 2.1.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/README.md +3 -1
- package/dist/components/Badge/Badge.d.ts +1 -1
- package/dist/components/Badge/Badge.d.ts.map +1 -1
- package/dist/components/Badge/Badge.js +34 -24
- package/dist/components/Badge/Badge.stories.d.ts.map +1 -1
- package/dist/components/Badge/Badge.stories.js +60 -52
- package/dist/components/Badge/Badge.styles.d.ts +1 -0
- package/dist/components/Badge/Badge.styles.d.ts.map +1 -1
- package/dist/components/Badge/Badge.styles.js +17 -8
- package/dist/components/Breadcrumbs/BreadcrumbItem.js +1 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.stories.d.ts.map +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.stories.js +19 -13
- package/dist/components/Button/Button.d.ts +1 -1
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/Button/Button.stories.d.ts +76 -2
- package/dist/components/Button/Button.stories.d.ts.map +1 -1
- package/dist/components/Button/Button.stories.js +86 -10
- package/dist/components/Button/Button.styles.d.ts.map +1 -1
- package/dist/components/Button/Button.styles.js +16 -0
- package/dist/components/Button/GhostButton.d.ts +1 -1
- package/dist/components/Button/GhostButton.d.ts.map +1 -1
- package/dist/components/Button/GhostButton.stories.d.ts +78 -0
- package/dist/components/Button/GhostButton.stories.d.ts.map +1 -1
- package/dist/components/Button/GhostButton.stories.js +62 -7
- package/dist/components/Button/GhostButton.styles.d.ts.map +1 -1
- package/dist/components/Button/GhostButton.styles.js +17 -1
- package/dist/components/Button/IconButton.stories.d.ts +73 -1
- package/dist/components/Button/IconButton.stories.d.ts.map +1 -1
- package/dist/components/Button/IconButton.stories.js +57 -8
- package/dist/components/Button/constant.d.ts +10 -0
- package/dist/components/Button/constant.d.ts.map +1 -0
- package/dist/components/Button/constant.js +21 -0
- package/dist/components/DatePicker/DatePicker.d.ts +4 -0
- package/dist/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/components/DatePicker/DatePicker.js +4 -1
- package/dist/components/DatePicker/DatePicker.stories.d.ts +1 -0
- package/dist/components/DatePicker/DatePicker.stories.d.ts.map +1 -1
- package/dist/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/dist/components/Dropdown/Dropdown.js +5 -0
- package/dist/components/Dropdown/Dropdown.styles.d.ts.map +1 -1
- package/dist/components/Dropdown/Dropdown.styles.js +27 -3
- package/dist/components/Input/Input.d.ts +1 -1
- package/dist/components/Input/Input.d.ts.map +1 -1
- package/dist/components/Input/Input.js +15 -2
- package/dist/components/RowItem/RowItem.d.ts.map +1 -1
- package/dist/components/RowItem/RowItem.js +3 -6
- package/dist/components/Tabs/Tab.d.ts.map +1 -1
- package/dist/components/Tabs/Tab.js +1 -0
- package/dist/components/Tabs/Tabs.styles.js +1 -1
- package/dist/components/TextArea/TextArea.d.ts +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/patterns/EmptyState/EmptyState.d.ts +1 -1
- package/dist/patterns/EmptyState/EmptyState.d.ts.map +1 -1
- package/dist/patterns/EmptyState/EmptyState.js +52 -47
- package/dist/patterns/EmptyState/EmptyState.stories.d.ts +11 -1
- package/dist/patterns/EmptyState/EmptyState.stories.d.ts.map +1 -1
- package/dist/patterns/EmptyState/EmptyState.stories.js +50 -11
- package/dist/patterns/EmptyState/EmptyState.styles.d.ts +3 -15
- package/dist/patterns/EmptyState/EmptyState.styles.d.ts.map +1 -1
- package/dist/patterns/EmptyState/EmptyState.styles.js +23 -40
- package/dist/patterns/InputGroup/InputGroup.d.ts +1 -1
- package/dist/patterns/InputGroup/InputGroup.styles.d.ts.map +1 -1
- package/dist/patterns/InputGroup/InputGroup.styles.js +3 -2
- package/dist/patterns/MultiSearchDropdown/MultiSearchDropdown.d.ts +1 -1
- package/dist/patterns/MultiSearchDropdown/MultiSearchDropdown.d.ts.map +1 -1
- package/dist/patterns/MultiSearchDropdown/MultiSearchDropdown.js +4 -0
- package/dist/patterns/RangeInput/RangeInput.d.ts +30 -0
- package/dist/patterns/RangeInput/RangeInput.d.ts.map +1 -0
- package/dist/patterns/RangeInput/RangeInput.js +27 -0
- package/dist/patterns/RangeInput/RangeInput.stories.d.ts +68 -0
- package/dist/patterns/RangeInput/RangeInput.stories.d.ts.map +1 -0
- package/dist/patterns/RangeInput/RangeInput.stories.js +121 -0
- package/dist/patterns/RangeInput/RangeInput.styles.d.ts +5 -0
- package/dist/patterns/RangeInput/RangeInput.styles.d.ts.map +1 -0
- package/dist/patterns/RangeInput/RangeInput.styles.js +32 -0
- package/dist/patterns/SearchInput/SearchInput.d.ts +1 -1
- package/dist/patterns/SearchInput/SearchInput.d.ts.map +1 -1
- package/dist/patterns/SearchInput/SearchInput.js +7 -8
- package/dist/patterns/Searchbar/Searchbar.d.ts +28 -0
- package/dist/patterns/Searchbar/Searchbar.d.ts.map +1 -0
- package/dist/patterns/Searchbar/Searchbar.js +37 -0
- package/dist/patterns/Searchbar/Searchbar.stories.d.ts +70 -0
- package/dist/patterns/Searchbar/Searchbar.stories.d.ts.map +1 -0
- package/dist/patterns/Searchbar/Searchbar.stories.js +80 -0
- package/dist/patterns/Searchbar/Searchbar.styles.d.ts +3 -0
- package/dist/patterns/Searchbar/Searchbar.styles.d.ts.map +1 -0
- package/dist/patterns/Searchbar/Searchbar.styles.js +48 -0
- package/dist/patterns/TagCloud/TagCloud.d.ts +1 -1
- package/dist/patterns/index.d.ts +4 -0
- package/dist/patterns/index.d.ts.map +1 -1
- package/dist/patterns/index.js +2 -0
- package/dist/storybook/ColorFoundationList.js +2 -2
- package/dist/theme/chotot.d.ts +8 -4
- package/dist/theme/chotot.d.ts.map +1 -1
- package/dist/theme/chotot.js +10 -6
- package/dist/theme/ct-job.d.ts +8 -4
- package/dist/theme/ct-job.d.ts.map +1 -1
- package/dist/theme/ct-pty.d.ts +8 -4
- package/dist/theme/ct-pty.d.ts.map +1 -1
- package/dist/theme/ct-veh.d.ts +8 -4
- package/dist/theme/ct-veh.d.ts.map +1 -1
- package/dist/theme/mudah.js +1 -1
- package/dist/typography/HeaderAnnotation.d.ts +19 -0
- package/dist/typography/HeaderAnnotation.d.ts.map +1 -0
- package/dist/typography/HeaderAnnotation.js +15 -0
- package/dist/typography/index.d.ts +2 -0
- package/dist/typography/index.d.ts.map +1 -1
- package/dist/typography/index.js +1 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import theme from '@clad-ui/theme';
|
|
2
|
-
import {
|
|
3
|
-
const { colors,
|
|
4
|
-
export const
|
|
2
|
+
import { css } from '@linaria/core';
|
|
3
|
+
const { colors, space, typo } = theme;
|
|
4
|
+
export const emptyStateClass = css `
|
|
5
5
|
display: flex;
|
|
6
6
|
justify-content: center;
|
|
7
7
|
align-items: center;
|
|
@@ -10,51 +10,34 @@ export const StyledEmptyState = styled.div `
|
|
|
10
10
|
outline: 1px solid var(--cladebug);
|
|
11
11
|
outline-offset: 1px;
|
|
12
12
|
position: relative;
|
|
13
|
-
`;
|
|
14
|
-
export const StyledEmptyHeaderText = styled.h3 `
|
|
15
|
-
font-size: ${fontSizes.h3};
|
|
16
|
-
line-height: ${lineHeights.md};
|
|
17
|
-
font-weight: ${fontWeights.bold};
|
|
18
|
-
color: ${colors.textPrimary};
|
|
19
|
-
`;
|
|
20
|
-
export const StyledEmptyBodyText = styled.p `
|
|
21
|
-
font-size: ${fontSizes.sm};
|
|
22
|
-
line-height: ${lineHeights.xs};
|
|
23
|
-
color: ${colors.textPrimary};
|
|
24
|
-
text-align: center;
|
|
25
|
-
white-space: break-spaces;
|
|
26
|
-
max-width: ${sizes.$md};
|
|
27
|
-
margin-bottom: ${space.md};
|
|
28
13
|
|
|
29
|
-
|
|
30
|
-
|
|
14
|
+
img {
|
|
15
|
+
object-fit: contain;
|
|
31
16
|
}
|
|
32
17
|
`;
|
|
33
|
-
export const
|
|
18
|
+
export const emptyStateContentClass = css `
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
align-items: center;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
gap: ${space.xs};
|
|
24
|
+
`;
|
|
25
|
+
export const emptyStateContentTextClass = css `
|
|
34
26
|
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
35
28
|
align-items: center;
|
|
36
29
|
justify-content: center;
|
|
37
|
-
|
|
38
|
-
width:
|
|
39
|
-
|
|
30
|
+
gap: ${space.xxs};
|
|
31
|
+
max-width: 700px;
|
|
32
|
+
text-align: center;
|
|
40
33
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
height: auto;
|
|
44
|
-
max-width: 375px;
|
|
45
|
-
max-height: 245px;
|
|
34
|
+
h3 {
|
|
35
|
+
${typo.display.annotation}
|
|
46
36
|
}
|
|
47
37
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
img {
|
|
53
|
-
max-width: 400px;
|
|
54
|
-
max-height: 260px;
|
|
55
|
-
}
|
|
38
|
+
p {
|
|
39
|
+
${typo.body.section}
|
|
40
|
+
color: ${colors.textSecondary};
|
|
41
|
+
white-space: pre-line;
|
|
56
42
|
}
|
|
57
43
|
`;
|
|
58
|
-
export const StyledButtonWrapper = styled.div `
|
|
59
|
-
min-width: 180px;
|
|
60
|
-
`;
|
|
@@ -9,7 +9,7 @@ export type InputGroupProps = {
|
|
|
9
9
|
*/
|
|
10
10
|
status?: 'default' | 'error';
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Prompt a helptext below input group (useful when implemented with form validation)
|
|
13
13
|
*/
|
|
14
14
|
helptext?: string;
|
|
15
15
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputGroup.styles.d.ts","sourceRoot":"","sources":["../../../patterns/InputGroup/InputGroup.styles.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,OAAO;;
|
|
1
|
+
{"version":3,"file":"InputGroup.styles.d.ts","sourceRoot":"","sources":["../../../patterns/InputGroup/InputGroup.styles.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,OAAO;;EA0EZ,CAAC;AAEF,QAAA,MAAM,SAAS;;EAQd,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -49,8 +49,9 @@ const Wrapper = styled.div `
|
|
|
49
49
|
border-bottom-left-radius: 0;
|
|
50
50
|
border-top-right-radius: 10px;
|
|
51
51
|
border-bottom-right-radius: 10px;
|
|
52
|
+
height: auto;
|
|
52
53
|
|
|
53
|
-
> :first-child {
|
|
54
|
+
> :first-child:not(svg) {
|
|
54
55
|
border: 0;
|
|
55
56
|
border-left: 1px solid ${colors.borderThin};
|
|
56
57
|
border-top-left-radius: 0;
|
|
@@ -59,7 +60,7 @@ const Wrapper = styled.div `
|
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
> :not(:first-child):not(:last-child) {
|
|
62
|
-
> :first-child {
|
|
63
|
+
> :first-child:not(svg) {
|
|
63
64
|
border: 0;
|
|
64
65
|
border-left: 1px solid ${colors.borderThin};
|
|
65
66
|
border-radius: 0;
|
|
@@ -82,7 +82,7 @@ export interface MultiSearchDropdownProps {
|
|
|
82
82
|
*/
|
|
83
83
|
required?: boolean;
|
|
84
84
|
/**
|
|
85
|
-
*
|
|
85
|
+
* Prompt a helptext below input group (useful when implemented with form validation)
|
|
86
86
|
*/
|
|
87
87
|
helptext?: string;
|
|
88
88
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSearchDropdown.d.ts","sourceRoot":"","sources":["../../../patterns/MultiSearchDropdown/MultiSearchDropdown.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAc,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AA6BnD,MAAM,MAAM,yBAAyB,GAAG;IACtC,0BAA0B;IAC1B,IAAI,EAAE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CAAC,KAAK,IAAI,CAAC;IAC1D;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IACzD;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,aAAa,CAAC,EAAE,KAAK,CAAC;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,MAAM,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAC7B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,QAAA,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,
|
|
1
|
+
{"version":3,"file":"MultiSearchDropdown.d.ts","sourceRoot":"","sources":["../../../patterns/MultiSearchDropdown/MultiSearchDropdown.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAc,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AA6BnD,MAAM,MAAM,yBAAyB,GAAG;IACtC,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,KAAK,CAAC,EAAE,yBAAyB,EAAE,CAAC;IACpC;;OAEG;IACH,OAAO,CAAC,EAAE,yBAAyB,EAAE,CAAC;IACtC;;OAEG;IACH,QAAQ,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AC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,MAAM,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAC7B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,QAAA,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CA8X3D,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -57,6 +57,10 @@ const MultiSearchDropdown = ({ id, label = '', value = [], options = [], onInput
|
|
|
57
57
|
setValues(value);
|
|
58
58
|
}
|
|
59
59
|
}, [value.length]);
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
setModifiedOptions(options);
|
|
62
|
+
setFilteredOptions(options);
|
|
63
|
+
}, [options]);
|
|
60
64
|
// the positioning stuff...
|
|
61
65
|
const { renderLayer, triggerProps: { ref: setTriggerRef }, // ref from useLayer is a function
|
|
62
66
|
layerProps, triggerBounds,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type RangeInputProps = {
|
|
3
|
+
/**
|
|
4
|
+
* Input group content
|
|
5
|
+
*/
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* Input group status (useful when implemented with form validation)
|
|
9
|
+
*/
|
|
10
|
+
status?: 'default' | 'error';
|
|
11
|
+
/**
|
|
12
|
+
* Prompt a helptext below input group (useful when implemented with form validation)
|
|
13
|
+
*/
|
|
14
|
+
helptext?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Custom helptext
|
|
17
|
+
*/
|
|
18
|
+
helptextClassName?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Custom class name
|
|
21
|
+
*/
|
|
22
|
+
className?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Custom separator component
|
|
25
|
+
*/
|
|
26
|
+
separatorComponent?: React.ReactNode;
|
|
27
|
+
};
|
|
28
|
+
declare const RangeInput: React.FC<RangeInputProps>;
|
|
29
|
+
export default RangeInput;
|
|
30
|
+
//# sourceMappingURL=RangeInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RangeInput.d.ts","sourceRoot":"","sources":["../../../patterns/RangeInput/RangeInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;OAEG;IACH,MAAM,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAC7B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,kBAAkB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACtC,CAAC;AAEF,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAkCzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { cx } from '../../utils';
|
|
3
|
+
import { Paragraph } from '../../components/Input/Input.styles';
|
|
4
|
+
import { containerClass, helptextClass, inputWrapperClass, separatorClass, } from './RangeInput.styles';
|
|
5
|
+
const RangeInput = ({ children, helptext = '', helptextClassName = '', className = '', status = 'default', separatorComponent, }) => {
|
|
6
|
+
const isWithError = status === 'error';
|
|
7
|
+
const containerCss = cx(containerClass, className);
|
|
8
|
+
const helptextCss = cx(helptextClass, helptextClassName, isWithError && 'error');
|
|
9
|
+
return (<div className={containerCss} data-clad="Range Input">
|
|
10
|
+
<div className={inputWrapperClass}>
|
|
11
|
+
{React.Children.map(children, (child, index) => {
|
|
12
|
+
var _a;
|
|
13
|
+
const key = (_a = child === null || child === void 0 ? void 0 : child.key) !== null && _a !== void 0 ? _a : index;
|
|
14
|
+
let renderSeparator = null;
|
|
15
|
+
if (index > 0) {
|
|
16
|
+
renderSeparator = separatorComponent || <p className={separatorClass}>-</p>;
|
|
17
|
+
}
|
|
18
|
+
return (<span key={key} className="separator-wrapper">
|
|
19
|
+
{renderSeparator}
|
|
20
|
+
{child}
|
|
21
|
+
</span>);
|
|
22
|
+
})}
|
|
23
|
+
</div>
|
|
24
|
+
{helptext ? <Paragraph className={helptextCss}>{helptext}</Paragraph> : null}
|
|
25
|
+
</div>);
|
|
26
|
+
};
|
|
27
|
+
export default RangeInput;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: React.FC<import("./RangeInput").RangeInputProps>;
|
|
5
|
+
tags: string[];
|
|
6
|
+
parameters: {
|
|
7
|
+
docs: {
|
|
8
|
+
description: {
|
|
9
|
+
component: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
argTypes: {
|
|
14
|
+
status: {
|
|
15
|
+
control: string;
|
|
16
|
+
options: string[];
|
|
17
|
+
description: string;
|
|
18
|
+
defaultValue: string;
|
|
19
|
+
};
|
|
20
|
+
helptext: {
|
|
21
|
+
control: string;
|
|
22
|
+
description: string;
|
|
23
|
+
};
|
|
24
|
+
helptextClassName: {
|
|
25
|
+
control: string;
|
|
26
|
+
description: string;
|
|
27
|
+
};
|
|
28
|
+
className: {
|
|
29
|
+
control: string;
|
|
30
|
+
description: string;
|
|
31
|
+
};
|
|
32
|
+
separatorComponent: {
|
|
33
|
+
control: boolean;
|
|
34
|
+
description: string;
|
|
35
|
+
};
|
|
36
|
+
children: {
|
|
37
|
+
control: boolean;
|
|
38
|
+
description: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
args: {
|
|
42
|
+
status: string;
|
|
43
|
+
helptext: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export default meta;
|
|
47
|
+
export declare const Overview: {
|
|
48
|
+
render: (args: any) => JSX.Element;
|
|
49
|
+
};
|
|
50
|
+
export declare const PriceRange: {
|
|
51
|
+
render: () => JSX.Element;
|
|
52
|
+
};
|
|
53
|
+
export declare const WithLongError: {
|
|
54
|
+
render: () => JSX.Element;
|
|
55
|
+
};
|
|
56
|
+
export declare const CustomSeparator: {
|
|
57
|
+
render: () => JSX.Element;
|
|
58
|
+
};
|
|
59
|
+
export declare const WithoutLabels: {
|
|
60
|
+
render: () => JSX.Element;
|
|
61
|
+
};
|
|
62
|
+
export declare const MultipleRanges: {
|
|
63
|
+
render: () => JSX.Element;
|
|
64
|
+
};
|
|
65
|
+
export declare const Disabled: {
|
|
66
|
+
render: () => JSX.Element;
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=RangeInput.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RangeInput.stories.d.ts","sourceRoot":"","sources":["../../../patterns/RangeInput/RangeInput.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAIxC,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8CT,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,QAAQ;mBACJ,GAAG;CAqBnB,CAAC;AAEF,eAAO,MAAM,UAAU;;CAwBtB,CAAC;AAEF,eAAO,MAAM,aAAa;;CAyBzB,CAAC;AAEF,eAAO,MAAM,eAAe;;CAe3B,CAAC;AAEF,eAAO,MAAM,aAAa;;CAoBzB,CAAC;AAEF,eAAO,MAAM,cAAc;;CA4B1B,CAAC;AAEF,eAAO,MAAM,QAAQ;;CAOpB,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import RangeInput from './RangeInput';
|
|
3
|
+
import { Input } from '../../components';
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Patterns/RangeInput',
|
|
6
|
+
component: RangeInput,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
parameters: {
|
|
9
|
+
docs: {
|
|
10
|
+
description: {
|
|
11
|
+
component: `A range input component that groups two related inputs with a separator. Perfect for date ranges, price ranges, or any paired input scenarios.
|
|
12
|
+
|
|
13
|
+
\`🧪 Beta \` [\`🎨 Figma Specs\`](https://www.figma.com/design/CYWl6Rz8BD5Pvv7LRsupYk/Design-System-Handoff?node-id=8873-5334&t=fVzdnRlA1pOFBpL3-4)
|
|
14
|
+
`,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
argTypes: {
|
|
19
|
+
status: {
|
|
20
|
+
control: 'select',
|
|
21
|
+
options: ['default', 'error'],
|
|
22
|
+
description: 'Input group status (useful when implemented with form validation)',
|
|
23
|
+
defaultValue: 'default',
|
|
24
|
+
},
|
|
25
|
+
helptext: {
|
|
26
|
+
control: 'text',
|
|
27
|
+
description: 'Help text displayed below the input group',
|
|
28
|
+
},
|
|
29
|
+
helptextClassName: {
|
|
30
|
+
control: 'text',
|
|
31
|
+
description: 'Custom class name for help text styling',
|
|
32
|
+
},
|
|
33
|
+
className: {
|
|
34
|
+
control: 'text',
|
|
35
|
+
description: 'Custom class name for the container',
|
|
36
|
+
},
|
|
37
|
+
separatorComponent: {
|
|
38
|
+
control: false,
|
|
39
|
+
description: 'Custom separator component (defaults to "-")',
|
|
40
|
+
},
|
|
41
|
+
children: {
|
|
42
|
+
control: false,
|
|
43
|
+
description: 'Input components to be grouped',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
args: {
|
|
47
|
+
status: 'default',
|
|
48
|
+
helptext: '',
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
export default meta;
|
|
52
|
+
export const Overview = {
|
|
53
|
+
render: (args) => {
|
|
54
|
+
const [firstValue, setFirstValue] = useState('');
|
|
55
|
+
const [secondValue, setSecondValue] = useState('');
|
|
56
|
+
return (<RangeInput {...args}>
|
|
57
|
+
<Input label="From" placeholder="Start value" value={firstValue} onChange={(e) => setFirstValue(e.target.value)}/>
|
|
58
|
+
<Input label="To" placeholder="End value" value={secondValue} onChange={(e) => setSecondValue(e.target.value)}/>
|
|
59
|
+
</RangeInput>);
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
export const PriceRange = {
|
|
63
|
+
render: () => {
|
|
64
|
+
const [minPrice, setMinPrice] = useState('');
|
|
65
|
+
const [maxPrice, setMaxPrice] = useState('');
|
|
66
|
+
return (<RangeInput helptext="Enter your budget range">
|
|
67
|
+
<Input label="Min Price" type="number" placeholder="0" value={minPrice} onChange={(e) => setMinPrice(e.target.value)}/>
|
|
68
|
+
<Input label="Max Price" type="number" placeholder="1000" value={maxPrice} onChange={(e) => setMaxPrice(e.target.value)}/>
|
|
69
|
+
</RangeInput>);
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
export const WithLongError = {
|
|
73
|
+
render: () => {
|
|
74
|
+
const [firstValue, setFirstValue] = useState('100');
|
|
75
|
+
const [secondValue, setSecondValue] = useState('50');
|
|
76
|
+
return (<RangeInput status="error" helptext="This is a long error message that should be displayed below the input group. It should wrap to multiple lines if necessary. This is a long error message that should be displayed below the input group. It should wrap to multiple lines if necessary.">
|
|
77
|
+
<Input label="From" value={firstValue} onChange={(e) => setFirstValue(e.target.value)} status="error"/>
|
|
78
|
+
<Input label="To" value={secondValue} onChange={(e) => setSecondValue(e.target.value)} status="error"/>
|
|
79
|
+
</RangeInput>);
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
export const CustomSeparator = {
|
|
83
|
+
render: () => {
|
|
84
|
+
const [firstValue, setFirstValue] = useState('');
|
|
85
|
+
const [secondValue, setSecondValue] = useState('');
|
|
86
|
+
return (<RangeInput separatorComponent={<span style={{ fontSize: '18px', fontWeight: 'bold' }}>to</span>} helptext="Custom separator example">
|
|
87
|
+
<Input label="From" value={firstValue} onChange={(e) => setFirstValue(e.target.value)}/>
|
|
88
|
+
<Input label="To" value={secondValue} onChange={(e) => setSecondValue(e.target.value)}/>
|
|
89
|
+
</RangeInput>);
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
export const WithoutLabels = {
|
|
93
|
+
render: () => {
|
|
94
|
+
const [firstValue, setFirstValue] = useState('');
|
|
95
|
+
const [secondValue, setSecondValue] = useState('');
|
|
96
|
+
return (<RangeInput helptext="Range inputs without labels">
|
|
97
|
+
<Input placeholder="Minimum value" value={firstValue} onChange={(e) => setFirstValue(e.target.value)}/>
|
|
98
|
+
<Input placeholder="Maximum value" value={secondValue} onChange={(e) => setSecondValue(e.target.value)}/>
|
|
99
|
+
</RangeInput>);
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
export const MultipleRanges = {
|
|
103
|
+
render: () => {
|
|
104
|
+
const [firstValue, setFirstValue] = useState('');
|
|
105
|
+
const [secondValue, setSecondValue] = useState('');
|
|
106
|
+
const [thirdValue, setThirdValue] = useState('');
|
|
107
|
+
return (<div style={{ display: 'flex', flexDirection: 'column', gap: '24px' }}>
|
|
108
|
+
<RangeInput helptext="Price range filter">
|
|
109
|
+
<Input label="First Value" value={firstValue} onChange={(e) => setFirstValue(e.target.value)}/>
|
|
110
|
+
<Input label="Second Value" value={secondValue} onChange={(e) => setSecondValue(e.target.value)}/>
|
|
111
|
+
<Input label="Third Value" value={thirdValue} onChange={(e) => setThirdValue(e.target.value)}/>
|
|
112
|
+
</RangeInput>
|
|
113
|
+
</div>);
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
export const Disabled = {
|
|
117
|
+
render: () => (<RangeInput helptext="Disabled range inputs">
|
|
118
|
+
<Input label="From" value="100" disabled/>
|
|
119
|
+
<Input label="To" value="500" disabled/>
|
|
120
|
+
</RangeInput>),
|
|
121
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const containerClass: import("@linaria/core").LinariaClassName;
|
|
2
|
+
export declare const inputWrapperClass: import("@linaria/core").LinariaClassName;
|
|
3
|
+
export declare const separatorClass: import("@linaria/core").LinariaClassName;
|
|
4
|
+
export declare const helptextClass: import("@linaria/core").LinariaClassName;
|
|
5
|
+
//# sourceMappingURL=RangeInput.styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RangeInput.styles.d.ts","sourceRoot":"","sources":["../../../patterns/RangeInput/RangeInput.styles.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,cAAc,0CAQ1B,CAAC;AAEF,eAAO,MAAM,iBAAiB,0CAQ7B,CAAC;AAEF,eAAO,MAAM,cAAc,0CAK1B,CAAC;AAEF,eAAO,MAAM,aAAa,0CAIzB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { css } from '@linaria/core';
|
|
2
|
+
import theme from '@clad-ui/theme';
|
|
3
|
+
const { space, colors, typo } = theme;
|
|
4
|
+
export const containerClass = css `
|
|
5
|
+
/* Standard highlight for manual testing & verification */
|
|
6
|
+
position: relative;
|
|
7
|
+
outline: 1px solid var(--cladebug);
|
|
8
|
+
outline-offset: 1px;
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
gap: ${space.xxs};
|
|
12
|
+
`;
|
|
13
|
+
export const inputWrapperClass = css `
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
gap: ${space.sm};
|
|
17
|
+
|
|
18
|
+
.separator-wrapper {
|
|
19
|
+
display: contents;
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
22
|
+
export const separatorClass = css `
|
|
23
|
+
color: ${colors.textPrimary};
|
|
24
|
+
margin: 0;
|
|
25
|
+
|
|
26
|
+
${typo.label.section}
|
|
27
|
+
`;
|
|
28
|
+
export const helptextClass = css `
|
|
29
|
+
&.error {
|
|
30
|
+
color: ${colors.textError};
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
@@ -89,7 +89,7 @@ export interface SearchInputProps {
|
|
|
89
89
|
*/
|
|
90
90
|
status?: 'default' | 'error';
|
|
91
91
|
/**
|
|
92
|
-
*
|
|
92
|
+
* Prompt a helptext below input (useful when implemented with form validation)
|
|
93
93
|
*/
|
|
94
94
|
helptext?: string;
|
|
95
95
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchInput.d.ts","sourceRoot":"","sources":["../../../patterns/SearchInput/SearchInput.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAc,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"SearchInput.d.ts","sourceRoot":"","sources":["../../../patterns/SearchInput/SearchInput.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAc,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAiBnD,MAAM,WAAW,iBAAiB;IAChC,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4BAA4B;IAC5B,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAC9B;AAED,MAAM,WAAW,gBAAiB,SAAQ,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC;IAC3E,KAAK,EAAE,gBAAgB,CAAC;CACzB;AAGD,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB;;OAEG;IACH,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,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AAG,MAAM,GAAG,KAAK,CAAC;IACzF;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;IACd;;OAEG;IACH,aAAa,CAAC,EAAE,KAAK,CAAC;IACtB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AACD;;;;GAIG;AAEH,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA4M3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -5,7 +5,6 @@ import { useLayer } from 'react-laag';
|
|
|
5
5
|
import theme from '@clad-ui/theme';
|
|
6
6
|
import Search from '../../icons/Search';
|
|
7
7
|
import { cx } from '../../utils';
|
|
8
|
-
import noop from '../../utils/noop';
|
|
9
8
|
import ChevronDownFilled from '../../icons/ChevronDownFilled';
|
|
10
9
|
import normalizeArrowKey from '../../utils/_normalizeArrowKey';
|
|
11
10
|
import { menuClass, optionClass, invertedArrowClass, searchInputWrapperClass, searchDropdownIconClass, Wrapper, } from './SearchInput.styles';
|
|
@@ -129,17 +128,17 @@ allowClear = true, menuMaxHeight = '$sm', showSearchIcon = false, ...inputProps
|
|
|
129
128
|
setHiliIndex(+itemIndex);
|
|
130
129
|
}
|
|
131
130
|
};
|
|
132
|
-
const
|
|
131
|
+
const handleInputFocus = (e) => {
|
|
133
132
|
e.persist();
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
|
|
134
|
+
if (variant === 'dropdown') {
|
|
135
|
+
setTimeout(() => {
|
|
136
|
+
setMenuOpen(true);
|
|
137
|
+
}, 0);
|
|
136
138
|
}
|
|
137
|
-
setTimeout(() => {
|
|
138
|
-
setMenuOpen(true);
|
|
139
|
-
}, 0);
|
|
140
139
|
};
|
|
141
140
|
return (<Wrapper id={id ? id : ''} role="combobox" onKeyUp={handleKeyUp} onKeyDown={handleKeyDown} tabIndex={0} aria-haspopup="listbox" aria-expanded={showMenu} aria-controls="search-input-listbox" className={cx(variant === 'dropdown' && searchInputWrapperClass)} data-clad="Input Field - Search Bar">
|
|
142
|
-
<Input {...inputProps} allowClear={allowClear} inputRef={textFieldRef} value={textValue} onChange={handleInputChange} onFocus={
|
|
141
|
+
<Input {...inputProps} allowClear={allowClear} inputRef={textFieldRef} value={textValue} onChange={handleInputChange} onFocus={handleInputFocus} icon={!!showSearchIcon && <Search width={20} height={20}/>}/>
|
|
143
142
|
{!!showMenu &&
|
|
144
143
|
renderLayer(<ul id="search-input-listbox" role="listbox" className={menuClass} {...layerProps} style={{
|
|
145
144
|
width: triggerBounds === null || triggerBounds === void 0 ? void 0 : triggerBounds.width, // we want the same width as the input
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type HTMLCladUIProps, type ReactRef } from '../../utils/types';
|
|
2
|
+
type ClassNames = {
|
|
3
|
+
container: string;
|
|
4
|
+
input: string;
|
|
5
|
+
actionBtn: string;
|
|
6
|
+
};
|
|
7
|
+
export interface SearchbarProps extends HTMLCladUIProps<'input'> {
|
|
8
|
+
/**
|
|
9
|
+
* Ref to the DOM node.
|
|
10
|
+
*/
|
|
11
|
+
ref?: ReactRef<HTMLInputElement | null>;
|
|
12
|
+
/**
|
|
13
|
+
* Additional classes to be added for customization
|
|
14
|
+
*/
|
|
15
|
+
classNames?: ClassNames;
|
|
16
|
+
/**
|
|
17
|
+
* Allow to remove input content with clear icon
|
|
18
|
+
* @default true
|
|
19
|
+
*/
|
|
20
|
+
allowClear?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Default value
|
|
23
|
+
*/
|
|
24
|
+
defaultValue?: string;
|
|
25
|
+
}
|
|
26
|
+
declare const Searchbar: import("../../utils/types").InternalForwardRefRenderFunction<"input", SearchbarProps>;
|
|
27
|
+
export default Searchbar;
|
|
28
|
+
//# sourceMappingURL=Searchbar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Searchbar.d.ts","sourceRoot":"","sources":["../../../patterns/Searchbar/Searchbar.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAc,KAAK,eAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAIpF,KAAK,UAAU,GAAG;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,cAAe,SAAQ,eAAe,CAAC,OAAO,CAAC;IAC9D;;OAEG;IACH,GAAG,CAAC,EAAE,QAAQ,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IACxC;;OAEG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,QAAA,MAAM,SAAS,uFAyDb,CAAC;AAIH,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { useRef, useState, useImperativeHandle } from 'react';
|
|
3
|
+
import { cx } from '../../utils';
|
|
4
|
+
import { forwardRef } from '../../utils/types';
|
|
5
|
+
import { Search, CloseFilled } from '../../icons';
|
|
6
|
+
import { actionBtnClass, containerClass } from './Searchbar.styles';
|
|
7
|
+
const Searchbar = forwardRef((props, ref) => {
|
|
8
|
+
const { placeholder = 'Tìm sản phẩm...', value, classNames, onChange, defaultValue = '', allowClear = true, disabled = false, ...rest } = props;
|
|
9
|
+
const [inputValue, setInputValue] = useState(value || defaultValue);
|
|
10
|
+
const internalRef = useRef(null);
|
|
11
|
+
useImperativeHandle(ref, () => internalRef === null || internalRef === void 0 ? void 0 : internalRef.current);
|
|
12
|
+
const onInputChange = (e) => {
|
|
13
|
+
setInputValue(e.target.value);
|
|
14
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(e);
|
|
15
|
+
};
|
|
16
|
+
const onClear = () => {
|
|
17
|
+
var _a;
|
|
18
|
+
setInputValue('');
|
|
19
|
+
if (onChange && internalRef.current) {
|
|
20
|
+
const syntheticEvent = {
|
|
21
|
+
target: { value: '' },
|
|
22
|
+
currentTarget: internalRef.current,
|
|
23
|
+
};
|
|
24
|
+
onChange(syntheticEvent);
|
|
25
|
+
}
|
|
26
|
+
(_a = internalRef === null || internalRef === void 0 ? void 0 : internalRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
27
|
+
};
|
|
28
|
+
return (<div className={cx(containerClass, classNames === null || classNames === void 0 ? void 0 : classNames.container)}>
|
|
29
|
+
<Search width={20} height={20}/>
|
|
30
|
+
<input className={classNames === null || classNames === void 0 ? void 0 : classNames.input} value={inputValue} placeholder={placeholder} disabled={disabled} onChange={onInputChange} {...rest} ref={internalRef}/>
|
|
31
|
+
{inputValue && allowClear && !disabled ? (<button type="button" onClick={onClear} className={cx(actionBtnClass, classNames === null || classNames === void 0 ? void 0 : classNames.actionBtn)}>
|
|
32
|
+
<CloseFilled width={24} height={24}/>
|
|
33
|
+
</button>) : null}
|
|
34
|
+
</div>);
|
|
35
|
+
});
|
|
36
|
+
Searchbar.displayName = 'Searchbar';
|
|
37
|
+
export default Searchbar;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
declare const meta: {
|
|
2
|
+
title: string;
|
|
3
|
+
component: import("../../utils/types").InternalForwardRefRenderFunction<"input", import("./Searchbar").SearchbarProps>;
|
|
4
|
+
tags: string[];
|
|
5
|
+
parameters: {
|
|
6
|
+
docs: {
|
|
7
|
+
description: {
|
|
8
|
+
component: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
argTypes: {
|
|
13
|
+
allowClear: {
|
|
14
|
+
control: string;
|
|
15
|
+
description: string;
|
|
16
|
+
defaultValue: boolean;
|
|
17
|
+
};
|
|
18
|
+
classNames: {
|
|
19
|
+
control: string;
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
args: {
|
|
24
|
+
placeholder: string;
|
|
25
|
+
allowClear: boolean;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export default meta;
|
|
29
|
+
export declare const Overview: {
|
|
30
|
+
render: (args: any) => JSX.Element;
|
|
31
|
+
};
|
|
32
|
+
export declare const WithInitialValue: {
|
|
33
|
+
render: (args: any) => JSX.Element;
|
|
34
|
+
};
|
|
35
|
+
export declare const CustomPlaceholder: {
|
|
36
|
+
args: {
|
|
37
|
+
placeholder: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export declare const Disabled: {
|
|
41
|
+
args: {
|
|
42
|
+
disabled: boolean;
|
|
43
|
+
defaultValue: string;
|
|
44
|
+
placeholder: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export declare const NoClearButton: {
|
|
48
|
+
args: {
|
|
49
|
+
allowClear: boolean;
|
|
50
|
+
defaultValue: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
export declare const CustomStyling: {
|
|
54
|
+
args: {
|
|
55
|
+
placeholder: string;
|
|
56
|
+
classNames: {
|
|
57
|
+
container: string;
|
|
58
|
+
input: string;
|
|
59
|
+
actionBtn: string;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
parameters: {
|
|
63
|
+
docs: {
|
|
64
|
+
description: {
|
|
65
|
+
story: string;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=Searchbar.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Searchbar.stories.d.ts","sourceRoot":"","sources":["../../../patterns/Searchbar/Searchbar.stories.tsx"],"names":[],"mappings":"AAGA,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BT,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,QAAQ;mBACJ,GAAG;CAKnB,CAAC;AAEF,eAAO,MAAM,gBAAgB;mBACZ,GAAG;CAKnB,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;CAI7B,CAAC;AAEF,eAAO,MAAM,QAAQ;;;;;;CAMpB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;CAKzB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;CAgBzB,CAAC"}
|