@pareto-engineering/design-system 4.0.0-alpha.36 → 4.0.0-alpha.38

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 (33) hide show
  1. package/dist/cjs/f/FormInput/FormInput.js +6 -0
  2. package/dist/cjs/f/fields/ChoicesInput/styles.scss +2 -2
  3. package/dist/cjs/f/fields/LinkInput/LinkInput.js +164 -0
  4. package/dist/cjs/f/fields/LinkInput/index.js +13 -0
  5. package/dist/cjs/f/fields/LinkInput/styles.scss +89 -0
  6. package/dist/cjs/f/fields/QueryCombobox/styles.scss +2 -2
  7. package/dist/cjs/f/fields/SelectInput/styles.scss +3 -2
  8. package/dist/cjs/f/fields/TextInput/styles.scss +2 -2
  9. package/dist/cjs/f/fields/TextareaInput/styles.scss +2 -2
  10. package/dist/cjs/f/fields/index.js +8 -1
  11. package/dist/es/f/FormInput/FormInput.js +7 -1
  12. package/dist/es/f/fields/ChoicesInput/styles.scss +2 -2
  13. package/dist/es/f/fields/LinkInput/LinkInput.js +156 -0
  14. package/dist/es/f/fields/LinkInput/index.js +2 -0
  15. package/dist/es/f/fields/LinkInput/styles.scss +89 -0
  16. package/dist/es/f/fields/QueryCombobox/styles.scss +2 -2
  17. package/dist/es/f/fields/SelectInput/styles.scss +3 -2
  18. package/dist/es/f/fields/TextInput/styles.scss +2 -2
  19. package/dist/es/f/fields/TextareaInput/styles.scss +2 -2
  20. package/dist/es/f/fields/index.js +2 -1
  21. package/package.json +2 -2
  22. package/src/stories/f/LinkInput.stories.jsx +100 -0
  23. package/src/ui/f/FormInput/FormInput.jsx +12 -0
  24. package/src/ui/f/fields/ChoicesInput/styles.scss +2 -2
  25. package/src/ui/f/fields/LinkInput/LinkInput.jsx +197 -0
  26. package/src/ui/f/fields/LinkInput/index.js +2 -0
  27. package/src/ui/f/fields/LinkInput/styles.scss +89 -0
  28. package/src/ui/f/fields/QueryCombobox/styles.scss +2 -2
  29. package/src/ui/f/fields/SelectInput/styles.scss +3 -2
  30. package/src/ui/f/fields/TextInput/styles.scss +2 -2
  31. package/src/ui/f/fields/TextareaInput/styles.scss +2 -2
  32. package/src/ui/f/fields/index.js +1 -0
  33. package/tests/__snapshots__/Storyshots.test.js.snap +392 -0
@@ -15,8 +15,8 @@ $default-input-border-radius: var(--theme-default-input-border-radius);
15
15
  $default-border: var(--theme-default-input-border);
16
16
  $hover-border: var(--theme-hover-input-border);
17
17
  $focus-border: var(--theme-focus-input-border);
18
- $default-background: var(--theme-default-input-background);
19
- $disabled-background: var(--theme-disabled-input-background);
18
+ $default-background: var(--background-inputs);
19
+ $disabled-background: var(--background-inputs-30);
20
20
 
21
21
  .#{bem.$base}.text-input {
22
22
  &.#{bem.$base}.input-wrapper {
@@ -10,8 +10,8 @@ $default-input-border-radius: var(--theme-default-input-border-radius);
10
10
  $default-border: var(--theme-default-input-border);
11
11
  $hover-border: var(--theme-hover-input-border);
12
12
  $focus-border: var(--theme-focus-input-border);
13
- $default-background: var(--theme-default-input-background);
14
- $disabled-background: var(--theme-disabled-input-background);
13
+ $default-background: var(--background-inputs);
14
+ $disabled-background: var(--background-inputs-30);
15
15
 
16
16
  .#{bem.$base}.text-area-input {
17
17
  &.#{bem.$base}.input-wrapper {
@@ -6,4 +6,5 @@ export { RatingsInput } from "./RatingsInput";
6
6
  export { QueryCombobox } from "./QueryCombobox";
7
7
  export { QuerySelect } from "./QuerySelect";
8
8
  export { Checkbox } from "./Checkbox";
9
- export { QueryChoices } from "./QueryChoices";
9
+ export { QueryChoices } from "./QueryChoices";
10
+ export { LinkInput } from "./LinkInput";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pareto-engineering/design-system",
3
- "version": "4.0.0-alpha.36",
3
+ "version": "4.0.0-alpha.38",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/es/index.js",
@@ -68,5 +68,5 @@
68
68
  "relay-test-utils": "^15.0.0"
69
69
  },
70
70
  "browserslist": "> 2%",
71
- "gitHead": "4dc53480a5291f6c20adad65bbcaf9fafe2cfa02"
71
+ "gitHead": "74937b2e2b5182c4e6e47351c10121f18a8d6883"
72
72
  }
@@ -0,0 +1,100 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ import * as React from 'react'
3
+ import { Formik, Form } from 'formik'
4
+
5
+ import {
6
+ LinkInput,
7
+ FormDebugger,
8
+ } from 'ui'
9
+
10
+ export default {
11
+ title :'f/fields/LinkInput',
12
+ component :LinkInput,
13
+ subcomponents:{
14
+ // Item:TextInput.Item
15
+ },
16
+ decorators:[
17
+ (storyfn) => (
18
+ <Formik
19
+ initialValues={{ email: '', name: '', company: '' }}
20
+ >
21
+ <Form>
22
+
23
+ { storyfn() }
24
+ </Form>
25
+ </Formik>
26
+ ),
27
+ ],
28
+ argTypes:{
29
+ // backgroundColor:{ control: 'color' },
30
+ placeholder :{ control: 'text' },
31
+ autoComplete :{ control: 'select', options: ['off', 'on'] },
32
+ disabled :{ control: 'boolean' },
33
+ name :{ control: 'text' },
34
+ label :{ control: 'text' },
35
+ labelColor :{ control: 'text' },
36
+ optional :{ control: 'boolean' },
37
+ symbol :{ control: 'text' },
38
+ labelSpan :{ control: 'number' },
39
+ inputSpan :{ control: 'number' },
40
+ desktopLabelSpan:{ control: 'number' },
41
+ desktopInputSpan:{ control: 'number' },
42
+ },
43
+ }
44
+
45
+ // eslint-disable-next-line react/prop-types
46
+ const Template = (args) => (
47
+ <div className="grid">
48
+ <LinkInput {...args} />
49
+ <FormDebugger />
50
+ </div>
51
+ )
52
+
53
+ export const Base = Template.bind({})
54
+ Base.args = {
55
+ name :'link',
56
+ label:'Spreadsheet Link',
57
+ }
58
+
59
+ export const Optional = Template.bind({})
60
+ Optional.args = {
61
+ ...Base.args,
62
+ optional:true,
63
+ }
64
+
65
+ const validate = (value) => {
66
+ let errorMessage = ''
67
+ const isValid = value.length > 3
68
+
69
+ if (!isValid) {
70
+ errorMessage = 'Value should be greater than 3 characters'
71
+ }
72
+ return errorMessage
73
+ }
74
+
75
+ export const WithValidation = Template.bind({})
76
+ WithValidation.args = {
77
+ ...Base.args,
78
+ validate,
79
+ }
80
+
81
+ export const WithPlaceholder = Template.bind({})
82
+ WithPlaceholder.args = {
83
+ ...Base.args,
84
+ placeholder:'Email address',
85
+ }
86
+
87
+ export const WithDisabled = Template.bind({})
88
+ WithDisabled.args = {
89
+ ...Base.args,
90
+ disabled:true,
91
+ }
92
+
93
+ export const OnSingleRow = Template.bind({})
94
+ OnSingleRow.args = {
95
+ ...Base.args,
96
+ labelSpan :4,
97
+ inputSpan :4,
98
+ desktopLabelSpan:4,
99
+ desktopInputSpan:10,
100
+ }
@@ -15,6 +15,7 @@ import {
15
15
  RatingsInput,
16
16
  Checkbox,
17
17
  QueryChoices,
18
+ LinkInput,
18
19
  } from '../fields'
19
20
 
20
21
  // Local Definitions
@@ -117,6 +118,16 @@ const FormInput = ({
117
118
  )
118
119
  }
119
120
 
121
+ if (type === 'link') {
122
+ return (
123
+ <LinkInput
124
+ className={newClassName}
125
+ disabled={disabled}
126
+ {...otherProps}
127
+ />
128
+ )
129
+ }
130
+
120
131
  if (extraTypes?.[type]) {
121
132
  const Component = extraTypes[type]
122
133
  return (
@@ -127,6 +138,7 @@ const FormInput = ({
127
138
  />
128
139
  )
129
140
  }
141
+
130
142
  return (
131
143
  <TextInput
132
144
  className={newClassName}
@@ -14,8 +14,8 @@ $default-input-border-radius: var(--theme-default-input-border-radius);
14
14
  $default-border: var(--theme-default-input-border);
15
15
  $hover-border: var(--theme-hover-input-border);
16
16
  $focus-border: var(--theme-focus-input-border);
17
- $default-background: var(--theme-default-input-background);
18
- $disabled-background: var(--theme-disabled-input-background);
17
+ $default-background: var(--background-inputs);
18
+ $disabled-background: var(--background-inputs-30);
19
19
 
20
20
  .#{bem.$base}.choices-input {
21
21
  &.#{bem.$base}.input-wrapper {
@@ -0,0 +1,197 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ import * as React from 'react'
3
+
4
+ import { useInsertionEffect, memo } from 'react'
5
+
6
+ import PropTypes from 'prop-types'
7
+
8
+ import styleNames from '@pareto-engineering/bem/exports'
9
+
10
+ import { useField } from 'formik'
11
+
12
+ import { FormLabel, FormDescription, InputWrapper } from '../../common'
13
+
14
+ // Local Definitions
15
+
16
+ const baseClassName = styleNames.base
17
+
18
+ const componentClassName = 'link-input'
19
+
20
+ /**
21
+ * This is the component description.
22
+ */
23
+ const LinkInput = ({
24
+ id,
25
+ className:userClassName,
26
+ style,
27
+ name,
28
+ label,
29
+ color,
30
+ labelColor,
31
+ validate,
32
+ description,
33
+ disabled,
34
+ placeholder,
35
+ optional,
36
+ autoComplete,
37
+ labelSpan,
38
+ desktopLabelSpan,
39
+ inputSpan,
40
+ desktopInputSpan,
41
+ // ...otherProps
42
+ }) => {
43
+ useInsertionEffect(() => {
44
+ import('./styles.scss')
45
+ }, [])
46
+
47
+ const [field] = useField({ name, validate })
48
+
49
+ return (
50
+ <>
51
+ <FormLabel
52
+ name={name}
53
+ color={labelColor}
54
+ optional={optional}
55
+ columnSpan={labelSpan}
56
+ desktopColumnSpan={desktopLabelSpan}
57
+ // {...otherProps}
58
+ >
59
+ {label}
60
+ </FormLabel>
61
+ <InputWrapper
62
+ id={id}
63
+ className={[
64
+ baseClassName,
65
+ componentClassName,
66
+ userClassName,
67
+ `y-${color}`,
68
+ ]
69
+ .filter((e) => e)
70
+ .join(' ')}
71
+ style={style}
72
+ columnSpan={inputSpan}
73
+ desktopColumnSpan={desktopInputSpan}
74
+ >
75
+ <div className="input-link-wrapper">
76
+ <input
77
+ id={name}
78
+ className="input"
79
+ type="text"
80
+ disabled={disabled}
81
+ placeholder={placeholder}
82
+ autoComplete={autoComplete}
83
+ {...field}
84
+ />
85
+ <a
86
+ href={field.value}
87
+ target="_blank"
88
+ rel="noopener noreferrer"
89
+ >
90
+ &#8594;
91
+ </a>
92
+ </div>
93
+ <FormDescription className="s-1" description={description} name={name} />
94
+ </InputWrapper>
95
+ </>
96
+ )
97
+ }
98
+
99
+ LinkInput.propTypes = {
100
+ /**
101
+ * The HTML id for this element
102
+ */
103
+ id:PropTypes.string,
104
+
105
+ /**
106
+ * The HTML class names for this element
107
+ */
108
+ className:PropTypes.string,
109
+
110
+ /**
111
+ * The React-written, css properties for this element.
112
+ */
113
+ style:PropTypes.objectOf(PropTypes.string),
114
+
115
+ /**
116
+ * The input name (html - and Formik state)
117
+ */
118
+ name:PropTypes.string.isRequired,
119
+
120
+ /**
121
+ * The input label
122
+ */
123
+ label:PropTypes.string.isRequired,
124
+
125
+ /**
126
+ * The input label color
127
+ */
128
+ labelColor:PropTypes.string,
129
+
130
+ /**
131
+ * The input field validator function
132
+ */
133
+ validate:PropTypes.func,
134
+
135
+ /**
136
+ * If the slide will only have one input
137
+ */
138
+ oneInputLabel:PropTypes.bool,
139
+
140
+ /**
141
+ * Input description
142
+ */
143
+ description:PropTypes.string,
144
+
145
+ /**
146
+ * Whether the text input should be disabled
147
+ */
148
+ disabled:PropTypes.bool,
149
+
150
+ /**
151
+ * The placeholder text for the input
152
+ */
153
+ placeholder:PropTypes.string,
154
+
155
+ /**
156
+ * The text input color
157
+ */
158
+ color:PropTypes.string,
159
+
160
+ /**
161
+ * Whether the input is optional or not
162
+ */
163
+ optional:PropTypes.bool,
164
+
165
+ /**
166
+ * The autoComplete value that the browser should watch for the input
167
+ * `https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete`
168
+ */
169
+ autoComplete:PropTypes.string,
170
+
171
+ /**
172
+ * The number of columns the label should span
173
+ */
174
+ labelSpan:PropTypes.number,
175
+
176
+ /**
177
+ * The number of columns the input should span
178
+ */
179
+ inputSpan:PropTypes.number,
180
+
181
+ /**
182
+ * The number of columns the label should span on desktop
183
+ */
184
+ desktopLabelSpan:PropTypes.number,
185
+
186
+ /**
187
+ * The number of columns the input should span on desktop
188
+ */
189
+ desktopInputSpan:PropTypes.number,
190
+ }
191
+
192
+ LinkInput.defaultProps = {
193
+ color :'paragraph',
194
+ disabled:false,
195
+ }
196
+
197
+ export default memo(LinkInput)
@@ -0,0 +1,2 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ export { default as LinkInput } from './LinkInput'
@@ -0,0 +1,89 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ /* stylelint-disable max-nesting-depth -- required here */
3
+
4
+ @use "@pareto-engineering/bem";
5
+ @use "@pareto-engineering/styles/src/mixins";
6
+ @use "@pareto-engineering/styles/src/globals" as *;
7
+
8
+ $default-padding: .55em .75em;
9
+ $default-symbol-left: 1em;
10
+ $default-padding-with-symbol:
11
+ .55em
12
+ calc($default-symbol-left - 1em)
13
+ .55em
14
+ calc($default-symbol-left + 1em);
15
+ $default-input-border-radius: var(--theme-default-input-border-radius);
16
+ $default-border: var(--theme-default-input-border);
17
+ $hover-border: var(--theme-hover-input-border);
18
+ $focus-border: var(--theme-focus-input-border);
19
+ $default-background: var(--background-inputs);
20
+ $disabled-background: var(--background-inputs-30);
21
+
22
+ .#{bem.$base}.link-input {
23
+ &.#{bem.$base}.input-wrapper {
24
+ display: flex;
25
+ flex-direction: column;
26
+ position: relative;
27
+
28
+ &.has-symbol {
29
+ &::before {
30
+ color: var(--y);
31
+ content: var(--symbol);
32
+ left: $default-symbol-left;
33
+ position: absolute;
34
+ top: 50%;
35
+ transform: translate(-50%, -50%);
36
+ }
37
+
38
+ input {
39
+ padding: $default-padding-with-symbol;
40
+ }
41
+ }
42
+
43
+ > .input-link-wrapper {
44
+ display: flex;
45
+ gap: calc(var(--gap) / 2);
46
+
47
+ > a {
48
+ align-self: center;
49
+ border: 1px solid var(--interactive);
50
+ border-radius: var(--theme-default-input-border-radius);
51
+ padding: .5em;
52
+
53
+ &:hover {
54
+ background-color: var(--interactive);
55
+ color: var(--on-interactive);
56
+ }
57
+ }
58
+
59
+ > input {
60
+ background-color: $default-background;
61
+ border: $default-border;
62
+ border-radius: $default-input-border-radius;
63
+ color: var(--y);
64
+ outline: none;
65
+ padding: $default-padding;
66
+ width: 100%;
67
+
68
+ &::placeholder {
69
+ color: var(--metadata);
70
+ }
71
+
72
+ &:disabled {
73
+ background-color: $disabled-background;
74
+ }
75
+
76
+ &:not(:disabled) {
77
+ &:hover,
78
+ &:active {
79
+ border: $hover-border;
80
+ }
81
+
82
+ &:focus {
83
+ border: $focus-border;
84
+ }
85
+ }
86
+ }
87
+ }
88
+ }
89
+ }
@@ -13,8 +13,8 @@ $default-input-border-radius: var(--theme-default-input-border-radius);
13
13
  $default-border: var(--theme-default-input-border);
14
14
  $hover-border: var(--theme-hover-input-border);
15
15
  $focus-border: var(--theme-focus-input-border);
16
- $default-background: var(--theme-default-input-background);
17
- $disabled-background: var(--theme-disabled-input-background);
16
+ $default-background: var(--background-inputs);
17
+ $disabled-background: var(--background-inputs-30);
18
18
 
19
19
  .#{bem.$base}.combobox,
20
20
  .#{bem.$base}.multiple-combobox {
@@ -12,8 +12,8 @@ $default-input-border-radius: var(--theme-default-input-border-radius);
12
12
  $default-border: var(--theme-default-input-border);
13
13
  $hover-border: var(--theme-hover-input-border);
14
14
  $focus-border: var(--theme-focus-input-border);
15
- $default-background: var(--theme-default-input-background);
16
- $disabled-background: var(--theme-disabled-input-background);
15
+ $default-background: var(--background-inputs);
16
+ $disabled-background: var(--background-inputs-30);
17
17
 
18
18
  .#{bem.$base}.select-input {
19
19
  &.#{bem.$base}.label {
@@ -62,6 +62,7 @@ $disabled-background: var(--theme-disabled-input-background);
62
62
 
63
63
  select {
64
64
  appearance: none;
65
+ background-color: $default-background;
65
66
  background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMTIiIHZpZXdCb3g9IjAgMCAyMCAxMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTE5IDEuNUwxMCAxMC41TDEgMS41IiBzdHJva2U9IiM0QzRENTMiIHN0cm9rZS13aWR0aD0iMiIvPgo8L3N2Zz4=");
66
67
  background-position: calc(100% - $default-spacing-size);
67
68
  background-repeat: no-repeat;
@@ -15,8 +15,8 @@ $default-input-border-radius: var(--theme-default-input-border-radius);
15
15
  $default-border: var(--theme-default-input-border);
16
16
  $hover-border: var(--theme-hover-input-border);
17
17
  $focus-border: var(--theme-focus-input-border);
18
- $default-background: var(--theme-default-input-background);
19
- $disabled-background: var(--theme-disabled-input-background);
18
+ $default-background: var(--background-inputs);
19
+ $disabled-background: var(--background-inputs-30);
20
20
 
21
21
  .#{bem.$base}.text-input {
22
22
  &.#{bem.$base}.input-wrapper {
@@ -10,8 +10,8 @@ $default-input-border-radius: var(--theme-default-input-border-radius);
10
10
  $default-border: var(--theme-default-input-border);
11
11
  $hover-border: var(--theme-hover-input-border);
12
12
  $focus-border: var(--theme-focus-input-border);
13
- $default-background: var(--theme-default-input-background);
14
- $disabled-background: var(--theme-disabled-input-background);
13
+ $default-background: var(--background-inputs);
14
+ $disabled-background: var(--background-inputs-30);
15
15
 
16
16
  .#{bem.$base}.text-area-input {
17
17
  &.#{bem.$base}.input-wrapper {
@@ -7,3 +7,4 @@ export { QueryCombobox } from './QueryCombobox'
7
7
  export { QuerySelect } from './QuerySelect'
8
8
  export { Checkbox } from './Checkbox'
9
9
  export { QueryChoices } from './QueryChoices'
10
+ export { LinkInput } from './LinkInput'