@takaro/lib-components 0.0.1 → 0.0.5

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.
Files changed (144) hide show
  1. package/package.json +5 -6
  2. package/src/components/actions/Button/index.tsx +68 -70
  3. package/src/components/actions/Button/style.ts +1 -1
  4. package/src/components/actions/ContextMenu/Group.tsx +1 -1
  5. package/src/components/actions/ContextMenu/MenuItem.tsx +4 -1
  6. package/src/components/actions/ContextMenu/index.tsx +11 -12
  7. package/src/components/actions/Dropdown/DropdownMenu.tsx +5 -2
  8. package/src/components/actions/Dropdown/DropdownTrigger.tsx +55 -57
  9. package/src/components/actions/Dropdown/useDropdown.tsx +1 -1
  10. package/src/components/actions/IconButton/index.tsx +11 -10
  11. package/src/components/actions/IconButton/style.ts +5 -2
  12. package/src/components/actions/ToggleButton/ToggleButton.tsx +26 -28
  13. package/src/components/actions/ToggleButton/ToggleButtonGroup.tsx +3 -8
  14. package/src/components/actions/ToggleButton/style.ts +5 -7
  15. package/src/components/charts/AreaChart/index.tsx +7 -8
  16. package/src/components/charts/BarChart/index.tsx +4 -4
  17. package/src/components/charts/GeoMercator/index.tsx +1 -1
  18. package/src/components/charts/Heatmap/index.tsx +3 -4
  19. package/src/components/charts/LineChart/index.tsx +3 -3
  20. package/src/components/charts/PieChart/index.tsx +1 -1
  21. package/src/components/charts/RadarChart/index.tsx +1 -1
  22. package/src/components/charts/RadialBarChart/index.tsx +1 -1
  23. package/src/components/charts/index.tsx +3 -0
  24. package/src/components/data/Avatar/index.tsx +7 -3
  25. package/src/components/data/Avatar/style.ts +2 -2
  26. package/src/components/data/Chip/index.tsx +39 -41
  27. package/src/components/data/Chip/style.ts +3 -2
  28. package/src/components/data/Console/Console.tsx +14 -12
  29. package/src/components/data/CopyId/index.tsx +3 -2
  30. package/src/components/data/Drawer/Drawer.stories.tsx +3 -5
  31. package/src/components/data/Drawer/DrawerContent.tsx +1 -1
  32. package/src/components/data/Drawer/DrawerHeading.tsx +30 -29
  33. package/src/components/data/Drawer/useDrawer.tsx +1 -1
  34. package/src/components/data/InfiniteScroll/index.tsx +37 -36
  35. package/src/components/data/Table/Table.stories.tsx +6 -2
  36. package/src/components/data/Table/index.tsx +63 -44
  37. package/src/components/data/Table/style.ts +3 -2
  38. package/src/components/data/Table/subcomponents/ColumnHeader/ColumnSettings.tsx +22 -19
  39. package/src/components/data/Table/subcomponents/ColumnHeader/index.tsx +3 -3
  40. package/src/components/data/Table/subcomponents/ColumnHeader/style.ts +2 -1
  41. package/src/components/data/Table/subcomponents/Filter/field.tsx +2 -3
  42. package/src/components/data/Table/subcomponents/Filter/index.tsx +6 -10
  43. package/src/components/data/Table/subcomponents/Pagination/{index.tsx → PagePicker.tsx} +7 -7
  44. package/src/components/data/Table/subcomponents/Pagination/PageSizeSelect.tsx +37 -0
  45. package/src/components/data/Table/subcomponents/Pagination/style.ts +1 -1
  46. package/src/components/dialogs/Dialog/Dialog.stories.tsx +1 -2
  47. package/src/components/dialogs/Dialog/DialogBody.tsx +18 -17
  48. package/src/components/dialogs/Dialog/DialogContent.tsx +30 -28
  49. package/src/components/dialogs/Dialog/DialogHeading.tsx +1 -1
  50. package/src/components/dialogs/Dialog/useDialog.tsx +1 -1
  51. package/src/components/feedback/Alert/index.tsx +74 -73
  52. package/src/components/feedback/NotificationBanner/NotificationBanner.test.tsx +1 -1
  53. package/src/components/feedback/NotificationBanner/index.tsx +1 -1
  54. package/src/components/feedback/Popover/PopoverContent.tsx +4 -1
  55. package/src/components/feedback/Popover/PopoverTrigger.tsx +33 -31
  56. package/src/components/feedback/Popover/usePopover.tsx +1 -1
  57. package/src/components/feedback/ProgressBar/index.tsx +1 -1
  58. package/src/components/feedback/QuestionTooltip/index.tsx +1 -2
  59. package/src/components/feedback/Tooltip/TooltipContent.tsx +4 -1
  60. package/src/components/feedback/Tooltip/TooltipTrigger.tsx +3 -3
  61. package/src/components/feedback/Tooltip/useTooltip.tsx +1 -1
  62. package/src/components/feedback/snacks/CookieConsent/index.tsx +5 -2
  63. package/src/components/feedback/snacks/Default/index.tsx +51 -50
  64. package/src/components/feedback/snacks/Drawer/index.tsx +22 -21
  65. package/src/components/feedback/snacks/NetworkDetector/index.tsx +35 -31
  66. package/src/components/inputs/CheckBox/Controlled.tsx +2 -3
  67. package/src/components/inputs/CheckBox/Generic.tsx +18 -72
  68. package/src/components/inputs/CheckBox/style.ts +40 -97
  69. package/src/components/inputs/CodeField/CodeField.stories.tsx +4 -5
  70. package/src/components/inputs/CodeField/index.tsx +1 -0
  71. package/src/components/inputs/Date/DatePicker/DatePicker.stories.tsx +2 -3
  72. package/src/components/inputs/Date/DatePicker/Generic.tsx +20 -10
  73. package/src/components/inputs/Date/DateRangePicker/Context.tsx +12 -1
  74. package/src/components/inputs/Date/DateRangePicker/Controlled.tsx +74 -0
  75. package/src/components/inputs/Date/DateRangePicker/DateRangePicker.stories.tsx +11 -6
  76. package/src/components/inputs/Date/DateRangePicker/DateSelector/Absolute.tsx +3 -3
  77. package/src/components/inputs/Date/DateRangePicker/DateSelector/Relative.tsx +1 -1
  78. package/src/components/inputs/Date/DateRangePicker/DateSelector/index.tsx +1 -1
  79. package/src/components/inputs/Date/DateRangePicker/{index.tsx → Generic.tsx} +43 -11
  80. package/src/components/inputs/Date/DateRangePicker/QuickSelect/index.tsx +1 -1
  81. package/src/components/inputs/Date/DateRangePicker/style.ts +19 -5
  82. package/src/components/inputs/Date/subcomponents/Calendar/index.tsx +1 -1
  83. package/src/components/inputs/Date/subcomponents/RelativePicker/index.tsx +1 -1
  84. package/src/components/inputs/DurationField/Generic.tsx +149 -152
  85. package/src/components/inputs/FileField/FileField.stories.tsx +6 -6
  86. package/src/components/inputs/FileField/Generic.tsx +101 -99
  87. package/src/components/inputs/InputProps.ts +0 -2
  88. package/src/components/inputs/RadioGroup/Controlled.tsx +1 -2
  89. package/src/components/inputs/RadioGroup/RadioGroup.stories.tsx +6 -4
  90. package/src/components/inputs/RadioGroup/RadioItem.tsx +54 -53
  91. package/src/components/inputs/Slider/Generic.tsx +1 -1
  92. package/src/components/inputs/Slider/Slider.stories.tsx +1 -1
  93. package/src/components/inputs/Slider/handle.tsx +1 -0
  94. package/src/components/inputs/Switch/Controlled.tsx +1 -2
  95. package/src/components/inputs/Switch/Generic.tsx +18 -45
  96. package/src/components/inputs/Switch/Switch.stories.tsx +2 -4
  97. package/src/components/inputs/Switch/style.ts +44 -38
  98. package/src/components/inputs/TagField/Generic.tsx +109 -109
  99. package/src/components/inputs/TextAreaField/Generic.tsx +41 -39
  100. package/src/components/inputs/TextAreaField/TextAreaField.stories.tsx +2 -3
  101. package/src/components/inputs/TextField/Generic.tsx +81 -79
  102. package/src/components/inputs/TextField/TextField.stories.tsx +3 -4
  103. package/src/components/inputs/index.ts +3 -2
  104. package/src/components/inputs/layout/Description.tsx +1 -2
  105. package/src/components/inputs/layout/InputWrapper.ts +2 -2
  106. package/src/components/inputs/selects/SelectField/Controlled.tsx +1 -2
  107. package/src/components/inputs/selects/SelectField/Generic/FilterInput.tsx +4 -1
  108. package/src/components/inputs/selects/SelectField/SelectField.stories.tsx +9 -10
  109. package/src/components/inputs/selects/SelectQueryField/Generic/index.tsx +200 -197
  110. package/src/components/inputs/selects/SelectQueryField/SelectQueryField.stories.tsx +1 -1
  111. package/src/components/inputs/selects/SubComponents/Option.tsx +3 -3
  112. package/src/components/inputs/selects/SubComponents/OptionGroup.tsx +1 -1
  113. package/src/components/inputs/selects/SubComponents/style.ts +18 -4
  114. package/src/components/inputs/selects/index.tsx +5 -2
  115. package/src/components/inputs/selects/sharedStyle.ts +1 -0
  116. package/src/components/navigation/HorizontalNav/index.tsx +5 -32
  117. package/src/components/navigation/HorizontalNav/style.ts +11 -26
  118. package/src/components/navigation/IconNav/index.tsx +1 -1
  119. package/src/components/navigation/Steppers/SlimStepper/index.tsx +1 -1
  120. package/src/components/navigation/Steppers/SlimStepper/style.ts +1 -2
  121. package/src/components/navigation/Steppers/Stepper/index.tsx +1 -1
  122. package/src/components/navigation/Steppers/context.tsx +2 -2
  123. package/src/components/navigation/Tabs/Content.tsx +4 -1
  124. package/src/components/navigation/Tabs/Trigger.tsx +24 -23
  125. package/src/components/navigation/index.ts +1 -1
  126. package/src/components/other/ActionMenu/ActionMenu.stories.tsx +1 -2
  127. package/src/components/other/ActionMenu/index.tsx +30 -29
  128. package/src/components/other/Collapsible/CollapsibleTrigger.tsx +8 -4
  129. package/src/components/other/Company/index.tsx +25 -26
  130. package/src/components/other/Empty/Empty.stories.tsx +1 -1
  131. package/src/components/other/Empty/index.tsx +1 -3
  132. package/src/components/other/PermissionsGuard/index.tsx +2 -2
  133. package/src/components/visual/Card/index.tsx +4 -1
  134. package/src/errors/base.ts +4 -1
  135. package/src/errors/errors.ts +19 -2
  136. package/src/helpers/getSnackbarProvider.tsx +3 -3
  137. package/src/helpers/regexprs.ts +1 -0
  138. package/src/hooks/useFocus.tsx +3 -1
  139. package/src/hooks/useOnScreen.ts +1 -1
  140. package/src/hooks/useTableActions.ts +10 -5
  141. package/src/styled/GlobalStyle.ts +2 -1
  142. package/src/styled/zIndex.ts +1 -1
  143. package/src/test/testUtils.tsx +3 -0
  144. package/src/components/data/Table/subcomponents/index.ts +0 -4
@@ -22,117 +22,117 @@ export interface TagFieldProps {
22
22
  // these are props that should only be available on the generic version.
23
23
  export type GenericTagFieldProps = TagFieldProps & GenericInputPropsFunctionHandlers<string[], HTMLInputElement>;
24
24
 
25
- export const GenericTagField = forwardRef<HTMLDivElement, GenericTagFieldProps>(
26
- (
27
- {
28
- onRemoved,
29
- separators = [],
30
- name,
31
- readOnly,
32
- placeholder,
33
- // TODO: tagValidationSchema,
34
- disableBackspaceRemove,
35
- value = [],
36
- onKeyUp,
37
- allowDuplicates = false,
38
- isEditOnRemove,
39
- disabled = false,
40
- onBlur = () => {},
41
- onFocus = () => {},
42
- onChange,
43
- required,
44
- hasDescription,
45
- },
46
- ref
47
- ) => {
48
- const combinedSeparators = [...defaultSeparators, ...separators];
49
- const [tags, setTags] = useState<string[]>(Array.isArray(value) ? value : []);
50
-
51
- useDidUpdateEffect(() => {
52
- onChange(tags);
53
- }, [tags]);
54
-
55
- const handleKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {
56
- e.stopPropagation();
57
- const text = e.currentTarget.value;
58
-
59
- // handle tag removing
60
- if (!text && !disableBackspaceRemove && tags.length && e.key === 'Backspace') {
61
- e.currentTarget.value = isEditOnRemove ? `${tags.at(-1)} ` : '';
62
- setTags([...tags.slice(0, -1)]);
25
+ export const GenericTagField = forwardRef<HTMLDivElement, GenericTagFieldProps>(function GenericTagField(
26
+ {
27
+ onRemoved,
28
+ separators = [],
29
+ name,
30
+ readOnly,
31
+ placeholder,
32
+ // TODO: tagValidationSchema,
33
+ disableBackspaceRemove,
34
+ value = [],
35
+ onKeyUp,
36
+ allowDuplicates = false,
37
+ isEditOnRemove,
38
+ disabled = false,
39
+ onBlur = () => {},
40
+ onFocus = () => {},
41
+ onChange,
42
+ required,
43
+ hasDescription,
44
+ },
45
+ ref,
46
+ ) {
47
+ const combinedSeparators = [...defaultSeparators, ...separators];
48
+ const [tags, setTags] = useState<string[]>(Array.isArray(value) ? value : []);
49
+
50
+ useDidUpdateEffect(() => {
51
+ onChange(tags);
52
+ }, [tags]);
53
+
54
+ const handleKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {
55
+ e.stopPropagation();
56
+ const text = e.currentTarget.value;
57
+
58
+ // handle tag removing
59
+ if (!text && !disableBackspaceRemove && tags.length && e.key === 'Backspace') {
60
+ e.currentTarget.value = isEditOnRemove ? `${tags.at(-1)} ` : '';
61
+ setTags([...tags.slice(0, -1)]);
62
+ }
63
+
64
+ // handle new tag confirmation
65
+ if (text && combinedSeparators.includes(e.key)) {
66
+ e.preventDefault();
67
+
68
+ // TODO: check tag validation logic
69
+ // if (tagValidationSchema && tagValidationSchema.parse(tags)) return;
70
+
71
+ if (tags.includes(text) && !allowDuplicates) {
72
+ // should not add duplicate tags
73
+ return;
63
74
  }
64
75
 
65
- // handle new tag confirmation
66
- if (text && combinedSeparators.includes(e.key)) {
67
- e.preventDefault();
68
-
69
- // TODO: check tag validation logic
70
- // if (tagValidationSchema && tagValidationSchema.parse(tags)) return;
71
-
72
- if (tags.includes(text) && !allowDuplicates) {
73
- // should not add duplicate tags
74
- return;
75
- }
76
-
77
- setTags([...tags, text]);
78
-
79
- // clear input field
80
- e.currentTarget.value = '';
81
- }
82
- };
83
-
84
- useEffect(() => {
85
- // remove duplicates from tag list when allowDuplicates is set to false
86
- if (!allowDuplicates) {
87
- setTags([...new Set(tags)]);
88
- }
89
- }, [allowDuplicates]);
90
-
91
- const onTagDelete = (text: string) => {
92
- setTags(tags.filter((tag) => tag !== text));
93
- onRemoved && onRemoved(text);
94
- };
95
-
96
- const handleOnPaste = (event: ClipboardEvent<HTMLInputElement>) => {
97
- const pasteText = event.clipboardData.getData('text');
98
- if (pasteText.length < 1) return;
99
-
100
- const pasteTags = splitPaste({
101
- text: pasteText,
102
- tags,
103
- separators: combinedSeparators,
104
- });
105
- setTags([...tags, ...pasteTags]);
106
- event.preventDefault();
107
- };
108
-
109
- return (
110
- <TagsContainer aria-labelledby={name} ref={ref}>
111
- {tags.map((tag) => (
112
- <Tag
113
- key={tag}
114
- label={tag}
115
- onDelete={() => onTagDelete(tag)}
116
- disabled={disabled}
117
- readOnly={readOnly}
118
- color="secondary"
119
- />
120
- ))}
121
- <input
122
- type="text"
123
- name={name}
124
- placeholder={placeholder}
76
+ setTags([...tags, text]);
77
+
78
+ // clear input field
79
+ e.currentTarget.value = '';
80
+ }
81
+ };
82
+
83
+ useEffect(() => {
84
+ // remove duplicates from tag list when allowDuplicates is set to false
85
+ if (!allowDuplicates) {
86
+ setTags([...new Set(tags)]);
87
+ }
88
+ }, [allowDuplicates]);
89
+
90
+ const onTagDelete = (text: string) => {
91
+ setTags(tags.filter((tag) => tag !== text));
92
+ if (onRemoved) {
93
+ onRemoved(text);
94
+ }
95
+ };
96
+
97
+ const handleOnPaste = (event: ClipboardEvent<HTMLInputElement>) => {
98
+ const pasteText = event.clipboardData.getData('text');
99
+ if (pasteText.length < 1) return;
100
+
101
+ const pasteTags = splitPaste({
102
+ text: pasteText,
103
+ tags,
104
+ separators: combinedSeparators,
105
+ });
106
+ setTags([...tags, ...pasteTags]);
107
+ event.preventDefault();
108
+ };
109
+
110
+ return (
111
+ <TagsContainer aria-labelledby={name} ref={ref}>
112
+ {tags.map((tag) => (
113
+ <Tag
114
+ key={tag}
115
+ label={tag}
116
+ onDelete={() => onTagDelete(tag)}
125
117
  disabled={disabled}
126
- onKeyDown={handleKeyDown}
127
- onKeyUp={onKeyUp}
128
118
  readOnly={readOnly}
129
- onBlur={onBlur}
130
- onPaste={handleOnPaste}
131
- onFocus={onFocus}
132
- aria-describedby={setAriaDescribedBy(name, hasDescription)}
133
- aria-required={required}
119
+ color="secondary"
134
120
  />
135
- </TagsContainer>
136
- );
137
- }
138
- );
121
+ ))}
122
+ <input
123
+ type="text"
124
+ name={name}
125
+ placeholder={placeholder}
126
+ disabled={disabled}
127
+ onKeyDown={handleKeyDown}
128
+ onKeyUp={onKeyUp}
129
+ readOnly={readOnly}
130
+ onBlur={onBlur}
131
+ onPaste={handleOnPaste}
132
+ onFocus={onFocus}
133
+ aria-describedby={setAriaDescribedBy(name, hasDescription)}
134
+ aria-required={required}
135
+ />
136
+ </TagsContainer>
137
+ );
138
+ });
@@ -12,45 +12,47 @@ export interface TextAreaFieldProps {
12
12
  export type GenericTextAreaFieldProps = TextAreaFieldProps & GenericInputProps<string, HTMLTextAreaElement>;
13
13
 
14
14
  const defaultsApplier = defaultInputPropsFactory<TextAreaFieldProps & GenericInputProps<string, HTMLTextAreaElement>>(
15
- defaultInputProps
15
+ defaultInputProps,
16
16
  );
17
17
 
18
- export const GenericTextAreaField = forwardRef<HTMLTextAreaElement, GenericTextAreaFieldProps>((props, ref) => {
19
- const {
20
- disabled,
21
- required,
22
- onBlur = () => {},
23
- placeholder,
24
- onChange,
25
- onFocus = () => {},
26
- name,
27
- rows = 4,
28
- hasError,
29
- hasDescription,
30
- value,
31
- readOnly,
32
- id,
33
- } = defaultsApplier(props);
18
+ export const GenericTextAreaField = forwardRef<HTMLTextAreaElement, GenericTextAreaFieldProps>(
19
+ function GenericTextAreaField(props, ref) {
20
+ const {
21
+ disabled,
22
+ required,
23
+ onBlur = () => {},
24
+ placeholder,
25
+ onChange,
26
+ onFocus = () => {},
27
+ name,
28
+ rows = 4,
29
+ hasError,
30
+ hasDescription,
31
+ value,
32
+ readOnly,
33
+ id,
34
+ } = defaultsApplier(props);
34
35
 
35
- return (
36
- <TextAreaContainer>
37
- <TextArea
38
- hasError={hasError}
39
- id={id}
40
- name={name}
41
- onChange={onChange}
42
- onBlur={onBlur}
43
- onFocus={onFocus}
44
- placeholder={placeholder}
45
- readOnly={readOnly}
46
- role="presentation"
47
- disabled={disabled}
48
- ref={ref}
49
- value={value}
50
- rows={rows}
51
- aria-required={required}
52
- aria-describedby={setAriaDescribedBy(name, hasDescription)}
53
- />
54
- </TextAreaContainer>
55
- );
56
- });
36
+ return (
37
+ <TextAreaContainer>
38
+ <TextArea
39
+ hasError={hasError}
40
+ id={id}
41
+ name={name}
42
+ onChange={onChange}
43
+ onBlur={onBlur}
44
+ onFocus={onFocus}
45
+ placeholder={placeholder}
46
+ readOnly={readOnly}
47
+ role="presentation"
48
+ disabled={disabled}
49
+ ref={ref}
50
+ value={value}
51
+ rows={rows}
52
+ aria-required={required}
53
+ aria-describedby={setAriaDescribedBy(name, hasDescription)}
54
+ />
55
+ </TextAreaContainer>
56
+ );
57
+ },
58
+ );
@@ -1,5 +1,4 @@
1
- import React from 'react';
2
- import { useState } from 'react';
1
+ import React, { useState } from 'react';
3
2
  import { Meta, StoryFn } from '@storybook/react';
4
3
  import { styled } from '../../../styled';
5
4
  import { TextAreaField, TextAreaFieldProps, Button } from '../../../components';
@@ -31,7 +30,7 @@ export default {
31
30
  } as Meta<TextAreaFieldProps>;
32
31
 
33
32
  const validationSchema = z.object({
34
- name: z.string().min(6).nonempty('Name is a required field.'),
33
+ name: z.string().min(6),
35
34
  });
36
35
 
37
36
  type FormFields = { name: string };
@@ -27,87 +27,89 @@ export type GenericTextFieldProps = GenericInputProps<string, HTMLInputElement>
27
27
 
28
28
  const defaultsApplier = defaultInputPropsFactory<GenericTextFieldProps>(defaultInputProps);
29
29
 
30
- export const GenericTextField = forwardRef<HTMLInputElement, GenericTextFieldProps>((props, ref) => {
31
- const {
32
- onChange,
33
- onBlur = () => {},
34
- onFocus = () => {},
35
- name,
36
- disabled,
37
- required,
38
- readOnly,
39
- hasError,
40
- placeholder,
41
- icon,
42
- type = 'text',
43
- prefix,
44
- suffix,
45
- value,
46
- id,
47
- hasDescription,
48
- } = defaultsApplier(props);
30
+ export const GenericTextField = forwardRef<HTMLInputElement, GenericTextFieldProps>(
31
+ function GenericTextField(props, ref) {
32
+ const {
33
+ onChange,
34
+ onBlur = () => {},
35
+ onFocus = () => {},
36
+ name,
37
+ disabled,
38
+ required,
39
+ readOnly,
40
+ hasError,
41
+ placeholder,
42
+ icon,
43
+ type = 'text',
44
+ prefix,
45
+ suffix,
46
+ value,
47
+ id,
48
+ hasDescription,
49
+ } = defaultsApplier(props);
49
50
 
50
- const [showPassword, setShowPassword] = useState(false);
51
+ const [showPassword, setShowPassword] = useState(false);
51
52
 
52
- const handleOnChange = (e: ChangeEvent<HTMLInputElement>) => {
53
- // not a perfect solution, but works for now
54
- if (type === 'number') {
55
- if (isNumber(e.target.value) || e.target.value === '-') {
53
+ const handleOnChange = (e: ChangeEvent<HTMLInputElement>) => {
54
+ // not a perfect solution, but works for now
55
+ if (type === 'number') {
56
+ if (isNumber(e.target.value) || e.target.value === '-') {
57
+ onChange(e);
58
+ }
59
+ } else {
56
60
  onChange(e);
57
61
  }
58
- } else {
59
- onChange(e);
60
- }
61
- };
62
+ };
62
63
 
63
- return (
64
- <InputContainer>
65
- {prefix && <PrefixContainer hasError={hasError}>{prefix}</PrefixContainer>}
66
- {icon && cloneElement(icon, { size: 18, className: 'icon' })}
67
- <Input
68
- autoCapitalize="off"
69
- autoComplete={type === 'password' ? 'new-password' : 'off'}
70
- hasError={hasError}
71
- hasIcon={!!icon}
72
- hasPrefix={!!prefix}
73
- hasSuffix={!!suffix}
74
- isPassword={type === 'password'}
75
- id={id}
76
- name={name}
77
- onChange={handleOnChange}
78
- onBlur={onBlur}
79
- onFocus={onFocus}
80
- placeholder={placeholder}
81
- disabled={disabled}
82
- readOnly={readOnly}
83
- role="presentation"
84
- inputMode={getInputMode(type)}
85
- type={getFieldType(type, showPassword)}
86
- ref={ref}
87
- value={value}
88
- aria-readonly={readOnly}
89
- aria-required={required}
90
- aria-describedby={setAriaDescribedBy(name, hasDescription)}
91
- />
92
- {type === 'password' &&
93
- (showPassword ? (
94
- <HidePasswordIcon
95
- className="password-icon"
96
- onClick={() => {
97
- setShowPassword(false);
98
- }}
99
- size={18}
100
- />
101
- ) : (
102
- <ShowPasswordIcon
103
- className="password-icon"
104
- onClick={() => {
105
- setShowPassword(true);
106
- }}
107
- size={18}
108
- />
109
- ))}
110
- {suffix && <SuffixContainer hasError={hasError}>{suffix}</SuffixContainer>}
111
- </InputContainer>
112
- );
113
- });
64
+ return (
65
+ <InputContainer>
66
+ {prefix && <PrefixContainer hasError={hasError}>{prefix}</PrefixContainer>}
67
+ {icon && cloneElement(icon, { size: 18, className: 'icon' })}
68
+ <Input
69
+ autoCapitalize="off"
70
+ autoComplete={type === 'password' ? 'new-password' : 'off'}
71
+ hasError={hasError}
72
+ hasIcon={!!icon}
73
+ hasPrefix={!!prefix}
74
+ hasSuffix={!!suffix}
75
+ isPassword={type === 'password'}
76
+ id={id}
77
+ name={name}
78
+ onChange={handleOnChange}
79
+ onBlur={onBlur}
80
+ onFocus={onFocus}
81
+ placeholder={placeholder}
82
+ disabled={disabled}
83
+ readOnly={readOnly}
84
+ role="presentation"
85
+ inputMode={getInputMode(type)}
86
+ type={getFieldType(type, showPassword)}
87
+ ref={ref}
88
+ value={value}
89
+ aria-readonly={readOnly}
90
+ aria-required={required}
91
+ aria-describedby={setAriaDescribedBy(name, hasDescription)}
92
+ />
93
+ {type === 'password' &&
94
+ (showPassword ? (
95
+ <HidePasswordIcon
96
+ className="password-icon"
97
+ onClick={() => {
98
+ setShowPassword(false);
99
+ }}
100
+ size={18}
101
+ />
102
+ ) : (
103
+ <ShowPasswordIcon
104
+ className="password-icon"
105
+ onClick={() => {
106
+ setShowPassword(true);
107
+ }}
108
+ size={18}
109
+ />
110
+ ))}
111
+ {suffix && <SuffixContainer hasError={hasError}>{suffix}</SuffixContainer>}
112
+ </InputContainer>
113
+ );
114
+ },
115
+ );
@@ -1,5 +1,4 @@
1
- import React from 'react';
2
- import { useState } from 'react';
1
+ import React, { useState } from 'react';
3
2
  import { Meta, StoryFn } from '@storybook/react';
4
3
  import { styled } from '../../../styled';
5
4
  import { TextField, TextFieldProps, Button } from '../../../components';
@@ -38,11 +37,11 @@ export default {
38
37
  } as Meta<TextFieldProps>;
39
38
 
40
39
  const validationSchema = z.object({
41
- name: z.string().min(6).nonempty('Name is a required field.'),
40
+ name: z.string().min(6, 'Name must be at least 6 characters'),
42
41
  });
43
42
  type FormFields = { name: string };
44
43
 
45
- export const onChange: StoryFn<TextFieldProps> = (args) => {
44
+ export const OnChange: StoryFn<TextFieldProps> = (args) => {
46
45
  const { control } = useForm({ mode: 'onChange' });
47
46
  const TextFieldValue = useWatch({ name: args.name, control });
48
47
 
@@ -55,8 +55,9 @@ export { ErrorMessage } from './layout/ErrorMessage';
55
55
  export { InputWrapper } from './layout/InputWrapper';
56
56
  export { Description } from './layout/Description';
57
57
 
58
- export { DateRangePicker } from './Date/DateRangePicker';
59
- export type { DateRangePickerProps } from './Date/DateRangePicker';
58
+ export { ControlledDateRangePicker as DateRangePicker } from './Date/DateRangePicker/Controlled';
59
+ export type { DateRangePickerProps } from './Date/DateRangePicker/Generic';
60
+ export { GenericDateRangePicker as UnControlledDateRangePicker } from './Date/DateRangePicker/Generic';
60
61
 
61
62
  export { ControlledDurationField as DurationField } from './DurationField/Controlled';
62
63
  export type { ControlledDurationFieldProps as DurationFieldProps } from './DurationField/Controlled';
@@ -27,9 +27,8 @@ export const Description: FC<DescriptionProps> = ({ description, inputName, styl
27
27
  {part}
28
28
  </a>
29
29
  );
30
- } else {
31
- return part;
32
30
  }
31
+ return part;
33
32
  })}
34
33
  </StyledP>
35
34
  );
@@ -1,6 +1,6 @@
1
1
  import { styled } from '../../../styled';
2
2
 
3
- export const InputWrapper = styled.div<{ marginBottom?: string }>`
3
+ export const InputWrapper = styled.div`
4
4
  width: 100%;
5
- margin-bottom: ${({ theme, marginBottom }) => (marginBottom ? marginBottom : theme.spacing[2])};
5
+ margin-bottom: ${({ theme }) => theme.spacing[2]};
6
6
  `;
@@ -32,7 +32,6 @@ export const ControlledSelectField: FC<ControlledSelectFieldProps> & SubComponen
32
32
  enableFilter,
33
33
  inPortal,
34
34
  canClear,
35
- hasMargin = true,
36
35
  } = defaultsApplier(props);
37
36
 
38
37
  const {
@@ -81,7 +80,7 @@ export const ControlledSelectField: FC<ControlledSelectFieldProps> & SubComponen
81
80
  }
82
81
 
83
82
  return (
84
- <InputWrapper marginBottom={hasMargin ? undefined : '0'}>
83
+ <InputWrapper>
85
84
  <Container>
86
85
  {label && (
87
86
  <Label
@@ -19,7 +19,10 @@ interface FilterInputProps {
19
19
  onFilterChange: (value: string) => void;
20
20
  }
21
21
 
22
- export const FilterInput = forwardRef<HTMLInputElement, FilterInputProps>(({ selectName, onFilterChange }, ref) => {
22
+ export const FilterInput = forwardRef<HTMLInputElement, FilterInputProps>(function FilterInput(
23
+ { selectName, onFilterChange },
24
+ ref,
25
+ ) {
23
26
  const [inputValue, setInputValue] = useState<string>('');
24
27
  const onChangeHandler = (value: string) => {
25
28
  setInputValue(value);
@@ -1,6 +1,5 @@
1
- import React from 'react';
2
1
  import { Meta, StoryFn } from '@storybook/react';
3
- import { useMemo, useState } from 'react';
2
+ import React, { useMemo, useState } from 'react';
4
3
  import { Button, SelectField, SelectFieldProps } from '../../../../components';
5
4
  import { SubmitHandler, useForm, useWatch } from 'react-hook-form';
6
5
  import { styled } from '../../../../styled';
@@ -34,7 +33,7 @@ const OptionIcon = styled.img`
34
33
  color: transparent;
35
34
  `;
36
35
 
37
- export const onChange: StoryFn<SelectFieldProps & ExtraStoryProps> = (args) => {
36
+ export const OnChange: StoryFn<SelectFieldProps & ExtraStoryProps> = (args) => {
38
37
  const { control } = useForm();
39
38
  const selectValue = useWatch({ control, name: 'film' });
40
39
 
@@ -88,7 +87,7 @@ export const OnSubmit: StoryFn<SelectFieldProps> = (args) => {
88
87
  z.object({
89
88
  film: z.enum(['not-sure-how-this-works', ...films.map((film) => film.name)]),
90
89
  }),
91
- []
90
+ [],
92
91
  );
93
92
 
94
93
  const { control, handleSubmit } = useForm<FormFields>({
@@ -151,7 +150,7 @@ export const MultiSelect: StoryFn<SelectFieldProps> = (args) => {
151
150
  z.object({
152
151
  film: z.string().array(),
153
152
  }),
154
- []
153
+ [],
155
154
  );
156
155
 
157
156
  const { control, handleSubmit } = useForm<FormFields>({
@@ -182,11 +181,11 @@ export const MultiSelect: StoryFn<SelectFieldProps> = (args) => {
182
181
  {selectedFilms.length === 0
183
182
  ? 'Select...'
184
183
  : selectedFilms.length <= 3
185
- ? selectedFilms.map((film) => film.name).join(', ')
186
- : `${selectedFilms
187
- .slice(0, 3)
188
- .map((film) => film.name)
189
- .join(', ')} and ${selectedFilms.length - 3} more`}
184
+ ? selectedFilms.map((film) => film.name).join(', ')
185
+ : `${selectedFilms
186
+ .slice(0, 3)
187
+ .map((film) => film.name)
188
+ .join(', ')} and ${selectedFilms.length - 3} more`}
190
189
  </div>
191
190
  );
192
191
  }}