@qld-gov-au/qgds-bootstrap5 2.0.11 → 2.0.12
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/.storybook/preview.js +5 -2
- package/dist/assets/components/bs5/dateinput/dateinput.hbs +27 -27
- package/dist/assets/components/bs5/formcheck/formcheck.hbs +10 -2
- package/dist/assets/components/bs5/head/head.hbs +1 -1
- package/dist/assets/components/bs5/searchInput/searchInput.hbs +31 -29
- package/dist/assets/components/bs5/select/select.hbs +19 -19
- package/dist/assets/components/bs5/textarea/textarea.hbs +17 -17
- package/dist/assets/components/bs5/textbox/textbox.hbs +17 -18
- package/dist/assets/css/qld.bootstrap.css +2 -2
- package/dist/assets/css/qld.bootstrap.css.map +3 -3
- package/dist/assets/css/qld.bootstrap.legacy.css +2 -2
- package/dist/assets/css/qld.bootstrap.legacy.css.map +3 -3
- package/dist/assets/js/handlebars.helpers.bundle.js +1 -1
- package/dist/assets/js/handlebars.init.min.js +134 -125
- package/dist/assets/js/handlebars.init.min.js.map +2 -2
- package/dist/assets/js/handlebars.partials.js +134 -125
- package/dist/assets/js/handlebars.partials.js.map +2 -2
- package/dist/assets/js/qld.bootstrap.min.js +9 -10
- package/dist/assets/js/qld.bootstrap.min.js.map +3 -3
- package/dist/assets/node/handlebars.init.min.js +51 -7
- package/dist/assets/node/handlebars.init.min.js.map +2 -2
- package/dist/components/bs5/dateinput/dateinput.hbs +27 -27
- package/dist/components/bs5/formcheck/formcheck.hbs +10 -2
- package/dist/components/bs5/head/head.hbs +1 -1
- package/dist/components/bs5/searchInput/searchInput.hbs +31 -29
- package/dist/components/bs5/select/select.hbs +19 -19
- package/dist/components/bs5/textarea/textarea.hbs +17 -17
- package/dist/components/bs5/textbox/textbox.hbs +17 -18
- package/dist/package.json +1 -1
- package/dist/sample-data/dateinput/dateinput.data.json +14 -12
- package/dist/sample-data/formcheck/stories/checkbox/checkbox.data.json +4 -5
- package/dist/sample-data/formcheck/stories/radio/radio.data.json +4 -4
- package/dist/sample-data/searchInput/searchInput.data.json +19 -10
- package/dist/sample-data/select/select.data.json +12 -10
- package/dist/sample-data/textarea/textarea.data.json +14 -11
- package/dist/sample-data/textbox/textbox.data.json +13 -10
- package/package.json +1 -1
- package/src/components/bs5/dateinput/Dateinput.js +26 -11
- package/src/components/bs5/dateinput/dateinput.data.json +14 -12
- package/src/components/bs5/dateinput/dateinput.hbs +27 -27
- package/src/components/bs5/formcheck/Formcheck.js +57 -6
- package/src/components/bs5/formcheck/_form-variables.scss +131 -0
- package/src/components/bs5/formcheck/formcheck.hbs +10 -2
- package/src/components/bs5/formcheck/formcheck.scss +229 -66
- package/src/components/bs5/formcheck/stories/bootstrap-validation/bootstrap-validation.stories.js +304 -0
- package/src/components/bs5/formcheck/stories/checkbox/checkbox.data.json +4 -5
- package/src/components/bs5/formcheck/stories/checkbox/checkbox.stories.js +19 -111
- package/src/components/bs5/formcheck/stories/radio/radio.data.json +4 -4
- package/src/components/bs5/formcheck/stories/radio/radio.stories.js +30 -122
- package/src/components/bs5/inpageAlert/inpageAlert.scss +1 -1
- package/src/components/bs5/pageLayout/{ThemeShowcase.stories.js → PaletteShowcase.stories.js} +36 -35
- package/src/components/bs5/searchInput/__snapshots__/searchInput.test.js.snap +24 -28
- package/src/components/bs5/searchInput/search.functions.js +93 -76
- package/src/components/bs5/searchInput/searchInput.data.json +19 -10
- package/src/components/bs5/searchInput/searchInput.hbs +31 -29
- package/src/components/bs5/searchInput/searchInput.scss +140 -196
- package/src/components/bs5/searchInput/searchInput.stories.js +35 -13
- package/src/components/bs5/searchInput/searchInput.test.js +5 -1
- package/src/components/bs5/select/Select.js +13 -5
- package/src/components/bs5/select/Select.stories.js +27 -83
- package/src/components/bs5/select/select.data.json +12 -10
- package/src/components/bs5/select/select.hbs +19 -19
- package/src/components/bs5/textarea/Textarea.js +13 -5
- package/src/components/bs5/textarea/Textarea.stories.js +29 -55
- package/src/components/bs5/textarea/textarea.data.json +14 -11
- package/src/components/bs5/textarea/textarea.hbs +17 -17
- package/src/components/bs5/textbox/Textbox.js +16 -5
- package/src/components/bs5/textbox/Textbox.stories.js +26 -51
- package/src/components/bs5/textbox/textInput.scss +12 -232
- package/src/components/bs5/textbox/textbox.data.json +13 -10
- package/src/components/bs5/textbox/textbox.hbs +17 -18
- package/src/css/functions/_index.scss +2 -0
- package/src/css/functions/remify.scss +32 -0
- package/src/css/functions/snap-line-height.scss +7 -0
- package/src/css/main.scss +1 -1
- package/src/css/mixins/focusable.scss +3 -0
- package/src/css/{qld-theme.scss → qld-palettes.scss} +30 -23
- package/src/components/bs5/formcheck/_formcheck.stories.bak.js +0 -432
|
@@ -1,131 +1,75 @@
|
|
|
1
1
|
// ComponentExample.stories.js
|
|
2
|
-
import { Select } from "./Select.js";
|
|
2
|
+
import { Select, argTypes } from "./Select.js";
|
|
3
3
|
import defaultdata from "./select.data.json";
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
tags: ["autodocs"],
|
|
7
7
|
title: "3. Components/Forms/Select",
|
|
8
8
|
render: (args) => {
|
|
9
|
-
|
|
10
|
-
//Storybook produces a comma delimited string when using the check control type (table-striped, table-bordered) etc.
|
|
9
|
+
//Storybook produces a comma delimited string when using the check control type (table-striped, table-bordered) etc.
|
|
11
10
|
//We can't use commas on our class="..." attribute, so we need to replace the commas with spaces.
|
|
12
11
|
|
|
13
|
-
if(
|
|
14
|
-
args.customClass = args.customClass.replaceAll(","," ");
|
|
15
|
-
} else if (
|
|
12
|
+
if (typeof args.customClass === "string") {
|
|
13
|
+
args.customClass = args.customClass.replaceAll(",", " ");
|
|
14
|
+
} else if (typeof args.customClass === "object") {
|
|
16
15
|
args.customClass = args.customClass.join(" ");
|
|
17
16
|
}
|
|
18
|
-
|
|
17
|
+
|
|
19
18
|
return new Select(args).html;
|
|
20
|
-
|
|
21
19
|
},
|
|
20
|
+
parameters: { backgrounds: { disable: false } },
|
|
21
|
+
globals: { backgrounds: { value: "default" } },
|
|
22
22
|
|
|
23
23
|
//https://storybook.js.org/docs/api/arg-types
|
|
24
|
-
argTypes
|
|
25
|
-
/*customClass: {
|
|
26
|
-
name: "Classes",
|
|
27
|
-
description: 'Settable classes for the component',
|
|
28
|
-
control: {
|
|
29
|
-
type: "check",
|
|
30
|
-
labels: {
|
|
31
|
-
"form-style-filled": "Filled",
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
options: [
|
|
35
|
-
"form-style-filled",
|
|
36
|
-
],
|
|
37
|
-
},
|
|
38
|
-
states: {
|
|
39
|
-
name: "States",
|
|
40
|
-
description: `Valid/Invalid states`,
|
|
41
|
-
control: {
|
|
42
|
-
type: "radio",
|
|
43
|
-
labels: {
|
|
44
|
-
"default": "Default",
|
|
45
|
-
"qld-input-success": "Success",
|
|
46
|
-
"qld-input-error": "Error",
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
options: [
|
|
50
|
-
"default",
|
|
51
|
-
"qld-input-success",
|
|
52
|
-
"qld-input-error",
|
|
53
|
-
],
|
|
54
|
-
},*/
|
|
55
|
-
},
|
|
24
|
+
argTypes,
|
|
56
25
|
};
|
|
57
26
|
|
|
58
27
|
/**
|
|
59
|
-
* Default
|
|
28
|
+
* Default palette context
|
|
60
29
|
*/
|
|
61
30
|
export const Default = {
|
|
62
31
|
args: defaultdata,
|
|
63
32
|
};
|
|
64
33
|
|
|
65
34
|
/**
|
|
66
|
-
* Dark
|
|
35
|
+
* Dark pallete context
|
|
67
36
|
*/
|
|
68
37
|
export const Dark = {
|
|
69
|
-
args: {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
},
|
|
73
|
-
parameters: {
|
|
74
|
-
backgrounds: {
|
|
75
|
-
default: 'Dark',
|
|
76
|
-
values: [
|
|
77
|
-
{ name: 'Dark', value: 'var(--qld-brand-primary)' },
|
|
78
|
-
],
|
|
79
|
-
},
|
|
38
|
+
args: {
|
|
39
|
+
...defaultdata,
|
|
40
|
+
isDisabled: false,
|
|
80
41
|
},
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return `
|
|
84
|
-
<div class="dark">
|
|
85
|
-
${Story()}
|
|
86
|
-
</div>
|
|
87
|
-
`;
|
|
88
|
-
},
|
|
89
|
-
],
|
|
42
|
+
globals: { backgrounds: { value: "dark" } },
|
|
43
|
+
render: (args) => `<div class="dark">${new Select(args).html}</div>`,
|
|
90
44
|
};
|
|
91
45
|
|
|
92
46
|
/**
|
|
93
|
-
*
|
|
47
|
+
* Add custom class `form-style-filled`
|
|
94
48
|
*/
|
|
95
49
|
export const Filled = {
|
|
96
|
-
args: {
|
|
97
|
-
|
|
98
|
-
|
|
50
|
+
args: {
|
|
51
|
+
...defaultdata,
|
|
52
|
+
isFilled: "true",
|
|
99
53
|
},
|
|
100
54
|
};
|
|
101
55
|
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Disabled select
|
|
105
|
-
*/
|
|
106
56
|
export const Disabled = {
|
|
107
|
-
args: {
|
|
108
|
-
|
|
109
|
-
|
|
57
|
+
args: {
|
|
58
|
+
...defaultdata,
|
|
59
|
+
isDisabled: true,
|
|
110
60
|
},
|
|
111
61
|
};
|
|
112
62
|
|
|
113
|
-
/**
|
|
114
|
-
* Valid select
|
|
115
|
-
*/
|
|
116
63
|
export const Valid = {
|
|
117
64
|
args: {
|
|
118
|
-
|
|
119
|
-
|
|
65
|
+
...defaultdata,
|
|
66
|
+
isValid: true,
|
|
120
67
|
},
|
|
121
68
|
};
|
|
122
69
|
|
|
123
|
-
/**
|
|
124
|
-
* Invalid select
|
|
125
|
-
*/
|
|
126
70
|
export const Invalid = {
|
|
127
71
|
args: {
|
|
128
|
-
|
|
129
|
-
|
|
72
|
+
...defaultdata,
|
|
73
|
+
isValid: false,
|
|
130
74
|
},
|
|
131
75
|
};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
"id": "example-1",
|
|
3
|
+
"isDisabled": false,
|
|
4
|
+
"isRequired": true,
|
|
5
|
+
"isFilled": false,
|
|
6
|
+
"isValid": null,
|
|
7
|
+
"customClass": "",
|
|
8
|
+
"label-text": "Label",
|
|
9
|
+
"placeholder": "Please select",
|
|
10
|
+
"optional-text": "optional",
|
|
11
|
+
"hint-text": "Hint",
|
|
12
|
+
"successMessageText": "Success message",
|
|
13
|
+
"errorMessageText": "Error message"
|
|
12
14
|
}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
<!-- QGDS Component: Select -->
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
<label class="qld-text-input-label {{#if isRequired}}field-required{{/if}} {{#if isDisabled}}field-disabled{{/if}}" for="example-1">
|
|
3
|
+
<label class="qld-text-input-label {{#if isRequired}}field-required{{/if}} {{#if isDisabled}}field-disabled{{/if}}" for="{{id}}">
|
|
5
4
|
{{label-text}}
|
|
6
5
|
{{#if optional-text}}
|
|
7
|
-
<span class="label-text-optional">({{optional-text}})</span
|
|
6
|
+
<span class="label-text-optional">({{optional-text}})</span>
|
|
8
7
|
{{/if}}
|
|
8
|
+
</label>
|
|
9
9
|
|
|
10
|
-
<!-- Hint text for the first input field -->
|
|
11
10
|
{{#if hint-text}}
|
|
12
|
-
<span class="qld-hint-text" id="
|
|
11
|
+
<span class="qld-hint-text" id="{{id}}-hint">{{hint-text}}</span>
|
|
13
12
|
{{/if}}
|
|
14
13
|
|
|
15
|
-
{{#contains "qld-input-success" customClass}}
|
|
16
|
-
<span
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
{{
|
|
14
|
+
{{#contains "qld-input-success" customClass}}{{! legacy support for feedback classes `qld-input-success`}}
|
|
15
|
+
<span class="qld-input-success">{{successMessageText}}</span>
|
|
16
|
+
{{else}}{{! updated bootstrap style classes - `valid-feedback`}}
|
|
17
|
+
{{#if successMessageText}}
|
|
18
|
+
<div class="valid-feedback">{{successMessageText}}</div>
|
|
19
|
+
{{/if}}{{/contains}}
|
|
20
20
|
|
|
21
|
-
{{#contains "qld-input-error" customClass}}
|
|
22
|
-
<span
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
{{
|
|
21
|
+
{{#contains "qld-input-error" customClass}}{{! legacy support for feedback classes `qld-input-error`}}
|
|
22
|
+
<span class="qld-input-error">{{errorMessageText}}</span>
|
|
23
|
+
{{else}}{{! updated bootstrap style classes - `invalid-feedback`}}
|
|
24
|
+
{{#if errorMessageText}}
|
|
25
|
+
<div class="invalid-feedback">{{errorMessageText}}</div>
|
|
26
|
+
{{/if}}{{/contains}}
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
<option selected>{{placeholder}}</option>
|
|
28
|
+
<select id={{id}} class="form-select {{#if isFilled}}is-filled{{/if}} {{#if isValid}}is-valid{{else}}{{#ifCond isValid "===" false}}is-invalid{{/ifCond}}{{/if}} {{customClass}}"
|
|
29
|
+
{{#if hint-text}}aria-describedby="{{id}}-hint"{{/if}} {{#if isDisabled}}disabled{{/if}} {{#if isRequired}}required{{/if}} >
|
|
30
|
+
<option selected value="">{{placeholder}}</option>
|
|
31
31
|
<option value="1">Option 1</option>
|
|
32
32
|
<option value="2">Option 2</option>
|
|
33
33
|
<option value="3">Option 3</option>
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import Component from
|
|
1
|
+
import Component from "../../../js/QGDSComponent.js";
|
|
2
2
|
import template from "./textarea.hbs?raw";
|
|
3
3
|
|
|
4
4
|
export class Textarea {
|
|
5
|
-
|
|
6
5
|
// Use the global Component class to create a new instance of the Textarea component.
|
|
7
|
-
// A data object, containing the Handlebars placeholder replacement strings, should be provided as an argument.
|
|
6
|
+
// A data object, containing the Handlebars placeholder replacement strings, should be provided as an argument.
|
|
8
7
|
|
|
9
|
-
constructor(
|
|
8
|
+
constructor(data = {}) {
|
|
10
9
|
return new Component(template, data);
|
|
11
10
|
}
|
|
12
|
-
|
|
13
11
|
}
|
|
12
|
+
|
|
13
|
+
export const argTypes = {
|
|
14
|
+
isValid: {
|
|
15
|
+
description:
|
|
16
|
+
"For server-side validation, set to true or false. Omit or set to null to to indicate the input is yet to be validated.",
|
|
17
|
+
control: "radio",
|
|
18
|
+
options: [true, false, null],
|
|
19
|
+
type: "boolean | null",
|
|
20
|
+
},
|
|
21
|
+
};
|
|
@@ -1,101 +1,75 @@
|
|
|
1
1
|
// ComponentExample.stories.js
|
|
2
|
-
import { Textarea } from "./Textarea.js";
|
|
2
|
+
import { Textarea, argTypes } from "./Textarea.js";
|
|
3
3
|
import defaultdata from "./textarea.data.json";
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
tags: ["autodocs"],
|
|
7
|
-
title: "3. Components/Forms/
|
|
7
|
+
title: "3. Components/Forms/Text Area",
|
|
8
8
|
render: (args) => {
|
|
9
|
-
|
|
10
|
-
//Storybook produces a comma delimited string when using the check control type (table-striped, table-bordered) etc.
|
|
9
|
+
//Storybook produces a comma delimited string when using the check control type (table-striped, table-bordered) etc.
|
|
11
10
|
//We can't use commas on our class="..." attribute, so we need to replace the commas with spaces.
|
|
12
11
|
|
|
13
|
-
if(
|
|
14
|
-
args.customClass = args.customClass.replaceAll(","," ");
|
|
15
|
-
} else if (
|
|
12
|
+
if (typeof args.customClass === "string") {
|
|
13
|
+
args.customClass = args.customClass.replaceAll(",", " ");
|
|
14
|
+
} else if (typeof args.customClass === "object") {
|
|
16
15
|
args.customClass = args.customClass.join(" ");
|
|
17
16
|
}
|
|
18
|
-
|
|
17
|
+
|
|
19
18
|
return new Textarea(args).html;
|
|
20
|
-
|
|
21
19
|
},
|
|
22
|
-
|
|
20
|
+
parameters: { backgrounds: { disable: false } },
|
|
21
|
+
globals: { backgrounds: { value: "default" } },
|
|
23
22
|
//https://storybook.js.org/docs/api/arg-types
|
|
24
|
-
argTypes
|
|
25
|
-
},
|
|
23
|
+
argTypes,
|
|
26
24
|
};
|
|
27
25
|
|
|
28
26
|
/**
|
|
29
|
-
* Default
|
|
27
|
+
* Default palette
|
|
30
28
|
*/
|
|
31
29
|
export const Default = {
|
|
32
30
|
args: defaultdata,
|
|
33
31
|
};
|
|
34
32
|
|
|
35
33
|
/**
|
|
36
|
-
* Dark
|
|
34
|
+
* Dark palette
|
|
37
35
|
*/
|
|
38
36
|
export const Dark = {
|
|
39
|
-
args: {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
},
|
|
43
|
-
parameters: {
|
|
44
|
-
backgrounds: {
|
|
45
|
-
default: 'Dark',
|
|
46
|
-
values: [
|
|
47
|
-
{ name: 'Dark', value: 'var(--qld-brand-primary)' },
|
|
48
|
-
],
|
|
49
|
-
},
|
|
37
|
+
args: {
|
|
38
|
+
...defaultdata,
|
|
39
|
+
isDisabled: false,
|
|
50
40
|
},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return `
|
|
54
|
-
<div class="dark">
|
|
55
|
-
${Story()}
|
|
56
|
-
</div>
|
|
57
|
-
`;
|
|
58
|
-
},
|
|
59
|
-
],
|
|
41
|
+
globals: { backgrounds: { value: "dark" } },
|
|
42
|
+
render: (args) => `<div class="dark">${new Textarea(args).html}</div>`,
|
|
60
43
|
};
|
|
61
44
|
|
|
62
45
|
/**
|
|
63
|
-
*
|
|
46
|
+
* Add `customClass: "form-style-filled"`
|
|
64
47
|
*/
|
|
65
48
|
export const Filled = {
|
|
66
|
-
args: {
|
|
67
|
-
|
|
68
|
-
|
|
49
|
+
args: {
|
|
50
|
+
...defaultdata,
|
|
51
|
+
isFilled: true,
|
|
69
52
|
},
|
|
70
53
|
};
|
|
71
54
|
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Disabled textarea
|
|
75
|
-
*/
|
|
76
55
|
export const Disabled = {
|
|
77
|
-
args: {
|
|
78
|
-
|
|
79
|
-
|
|
56
|
+
args: {
|
|
57
|
+
...defaultdata,
|
|
58
|
+
isDisabled: true,
|
|
59
|
+
isRequired: false,
|
|
80
60
|
},
|
|
81
61
|
};
|
|
82
62
|
|
|
83
|
-
/**
|
|
84
|
-
* Valid textbox
|
|
85
|
-
*/
|
|
86
63
|
export const Valid = {
|
|
87
64
|
args: {
|
|
88
|
-
|
|
89
|
-
|
|
65
|
+
...defaultdata,
|
|
66
|
+
isValid: true,
|
|
90
67
|
},
|
|
91
68
|
};
|
|
92
69
|
|
|
93
|
-
/**
|
|
94
|
-
* Invalid textbox
|
|
95
|
-
*/
|
|
96
70
|
export const Invalid = {
|
|
97
71
|
args: {
|
|
98
|
-
|
|
99
|
-
|
|
72
|
+
...defaultdata,
|
|
73
|
+
isValid: false,
|
|
100
74
|
},
|
|
101
75
|
};
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
"id": "example-1",
|
|
3
|
+
"value": "",
|
|
4
|
+
"isDisabled": false,
|
|
5
|
+
"isRequired": true,
|
|
6
|
+
"isValid": null,
|
|
7
|
+
"isFilled": false,
|
|
8
|
+
"customClass": "",
|
|
9
|
+
"rows": 3,
|
|
10
|
+
"label-text": "Label",
|
|
11
|
+
"placeholder": "",
|
|
12
|
+
"optional-text": "optional",
|
|
13
|
+
"hint-text": "Hint",
|
|
14
|
+
"successMessageText": "Success message",
|
|
15
|
+
"errorMessageText": "Error message"
|
|
13
16
|
}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
<!-- QGDS Component: Textarea -->
|
|
2
2
|
|
|
3
|
-
<!-- Label for the first input field -->
|
|
4
3
|
<label class="qld-text-input-label {{#if isRequired}}field-required{{/if}} {{#if isDisabled}}field-disabled{{/if}}"
|
|
5
|
-
for="
|
|
4
|
+
for="{{id}}">
|
|
6
5
|
{{label-text}}
|
|
7
6
|
{{#if optional-text}}
|
|
8
7
|
<span class="label-text-optional">({{optional-text}})</span>
|
|
9
8
|
{{/if}}
|
|
10
9
|
</label>
|
|
11
10
|
|
|
12
|
-
<!-- Hint text for the first input field -->
|
|
13
11
|
{{#if hint-text}}
|
|
14
|
-
<span class="qld-hint-text" id="
|
|
12
|
+
<span class="qld-hint-text" id="{{id}}-hint">{{hint-text}}</span>
|
|
15
13
|
{{/if}}
|
|
16
14
|
|
|
17
|
-
{{#contains "qld-input-success" customClass}}
|
|
18
|
-
<span
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
{{
|
|
15
|
+
{{#contains "qld-input-success" customClass}}{{! legacy support for feedback classes `qld-input-success`}}
|
|
16
|
+
<span class="qld-input-success">{{successMessageText}}</span>
|
|
17
|
+
{{else}}
|
|
18
|
+
{{#if successMessageText}}{{! updated bootstrap style classes - `valid-feedback`}}
|
|
19
|
+
<div class="valid-feedback">{{successMessageText}}</div>
|
|
20
|
+
{{/if}}{{/contains}}
|
|
22
21
|
|
|
23
|
-
{{#contains "qld-input-error" customClass}}
|
|
24
|
-
<span
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
{{
|
|
22
|
+
{{#contains "qld-input-error" customClass}}{{! legacy support for feedback classes `qld-input-error`}}
|
|
23
|
+
<span class="qld-input-error">{{errorMessageText}}</span>
|
|
24
|
+
{{else}}
|
|
25
|
+
{{#if errorMessageText}}{{! updated bootstrap style classes - `invalid-feedback`}}
|
|
26
|
+
<div class="invalid-feedback">{{errorMessageText}}</div>
|
|
27
|
+
{{/if}}{{/contains}}
|
|
28
28
|
|
|
29
29
|
<!-- First text input field, described by the hint text above -->
|
|
30
|
-
<textarea id="
|
|
31
|
-
placeholder="{{placeholder}}" rows="{{rows}}" {{#if isDisabled}}disabled{{/if}} {{#if isRequired}}required
|
|
32
|
-
aria-
|
|
30
|
+
<textarea id="{{id}}" class="form-control {{customClass}} {{#if isFilled}}is-filled{{/if}} {{#if isValid}}is-valid{{else}}{{#ifCond isValid "===" false}}is-invalid{{/ifCond}}{{/if}}"
|
|
31
|
+
placeholder="{{placeholder}}" rows="{{rows}}" {{#if isDisabled}}disabled{{/if}} {{#if isRequired}}required{{/if}}
|
|
32
|
+
{{#if hint-text}}aria-describedby="{{id}}-hint"{{/if}}>{{value}}</textarea>
|
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
import Component from
|
|
1
|
+
import Component from "../../../js/QGDSComponent.js";
|
|
2
2
|
import template from "./textbox.hbs?raw";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Named `Text input` in Design system.
|
|
6
|
+
*/
|
|
4
7
|
export class Textbox {
|
|
5
|
-
|
|
6
8
|
// Use the global Component class to create a new instance of the Textbox component.
|
|
7
|
-
// A data object, containing the Handlebars placeholder replacement strings, should be provided as an argument.
|
|
9
|
+
// A data object, containing the Handlebars placeholder replacement strings, should be provided as an argument.
|
|
8
10
|
|
|
9
|
-
constructor(
|
|
11
|
+
constructor(data = {}) {
|
|
10
12
|
return new Component(template, data);
|
|
11
13
|
}
|
|
12
|
-
|
|
13
14
|
}
|
|
15
|
+
|
|
16
|
+
export const argTypes = {
|
|
17
|
+
isValid: {
|
|
18
|
+
description:
|
|
19
|
+
"For server-side validation, set to true or false. Omit or set to null to to indicate the input is yet to be validated.",
|
|
20
|
+
control: "radio",
|
|
21
|
+
options: [true, false, null],
|
|
22
|
+
type: "boolean | null",
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -1,45 +1,26 @@
|
|
|
1
1
|
// ComponentExample.stories.js
|
|
2
|
-
import { Textbox } from "./Textbox.js";
|
|
2
|
+
import { Textbox, argTypes } from "./Textbox.js";
|
|
3
3
|
import defaultdata from "./textbox.data.json";
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
tags: ["autodocs"],
|
|
7
|
-
title: "3. Components/Forms/
|
|
7
|
+
title: "3. Components/Forms/Text input",
|
|
8
8
|
render: (args) => {
|
|
9
|
-
|
|
10
|
-
//Storybook produces a comma delimited string when using the check control type (table-striped, table-bordered) etc.
|
|
9
|
+
//Storybook produces a comma delimited string when using the check control type (table-striped, table-bordered) etc.
|
|
11
10
|
//We can't use commas on our class="..." attribute, so we need to replace the commas with spaces.
|
|
12
11
|
|
|
13
|
-
if(
|
|
14
|
-
args.customClass = args.customClass.replaceAll(","," ");
|
|
15
|
-
} else if (
|
|
12
|
+
if (typeof args.customClass === "string") {
|
|
13
|
+
args.customClass = args.customClass.replaceAll(",", " ");
|
|
14
|
+
} else if (typeof args.customClass === "object") {
|
|
16
15
|
args.customClass = args.customClass.join(" ");
|
|
17
16
|
}
|
|
18
|
-
|
|
17
|
+
|
|
19
18
|
return new Textbox(args).html;
|
|
20
|
-
|
|
21
19
|
},
|
|
22
|
-
|
|
20
|
+
parameters: { backgrounds: { disable: false } },
|
|
21
|
+
globals: { backgrounds: { value: "default" } },
|
|
23
22
|
//https://storybook.js.org/docs/api/arg-types
|
|
24
|
-
argTypes
|
|
25
|
-
states: {
|
|
26
|
-
name: "States",
|
|
27
|
-
description: `Valid/Invalid states`,
|
|
28
|
-
control: {
|
|
29
|
-
type: "radio",
|
|
30
|
-
labels: {
|
|
31
|
-
"default": "Default",
|
|
32
|
-
"qld-input-success": "Success",
|
|
33
|
-
"qld-input-error": "Error",
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
options: [
|
|
37
|
-
"default",
|
|
38
|
-
"qld-input-success",
|
|
39
|
-
"qld-input-error",
|
|
40
|
-
],
|
|
41
|
-
},
|
|
42
|
-
},
|
|
23
|
+
argTypes,
|
|
43
24
|
};
|
|
44
25
|
|
|
45
26
|
/**
|
|
@@ -53,18 +34,11 @@ export const Default = {
|
|
|
53
34
|
* Dark themed textbox
|
|
54
35
|
*/
|
|
55
36
|
export const Dark = {
|
|
56
|
-
args: {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
},
|
|
60
|
-
parameters: {
|
|
61
|
-
backgrounds: {
|
|
62
|
-
default: 'Dark',
|
|
63
|
-
values: [
|
|
64
|
-
{ name: 'Dark', value: 'var(--qld-brand-primary)' },
|
|
65
|
-
],
|
|
66
|
-
},
|
|
37
|
+
args: {
|
|
38
|
+
...defaultdata,
|
|
39
|
+
...{ isDisabled: false },
|
|
67
40
|
},
|
|
41
|
+
globals: { backgrounds: { value: "dark" } },
|
|
68
42
|
decorators: [
|
|
69
43
|
(Story) => {
|
|
70
44
|
return `
|
|
@@ -80,20 +54,19 @@ export const Dark = {
|
|
|
80
54
|
* Filled style textbox
|
|
81
55
|
*/
|
|
82
56
|
export const Filled = {
|
|
83
|
-
args: {
|
|
84
|
-
|
|
85
|
-
|
|
57
|
+
args: {
|
|
58
|
+
...defaultdata,
|
|
59
|
+
customClass: "form-style-filled",
|
|
86
60
|
},
|
|
87
61
|
};
|
|
88
62
|
|
|
89
|
-
|
|
90
63
|
/**
|
|
91
64
|
* Disabled textbox
|
|
92
65
|
*/
|
|
93
66
|
export const Disabled = {
|
|
94
|
-
args: {
|
|
95
|
-
|
|
96
|
-
|
|
67
|
+
args: {
|
|
68
|
+
...defaultdata,
|
|
69
|
+
isDisabled: true,
|
|
97
70
|
},
|
|
98
71
|
};
|
|
99
72
|
|
|
@@ -102,8 +75,9 @@ export const Disabled = {
|
|
|
102
75
|
*/
|
|
103
76
|
export const Valid = {
|
|
104
77
|
args: {
|
|
105
|
-
|
|
106
|
-
|
|
78
|
+
...defaultdata,
|
|
79
|
+
isValid: true,
|
|
80
|
+
// ...{ customClass: "qld-input-success" },
|
|
107
81
|
},
|
|
108
82
|
};
|
|
109
83
|
|
|
@@ -112,7 +86,8 @@ export const Valid = {
|
|
|
112
86
|
*/
|
|
113
87
|
export const Invalid = {
|
|
114
88
|
args: {
|
|
115
|
-
|
|
116
|
-
|
|
89
|
+
...defaultdata,
|
|
90
|
+
isValid: false,
|
|
91
|
+
// ...{ customClass: "qld-input-error" },
|
|
117
92
|
},
|
|
118
93
|
};
|