@automattic/vip-design-system 0.26.0 → 0.26.2

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 (38) hide show
  1. package/.storybook/preview.js +6 -0
  2. package/build/system/Accordion/Accordion.js +5 -4
  3. package/build/system/Form/Checkbox.stories.js +85 -0
  4. package/build/system/Form/Input.js +55 -31
  5. package/build/system/Form/Input.stories.js +34 -4
  6. package/build/system/Form/Radio.stories.js +95 -0
  7. package/build/system/Form/Select.stories.js +1 -1
  8. package/build/system/Form/Textarea.js +14 -53
  9. package/build/system/Form/Textarea.stories.js +67 -0
  10. package/build/system/Form/Validation.js +17 -10
  11. package/build/system/NewConfirmationDialog/NewConfirmationDialog.stories.js +1 -1
  12. package/build/system/NewDialog/NewDialog.stories.js +1 -1
  13. package/build/system/NewForm/FormAutocomplete.js +22 -6
  14. package/build/system/NewForm/FormAutocomplete.stories.js +13 -2
  15. package/build/system/NewForm/index.js +12 -0
  16. package/build/system/NewTabs/Tabs.stories.js +11 -5
  17. package/build/system/NewTabs/TabsList.js +1 -1
  18. package/build/system/ResourceList/ResourceList.js +35 -26
  19. package/build/system/ResourceList/ResourceList.stories.js +2 -0
  20. package/build/system/Tabs/Tabs.stories.js +1 -1
  21. package/package.json +1 -1
  22. package/src/system/Accordion/Accordion.js +2 -1
  23. package/src/system/Form/Checkbox.stories.jsx +54 -0
  24. package/src/system/Form/Input.js +44 -27
  25. package/src/system/Form/Input.stories.jsx +29 -4
  26. package/src/system/Form/Radio.stories.jsx +66 -0
  27. package/src/system/Form/Select.stories.jsx +1 -1
  28. package/src/system/Form/Textarea.js +4 -49
  29. package/src/system/Form/Textarea.stories.jsx +40 -0
  30. package/src/system/Form/Validation.js +14 -8
  31. package/src/system/NewConfirmationDialog/NewConfirmationDialog.stories.jsx +1 -1
  32. package/src/system/NewDialog/NewDialog.stories.jsx +1 -1
  33. package/src/system/NewForm/FormAutocomplete.js +17 -6
  34. package/src/system/NewForm/FormAutocomplete.stories.jsx +13 -0
  35. package/src/system/NewForm/index.js +4 -1
  36. package/src/system/NewTabs/Tabs.stories.jsx +7 -3
  37. package/src/system/NewTabs/TabsList.js +1 -1
  38. package/src/system/Tabs/Tabs.stories.jsx +1 -1
@@ -3,7 +3,7 @@
3
3
  /**
4
4
  * External dependencies
5
5
  */
6
- import React, { useCallback, useEffect, useMemo } from 'react';
6
+ import React, { useCallback, useEffect, useMemo, useState } from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import { Label } from '../Form/Label';
9
9
  import Autocomplete from 'accessible-autocomplete/react';
@@ -42,6 +42,7 @@ const defaultStyles = {
42
42
  '&:focus-visible': { outlineWidth: 0, boxShadow: 'none' },
43
43
  '&:focus-within': { outlineWidth: 0, boxShadow: 'none' },
44
44
  '&.autocomplete__input--focused': { outlineWidth: 0, boxShadow: 'none' },
45
+ '&.autocomplete__input--show-all-values': { paddingRight: '40px' },
45
46
  },
46
47
  '& .autocomplete__menu': {
47
48
  borderWidth: '1px',
@@ -56,7 +57,6 @@ const defaultStyles = {
56
57
  },
57
58
  '& .autocomplete__wrapper': {
58
59
  width: '100%',
59
- paddingRight: '40px',
60
60
  },
61
61
  '& .autocomplete__input--show-all-values': {
62
62
  paddingRight: 0,
@@ -85,6 +85,8 @@ const FormAutocomplete = React.forwardRef(
85
85
  },
86
86
  forwardRef
87
87
  ) => {
88
+ const [ isDirty, setIsDirty ] = useState( false );
89
+
88
90
  const SelectLabel = () => <Label htmlFor={ forLabel || id }>{ label }</Label>;
89
91
 
90
92
  const inlineLabel = !! ( isInline && label );
@@ -120,12 +122,15 @@ const FormAutocomplete = React.forwardRef(
120
122
 
121
123
  const suggest = useCallback(
122
124
  ( query, populateResults ) => {
123
- const data = options.filter(
124
- option => optionLabel( option ).toLowerCase().indexOf( query.toLowerCase() ) >= 0
125
- );
125
+ let data = options;
126
+ if ( isDirty ) {
127
+ data = options.filter(
128
+ option => optionLabel( option ).toLowerCase().indexOf( query.toLowerCase() ) >= 0
129
+ );
130
+ }
126
131
  populateResults( data.map( option => optionLabel( option ) ) );
127
132
  },
128
- [ options ]
133
+ [ options, isDirty ]
129
134
  );
130
135
 
131
136
  useEffect( () => {
@@ -140,6 +145,12 @@ const FormAutocomplete = React.forwardRef(
140
145
  .setAttribute( 'aria-label', `${ label } list` );
141
146
  }, [ label ] );
142
147
 
148
+ useEffect( () => {
149
+ global.document.querySelector( `#${ id }` ).addEventListener( 'keydown', () => {
150
+ setIsDirty( true );
151
+ } );
152
+ }, [ setIsDirty ] );
153
+
143
154
  return (
144
155
  <>
145
156
  { label && ! isInline && <SelectLabel /> }
@@ -61,3 +61,16 @@ export const Inline = () => {
61
61
  </>
62
62
  );
63
63
  };
64
+
65
+ export const WithDefaultValue = () => {
66
+ const customArgs = {
67
+ ...args,
68
+ value: 'Chocolate',
69
+ };
70
+
71
+ return (
72
+ <>
73
+ <DefaultComponent { ...customArgs } />
74
+ </>
75
+ );
76
+ };
@@ -4,12 +4,15 @@
4
4
 
5
5
  import { FormSelect } from './FormSelect';
6
6
  import { FormAutocomplete } from './FormAutocomplete';
7
+ import { Textarea } from '../Form/Textarea';
8
+ import { Input } from '../Form/Input';
7
9
  import { Form } from './Form';
10
+ import { Label } from '../Form/Label';
8
11
 
9
12
  const Select = FormSelect;
10
13
  const Autocomplete = FormAutocomplete;
11
14
  const Root = Form;
12
15
 
13
- export { Root, Select, Autocomplete };
16
+ export { Root, Select, Autocomplete, Textarea, Input, Label };
14
17
 
15
18
  export default Root;
@@ -4,7 +4,7 @@
4
4
  import { NewTabs, TabsTrigger, TabsList, TabsContent, Text } from '..';
5
5
 
6
6
  export default {
7
- title: 'NewTabs',
7
+ title: 'Tabs',
8
8
  component: NewTabs,
9
9
  };
10
10
 
@@ -19,11 +19,15 @@ export const Default = () => (
19
19
  </TabsTrigger>
20
20
  </TabsList>
21
21
  <TabsContent value="all">
22
- <Text>All content</Text>
22
+ <Text>
23
+ All content <a href="https://google.com">https://google.com</a>
24
+ </Text>
23
25
  </TabsContent>
24
26
  <TabsContent value="live">Live content</TabsContent>
25
27
  <TabsContent value="dev">
26
- <Text>In Development content</Text>
28
+ <Text>
29
+ In Development content <button type="button">Hey I am a button</button>{ ' ' }
30
+ </Text>
27
31
  </TabsContent>
28
32
  </NewTabs>
29
33
  );
@@ -18,7 +18,7 @@ const TabsList = ( { children, title, sx } ) => (
18
18
  display: 'flex',
19
19
  ...sx,
20
20
  } }
21
- title={ title }
21
+ aria-label={ title }
22
22
  >
23
23
  { children }
24
24
  </TabsPrimitive.List>
@@ -4,7 +4,7 @@
4
4
  import { Tabs, TabItem } from '..';
5
5
 
6
6
  export default {
7
- title: 'Tabs',
7
+ title: 'Deprecated/Tabs',
8
8
  component: Tabs,
9
9
  };
10
10