@platformatic/ui-components 0.2.16 → 0.2.19

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.
@@ -35,18 +35,13 @@ Default.args = {
35
35
  const TemplateBorderMainDarkBlue = (args) => {
36
36
  const [value, setValue] = useState('')
37
37
 
38
- function handleChange (event) {
39
- setValue(event.target.value)
40
- }
41
-
42
38
  function handleSelect (event) {
43
39
  setValue(event.detail.label)
44
40
  }
45
41
 
46
42
  return (
47
43
  <div style={{ backgroundColor: 'white', padding: '20px 10px' }}>
48
- <p>Value of the input {value}</p>
49
- <Select {...args} value={value} onChange={handleChange} onSelect={handleSelect} />
44
+ <Select {...args} value={value} onSelect={handleSelect} />
50
45
  </div>
51
46
  )
52
47
  }
@@ -54,10 +49,6 @@ const TemplateBorderMainDarkBlue = (args) => {
54
49
  const TemplateBorderMainDarkBlue2 = (args) => {
55
50
  const [value, setValue] = useState('')
56
51
 
57
- function handleChange (event) {
58
- setValue(event.target.value)
59
- }
60
-
61
52
  function handleSelect (event) {
62
53
  setValue(event.detail.label)
63
54
  }
@@ -66,7 +57,7 @@ const TemplateBorderMainDarkBlue2 = (args) => {
66
57
  <>
67
58
  <div style={{ backgroundColor: 'white', padding: '20px 10px' }}>
68
59
  <p>Value of the input {value}</p>
69
- <Select {...args} value={value} onChange={handleChange} onSelect={handleSelect} />
60
+ <Select {...args} value={value} onSelect={handleSelect} />
70
61
  <br />
71
62
  <Select placeholder='Disabled' disabled />
72
63
 
@@ -146,10 +137,6 @@ githubRepoExample.args = {
146
137
  const TemplateTransparent = (args) => {
147
138
  const [value, setValue] = useState('')
148
139
 
149
- function handleChange (event) {
150
- setValue(event.target.value)
151
- }
152
-
153
140
  function handleSelect (event) {
154
141
  setValue(event.detail.label)
155
142
  }
@@ -157,7 +144,7 @@ const TemplateTransparent = (args) => {
157
144
  return (
158
145
  <div style={{ padding: '20px 10px' }}>
159
146
  <p>Value of the input {value}</p>
160
- <Select {...args} value={value} onChange={handleChange} onSelect={handleSelect} />
147
+ <Select {...args} value={value} onSelect={handleSelect} />
161
148
  </div>
162
149
  )
163
150
  }
@@ -0,0 +1,176 @@
1
+ 'use strict'
2
+ import React, { useState } from 'react'
3
+ import SelectWithInput from '../../components/forms/SelectWithInput'
4
+ import { MAIN_DARK_BLUE, MAIN_GREEN, RICH_BLACK, WHITE } from '../../components/constants'
5
+
6
+ const divStyle = {
7
+ width: '100%',
8
+ height: 'auto',
9
+ padding: '20px',
10
+ backgroundColor: 'transparent'
11
+ }
12
+
13
+ export default {
14
+ title: 'Platformatic/Forms/SelectWithInput',
15
+ component: SelectWithInput,
16
+ decorators: [
17
+ (Story) => (
18
+ <div style={divStyle}>
19
+ <Story />
20
+ </div>
21
+ )
22
+ ]
23
+ }
24
+
25
+ const Template = (args) => <SelectWithInput {...args} />
26
+
27
+ export const Default = Template.bind({})
28
+
29
+ Default.args = {
30
+ name: 'test',
31
+ placeholder: 'Platformatic empty select',
32
+ borderColor: MAIN_GREEN
33
+ }
34
+
35
+ const TemplateBorderMainDarkBlue = (args) => {
36
+ const [value, setValue] = useState('')
37
+
38
+ function handleChange (event) {
39
+ setValue(event.target.value)
40
+ }
41
+
42
+ function handleSelect (event) {
43
+ setValue(event.detail.label)
44
+ }
45
+
46
+ return (
47
+ <div style={{ backgroundColor: 'white', padding: '20px 10px' }}>
48
+ <p>Value of the input {value}</p>
49
+ <SelectWithInput {...args} value={value} onChange={handleChange} onSelect={handleSelect} />
50
+ </div>
51
+ )
52
+ }
53
+
54
+ const TemplateBorderMainDarkBlue2 = (args) => {
55
+ const [value, setValue] = useState('')
56
+
57
+ function handleChange (event) {
58
+ setValue(event.target.value)
59
+ }
60
+
61
+ function handleSelect (event) {
62
+ setValue(event.detail.label)
63
+ }
64
+
65
+ return (
66
+ <>
67
+ <div style={{ backgroundColor: 'white', padding: '20px 10px' }}>
68
+ <p>Value of the input {value}</p>
69
+ <SelectWithInput {...args} value={value} onChange={handleChange} onSelect={handleSelect} />
70
+ <br />
71
+ <SelectWithInput placeholder='Disabled' disabled />
72
+
73
+ </div>
74
+ </>
75
+ )
76
+ }
77
+
78
+ export const BorderMainDarkBlue = TemplateBorderMainDarkBlue.bind({})
79
+
80
+ BorderMainDarkBlue.args = {
81
+ name: 'test',
82
+ placeholder: 'Defaul option',
83
+ options: [...Array(20).keys()].map(ele => ({ label: `Option ${ele}`, value: `Value${ele}`, iconName: 'SocialGitHubIcon' })),
84
+ borderColor: MAIN_DARK_BLUE
85
+ }
86
+
87
+ export const DefaultInvalid = TemplateBorderMainDarkBlue.bind({})
88
+
89
+ DefaultInvalid.args = {
90
+ name: 'test',
91
+ placeholder: 'Platformatic empty select',
92
+ options: [{ label: 'Option 1', value: '1' }, { label: 'Option 2', value: '2' }, { label: 'Option 3', value: '3' }],
93
+ borderColor: MAIN_GREEN,
94
+ errorMessage: 'This is an error message'
95
+ }
96
+
97
+ export const withDifferentOptions = TemplateBorderMainDarkBlue2.bind({})
98
+
99
+ withDifferentOptions.args = {
100
+ name: 'test',
101
+ placeholder: 'Platformatic',
102
+ options: [...Array(20).keys()].map(ele => ({
103
+ label: `Option ${ele}`,
104
+ value: `Value${ele}`,
105
+ iconName: 'SocialGitHubIcon'
106
+ })).concat({
107
+ label: 'Last but not least',
108
+ iconName: 'AddIcon',
109
+ value: 123123,
110
+ notSelectable: true,
111
+ onClick: () => alert('you clicked last but not least')
112
+ }).concat({
113
+ label: 'Play',
114
+ iconName: 'PlayIcon',
115
+ value: 123123,
116
+ notSelectable: true
117
+ }),
118
+ borderColor: MAIN_DARK_BLUE
119
+ }
120
+
121
+ export const githubRepoExample = TemplateBorderMainDarkBlue2.bind({})
122
+
123
+ githubRepoExample.args = {
124
+ name: 'test',
125
+ placeholder: 'Platformatic',
126
+ options: [...Array(4).keys()].map(ele => ({
127
+ label: `GitHub Repo ${ele}`,
128
+ value: `Value${ele}`,
129
+ iconName: 'SocialGitHubIcon'
130
+ })).concat({
131
+ label: 'this is an option that is not selectable',
132
+ iconName: 'AddIcon',
133
+ value: 123123,
134
+ notSelectable: true,
135
+ onClick: () => alert('you clicked last but not least')
136
+ }).concat({
137
+ label: 'Add Github repo',
138
+ iconName: 'PlayIcon',
139
+ value: 123123,
140
+ notSelectable: true,
141
+ notFilterable: true
142
+ }),
143
+ borderColor: MAIN_DARK_BLUE
144
+ }
145
+
146
+ const TemplateTransparent = (args) => {
147
+ const [value, setValue] = useState('')
148
+
149
+ function handleChange (event) {
150
+ setValue(event.target.value)
151
+ }
152
+
153
+ function handleSelect (event) {
154
+ setValue(event.detail.label)
155
+ }
156
+
157
+ return (
158
+ <div style={{ padding: '20px 10px' }}>
159
+ <p>Value of the input {value}</p>
160
+ <SelectWithInput {...args} value={value} onChange={handleChange} onSelect={handleSelect} />
161
+ </div>
162
+ )
163
+ }
164
+
165
+ export const TemplateBackgroundTransparent = TemplateTransparent.bind({})
166
+
167
+ TemplateBackgroundTransparent.args = {
168
+ name: 'test',
169
+ placeholder: 'Defaul option',
170
+ optionsBorderedBottom: false,
171
+ options: [...Array(20).keys()].map(ele => ({ label: `Option ${ele}`, value: `Value${ele}`, iconName: 'OrganizationIcon' })),
172
+ borderColor: WHITE,
173
+ mainColor: WHITE,
174
+ backgroundColor: RICH_BLACK,
175
+ borderListColor: WHITE
176
+ }