@scm-manager/ui-components 2.29.1-20220012-084149 → 2.29.1

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": "@scm-manager/ui-components",
3
- "version": "2.29.1-20220012-084149",
3
+ "version": "2.29.1",
4
4
  "description": "UI Components for SCM-Manager and its plugins",
5
5
  "main": "src/index.ts",
6
6
  "files": [
@@ -25,7 +25,7 @@
25
25
  "@scm-manager/jest-preset": "^2.13.0",
26
26
  "@scm-manager/prettier-config": "^2.10.1",
27
27
  "@scm-manager/tsconfig": "^2.12.0",
28
- "@scm-manager/ui-tests": "^2.29.1-20220012-084149",
28
+ "@scm-manager/ui-tests": "^2.29.1",
29
29
  "@storybook/addon-actions": "^6.3.12",
30
30
  "@storybook/addon-storyshots": "^6.3.12",
31
31
  "@storybook/builder-webpack5": "^6.3.12",
@@ -65,9 +65,9 @@
65
65
  "worker-plugin": "^3.2.0"
66
66
  },
67
67
  "dependencies": {
68
- "@scm-manager/ui-api": "^2.29.1-20220012-084149",
69
- "@scm-manager/ui-extensions": "^2.29.1-20220012-084149",
70
- "@scm-manager/ui-types": "^2.29.1-20220012-084149",
68
+ "@scm-manager/ui-api": "^2.29.1",
69
+ "@scm-manager/ui-extensions": "^2.29.1",
70
+ "@scm-manager/ui-types": "^2.29.1",
71
71
  "classnames": "^2.2.6",
72
72
  "date-fns": "^2.4.1",
73
73
  "deepmerge": "^4.2.2",
@@ -37,11 +37,8 @@ type Props = {
37
37
  placeholder: string;
38
38
  loadingMessage: string;
39
39
  noOptionsMessage: string;
40
- errorMessage?: string;
41
- informationMessage?: string;
42
40
  creatable?: boolean;
43
41
  className?: string;
44
- disabled?: boolean;
45
42
  };
46
43
 
47
44
  type State = {};
@@ -81,51 +78,52 @@ class Autocomplete extends React.Component<Props, State> {
81
78
  loadingMessage,
82
79
  noOptionsMessage,
83
80
  loadSuggestions,
84
- errorMessage,
85
- informationMessage,
86
81
  creatable,
87
- className,
88
- disabled
82
+ className
89
83
  } = this.props;
90
84
 
91
- const asyncProps = {
92
- className: "autocomplete-entry",
93
- classNamePrefix: "autocomplete-entry",
94
- cacheOptions: true,
95
- loadOptions: loadSuggestions,
96
- onChange: this.handleInputChange,
97
- value,
98
- placeholder,
99
- loadingMessage: () => loadingMessage,
100
- noOptionsMessage: () => noOptionsMessage,
101
- isDisabled: disabled,
102
- "aria-label": helpText || label
103
- };
104
-
105
85
  return (
106
86
  <div className={classNames("field", className)}>
107
87
  <LabelWithHelpIcon label={label} helpText={helpText} />
108
88
  <div className="control">
109
89
  {creatable ? (
110
90
  <AsyncCreatable
111
- {...asyncProps}
91
+ className="autocomplete-entry"
92
+ classNamePrefix="autocomplete-entry"
93
+ cacheOptions
94
+ loadOptions={loadSuggestions}
95
+ onChange={this.handleInputChange}
96
+ value={value}
97
+ placeholder={placeholder}
98
+ loadingMessage={() => loadingMessage}
99
+ noOptionsMessage={() => noOptionsMessage}
112
100
  isValidNewOption={this.isValidNewOption}
113
- onCreateOption={newValue => {
101
+ onCreateOption={value => {
114
102
  this.selectValue({
115
- label: newValue,
103
+ label: value,
116
104
  value: {
117
- id: newValue,
118
- displayName: newValue
105
+ id: value,
106
+ displayName: value
119
107
  }
120
108
  });
121
109
  }}
110
+ aria-label={helpText || label}
122
111
  />
123
112
  ) : (
124
- <Async {...asyncProps} />
113
+ <Async
114
+ className="autocomplete-entry"
115
+ classNamePrefix="autocomplete-entry"
116
+ cacheOptions
117
+ loadOptions={loadSuggestions}
118
+ onChange={this.handleInputChange}
119
+ value={value}
120
+ placeholder={placeholder}
121
+ loadingMessage={() => loadingMessage}
122
+ noOptionsMessage={() => noOptionsMessage}
123
+ aria-label={helpText || label}
124
+ />
125
125
  )}
126
126
  </div>
127
- {errorMessage ? <p className="help is-danger">{errorMessage}</p> : null}
128
- {informationMessage ? <p className="help is-info">{informationMessage}</p> : null}
129
127
  </div>
130
128
  );
131
129
  }
@@ -19219,10 +19219,6 @@ exports[`Storyshots Modal/Modal With form elements 1`] = `null`;
19219
19219
 
19220
19220
  exports[`Storyshots Modal/Modal With long tooltips 1`] = `null`;
19221
19221
 
19222
- exports[`Storyshots Modal/Modal With overflow 1`] = `null`;
19223
-
19224
- exports[`Storyshots Modal/Modal With overflow and footer 1`] = `null`;
19225
-
19226
19222
  exports[`Storyshots Notification Closeable 1`] = `
19227
19223
  <div
19228
19224
  className="Notificationstories__Wrapper-sc-8fx7tr-0 gJPbVB"
@@ -32,8 +32,6 @@ import ExternalLink from "../navigation/ExternalLink";
32
32
  import { Radio, Textarea, InputField } from "../forms";
33
33
  import { ButtonGroup, Button } from "../buttons";
34
34
  import Notification from "../Notification";
35
- import { Autocomplete } from "../index";
36
- import { SelectValue } from "@scm-manager/ui-types";
37
35
 
38
36
  const TopAndBottomMargin = styled.div`
39
37
  margin: 0.75rem 0; // only for aesthetic reasons
@@ -53,9 +51,7 @@ const text = `Mind-paralyzing change needed improbability vortex machine sorts s
53
51
  ordinary mob.`;
54
52
 
55
53
  // eslint-disable-next-line @typescript-eslint/no-empty-function
56
- const doNothing = () => {
57
- // nothing to do
58
- };
54
+ const doNothing = () => {};
59
55
  const withFormElementsBody = (
60
56
  <>
61
57
  <RadioList>
@@ -75,21 +71,8 @@ const withFormElementsFooter = (
75
71
  </ButtonGroup>
76
72
  );
77
73
 
78
- const loadSuggestions: (p: string) => Promise<SelectValue[]> = () =>
79
- new Promise(resolve => {
80
- setTimeout(() => {
81
- resolve([
82
- { value: { id: "trillian", displayName: "Tricia McMillan" }, label: "Tricia McMillan" },
83
- { value: { id: "zaphod", displayName: "Zaphod Beeblebrox" }, label: "Zaphod Beeblebrox" },
84
- { value: { id: "ford", displayName: "Ford Prefect" }, label: "Ford Prefect" },
85
- { value: { id: "dent", displayName: "Arthur Dent" }, label: "Arthur Dent" },
86
- { value: { id: "marvin", displayName: "Marvin" }, label: "Marvin the Paranoid Android " }
87
- ]);
88
- });
89
- });
90
-
91
74
  storiesOf("Modal/Modal", module)
92
- .addDecorator(story => <MemoryRouter initialEntries={["/"]}>{story()}</MemoryRouter>)
75
+ .addDecorator((story) => <MemoryRouter initialEntries={["/"]}>{story()}</MemoryRouter>)
93
76
  .add("Default", () => (
94
77
  <NonCloseableModal>
95
78
  <p>{text}</p>
@@ -121,7 +104,7 @@ storiesOf("Modal/Modal", module)
121
104
  This story exists because we had a problem, that long tooltips causes a horizontal scrollbar on the modal.
122
105
  </Notification>
123
106
  <hr />
124
- <p>The following elements will have a very long help text, which has triggered the scrollbar in the past.</p>
107
+ <p>The following elements will have a verly long help text, which has triggered the scrollbar in the past.</p>
125
108
  <hr />
126
109
  <TopAndBottomMargin>
127
110
  <Checkbox label="Checkbox" checked={true} helpText={text} />
@@ -228,47 +211,10 @@ storiesOf("Modal/Modal", module)
228
211
  </p>
229
212
  </div>
230
213
  </NonCloseableModal>
231
- ))
232
- .add("With overflow", () => {
233
- return (
234
- <NonCloseableModal overflowVisible={true}>
235
- <h1 className="title">Please Select</h1>
236
- <Autocomplete
237
- valueSelected={() => {
238
- // nothing to do
239
- }}
240
- loadSuggestions={loadSuggestions}
241
- />
242
- </NonCloseableModal>
243
- );
244
- })
245
- .add("With overflow and footer", () => {
246
- return (
247
- <NonCloseableModal overflowVisible={true} footer={withFormElementsFooter}>
248
- <h1 className="title">Please Select</h1>
249
- <Autocomplete
250
- valueSelected={() => {
251
- // nothing to do
252
- }}
253
- loadSuggestions={loadSuggestions}
254
- />
255
- </NonCloseableModal>
256
- );
257
- });
258
-
259
- type NonCloseableModalProps = { overflowVisible?: boolean; footer?: any };
214
+ ));
260
215
 
261
- const NonCloseableModal: FC<NonCloseableModalProps> = ({ overflowVisible, footer, children }) => {
262
- return (
263
- <Modal
264
- body={children}
265
- closeFunction={doNothing}
266
- active={true}
267
- title={"Hitchhiker Modal"}
268
- overflowVisible={overflowVisible}
269
- footer={footer}
270
- />
271
- );
216
+ const NonCloseableModal: FC = ({ children }) => {
217
+ return <Modal body={children} closeFunction={doNothing} active={true} title={"Hitchhiker Modal"} />;
272
218
  };
273
219
 
274
220
  const CloseableModal: FC = ({ children }) => {
@@ -42,24 +42,10 @@ type Props = {
42
42
  headColor?: string;
43
43
  headTextColor?: string;
44
44
  size?: ModalSize;
45
- overflowVisible?: boolean;
46
45
  };
47
46
 
48
- const SizedModal = styled.div<{ size?: ModalSize; overflow: string }>`
47
+ const SizedModal = styled.div<{ size?: ModalSize }>`
49
48
  width: ${props => (props.size ? `${modalSizes[props.size]}%` : "640px")};
50
- overflow: ${props => props.overflow};
51
- `;
52
-
53
- const DivWithOptionalOverflow = styled.div<{ overflow: string; borderBottomRadius: string }>`
54
- overflow: ${props => props.overflow};
55
- border-bottom-left-radius: ${props => props.borderBottomRadius};
56
- border-bottom-right-radius: ${props => props.borderBottomRadius};
57
- `;
58
-
59
- const SectionWithOptionalOverflow = styled.section<{ overflow: string; borderBottomRadius: string }>`
60
- overflow: ${props => props.overflow};
61
- border-bottom-left-radius: ${props => props.borderBottomRadius};
62
- border-bottom-right-radius: ${props => props.borderBottomRadius};
63
49
  `;
64
50
 
65
51
  export const Modal: FC<Props> = ({
@@ -71,8 +57,7 @@ export const Modal: FC<Props> = ({
71
57
  className,
72
58
  headColor = "secondary-less",
73
59
  headTextColor = "secondary-most",
74
- size,
75
- overflowVisible
60
+ size
76
61
  }) => {
77
62
  const portalRootElement = usePortalRootElement("modalsRoot");
78
63
  const initialFocusRef = useRef(null);
@@ -100,29 +85,18 @@ export const Modal: FC<Props> = ({
100
85
  }
101
86
  };
102
87
 
103
- const overflowAttribute = overflowVisible ? "visible" : "auto";
104
- const borderBottomRadiusAttribute = overflowVisible && !footer ? "inherit" : "unset";
105
-
106
88
  const modalElement = (
107
- <DivWithOptionalOverflow
108
- className={classNames("modal", className, isActive)}
109
- ref={trapRef}
110
- onKeyDown={onKeyDown}
111
- overflow={overflowAttribute}
112
- borderBottomRadius={borderBottomRadiusAttribute}
113
- >
89
+ <div className={classNames("modal", className, isActive)} ref={trapRef} onKeyDown={onKeyDown}>
114
90
  <div className="modal-background" onClick={closeFunction} />
115
- <SizedModal className="modal-card" size={size} overflow={overflowAttribute}>
91
+ <SizedModal className="modal-card" size={size}>
116
92
  <header className={classNames("modal-card-head", `has-background-${headColor}`)}>
117
93
  <h2 className={`modal-card-title m-0 has-text-${headTextColor}`}>{title}</h2>
118
94
  <button className="delete" aria-label="close" onClick={closeFunction} ref={initialFocusRef} autoFocus />
119
95
  </header>
120
- <SectionWithOptionalOverflow className="modal-card-body" overflow={overflowAttribute} borderBottomRadius={borderBottomRadiusAttribute}>
121
- {body}
122
- </SectionWithOptionalOverflow>
96
+ <section className="modal-card-body">{body}</section>
123
97
  {showFooter}
124
98
  </SizedModal>
125
- </DivWithOptionalOverflow>
99
+ </div>
126
100
  );
127
101
 
128
102
  return ReactDOM.createPortal(modalElement, portalRootElement);