@progressive-development/pd-forms 0.0.13 → 0.0.15

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 (42) hide show
  1. package/package.json +2 -2
  2. package/pd-button-goup.js +3 -0
  3. package/pd-button.js +3 -0
  4. package/pd-checkbox.js +3 -0
  5. package/pd-form-container.js +3 -0
  6. package/pd-form-row.js +3 -0
  7. package/pd-input-area.js +3 -0
  8. package/pd-input.js +3 -0
  9. package/pd-label-value.js +3 -0
  10. package/pd-radio-group.js +3 -0
  11. package/pd-select.js +3 -0
  12. package/src/{squi-base-ui.js → PdBaseUi.js} +1 -1
  13. package/src/{squi-base-ui-input.js → PdBaseUiInput.js} +2 -2
  14. package/src/{squi-button.js → PdButton.js} +10 -10
  15. package/src/{squi-button-group.js → PdButtonGroup.js} +3 -3
  16. package/src/{squi-checkbox.js → PdCheckbox.js} +22 -22
  17. package/src/{squi-form-container.js → PdFormContainer.js} +1 -1
  18. package/src/{squi-form-row.js → PdFormRow.js} +1 -1
  19. package/src/{squi-input.js → PdInput.js} +15 -15
  20. package/src/{squi-input-area.js → PdInputArea.js} +13 -13
  21. package/src/PdLabelValue.js +75 -0
  22. package/src/{squi-radio-group.js → PdRadioGroup.js} +4 -4
  23. package/src/{squi-select.js → PdSelect.js} +9 -9
  24. package/src/shared-input-styles.js +11 -11
  25. package/stories/button.stories.js +15 -0
  26. package/stories/checkbox.stories.js +50 -0
  27. package/stories/form-container.stories.js +50 -0
  28. package/stories/index.stories.js +297 -29
  29. package/stories/input-area.stories.js +129 -0
  30. package/stories/input.stories.js +130 -0
  31. package/stories/label-value.stories.js +32 -0
  32. package/stories/radio-group.stories.js +45 -0
  33. package/stories/select.stories.js +104 -0
  34. package/PdButton.js +0 -3
  35. package/PdButtonGroup.js +0 -3
  36. package/PdCheckbox.js +0 -3
  37. package/PdFormContainer.js +0 -3
  38. package/PdFormRow.js +0 -3
  39. package/PdInput.js +0 -3
  40. package/PdInputArea.js +0 -3
  41. package/PdRadioGroup.js +0 -3
  42. package/PdSelect.js +0 -3
@@ -0,0 +1,15 @@
1
+ import { html } from 'lit';
2
+ import '../pd-button.js';
3
+
4
+ export default {
5
+ title: 'PdForms/Button',
6
+ component: 'pd-button',
7
+ argTypes: {},
8
+ };
9
+
10
+ function ButtonTemplate() {
11
+ return html` <pd-button text="My Button"></pd-button> `;
12
+ }
13
+
14
+ export const Button = ButtonTemplate.bind({});
15
+ Button.args = {};
@@ -0,0 +1,50 @@
1
+ import { html } from 'lit';
2
+ import '../pd-checkbox.js';
3
+
4
+ export default {
5
+ title: 'PdForms/Checkbox',
6
+ component: 'pd-checkbox',
7
+ parameters: {
8
+ actions: {
9
+ handles: ['checkbox-changed'],
10
+ },
11
+ },
12
+ };
13
+
14
+ function Template({ errorMsg }) {
15
+ return html`
16
+ <h3>Checkbox selected</h3>
17
+ <pd-checkbox name="Test1" value="true" errorMsg="${errorMsg}"
18
+ >Label zur Checkbox</pd-checkbox
19
+ >
20
+
21
+ <h3>Checkbox unselected</h3>
22
+ <pd-checkbox name="Test2" value="false" errorMsg="${errorMsg}"
23
+ >Label zur Checkbox</pd-checkbox
24
+ >
25
+ `;
26
+ }
27
+
28
+ function SwitchTemplate({ errorMsg }) {
29
+ return html`
30
+ <h3>Switch selected</h3>
31
+ <pd-checkbox name="Test1" isSwitch value="true" errorMsg="${errorMsg}"
32
+ >Label zur Checkbox</pd-checkbox
33
+ >
34
+
35
+ <h3>Switch unselected</h3>
36
+ <pd-checkbox name="Test2" isSwitch value="false" errorMsg="${errorMsg}"
37
+ >Label zur Checkbox</pd-checkbox
38
+ >
39
+ `;
40
+ }
41
+
42
+ export const Checkbox = Template.bind({});
43
+ Checkbox.args = {
44
+ errorMsg: '',
45
+ };
46
+
47
+ export const Switch = SwitchTemplate.bind({});
48
+ Switch.args = {
49
+ errorMsg: '',
50
+ };
@@ -0,0 +1,50 @@
1
+ import { html } from 'lit';
2
+ import '../pd-form-container.js';
3
+ import '../pd-form-row.js';
4
+ import '../pd-input.js';
5
+
6
+ export default {
7
+ title: 'PdForms/Form Container',
8
+ component: 'pd-form-container',
9
+ argTypes: {},
10
+ };
11
+
12
+ function Template() {
13
+ return html`
14
+ <h3>Mit Forms</h3>
15
+ <pd-form-container>
16
+ <pd-form-row>
17
+ <pd-input class="quarter2" id="test1Id" label="Label 1"></pd-input>
18
+ <pd-input class="quarter2" id="test2Id" label="Label 2"></pd-input>
19
+ </pd-form-row>
20
+ <pd-form-row>
21
+ <pd-input class="quarter4" id="test3Id" label="Label 3"></pd-input>
22
+ </pd-form-row>
23
+ <pd-form-row>
24
+ <pd-input class="quarter3" id="test4Id" label="Label 4"></pd-input>
25
+ </pd-form-row>
26
+ <pd-form-row>
27
+ <pd-input class="quarter1" id="test5Id" label="Label 5"></pd-input>
28
+ <pd-input class="quarter1" id="test6Id" label="Label 6"></pd-input>
29
+ <pd-input class="quarter1" id="test7Id" label="Label 7"></pd-input>
30
+ <pd-input class="quarter1" id="test8Id" label="Label 8"></pd-input>
31
+ </pd-form-row>
32
+ <pd-form-row>
33
+ <pd-input class="quarter3" id="test9Id" label="Label 5"></pd-input>
34
+ <pd-input class="quarter1" id="test10Id" label="Label 6"></pd-input>
35
+ </pd-form-row>
36
+ <pd-form-row>
37
+ <pd-input class="quarter1" id="test11Id" label="Label 5"></pd-input>
38
+ <pd-input class="quarter3" id="test12Id" label="Label 6"></pd-input>
39
+ </pd-form-row>
40
+ <pd-form-row>
41
+ <pd-input class="quarter1" id="test13Id" label="Label 5"></pd-input>
42
+ <pd-input class="quarter1" id="test14Id" label="Label 5"></pd-input>
43
+ <pd-input class="quarter2" id="test15Id" label="Label 6"></pd-input>
44
+ </pd-form-row>
45
+ </pd-form-container>
46
+ `;
47
+ }
48
+
49
+ export const FormContainer = Template.bind({});
50
+ FormContainer.args = {};
@@ -1,44 +1,312 @@
1
1
  import { html } from 'lit';
2
- import '../pd-forms.js';
2
+
3
+ import '../pd-button.js';
4
+ import '../pd-button-goup.js';
5
+ import '../pd-checkbox.js';
6
+ import '../pd-input.js';
7
+ import '../pd-input-area.js';
8
+ import '../pd-radio-group.js';
9
+ import '../pd-select.js';
3
10
 
4
11
  export default {
5
- title: 'PdForms',
12
+ title: 'Form Examples',
6
13
  component: 'pd-forms',
7
14
  argTypes: {
8
- title: { control: 'text' },
9
- counter: { control: 'number' },
15
+ gradient: { control: 'boolean' },
16
+ primaryColor: { control: 'color' },
17
+ secondaryColor: { control: 'color' },
18
+ thirdColor: { control: 'color' },
10
19
  textColor: { control: 'color' },
20
+ highlightColor: { control: 'color' },
21
+ errorColor: { control: 'color' },
22
+ errorBackgroundColor: { control: 'color' },
23
+ borderRadius: { control: 'text' },
24
+ displayFont: { control: 'text' },
25
+ fontSize: { control: 'text' },
26
+ inputHeigth: { control: 'text' },
11
27
  },
12
28
  };
13
29
 
14
- function Template({ title = 'Hello world', counter = 5, textColor, slot }) {
15
- return html`
16
- <pd-forms
17
- style="--pd-forms-text-color: ${textColor || 'black'}"
18
- .title=${title}
19
- .counter=${counter}
30
+ function Template({
31
+ selectVals,
32
+ gradient,
33
+ primaryColor,
34
+ secondaryColor,
35
+ thirdColor,
36
+ textColor,
37
+ highlightColor,
38
+ errorColor,
39
+ errorBackgroundColor,
40
+ borderRadius,
41
+ displayFont,
42
+ fontSize,
43
+ inputHeigth,
44
+ }) {
45
+
46
+ let style = '';
47
+ if (primaryColor) {
48
+ style += `--squi-primary-color:${primaryColor};`;
49
+ }
50
+ if (secondaryColor) {
51
+ style += `--squi-secondary-color:${secondaryColor};`;
52
+ }
53
+ if (thirdColor) {
54
+ style += `--squi-third-color:${thirdColor};`;
55
+ }
56
+ if (textColor) {
57
+ style += `--squi-text-color:${textColor};`;
58
+ }
59
+ if (highlightColor) {
60
+ style += `--squi-highlight-color:${highlightColor};`;
61
+ }
62
+ if (errorColor) {
63
+ style += `--squi-error-color:${errorColor};`;
64
+ }
65
+ if (errorBackgroundColor) {
66
+ style += `--squi-error-background-color:${errorBackgroundColor};`;
67
+ }
68
+ if (borderRadius) {
69
+ style += `--squi-border-radius:${borderRadius};`;
70
+ }
71
+ if (displayFont) {
72
+ style += `--squi-display-font:${displayFont};`;
73
+ }
74
+ if (fontSize) {
75
+ style += `--squi-font-size:${fontSize};`;
76
+ }
77
+ if (inputHeigth) {
78
+ style += `--squi-input-height:${inputHeigth};`;
79
+ }
80
+
81
+ return html`
82
+ <h3>Defaults Inputs with labels</h3>
83
+ <div
84
+ style="display: flex; justify-content: space-between; max-width: 800px"
20
85
  >
21
- ${slot}
22
- </pd-forms>
23
- `;
24
- }
86
+ <pd-select
87
+ id="testId1"
88
+ ?gradient="${gradient}"
89
+ style="${style}"
90
+ label="Select Label"
91
+ ></pd-select>
92
+ <pd-input
93
+ id="testId1"
94
+ ?gradient="${gradient}"
95
+ style="${style}"
96
+ label="Input Label"
97
+ ></pd-input>
98
+ <pd-input-area
99
+ id="testId2"
100
+ ?gradient="${gradient}"
101
+ style="${style}"
102
+ label="Input Area Label"
103
+ ></pd-input-area>
104
+ </div>
25
105
 
26
- export const Regular = Template.bind({});
106
+ <div
107
+ style="display: flex; justify-content: space-between; max-width: 800px"
108
+ >
109
+ <pd-select
110
+ id="testId1"
111
+ ?gradient="${gradient}"
112
+ .values="${selectVals}"
113
+ style="${style}"
114
+ label="Select Label"
115
+ ></pd-select>
116
+ <pd-input
117
+ id="testId1"
118
+ ?gradient="${gradient}"
119
+ style="${style}"
120
+ label="Input Label"
121
+ value="My Value"
122
+ ></pd-input>
123
+ <pd-input-area
124
+ id="testId2"
125
+ ?gradient="${gradient}"
126
+ style="${style}"
127
+ label="Input Area Label"
128
+ value="My Value Area Text and ..."
129
+ ></pd-input-area>
130
+ </div>
27
131
 
28
- export const CustomTitle = Template.bind({});
29
- CustomTitle.args = {
30
- title: 'My title',
31
- };
132
+ <div
133
+ style="display: flex; justify-content: space-between; max-width: 800px"
134
+ >
135
+ <pd-select
136
+ id="testId1"
137
+ .values="${selectVals}"
138
+ ?gradient="${gradient}"
139
+ style="${style}"
140
+ label="Select Label"
141
+ errorMsg="Fehler 1"
142
+ ></pd-select>
143
+ <pd-input
144
+ id="testId1"
145
+ style="${style}"
146
+ ?gradient="${gradient}"
147
+ label="Input Label"
148
+ value="My Value"
149
+ errorMsg="Fehler 2"
150
+ ></pd-input>
151
+ <pd-input-area
152
+ id="testId2"
153
+ style="${style}"
154
+ ?gradient="${gradient}"
155
+ label="Input Area Label"
156
+ errorMsg="Fehler 3"
157
+ value="My Value Area Text and ..."
158
+ ></pd-input-area>
159
+ </div>
32
160
 
33
- export const CustomCounter = Template.bind({});
34
- CustomCounter.args = {
35
- counter: 123456,
36
- };
161
+ <div
162
+ style="display: flex; justify-content: space-between; max-width: 800px"
163
+ >
164
+ <pd-select
165
+ id="testId1"
166
+ .values="${selectVals}"
167
+ ?gradient="${gradient}"
168
+ style="${style}"
169
+ ?disabled="${true}"
170
+ label="Select Label"
171
+ ></pd-select>
172
+ <pd-input
173
+ id="testId1"
174
+ style="${style}"
175
+ ?gradient="${gradient}"
176
+ label="Input Label"
177
+ ?disabled="${true}"
178
+ value="My Value"
179
+ ></pd-input>
180
+ <pd-input-area
181
+ id="testId2"
182
+ style="${style}"
183
+ ?gradient="${gradient}"
184
+ label="Input Area Label"
185
+ ?disabled="${true}"
186
+ value="My Value Area Text and ..."
187
+ ></pd-input-area>
188
+ </div>
37
189
 
38
- export const SlottedContent = Template.bind({});
39
- SlottedContent.args = {
40
- slot: html`<p>Slotted content</p>`,
41
- };
42
- SlottedContent.argTypes = {
43
- slot: { table: { disable: true } },
190
+ <div
191
+ style="display: flex; justify-content: space-between; max-width: 800px"
192
+ >
193
+ <pd-select
194
+ id="testId1"
195
+ .values="${selectVals}"
196
+ ?gradient="${gradient}"
197
+ style="${style}"
198
+ ?disabled="${true}"
199
+ label="Select ohne Placeholder"
200
+ ></pd-select>
201
+ <pd-input
202
+ id="testId1"
203
+ style="${style}"
204
+ ?gradient="${gradient}"
205
+ label="Input Label"
206
+ placeHolder="Placeholder Text"
207
+ ></pd-input>
208
+ <pd-input-area
209
+ id="testId2"
210
+ style="${style}"
211
+ ?gradient="${gradient}"
212
+ label="Input Area Label"
213
+ placeHolder="Placeholder Text"
214
+ ></pd-input-area>
215
+ </div>
216
+
217
+ <h3>Radio & Switch</h3>
218
+ <div
219
+ style="display: flex; justify-content: space-between; max-width: 1000px"
220
+ >
221
+ <pd-checkbox name="Test1" value="true"
222
+ >Label zur Checkbox</pd-checkbox
223
+ >
224
+ <pd-checkbox name="Test2" value="false"
225
+ >Label zur Checkbox</pd-checkbox
226
+ >
227
+ <pd-checkbox name="Test1" isSwitch value="true"
228
+ >Label zur Checkbox</pd-checkbox
229
+ >
230
+ <pd-checkbox name="Test2" isSwitch value="false"
231
+ >Label zur Checkbox</pd-checkbox
232
+ >
233
+ </div>
234
+
235
+ <h3>Radio Group</h3>
236
+ <pd-radio-group>
237
+ <pd-checkbox name="Test1" value="true"
238
+ >Label zur Checkbox</pd-checkbox
239
+ >
240
+ <pd-checkbox name="Test2" value="false"
241
+ >Label zur Checkbox</pd-checkbox
242
+ >
243
+ </pd-radio-group>
244
+ <pd-radio-group style="--group-direction: column;">
245
+ <pd-checkbox name="Test3" value="true"
246
+ >Label zur Checkbox</pd-checkbox
247
+ >
248
+ <pd-checkbox name="Test4" value="false"
249
+ >Label zur Checkbox</pd-checkbox
250
+ >
251
+ </pd-radio-group>
252
+
253
+ <h3>Buttons</h3>
254
+ <pd-button
255
+ ?gradient="${gradient}"
256
+ style="${style}"
257
+ text="Primary"
258
+ ?primary="${true}"
259
+ ></pd-button>
260
+ <pd-button
261
+ ?gradient="${gradient}"
262
+ style="${style}"
263
+ text="Normal"
264
+ ></pd-button>
265
+ <pd-button
266
+ ?gradient="${gradient}"
267
+ style="${style}"
268
+ ?disabled="${true}"
269
+ text="Disabled"
270
+ ></pd-button>
271
+ <pd-button
272
+ ?gradient="${gradient}"
273
+ style="${style}"
274
+ text="Primary Disabled"
275
+ ?disabled="${true}"
276
+ ?primary="${true}"
277
+ ></pd-button>
278
+
279
+ <h3>Button Group</h3>
280
+ <pd-button-group
281
+ @button-click="${e => alert('Button click:', e)}"
282
+ .buttons="${[
283
+ { text: 'Button 1' },
284
+ { text: 'Button 2' },
285
+ { text: 'Button 3' },
286
+ { text: 'Button 4' },
287
+ ]}"
288
+ >
289
+ </pd-button-group>
290
+
291
+ <pd-button-group
292
+ .buttons="${[
293
+ { text: 'Button 1' },
294
+ { text: 'Button 2', visibility: 'hidden' },
295
+ { text: 'Button 3' },
296
+ { text: 'Button 4' },
297
+ ]}"
298
+ >
299
+ </pd-button-group>
300
+ `;
301
+ }
302
+
303
+ export const FormExamples = Template.bind({});
304
+ FormExamples.args = {
305
+ selectVals: [
306
+ { name: 'Option 1', value: 1 },
307
+ { name: 'Option 2', value: 2 },
308
+ { name: 'Option 3', value: 3 },
309
+ ],
310
+ gradient: false,
44
311
  };
312
+
@@ -0,0 +1,129 @@
1
+ import { html } from 'lit';
2
+ import '../pd-input-area.js';
3
+
4
+ export default {
5
+ title: 'PdForms/Input Area',
6
+ component: 'pd-input-area',
7
+ argTypes: {
8
+ primaryColor: { control: 'color' },
9
+ secondaryColor: { control: 'color' },
10
+ textColor: { control: 'color' },
11
+ highlightColor: { control: 'color' },
12
+ errorColor: { control: 'color' },
13
+ errorBackgroundColor: { control: 'color' },
14
+ borderRadius: { control: 'text' },
15
+ displayFont: { control: 'text' },
16
+ fontSize: { control: 'text' },
17
+ },
18
+ };
19
+
20
+ function Template({
21
+ primaryColor,
22
+ secondaryColor,
23
+ textColor,
24
+ highlightColor,
25
+ errorColor,
26
+ errorBackgroundColor,
27
+ borderRadius,
28
+ displayFont,
29
+ fontSize,
30
+ }) {
31
+ let style = '';
32
+ if (primaryColor) {
33
+ style += `--squi-primary-color:${primaryColor};`;
34
+ }
35
+ if (secondaryColor) {
36
+ style += `--squi-secondary-color:${secondaryColor};`;
37
+ }
38
+ if (textColor) {
39
+ style += `--squi-text-color:${textColor};`;
40
+ }
41
+ if (highlightColor) {
42
+ style += `--squi-highlight-color:${highlightColor};`;
43
+ }
44
+ if (errorColor) {
45
+ style += `--squi-error-color:${errorColor};`;
46
+ }
47
+ if (errorBackgroundColor) {
48
+ style += `--squi-error-background-color:${errorBackgroundColor};`;
49
+ }
50
+ if (borderRadius) {
51
+ style += `--squi-border-radius:${borderRadius};`;
52
+ }
53
+ if (displayFont) {
54
+ style += `--squi-display-font:${displayFont};`;
55
+ }
56
+ if (fontSize) {
57
+ style += `--squi-font-size:${fontSize};`;
58
+ }
59
+
60
+ return html`
61
+ <h3>Input Area default</h3>
62
+ <pd-input-area id="testId1" style="${style}"></pd-input-area>
63
+
64
+ <h3>Input Area default with value</h3>
65
+ <pd-input-area
66
+ id="testId2"
67
+ style="${style}"
68
+ value="Das ist mein Text-Area Input value"
69
+ ></pd-input-area>
70
+
71
+ <h3>Input Area with value - custom size</h3>
72
+ <pd-input-area
73
+ id="testId3"
74
+ style="${style}"
75
+ value="Das ist mein Text-Area Input value. Der kann auch ein bißchen länger sein. Weitere Zeilen stehen hier...."
76
+ ></pd-input-area>
77
+
78
+ <h3>Input Area with placeholder - custom size</h3>
79
+ <pd-input-area
80
+ id="testId4"
81
+ style="${style}"
82
+ placeHolder="Hier steht ein placeholder Text"
83
+ ></pd-input-area>
84
+
85
+ <h3>
86
+ Input Area with value - custom size - label => ToDo: Derzeit ohne
87
+ cols/rows nur mit css props
88
+ </h3>
89
+ <pd-input-area
90
+ id="testId5"
91
+ style="${style}"
92
+ label="Area Label 1"
93
+ rows="10"
94
+ value="Mein Text..."
95
+ ></pd-input-area>
96
+
97
+ <h3>Input Area with error - custom size - label</h3>
98
+ <pd-input-area
99
+ id="testId6"
100
+ style="${style}"
101
+ label="Area Label 2"
102
+ value="Mein Text..."
103
+ errorMsg="Fehler augetreten"
104
+ ></pd-input-area>
105
+
106
+ <h3>Input Area disabled - custom size - label</h3>
107
+ <pd-input-area
108
+ id="testId7"
109
+ style="${style}"
110
+ label="Area Label 3"
111
+ value="Mein Text..."
112
+ ?disabled="${true}"
113
+ ></pd-input-area>
114
+
115
+ <h3>Input Area readonly - custom size - label</h3>
116
+ <pd-input-area
117
+ id="testId8"
118
+ style="${style}"
119
+ cols="60"
120
+ rows="3"
121
+ label="Area Label 4"
122
+ value="Mein Text..."
123
+ ?readonly="${true}"
124
+ ></pd-input-area>
125
+ `;
126
+ }
127
+
128
+ export const InputArea = Template.bind({});
129
+ InputArea.args = {};