@aarhus-university/au-lib-react-components 12.0.2 → 12.1.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.
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { ComponentStory, ComponentMeta } from '@storybook/react';
2
+ import { StoryObj, Meta } from '@storybook/react';
3
3
  import AUButtonComponent from '../src/components/AUButtonComponent';
4
4
  import { ThemeWrapper } from './lib/helpers';
5
5
 
@@ -52,12 +52,12 @@ export default {
52
52
  if: {
53
53
  arg: 'icon',
54
54
  },
55
- },
55
+ },
56
56
  mode: {
57
57
  table: {
58
58
  disable: true,
59
59
  }
60
- },
60
+ },
61
61
  },
62
62
  decorators: [
63
63
  (Story, context) => (
@@ -66,63 +66,74 @@ export default {
66
66
  </ThemeWrapper>
67
67
  )
68
68
  ],
69
- } as ComponentMeta<typeof AUButtonComponent>;
69
+ } as Meta<typeof AUButtonComponent>;
70
70
 
71
- const Template: ComponentStory<typeof AUButtonComponent> = (args) => <AUButtonComponent {...args} />;
71
+ type Story = StoryObj<typeof AUButtonComponent>;
72
72
 
73
- export const Default = Template.bind({});
74
- Default.args = {
75
- label: 'Button',
76
- type: 'default',
77
- size: 'default',
78
- mode: 'none',
73
+ export const Default: Story = {
74
+ args: {
75
+ label: 'Button',
76
+ type: 'default',
77
+ size: 'default',
78
+ mode: 'none',
79
+ },
80
+ render: (args) => <AUButtonComponent {...args} />,
79
81
  };
80
82
 
81
- export const With_Icon = Template.bind({});
82
- With_Icon.args = {
83
- label: 'Button',
84
- type: 'default',
85
- size: 'default',
86
- mode: 'none',
87
- icon: 'delphinus',
88
- iconPosition: 'left',
89
- hideLabel: false,
83
+ export const With_Icon = {
84
+ args: {
85
+ label: 'Button',
86
+ type: 'default',
87
+ size: 'default',
88
+ mode: 'none',
89
+ icon: 'delphinus',
90
+ iconPosition: 'left',
91
+ hideLabel: false,
92
+ },
93
+ render: (args) => <AUButtonComponent {...args} />,
90
94
  };
91
95
 
92
- export const Icon_Only = Template.bind({});
93
- Icon_Only.args = {
94
- label: 'Button',
95
- type: 'default',
96
- size: 'default',
97
- mode: 'none',
98
- icon: 'delphinus',
99
- iconPosition: 'left',
100
- hideLabel: true,
96
+ export const Icon_Only = {
97
+ args: {
98
+ label: 'Button',
99
+ type: 'default',
100
+ size: 'default',
101
+ mode: 'none',
102
+ icon: 'delphinus',
103
+ iconPosition: 'left',
104
+ hideLabel: true,
105
+ },
106
+ render: (args) => <AUButtonComponent {...args} />,
101
107
  };
102
108
 
103
- export const Irreversible_Action = Template.bind({});
104
- Irreversible_Action.args = {
105
- label: 'Button',
106
- type: 'default',
107
- size: 'default',
108
- mode: 'ireversable-action',
109
- icon: 'delphinus',
109
+ export const Irreversible_Action = {
110
+ args: {
111
+ label: 'Button',
112
+ type: 'default',
113
+ size: 'default',
114
+ mode: 'irreversible-action',
115
+ icon: 'delphinus',
116
+ },
117
+ render: (args) => <AUButtonComponent {...args} />,
110
118
  };
111
119
 
112
- export const Confirmable_Action = Template.bind({});
113
- Confirmable_Action.args = {
114
- label: 'Button',
115
- type: 'default',
116
- size: 'default',
117
- mode: 'confirmable-action',
118
- icon: 'delphinus',
120
+ export const Confirmable_Action = {
121
+ args: {
122
+ label: 'Button',
123
+ type: 'default',
124
+ size: 'default',
125
+ mode: 'confirmable-action',
126
+ icon: 'delphinus',
127
+ },
128
+ render: (args) => <AUButtonComponent {...args} />,
119
129
  };
120
130
 
121
- export const Processing = Template.bind({});
122
- Processing.args = {
123
- label: 'Button',
124
- type: 'default',
125
- size: 'default',
126
- mode: 'processing',
127
- disabled: true,
128
- };
131
+ export const Processing = {
132
+ args: {
133
+ label: 'Button',
134
+ type: 'default',
135
+ size: 'default',
136
+ mode: 'processing',
137
+ },
138
+ render: (args) => <AUButtonComponent {...args} />,
139
+ };
@@ -0,0 +1,146 @@
1
+ import React from 'react';
2
+ import { StoryObj, Meta } from '@storybook/react';
3
+ import AUCharacterCountComponent from '../src/components/AUCharacterCountComponent';
4
+ import { ThemeWrapper } from './lib/helpers';
5
+
6
+ export const translations = {
7
+ character_count: {
8
+ overflow: {
9
+ message: {
10
+ recommended: 'Vi anbefaler, at du maksimalt skriver {{maxchars}} tegn.',
11
+ allowed: 'Du må maks. skrive {{maxchars}} tegn.'
12
+ },
13
+ count: {
14
+ recommended: {
15
+ one: 'Du har skrevet 1 tegn mere end anbefalet.',
16
+ other: 'Du har skrevet {{overflow}} tegn mere end anbefalet.'
17
+ },
18
+ allowed: {
19
+ one: 'Du har skrevet 1 tegn for meget.',
20
+ other: 'Du har skrevet {{overflow}} tegn for meget.'
21
+ }
22
+ }
23
+ },
24
+ count_down: {
25
+ one: 'Du har 1 tegn tilbage',
26
+ other: 'Du har {{remaining}} tegn tilbage'
27
+ }
28
+ },
29
+ };
30
+
31
+ export default {
32
+ title: 'Delphinus/Character Count',
33
+ component: AUCharacterCountComponent,
34
+ argTypes: {
35
+ },
36
+ decorators: [
37
+ (Story, context) => (
38
+ <ThemeWrapper theme={context.globals.theme}>
39
+ <div className="form">
40
+ <div className="form__field">
41
+ {Story()}
42
+ </div>
43
+ </div>
44
+ </ThemeWrapper>
45
+ )
46
+ ],
47
+ } as Meta<typeof AUCharacterCountComponent>;
48
+
49
+ type Story = StoryObj<typeof AUCharacterCountComponent>;
50
+
51
+ export const Recommended_empty: Story = {
52
+ args: {
53
+ type: 'recommended',
54
+ initialChars: 0,
55
+ maxChars: 100,
56
+ translations,
57
+ children: (
58
+ <input type='text' />
59
+ ),
60
+ },
61
+ render: (args) => {
62
+ return (
63
+ <AUCharacterCountComponent {...args}>
64
+ {args.children}
65
+ </AUCharacterCountComponent>
66
+ );
67
+ },
68
+ };
69
+
70
+ export const Recommended_initial: Story = {
71
+ args: {
72
+ type: 'recommended',
73
+ initialChars: 19,
74
+ maxChars: 15,
75
+ translations,
76
+ children: (
77
+ <input type='text' defaultValue="Her står noget tekst" />
78
+ ),
79
+ },
80
+ render: (args) => {
81
+ return (
82
+ <AUCharacterCountComponent {...args}>
83
+ {args.children}
84
+ </AUCharacterCountComponent>
85
+ );
86
+ },
87
+ };
88
+
89
+ export const Allowed_empty: Story = {
90
+ args: {
91
+ type: 'allowed',
92
+ initialChars: 0,
93
+ maxChars: 30,
94
+ translations,
95
+ children: (
96
+ <input type='text' />
97
+ ),
98
+ },
99
+ render: (args) => {
100
+ return (
101
+ <AUCharacterCountComponent {...args}>
102
+ {args.children}
103
+ </AUCharacterCountComponent>
104
+ );
105
+ },
106
+ };
107
+
108
+ export const Allowed_initial: Story = {
109
+ args: {
110
+ type: 'allowed',
111
+ initialChars: 19,
112
+ maxChars: 15,
113
+ translations,
114
+ children: (
115
+ <input type='text' defaultValue="Her står noget tekst" />
116
+ ),
117
+ },
118
+ render: (args) => {
119
+ return (
120
+ <AUCharacterCountComponent {...args}>
121
+ {args.children}
122
+ </AUCharacterCountComponent>
123
+ );
124
+ },
125
+ };
126
+
127
+ export const Allowed_initial_with_textarea: Story = {
128
+ args: {
129
+ type: 'allowed',
130
+ initialChars: 664,
131
+ maxChars: 500,
132
+ translations,
133
+ children: (
134
+ <textarea defaultValue="Lorem ipsum dolor sit, amet consectetur adipisicing elit. Nihil totam hic, eligendi illo perspiciatis temporibus quas magnam illum, amet debitis voluptatibus libero similique assumenda harum consequatur dolore veniam tenetur voluptatum.
135
+ Dolorem aliquam qui pariatur sapiente commodi! Odit dicta aspernatur officia quod saepe molestias tempore similique iste quasi possimus voluptas deleniti, consequatur ut facere vitae. Accusamus atque illo omnis eum unde.
136
+ Error necessitatibus repellat qui! Iusto, neque officia quae facilis debitis corrupti error. Quaerat nobis nesciunt, earum ea quo id unde iure quas soluta, nemo tempora natus, nisi beatae aspernatur fugiat." />
137
+ ),
138
+ },
139
+ render: (args) => {
140
+ return (
141
+ <AUCharacterCountComponent {...args}>
142
+ {args.children}
143
+ </AUCharacterCountComponent>
144
+ );
145
+ },
146
+ };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { ComponentStory, ComponentMeta } from '@storybook/react';
2
+ import { StoryObj, Meta } from '@storybook/react';
3
3
  import AUComboBoxComponent from '../src/components/AUComboBoxComponent';
4
4
  import { ThemeWrapper } from './lib/helpers';
5
5
 
@@ -66,7 +66,7 @@ export default {
66
66
  title: 'Delphinus/ComboBox',
67
67
  component: AUComboBoxComponent,
68
68
  argTypes: {
69
- label: {
69
+ onItemSelect: {
70
70
  table: {
71
71
  disable: true,
72
72
  }
@@ -79,16 +79,17 @@ export default {
79
79
  </ThemeWrapper>
80
80
  )
81
81
  ],
82
- } as ComponentMeta<typeof AUComboBoxComponent>;
82
+ } as Meta<typeof AUComboBoxComponent>;
83
83
 
84
- const Template: ComponentStory<typeof AUComboBoxComponent> = (args) => <AUComboBoxComponent {...args} />;
84
+ type Story = StoryObj<typeof AUComboBoxComponent>;
85
85
 
86
- export const ComboBox = Template.bind({});
87
-
88
- ComboBox.args = {
89
- data: countries,
90
- label: 'Country',
91
- resultsText: 'There are {{dataLength}} countries available.',
92
- noResultsText: 'No countries found.',
93
- noResultsTextSecondary: 'Try searching for something else.',
86
+ export const ComboBox: Story = {
87
+ args: {
88
+ data: countries,
89
+ label: 'Country',
90
+ resultsText: 'There are {{dataLength}} countries available.',
91
+ noResultsText: 'No countries found.',
92
+ noResultsTextSecondary: 'Try searching for something else.',
93
+ },
94
+ render: (args) => <AUComboBoxComponent {...args} />,
94
95
  };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { ComponentStory, ComponentMeta } from '@storybook/react';
2
+ import { StoryObj, Meta } from '@storybook/react';
3
3
  import AUContentToggleComponent from '../src/components/AUContentToggleComponent';
4
4
  import { ThemeWrapper } from './lib/helpers';
5
5
 
@@ -16,7 +16,27 @@ export default {
16
16
  table: {
17
17
  disable: true,
18
18
  }
19
- },
19
+ },
20
+ classNames: {
21
+ table: {
22
+ disable: true,
23
+ }
24
+ },
25
+ onClick: {
26
+ table: {
27
+ disable: true,
28
+ }
29
+ },
30
+ beforeCallback: {
31
+ table: {
32
+ disable: true,
33
+ }
34
+ },
35
+ afterCallback: {
36
+ table: {
37
+ disable: true,
38
+ }
39
+ },
20
40
  },
21
41
  decorators: [
22
42
  (Story, context) => (
@@ -25,39 +45,43 @@ export default {
25
45
  </ThemeWrapper>
26
46
  )
27
47
  ],
28
- } as ComponentMeta<typeof AUContentToggleComponent>;
48
+ } as Meta<typeof AUContentToggleComponent>;
29
49
 
30
- const Template: ComponentStory<typeof AUContentToggleComponent> = (args) => <AUContentToggleComponent {...args} />;
50
+ type Story = StoryObj<typeof AUContentToggleComponent>;
31
51
 
32
- export const Hidden_when_loaded = Template.bind({});
33
- Hidden_when_loaded.args = {
34
- toggled: false,
35
- children: (
36
- <div className="box theme--background-secondary box--constrain-width">
37
- <button className="content-toggle__toggle button button--small" aria-expanded="false">
38
- Very interesting content is hidden
39
- </button>
40
- <div className="content-toggle__content vertical-spacing-top" hidden>
41
- <h4 className="text--label-header text--pull">The content that is toggled</h4>
42
- <p>Collapsible sections are perhaps the most rudimentary of interactive design patterns on the web. All they do is let you toggle the visibility of content by clicking that content's label. Big whoop.</p>
52
+ export const Hidden_when_loaded: Story = {
53
+ args: {
54
+ toggled: false,
55
+ children: (
56
+ <div className="box theme--background-secondary box--constrain-width">
57
+ <button className="content-toggle__toggle button button--small" aria-expanded="false">
58
+ Very interesting content is hidden
59
+ </button>
60
+ <div className="content-toggle__content vertical-spacing-top" hidden>
61
+ <h4 className="text--label-header text--pull">The content that is toggled</h4>
62
+ <p>Collapsible sections are perhaps the most rudimentary of interactive design patterns on the web. All they do is let you toggle the visibility of content by clicking that content's label. Big whoop.</p>
63
+ </div>
43
64
  </div>
44
- </div>
45
- ),
65
+ ),
66
+ },
67
+ render: (args) => <AUContentToggleComponent {...args} />,
46
68
  };
47
69
 
48
- export const Shown_when_loaded = Template.bind({});
49
- Shown_when_loaded.args = {
50
- toggled: true,
51
- children: (
52
- <div className="box theme--background-secondary box--constrain-width">
53
- <button className="content-toggle__toggle button button--small" aria-expanded="true">
54
- Very interesting content is hidden
55
- </button>
56
- <div className="content-toggle__content vertical-spacing-top">
57
- <h4 className="text--label-header text--pull">The content that is toggled</h4>
58
- <p>Collapsible sections are perhaps the most rudimentary of interactive design patterns on the web. All they do is let you toggle the visibility of content by clicking that content's label. Big whoop.</p>
70
+ export const Shown_when_loaded: Story = {
71
+ args: {
72
+ toggled: true,
73
+ children: (
74
+ <div className="box theme--background-secondary box--constrain-width">
75
+ <button className="content-toggle__toggle button button--small" aria-expanded="true">
76
+ Very interesting content is hidden
77
+ </button>
78
+ <div className="content-toggle__content vertical-spacing-top">
79
+ <h4 className="text--label-header text--pull">The content that is toggled</h4>
80
+ <p>Collapsible sections are perhaps the most rudimentary of interactive design patterns on the web. All they do is let you toggle the visibility of content by clicking that content's label. Big whoop.</p>
81
+ </div>
59
82
  </div>
60
- </div>
61
- ),
83
+ ),
84
+ },
85
+ render: (args) => <AUContentToggleComponent {...args} />,
62
86
  };
63
87
 
@@ -0,0 +1,68 @@
1
+ import React from 'react';
2
+ import { StoryObj, Meta } from '@storybook/react';
3
+ import AUEditorComponent from '../src/components/AUEditorComponent';
4
+ import { ThemeWrapper } from './lib/helpers';
5
+ import { translations } from './AUCharacterCountComponent.stories';
6
+
7
+ export default {
8
+ title: 'Delphinus/Editor',
9
+ component: AUEditorComponent,
10
+ argTypes: {
11
+ title: {
12
+ table: {
13
+ disable: true,
14
+ }
15
+ },
16
+ },
17
+ decorators: [
18
+ (Story, context) => (
19
+ <ThemeWrapper theme={context.globals.theme}>
20
+ {Story()}
21
+ </ThemeWrapper>
22
+ )
23
+ ],
24
+ } as Meta<typeof AUEditorComponent>;
25
+
26
+ type Story = StoryObj<typeof AUEditorComponent>;
27
+
28
+ export const Without_Character_Count: Story = {
29
+ args: {
30
+ lang: 'en',
31
+ id: 'editor',
32
+ textareaName: 'editor',
33
+ initialValue: '<h3>Overskrift</h3><p>Indhold</p>',
34
+ translations,
35
+ onEditorChange: (value: string) => console.log(value),
36
+ },
37
+ render: (args) => <AUEditorComponent {...args} />,
38
+ };
39
+
40
+ export const With_Recommended_Character_Count: Story = {
41
+ args: {
42
+ lang: 'da',
43
+ id: 'editor',
44
+ textareaName: 'editor',
45
+ initialValue: '',
46
+ showCounter: true,
47
+ counterType: 'recommended',
48
+ maxChars: 100,
49
+ translations,
50
+ onEditorChange: (value: string) => console.log(value),
51
+ },
52
+ render: (args) => <AUEditorComponent {...args} />,
53
+ };
54
+
55
+ export const With_Allowed_Character_Count: Story = {
56
+ args: {
57
+ lang: 'da',
58
+ id: 'editor',
59
+ textareaName: 'editor',
60
+ initialValue: '',
61
+ showCounter: true,
62
+ counterType: 'allowed',
63
+ maxChars: 100,
64
+ translations,
65
+ onEditorChange: (value: string) => console.log(value),
66
+ },
67
+ render: (args) => <AUEditorComponent {...args} />,
68
+ };