agroptima-design-system 0.21.6 → 0.22.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agroptima-design-system",
3
- "version": "0.21.6",
3
+ "version": "0.22.0",
4
4
  "scripts": {
5
5
  "dev": "npm run storybook",
6
6
  "storybook": "storybook dev -p 6006 --ci",
@@ -34,7 +34,7 @@ export function Input({
34
34
  }: InputProps): React.JSX.Element {
35
35
  const identifier = id || name
36
36
  const [showPassword, setShowPassword] = useState(false)
37
- const cssClasses = classNames('input', className, {
37
+ const cssClasses = classNames('input', {
38
38
  'with-icon': icon,
39
39
  invalid: errors?.length,
40
40
  })
@@ -55,7 +55,7 @@ export function Input({
55
55
  }
56
56
 
57
57
  return (
58
- <div className={`input-group ${variant}`}>
58
+ <div className={classNames('input-group', variant, className)}>
59
59
  {!hideLabel && (
60
60
  <label className="input-label" htmlFor={identifier}>
61
61
  {label}
@@ -21,7 +21,7 @@
21
21
 
22
22
  .selected-option {
23
23
  border-radius: config.$corner-radius-m;
24
- border: 1px solid color_alias.$neutral-color-600;
24
+ border: 1px solid color_alias.$neutral-color-400;
25
25
  background: color_alias.$neutral-white;
26
26
  @include typography.select-text;
27
27
 
@@ -64,6 +64,9 @@
64
64
  }
65
65
 
66
66
  .select-options {
67
+ max-height: 256px;
68
+ overflow-y: scroll;
69
+ overflow-anchor: none;
67
70
  z-index: depth.$z-dropdown-options;
68
71
  border-radius: config.$corner-radius-xxs;
69
72
  background: color_alias.$neutral-white;
@@ -20,10 +20,12 @@ export interface SelectProps extends InputPropsWithoutOnChange {
20
20
  label: string
21
21
  accessibilityLabel?: string
22
22
  hideLabel?: boolean
23
- selected?: Option
23
+ defaultValue?: string
24
24
  onChange?: (value: string) => void
25
25
  }
26
26
 
27
+ const EMPTY_OPTION = { id: '', label: '' }
28
+
27
29
  export function Select({
28
30
  className,
29
31
  placeholder,
@@ -36,18 +38,17 @@ export function Select({
36
38
  label,
37
39
  accessibilityLabel,
38
40
  hideLabel = false,
39
- selected,
40
41
  onChange,
42
+ defaultValue,
41
43
  ...props
42
44
  }: SelectProps): React.JSX.Element {
43
45
  const helpTexts = buildHelpText(helpText, errors)
44
46
  const [showOptionsList, setShowOptionsList] = useState(false)
45
- const [selectedOption, setSelectedOption] = useState<Option>({
46
- id: selected?.id || '',
47
- label: selected?.label || '',
48
- })
47
+ const defaultOption =
48
+ options.find((option) => option.id === defaultValue) || EMPTY_OPTION
49
+ const [selectedOption, setSelectedOption] = useState<Option>(defaultOption)
49
50
 
50
- const cssClasses = classNames('selected-option', className, {
51
+ const cssClasses = classNames('selected-option', {
51
52
  open: showOptionsList,
52
53
  filled: selectedOption.id,
53
54
  disabled: disabled,
@@ -65,10 +66,6 @@ export function Select({
65
66
  if (onChange !== undefined) onChange(option.id)
66
67
  }
67
68
 
68
- function handleSelectIcon() {
69
- return showOptionsList ? 'AngleUp' : 'AngleDown'
70
- }
71
-
72
69
  function handleBlur(event: React.FocusEvent<HTMLDivElement>) {
73
70
  const isAComponentElement = event.relatedTarget
74
71
  if (!isAComponentElement) {
@@ -77,7 +74,7 @@ export function Select({
77
74
  }
78
75
 
79
76
  return (
80
- <div className={`select-group ${variant}`}>
77
+ <div className={classNames('select-group', variant, className)}>
81
78
  {!hideLabel && <span className="select-label">{label}</span>}
82
79
  <div className="select-container" onBlur={handleBlur}>
83
80
  <div
@@ -89,7 +86,7 @@ export function Select({
89
86
  role="alert"
90
87
  >
91
88
  <span>{selectedOption.label || placeholder}</span>
92
- <Icon name={handleSelectIcon()} />
89
+ <Icon name={showOptionsList ? 'AngleUp' : 'AngleDown'} />
93
90
  </div>
94
91
  {showOptionsList && (
95
92
  <ul className="select-options" role="listbox">
@@ -4,6 +4,13 @@ import { Meta } from "@storybook/blocks";
4
4
 
5
5
  # Changelog
6
6
 
7
+ ## 0.22.0
8
+
9
+ * Added FloatingButton component to Storybook
10
+
11
+ BREAKING CHANGES
12
+
13
+ * Replece selected prop by defaultValue in Select component
7
14
 
8
15
  ## 0.21.5
9
16
  * Update open state in Collapsible component
@@ -34,7 +34,7 @@ const meta = {
34
34
  options: {
35
35
  description: 'Array of values to be displayed on the select list',
36
36
  },
37
- selected: {
37
+ defaultValue: {
38
38
  description: 'Value to be displayed as selected',
39
39
  },
40
40
  errors: {
@@ -68,6 +68,21 @@ export const Primary: Story = {
68
68
  { id: '1', label: 'Nintendo Switch' },
69
69
  { id: '2', label: 'PlayStation 5' },
70
70
  { id: '3', label: 'Xbox Series S/X' },
71
+ { id: '4', label: 'PC' },
72
+ { id: '5', label: 'Mobile' },
73
+ { id: '6', label: 'PlayStation 4' },
74
+ { id: '7', label: 'Xbox One' },
75
+ { id: '8', label: 'PlayStation 3' },
76
+ { id: '9', label: 'Xbox 360' },
77
+ { id: '10', label: 'PlayStation 2' },
78
+ { id: '11', label: 'Xbox' },
79
+ { id: '12', label: 'PlayStation' },
80
+ { id: '13', label: 'Nintendo 64' },
81
+ { id: '14', label: 'Super Nintendo' },
82
+ { id: '15', label: 'Sega Genesis' },
83
+ { id: '16', label: 'Sega Saturn' },
84
+ { id: '17', label: 'Sega Dreamcast' },
85
+ { id: '18', label: 'Atari 2600' },
71
86
  ],
72
87
  id: 'select-videogames',
73
88
  onChange: (optionId) => console.log('onChange optionId:', optionId),
@@ -89,7 +104,7 @@ export const PrimaryWithSelectedOptions: Story = {
89
104
  { id: '2', label: 'PlayStation 5' },
90
105
  { id: '3', label: 'Xbox Series S/X' },
91
106
  ],
92
- selected: { id: '2', label: 'PlayStation 5' },
107
+ defaultValue: '2',
93
108
  id: 'select-videogames',
94
109
  },
95
110
  parameters: figmaPrimaryDesign,