@aarhus-university/au-lib-react-components 11.6.0 → 11.7.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,7 +1,7 @@
1
1
  {
2
2
  "sideEffects": false,
3
3
  "name": "@aarhus-university/au-lib-react-components",
4
- "version": "11.6.0",
4
+ "version": "11.7.0",
5
5
  "description": "Library for shared React components for various applications on au.dk",
6
6
  "scripts": {
7
7
  "test": "jest",
@@ -72,9 +72,9 @@
72
72
  "webpack-cli": "^4.9.2"
73
73
  },
74
74
  "dependencies": {
75
- "@aarhus-university/au-designsystem-delphinus": "0.35.2",
75
+ "@aarhus-university/au-designsystem-delphinus": "0.41.1",
76
76
  "@aarhus-university/au-designsystem-delphinus-dev": "0.2.0",
77
- "@aarhus-university/types": "0.18.0",
77
+ "@aarhus-university/types": "0.21.1",
78
78
  "@reduxjs/toolkit": "^1.8.3",
79
79
  "@types/google.analytics": "^0.0.42",
80
80
  "@types/history": "^5.0.0",
@@ -116,20 +116,20 @@ AUAutoSuggestComponent.displayName = 'AUAutoSuggestComponent';
116
116
  AUAutoSuggestComponent.defaultProps = {
117
117
  id: 'autosuggest1',
118
118
  theme: {
119
- container: 'react-autosuggest__container',
120
- containerOpen: 'react-autosuggest__container--open',
121
- input: 'react-autosuggest__input',
122
- inputOpen: 'react-autosuggest__input--open',
123
- inputFocused: 'react-autosuggest__input--focused',
124
- suggestionsContainer: 'react-autosuggest__suggestions-container',
125
- suggestionsContainerOpen: 'react-autosuggest__suggestions-container--open',
126
- suggestionsList: 'react-autosuggest__suggestions-list',
127
- suggestion: 'react-autosuggest__suggestion',
128
- suggestionFirst: 'react-autosuggest__suggestion--first',
129
- suggestionHighlighted: 'react-autosuggest__suggestion--highlighted',
130
- sectionContainer: 'react-autosuggest__section-container',
131
- sectionContainerFirst: 'react-autosuggest__section-container--first',
132
- sectionTitle: 'react-autosuggest__section-title',
119
+ container: 'autosuggest',
120
+ containerOpen: 'autosuggest--open',
121
+ input: 'autosuggest__input',
122
+ inputOpen: 'autosuggest__input--open',
123
+ inputFocused: 'autosuggest__input--focused',
124
+ suggestionsContainer: 'autosuggest__suggestions',
125
+ suggestionsContainerOpen: 'autosuggest__suggestions--open',
126
+ suggestionsList: 'autosuggest__suggestions__list',
127
+ suggestion: 'autosuggest__suggestions__list__item',
128
+ suggestionFirst: 'autosuggest__suggestions__list--first',
129
+ suggestionHighlighted: 'autosuggest__suggestions__list--highlighted',
130
+ sectionContainer: 'autosuggest__section',
131
+ sectionContainerFirst: 'autosuggest__section--first',
132
+ sectionTitle: 'autosuggest__section__title',
133
133
  },
134
134
  clearInput: false,
135
135
  type: 'text',
@@ -1,20 +1,40 @@
1
+ /* eslint-disable max-len */
1
2
  /* eslint-disable react/no-array-index-key */
2
3
  import React, { FC } from 'react';
3
4
 
5
+ const getStepItemClass = (current: boolean, final: boolean, finalIcon: string): string => {
6
+ let className = 'stepper__item';
7
+ if (current) {
8
+ className = `${className} stepper__item--active`;
9
+ }
10
+ if (final) {
11
+ className = `${className} stepper__item--final`;
12
+ if (finalIcon) {
13
+ className = `${className} icon-${finalIcon}`;
14
+ }
15
+ }
16
+
17
+ return className;
18
+ };
19
+
4
20
  const AUStepComponent: FC<AUStepComponentProps> = ({
21
+ title,
5
22
  step,
6
23
  children,
7
24
  stepHeadlines,
8
25
  introElement,
9
26
  outroElement,
27
+ showFinal,
28
+ finalIcon,
10
29
  }: AUStepComponentProps) => (
11
- <>
30
+ <div className="stepper">
31
+ <h1 className="stepper__step-title">{title}</h1>
12
32
  {
13
33
  (step > -1 && step < children.length) && (
14
- <ol className="stepper" data-steps={children.length}>
34
+ <ol className="stepper__list" data-steps={children.length} aria-hidden>
15
35
  {
16
36
  stepHeadlines.map((headline, index) => (
17
- <li key={headline} className={`stepper__item${index === step ? ' stepper__item--active' : ''}`}>
37
+ <li key={headline} className={getStepItemClass(index === step, (typeof showFinal !== 'undefined' && showFinal) && (children.length - 1 === index), finalIcon || '')}>
18
38
  <span className="stepper__item__label">{headline}</span>
19
39
  </li>
20
40
  ))
@@ -35,12 +55,14 @@ const AUStepComponent: FC<AUStepComponentProps> = ({
35
55
  {
36
56
  (step > children.length - 1) && outroElement
37
57
  }
38
- </>
58
+ </div>
39
59
  );
40
60
 
41
61
  AUStepComponent.defaultProps = {
42
62
  introElement: undefined,
43
63
  outroElement: undefined,
64
+ showFinal: false,
65
+ finalIcon: '',
44
66
  };
45
67
 
46
68
  AUStepComponent.displayName = 'AUStepComponent';
@@ -14,6 +14,7 @@ const AUSubmitButtonContainerComponent: FC<AUSubmitButtonContainerComponentProps
14
14
  label={submitText}
15
15
  classNames={[disabled ? 'button--processing' : '']}
16
16
  disabled={disabled}
17
+ mode={disabled ? 'processing' : 'none'}
17
18
  onClick={onSubmit}
18
19
  />
19
20
  <AUButtonComponent
@@ -0,0 +1,97 @@
1
+ import React from 'react';
2
+ import { ComponentStory, ComponentMeta } from '@storybook/react';
3
+ import AUAutoSuggestComponent from '../src/components/AUAutoSuggestComponent';
4
+ import { ThemeWrapper } from './lib/helpers';
5
+
6
+ export default {
7
+ title: 'Delphinus/AutoSuggest',
8
+ component: AUAutoSuggestComponent,
9
+ argTypes: {
10
+ label: {
11
+ table: {
12
+ disable: true,
13
+ }
14
+ },
15
+ },
16
+ decorators: [
17
+ (Story, context) => (
18
+ <ThemeWrapper theme={context.globals.theme}>
19
+ {Story()}
20
+ </ThemeWrapper>
21
+ )
22
+ ],
23
+ } as ComponentMeta<typeof AUAutoSuggestComponent>;
24
+
25
+ const Template: ComponentStory<typeof AUAutoSuggestComponent> = (args) => <div className="form__field"><AUAutoSuggestComponent {...args} /></div>;
26
+
27
+ export const AutoComplete = Template.bind({});
28
+
29
+ AutoComplete.args = {
30
+ collection: [],
31
+ getSuggestions: (value, _, callback) => {
32
+ const inputValue = value.trim().toLowerCase();
33
+ const inputLength = inputValue.length;
34
+
35
+ console.log('tis ');
36
+
37
+ const results = inputLength === 0
38
+ ? []
39
+ : [
40
+ { id: 1, name: 'Copenhagen' },
41
+ { id: 2, name: 'Aarhus' },
42
+ { id: 3, name: 'Odense' },
43
+ { id: 4, name: 'Aalborg' },
44
+ { id: 5, name: 'Esbjerg' },
45
+ { id: 6, name: 'Randers' },
46
+ { id: 7, name: 'Kolding' },
47
+ { id: 8, name: 'Horsens' },
48
+ { id: 9, name: 'Vejle' },
49
+ { id: 10, name: 'Herning' },
50
+ { id: 11, name: 'Frederiksberg' },
51
+ { id: 12, name: 'Fredericia' },
52
+ { id: 13, name: 'Roskilde' },
53
+ { id: 14, name: 'Silkeborg' },
54
+ { id: 15, name: 'Næstved' },
55
+ { id: 16, name: 'Helsingør' },
56
+ { id: 17, name: 'Hvidovre' },
57
+ { id: 18, name: 'Holstebro' },
58
+ { id: 19, name: 'Hjørring' },
59
+ { id: 20, name: 'Glostrup' },
60
+ { id: 21, name: 'Hillerød' },
61
+ { id: 22, name: 'Slagelse' },
62
+ { id: 23, name: 'Viborg' },
63
+ { id: 24, name: 'Ikast-Brande' },
64
+ { id: 25, name: 'Frederikshavn' },
65
+ { id: 26, name: 'Ringsted' },
66
+ { id: 27, name: 'Taastrup' },
67
+ { id: 28, name: 'Køge' },
68
+ { id: 29, name: 'Nørresundby' },
69
+ { id: 30, name: 'Haderslev' },
70
+ { id: 31, name: 'Varde' },
71
+ { id: 32, name: 'Hedensted' },
72
+ { id: 33, name: 'Sønderborg' },
73
+ { id: 34, name: 'Greve' },
74
+ { id: 35, name: 'Albertslund' },
75
+ { id: 36, name: 'Skive' },
76
+ { id: 37, name: 'Hørsholm' },
77
+ { id: 38, name: 'Horsens' },
78
+ { id: 39, name: 'Herning' },
79
+ { id: 40, name: 'Frederiksberg' },
80
+ { id: 41, name: 'Fredericia' },
81
+ { id: 42, name: 'Roskilde' },
82
+ { id: 43, name: 'Silkeborg' },
83
+ { id: 44, name: 'Næstved' },
84
+ { id: 45, name: 'Helsingør' },
85
+ { id: 46, name: 'Hvidovre' },
86
+ { id: 47, name: 'Holstebro' },
87
+
88
+ ].filter((lang) => lang.name.toLowerCase().slice(0, inputLength) === inputValue);
89
+
90
+ callback(results);
91
+ },
92
+ getSuggestionValue: (suggestion) => suggestion.name,
93
+ setResults: () => { },
94
+ setQuery: () => { },
95
+ renderSuggestion: (suggestion) => <span>{suggestion.name}</span>,
96
+ placeholder: 'Search',
97
+ };
@@ -26,6 +26,7 @@ const Template: ComponentStory<typeof AUStepComponent> = (args) => (
26
26
  export const Five_Steps = Template.bind({});
27
27
  Five_Steps.args = {
28
28
  step: -1,
29
+ title: 'Dette er en overskrift af hensyn til tilgængelighed',
29
30
  children: [
30
31
  <p>Step 1</p>,
31
32
  <p>Step 2</p>,
@@ -36,5 +37,24 @@ Five_Steps.args = {
36
37
  stepHeadlines: ['Introduction', 'Network connection', 'Sign out devices', 'Change password', 'Update device'],
37
38
  introElement: <p>Her begynder vi</p>,
38
39
  outroElement: <p>Her slutter vi</p>,
40
+ showFinal: false,
41
+ };
42
+
43
+ export const Five_Steps_With_Icon = Template.bind({});
44
+ Five_Steps_With_Icon.args = {
45
+ step: -1,
46
+ title: 'Dette er en overskrift af hensyn til tilgængelighed',
47
+ children: [
48
+ <p>Step 1</p>,
49
+ <p>Step 2</p>,
50
+ <p>Step 3</p>,
51
+ <p>Step 4</p>,
52
+ <p>Step 5</p>,
53
+ ],
54
+ stepHeadlines: ['Introduction', 'Network connection', 'Sign out devices', 'Change password', 'Update device'],
55
+ introElement: <p>Her begynder vi</p>,
56
+ outroElement: <p>Her slutter vi</p>,
57
+ showFinal: true,
58
+ finalIcon: 'send',
39
59
  };
40
60