@descope/web-components-ui 3.5.0 → 3.6.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 +34 -33
- package/stories/commonControls.js +359 -0
- package/stories/descope-alert.stories.js +102 -0
- package/stories/descope-button-multi-selection-group.stories.js +130 -0
- package/stories/descope-button-selection-group.stories.js +131 -0
- package/stories/descope-calendar.stories.js +115 -0
- package/stories/descope-checkbox.stories.js +74 -0
- package/stories/descope-code-snippet.stories.js +118 -0
- package/stories/descope-container.stories.js +96 -0
- package/stories/descope-date-field.stories.js +169 -0
- package/stories/descope-divider.stories.js +43 -0
- package/stories/descope-email-field.stories.js +109 -0
- package/stories/descope-grid.stories.js +218 -0
- package/stories/descope-hcaptcha.stories.js +29 -0
- package/stories/descope-hybrid-field.stories.js +151 -0
- package/stories/descope-loader-linear.stories.js +29 -0
- package/stories/descope-loader-radial.stories.js +29 -0
- package/stories/descope-logo.stories.js +40 -0
- package/stories/descope-mappings-field.stories.js +108 -0
- package/stories/descope-modal.stories.js +48 -0
- package/stories/descope-multi-select-combo-box.stories.js +183 -0
- package/stories/descope-new-password.stories.js +206 -0
- package/stories/descope-notification.stories.js +81 -0
- package/stories/descope-notp-image.stories.js +29 -0
- package/stories/descope-number-field.stories.js +83 -0
- package/stories/descope-passcode.stories.js +89 -0
- package/stories/descope-password.stories.js +89 -0
- package/stories/descope-phone-field.stories.js +137 -0
- package/stories/descope-phone-input-box-field.stories.js +128 -0
- package/stories/descope-policy-validation.stories.js +92 -0
- package/stories/descope-radio-group.stories.js +142 -0
- package/stories/descope-recaptcha.stories.js +38 -0
- package/stories/descope-saml-group-mappings.stories.js +109 -0
- package/stories/descope-scopes-list.stories.js +81 -0
- package/stories/descope-security-questions-setup.stories.js +125 -0
- package/stories/descope-security-questions-verify.stories.js +111 -0
- package/stories/descope-switch-toggle.stories.js +74 -0
- package/stories/descope-text-area.stories.js +77 -0
- package/stories/descope-text-field.stories.js +98 -0
- package/stories/descope-third-party-app-logo.stories.js +42 -0
- package/stories/descope-totp-image.stories.js +29 -0
- package/stories/descope-upload-file.stories.js +113 -0
- package/stories/descope-user-attribute.stories.js +85 -0
- package/stories/descope-user-auth-method.stories.js +77 -0
- package/stories/helpers.js +86 -0
- package/stories/icons/alert.svg +9 -0
- package/stories/icons/apple.svg +10 -0
- package/stories/icons/base64png.js +1 -0
- package/stories/icons/base64svg.js +1 -0
- package/stories/icons/button-icon.svg +3 -0
- package/stories/icons/errorMessageIconBase64.js +1 -0
- package/stories/icons/fulfilled-button-icon.svg +3 -0
- package/stories/icons/google.svg +25 -0
- package/stories/icons/method-icon.svg +3 -0
- package/stories/images/150x200.jpg +0 -0
- package/stories/images/800x150.jpg +0 -0
- package/stories/images/avatar.jpeg +0 -0
- package/stories/images/demo.jpg +0 -0
- package/stories/images/game.png +0 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { componentName } from '../src/components/descope-hybrid-field';
|
|
2
|
+
import {
|
|
3
|
+
labelControl,
|
|
4
|
+
placeholderControl,
|
|
5
|
+
sizeControl,
|
|
6
|
+
fullWidthControl,
|
|
7
|
+
directionControl,
|
|
8
|
+
disabledControl,
|
|
9
|
+
readOnlyControl,
|
|
10
|
+
requiredControl,
|
|
11
|
+
borderedControl,
|
|
12
|
+
inputLabelTypeControl,
|
|
13
|
+
errorMessageIconControl,
|
|
14
|
+
errorMessageIconAttrs,
|
|
15
|
+
} from './commonControls';
|
|
16
|
+
import CountryCodes from '../src/components/phone-fields/CountryCodes';
|
|
17
|
+
|
|
18
|
+
const Template = ({
|
|
19
|
+
label,
|
|
20
|
+
placeholder,
|
|
21
|
+
size,
|
|
22
|
+
bordered,
|
|
23
|
+
direction,
|
|
24
|
+
disabled,
|
|
25
|
+
required,
|
|
26
|
+
readonly,
|
|
27
|
+
'label-type': labelType,
|
|
28
|
+
'full-width': fullWidth,
|
|
29
|
+
'external-input': externalInput,
|
|
30
|
+
'data-errormessage-pattern-mismatch-email': emailCustomErrorTypeMismatch,
|
|
31
|
+
'data-errormessage-value-missing-email': emailCustomErrorMissingValue,
|
|
32
|
+
'data-errormessage-value-missing-phone': phoneCustomErrorMissingValue,
|
|
33
|
+
// phone
|
|
34
|
+
'phone-input-label': phoneInputLabel,
|
|
35
|
+
'country-input-label': countryInputLabel,
|
|
36
|
+
'country-input-placeholder': countryInputPlaceholder,
|
|
37
|
+
'default-code': defaultCode,
|
|
38
|
+
'restrict-countries': restrictCountries,
|
|
39
|
+
'phone-variant': phoneVariant,
|
|
40
|
+
'phone-minlength': phoneMinLength,
|
|
41
|
+
'phone-format-value': phoneFormatValue,
|
|
42
|
+
'phone-strict-validation': phoneStrictValidation,
|
|
43
|
+
errorMsgIcon,
|
|
44
|
+
}) => `
|
|
45
|
+
<descope-hybrid-field
|
|
46
|
+
size="${size}"
|
|
47
|
+
bordered="${bordered}"
|
|
48
|
+
disabled="${disabled || false}"
|
|
49
|
+
required="${required || false}"
|
|
50
|
+
readonly="${readonly || false}"
|
|
51
|
+
full-width="${fullWidth || false}"
|
|
52
|
+
st-host-direction="${direction ?? ''}"
|
|
53
|
+
external-input="${externalInput || false}"
|
|
54
|
+
label-type="${labelType || 'static'}"
|
|
55
|
+
phone-variant="${phoneVariant || ''}"
|
|
56
|
+
label="${label || ''}"
|
|
57
|
+
placeholder="${placeholder || ''}"
|
|
58
|
+
phone-input-label="${phoneInputLabel || ''}"
|
|
59
|
+
phone-format-value="${phoneFormatValue || false}"
|
|
60
|
+
phone-strict-validation="${phoneStrictValidation || false}"
|
|
61
|
+
country-input-label="${countryInputLabel || ''}"
|
|
62
|
+
country-input-placeholder="${countryInputPlaceholder || ''}"
|
|
63
|
+
default-code="${defaultCode || ''}"
|
|
64
|
+
restrict-countries="${restrictCountries || ''}"
|
|
65
|
+
phone-minlength="${phoneMinLength || ''}"
|
|
66
|
+
data-errormessage-value-missing-email="${emailCustomErrorMissingValue || ''}"
|
|
67
|
+
data-errormessage-pattern-mismatch-email="${emailCustomErrorTypeMismatch || ''}"
|
|
68
|
+
data-errormessage-value-missing-phone="${phoneCustomErrorMissingValue || ''}"
|
|
69
|
+
${errorMsgIcon ? errorMessageIconAttrs : ''}
|
|
70
|
+
></descope-hybrid-field>
|
|
71
|
+
<div>
|
|
72
|
+
<button id="validate">Validate</button>
|
|
73
|
+
</div>
|
|
74
|
+
`;
|
|
75
|
+
|
|
76
|
+
export default {
|
|
77
|
+
component: componentName,
|
|
78
|
+
title: 'descope-hybrid-field',
|
|
79
|
+
decorators: [
|
|
80
|
+
(story, { args }) => {
|
|
81
|
+
setTimeout(() => {
|
|
82
|
+
const button = document.querySelector('#validate');
|
|
83
|
+
const ele = document.querySelector('descope-hybrid-field');
|
|
84
|
+
button.onclick = () => {
|
|
85
|
+
ele.reportValidity();
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
return story();
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
argTypes: {
|
|
92
|
+
...labelControl,
|
|
93
|
+
...placeholderControl,
|
|
94
|
+
...inputLabelTypeControl,
|
|
95
|
+
...sizeControl,
|
|
96
|
+
...fullWidthControl,
|
|
97
|
+
...disabledControl,
|
|
98
|
+
...readOnlyControl,
|
|
99
|
+
...requiredControl,
|
|
100
|
+
...borderedControl,
|
|
101
|
+
...directionControl,
|
|
102
|
+
...errorMessageIconControl,
|
|
103
|
+
'external-input': {
|
|
104
|
+
control: { type: 'boolean' },
|
|
105
|
+
},
|
|
106
|
+
// phone
|
|
107
|
+
'phone-input-label': {
|
|
108
|
+
control: { type: 'text' },
|
|
109
|
+
},
|
|
110
|
+
'country-input-label': {
|
|
111
|
+
control: { type: 'text' },
|
|
112
|
+
},
|
|
113
|
+
'country-input-placeholder': {
|
|
114
|
+
control: { type: 'text' },
|
|
115
|
+
},
|
|
116
|
+
'default-code': {
|
|
117
|
+
options: [''].concat(CountryCodes.map((c) => c.code)),
|
|
118
|
+
control: { type: 'select' },
|
|
119
|
+
},
|
|
120
|
+
'restrict-countries': {
|
|
121
|
+
control: { type: 'text' },
|
|
122
|
+
},
|
|
123
|
+
'phone-variant': {
|
|
124
|
+
options: ['countrySelection', 'inputBox'],
|
|
125
|
+
control: { type: 'select' },
|
|
126
|
+
},
|
|
127
|
+
'phone-minlength': {
|
|
128
|
+
control: { type: 'number' },
|
|
129
|
+
},
|
|
130
|
+
'phone-format-value': {
|
|
131
|
+
name: 'Format Value',
|
|
132
|
+
control: { type: 'boolean' },
|
|
133
|
+
},
|
|
134
|
+
'phone-strict-validation': {
|
|
135
|
+
name: 'Strict Validation',
|
|
136
|
+
control: { type: 'boolean' },
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export const Default = Template.bind({});
|
|
142
|
+
|
|
143
|
+
Default.args = {
|
|
144
|
+
size: 'md',
|
|
145
|
+
bordered: true,
|
|
146
|
+
'restrict-countries': 'IL,US', // for test purposes, as Storybook cannot load preview url with comma separted values
|
|
147
|
+
'data-errormessage-value-missing-phone': 'missing phone',
|
|
148
|
+
'data-errormessage-value-missing-email': 'missing email',
|
|
149
|
+
'data-errormessage-pattern-mismatch-email': 'pattern mismatch email',
|
|
150
|
+
'phone-minlength': 8,
|
|
151
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { componentName } from '../src/components/descope-loader-linear';
|
|
2
|
+
import { modeControl, sizeControl } from './commonControls';
|
|
3
|
+
|
|
4
|
+
const Template = ({ mode, size }) => `
|
|
5
|
+
<descope-loader-linear
|
|
6
|
+
size="${size || ''}"
|
|
7
|
+
mode="${mode || ''}"
|
|
8
|
+
></descope-loader-linear>
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
component: componentName,
|
|
13
|
+
title: 'descope-loader-linear',
|
|
14
|
+
parameters: {
|
|
15
|
+
panelPosition: 'right',
|
|
16
|
+
controls: { expanded: true },
|
|
17
|
+
},
|
|
18
|
+
argTypes: {
|
|
19
|
+
...modeControl,
|
|
20
|
+
...sizeControl,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const Default = Template.bind({});
|
|
25
|
+
|
|
26
|
+
Default.args = {
|
|
27
|
+
size: 'md',
|
|
28
|
+
mode: 'primary',
|
|
29
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { componentName } from '../src/components/descope-loader-radial';
|
|
2
|
+
import { modeControl, sizeControl } from './commonControls';
|
|
3
|
+
|
|
4
|
+
const Template = ({ mode, size }) => `
|
|
5
|
+
<descope-loader-radial
|
|
6
|
+
size="${size || ''}"
|
|
7
|
+
mode="${mode || ''}"
|
|
8
|
+
></descope-loader-radial>
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
component: componentName,
|
|
13
|
+
title: 'descope-loader-radial',
|
|
14
|
+
parameters: {
|
|
15
|
+
panelPosition: 'right',
|
|
16
|
+
controls: { expanded: true },
|
|
17
|
+
},
|
|
18
|
+
argTypes: {
|
|
19
|
+
...modeControl,
|
|
20
|
+
...sizeControl,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const Default = Template.bind({});
|
|
25
|
+
|
|
26
|
+
Default.args = {
|
|
27
|
+
size: 'md',
|
|
28
|
+
mode: 'primary',
|
|
29
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { componentName } from '../src/components/descope-logo';
|
|
2
|
+
import { imgSrcControl } from './commonControls';
|
|
3
|
+
|
|
4
|
+
const Template = ({ src, width, height }) => `
|
|
5
|
+
<style nonce="${window.DESCOPE_NONCE}">
|
|
6
|
+
body {
|
|
7
|
+
${src ? `--descope-logo-url: url(${src});` : ''}
|
|
8
|
+
}
|
|
9
|
+
</style>
|
|
10
|
+
<descope-logo
|
|
11
|
+
st-width="${width || ''}"
|
|
12
|
+
st-height="${height || ''}"
|
|
13
|
+
></descope-logo>
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
component: componentName,
|
|
18
|
+
title: 'descope-logo',
|
|
19
|
+
parameters: {
|
|
20
|
+
panelPosition: 'right',
|
|
21
|
+
controls: { expanded: true },
|
|
22
|
+
},
|
|
23
|
+
argTypes: {
|
|
24
|
+
...imgSrcControl,
|
|
25
|
+
width: {
|
|
26
|
+
name: 'Width',
|
|
27
|
+
control: { type: 'text' },
|
|
28
|
+
},
|
|
29
|
+
height: {
|
|
30
|
+
name: 'Height',
|
|
31
|
+
control: { type: 'text' },
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const Default = Template.bind({});
|
|
37
|
+
|
|
38
|
+
Default.args = {
|
|
39
|
+
src: 'https://static.descope.com/pages/P2KFKhheHR9aICDa9kYkrGsYNnk3/v2-alpha/light/logo.svg',
|
|
40
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { componentName } from '../src/components/mapping-fields/descope-mappings-field';
|
|
2
|
+
import { withForm } from './helpers';
|
|
3
|
+
import {
|
|
4
|
+
sizeControl,
|
|
5
|
+
fullWidthControl,
|
|
6
|
+
disabledControl,
|
|
7
|
+
directionControl,
|
|
8
|
+
readOnlyControl,
|
|
9
|
+
errorPatternMismatchControl,
|
|
10
|
+
errorMessageIconAttrs,
|
|
11
|
+
errorMessageIconControl,
|
|
12
|
+
} from './commonControls';
|
|
13
|
+
|
|
14
|
+
const Template = ({
|
|
15
|
+
size,
|
|
16
|
+
'full-width': fullWidth,
|
|
17
|
+
disabled,
|
|
18
|
+
direction,
|
|
19
|
+
'label-value': labelValue,
|
|
20
|
+
'label-attr': labelAttr,
|
|
21
|
+
'button-label': buttonLabel,
|
|
22
|
+
separator,
|
|
23
|
+
options,
|
|
24
|
+
readonly,
|
|
25
|
+
'default-values': defaultValues,
|
|
26
|
+
'data-errormessage-pattern-mismatch': customErrorPatternMismatch,
|
|
27
|
+
errorMsgIcon,
|
|
28
|
+
}) => {
|
|
29
|
+
let serializedOptions;
|
|
30
|
+
let serializedDefaultValues;
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
serializedOptions = JSON.stringify(options);
|
|
34
|
+
serializedDefaultValues = JSON.stringify(defaultValues);
|
|
35
|
+
} catch (e) {
|
|
36
|
+
// do nothing
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return `
|
|
40
|
+
<descope-mappings-field
|
|
41
|
+
size="${size}"
|
|
42
|
+
disabled="${disabled || false}"
|
|
43
|
+
readonly="${readonly || false}"
|
|
44
|
+
full-width="${fullWidth || false}"
|
|
45
|
+
st-host-direction="${direction ?? ''}"
|
|
46
|
+
options='${serializedOptions || ''}'
|
|
47
|
+
button-label="${buttonLabel}"
|
|
48
|
+
separator="${separator}"
|
|
49
|
+
label-value="${labelValue}"
|
|
50
|
+
label-attr="${labelAttr}"
|
|
51
|
+
data-errormessage-pattern-mismatch="${customErrorPatternMismatch || ''}"
|
|
52
|
+
default-values='${serializedDefaultValues || ''}'
|
|
53
|
+
${errorMsgIcon ? errorMessageIconAttrs : ''}
|
|
54
|
+
>
|
|
55
|
+
</descope-mappings-field>`;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export default {
|
|
59
|
+
component: componentName,
|
|
60
|
+
title: 'descope-mappings-field',
|
|
61
|
+
decorators: [withForm],
|
|
62
|
+
argTypes: {
|
|
63
|
+
'label-value': {
|
|
64
|
+
name: 'Label Value',
|
|
65
|
+
control: { type: 'text' },
|
|
66
|
+
},
|
|
67
|
+
'label-attr': {
|
|
68
|
+
name: 'Label Attribute',
|
|
69
|
+
control: { type: 'text' },
|
|
70
|
+
},
|
|
71
|
+
'button-label': {
|
|
72
|
+
name: 'Button Label',
|
|
73
|
+
control: { type: 'text' },
|
|
74
|
+
},
|
|
75
|
+
separator: {
|
|
76
|
+
name: 'Separator',
|
|
77
|
+
control: { type: 'text' },
|
|
78
|
+
},
|
|
79
|
+
'default-values': {
|
|
80
|
+
name: 'Default Values',
|
|
81
|
+
control: { type: 'object' },
|
|
82
|
+
},
|
|
83
|
+
...sizeControl,
|
|
84
|
+
...fullWidthControl,
|
|
85
|
+
...disabledControl,
|
|
86
|
+
...readOnlyControl,
|
|
87
|
+
...directionControl,
|
|
88
|
+
...errorPatternMismatchControl,
|
|
89
|
+
...errorMessageIconControl,
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const Default = Template.bind({});
|
|
94
|
+
|
|
95
|
+
Default.args = {
|
|
96
|
+
size: 'md',
|
|
97
|
+
'full-width': false,
|
|
98
|
+
'label-value': 'Value',
|
|
99
|
+
'label-attr': 'Attribute',
|
|
100
|
+
'button-label': 'Add mapping',
|
|
101
|
+
separator: 'map to',
|
|
102
|
+
options: [
|
|
103
|
+
{ value: 'itemId1', label: 'item 1' },
|
|
104
|
+
{ value: 'itemId2', label: 'item 2' },
|
|
105
|
+
{ value: 'itemId3', label: 'item 3' },
|
|
106
|
+
{ value: 'itemId4', label: 'item 4' },
|
|
107
|
+
],
|
|
108
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { componentName } from '../src/components/descope-modal';
|
|
2
|
+
|
|
3
|
+
const template = `
|
|
4
|
+
<descope-container direction="column" st-horizontal-padding="1.25rem" st-vertical-padding="1.25rem" st-gap="0.75rem" st-background-color="transparent">
|
|
5
|
+
<descope-container direction="column" st-horizontal-padding="1.25rem" st-vertical-padding="1.25rem" st-gap="0.75rem" st-background-color="transparent">
|
|
6
|
+
<descope-text-field full-width="true" size="xs" bordered="true" label="Name"></descope-text-field>
|
|
7
|
+
<descope-email-field full-width="true" size="xs" bordered="true" label="Email"></descope-email-field>
|
|
8
|
+
<descope-phone-field full-width="true" size="xs" bordered="true" label="Phone"></descope-phone-field>
|
|
9
|
+
</descope-container>
|
|
10
|
+
<descope-container direction="row" justify-content="flex-end" st-horizontal-padding="1.25rem" st-vertical-padding="1.25rem" st-gap="0.75rem" st-background-color="transparent">
|
|
11
|
+
<descope-button variant="link" size="xs" mode="error">Cancel</descope-button>
|
|
12
|
+
<descope-button variant="contained" size="xs" mode="primary">Submit</descope-button>
|
|
13
|
+
</descope-container>
|
|
14
|
+
</descope-container>`;
|
|
15
|
+
|
|
16
|
+
const Template = ({ opened }) => {
|
|
17
|
+
const loader = `
|
|
18
|
+
<descope-container direction="column" st-align-items="center" st-horizontal-padding="1.25rem" st-vertical-padding="1.25rem" st-gap="0.75rem" st-background-color="transparent">
|
|
19
|
+
<descope-loader-radial size="sm" mode="primary"></descope-loader-radial>
|
|
20
|
+
</descope-container>
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
return `
|
|
24
|
+
<descope-modal opened="${opened}">
|
|
25
|
+
${loader}
|
|
26
|
+
</descope-modal>
|
|
27
|
+
`;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default {
|
|
31
|
+
component: componentName,
|
|
32
|
+
title: 'descope-modal',
|
|
33
|
+
decorators: [
|
|
34
|
+
(render) => {
|
|
35
|
+
setTimeout(() => {
|
|
36
|
+
const modal = document.querySelector('descope-modal');
|
|
37
|
+
setTimeout(() => (modal.innerHTML = template), 500);
|
|
38
|
+
});
|
|
39
|
+
return render();
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const Default = Template.bind({});
|
|
45
|
+
|
|
46
|
+
Default.args = {
|
|
47
|
+
opened: true,
|
|
48
|
+
};
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { componentName } from '../src/components/descope-multi-select-combo-box';
|
|
2
|
+
import { toggleDefaultErrorMessageValueMissingDecorator, withForm } from './helpers';
|
|
3
|
+
import {
|
|
4
|
+
labelControl,
|
|
5
|
+
placeholderControl,
|
|
6
|
+
sizeControl,
|
|
7
|
+
fullWidthControl,
|
|
8
|
+
directionControl,
|
|
9
|
+
disabledControl,
|
|
10
|
+
minItemsSelectionControl,
|
|
11
|
+
maxItemsSelectionControl,
|
|
12
|
+
readOnlyControl,
|
|
13
|
+
requiredControl,
|
|
14
|
+
borderedControl,
|
|
15
|
+
errorMissingValueControl,
|
|
16
|
+
overrideRenderItemControl,
|
|
17
|
+
itemsSourceControl,
|
|
18
|
+
inputLabelTypeControl,
|
|
19
|
+
errorPatternMismatchControl,
|
|
20
|
+
errorMessageIconControl,
|
|
21
|
+
errorMessageIconAttrs,
|
|
22
|
+
defaultValueMissingControl,
|
|
23
|
+
} from './commonControls';
|
|
24
|
+
|
|
25
|
+
const altRenderItem = ({ displayName, label, value }) =>
|
|
26
|
+
`<span data-name="${displayName}" data-id="${value}">${label}</span>`;
|
|
27
|
+
|
|
28
|
+
const Template = ({
|
|
29
|
+
'allow-custom-value': allowCustomValue,
|
|
30
|
+
label,
|
|
31
|
+
placeholder,
|
|
32
|
+
size,
|
|
33
|
+
bordered,
|
|
34
|
+
'full-width': fullWidth,
|
|
35
|
+
readonly,
|
|
36
|
+
required,
|
|
37
|
+
direction,
|
|
38
|
+
disabled,
|
|
39
|
+
data,
|
|
40
|
+
overrideRenderItem,
|
|
41
|
+
itemsSource,
|
|
42
|
+
minItemsSelection,
|
|
43
|
+
maxItemsSelection,
|
|
44
|
+
pattern,
|
|
45
|
+
'default-values': defaultValues,
|
|
46
|
+
'data-errormessage-value-missing': customErrorMissingValue,
|
|
47
|
+
'data-errormessage-pattern-mismatch': customErrorPatternMismatch,
|
|
48
|
+
'ignore-data': ignoreData,
|
|
49
|
+
'label-type': labelType,
|
|
50
|
+
errorMsgIcon,
|
|
51
|
+
}) => {
|
|
52
|
+
let serializedData;
|
|
53
|
+
let serializedDefaultValues;
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
serializedData = JSON.stringify(data);
|
|
57
|
+
serializedDefaultValues = JSON.stringify(defaultValues);
|
|
58
|
+
} catch (e) {
|
|
59
|
+
// do nothing
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (ignoreData) {
|
|
63
|
+
serializedData = '[]';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return `
|
|
67
|
+
<descope-multi-select-combo-box
|
|
68
|
+
clear-button-visible
|
|
69
|
+
data='${(itemsSource === 'attr' && serializedData) || ''}'
|
|
70
|
+
size="${size}"
|
|
71
|
+
bordered="${bordered}"
|
|
72
|
+
item-label-path="data-name"
|
|
73
|
+
item-value-path="data-id"
|
|
74
|
+
label="${label || ''}"
|
|
75
|
+
placeholder="${placeholder || ''}"
|
|
76
|
+
default-values='${serializedDefaultValues || ''}'
|
|
77
|
+
required="${required || false}"
|
|
78
|
+
full-width="${fullWidth || false}"
|
|
79
|
+
readonly="${readonly || false}"
|
|
80
|
+
disabled="${disabled || false}"
|
|
81
|
+
data-errormessage-value-missing="${customErrorMissingValue || ''}"
|
|
82
|
+
data-errormessage-pattern-mismatch="${customErrorPatternMismatch || ''}"
|
|
83
|
+
st-host-direction="${direction ?? ''}"
|
|
84
|
+
allow-custom-value="${allowCustomValue || false}"
|
|
85
|
+
min-items-selection="${minItemsSelection || ''}"
|
|
86
|
+
max-items-selection="${maxItemsSelection || ''}"
|
|
87
|
+
label-type="${labelType || ''}"
|
|
88
|
+
pattern="${pattern || ''}"
|
|
89
|
+
${errorMsgIcon ? errorMessageIconAttrs : ''}
|
|
90
|
+
>
|
|
91
|
+
${
|
|
92
|
+
itemsSource === 'children' &&
|
|
93
|
+
`
|
|
94
|
+
<span data-name="ItemName1" data-id="itemId1">Trojan War Heroes' Valor</span>
|
|
95
|
+
<span data-name="ItemName2" data-id="itemId2">Achilles' Fateful Wrath</span>
|
|
96
|
+
<span data-name="ItemName3" data-id="itemId3">Epic Battle of Gods</span>
|
|
97
|
+
<span data-name="ItemName4" data-id="itemId4">Hector's Brave Sacrifice</span>
|
|
98
|
+
<span data-name="ItemName5" data-id="itemId5">Trojan Horse Deception</span>
|
|
99
|
+
<span data-name="ItemName6" data-id="itemId6">Agamemnon's Royal Command</span>
|
|
100
|
+
<span data-name="ItemName7" data-id="itemId7">Odysseus' Cunning Strategy</span>
|
|
101
|
+
<span data-name="ItemName8" data-id="itemId8">Helen's Beauty's Curse</span>
|
|
102
|
+
<span data-name="ItemName9" data-id="itemId9">Achilles' Heel Weakness</span>
|
|
103
|
+
<span data-name="ItemName10" data-id="itemId10">Epic Poem of Ancient</span>
|
|
104
|
+
`
|
|
105
|
+
}
|
|
106
|
+
</descope-multi-select-combo-box>
|
|
107
|
+
`;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const allowCustomValueControl = {
|
|
111
|
+
'allow-custom-value': {
|
|
112
|
+
name: 'Allow Custom Values',
|
|
113
|
+
control: { type: 'boolean' },
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export default {
|
|
118
|
+
component: componentName,
|
|
119
|
+
title: 'descope-multi-select-combo-box',
|
|
120
|
+
decorators: [
|
|
121
|
+
(story, { args }) => {
|
|
122
|
+
setTimeout(() => {
|
|
123
|
+
const ele = document.querySelector('descope-multi-select-combo-box');
|
|
124
|
+
if (args.itemsSource === 'prop') {
|
|
125
|
+
ele.data = args.data;
|
|
126
|
+
}
|
|
127
|
+
if (args.overrideRenderItem) {
|
|
128
|
+
ele.renderItem = altRenderItem;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
return story();
|
|
132
|
+
},
|
|
133
|
+
toggleDefaultErrorMessageValueMissingDecorator,
|
|
134
|
+
withForm,
|
|
135
|
+
],
|
|
136
|
+
argTypes: {
|
|
137
|
+
...labelControl,
|
|
138
|
+
...placeholderControl,
|
|
139
|
+
...inputLabelTypeControl,
|
|
140
|
+
...sizeControl,
|
|
141
|
+
...fullWidthControl,
|
|
142
|
+
...disabledControl,
|
|
143
|
+
...readOnlyControl,
|
|
144
|
+
...requiredControl,
|
|
145
|
+
...borderedControl,
|
|
146
|
+
...errorMissingValueControl,
|
|
147
|
+
...errorPatternMismatchControl,
|
|
148
|
+
...overrideRenderItemControl,
|
|
149
|
+
...itemsSourceControl,
|
|
150
|
+
...allowCustomValueControl,
|
|
151
|
+
...minItemsSelectionControl,
|
|
152
|
+
...maxItemsSelectionControl,
|
|
153
|
+
...directionControl,
|
|
154
|
+
...errorMessageIconControl,
|
|
155
|
+
...defaultValueMissingControl,
|
|
156
|
+
'default-values': {
|
|
157
|
+
name: 'Default Values',
|
|
158
|
+
control: { type: 'object' },
|
|
159
|
+
},
|
|
160
|
+
// Control used to ignore the default data values, required for testing specific behavior
|
|
161
|
+
'ignore-data': {
|
|
162
|
+
name: 'Ignore Data Value',
|
|
163
|
+
control: { type: 'boolean' },
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export const Default = Template.bind({});
|
|
169
|
+
|
|
170
|
+
Default.args = {
|
|
171
|
+
size: 'md',
|
|
172
|
+
bordered: true,
|
|
173
|
+
itemsSource: 'children',
|
|
174
|
+
data: [
|
|
175
|
+
{ displayName: 'Item1', value: '1', label: 'data item 1' },
|
|
176
|
+
{ displayName: 'Item2', value: 'itemId2', label: 'data item 2' },
|
|
177
|
+
{ displayName: 'Item3', value: '3', label: 'data item 3' },
|
|
178
|
+
{ displayName: 'Item4', value: '4', label: 'data item 4' },
|
|
179
|
+
],
|
|
180
|
+
pattern: '',
|
|
181
|
+
'data-errormessage-value-missing': 'Please fill out this field.',
|
|
182
|
+
'data-errormessage-pattern-mismatch': 'Please match the requested format.',
|
|
183
|
+
};
|